Browse Source

Added MarchingCubes object.

Very much work-in-progress. Expect things to change.

Also changed film shader to have optional grayscale (controlled via uniform).
alteredq 14 years ago
parent
commit
b198531c66
7 changed files with 1518 additions and 464 deletions
  1. 143 140
      build/Three.js
  2. 144 141
      build/ThreeDebug.js
  3. 210 171
      build/ThreeExtras.js
  4. 7 2
      src/extras/ShaderUtils.js
  5. 909 0
      src/extras/objects/MarchingCubes.js
  6. 104 10
      src/renderers/WebGLRenderer.js
  7. 1 0
      utils/build.py

+ 143 - 140
build/Three.js

@@ -1,66 +1,66 @@
 // Three.js r32 - 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,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var e,h,b,q,r,l;if(d==0)e=h=b=0;else{q=Math.floor(a*6);r=a*6-q;a=d*(1-c);l=d*(1-c*r);c=d*(1-c*(1-r));switch(q){case 1:e=l;h=d;b=a;break;case 2:e=a;h=d;b=c;break;case 3:e=a;h=l;b=d;break;case 4:e=c;h=a;b=d;break;case 5:e=d;h=a;b=l;break;case 6:case 0:e=d;h=c;b=a}}this.r=e;this.g=h;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
+THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var f,h,b,q,r,l;if(d==0)f=h=b=0;else{q=Math.floor(a*6);r=a*6-q;a=d*(1-c);l=d*(1-c*r);c=d*(1-c*(1-r));switch(q){case 1:f=l;h=d;b=a;break;case 2:f=a;h=d;b=c;break;case 3:f=a;h=l;b=d;break;case 4:f=c;h=a;b=d;break;case 5:f=d;h=a;b=l;break;case 6:case 0:f=d;h=c;b=a}}this.r=f;this.g=h;this.b=b;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,c){this.x=a||0;this.y=c||0};
 THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;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,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.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,c,d){this.x=a||0;this.y=c||0;this.z=d||0};
 THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
-cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
+cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,f=this.z;this.x=d*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
 a.z;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 c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+d*d+a*a)},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+d*d+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,c,d,e){this.x=a||0;this.y=c||0;this.z=d||0;this.w=e||1};
-THREE.Vector4.prototype={set:function(a,c,d,e){this.x=a;this.y=c;this.z=d;this.w=e;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.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,c,d,f){this.x=a||0;this.y=c||0;this.z=d||0;this.w=f||1};
+THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;this.z=d;this.w=f;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.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,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},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,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,h=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)h=h.concat(this.intersectObject(d))}h.sort(function(b,q){return b.distance-q.distance});return h},intersectObject:function(a){function c(L,t,T,E){E=E.clone().subSelf(t);T=T.clone().subSelf(t);var f=L.clone().subSelf(t);L=E.dot(E);t=E.dot(T);E=E.dot(f);var k=T.dot(T);T=T.dot(f);f=1/(L*k-t*t);k=(k*E-t*T)*f;L=(L*T-t*E)*f;return k>0&&L>0&&k+L<1}var d,e,h,b,q,r,l,n,y,x,
-v,w=a.geometry,G=w.vertices,K=[];d=0;for(e=w.faces.length;d<e;d++){h=w.faces[d];x=this.origin.clone();v=this.direction.clone();b=a.matrix.multiplyVector3(G[h.a].position.clone());q=a.matrix.multiplyVector3(G[h.b].position.clone());r=a.matrix.multiplyVector3(G[h.c].position.clone());l=h instanceof THREE.Face4?a.matrix.multiplyVector3(G[h.d].position.clone()):null;n=a.rotationMatrix.multiplyVector3(h.normal.clone());y=v.dot(n);if(y<0){n=n.dot((new THREE.Vector3).sub(b,x))/y;x=x.addSelf(v.multiplyScalar(n));
-if(h instanceof THREE.Face3){if(c(x,b,q,r)){h={distance:this.origin.distanceTo(x),point:x,face:h,object:a};K.push(h)}}else if(h instanceof THREE.Face4)if(c(x,b,q,l)||c(x,q,r,l)){h={distance:this.origin.distanceTo(x),point:x,face:h,object:a};K.push(h)}}}return K}};
-THREE.Rectangle=function(){function a(){b=e-c;q=h-d}var c,d,e,h,b,q,r=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return b};this.getHeight=function(){return q};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return h};this.set=function(l,n,y,x){r=false;c=l;d=n;e=y;h=x;a()};this.addPoint=function(l,n){if(r){r=false;c=l;d=n;e=l;h=n}else{c=c<l?c:l;d=d<n?d:n;e=e>l?e:l;h=h>n?
-h:n}a()};this.add3Points=function(l,n,y,x,v,w){if(r){r=false;c=l<y?l<v?l:v:y<v?y:v;d=n<x?n<w?n:w:x<w?x:w;e=l>y?l>v?l:v:y>v?y:v;h=n>x?n>w?n:w:x>w?x:w}else{c=l<y?l<v?l<c?l:c:v<c?v:c:y<v?y<c?y:c:v<c?v:c;d=n<x?n<w?n<d?n:d:w<d?w:d:x<w?x<d?x:d:w<d?w:d;e=l>y?l>v?l>e?l:e:v>e?v:e:y>v?y>e?y:e:v>e?v:e;h=n>x?n>w?n>h?n:h:w>h?w:h:x>w?x>h?x:h:w>h?w:h}a()};this.addRectangle=function(l){if(r){r=false;c=l.getLeft();d=l.getTop();e=l.getRight();h=l.getBottom()}else{c=c<l.getLeft()?c:l.getLeft();d=d<l.getTop()?d:l.getTop();
-e=e>l.getRight()?e:l.getRight();h=h>l.getBottom()?h:l.getBottom()}a()};this.inflate=function(l){c-=l;d-=l;e+=l;h+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();d=d>l.getTop()?d:l.getTop();e=e<l.getRight()?e:l.getRight();h=h<l.getBottom()?h:l.getBottom();a()};this.instersects=function(l){return Math.min(e,l.getRight())-Math.max(c,l.getLeft())>=0&&Math.min(h,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){r=true;h=e=d=c=0;a()};this.isEmpty=function(){return r};this.toString=
-function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+h+", width: "+b+", height: "+q+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this}};
-THREE.Matrix4=function(a,c,d,e,h,b,q,r,l,n,y,x,v,w,G,K){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=h||0;this.n22=b||1;this.n23=q||0;this.n24=r||0;this.n31=l||0;this.n32=n||0;this.n33=y||1;this.n34=x||0;this.n41=v||0;this.n42=w||0;this.n43=G||0;this.n44=K||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
-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,c,d,e,h,b,q,r,l,n,y,x,v,w,G,K){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=h;this.n22=b;this.n23=q;this.n24=r;this.n31=l;this.n32=n;this.n33=y;this.n34=x;this.n41=v;this.n42=w;this.n43=G;this.n44=K;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,c,d){var e=THREE.Matrix4.__tmpVec1,h=THREE.Matrix4.__tmpVec2,b=THREE.Matrix4.__tmpVec3;b.sub(a,c).normalize();e.cross(d,b).normalize();h.cross(b,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);
-this.n31=b.x;this.n32=b.y;this.n33=b.z;this.n34=-b.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,e=a.z,h=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*h;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*h;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*h;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,h=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*h;a.y=this.n21*c+this.n22*d+this.n23*
-e+this.n24*h;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*h;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*h;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,e=a.n12,h=a.n13,b=a.n14,q=a.n21,r=a.n22,l=a.n23,n=a.n24,y=a.n31,
-x=a.n32,v=a.n33,w=a.n34,G=a.n41,K=a.n42,L=a.n43,t=a.n44,T=c.n11,E=c.n12,f=c.n13,k=c.n14,i=c.n21,g=c.n22,m=c.n23,j=c.n24,o=c.n31,p=c.n32,s=c.n33,u=c.n34,z=c.n41,H=c.n42,F=c.n43,I=c.n44;this.n11=d*T+e*i+h*o+b*z;this.n12=d*E+e*g+h*p+b*H;this.n13=d*f+e*m+h*s+b*F;this.n14=d*k+e*j+h*u+b*I;this.n21=q*T+r*i+l*o+n*z;this.n22=q*E+r*g+l*p+n*H;this.n23=q*f+r*m+l*s+n*F;this.n24=q*k+r*j+l*u+n*I;this.n31=y*T+x*i+v*o+w*z;this.n32=y*E+x*g+v*p+w*H;this.n33=y*f+x*m+v*s+w*F;this.n34=y*k+x*j+v*u+w*I;this.n41=G*T+K*i+
-L*o+t*z;this.n42=G*E+K*g+L*p+t*H;this.n43=G*f+K*m+L*s+t*F;this.n44=G*k+K*j+L*u+t*I;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,h=this.n14,b=this.n21,q=this.n22,r=this.n23,l=this.n24,n=this.n31,y=this.n32,x=this.n33,v=this.n34,w=this.n41,G=this.n42,K=this.n43,L=this.n44,t=a.n11,T=a.n21,E=a.n31,f=a.n41,k=a.n12,i=a.n22,g=a.n32,m=a.n42,j=a.n13,o=a.n23,p=a.n33,s=a.n43,u=a.n14,z=a.n24,H=a.n34;a=a.n44;this.n11=c*t+d*T+e*E+h*f;this.n12=c*k+d*i+e*g+h*m;this.n13=c*j+d*o+e*p+h*
-s;this.n14=c*u+d*z+e*H+h*a;this.n21=b*t+q*T+r*E+l*f;this.n22=b*k+q*i+r*g+l*m;this.n23=b*j+q*o+r*p+l*s;this.n24=b*u+q*z+r*H+l*a;this.n31=n*t+y*T+x*E+v*f;this.n32=n*k+y*i+x*g+v*m;this.n33=n*j+y*o+x*p+v*s;this.n34=n*u+y*z+x*H+v*a;this.n41=w*t+G*T+K*E+L*f;this.n42=w*k+G*i+K*g+L*m;this.n43=w*j+G*o+K*p+L*s;this.n44=w*u+G*z+K*H+L*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=
-a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,c=this.n12,d=this.n13,e=this.n14,h=this.n21,b=this.n22,q=this.n23,r=this.n24,l=this.n31,n=this.n32,y=this.n33,x=this.n34,v=this.n41,w=this.n42,G=this.n43,K=this.n44;return e*q*n*v-d*r*n*v-e*b*y*v+c*r*y*v+d*b*x*v-c*q*x*v-e*q*l*w+d*r*l*w+e*h*y*w-a*r*y*w-d*h*x*w+a*q*x*w+e*b*l*G-c*r*l*G-e*h*n*G+a*r*n*G+c*h*x*G-a*b*x*G-d*b*l*K+c*q*l*K+d*h*n*K-a*q*n*K-c*h*y*K+a*b*y*K},transpose:function(){function a(c,d,
-e){var h=c[d];c[d]=c[e];c[e]=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(){var a=this.flat;a[0]=this.n11;
+THREE.Ray.prototype={intersectScene:function(a){var c,d,f=a.objects,h=[];a=0;for(c=f.length;a<c;a++){d=f[a];if(d instanceof THREE.Mesh)h=h.concat(this.intersectObject(d))}h.sort(function(b,q){return b.distance-q.distance});return h},intersectObject:function(a){function c(M,s,T,G){G=G.clone().subSelf(s);T=T.clone().subSelf(s);var g=M.clone().subSelf(s);M=G.dot(G);s=G.dot(T);G=G.dot(g);var m=T.dot(T);T=T.dot(g);g=1/(M*m-s*s);m=(m*G-s*T)*g;M=(M*T-s*G)*g;return m>0&&M>0&&m+M<1}var d,f,h,b,q,r,l,p,z,y,
+u,x=a.geometry,H=x.vertices,K=[];d=0;for(f=x.faces.length;d<f;d++){h=x.faces[d];y=this.origin.clone();u=this.direction.clone();b=a.matrix.multiplyVector3(H[h.a].position.clone());q=a.matrix.multiplyVector3(H[h.b].position.clone());r=a.matrix.multiplyVector3(H[h.c].position.clone());l=h instanceof THREE.Face4?a.matrix.multiplyVector3(H[h.d].position.clone()):null;p=a.rotationMatrix.multiplyVector3(h.normal.clone());z=u.dot(p);if(z<0){p=p.dot((new THREE.Vector3).sub(b,y))/z;y=y.addSelf(u.multiplyScalar(p));
+if(h instanceof THREE.Face3){if(c(y,b,q,r)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};K.push(h)}}else if(h instanceof THREE.Face4)if(c(y,b,q,l)||c(y,q,r,l)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};K.push(h)}}}return K}};
+THREE.Rectangle=function(){function a(){b=f-c;q=h-d}var c,d,f,h,b,q,r=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return b};this.getHeight=function(){return q};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(l,p,z,y){r=false;c=l;d=p;f=z;h=y;a()};this.addPoint=function(l,p){if(r){r=false;c=l;d=p;f=l;h=p}else{c=c<l?c:l;d=d<p?d:p;f=f>l?f:l;h=h>p?
+h:p}a()};this.add3Points=function(l,p,z,y,u,x){if(r){r=false;c=l<z?l<u?l:u:z<u?z:u;d=p<y?p<x?p:x:y<x?y:x;f=l>z?l>u?l:u:z>u?z:u;h=p>y?p>x?p:x:y>x?y:x}else{c=l<z?l<u?l<c?l:c:u<c?u:c:z<u?z<c?z:c:u<c?u:c;d=p<y?p<x?p<d?p:d:x<d?x:d:y<x?y<d?y:d:x<d?x:d;f=l>z?l>u?l>f?l:f:u>f?u:f:z>u?z>f?z:f:u>f?u:f;h=p>y?p>x?p>h?p:h:x>h?x:h:y>x?y>h?y:h:x>h?x:h}a()};this.addRectangle=function(l){if(r){r=false;c=l.getLeft();d=l.getTop();f=l.getRight();h=l.getBottom()}else{c=c<l.getLeft()?c:l.getLeft();d=d<l.getTop()?d:l.getTop();
+f=f>l.getRight()?f:l.getRight();h=h>l.getBottom()?h:l.getBottom()}a()};this.inflate=function(l){c-=l;d-=l;f+=l;h+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();d=d>l.getTop()?d:l.getTop();f=f<l.getRight()?f:l.getRight();h=h<l.getBottom()?h:l.getBottom();a()};this.instersects=function(l){return Math.min(f,l.getRight())-Math.max(c,l.getLeft())>=0&&Math.min(h,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){r=true;h=f=d=c=0;a()};this.isEmpty=function(){return r};this.toString=
+function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+h+", width: "+b+", height: "+q+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this}};
+THREE.Matrix4=function(a,c,d,f,h,b,q,r,l,p,z,y,u,x,H,K){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=h||0;this.n22=b||1;this.n23=q||0;this.n24=r||0;this.n31=l||0;this.n32=p||0;this.n33=z||1;this.n34=y||0;this.n41=u||0;this.n42=x||0;this.n43=H||0;this.n44=K||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
+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,c,d,f,h,b,q,r,l,p,z,y,u,x,H,K){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=h;this.n22=b;this.n23=q;this.n24=r;this.n31=l;this.n32=p;this.n33=z;this.n34=y;this.n41=u;this.n42=x;this.n43=H;this.n44=K;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,c,d){var f=THREE.Matrix4.__tmpVec1,h=THREE.Matrix4.__tmpVec2,b=THREE.Matrix4.__tmpVec3;b.sub(a,c).normalize();f.cross(d,b).normalize();h.cross(b,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);
+this.n31=b.x;this.n32=b.y;this.n33=b.z;this.n34=-b.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,h=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*h;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*h;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*h;return a},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,h=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*h;a.y=this.n21*c+this.n22*d+this.n23*
+f+this.n24*h;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*h;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*h;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,f=a.n12,h=a.n13,b=a.n14,q=a.n21,r=a.n22,l=a.n23,p=a.n24,z=a.n31,
+y=a.n32,u=a.n33,x=a.n34,H=a.n41,K=a.n42,M=a.n43,s=a.n44,T=c.n11,G=c.n12,g=c.n13,m=c.n14,i=c.n21,e=c.n22,j=c.n23,k=c.n24,o=c.n31,w=c.n32,n=c.n33,t=c.n34,v=c.n41,D=c.n42,E=c.n43,I=c.n44;this.n11=d*T+f*i+h*o+b*v;this.n12=d*G+f*e+h*w+b*D;this.n13=d*g+f*j+h*n+b*E;this.n14=d*m+f*k+h*t+b*I;this.n21=q*T+r*i+l*o+p*v;this.n22=q*G+r*e+l*w+p*D;this.n23=q*g+r*j+l*n+p*E;this.n24=q*m+r*k+l*t+p*I;this.n31=z*T+y*i+u*o+x*v;this.n32=z*G+y*e+u*w+x*D;this.n33=z*g+y*j+u*n+x*E;this.n34=z*m+y*k+u*t+x*I;this.n41=H*T+K*i+
+M*o+s*v;this.n42=H*G+K*e+M*w+s*D;this.n43=H*g+K*j+M*n+s*E;this.n44=H*m+K*k+M*t+s*I;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,h=this.n14,b=this.n21,q=this.n22,r=this.n23,l=this.n24,p=this.n31,z=this.n32,y=this.n33,u=this.n34,x=this.n41,H=this.n42,K=this.n43,M=this.n44,s=a.n11,T=a.n21,G=a.n31,g=a.n41,m=a.n12,i=a.n22,e=a.n32,j=a.n42,k=a.n13,o=a.n23,w=a.n33,n=a.n43,t=a.n14,v=a.n24,D=a.n34;a=a.n44;this.n11=c*s+d*T+f*G+h*g;this.n12=c*m+d*i+f*e+h*j;this.n13=c*k+d*o+f*w+h*
+n;this.n14=c*t+d*v+f*D+h*a;this.n21=b*s+q*T+r*G+l*g;this.n22=b*m+q*i+r*e+l*j;this.n23=b*k+q*o+r*w+l*n;this.n24=b*t+q*v+r*D+l*a;this.n31=p*s+z*T+y*G+u*g;this.n32=p*m+z*i+y*e+u*j;this.n33=p*k+z*o+y*w+u*n;this.n34=p*t+z*v+y*D+u*a;this.n41=x*s+H*T+K*G+M*g;this.n42=x*m+H*i+K*e+M*j;this.n43=x*k+H*o+K*w+M*n;this.n44=x*t+H*v+K*D+M*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=
+a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,c=this.n12,d=this.n13,f=this.n14,h=this.n21,b=this.n22,q=this.n23,r=this.n24,l=this.n31,p=this.n32,z=this.n33,y=this.n34,u=this.n41,x=this.n42,H=this.n43,K=this.n44;return f*q*p*u-d*r*p*u-f*b*z*u+c*r*z*u+d*b*y*u-c*q*y*u-f*q*l*x+d*r*l*x+f*h*z*x-a*r*z*x-d*h*y*x+a*q*y*x+f*b*l*H-c*r*l*H-f*h*p*H+a*r*p*H+c*h*y*H-a*b*y*H-d*b*l*K+c*q*l*K+d*h*p*K-a*q*p*K-c*h*z*K+a*b*z*K},transpose:function(){function a(c,d,
+f){var h=c[d];c[d]=c[f];c[f]=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(){var a=this.flat;a[0]=this.n11;
 a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=
-Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),h=1-d,b=a.x,q=a.y,r=a.z,l=h*b,n=h*q;this.set(l*b+d,l*q-e*r,l*r+e*q,0,l*q+e*r,n*q+d,n*r-e*b,0,l*r-e*q,n*r+e*b,h*r*r+d,0,0,0,0,1);return this},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,c,d){var e=new THREE.Matrix4;e.setTranslation(a,c,d);return e};THREE.Matrix4.scaleMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setScale(a,c,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};
+Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),f=Math.sin(c),h=1-d,b=a.x,q=a.y,r=a.z,l=h*b,p=h*q;this.set(l*b+d,l*q-f*r,l*r+f*q,0,l*q+f*r,p*q+d,p*r-f*b,0,l*r-f*q,p*r+f*b,h*r*r+d,0,0,0,0,1);return this},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,c,d){var f=new THREE.Matrix4;f.setTranslation(a,c,d);return f};THREE.Matrix4.scaleMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setScale(a,c,d);return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};
 THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
-THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,h=a.n14,b=a.n21,q=a.n22,r=a.n23,l=a.n24,n=a.n31,y=a.n32,x=a.n33,v=a.n34,w=a.n41,G=a.n42,K=a.n43,L=a.n44,t=new THREE.Matrix4;t.n11=r*v*G-l*x*G+l*y*K-q*v*K-r*y*L+q*x*L;t.n12=h*x*G-e*v*G-h*y*K+d*v*K+e*y*L-d*x*L;t.n13=e*l*G-h*r*G+h*q*K-d*l*K-e*q*L+d*r*L;t.n14=h*r*y-e*l*y-h*q*x+d*l*x+e*q*v-d*r*v;t.n21=l*x*w-r*v*w-l*n*K+b*v*K+r*n*L-b*x*L;t.n22=e*v*w-h*x*w+h*n*K-c*v*K-e*n*L+c*x*L;t.n23=h*r*w-e*l*w-h*b*K+c*l*K+e*b*L-c*r*L;t.n24=e*l*n-h*r*n+
-h*b*x-c*l*x-e*b*v+c*r*v;t.n31=q*v*w-l*y*w+l*n*G-b*v*G-q*n*L+b*y*L;t.n32=h*y*w-d*v*w-h*n*G+c*v*G+d*n*L-c*y*L;t.n33=e*l*w-h*q*w+h*b*G-c*l*G-d*b*L+c*q*L;t.n34=h*q*n-d*l*n-h*b*y+c*l*y+d*b*v-c*q*v;t.n41=r*y*w-q*x*w-r*n*G+b*x*G+q*n*K-b*y*K;t.n42=d*x*w-e*y*w+e*n*G-c*x*G-d*n*K+c*y*K;t.n43=e*q*w-d*r*w-e*b*G+c*r*G+d*b*K-c*q*K;t.n44=d*r*n-e*q*n+e*b*y-c*r*y-d*b*x+c*q*x;t.multiplyScalar(1/a.determinant());return t};
-THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],h=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],q=-c[10]*c[4]+c[6]*c[8],r=c[10]*c[0]-c[2]*c[8],l=-c[6]*c[0]+c[2]*c[4],n=c[9]*c[4]-c[5]*c[8],y=-c[9]*c[0]+c[1]*c[8],x=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*q+c[2]*n;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*h;d[2]=c*b;d[3]=c*q;d[4]=c*r;d[5]=c*l;d[6]=c*n;d[7]=c*y;d[8]=c*x;return a};
-THREE.Matrix4.makeFrustum=function(a,c,d,e,h,b){var q,r,l;q=new THREE.Matrix4;r=2*h/(c-a);l=2*h/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(b+h)/(b-h);h=-2*b*h/(b-h);q.n11=r;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=d;q.n24=0;q.n31=0;q.n32=0;q.n33=e;q.n34=h;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,d,e){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*c,a*c,h,a,d,e)};
-THREE.Matrix4.makeOrtho=function(a,c,d,e,h,b){var q,r,l,n;q=new THREE.Matrix4;r=c-a;l=d-e;n=b-h;a=(c+a)/r;d=(d+e)/l;h=(b+h)/n;q.n11=2/r;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-d;q.n31=0;q.n32=0;q.n33=-2/n;q.n34=-h;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
+THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,f=a.n13,h=a.n14,b=a.n21,q=a.n22,r=a.n23,l=a.n24,p=a.n31,z=a.n32,y=a.n33,u=a.n34,x=a.n41,H=a.n42,K=a.n43,M=a.n44,s=new THREE.Matrix4;s.n11=r*u*H-l*y*H+l*z*K-q*u*K-r*z*M+q*y*M;s.n12=h*y*H-f*u*H-h*z*K+d*u*K+f*z*M-d*y*M;s.n13=f*l*H-h*r*H+h*q*K-d*l*K-f*q*M+d*r*M;s.n14=h*r*z-f*l*z-h*q*y+d*l*y+f*q*u-d*r*u;s.n21=l*y*x-r*u*x-l*p*K+b*u*K+r*p*M-b*y*M;s.n22=f*u*x-h*y*x+h*p*K-c*u*K-f*p*M+c*y*M;s.n23=h*r*x-f*l*x-h*b*K+c*l*K+f*b*M-c*r*M;s.n24=f*l*p-h*r*p+
+h*b*y-c*l*y-f*b*u+c*r*u;s.n31=q*u*x-l*z*x+l*p*H-b*u*H-q*p*M+b*z*M;s.n32=h*z*x-d*u*x-h*p*H+c*u*H+d*p*M-c*z*M;s.n33=f*l*x-h*q*x+h*b*H-c*l*H-d*b*M+c*q*M;s.n34=h*q*p-d*l*p-h*b*z+c*l*z+d*b*u-c*q*u;s.n41=r*z*x-q*y*x-r*p*H+b*y*H+q*p*K-b*z*K;s.n42=d*y*x-f*z*x+f*p*H-c*y*H-d*p*K+c*z*K;s.n43=f*q*x-d*r*x-f*b*H+c*r*H+d*b*K-c*q*K;s.n44=d*r*p-f*q*p+f*b*z-c*r*z-d*b*y+c*q*y;s.multiplyScalar(1/a.determinant());return s};
+THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,f=c[10]*c[5]-c[6]*c[9],h=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],q=-c[10]*c[4]+c[6]*c[8],r=c[10]*c[0]-c[2]*c[8],l=-c[6]*c[0]+c[2]*c[4],p=c[9]*c[4]-c[5]*c[8],z=-c[9]*c[0]+c[1]*c[8],y=c[5]*c[0]-c[1]*c[4];c=c[0]*f+c[1]*q+c[2]*p;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*f;d[1]=c*h;d[2]=c*b;d[3]=c*q;d[4]=c*r;d[5]=c*l;d[6]=c*p;d[7]=c*z;d[8]=c*y;return a};
+THREE.Matrix4.makeFrustum=function(a,c,d,f,h,b){var q,r,l;q=new THREE.Matrix4;r=2*h/(c-a);l=2*h/(f-d);a=(c+a)/(c-a);d=(f+d)/(f-d);f=-(b+h)/(b-h);h=-2*b*h/(b-h);q.n11=r;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=d;q.n24=0;q.n31=0;q.n32=0;q.n33=f;q.n34=h;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,d,f){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*c,a*c,h,a,d,f)};
+THREE.Matrix4.makeOrtho=function(a,c,d,f,h,b){var q,r,l,p;q=new THREE.Matrix4;r=c-a;l=d-f;p=b-h;a=(c+a)/r;d=(d+f)/l;h=(b+h)/p;q.n11=2/r;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-d;q.n31=0;q.n32=0;q.n33=-2/p;q.n34=-h;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||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,c,d,e,h){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];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,c,d,e,h,b){this.a=a;this.b=c;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=b instanceof Array?b:[b]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
+THREE.Face3=function(a,c,d,f,h){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];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,c,d,f,h,b){this.a=a;this.b=c;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=b instanceof Array?b:[b]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||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.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
 THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
-d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,e,h,b,q,r=new THREE.Vector3,l=new THREE.Vector3;e=0;for(h=this.vertices.length;e<h;e++){b=this.vertices[e];b.normal.set(0,0,0)}e=0;for(h=this.faces.length;e<h;e++){b=this.faces[e];if(a&&b.vertexNormals.length){r.set(0,0,0);c=0;for(d=b.normal.length;c<d;c++)r.addSelf(b.vertexNormals[c]);r.divideScalar(3)}else{c=this.vertices[b.a];d=this.vertices[b.b];q=this.vertices[b.c];r.sub(q.position,
-d.position);l.sub(c.position,d.position);r.crossSelf(l)}r.isZero()||r.normalize();b.normal.copy(r)}},computeVertexNormals:function(){var a,c,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)e[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
-new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)e[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal);e[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)e[a].normalize();a=0;for(c=this.faces.length;a<
-c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(u,z,H,F,I,M,N){b=u.vertices[z].position;q=u.vertices[H].position;r=u.vertices[F].position;l=h[I];n=h[M];y=h[N];x=q.x-b.x;v=r.x-b.x;w=q.y-b.y;G=r.y-b.y;
-K=q.z-b.z;L=r.z-b.z;t=n.u-l.u;T=y.u-l.u;E=n.v-l.v;f=y.v-l.v;k=1/(t*f-T*E);m.set((f*x-E*v)*k,(f*w-E*G)*k,(f*K-E*L)*k);j.set((t*v-T*x)*k,(t*G-T*w)*k,(t*L-T*K)*k);i[z].addSelf(m);i[H].addSelf(m);i[F].addSelf(m);g[z].addSelf(j);g[H].addSelf(j);g[F].addSelf(j)}var c,d,e,h,b,q,r,l,n,y,x,v,w,G,K,L,t,T,E,f,k,i=[],g=[],m=new THREE.Vector3,j=new THREE.Vector3,o=new THREE.Vector3,p=new THREE.Vector3,s=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){i[c]=new THREE.Vector3;g[c]=new THREE.Vector3}c=0;
-for(d=this.faces.length;c<d;c++){e=this.faces[c];h=this.uvs[c];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
-this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){s.copy(this.vertices[c].normal);e=i[c];o.copy(e);o.subSelf(s.multiplyScalar(s.dot(e))).normalize();p.cross(this.vertices[c].normal,e);e=p.dot(g[c]);e=e<0?-1:1;this.vertices[c].tangent.set(o.x,o.y,o.z,e)}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],
+d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,f,h,b,q,r=new THREE.Vector3,l=new THREE.Vector3;f=0;for(h=this.vertices.length;f<h;f++){b=this.vertices[f];b.normal.set(0,0,0)}f=0;for(h=this.faces.length;f<h;f++){b=this.faces[f];if(a&&b.vertexNormals.length){r.set(0,0,0);c=0;for(d=b.normal.length;c<d;c++)r.addSelf(b.vertexNormals[c]);r.divideScalar(3)}else{c=this.vertices[b.a];d=this.vertices[b.b];q=this.vertices[b.c];r.sub(q.position,
+d.position);l.sub(c.position,d.position);r.crossSelf(l)}r.isZero()||r.normalize();b.normal.copy(r)}},computeVertexNormals:function(){var a,c,d,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
+new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal);f[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
+c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c]);d.vertexNormals[3].copy(f[d.d])}}},computeTangents:function(){function a(t,v,D,E,I,L,N){b=t.vertices[v].position;q=t.vertices[D].position;r=t.vertices[E].position;l=h[I];p=h[L];z=h[N];y=q.x-b.x;u=r.x-b.x;x=q.y-b.y;H=r.y-b.y;
+K=q.z-b.z;M=r.z-b.z;s=p.u-l.u;T=z.u-l.u;G=p.v-l.v;g=z.v-l.v;m=1/(s*g-T*G);j.set((g*y-G*u)*m,(g*x-G*H)*m,(g*K-G*M)*m);k.set((s*u-T*y)*m,(s*H-T*x)*m,(s*M-T*K)*m);i[v].addSelf(j);i[D].addSelf(j);i[E].addSelf(j);e[v].addSelf(k);e[D].addSelf(k);e[E].addSelf(k)}var c,d,f,h,b,q,r,l,p,z,y,u,x,H,K,M,s,T,G,g,m,i=[],e=[],j=new THREE.Vector3,k=new THREE.Vector3,o=new THREE.Vector3,w=new THREE.Vector3,n=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){i[c]=new THREE.Vector3;e[c]=new THREE.Vector3}c=0;
+for(d=this.faces.length;c<d;c++){f=this.faces[c];h=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
+this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){n.copy(this.vertices[c].normal);f=i[c];o.copy(f);o.subSelf(n.multiplyScalar(n.dot(f))).normalize();w.cross(this.vertices[c].normal,f);f=w.dot(e[c]);f=f<0?-1:1;this.vertices[c].tangent.set(o.x,o.y,o.z,f)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
 z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
-this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(y){var x=[];c=0;for(d=y.length;c<d;c++)y[c]==undefined?x.push("undefined"):x.push(y[c].toString());return x.join("_")}var c,d,e,h,b,q,r,l,n={};e=0;for(h=this.faces.length;e<h;e++){b=this.faces[e];
-q=b.materials;r=a(q);if(n[r]==undefined)n[r]={hash:r,counter:0};l=n[r].hash+"_"+n[r].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0};b=b instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+b>65535){n[r].counter+=1;l=n[r].hash+"_"+n[r].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(e);this.geometryChunks[l].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+
+this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(z){var y=[];c=0;for(d=z.length;c<d;c++)z[c]==undefined?y.push("undefined"):y.push(z[c].toString());return y.join("_")}var c,d,f,h,b,q,r,l,p={};f=0;for(h=this.faces.length;f<h;f++){b=this.faces[f];
+q=b.materials;r=a(q);if(p[r]==undefined)p[r]={hash:r,counter:0};l=p[r].hash+"_"+p[r].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0};b=b instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+b>65535){p[r].counter+=1;l=p[r].hash+"_"+p[r].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(f);this.geometryChunks[l].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+
 this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
-THREE.Camera=function(a,c,d,e){this.fov=a;this.aspect=c;this.near=d;this.far=e;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.tmpVec=new THREE.Vector3;this.translateX=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
+THREE.Camera=function(a,c,d,f){this.fov=a;this.aspect=c;this.near=d;this.far=f;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.tmpVec=new THREE.Vector3;this.translateX=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
 this.translateZ=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};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,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;
 THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.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.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
-THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,e=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){e.setRotY(c.y);this.rotationMatrix.multiplySelf(e)}if(c.z!=0){e.setRotZ(c.z);this.rotationMatrix.multiplySelf(e)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){e.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(e)}}};THREE.Object3DCounter={value:0};
+THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,f=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){f.setRotY(c.y);this.rotationMatrix.multiplySelf(f)}if(c.z!=0){f.setRotZ(c.z);this.rotationMatrix.multiplySelf(f)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){f.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(f)}}};THREE.Object3DCounter={value:0};
 THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
 THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
 THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;
@@ -90,112 +90,115 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM
 THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.size=this.opacity=1;this.vertex_colors=false;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.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
 THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>size: "+this.size+"<br/>blending: "+this.blending+"<br/>vertex_colors: "+this.vertex_colors+"<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,c,d,e,h,b){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=b!==undefined?b:THREE.LinearMipMapLinearFilter};
+THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,f,h,b){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=b!==undefined?b: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;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
 THREE.RenderTarget=function(a,c,d){this.width=a;this.height=c;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType};
-var Uniforms={clone:function(a){var c,d,e,h={};for(c in a){h[c]={};for(d in a[c]){e=a[c][d];h[c][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return h},merge:function(a){var c,d,e,h={};for(c=0;c<a.length;c++){e=this.clone(a[c]);for(d in e)h[d]=e[d]}return h}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
+var Uniforms={clone:function(a){var c,d,f,h={};for(c in a){h[c]={};for(d in a[c]){f=a[c][d];h[c][d]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return h},merge:function(a){var c,d,f,h={};for(c=0;c<a.length;c++){f=this.clone(a[c]);for(d in f)h[d]=f[d]}return h}};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,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
-THREE.Projector=function(){function a(g,m){return m.z-g.z}function c(g,m){var j=0,o=1,p=g.z+g.w,s=m.z+m.w,u=-g.z+g.w,z=-m.z+m.w;if(p>=0&&s>=0&&u>=0&&z>=0)return true;else if(p<0&&s<0||u<0&&z<0)return false;else{if(p<0)j=Math.max(j,p/(p-s));else if(s<0)o=Math.min(o,p/(p-s));if(u<0)j=Math.max(j,u/(u-z));else if(z<0)o=Math.min(o,u/(u-z));if(o<j)return false;else{g.lerpSelf(m,j);m.lerpSelf(g,1-o);return true}}}var d,e,h=[],b,q,r,l=[],n,y,x=[],v,w,G=[],K=new THREE.Vector4,L=new THREE.Vector4,t=new THREE.Matrix4,
-T=new THREE.Matrix4,E=[],f=new THREE.Vector4,k=new THREE.Vector4,i;this.projectObjects=function(g,m,j){var o=[],p,s;e=0;t.multiply(m.projectionMatrix,m.matrix);E[0]=new THREE.Vector4(t.n41-t.n11,t.n42-t.n12,t.n43-t.n13,t.n44-t.n14);E[1]=new THREE.Vector4(t.n41+t.n11,t.n42+t.n12,t.n43+t.n13,t.n44+t.n14);E[2]=new THREE.Vector4(t.n41+t.n21,t.n42+t.n22,t.n43+t.n23,t.n44+t.n24);E[3]=new THREE.Vector4(t.n41-t.n21,t.n42-t.n22,t.n43-t.n23,t.n44-t.n24);E[4]=new THREE.Vector4(t.n41-t.n31,t.n42-t.n32,t.n43-
-t.n33,t.n44-t.n34);E[5]=new THREE.Vector4(t.n41+t.n31,t.n42+t.n32,t.n43+t.n33,t.n44+t.n34);m=0;for(p=E.length;m<p;m++){s=E[m];s.divideScalar(Math.sqrt(s.x*s.x+s.y*s.y+s.z*s.z))}p=g.objects;g=0;for(m=p.length;g<m;g++){s=p[g];var u;if(!(u=!s.visible)){if(u=s instanceof THREE.Mesh){a:{u=void 0;for(var z=s.position,H=-s.geometry.boundingSphere.radius*Math.max(s.scale.x,Math.max(s.scale.y,s.scale.z)),F=0;F<6;F++){u=E[F].x*z.x+E[F].y*z.y+E[F].z*z.z+E[F].w;if(u<=H){u=false;break a}}u=true}u=!u}u=u}if(!u){d=
-h[e]=h[e]||new THREE.RenderableObject;K.copy(s.position);t.multiplyVector3(K);d.object=s;d.z=K.z;o.push(d);e++}}j&&o.sort(a);return o};this.projectScene=function(g,m,j){var o=[],p=m.near,s=m.far,u,z,H,F,I,M,N,V,W,J,B,R,O,C,Q,U;r=y=w=0;m.autoUpdateMatrix&&m.updateMatrix();t.multiply(m.projectionMatrix,m.matrix);M=this.projectObjects(g,m,true);g=0;for(u=M.length;g<u;g++){N=M[g].object;if(N.visible){N.autoUpdateMatrix&&N.updateMatrix();V=N.matrix;W=N.rotationMatrix;J=N.materials;B=N.overdraw;if(N instanceof
-THREE.Mesh){R=N.geometry;O=R.vertices;z=0;for(H=O.length;z<H;z++){C=O[z];C.positionWorld.copy(C.position);V.multiplyVector3(C.positionWorld);F=C.positionScreen;F.copy(C.positionWorld);t.multiplyVector4(F);F.x/=F.w;F.y/=F.w;C.__visible=F.z>p&&F.z<s}R=R.faces;z=0;for(H=R.length;z<H;z++){C=R[z];if(C instanceof THREE.Face3){F=O[C.a];I=O[C.b];Q=O[C.c];if(F.__visible&&I.__visible&&Q.__visible)if(N.doubleSided||N.flipSided!=(Q.positionScreen.x-F.positionScreen.x)*(I.positionScreen.y-F.positionScreen.y)-
-(Q.positionScreen.y-F.positionScreen.y)*(I.positionScreen.x-F.positionScreen.x)<0){b=l[r]=l[r]||new THREE.RenderableFace3;b.v1.positionWorld.copy(F.positionWorld);b.v2.positionWorld.copy(I.positionWorld);b.v3.positionWorld.copy(Q.positionWorld);b.v1.positionScreen.copy(F.positionScreen);b.v2.positionScreen.copy(I.positionScreen);b.v3.positionScreen.copy(Q.positionScreen);b.normalWorld.copy(C.normal);W.multiplyVector3(b.normalWorld);b.centroidWorld.copy(C.centroid);V.multiplyVector3(b.centroidWorld);
-b.centroidScreen.copy(b.centroidWorld);t.multiplyVector3(b.centroidScreen);Q=C.vertexNormals;i=b.vertexNormalsWorld;F=0;for(I=Q.length;F<I;F++){U=i[F]=i[F]||new THREE.Vector3;U.copy(Q[F]);W.multiplyVector3(U)}b.z=b.centroidScreen.z;b.meshMaterials=J;b.faceMaterials=C.materials;b.overdraw=B;if(N.geometry.uvs[z]){b.uvs[0]=N.geometry.uvs[z][0];b.uvs[1]=N.geometry.uvs[z][1];b.uvs[2]=N.geometry.uvs[z][2]}o.push(b);r++}}else if(C instanceof THREE.Face4){F=O[C.a];I=O[C.b];Q=O[C.c];U=O[C.d];if(F.__visible&&
-I.__visible&&Q.__visible&&U.__visible)if(N.doubleSided||N.flipSided!=((U.positionScreen.x-F.positionScreen.x)*(I.positionScreen.y-F.positionScreen.y)-(U.positionScreen.y-F.positionScreen.y)*(I.positionScreen.x-F.positionScreen.x)<0||(I.positionScreen.x-Q.positionScreen.x)*(U.positionScreen.y-Q.positionScreen.y)-(I.positionScreen.y-Q.positionScreen.y)*(U.positionScreen.x-Q.positionScreen.x)<0)){b=l[r]=l[r]||new THREE.RenderableFace3;b.v1.positionWorld.copy(F.positionWorld);b.v2.positionWorld.copy(I.positionWorld);
-b.v3.positionWorld.copy(U.positionWorld);b.v1.positionScreen.copy(F.positionScreen);b.v2.positionScreen.copy(I.positionScreen);b.v3.positionScreen.copy(U.positionScreen);b.normalWorld.copy(C.normal);W.multiplyVector3(b.normalWorld);b.centroidWorld.copy(C.centroid);V.multiplyVector3(b.centroidWorld);b.centroidScreen.copy(b.centroidWorld);t.multiplyVector3(b.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterials=J;b.faceMaterials=C.materials;b.overdraw=B;if(N.geometry.uvs[z]){b.uvs[0]=N.geometry.uvs[z][0];
-b.uvs[1]=N.geometry.uvs[z][1];b.uvs[2]=N.geometry.uvs[z][3]}o.push(b);r++;q=l[r]=l[r]||new THREE.RenderableFace3;q.v1.positionWorld.copy(I.positionWorld);q.v2.positionWorld.copy(Q.positionWorld);q.v3.positionWorld.copy(U.positionWorld);q.v1.positionScreen.copy(I.positionScreen);q.v2.positionScreen.copy(Q.positionScreen);q.v3.positionScreen.copy(U.positionScreen);q.normalWorld.copy(b.normalWorld);q.centroidWorld.copy(b.centroidWorld);q.centroidScreen.copy(b.centroidScreen);q.z=q.centroidScreen.z;q.meshMaterials=
-J;q.faceMaterials=C.materials;q.overdraw=B;if(N.geometry.uvs[z]){q.uvs[0]=N.geometry.uvs[z][1];q.uvs[1]=N.geometry.uvs[z][2];q.uvs[2]=N.geometry.uvs[z][3]}o.push(q);r++}}}}else if(N instanceof THREE.Line){T.multiply(t,V);O=N.geometry.vertices;C=O[0];C.positionScreen.copy(C.position);T.multiplyVector4(C.positionScreen);z=1;for(H=O.length;z<H;z++){F=O[z];F.positionScreen.copy(F.position);T.multiplyVector4(F.positionScreen);I=O[z-1];f.copy(F.positionScreen);k.copy(I.positionScreen);if(c(f,k)){f.multiplyScalar(1/
-f.w);k.multiplyScalar(1/k.w);n=x[y]=x[y]||new THREE.RenderableLine;n.v1.positionScreen.copy(f);n.v2.positionScreen.copy(k);n.z=Math.max(f.z,k.z);n.materials=N.materials;o.push(n);y++}}}else if(N instanceof THREE.Particle){L.set(N.position.x,N.position.y,N.position.z,1);t.multiplyVector4(L);L.z/=L.w;if(L.z>0&&L.z<1){v=G[w]=G[w]||new THREE.RenderableParticle;v.x=L.x/L.w;v.y=L.y/L.w;v.z=L.z;v.rotation=N.rotation.z;v.scale.x=N.scale.x*Math.abs(v.x-(L.x+m.projectionMatrix.n11)/(L.w+m.projectionMatrix.n14));
-v.scale.y=N.scale.y*Math.abs(v.y-(L.y+m.projectionMatrix.n22)/(L.w+m.projectionMatrix.n24));v.materials=N.materials;o.push(v);w++}}}}j&&o.sort(a);return o};this.unprojectVector=function(g,m){var j=THREE.Matrix4.makeInvert(m.matrix);j.multiplySelf(THREE.Matrix4.makeInvert(m.projectionMatrix));j.multiplyVector3(g);return g}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,h,b;this.domElement=document.createElement("div");this.setSize=function(q,r){d=q;e=r;h=d/2;b=e/2};this.render=function(q,r){var l,n,y,x,v,w,G,K;a=c.projectScene(q,r);l=0;for(n=a.length;l<n;l++){v=a[l];if(v instanceof THREE.RenderableParticle){G=v.x*h+h;K=v.y*b+b;y=0;for(x=v.material.length;y<x;y++){w=v.material[y];if(w instanceof THREE.ParticleDOMMaterial){w=w.domElement;w.style.left=G+"px";w.style.top=K+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(ca){if(v!=ca)n.globalAlpha=v=ca}function c(ca){if(w!=ca){switch(ca){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}w=ca}}var d=null,e=new THREE.Projector,h=document.createElement("canvas"),b,q,r,l,n=h.getContext("2d"),y=new THREE.Color(0),x=0,v=1,w=0,G=null,K=null,L=1,t,T,E,f,k,i,g,m,j,o=new THREE.Color,
-p=new THREE.Color,s=new THREE.Color,u=new THREE.Color,z=new THREE.Color,H,F,I,M,N,V,W,J,B,R=new THREE.Rectangle,O=new THREE.Rectangle,C=new THREE.Rectangle,Q=false,U=new THREE.Color,Y=new THREE.Color,fa=new THREE.Color,aa=new THREE.Color,za=Math.PI*2,Z=new THREE.Vector3,na,oa,ka,ga,pa,ea,qa=16;na=document.createElement("canvas");na.width=na.height=2;oa=na.getContext("2d");oa.fillStyle="rgba(0,0,0,1)";oa.fillRect(0,0,2,2);ka=oa.getImageData(0,0,2,2);ga=ka.data;pa=document.createElement("canvas");pa.width=
-pa.height=qa;ea=pa.getContext("2d");ea.translate(-qa/2,-qa/2);ea.scale(qa,qa);qa--;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ca,la){b=ca;q=la;r=b/2;l=q/2;h.width=b;h.height=q;R.set(-r,-l,r,l);v=1;w=0;K=G=null;L=1};this.setClearColor=function(ca,la){y.setHex(ca);x=la;O.set(-r,-l,r,l);n.setTransform(1,0,0,-1,r,l);this.clear()};this.clear=function(){n.setTransform(1,0,0,-1,r,l);if(!O.isEmpty()){O.inflate(1);O.minSelf(R);if(y.hex==0&&x==0)n.clearRect(O.getX(),
-O.getY(),O.getWidth(),O.getHeight());else{c(THREE.NormalBlending);a(1);n.fillStyle="rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b*255)+","+x+")";n.fillRect(O.getX(),O.getY(),O.getWidth(),O.getHeight())}O.empty()}};this.render=function(ca,la){function Ea(A){var X,S,D,P=A.lights;Y.setRGB(0,0,0);fa.setRGB(0,0,0);aa.setRGB(0,0,0);A=0;for(X=P.length;A<X;A++){S=P[A];D=S.color;if(S instanceof THREE.AmbientLight){Y.r+=D.r;Y.g+=D.g;Y.b+=D.b}else if(S instanceof THREE.DirectionalLight){fa.r+=
-D.r;fa.g+=D.g;fa.b+=D.b}else if(S instanceof THREE.PointLight){aa.r+=D.r;aa.g+=D.g;aa.b+=D.b}}}function Aa(A,X,S,D){var P,$,da,ha,ia=A.lights;A=0;for(P=ia.length;A<P;A++){$=ia[A];da=$.color;ha=$.intensity;if($ instanceof THREE.DirectionalLight){$=S.dot($.position)*ha;if($>0){D.r+=da.r*$;D.g+=da.g*$;D.b+=da.b*$}}else if($ instanceof THREE.PointLight){Z.sub($.position,X);Z.normalize();$=S.dot(Z)*ha;if($>0){D.r+=da.r*$;D.g+=da.g*$;D.b+=da.b*$}}}}function Na(A,X,S){if(S.opacity!=0){a(S.opacity);c(S.blending);
-var D,P,$,da,ha,ia;if(S instanceof THREE.ParticleBasicMaterial){if(S.map&&S.map.image.loaded){da=S.map.image;ha=da.width>>1;ia=da.height>>1;P=X.scale.x*r;$=X.scale.y*l;S=P*ha;D=$*ia;C.set(A.x-S,A.y-D,A.x+S,A.y+D);if(R.instersects(C)){n.save();n.translate(A.x,A.y);n.rotate(-X.rotation);n.scale(P,-$);n.translate(-ha,-ia);n.drawImage(da,0,0);n.restore()}}}else if(S instanceof THREE.ParticleCircleMaterial){if(Q){U.r=Y.r+fa.r+aa.r;U.g=Y.g+fa.g+aa.g;U.b=Y.b+fa.b+aa.b;o.r=S.color.r*U.r;o.g=S.color.g*U.g;
-o.b=S.color.b*U.b;o.updateStyleString()}else o.__styleString=S.color.__styleString;S=X.scale.x*r;D=X.scale.y*l;C.set(A.x-S,A.y-D,A.x+S,A.y+D);if(R.instersects(C)){P=o.__styleString;if(K!=P)n.fillStyle=K=P;n.save();n.translate(A.x,A.y);n.rotate(-X.rotation);n.scale(S,D);n.beginPath();n.arc(0,0,1,0,za,true);n.closePath();n.fill();n.restore()}}}}function Oa(A,X,S,D){if(D.opacity!=0){a(D.opacity);c(D.blending);n.beginPath();n.moveTo(A.positionScreen.x,A.positionScreen.y);n.lineTo(X.positionScreen.x,X.positionScreen.y);
-n.closePath();if(D instanceof THREE.LineBasicMaterial){o.__styleString=D.color.__styleString;A=D.linewidth;if(L!=A)n.lineWidth=L=A;A=o.__styleString;if(G!=A)n.strokeStyle=G=A;n.stroke();C.inflate(D.linewidth*2)}}}function Ja(A,X,S,D,P,$){if(P.opacity!=0){a(P.opacity);c(P.blending);f=A.positionScreen.x;k=A.positionScreen.y;i=X.positionScreen.x;g=X.positionScreen.y;m=S.positionScreen.x;j=S.positionScreen.y;n.beginPath();n.moveTo(f,k);n.lineTo(i,g);n.lineTo(m,j);n.lineTo(f,k);n.closePath();if(P instanceof
-THREE.MeshBasicMaterial)if(P.map)P.map.image.loaded&&P.map.mapping instanceof THREE.UVMapping&&wa(f,k,i,g,m,j,P.map.image,D.uvs[0].u,D.uvs[0].v,D.uvs[1].u,D.uvs[1].v,D.uvs[2].u,D.uvs[2].v);else if(P.env_map){if(P.env_map.image.loaded)if(P.env_map.mapping instanceof THREE.SphericalReflectionMapping){A=la.matrix;Z.copy(D.vertexNormalsWorld[0]);M=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;N=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;Z.copy(D.vertexNormalsWorld[1]);V=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;
-W=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;Z.copy(D.vertexNormalsWorld[2]);J=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;B=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;wa(f,k,i,g,m,j,P.env_map.image,M,N,V,W,J,B)}}else P.wireframe?Ba(P.color.__styleString,P.wireframe_linewidth):Ca(P.color.__styleString);else if(P instanceof THREE.MeshLambertMaterial){if(P.map&&!P.wireframe){P.map.mapping instanceof THREE.UVMapping&&wa(f,k,i,g,m,j,P.map.image,D.uvs[0].u,D.uvs[0].v,D.uvs[1].u,D.uvs[1].v,D.uvs[2].u,D.uvs[2].v);
-c(THREE.SubtractiveBlending)}if(Q)if(!P.wireframe&&P.shading==THREE.SmoothShading&&D.vertexNormalsWorld.length==3){p.r=s.r=u.r=Y.r;p.g=s.g=u.g=Y.g;p.b=s.b=u.b=Y.b;Aa($,D.v1.positionWorld,D.vertexNormalsWorld[0],p);Aa($,D.v2.positionWorld,D.vertexNormalsWorld[1],s);Aa($,D.v3.positionWorld,D.vertexNormalsWorld[2],u);z.r=(s.r+u.r)*0.5;z.g=(s.g+u.g)*0.5;z.b=(s.b+u.b)*0.5;I=Ka(p,s,u,z);wa(f,k,i,g,m,j,I,0,0,1,0,0,1)}else{U.r=Y.r;U.g=Y.g;U.b=Y.b;Aa($,D.centroidWorld,D.normalWorld,U);o.r=P.color.r*U.r;o.g=
-P.color.g*U.g;o.b=P.color.b*U.b;o.updateStyleString();P.wireframe?Ba(o.__styleString,P.wireframe_linewidth):Ca(o.__styleString)}else P.wireframe?Ba(P.color.__styleString,P.wireframe_linewidth):Ca(P.color.__styleString)}else if(P instanceof THREE.MeshDepthMaterial){H=la.near;F=la.far;p.r=p.g=p.b=1-Fa(A.positionScreen.z,H,F);s.r=s.g=s.b=1-Fa(X.positionScreen.z,H,F);u.r=u.g=u.b=1-Fa(S.positionScreen.z,H,F);z.r=(s.r+u.r)*0.5;z.g=(s.g+u.g)*0.5;z.b=(s.b+u.b)*0.5;I=Ka(p,s,u,z);wa(f,k,i,g,m,j,I,0,0,1,0,0,
-1)}else if(P instanceof THREE.MeshNormalMaterial){o.r=Ga(D.normalWorld.x);o.g=Ga(D.normalWorld.y);o.b=Ga(D.normalWorld.z);o.updateStyleString();P.wireframe?Ba(o.__styleString,P.wireframe_linewidth):Ca(o.__styleString)}}}function Ba(A,X){if(G!=A)n.strokeStyle=G=A;if(L!=X)n.lineWidth=L=X;n.stroke();C.inflate(X*2)}function Ca(A){if(K!=A)n.fillStyle=K=A;n.fill()}function wa(A,X,S,D,P,$,da,ha,ia,ra,ja,sa,xa){var ua,ta;ua=da.width-1;ta=da.height-1;ha*=ua;ia*=ta;ra*=ua;ja*=ta;sa*=ua;xa*=ta;S-=A;D-=X;P-=
-A;$-=X;ra-=ha;ja-=ia;sa-=ha;xa-=ia;ta=1/(ra*xa-sa*ja);ua=(xa*S-ja*P)*ta;ja=(xa*D-ja*$)*ta;S=(ra*P-sa*S)*ta;D=(ra*$-sa*D)*ta;A=A-ua*ha-S*ia;X=X-ja*ha-D*ia;n.save();n.transform(ua,ja,S,D,A,X);n.clip();n.drawImage(da,0,0);n.restore()}function Ka(A,X,S,D){var P=~~(A.r*255),$=~~(A.g*255);A=~~(A.b*255);var da=~~(X.r*255),ha=~~(X.g*255);X=~~(X.b*255);var ia=~~(S.r*255),ra=~~(S.g*255);S=~~(S.b*255);var ja=~~(D.r*255),sa=~~(D.g*255);D=~~(D.b*255);ga[0]=P<0?0:P>255?255:P;ga[1]=$<0?0:$>255?255:$;ga[2]=A<0?0:
-A>255?255:A;ga[4]=da<0?0:da>255?255:da;ga[5]=ha<0?0:ha>255?255:ha;ga[6]=X<0?0:X>255?255:X;ga[8]=ia<0?0:ia>255?255:ia;ga[9]=ra<0?0:ra>255?255:ra;ga[10]=S<0?0:S>255?255:S;ga[12]=ja<0?0:ja>255?255:ja;ga[13]=sa<0?0:sa>255?255:sa;ga[14]=D<0?0:D>255?255:D;oa.putImageData(ka,0,0);ea.drawImage(na,0,0);return pa}function Fa(A,X,S){A=(A-X)/(S-X);return A*A*(3-2*A)}function Ga(A){A=(A+1)*0.5;return A<0?0:A>1?1:A}function Ha(A,X){var S=X.x-A.x,D=X.y-A.y,P=1/Math.sqrt(S*S+D*D);S*=P;D*=P;X.x+=S;X.y+=D;A.x-=S;A.y-=
-D}var Da,La,ba,ma,va,Ia,Ma,ya;this.autoClear?this.clear():n.setTransform(1,0,0,-1,r,l);d=e.projectScene(ca,la,this.sortElements);(Q=ca.lights.length>0)&&Ea(ca);Da=0;for(La=d.length;Da<La;Da++){ba=d[Da];C.empty();if(ba instanceof THREE.RenderableParticle){t=ba;t.x*=r;t.y*=l;ma=0;for(va=ba.materials.length;ma<va;ma++)Na(t,ba,ba.materials[ma],ca)}else if(ba instanceof THREE.RenderableLine){t=ba.v1;T=ba.v2;t.positionScreen.x*=r;t.positionScreen.y*=l;T.positionScreen.x*=r;T.positionScreen.y*=l;C.addPoint(t.positionScreen.x,
-t.positionScreen.y);C.addPoint(T.positionScreen.x,T.positionScreen.y);if(R.instersects(C)){ma=0;for(va=ba.materials.length;ma<va;)Oa(t,T,ba,ba.materials[ma++],ca)}}else if(ba instanceof THREE.RenderableFace3){t=ba.v1;T=ba.v2;E=ba.v3;t.positionScreen.x*=r;t.positionScreen.y*=l;T.positionScreen.x*=r;T.positionScreen.y*=l;E.positionScreen.x*=r;E.positionScreen.y*=l;if(ba.overdraw){Ha(t.positionScreen,T.positionScreen);Ha(T.positionScreen,E.positionScreen);Ha(E.positionScreen,t.positionScreen)}C.add3Points(t.positionScreen.x,
-t.positionScreen.y,T.positionScreen.x,T.positionScreen.y,E.positionScreen.x,E.positionScreen.y);if(R.instersects(C)){ma=0;for(va=ba.meshMaterials.length;ma<va;){ya=ba.meshMaterials[ma++];if(ya instanceof THREE.MeshFaceMaterial){Ia=0;for(Ma=ba.faceMaterials.length;Ia<Ma;)(ya=ba.faceMaterials[Ia++])&&Ja(t,T,E,ba,ya,ca)}else Ja(t,T,E,ba,ya,ca)}}}O.addRectangle(C)}n.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(M,N,V){var W,J,B,R;W=0;for(J=M.lights.length;W<J;W++){B=M.lights[W];if(B instanceof THREE.DirectionalLight){R=N.normalWorld.dot(B.position)*B.intensity;if(R>0){V.r+=B.color.r*R;V.g+=B.color.g*R;V.b+=B.color.b*R}}else if(B instanceof THREE.PointLight){j.sub(B.position,N.centroidWorld);j.normalize();R=N.normalWorld.dot(j)*B.intensity;if(R>0){V.r+=B.color.r*R;V.g+=B.color.g*R;V.b+=B.color.b*R}}}}function c(M,N,V,W,J,B){u=e(z++);u.setAttribute("d","M "+M.positionScreen.x+
-" "+M.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)E.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(T){f.r=k.r;f.g=k.g;f.b=k.b;a(B,W,f);E.r=J.color.r*f.r;E.g=J.color.g*f.g;E.b=J.color.b*f.b;E.updateStyleString()}else E.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){m=1-J.__2near/(J.__farPlusNear-W.z*J.__farMinusNear);
-E.setRGB(m,m,m)}else J instanceof THREE.MeshNormalMaterial&&E.setRGB(h(W.normalWorld.x),h(W.normalWorld.y),h(W.normalWorld.z));J.wireframe?u.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):u.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+J.opacity);r.appendChild(u)}function d(M,N,V,W,J,B,R){u=e(z++);u.setAttribute("d",
-"M "+M.positionScreen.x+" "+M.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)E.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(T){f.r=k.r;f.g=k.g;f.b=k.b;a(R,J,f);E.r=B.color.r*f.r;E.g=B.color.g*f.g;E.b=B.color.b*f.b;E.updateStyleString()}else E.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){m=
-1-B.__2near/(B.__farPlusNear-J.z*B.__farMinusNear);E.setRGB(m,m,m)}else B instanceof THREE.MeshNormalMaterial&&E.setRGB(h(J.normalWorld.x),h(J.normalWorld.y),h(J.normalWorld.z));B.wireframe?u.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):u.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+B.opacity);r.appendChild(u)}
-function e(M){if(o[M]==null){o[M]=document.createElementNS("http://www.w3.org/2000/svg","path");I==0&&o[M].setAttribute("shape-rendering","crispEdges");return o[M]}return o[M]}function h(M){return M<0?Math.min((1+M)*0.5,0.5):0.5+Math.min(M*0.5,0.5)}var b=null,q=new THREE.Projector,r=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,n,y,x,v,w,G,K,L=new THREE.Rectangle,t=new THREE.Rectangle,T=false,E=new THREE.Color(16777215),f=new THREE.Color(16777215),k=new THREE.Color(0),i=new THREE.Color(0),
-g=new THREE.Color(0),m,j=new THREE.Vector3,o=[],p=[],s=[],u,z,H,F,I=1;this.domElement=r;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(M){switch(M){case "high":I=1;break;case "low":I=0}};this.setSize=function(M,N){l=M;n=N;y=l/2;x=n/2;r.setAttribute("viewBox",-y+" "+-x+" "+l+" "+n);r.setAttribute("width",l);r.setAttribute("height",n);L.set(-y,-x,y,x)};this.clear=function(){for(;r.childNodes.length>0;)r.removeChild(r.childNodes[0])};this.render=function(M,N){var V,W,
-J,B,R,O,C,Q;this.autoClear&&this.clear();b=q.projectScene(M,N,this.sortElements);F=H=z=0;if(T=M.lights.length>0){C=M.lights;k.setRGB(0,0,0);i.setRGB(0,0,0);g.setRGB(0,0,0);V=0;for(W=C.length;V<W;V++){J=C[V];B=J.color;if(J instanceof THREE.AmbientLight){k.r+=B.r;k.g+=B.g;k.b+=B.b}else if(J instanceof THREE.DirectionalLight){i.r+=B.r;i.g+=B.g;i.b+=B.b}else if(J instanceof THREE.PointLight){g.r+=B.r;g.g+=B.g;g.b+=B.b}}}V=0;for(W=b.length;V<W;V++){C=b[V];t.empty();if(C instanceof THREE.RenderableParticle){v=
-C;v.x*=y;v.y*=-x;J=0;for(B=C.materials.length;J<B;J++)if(Q=C.materials[J]){R=v;O=C;Q=Q;var U=H++;if(p[U]==null){p[U]=document.createElementNS("http://www.w3.org/2000/svg","circle");I==0&&p[U].setAttribute("shape-rendering","crispEdges")}u=p[U];u.setAttribute("cx",R.x);u.setAttribute("cy",R.y);u.setAttribute("r",O.scale.x*y);if(Q instanceof THREE.ParticleCircleMaterial){if(T){f.r=k.r+i.r+g.r;f.g=k.g+i.g+g.g;f.b=k.b+i.b+g.b;E.r=Q.color.r*f.r;E.g=Q.color.g*f.g;E.b=Q.color.b*f.b;E.updateStyleString()}else E=
-Q.color;u.setAttribute("style","fill: "+E.__styleString)}r.appendChild(u)}}else if(C instanceof THREE.RenderableLine){v=C.v1;w=C.v2;v.positionScreen.x*=y;v.positionScreen.y*=-x;w.positionScreen.x*=y;w.positionScreen.y*=-x;t.addPoint(v.positionScreen.x,v.positionScreen.y);t.addPoint(w.positionScreen.x,w.positionScreen.y);if(L.instersects(t)){J=0;for(B=C.materials.length;J<B;)if(Q=C.materials[J++]){R=v;O=w;Q=Q;U=F++;if(s[U]==null){s[U]=document.createElementNS("http://www.w3.org/2000/svg","line");I==
-0&&s[U].setAttribute("shape-rendering","crispEdges")}u=s[U];u.setAttribute("x1",R.positionScreen.x);u.setAttribute("y1",R.positionScreen.y);u.setAttribute("x2",O.positionScreen.x);u.setAttribute("y2",O.positionScreen.y);if(Q instanceof THREE.LineBasicMaterial){E.__styleString=Q.color.__styleString;u.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+Q.linewidth+"; stroke-opacity: "+Q.opacity+"; stroke-linecap: "+Q.linecap+"; stroke-linejoin: "+Q.linejoin);r.appendChild(u)}}}}else if(C instanceof
-THREE.RenderableFace3){v=C.v1;w=C.v2;G=C.v3;v.positionScreen.x*=y;v.positionScreen.y*=-x;w.positionScreen.x*=y;w.positionScreen.y*=-x;G.positionScreen.x*=y;G.positionScreen.y*=-x;t.addPoint(v.positionScreen.x,v.positionScreen.y);t.addPoint(w.positionScreen.x,w.positionScreen.y);t.addPoint(G.positionScreen.x,G.positionScreen.y);if(L.instersects(t)){J=0;for(B=C.meshMaterials.length;J<B;){Q=C.meshMaterials[J++];if(Q instanceof THREE.MeshFaceMaterial){R=0;for(O=C.faceMaterials.length;R<O;)(Q=C.faceMaterials[R++])&&
-c(v,w,G,C,Q,M)}else Q&&c(v,w,G,C,Q,M)}}}else if(C instanceof THREE.RenderableFace4){v=C.v1;w=C.v2;G=C.v3;K=C.v4;v.positionScreen.x*=y;v.positionScreen.y*=-x;w.positionScreen.x*=y;w.positionScreen.y*=-x;G.positionScreen.x*=y;G.positionScreen.y*=-x;K.positionScreen.x*=y;K.positionScreen.y*=-x;t.addPoint(v.positionScreen.x,v.positionScreen.y);t.addPoint(w.positionScreen.x,w.positionScreen.y);t.addPoint(G.positionScreen.x,G.positionScreen.y);t.addPoint(K.positionScreen.x,K.positionScreen.y);if(L.instersects(t)){J=
-0;for(B=C.meshMaterials.length;J<B;){Q=C.meshMaterials[J++];if(Q instanceof THREE.MeshFaceMaterial){R=0;for(O=C.faceMaterials.length;R<O;)(Q=C.faceMaterials[R++])&&d(v,w,G,K,C,Q,M)}else Q&&d(v,w,G,K,C,Q,M)}}}}}};
-THREE.WebGLRenderer=function(a){function c(f,k){f.fragment_shader=k.fragment_shader;f.vertex_shader=k.vertex_shader;f.uniforms=Uniforms.clone(k.uniforms)}function d(f,k){var i;if(f=="fragment")i=b.createShader(b.FRAGMENT_SHADER);else if(f=="vertex")i=b.createShader(b.VERTEX_SHADER);b.shaderSource(i,k);b.compileShader(i);if(!b.getShaderParameter(i,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(i));return null}return i}function e(f){switch(f){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;
+THREE.Projector=function(){function a(e,j){return j.z-e.z}function c(e,j){var k=0,o=1,w=e.z+e.w,n=j.z+j.w,t=-e.z+e.w,v=-j.z+j.w;if(w>=0&&n>=0&&t>=0&&v>=0)return true;else if(w<0&&n<0||t<0&&v<0)return false;else{if(w<0)k=Math.max(k,w/(w-n));else if(n<0)o=Math.min(o,w/(w-n));if(t<0)k=Math.max(k,t/(t-v));else if(v<0)o=Math.min(o,t/(t-v));if(o<k)return false;else{e.lerpSelf(j,k);j.lerpSelf(e,1-o);return true}}}var d,f,h=[],b,q,r,l=[],p,z,y=[],u,x,H=[],K=new THREE.Vector4,M=new THREE.Vector4,s=new THREE.Matrix4,
+T=new THREE.Matrix4,G=[],g=new THREE.Vector4,m=new THREE.Vector4,i;this.projectObjects=function(e,j,k){var o=[],w,n;f=0;s.multiply(j.projectionMatrix,j.matrix);G[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);G[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);G[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);G[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);G[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
+s.n33,s.n44-s.n34);G[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);j=0;for(w=G.length;j<w;j++){n=G[j];n.divideScalar(Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z))}w=e.objects;e=0;for(j=w.length;e<j;e++){n=w[e];var t;if(!(t=!n.visible)){if(t=n instanceof THREE.Mesh){a:{t=void 0;for(var v=n.position,D=-n.geometry.boundingSphere.radius*Math.max(n.scale.x,Math.max(n.scale.y,n.scale.z)),E=0;E<6;E++){t=G[E].x*v.x+G[E].y*v.y+G[E].z*v.z+G[E].w;if(t<=D){t=false;break a}}t=true}t=!t}t=t}if(!t){d=
+h[f]=h[f]||new THREE.RenderableObject;K.copy(n.position);s.multiplyVector3(K);d.object=n;d.z=K.z;o.push(d);f++}}k&&o.sort(a);return o};this.projectScene=function(e,j,k){var o=[],w=j.near,n=j.far,t,v,D,E,I,L,N,V,W,J,B,R,O,C,Q,U;r=z=x=0;j.autoUpdateMatrix&&j.updateMatrix();s.multiply(j.projectionMatrix,j.matrix);L=this.projectObjects(e,j,true);e=0;for(t=L.length;e<t;e++){N=L[e].object;if(N.visible){N.autoUpdateMatrix&&N.updateMatrix();V=N.matrix;W=N.rotationMatrix;J=N.materials;B=N.overdraw;if(N instanceof
+THREE.Mesh){R=N.geometry;O=R.vertices;v=0;for(D=O.length;v<D;v++){C=O[v];C.positionWorld.copy(C.position);V.multiplyVector3(C.positionWorld);E=C.positionScreen;E.copy(C.positionWorld);s.multiplyVector4(E);E.x/=E.w;E.y/=E.w;C.__visible=E.z>w&&E.z<n}R=R.faces;v=0;for(D=R.length;v<D;v++){C=R[v];if(C instanceof THREE.Face3){E=O[C.a];I=O[C.b];Q=O[C.c];if(E.__visible&&I.__visible&&Q.__visible)if(N.doubleSided||N.flipSided!=(Q.positionScreen.x-E.positionScreen.x)*(I.positionScreen.y-E.positionScreen.y)-
+(Q.positionScreen.y-E.positionScreen.y)*(I.positionScreen.x-E.positionScreen.x)<0){b=l[r]=l[r]||new THREE.RenderableFace3;b.v1.positionWorld.copy(E.positionWorld);b.v2.positionWorld.copy(I.positionWorld);b.v3.positionWorld.copy(Q.positionWorld);b.v1.positionScreen.copy(E.positionScreen);b.v2.positionScreen.copy(I.positionScreen);b.v3.positionScreen.copy(Q.positionScreen);b.normalWorld.copy(C.normal);W.multiplyVector3(b.normalWorld);b.centroidWorld.copy(C.centroid);V.multiplyVector3(b.centroidWorld);
+b.centroidScreen.copy(b.centroidWorld);s.multiplyVector3(b.centroidScreen);Q=C.vertexNormals;i=b.vertexNormalsWorld;E=0;for(I=Q.length;E<I;E++){U=i[E]=i[E]||new THREE.Vector3;U.copy(Q[E]);W.multiplyVector3(U)}b.z=b.centroidScreen.z;b.meshMaterials=J;b.faceMaterials=C.materials;b.overdraw=B;if(N.geometry.uvs[v]){b.uvs[0]=N.geometry.uvs[v][0];b.uvs[1]=N.geometry.uvs[v][1];b.uvs[2]=N.geometry.uvs[v][2]}o.push(b);r++}}else if(C instanceof THREE.Face4){E=O[C.a];I=O[C.b];Q=O[C.c];U=O[C.d];if(E.__visible&&
+I.__visible&&Q.__visible&&U.__visible)if(N.doubleSided||N.flipSided!=((U.positionScreen.x-E.positionScreen.x)*(I.positionScreen.y-E.positionScreen.y)-(U.positionScreen.y-E.positionScreen.y)*(I.positionScreen.x-E.positionScreen.x)<0||(I.positionScreen.x-Q.positionScreen.x)*(U.positionScreen.y-Q.positionScreen.y)-(I.positionScreen.y-Q.positionScreen.y)*(U.positionScreen.x-Q.positionScreen.x)<0)){b=l[r]=l[r]||new THREE.RenderableFace3;b.v1.positionWorld.copy(E.positionWorld);b.v2.positionWorld.copy(I.positionWorld);
+b.v3.positionWorld.copy(U.positionWorld);b.v1.positionScreen.copy(E.positionScreen);b.v2.positionScreen.copy(I.positionScreen);b.v3.positionScreen.copy(U.positionScreen);b.normalWorld.copy(C.normal);W.multiplyVector3(b.normalWorld);b.centroidWorld.copy(C.centroid);V.multiplyVector3(b.centroidWorld);b.centroidScreen.copy(b.centroidWorld);s.multiplyVector3(b.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterials=J;b.faceMaterials=C.materials;b.overdraw=B;if(N.geometry.uvs[v]){b.uvs[0]=N.geometry.uvs[v][0];
+b.uvs[1]=N.geometry.uvs[v][1];b.uvs[2]=N.geometry.uvs[v][3]}o.push(b);r++;q=l[r]=l[r]||new THREE.RenderableFace3;q.v1.positionWorld.copy(I.positionWorld);q.v2.positionWorld.copy(Q.positionWorld);q.v3.positionWorld.copy(U.positionWorld);q.v1.positionScreen.copy(I.positionScreen);q.v2.positionScreen.copy(Q.positionScreen);q.v3.positionScreen.copy(U.positionScreen);q.normalWorld.copy(b.normalWorld);q.centroidWorld.copy(b.centroidWorld);q.centroidScreen.copy(b.centroidScreen);q.z=q.centroidScreen.z;q.meshMaterials=
+J;q.faceMaterials=C.materials;q.overdraw=B;if(N.geometry.uvs[v]){q.uvs[0]=N.geometry.uvs[v][1];q.uvs[1]=N.geometry.uvs[v][2];q.uvs[2]=N.geometry.uvs[v][3]}o.push(q);r++}}}}else if(N instanceof THREE.Line){T.multiply(s,V);O=N.geometry.vertices;C=O[0];C.positionScreen.copy(C.position);T.multiplyVector4(C.positionScreen);v=1;for(D=O.length;v<D;v++){E=O[v];E.positionScreen.copy(E.position);T.multiplyVector4(E.positionScreen);I=O[v-1];g.copy(E.positionScreen);m.copy(I.positionScreen);if(c(g,m)){g.multiplyScalar(1/
+g.w);m.multiplyScalar(1/m.w);p=y[z]=y[z]||new THREE.RenderableLine;p.v1.positionScreen.copy(g);p.v2.positionScreen.copy(m);p.z=Math.max(g.z,m.z);p.materials=N.materials;o.push(p);z++}}}else if(N instanceof THREE.Particle){M.set(N.position.x,N.position.y,N.position.z,1);s.multiplyVector4(M);M.z/=M.w;if(M.z>0&&M.z<1){u=H[x]=H[x]||new THREE.RenderableParticle;u.x=M.x/M.w;u.y=M.y/M.w;u.z=M.z;u.rotation=N.rotation.z;u.scale.x=N.scale.x*Math.abs(u.x-(M.x+j.projectionMatrix.n11)/(M.w+j.projectionMatrix.n14));
+u.scale.y=N.scale.y*Math.abs(u.y-(M.y+j.projectionMatrix.n22)/(M.w+j.projectionMatrix.n24));u.materials=N.materials;o.push(u);x++}}}}k&&o.sort(a);return o};this.unprojectVector=function(e,j){var k=THREE.Matrix4.makeInvert(j.matrix);k.multiplySelf(THREE.Matrix4.makeInvert(j.projectionMatrix));k.multiplyVector3(e);return e}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,h,b;this.domElement=document.createElement("div");this.setSize=function(q,r){d=q;f=r;h=d/2;b=f/2};this.render=function(q,r){var l,p,z,y,u,x,H,K;a=c.projectScene(q,r);l=0;for(p=a.length;l<p;l++){u=a[l];if(u instanceof THREE.RenderableParticle){H=u.x*h+h;K=u.y*b+b;z=0;for(y=u.material.length;z<y;z++){x=u.material[z];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=H+"px";x.style.top=K+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(ca){if(u!=ca)p.globalAlpha=u=ca}function c(ca){if(x!=ca){switch(ca){case THREE.NormalBlending:p.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:p.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:p.globalCompositeOperation="darker"}x=ca}}var d=null,f=new THREE.Projector,h=document.createElement("canvas"),b,q,r,l,p=h.getContext("2d"),z=new THREE.Color(0),y=0,u=1,x=0,H=null,K=null,M=1,s,T,G,g,m,i,e,j,k,o=new THREE.Color,
+w=new THREE.Color,n=new THREE.Color,t=new THREE.Color,v=new THREE.Color,D,E,I,L,N,V,W,J,B,R=new THREE.Rectangle,O=new THREE.Rectangle,C=new THREE.Rectangle,Q=false,U=new THREE.Color,Y=new THREE.Color,fa=new THREE.Color,aa=new THREE.Color,za=Math.PI*2,Z=new THREE.Vector3,na,oa,ka,ga,pa,ea,qa=16;na=document.createElement("canvas");na.width=na.height=2;oa=na.getContext("2d");oa.fillStyle="rgba(0,0,0,1)";oa.fillRect(0,0,2,2);ka=oa.getImageData(0,0,2,2);ga=ka.data;pa=document.createElement("canvas");pa.width=
+pa.height=qa;ea=pa.getContext("2d");ea.translate(-qa/2,-qa/2);ea.scale(qa,qa);qa--;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ca,la){b=ca;q=la;r=b/2;l=q/2;h.width=b;h.height=q;R.set(-r,-l,r,l);u=1;x=0;K=H=null;M=1};this.setClearColor=function(ca,la){z.setHex(ca);y=la;O.set(-r,-l,r,l);p.setTransform(1,0,0,-1,r,l);this.clear()};this.clear=function(){p.setTransform(1,0,0,-1,r,l);if(!O.isEmpty()){O.inflate(1);O.minSelf(R);if(z.hex==0&&y==0)p.clearRect(O.getX(),
+O.getY(),O.getWidth(),O.getHeight());else{c(THREE.NormalBlending);a(1);p.fillStyle="rgba("+Math.floor(z.r*255)+","+Math.floor(z.g*255)+","+Math.floor(z.b*255)+","+y+")";p.fillRect(O.getX(),O.getY(),O.getWidth(),O.getHeight())}O.empty()}};this.render=function(ca,la){function Ea(A){var X,S,F,P=A.lights;Y.setRGB(0,0,0);fa.setRGB(0,0,0);aa.setRGB(0,0,0);A=0;for(X=P.length;A<X;A++){S=P[A];F=S.color;if(S instanceof THREE.AmbientLight){Y.r+=F.r;Y.g+=F.g;Y.b+=F.b}else if(S instanceof THREE.DirectionalLight){fa.r+=
+F.r;fa.g+=F.g;fa.b+=F.b}else if(S instanceof THREE.PointLight){aa.r+=F.r;aa.g+=F.g;aa.b+=F.b}}}function Aa(A,X,S,F){var P,$,da,ha,ia=A.lights;A=0;for(P=ia.length;A<P;A++){$=ia[A];da=$.color;ha=$.intensity;if($ instanceof THREE.DirectionalLight){$=S.dot($.position)*ha;if($>0){F.r+=da.r*$;F.g+=da.g*$;F.b+=da.b*$}}else if($ instanceof THREE.PointLight){Z.sub($.position,X);Z.normalize();$=S.dot(Z)*ha;if($>0){F.r+=da.r*$;F.g+=da.g*$;F.b+=da.b*$}}}}function Na(A,X,S){if(S.opacity!=0){a(S.opacity);c(S.blending);
+var F,P,$,da,ha,ia;if(S instanceof THREE.ParticleBasicMaterial){if(S.map&&S.map.image.loaded){da=S.map.image;ha=da.width>>1;ia=da.height>>1;P=X.scale.x*r;$=X.scale.y*l;S=P*ha;F=$*ia;C.set(A.x-S,A.y-F,A.x+S,A.y+F);if(R.instersects(C)){p.save();p.translate(A.x,A.y);p.rotate(-X.rotation);p.scale(P,-$);p.translate(-ha,-ia);p.drawImage(da,0,0);p.restore()}}}else if(S instanceof THREE.ParticleCircleMaterial){if(Q){U.r=Y.r+fa.r+aa.r;U.g=Y.g+fa.g+aa.g;U.b=Y.b+fa.b+aa.b;o.r=S.color.r*U.r;o.g=S.color.g*U.g;
+o.b=S.color.b*U.b;o.updateStyleString()}else o.__styleString=S.color.__styleString;S=X.scale.x*r;F=X.scale.y*l;C.set(A.x-S,A.y-F,A.x+S,A.y+F);if(R.instersects(C)){P=o.__styleString;if(K!=P)p.fillStyle=K=P;p.save();p.translate(A.x,A.y);p.rotate(-X.rotation);p.scale(S,F);p.beginPath();p.arc(0,0,1,0,za,true);p.closePath();p.fill();p.restore()}}}}function Oa(A,X,S,F){if(F.opacity!=0){a(F.opacity);c(F.blending);p.beginPath();p.moveTo(A.positionScreen.x,A.positionScreen.y);p.lineTo(X.positionScreen.x,X.positionScreen.y);
+p.closePath();if(F instanceof THREE.LineBasicMaterial){o.__styleString=F.color.__styleString;A=F.linewidth;if(M!=A)p.lineWidth=M=A;A=o.__styleString;if(H!=A)p.strokeStyle=H=A;p.stroke();C.inflate(F.linewidth*2)}}}function Ja(A,X,S,F,P,$){if(P.opacity!=0){a(P.opacity);c(P.blending);g=A.positionScreen.x;m=A.positionScreen.y;i=X.positionScreen.x;e=X.positionScreen.y;j=S.positionScreen.x;k=S.positionScreen.y;p.beginPath();p.moveTo(g,m);p.lineTo(i,e);p.lineTo(j,k);p.lineTo(g,m);p.closePath();if(P instanceof
+THREE.MeshBasicMaterial)if(P.map)P.map.image.loaded&&P.map.mapping instanceof THREE.UVMapping&&wa(g,m,i,e,j,k,P.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);else if(P.env_map){if(P.env_map.image.loaded)if(P.env_map.mapping instanceof THREE.SphericalReflectionMapping){A=la.matrix;Z.copy(F.vertexNormalsWorld[0]);L=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;N=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;Z.copy(F.vertexNormalsWorld[1]);V=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;
+W=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;Z.copy(F.vertexNormalsWorld[2]);J=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;B=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;wa(g,m,i,e,j,k,P.env_map.image,L,N,V,W,J,B)}}else P.wireframe?Ba(P.color.__styleString,P.wireframe_linewidth):Ca(P.color.__styleString);else if(P instanceof THREE.MeshLambertMaterial){if(P.map&&!P.wireframe){P.map.mapping instanceof THREE.UVMapping&&wa(g,m,i,e,j,k,P.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);
+c(THREE.SubtractiveBlending)}if(Q)if(!P.wireframe&&P.shading==THREE.SmoothShading&&F.vertexNormalsWorld.length==3){w.r=n.r=t.r=Y.r;w.g=n.g=t.g=Y.g;w.b=n.b=t.b=Y.b;Aa($,F.v1.positionWorld,F.vertexNormalsWorld[0],w);Aa($,F.v2.positionWorld,F.vertexNormalsWorld[1],n);Aa($,F.v3.positionWorld,F.vertexNormalsWorld[2],t);v.r=(n.r+t.r)*0.5;v.g=(n.g+t.g)*0.5;v.b=(n.b+t.b)*0.5;I=Ka(w,n,t,v);wa(g,m,i,e,j,k,I,0,0,1,0,0,1)}else{U.r=Y.r;U.g=Y.g;U.b=Y.b;Aa($,F.centroidWorld,F.normalWorld,U);o.r=P.color.r*U.r;o.g=
+P.color.g*U.g;o.b=P.color.b*U.b;o.updateStyleString();P.wireframe?Ba(o.__styleString,P.wireframe_linewidth):Ca(o.__styleString)}else P.wireframe?Ba(P.color.__styleString,P.wireframe_linewidth):Ca(P.color.__styleString)}else if(P instanceof THREE.MeshDepthMaterial){D=la.near;E=la.far;w.r=w.g=w.b=1-Fa(A.positionScreen.z,D,E);n.r=n.g=n.b=1-Fa(X.positionScreen.z,D,E);t.r=t.g=t.b=1-Fa(S.positionScreen.z,D,E);v.r=(n.r+t.r)*0.5;v.g=(n.g+t.g)*0.5;v.b=(n.b+t.b)*0.5;I=Ka(w,n,t,v);wa(g,m,i,e,j,k,I,0,0,1,0,0,
+1)}else if(P instanceof THREE.MeshNormalMaterial){o.r=Ga(F.normalWorld.x);o.g=Ga(F.normalWorld.y);o.b=Ga(F.normalWorld.z);o.updateStyleString();P.wireframe?Ba(o.__styleString,P.wireframe_linewidth):Ca(o.__styleString)}}}function Ba(A,X){if(H!=A)p.strokeStyle=H=A;if(M!=X)p.lineWidth=M=X;p.stroke();C.inflate(X*2)}function Ca(A){if(K!=A)p.fillStyle=K=A;p.fill()}function wa(A,X,S,F,P,$,da,ha,ia,ra,ja,sa,xa){var ua,ta;ua=da.width-1;ta=da.height-1;ha*=ua;ia*=ta;ra*=ua;ja*=ta;sa*=ua;xa*=ta;S-=A;F-=X;P-=
+A;$-=X;ra-=ha;ja-=ia;sa-=ha;xa-=ia;ta=1/(ra*xa-sa*ja);ua=(xa*S-ja*P)*ta;ja=(xa*F-ja*$)*ta;S=(ra*P-sa*S)*ta;F=(ra*$-sa*F)*ta;A=A-ua*ha-S*ia;X=X-ja*ha-F*ia;p.save();p.transform(ua,ja,S,F,A,X);p.clip();p.drawImage(da,0,0);p.restore()}function Ka(A,X,S,F){var P=~~(A.r*255),$=~~(A.g*255);A=~~(A.b*255);var da=~~(X.r*255),ha=~~(X.g*255);X=~~(X.b*255);var ia=~~(S.r*255),ra=~~(S.g*255);S=~~(S.b*255);var ja=~~(F.r*255),sa=~~(F.g*255);F=~~(F.b*255);ga[0]=P<0?0:P>255?255:P;ga[1]=$<0?0:$>255?255:$;ga[2]=A<0?0:
+A>255?255:A;ga[4]=da<0?0:da>255?255:da;ga[5]=ha<0?0:ha>255?255:ha;ga[6]=X<0?0:X>255?255:X;ga[8]=ia<0?0:ia>255?255:ia;ga[9]=ra<0?0:ra>255?255:ra;ga[10]=S<0?0:S>255?255:S;ga[12]=ja<0?0:ja>255?255:ja;ga[13]=sa<0?0:sa>255?255:sa;ga[14]=F<0?0:F>255?255:F;oa.putImageData(ka,0,0);ea.drawImage(na,0,0);return pa}function Fa(A,X,S){A=(A-X)/(S-X);return A*A*(3-2*A)}function Ga(A){A=(A+1)*0.5;return A<0?0:A>1?1:A}function Ha(A,X){var S=X.x-A.x,F=X.y-A.y,P=1/Math.sqrt(S*S+F*F);S*=P;F*=P;X.x+=S;X.y+=F;A.x-=S;A.y-=
+F}var Da,La,ba,ma,va,Ia,Ma,ya;this.autoClear?this.clear():p.setTransform(1,0,0,-1,r,l);d=f.projectScene(ca,la,this.sortElements);(Q=ca.lights.length>0)&&Ea(ca);Da=0;for(La=d.length;Da<La;Da++){ba=d[Da];C.empty();if(ba instanceof THREE.RenderableParticle){s=ba;s.x*=r;s.y*=l;ma=0;for(va=ba.materials.length;ma<va;ma++)Na(s,ba,ba.materials[ma],ca)}else if(ba instanceof THREE.RenderableLine){s=ba.v1;T=ba.v2;s.positionScreen.x*=r;s.positionScreen.y*=l;T.positionScreen.x*=r;T.positionScreen.y*=l;C.addPoint(s.positionScreen.x,
+s.positionScreen.y);C.addPoint(T.positionScreen.x,T.positionScreen.y);if(R.instersects(C)){ma=0;for(va=ba.materials.length;ma<va;)Oa(s,T,ba,ba.materials[ma++],ca)}}else if(ba instanceof THREE.RenderableFace3){s=ba.v1;T=ba.v2;G=ba.v3;s.positionScreen.x*=r;s.positionScreen.y*=l;T.positionScreen.x*=r;T.positionScreen.y*=l;G.positionScreen.x*=r;G.positionScreen.y*=l;if(ba.overdraw){Ha(s.positionScreen,T.positionScreen);Ha(T.positionScreen,G.positionScreen);Ha(G.positionScreen,s.positionScreen)}C.add3Points(s.positionScreen.x,
+s.positionScreen.y,T.positionScreen.x,T.positionScreen.y,G.positionScreen.x,G.positionScreen.y);if(R.instersects(C)){ma=0;for(va=ba.meshMaterials.length;ma<va;){ya=ba.meshMaterials[ma++];if(ya instanceof THREE.MeshFaceMaterial){Ia=0;for(Ma=ba.faceMaterials.length;Ia<Ma;)(ya=ba.faceMaterials[Ia++])&&Ja(s,T,G,ba,ya,ca)}else Ja(s,T,G,ba,ya,ca)}}}O.addRectangle(C)}p.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(L,N,V){var W,J,B,R;W=0;for(J=L.lights.length;W<J;W++){B=L.lights[W];if(B instanceof THREE.DirectionalLight){R=N.normalWorld.dot(B.position)*B.intensity;if(R>0){V.r+=B.color.r*R;V.g+=B.color.g*R;V.b+=B.color.b*R}}else if(B instanceof THREE.PointLight){k.sub(B.position,N.centroidWorld);k.normalize();R=N.normalWorld.dot(k)*B.intensity;if(R>0){V.r+=B.color.r*R;V.g+=B.color.g*R;V.b+=B.color.b*R}}}}function c(L,N,V,W,J,B){t=f(v++);t.setAttribute("d","M "+L.positionScreen.x+
+" "+L.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)G.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(T){g.r=m.r;g.g=m.g;g.b=m.b;a(B,W,g);G.r=J.color.r*g.r;G.g=J.color.g*g.g;G.b=J.color.b*g.b;G.updateStyleString()}else G.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){j=1-J.__2near/(J.__farPlusNear-W.z*J.__farMinusNear);
+G.setRGB(j,j,j)}else J instanceof THREE.MeshNormalMaterial&&G.setRGB(h(W.normalWorld.x),h(W.normalWorld.y),h(W.normalWorld.z));J.wireframe?t.setAttribute("style","fill: none; stroke: "+G.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):t.setAttribute("style","fill: "+G.__styleString+"; fill-opacity: "+J.opacity);r.appendChild(t)}function d(L,N,V,W,J,B,R){t=f(v++);t.setAttribute("d",
+"M "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)G.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(T){g.r=m.r;g.g=m.g;g.b=m.b;a(R,J,g);G.r=B.color.r*g.r;G.g=B.color.g*g.g;G.b=B.color.b*g.b;G.updateStyleString()}else G.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){j=
+1-B.__2near/(B.__farPlusNear-J.z*B.__farMinusNear);G.setRGB(j,j,j)}else B instanceof THREE.MeshNormalMaterial&&G.setRGB(h(J.normalWorld.x),h(J.normalWorld.y),h(J.normalWorld.z));B.wireframe?t.setAttribute("style","fill: none; stroke: "+G.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):t.setAttribute("style","fill: "+G.__styleString+"; fill-opacity: "+B.opacity);r.appendChild(t)}
+function f(L){if(o[L]==null){o[L]=document.createElementNS("http://www.w3.org/2000/svg","path");I==0&&o[L].setAttribute("shape-rendering","crispEdges");return o[L]}return o[L]}function h(L){return L<0?Math.min((1+L)*0.5,0.5):0.5+Math.min(L*0.5,0.5)}var b=null,q=new THREE.Projector,r=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,p,z,y,u,x,H,K,M=new THREE.Rectangle,s=new THREE.Rectangle,T=false,G=new THREE.Color(16777215),g=new THREE.Color(16777215),m=new THREE.Color(0),i=new THREE.Color(0),
+e=new THREE.Color(0),j,k=new THREE.Vector3,o=[],w=[],n=[],t,v,D,E,I=1;this.domElement=r;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(L){switch(L){case "high":I=1;break;case "low":I=0}};this.setSize=function(L,N){l=L;p=N;z=l/2;y=p/2;r.setAttribute("viewBox",-z+" "+-y+" "+l+" "+p);r.setAttribute("width",l);r.setAttribute("height",p);M.set(-z,-y,z,y)};this.clear=function(){for(;r.childNodes.length>0;)r.removeChild(r.childNodes[0])};this.render=function(L,N){var V,W,
+J,B,R,O,C,Q;this.autoClear&&this.clear();b=q.projectScene(L,N,this.sortElements);E=D=v=0;if(T=L.lights.length>0){C=L.lights;m.setRGB(0,0,0);i.setRGB(0,0,0);e.setRGB(0,0,0);V=0;for(W=C.length;V<W;V++){J=C[V];B=J.color;if(J instanceof THREE.AmbientLight){m.r+=B.r;m.g+=B.g;m.b+=B.b}else if(J instanceof THREE.DirectionalLight){i.r+=B.r;i.g+=B.g;i.b+=B.b}else if(J instanceof THREE.PointLight){e.r+=B.r;e.g+=B.g;e.b+=B.b}}}V=0;for(W=b.length;V<W;V++){C=b[V];s.empty();if(C instanceof THREE.RenderableParticle){u=
+C;u.x*=z;u.y*=-y;J=0;for(B=C.materials.length;J<B;J++)if(Q=C.materials[J]){R=u;O=C;Q=Q;var U=D++;if(w[U]==null){w[U]=document.createElementNS("http://www.w3.org/2000/svg","circle");I==0&&w[U].setAttribute("shape-rendering","crispEdges")}t=w[U];t.setAttribute("cx",R.x);t.setAttribute("cy",R.y);t.setAttribute("r",O.scale.x*z);if(Q instanceof THREE.ParticleCircleMaterial){if(T){g.r=m.r+i.r+e.r;g.g=m.g+i.g+e.g;g.b=m.b+i.b+e.b;G.r=Q.color.r*g.r;G.g=Q.color.g*g.g;G.b=Q.color.b*g.b;G.updateStyleString()}else G=
+Q.color;t.setAttribute("style","fill: "+G.__styleString)}r.appendChild(t)}}else if(C instanceof THREE.RenderableLine){u=C.v1;x=C.v2;u.positionScreen.x*=z;u.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);if(M.instersects(s)){J=0;for(B=C.materials.length;J<B;)if(Q=C.materials[J++]){R=u;O=x;Q=Q;U=E++;if(n[U]==null){n[U]=document.createElementNS("http://www.w3.org/2000/svg","line");I==
+0&&n[U].setAttribute("shape-rendering","crispEdges")}t=n[U];t.setAttribute("x1",R.positionScreen.x);t.setAttribute("y1",R.positionScreen.y);t.setAttribute("x2",O.positionScreen.x);t.setAttribute("y2",O.positionScreen.y);if(Q instanceof THREE.LineBasicMaterial){G.__styleString=Q.color.__styleString;t.setAttribute("style","fill: none; stroke: "+G.__styleString+"; stroke-width: "+Q.linewidth+"; stroke-opacity: "+Q.opacity+"; stroke-linecap: "+Q.linecap+"; stroke-linejoin: "+Q.linejoin);r.appendChild(t)}}}}else if(C instanceof
+THREE.RenderableFace3){u=C.v1;x=C.v2;H=C.v3;u.positionScreen.x*=z;u.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;H.positionScreen.x*=z;H.positionScreen.y*=-y;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(H.positionScreen.x,H.positionScreen.y);if(M.instersects(s)){J=0;for(B=C.meshMaterials.length;J<B;){Q=C.meshMaterials[J++];if(Q instanceof THREE.MeshFaceMaterial){R=0;for(O=C.faceMaterials.length;R<O;)(Q=C.faceMaterials[R++])&&
+c(u,x,H,C,Q,L)}else Q&&c(u,x,H,C,Q,L)}}}else if(C instanceof THREE.RenderableFace4){u=C.v1;x=C.v2;H=C.v3;K=C.v4;u.positionScreen.x*=z;u.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;H.positionScreen.x*=z;H.positionScreen.y*=-y;K.positionScreen.x*=z;K.positionScreen.y*=-y;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(H.positionScreen.x,H.positionScreen.y);s.addPoint(K.positionScreen.x,K.positionScreen.y);if(M.instersects(s)){J=
+0;for(B=C.meshMaterials.length;J<B;){Q=C.meshMaterials[J++];if(Q instanceof THREE.MeshFaceMaterial){R=0;for(O=C.faceMaterials.length;R<O;)(Q=C.faceMaterials[R++])&&d(u,x,H,K,C,Q,L)}else Q&&d(u,x,H,K,C,Q,L)}}}}}};
+THREE.WebGLRenderer=function(a){function c(g,m){g.fragment_shader=m.fragment_shader;g.vertex_shader=m.vertex_shader;g.uniforms=Uniforms.clone(m.uniforms)}function d(g,m){var i;if(g=="fragment")i=b.createShader(b.FRAGMENT_SHADER);else if(g=="vertex")i=b.createShader(b.VERTEX_SHADER);b.shaderSource(i,m);b.compileShader(i);if(!b.getShaderParameter(i,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(i));return null}return i}function f(g){switch(g){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;
 case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;
-case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var h=document.createElement("canvas"),b,q=null,r=null,l=new THREE.Matrix4,n,y=new Float32Array(16),x=new Float32Array(16),
-v=new Float32Array(16),w=new Float32Array(9),G=new Float32Array(16),K=new THREE.Matrix4,L=new THREE.Vector4,t=true,T=new THREE.Color(0),E=0;if(a){if(a.antialias!==undefined)t=a.antialias;a.clearColor!==undefined&&T.setHex(a.clearColor);if(a.clearAlpha!==undefined)E=a.clearAlpha}this.domElement=h;this.autoClear=true;(function(f,k,i){try{b=h.getContext("experimental-webgl",{antialias:f})}catch(g){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);
-b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(k.r,k.g,k.b,i)})(t,T,E);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,k){h.width=f;h.height=k;b.viewport(0,0,h.width,h.height)};this.setClearColor=function(f,k){var i=new THREE.Color(f);b.clearColor(i.r,i.g,i.b,k)};
-this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(f,k){var i,g,m,j=0,o=0,p=0,s,u,z,H=this.lights,F=H.directional.colors,I=H.directional.positions,M=H.point.colors,N=H.point.positions,V=0,W=0;i=0;for(g=k.length;i<g;i++){m=k[i];s=m.color;u=m.position;z=m.intensity;if(m instanceof THREE.AmbientLight){j+=s.r;o+=s.g;p+=s.b}else if(m instanceof THREE.DirectionalLight){F[V*3]=s.r*z;F[V*3+1]=s.g*z;F[V*3+2]=s.b*z;I[V*3]=u.x;I[V*3+1]=u.y;I[V*3+2]=u.z;V+=1}else if(m instanceof
-THREE.PointLight){M[W*3]=s.r*z;M[W*3+1]=s.g*z;M[W*3+2]=s.b*z;N[W*3]=u.x;N[W*3+1]=u.y;N[W*3+2]=u.z;W+=1}}H.point.length=W;H.directional.length=V;H.ambient[0]=j;H.ambient[1]=o;H.ambient[2]=p};this.createParticleBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();f.__webGLParticleBuffer=b.createBuffer();f.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();f.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=function(f){f.__webGLVertexBuffer=
-b.createBuffer();f.__webGLNormalBuffer=b.createBuffer();f.__webGLTangentBuffer=b.createBuffer();f.__webGLUVBuffer=b.createBuffer();f.__webGLUV2Buffer=b.createBuffer();f.__webGLFaceBuffer=b.createBuffer();f.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(f){var k=f.vertices.length;f.__vertexArray=new Float32Array(k*3);f.__lineArray=new Uint16Array(k);f.__webGLLineCount=k};this.initParticleBuffers=function(f){var k=f.vertices.length;f.__vertexArray=new Float32Array(k*3);f.__colorArray=
-new Float32Array(k*3);f.__particleArray=new Uint16Array(k);f.__sortArray=[];f.__webGLParticleCount=k};this.initMeshBuffers=function(f,k){var i,g,m=0,j=0,o=0,p=k.geometry.faces,s=f.faces;i=0;for(g=s.length;i<g;i++){fi=s[i];face=p[fi];if(face instanceof THREE.Face3){m+=3;j+=1;o+=3}else if(face instanceof THREE.Face4){m+=4;j+=2;o+=4}}f.__vertexArray=new Float32Array(m*3);f.__normalArray=new Float32Array(m*3);f.__tangentArray=new Float32Array(m*4);f.__uvArray=new Float32Array(m*2);f.__uv2Array=new Float32Array(m*
-2);f.__faceArray=new Uint16Array(j*3);f.__lineArray=new Uint16Array(o*2);m=false;i=0;for(g=k.materials.length;i<g;i++){p=k.materials[i];if(p instanceof THREE.MeshFaceMaterial){p=0;for(s=f.materials.length;p<s;p++)if(f.materials[p]&&f.materials[p].shading!=undefined&&f.materials[p].shading==THREE.SmoothShading){m=true;break}}else if(p&&p.shading!=undefined&&p.shading==THREE.SmoothShading){m=true;break}if(m)break}f.__needsSmoothNormals=m;f.__webGLFaceCount=j*3;f.__webGLLineCount=o*2};this.setMeshBuffers=
-function(f,k,i){var g,m,j,o,p,s,u,z,H,F,I=0,M=0,N=0,V=0,W=0,J=0,B=0,R=0,O=f.__vertexArray,C=f.__uvArray,Q=f.__uv2Array,U=f.__normalArray,Y=f.__tangentArray,fa=f.__faceArray,aa=f.__lineArray,za=f.__needsSmoothNormals,Z=k.geometry,na=Z.__dirtyVertices,oa=Z.__dirtyElements,ka=Z.__dirtyUvs,ga=Z.__dirtyNormals,pa=Z.__dirtyTangents,ea=Z.vertices,qa=f.faces,ca=Z.faces,la=Z.uvs,Ea=Z.uvs2;k=0;for(g=qa.length;k<g;k++){m=qa[k];j=ca[m];s=la[m];m=Ea[m];o=j.vertexNormals;p=j.normal;if(j instanceof THREE.Face3){if(na){u=
-ea[j.a].position;z=ea[j.b].position;H=ea[j.c].position;O[M]=u.x;O[M+1]=u.y;O[M+2]=u.z;O[M+3]=z.x;O[M+4]=z.y;O[M+5]=z.z;O[M+6]=H.x;O[M+7]=H.y;O[M+8]=H.z;M+=9}if(pa&&Z.hasTangents){u=ea[j.a].tangent;z=ea[j.b].tangent;H=ea[j.c].tangent;Y[B]=u.x;Y[B+1]=u.y;Y[B+2]=u.z;Y[B+3]=u.w;Y[B+4]=z.x;Y[B+5]=z.y;Y[B+6]=z.z;Y[B+7]=z.w;Y[B+8]=H.x;Y[B+9]=H.y;Y[B+10]=H.z;Y[B+11]=H.w;B+=12}if(ga)if(o.length==3&&za)for(j=0;j<3;j++){p=o[j];U[J]=p.x;U[J+1]=p.y;U[J+2]=p.z;J+=3}else for(j=0;j<3;j++){U[J]=p.x;U[J+1]=p.y;U[J+
-2]=p.z;J+=3}if(ka&&s)for(j=0;j<3;j++){o=s[j];C[N]=o.u;C[N+1]=o.v;N+=2}if(ka&&m)for(j=0;j<3;j++){s=m[j];Q[V]=s.u;Q[V+1]=s.v;V+=2}if(oa){fa[W]=I;fa[W+1]=I+1;fa[W+2]=I+2;W+=3;aa[R]=I;aa[R+1]=I+1;aa[R+2]=I;aa[R+3]=I+2;aa[R+4]=I+1;aa[R+5]=I+2;R+=6;I+=3}}else if(j instanceof THREE.Face4){if(na){u=ea[j.a].position;z=ea[j.b].position;H=ea[j.c].position;F=ea[j.d].position;O[M]=u.x;O[M+1]=u.y;O[M+2]=u.z;O[M+3]=z.x;O[M+4]=z.y;O[M+5]=z.z;O[M+6]=H.x;O[M+7]=H.y;O[M+8]=H.z;O[M+9]=F.x;O[M+10]=F.y;O[M+11]=F.z;M+=
-12}if(pa&&Z.hasTangents){u=ea[j.a].tangent;z=ea[j.b].tangent;H=ea[j.c].tangent;j=ea[j.d].tangent;Y[B]=u.x;Y[B+1]=u.y;Y[B+2]=u.z;Y[B+3]=u.w;Y[B+4]=z.x;Y[B+5]=z.y;Y[B+6]=z.z;Y[B+7]=z.w;Y[B+8]=H.x;Y[B+9]=H.y;Y[B+10]=H.z;Y[B+11]=H.w;Y[B+12]=j.x;Y[B+13]=j.y;Y[B+14]=j.z;Y[B+15]=j.w;B+=16}if(ga)if(o.length==4&&za)for(j=0;j<4;j++){p=o[j];U[J]=p.x;U[J+1]=p.y;U[J+2]=p.z;J+=3}else for(j=0;j<4;j++){U[J]=p.x;U[J+1]=p.y;U[J+2]=p.z;J+=3}if(ka&&s)for(j=0;j<4;j++){o=s[j];C[N]=o.u;C[N+1]=o.v;N+=2}if(ka&&m)for(j=0;j<
-4;j++){s=m[j];Q[V]=s.u;Q[V+1]=s.v;V+=2}if(oa){fa[W]=I;fa[W+1]=I+1;fa[W+2]=I+2;fa[W+3]=I;fa[W+4]=I+2;fa[W+5]=I+3;W+=6;aa[R]=I;aa[R+1]=I+1;aa[R+2]=I;aa[R+3]=I+3;aa[R+4]=I+1;aa[R+5]=I+2;aa[R+6]=I+2;aa[R+7]=I+3;R+=8;I+=4}}}if(na){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,O,i)}if(ga){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,U,i)}if(pa&&Z.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,
-Y,i)}if(ka&&N>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,C,i)}if(ka&&V>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,Q,i)}if(oa){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,fa,i);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,aa,i)}};this.setLineBuffers=function(f,k){var i,g,m,j=f.vertices,o=j.length,p=f.__vertexArray,s=f.__lineArray,u=
-f.__dirtyElements;if(f.__dirtyVertices){for(i=0;i<o;i++){g=j[i].position;m=i*3;p[m]=g.x;p[m+1]=g.y;p[m+2]=g.z}b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,p,k)}if(u){for(i=0;i<o;i++)s[i]=i;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,s,k)}};this.setParticleBuffers=function(f,k,i,g){var m,j,o;j=f.vertices;var p=j.length,s=f.colors,u=s.length,z=f.__vertexArray,H=f.__particleArray,F=f.__colorArray,I=f.__sortArray,M=f.__dirtyVertices,
-N=f.__dirtyElements,V=f.__dirtyColors;if(i.sortParticles){K.multiply(g.projectionMatrix,g.matrix);K.multiplySelf(i.matrix);for(m=0;m<p;m++){o=j[m].position;L.copy(o);K.multiplyVector3(L);I[m]=[L.z,m]}I.sort(function(W,J){return J[0]-W[0]});for(m=0;m<p;m++){o=j[I[m][1]].position;g=m*3;z[g]=o.x;z[g+1]=o.y;z[g+2]=o.z}for(j=0;j<u;j++){g=j*3;color=s[I[j][1]];F[g]=color.r;F[g+1]=color.g;F[g+2]=color.b}}else{if(M)for(m=0;m<p;m++){o=j[m].position;g=m*3;z[g]=o.x;z[g+1]=o.y;z[g+2]=o.z}if(V)for(j=0;j<u;j++){color=
-s[j];g=j*3;F[g]=color.r;F[g+1]=color.g;F[g+2]=color.b}}if(N){for(m=0;m<p;m++)H[m]=m;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,H,k)}if(M||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,z,k)}if(V||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,F,k)}};this.initMaterial=function(f,k,i){if(!f.program){var g,m;if(f instanceof THREE.MeshDepthMaterial)c(f,
-THREE.ShaderLib.depth);else if(f instanceof THREE.MeshNormalMaterial)c(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)c(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)c(f,THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)c(f,THREE.ShaderLib.phong);else if(f instanceof THREE.LineBasicMaterial)c(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&c(f,THREE.ShaderLib.particle_basic);var j,o,p,s;m=p=s=0;for(j=k.length;m<
-j;m++){o=k[m];o instanceof THREE.DirectionalLight&&p++;o instanceof THREE.PointLight&&s++}if(s+p<=4){k=p;s=s}else{k=Math.ceil(4*p/(s+p));s=4-k}m={directional:k,point:s};s=f.fragment_shader;k=f.vertex_shader;j={fog:i,map:f.map,env_map:f.env_map,light_map:f.light_map,vertex_colors:f.vertex_colors,maxDirLights:m.directional,maxPointLights:m.point};i=b.createProgram();m=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+j.maxDirLights,"#define MAX_POINT_LIGHTS "+j.maxPointLights,
-j.fog?"#define USE_FOG":"",j.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",j.map?"#define USE_MAP":"",j.env_map?"#define USE_ENVMAP":"",j.light_map?"#define USE_LIGHTMAP":"",j.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");j=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+j.maxDirLights,"#define MAX_POINT_LIGHTS "+j.maxPointLights,j.map?"#define USE_MAP":"",j.env_map?"#define USE_ENVMAP":
-"",j.light_map?"#define USE_LIGHTMAP":"",j.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(i,d("fragment",m+s));b.attachShader(i,d("vertex",j+k));b.linkProgram(i);b.getProgramParameter(i,b.LINK_STATUS)||
-alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(i,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");i.uniforms={};i.attributes={};f.program=i;i=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(g in f.uniforms)i.push(g);g=f.program;s=0;for(k=i.length;s<k;s++){m=i[s];g.uniforms[m]=b.getUniformLocation(g,m)}f=f.program;g=["position","normal","uv","uv2","tangent","color"];i=0;for(s=g.length;i<s;i++){k=g[i];f.attributes[k]=
-b.getAttribLocation(f,k)}}};this.renderBuffer=function(f,k,i,g,m,j){var o;this.initMaterial(g,k,i);o=g.program;if(o!=q){b.useProgram(o);q=o}this.loadCamera(o,f);this.loadMatrices(o);if(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial){this.setupLights(o,k);k=this.lights;g.uniforms.enableLighting.value=k.directional.length+k.point.length;g.uniforms.ambientLightColor.value=k.ambient;g.uniforms.directionalLightColor.value=k.directional.colors;g.uniforms.directionalLightDirection.value=
-k.directional.positions;g.uniforms.pointLightColor.value=k.point.colors;g.uniforms.pointLightPosition.value=k.point.positions}if(g instanceof THREE.MeshBasicMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshPhongMaterial){g.uniforms.diffuse.value.setRGB(g.color.r*g.opacity,g.color.g*g.opacity,g.color.b*g.opacity);g.uniforms.opacity.value=g.opacity;g.uniforms.map.texture=g.map;g.uniforms.light_map.texture=g.light_map;g.uniforms.env_map.texture=g.env_map;g.uniforms.reflectivity.value=
-g.reflectivity;g.uniforms.refraction_ratio.value=g.refraction_ratio;g.uniforms.combine.value=g.combine;g.uniforms.useRefract.value=g.env_map&&g.env_map.mapping instanceof THREE.CubeRefractionMapping;if(i){g.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){g.uniforms.fogNear.value=i.near;g.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)g.uniforms.fogDensity.value=i.density}}if(g instanceof THREE.LineBasicMaterial){g.uniforms.diffuse.value.setRGB(g.color.r*g.opacity,
-g.color.g*g.opacity,g.color.b*g.opacity);g.uniforms.opacity.value=g.opacity;if(i){g.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){g.uniforms.fogNear.value=i.near;g.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)g.uniforms.fogDensity.value=i.density}}if(g instanceof THREE.ParticleBasicMaterial){g.uniforms.psColor.value.setRGB(g.color.r*g.opacity,g.color.g*g.opacity,g.color.b*g.opacity);g.uniforms.opacity.value=g.opacity;g.uniforms.size.value=g.size;g.uniforms.map.texture=
-g.map;if(i){g.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){g.uniforms.fogNear.value=i.near;g.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)g.uniforms.fogDensity.value=i.density}}if(g instanceof THREE.MeshPhongMaterial){g.uniforms.ambient.value.setRGB(g.ambient.r,g.ambient.g,g.ambient.b);g.uniforms.specular.value.setRGB(g.specular.r,g.specular.g,g.specular.b);g.uniforms.shininess.value=g.shininess}if(g instanceof THREE.MeshDepthMaterial){g.uniforms.mNear.value=
-f.near;g.uniforms.mFar.value=f.far}f=g.uniforms;var p,s,u;for(p in f)if(u=o.uniforms[p]){k=f[p];s=k.type;i=k.value;if(s=="i")b.uniform1i(u,i);else if(s=="f")b.uniform1f(u,i);else if(s=="fv1")b.uniform1fv(u,i);else if(s=="fv")b.uniform3fv(u,i);else if(s=="v2")b.uniform2f(u,i.x,i.y);else if(s=="v3")b.uniform3f(u,i.x,i.y,i.z);else if(s=="c")b.uniform3f(u,i.r,i.g,i.b);else if(s=="t"){b.uniform1i(u,i);if(k=k.texture)if(k.image instanceof Array&&k.image.length==6){k=k;i=i;if(k.image.length==6){if(!k.image.__webGLTextureCube&&
-!k.image.__cubeMapInitialized&&k.image.loadCount==6){k.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,k.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(s=0;s<6;++s)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+
-s,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,k.image[s]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);k.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_CUBE_MAP,k.image.__webGLTextureCube)}}else{k=k;i=i;if(!k.__webGLTexture&&k.image.loaded){k.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,k.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,k.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,e(k.wrap_s));
-b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,e(k.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,e(k.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e(k.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_2D,k.__webGLTexture)}}}o=o.attributes;b.bindBuffer(b.ARRAY_BUFFER,m.__webGLVertexBuffer);b.vertexAttribPointer(o.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(o.position);if(o.color>=
-0){b.bindBuffer(b.ARRAY_BUFFER,m.__webGLColorBuffer);b.vertexAttribPointer(o.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(o.color)}if(o.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,m.__webGLNormalBuffer);b.vertexAttribPointer(o.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(o.normal)}if(o.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,m.__webGLTangentBuffer);b.vertexAttribPointer(o.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(o.tangent)}if(o.uv>=0)if(m.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,
-m.__webGLUVBuffer);b.vertexAttribPointer(o.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(o.uv)}else b.disableVertexAttribArray(o.uv);if(o.uv2>=0)if(m.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,m.__webGLUV2Buffer);b.vertexAttribPointer(o.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(o.uv2)}else b.disableVertexAttribArray(o.uv2);if(g.wireframe||g instanceof THREE.LineBasicMaterial){o=g.wireframe_linewidth!==undefined?g.wireframe_linewidth:g.linewidth!==undefined?g.linewidth:1;g=g instanceof
-THREE.LineBasicMaterial&&j.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(o);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,m.__webGLLineBuffer);b.drawElements(g,m.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(g instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,m.__webGLParticleBuffer);b.drawElements(b.POINTS,m.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,m.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,m.__webGLFaceCount,b.UNSIGNED_SHORT,
-0)}};this.renderPass=function(f,k,i,g,m,j,o){var p,s,u,z,H;u=0;for(z=g.materials.length;u<z;u++){p=g.materials[u];if(p instanceof THREE.MeshFaceMaterial){p=0;for(s=m.materials.length;p<s;p++)if((H=m.materials[p])&&H.blending==j&&H.opacity<1==o){this.setBlending(H.blending);this.renderBuffer(f,k,i,H,m,g)}}else if((H=p)&&H.blending==j&&H.opacity<1==o){this.setBlending(H.blending);this.renderBuffer(f,k,i,H,m,g)}}};this.render=function(f,k,i,g){var m,j,o,p=f.lights,s=f.fog;k.autoUpdateMatrix&&k.updateMatrix();
-y.set(k.matrix.flatten());v.set(k.projectionMatrix.flatten());this.initWebGLObjects(f,k);g=g!==undefined?g:true;if(i&&!i.__webGLFramebuffer){i.__webGLFramebuffer=b.createFramebuffer();i.__webGLRenderbuffer=b.createRenderbuffer();i.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,i.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,i.width,i.height);b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,e(i.wrap_s));b.texParameteri(b.TEXTURE_2D,
-b.TEXTURE_WRAP_T,e(i.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,e(i.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e(i.min_filter));b.texImage2D(b.TEXTURE_2D,0,e(i.format),i.width,i.height,0,e(i.format),e(i.type),null);b.bindFramebuffer(b.FRAMEBUFFER,i.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,i.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,i.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,
-null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(i){m=i.__webGLFramebuffer;o=i.width;j=i.height}else{m=null;o=h.width;j=h.height}if(m!=r){b.bindFramebuffer(b.FRAMEBUFFER,m);b.viewport(0,0,o,j);g&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);r=m}this.autoClear&&this.clear();m=f.__webGLObjects.length;for(g=0;g<m;g++){j=f.__webGLObjects[g];o=j.object;if(o.visible){o.autoUpdateMatrix&&o.updateMatrix();if(o.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);
-o.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}}for(g=0;g<m;g++){j=f.__webGLObjects[g];o=j.object;j=j.buffer;if(o.visible){this.setupMatrices(o,k);this.renderPass(k,p,s,o,j,THREE.NormalBlending,false)}}for(g=0;g<m;g++){j=f.__webGLObjects[g];o=j.object;j=j.buffer;if(o.visible){this.setupMatrices(o,k);this.renderPass(k,p,s,o,j,THREE.AdditiveBlending,false);this.renderPass(k,p,s,o,j,THREE.SubtractiveBlending,false);this.renderPass(k,p,s,o,j,THREE.AdditiveBlending,true);this.renderPass(k,p,s,o,j,THREE.SubtractiveBlending,
-true);this.renderPass(k,p,s,o,j,THREE.NormalBlending,true);this.renderPass(k,p,s,o,j,THREE.BillboardBlending,false)}}if(i&&i.min_filter!==THREE.NearestFilter&&i.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(f,k){function i(z,H,F,I){if(z[H]==undefined){f.__webGLObjects.push({buffer:F,object:I});z[H]=1}}var g,m,j,o,p,s,u;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap=
-{}}g=0;for(m=f.objects.length;g<m;g++){j=f.objects[g];p=j.geometry;if(f.__webGLObjectsMap[j.id]==undefined)f.__webGLObjectsMap[j.id]={};u=f.__webGLObjectsMap[j.id];if(j instanceof THREE.Mesh){for(o in p.geometryChunks){s=p.geometryChunks[o];if(!s.__webGLVertexBuffer){this.createMeshBuffers(s);this.initMeshBuffers(s,j);p.__dirtyVertices=true;p.__dirtyElements=true;p.__dirtyUvs=true;p.__dirtyNormals=true;p.__dirtyTangents=true}if(p.__dirtyVertices||p.__dirtyElements||p.__dirtyUvs)this.setMeshBuffers(s,
-j,b.DYNAMIC_DRAW);i(u,o,s,j)}p.__dirtyVertices=false;p.__dirtyElements=false;p.__dirtyUvs=false;p.__dirtyNormals=false;p.__dirtyTangents=false}else if(j instanceof THREE.Line){if(!p.__webGLVertexBuffer){this.createLineBuffers(p);this.initLineBuffers(p);p.__dirtyVertices=true;p.__dirtyElements=true}p.__dirtyVertices&&this.setLineBuffers(p,b.DYNAMIC_DRAW);i(u,0,p,j);p.__dirtyVertices=false;p.__dirtyElements=false}else if(j instanceof THREE.ParticleSystem){if(!p.__webGLVertexBuffer){this.createParticleBuffers(p);
-this.initParticleBuffers(p);p.__dirtyVertices=true;p.__dirtyColors=true;p.__dirtyElements=true}if(p.__dirtyVertices||p.__dirtyColors||j.sortParticles)this.setParticleBuffers(p,b.DYNAMIC_DRAW,j,k);i(u,0,p,j);p.__dirtyVertices=false;p.__dirtyColors=false;p.__dirtyElements=false}}};this.removeObject=function(f,k){var i,g;for(i=f.__webGLObjects.length-1;i>=0;i--){g=f.__webGLObjects[i].object;k==g&&f.__webGLObjects.splice(i,1)}};this.setupMatrices=function(f,k){l.multiply(k.matrix,f.matrix);x.set(l.flatten());
-n=THREE.Matrix4.makeInvert3x3(l).transpose();w.set(n.m);G.set(f.matrix.flatten())};this.loadMatrices=function(f){b.uniformMatrix4fv(f.uniforms.viewMatrix,false,y);b.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,x);b.uniformMatrix4fv(f.uniforms.projectionMatrix,false,v);b.uniformMatrix3fv(f.uniforms.normalMatrix,false,w);b.uniformMatrix4fv(f.uniforms.objectMatrix,false,G)};this.loadCamera=function(f,k){b.uniform3f(f.uniforms.cameraPosition,k.position.x,k.position.y,k.position.z)};this.setBlending=
-function(f){switch(f){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(f,k){if(f){!k||k=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(f=="back")b.cullFace(b.BACK);else f=="front"?
-b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
-THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
-envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
-map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",
-lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\nlightmapColor = texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
+case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var h=document.createElement("canvas"),b,q=null,r=null,l=new THREE.Matrix4,p,z=new Float32Array(16),y=new Float32Array(16),
+u=new Float32Array(16),x=new Float32Array(9),H=new Float32Array(16),K=new THREE.Matrix4,M=new THREE.Vector4,s=true,T=new THREE.Color(0),G=0;if(a){if(a.antialias!==undefined)s=a.antialias;a.clearColor!==undefined&&T.setHex(a.clearColor);if(a.clearAlpha!==undefined)G=a.clearAlpha}this.domElement=h;this.autoClear=true;(function(g,m,i){try{b=h.getContext("experimental-webgl",{antialias:g})}catch(e){console.log(e)}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,
+0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(m.r,m.g,m.b,i)})(s,T,G);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(g,m){h.width=g;h.height=m;b.viewport(0,0,h.width,h.height)};this.setClearColor=function(g,m){var i=new THREE.Color(g);b.clearColor(i.r,
+i.g,i.b,m)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(g,m){var i,e,j,k=0,o=0,w=0,n,t,v,D=this.lights,E=D.directional.colors,I=D.directional.positions,L=D.point.colors,N=D.point.positions,V=0,W=0;i=0;for(e=m.length;i<e;i++){j=m[i];n=j.color;t=j.position;v=j.intensity;if(j instanceof THREE.AmbientLight){k+=n.r;o+=n.g;w+=n.b}else if(j instanceof THREE.DirectionalLight){E[V*3]=n.r*v;E[V*3+1]=n.g*v;E[V*3+2]=n.b*v;I[V*3]=t.x;I[V*3+1]=t.y;I[V*3+2]=t.z;
+V+=1}else if(j instanceof THREE.PointLight){L[W*3]=n.r*v;L[W*3+1]=n.g*v;L[W*3+2]=n.b*v;N[W*3]=t.x;N[W*3+1]=t.y;N[W*3+2]=t.z;W+=1}}D.point.length=W;D.directional.length=V;D.ambient[0]=k;D.ambient[1]=o;D.ambient[2]=w};this.createParticleBuffers=function(g){g.__webGLVertexBuffer=b.createBuffer();g.__webGLParticleBuffer=b.createBuffer();g.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(g){g.__webGLVertexBuffer=b.createBuffer();g.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=
+function(g){g.__webGLVertexBuffer=b.createBuffer();g.__webGLNormalBuffer=b.createBuffer();g.__webGLTangentBuffer=b.createBuffer();g.__webGLUVBuffer=b.createBuffer();g.__webGLUV2Buffer=b.createBuffer();g.__webGLFaceBuffer=b.createBuffer();g.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(g){var m=g.vertices.length;g.__vertexArray=new Float32Array(m*3);g.__lineArray=new Uint16Array(m);g.__webGLLineCount=m};this.initParticleBuffers=function(g){var m=g.vertices.length;g.__vertexArray=
+new Float32Array(m*3);g.__colorArray=new Float32Array(m*3);g.__particleArray=new Uint16Array(m);g.__sortArray=[];g.__webGLParticleCount=m};this.initMeshBuffers=function(g,m){var i,e,j=0,k=0,o=0,w=m.geometry.faces,n=g.faces;i=0;for(e=n.length;i<e;i++){fi=n[i];face=w[fi];if(face instanceof THREE.Face3){j+=3;k+=1;o+=3}else if(face instanceof THREE.Face4){j+=4;k+=2;o+=4}}g.__vertexArray=new Float32Array(j*3);g.__normalArray=new Float32Array(j*3);g.__tangentArray=new Float32Array(j*4);g.__uvArray=new Float32Array(j*
+2);g.__uv2Array=new Float32Array(j*2);g.__faceArray=new Uint16Array(k*3);g.__lineArray=new Uint16Array(o*2);j=false;i=0;for(e=m.materials.length;i<e;i++){w=m.materials[i];if(w instanceof THREE.MeshFaceMaterial){w=0;for(n=g.materials.length;w<n;w++)if(g.materials[w]&&g.materials[w].shading!=undefined&&g.materials[w].shading==THREE.SmoothShading){j=true;break}}else if(w&&w.shading!=undefined&&w.shading==THREE.SmoothShading){j=true;break}if(j)break}g.__needsSmoothNormals=j;g.__webGLFaceCount=k*3;g.__webGLLineCount=
+o*2};this.setMeshBuffers=function(g,m,i){var e,j,k,o,w,n,t,v,D,E,I=0,L=0,N=0,V=0,W=0,J=0,B=0,R=0,O=g.__vertexArray,C=g.__uvArray,Q=g.__uv2Array,U=g.__normalArray,Y=g.__tangentArray,fa=g.__faceArray,aa=g.__lineArray,za=g.__needsSmoothNormals,Z=m.geometry,na=Z.__dirtyVertices,oa=Z.__dirtyElements,ka=Z.__dirtyUvs,ga=Z.__dirtyNormals,pa=Z.__dirtyTangents,ea=Z.vertices,qa=g.faces,ca=Z.faces,la=Z.uvs,Ea=Z.uvs2;m=0;for(e=qa.length;m<e;m++){j=qa[m];k=ca[j];n=la[j];j=Ea[j];o=k.vertexNormals;w=k.normal;if(k instanceof
+THREE.Face3){if(na){t=ea[k.a].position;v=ea[k.b].position;D=ea[k.c].position;O[L]=t.x;O[L+1]=t.y;O[L+2]=t.z;O[L+3]=v.x;O[L+4]=v.y;O[L+5]=v.z;O[L+6]=D.x;O[L+7]=D.y;O[L+8]=D.z;L+=9}if(pa&&Z.hasTangents){t=ea[k.a].tangent;v=ea[k.b].tangent;D=ea[k.c].tangent;Y[B]=t.x;Y[B+1]=t.y;Y[B+2]=t.z;Y[B+3]=t.w;Y[B+4]=v.x;Y[B+5]=v.y;Y[B+6]=v.z;Y[B+7]=v.w;Y[B+8]=D.x;Y[B+9]=D.y;Y[B+10]=D.z;Y[B+11]=D.w;B+=12}if(ga)if(o.length==3&&za)for(k=0;k<3;k++){w=o[k];U[J]=w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}else for(k=0;k<3;k++){U[J]=
+w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}if(ka&&n)for(k=0;k<3;k++){o=n[k];C[N]=o.u;C[N+1]=o.v;N+=2}if(ka&&j)for(k=0;k<3;k++){n=j[k];Q[V]=n.u;Q[V+1]=n.v;V+=2}if(oa){fa[W]=I;fa[W+1]=I+1;fa[W+2]=I+2;W+=3;aa[R]=I;aa[R+1]=I+1;aa[R+2]=I;aa[R+3]=I+2;aa[R+4]=I+1;aa[R+5]=I+2;R+=6;I+=3}}else if(k instanceof THREE.Face4){if(na){t=ea[k.a].position;v=ea[k.b].position;D=ea[k.c].position;E=ea[k.d].position;O[L]=t.x;O[L+1]=t.y;O[L+2]=t.z;O[L+3]=v.x;O[L+4]=v.y;O[L+5]=v.z;O[L+6]=D.x;O[L+7]=D.y;O[L+8]=D.z;O[L+9]=E.x;O[L+10]=
+E.y;O[L+11]=E.z;L+=12}if(pa&&Z.hasTangents){t=ea[k.a].tangent;v=ea[k.b].tangent;D=ea[k.c].tangent;k=ea[k.d].tangent;Y[B]=t.x;Y[B+1]=t.y;Y[B+2]=t.z;Y[B+3]=t.w;Y[B+4]=v.x;Y[B+5]=v.y;Y[B+6]=v.z;Y[B+7]=v.w;Y[B+8]=D.x;Y[B+9]=D.y;Y[B+10]=D.z;Y[B+11]=D.w;Y[B+12]=k.x;Y[B+13]=k.y;Y[B+14]=k.z;Y[B+15]=k.w;B+=16}if(ga)if(o.length==4&&za)for(k=0;k<4;k++){w=o[k];U[J]=w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}else for(k=0;k<4;k++){U[J]=w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}if(ka&&n)for(k=0;k<4;k++){o=n[k];C[N]=o.u;C[N+1]=o.v;N+=
+2}if(ka&&j)for(k=0;k<4;k++){n=j[k];Q[V]=n.u;Q[V+1]=n.v;V+=2}if(oa){fa[W]=I;fa[W+1]=I+1;fa[W+2]=I+2;fa[W+3]=I;fa[W+4]=I+2;fa[W+5]=I+3;W+=6;aa[R]=I;aa[R+1]=I+1;aa[R+2]=I;aa[R+3]=I+3;aa[R+4]=I+1;aa[R+5]=I+2;aa[R+6]=I+2;aa[R+7]=I+3;R+=8;I+=4}}}if(na){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,O,i)}if(ga){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,U,i)}if(pa&&Z.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,
+Y,i)}if(ka&&N>0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,C,i)}if(ka&&V>0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,Q,i)}if(oa){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,fa,i);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,aa,i)}};this.setLineBuffers=function(g,m){var i,e,j,k=g.vertices,o=k.length,w=g.__vertexArray,n=g.__lineArray,t=
+g.__dirtyElements;if(g.__dirtyVertices){for(i=0;i<o;i++){e=k[i].position;j=i*3;w[j]=e.x;w[j+1]=e.y;w[j+2]=e.z}b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,w,m)}if(t){for(i=0;i<o;i++)n[i]=i;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,n,m)}};this.setParticleBuffers=function(g,m,i,e){var j,k,o;k=g.vertices;var w=k.length,n=g.colors,t=n.length,v=g.__vertexArray,D=g.__particleArray,E=g.__colorArray,I=g.__sortArray,L=g.__dirtyVertices,
+N=g.__dirtyElements,V=g.__dirtyColors;if(i.sortParticles){K.multiply(e.projectionMatrix,e.matrix);K.multiplySelf(i.matrix);for(j=0;j<w;j++){o=k[j].position;M.copy(o);K.multiplyVector3(M);I[j]=[M.z,j]}I.sort(function(W,J){return J[0]-W[0]});for(j=0;j<w;j++){o=k[I[j][1]].position;e=j*3;v[e]=o.x;v[e+1]=o.y;v[e+2]=o.z}for(k=0;k<t;k++){e=k*3;color=n[I[k][1]];E[e]=color.r;E[e+1]=color.g;E[e+2]=color.b}}else{if(L)for(j=0;j<w;j++){o=k[j].position;e=j*3;v[e]=o.x;v[e+1]=o.y;v[e+2]=o.z}if(V)for(k=0;k<t;k++){color=
+n[k];e=k*3;E[e]=color.r;E[e+1]=color.g;E[e+2]=color.b}}if(N){for(j=0;j<w;j++)D[j]=j;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,D,m)}if(L||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v,m)}if(V||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,E,m)}};this.initMaterial=function(g,m,i){if(!g.program){var e,j;if(g instanceof THREE.MeshDepthMaterial)c(g,
+THREE.ShaderLib.depth);else if(g instanceof THREE.MeshNormalMaterial)c(g,THREE.ShaderLib.normal);else if(g instanceof THREE.MeshBasicMaterial)c(g,THREE.ShaderLib.basic);else if(g instanceof THREE.MeshLambertMaterial)c(g,THREE.ShaderLib.lambert);else if(g instanceof THREE.MeshPhongMaterial)c(g,THREE.ShaderLib.phong);else if(g instanceof THREE.LineBasicMaterial)c(g,THREE.ShaderLib.basic);else g instanceof THREE.ParticleBasicMaterial&&c(g,THREE.ShaderLib.particle_basic);var k,o,w,n;j=w=n=0;for(k=m.length;j<
+k;j++){o=m[j];o instanceof THREE.DirectionalLight&&w++;o instanceof THREE.PointLight&&n++}if(n+w<=4){m=w;n=n}else{m=Math.ceil(4*w/(n+w));n=4-m}j={directional:m,point:n};n=g.fragment_shader;m=g.vertex_shader;k={fog:i,map:g.map,env_map:g.env_map,light_map:g.light_map,vertex_colors:g.vertex_colors,maxDirLights:j.directional,maxPointLights:j.point};i=b.createProgram();j=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+k.maxDirLights,"#define MAX_POINT_LIGHTS "+k.maxPointLights,
+k.fog?"#define USE_FOG":"",k.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",k.map?"#define USE_MAP":"",k.env_map?"#define USE_ENVMAP":"",k.light_map?"#define USE_LIGHTMAP":"",k.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");k=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+k.maxDirLights,"#define MAX_POINT_LIGHTS "+k.maxPointLights,k.map?"#define USE_MAP":"",k.env_map?"#define USE_ENVMAP":
+"",k.light_map?"#define USE_LIGHTMAP":"",k.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(i,d("fragment",j+n));b.attachShader(i,d("vertex",k+m));b.linkProgram(i);b.getProgramParameter(i,b.LINK_STATUS)||
+alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(i,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");i.uniforms={};i.attributes={};g.program=i;i=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(e in g.uniforms)i.push(e);e=g.program;n=0;for(m=i.length;n<m;n++){j=i[n];e.uniforms[j]=b.getUniformLocation(e,j)}g=g.program;e=["position","normal","uv","uv2","tangent","color"];i=0;for(n=e.length;i<n;i++){m=e[i];g.attributes[m]=
+b.getAttribLocation(g,m)}}};this.setProgram=function(g,m,i,e){this.initMaterial(e,m,i);var j=e.program;if(j!=q){b.useProgram(j);q=j}this.loadCamera(j,g);this.loadMatrices(j);if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial){this.setupLights(j,m);m=this.lights;e.uniforms.enableLighting.value=m.directional.length+m.point.length;e.uniforms.ambientLightColor.value=m.ambient;e.uniforms.directionalLightColor.value=m.directional.colors;e.uniforms.directionalLightDirection.value=
+m.directional.positions;e.uniforms.pointLightColor.value=m.point.colors;e.uniforms.pointLightPosition.value=m.point.positions}if(e instanceof THREE.MeshBasicMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshPhongMaterial){e.uniforms.diffuse.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;e.uniforms.map.texture=e.map;e.uniforms.light_map.texture=e.light_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(i){e.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){e.uniforms.fogNear.value=i.near;e.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)e.uniforms.fogDensity.value=i.density}}if(e instanceof THREE.LineBasicMaterial){e.uniforms.diffuse.value.setRGB(e.color.r*e.opacity,
+e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;if(i){e.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){e.uniforms.fogNear.value=i.near;e.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)e.uniforms.fogDensity.value=i.density}}if(e instanceof THREE.ParticleBasicMaterial){e.uniforms.psColor.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;e.uniforms.size.value=e.size;e.uniforms.map.texture=
+e.map;if(i){e.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){e.uniforms.fogNear.value=i.near;e.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)e.uniforms.fogDensity.value=i.density}}if(e instanceof THREE.MeshPhongMaterial){e.uniforms.ambient.value.setRGB(e.ambient.r,e.ambient.g,e.ambient.b);e.uniforms.specular.value.setRGB(e.specular.r,e.specular.g,e.specular.b);e.uniforms.shininess.value=e.shininess}if(e instanceof THREE.MeshDepthMaterial){e.uniforms.mNear.value=
+g.near;e.uniforms.mFar.value=g.far}g=e.uniforms;var k,o;for(k in g)if(o=j.uniforms[k]){e=g[k];m=e.type;i=e.value;if(m=="i")b.uniform1i(o,i);else if(m=="f")b.uniform1f(o,i);else if(m=="fv1")b.uniform1fv(o,i);else if(m=="fv")b.uniform3fv(o,i);else if(m=="v2")b.uniform2f(o,i.x,i.y);else if(m=="v3")b.uniform3f(o,i.x,i.y,i.z);else if(m=="c")b.uniform3f(o,i.r,i.g,i.b);else if(m=="t"){b.uniform1i(o,i);if(e=e.texture)if(e.image instanceof Array&&e.image.length==6){e=e;i=i;if(e.image.length==6){if(!e.image.__webGLTextureCube&&
+!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(m=0;m<6;++m)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+
+m,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.image[m]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}else{e=e;i=i;if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,f(e.wrap_s));
+b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,f(e.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,f(e.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,f(e.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_2D,e.__webGLTexture)}}}return j};this.renderBuffer=function(g,m,i,e,j,k){g=this.setProgram(g,m,i,e,k).attributes;b.bindBuffer(b.ARRAY_BUFFER,j.__webGLVertexBuffer);b.vertexAttribPointer(g.position,
+3,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.position);if(g.color>=0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLColorBuffer);b.vertexAttribPointer(g.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.color)}if(g.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLNormalBuffer);b.vertexAttribPointer(g.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.normal)}if(g.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLTangentBuffer);b.vertexAttribPointer(g.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.tangent)}if(g.uv>=
+0)if(j.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLUVBuffer);b.vertexAttribPointer(g.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.uv)}else b.disableVertexAttribArray(g.uv);if(g.uv2>=0)if(j.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLUV2Buffer);b.vertexAttribPointer(g.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.uv2)}else b.disableVertexAttribArray(g.uv2);if(e.wireframe||e instanceof THREE.LineBasicMaterial){g=e.wireframe_linewidth!==undefined?e.wireframe_linewidth:
+e.linewidth!==undefined?e.linewidth:1;e=e instanceof THREE.LineBasicMaterial&&k.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(g);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLLineBuffer);b.drawElements(e,j.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(e instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLParticleBuffer);b.drawElements(b.POINTS,j.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,
+j.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(g,m,i,e,j,k,o){var w,n,t,v,D;t=0;for(v=e.materials.length;t<v;t++){w=e.materials[t];if(w instanceof THREE.MeshFaceMaterial){w=0;for(n=j.materials.length;w<n;w++)if((D=j.materials[w])&&D.blending==k&&D.opacity<1==o){this.setBlending(D.blending);this.renderBuffer(g,m,i,D,j,e)}}else if((D=w)&&D.blending==k&&D.opacity<1==o){this.setBlending(D.blending);this.renderBuffer(g,m,i,D,j,e)}}};this.renderPassImmediate=function(g,m,i,e,j,k){var o,
+w,n,t;o=0;for(w=e.materials.length;o<w;o++)if((n=e.materials[o])&&n.blending==j&&n.opacity<1==k){this.setBlending(n.blending);t=this.setProgram(g,m,i,n,e);e.render(function(v){var D=t;if(!v.__webGLVertexBuffer)v.__webGLVertexBuffer=b.createBuffer();if(!v.__webGLNormalBuffer)v.__webGLNormalBuffer=b.createBuffer();if(v.hasPos){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(D.attributes.position);b.vertexAttribPointer(D.attributes.position,
+3,b.FLOAT,false,0,0)}if(v.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,v.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(D.attributes.normal);b.vertexAttribPointer(D.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,v.count);v.count=0})}};this.render=function(g,m,i,e){var j,k,o,w=g.lights,n=g.fog;m.autoUpdateMatrix&&m.updateMatrix();z.set(m.matrix.flatten());u.set(m.projectionMatrix.flatten());this.initWebGLObjects(g,m);e=e!==undefined?
+e:true;if(i&&!i.__webGLFramebuffer){i.__webGLFramebuffer=b.createFramebuffer();i.__webGLRenderbuffer=b.createRenderbuffer();i.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,i.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,i.width,i.height);b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,f(i.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,f(i.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,
+f(i.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,f(i.min_filter));b.texImage2D(b.TEXTURE_2D,0,f(i.format),i.width,i.height,0,f(i.format),f(i.type),null);b.bindFramebuffer(b.FRAMEBUFFER,i.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,i.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,i.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,
+null)}if(i){j=i.__webGLFramebuffer;o=i.width;k=i.height}else{j=null;o=h.width;k=h.height}if(j!=r){b.bindFramebuffer(b.FRAMEBUFFER,j);b.viewport(0,0,o,k);e&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);r=j}this.autoClear&&this.clear();j=g.__webGLObjects.length;for(e=0;e<j;e++){k=g.__webGLObjects[e];o=k.object;if(o.visible){o.autoUpdateMatrix&&o.updateMatrix();if(o.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);o.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}}for(e=0;e<j;e++){k=g.__webGLObjects[e];
+o=k.object;k=k.buffer;if(o.visible){o.autoUpdateMatrix&&o.updateMatrix();this.setupMatrices(o,m);this.renderPass(m,w,n,o,k,THREE.NormalBlending,false)}}for(e=0;e<g.__webGLObjectsImmediate.length;e++){k=g.__webGLObjectsImmediate[e];o=k.object;if(o.visible){this.setupMatrices(o,m);this.renderPassImmediate(m,w,n,o,THREE.NormalBlending,false)}}for(e=0;e<j;e++){k=g.__webGLObjects[e];o=k.object;k=k.buffer;if(o.visible){this.setupMatrices(o,m);this.renderPass(m,w,n,o,k,THREE.AdditiveBlending,false);this.renderPass(m,
+w,n,o,k,THREE.SubtractiveBlending,false);this.renderPass(m,w,n,o,k,THREE.AdditiveBlending,true);this.renderPass(m,w,n,o,k,THREE.SubtractiveBlending,true);this.renderPass(m,w,n,o,k,THREE.NormalBlending,true);this.renderPass(m,w,n,o,k,THREE.BillboardBlending,false)}}if(i&&i.min_filter!==THREE.NearestFilter&&i.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(g,m){function i(D,
+E,I,L){if(D[E]==undefined){g.__webGLObjects.push({buffer:I,object:L});D[E]=1}}function e(D,E,I){if(D[E]==undefined){g.__webGLObjectsImmediate.push({object:I});D[E]=1}}var j,k,o,w,n,t,v;if(!g.__webGLObjects){g.__webGLObjects=[];g.__webGLObjectsMap={};g.__webGLObjectsImmediate=[]}j=0;for(k=g.objects.length;j<k;j++){o=g.objects[j];n=o.geometry;if(g.__webGLObjectsMap[o.id]==undefined)g.__webGLObjectsMap[o.id]={};v=g.__webGLObjectsMap[o.id];if(o instanceof THREE.Mesh){for(w in n.geometryChunks){t=n.geometryChunks[w];
+if(!t.__webGLVertexBuffer){this.createMeshBuffers(t);this.initMeshBuffers(t,o);n.__dirtyVertices=true;n.__dirtyElements=true;n.__dirtyUvs=true;n.__dirtyNormals=true;n.__dirtyTangents=true}if(n.__dirtyVertices||n.__dirtyElements||n.__dirtyUvs)this.setMeshBuffers(t,o,b.DYNAMIC_DRAW);i(v,w,t,o)}n.__dirtyVertices=false;n.__dirtyElements=false;n.__dirtyUvs=false;n.__dirtyNormals=false;n.__dirtyTangents=false}else if(o instanceof THREE.Line){if(!n.__webGLVertexBuffer){this.createLineBuffers(n);this.initLineBuffers(n);
+n.__dirtyVertices=true;n.__dirtyElements=true}n.__dirtyVertices&&this.setLineBuffers(n,b.DYNAMIC_DRAW);i(v,0,n,o);n.__dirtyVertices=false;n.__dirtyElements=false}else if(o instanceof THREE.ParticleSystem){if(!n.__webGLVertexBuffer){this.createParticleBuffers(n);this.initParticleBuffers(n);n.__dirtyVertices=true;n.__dirtyColors=true;n.__dirtyElements=true}if(n.__dirtyVertices||n.__dirtyColors||o.sortParticles)this.setParticleBuffers(n,b.DYNAMIC_DRAW,o,m);i(v,0,n,o);n.__dirtyVertices=false;n.__dirtyColors=
+false;n.__dirtyElements=false}else o instanceof THREE.MarchingCubes&&e(v,0,o)}};this.removeObject=function(g,m){var i,e;for(i=g.__webGLObjects.length-1;i>=0;i--){e=g.__webGLObjects[i].object;m==e&&g.__webGLObjects.splice(i,1)}};this.setupMatrices=function(g,m){l.multiply(m.matrix,g.matrix);y.set(l.flatten());p=THREE.Matrix4.makeInvert3x3(l).transpose();x.set(p.m);H.set(g.matrix.flatten())};this.loadMatrices=function(g){b.uniformMatrix4fv(g.uniforms.viewMatrix,false,z);b.uniformMatrix4fv(g.uniforms.modelViewMatrix,
+false,y);b.uniformMatrix4fv(g.uniforms.projectionMatrix,false,u);b.uniformMatrix3fv(g.uniforms.normalMatrix,false,x);b.uniformMatrix4fv(g.uniforms.objectMatrix,false,H)};this.loadCamera=function(g,m){b.uniform3f(g.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(g){switch(g){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);
+b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(g,m){if(g){!m||m=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(g=="back")b.cullFace(b.BACK);else g=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
+THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
+envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",
+envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
+map_particle_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",
+lightmap_fragment:"#ifdef USE_LIGHTMAP\nlightmapColor = texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
 lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
 lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse  = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse  += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse  = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse  += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif",
 color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\nvertexColor = vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif"};

+ 144 - 141
build/ThreeDebug.js

@@ -1,66 +1,66 @@
 // ThreeDebug.js r32 - 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,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var e,h,b,q,r,l;if(d==0)e=h=b=0;else{q=Math.floor(a*6);r=a*6-q;a=d*(1-c);l=d*(1-c*r);c=d*(1-c*(1-r));switch(q){case 1:e=l;h=d;b=a;break;case 2:e=a;h=d;b=c;break;case 3:e=a;h=l;b=d;break;case 4:e=c;h=a;b=d;break;case 5:e=d;h=a;b=l;break;case 6:case 0:e=d;h=c;b=a}}this.r=e;this.g=h;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
+THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var f,h,b,q,r,l;if(d==0)f=h=b=0;else{q=Math.floor(a*6);r=a*6-q;a=d*(1-c);l=d*(1-c*r);c=d*(1-c*(1-r));switch(q){case 1:f=l;h=d;b=a;break;case 2:f=a;h=d;b=c;break;case 3:f=a;h=l;b=d;break;case 4:f=c;h=a;b=d;break;case 5:f=d;h=a;b=l;break;case 6:case 0:f=d;h=c;b=a}}this.r=f;this.g=h;this.b=b;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,c){this.x=a||0;this.y=c||0};
 THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;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,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.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,c,d){this.x=a||0;this.y=c||0;this.z=d||0};
 THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
-cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
+cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,f=this.z;this.x=d*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
 a.z;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 c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+d*d+a*a)},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+d*d+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,c,d,e){this.x=a||0;this.y=c||0;this.z=d||0;this.w=e||1};
-THREE.Vector4.prototype={set:function(a,c,d,e){this.x=a;this.y=c;this.z=d;this.w=e;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.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,c,d,f){this.x=a||0;this.y=c||0;this.z=d||0;this.w=f||1};
+THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;this.z=d;this.w=f;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.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,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},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,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,h=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)h=h.concat(this.intersectObject(d))}h.sort(function(b,q){return b.distance-q.distance});return h},intersectObject:function(a){function c(L,t,T,E){E=E.clone().subSelf(t);T=T.clone().subSelf(t);var f=L.clone().subSelf(t);L=E.dot(E);t=E.dot(T);E=E.dot(f);var k=T.dot(T);T=T.dot(f);f=1/(L*k-t*t);k=(k*E-t*T)*f;L=(L*T-t*E)*f;return k>0&&L>0&&k+L<1}var d,e,h,b,q,r,l,m,y,x,
-v,w=a.geometry,G=w.vertices,K=[];d=0;for(e=w.faces.length;d<e;d++){h=w.faces[d];x=this.origin.clone();v=this.direction.clone();b=a.matrix.multiplyVector3(G[h.a].position.clone());q=a.matrix.multiplyVector3(G[h.b].position.clone());r=a.matrix.multiplyVector3(G[h.c].position.clone());l=h instanceof THREE.Face4?a.matrix.multiplyVector3(G[h.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(h.normal.clone());y=v.dot(m);if(y<0){m=m.dot((new THREE.Vector3).sub(b,x))/y;x=x.addSelf(v.multiplyScalar(m));
-if(h instanceof THREE.Face3){if(c(x,b,q,r)){h={distance:this.origin.distanceTo(x),point:x,face:h,object:a};K.push(h)}}else if(h instanceof THREE.Face4)if(c(x,b,q,l)||c(x,q,r,l)){h={distance:this.origin.distanceTo(x),point:x,face:h,object:a};K.push(h)}}}return K}};
-THREE.Rectangle=function(){function a(){b=e-c;q=h-d}var c,d,e,h,b,q,r=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return b};this.getHeight=function(){return q};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return h};this.set=function(l,m,y,x){r=false;c=l;d=m;e=y;h=x;a()};this.addPoint=function(l,m){if(r){r=false;c=l;d=m;e=l;h=m}else{c=c<l?c:l;d=d<m?d:m;e=e>l?e:l;h=h>m?
-h:m}a()};this.add3Points=function(l,m,y,x,v,w){if(r){r=false;c=l<y?l<v?l:v:y<v?y:v;d=m<x?m<w?m:w:x<w?x:w;e=l>y?l>v?l:v:y>v?y:v;h=m>x?m>w?m:w:x>w?x:w}else{c=l<y?l<v?l<c?l:c:v<c?v:c:y<v?y<c?y:c:v<c?v:c;d=m<x?m<w?m<d?m:d:w<d?w:d:x<w?x<d?x:d:w<d?w:d;e=l>y?l>v?l>e?l:e:v>e?v:e:y>v?y>e?y:e:v>e?v:e;h=m>x?m>w?m>h?m:h:w>h?w:h:x>w?x>h?x:h:w>h?w:h}a()};this.addRectangle=function(l){if(r){r=false;c=l.getLeft();d=l.getTop();e=l.getRight();h=l.getBottom()}else{c=c<l.getLeft()?c:l.getLeft();d=d<l.getTop()?d:l.getTop();
-e=e>l.getRight()?e:l.getRight();h=h>l.getBottom()?h:l.getBottom()}a()};this.inflate=function(l){c-=l;d-=l;e+=l;h+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();d=d>l.getTop()?d:l.getTop();e=e<l.getRight()?e:l.getRight();h=h<l.getBottom()?h:l.getBottom();a()};this.instersects=function(l){return Math.min(e,l.getRight())-Math.max(c,l.getLeft())>=0&&Math.min(h,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){r=true;h=e=d=c=0;a()};this.isEmpty=function(){return r};this.toString=
-function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+h+", width: "+b+", height: "+q+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this}};
-THREE.Matrix4=function(a,c,d,e,h,b,q,r,l,m,y,x,v,w,G,K){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=h||0;this.n22=b||1;this.n23=q||0;this.n24=r||0;this.n31=l||0;this.n32=m||0;this.n33=y||1;this.n34=x||0;this.n41=v||0;this.n42=w||0;this.n43=G||0;this.n44=K||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
-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,c,d,e,h,b,q,r,l,m,y,x,v,w,G,K){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=h;this.n22=b;this.n23=q;this.n24=r;this.n31=l;this.n32=m;this.n33=y;this.n34=x;this.n41=v;this.n42=w;this.n43=G;this.n44=K;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,c,d){var e=THREE.Matrix4.__tmpVec1,h=THREE.Matrix4.__tmpVec2,b=THREE.Matrix4.__tmpVec3;b.sub(a,c).normalize();e.cross(d,b).normalize();h.cross(b,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);
-this.n31=b.x;this.n32=b.y;this.n33=b.z;this.n34=-b.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,e=a.z,h=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*h;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*h;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*h;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,h=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*h;a.y=this.n21*c+this.n22*d+this.n23*
-e+this.n24*h;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*h;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*h;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,e=a.n12,h=a.n13,b=a.n14,q=a.n21,r=a.n22,l=a.n23,m=a.n24,y=a.n31,
-x=a.n32,v=a.n33,w=a.n34,G=a.n41,K=a.n42,L=a.n43,t=a.n44,T=c.n11,E=c.n12,f=c.n13,k=c.n14,i=c.n21,g=c.n22,n=c.n23,j=c.n24,o=c.n31,p=c.n32,s=c.n33,u=c.n34,z=c.n41,H=c.n42,F=c.n43,I=c.n44;this.n11=d*T+e*i+h*o+b*z;this.n12=d*E+e*g+h*p+b*H;this.n13=d*f+e*n+h*s+b*F;this.n14=d*k+e*j+h*u+b*I;this.n21=q*T+r*i+l*o+m*z;this.n22=q*E+r*g+l*p+m*H;this.n23=q*f+r*n+l*s+m*F;this.n24=q*k+r*j+l*u+m*I;this.n31=y*T+x*i+v*o+w*z;this.n32=y*E+x*g+v*p+w*H;this.n33=y*f+x*n+v*s+w*F;this.n34=y*k+x*j+v*u+w*I;this.n41=G*T+K*i+
-L*o+t*z;this.n42=G*E+K*g+L*p+t*H;this.n43=G*f+K*n+L*s+t*F;this.n44=G*k+K*j+L*u+t*I;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,h=this.n14,b=this.n21,q=this.n22,r=this.n23,l=this.n24,m=this.n31,y=this.n32,x=this.n33,v=this.n34,w=this.n41,G=this.n42,K=this.n43,L=this.n44,t=a.n11,T=a.n21,E=a.n31,f=a.n41,k=a.n12,i=a.n22,g=a.n32,n=a.n42,j=a.n13,o=a.n23,p=a.n33,s=a.n43,u=a.n14,z=a.n24,H=a.n34;a=a.n44;this.n11=c*t+d*T+e*E+h*f;this.n12=c*k+d*i+e*g+h*n;this.n13=c*j+d*o+e*p+h*
-s;this.n14=c*u+d*z+e*H+h*a;this.n21=b*t+q*T+r*E+l*f;this.n22=b*k+q*i+r*g+l*n;this.n23=b*j+q*o+r*p+l*s;this.n24=b*u+q*z+r*H+l*a;this.n31=m*t+y*T+x*E+v*f;this.n32=m*k+y*i+x*g+v*n;this.n33=m*j+y*o+x*p+v*s;this.n34=m*u+y*z+x*H+v*a;this.n41=w*t+G*T+K*E+L*f;this.n42=w*k+G*i+K*g+L*n;this.n43=w*j+G*o+K*p+L*s;this.n44=w*u+G*z+K*H+L*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=
-a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,c=this.n12,d=this.n13,e=this.n14,h=this.n21,b=this.n22,q=this.n23,r=this.n24,l=this.n31,m=this.n32,y=this.n33,x=this.n34,v=this.n41,w=this.n42,G=this.n43,K=this.n44;return e*q*m*v-d*r*m*v-e*b*y*v+c*r*y*v+d*b*x*v-c*q*x*v-e*q*l*w+d*r*l*w+e*h*y*w-a*r*y*w-d*h*x*w+a*q*x*w+e*b*l*G-c*r*l*G-e*h*m*G+a*r*m*G+c*h*x*G-a*b*x*G-d*b*l*K+c*q*l*K+d*h*m*K-a*q*m*K-c*h*y*K+a*b*y*K},transpose:function(){function a(c,d,
-e){var h=c[d];c[d]=c[e];c[e]=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(){var a=this.flat;a[0]=this.n11;
+THREE.Ray.prototype={intersectScene:function(a){var c,d,f=a.objects,h=[];a=0;for(c=f.length;a<c;a++){d=f[a];if(d instanceof THREE.Mesh)h=h.concat(this.intersectObject(d))}h.sort(function(b,q){return b.distance-q.distance});return h},intersectObject:function(a){function c(M,s,T,G){G=G.clone().subSelf(s);T=T.clone().subSelf(s);var g=M.clone().subSelf(s);M=G.dot(G);s=G.dot(T);G=G.dot(g);var n=T.dot(T);T=T.dot(g);g=1/(M*n-s*s);n=(n*G-s*T)*g;M=(M*T-s*G)*g;return n>0&&M>0&&n+M<1}var d,f,h,b,q,r,l,m,z,y,
+u,x=a.geometry,H=x.vertices,K=[];d=0;for(f=x.faces.length;d<f;d++){h=x.faces[d];y=this.origin.clone();u=this.direction.clone();b=a.matrix.multiplyVector3(H[h.a].position.clone());q=a.matrix.multiplyVector3(H[h.b].position.clone());r=a.matrix.multiplyVector3(H[h.c].position.clone());l=h instanceof THREE.Face4?a.matrix.multiplyVector3(H[h.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(h.normal.clone());z=u.dot(m);if(z<0){m=m.dot((new THREE.Vector3).sub(b,y))/z;y=y.addSelf(u.multiplyScalar(m));
+if(h instanceof THREE.Face3){if(c(y,b,q,r)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};K.push(h)}}else if(h instanceof THREE.Face4)if(c(y,b,q,l)||c(y,q,r,l)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};K.push(h)}}}return K}};
+THREE.Rectangle=function(){function a(){b=f-c;q=h-d}var c,d,f,h,b,q,r=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return b};this.getHeight=function(){return q};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(l,m,z,y){r=false;c=l;d=m;f=z;h=y;a()};this.addPoint=function(l,m){if(r){r=false;c=l;d=m;f=l;h=m}else{c=c<l?c:l;d=d<m?d:m;f=f>l?f:l;h=h>m?
+h:m}a()};this.add3Points=function(l,m,z,y,u,x){if(r){r=false;c=l<z?l<u?l:u:z<u?z:u;d=m<y?m<x?m:x:y<x?y:x;f=l>z?l>u?l:u:z>u?z:u;h=m>y?m>x?m:x:y>x?y:x}else{c=l<z?l<u?l<c?l:c:u<c?u:c:z<u?z<c?z:c:u<c?u:c;d=m<y?m<x?m<d?m:d:x<d?x:d:y<x?y<d?y:d:x<d?x:d;f=l>z?l>u?l>f?l:f:u>f?u:f:z>u?z>f?z:f:u>f?u:f;h=m>y?m>x?m>h?m:h:x>h?x:h:y>x?y>h?y:h:x>h?x:h}a()};this.addRectangle=function(l){if(r){r=false;c=l.getLeft();d=l.getTop();f=l.getRight();h=l.getBottom()}else{c=c<l.getLeft()?c:l.getLeft();d=d<l.getTop()?d:l.getTop();
+f=f>l.getRight()?f:l.getRight();h=h>l.getBottom()?h:l.getBottom()}a()};this.inflate=function(l){c-=l;d-=l;f+=l;h+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();d=d>l.getTop()?d:l.getTop();f=f<l.getRight()?f:l.getRight();h=h<l.getBottom()?h:l.getBottom();a()};this.instersects=function(l){return Math.min(f,l.getRight())-Math.max(c,l.getLeft())>=0&&Math.min(h,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){r=true;h=f=d=c=0;a()};this.isEmpty=function(){return r};this.toString=
+function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+h+", width: "+b+", height: "+q+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this}};
+THREE.Matrix4=function(a,c,d,f,h,b,q,r,l,m,z,y,u,x,H,K){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=h||0;this.n22=b||1;this.n23=q||0;this.n24=r||0;this.n31=l||0;this.n32=m||0;this.n33=z||1;this.n34=y||0;this.n41=u||0;this.n42=x||0;this.n43=H||0;this.n44=K||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
+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,c,d,f,h,b,q,r,l,m,z,y,u,x,H,K){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=h;this.n22=b;this.n23=q;this.n24=r;this.n31=l;this.n32=m;this.n33=z;this.n34=y;this.n41=u;this.n42=x;this.n43=H;this.n44=K;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,c,d){var f=THREE.Matrix4.__tmpVec1,h=THREE.Matrix4.__tmpVec2,b=THREE.Matrix4.__tmpVec3;b.sub(a,c).normalize();f.cross(d,b).normalize();h.cross(b,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);
+this.n31=b.x;this.n32=b.y;this.n33=b.z;this.n34=-b.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,h=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*h;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*h;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*h;return a},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,h=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*h;a.y=this.n21*c+this.n22*d+this.n23*
+f+this.n24*h;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*h;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*h;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,f=a.n12,h=a.n13,b=a.n14,q=a.n21,r=a.n22,l=a.n23,m=a.n24,z=a.n31,
+y=a.n32,u=a.n33,x=a.n34,H=a.n41,K=a.n42,M=a.n43,s=a.n44,T=c.n11,G=c.n12,g=c.n13,n=c.n14,i=c.n21,e=c.n22,j=c.n23,k=c.n24,p=c.n31,w=c.n32,o=c.n33,t=c.n34,v=c.n41,D=c.n42,E=c.n43,I=c.n44;this.n11=d*T+f*i+h*p+b*v;this.n12=d*G+f*e+h*w+b*D;this.n13=d*g+f*j+h*o+b*E;this.n14=d*n+f*k+h*t+b*I;this.n21=q*T+r*i+l*p+m*v;this.n22=q*G+r*e+l*w+m*D;this.n23=q*g+r*j+l*o+m*E;this.n24=q*n+r*k+l*t+m*I;this.n31=z*T+y*i+u*p+x*v;this.n32=z*G+y*e+u*w+x*D;this.n33=z*g+y*j+u*o+x*E;this.n34=z*n+y*k+u*t+x*I;this.n41=H*T+K*i+
+M*p+s*v;this.n42=H*G+K*e+M*w+s*D;this.n43=H*g+K*j+M*o+s*E;this.n44=H*n+K*k+M*t+s*I;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,h=this.n14,b=this.n21,q=this.n22,r=this.n23,l=this.n24,m=this.n31,z=this.n32,y=this.n33,u=this.n34,x=this.n41,H=this.n42,K=this.n43,M=this.n44,s=a.n11,T=a.n21,G=a.n31,g=a.n41,n=a.n12,i=a.n22,e=a.n32,j=a.n42,k=a.n13,p=a.n23,w=a.n33,o=a.n43,t=a.n14,v=a.n24,D=a.n34;a=a.n44;this.n11=c*s+d*T+f*G+h*g;this.n12=c*n+d*i+f*e+h*j;this.n13=c*k+d*p+f*w+h*
+o;this.n14=c*t+d*v+f*D+h*a;this.n21=b*s+q*T+r*G+l*g;this.n22=b*n+q*i+r*e+l*j;this.n23=b*k+q*p+r*w+l*o;this.n24=b*t+q*v+r*D+l*a;this.n31=m*s+z*T+y*G+u*g;this.n32=m*n+z*i+y*e+u*j;this.n33=m*k+z*p+y*w+u*o;this.n34=m*t+z*v+y*D+u*a;this.n41=x*s+H*T+K*G+M*g;this.n42=x*n+H*i+K*e+M*j;this.n43=x*k+H*p+K*w+M*o;this.n44=x*t+H*v+K*D+M*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=
+a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,c=this.n12,d=this.n13,f=this.n14,h=this.n21,b=this.n22,q=this.n23,r=this.n24,l=this.n31,m=this.n32,z=this.n33,y=this.n34,u=this.n41,x=this.n42,H=this.n43,K=this.n44;return f*q*m*u-d*r*m*u-f*b*z*u+c*r*z*u+d*b*y*u-c*q*y*u-f*q*l*x+d*r*l*x+f*h*z*x-a*r*z*x-d*h*y*x+a*q*y*x+f*b*l*H-c*r*l*H-f*h*m*H+a*r*m*H+c*h*y*H-a*b*y*H-d*b*l*K+c*q*l*K+d*h*m*K-a*q*m*K-c*h*z*K+a*b*z*K},transpose:function(){function a(c,d,
+f){var h=c[d];c[d]=c[f];c[f]=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(){var a=this.flat;a[0]=this.n11;
 a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=
-Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),h=1-d,b=a.x,q=a.y,r=a.z,l=h*b,m=h*q;this.set(l*b+d,l*q-e*r,l*r+e*q,0,l*q+e*r,m*q+d,m*r-e*b,0,l*r-e*q,m*r+e*b,h*r*r+d,0,0,0,0,1);return this},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,c,d){var e=new THREE.Matrix4;e.setTranslation(a,c,d);return e};THREE.Matrix4.scaleMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setScale(a,c,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};
+Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),f=Math.sin(c),h=1-d,b=a.x,q=a.y,r=a.z,l=h*b,m=h*q;this.set(l*b+d,l*q-f*r,l*r+f*q,0,l*q+f*r,m*q+d,m*r-f*b,0,l*r-f*q,m*r+f*b,h*r*r+d,0,0,0,0,1);return this},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,c,d){var f=new THREE.Matrix4;f.setTranslation(a,c,d);return f};THREE.Matrix4.scaleMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setScale(a,c,d);return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};
 THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
-THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,h=a.n14,b=a.n21,q=a.n22,r=a.n23,l=a.n24,m=a.n31,y=a.n32,x=a.n33,v=a.n34,w=a.n41,G=a.n42,K=a.n43,L=a.n44,t=new THREE.Matrix4;t.n11=r*v*G-l*x*G+l*y*K-q*v*K-r*y*L+q*x*L;t.n12=h*x*G-e*v*G-h*y*K+d*v*K+e*y*L-d*x*L;t.n13=e*l*G-h*r*G+h*q*K-d*l*K-e*q*L+d*r*L;t.n14=h*r*y-e*l*y-h*q*x+d*l*x+e*q*v-d*r*v;t.n21=l*x*w-r*v*w-l*m*K+b*v*K+r*m*L-b*x*L;t.n22=e*v*w-h*x*w+h*m*K-c*v*K-e*m*L+c*x*L;t.n23=h*r*w-e*l*w-h*b*K+c*l*K+e*b*L-c*r*L;t.n24=e*l*m-h*r*m+
-h*b*x-c*l*x-e*b*v+c*r*v;t.n31=q*v*w-l*y*w+l*m*G-b*v*G-q*m*L+b*y*L;t.n32=h*y*w-d*v*w-h*m*G+c*v*G+d*m*L-c*y*L;t.n33=e*l*w-h*q*w+h*b*G-c*l*G-d*b*L+c*q*L;t.n34=h*q*m-d*l*m-h*b*y+c*l*y+d*b*v-c*q*v;t.n41=r*y*w-q*x*w-r*m*G+b*x*G+q*m*K-b*y*K;t.n42=d*x*w-e*y*w+e*m*G-c*x*G-d*m*K+c*y*K;t.n43=e*q*w-d*r*w-e*b*G+c*r*G+d*b*K-c*q*K;t.n44=d*r*m-e*q*m+e*b*y-c*r*y-d*b*x+c*q*x;t.multiplyScalar(1/a.determinant());return t};
-THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],h=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],q=-c[10]*c[4]+c[6]*c[8],r=c[10]*c[0]-c[2]*c[8],l=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],y=-c[9]*c[0]+c[1]*c[8],x=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*q+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*h;d[2]=c*b;d[3]=c*q;d[4]=c*r;d[5]=c*l;d[6]=c*m;d[7]=c*y;d[8]=c*x;return a};
-THREE.Matrix4.makeFrustum=function(a,c,d,e,h,b){var q,r,l;q=new THREE.Matrix4;r=2*h/(c-a);l=2*h/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(b+h)/(b-h);h=-2*b*h/(b-h);q.n11=r;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=d;q.n24=0;q.n31=0;q.n32=0;q.n33=e;q.n34=h;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,d,e){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*c,a*c,h,a,d,e)};
-THREE.Matrix4.makeOrtho=function(a,c,d,e,h,b){var q,r,l,m;q=new THREE.Matrix4;r=c-a;l=d-e;m=b-h;a=(c+a)/r;d=(d+e)/l;h=(b+h)/m;q.n11=2/r;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-d;q.n31=0;q.n32=0;q.n33=-2/m;q.n34=-h;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
+THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,f=a.n13,h=a.n14,b=a.n21,q=a.n22,r=a.n23,l=a.n24,m=a.n31,z=a.n32,y=a.n33,u=a.n34,x=a.n41,H=a.n42,K=a.n43,M=a.n44,s=new THREE.Matrix4;s.n11=r*u*H-l*y*H+l*z*K-q*u*K-r*z*M+q*y*M;s.n12=h*y*H-f*u*H-h*z*K+d*u*K+f*z*M-d*y*M;s.n13=f*l*H-h*r*H+h*q*K-d*l*K-f*q*M+d*r*M;s.n14=h*r*z-f*l*z-h*q*y+d*l*y+f*q*u-d*r*u;s.n21=l*y*x-r*u*x-l*m*K+b*u*K+r*m*M-b*y*M;s.n22=f*u*x-h*y*x+h*m*K-c*u*K-f*m*M+c*y*M;s.n23=h*r*x-f*l*x-h*b*K+c*l*K+f*b*M-c*r*M;s.n24=f*l*m-h*r*m+
+h*b*y-c*l*y-f*b*u+c*r*u;s.n31=q*u*x-l*z*x+l*m*H-b*u*H-q*m*M+b*z*M;s.n32=h*z*x-d*u*x-h*m*H+c*u*H+d*m*M-c*z*M;s.n33=f*l*x-h*q*x+h*b*H-c*l*H-d*b*M+c*q*M;s.n34=h*q*m-d*l*m-h*b*z+c*l*z+d*b*u-c*q*u;s.n41=r*z*x-q*y*x-r*m*H+b*y*H+q*m*K-b*z*K;s.n42=d*y*x-f*z*x+f*m*H-c*y*H-d*m*K+c*z*K;s.n43=f*q*x-d*r*x-f*b*H+c*r*H+d*b*K-c*q*K;s.n44=d*r*m-f*q*m+f*b*z-c*r*z-d*b*y+c*q*y;s.multiplyScalar(1/a.determinant());return s};
+THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,f=c[10]*c[5]-c[6]*c[9],h=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],q=-c[10]*c[4]+c[6]*c[8],r=c[10]*c[0]-c[2]*c[8],l=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],z=-c[9]*c[0]+c[1]*c[8],y=c[5]*c[0]-c[1]*c[4];c=c[0]*f+c[1]*q+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*f;d[1]=c*h;d[2]=c*b;d[3]=c*q;d[4]=c*r;d[5]=c*l;d[6]=c*m;d[7]=c*z;d[8]=c*y;return a};
+THREE.Matrix4.makeFrustum=function(a,c,d,f,h,b){var q,r,l;q=new THREE.Matrix4;r=2*h/(c-a);l=2*h/(f-d);a=(c+a)/(c-a);d=(f+d)/(f-d);f=-(b+h)/(b-h);h=-2*b*h/(b-h);q.n11=r;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=d;q.n24=0;q.n31=0;q.n32=0;q.n33=f;q.n34=h;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,d,f){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*c,a*c,h,a,d,f)};
+THREE.Matrix4.makeOrtho=function(a,c,d,f,h,b){var q,r,l,m;q=new THREE.Matrix4;r=c-a;l=d-f;m=b-h;a=(c+a)/r;d=(d+f)/l;h=(b+h)/m;q.n11=2/r;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-d;q.n31=0;q.n32=0;q.n33=-2/m;q.n34=-h;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||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,c,d,e,h){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];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,c,d,e,h,b){this.a=a;this.b=c;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=b instanceof Array?b:[b]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
+THREE.Face3=function(a,c,d,f,h){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];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,c,d,f,h,b){this.a=a;this.b=c;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=b instanceof Array?b:[b]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||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.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
 THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
-d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,e,h,b,q,r=new THREE.Vector3,l=new THREE.Vector3;e=0;for(h=this.vertices.length;e<h;e++){b=this.vertices[e];b.normal.set(0,0,0)}e=0;for(h=this.faces.length;e<h;e++){b=this.faces[e];if(a&&b.vertexNormals.length){r.set(0,0,0);c=0;for(d=b.normal.length;c<d;c++)r.addSelf(b.vertexNormals[c]);r.divideScalar(3)}else{c=this.vertices[b.a];d=this.vertices[b.b];q=this.vertices[b.c];r.sub(q.position,
-d.position);l.sub(c.position,d.position);r.crossSelf(l)}r.isZero()||r.normalize();b.normal.copy(r)}},computeVertexNormals:function(){var a,c,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)e[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
-new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)e[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal);e[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)e[a].normalize();a=0;for(c=this.faces.length;a<
-c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(u,z,H,F,I,M,N){b=u.vertices[z].position;q=u.vertices[H].position;r=u.vertices[F].position;l=h[I];m=h[M];y=h[N];x=q.x-b.x;v=r.x-b.x;w=q.y-b.y;G=r.y-b.y;
-K=q.z-b.z;L=r.z-b.z;t=m.u-l.u;T=y.u-l.u;E=m.v-l.v;f=y.v-l.v;k=1/(t*f-T*E);n.set((f*x-E*v)*k,(f*w-E*G)*k,(f*K-E*L)*k);j.set((t*v-T*x)*k,(t*G-T*w)*k,(t*L-T*K)*k);i[z].addSelf(n);i[H].addSelf(n);i[F].addSelf(n);g[z].addSelf(j);g[H].addSelf(j);g[F].addSelf(j)}var c,d,e,h,b,q,r,l,m,y,x,v,w,G,K,L,t,T,E,f,k,i=[],g=[],n=new THREE.Vector3,j=new THREE.Vector3,o=new THREE.Vector3,p=new THREE.Vector3,s=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){i[c]=new THREE.Vector3;g[c]=new THREE.Vector3}c=0;
-for(d=this.faces.length;c<d;c++){e=this.faces[c];h=this.uvs[c];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
-this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){s.copy(this.vertices[c].normal);e=i[c];o.copy(e);o.subSelf(s.multiplyScalar(s.dot(e))).normalize();p.cross(this.vertices[c].normal,e);e=p.dot(g[c]);e=e<0?-1:1;this.vertices[c].tangent.set(o.x,o.y,o.z,e)}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],
+d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,f,h,b,q,r=new THREE.Vector3,l=new THREE.Vector3;f=0;for(h=this.vertices.length;f<h;f++){b=this.vertices[f];b.normal.set(0,0,0)}f=0;for(h=this.faces.length;f<h;f++){b=this.faces[f];if(a&&b.vertexNormals.length){r.set(0,0,0);c=0;for(d=b.normal.length;c<d;c++)r.addSelf(b.vertexNormals[c]);r.divideScalar(3)}else{c=this.vertices[b.a];d=this.vertices[b.b];q=this.vertices[b.c];r.sub(q.position,
+d.position);l.sub(c.position,d.position);r.crossSelf(l)}r.isZero()||r.normalize();b.normal.copy(r)}},computeVertexNormals:function(){var a,c,d,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
+new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal);f[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
+c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c]);d.vertexNormals[3].copy(f[d.d])}}},computeTangents:function(){function a(t,v,D,E,I,L,N){b=t.vertices[v].position;q=t.vertices[D].position;r=t.vertices[E].position;l=h[I];m=h[L];z=h[N];y=q.x-b.x;u=r.x-b.x;x=q.y-b.y;H=r.y-b.y;
+K=q.z-b.z;M=r.z-b.z;s=m.u-l.u;T=z.u-l.u;G=m.v-l.v;g=z.v-l.v;n=1/(s*g-T*G);j.set((g*y-G*u)*n,(g*x-G*H)*n,(g*K-G*M)*n);k.set((s*u-T*y)*n,(s*H-T*x)*n,(s*M-T*K)*n);i[v].addSelf(j);i[D].addSelf(j);i[E].addSelf(j);e[v].addSelf(k);e[D].addSelf(k);e[E].addSelf(k)}var c,d,f,h,b,q,r,l,m,z,y,u,x,H,K,M,s,T,G,g,n,i=[],e=[],j=new THREE.Vector3,k=new THREE.Vector3,p=new THREE.Vector3,w=new THREE.Vector3,o=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){i[c]=new THREE.Vector3;e[c]=new THREE.Vector3}c=0;
+for(d=this.faces.length;c<d;c++){f=this.faces[c];h=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
+this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){o.copy(this.vertices[c].normal);f=i[c];p.copy(f);p.subSelf(o.multiplyScalar(o.dot(f))).normalize();w.cross(this.vertices[c].normal,f);f=w.dot(e[c]);f=f<0?-1:1;this.vertices[c].tangent.set(p.x,p.y,p.z,f)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
 z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
-this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(y){var x=[];c=0;for(d=y.length;c<d;c++)y[c]==undefined?x.push("undefined"):x.push(y[c].toString());return x.join("_")}var c,d,e,h,b,q,r,l,m={};e=0;for(h=this.faces.length;e<h;e++){b=this.faces[e];
-q=b.materials;r=a(q);if(m[r]==undefined)m[r]={hash:r,counter:0};l=m[r].hash+"_"+m[r].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0};b=b instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+b>65535){m[r].counter+=1;l=m[r].hash+"_"+m[r].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(e);this.geometryChunks[l].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+
+this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(z){var y=[];c=0;for(d=z.length;c<d;c++)z[c]==undefined?y.push("undefined"):y.push(z[c].toString());return y.join("_")}var c,d,f,h,b,q,r,l,m={};f=0;for(h=this.faces.length;f<h;f++){b=this.faces[f];
+q=b.materials;r=a(q);if(m[r]==undefined)m[r]={hash:r,counter:0};l=m[r].hash+"_"+m[r].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0};b=b instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+b>65535){m[r].counter+=1;l=m[r].hash+"_"+m[r].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(f);this.geometryChunks[l].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+
 this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
-THREE.Camera=function(a,c,d,e){this.fov=a;this.aspect=c;this.near=d;this.far=e;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.tmpVec=new THREE.Vector3;this.translateX=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
+THREE.Camera=function(a,c,d,f){this.fov=a;this.aspect=c;this.near=d;this.far=f;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.tmpVec=new THREE.Vector3;this.translateX=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
 this.translateZ=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};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,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;
 THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.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.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
-THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,e=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){e.setRotY(c.y);this.rotationMatrix.multiplySelf(e)}if(c.z!=0){e.setRotZ(c.z);this.rotationMatrix.multiplySelf(e)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){e.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(e)}}};THREE.Object3DCounter={value:0};
+THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,f=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){f.setRotY(c.y);this.rotationMatrix.multiplySelf(f)}if(c.z!=0){f.setRotZ(c.z);this.rotationMatrix.multiplySelf(f)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){f.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(f)}}};THREE.Object3DCounter={value:0};
 THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
 THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
 THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;
@@ -90,113 +90,116 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM
 THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.size=this.opacity=1;this.vertex_colors=false;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.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
 THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>size: "+this.size+"<br/>blending: "+this.blending+"<br/>vertex_colors: "+this.vertex_colors+"<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,c,d,e,h,b){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=b!==undefined?b:THREE.LinearMipMapLinearFilter};
+THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,f,h,b){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=b!==undefined?b: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;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
 THREE.RenderTarget=function(a,c,d){this.width=a;this.height=c;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType};
-var Uniforms={clone:function(a){var c,d,e,h={};for(c in a){h[c]={};for(d in a[c]){e=a[c][d];h[c][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return h},merge:function(a){var c,d,e,h={};for(c=0;c<a.length;c++){e=this.clone(a[c]);for(d in e)h[d]=e[d]}return h}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
+var Uniforms={clone:function(a){var c,d,f,h={};for(c in a){h[c]={};for(d in a[c]){f=a[c][d];h[c][d]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return h},merge:function(a){var c,d,f,h={};for(c=0;c<a.length;c++){f=this.clone(a[c]);for(d in f)h[d]=f[d]}return h}};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,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
-THREE.Projector=function(){function a(g,n){return n.z-g.z}function c(g,n){var j=0,o=1,p=g.z+g.w,s=n.z+n.w,u=-g.z+g.w,z=-n.z+n.w;if(p>=0&&s>=0&&u>=0&&z>=0)return true;else if(p<0&&s<0||u<0&&z<0)return false;else{if(p<0)j=Math.max(j,p/(p-s));else if(s<0)o=Math.min(o,p/(p-s));if(u<0)j=Math.max(j,u/(u-z));else if(z<0)o=Math.min(o,u/(u-z));if(o<j)return false;else{g.lerpSelf(n,j);n.lerpSelf(g,1-o);return true}}}var d,e,h=[],b,q,r,l=[],m,y,x=[],v,w,G=[],K=new THREE.Vector4,L=new THREE.Vector4,t=new THREE.Matrix4,
-T=new THREE.Matrix4,E=[],f=new THREE.Vector4,k=new THREE.Vector4,i;this.projectObjects=function(g,n,j){var o=[],p,s;e=0;t.multiply(n.projectionMatrix,n.matrix);E[0]=new THREE.Vector4(t.n41-t.n11,t.n42-t.n12,t.n43-t.n13,t.n44-t.n14);E[1]=new THREE.Vector4(t.n41+t.n11,t.n42+t.n12,t.n43+t.n13,t.n44+t.n14);E[2]=new THREE.Vector4(t.n41+t.n21,t.n42+t.n22,t.n43+t.n23,t.n44+t.n24);E[3]=new THREE.Vector4(t.n41-t.n21,t.n42-t.n22,t.n43-t.n23,t.n44-t.n24);E[4]=new THREE.Vector4(t.n41-t.n31,t.n42-t.n32,t.n43-
-t.n33,t.n44-t.n34);E[5]=new THREE.Vector4(t.n41+t.n31,t.n42+t.n32,t.n43+t.n33,t.n44+t.n34);n=0;for(p=E.length;n<p;n++){s=E[n];s.divideScalar(Math.sqrt(s.x*s.x+s.y*s.y+s.z*s.z))}p=g.objects;g=0;for(n=p.length;g<n;g++){s=p[g];var u;if(!(u=!s.visible)){if(u=s instanceof THREE.Mesh){a:{u=void 0;for(var z=s.position,H=-s.geometry.boundingSphere.radius*Math.max(s.scale.x,Math.max(s.scale.y,s.scale.z)),F=0;F<6;F++){u=E[F].x*z.x+E[F].y*z.y+E[F].z*z.z+E[F].w;if(u<=H){u=false;break a}}u=true}u=!u}u=u}if(!u){d=
-h[e]=h[e]||new THREE.RenderableObject;K.copy(s.position);t.multiplyVector3(K);d.object=s;d.z=K.z;o.push(d);e++}}j&&o.sort(a);return o};this.projectScene=function(g,n,j){var o=[],p=n.near,s=n.far,u,z,H,F,I,M,N,V,W,J,B,P,O,C,R,U;r=y=w=0;n.autoUpdateMatrix&&n.updateMatrix();t.multiply(n.projectionMatrix,n.matrix);M=this.projectObjects(g,n,true);g=0;for(u=M.length;g<u;g++){N=M[g].object;if(N.visible){N.autoUpdateMatrix&&N.updateMatrix();V=N.matrix;W=N.rotationMatrix;J=N.materials;B=N.overdraw;if(N instanceof
-THREE.Mesh){P=N.geometry;O=P.vertices;z=0;for(H=O.length;z<H;z++){C=O[z];C.positionWorld.copy(C.position);V.multiplyVector3(C.positionWorld);F=C.positionScreen;F.copy(C.positionWorld);t.multiplyVector4(F);F.x/=F.w;F.y/=F.w;C.__visible=F.z>p&&F.z<s}P=P.faces;z=0;for(H=P.length;z<H;z++){C=P[z];if(C instanceof THREE.Face3){F=O[C.a];I=O[C.b];R=O[C.c];if(F.__visible&&I.__visible&&R.__visible)if(N.doubleSided||N.flipSided!=(R.positionScreen.x-F.positionScreen.x)*(I.positionScreen.y-F.positionScreen.y)-
-(R.positionScreen.y-F.positionScreen.y)*(I.positionScreen.x-F.positionScreen.x)<0){b=l[r]=l[r]||new THREE.RenderableFace3;b.v1.positionWorld.copy(F.positionWorld);b.v2.positionWorld.copy(I.positionWorld);b.v3.positionWorld.copy(R.positionWorld);b.v1.positionScreen.copy(F.positionScreen);b.v2.positionScreen.copy(I.positionScreen);b.v3.positionScreen.copy(R.positionScreen);b.normalWorld.copy(C.normal);W.multiplyVector3(b.normalWorld);b.centroidWorld.copy(C.centroid);V.multiplyVector3(b.centroidWorld);
-b.centroidScreen.copy(b.centroidWorld);t.multiplyVector3(b.centroidScreen);R=C.vertexNormals;i=b.vertexNormalsWorld;F=0;for(I=R.length;F<I;F++){U=i[F]=i[F]||new THREE.Vector3;U.copy(R[F]);W.multiplyVector3(U)}b.z=b.centroidScreen.z;b.meshMaterials=J;b.faceMaterials=C.materials;b.overdraw=B;if(N.geometry.uvs[z]){b.uvs[0]=N.geometry.uvs[z][0];b.uvs[1]=N.geometry.uvs[z][1];b.uvs[2]=N.geometry.uvs[z][2]}o.push(b);r++}}else if(C instanceof THREE.Face4){F=O[C.a];I=O[C.b];R=O[C.c];U=O[C.d];if(F.__visible&&
-I.__visible&&R.__visible&&U.__visible)if(N.doubleSided||N.flipSided!=((U.positionScreen.x-F.positionScreen.x)*(I.positionScreen.y-F.positionScreen.y)-(U.positionScreen.y-F.positionScreen.y)*(I.positionScreen.x-F.positionScreen.x)<0||(I.positionScreen.x-R.positionScreen.x)*(U.positionScreen.y-R.positionScreen.y)-(I.positionScreen.y-R.positionScreen.y)*(U.positionScreen.x-R.positionScreen.x)<0)){b=l[r]=l[r]||new THREE.RenderableFace3;b.v1.positionWorld.copy(F.positionWorld);b.v2.positionWorld.copy(I.positionWorld);
-b.v3.positionWorld.copy(U.positionWorld);b.v1.positionScreen.copy(F.positionScreen);b.v2.positionScreen.copy(I.positionScreen);b.v3.positionScreen.copy(U.positionScreen);b.normalWorld.copy(C.normal);W.multiplyVector3(b.normalWorld);b.centroidWorld.copy(C.centroid);V.multiplyVector3(b.centroidWorld);b.centroidScreen.copy(b.centroidWorld);t.multiplyVector3(b.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterials=J;b.faceMaterials=C.materials;b.overdraw=B;if(N.geometry.uvs[z]){b.uvs[0]=N.geometry.uvs[z][0];
-b.uvs[1]=N.geometry.uvs[z][1];b.uvs[2]=N.geometry.uvs[z][3]}o.push(b);r++;q=l[r]=l[r]||new THREE.RenderableFace3;q.v1.positionWorld.copy(I.positionWorld);q.v2.positionWorld.copy(R.positionWorld);q.v3.positionWorld.copy(U.positionWorld);q.v1.positionScreen.copy(I.positionScreen);q.v2.positionScreen.copy(R.positionScreen);q.v3.positionScreen.copy(U.positionScreen);q.normalWorld.copy(b.normalWorld);q.centroidWorld.copy(b.centroidWorld);q.centroidScreen.copy(b.centroidScreen);q.z=q.centroidScreen.z;q.meshMaterials=
-J;q.faceMaterials=C.materials;q.overdraw=B;if(N.geometry.uvs[z]){q.uvs[0]=N.geometry.uvs[z][1];q.uvs[1]=N.geometry.uvs[z][2];q.uvs[2]=N.geometry.uvs[z][3]}o.push(q);r++}}}}else if(N instanceof THREE.Line){T.multiply(t,V);O=N.geometry.vertices;C=O[0];C.positionScreen.copy(C.position);T.multiplyVector4(C.positionScreen);z=1;for(H=O.length;z<H;z++){F=O[z];F.positionScreen.copy(F.position);T.multiplyVector4(F.positionScreen);I=O[z-1];f.copy(F.positionScreen);k.copy(I.positionScreen);if(c(f,k)){f.multiplyScalar(1/
-f.w);k.multiplyScalar(1/k.w);m=x[y]=x[y]||new THREE.RenderableLine;m.v1.positionScreen.copy(f);m.v2.positionScreen.copy(k);m.z=Math.max(f.z,k.z);m.materials=N.materials;o.push(m);y++}}}else if(N instanceof THREE.Particle){L.set(N.position.x,N.position.y,N.position.z,1);t.multiplyVector4(L);L.z/=L.w;if(L.z>0&&L.z<1){v=G[w]=G[w]||new THREE.RenderableParticle;v.x=L.x/L.w;v.y=L.y/L.w;v.z=L.z;v.rotation=N.rotation.z;v.scale.x=N.scale.x*Math.abs(v.x-(L.x+n.projectionMatrix.n11)/(L.w+n.projectionMatrix.n14));
-v.scale.y=N.scale.y*Math.abs(v.y-(L.y+n.projectionMatrix.n22)/(L.w+n.projectionMatrix.n24));v.materials=N.materials;o.push(v);w++}}}}j&&o.sort(a);return o};this.unprojectVector=function(g,n){var j=THREE.Matrix4.makeInvert(n.matrix);j.multiplySelf(THREE.Matrix4.makeInvert(n.projectionMatrix));j.multiplyVector3(g);return g}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,h,b;this.domElement=document.createElement("div");this.setSize=function(q,r){d=q;e=r;h=d/2;b=e/2};this.render=function(q,r){var l,m,y,x,v,w,G,K;a=c.projectScene(q,r);l=0;for(m=a.length;l<m;l++){v=a[l];if(v instanceof THREE.RenderableParticle){G=v.x*h+h;K=v.y*b+b;y=0;for(x=v.material.length;y<x;y++){w=v.material[y];if(w instanceof THREE.ParticleDOMMaterial){w=w.domElement;w.style.left=G+"px";w.style.top=K+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(ca){if(v!=ca)m.globalAlpha=v=ca}function c(ca){if(w!=ca){switch(ca){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}w=ca}}var d=null,e=new THREE.Projector,h=document.createElement("canvas"),b,q,r,l,m=h.getContext("2d"),y=new THREE.Color(0),x=0,v=1,w=0,G=null,K=null,L=1,t,T,E,f,k,i,g,n,j,o=new THREE.Color,
-p=new THREE.Color,s=new THREE.Color,u=new THREE.Color,z=new THREE.Color,H,F,I,M,N,V,W,J,B,P=new THREE.Rectangle,O=new THREE.Rectangle,C=new THREE.Rectangle,R=false,U=new THREE.Color,Y=new THREE.Color,fa=new THREE.Color,aa=new THREE.Color,za=Math.PI*2,Z=new THREE.Vector3,na,oa,ka,ga,pa,ea,qa=16;na=document.createElement("canvas");na.width=na.height=2;oa=na.getContext("2d");oa.fillStyle="rgba(0,0,0,1)";oa.fillRect(0,0,2,2);ka=oa.getImageData(0,0,2,2);ga=ka.data;pa=document.createElement("canvas");pa.width=
-pa.height=qa;ea=pa.getContext("2d");ea.translate(-qa/2,-qa/2);ea.scale(qa,qa);qa--;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ca,la){b=ca;q=la;r=b/2;l=q/2;h.width=b;h.height=q;P.set(-r,-l,r,l);v=1;w=0;K=G=null;L=1};this.setClearColor=function(ca,la){y.setHex(ca);x=la;O.set(-r,-l,r,l);m.setTransform(1,0,0,-1,r,l);this.clear()};this.clear=function(){m.setTransform(1,0,0,-1,r,l);if(!O.isEmpty()){O.inflate(1);O.minSelf(P);if(y.hex==0&&x==0)m.clearRect(O.getX(),
-O.getY(),O.getWidth(),O.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b*255)+","+x+")";m.fillRect(O.getX(),O.getY(),O.getWidth(),O.getHeight())}O.empty()}};this.render=function(ca,la){function Ea(A){var X,S,D,Q=A.lights;Y.setRGB(0,0,0);fa.setRGB(0,0,0);aa.setRGB(0,0,0);A=0;for(X=Q.length;A<X;A++){S=Q[A];D=S.color;if(S instanceof THREE.AmbientLight){Y.r+=D.r;Y.g+=D.g;Y.b+=D.b}else if(S instanceof THREE.DirectionalLight){fa.r+=
-D.r;fa.g+=D.g;fa.b+=D.b}else if(S instanceof THREE.PointLight){aa.r+=D.r;aa.g+=D.g;aa.b+=D.b}}}function Aa(A,X,S,D){var Q,$,da,ha,ia=A.lights;A=0;for(Q=ia.length;A<Q;A++){$=ia[A];da=$.color;ha=$.intensity;if($ instanceof THREE.DirectionalLight){$=S.dot($.position)*ha;if($>0){D.r+=da.r*$;D.g+=da.g*$;D.b+=da.b*$}}else if($ instanceof THREE.PointLight){Z.sub($.position,X);Z.normalize();$=S.dot(Z)*ha;if($>0){D.r+=da.r*$;D.g+=da.g*$;D.b+=da.b*$}}}}function Na(A,X,S){if(S.opacity!=0){a(S.opacity);c(S.blending);
-var D,Q,$,da,ha,ia;if(S instanceof THREE.ParticleBasicMaterial){if(S.map&&S.map.image.loaded){da=S.map.image;ha=da.width>>1;ia=da.height>>1;Q=X.scale.x*r;$=X.scale.y*l;S=Q*ha;D=$*ia;C.set(A.x-S,A.y-D,A.x+S,A.y+D);if(!P.instersects(C))return;m.save();m.translate(A.x,A.y);m.rotate(-X.rotation);m.scale(Q,-$);m.translate(-ha,-ia);m.drawImage(da,0,0);m.restore()}m.beginPath();m.moveTo(A.x-10,A.y);m.lineTo(A.x+10,A.y);m.moveTo(A.x,A.y-10);m.lineTo(A.x,A.y+10);m.closePath();m.strokeStyle="rgb(255,255,0)";
-m.stroke()}else if(S instanceof THREE.ParticleCircleMaterial){if(R){U.r=Y.r+fa.r+aa.r;U.g=Y.g+fa.g+aa.g;U.b=Y.b+fa.b+aa.b;o.r=S.color.r*U.r;o.g=S.color.g*U.g;o.b=S.color.b*U.b;o.updateStyleString()}else o.__styleString=S.color.__styleString;S=X.scale.x*r;D=X.scale.y*l;C.set(A.x-S,A.y-D,A.x+S,A.y+D);if(P.instersects(C)){Q=o.__styleString;if(K!=Q)m.fillStyle=K=Q;m.save();m.translate(A.x,A.y);m.rotate(-X.rotation);m.scale(S,D);m.beginPath();m.arc(0,0,1,0,za,true);m.closePath();m.fill();m.restore()}}}}
-function Oa(A,X,S,D){if(D.opacity!=0){a(D.opacity);c(D.blending);m.beginPath();m.moveTo(A.positionScreen.x,A.positionScreen.y);m.lineTo(X.positionScreen.x,X.positionScreen.y);m.closePath();if(D instanceof THREE.LineBasicMaterial){o.__styleString=D.color.__styleString;A=D.linewidth;if(L!=A)m.lineWidth=L=A;A=o.__styleString;if(G!=A)m.strokeStyle=G=A;m.stroke();C.inflate(D.linewidth*2)}}}function Ja(A,X,S,D,Q,$){if(Q.opacity!=0){a(Q.opacity);c(Q.blending);f=A.positionScreen.x;k=A.positionScreen.y;i=
-X.positionScreen.x;g=X.positionScreen.y;n=S.positionScreen.x;j=S.positionScreen.y;m.beginPath();m.moveTo(f,k);m.lineTo(i,g);m.lineTo(n,j);m.lineTo(f,k);m.closePath();if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&wa(f,k,i,g,n,j,Q.map.image,D.uvs[0].u,D.uvs[0].v,D.uvs[1].u,D.uvs[1].v,D.uvs[2].u,D.uvs[2].v);else if(Q.env_map){if(Q.env_map.image.loaded)if(Q.env_map.mapping instanceof THREE.SphericalReflectionMapping){A=la.matrix;Z.copy(D.vertexNormalsWorld[0]);
-M=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;N=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;Z.copy(D.vertexNormalsWorld[1]);V=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;W=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;Z.copy(D.vertexNormalsWorld[2]);J=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;B=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;wa(f,k,i,g,n,j,Q.env_map.image,M,N,V,W,J,B)}}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):Ca(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&
-!Q.wireframe){Q.map.mapping instanceof THREE.UVMapping&&wa(f,k,i,g,n,j,Q.map.image,D.uvs[0].u,D.uvs[0].v,D.uvs[1].u,D.uvs[1].v,D.uvs[2].u,D.uvs[2].v);c(THREE.SubtractiveBlending)}if(R)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&D.vertexNormalsWorld.length==3){p.r=s.r=u.r=Y.r;p.g=s.g=u.g=Y.g;p.b=s.b=u.b=Y.b;Aa($,D.v1.positionWorld,D.vertexNormalsWorld[0],p);Aa($,D.v2.positionWorld,D.vertexNormalsWorld[1],s);Aa($,D.v3.positionWorld,D.vertexNormalsWorld[2],u);z.r=(s.r+u.r)*0.5;z.g=(s.g+u.g)*0.5;
-z.b=(s.b+u.b)*0.5;I=Ka(p,s,u,z);wa(f,k,i,g,n,j,I,0,0,1,0,0,1)}else{U.r=Y.r;U.g=Y.g;U.b=Y.b;Aa($,D.centroidWorld,D.normalWorld,U);o.r=Q.color.r*U.r;o.g=Q.color.g*U.g;o.b=Q.color.b*U.b;o.updateStyleString();Q.wireframe?Ba(o.__styleString,Q.wireframe_linewidth):Ca(o.__styleString)}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):Ca(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){H=la.near;F=la.far;p.r=p.g=p.b=1-Fa(A.positionScreen.z,H,F);s.r=s.g=s.b=1-Fa(X.positionScreen.z,
-H,F);u.r=u.g=u.b=1-Fa(S.positionScreen.z,H,F);z.r=(s.r+u.r)*0.5;z.g=(s.g+u.g)*0.5;z.b=(s.b+u.b)*0.5;I=Ka(p,s,u,z);wa(f,k,i,g,n,j,I,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){o.r=Ga(D.normalWorld.x);o.g=Ga(D.normalWorld.y);o.b=Ga(D.normalWorld.z);o.updateStyleString();Q.wireframe?Ba(o.__styleString,Q.wireframe_linewidth):Ca(o.__styleString)}}}function Ba(A,X){if(G!=A)m.strokeStyle=G=A;if(L!=X)m.lineWidth=L=X;m.stroke();C.inflate(X*2)}function Ca(A){if(K!=A)m.fillStyle=K=A;m.fill()}
-function wa(A,X,S,D,Q,$,da,ha,ia,ra,ja,sa,xa){var ua,ta;ua=da.width-1;ta=da.height-1;ha*=ua;ia*=ta;ra*=ua;ja*=ta;sa*=ua;xa*=ta;S-=A;D-=X;Q-=A;$-=X;ra-=ha;ja-=ia;sa-=ha;xa-=ia;ta=1/(ra*xa-sa*ja);ua=(xa*S-ja*Q)*ta;ja=(xa*D-ja*$)*ta;S=(ra*Q-sa*S)*ta;D=(ra*$-sa*D)*ta;A=A-ua*ha-S*ia;X=X-ja*ha-D*ia;m.save();m.transform(ua,ja,S,D,A,X);m.clip();m.drawImage(da,0,0);m.restore()}function Ka(A,X,S,D){var Q=~~(A.r*255),$=~~(A.g*255);A=~~(A.b*255);var da=~~(X.r*255),ha=~~(X.g*255);X=~~(X.b*255);var ia=~~(S.r*255),
-ra=~~(S.g*255);S=~~(S.b*255);var ja=~~(D.r*255),sa=~~(D.g*255);D=~~(D.b*255);ga[0]=Q<0?0:Q>255?255:Q;ga[1]=$<0?0:$>255?255:$;ga[2]=A<0?0:A>255?255:A;ga[4]=da<0?0:da>255?255:da;ga[5]=ha<0?0:ha>255?255:ha;ga[6]=X<0?0:X>255?255:X;ga[8]=ia<0?0:ia>255?255:ia;ga[9]=ra<0?0:ra>255?255:ra;ga[10]=S<0?0:S>255?255:S;ga[12]=ja<0?0:ja>255?255:ja;ga[13]=sa<0?0:sa>255?255:sa;ga[14]=D<0?0:D>255?255:D;oa.putImageData(ka,0,0);ea.drawImage(na,0,0);return pa}function Fa(A,X,S){A=(A-X)/(S-X);return A*A*(3-2*A)}function Ga(A){A=
-(A+1)*0.5;return A<0?0:A>1?1:A}function Ha(A,X){var S=X.x-A.x,D=X.y-A.y,Q=1/Math.sqrt(S*S+D*D);S*=Q;D*=Q;X.x+=S;X.y+=D;A.x-=S;A.y-=D}var Da,La,ba,ma,va,Ia,Ma,ya;this.autoClear?this.clear():m.setTransform(1,0,0,-1,r,l);d=e.projectScene(ca,la,this.sortElements);m.fillStyle="rgba( 0, 255, 255, 0.5 )";m.fillRect(P.getX(),P.getY(),P.getWidth(),P.getHeight());(R=ca.lights.length>0)&&Ea(ca);Da=0;for(La=d.length;Da<La;Da++){ba=d[Da];C.empty();if(ba instanceof THREE.RenderableParticle){t=ba;t.x*=r;t.y*=l;
-ma=0;for(va=ba.materials.length;ma<va;ma++)Na(t,ba,ba.materials[ma],ca)}else if(ba instanceof THREE.RenderableLine){t=ba.v1;T=ba.v2;t.positionScreen.x*=r;t.positionScreen.y*=l;T.positionScreen.x*=r;T.positionScreen.y*=l;C.addPoint(t.positionScreen.x,t.positionScreen.y);C.addPoint(T.positionScreen.x,T.positionScreen.y);if(P.instersects(C)){ma=0;for(va=ba.materials.length;ma<va;)Oa(t,T,ba,ba.materials[ma++],ca)}}else if(ba instanceof THREE.RenderableFace3){t=ba.v1;T=ba.v2;E=ba.v3;t.positionScreen.x*=
-r;t.positionScreen.y*=l;T.positionScreen.x*=r;T.positionScreen.y*=l;E.positionScreen.x*=r;E.positionScreen.y*=l;if(ba.overdraw){Ha(t.positionScreen,T.positionScreen);Ha(T.positionScreen,E.positionScreen);Ha(E.positionScreen,t.positionScreen)}C.add3Points(t.positionScreen.x,t.positionScreen.y,T.positionScreen.x,T.positionScreen.y,E.positionScreen.x,E.positionScreen.y);if(P.instersects(C)){ma=0;for(va=ba.meshMaterials.length;ma<va;){ya=ba.meshMaterials[ma++];if(ya instanceof THREE.MeshFaceMaterial){Ia=
-0;for(Ma=ba.faceMaterials.length;Ia<Ma;)(ya=ba.faceMaterials[Ia++])&&Ja(t,T,E,ba,ya,ca)}else Ja(t,T,E,ba,ya,ca)}}}O.addRectangle(C)}m.lineWidth=1;m.strokeStyle="rgba( 255, 0, 0, 0.5 )";m.strokeRect(O.getX(),O.getY(),O.getWidth(),O.getHeight());m.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(M,N,V){var W,J,B,P;W=0;for(J=M.lights.length;W<J;W++){B=M.lights[W];if(B instanceof THREE.DirectionalLight){P=N.normalWorld.dot(B.position)*B.intensity;if(P>0){V.r+=B.color.r*P;V.g+=B.color.g*P;V.b+=B.color.b*P}}else if(B instanceof THREE.PointLight){j.sub(B.position,N.centroidWorld);j.normalize();P=N.normalWorld.dot(j)*B.intensity;if(P>0){V.r+=B.color.r*P;V.g+=B.color.g*P;V.b+=B.color.b*P}}}}function c(M,N,V,W,J,B){u=e(z++);u.setAttribute("d","M "+M.positionScreen.x+
-" "+M.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)E.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(T){f.r=k.r;f.g=k.g;f.b=k.b;a(B,W,f);E.r=J.color.r*f.r;E.g=J.color.g*f.g;E.b=J.color.b*f.b;E.updateStyleString()}else E.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){n=1-J.__2near/(J.__farPlusNear-W.z*J.__farMinusNear);
-E.setRGB(n,n,n)}else J instanceof THREE.MeshNormalMaterial&&E.setRGB(h(W.normalWorld.x),h(W.normalWorld.y),h(W.normalWorld.z));J.wireframe?u.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):u.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+J.opacity);r.appendChild(u)}function d(M,N,V,W,J,B,P){u=e(z++);u.setAttribute("d",
-"M "+M.positionScreen.x+" "+M.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)E.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(T){f.r=k.r;f.g=k.g;f.b=k.b;a(P,J,f);E.r=B.color.r*f.r;E.g=B.color.g*f.g;E.b=B.color.b*f.b;E.updateStyleString()}else E.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){n=
-1-B.__2near/(B.__farPlusNear-J.z*B.__farMinusNear);E.setRGB(n,n,n)}else B instanceof THREE.MeshNormalMaterial&&E.setRGB(h(J.normalWorld.x),h(J.normalWorld.y),h(J.normalWorld.z));B.wireframe?u.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):u.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+B.opacity);r.appendChild(u)}
-function e(M){if(o[M]==null){o[M]=document.createElementNS("http://www.w3.org/2000/svg","path");I==0&&o[M].setAttribute("shape-rendering","crispEdges");return o[M]}return o[M]}function h(M){return M<0?Math.min((1+M)*0.5,0.5):0.5+Math.min(M*0.5,0.5)}var b=null,q=new THREE.Projector,r=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,m,y,x,v,w,G,K,L=new THREE.Rectangle,t=new THREE.Rectangle,T=false,E=new THREE.Color(16777215),f=new THREE.Color(16777215),k=new THREE.Color(0),i=new THREE.Color(0),
-g=new THREE.Color(0),n,j=new THREE.Vector3,o=[],p=[],s=[],u,z,H,F,I=1;this.domElement=r;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(M){switch(M){case "high":I=1;break;case "low":I=0}};this.setSize=function(M,N){l=M;m=N;y=l/2;x=m/2;r.setAttribute("viewBox",-y+" "+-x+" "+l+" "+m);r.setAttribute("width",l);r.setAttribute("height",m);L.set(-y,-x,y,x)};this.clear=function(){for(;r.childNodes.length>0;)r.removeChild(r.childNodes[0])};this.render=function(M,N){var V,W,
-J,B,P,O,C,R;this.autoClear&&this.clear();b=q.projectScene(M,N,this.sortElements);F=H=z=0;if(T=M.lights.length>0){C=M.lights;k.setRGB(0,0,0);i.setRGB(0,0,0);g.setRGB(0,0,0);V=0;for(W=C.length;V<W;V++){J=C[V];B=J.color;if(J instanceof THREE.AmbientLight){k.r+=B.r;k.g+=B.g;k.b+=B.b}else if(J instanceof THREE.DirectionalLight){i.r+=B.r;i.g+=B.g;i.b+=B.b}else if(J instanceof THREE.PointLight){g.r+=B.r;g.g+=B.g;g.b+=B.b}}}V=0;for(W=b.length;V<W;V++){C=b[V];t.empty();if(C instanceof THREE.RenderableParticle){v=
-C;v.x*=y;v.y*=-x;J=0;for(B=C.materials.length;J<B;J++)if(R=C.materials[J]){P=v;O=C;R=R;var U=H++;if(p[U]==null){p[U]=document.createElementNS("http://www.w3.org/2000/svg","circle");I==0&&p[U].setAttribute("shape-rendering","crispEdges")}u=p[U];u.setAttribute("cx",P.x);u.setAttribute("cy",P.y);u.setAttribute("r",O.scale.x*y);if(R instanceof THREE.ParticleCircleMaterial){if(T){f.r=k.r+i.r+g.r;f.g=k.g+i.g+g.g;f.b=k.b+i.b+g.b;E.r=R.color.r*f.r;E.g=R.color.g*f.g;E.b=R.color.b*f.b;E.updateStyleString()}else E=
-R.color;u.setAttribute("style","fill: "+E.__styleString)}r.appendChild(u)}}else if(C instanceof THREE.RenderableLine){v=C.v1;w=C.v2;v.positionScreen.x*=y;v.positionScreen.y*=-x;w.positionScreen.x*=y;w.positionScreen.y*=-x;t.addPoint(v.positionScreen.x,v.positionScreen.y);t.addPoint(w.positionScreen.x,w.positionScreen.y);if(L.instersects(t)){J=0;for(B=C.materials.length;J<B;)if(R=C.materials[J++]){P=v;O=w;R=R;U=F++;if(s[U]==null){s[U]=document.createElementNS("http://www.w3.org/2000/svg","line");I==
-0&&s[U].setAttribute("shape-rendering","crispEdges")}u=s[U];u.setAttribute("x1",P.positionScreen.x);u.setAttribute("y1",P.positionScreen.y);u.setAttribute("x2",O.positionScreen.x);u.setAttribute("y2",O.positionScreen.y);if(R instanceof THREE.LineBasicMaterial){E.__styleString=R.color.__styleString;u.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+R.linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.linecap+"; stroke-linejoin: "+R.linejoin);r.appendChild(u)}}}}else if(C instanceof
-THREE.RenderableFace3){v=C.v1;w=C.v2;G=C.v3;v.positionScreen.x*=y;v.positionScreen.y*=-x;w.positionScreen.x*=y;w.positionScreen.y*=-x;G.positionScreen.x*=y;G.positionScreen.y*=-x;t.addPoint(v.positionScreen.x,v.positionScreen.y);t.addPoint(w.positionScreen.x,w.positionScreen.y);t.addPoint(G.positionScreen.x,G.positionScreen.y);if(L.instersects(t)){J=0;for(B=C.meshMaterials.length;J<B;){R=C.meshMaterials[J++];if(R instanceof THREE.MeshFaceMaterial){P=0;for(O=C.faceMaterials.length;P<O;)(R=C.faceMaterials[P++])&&
-c(v,w,G,C,R,M)}else R&&c(v,w,G,C,R,M)}}}else if(C instanceof THREE.RenderableFace4){v=C.v1;w=C.v2;G=C.v3;K=C.v4;v.positionScreen.x*=y;v.positionScreen.y*=-x;w.positionScreen.x*=y;w.positionScreen.y*=-x;G.positionScreen.x*=y;G.positionScreen.y*=-x;K.positionScreen.x*=y;K.positionScreen.y*=-x;t.addPoint(v.positionScreen.x,v.positionScreen.y);t.addPoint(w.positionScreen.x,w.positionScreen.y);t.addPoint(G.positionScreen.x,G.positionScreen.y);t.addPoint(K.positionScreen.x,K.positionScreen.y);if(L.instersects(t)){J=
-0;for(B=C.meshMaterials.length;J<B;){R=C.meshMaterials[J++];if(R instanceof THREE.MeshFaceMaterial){P=0;for(O=C.faceMaterials.length;P<O;)(R=C.faceMaterials[P++])&&d(v,w,G,K,C,R,M)}else R&&d(v,w,G,K,C,R,M)}}}}}};
-THREE.WebGLRenderer=function(a){function c(f,k){f.fragment_shader=k.fragment_shader;f.vertex_shader=k.vertex_shader;f.uniforms=Uniforms.clone(k.uniforms)}function d(f,k){var i;if(f=="fragment")i=b.createShader(b.FRAGMENT_SHADER);else if(f=="vertex")i=b.createShader(b.VERTEX_SHADER);b.shaderSource(i,k);b.compileShader(i);if(!b.getShaderParameter(i,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(i));return null}return i}function e(f){switch(f){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;
+THREE.Projector=function(){function a(e,j){return j.z-e.z}function c(e,j){var k=0,p=1,w=e.z+e.w,o=j.z+j.w,t=-e.z+e.w,v=-j.z+j.w;if(w>=0&&o>=0&&t>=0&&v>=0)return true;else if(w<0&&o<0||t<0&&v<0)return false;else{if(w<0)k=Math.max(k,w/(w-o));else if(o<0)p=Math.min(p,w/(w-o));if(t<0)k=Math.max(k,t/(t-v));else if(v<0)p=Math.min(p,t/(t-v));if(p<k)return false;else{e.lerpSelf(j,k);j.lerpSelf(e,1-p);return true}}}var d,f,h=[],b,q,r,l=[],m,z,y=[],u,x,H=[],K=new THREE.Vector4,M=new THREE.Vector4,s=new THREE.Matrix4,
+T=new THREE.Matrix4,G=[],g=new THREE.Vector4,n=new THREE.Vector4,i;this.projectObjects=function(e,j,k){var p=[],w,o;f=0;s.multiply(j.projectionMatrix,j.matrix);G[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);G[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);G[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);G[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);G[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
+s.n33,s.n44-s.n34);G[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);j=0;for(w=G.length;j<w;j++){o=G[j];o.divideScalar(Math.sqrt(o.x*o.x+o.y*o.y+o.z*o.z))}w=e.objects;e=0;for(j=w.length;e<j;e++){o=w[e];var t;if(!(t=!o.visible)){if(t=o instanceof THREE.Mesh){a:{t=void 0;for(var v=o.position,D=-o.geometry.boundingSphere.radius*Math.max(o.scale.x,Math.max(o.scale.y,o.scale.z)),E=0;E<6;E++){t=G[E].x*v.x+G[E].y*v.y+G[E].z*v.z+G[E].w;if(t<=D){t=false;break a}}t=true}t=!t}t=t}if(!t){d=
+h[f]=h[f]||new THREE.RenderableObject;K.copy(o.position);s.multiplyVector3(K);d.object=o;d.z=K.z;p.push(d);f++}}k&&p.sort(a);return p};this.projectScene=function(e,j,k){var p=[],w=j.near,o=j.far,t,v,D,E,I,L,N,V,W,J,B,P,O,C,R,U;r=z=x=0;j.autoUpdateMatrix&&j.updateMatrix();s.multiply(j.projectionMatrix,j.matrix);L=this.projectObjects(e,j,true);e=0;for(t=L.length;e<t;e++){N=L[e].object;if(N.visible){N.autoUpdateMatrix&&N.updateMatrix();V=N.matrix;W=N.rotationMatrix;J=N.materials;B=N.overdraw;if(N instanceof
+THREE.Mesh){P=N.geometry;O=P.vertices;v=0;for(D=O.length;v<D;v++){C=O[v];C.positionWorld.copy(C.position);V.multiplyVector3(C.positionWorld);E=C.positionScreen;E.copy(C.positionWorld);s.multiplyVector4(E);E.x/=E.w;E.y/=E.w;C.__visible=E.z>w&&E.z<o}P=P.faces;v=0;for(D=P.length;v<D;v++){C=P[v];if(C instanceof THREE.Face3){E=O[C.a];I=O[C.b];R=O[C.c];if(E.__visible&&I.__visible&&R.__visible)if(N.doubleSided||N.flipSided!=(R.positionScreen.x-E.positionScreen.x)*(I.positionScreen.y-E.positionScreen.y)-
+(R.positionScreen.y-E.positionScreen.y)*(I.positionScreen.x-E.positionScreen.x)<0){b=l[r]=l[r]||new THREE.RenderableFace3;b.v1.positionWorld.copy(E.positionWorld);b.v2.positionWorld.copy(I.positionWorld);b.v3.positionWorld.copy(R.positionWorld);b.v1.positionScreen.copy(E.positionScreen);b.v2.positionScreen.copy(I.positionScreen);b.v3.positionScreen.copy(R.positionScreen);b.normalWorld.copy(C.normal);W.multiplyVector3(b.normalWorld);b.centroidWorld.copy(C.centroid);V.multiplyVector3(b.centroidWorld);
+b.centroidScreen.copy(b.centroidWorld);s.multiplyVector3(b.centroidScreen);R=C.vertexNormals;i=b.vertexNormalsWorld;E=0;for(I=R.length;E<I;E++){U=i[E]=i[E]||new THREE.Vector3;U.copy(R[E]);W.multiplyVector3(U)}b.z=b.centroidScreen.z;b.meshMaterials=J;b.faceMaterials=C.materials;b.overdraw=B;if(N.geometry.uvs[v]){b.uvs[0]=N.geometry.uvs[v][0];b.uvs[1]=N.geometry.uvs[v][1];b.uvs[2]=N.geometry.uvs[v][2]}p.push(b);r++}}else if(C instanceof THREE.Face4){E=O[C.a];I=O[C.b];R=O[C.c];U=O[C.d];if(E.__visible&&
+I.__visible&&R.__visible&&U.__visible)if(N.doubleSided||N.flipSided!=((U.positionScreen.x-E.positionScreen.x)*(I.positionScreen.y-E.positionScreen.y)-(U.positionScreen.y-E.positionScreen.y)*(I.positionScreen.x-E.positionScreen.x)<0||(I.positionScreen.x-R.positionScreen.x)*(U.positionScreen.y-R.positionScreen.y)-(I.positionScreen.y-R.positionScreen.y)*(U.positionScreen.x-R.positionScreen.x)<0)){b=l[r]=l[r]||new THREE.RenderableFace3;b.v1.positionWorld.copy(E.positionWorld);b.v2.positionWorld.copy(I.positionWorld);
+b.v3.positionWorld.copy(U.positionWorld);b.v1.positionScreen.copy(E.positionScreen);b.v2.positionScreen.copy(I.positionScreen);b.v3.positionScreen.copy(U.positionScreen);b.normalWorld.copy(C.normal);W.multiplyVector3(b.normalWorld);b.centroidWorld.copy(C.centroid);V.multiplyVector3(b.centroidWorld);b.centroidScreen.copy(b.centroidWorld);s.multiplyVector3(b.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterials=J;b.faceMaterials=C.materials;b.overdraw=B;if(N.geometry.uvs[v]){b.uvs[0]=N.geometry.uvs[v][0];
+b.uvs[1]=N.geometry.uvs[v][1];b.uvs[2]=N.geometry.uvs[v][3]}p.push(b);r++;q=l[r]=l[r]||new THREE.RenderableFace3;q.v1.positionWorld.copy(I.positionWorld);q.v2.positionWorld.copy(R.positionWorld);q.v3.positionWorld.copy(U.positionWorld);q.v1.positionScreen.copy(I.positionScreen);q.v2.positionScreen.copy(R.positionScreen);q.v3.positionScreen.copy(U.positionScreen);q.normalWorld.copy(b.normalWorld);q.centroidWorld.copy(b.centroidWorld);q.centroidScreen.copy(b.centroidScreen);q.z=q.centroidScreen.z;q.meshMaterials=
+J;q.faceMaterials=C.materials;q.overdraw=B;if(N.geometry.uvs[v]){q.uvs[0]=N.geometry.uvs[v][1];q.uvs[1]=N.geometry.uvs[v][2];q.uvs[2]=N.geometry.uvs[v][3]}p.push(q);r++}}}}else if(N instanceof THREE.Line){T.multiply(s,V);O=N.geometry.vertices;C=O[0];C.positionScreen.copy(C.position);T.multiplyVector4(C.positionScreen);v=1;for(D=O.length;v<D;v++){E=O[v];E.positionScreen.copy(E.position);T.multiplyVector4(E.positionScreen);I=O[v-1];g.copy(E.positionScreen);n.copy(I.positionScreen);if(c(g,n)){g.multiplyScalar(1/
+g.w);n.multiplyScalar(1/n.w);m=y[z]=y[z]||new THREE.RenderableLine;m.v1.positionScreen.copy(g);m.v2.positionScreen.copy(n);m.z=Math.max(g.z,n.z);m.materials=N.materials;p.push(m);z++}}}else if(N instanceof THREE.Particle){M.set(N.position.x,N.position.y,N.position.z,1);s.multiplyVector4(M);M.z/=M.w;if(M.z>0&&M.z<1){u=H[x]=H[x]||new THREE.RenderableParticle;u.x=M.x/M.w;u.y=M.y/M.w;u.z=M.z;u.rotation=N.rotation.z;u.scale.x=N.scale.x*Math.abs(u.x-(M.x+j.projectionMatrix.n11)/(M.w+j.projectionMatrix.n14));
+u.scale.y=N.scale.y*Math.abs(u.y-(M.y+j.projectionMatrix.n22)/(M.w+j.projectionMatrix.n24));u.materials=N.materials;p.push(u);x++}}}}k&&p.sort(a);return p};this.unprojectVector=function(e,j){var k=THREE.Matrix4.makeInvert(j.matrix);k.multiplySelf(THREE.Matrix4.makeInvert(j.projectionMatrix));k.multiplyVector3(e);return e}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,h,b;this.domElement=document.createElement("div");this.setSize=function(q,r){d=q;f=r;h=d/2;b=f/2};this.render=function(q,r){var l,m,z,y,u,x,H,K;a=c.projectScene(q,r);l=0;for(m=a.length;l<m;l++){u=a[l];if(u instanceof THREE.RenderableParticle){H=u.x*h+h;K=u.y*b+b;z=0;for(y=u.material.length;z<y;z++){x=u.material[z];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=H+"px";x.style.top=K+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(ca){if(u!=ca)m.globalAlpha=u=ca}function c(ca){if(x!=ca){switch(ca){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}x=ca}}var d=null,f=new THREE.Projector,h=document.createElement("canvas"),b,q,r,l,m=h.getContext("2d"),z=new THREE.Color(0),y=0,u=1,x=0,H=null,K=null,M=1,s,T,G,g,n,i,e,j,k,p=new THREE.Color,
+w=new THREE.Color,o=new THREE.Color,t=new THREE.Color,v=new THREE.Color,D,E,I,L,N,V,W,J,B,P=new THREE.Rectangle,O=new THREE.Rectangle,C=new THREE.Rectangle,R=false,U=new THREE.Color,Y=new THREE.Color,fa=new THREE.Color,aa=new THREE.Color,za=Math.PI*2,Z=new THREE.Vector3,na,oa,ka,ga,pa,ea,qa=16;na=document.createElement("canvas");na.width=na.height=2;oa=na.getContext("2d");oa.fillStyle="rgba(0,0,0,1)";oa.fillRect(0,0,2,2);ka=oa.getImageData(0,0,2,2);ga=ka.data;pa=document.createElement("canvas");pa.width=
+pa.height=qa;ea=pa.getContext("2d");ea.translate(-qa/2,-qa/2);ea.scale(qa,qa);qa--;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ca,la){b=ca;q=la;r=b/2;l=q/2;h.width=b;h.height=q;P.set(-r,-l,r,l);u=1;x=0;K=H=null;M=1};this.setClearColor=function(ca,la){z.setHex(ca);y=la;O.set(-r,-l,r,l);m.setTransform(1,0,0,-1,r,l);this.clear()};this.clear=function(){m.setTransform(1,0,0,-1,r,l);if(!O.isEmpty()){O.inflate(1);O.minSelf(P);if(z.hex==0&&y==0)m.clearRect(O.getX(),
+O.getY(),O.getWidth(),O.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(z.r*255)+","+Math.floor(z.g*255)+","+Math.floor(z.b*255)+","+y+")";m.fillRect(O.getX(),O.getY(),O.getWidth(),O.getHeight())}O.empty()}};this.render=function(ca,la){function Ea(A){var X,S,F,Q=A.lights;Y.setRGB(0,0,0);fa.setRGB(0,0,0);aa.setRGB(0,0,0);A=0;for(X=Q.length;A<X;A++){S=Q[A];F=S.color;if(S instanceof THREE.AmbientLight){Y.r+=F.r;Y.g+=F.g;Y.b+=F.b}else if(S instanceof THREE.DirectionalLight){fa.r+=
+F.r;fa.g+=F.g;fa.b+=F.b}else if(S instanceof THREE.PointLight){aa.r+=F.r;aa.g+=F.g;aa.b+=F.b}}}function Aa(A,X,S,F){var Q,$,da,ha,ia=A.lights;A=0;for(Q=ia.length;A<Q;A++){$=ia[A];da=$.color;ha=$.intensity;if($ instanceof THREE.DirectionalLight){$=S.dot($.position)*ha;if($>0){F.r+=da.r*$;F.g+=da.g*$;F.b+=da.b*$}}else if($ instanceof THREE.PointLight){Z.sub($.position,X);Z.normalize();$=S.dot(Z)*ha;if($>0){F.r+=da.r*$;F.g+=da.g*$;F.b+=da.b*$}}}}function Na(A,X,S){if(S.opacity!=0){a(S.opacity);c(S.blending);
+var F,Q,$,da,ha,ia;if(S instanceof THREE.ParticleBasicMaterial){if(S.map&&S.map.image.loaded){da=S.map.image;ha=da.width>>1;ia=da.height>>1;Q=X.scale.x*r;$=X.scale.y*l;S=Q*ha;F=$*ia;C.set(A.x-S,A.y-F,A.x+S,A.y+F);if(!P.instersects(C))return;m.save();m.translate(A.x,A.y);m.rotate(-X.rotation);m.scale(Q,-$);m.translate(-ha,-ia);m.drawImage(da,0,0);m.restore()}m.beginPath();m.moveTo(A.x-10,A.y);m.lineTo(A.x+10,A.y);m.moveTo(A.x,A.y-10);m.lineTo(A.x,A.y+10);m.closePath();m.strokeStyle="rgb(255,255,0)";
+m.stroke()}else if(S instanceof THREE.ParticleCircleMaterial){if(R){U.r=Y.r+fa.r+aa.r;U.g=Y.g+fa.g+aa.g;U.b=Y.b+fa.b+aa.b;p.r=S.color.r*U.r;p.g=S.color.g*U.g;p.b=S.color.b*U.b;p.updateStyleString()}else p.__styleString=S.color.__styleString;S=X.scale.x*r;F=X.scale.y*l;C.set(A.x-S,A.y-F,A.x+S,A.y+F);if(P.instersects(C)){Q=p.__styleString;if(K!=Q)m.fillStyle=K=Q;m.save();m.translate(A.x,A.y);m.rotate(-X.rotation);m.scale(S,F);m.beginPath();m.arc(0,0,1,0,za,true);m.closePath();m.fill();m.restore()}}}}
+function Oa(A,X,S,F){if(F.opacity!=0){a(F.opacity);c(F.blending);m.beginPath();m.moveTo(A.positionScreen.x,A.positionScreen.y);m.lineTo(X.positionScreen.x,X.positionScreen.y);m.closePath();if(F instanceof THREE.LineBasicMaterial){p.__styleString=F.color.__styleString;A=F.linewidth;if(M!=A)m.lineWidth=M=A;A=p.__styleString;if(H!=A)m.strokeStyle=H=A;m.stroke();C.inflate(F.linewidth*2)}}}function Ja(A,X,S,F,Q,$){if(Q.opacity!=0){a(Q.opacity);c(Q.blending);g=A.positionScreen.x;n=A.positionScreen.y;i=
+X.positionScreen.x;e=X.positionScreen.y;j=S.positionScreen.x;k=S.positionScreen.y;m.beginPath();m.moveTo(g,n);m.lineTo(i,e);m.lineTo(j,k);m.lineTo(g,n);m.closePath();if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&wa(g,n,i,e,j,k,Q.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);else if(Q.env_map){if(Q.env_map.image.loaded)if(Q.env_map.mapping instanceof THREE.SphericalReflectionMapping){A=la.matrix;Z.copy(F.vertexNormalsWorld[0]);
+L=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;N=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;Z.copy(F.vertexNormalsWorld[1]);V=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;W=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;Z.copy(F.vertexNormalsWorld[2]);J=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;B=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;wa(g,n,i,e,j,k,Q.env_map.image,L,N,V,W,J,B)}}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):Ca(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&
+!Q.wireframe){Q.map.mapping instanceof THREE.UVMapping&&wa(g,n,i,e,j,k,Q.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);c(THREE.SubtractiveBlending)}if(R)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&F.vertexNormalsWorld.length==3){w.r=o.r=t.r=Y.r;w.g=o.g=t.g=Y.g;w.b=o.b=t.b=Y.b;Aa($,F.v1.positionWorld,F.vertexNormalsWorld[0],w);Aa($,F.v2.positionWorld,F.vertexNormalsWorld[1],o);Aa($,F.v3.positionWorld,F.vertexNormalsWorld[2],t);v.r=(o.r+t.r)*0.5;v.g=(o.g+t.g)*0.5;
+v.b=(o.b+t.b)*0.5;I=Ka(w,o,t,v);wa(g,n,i,e,j,k,I,0,0,1,0,0,1)}else{U.r=Y.r;U.g=Y.g;U.b=Y.b;Aa($,F.centroidWorld,F.normalWorld,U);p.r=Q.color.r*U.r;p.g=Q.color.g*U.g;p.b=Q.color.b*U.b;p.updateStyleString();Q.wireframe?Ba(p.__styleString,Q.wireframe_linewidth):Ca(p.__styleString)}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):Ca(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){D=la.near;E=la.far;w.r=w.g=w.b=1-Fa(A.positionScreen.z,D,E);o.r=o.g=o.b=1-Fa(X.positionScreen.z,
+D,E);t.r=t.g=t.b=1-Fa(S.positionScreen.z,D,E);v.r=(o.r+t.r)*0.5;v.g=(o.g+t.g)*0.5;v.b=(o.b+t.b)*0.5;I=Ka(w,o,t,v);wa(g,n,i,e,j,k,I,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){p.r=Ga(F.normalWorld.x);p.g=Ga(F.normalWorld.y);p.b=Ga(F.normalWorld.z);p.updateStyleString();Q.wireframe?Ba(p.__styleString,Q.wireframe_linewidth):Ca(p.__styleString)}}}function Ba(A,X){if(H!=A)m.strokeStyle=H=A;if(M!=X)m.lineWidth=M=X;m.stroke();C.inflate(X*2)}function Ca(A){if(K!=A)m.fillStyle=K=A;m.fill()}
+function wa(A,X,S,F,Q,$,da,ha,ia,ra,ja,sa,xa){var ua,ta;ua=da.width-1;ta=da.height-1;ha*=ua;ia*=ta;ra*=ua;ja*=ta;sa*=ua;xa*=ta;S-=A;F-=X;Q-=A;$-=X;ra-=ha;ja-=ia;sa-=ha;xa-=ia;ta=1/(ra*xa-sa*ja);ua=(xa*S-ja*Q)*ta;ja=(xa*F-ja*$)*ta;S=(ra*Q-sa*S)*ta;F=(ra*$-sa*F)*ta;A=A-ua*ha-S*ia;X=X-ja*ha-F*ia;m.save();m.transform(ua,ja,S,F,A,X);m.clip();m.drawImage(da,0,0);m.restore()}function Ka(A,X,S,F){var Q=~~(A.r*255),$=~~(A.g*255);A=~~(A.b*255);var da=~~(X.r*255),ha=~~(X.g*255);X=~~(X.b*255);var ia=~~(S.r*255),
+ra=~~(S.g*255);S=~~(S.b*255);var ja=~~(F.r*255),sa=~~(F.g*255);F=~~(F.b*255);ga[0]=Q<0?0:Q>255?255:Q;ga[1]=$<0?0:$>255?255:$;ga[2]=A<0?0:A>255?255:A;ga[4]=da<0?0:da>255?255:da;ga[5]=ha<0?0:ha>255?255:ha;ga[6]=X<0?0:X>255?255:X;ga[8]=ia<0?0:ia>255?255:ia;ga[9]=ra<0?0:ra>255?255:ra;ga[10]=S<0?0:S>255?255:S;ga[12]=ja<0?0:ja>255?255:ja;ga[13]=sa<0?0:sa>255?255:sa;ga[14]=F<0?0:F>255?255:F;oa.putImageData(ka,0,0);ea.drawImage(na,0,0);return pa}function Fa(A,X,S){A=(A-X)/(S-X);return A*A*(3-2*A)}function Ga(A){A=
+(A+1)*0.5;return A<0?0:A>1?1:A}function Ha(A,X){var S=X.x-A.x,F=X.y-A.y,Q=1/Math.sqrt(S*S+F*F);S*=Q;F*=Q;X.x+=S;X.y+=F;A.x-=S;A.y-=F}var Da,La,ba,ma,va,Ia,Ma,ya;this.autoClear?this.clear():m.setTransform(1,0,0,-1,r,l);d=f.projectScene(ca,la,this.sortElements);m.fillStyle="rgba( 0, 255, 255, 0.5 )";m.fillRect(P.getX(),P.getY(),P.getWidth(),P.getHeight());(R=ca.lights.length>0)&&Ea(ca);Da=0;for(La=d.length;Da<La;Da++){ba=d[Da];C.empty();if(ba instanceof THREE.RenderableParticle){s=ba;s.x*=r;s.y*=l;
+ma=0;for(va=ba.materials.length;ma<va;ma++)Na(s,ba,ba.materials[ma],ca)}else if(ba instanceof THREE.RenderableLine){s=ba.v1;T=ba.v2;s.positionScreen.x*=r;s.positionScreen.y*=l;T.positionScreen.x*=r;T.positionScreen.y*=l;C.addPoint(s.positionScreen.x,s.positionScreen.y);C.addPoint(T.positionScreen.x,T.positionScreen.y);if(P.instersects(C)){ma=0;for(va=ba.materials.length;ma<va;)Oa(s,T,ba,ba.materials[ma++],ca)}}else if(ba instanceof THREE.RenderableFace3){s=ba.v1;T=ba.v2;G=ba.v3;s.positionScreen.x*=
+r;s.positionScreen.y*=l;T.positionScreen.x*=r;T.positionScreen.y*=l;G.positionScreen.x*=r;G.positionScreen.y*=l;if(ba.overdraw){Ha(s.positionScreen,T.positionScreen);Ha(T.positionScreen,G.positionScreen);Ha(G.positionScreen,s.positionScreen)}C.add3Points(s.positionScreen.x,s.positionScreen.y,T.positionScreen.x,T.positionScreen.y,G.positionScreen.x,G.positionScreen.y);if(P.instersects(C)){ma=0;for(va=ba.meshMaterials.length;ma<va;){ya=ba.meshMaterials[ma++];if(ya instanceof THREE.MeshFaceMaterial){Ia=
+0;for(Ma=ba.faceMaterials.length;Ia<Ma;)(ya=ba.faceMaterials[Ia++])&&Ja(s,T,G,ba,ya,ca)}else Ja(s,T,G,ba,ya,ca)}}}O.addRectangle(C)}m.lineWidth=1;m.strokeStyle="rgba( 255, 0, 0, 0.5 )";m.strokeRect(O.getX(),O.getY(),O.getWidth(),O.getHeight());m.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(L,N,V){var W,J,B,P;W=0;for(J=L.lights.length;W<J;W++){B=L.lights[W];if(B instanceof THREE.DirectionalLight){P=N.normalWorld.dot(B.position)*B.intensity;if(P>0){V.r+=B.color.r*P;V.g+=B.color.g*P;V.b+=B.color.b*P}}else if(B instanceof THREE.PointLight){k.sub(B.position,N.centroidWorld);k.normalize();P=N.normalWorld.dot(k)*B.intensity;if(P>0){V.r+=B.color.r*P;V.g+=B.color.g*P;V.b+=B.color.b*P}}}}function c(L,N,V,W,J,B){t=f(v++);t.setAttribute("d","M "+L.positionScreen.x+
+" "+L.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)G.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(T){g.r=n.r;g.g=n.g;g.b=n.b;a(B,W,g);G.r=J.color.r*g.r;G.g=J.color.g*g.g;G.b=J.color.b*g.b;G.updateStyleString()}else G.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){j=1-J.__2near/(J.__farPlusNear-W.z*J.__farMinusNear);
+G.setRGB(j,j,j)}else J instanceof THREE.MeshNormalMaterial&&G.setRGB(h(W.normalWorld.x),h(W.normalWorld.y),h(W.normalWorld.z));J.wireframe?t.setAttribute("style","fill: none; stroke: "+G.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):t.setAttribute("style","fill: "+G.__styleString+"; fill-opacity: "+J.opacity);r.appendChild(t)}function d(L,N,V,W,J,B,P){t=f(v++);t.setAttribute("d",
+"M "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)G.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(T){g.r=n.r;g.g=n.g;g.b=n.b;a(P,J,g);G.r=B.color.r*g.r;G.g=B.color.g*g.g;G.b=B.color.b*g.b;G.updateStyleString()}else G.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){j=
+1-B.__2near/(B.__farPlusNear-J.z*B.__farMinusNear);G.setRGB(j,j,j)}else B instanceof THREE.MeshNormalMaterial&&G.setRGB(h(J.normalWorld.x),h(J.normalWorld.y),h(J.normalWorld.z));B.wireframe?t.setAttribute("style","fill: none; stroke: "+G.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):t.setAttribute("style","fill: "+G.__styleString+"; fill-opacity: "+B.opacity);r.appendChild(t)}
+function f(L){if(p[L]==null){p[L]=document.createElementNS("http://www.w3.org/2000/svg","path");I==0&&p[L].setAttribute("shape-rendering","crispEdges");return p[L]}return p[L]}function h(L){return L<0?Math.min((1+L)*0.5,0.5):0.5+Math.min(L*0.5,0.5)}var b=null,q=new THREE.Projector,r=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,m,z,y,u,x,H,K,M=new THREE.Rectangle,s=new THREE.Rectangle,T=false,G=new THREE.Color(16777215),g=new THREE.Color(16777215),n=new THREE.Color(0),i=new THREE.Color(0),
+e=new THREE.Color(0),j,k=new THREE.Vector3,p=[],w=[],o=[],t,v,D,E,I=1;this.domElement=r;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(L){switch(L){case "high":I=1;break;case "low":I=0}};this.setSize=function(L,N){l=L;m=N;z=l/2;y=m/2;r.setAttribute("viewBox",-z+" "+-y+" "+l+" "+m);r.setAttribute("width",l);r.setAttribute("height",m);M.set(-z,-y,z,y)};this.clear=function(){for(;r.childNodes.length>0;)r.removeChild(r.childNodes[0])};this.render=function(L,N){var V,W,
+J,B,P,O,C,R;this.autoClear&&this.clear();b=q.projectScene(L,N,this.sortElements);E=D=v=0;if(T=L.lights.length>0){C=L.lights;n.setRGB(0,0,0);i.setRGB(0,0,0);e.setRGB(0,0,0);V=0;for(W=C.length;V<W;V++){J=C[V];B=J.color;if(J instanceof THREE.AmbientLight){n.r+=B.r;n.g+=B.g;n.b+=B.b}else if(J instanceof THREE.DirectionalLight){i.r+=B.r;i.g+=B.g;i.b+=B.b}else if(J instanceof THREE.PointLight){e.r+=B.r;e.g+=B.g;e.b+=B.b}}}V=0;for(W=b.length;V<W;V++){C=b[V];s.empty();if(C instanceof THREE.RenderableParticle){u=
+C;u.x*=z;u.y*=-y;J=0;for(B=C.materials.length;J<B;J++)if(R=C.materials[J]){P=u;O=C;R=R;var U=D++;if(w[U]==null){w[U]=document.createElementNS("http://www.w3.org/2000/svg","circle");I==0&&w[U].setAttribute("shape-rendering","crispEdges")}t=w[U];t.setAttribute("cx",P.x);t.setAttribute("cy",P.y);t.setAttribute("r",O.scale.x*z);if(R instanceof THREE.ParticleCircleMaterial){if(T){g.r=n.r+i.r+e.r;g.g=n.g+i.g+e.g;g.b=n.b+i.b+e.b;G.r=R.color.r*g.r;G.g=R.color.g*g.g;G.b=R.color.b*g.b;G.updateStyleString()}else G=
+R.color;t.setAttribute("style","fill: "+G.__styleString)}r.appendChild(t)}}else if(C instanceof THREE.RenderableLine){u=C.v1;x=C.v2;u.positionScreen.x*=z;u.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);if(M.instersects(s)){J=0;for(B=C.materials.length;J<B;)if(R=C.materials[J++]){P=u;O=x;R=R;U=E++;if(o[U]==null){o[U]=document.createElementNS("http://www.w3.org/2000/svg","line");I==
+0&&o[U].setAttribute("shape-rendering","crispEdges")}t=o[U];t.setAttribute("x1",P.positionScreen.x);t.setAttribute("y1",P.positionScreen.y);t.setAttribute("x2",O.positionScreen.x);t.setAttribute("y2",O.positionScreen.y);if(R instanceof THREE.LineBasicMaterial){G.__styleString=R.color.__styleString;t.setAttribute("style","fill: none; stroke: "+G.__styleString+"; stroke-width: "+R.linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.linecap+"; stroke-linejoin: "+R.linejoin);r.appendChild(t)}}}}else if(C instanceof
+THREE.RenderableFace3){u=C.v1;x=C.v2;H=C.v3;u.positionScreen.x*=z;u.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;H.positionScreen.x*=z;H.positionScreen.y*=-y;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(H.positionScreen.x,H.positionScreen.y);if(M.instersects(s)){J=0;for(B=C.meshMaterials.length;J<B;){R=C.meshMaterials[J++];if(R instanceof THREE.MeshFaceMaterial){P=0;for(O=C.faceMaterials.length;P<O;)(R=C.faceMaterials[P++])&&
+c(u,x,H,C,R,L)}else R&&c(u,x,H,C,R,L)}}}else if(C instanceof THREE.RenderableFace4){u=C.v1;x=C.v2;H=C.v3;K=C.v4;u.positionScreen.x*=z;u.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;H.positionScreen.x*=z;H.positionScreen.y*=-y;K.positionScreen.x*=z;K.positionScreen.y*=-y;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(H.positionScreen.x,H.positionScreen.y);s.addPoint(K.positionScreen.x,K.positionScreen.y);if(M.instersects(s)){J=
+0;for(B=C.meshMaterials.length;J<B;){R=C.meshMaterials[J++];if(R instanceof THREE.MeshFaceMaterial){P=0;for(O=C.faceMaterials.length;P<O;)(R=C.faceMaterials[P++])&&d(u,x,H,K,C,R,L)}else R&&d(u,x,H,K,C,R,L)}}}}}};
+THREE.WebGLRenderer=function(a){function c(g,n){g.fragment_shader=n.fragment_shader;g.vertex_shader=n.vertex_shader;g.uniforms=Uniforms.clone(n.uniforms)}function d(g,n){var i;if(g=="fragment")i=b.createShader(b.FRAGMENT_SHADER);else if(g=="vertex")i=b.createShader(b.VERTEX_SHADER);b.shaderSource(i,n);b.compileShader(i);if(!b.getShaderParameter(i,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(i));return null}return i}function f(g){switch(g){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;
 case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;
-case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var h=document.createElement("canvas"),b,q=null,r=null,l=new THREE.Matrix4,m,y=new Float32Array(16),x=new Float32Array(16),
-v=new Float32Array(16),w=new Float32Array(9),G=new Float32Array(16),K=new THREE.Matrix4,L=new THREE.Vector4,t=true,T=new THREE.Color(0),E=0;if(a){if(a.antialias!==undefined)t=a.antialias;a.clearColor!==undefined&&T.setHex(a.clearColor);if(a.clearAlpha!==undefined)E=a.clearAlpha}this.domElement=h;this.autoClear=true;(function(f,k,i){try{b=h.getContext("experimental-webgl",{antialias:f})}catch(g){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);
-b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(k.r,k.g,k.b,i)})(t,T,E);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,k){h.width=f;h.height=k;b.viewport(0,0,h.width,h.height)};this.setClearColor=function(f,k){var i=new THREE.Color(f);b.clearColor(i.r,i.g,i.b,k)};
-this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(f,k){var i,g,n,j=0,o=0,p=0,s,u,z,H=this.lights,F=H.directional.colors,I=H.directional.positions,M=H.point.colors,N=H.point.positions,V=0,W=0;i=0;for(g=k.length;i<g;i++){n=k[i];s=n.color;u=n.position;z=n.intensity;if(n instanceof THREE.AmbientLight){j+=s.r;o+=s.g;p+=s.b}else if(n instanceof THREE.DirectionalLight){F[V*3]=s.r*z;F[V*3+1]=s.g*z;F[V*3+2]=s.b*z;I[V*3]=u.x;I[V*3+1]=u.y;I[V*3+2]=u.z;V+=1}else if(n instanceof
-THREE.PointLight){M[W*3]=s.r*z;M[W*3+1]=s.g*z;M[W*3+2]=s.b*z;N[W*3]=u.x;N[W*3+1]=u.y;N[W*3+2]=u.z;W+=1}}H.point.length=W;H.directional.length=V;H.ambient[0]=j;H.ambient[1]=o;H.ambient[2]=p};this.createParticleBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();f.__webGLParticleBuffer=b.createBuffer();f.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();f.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=function(f){f.__webGLVertexBuffer=
-b.createBuffer();f.__webGLNormalBuffer=b.createBuffer();f.__webGLTangentBuffer=b.createBuffer();f.__webGLUVBuffer=b.createBuffer();f.__webGLUV2Buffer=b.createBuffer();f.__webGLFaceBuffer=b.createBuffer();f.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(f){var k=f.vertices.length;f.__vertexArray=new Float32Array(k*3);f.__lineArray=new Uint16Array(k);f.__webGLLineCount=k};this.initParticleBuffers=function(f){var k=f.vertices.length;f.__vertexArray=new Float32Array(k*3);f.__colorArray=
-new Float32Array(k*3);f.__particleArray=new Uint16Array(k);f.__sortArray=[];f.__webGLParticleCount=k};this.initMeshBuffers=function(f,k){var i,g,n=0,j=0,o=0,p=k.geometry.faces,s=f.faces;i=0;for(g=s.length;i<g;i++){fi=s[i];face=p[fi];if(face instanceof THREE.Face3){n+=3;j+=1;o+=3}else if(face instanceof THREE.Face4){n+=4;j+=2;o+=4}}f.__vertexArray=new Float32Array(n*3);f.__normalArray=new Float32Array(n*3);f.__tangentArray=new Float32Array(n*4);f.__uvArray=new Float32Array(n*2);f.__uv2Array=new Float32Array(n*
-2);f.__faceArray=new Uint16Array(j*3);f.__lineArray=new Uint16Array(o*2);n=false;i=0;for(g=k.materials.length;i<g;i++){p=k.materials[i];if(p instanceof THREE.MeshFaceMaterial){p=0;for(s=f.materials.length;p<s;p++)if(f.materials[p]&&f.materials[p].shading!=undefined&&f.materials[p].shading==THREE.SmoothShading){n=true;break}}else if(p&&p.shading!=undefined&&p.shading==THREE.SmoothShading){n=true;break}if(n)break}f.__needsSmoothNormals=n;f.__webGLFaceCount=j*3;f.__webGLLineCount=o*2};this.setMeshBuffers=
-function(f,k,i){var g,n,j,o,p,s,u,z,H,F,I=0,M=0,N=0,V=0,W=0,J=0,B=0,P=0,O=f.__vertexArray,C=f.__uvArray,R=f.__uv2Array,U=f.__normalArray,Y=f.__tangentArray,fa=f.__faceArray,aa=f.__lineArray,za=f.__needsSmoothNormals,Z=k.geometry,na=Z.__dirtyVertices,oa=Z.__dirtyElements,ka=Z.__dirtyUvs,ga=Z.__dirtyNormals,pa=Z.__dirtyTangents,ea=Z.vertices,qa=f.faces,ca=Z.faces,la=Z.uvs,Ea=Z.uvs2;k=0;for(g=qa.length;k<g;k++){n=qa[k];j=ca[n];s=la[n];n=Ea[n];o=j.vertexNormals;p=j.normal;if(j instanceof THREE.Face3){if(na){u=
-ea[j.a].position;z=ea[j.b].position;H=ea[j.c].position;O[M]=u.x;O[M+1]=u.y;O[M+2]=u.z;O[M+3]=z.x;O[M+4]=z.y;O[M+5]=z.z;O[M+6]=H.x;O[M+7]=H.y;O[M+8]=H.z;M+=9}if(pa&&Z.hasTangents){u=ea[j.a].tangent;z=ea[j.b].tangent;H=ea[j.c].tangent;Y[B]=u.x;Y[B+1]=u.y;Y[B+2]=u.z;Y[B+3]=u.w;Y[B+4]=z.x;Y[B+5]=z.y;Y[B+6]=z.z;Y[B+7]=z.w;Y[B+8]=H.x;Y[B+9]=H.y;Y[B+10]=H.z;Y[B+11]=H.w;B+=12}if(ga)if(o.length==3&&za)for(j=0;j<3;j++){p=o[j];U[J]=p.x;U[J+1]=p.y;U[J+2]=p.z;J+=3}else for(j=0;j<3;j++){U[J]=p.x;U[J+1]=p.y;U[J+
-2]=p.z;J+=3}if(ka&&s)for(j=0;j<3;j++){o=s[j];C[N]=o.u;C[N+1]=o.v;N+=2}if(ka&&n)for(j=0;j<3;j++){s=n[j];R[V]=s.u;R[V+1]=s.v;V+=2}if(oa){fa[W]=I;fa[W+1]=I+1;fa[W+2]=I+2;W+=3;aa[P]=I;aa[P+1]=I+1;aa[P+2]=I;aa[P+3]=I+2;aa[P+4]=I+1;aa[P+5]=I+2;P+=6;I+=3}}else if(j instanceof THREE.Face4){if(na){u=ea[j.a].position;z=ea[j.b].position;H=ea[j.c].position;F=ea[j.d].position;O[M]=u.x;O[M+1]=u.y;O[M+2]=u.z;O[M+3]=z.x;O[M+4]=z.y;O[M+5]=z.z;O[M+6]=H.x;O[M+7]=H.y;O[M+8]=H.z;O[M+9]=F.x;O[M+10]=F.y;O[M+11]=F.z;M+=
-12}if(pa&&Z.hasTangents){u=ea[j.a].tangent;z=ea[j.b].tangent;H=ea[j.c].tangent;j=ea[j.d].tangent;Y[B]=u.x;Y[B+1]=u.y;Y[B+2]=u.z;Y[B+3]=u.w;Y[B+4]=z.x;Y[B+5]=z.y;Y[B+6]=z.z;Y[B+7]=z.w;Y[B+8]=H.x;Y[B+9]=H.y;Y[B+10]=H.z;Y[B+11]=H.w;Y[B+12]=j.x;Y[B+13]=j.y;Y[B+14]=j.z;Y[B+15]=j.w;B+=16}if(ga)if(o.length==4&&za)for(j=0;j<4;j++){p=o[j];U[J]=p.x;U[J+1]=p.y;U[J+2]=p.z;J+=3}else for(j=0;j<4;j++){U[J]=p.x;U[J+1]=p.y;U[J+2]=p.z;J+=3}if(ka&&s)for(j=0;j<4;j++){o=s[j];C[N]=o.u;C[N+1]=o.v;N+=2}if(ka&&n)for(j=0;j<
-4;j++){s=n[j];R[V]=s.u;R[V+1]=s.v;V+=2}if(oa){fa[W]=I;fa[W+1]=I+1;fa[W+2]=I+2;fa[W+3]=I;fa[W+4]=I+2;fa[W+5]=I+3;W+=6;aa[P]=I;aa[P+1]=I+1;aa[P+2]=I;aa[P+3]=I+3;aa[P+4]=I+1;aa[P+5]=I+2;aa[P+6]=I+2;aa[P+7]=I+3;P+=8;I+=4}}}if(na){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,O,i)}if(ga){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,U,i)}if(pa&&Z.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,
-Y,i)}if(ka&&N>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,C,i)}if(ka&&V>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,R,i)}if(oa){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,fa,i);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,aa,i)}};this.setLineBuffers=function(f,k){var i,g,n,j=f.vertices,o=j.length,p=f.__vertexArray,s=f.__lineArray,u=
-f.__dirtyElements;if(f.__dirtyVertices){for(i=0;i<o;i++){g=j[i].position;n=i*3;p[n]=g.x;p[n+1]=g.y;p[n+2]=g.z}b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,p,k)}if(u){for(i=0;i<o;i++)s[i]=i;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,s,k)}};this.setParticleBuffers=function(f,k,i,g){var n,j,o;j=f.vertices;var p=j.length,s=f.colors,u=s.length,z=f.__vertexArray,H=f.__particleArray,F=f.__colorArray,I=f.__sortArray,M=f.__dirtyVertices,
-N=f.__dirtyElements,V=f.__dirtyColors;if(i.sortParticles){K.multiply(g.projectionMatrix,g.matrix);K.multiplySelf(i.matrix);for(n=0;n<p;n++){o=j[n].position;L.copy(o);K.multiplyVector3(L);I[n]=[L.z,n]}I.sort(function(W,J){return J[0]-W[0]});for(n=0;n<p;n++){o=j[I[n][1]].position;g=n*3;z[g]=o.x;z[g+1]=o.y;z[g+2]=o.z}for(j=0;j<u;j++){g=j*3;color=s[I[j][1]];F[g]=color.r;F[g+1]=color.g;F[g+2]=color.b}}else{if(M)for(n=0;n<p;n++){o=j[n].position;g=n*3;z[g]=o.x;z[g+1]=o.y;z[g+2]=o.z}if(V)for(j=0;j<u;j++){color=
-s[j];g=j*3;F[g]=color.r;F[g+1]=color.g;F[g+2]=color.b}}if(N){for(n=0;n<p;n++)H[n]=n;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,H,k)}if(M||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,z,k)}if(V||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,F,k)}};this.initMaterial=function(f,k,i){if(!f.program){var g,n;if(f instanceof THREE.MeshDepthMaterial)c(f,
-THREE.ShaderLib.depth);else if(f instanceof THREE.MeshNormalMaterial)c(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)c(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)c(f,THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)c(f,THREE.ShaderLib.phong);else if(f instanceof THREE.LineBasicMaterial)c(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&c(f,THREE.ShaderLib.particle_basic);var j,o,p,s;n=p=s=0;for(j=k.length;n<
-j;n++){o=k[n];o instanceof THREE.DirectionalLight&&p++;o instanceof THREE.PointLight&&s++}if(s+p<=4){k=p;s=s}else{k=Math.ceil(4*p/(s+p));s=4-k}n={directional:k,point:s};s=f.fragment_shader;k=f.vertex_shader;j={fog:i,map:f.map,env_map:f.env_map,light_map:f.light_map,vertex_colors:f.vertex_colors,maxDirLights:n.directional,maxPointLights:n.point};i=b.createProgram();n=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+j.maxDirLights,"#define MAX_POINT_LIGHTS "+j.maxPointLights,
-j.fog?"#define USE_FOG":"",j.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",j.map?"#define USE_MAP":"",j.env_map?"#define USE_ENVMAP":"",j.light_map?"#define USE_LIGHTMAP":"",j.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");j=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+j.maxDirLights,"#define MAX_POINT_LIGHTS "+j.maxPointLights,j.map?"#define USE_MAP":"",j.env_map?"#define USE_ENVMAP":
-"",j.light_map?"#define USE_LIGHTMAP":"",j.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(i,d("fragment",n+s));b.attachShader(i,d("vertex",j+k));b.linkProgram(i);b.getProgramParameter(i,b.LINK_STATUS)||
-alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(i,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");i.uniforms={};i.attributes={};f.program=i;i=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(g in f.uniforms)i.push(g);g=f.program;s=0;for(k=i.length;s<k;s++){n=i[s];g.uniforms[n]=b.getUniformLocation(g,n)}f=f.program;g=["position","normal","uv","uv2","tangent","color"];i=0;for(s=g.length;i<s;i++){k=g[i];f.attributes[k]=
-b.getAttribLocation(f,k)}}};this.renderBuffer=function(f,k,i,g,n,j){var o;this.initMaterial(g,k,i);o=g.program;if(o!=q){b.useProgram(o);q=o}this.loadCamera(o,f);this.loadMatrices(o);if(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial){this.setupLights(o,k);k=this.lights;g.uniforms.enableLighting.value=k.directional.length+k.point.length;g.uniforms.ambientLightColor.value=k.ambient;g.uniforms.directionalLightColor.value=k.directional.colors;g.uniforms.directionalLightDirection.value=
-k.directional.positions;g.uniforms.pointLightColor.value=k.point.colors;g.uniforms.pointLightPosition.value=k.point.positions}if(g instanceof THREE.MeshBasicMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshPhongMaterial){g.uniforms.diffuse.value.setRGB(g.color.r*g.opacity,g.color.g*g.opacity,g.color.b*g.opacity);g.uniforms.opacity.value=g.opacity;g.uniforms.map.texture=g.map;g.uniforms.light_map.texture=g.light_map;g.uniforms.env_map.texture=g.env_map;g.uniforms.reflectivity.value=
-g.reflectivity;g.uniforms.refraction_ratio.value=g.refraction_ratio;g.uniforms.combine.value=g.combine;g.uniforms.useRefract.value=g.env_map&&g.env_map.mapping instanceof THREE.CubeRefractionMapping;if(i){g.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){g.uniforms.fogNear.value=i.near;g.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)g.uniforms.fogDensity.value=i.density}}if(g instanceof THREE.LineBasicMaterial){g.uniforms.diffuse.value.setRGB(g.color.r*g.opacity,
-g.color.g*g.opacity,g.color.b*g.opacity);g.uniforms.opacity.value=g.opacity;if(i){g.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){g.uniforms.fogNear.value=i.near;g.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)g.uniforms.fogDensity.value=i.density}}if(g instanceof THREE.ParticleBasicMaterial){g.uniforms.psColor.value.setRGB(g.color.r*g.opacity,g.color.g*g.opacity,g.color.b*g.opacity);g.uniforms.opacity.value=g.opacity;g.uniforms.size.value=g.size;g.uniforms.map.texture=
-g.map;if(i){g.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){g.uniforms.fogNear.value=i.near;g.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)g.uniforms.fogDensity.value=i.density}}if(g instanceof THREE.MeshPhongMaterial){g.uniforms.ambient.value.setRGB(g.ambient.r,g.ambient.g,g.ambient.b);g.uniforms.specular.value.setRGB(g.specular.r,g.specular.g,g.specular.b);g.uniforms.shininess.value=g.shininess}if(g instanceof THREE.MeshDepthMaterial){g.uniforms.mNear.value=
-f.near;g.uniforms.mFar.value=f.far}f=g.uniforms;var p,s,u;for(p in f)if(u=o.uniforms[p]){k=f[p];s=k.type;i=k.value;if(s=="i")b.uniform1i(u,i);else if(s=="f")b.uniform1f(u,i);else if(s=="fv1")b.uniform1fv(u,i);else if(s=="fv")b.uniform3fv(u,i);else if(s=="v2")b.uniform2f(u,i.x,i.y);else if(s=="v3")b.uniform3f(u,i.x,i.y,i.z);else if(s=="c")b.uniform3f(u,i.r,i.g,i.b);else if(s=="t"){b.uniform1i(u,i);if(k=k.texture)if(k.image instanceof Array&&k.image.length==6){k=k;i=i;if(k.image.length==6){if(!k.image.__webGLTextureCube&&
-!k.image.__cubeMapInitialized&&k.image.loadCount==6){k.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,k.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(s=0;s<6;++s)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+
-s,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,k.image[s]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);k.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_CUBE_MAP,k.image.__webGLTextureCube)}}else{k=k;i=i;if(!k.__webGLTexture&&k.image.loaded){k.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,k.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,k.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,e(k.wrap_s));
-b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,e(k.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,e(k.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e(k.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_2D,k.__webGLTexture)}}}o=o.attributes;b.bindBuffer(b.ARRAY_BUFFER,n.__webGLVertexBuffer);b.vertexAttribPointer(o.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(o.position);if(o.color>=
-0){b.bindBuffer(b.ARRAY_BUFFER,n.__webGLColorBuffer);b.vertexAttribPointer(o.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(o.color)}if(o.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,n.__webGLNormalBuffer);b.vertexAttribPointer(o.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(o.normal)}if(o.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,n.__webGLTangentBuffer);b.vertexAttribPointer(o.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(o.tangent)}if(o.uv>=0)if(n.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,
-n.__webGLUVBuffer);b.vertexAttribPointer(o.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(o.uv)}else b.disableVertexAttribArray(o.uv);if(o.uv2>=0)if(n.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,n.__webGLUV2Buffer);b.vertexAttribPointer(o.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(o.uv2)}else b.disableVertexAttribArray(o.uv2);if(g.wireframe||g instanceof THREE.LineBasicMaterial){o=g.wireframe_linewidth!==undefined?g.wireframe_linewidth:g.linewidth!==undefined?g.linewidth:1;g=g instanceof
-THREE.LineBasicMaterial&&j.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(o);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);b.drawElements(g,n.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(g instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,n.__webGLParticleBuffer);b.drawElements(b.POINTS,n.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,n.__webGLFaceCount,b.UNSIGNED_SHORT,
-0)}};this.renderPass=function(f,k,i,g,n,j,o){var p,s,u,z,H;u=0;for(z=g.materials.length;u<z;u++){p=g.materials[u];if(p instanceof THREE.MeshFaceMaterial){p=0;for(s=n.materials.length;p<s;p++)if((H=n.materials[p])&&H.blending==j&&H.opacity<1==o){this.setBlending(H.blending);this.renderBuffer(f,k,i,H,n,g)}}else if((H=p)&&H.blending==j&&H.opacity<1==o){this.setBlending(H.blending);this.renderBuffer(f,k,i,H,n,g)}}};this.render=function(f,k,i,g){var n,j,o,p=f.lights,s=f.fog;k.autoUpdateMatrix&&k.updateMatrix();
-y.set(k.matrix.flatten());v.set(k.projectionMatrix.flatten());this.initWebGLObjects(f,k);g=g!==undefined?g:true;if(i&&!i.__webGLFramebuffer){i.__webGLFramebuffer=b.createFramebuffer();i.__webGLRenderbuffer=b.createRenderbuffer();i.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,i.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,i.width,i.height);b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,e(i.wrap_s));b.texParameteri(b.TEXTURE_2D,
-b.TEXTURE_WRAP_T,e(i.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,e(i.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e(i.min_filter));b.texImage2D(b.TEXTURE_2D,0,e(i.format),i.width,i.height,0,e(i.format),e(i.type),null);b.bindFramebuffer(b.FRAMEBUFFER,i.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,i.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,i.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,
-null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(i){n=i.__webGLFramebuffer;o=i.width;j=i.height}else{n=null;o=h.width;j=h.height}if(n!=r){b.bindFramebuffer(b.FRAMEBUFFER,n);b.viewport(0,0,o,j);g&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);r=n}this.autoClear&&this.clear();n=f.__webGLObjects.length;for(g=0;g<n;g++){j=f.__webGLObjects[g];o=j.object;if(o.visible){o.autoUpdateMatrix&&o.updateMatrix();if(o.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);
-o.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}}for(g=0;g<n;g++){j=f.__webGLObjects[g];o=j.object;j=j.buffer;if(o.visible){this.setupMatrices(o,k);this.renderPass(k,p,s,o,j,THREE.NormalBlending,false)}}for(g=0;g<n;g++){j=f.__webGLObjects[g];o=j.object;j=j.buffer;if(o.visible){this.setupMatrices(o,k);this.renderPass(k,p,s,o,j,THREE.AdditiveBlending,false);this.renderPass(k,p,s,o,j,THREE.SubtractiveBlending,false);this.renderPass(k,p,s,o,j,THREE.AdditiveBlending,true);this.renderPass(k,p,s,o,j,THREE.SubtractiveBlending,
-true);this.renderPass(k,p,s,o,j,THREE.NormalBlending,true);this.renderPass(k,p,s,o,j,THREE.BillboardBlending,false)}}if(i&&i.min_filter!==THREE.NearestFilter&&i.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(f,k){function i(z,H,F,I){if(z[H]==undefined){f.__webGLObjects.push({buffer:F,object:I});z[H]=1}}var g,n,j,o,p,s,u;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap=
-{}}g=0;for(n=f.objects.length;g<n;g++){j=f.objects[g];p=j.geometry;if(f.__webGLObjectsMap[j.id]==undefined)f.__webGLObjectsMap[j.id]={};u=f.__webGLObjectsMap[j.id];if(j instanceof THREE.Mesh){for(o in p.geometryChunks){s=p.geometryChunks[o];if(!s.__webGLVertexBuffer){this.createMeshBuffers(s);this.initMeshBuffers(s,j);p.__dirtyVertices=true;p.__dirtyElements=true;p.__dirtyUvs=true;p.__dirtyNormals=true;p.__dirtyTangents=true}if(p.__dirtyVertices||p.__dirtyElements||p.__dirtyUvs)this.setMeshBuffers(s,
-j,b.DYNAMIC_DRAW);i(u,o,s,j)}p.__dirtyVertices=false;p.__dirtyElements=false;p.__dirtyUvs=false;p.__dirtyNormals=false;p.__dirtyTangents=false}else if(j instanceof THREE.Line){if(!p.__webGLVertexBuffer){this.createLineBuffers(p);this.initLineBuffers(p);p.__dirtyVertices=true;p.__dirtyElements=true}p.__dirtyVertices&&this.setLineBuffers(p,b.DYNAMIC_DRAW);i(u,0,p,j);p.__dirtyVertices=false;p.__dirtyElements=false}else if(j instanceof THREE.ParticleSystem){if(!p.__webGLVertexBuffer){this.createParticleBuffers(p);
-this.initParticleBuffers(p);p.__dirtyVertices=true;p.__dirtyColors=true;p.__dirtyElements=true}if(p.__dirtyVertices||p.__dirtyColors||j.sortParticles)this.setParticleBuffers(p,b.DYNAMIC_DRAW,j,k);i(u,0,p,j);p.__dirtyVertices=false;p.__dirtyColors=false;p.__dirtyElements=false}}};this.removeObject=function(f,k){var i,g;for(i=f.__webGLObjects.length-1;i>=0;i--){g=f.__webGLObjects[i].object;k==g&&f.__webGLObjects.splice(i,1)}};this.setupMatrices=function(f,k){l.multiply(k.matrix,f.matrix);x.set(l.flatten());
-m=THREE.Matrix4.makeInvert3x3(l).transpose();w.set(m.m);G.set(f.matrix.flatten())};this.loadMatrices=function(f){b.uniformMatrix4fv(f.uniforms.viewMatrix,false,y);b.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,x);b.uniformMatrix4fv(f.uniforms.projectionMatrix,false,v);b.uniformMatrix3fv(f.uniforms.normalMatrix,false,w);b.uniformMatrix4fv(f.uniforms.objectMatrix,false,G)};this.loadCamera=function(f,k){b.uniform3f(f.uniforms.cameraPosition,k.position.x,k.position.y,k.position.z)};this.setBlending=
-function(f){switch(f){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(f,k){if(f){!k||k=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(f=="back")b.cullFace(b.BACK);else f=="front"?
-b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
-THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
-envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
-map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",
-lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\nlightmapColor = texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
+case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var h=document.createElement("canvas"),b,q=null,r=null,l=new THREE.Matrix4,m,z=new Float32Array(16),y=new Float32Array(16),
+u=new Float32Array(16),x=new Float32Array(9),H=new Float32Array(16),K=new THREE.Matrix4,M=new THREE.Vector4,s=true,T=new THREE.Color(0),G=0;if(a){if(a.antialias!==undefined)s=a.antialias;a.clearColor!==undefined&&T.setHex(a.clearColor);if(a.clearAlpha!==undefined)G=a.clearAlpha}this.domElement=h;this.autoClear=true;(function(g,n,i){try{b=h.getContext("experimental-webgl",{antialias:g})}catch(e){console.log(e)}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,
+0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(n.r,n.g,n.b,i)})(s,T,G);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(g,n){h.width=g;h.height=n;b.viewport(0,0,h.width,h.height)};this.setClearColor=function(g,n){var i=new THREE.Color(g);b.clearColor(i.r,
+i.g,i.b,n)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(g,n){var i,e,j,k=0,p=0,w=0,o,t,v,D=this.lights,E=D.directional.colors,I=D.directional.positions,L=D.point.colors,N=D.point.positions,V=0,W=0;i=0;for(e=n.length;i<e;i++){j=n[i];o=j.color;t=j.position;v=j.intensity;if(j instanceof THREE.AmbientLight){k+=o.r;p+=o.g;w+=o.b}else if(j instanceof THREE.DirectionalLight){E[V*3]=o.r*v;E[V*3+1]=o.g*v;E[V*3+2]=o.b*v;I[V*3]=t.x;I[V*3+1]=t.y;I[V*3+2]=t.z;
+V+=1}else if(j instanceof THREE.PointLight){L[W*3]=o.r*v;L[W*3+1]=o.g*v;L[W*3+2]=o.b*v;N[W*3]=t.x;N[W*3+1]=t.y;N[W*3+2]=t.z;W+=1}}D.point.length=W;D.directional.length=V;D.ambient[0]=k;D.ambient[1]=p;D.ambient[2]=w};this.createParticleBuffers=function(g){g.__webGLVertexBuffer=b.createBuffer();g.__webGLParticleBuffer=b.createBuffer();g.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(g){g.__webGLVertexBuffer=b.createBuffer();g.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=
+function(g){g.__webGLVertexBuffer=b.createBuffer();g.__webGLNormalBuffer=b.createBuffer();g.__webGLTangentBuffer=b.createBuffer();g.__webGLUVBuffer=b.createBuffer();g.__webGLUV2Buffer=b.createBuffer();g.__webGLFaceBuffer=b.createBuffer();g.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(g){var n=g.vertices.length;g.__vertexArray=new Float32Array(n*3);g.__lineArray=new Uint16Array(n);g.__webGLLineCount=n};this.initParticleBuffers=function(g){var n=g.vertices.length;g.__vertexArray=
+new Float32Array(n*3);g.__colorArray=new Float32Array(n*3);g.__particleArray=new Uint16Array(n);g.__sortArray=[];g.__webGLParticleCount=n};this.initMeshBuffers=function(g,n){var i,e,j=0,k=0,p=0,w=n.geometry.faces,o=g.faces;i=0;for(e=o.length;i<e;i++){fi=o[i];face=w[fi];if(face instanceof THREE.Face3){j+=3;k+=1;p+=3}else if(face instanceof THREE.Face4){j+=4;k+=2;p+=4}}g.__vertexArray=new Float32Array(j*3);g.__normalArray=new Float32Array(j*3);g.__tangentArray=new Float32Array(j*4);g.__uvArray=new Float32Array(j*
+2);g.__uv2Array=new Float32Array(j*2);g.__faceArray=new Uint16Array(k*3);g.__lineArray=new Uint16Array(p*2);j=false;i=0;for(e=n.materials.length;i<e;i++){w=n.materials[i];if(w instanceof THREE.MeshFaceMaterial){w=0;for(o=g.materials.length;w<o;w++)if(g.materials[w]&&g.materials[w].shading!=undefined&&g.materials[w].shading==THREE.SmoothShading){j=true;break}}else if(w&&w.shading!=undefined&&w.shading==THREE.SmoothShading){j=true;break}if(j)break}g.__needsSmoothNormals=j;g.__webGLFaceCount=k*3;g.__webGLLineCount=
+p*2};this.setMeshBuffers=function(g,n,i){var e,j,k,p,w,o,t,v,D,E,I=0,L=0,N=0,V=0,W=0,J=0,B=0,P=0,O=g.__vertexArray,C=g.__uvArray,R=g.__uv2Array,U=g.__normalArray,Y=g.__tangentArray,fa=g.__faceArray,aa=g.__lineArray,za=g.__needsSmoothNormals,Z=n.geometry,na=Z.__dirtyVertices,oa=Z.__dirtyElements,ka=Z.__dirtyUvs,ga=Z.__dirtyNormals,pa=Z.__dirtyTangents,ea=Z.vertices,qa=g.faces,ca=Z.faces,la=Z.uvs,Ea=Z.uvs2;n=0;for(e=qa.length;n<e;n++){j=qa[n];k=ca[j];o=la[j];j=Ea[j];p=k.vertexNormals;w=k.normal;if(k instanceof
+THREE.Face3){if(na){t=ea[k.a].position;v=ea[k.b].position;D=ea[k.c].position;O[L]=t.x;O[L+1]=t.y;O[L+2]=t.z;O[L+3]=v.x;O[L+4]=v.y;O[L+5]=v.z;O[L+6]=D.x;O[L+7]=D.y;O[L+8]=D.z;L+=9}if(pa&&Z.hasTangents){t=ea[k.a].tangent;v=ea[k.b].tangent;D=ea[k.c].tangent;Y[B]=t.x;Y[B+1]=t.y;Y[B+2]=t.z;Y[B+3]=t.w;Y[B+4]=v.x;Y[B+5]=v.y;Y[B+6]=v.z;Y[B+7]=v.w;Y[B+8]=D.x;Y[B+9]=D.y;Y[B+10]=D.z;Y[B+11]=D.w;B+=12}if(ga)if(p.length==3&&za)for(k=0;k<3;k++){w=p[k];U[J]=w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}else for(k=0;k<3;k++){U[J]=
+w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}if(ka&&o)for(k=0;k<3;k++){p=o[k];C[N]=p.u;C[N+1]=p.v;N+=2}if(ka&&j)for(k=0;k<3;k++){o=j[k];R[V]=o.u;R[V+1]=o.v;V+=2}if(oa){fa[W]=I;fa[W+1]=I+1;fa[W+2]=I+2;W+=3;aa[P]=I;aa[P+1]=I+1;aa[P+2]=I;aa[P+3]=I+2;aa[P+4]=I+1;aa[P+5]=I+2;P+=6;I+=3}}else if(k instanceof THREE.Face4){if(na){t=ea[k.a].position;v=ea[k.b].position;D=ea[k.c].position;E=ea[k.d].position;O[L]=t.x;O[L+1]=t.y;O[L+2]=t.z;O[L+3]=v.x;O[L+4]=v.y;O[L+5]=v.z;O[L+6]=D.x;O[L+7]=D.y;O[L+8]=D.z;O[L+9]=E.x;O[L+10]=
+E.y;O[L+11]=E.z;L+=12}if(pa&&Z.hasTangents){t=ea[k.a].tangent;v=ea[k.b].tangent;D=ea[k.c].tangent;k=ea[k.d].tangent;Y[B]=t.x;Y[B+1]=t.y;Y[B+2]=t.z;Y[B+3]=t.w;Y[B+4]=v.x;Y[B+5]=v.y;Y[B+6]=v.z;Y[B+7]=v.w;Y[B+8]=D.x;Y[B+9]=D.y;Y[B+10]=D.z;Y[B+11]=D.w;Y[B+12]=k.x;Y[B+13]=k.y;Y[B+14]=k.z;Y[B+15]=k.w;B+=16}if(ga)if(p.length==4&&za)for(k=0;k<4;k++){w=p[k];U[J]=w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}else for(k=0;k<4;k++){U[J]=w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}if(ka&&o)for(k=0;k<4;k++){p=o[k];C[N]=p.u;C[N+1]=p.v;N+=
+2}if(ka&&j)for(k=0;k<4;k++){o=j[k];R[V]=o.u;R[V+1]=o.v;V+=2}if(oa){fa[W]=I;fa[W+1]=I+1;fa[W+2]=I+2;fa[W+3]=I;fa[W+4]=I+2;fa[W+5]=I+3;W+=6;aa[P]=I;aa[P+1]=I+1;aa[P+2]=I;aa[P+3]=I+3;aa[P+4]=I+1;aa[P+5]=I+2;aa[P+6]=I+2;aa[P+7]=I+3;P+=8;I+=4}}}if(na){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,O,i)}if(ga){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,U,i)}if(pa&&Z.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,
+Y,i)}if(ka&&N>0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,C,i)}if(ka&&V>0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,R,i)}if(oa){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,fa,i);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,aa,i)}};this.setLineBuffers=function(g,n){var i,e,j,k=g.vertices,p=k.length,w=g.__vertexArray,o=g.__lineArray,t=
+g.__dirtyElements;if(g.__dirtyVertices){for(i=0;i<p;i++){e=k[i].position;j=i*3;w[j]=e.x;w[j+1]=e.y;w[j+2]=e.z}b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,w,n)}if(t){for(i=0;i<p;i++)o[i]=i;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,o,n)}};this.setParticleBuffers=function(g,n,i,e){var j,k,p;k=g.vertices;var w=k.length,o=g.colors,t=o.length,v=g.__vertexArray,D=g.__particleArray,E=g.__colorArray,I=g.__sortArray,L=g.__dirtyVertices,
+N=g.__dirtyElements,V=g.__dirtyColors;if(i.sortParticles){K.multiply(e.projectionMatrix,e.matrix);K.multiplySelf(i.matrix);for(j=0;j<w;j++){p=k[j].position;M.copy(p);K.multiplyVector3(M);I[j]=[M.z,j]}I.sort(function(W,J){return J[0]-W[0]});for(j=0;j<w;j++){p=k[I[j][1]].position;e=j*3;v[e]=p.x;v[e+1]=p.y;v[e+2]=p.z}for(k=0;k<t;k++){e=k*3;color=o[I[k][1]];E[e]=color.r;E[e+1]=color.g;E[e+2]=color.b}}else{if(L)for(j=0;j<w;j++){p=k[j].position;e=j*3;v[e]=p.x;v[e+1]=p.y;v[e+2]=p.z}if(V)for(k=0;k<t;k++){color=
+o[k];e=k*3;E[e]=color.r;E[e+1]=color.g;E[e+2]=color.b}}if(N){for(j=0;j<w;j++)D[j]=j;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,D,n)}if(L||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v,n)}if(V||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,E,n)}};this.initMaterial=function(g,n,i){if(!g.program){var e,j;if(g instanceof THREE.MeshDepthMaterial)c(g,
+THREE.ShaderLib.depth);else if(g instanceof THREE.MeshNormalMaterial)c(g,THREE.ShaderLib.normal);else if(g instanceof THREE.MeshBasicMaterial)c(g,THREE.ShaderLib.basic);else if(g instanceof THREE.MeshLambertMaterial)c(g,THREE.ShaderLib.lambert);else if(g instanceof THREE.MeshPhongMaterial)c(g,THREE.ShaderLib.phong);else if(g instanceof THREE.LineBasicMaterial)c(g,THREE.ShaderLib.basic);else g instanceof THREE.ParticleBasicMaterial&&c(g,THREE.ShaderLib.particle_basic);var k,p,w,o;j=w=o=0;for(k=n.length;j<
+k;j++){p=n[j];p instanceof THREE.DirectionalLight&&w++;p instanceof THREE.PointLight&&o++}if(o+w<=4){n=w;o=o}else{n=Math.ceil(4*w/(o+w));o=4-n}j={directional:n,point:o};o=g.fragment_shader;n=g.vertex_shader;k={fog:i,map:g.map,env_map:g.env_map,light_map:g.light_map,vertex_colors:g.vertex_colors,maxDirLights:j.directional,maxPointLights:j.point};i=b.createProgram();j=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+k.maxDirLights,"#define MAX_POINT_LIGHTS "+k.maxPointLights,
+k.fog?"#define USE_FOG":"",k.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",k.map?"#define USE_MAP":"",k.env_map?"#define USE_ENVMAP":"",k.light_map?"#define USE_LIGHTMAP":"",k.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");k=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+k.maxDirLights,"#define MAX_POINT_LIGHTS "+k.maxPointLights,k.map?"#define USE_MAP":"",k.env_map?"#define USE_ENVMAP":
+"",k.light_map?"#define USE_LIGHTMAP":"",k.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(i,d("fragment",j+o));b.attachShader(i,d("vertex",k+n));b.linkProgram(i);b.getProgramParameter(i,b.LINK_STATUS)||
+alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(i,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");i.uniforms={};i.attributes={};g.program=i;i=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(e in g.uniforms)i.push(e);e=g.program;o=0;for(n=i.length;o<n;o++){j=i[o];e.uniforms[j]=b.getUniformLocation(e,j)}g=g.program;e=["position","normal","uv","uv2","tangent","color"];i=0;for(o=e.length;i<o;i++){n=e[i];g.attributes[n]=
+b.getAttribLocation(g,n)}}};this.setProgram=function(g,n,i,e){this.initMaterial(e,n,i);var j=e.program;if(j!=q){b.useProgram(j);q=j}this.loadCamera(j,g);this.loadMatrices(j);if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial){this.setupLights(j,n);n=this.lights;e.uniforms.enableLighting.value=n.directional.length+n.point.length;e.uniforms.ambientLightColor.value=n.ambient;e.uniforms.directionalLightColor.value=n.directional.colors;e.uniforms.directionalLightDirection.value=
+n.directional.positions;e.uniforms.pointLightColor.value=n.point.colors;e.uniforms.pointLightPosition.value=n.point.positions}if(e instanceof THREE.MeshBasicMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshPhongMaterial){e.uniforms.diffuse.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;e.uniforms.map.texture=e.map;e.uniforms.light_map.texture=e.light_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(i){e.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){e.uniforms.fogNear.value=i.near;e.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)e.uniforms.fogDensity.value=i.density}}if(e instanceof THREE.LineBasicMaterial){e.uniforms.diffuse.value.setRGB(e.color.r*e.opacity,
+e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;if(i){e.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){e.uniforms.fogNear.value=i.near;e.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)e.uniforms.fogDensity.value=i.density}}if(e instanceof THREE.ParticleBasicMaterial){e.uniforms.psColor.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;e.uniforms.size.value=e.size;e.uniforms.map.texture=
+e.map;if(i){e.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){e.uniforms.fogNear.value=i.near;e.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)e.uniforms.fogDensity.value=i.density}}if(e instanceof THREE.MeshPhongMaterial){e.uniforms.ambient.value.setRGB(e.ambient.r,e.ambient.g,e.ambient.b);e.uniforms.specular.value.setRGB(e.specular.r,e.specular.g,e.specular.b);e.uniforms.shininess.value=e.shininess}if(e instanceof THREE.MeshDepthMaterial){e.uniforms.mNear.value=
+g.near;e.uniforms.mFar.value=g.far}g=e.uniforms;var k,p;for(k in g)if(p=j.uniforms[k]){e=g[k];n=e.type;i=e.value;if(n=="i")b.uniform1i(p,i);else if(n=="f")b.uniform1f(p,i);else if(n=="fv1")b.uniform1fv(p,i);else if(n=="fv")b.uniform3fv(p,i);else if(n=="v2")b.uniform2f(p,i.x,i.y);else if(n=="v3")b.uniform3f(p,i.x,i.y,i.z);else if(n=="c")b.uniform3f(p,i.r,i.g,i.b);else if(n=="t"){b.uniform1i(p,i);if(e=e.texture)if(e.image instanceof Array&&e.image.length==6){e=e;i=i;if(e.image.length==6){if(!e.image.__webGLTextureCube&&
+!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(n=0;n<6;++n)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+
+n,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.image[n]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}else{e=e;i=i;if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,f(e.wrap_s));
+b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,f(e.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,f(e.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,f(e.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_2D,e.__webGLTexture)}}}return j};this.renderBuffer=function(g,n,i,e,j,k){g=this.setProgram(g,n,i,e,k).attributes;b.bindBuffer(b.ARRAY_BUFFER,j.__webGLVertexBuffer);b.vertexAttribPointer(g.position,
+3,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.position);if(g.color>=0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLColorBuffer);b.vertexAttribPointer(g.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.color)}if(g.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLNormalBuffer);b.vertexAttribPointer(g.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.normal)}if(g.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLTangentBuffer);b.vertexAttribPointer(g.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.tangent)}if(g.uv>=
+0)if(j.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLUVBuffer);b.vertexAttribPointer(g.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.uv)}else b.disableVertexAttribArray(g.uv);if(g.uv2>=0)if(j.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLUV2Buffer);b.vertexAttribPointer(g.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.uv2)}else b.disableVertexAttribArray(g.uv2);if(e.wireframe||e instanceof THREE.LineBasicMaterial){g=e.wireframe_linewidth!==undefined?e.wireframe_linewidth:
+e.linewidth!==undefined?e.linewidth:1;e=e instanceof THREE.LineBasicMaterial&&k.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(g);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLLineBuffer);b.drawElements(e,j.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(e instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLParticleBuffer);b.drawElements(b.POINTS,j.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,
+j.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(g,n,i,e,j,k,p){var w,o,t,v,D;t=0;for(v=e.materials.length;t<v;t++){w=e.materials[t];if(w instanceof THREE.MeshFaceMaterial){w=0;for(o=j.materials.length;w<o;w++)if((D=j.materials[w])&&D.blending==k&&D.opacity<1==p){this.setBlending(D.blending);this.renderBuffer(g,n,i,D,j,e)}}else if((D=w)&&D.blending==k&&D.opacity<1==p){this.setBlending(D.blending);this.renderBuffer(g,n,i,D,j,e)}}};this.renderPassImmediate=function(g,n,i,e,j,k){var p,
+w,o,t;p=0;for(w=e.materials.length;p<w;p++)if((o=e.materials[p])&&o.blending==j&&o.opacity<1==k){this.setBlending(o.blending);t=this.setProgram(g,n,i,o,e);e.render(function(v){var D=t;if(!v.__webGLVertexBuffer)v.__webGLVertexBuffer=b.createBuffer();if(!v.__webGLNormalBuffer)v.__webGLNormalBuffer=b.createBuffer();if(v.hasPos){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(D.attributes.position);b.vertexAttribPointer(D.attributes.position,
+3,b.FLOAT,false,0,0)}if(v.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,v.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(D.attributes.normal);b.vertexAttribPointer(D.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,v.count);v.count=0})}};this.render=function(g,n,i,e){var j,k,p,w=g.lights,o=g.fog;n.autoUpdateMatrix&&n.updateMatrix();z.set(n.matrix.flatten());u.set(n.projectionMatrix.flatten());this.initWebGLObjects(g,n);e=e!==undefined?
+e:true;if(i&&!i.__webGLFramebuffer){i.__webGLFramebuffer=b.createFramebuffer();i.__webGLRenderbuffer=b.createRenderbuffer();i.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,i.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,i.width,i.height);b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,f(i.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,f(i.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,
+f(i.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,f(i.min_filter));b.texImage2D(b.TEXTURE_2D,0,f(i.format),i.width,i.height,0,f(i.format),f(i.type),null);b.bindFramebuffer(b.FRAMEBUFFER,i.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,i.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,i.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,
+null)}if(i){j=i.__webGLFramebuffer;p=i.width;k=i.height}else{j=null;p=h.width;k=h.height}if(j!=r){b.bindFramebuffer(b.FRAMEBUFFER,j);b.viewport(0,0,p,k);e&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);r=j}this.autoClear&&this.clear();j=g.__webGLObjects.length;for(e=0;e<j;e++){k=g.__webGLObjects[e];p=k.object;if(p.visible){p.autoUpdateMatrix&&p.updateMatrix();if(p.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);p.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}}for(e=0;e<j;e++){k=g.__webGLObjects[e];
+p=k.object;k=k.buffer;if(p.visible){p.autoUpdateMatrix&&p.updateMatrix();this.setupMatrices(p,n);this.renderPass(n,w,o,p,k,THREE.NormalBlending,false)}}for(e=0;e<g.__webGLObjectsImmediate.length;e++){k=g.__webGLObjectsImmediate[e];p=k.object;if(p.visible){this.setupMatrices(p,n);this.renderPassImmediate(n,w,o,p,THREE.NormalBlending,false)}}for(e=0;e<j;e++){k=g.__webGLObjects[e];p=k.object;k=k.buffer;if(p.visible){this.setupMatrices(p,n);this.renderPass(n,w,o,p,k,THREE.AdditiveBlending,false);this.renderPass(n,
+w,o,p,k,THREE.SubtractiveBlending,false);this.renderPass(n,w,o,p,k,THREE.AdditiveBlending,true);this.renderPass(n,w,o,p,k,THREE.SubtractiveBlending,true);this.renderPass(n,w,o,p,k,THREE.NormalBlending,true);this.renderPass(n,w,o,p,k,THREE.BillboardBlending,false)}}if(i&&i.min_filter!==THREE.NearestFilter&&i.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(g,n){function i(D,
+E,I,L){if(D[E]==undefined){g.__webGLObjects.push({buffer:I,object:L});D[E]=1}}function e(D,E,I){if(D[E]==undefined){g.__webGLObjectsImmediate.push({object:I});D[E]=1}}var j,k,p,w,o,t,v;if(!g.__webGLObjects){g.__webGLObjects=[];g.__webGLObjectsMap={};g.__webGLObjectsImmediate=[]}j=0;for(k=g.objects.length;j<k;j++){p=g.objects[j];o=p.geometry;if(g.__webGLObjectsMap[p.id]==undefined)g.__webGLObjectsMap[p.id]={};v=g.__webGLObjectsMap[p.id];if(p instanceof THREE.Mesh){for(w in o.geometryChunks){t=o.geometryChunks[w];
+if(!t.__webGLVertexBuffer){this.createMeshBuffers(t);this.initMeshBuffers(t,p);o.__dirtyVertices=true;o.__dirtyElements=true;o.__dirtyUvs=true;o.__dirtyNormals=true;o.__dirtyTangents=true}if(o.__dirtyVertices||o.__dirtyElements||o.__dirtyUvs)this.setMeshBuffers(t,p,b.DYNAMIC_DRAW);i(v,w,t,p)}o.__dirtyVertices=false;o.__dirtyElements=false;o.__dirtyUvs=false;o.__dirtyNormals=false;o.__dirtyTangents=false}else if(p instanceof THREE.Line){if(!o.__webGLVertexBuffer){this.createLineBuffers(o);this.initLineBuffers(o);
+o.__dirtyVertices=true;o.__dirtyElements=true}o.__dirtyVertices&&this.setLineBuffers(o,b.DYNAMIC_DRAW);i(v,0,o,p);o.__dirtyVertices=false;o.__dirtyElements=false}else if(p instanceof THREE.ParticleSystem){if(!o.__webGLVertexBuffer){this.createParticleBuffers(o);this.initParticleBuffers(o);o.__dirtyVertices=true;o.__dirtyColors=true;o.__dirtyElements=true}if(o.__dirtyVertices||o.__dirtyColors||p.sortParticles)this.setParticleBuffers(o,b.DYNAMIC_DRAW,p,n);i(v,0,o,p);o.__dirtyVertices=false;o.__dirtyColors=
+false;o.__dirtyElements=false}else p instanceof THREE.MarchingCubes&&e(v,0,p)}};this.removeObject=function(g,n){var i,e;for(i=g.__webGLObjects.length-1;i>=0;i--){e=g.__webGLObjects[i].object;n==e&&g.__webGLObjects.splice(i,1)}};this.setupMatrices=function(g,n){l.multiply(n.matrix,g.matrix);y.set(l.flatten());m=THREE.Matrix4.makeInvert3x3(l).transpose();x.set(m.m);H.set(g.matrix.flatten())};this.loadMatrices=function(g){b.uniformMatrix4fv(g.uniforms.viewMatrix,false,z);b.uniformMatrix4fv(g.uniforms.modelViewMatrix,
+false,y);b.uniformMatrix4fv(g.uniforms.projectionMatrix,false,u);b.uniformMatrix3fv(g.uniforms.normalMatrix,false,x);b.uniformMatrix4fv(g.uniforms.objectMatrix,false,H)};this.loadCamera=function(g,n){b.uniform3f(g.uniforms.cameraPosition,n.position.x,n.position.y,n.position.z)};this.setBlending=function(g){switch(g){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);
+b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(g,n){if(g){!n||n=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(g=="back")b.cullFace(b.BACK);else g=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
+THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
+envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",
+envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
+map_particle_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",
+lightmap_fragment:"#ifdef USE_LIGHTMAP\nlightmapColor = texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
 lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
 lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse  = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse  += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse  = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse  += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif",
 color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\nvertexColor = vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif"};

+ 210 - 171
build/ThreeExtras.js

@@ -1,6 +1,6 @@
 // ThreeExtras.js r32 - 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,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var e,f,b,l,h,g;if(d==0)e=f=b=0;else{l=Math.floor(a*6);h=a*6-l;a=d*(1-c);g=d*(1-c*h);c=d*(1-c*(1-h));switch(l){case 1:e=g;f=d;b=a;break;case 2:e=a;f=d;b=c;break;case 3:e=a;f=g;b=d;break;case 4:e=c;f=a;b=d;break;case 5:e=d;f=a;b=g;break;case 6:case 0:e=d;f=c;b=a}}this.r=e;this.g=f;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
+THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var e,f,b,h,k,g;if(d==0)e=f=b=0;else{h=Math.floor(a*6);k=a*6-h;a=d*(1-c);g=d*(1-c*k);c=d*(1-c*(1-k));switch(h){case 1:e=g;f=d;b=a;break;case 2:e=a;f=d;b=c;break;case 3:e=a;f=g;b=d;break;case 4:e=c;f=a;b=d;break;case 5:e=d;f=a;b=g;break;case 6:case 0:e=d;f=c;b=a}}this.r=e;this.g=f;this.b=b;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,c){this.x=a||0;this.y=c||0};
 THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;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,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.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*
@@ -13,47 +13,47 @@ THREE.Vector4=function(a,c,d,e){this.x=a||0;this.y=c||0;this.z=d||0;this.w=e||1}
 THREE.Vector4.prototype={set:function(a,c,d,e){this.x=a;this.y=c;this.z=d;this.w=e;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.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,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},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,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,f=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)f=f.concat(this.intersectObject(d))}f.sort(function(b,l){return b.distance-l.distance});return f},intersectObject:function(a){function c(G,u,H,n){n=n.clone().subSelf(u);H=H.clone().subSelf(u);var k=G.clone().subSelf(u);G=n.dot(n);u=n.dot(H);n=n.dot(k);var o=H.dot(H);H=H.dot(k);k=1/(G*o-u*u);o=(o*n-u*H)*k;G=(G*H-u*n)*k;return o>0&&G>0&&o+G<1}var d,e,f,b,l,h,g,m,y,C,
-w,p=a.geometry,z=p.vertices,F=[];d=0;for(e=p.faces.length;d<e;d++){f=p.faces[d];C=this.origin.clone();w=this.direction.clone();b=a.matrix.multiplyVector3(z[f.a].position.clone());l=a.matrix.multiplyVector3(z[f.b].position.clone());h=a.matrix.multiplyVector3(z[f.c].position.clone());g=f instanceof THREE.Face4?a.matrix.multiplyVector3(z[f.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(f.normal.clone());y=w.dot(m);if(y<0){m=m.dot((new THREE.Vector3).sub(b,C))/y;C=C.addSelf(w.multiplyScalar(m));
-if(f instanceof THREE.Face3){if(c(C,b,l,h)){f={distance:this.origin.distanceTo(C),point:C,face:f,object:a};F.push(f)}}else if(f instanceof THREE.Face4)if(c(C,b,l,g)||c(C,l,h,g)){f={distance:this.origin.distanceTo(C),point:C,face:f,object:a};F.push(f)}}}return F}};
-THREE.Rectangle=function(){function a(){b=e-c;l=f-d}var c,d,e,f,b,l,h=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return b};this.getHeight=function(){return l};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(g,m,y,C){h=false;c=g;d=m;e=y;f=C;a()};this.addPoint=function(g,m){if(h){h=false;c=g;d=m;e=g;f=m}else{c=c<g?c:g;d=d<m?d:m;e=e>g?e:g;f=f>m?
-f:m}a()};this.add3Points=function(g,m,y,C,w,p){if(h){h=false;c=g<y?g<w?g:w:y<w?y:w;d=m<C?m<p?m:p:C<p?C:p;e=g>y?g>w?g:w:y>w?y:w;f=m>C?m>p?m:p:C>p?C:p}else{c=g<y?g<w?g<c?g:c:w<c?w:c:y<w?y<c?y:c:w<c?w:c;d=m<C?m<p?m<d?m:d:p<d?p:d:C<p?C<d?C:d:p<d?p:d;e=g>y?g>w?g>e?g:e:w>e?w:e:y>w?y>e?y:e:w>e?w:e;f=m>C?m>p?m>f?m:f:p>f?p:f:C>p?C>f?C:f:p>f?p:f}a()};this.addRectangle=function(g){if(h){h=false;c=g.getLeft();d=g.getTop();e=g.getRight();f=g.getBottom()}else{c=c<g.getLeft()?c:g.getLeft();d=d<g.getTop()?d:g.getTop();
-e=e>g.getRight()?e:g.getRight();f=f>g.getBottom()?f:g.getBottom()}a()};this.inflate=function(g){c-=g;d-=g;e+=g;f+=g;a()};this.minSelf=function(g){c=c>g.getLeft()?c:g.getLeft();d=d>g.getTop()?d:g.getTop();e=e<g.getRight()?e:g.getRight();f=f<g.getBottom()?f:g.getBottom();a()};this.instersects=function(g){return Math.min(e,g.getRight())-Math.max(c,g.getLeft())>=0&&Math.min(f,g.getBottom())-Math.max(d,g.getTop())>=0};this.empty=function(){h=true;f=e=d=c=0;a()};this.isEmpty=function(){return h};this.toString=
-function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+f+", width: "+b+", height: "+l+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this}};
-THREE.Matrix4=function(a,c,d,e,f,b,l,h,g,m,y,C,w,p,z,F){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=f||0;this.n22=b||1;this.n23=l||0;this.n24=h||0;this.n31=g||0;this.n32=m||0;this.n33=y||1;this.n34=C||0;this.n41=w||0;this.n42=p||0;this.n43=z||0;this.n44=F||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
-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,c,d,e,f,b,l,h,g,m,y,C,w,p,z,F){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=f;this.n22=b;this.n23=l;this.n24=h;this.n31=g;this.n32=m;this.n33=y;this.n34=C;this.n41=w;this.n42=p;this.n43=z;this.n44=F;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
+THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,f=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)f=f.concat(this.intersectObject(d))}f.sort(function(b,h){return b.distance-h.distance});return f},intersectObject:function(a){function c(G,w,H,o){o=o.clone().subSelf(w);H=H.clone().subSelf(w);var l=G.clone().subSelf(w);G=o.dot(o);w=o.dot(H);o=o.dot(l);var u=H.dot(H);H=H.dot(l);l=1/(G*u-w*w);u=(u*o-w*H)*l;G=(G*H-w*o)*l;return u>0&&G>0&&u+G<1}var d,e,f,b,h,k,g,m,q,A,
+v,n=a.geometry,z=n.vertices,C=[];d=0;for(e=n.faces.length;d<e;d++){f=n.faces[d];A=this.origin.clone();v=this.direction.clone();b=a.matrix.multiplyVector3(z[f.a].position.clone());h=a.matrix.multiplyVector3(z[f.b].position.clone());k=a.matrix.multiplyVector3(z[f.c].position.clone());g=f instanceof THREE.Face4?a.matrix.multiplyVector3(z[f.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(f.normal.clone());q=v.dot(m);if(q<0){m=m.dot((new THREE.Vector3).sub(b,A))/q;A=A.addSelf(v.multiplyScalar(m));
+if(f instanceof THREE.Face3){if(c(A,b,h,k)){f={distance:this.origin.distanceTo(A),point:A,face:f,object:a};C.push(f)}}else if(f instanceof THREE.Face4)if(c(A,b,h,g)||c(A,h,k,g)){f={distance:this.origin.distanceTo(A),point:A,face:f,object:a};C.push(f)}}}return C}};
+THREE.Rectangle=function(){function a(){b=e-c;h=f-d}var c,d,e,f,b,h,k=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return b};this.getHeight=function(){return h};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(g,m,q,A){k=false;c=g;d=m;e=q;f=A;a()};this.addPoint=function(g,m){if(k){k=false;c=g;d=m;e=g;f=m}else{c=c<g?c:g;d=d<m?d:m;e=e>g?e:g;f=f>m?
+f:m}a()};this.add3Points=function(g,m,q,A,v,n){if(k){k=false;c=g<q?g<v?g:v:q<v?q:v;d=m<A?m<n?m:n:A<n?A:n;e=g>q?g>v?g:v:q>v?q:v;f=m>A?m>n?m:n:A>n?A:n}else{c=g<q?g<v?g<c?g:c:v<c?v:c:q<v?q<c?q:c:v<c?v:c;d=m<A?m<n?m<d?m:d:n<d?n:d:A<n?A<d?A:d:n<d?n:d;e=g>q?g>v?g>e?g:e:v>e?v:e:q>v?q>e?q:e:v>e?v:e;f=m>A?m>n?m>f?m:f:n>f?n:f:A>n?A>f?A:f:n>f?n:f}a()};this.addRectangle=function(g){if(k){k=false;c=g.getLeft();d=g.getTop();e=g.getRight();f=g.getBottom()}else{c=c<g.getLeft()?c:g.getLeft();d=d<g.getTop()?d:g.getTop();
+e=e>g.getRight()?e:g.getRight();f=f>g.getBottom()?f:g.getBottom()}a()};this.inflate=function(g){c-=g;d-=g;e+=g;f+=g;a()};this.minSelf=function(g){c=c>g.getLeft()?c:g.getLeft();d=d>g.getTop()?d:g.getTop();e=e<g.getRight()?e:g.getRight();f=f<g.getBottom()?f:g.getBottom();a()};this.instersects=function(g){return Math.min(e,g.getRight())-Math.max(c,g.getLeft())>=0&&Math.min(f,g.getBottom())-Math.max(d,g.getTop())>=0};this.empty=function(){k=true;f=e=d=c=0;a()};this.isEmpty=function(){return k};this.toString=
+function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+f+", width: "+b+", height: "+h+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this}};
+THREE.Matrix4=function(a,c,d,e,f,b,h,k,g,m,q,A,v,n,z,C){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=f||0;this.n22=b||1;this.n23=h||0;this.n24=k||0;this.n31=g||0;this.n32=m||0;this.n33=q||1;this.n34=A||0;this.n41=v||0;this.n42=n||0;this.n43=z||0;this.n44=C||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
+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,c,d,e,f,b,h,k,g,m,q,A,v,n,z,C){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=f;this.n22=b;this.n23=h;this.n24=k;this.n31=g;this.n32=m;this.n33=q;this.n34=A;this.n41=v;this.n42=n;this.n43=z;this.n44=C;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,c,d){var e=THREE.Matrix4.__tmpVec1,f=THREE.Matrix4.__tmpVec2,b=THREE.Matrix4.__tmpVec3;b.sub(a,c).normalize();e.cross(d,b).normalize();f.cross(b,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);
 this.n31=b.x;this.n32=b.y;this.n33=b.z;this.n34=-b.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,e=a.z,f=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*f;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*c+this.n22*d+this.n23*
-e+this.n24*f;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*f;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,e=a.n12,f=a.n13,b=a.n14,l=a.n21,h=a.n22,g=a.n23,m=a.n24,y=a.n31,
-C=a.n32,w=a.n33,p=a.n34,z=a.n41,F=a.n42,G=a.n43,u=a.n44,H=c.n11,n=c.n12,k=c.n13,o=c.n14,q=c.n21,j=c.n22,v=c.n23,t=c.n24,x=c.n31,A=c.n32,D=c.n33,B=c.n34,I=c.n41,P=c.n42,O=c.n43,Q=c.n44;this.n11=d*H+e*q+f*x+b*I;this.n12=d*n+e*j+f*A+b*P;this.n13=d*k+e*v+f*D+b*O;this.n14=d*o+e*t+f*B+b*Q;this.n21=l*H+h*q+g*x+m*I;this.n22=l*n+h*j+g*A+m*P;this.n23=l*k+h*v+g*D+m*O;this.n24=l*o+h*t+g*B+m*Q;this.n31=y*H+C*q+w*x+p*I;this.n32=y*n+C*j+w*A+p*P;this.n33=y*k+C*v+w*D+p*O;this.n34=y*o+C*t+w*B+p*Q;this.n41=z*H+F*q+
-G*x+u*I;this.n42=z*n+F*j+G*A+u*P;this.n43=z*k+F*v+G*D+u*O;this.n44=z*o+F*t+G*B+u*Q;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,f=this.n14,b=this.n21,l=this.n22,h=this.n23,g=this.n24,m=this.n31,y=this.n32,C=this.n33,w=this.n34,p=this.n41,z=this.n42,F=this.n43,G=this.n44,u=a.n11,H=a.n21,n=a.n31,k=a.n41,o=a.n12,q=a.n22,j=a.n32,v=a.n42,t=a.n13,x=a.n23,A=a.n33,D=a.n43,B=a.n14,I=a.n24,P=a.n34;a=a.n44;this.n11=c*u+d*H+e*n+f*k;this.n12=c*o+d*q+e*j+f*v;this.n13=c*t+d*x+e*A+f*
-D;this.n14=c*B+d*I+e*P+f*a;this.n21=b*u+l*H+h*n+g*k;this.n22=b*o+l*q+h*j+g*v;this.n23=b*t+l*x+h*A+g*D;this.n24=b*B+l*I+h*P+g*a;this.n31=m*u+y*H+C*n+w*k;this.n32=m*o+y*q+C*j+w*v;this.n33=m*t+y*x+C*A+w*D;this.n34=m*B+y*I+C*P+w*a;this.n41=p*u+z*H+F*n+G*k;this.n42=p*o+z*q+F*j+G*v;this.n43=p*t+z*x+F*A+G*D;this.n44=p*B+z*I+F*P+G*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=
-a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,b=this.n22,l=this.n23,h=this.n24,g=this.n31,m=this.n32,y=this.n33,C=this.n34,w=this.n41,p=this.n42,z=this.n43,F=this.n44;return e*l*m*w-d*h*m*w-e*b*y*w+c*h*y*w+d*b*C*w-c*l*C*w-e*l*g*p+d*h*g*p+e*f*y*p-a*h*y*p-d*f*C*p+a*l*C*p+e*b*g*z-c*h*g*z-e*f*m*z+a*h*m*z+c*f*C*z-a*b*C*z-d*b*g*F+c*l*g*F+d*f*m*F-a*l*m*F-c*f*y*F+a*b*y*F},transpose:function(){function a(c,d,
+e+this.n24*f;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*f;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,e=a.n12,f=a.n13,b=a.n14,h=a.n21,k=a.n22,g=a.n23,m=a.n24,q=a.n31,
+A=a.n32,v=a.n33,n=a.n34,z=a.n41,C=a.n42,G=a.n43,w=a.n44,H=c.n11,o=c.n12,l=c.n13,u=c.n14,t=c.n21,j=c.n22,p=c.n23,x=c.n24,y=c.n31,F=c.n32,B=c.n33,D=c.n34,I=c.n41,N=c.n42,O=c.n43,Q=c.n44;this.n11=d*H+e*t+f*y+b*I;this.n12=d*o+e*j+f*F+b*N;this.n13=d*l+e*p+f*B+b*O;this.n14=d*u+e*x+f*D+b*Q;this.n21=h*H+k*t+g*y+m*I;this.n22=h*o+k*j+g*F+m*N;this.n23=h*l+k*p+g*B+m*O;this.n24=h*u+k*x+g*D+m*Q;this.n31=q*H+A*t+v*y+n*I;this.n32=q*o+A*j+v*F+n*N;this.n33=q*l+A*p+v*B+n*O;this.n34=q*u+A*x+v*D+n*Q;this.n41=z*H+C*t+
+G*y+w*I;this.n42=z*o+C*j+G*F+w*N;this.n43=z*l+C*p+G*B+w*O;this.n44=z*u+C*x+G*D+w*Q;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,f=this.n14,b=this.n21,h=this.n22,k=this.n23,g=this.n24,m=this.n31,q=this.n32,A=this.n33,v=this.n34,n=this.n41,z=this.n42,C=this.n43,G=this.n44,w=a.n11,H=a.n21,o=a.n31,l=a.n41,u=a.n12,t=a.n22,j=a.n32,p=a.n42,x=a.n13,y=a.n23,F=a.n33,B=a.n43,D=a.n14,I=a.n24,N=a.n34;a=a.n44;this.n11=c*w+d*H+e*o+f*l;this.n12=c*u+d*t+e*j+f*p;this.n13=c*x+d*y+e*F+f*
+B;this.n14=c*D+d*I+e*N+f*a;this.n21=b*w+h*H+k*o+g*l;this.n22=b*u+h*t+k*j+g*p;this.n23=b*x+h*y+k*F+g*B;this.n24=b*D+h*I+k*N+g*a;this.n31=m*w+q*H+A*o+v*l;this.n32=m*u+q*t+A*j+v*p;this.n33=m*x+q*y+A*F+v*B;this.n34=m*D+q*I+A*N+v*a;this.n41=n*w+z*H+C*o+G*l;this.n42=n*u+z*t+C*j+G*p;this.n43=n*x+z*y+C*F+G*B;this.n44=n*D+z*I+C*N+G*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=
+a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,b=this.n22,h=this.n23,k=this.n24,g=this.n31,m=this.n32,q=this.n33,A=this.n34,v=this.n41,n=this.n42,z=this.n43,C=this.n44;return e*h*m*v-d*k*m*v-e*b*q*v+c*k*q*v+d*b*A*v-c*h*A*v-e*h*g*n+d*k*g*n+e*f*q*n-a*k*q*n-d*f*A*n+a*h*A*n+e*b*g*z-c*k*g*z-e*f*m*z+a*k*m*z+c*f*A*z-a*b*A*z-d*b*g*C+c*h*g*C+d*f*m*C-a*h*m*C-c*f*q*C+a*b*q*C},transpose:function(){function a(c,d,
 e){var f=c[d];c[d]=c[e];c[e]=f}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(){var a=this.flat;a[0]=this.n11;
 a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=
-Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),f=1-d,b=a.x,l=a.y,h=a.z,g=f*b,m=f*l;this.set(g*b+d,g*l-e*h,g*h+e*l,0,g*l+e*h,m*l+d,m*h-e*b,0,g*h-e*l,m*h+e*b,f*h*h+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+
+Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),f=1-d,b=a.x,h=a.y,k=a.z,g=f*b,m=f*h;this.set(g*b+d,g*h-e*k,g*k+e*h,0,g*h+e*k,m*h+d,m*k-e*b,0,g*k-e*h,m*k+e*b,f*k*k+d,0,0,0,0,1);return this},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,c,d){var e=new THREE.Matrix4;e.setTranslation(a,c,d);return e};THREE.Matrix4.scaleMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setScale(a,c,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};
 THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
-THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,b=a.n21,l=a.n22,h=a.n23,g=a.n24,m=a.n31,y=a.n32,C=a.n33,w=a.n34,p=a.n41,z=a.n42,F=a.n43,G=a.n44,u=new THREE.Matrix4;u.n11=h*w*z-g*C*z+g*y*F-l*w*F-h*y*G+l*C*G;u.n12=f*C*z-e*w*z-f*y*F+d*w*F+e*y*G-d*C*G;u.n13=e*g*z-f*h*z+f*l*F-d*g*F-e*l*G+d*h*G;u.n14=f*h*y-e*g*y-f*l*C+d*g*C+e*l*w-d*h*w;u.n21=g*C*p-h*w*p-g*m*F+b*w*F+h*m*G-b*C*G;u.n22=e*w*p-f*C*p+f*m*F-c*w*F-e*m*G+c*C*G;u.n23=f*h*p-e*g*p-f*b*F+c*g*F+e*b*G-c*h*G;u.n24=e*g*m-f*h*m+
-f*b*C-c*g*C-e*b*w+c*h*w;u.n31=l*w*p-g*y*p+g*m*z-b*w*z-l*m*G+b*y*G;u.n32=f*y*p-d*w*p-f*m*z+c*w*z+d*m*G-c*y*G;u.n33=e*g*p-f*l*p+f*b*z-c*g*z-d*b*G+c*l*G;u.n34=f*l*m-d*g*m-f*b*y+c*g*y+d*b*w-c*l*w;u.n41=h*y*p-l*C*p-h*m*z+b*C*z+l*m*F-b*y*F;u.n42=d*C*p-e*y*p+e*m*z-c*C*z-d*m*F+c*y*F;u.n43=e*l*p-d*h*p-e*b*z+c*h*z+d*b*F-c*l*F;u.n44=d*h*m-e*l*m+e*b*y-c*h*y-d*b*C+c*l*C;u.multiplyScalar(1/a.determinant());return u};
-THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],f=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],l=-c[10]*c[4]+c[6]*c[8],h=c[10]*c[0]-c[2]*c[8],g=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],y=-c[9]*c[0]+c[1]*c[8],C=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*l+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*f;d[2]=c*b;d[3]=c*l;d[4]=c*h;d[5]=c*g;d[6]=c*m;d[7]=c*y;d[8]=c*C;return a};
-THREE.Matrix4.makeFrustum=function(a,c,d,e,f,b){var l,h,g;l=new THREE.Matrix4;h=2*f/(c-a);g=2*f/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(b+f)/(b-f);f=-2*b*f/(b-f);l.n11=h;l.n12=0;l.n13=a;l.n14=0;l.n21=0;l.n22=g;l.n23=d;l.n24=0;l.n31=0;l.n32=0;l.n33=e;l.n34=f;l.n41=0;l.n42=0;l.n43=-1;l.n44=0;return l};THREE.Matrix4.makePerspective=function(a,c,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,d,e)};
-THREE.Matrix4.makeOrtho=function(a,c,d,e,f,b){var l,h,g,m;l=new THREE.Matrix4;h=c-a;g=d-e;m=b-f;a=(c+a)/h;d=(d+e)/g;f=(b+f)/m;l.n11=2/h;l.n12=0;l.n13=0;l.n14=-a;l.n21=0;l.n22=2/g;l.n23=0;l.n24=-d;l.n31=0;l.n32=0;l.n33=-2/m;l.n34=-f;l.n41=0;l.n42=0;l.n43=0;l.n44=1;return l};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
+THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,b=a.n21,h=a.n22,k=a.n23,g=a.n24,m=a.n31,q=a.n32,A=a.n33,v=a.n34,n=a.n41,z=a.n42,C=a.n43,G=a.n44,w=new THREE.Matrix4;w.n11=k*v*z-g*A*z+g*q*C-h*v*C-k*q*G+h*A*G;w.n12=f*A*z-e*v*z-f*q*C+d*v*C+e*q*G-d*A*G;w.n13=e*g*z-f*k*z+f*h*C-d*g*C-e*h*G+d*k*G;w.n14=f*k*q-e*g*q-f*h*A+d*g*A+e*h*v-d*k*v;w.n21=g*A*n-k*v*n-g*m*C+b*v*C+k*m*G-b*A*G;w.n22=e*v*n-f*A*n+f*m*C-c*v*C-e*m*G+c*A*G;w.n23=f*k*n-e*g*n-f*b*C+c*g*C+e*b*G-c*k*G;w.n24=e*g*m-f*k*m+
+f*b*A-c*g*A-e*b*v+c*k*v;w.n31=h*v*n-g*q*n+g*m*z-b*v*z-h*m*G+b*q*G;w.n32=f*q*n-d*v*n-f*m*z+c*v*z+d*m*G-c*q*G;w.n33=e*g*n-f*h*n+f*b*z-c*g*z-d*b*G+c*h*G;w.n34=f*h*m-d*g*m-f*b*q+c*g*q+d*b*v-c*h*v;w.n41=k*q*n-h*A*n-k*m*z+b*A*z+h*m*C-b*q*C;w.n42=d*A*n-e*q*n+e*m*z-c*A*z-d*m*C+c*q*C;w.n43=e*h*n-d*k*n-e*b*z+c*k*z+d*b*C-c*h*C;w.n44=d*k*m-e*h*m+e*b*q-c*k*q-d*b*A+c*h*A;w.multiplyScalar(1/a.determinant());return w};
+THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],f=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],h=-c[10]*c[4]+c[6]*c[8],k=c[10]*c[0]-c[2]*c[8],g=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],q=-c[9]*c[0]+c[1]*c[8],A=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*h+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*f;d[2]=c*b;d[3]=c*h;d[4]=c*k;d[5]=c*g;d[6]=c*m;d[7]=c*q;d[8]=c*A;return a};
+THREE.Matrix4.makeFrustum=function(a,c,d,e,f,b){var h,k,g;h=new THREE.Matrix4;k=2*f/(c-a);g=2*f/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(b+f)/(b-f);f=-2*b*f/(b-f);h.n11=k;h.n12=0;h.n13=a;h.n14=0;h.n21=0;h.n22=g;h.n23=d;h.n24=0;h.n31=0;h.n32=0;h.n33=e;h.n34=f;h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,d,e)};
+THREE.Matrix4.makeOrtho=function(a,c,d,e,f,b){var h,k,g,m;h=new THREE.Matrix4;k=c-a;g=d-e;m=b-f;a=(c+a)/k;d=(d+e)/g;f=(b+f)/m;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-a;h.n21=0;h.n22=2/g;h.n23=0;h.n24=-d;h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-f;h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||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,c,d,e,f){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
 THREE.Face4=function(a,c,d,e,f,b){this.a=a;this.b=c;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=b instanceof Array?b:[b]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||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.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
 THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
-d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,e,f,b,l,h=new THREE.Vector3,g=new THREE.Vector3;e=0;for(f=this.vertices.length;e<f;e++){b=this.vertices[e];b.normal.set(0,0,0)}e=0;for(f=this.faces.length;e<f;e++){b=this.faces[e];if(a&&b.vertexNormals.length){h.set(0,0,0);c=0;for(d=b.normal.length;c<d;c++)h.addSelf(b.vertexNormals[c]);h.divideScalar(3)}else{c=this.vertices[b.a];d=this.vertices[b.b];l=this.vertices[b.c];h.sub(l.position,
-d.position);g.sub(c.position,d.position);h.crossSelf(g)}h.isZero()||h.normalize();b.normal.copy(h)}},computeVertexNormals:function(){var a,c,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)e[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
+d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,e,f,b,h,k=new THREE.Vector3,g=new THREE.Vector3;e=0;for(f=this.vertices.length;e<f;e++){b=this.vertices[e];b.normal.set(0,0,0)}e=0;for(f=this.faces.length;e<f;e++){b=this.faces[e];if(a&&b.vertexNormals.length){k.set(0,0,0);c=0;for(d=b.normal.length;c<d;c++)k.addSelf(b.vertexNormals[c]);k.divideScalar(3)}else{c=this.vertices[b.a];d=this.vertices[b.b];h=this.vertices[b.c];k.sub(h.position,
+d.position);g.sub(c.position,d.position);k.crossSelf(g)}k.isZero()||k.normalize();b.normal.copy(k)}},computeVertexNormals:function(){var a,c,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)e[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
 new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)e[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal);e[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)e[a].normalize();a=0;for(c=this.faces.length;a<
-c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(B,I,P,O,Q,T,U){b=B.vertices[I].position;l=B.vertices[P].position;h=B.vertices[O].position;g=f[Q];m=f[T];y=f[U];C=l.x-b.x;w=h.x-b.x;p=l.y-b.y;z=h.y-b.y;
-F=l.z-b.z;G=h.z-b.z;u=m.u-g.u;H=y.u-g.u;n=m.v-g.v;k=y.v-g.v;o=1/(u*k-H*n);v.set((k*C-n*w)*o,(k*p-n*z)*o,(k*F-n*G)*o);t.set((u*w-H*C)*o,(u*z-H*p)*o,(u*G-H*F)*o);q[I].addSelf(v);q[P].addSelf(v);q[O].addSelf(v);j[I].addSelf(t);j[P].addSelf(t);j[O].addSelf(t)}var c,d,e,f,b,l,h,g,m,y,C,w,p,z,F,G,u,H,n,k,o,q=[],j=[],v=new THREE.Vector3,t=new THREE.Vector3,x=new THREE.Vector3,A=new THREE.Vector3,D=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){q[c]=new THREE.Vector3;j[c]=new THREE.Vector3}c=0;
+c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(D,I,N,O,Q,T,U){b=D.vertices[I].position;h=D.vertices[N].position;k=D.vertices[O].position;g=f[Q];m=f[T];q=f[U];A=h.x-b.x;v=k.x-b.x;n=h.y-b.y;z=k.y-b.y;
+C=h.z-b.z;G=k.z-b.z;w=m.u-g.u;H=q.u-g.u;o=m.v-g.v;l=q.v-g.v;u=1/(w*l-H*o);p.set((l*A-o*v)*u,(l*n-o*z)*u,(l*C-o*G)*u);x.set((w*v-H*A)*u,(w*z-H*n)*u,(w*G-H*C)*u);t[I].addSelf(p);t[N].addSelf(p);t[O].addSelf(p);j[I].addSelf(x);j[N].addSelf(x);j[O].addSelf(x)}var c,d,e,f,b,h,k,g,m,q,A,v,n,z,C,G,w,H,o,l,u,t=[],j=[],p=new THREE.Vector3,x=new THREE.Vector3,y=new THREE.Vector3,F=new THREE.Vector3,B=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){t[c]=new THREE.Vector3;j[c]=new THREE.Vector3}c=0;
 for(d=this.faces.length;c<d;c++){e=this.faces[c];f=this.uvs[c];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
-this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){D.copy(this.vertices[c].normal);e=q[c];x.copy(e);x.subSelf(D.multiplyScalar(D.dot(e))).normalize();A.cross(this.vertices[c].normal,e);e=A.dot(j[c]);e=e<0?-1:1;this.vertices[c].tangent.set(x.x,x.y,x.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
+this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){B.copy(this.vertices[c].normal);e=t[c];y.copy(e);y.subSelf(B.multiplyScalar(B.dot(e))).normalize();F.cross(this.vertices[c].normal,e);e=F.dot(j[c]);e=e<0?-1:1;this.vertices[c].tangent.set(y.x,y.y,y.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
 z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
-this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(y){var C=[];c=0;for(d=y.length;c<d;c++)y[c]==undefined?C.push("undefined"):C.push(y[c].toString());return C.join("_")}var c,d,e,f,b,l,h,g,m={};e=0;for(f=this.faces.length;e<f;e++){b=this.faces[e];
-l=b.materials;h=a(l);if(m[h]==undefined)m[h]={hash:h,counter:0};g=m[h].hash+"_"+m[h].counter;if(this.geometryChunks[g]==undefined)this.geometryChunks[g]={faces:[],materials:l,vertices:0};b=b instanceof THREE.Face3?3:4;if(this.geometryChunks[g].vertices+b>65535){m[h].counter+=1;g=m[h].hash+"_"+m[h].counter;if(this.geometryChunks[g]==undefined)this.geometryChunks[g]={faces:[],materials:l,vertices:0}}this.geometryChunks[g].faces.push(e);this.geometryChunks[g].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+
+this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(q){var A=[];c=0;for(d=q.length;c<d;c++)q[c]==undefined?A.push("undefined"):A.push(q[c].toString());return A.join("_")}var c,d,e,f,b,h,k,g,m={};e=0;for(f=this.faces.length;e<f;e++){b=this.faces[e];
+h=b.materials;k=a(h);if(m[k]==undefined)m[k]={hash:k,counter:0};g=m[k].hash+"_"+m[k].counter;if(this.geometryChunks[g]==undefined)this.geometryChunks[g]={faces:[],materials:h,vertices:0};b=b instanceof THREE.Face3?3:4;if(this.geometryChunks[g].vertices+b>65535){m[k].counter+=1;g=m[k].hash+"_"+m[k].counter;if(this.geometryChunks[g]==undefined)this.geometryChunks[g]={faces:[],materials:h,vertices:0}}this.geometryChunks[g].faces.push(e);this.geometryChunks[g].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+
 this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
 THREE.Camera=function(a,c,d,e){this.fov=a;this.aspect=c;this.near=d;this.far=e;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.tmpVec=new THREE.Vector3;this.translateX=function(f){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
 this.translateZ=function(f){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};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()};
@@ -98,105 +98,108 @@ var Uniforms={clone:function(a){var c,d,e,f={};for(c in a){f[c]={};for(d in a[c]
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
 THREE.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
-THREE.Projector=function(){function a(j,v){return v.z-j.z}function c(j,v){var t=0,x=1,A=j.z+j.w,D=v.z+v.w,B=-j.z+j.w,I=-v.z+v.w;if(A>=0&&D>=0&&B>=0&&I>=0)return true;else if(A<0&&D<0||B<0&&I<0)return false;else{if(A<0)t=Math.max(t,A/(A-D));else if(D<0)x=Math.min(x,A/(A-D));if(B<0)t=Math.max(t,B/(B-I));else if(I<0)x=Math.min(x,B/(B-I));if(x<t)return false;else{j.lerpSelf(v,t);v.lerpSelf(j,1-x);return true}}}var d,e,f=[],b,l,h,g=[],m,y,C=[],w,p,z=[],F=new THREE.Vector4,G=new THREE.Vector4,u=new THREE.Matrix4,
-H=new THREE.Matrix4,n=[],k=new THREE.Vector4,o=new THREE.Vector4,q;this.projectObjects=function(j,v,t){var x=[],A,D;e=0;u.multiply(v.projectionMatrix,v.matrix);n[0]=new THREE.Vector4(u.n41-u.n11,u.n42-u.n12,u.n43-u.n13,u.n44-u.n14);n[1]=new THREE.Vector4(u.n41+u.n11,u.n42+u.n12,u.n43+u.n13,u.n44+u.n14);n[2]=new THREE.Vector4(u.n41+u.n21,u.n42+u.n22,u.n43+u.n23,u.n44+u.n24);n[3]=new THREE.Vector4(u.n41-u.n21,u.n42-u.n22,u.n43-u.n23,u.n44-u.n24);n[4]=new THREE.Vector4(u.n41-u.n31,u.n42-u.n32,u.n43-
-u.n33,u.n44-u.n34);n[5]=new THREE.Vector4(u.n41+u.n31,u.n42+u.n32,u.n43+u.n33,u.n44+u.n34);v=0;for(A=n.length;v<A;v++){D=n[v];D.divideScalar(Math.sqrt(D.x*D.x+D.y*D.y+D.z*D.z))}A=j.objects;j=0;for(v=A.length;j<v;j++){D=A[j];var B;if(!(B=!D.visible)){if(B=D instanceof THREE.Mesh){a:{B=void 0;for(var I=D.position,P=-D.geometry.boundingSphere.radius*Math.max(D.scale.x,Math.max(D.scale.y,D.scale.z)),O=0;O<6;O++){B=n[O].x*I.x+n[O].y*I.y+n[O].z*I.z+n[O].w;if(B<=P){B=false;break a}}B=true}B=!B}B=B}if(!B){d=
-f[e]=f[e]||new THREE.RenderableObject;F.copy(D.position);u.multiplyVector3(F);d.object=D;d.z=F.z;x.push(d);e++}}t&&x.sort(a);return x};this.projectScene=function(j,v,t){var x=[],A=v.near,D=v.far,B,I,P,O,Q,T,U,ba,ca,S,K,Z,V,N,W,$;h=y=p=0;v.autoUpdateMatrix&&v.updateMatrix();u.multiply(v.projectionMatrix,v.matrix);T=this.projectObjects(j,v,true);j=0;for(B=T.length;j<B;j++){U=T[j].object;if(U.visible){U.autoUpdateMatrix&&U.updateMatrix();ba=U.matrix;ca=U.rotationMatrix;S=U.materials;K=U.overdraw;if(U instanceof
-THREE.Mesh){Z=U.geometry;V=Z.vertices;I=0;for(P=V.length;I<P;I++){N=V[I];N.positionWorld.copy(N.position);ba.multiplyVector3(N.positionWorld);O=N.positionScreen;O.copy(N.positionWorld);u.multiplyVector4(O);O.x/=O.w;O.y/=O.w;N.__visible=O.z>A&&O.z<D}Z=Z.faces;I=0;for(P=Z.length;I<P;I++){N=Z[I];if(N instanceof THREE.Face3){O=V[N.a];Q=V[N.b];W=V[N.c];if(O.__visible&&Q.__visible&&W.__visible)if(U.doubleSided||U.flipSided!=(W.positionScreen.x-O.positionScreen.x)*(Q.positionScreen.y-O.positionScreen.y)-
-(W.positionScreen.y-O.positionScreen.y)*(Q.positionScreen.x-O.positionScreen.x)<0){b=g[h]=g[h]||new THREE.RenderableFace3;b.v1.positionWorld.copy(O.positionWorld);b.v2.positionWorld.copy(Q.positionWorld);b.v3.positionWorld.copy(W.positionWorld);b.v1.positionScreen.copy(O.positionScreen);b.v2.positionScreen.copy(Q.positionScreen);b.v3.positionScreen.copy(W.positionScreen);b.normalWorld.copy(N.normal);ca.multiplyVector3(b.normalWorld);b.centroidWorld.copy(N.centroid);ba.multiplyVector3(b.centroidWorld);
-b.centroidScreen.copy(b.centroidWorld);u.multiplyVector3(b.centroidScreen);W=N.vertexNormals;q=b.vertexNormalsWorld;O=0;for(Q=W.length;O<Q;O++){$=q[O]=q[O]||new THREE.Vector3;$.copy(W[O]);ca.multiplyVector3($)}b.z=b.centroidScreen.z;b.meshMaterials=S;b.faceMaterials=N.materials;b.overdraw=K;if(U.geometry.uvs[I]){b.uvs[0]=U.geometry.uvs[I][0];b.uvs[1]=U.geometry.uvs[I][1];b.uvs[2]=U.geometry.uvs[I][2]}x.push(b);h++}}else if(N instanceof THREE.Face4){O=V[N.a];Q=V[N.b];W=V[N.c];$=V[N.d];if(O.__visible&&
-Q.__visible&&W.__visible&&$.__visible)if(U.doubleSided||U.flipSided!=(($.positionScreen.x-O.positionScreen.x)*(Q.positionScreen.y-O.positionScreen.y)-($.positionScreen.y-O.positionScreen.y)*(Q.positionScreen.x-O.positionScreen.x)<0||(Q.positionScreen.x-W.positionScreen.x)*($.positionScreen.y-W.positionScreen.y)-(Q.positionScreen.y-W.positionScreen.y)*($.positionScreen.x-W.positionScreen.x)<0)){b=g[h]=g[h]||new THREE.RenderableFace3;b.v1.positionWorld.copy(O.positionWorld);b.v2.positionWorld.copy(Q.positionWorld);
-b.v3.positionWorld.copy($.positionWorld);b.v1.positionScreen.copy(O.positionScreen);b.v2.positionScreen.copy(Q.positionScreen);b.v3.positionScreen.copy($.positionScreen);b.normalWorld.copy(N.normal);ca.multiplyVector3(b.normalWorld);b.centroidWorld.copy(N.centroid);ba.multiplyVector3(b.centroidWorld);b.centroidScreen.copy(b.centroidWorld);u.multiplyVector3(b.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterials=S;b.faceMaterials=N.materials;b.overdraw=K;if(U.geometry.uvs[I]){b.uvs[0]=U.geometry.uvs[I][0];
-b.uvs[1]=U.geometry.uvs[I][1];b.uvs[2]=U.geometry.uvs[I][3]}x.push(b);h++;l=g[h]=g[h]||new THREE.RenderableFace3;l.v1.positionWorld.copy(Q.positionWorld);l.v2.positionWorld.copy(W.positionWorld);l.v3.positionWorld.copy($.positionWorld);l.v1.positionScreen.copy(Q.positionScreen);l.v2.positionScreen.copy(W.positionScreen);l.v3.positionScreen.copy($.positionScreen);l.normalWorld.copy(b.normalWorld);l.centroidWorld.copy(b.centroidWorld);l.centroidScreen.copy(b.centroidScreen);l.z=l.centroidScreen.z;l.meshMaterials=
-S;l.faceMaterials=N.materials;l.overdraw=K;if(U.geometry.uvs[I]){l.uvs[0]=U.geometry.uvs[I][1];l.uvs[1]=U.geometry.uvs[I][2];l.uvs[2]=U.geometry.uvs[I][3]}x.push(l);h++}}}}else if(U instanceof THREE.Line){H.multiply(u,ba);V=U.geometry.vertices;N=V[0];N.positionScreen.copy(N.position);H.multiplyVector4(N.positionScreen);I=1;for(P=V.length;I<P;I++){O=V[I];O.positionScreen.copy(O.position);H.multiplyVector4(O.positionScreen);Q=V[I-1];k.copy(O.positionScreen);o.copy(Q.positionScreen);if(c(k,o)){k.multiplyScalar(1/
-k.w);o.multiplyScalar(1/o.w);m=C[y]=C[y]||new THREE.RenderableLine;m.v1.positionScreen.copy(k);m.v2.positionScreen.copy(o);m.z=Math.max(k.z,o.z);m.materials=U.materials;x.push(m);y++}}}else if(U instanceof THREE.Particle){G.set(U.position.x,U.position.y,U.position.z,1);u.multiplyVector4(G);G.z/=G.w;if(G.z>0&&G.z<1){w=z[p]=z[p]||new THREE.RenderableParticle;w.x=G.x/G.w;w.y=G.y/G.w;w.z=G.z;w.rotation=U.rotation.z;w.scale.x=U.scale.x*Math.abs(w.x-(G.x+v.projectionMatrix.n11)/(G.w+v.projectionMatrix.n14));
-w.scale.y=U.scale.y*Math.abs(w.y-(G.y+v.projectionMatrix.n22)/(G.w+v.projectionMatrix.n24));w.materials=U.materials;x.push(w);p++}}}}t&&x.sort(a);return x};this.unprojectVector=function(j,v){var t=THREE.Matrix4.makeInvert(v.matrix);t.multiplySelf(THREE.Matrix4.makeInvert(v.projectionMatrix));t.multiplyVector3(j);return j}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,f,b;this.domElement=document.createElement("div");this.setSize=function(l,h){d=l;e=h;f=d/2;b=e/2};this.render=function(l,h){var g,m,y,C,w,p,z,F;a=c.projectScene(l,h);g=0;for(m=a.length;g<m;g++){w=a[g];if(w instanceof THREE.RenderableParticle){z=w.x*f+f;F=w.y*b+b;y=0;for(C=w.material.length;y<C;y++){p=w.material[y];if(p instanceof THREE.ParticleDOMMaterial){p=p.domElement;p.style.left=z+"px";p.style.top=F+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(ma){if(w!=ma)m.globalAlpha=w=ma}function c(ma){if(p!=ma){switch(ma){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}p=ma}}var d=null,e=new THREE.Projector,f=document.createElement("canvas"),b,l,h,g,m=f.getContext("2d"),y=new THREE.Color(0),C=0,w=1,p=0,z=null,F=null,G=1,u,H,n,k,o,q,j,v,t,x=new THREE.Color,
-A=new THREE.Color,D=new THREE.Color,B=new THREE.Color,I=new THREE.Color,P,O,Q,T,U,ba,ca,S,K,Z=new THREE.Rectangle,V=new THREE.Rectangle,N=new THREE.Rectangle,W=false,$=new THREE.Color,da=new THREE.Color,ha=new THREE.Color,E=new THREE.Color,L=Math.PI*2,J=new THREE.Vector3,X,ea,ja,ia,qa,la,ua=16;X=document.createElement("canvas");X.width=X.height=2;ea=X.getContext("2d");ea.fillStyle="rgba(0,0,0,1)";ea.fillRect(0,0,2,2);ja=ea.getImageData(0,0,2,2);ia=ja.data;qa=document.createElement("canvas");qa.width=
-qa.height=ua;la=qa.getContext("2d");la.translate(-ua/2,-ua/2);la.scale(ua,ua);ua--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ma,sa){b=ma;l=sa;h=b/2;g=l/2;f.width=b;f.height=l;Z.set(-h,-g,h,g);w=1;p=0;F=z=null;G=1};this.setClearColor=function(ma,sa){y.setHex(ma);C=sa;V.set(-h,-g,h,g);m.setTransform(1,0,0,-1,h,g);this.clear()};this.clear=function(){m.setTransform(1,0,0,-1,h,g);if(!V.isEmpty()){V.inflate(1);V.minSelf(Z);if(y.hex==0&&C==0)m.clearRect(V.getX(),
-V.getY(),V.getWidth(),V.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b*255)+","+C+")";m.fillRect(V.getX(),V.getY(),V.getWidth(),V.getHeight())}V.empty()}};this.render=function(ma,sa){function Ha(M){var fa,aa,R,Y=M.lights;da.setRGB(0,0,0);ha.setRGB(0,0,0);E.setRGB(0,0,0);M=0;for(fa=Y.length;M<fa;M++){aa=Y[M];R=aa.color;if(aa instanceof THREE.AmbientLight){da.r+=R.r;da.g+=R.g;da.b+=R.b}else if(aa instanceof THREE.DirectionalLight){ha.r+=
+THREE.Projector=function(){function a(j,p){return p.z-j.z}function c(j,p){var x=0,y=1,F=j.z+j.w,B=p.z+p.w,D=-j.z+j.w,I=-p.z+p.w;if(F>=0&&B>=0&&D>=0&&I>=0)return true;else if(F<0&&B<0||D<0&&I<0)return false;else{if(F<0)x=Math.max(x,F/(F-B));else if(B<0)y=Math.min(y,F/(F-B));if(D<0)x=Math.max(x,D/(D-I));else if(I<0)y=Math.min(y,D/(D-I));if(y<x)return false;else{j.lerpSelf(p,x);p.lerpSelf(j,1-y);return true}}}var d,e,f=[],b,h,k,g=[],m,q,A=[],v,n,z=[],C=new THREE.Vector4,G=new THREE.Vector4,w=new THREE.Matrix4,
+H=new THREE.Matrix4,o=[],l=new THREE.Vector4,u=new THREE.Vector4,t;this.projectObjects=function(j,p,x){var y=[],F,B;e=0;w.multiply(p.projectionMatrix,p.matrix);o[0]=new THREE.Vector4(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);o[1]=new THREE.Vector4(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);o[2]=new THREE.Vector4(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);o[3]=new THREE.Vector4(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);o[4]=new THREE.Vector4(w.n41-w.n31,w.n42-w.n32,w.n43-
+w.n33,w.n44-w.n34);o[5]=new THREE.Vector4(w.n41+w.n31,w.n42+w.n32,w.n43+w.n33,w.n44+w.n34);p=0;for(F=o.length;p<F;p++){B=o[p];B.divideScalar(Math.sqrt(B.x*B.x+B.y*B.y+B.z*B.z))}F=j.objects;j=0;for(p=F.length;j<p;j++){B=F[j];var D;if(!(D=!B.visible)){if(D=B instanceof THREE.Mesh){a:{D=void 0;for(var I=B.position,N=-B.geometry.boundingSphere.radius*Math.max(B.scale.x,Math.max(B.scale.y,B.scale.z)),O=0;O<6;O++){D=o[O].x*I.x+o[O].y*I.y+o[O].z*I.z+o[O].w;if(D<=N){D=false;break a}}D=true}D=!D}D=D}if(!D){d=
+f[e]=f[e]||new THREE.RenderableObject;C.copy(B.position);w.multiplyVector3(C);d.object=B;d.z=C.z;y.push(d);e++}}x&&y.sort(a);return y};this.projectScene=function(j,p,x){var y=[],F=p.near,B=p.far,D,I,N,O,Q,T,U,ba,ca,S,K,Z,V,P,W,$;k=q=n=0;p.autoUpdateMatrix&&p.updateMatrix();w.multiply(p.projectionMatrix,p.matrix);T=this.projectObjects(j,p,true);j=0;for(D=T.length;j<D;j++){U=T[j].object;if(U.visible){U.autoUpdateMatrix&&U.updateMatrix();ba=U.matrix;ca=U.rotationMatrix;S=U.materials;K=U.overdraw;if(U instanceof
+THREE.Mesh){Z=U.geometry;V=Z.vertices;I=0;for(N=V.length;I<N;I++){P=V[I];P.positionWorld.copy(P.position);ba.multiplyVector3(P.positionWorld);O=P.positionScreen;O.copy(P.positionWorld);w.multiplyVector4(O);O.x/=O.w;O.y/=O.w;P.__visible=O.z>F&&O.z<B}Z=Z.faces;I=0;for(N=Z.length;I<N;I++){P=Z[I];if(P instanceof THREE.Face3){O=V[P.a];Q=V[P.b];W=V[P.c];if(O.__visible&&Q.__visible&&W.__visible)if(U.doubleSided||U.flipSided!=(W.positionScreen.x-O.positionScreen.x)*(Q.positionScreen.y-O.positionScreen.y)-
+(W.positionScreen.y-O.positionScreen.y)*(Q.positionScreen.x-O.positionScreen.x)<0){b=g[k]=g[k]||new THREE.RenderableFace3;b.v1.positionWorld.copy(O.positionWorld);b.v2.positionWorld.copy(Q.positionWorld);b.v3.positionWorld.copy(W.positionWorld);b.v1.positionScreen.copy(O.positionScreen);b.v2.positionScreen.copy(Q.positionScreen);b.v3.positionScreen.copy(W.positionScreen);b.normalWorld.copy(P.normal);ca.multiplyVector3(b.normalWorld);b.centroidWorld.copy(P.centroid);ba.multiplyVector3(b.centroidWorld);
+b.centroidScreen.copy(b.centroidWorld);w.multiplyVector3(b.centroidScreen);W=P.vertexNormals;t=b.vertexNormalsWorld;O=0;for(Q=W.length;O<Q;O++){$=t[O]=t[O]||new THREE.Vector3;$.copy(W[O]);ca.multiplyVector3($)}b.z=b.centroidScreen.z;b.meshMaterials=S;b.faceMaterials=P.materials;b.overdraw=K;if(U.geometry.uvs[I]){b.uvs[0]=U.geometry.uvs[I][0];b.uvs[1]=U.geometry.uvs[I][1];b.uvs[2]=U.geometry.uvs[I][2]}y.push(b);k++}}else if(P instanceof THREE.Face4){O=V[P.a];Q=V[P.b];W=V[P.c];$=V[P.d];if(O.__visible&&
+Q.__visible&&W.__visible&&$.__visible)if(U.doubleSided||U.flipSided!=(($.positionScreen.x-O.positionScreen.x)*(Q.positionScreen.y-O.positionScreen.y)-($.positionScreen.y-O.positionScreen.y)*(Q.positionScreen.x-O.positionScreen.x)<0||(Q.positionScreen.x-W.positionScreen.x)*($.positionScreen.y-W.positionScreen.y)-(Q.positionScreen.y-W.positionScreen.y)*($.positionScreen.x-W.positionScreen.x)<0)){b=g[k]=g[k]||new THREE.RenderableFace3;b.v1.positionWorld.copy(O.positionWorld);b.v2.positionWorld.copy(Q.positionWorld);
+b.v3.positionWorld.copy($.positionWorld);b.v1.positionScreen.copy(O.positionScreen);b.v2.positionScreen.copy(Q.positionScreen);b.v3.positionScreen.copy($.positionScreen);b.normalWorld.copy(P.normal);ca.multiplyVector3(b.normalWorld);b.centroidWorld.copy(P.centroid);ba.multiplyVector3(b.centroidWorld);b.centroidScreen.copy(b.centroidWorld);w.multiplyVector3(b.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterials=S;b.faceMaterials=P.materials;b.overdraw=K;if(U.geometry.uvs[I]){b.uvs[0]=U.geometry.uvs[I][0];
+b.uvs[1]=U.geometry.uvs[I][1];b.uvs[2]=U.geometry.uvs[I][3]}y.push(b);k++;h=g[k]=g[k]||new THREE.RenderableFace3;h.v1.positionWorld.copy(Q.positionWorld);h.v2.positionWorld.copy(W.positionWorld);h.v3.positionWorld.copy($.positionWorld);h.v1.positionScreen.copy(Q.positionScreen);h.v2.positionScreen.copy(W.positionScreen);h.v3.positionScreen.copy($.positionScreen);h.normalWorld.copy(b.normalWorld);h.centroidWorld.copy(b.centroidWorld);h.centroidScreen.copy(b.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=
+S;h.faceMaterials=P.materials;h.overdraw=K;if(U.geometry.uvs[I]){h.uvs[0]=U.geometry.uvs[I][1];h.uvs[1]=U.geometry.uvs[I][2];h.uvs[2]=U.geometry.uvs[I][3]}y.push(h);k++}}}}else if(U instanceof THREE.Line){H.multiply(w,ba);V=U.geometry.vertices;P=V[0];P.positionScreen.copy(P.position);H.multiplyVector4(P.positionScreen);I=1;for(N=V.length;I<N;I++){O=V[I];O.positionScreen.copy(O.position);H.multiplyVector4(O.positionScreen);Q=V[I-1];l.copy(O.positionScreen);u.copy(Q.positionScreen);if(c(l,u)){l.multiplyScalar(1/
+l.w);u.multiplyScalar(1/u.w);m=A[q]=A[q]||new THREE.RenderableLine;m.v1.positionScreen.copy(l);m.v2.positionScreen.copy(u);m.z=Math.max(l.z,u.z);m.materials=U.materials;y.push(m);q++}}}else if(U instanceof THREE.Particle){G.set(U.position.x,U.position.y,U.position.z,1);w.multiplyVector4(G);G.z/=G.w;if(G.z>0&&G.z<1){v=z[n]=z[n]||new THREE.RenderableParticle;v.x=G.x/G.w;v.y=G.y/G.w;v.z=G.z;v.rotation=U.rotation.z;v.scale.x=U.scale.x*Math.abs(v.x-(G.x+p.projectionMatrix.n11)/(G.w+p.projectionMatrix.n14));
+v.scale.y=U.scale.y*Math.abs(v.y-(G.y+p.projectionMatrix.n22)/(G.w+p.projectionMatrix.n24));v.materials=U.materials;y.push(v);n++}}}}x&&y.sort(a);return y};this.unprojectVector=function(j,p){var x=THREE.Matrix4.makeInvert(p.matrix);x.multiplySelf(THREE.Matrix4.makeInvert(p.projectionMatrix));x.multiplyVector3(j);return j}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,f,b;this.domElement=document.createElement("div");this.setSize=function(h,k){d=h;e=k;f=d/2;b=e/2};this.render=function(h,k){var g,m,q,A,v,n,z,C;a=c.projectScene(h,k);g=0;for(m=a.length;g<m;g++){v=a[g];if(v instanceof THREE.RenderableParticle){z=v.x*f+f;C=v.y*b+b;q=0;for(A=v.material.length;q<A;q++){n=v.material[q];if(n instanceof THREE.ParticleDOMMaterial){n=n.domElement;n.style.left=z+"px";n.style.top=C+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(ma){if(v!=ma)m.globalAlpha=v=ma}function c(ma){if(n!=ma){switch(ma){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}n=ma}}var d=null,e=new THREE.Projector,f=document.createElement("canvas"),b,h,k,g,m=f.getContext("2d"),q=new THREE.Color(0),A=0,v=1,n=0,z=null,C=null,G=1,w,H,o,l,u,t,j,p,x,y=new THREE.Color,
+F=new THREE.Color,B=new THREE.Color,D=new THREE.Color,I=new THREE.Color,N,O,Q,T,U,ba,ca,S,K,Z=new THREE.Rectangle,V=new THREE.Rectangle,P=new THREE.Rectangle,W=false,$=new THREE.Color,da=new THREE.Color,ha=new THREE.Color,E=new THREE.Color,L=Math.PI*2,J=new THREE.Vector3,X,ea,ja,ia,qa,la,ua=16;X=document.createElement("canvas");X.width=X.height=2;ea=X.getContext("2d");ea.fillStyle="rgba(0,0,0,1)";ea.fillRect(0,0,2,2);ja=ea.getImageData(0,0,2,2);ia=ja.data;qa=document.createElement("canvas");qa.width=
+qa.height=ua;la=qa.getContext("2d");la.translate(-ua/2,-ua/2);la.scale(ua,ua);ua--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ma,sa){b=ma;h=sa;k=b/2;g=h/2;f.width=b;f.height=h;Z.set(-k,-g,k,g);v=1;n=0;C=z=null;G=1};this.setClearColor=function(ma,sa){q.setHex(ma);A=sa;V.set(-k,-g,k,g);m.setTransform(1,0,0,-1,k,g);this.clear()};this.clear=function(){m.setTransform(1,0,0,-1,k,g);if(!V.isEmpty()){V.inflate(1);V.minSelf(Z);if(q.hex==0&&A==0)m.clearRect(V.getX(),
+V.getY(),V.getWidth(),V.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(q.r*255)+","+Math.floor(q.g*255)+","+Math.floor(q.b*255)+","+A+")";m.fillRect(V.getX(),V.getY(),V.getWidth(),V.getHeight())}V.empty()}};this.render=function(ma,sa){function Ha(M){var fa,aa,R,Y=M.lights;da.setRGB(0,0,0);ha.setRGB(0,0,0);E.setRGB(0,0,0);M=0;for(fa=Y.length;M<fa;M++){aa=Y[M];R=aa.color;if(aa instanceof THREE.AmbientLight){da.r+=R.r;da.g+=R.g;da.b+=R.b}else if(aa instanceof THREE.DirectionalLight){ha.r+=
 R.r;ha.g+=R.g;ha.b+=R.b}else if(aa instanceof THREE.PointLight){E.r+=R.r;E.g+=R.g;E.b+=R.b}}}function Da(M,fa,aa,R){var Y,ga,na,oa,pa=M.lights;M=0;for(Y=pa.length;M<Y;M++){ga=pa[M];na=ga.color;oa=ga.intensity;if(ga instanceof THREE.DirectionalLight){ga=aa.dot(ga.position)*oa;if(ga>0){R.r+=na.r*ga;R.g+=na.g*ga;R.b+=na.b*ga}}else if(ga instanceof THREE.PointLight){J.sub(ga.position,fa);J.normalize();ga=aa.dot(J)*oa;if(ga>0){R.r+=na.r*ga;R.g+=na.g*ga;R.b+=na.b*ga}}}}function Qa(M,fa,aa){if(aa.opacity!=
-0){a(aa.opacity);c(aa.blending);var R,Y,ga,na,oa,pa;if(aa instanceof THREE.ParticleBasicMaterial){if(aa.map&&aa.map.image.loaded){na=aa.map.image;oa=na.width>>1;pa=na.height>>1;Y=fa.scale.x*h;ga=fa.scale.y*g;aa=Y*oa;R=ga*pa;N.set(M.x-aa,M.y-R,M.x+aa,M.y+R);if(Z.instersects(N)){m.save();m.translate(M.x,M.y);m.rotate(-fa.rotation);m.scale(Y,-ga);m.translate(-oa,-pa);m.drawImage(na,0,0);m.restore()}}}else if(aa instanceof THREE.ParticleCircleMaterial){if(W){$.r=da.r+ha.r+E.r;$.g=da.g+ha.g+E.g;$.b=da.b+
-ha.b+E.b;x.r=aa.color.r*$.r;x.g=aa.color.g*$.g;x.b=aa.color.b*$.b;x.updateStyleString()}else x.__styleString=aa.color.__styleString;aa=fa.scale.x*h;R=fa.scale.y*g;N.set(M.x-aa,M.y-R,M.x+aa,M.y+R);if(Z.instersects(N)){Y=x.__styleString;if(F!=Y)m.fillStyle=F=Y;m.save();m.translate(M.x,M.y);m.rotate(-fa.rotation);m.scale(aa,R);m.beginPath();m.arc(0,0,1,0,L,true);m.closePath();m.fill();m.restore()}}}}function Ra(M,fa,aa,R){if(R.opacity!=0){a(R.opacity);c(R.blending);m.beginPath();m.moveTo(M.positionScreen.x,
-M.positionScreen.y);m.lineTo(fa.positionScreen.x,fa.positionScreen.y);m.closePath();if(R instanceof THREE.LineBasicMaterial){x.__styleString=R.color.__styleString;M=R.linewidth;if(G!=M)m.lineWidth=G=M;M=x.__styleString;if(z!=M)m.strokeStyle=z=M;m.stroke();N.inflate(R.linewidth*2)}}}function Ma(M,fa,aa,R,Y,ga){if(Y.opacity!=0){a(Y.opacity);c(Y.blending);k=M.positionScreen.x;o=M.positionScreen.y;q=fa.positionScreen.x;j=fa.positionScreen.y;v=aa.positionScreen.x;t=aa.positionScreen.y;m.beginPath();m.moveTo(k,
-o);m.lineTo(q,j);m.lineTo(v,t);m.lineTo(k,o);m.closePath();if(Y instanceof THREE.MeshBasicMaterial)if(Y.map)Y.map.image.loaded&&Y.map.mapping instanceof THREE.UVMapping&&Aa(k,o,q,j,v,t,Y.map.image,R.uvs[0].u,R.uvs[0].v,R.uvs[1].u,R.uvs[1].v,R.uvs[2].u,R.uvs[2].v);else if(Y.env_map){if(Y.env_map.image.loaded)if(Y.env_map.mapping instanceof THREE.SphericalReflectionMapping){M=sa.matrix;J.copy(R.vertexNormalsWorld[0]);T=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;U=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;
-J.copy(R.vertexNormalsWorld[1]);ba=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;ca=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;J.copy(R.vertexNormalsWorld[2]);S=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;K=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;Aa(k,o,q,j,v,t,Y.env_map.image,T,U,ba,ca,S,K)}}else Y.wireframe?Ea(Y.color.__styleString,Y.wireframe_linewidth):Fa(Y.color.__styleString);else if(Y instanceof THREE.MeshLambertMaterial){if(Y.map&&!Y.wireframe){Y.map.mapping instanceof THREE.UVMapping&&Aa(k,o,q,j,v,
-t,Y.map.image,R.uvs[0].u,R.uvs[0].v,R.uvs[1].u,R.uvs[1].v,R.uvs[2].u,R.uvs[2].v);c(THREE.SubtractiveBlending)}if(W)if(!Y.wireframe&&Y.shading==THREE.SmoothShading&&R.vertexNormalsWorld.length==3){A.r=D.r=B.r=da.r;A.g=D.g=B.g=da.g;A.b=D.b=B.b=da.b;Da(ga,R.v1.positionWorld,R.vertexNormalsWorld[0],A);Da(ga,R.v2.positionWorld,R.vertexNormalsWorld[1],D);Da(ga,R.v3.positionWorld,R.vertexNormalsWorld[2],B);I.r=(D.r+B.r)*0.5;I.g=(D.g+B.g)*0.5;I.b=(D.b+B.b)*0.5;Q=Na(A,D,B,I);Aa(k,o,q,j,v,t,Q,0,0,1,0,0,1)}else{$.r=
-da.r;$.g=da.g;$.b=da.b;Da(ga,R.centroidWorld,R.normalWorld,$);x.r=Y.color.r*$.r;x.g=Y.color.g*$.g;x.b=Y.color.b*$.b;x.updateStyleString();Y.wireframe?Ea(x.__styleString,Y.wireframe_linewidth):Fa(x.__styleString)}else Y.wireframe?Ea(Y.color.__styleString,Y.wireframe_linewidth):Fa(Y.color.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){P=sa.near;O=sa.far;A.r=A.g=A.b=1-Ia(M.positionScreen.z,P,O);D.r=D.g=D.b=1-Ia(fa.positionScreen.z,P,O);B.r=B.g=B.b=1-Ia(aa.positionScreen.z,P,O);I.r=(D.r+
-B.r)*0.5;I.g=(D.g+B.g)*0.5;I.b=(D.b+B.b)*0.5;Q=Na(A,D,B,I);Aa(k,o,q,j,v,t,Q,0,0,1,0,0,1)}else if(Y instanceof THREE.MeshNormalMaterial){x.r=Ja(R.normalWorld.x);x.g=Ja(R.normalWorld.y);x.b=Ja(R.normalWorld.z);x.updateStyleString();Y.wireframe?Ea(x.__styleString,Y.wireframe_linewidth):Fa(x.__styleString)}}}function Ea(M,fa){if(z!=M)m.strokeStyle=z=M;if(G!=fa)m.lineWidth=G=fa;m.stroke();N.inflate(fa*2)}function Fa(M){if(F!=M)m.fillStyle=F=M;m.fill()}function Aa(M,fa,aa,R,Y,ga,na,oa,pa,va,ra,wa,Ba){var ya,
+0){a(aa.opacity);c(aa.blending);var R,Y,ga,na,oa,pa;if(aa instanceof THREE.ParticleBasicMaterial){if(aa.map&&aa.map.image.loaded){na=aa.map.image;oa=na.width>>1;pa=na.height>>1;Y=fa.scale.x*k;ga=fa.scale.y*g;aa=Y*oa;R=ga*pa;P.set(M.x-aa,M.y-R,M.x+aa,M.y+R);if(Z.instersects(P)){m.save();m.translate(M.x,M.y);m.rotate(-fa.rotation);m.scale(Y,-ga);m.translate(-oa,-pa);m.drawImage(na,0,0);m.restore()}}}else if(aa instanceof THREE.ParticleCircleMaterial){if(W){$.r=da.r+ha.r+E.r;$.g=da.g+ha.g+E.g;$.b=da.b+
+ha.b+E.b;y.r=aa.color.r*$.r;y.g=aa.color.g*$.g;y.b=aa.color.b*$.b;y.updateStyleString()}else y.__styleString=aa.color.__styleString;aa=fa.scale.x*k;R=fa.scale.y*g;P.set(M.x-aa,M.y-R,M.x+aa,M.y+R);if(Z.instersects(P)){Y=y.__styleString;if(C!=Y)m.fillStyle=C=Y;m.save();m.translate(M.x,M.y);m.rotate(-fa.rotation);m.scale(aa,R);m.beginPath();m.arc(0,0,1,0,L,true);m.closePath();m.fill();m.restore()}}}}function Ra(M,fa,aa,R){if(R.opacity!=0){a(R.opacity);c(R.blending);m.beginPath();m.moveTo(M.positionScreen.x,
+M.positionScreen.y);m.lineTo(fa.positionScreen.x,fa.positionScreen.y);m.closePath();if(R instanceof THREE.LineBasicMaterial){y.__styleString=R.color.__styleString;M=R.linewidth;if(G!=M)m.lineWidth=G=M;M=y.__styleString;if(z!=M)m.strokeStyle=z=M;m.stroke();P.inflate(R.linewidth*2)}}}function Ma(M,fa,aa,R,Y,ga){if(Y.opacity!=0){a(Y.opacity);c(Y.blending);l=M.positionScreen.x;u=M.positionScreen.y;t=fa.positionScreen.x;j=fa.positionScreen.y;p=aa.positionScreen.x;x=aa.positionScreen.y;m.beginPath();m.moveTo(l,
+u);m.lineTo(t,j);m.lineTo(p,x);m.lineTo(l,u);m.closePath();if(Y instanceof THREE.MeshBasicMaterial)if(Y.map)Y.map.image.loaded&&Y.map.mapping instanceof THREE.UVMapping&&Aa(l,u,t,j,p,x,Y.map.image,R.uvs[0].u,R.uvs[0].v,R.uvs[1].u,R.uvs[1].v,R.uvs[2].u,R.uvs[2].v);else if(Y.env_map){if(Y.env_map.image.loaded)if(Y.env_map.mapping instanceof THREE.SphericalReflectionMapping){M=sa.matrix;J.copy(R.vertexNormalsWorld[0]);T=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;U=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;
+J.copy(R.vertexNormalsWorld[1]);ba=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;ca=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;J.copy(R.vertexNormalsWorld[2]);S=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;K=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;Aa(l,u,t,j,p,x,Y.env_map.image,T,U,ba,ca,S,K)}}else Y.wireframe?Ea(Y.color.__styleString,Y.wireframe_linewidth):Fa(Y.color.__styleString);else if(Y instanceof THREE.MeshLambertMaterial){if(Y.map&&!Y.wireframe){Y.map.mapping instanceof THREE.UVMapping&&Aa(l,u,t,j,p,
+x,Y.map.image,R.uvs[0].u,R.uvs[0].v,R.uvs[1].u,R.uvs[1].v,R.uvs[2].u,R.uvs[2].v);c(THREE.SubtractiveBlending)}if(W)if(!Y.wireframe&&Y.shading==THREE.SmoothShading&&R.vertexNormalsWorld.length==3){F.r=B.r=D.r=da.r;F.g=B.g=D.g=da.g;F.b=B.b=D.b=da.b;Da(ga,R.v1.positionWorld,R.vertexNormalsWorld[0],F);Da(ga,R.v2.positionWorld,R.vertexNormalsWorld[1],B);Da(ga,R.v3.positionWorld,R.vertexNormalsWorld[2],D);I.r=(B.r+D.r)*0.5;I.g=(B.g+D.g)*0.5;I.b=(B.b+D.b)*0.5;Q=Na(F,B,D,I);Aa(l,u,t,j,p,x,Q,0,0,1,0,0,1)}else{$.r=
+da.r;$.g=da.g;$.b=da.b;Da(ga,R.centroidWorld,R.normalWorld,$);y.r=Y.color.r*$.r;y.g=Y.color.g*$.g;y.b=Y.color.b*$.b;y.updateStyleString();Y.wireframe?Ea(y.__styleString,Y.wireframe_linewidth):Fa(y.__styleString)}else Y.wireframe?Ea(Y.color.__styleString,Y.wireframe_linewidth):Fa(Y.color.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){N=sa.near;O=sa.far;F.r=F.g=F.b=1-Ia(M.positionScreen.z,N,O);B.r=B.g=B.b=1-Ia(fa.positionScreen.z,N,O);D.r=D.g=D.b=1-Ia(aa.positionScreen.z,N,O);I.r=(B.r+
+D.r)*0.5;I.g=(B.g+D.g)*0.5;I.b=(B.b+D.b)*0.5;Q=Na(F,B,D,I);Aa(l,u,t,j,p,x,Q,0,0,1,0,0,1)}else if(Y instanceof THREE.MeshNormalMaterial){y.r=Ja(R.normalWorld.x);y.g=Ja(R.normalWorld.y);y.b=Ja(R.normalWorld.z);y.updateStyleString();Y.wireframe?Ea(y.__styleString,Y.wireframe_linewidth):Fa(y.__styleString)}}}function Ea(M,fa){if(z!=M)m.strokeStyle=z=M;if(G!=fa)m.lineWidth=G=fa;m.stroke();P.inflate(fa*2)}function Fa(M){if(C!=M)m.fillStyle=C=M;m.fill()}function Aa(M,fa,aa,R,Y,ga,na,oa,pa,va,ra,wa,Ba){var ya,
 xa;ya=na.width-1;xa=na.height-1;oa*=ya;pa*=xa;va*=ya;ra*=xa;wa*=ya;Ba*=xa;aa-=M;R-=fa;Y-=M;ga-=fa;va-=oa;ra-=pa;wa-=oa;Ba-=pa;xa=1/(va*Ba-wa*ra);ya=(Ba*aa-ra*Y)*xa;ra=(Ba*R-ra*ga)*xa;aa=(va*Y-wa*aa)*xa;R=(va*ga-wa*R)*xa;M=M-ya*oa-aa*pa;fa=fa-ra*oa-R*pa;m.save();m.transform(ya,ra,aa,R,M,fa);m.clip();m.drawImage(na,0,0);m.restore()}function Na(M,fa,aa,R){var Y=~~(M.r*255),ga=~~(M.g*255);M=~~(M.b*255);var na=~~(fa.r*255),oa=~~(fa.g*255);fa=~~(fa.b*255);var pa=~~(aa.r*255),va=~~(aa.g*255);aa=~~(aa.b*
 255);var ra=~~(R.r*255),wa=~~(R.g*255);R=~~(R.b*255);ia[0]=Y<0?0:Y>255?255:Y;ia[1]=ga<0?0:ga>255?255:ga;ia[2]=M<0?0:M>255?255:M;ia[4]=na<0?0:na>255?255:na;ia[5]=oa<0?0:oa>255?255:oa;ia[6]=fa<0?0:fa>255?255:fa;ia[8]=pa<0?0:pa>255?255:pa;ia[9]=va<0?0:va>255?255:va;ia[10]=aa<0?0:aa>255?255:aa;ia[12]=ra<0?0:ra>255?255:ra;ia[13]=wa<0?0:wa>255?255:wa;ia[14]=R<0?0:R>255?255:R;ea.putImageData(ja,0,0);la.drawImage(X,0,0);return qa}function Ia(M,fa,aa){M=(M-fa)/(aa-fa);return M*M*(3-2*M)}function Ja(M){M=(M+
-1)*0.5;return M<0?0:M>1?1:M}function Ka(M,fa){var aa=fa.x-M.x,R=fa.y-M.y,Y=1/Math.sqrt(aa*aa+R*R);aa*=Y;R*=Y;fa.x+=aa;fa.y+=R;M.x-=aa;M.y-=R}var Ga,Oa,ka,ta,za,La,Pa,Ca;this.autoClear?this.clear():m.setTransform(1,0,0,-1,h,g);d=e.projectScene(ma,sa,this.sortElements);(W=ma.lights.length>0)&&Ha(ma);Ga=0;for(Oa=d.length;Ga<Oa;Ga++){ka=d[Ga];N.empty();if(ka instanceof THREE.RenderableParticle){u=ka;u.x*=h;u.y*=g;ta=0;for(za=ka.materials.length;ta<za;ta++)Qa(u,ka,ka.materials[ta],ma)}else if(ka instanceof
-THREE.RenderableLine){u=ka.v1;H=ka.v2;u.positionScreen.x*=h;u.positionScreen.y*=g;H.positionScreen.x*=h;H.positionScreen.y*=g;N.addPoint(u.positionScreen.x,u.positionScreen.y);N.addPoint(H.positionScreen.x,H.positionScreen.y);if(Z.instersects(N)){ta=0;for(za=ka.materials.length;ta<za;)Ra(u,H,ka,ka.materials[ta++],ma)}}else if(ka instanceof THREE.RenderableFace3){u=ka.v1;H=ka.v2;n=ka.v3;u.positionScreen.x*=h;u.positionScreen.y*=g;H.positionScreen.x*=h;H.positionScreen.y*=g;n.positionScreen.x*=h;n.positionScreen.y*=
-g;if(ka.overdraw){Ka(u.positionScreen,H.positionScreen);Ka(H.positionScreen,n.positionScreen);Ka(n.positionScreen,u.positionScreen)}N.add3Points(u.positionScreen.x,u.positionScreen.y,H.positionScreen.x,H.positionScreen.y,n.positionScreen.x,n.positionScreen.y);if(Z.instersects(N)){ta=0;for(za=ka.meshMaterials.length;ta<za;){Ca=ka.meshMaterials[ta++];if(Ca instanceof THREE.MeshFaceMaterial){La=0;for(Pa=ka.faceMaterials.length;La<Pa;)(Ca=ka.faceMaterials[La++])&&Ma(u,H,n,ka,Ca,ma)}else Ma(u,H,n,ka,Ca,
-ma)}}}V.addRectangle(N)}m.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(T,U,ba){var ca,S,K,Z;ca=0;for(S=T.lights.length;ca<S;ca++){K=T.lights[ca];if(K instanceof THREE.DirectionalLight){Z=U.normalWorld.dot(K.position)*K.intensity;if(Z>0){ba.r+=K.color.r*Z;ba.g+=K.color.g*Z;ba.b+=K.color.b*Z}}else if(K instanceof THREE.PointLight){t.sub(K.position,U.centroidWorld);t.normalize();Z=U.normalWorld.dot(t)*K.intensity;if(Z>0){ba.r+=K.color.r*Z;ba.g+=K.color.g*Z;ba.b+=K.color.b*Z}}}}function c(T,U,ba,ca,S,K){B=e(I++);B.setAttribute("d",
-"M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)n.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(H){k.r=o.r;k.g=o.g;k.b=o.b;a(K,ca,k);n.r=S.color.r*k.r;n.g=S.color.g*k.g;n.b=S.color.b*k.b;n.updateStyleString()}else n.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){v=1-S.__2near/(S.__farPlusNear-
-ca.z*S.__farMinusNear);n.setRGB(v,v,v)}else S instanceof THREE.MeshNormalMaterial&&n.setRGB(f(ca.normalWorld.x),f(ca.normalWorld.y),f(ca.normalWorld.z));S.wireframe?B.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+S.wireframe_linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframe_linecap+"; stroke-linejoin: "+S.wireframe_linejoin):B.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+S.opacity);h.appendChild(B)}function d(T,U,ba,ca,S,
-K,Z){B=e(I++);B.setAttribute("d","M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");if(K instanceof THREE.MeshBasicMaterial)n.__styleString=K.color.__styleString;else if(K instanceof THREE.MeshLambertMaterial)if(H){k.r=o.r;k.g=o.g;k.b=o.b;a(Z,S,k);n.r=K.color.r*k.r;n.g=K.color.g*k.g;n.b=K.color.b*k.b;n.updateStyleString()}else n.__styleString=K.color.__styleString;
-else if(K instanceof THREE.MeshDepthMaterial){v=1-K.__2near/(K.__farPlusNear-S.z*K.__farMinusNear);n.setRGB(v,v,v)}else K instanceof THREE.MeshNormalMaterial&&n.setRGB(f(S.normalWorld.x),f(S.normalWorld.y),f(S.normalWorld.z));K.wireframe?B.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+K.wireframe_linewidth+"; stroke-opacity: "+K.opacity+"; stroke-linecap: "+K.wireframe_linecap+"; stroke-linejoin: "+K.wireframe_linejoin):B.setAttribute("style","fill: "+n.__styleString+
-"; fill-opacity: "+K.opacity);h.appendChild(B)}function e(T){if(x[T]==null){x[T]=document.createElementNS("http://www.w3.org/2000/svg","path");Q==0&&x[T].setAttribute("shape-rendering","crispEdges");return x[T]}return x[T]}function f(T){return T<0?Math.min((1+T)*0.5,0.5):0.5+Math.min(T*0.5,0.5)}var b=null,l=new THREE.Projector,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),g,m,y,C,w,p,z,F,G=new THREE.Rectangle,u=new THREE.Rectangle,H=false,n=new THREE.Color(16777215),k=new THREE.Color(16777215),
-o=new THREE.Color(0),q=new THREE.Color(0),j=new THREE.Color(0),v,t=new THREE.Vector3,x=[],A=[],D=[],B,I,P,O,Q=1;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(T){switch(T){case "high":Q=1;break;case "low":Q=0}};this.setSize=function(T,U){g=T;m=U;y=g/2;C=m/2;h.setAttribute("viewBox",-y+" "+-C+" "+g+" "+m);h.setAttribute("width",g);h.setAttribute("height",m);G.set(-y,-C,y,C)};this.clear=function(){for(;h.childNodes.length>0;)h.removeChild(h.childNodes[0])};
-this.render=function(T,U){var ba,ca,S,K,Z,V,N,W;this.autoClear&&this.clear();b=l.projectScene(T,U,this.sortElements);O=P=I=0;if(H=T.lights.length>0){N=T.lights;o.setRGB(0,0,0);q.setRGB(0,0,0);j.setRGB(0,0,0);ba=0;for(ca=N.length;ba<ca;ba++){S=N[ba];K=S.color;if(S instanceof THREE.AmbientLight){o.r+=K.r;o.g+=K.g;o.b+=K.b}else if(S instanceof THREE.DirectionalLight){q.r+=K.r;q.g+=K.g;q.b+=K.b}else if(S instanceof THREE.PointLight){j.r+=K.r;j.g+=K.g;j.b+=K.b}}}ba=0;for(ca=b.length;ba<ca;ba++){N=b[ba];
-u.empty();if(N instanceof THREE.RenderableParticle){w=N;w.x*=y;w.y*=-C;S=0;for(K=N.materials.length;S<K;S++)if(W=N.materials[S]){Z=w;V=N;W=W;var $=P++;if(A[$]==null){A[$]=document.createElementNS("http://www.w3.org/2000/svg","circle");Q==0&&A[$].setAttribute("shape-rendering","crispEdges")}B=A[$];B.setAttribute("cx",Z.x);B.setAttribute("cy",Z.y);B.setAttribute("r",V.scale.x*y);if(W instanceof THREE.ParticleCircleMaterial){if(H){k.r=o.r+q.r+j.r;k.g=o.g+q.g+j.g;k.b=o.b+q.b+j.b;n.r=W.color.r*k.r;n.g=
-W.color.g*k.g;n.b=W.color.b*k.b;n.updateStyleString()}else n=W.color;B.setAttribute("style","fill: "+n.__styleString)}h.appendChild(B)}}else if(N instanceof THREE.RenderableLine){w=N.v1;p=N.v2;w.positionScreen.x*=y;w.positionScreen.y*=-C;p.positionScreen.x*=y;p.positionScreen.y*=-C;u.addPoint(w.positionScreen.x,w.positionScreen.y);u.addPoint(p.positionScreen.x,p.positionScreen.y);if(G.instersects(u)){S=0;for(K=N.materials.length;S<K;)if(W=N.materials[S++]){Z=w;V=p;W=W;$=O++;if(D[$]==null){D[$]=document.createElementNS("http://www.w3.org/2000/svg",
-"line");Q==0&&D[$].setAttribute("shape-rendering","crispEdges")}B=D[$];B.setAttribute("x1",Z.positionScreen.x);B.setAttribute("y1",Z.positionScreen.y);B.setAttribute("x2",V.positionScreen.x);B.setAttribute("y2",V.positionScreen.y);if(W instanceof THREE.LineBasicMaterial){n.__styleString=W.color.__styleString;B.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+W.linewidth+"; stroke-opacity: "+W.opacity+"; stroke-linecap: "+W.linecap+"; stroke-linejoin: "+W.linejoin);h.appendChild(B)}}}}else if(N instanceof
-THREE.RenderableFace3){w=N.v1;p=N.v2;z=N.v3;w.positionScreen.x*=y;w.positionScreen.y*=-C;p.positionScreen.x*=y;p.positionScreen.y*=-C;z.positionScreen.x*=y;z.positionScreen.y*=-C;u.addPoint(w.positionScreen.x,w.positionScreen.y);u.addPoint(p.positionScreen.x,p.positionScreen.y);u.addPoint(z.positionScreen.x,z.positionScreen.y);if(G.instersects(u)){S=0;for(K=N.meshMaterials.length;S<K;){W=N.meshMaterials[S++];if(W instanceof THREE.MeshFaceMaterial){Z=0;for(V=N.faceMaterials.length;Z<V;)(W=N.faceMaterials[Z++])&&
-c(w,p,z,N,W,T)}else W&&c(w,p,z,N,W,T)}}}else if(N instanceof THREE.RenderableFace4){w=N.v1;p=N.v2;z=N.v3;F=N.v4;w.positionScreen.x*=y;w.positionScreen.y*=-C;p.positionScreen.x*=y;p.positionScreen.y*=-C;z.positionScreen.x*=y;z.positionScreen.y*=-C;F.positionScreen.x*=y;F.positionScreen.y*=-C;u.addPoint(w.positionScreen.x,w.positionScreen.y);u.addPoint(p.positionScreen.x,p.positionScreen.y);u.addPoint(z.positionScreen.x,z.positionScreen.y);u.addPoint(F.positionScreen.x,F.positionScreen.y);if(G.instersects(u)){S=
-0;for(K=N.meshMaterials.length;S<K;){W=N.meshMaterials[S++];if(W instanceof THREE.MeshFaceMaterial){Z=0;for(V=N.faceMaterials.length;Z<V;)(W=N.faceMaterials[Z++])&&d(w,p,z,F,N,W,T)}else W&&d(w,p,z,F,N,W,T)}}}}}};
-THREE.WebGLRenderer=function(a){function c(k,o){k.fragment_shader=o.fragment_shader;k.vertex_shader=o.vertex_shader;k.uniforms=Uniforms.clone(o.uniforms)}function d(k,o){var q;if(k=="fragment")q=b.createShader(b.FRAGMENT_SHADER);else if(k=="vertex")q=b.createShader(b.VERTEX_SHADER);b.shaderSource(q,o);b.compileShader(q);if(!b.getShaderParameter(q,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(q));return null}return q}function e(k){switch(k){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;
+1)*0.5;return M<0?0:M>1?1:M}function Ka(M,fa){var aa=fa.x-M.x,R=fa.y-M.y,Y=1/Math.sqrt(aa*aa+R*R);aa*=Y;R*=Y;fa.x+=aa;fa.y+=R;M.x-=aa;M.y-=R}var Ga,Oa,ka,ta,za,La,Pa,Ca;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,g);d=e.projectScene(ma,sa,this.sortElements);(W=ma.lights.length>0)&&Ha(ma);Ga=0;for(Oa=d.length;Ga<Oa;Ga++){ka=d[Ga];P.empty();if(ka instanceof THREE.RenderableParticle){w=ka;w.x*=k;w.y*=g;ta=0;for(za=ka.materials.length;ta<za;ta++)Qa(w,ka,ka.materials[ta],ma)}else if(ka instanceof
+THREE.RenderableLine){w=ka.v1;H=ka.v2;w.positionScreen.x*=k;w.positionScreen.y*=g;H.positionScreen.x*=k;H.positionScreen.y*=g;P.addPoint(w.positionScreen.x,w.positionScreen.y);P.addPoint(H.positionScreen.x,H.positionScreen.y);if(Z.instersects(P)){ta=0;for(za=ka.materials.length;ta<za;)Ra(w,H,ka,ka.materials[ta++],ma)}}else if(ka instanceof THREE.RenderableFace3){w=ka.v1;H=ka.v2;o=ka.v3;w.positionScreen.x*=k;w.positionScreen.y*=g;H.positionScreen.x*=k;H.positionScreen.y*=g;o.positionScreen.x*=k;o.positionScreen.y*=
+g;if(ka.overdraw){Ka(w.positionScreen,H.positionScreen);Ka(H.positionScreen,o.positionScreen);Ka(o.positionScreen,w.positionScreen)}P.add3Points(w.positionScreen.x,w.positionScreen.y,H.positionScreen.x,H.positionScreen.y,o.positionScreen.x,o.positionScreen.y);if(Z.instersects(P)){ta=0;for(za=ka.meshMaterials.length;ta<za;){Ca=ka.meshMaterials[ta++];if(Ca instanceof THREE.MeshFaceMaterial){La=0;for(Pa=ka.faceMaterials.length;La<Pa;)(Ca=ka.faceMaterials[La++])&&Ma(w,H,o,ka,Ca,ma)}else Ma(w,H,o,ka,Ca,
+ma)}}}V.addRectangle(P)}m.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(T,U,ba){var ca,S,K,Z;ca=0;for(S=T.lights.length;ca<S;ca++){K=T.lights[ca];if(K instanceof THREE.DirectionalLight){Z=U.normalWorld.dot(K.position)*K.intensity;if(Z>0){ba.r+=K.color.r*Z;ba.g+=K.color.g*Z;ba.b+=K.color.b*Z}}else if(K instanceof THREE.PointLight){x.sub(K.position,U.centroidWorld);x.normalize();Z=U.normalWorld.dot(x)*K.intensity;if(Z>0){ba.r+=K.color.r*Z;ba.g+=K.color.g*Z;ba.b+=K.color.b*Z}}}}function c(T,U,ba,ca,S,K){D=e(I++);D.setAttribute("d",
+"M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)o.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(H){l.r=u.r;l.g=u.g;l.b=u.b;a(K,ca,l);o.r=S.color.r*l.r;o.g=S.color.g*l.g;o.b=S.color.b*l.b;o.updateStyleString()}else o.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){p=1-S.__2near/(S.__farPlusNear-
+ca.z*S.__farMinusNear);o.setRGB(p,p,p)}else S instanceof THREE.MeshNormalMaterial&&o.setRGB(f(ca.normalWorld.x),f(ca.normalWorld.y),f(ca.normalWorld.z));S.wireframe?D.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+S.wireframe_linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframe_linecap+"; stroke-linejoin: "+S.wireframe_linejoin):D.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+S.opacity);k.appendChild(D)}function d(T,U,ba,ca,S,
+K,Z){D=e(I++);D.setAttribute("d","M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");if(K instanceof THREE.MeshBasicMaterial)o.__styleString=K.color.__styleString;else if(K instanceof THREE.MeshLambertMaterial)if(H){l.r=u.r;l.g=u.g;l.b=u.b;a(Z,S,l);o.r=K.color.r*l.r;o.g=K.color.g*l.g;o.b=K.color.b*l.b;o.updateStyleString()}else o.__styleString=K.color.__styleString;
+else if(K instanceof THREE.MeshDepthMaterial){p=1-K.__2near/(K.__farPlusNear-S.z*K.__farMinusNear);o.setRGB(p,p,p)}else K instanceof THREE.MeshNormalMaterial&&o.setRGB(f(S.normalWorld.x),f(S.normalWorld.y),f(S.normalWorld.z));K.wireframe?D.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+K.wireframe_linewidth+"; stroke-opacity: "+K.opacity+"; stroke-linecap: "+K.wireframe_linecap+"; stroke-linejoin: "+K.wireframe_linejoin):D.setAttribute("style","fill: "+o.__styleString+
+"; fill-opacity: "+K.opacity);k.appendChild(D)}function e(T){if(y[T]==null){y[T]=document.createElementNS("http://www.w3.org/2000/svg","path");Q==0&&y[T].setAttribute("shape-rendering","crispEdges");return y[T]}return y[T]}function f(T){return T<0?Math.min((1+T)*0.5,0.5):0.5+Math.min(T*0.5,0.5)}var b=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),g,m,q,A,v,n,z,C,G=new THREE.Rectangle,w=new THREE.Rectangle,H=false,o=new THREE.Color(16777215),l=new THREE.Color(16777215),
+u=new THREE.Color(0),t=new THREE.Color(0),j=new THREE.Color(0),p,x=new THREE.Vector3,y=[],F=[],B=[],D,I,N,O,Q=1;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(T){switch(T){case "high":Q=1;break;case "low":Q=0}};this.setSize=function(T,U){g=T;m=U;q=g/2;A=m/2;k.setAttribute("viewBox",-q+" "+-A+" "+g+" "+m);k.setAttribute("width",g);k.setAttribute("height",m);G.set(-q,-A,q,A)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};
+this.render=function(T,U){var ba,ca,S,K,Z,V,P,W;this.autoClear&&this.clear();b=h.projectScene(T,U,this.sortElements);O=N=I=0;if(H=T.lights.length>0){P=T.lights;u.setRGB(0,0,0);t.setRGB(0,0,0);j.setRGB(0,0,0);ba=0;for(ca=P.length;ba<ca;ba++){S=P[ba];K=S.color;if(S instanceof THREE.AmbientLight){u.r+=K.r;u.g+=K.g;u.b+=K.b}else if(S instanceof THREE.DirectionalLight){t.r+=K.r;t.g+=K.g;t.b+=K.b}else if(S instanceof THREE.PointLight){j.r+=K.r;j.g+=K.g;j.b+=K.b}}}ba=0;for(ca=b.length;ba<ca;ba++){P=b[ba];
+w.empty();if(P instanceof THREE.RenderableParticle){v=P;v.x*=q;v.y*=-A;S=0;for(K=P.materials.length;S<K;S++)if(W=P.materials[S]){Z=v;V=P;W=W;var $=N++;if(F[$]==null){F[$]=document.createElementNS("http://www.w3.org/2000/svg","circle");Q==0&&F[$].setAttribute("shape-rendering","crispEdges")}D=F[$];D.setAttribute("cx",Z.x);D.setAttribute("cy",Z.y);D.setAttribute("r",V.scale.x*q);if(W instanceof THREE.ParticleCircleMaterial){if(H){l.r=u.r+t.r+j.r;l.g=u.g+t.g+j.g;l.b=u.b+t.b+j.b;o.r=W.color.r*l.r;o.g=
+W.color.g*l.g;o.b=W.color.b*l.b;o.updateStyleString()}else o=W.color;D.setAttribute("style","fill: "+o.__styleString)}k.appendChild(D)}}else if(P instanceof THREE.RenderableLine){v=P.v1;n=P.v2;v.positionScreen.x*=q;v.positionScreen.y*=-A;n.positionScreen.x*=q;n.positionScreen.y*=-A;w.addPoint(v.positionScreen.x,v.positionScreen.y);w.addPoint(n.positionScreen.x,n.positionScreen.y);if(G.instersects(w)){S=0;for(K=P.materials.length;S<K;)if(W=P.materials[S++]){Z=v;V=n;W=W;$=O++;if(B[$]==null){B[$]=document.createElementNS("http://www.w3.org/2000/svg",
+"line");Q==0&&B[$].setAttribute("shape-rendering","crispEdges")}D=B[$];D.setAttribute("x1",Z.positionScreen.x);D.setAttribute("y1",Z.positionScreen.y);D.setAttribute("x2",V.positionScreen.x);D.setAttribute("y2",V.positionScreen.y);if(W instanceof THREE.LineBasicMaterial){o.__styleString=W.color.__styleString;D.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+W.linewidth+"; stroke-opacity: "+W.opacity+"; stroke-linecap: "+W.linecap+"; stroke-linejoin: "+W.linejoin);k.appendChild(D)}}}}else if(P instanceof
+THREE.RenderableFace3){v=P.v1;n=P.v2;z=P.v3;v.positionScreen.x*=q;v.positionScreen.y*=-A;n.positionScreen.x*=q;n.positionScreen.y*=-A;z.positionScreen.x*=q;z.positionScreen.y*=-A;w.addPoint(v.positionScreen.x,v.positionScreen.y);w.addPoint(n.positionScreen.x,n.positionScreen.y);w.addPoint(z.positionScreen.x,z.positionScreen.y);if(G.instersects(w)){S=0;for(K=P.meshMaterials.length;S<K;){W=P.meshMaterials[S++];if(W instanceof THREE.MeshFaceMaterial){Z=0;for(V=P.faceMaterials.length;Z<V;)(W=P.faceMaterials[Z++])&&
+c(v,n,z,P,W,T)}else W&&c(v,n,z,P,W,T)}}}else if(P instanceof THREE.RenderableFace4){v=P.v1;n=P.v2;z=P.v3;C=P.v4;v.positionScreen.x*=q;v.positionScreen.y*=-A;n.positionScreen.x*=q;n.positionScreen.y*=-A;z.positionScreen.x*=q;z.positionScreen.y*=-A;C.positionScreen.x*=q;C.positionScreen.y*=-A;w.addPoint(v.positionScreen.x,v.positionScreen.y);w.addPoint(n.positionScreen.x,n.positionScreen.y);w.addPoint(z.positionScreen.x,z.positionScreen.y);w.addPoint(C.positionScreen.x,C.positionScreen.y);if(G.instersects(w)){S=
+0;for(K=P.meshMaterials.length;S<K;){W=P.meshMaterials[S++];if(W instanceof THREE.MeshFaceMaterial){Z=0;for(V=P.faceMaterials.length;Z<V;)(W=P.faceMaterials[Z++])&&d(v,n,z,C,P,W,T)}else W&&d(v,n,z,C,P,W,T)}}}}}};
+THREE.WebGLRenderer=function(a){function c(l,u){l.fragment_shader=u.fragment_shader;l.vertex_shader=u.vertex_shader;l.uniforms=Uniforms.clone(u.uniforms)}function d(l,u){var t;if(l=="fragment")t=b.createShader(b.FRAGMENT_SHADER);else if(l=="vertex")t=b.createShader(b.VERTEX_SHADER);b.shaderSource(t,u);b.compileShader(t);if(!b.getShaderParameter(t,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(t));return null}return t}function e(l){switch(l){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;
 case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;
-case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var f=document.createElement("canvas"),b,l=null,h=null,g=new THREE.Matrix4,m,y=new Float32Array(16),C=new Float32Array(16),
-w=new Float32Array(16),p=new Float32Array(9),z=new Float32Array(16),F=new THREE.Matrix4,G=new THREE.Vector4,u=true,H=new THREE.Color(0),n=0;if(a){if(a.antialias!==undefined)u=a.antialias;a.clearColor!==undefined&&H.setHex(a.clearColor);if(a.clearAlpha!==undefined)n=a.clearAlpha}this.domElement=f;this.autoClear=true;(function(k,o,q){try{b=f.getContext("experimental-webgl",{antialias:k})}catch(j){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);
-b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(o.r,o.g,o.b,q)})(u,H,n);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(k,o){f.width=k;f.height=o;b.viewport(0,0,f.width,f.height)};this.setClearColor=function(k,o){var q=new THREE.Color(k);b.clearColor(q.r,q.g,q.b,o)};
-this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(k,o){var q,j,v,t=0,x=0,A=0,D,B,I,P=this.lights,O=P.directional.colors,Q=P.directional.positions,T=P.point.colors,U=P.point.positions,ba=0,ca=0;q=0;for(j=o.length;q<j;q++){v=o[q];D=v.color;B=v.position;I=v.intensity;if(v instanceof THREE.AmbientLight){t+=D.r;x+=D.g;A+=D.b}else if(v instanceof THREE.DirectionalLight){O[ba*3]=D.r*I;O[ba*3+1]=D.g*I;O[ba*3+2]=D.b*I;Q[ba*3]=B.x;Q[ba*3+1]=B.y;Q[ba*3+2]=B.z;ba+=
-1}else if(v instanceof THREE.PointLight){T[ca*3]=D.r*I;T[ca*3+1]=D.g*I;T[ca*3+2]=D.b*I;U[ca*3]=B.x;U[ca*3+1]=B.y;U[ca*3+2]=B.z;ca+=1}}P.point.length=ca;P.directional.length=ba;P.ambient[0]=t;P.ambient[1]=x;P.ambient[2]=A};this.createParticleBuffers=function(k){k.__webGLVertexBuffer=b.createBuffer();k.__webGLParticleBuffer=b.createBuffer();k.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(k){k.__webGLVertexBuffer=b.createBuffer();k.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=
-function(k){k.__webGLVertexBuffer=b.createBuffer();k.__webGLNormalBuffer=b.createBuffer();k.__webGLTangentBuffer=b.createBuffer();k.__webGLUVBuffer=b.createBuffer();k.__webGLUV2Buffer=b.createBuffer();k.__webGLFaceBuffer=b.createBuffer();k.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(k){var o=k.vertices.length;k.__vertexArray=new Float32Array(o*3);k.__lineArray=new Uint16Array(o);k.__webGLLineCount=o};this.initParticleBuffers=function(k){var o=k.vertices.length;k.__vertexArray=
-new Float32Array(o*3);k.__colorArray=new Float32Array(o*3);k.__particleArray=new Uint16Array(o);k.__sortArray=[];k.__webGLParticleCount=o};this.initMeshBuffers=function(k,o){var q,j,v=0,t=0,x=0,A=o.geometry.faces,D=k.faces;q=0;for(j=D.length;q<j;q++){fi=D[q];face=A[fi];if(face instanceof THREE.Face3){v+=3;t+=1;x+=3}else if(face instanceof THREE.Face4){v+=4;t+=2;x+=4}}k.__vertexArray=new Float32Array(v*3);k.__normalArray=new Float32Array(v*3);k.__tangentArray=new Float32Array(v*4);k.__uvArray=new Float32Array(v*
-2);k.__uv2Array=new Float32Array(v*2);k.__faceArray=new Uint16Array(t*3);k.__lineArray=new Uint16Array(x*2);v=false;q=0;for(j=o.materials.length;q<j;q++){A=o.materials[q];if(A instanceof THREE.MeshFaceMaterial){A=0;for(D=k.materials.length;A<D;A++)if(k.materials[A]&&k.materials[A].shading!=undefined&&k.materials[A].shading==THREE.SmoothShading){v=true;break}}else if(A&&A.shading!=undefined&&A.shading==THREE.SmoothShading){v=true;break}if(v)break}k.__needsSmoothNormals=v;k.__webGLFaceCount=t*3;k.__webGLLineCount=
-x*2};this.setMeshBuffers=function(k,o,q){var j,v,t,x,A,D,B,I,P,O,Q=0,T=0,U=0,ba=0,ca=0,S=0,K=0,Z=0,V=k.__vertexArray,N=k.__uvArray,W=k.__uv2Array,$=k.__normalArray,da=k.__tangentArray,ha=k.__faceArray,E=k.__lineArray,L=k.__needsSmoothNormals,J=o.geometry,X=J.__dirtyVertices,ea=J.__dirtyElements,ja=J.__dirtyUvs,ia=J.__dirtyNormals,qa=J.__dirtyTangents,la=J.vertices,ua=k.faces,ma=J.faces,sa=J.uvs,Ha=J.uvs2;o=0;for(j=ua.length;o<j;o++){v=ua[o];t=ma[v];D=sa[v];v=Ha[v];x=t.vertexNormals;A=t.normal;if(t instanceof
-THREE.Face3){if(X){B=la[t.a].position;I=la[t.b].position;P=la[t.c].position;V[T]=B.x;V[T+1]=B.y;V[T+2]=B.z;V[T+3]=I.x;V[T+4]=I.y;V[T+5]=I.z;V[T+6]=P.x;V[T+7]=P.y;V[T+8]=P.z;T+=9}if(qa&&J.hasTangents){B=la[t.a].tangent;I=la[t.b].tangent;P=la[t.c].tangent;da[K]=B.x;da[K+1]=B.y;da[K+2]=B.z;da[K+3]=B.w;da[K+4]=I.x;da[K+5]=I.y;da[K+6]=I.z;da[K+7]=I.w;da[K+8]=P.x;da[K+9]=P.y;da[K+10]=P.z;da[K+11]=P.w;K+=12}if(ia)if(x.length==3&&L)for(t=0;t<3;t++){A=x[t];$[S]=A.x;$[S+1]=A.y;$[S+2]=A.z;S+=3}else for(t=0;t<
-3;t++){$[S]=A.x;$[S+1]=A.y;$[S+2]=A.z;S+=3}if(ja&&D)for(t=0;t<3;t++){x=D[t];N[U]=x.u;N[U+1]=x.v;U+=2}if(ja&&v)for(t=0;t<3;t++){D=v[t];W[ba]=D.u;W[ba+1]=D.v;ba+=2}if(ea){ha[ca]=Q;ha[ca+1]=Q+1;ha[ca+2]=Q+2;ca+=3;E[Z]=Q;E[Z+1]=Q+1;E[Z+2]=Q;E[Z+3]=Q+2;E[Z+4]=Q+1;E[Z+5]=Q+2;Z+=6;Q+=3}}else if(t instanceof THREE.Face4){if(X){B=la[t.a].position;I=la[t.b].position;P=la[t.c].position;O=la[t.d].position;V[T]=B.x;V[T+1]=B.y;V[T+2]=B.z;V[T+3]=I.x;V[T+4]=I.y;V[T+5]=I.z;V[T+6]=P.x;V[T+7]=P.y;V[T+8]=P.z;V[T+9]=
-O.x;V[T+10]=O.y;V[T+11]=O.z;T+=12}if(qa&&J.hasTangents){B=la[t.a].tangent;I=la[t.b].tangent;P=la[t.c].tangent;t=la[t.d].tangent;da[K]=B.x;da[K+1]=B.y;da[K+2]=B.z;da[K+3]=B.w;da[K+4]=I.x;da[K+5]=I.y;da[K+6]=I.z;da[K+7]=I.w;da[K+8]=P.x;da[K+9]=P.y;da[K+10]=P.z;da[K+11]=P.w;da[K+12]=t.x;da[K+13]=t.y;da[K+14]=t.z;da[K+15]=t.w;K+=16}if(ia)if(x.length==4&&L)for(t=0;t<4;t++){A=x[t];$[S]=A.x;$[S+1]=A.y;$[S+2]=A.z;S+=3}else for(t=0;t<4;t++){$[S]=A.x;$[S+1]=A.y;$[S+2]=A.z;S+=3}if(ja&&D)for(t=0;t<4;t++){x=D[t];
-N[U]=x.u;N[U+1]=x.v;U+=2}if(ja&&v)for(t=0;t<4;t++){D=v[t];W[ba]=D.u;W[ba+1]=D.v;ba+=2}if(ea){ha[ca]=Q;ha[ca+1]=Q+1;ha[ca+2]=Q+2;ha[ca+3]=Q;ha[ca+4]=Q+2;ha[ca+5]=Q+3;ca+=6;E[Z]=Q;E[Z+1]=Q+1;E[Z+2]=Q;E[Z+3]=Q+3;E[Z+4]=Q+1;E[Z+5]=Q+2;E[Z+6]=Q+2;E[Z+7]=Q+3;Z+=8;Q+=4}}}if(X){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,V,q)}if(ia){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,$,q)}if(qa&&J.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLTangentBuffer);
-b.bufferData(b.ARRAY_BUFFER,da,q)}if(ja&&U>0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,N,q)}if(ja&&ba>0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,W,q)}if(ea){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ha,q);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,E,q)}};this.setLineBuffers=function(k,o){var q,j,v,t=k.vertices,x=t.length,A=k.__vertexArray,
-D=k.__lineArray,B=k.__dirtyElements;if(k.__dirtyVertices){for(q=0;q<x;q++){j=t[q].position;v=q*3;A[v]=j.x;A[v+1]=j.y;A[v+2]=j.z}b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,A,o)}if(B){for(q=0;q<x;q++)D[q]=q;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,D,o)}};this.setParticleBuffers=function(k,o,q,j){var v,t,x;t=k.vertices;var A=t.length,D=k.colors,B=D.length,I=k.__vertexArray,P=k.__particleArray,O=k.__colorArray,Q=k.__sortArray,
-T=k.__dirtyVertices,U=k.__dirtyElements,ba=k.__dirtyColors;if(q.sortParticles){F.multiply(j.projectionMatrix,j.matrix);F.multiplySelf(q.matrix);for(v=0;v<A;v++){x=t[v].position;G.copy(x);F.multiplyVector3(G);Q[v]=[G.z,v]}Q.sort(function(ca,S){return S[0]-ca[0]});for(v=0;v<A;v++){x=t[Q[v][1]].position;j=v*3;I[j]=x.x;I[j+1]=x.y;I[j+2]=x.z}for(t=0;t<B;t++){j=t*3;color=D[Q[t][1]];O[j]=color.r;O[j+1]=color.g;O[j+2]=color.b}}else{if(T)for(v=0;v<A;v++){x=t[v].position;j=v*3;I[j]=x.x;I[j+1]=x.y;I[j+2]=x.z}if(ba)for(t=
-0;t<B;t++){color=D[t];j=t*3;O[j]=color.r;O[j+1]=color.g;O[j+2]=color.b}}if(U){for(v=0;v<A;v++)P[v]=v;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,P,o)}if(T||q.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,I,o)}if(ba||q.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,O,o)}};this.initMaterial=function(k,o,q){if(!k.program){var j,v;if(k instanceof THREE.MeshDepthMaterial)c(k,
-THREE.ShaderLib.depth);else if(k instanceof THREE.MeshNormalMaterial)c(k,THREE.ShaderLib.normal);else if(k instanceof THREE.MeshBasicMaterial)c(k,THREE.ShaderLib.basic);else if(k instanceof THREE.MeshLambertMaterial)c(k,THREE.ShaderLib.lambert);else if(k instanceof THREE.MeshPhongMaterial)c(k,THREE.ShaderLib.phong);else if(k instanceof THREE.LineBasicMaterial)c(k,THREE.ShaderLib.basic);else k instanceof THREE.ParticleBasicMaterial&&c(k,THREE.ShaderLib.particle_basic);var t,x,A,D;v=A=D=0;for(t=o.length;v<
-t;v++){x=o[v];x instanceof THREE.DirectionalLight&&A++;x instanceof THREE.PointLight&&D++}if(D+A<=4){o=A;D=D}else{o=Math.ceil(4*A/(D+A));D=4-o}v={directional:o,point:D};D=k.fragment_shader;o=k.vertex_shader;t={fog:q,map:k.map,env_map:k.env_map,light_map:k.light_map,vertex_colors:k.vertex_colors,maxDirLights:v.directional,maxPointLights:v.point};q=b.createProgram();v=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+t.maxPointLights,
-t.fog?"#define USE_FOG":"",t.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.env_map?"#define USE_ENVMAP":"",t.light_map?"#define USE_LIGHTMAP":"",t.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");t=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+t.maxPointLights,t.map?"#define USE_MAP":"",t.env_map?"#define USE_ENVMAP":
-"",t.light_map?"#define USE_LIGHTMAP":"",t.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(q,d("fragment",v+D));b.attachShader(q,d("vertex",t+o));b.linkProgram(q);b.getProgramParameter(q,b.LINK_STATUS)||
-alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(q,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");q.uniforms={};q.attributes={};k.program=q;q=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(j in k.uniforms)q.push(j);j=k.program;D=0;for(o=q.length;D<o;D++){v=q[D];j.uniforms[v]=b.getUniformLocation(j,v)}k=k.program;j=["position","normal","uv","uv2","tangent","color"];q=0;for(D=j.length;q<D;q++){o=j[q];k.attributes[o]=
-b.getAttribLocation(k,o)}}};this.renderBuffer=function(k,o,q,j,v,t){var x;this.initMaterial(j,o,q);x=j.program;if(x!=l){b.useProgram(x);l=x}this.loadCamera(x,k);this.loadMatrices(x);if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){this.setupLights(x,o);o=this.lights;j.uniforms.enableLighting.value=o.directional.length+o.point.length;j.uniforms.ambientLightColor.value=o.ambient;j.uniforms.directionalLightColor.value=o.directional.colors;j.uniforms.directionalLightDirection.value=
-o.directional.positions;j.uniforms.pointLightColor.value=o.point.colors;j.uniforms.pointLightPosition.value=o.point.positions}if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial){j.uniforms.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);j.uniforms.opacity.value=j.opacity;j.uniforms.map.texture=j.map;j.uniforms.light_map.texture=j.light_map;j.uniforms.env_map.texture=j.env_map;j.uniforms.reflectivity.value=
-j.reflectivity;j.uniforms.refraction_ratio.value=j.refraction_ratio;j.uniforms.combine.value=j.combine;j.uniforms.useRefract.value=j.env_map&&j.env_map.mapping instanceof THREE.CubeRefractionMapping;if(q){j.uniforms.fogColor.value.setHex(q.color.hex);if(q instanceof THREE.Fog){j.uniforms.fogNear.value=q.near;j.uniforms.fogFar.value=q.far}else if(q instanceof THREE.FogExp2)j.uniforms.fogDensity.value=q.density}}if(j instanceof THREE.LineBasicMaterial){j.uniforms.diffuse.value.setRGB(j.color.r*j.opacity,
-j.color.g*j.opacity,j.color.b*j.opacity);j.uniforms.opacity.value=j.opacity;if(q){j.uniforms.fogColor.value.setHex(q.color.hex);if(q instanceof THREE.Fog){j.uniforms.fogNear.value=q.near;j.uniforms.fogFar.value=q.far}else if(q instanceof THREE.FogExp2)j.uniforms.fogDensity.value=q.density}}if(j instanceof THREE.ParticleBasicMaterial){j.uniforms.psColor.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);j.uniforms.opacity.value=j.opacity;j.uniforms.size.value=j.size;j.uniforms.map.texture=
-j.map;if(q){j.uniforms.fogColor.value.setHex(q.color.hex);if(q instanceof THREE.Fog){j.uniforms.fogNear.value=q.near;j.uniforms.fogFar.value=q.far}else if(q instanceof THREE.FogExp2)j.uniforms.fogDensity.value=q.density}}if(j instanceof THREE.MeshPhongMaterial){j.uniforms.ambient.value.setRGB(j.ambient.r,j.ambient.g,j.ambient.b);j.uniforms.specular.value.setRGB(j.specular.r,j.specular.g,j.specular.b);j.uniforms.shininess.value=j.shininess}if(j instanceof THREE.MeshDepthMaterial){j.uniforms.mNear.value=
-k.near;j.uniforms.mFar.value=k.far}k=j.uniforms;var A,D,B;for(A in k)if(B=x.uniforms[A]){o=k[A];D=o.type;q=o.value;if(D=="i")b.uniform1i(B,q);else if(D=="f")b.uniform1f(B,q);else if(D=="fv1")b.uniform1fv(B,q);else if(D=="fv")b.uniform3fv(B,q);else if(D=="v2")b.uniform2f(B,q.x,q.y);else if(D=="v3")b.uniform3f(B,q.x,q.y,q.z);else if(D=="c")b.uniform3f(B,q.r,q.g,q.b);else if(D=="t"){b.uniform1i(B,q);if(o=o.texture)if(o.image instanceof Array&&o.image.length==6){o=o;q=q;if(o.image.length==6){if(!o.image.__webGLTextureCube&&
-!o.image.__cubeMapInitialized&&o.image.loadCount==6){o.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,o.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(D=0;D<6;++D)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+
-D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,o.image[D]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);o.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+q);b.bindTexture(b.TEXTURE_CUBE_MAP,o.image.__webGLTextureCube)}}else{o=o;q=q;if(!o.__webGLTexture&&o.image.loaded){o.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,o.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,o.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,e(o.wrap_s));
-b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,e(o.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,e(o.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e(o.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+q);b.bindTexture(b.TEXTURE_2D,o.__webGLTexture)}}}x=x.attributes;b.bindBuffer(b.ARRAY_BUFFER,v.__webGLVertexBuffer);b.vertexAttribPointer(x.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(x.position);if(x.color>=
-0){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLColorBuffer);b.vertexAttribPointer(x.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(x.color)}if(x.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLNormalBuffer);b.vertexAttribPointer(x.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(x.normal)}if(x.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLTangentBuffer);b.vertexAttribPointer(x.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(x.tangent)}if(x.uv>=0)if(v.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,
-v.__webGLUVBuffer);b.vertexAttribPointer(x.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(x.uv)}else b.disableVertexAttribArray(x.uv);if(x.uv2>=0)if(v.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLUV2Buffer);b.vertexAttribPointer(x.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(x.uv2)}else b.disableVertexAttribArray(x.uv2);if(j.wireframe||j instanceof THREE.LineBasicMaterial){x=j.wireframe_linewidth!==undefined?j.wireframe_linewidth:j.linewidth!==undefined?j.linewidth:1;j=j instanceof
-THREE.LineBasicMaterial&&t.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(x);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,v.__webGLLineBuffer);b.drawElements(j,v.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(j instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,v.__webGLParticleBuffer);b.drawElements(b.POINTS,v.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,v.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,v.__webGLFaceCount,b.UNSIGNED_SHORT,
-0)}};this.renderPass=function(k,o,q,j,v,t,x){var A,D,B,I,P;B=0;for(I=j.materials.length;B<I;B++){A=j.materials[B];if(A instanceof THREE.MeshFaceMaterial){A=0;for(D=v.materials.length;A<D;A++)if((P=v.materials[A])&&P.blending==t&&P.opacity<1==x){this.setBlending(P.blending);this.renderBuffer(k,o,q,P,v,j)}}else if((P=A)&&P.blending==t&&P.opacity<1==x){this.setBlending(P.blending);this.renderBuffer(k,o,q,P,v,j)}}};this.render=function(k,o,q,j){var v,t,x,A=k.lights,D=k.fog;o.autoUpdateMatrix&&o.updateMatrix();
-y.set(o.matrix.flatten());w.set(o.projectionMatrix.flatten());this.initWebGLObjects(k,o);j=j!==undefined?j:true;if(q&&!q.__webGLFramebuffer){q.__webGLFramebuffer=b.createFramebuffer();q.__webGLRenderbuffer=b.createRenderbuffer();q.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,q.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,q.width,q.height);b.bindTexture(b.TEXTURE_2D,q.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,e(q.wrap_s));b.texParameteri(b.TEXTURE_2D,
-b.TEXTURE_WRAP_T,e(q.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,e(q.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e(q.min_filter));b.texImage2D(b.TEXTURE_2D,0,e(q.format),q.width,q.height,0,e(q.format),e(q.type),null);b.bindFramebuffer(b.FRAMEBUFFER,q.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,q.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,q.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,
-null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(q){v=q.__webGLFramebuffer;x=q.width;t=q.height}else{v=null;x=f.width;t=f.height}if(v!=h){b.bindFramebuffer(b.FRAMEBUFFER,v);b.viewport(0,0,x,t);j&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);h=v}this.autoClear&&this.clear();v=k.__webGLObjects.length;for(j=0;j<v;j++){t=k.__webGLObjects[j];x=t.object;if(x.visible){x.autoUpdateMatrix&&x.updateMatrix();if(x.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);
-x.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}}for(j=0;j<v;j++){t=k.__webGLObjects[j];x=t.object;t=t.buffer;if(x.visible){this.setupMatrices(x,o);this.renderPass(o,A,D,x,t,THREE.NormalBlending,false)}}for(j=0;j<v;j++){t=k.__webGLObjects[j];x=t.object;t=t.buffer;if(x.visible){this.setupMatrices(x,o);this.renderPass(o,A,D,x,t,THREE.AdditiveBlending,false);this.renderPass(o,A,D,x,t,THREE.SubtractiveBlending,false);this.renderPass(o,A,D,x,t,THREE.AdditiveBlending,true);this.renderPass(o,A,D,x,t,THREE.SubtractiveBlending,
-true);this.renderPass(o,A,D,x,t,THREE.NormalBlending,true);this.renderPass(o,A,D,x,t,THREE.BillboardBlending,false)}}if(q&&q.min_filter!==THREE.NearestFilter&&q.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,q.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(k,o){function q(I,P,O,Q){if(I[P]==undefined){k.__webGLObjects.push({buffer:O,object:Q});I[P]=1}}var j,v,t,x,A,D,B;if(!k.__webGLObjects){k.__webGLObjects=[];k.__webGLObjectsMap=
-{}}j=0;for(v=k.objects.length;j<v;j++){t=k.objects[j];A=t.geometry;if(k.__webGLObjectsMap[t.id]==undefined)k.__webGLObjectsMap[t.id]={};B=k.__webGLObjectsMap[t.id];if(t instanceof THREE.Mesh){for(x in A.geometryChunks){D=A.geometryChunks[x];if(!D.__webGLVertexBuffer){this.createMeshBuffers(D);this.initMeshBuffers(D,t);A.__dirtyVertices=true;A.__dirtyElements=true;A.__dirtyUvs=true;A.__dirtyNormals=true;A.__dirtyTangents=true}if(A.__dirtyVertices||A.__dirtyElements||A.__dirtyUvs)this.setMeshBuffers(D,
-t,b.DYNAMIC_DRAW);q(B,x,D,t)}A.__dirtyVertices=false;A.__dirtyElements=false;A.__dirtyUvs=false;A.__dirtyNormals=false;A.__dirtyTangents=false}else if(t instanceof THREE.Line){if(!A.__webGLVertexBuffer){this.createLineBuffers(A);this.initLineBuffers(A);A.__dirtyVertices=true;A.__dirtyElements=true}A.__dirtyVertices&&this.setLineBuffers(A,b.DYNAMIC_DRAW);q(B,0,A,t);A.__dirtyVertices=false;A.__dirtyElements=false}else if(t instanceof THREE.ParticleSystem){if(!A.__webGLVertexBuffer){this.createParticleBuffers(A);
-this.initParticleBuffers(A);A.__dirtyVertices=true;A.__dirtyColors=true;A.__dirtyElements=true}if(A.__dirtyVertices||A.__dirtyColors||t.sortParticles)this.setParticleBuffers(A,b.DYNAMIC_DRAW,t,o);q(B,0,A,t);A.__dirtyVertices=false;A.__dirtyColors=false;A.__dirtyElements=false}}};this.removeObject=function(k,o){var q,j;for(q=k.__webGLObjects.length-1;q>=0;q--){j=k.__webGLObjects[q].object;o==j&&k.__webGLObjects.splice(q,1)}};this.setupMatrices=function(k,o){g.multiply(o.matrix,k.matrix);C.set(g.flatten());
-m=THREE.Matrix4.makeInvert3x3(g).transpose();p.set(m.m);z.set(k.matrix.flatten())};this.loadMatrices=function(k){b.uniformMatrix4fv(k.uniforms.viewMatrix,false,y);b.uniformMatrix4fv(k.uniforms.modelViewMatrix,false,C);b.uniformMatrix4fv(k.uniforms.projectionMatrix,false,w);b.uniformMatrix3fv(k.uniforms.normalMatrix,false,p);b.uniformMatrix4fv(k.uniforms.objectMatrix,false,z)};this.loadCamera=function(k,o){b.uniform3f(k.uniforms.cameraPosition,o.position.x,o.position.y,o.position.z)};this.setBlending=
-function(k){switch(k){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(k,o){if(k){!o||o=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(k=="back")b.cullFace(b.BACK);else k=="front"?
-b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
-THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
-envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
-map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",
-lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\nlightmapColor = texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
+case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var f=document.createElement("canvas"),b,h=null,k=null,g=new THREE.Matrix4,m,q=new Float32Array(16),A=new Float32Array(16),
+v=new Float32Array(16),n=new Float32Array(9),z=new Float32Array(16),C=new THREE.Matrix4,G=new THREE.Vector4,w=true,H=new THREE.Color(0),o=0;if(a){if(a.antialias!==undefined)w=a.antialias;a.clearColor!==undefined&&H.setHex(a.clearColor);if(a.clearAlpha!==undefined)o=a.clearAlpha}this.domElement=f;this.autoClear=true;(function(l,u,t){try{b=f.getContext("experimental-webgl",{antialias:l})}catch(j){console.log(j)}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,
+0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(u.r,u.g,u.b,t)})(w,H,o);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,u){f.width=l;f.height=u;b.viewport(0,0,f.width,f.height)};this.setClearColor=function(l,u){var t=new THREE.Color(l);b.clearColor(t.r,
+t.g,t.b,u)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(l,u){var t,j,p,x=0,y=0,F=0,B,D,I,N=this.lights,O=N.directional.colors,Q=N.directional.positions,T=N.point.colors,U=N.point.positions,ba=0,ca=0;t=0;for(j=u.length;t<j;t++){p=u[t];B=p.color;D=p.position;I=p.intensity;if(p instanceof THREE.AmbientLight){x+=B.r;y+=B.g;F+=B.b}else if(p instanceof THREE.DirectionalLight){O[ba*3]=B.r*I;O[ba*3+1]=B.g*I;O[ba*3+2]=B.b*I;Q[ba*3]=D.x;Q[ba*3+1]=D.y;Q[ba*
+3+2]=D.z;ba+=1}else if(p instanceof THREE.PointLight){T[ca*3]=B.r*I;T[ca*3+1]=B.g*I;T[ca*3+2]=B.b*I;U[ca*3]=D.x;U[ca*3+1]=D.y;U[ca*3+2]=D.z;ca+=1}}N.point.length=ca;N.directional.length=ba;N.ambient[0]=x;N.ambient[1]=y;N.ambient[2]=F};this.createParticleBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLParticleBuffer=b.createBuffer();l.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLLineBuffer=b.createBuffer()};
+this.createMeshBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLNormalBuffer=b.createBuffer();l.__webGLTangentBuffer=b.createBuffer();l.__webGLUVBuffer=b.createBuffer();l.__webGLUV2Buffer=b.createBuffer();l.__webGLFaceBuffer=b.createBuffer();l.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(l){var u=l.vertices.length;l.__vertexArray=new Float32Array(u*3);l.__lineArray=new Uint16Array(u);l.__webGLLineCount=u};this.initParticleBuffers=function(l){var u=l.vertices.length;
+l.__vertexArray=new Float32Array(u*3);l.__colorArray=new Float32Array(u*3);l.__particleArray=new Uint16Array(u);l.__sortArray=[];l.__webGLParticleCount=u};this.initMeshBuffers=function(l,u){var t,j,p=0,x=0,y=0,F=u.geometry.faces,B=l.faces;t=0;for(j=B.length;t<j;t++){fi=B[t];face=F[fi];if(face instanceof THREE.Face3){p+=3;x+=1;y+=3}else if(face instanceof THREE.Face4){p+=4;x+=2;y+=4}}l.__vertexArray=new Float32Array(p*3);l.__normalArray=new Float32Array(p*3);l.__tangentArray=new Float32Array(p*4);
+l.__uvArray=new Float32Array(p*2);l.__uv2Array=new Float32Array(p*2);l.__faceArray=new Uint16Array(x*3);l.__lineArray=new Uint16Array(y*2);p=false;t=0;for(j=u.materials.length;t<j;t++){F=u.materials[t];if(F instanceof THREE.MeshFaceMaterial){F=0;for(B=l.materials.length;F<B;F++)if(l.materials[F]&&l.materials[F].shading!=undefined&&l.materials[F].shading==THREE.SmoothShading){p=true;break}}else if(F&&F.shading!=undefined&&F.shading==THREE.SmoothShading){p=true;break}if(p)break}l.__needsSmoothNormals=
+p;l.__webGLFaceCount=x*3;l.__webGLLineCount=y*2};this.setMeshBuffers=function(l,u,t){var j,p,x,y,F,B,D,I,N,O,Q=0,T=0,U=0,ba=0,ca=0,S=0,K=0,Z=0,V=l.__vertexArray,P=l.__uvArray,W=l.__uv2Array,$=l.__normalArray,da=l.__tangentArray,ha=l.__faceArray,E=l.__lineArray,L=l.__needsSmoothNormals,J=u.geometry,X=J.__dirtyVertices,ea=J.__dirtyElements,ja=J.__dirtyUvs,ia=J.__dirtyNormals,qa=J.__dirtyTangents,la=J.vertices,ua=l.faces,ma=J.faces,sa=J.uvs,Ha=J.uvs2;u=0;for(j=ua.length;u<j;u++){p=ua[u];x=ma[p];B=sa[p];
+p=Ha[p];y=x.vertexNormals;F=x.normal;if(x instanceof THREE.Face3){if(X){D=la[x.a].position;I=la[x.b].position;N=la[x.c].position;V[T]=D.x;V[T+1]=D.y;V[T+2]=D.z;V[T+3]=I.x;V[T+4]=I.y;V[T+5]=I.z;V[T+6]=N.x;V[T+7]=N.y;V[T+8]=N.z;T+=9}if(qa&&J.hasTangents){D=la[x.a].tangent;I=la[x.b].tangent;N=la[x.c].tangent;da[K]=D.x;da[K+1]=D.y;da[K+2]=D.z;da[K+3]=D.w;da[K+4]=I.x;da[K+5]=I.y;da[K+6]=I.z;da[K+7]=I.w;da[K+8]=N.x;da[K+9]=N.y;da[K+10]=N.z;da[K+11]=N.w;K+=12}if(ia)if(y.length==3&&L)for(x=0;x<3;x++){F=y[x];
+$[S]=F.x;$[S+1]=F.y;$[S+2]=F.z;S+=3}else for(x=0;x<3;x++){$[S]=F.x;$[S+1]=F.y;$[S+2]=F.z;S+=3}if(ja&&B)for(x=0;x<3;x++){y=B[x];P[U]=y.u;P[U+1]=y.v;U+=2}if(ja&&p)for(x=0;x<3;x++){B=p[x];W[ba]=B.u;W[ba+1]=B.v;ba+=2}if(ea){ha[ca]=Q;ha[ca+1]=Q+1;ha[ca+2]=Q+2;ca+=3;E[Z]=Q;E[Z+1]=Q+1;E[Z+2]=Q;E[Z+3]=Q+2;E[Z+4]=Q+1;E[Z+5]=Q+2;Z+=6;Q+=3}}else if(x instanceof THREE.Face4){if(X){D=la[x.a].position;I=la[x.b].position;N=la[x.c].position;O=la[x.d].position;V[T]=D.x;V[T+1]=D.y;V[T+2]=D.z;V[T+3]=I.x;V[T+4]=I.y;
+V[T+5]=I.z;V[T+6]=N.x;V[T+7]=N.y;V[T+8]=N.z;V[T+9]=O.x;V[T+10]=O.y;V[T+11]=O.z;T+=12}if(qa&&J.hasTangents){D=la[x.a].tangent;I=la[x.b].tangent;N=la[x.c].tangent;x=la[x.d].tangent;da[K]=D.x;da[K+1]=D.y;da[K+2]=D.z;da[K+3]=D.w;da[K+4]=I.x;da[K+5]=I.y;da[K+6]=I.z;da[K+7]=I.w;da[K+8]=N.x;da[K+9]=N.y;da[K+10]=N.z;da[K+11]=N.w;da[K+12]=x.x;da[K+13]=x.y;da[K+14]=x.z;da[K+15]=x.w;K+=16}if(ia)if(y.length==4&&L)for(x=0;x<4;x++){F=y[x];$[S]=F.x;$[S+1]=F.y;$[S+2]=F.z;S+=3}else for(x=0;x<4;x++){$[S]=F.x;$[S+1]=
+F.y;$[S+2]=F.z;S+=3}if(ja&&B)for(x=0;x<4;x++){y=B[x];P[U]=y.u;P[U+1]=y.v;U+=2}if(ja&&p)for(x=0;x<4;x++){B=p[x];W[ba]=B.u;W[ba+1]=B.v;ba+=2}if(ea){ha[ca]=Q;ha[ca+1]=Q+1;ha[ca+2]=Q+2;ha[ca+3]=Q;ha[ca+4]=Q+2;ha[ca+5]=Q+3;ca+=6;E[Z]=Q;E[Z+1]=Q+1;E[Z+2]=Q;E[Z+3]=Q+3;E[Z+4]=Q+1;E[Z+5]=Q+2;E[Z+6]=Q+2;E[Z+7]=Q+3;Z+=8;Q+=4}}}if(X){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,V,t)}if(ia){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,$,t)}if(qa&&
+J.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,da,t)}if(ja&&U>0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,P,t)}if(ja&&ba>0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,W,t)}if(ea){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ha,t);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,E,t)}};this.setLineBuffers=
+function(l,u){var t,j,p,x=l.vertices,y=x.length,F=l.__vertexArray,B=l.__lineArray,D=l.__dirtyElements;if(l.__dirtyVertices){for(t=0;t<y;t++){j=x[t].position;p=t*3;F[p]=j.x;F[p+1]=j.y;F[p+2]=j.z}b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,F,u)}if(D){for(t=0;t<y;t++)B[t]=t;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,B,u)}};this.setParticleBuffers=function(l,u,t,j){var p,x,y;x=l.vertices;var F=x.length,B=l.colors,D=B.length,
+I=l.__vertexArray,N=l.__particleArray,O=l.__colorArray,Q=l.__sortArray,T=l.__dirtyVertices,U=l.__dirtyElements,ba=l.__dirtyColors;if(t.sortParticles){C.multiply(j.projectionMatrix,j.matrix);C.multiplySelf(t.matrix);for(p=0;p<F;p++){y=x[p].position;G.copy(y);C.multiplyVector3(G);Q[p]=[G.z,p]}Q.sort(function(ca,S){return S[0]-ca[0]});for(p=0;p<F;p++){y=x[Q[p][1]].position;j=p*3;I[j]=y.x;I[j+1]=y.y;I[j+2]=y.z}for(x=0;x<D;x++){j=x*3;color=B[Q[x][1]];O[j]=color.r;O[j+1]=color.g;O[j+2]=color.b}}else{if(T)for(p=
+0;p<F;p++){y=x[p].position;j=p*3;I[j]=y.x;I[j+1]=y.y;I[j+2]=y.z}if(ba)for(x=0;x<D;x++){color=B[x];j=x*3;O[j]=color.r;O[j+1]=color.g;O[j+2]=color.b}}if(U){for(p=0;p<F;p++)N[p]=p;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,N,u)}if(T||t.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,I,u)}if(ba||t.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,O,u)}};this.initMaterial=
+function(l,u,t){if(!l.program){var j,p;if(l instanceof THREE.MeshDepthMaterial)c(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)c(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)c(l,THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)c(l,THREE.ShaderLib.phong);else if(l instanceof THREE.LineBasicMaterial)c(l,THREE.ShaderLib.basic);else l instanceof THREE.ParticleBasicMaterial&&
+c(l,THREE.ShaderLib.particle_basic);var x,y,F,B;p=F=B=0;for(x=u.length;p<x;p++){y=u[p];y instanceof THREE.DirectionalLight&&F++;y instanceof THREE.PointLight&&B++}if(B+F<=4){u=F;B=B}else{u=Math.ceil(4*F/(B+F));B=4-u}p={directional:u,point:B};B=l.fragment_shader;u=l.vertex_shader;x={fog:t,map:l.map,env_map:l.env_map,light_map:l.light_map,vertex_colors:l.vertex_colors,maxDirLights:p.directional,maxPointLights:p.point};t=b.createProgram();p=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+
+x.maxDirLights,"#define MAX_POINT_LIGHTS "+x.maxPointLights,x.fog?"#define USE_FOG":"",x.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",x.map?"#define USE_MAP":"",x.env_map?"#define USE_ENVMAP":"",x.light_map?"#define USE_LIGHTMAP":"",x.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");x=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+x.maxDirLights,"#define MAX_POINT_LIGHTS "+
+x.maxPointLights,x.map?"#define USE_MAP":"",x.env_map?"#define USE_ENVMAP":"",x.light_map?"#define USE_LIGHTMAP":"",x.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(t,d("fragment",p+B));b.attachShader(t,
+d("vertex",x+u));b.linkProgram(t);b.getProgramParameter(t,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(t,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");t.uniforms={};t.attributes={};l.program=t;t=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(j in l.uniforms)t.push(j);j=l.program;B=0;for(u=t.length;B<u;B++){p=t[B];j.uniforms[p]=b.getUniformLocation(j,p)}l=l.program;j=["position","normal",
+"uv","uv2","tangent","color"];t=0;for(B=j.length;t<B;t++){u=j[t];l.attributes[u]=b.getAttribLocation(l,u)}}};this.setProgram=function(l,u,t,j){this.initMaterial(j,u,t);var p=j.program;if(p!=h){b.useProgram(p);h=p}this.loadCamera(p,l);this.loadMatrices(p);if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){this.setupLights(p,u);u=this.lights;j.uniforms.enableLighting.value=u.directional.length+u.point.length;j.uniforms.ambientLightColor.value=u.ambient;j.uniforms.directionalLightColor.value=
+u.directional.colors;j.uniforms.directionalLightDirection.value=u.directional.positions;j.uniforms.pointLightColor.value=u.point.colors;j.uniforms.pointLightPosition.value=u.point.positions}if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial){j.uniforms.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);j.uniforms.opacity.value=j.opacity;j.uniforms.map.texture=j.map;j.uniforms.light_map.texture=j.light_map;
+j.uniforms.env_map.texture=j.env_map;j.uniforms.reflectivity.value=j.reflectivity;j.uniforms.refraction_ratio.value=j.refraction_ratio;j.uniforms.combine.value=j.combine;j.uniforms.useRefract.value=j.env_map&&j.env_map.mapping instanceof THREE.CubeRefractionMapping;if(t){j.uniforms.fogColor.value.setHex(t.color.hex);if(t instanceof THREE.Fog){j.uniforms.fogNear.value=t.near;j.uniforms.fogFar.value=t.far}else if(t instanceof THREE.FogExp2)j.uniforms.fogDensity.value=t.density}}if(j instanceof THREE.LineBasicMaterial){j.uniforms.diffuse.value.setRGB(j.color.r*
+j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);j.uniforms.opacity.value=j.opacity;if(t){j.uniforms.fogColor.value.setHex(t.color.hex);if(t instanceof THREE.Fog){j.uniforms.fogNear.value=t.near;j.uniforms.fogFar.value=t.far}else if(t instanceof THREE.FogExp2)j.uniforms.fogDensity.value=t.density}}if(j instanceof THREE.ParticleBasicMaterial){j.uniforms.psColor.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);j.uniforms.opacity.value=j.opacity;j.uniforms.size.value=j.size;
+j.uniforms.map.texture=j.map;if(t){j.uniforms.fogColor.value.setHex(t.color.hex);if(t instanceof THREE.Fog){j.uniforms.fogNear.value=t.near;j.uniforms.fogFar.value=t.far}else if(t instanceof THREE.FogExp2)j.uniforms.fogDensity.value=t.density}}if(j instanceof THREE.MeshPhongMaterial){j.uniforms.ambient.value.setRGB(j.ambient.r,j.ambient.g,j.ambient.b);j.uniforms.specular.value.setRGB(j.specular.r,j.specular.g,j.specular.b);j.uniforms.shininess.value=j.shininess}if(j instanceof THREE.MeshDepthMaterial){j.uniforms.mNear.value=
+l.near;j.uniforms.mFar.value=l.far}l=j.uniforms;var x,y;for(x in l)if(y=p.uniforms[x]){j=l[x];u=j.type;t=j.value;if(u=="i")b.uniform1i(y,t);else if(u=="f")b.uniform1f(y,t);else if(u=="fv1")b.uniform1fv(y,t);else if(u=="fv")b.uniform3fv(y,t);else if(u=="v2")b.uniform2f(y,t.x,t.y);else if(u=="v3")b.uniform3f(y,t.x,t.y,t.z);else if(u=="c")b.uniform3f(y,t.r,t.g,t.b);else if(u=="t"){b.uniform1i(y,t);if(j=j.texture)if(j.image instanceof Array&&j.image.length==6){j=j;t=t;if(j.image.length==6){if(!j.image.__webGLTextureCube&&
+!j.image.__cubeMapInitialized&&j.image.loadCount==6){j.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,j.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(u=0;u<6;++u)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+
+u,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,j.image[u]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);j.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+t);b.bindTexture(b.TEXTURE_CUBE_MAP,j.image.__webGLTextureCube)}}else{j=j;t=t;if(!j.__webGLTexture&&j.image.loaded){j.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,j.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,j.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,e(j.wrap_s));
+b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,e(j.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,e(j.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e(j.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+t);b.bindTexture(b.TEXTURE_2D,j.__webGLTexture)}}}return p};this.renderBuffer=function(l,u,t,j,p,x){l=this.setProgram(l,u,t,j,x).attributes;b.bindBuffer(b.ARRAY_BUFFER,p.__webGLVertexBuffer);b.vertexAttribPointer(l.position,
+3,b.FLOAT,false,0,0);b.enableVertexAttribArray(l.position);if(l.color>=0){b.bindBuffer(b.ARRAY_BUFFER,p.__webGLColorBuffer);b.vertexAttribPointer(l.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(l.color)}if(l.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,p.__webGLNormalBuffer);b.vertexAttribPointer(l.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(l.normal)}if(l.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,p.__webGLTangentBuffer);b.vertexAttribPointer(l.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(l.tangent)}if(l.uv>=
+0)if(p.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,p.__webGLUVBuffer);b.vertexAttribPointer(l.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(l.uv)}else b.disableVertexAttribArray(l.uv);if(l.uv2>=0)if(p.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,p.__webGLUV2Buffer);b.vertexAttribPointer(l.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(l.uv2)}else b.disableVertexAttribArray(l.uv2);if(j.wireframe||j instanceof THREE.LineBasicMaterial){l=j.wireframe_linewidth!==undefined?j.wireframe_linewidth:
+j.linewidth!==undefined?j.linewidth:1;j=j instanceof THREE.LineBasicMaterial&&x.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(l);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);b.drawElements(j,p.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(j instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,p.__webGLParticleBuffer);b.drawElements(b.POINTS,p.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,
+p.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(l,u,t,j,p,x,y){var F,B,D,I,N;D=0;for(I=j.materials.length;D<I;D++){F=j.materials[D];if(F instanceof THREE.MeshFaceMaterial){F=0;for(B=p.materials.length;F<B;F++)if((N=p.materials[F])&&N.blending==x&&N.opacity<1==y){this.setBlending(N.blending);this.renderBuffer(l,u,t,N,p,j)}}else if((N=F)&&N.blending==x&&N.opacity<1==y){this.setBlending(N.blending);this.renderBuffer(l,u,t,N,p,j)}}};this.renderPassImmediate=function(l,u,t,j,p,x){var y,
+F,B,D;y=0;for(F=j.materials.length;y<F;y++)if((B=j.materials[y])&&B.blending==p&&B.opacity<1==x){this.setBlending(B.blending);D=this.setProgram(l,u,t,B,j);j.render(function(I){var N=D;if(!I.__webGLVertexBuffer)I.__webGLVertexBuffer=b.createBuffer();if(!I.__webGLNormalBuffer)I.__webGLNormalBuffer=b.createBuffer();if(I.hasPos){b.bindBuffer(b.ARRAY_BUFFER,I.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,I.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(N.attributes.position);b.vertexAttribPointer(N.attributes.position,
+3,b.FLOAT,false,0,0)}if(I.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,I.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,I.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(N.attributes.normal);b.vertexAttribPointer(N.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,I.count);I.count=0})}};this.render=function(l,u,t,j){var p,x,y,F=l.lights,B=l.fog;u.autoUpdateMatrix&&u.updateMatrix();q.set(u.matrix.flatten());v.set(u.projectionMatrix.flatten());this.initWebGLObjects(l,u);j=j!==undefined?
+j:true;if(t&&!t.__webGLFramebuffer){t.__webGLFramebuffer=b.createFramebuffer();t.__webGLRenderbuffer=b.createRenderbuffer();t.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,t.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,t.width,t.height);b.bindTexture(b.TEXTURE_2D,t.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,e(t.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,e(t.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,
+e(t.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e(t.min_filter));b.texImage2D(b.TEXTURE_2D,0,e(t.format),t.width,t.height,0,e(t.format),e(t.type),null);b.bindFramebuffer(b.FRAMEBUFFER,t.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,t.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,t.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,
+null)}if(t){p=t.__webGLFramebuffer;y=t.width;x=t.height}else{p=null;y=f.width;x=f.height}if(p!=k){b.bindFramebuffer(b.FRAMEBUFFER,p);b.viewport(0,0,y,x);j&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);k=p}this.autoClear&&this.clear();p=l.__webGLObjects.length;for(j=0;j<p;j++){x=l.__webGLObjects[j];y=x.object;if(y.visible){y.autoUpdateMatrix&&y.updateMatrix();if(y.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);y.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}}for(j=0;j<p;j++){x=l.__webGLObjects[j];
+y=x.object;x=x.buffer;if(y.visible){y.autoUpdateMatrix&&y.updateMatrix();this.setupMatrices(y,u);this.renderPass(u,F,B,y,x,THREE.NormalBlending,false)}}for(j=0;j<l.__webGLObjectsImmediate.length;j++){x=l.__webGLObjectsImmediate[j];y=x.object;if(y.visible){this.setupMatrices(y,u);this.renderPassImmediate(u,F,B,y,THREE.NormalBlending,false)}}for(j=0;j<p;j++){x=l.__webGLObjects[j];y=x.object;x=x.buffer;if(y.visible){this.setupMatrices(y,u);this.renderPass(u,F,B,y,x,THREE.AdditiveBlending,false);this.renderPass(u,
+F,B,y,x,THREE.SubtractiveBlending,false);this.renderPass(u,F,B,y,x,THREE.AdditiveBlending,true);this.renderPass(u,F,B,y,x,THREE.SubtractiveBlending,true);this.renderPass(u,F,B,y,x,THREE.NormalBlending,true);this.renderPass(u,F,B,y,x,THREE.BillboardBlending,false)}}if(t&&t.min_filter!==THREE.NearestFilter&&t.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,t.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(l,u){function t(N,
+O,Q,T){if(N[O]==undefined){l.__webGLObjects.push({buffer:Q,object:T});N[O]=1}}function j(N,O,Q){if(N[O]==undefined){l.__webGLObjectsImmediate.push({object:Q});N[O]=1}}var p,x,y,F,B,D,I;if(!l.__webGLObjects){l.__webGLObjects=[];l.__webGLObjectsMap={};l.__webGLObjectsImmediate=[]}p=0;for(x=l.objects.length;p<x;p++){y=l.objects[p];B=y.geometry;if(l.__webGLObjectsMap[y.id]==undefined)l.__webGLObjectsMap[y.id]={};I=l.__webGLObjectsMap[y.id];if(y instanceof THREE.Mesh){for(F in B.geometryChunks){D=B.geometryChunks[F];
+if(!D.__webGLVertexBuffer){this.createMeshBuffers(D);this.initMeshBuffers(D,y);B.__dirtyVertices=true;B.__dirtyElements=true;B.__dirtyUvs=true;B.__dirtyNormals=true;B.__dirtyTangents=true}if(B.__dirtyVertices||B.__dirtyElements||B.__dirtyUvs)this.setMeshBuffers(D,y,b.DYNAMIC_DRAW);t(I,F,D,y)}B.__dirtyVertices=false;B.__dirtyElements=false;B.__dirtyUvs=false;B.__dirtyNormals=false;B.__dirtyTangents=false}else if(y instanceof THREE.Line){if(!B.__webGLVertexBuffer){this.createLineBuffers(B);this.initLineBuffers(B);
+B.__dirtyVertices=true;B.__dirtyElements=true}B.__dirtyVertices&&this.setLineBuffers(B,b.DYNAMIC_DRAW);t(I,0,B,y);B.__dirtyVertices=false;B.__dirtyElements=false}else if(y instanceof THREE.ParticleSystem){if(!B.__webGLVertexBuffer){this.createParticleBuffers(B);this.initParticleBuffers(B);B.__dirtyVertices=true;B.__dirtyColors=true;B.__dirtyElements=true}if(B.__dirtyVertices||B.__dirtyColors||y.sortParticles)this.setParticleBuffers(B,b.DYNAMIC_DRAW,y,u);t(I,0,B,y);B.__dirtyVertices=false;B.__dirtyColors=
+false;B.__dirtyElements=false}else y instanceof THREE.MarchingCubes&&j(I,0,y)}};this.removeObject=function(l,u){var t,j;for(t=l.__webGLObjects.length-1;t>=0;t--){j=l.__webGLObjects[t].object;u==j&&l.__webGLObjects.splice(t,1)}};this.setupMatrices=function(l,u){g.multiply(u.matrix,l.matrix);A.set(g.flatten());m=THREE.Matrix4.makeInvert3x3(g).transpose();n.set(m.m);z.set(l.matrix.flatten())};this.loadMatrices=function(l){b.uniformMatrix4fv(l.uniforms.viewMatrix,false,q);b.uniformMatrix4fv(l.uniforms.modelViewMatrix,
+false,A);b.uniformMatrix4fv(l.uniforms.projectionMatrix,false,v);b.uniformMatrix3fv(l.uniforms.normalMatrix,false,n);b.uniformMatrix4fv(l.uniforms.objectMatrix,false,z)};this.loadCamera=function(l,u){b.uniform3f(l.uniforms.cameraPosition,u.position.x,u.position.y,u.position.z)};this.setBlending=function(l){switch(l){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);
+b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(l,u){if(l){!u||u=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(l=="back")b.cullFace(b.BACK);else l=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
+THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
+envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",
+envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
+map_particle_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",
+lightmap_fragment:"#ifdef USE_LIGHTMAP\nlightmapColor = texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
 lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
 lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse  = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse  += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse  = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse  += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif",
 color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\nvertexColor = vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif"};
@@ -214,17 +217,17 @@ THREE.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].
 "gl_FragColor = mColor * mapColor * vertexColor;",THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["uniform float size;",THREE.Snippets.color_pars_vertex,"void main() {",THREE.Snippets.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\ngl_PointSize = size;\n}"].join("\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};
-var GeometryUtils={merge:function(a,c){var d=c instanceof THREE.Mesh,e=a.vertices.length,f=d?c.geometry:c,b=a.vertices,l=f.vertices,h=a.faces,g=f.faces,m=a.uvs;f=f.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var y=0,C=l.length;y<C;y++){var w=new THREE.Vertex(l[y].position.clone());d&&c.matrix.multiplyVector3(w.position);b.push(w)}y=0;for(C=g.length;y<C;y++){l=g[y];var p,z=l.vertexNormals;if(l instanceof THREE.Face3)p=new THREE.Face3(l.a+e,l.b+e,l.c+e);else if(l instanceof THREE.Face4)p=new THREE.Face4(l.a+
-e,l.b+e,l.c+e,l.d+e);p.centroid.copy(l.centroid);p.normal.copy(l.normal);d=0;for(b=z.length;d<b;d++){w=z[d];p.vertexNormals.push(w.clone())}p.materials=l.materials.slice();h.push(p)}y=0;for(C=f.length;y<C;y++){e=f[y];h=[];d=0;for(b=e.length;d<b;d++)h.push(new THREE.UV(e[d].u,e[d].v));m.push(h)}}},ImageUtils={loadTexture:function(a,c,d){var e=new Image;e.onload=function(){this.loaded=true;d&&d(this)};e.src=a;return new THREE.Texture(e,c)},loadArray:function(a,c){var d,e,f=[];d=f.loadCount=0;for(e=
-a.length;d<e;++d){f[d]=new Image;f[d].loaded=0;f[d].onload=function(){f.loadCount+=1;this.loaded=true;c&&c(this)};f[d].src=a[d]}return f}},SceneUtils={loadScene:function(a,c,d,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(f){function b(){for(y in j.objects)if(!B.objects[y]){F=j.objects[y];if(n=B.geometries[F.geometry]){q=[];for(i=0;i<F.materials.length;i++)q[i]=B.materials[F.materials[i]];G=F.position;r=F.rotation;s=F.scale;object=new THREE.Mesh(n,q);object.position.set(G[0],G[1],G[2]);
-object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=F.visible;B.scene.addObject(object);B.objects[y]=object}}}function l(I){return function(P){B.geometries[I]=P;b();t-=1;h()}}function h(){e({total_models:A,total_textures:D,loaded_models:A-t,loaded_textures:D-x},B);t==0&&x==0&&d(B)}var g,m,y,C,w,p,z,F,G,u,H,n,k,o,q,j,v,t,x,A,D,B;j=f.data;v=new THREE.Loader;x=t=0;B={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
-f=function(){x-=1;h()};for(w in j.cameras){u=j.cameras[w];if(u.type=="perspective")k=new THREE.Camera(u.fov,u.aspect,u.near,u.far);else if(u.type=="ortho"){k=new THREE.Camera;k.projectionMatrix=THREE.Matrix4.makeOrtho(u.left,u.right,u.top,u.bottom,u.near,u.far)}G=u.position;u=u.target;k.position.set(G[0],G[1],G[2]);k.target.position.set(u[0],u[1],u[2]);B.cameras[w]=k}for(C in j.lights){w=j.lights[C];if(w.type=="directional"){G=w.direction;light=new THREE.DirectionalLight;light.position.set(G[0],G[1],
-G[2]);light.position.normalize()}else if(w.type=="point"){G=w.position;light=new THREE.PointLight;light.position.set(G[0],G[1],G[2])}u=w.color;i=w.intensity||1;light.color.setRGB(u[0]*i,u[1]*i,u[2]*i);B.scene.addLight(light);B.lights[C]=light}for(p in j.fogs){C=j.fogs[p];if(C.type=="linear")o=new THREE.Fog(0,C.near,C.far);else if(C.type=="exp2")o=new THREE.FogExp2(0,C.density);u=C.color;o.color.setRGB(u[0],u[1],u[2]);B.fogs[p]=o}if(B.cameras&&j.defaults.camera)B.currentCamera=B.cameras[j.defaults.camera];
-if(B.fogs&&j.defaults.fog)B.scene.fog=B.fogs[j.defaults.fog];u=j.defaults.bgcolor;B.bgColor=new THREE.Color;B.bgColor.setRGB(u[0],u[1],u[2]);B.bgColorAlpha=j.defaults.bgalpha;for(g in j.geometries){p=j.geometries[g];if(p.type=="bin_mesh"||p.type=="ascii_mesh")t+=1}A=t;for(g in j.geometries){p=j.geometries[g];if(p.type=="cube"){n=new Cube(p.width,p.height,p.depth,p.segments_width,p.segments_height,null,p.flipped,p.sides);B.geometries[g]=n}else if(p.type=="plane"){n=new Plane(p.width,p.height,p.segments_width,
-p.segments_height);B.geometries[g]=n}else if(p.type=="sphere"){n=new Sphere(p.radius,p.segments_width,p.segments_height);B.geometries[g]=n}else if(p.type=="cylinder"){n=new Cylinder(p.numSegs,p.topRad,p.botRad,p.height,p.topOffset,p.botOffset);B.geometries[g]=n}else if(p.type=="torus"){n=new Torus(p.radius,p.tube,p.segmentsR,p.segmentsT);B.geometries[g]=n}else if(p.type=="icosahedron"){n=new Icosahedron(p.subdivisions);B.geometries[g]=n}else if(p.type=="bin_mesh")v.loadBinary({model:p.url,callback:l(g)});
-else p.type=="ascii_mesh"&&v.loadAscii({model:p.url,callback:l(g)})}for(z in j.textures){g=j.textures[z];x+=g.url instanceof Array?g.url.length:1}D=x;for(z in j.textures){g=j.textures[z];if(g.mapping!=undefined&&THREE[g.mapping]!=undefined)g.mapping=new THREE[g.mapping];if(g.url instanceof Array){p=ImageUtils.loadArray(g.url,f);p=new THREE.Texture(p,g.mapping)}else{p=ImageUtils.loadTexture(g.url,g.mapping,f);if(THREE[g.min_filter]!=undefined)p.min_filter=THREE[g.min_filter];if(THREE[g.mag_filter]!=
-undefined)p.mag_filter=THREE[g.mag_filter]}B.textures[z]=p}for(m in j.materials){z=j.materials[m];for(H in z.parameters)if(H=="env_map"||H=="map"||H=="light_map")z.parameters[H]=B.textures[z.parameters[H]];else if(H=="shading")z.parameters[H]=z.parameters[H]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(H=="blending")z.parameters[H]=THREE[z.parameters[H]]?THREE[z.parameters[H]]:THREE.NormalBlending;else if(H=="combine")z.parameters[H]=z.parameters[H]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
-z=new THREE[z.type](z.parameters);B.materials[m]=z}b();c(B)}},addMesh:function(a,c,d,e,f,b,l,h,g,m){c=new THREE.Mesh(c,m);c.scale.x=c.scale.y=c.scale.z=d;c.position.x=e;c.position.y=f;c.position.z=b;c.rotation.x=l;c.rotation.y=h;c.rotation.z=g;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,d){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=d;d=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,uniforms:e.uniforms});c=new THREE.Mesh(new Cube(c,
+var GeometryUtils={merge:function(a,c){var d=c instanceof THREE.Mesh,e=a.vertices.length,f=d?c.geometry:c,b=a.vertices,h=f.vertices,k=a.faces,g=f.faces,m=a.uvs;f=f.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var q=0,A=h.length;q<A;q++){var v=new THREE.Vertex(h[q].position.clone());d&&c.matrix.multiplyVector3(v.position);b.push(v)}q=0;for(A=g.length;q<A;q++){h=g[q];var n,z=h.vertexNormals;if(h instanceof THREE.Face3)n=new THREE.Face3(h.a+e,h.b+e,h.c+e);else if(h instanceof THREE.Face4)n=new THREE.Face4(h.a+
+e,h.b+e,h.c+e,h.d+e);n.centroid.copy(h.centroid);n.normal.copy(h.normal);d=0;for(b=z.length;d<b;d++){v=z[d];n.vertexNormals.push(v.clone())}n.materials=h.materials.slice();k.push(n)}q=0;for(A=f.length;q<A;q++){e=f[q];k=[];d=0;for(b=e.length;d<b;d++)k.push(new THREE.UV(e[d].u,e[d].v));m.push(k)}}},ImageUtils={loadTexture:function(a,c,d){var e=new Image;e.onload=function(){this.loaded=true;d&&d(this)};e.src=a;return new THREE.Texture(e,c)},loadArray:function(a,c){var d,e,f=[];d=f.loadCount=0;for(e=
+a.length;d<e;++d){f[d]=new Image;f[d].loaded=0;f[d].onload=function(){f.loadCount+=1;this.loaded=true;c&&c(this)};f[d].src=a[d]}return f}},SceneUtils={loadScene:function(a,c,d,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(f){function b(){for(q in j.objects)if(!D.objects[q]){C=j.objects[q];if(o=D.geometries[C.geometry]){t=[];for(i=0;i<C.materials.length;i++)t[i]=D.materials[C.materials[i]];G=C.position;r=C.rotation;s=C.scale;object=new THREE.Mesh(o,t);object.position.set(G[0],G[1],G[2]);
+object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=C.visible;D.scene.addObject(object);D.objects[q]=object}}}function h(I){return function(N){D.geometries[I]=N;b();x-=1;k()}}function k(){e({total_models:F,total_textures:B,loaded_models:F-x,loaded_textures:B-y},D);x==0&&y==0&&d(D)}var g,m,q,A,v,n,z,C,G,w,H,o,l,u,t,j,p,x,y,F,B,D;j=f.data;p=new THREE.Loader;y=x=0;D={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
+f=function(){y-=1;k()};for(v in j.cameras){w=j.cameras[v];if(w.type=="perspective")l=new THREE.Camera(w.fov,w.aspect,w.near,w.far);else if(w.type=="ortho"){l=new THREE.Camera;l.projectionMatrix=THREE.Matrix4.makeOrtho(w.left,w.right,w.top,w.bottom,w.near,w.far)}G=w.position;w=w.target;l.position.set(G[0],G[1],G[2]);l.target.position.set(w[0],w[1],w[2]);D.cameras[v]=l}for(A in j.lights){v=j.lights[A];if(v.type=="directional"){G=v.direction;light=new THREE.DirectionalLight;light.position.set(G[0],G[1],
+G[2]);light.position.normalize()}else if(v.type=="point"){G=v.position;light=new THREE.PointLight;light.position.set(G[0],G[1],G[2])}w=v.color;i=v.intensity||1;light.color.setRGB(w[0]*i,w[1]*i,w[2]*i);D.scene.addLight(light);D.lights[A]=light}for(n in j.fogs){A=j.fogs[n];if(A.type=="linear")u=new THREE.Fog(0,A.near,A.far);else if(A.type=="exp2")u=new THREE.FogExp2(0,A.density);w=A.color;u.color.setRGB(w[0],w[1],w[2]);D.fogs[n]=u}if(D.cameras&&j.defaults.camera)D.currentCamera=D.cameras[j.defaults.camera];
+if(D.fogs&&j.defaults.fog)D.scene.fog=D.fogs[j.defaults.fog];w=j.defaults.bgcolor;D.bgColor=new THREE.Color;D.bgColor.setRGB(w[0],w[1],w[2]);D.bgColorAlpha=j.defaults.bgalpha;for(g in j.geometries){n=j.geometries[g];if(n.type=="bin_mesh"||n.type=="ascii_mesh")x+=1}F=x;for(g in j.geometries){n=j.geometries[g];if(n.type=="cube"){o=new Cube(n.width,n.height,n.depth,n.segments_width,n.segments_height,null,n.flipped,n.sides);D.geometries[g]=o}else if(n.type=="plane"){o=new Plane(n.width,n.height,n.segments_width,
+n.segments_height);D.geometries[g]=o}else if(n.type=="sphere"){o=new Sphere(n.radius,n.segments_width,n.segments_height);D.geometries[g]=o}else if(n.type=="cylinder"){o=new Cylinder(n.numSegs,n.topRad,n.botRad,n.height,n.topOffset,n.botOffset);D.geometries[g]=o}else if(n.type=="torus"){o=new Torus(n.radius,n.tube,n.segmentsR,n.segmentsT);D.geometries[g]=o}else if(n.type=="icosahedron"){o=new Icosahedron(n.subdivisions);D.geometries[g]=o}else if(n.type=="bin_mesh")p.loadBinary({model:n.url,callback:h(g)});
+else n.type=="ascii_mesh"&&p.loadAscii({model:n.url,callback:h(g)})}for(z in j.textures){g=j.textures[z];y+=g.url instanceof Array?g.url.length:1}B=y;for(z in j.textures){g=j.textures[z];if(g.mapping!=undefined&&THREE[g.mapping]!=undefined)g.mapping=new THREE[g.mapping];if(g.url instanceof Array){n=ImageUtils.loadArray(g.url,f);n=new THREE.Texture(n,g.mapping)}else{n=ImageUtils.loadTexture(g.url,g.mapping,f);if(THREE[g.min_filter]!=undefined)n.min_filter=THREE[g.min_filter];if(THREE[g.mag_filter]!=
+undefined)n.mag_filter=THREE[g.mag_filter]}D.textures[z]=n}for(m in j.materials){z=j.materials[m];for(H in z.parameters)if(H=="env_map"||H=="map"||H=="light_map")z.parameters[H]=D.textures[z.parameters[H]];else if(H=="shading")z.parameters[H]=z.parameters[H]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(H=="blending")z.parameters[H]=THREE[z.parameters[H]]?THREE[z.parameters[H]]:THREE.NormalBlending;else if(H=="combine")z.parameters[H]=z.parameters[H]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
+z=new THREE[z.type](z.parameters);D.materials[m]=z}b();c(D)}},addMesh:function(a,c,d,e,f,b,h,k,g,m){c=new THREE.Mesh(c,m);c.scale.x=c.scale.y=c.scale.z=d;c.position.x=e;c.position.y=f;c.position.z=b;c.rotation.x=h;c.rotation.y=k;c.rotation.z=g;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,d){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=d;d=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,uniforms:e.uniforms});c=new THREE.Mesh(new Cube(c,
 c,c,1,1,null,true),d);a.addObject(c);return c},addPanoramaCube:function(a,c,d){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));c=new THREE.Mesh(new Cube(c,
 c,c,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(c);return c},addPanoramaCubePlanes:function(a,c,d){var e=c/2;c=new Plane(c,c);var f=Math.PI/2,b=Math.PI;SceneUtils.addMesh(a,c,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));SceneUtils.addMesh(a,c,1,-e,0,0,0,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,c,1,e,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,c,1,0,e,0,f,0,b,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));
 SceneUtils.addMesh(a,c,1,0,-e,0,-f,0,b,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
@@ -234,48 +237,84 @@ uDirLightColor:{type:"c",value:new THREE.Color(15658734)},uAmbientLightColor:{ty
 vertex_shader:"attribute vec4 tangent;\nuniform vec3 uPointLightPos;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"},
 cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"},convolution:{uniforms:{tDiffuse:{type:"t",
 value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertex_shader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
-film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nconst float fNintensity = 0.35;\nconst float fSintensity = 0.35;\nconst float fScount = 4096.0;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time *  1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin(vUv.y * fScount), cos(vUv.y * fScount) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * fSintensity;\ncResult = cTextureScreen.rgb + clamp( fNintensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\ngl_FragColor =  vec4( cResult, cTextureScreen.a );\n}"},
+film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},grayscale:{type:"i",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nconst float fNintensity = 0.35;\nconst float fSintensity = 0.35;\nconst float fScount = 4096.0;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time *  1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin(vUv.y * fScount), cos(vUv.y * fScount) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * fSintensity;\ncResult = cTextureScreen.rgb + clamp( fNintensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor =  vec4( cResult, cTextureScreen.a );\n}"},
 screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
-fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,d,e,f,b=2*Math.ceil(a*3)+1;if(b>25)b=25;f=(b-1)*0.5;d=Array(b);for(c=e=0;c<b;++c){d[c]=Math.exp(-((c-f)*(c-f))/(2*a*a));e+=d[c]}for(c=0;c<b;++c)d[c]/=e;return d}},Cube=function(a,c,d,e,f,b,l,h){function g(F,G,u,H,n,k,o,q){var j,v,t=e||1,x=f||1,A=t+1,D=x+1,B=n/2,I=k/2;n=n/t;var P=k/x,O=m.vertices.length;if(F=="x"&&G=="y"||F=="y"&&G=="x")j="z";else if(F=="x"&&G=="z"||F=="z"&&G=="x")j="y";else if(F==
-"z"&&G=="y"||F=="y"&&G=="z")j="x";for(v=0;v<D;v++)for(k=0;k<A;k++){var Q=new THREE.Vector3;Q[F]=(k*n-B)*u;Q[G]=(v*P-I)*H;Q[j]=o;m.vertices.push(new THREE.Vertex(Q))}for(v=0;v<x;v++)for(k=0;k<t;k++){m.faces.push(new THREE.Face4(k+A*v+O,k+A*(v+1)+O,k+1+A*(v+1)+O,k+1+A*v+O,null,q));m.uvs.push([new THREE.UV(k/t,v/x),new THREE.UV(k/t,(v+1)/x),new THREE.UV((k+1)/t,(v+1)/x),new THREE.UV((k+1)/t,v/x)])}}THREE.Geometry.call(this);var m=this,y=a/2,C=c/2,w=d/2;l=l?-1:1;if(b!==undefined)if(b instanceof Array)this.materials=
-b;else{this.materials=[];for(var p=0;p<6;p++)this.materials.push([b])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(h!=undefined)for(var z in h)if(this.sides[z]!=undefined)this.sides[z]=h[z];this.sides.px&&g("z","y",1*l,-1,d,c,-y,this.materials[0]);this.sides.nx&&g("z","y",-1*l,-1,d,c,y,this.materials[1]);this.sides.py&&g("x","z",1*l,1,a,d,C,this.materials[2]);this.sides.ny&&g("x","z",1*l,-1,a,d,-C,this.materials[3]);this.sides.pz&&g("x","y",1*l,-1,a,c,w,this.materials[4]);
-this.sides.nz&&g("x","y",-1*l,-1,a,c,-w,this.materials[5]);(function(){for(var F=[],G=[],u=0,H=m.vertices.length;u<H;u++){for(var n=m.vertices[u],k=false,o=0,q=F.length;o<q;o++){var j=F[o];if(n.position.x==j.position.x&&n.position.y==j.position.y&&n.position.z==j.position.z){G[u]=o;k=true;break}}if(!k){G[u]=F.length;F.push(new THREE.Vertex(n.position.clone()))}}u=0;for(H=m.faces.length;u<H;u++){n=m.faces[u];n.a=G[n.a];n.b=G[n.b];n.c=G[n.c];n.d=G[n.d]}m.vertices=F})();this.computeCentroids();this.computeFaceNormals();
+fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,d,e,f,b=2*Math.ceil(a*3)+1;if(b>25)b=25;f=(b-1)*0.5;d=Array(b);for(c=e=0;c<b;++c){d[c]=Math.exp(-((c-f)*(c-f))/(2*a*a));e+=d[c]}for(c=0;c<b;++c)d[c]/=e;return d}},Cube=function(a,c,d,e,f,b,h,k){function g(C,G,w,H,o,l,u,t){var j,p,x=e||1,y=f||1,F=x+1,B=y+1,D=o/2,I=l/2;o=o/x;var N=l/y,O=m.vertices.length;if(C=="x"&&G=="y"||C=="y"&&G=="x")j="z";else if(C=="x"&&G=="z"||C=="z"&&G=="x")j="y";else if(C==
+"z"&&G=="y"||C=="y"&&G=="z")j="x";for(p=0;p<B;p++)for(l=0;l<F;l++){var Q=new THREE.Vector3;Q[C]=(l*o-D)*w;Q[G]=(p*N-I)*H;Q[j]=u;m.vertices.push(new THREE.Vertex(Q))}for(p=0;p<y;p++)for(l=0;l<x;l++){m.faces.push(new THREE.Face4(l+F*p+O,l+F*(p+1)+O,l+1+F*(p+1)+O,l+1+F*p+O,null,t));m.uvs.push([new THREE.UV(l/x,p/y),new THREE.UV(l/x,(p+1)/y),new THREE.UV((l+1)/x,(p+1)/y),new THREE.UV((l+1)/x,p/y)])}}THREE.Geometry.call(this);var m=this,q=a/2,A=c/2,v=d/2;h=h?-1:1;if(b!==undefined)if(b instanceof Array)this.materials=
+b;else{this.materials=[];for(var n=0;n<6;n++)this.materials.push([b])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(k!=undefined)for(var z in k)if(this.sides[z]!=undefined)this.sides[z]=k[z];this.sides.px&&g("z","y",1*h,-1,d,c,-q,this.materials[0]);this.sides.nx&&g("z","y",-1*h,-1,d,c,q,this.materials[1]);this.sides.py&&g("x","z",1*h,1,a,d,A,this.materials[2]);this.sides.ny&&g("x","z",1*h,-1,a,d,-A,this.materials[3]);this.sides.pz&&g("x","y",1*h,-1,a,c,v,this.materials[4]);
+this.sides.nz&&g("x","y",-1*h,-1,a,c,-v,this.materials[5]);(function(){for(var C=[],G=[],w=0,H=m.vertices.length;w<H;w++){for(var o=m.vertices[w],l=false,u=0,t=C.length;u<t;u++){var j=C[u];if(o.position.x==j.position.x&&o.position.y==j.position.y&&o.position.z==j.position.z){G[w]=u;l=true;break}}if(!l){G[w]=C.length;C.push(new THREE.Vertex(o.position.clone()))}}w=0;for(H=m.faces.length;w<H;w++){o=m.faces[w];o.a=G[o.a];o.b=G[o.b];o.c=G[o.c];o.d=G[o.d]}m.vertices=C})();this.computeCentroids();this.computeFaceNormals();
 this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
-var Cylinder=function(a,c,d,e,f){function b(m,y,C){l.vertices.push(new THREE.Vertex(new THREE.Vector3(m,y,C)))}THREE.Geometry.call(this);var l=this,h=Math.PI,g;for(g=0;g<a;g++)b(Math.sin(2*h*g/a)*c,Math.cos(2*h*g/a)*c,0);for(g=0;g<a;g++)b(Math.sin(2*h*g/a)*d,Math.cos(2*h*g/a)*d,e);for(g=0;g<a;g++)l.faces.push(new THREE.Face4(g,g+a,a+(g+1)%a,(g+1)%a));if(d!=0){b(0,0,-f);for(g=a;g<a+a/2;g++)l.faces.push(new THREE.Face4(2*a,(2*g-2*a)%a,(2*g-2*a+1)%a,(2*g-2*a+2)%a))}if(c!=0){b(0,0,e+f);for(g=a+a/2;g<
-2*a;g++)l.faces.push(new THREE.Face4((2*g-2*a+2)%a+a,(2*g-2*a+1)%a+a,(2*g-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
-var Plane=function(a,c,d,e){THREE.Geometry.call(this);var f,b=a/2,l=c/2;d=d||1;e=e||1;var h=d+1,g=e+1;a=a/d;var m=c/e;for(f=0;f<g;f++)for(c=0;c<h;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-b,-(f*m-l),0)));for(f=0;f<e;f++)for(c=0;c<d;c++){this.faces.push(new THREE.Face4(c+h*f,c+h*(f+1),c+1+h*(f+1),c+1+h*f));this.uvs.push([new THREE.UV(c/d,f/e),new THREE.UV(c/d,(f+1)/e),new THREE.UV((c+1)/d,(f+1)/e),new THREE.UV((c+1)/d,f/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
+var Cylinder=function(a,c,d,e,f){function b(m,q,A){h.vertices.push(new THREE.Vertex(new THREE.Vector3(m,q,A)))}THREE.Geometry.call(this);var h=this,k=Math.PI,g;for(g=0;g<a;g++)b(Math.sin(2*k*g/a)*c,Math.cos(2*k*g/a)*c,0);for(g=0;g<a;g++)b(Math.sin(2*k*g/a)*d,Math.cos(2*k*g/a)*d,e);for(g=0;g<a;g++)h.faces.push(new THREE.Face4(g,g+a,a+(g+1)%a,(g+1)%a));if(d!=0){b(0,0,-f);for(g=a;g<a+a/2;g++)h.faces.push(new THREE.Face4(2*a,(2*g-2*a)%a,(2*g-2*a+1)%a,(2*g-2*a+2)%a))}if(c!=0){b(0,0,e+f);for(g=a+a/2;g<
+2*a;g++)h.faces.push(new THREE.Face4((2*g-2*a+2)%a+a,(2*g-2*a+1)%a+a,(2*g-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
+var Plane=function(a,c,d,e){THREE.Geometry.call(this);var f,b=a/2,h=c/2;d=d||1;e=e||1;var k=d+1,g=e+1;a=a/d;var m=c/e;for(f=0;f<g;f++)for(c=0;c<k;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-b,-(f*m-h),0)));for(f=0;f<e;f++)for(c=0;c<d;c++){this.faces.push(new THREE.Face4(c+k*f,c+k*(f+1),c+1+k*(f+1),c+1+k*f));this.uvs.push([new THREE.UV(c/d,f/e),new THREE.UV(c/d,(f+1)/e),new THREE.UV((c+1)/d,(f+1)/e),new THREE.UV((c+1)/d,f/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
-var Sphere=function(a,c,d){THREE.Geometry.call(this);var e,f=Math.PI,b=Math.max(3,c||8),l=Math.max(2,d||6);c=[];for(d=0;d<l+1;d++){e=d/l;var h=a*Math.cos(e*f),g=a*Math.sin(e*f),m=[],y=0;for(e=0;e<b;e++){var C=2*e/b,w=g*Math.sin(C*f);C=g*Math.cos(C*f);(d==0||d==l)&&e>0||(y=this.vertices.push(new THREE.Vertex(new THREE.Vector3(C,h,w)))-1);m.push(y)}c.push(m)}var p,z,F;f=c.length;for(d=0;d<f;d++){b=c[d].length;if(d>0)for(e=0;e<b;e++){m=e==b-1;l=c[d][m?0:e+1];h=c[d][m?b-1:e];g=c[d-1][m?b-1:e];m=c[d-1][m?
-0:e+1];w=d/(f-1);p=(d-1)/(f-1);z=(e+1)/b;C=e/b;y=new THREE.UV(1-z,w);w=new THREE.UV(1-C,w);C=new THREE.UV(1-C,p);var G=new THREE.UV(1-z,p);if(d<c.length-1){p=this.vertices[l].position.clone();z=this.vertices[h].position.clone();F=this.vertices[g].position.clone();p.normalize();z.normalize();F.normalize();this.faces.push(new THREE.Face3(l,h,g,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(F.x,F.y,F.z)]));this.uvs.push([y,w,C])}if(d>1){p=this.vertices[l].position.clone();
-z=this.vertices[g].position.clone();F=this.vertices[m].position.clone();p.normalize();z.normalize();F.normalize();this.faces.push(new THREE.Face3(l,g,m,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(F.x,F.y,F.z)]));this.uvs.push([y,C,G])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
+var Sphere=function(a,c,d){THREE.Geometry.call(this);var e,f=Math.PI,b=Math.max(3,c||8),h=Math.max(2,d||6);c=[];for(d=0;d<h+1;d++){e=d/h;var k=a*Math.cos(e*f),g=a*Math.sin(e*f),m=[],q=0;for(e=0;e<b;e++){var A=2*e/b,v=g*Math.sin(A*f);A=g*Math.cos(A*f);(d==0||d==h)&&e>0||(q=this.vertices.push(new THREE.Vertex(new THREE.Vector3(A,k,v)))-1);m.push(q)}c.push(m)}var n,z,C;f=c.length;for(d=0;d<f;d++){b=c[d].length;if(d>0)for(e=0;e<b;e++){m=e==b-1;h=c[d][m?0:e+1];k=c[d][m?b-1:e];g=c[d-1][m?b-1:e];m=c[d-1][m?
+0:e+1];v=d/(f-1);n=(d-1)/(f-1);z=(e+1)/b;A=e/b;q=new THREE.UV(1-z,v);v=new THREE.UV(1-A,v);A=new THREE.UV(1-A,n);var G=new THREE.UV(1-z,n);if(d<c.length-1){n=this.vertices[h].position.clone();z=this.vertices[k].position.clone();C=this.vertices[g].position.clone();n.normalize();z.normalize();C.normalize();this.faces.push(new THREE.Face3(h,k,g,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([q,v,A])}if(d>1){n=this.vertices[h].position.clone();
+z=this.vertices[g].position.clone();C=this.vertices[m].position.clone();n.normalize();z.normalize();C.normalize();this.faces.push(new THREE.Face3(h,g,m,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([q,A,G])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
 var Torus=function(a,c,d,e){this.radius=a||100;this.tube=c||40;this.segmentsR=d||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(d=0;d<=this.segmentsT;++d){e=d/this.segmentsT*2*Math.PI;var f=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(e),(this.radius+this.tube*Math.cos(f))*Math.sin(e),this.tube*Math.sin(f))));a.push([d/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(d=
-1;d<=this.segmentsT;++d){e=(this.segmentsT+1)*c+d;f=(this.segmentsT+1)*c+d-1;var b=(this.segmentsT+1)*(c-1)+d-1,l=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,f,b,l));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[b][0],a[b][1]),new THREE.UV(a[l][0],a[l][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
-var Icosahedron=function(a){function c(C,w,p){var z=Math.sqrt(C*C+w*w+p*p);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(C/z,w/z,p/z)))-1}function d(C,w,p,z){z.faces.push(new THREE.Face3(C,w,p))}function e(C,w){var p=f.vertices[C].position,z=f.vertices[w].position;return c((p.x+z.x)/2,(p.y+z.y)/2,(p.z+z.z)/2)}var f=this,b=new THREE.Geometry,l;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
-1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);d(0,11,5,b);d(0,5,1,b);d(0,1,7,b);d(0,7,10,b);d(0,10,11,b);d(1,5,9,b);d(5,11,4,b);d(11,10,2,b);d(10,7,6,b);d(7,1,8,b);d(3,9,4,b);d(3,4,2,b);d(3,2,6,b);d(3,6,8,b);d(3,8,9,b);d(4,9,5,b);d(2,4,11,b);d(6,2,10,b);d(8,6,7,b);d(9,8,1,b);for(a=0;a<this.subdivisions;a++){l=new THREE.Geometry;for(var h in b.faces){var g=e(b.faces[h].a,b.faces[h].b),m=e(b.faces[h].b,b.faces[h].c),y=e(b.faces[h].c,b.faces[h].a);d(b.faces[h].a,g,y,l);d(b.faces[h].b,m,g,l);d(b.faces[h].c,
-y,m,l);d(g,m,y,l)}b.faces=l.faces}f.faces=b.faces;delete b;delete l;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
-function LathedObject(a,c,d){THREE.Geometry.call(this);c=c||12;d=d||2*Math.PI;c=d/c;for(var e=[],f=[],b=[],l=[],h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));f[h]=this.vertices.length-1;e[h]=new THREE.Vector3(a[h].x,a[h].y,a[h].z)}for(var g=THREE.Matrix4.rotationZMatrix(c),m=0;m<=d+0.0010;m+=c){for(h=0;h<e.length;h++)if(m<d){e[h]=g.multiplyVector3(e[h].clone());this.vertices.push(new THREE.Vertex(e[h]));b[h]=this.vertices.length-1}else b=l;if(m==0)l=f;for(h=0;h<f.length-1;h++){this.faces.push(new THREE.Face4(b[h],
-b[h+1],f[h+1],f[h]));this.uvs.push([new THREE.UV(m/d,h/a.length),new THREE.UV(m/d,(h+1)/a.length),new THREE.UV((m-c)/d,(h+1)/a.length),new THREE.UV((m-c)/d,h/a.length)])}f=b;b=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
+1;d<=this.segmentsT;++d){e=(this.segmentsT+1)*c+d;f=(this.segmentsT+1)*c+d-1;var b=(this.segmentsT+1)*(c-1)+d-1,h=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,f,b,h));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[b][0],a[b][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
+var Icosahedron=function(a){function c(A,v,n){var z=Math.sqrt(A*A+v*v+n*n);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(A/z,v/z,n/z)))-1}function d(A,v,n,z){z.faces.push(new THREE.Face3(A,v,n))}function e(A,v){var n=f.vertices[A].position,z=f.vertices[v].position;return c((n.x+z.x)/2,(n.y+z.y)/2,(n.z+z.z)/2)}var f=this,b=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
+1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);d(0,11,5,b);d(0,5,1,b);d(0,1,7,b);d(0,7,10,b);d(0,10,11,b);d(1,5,9,b);d(5,11,4,b);d(11,10,2,b);d(10,7,6,b);d(7,1,8,b);d(3,9,4,b);d(3,4,2,b);d(3,2,6,b);d(3,6,8,b);d(3,8,9,b);d(4,9,5,b);d(2,4,11,b);d(6,2,10,b);d(8,6,7,b);d(9,8,1,b);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var k in b.faces){var g=e(b.faces[k].a,b.faces[k].b),m=e(b.faces[k].b,b.faces[k].c),q=e(b.faces[k].c,b.faces[k].a);d(b.faces[k].a,g,q,h);d(b.faces[k].b,m,g,h);d(b.faces[k].c,
+q,m,h);d(g,m,q,h)}b.faces=h.faces}f.faces=b.faces;delete b;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
+function LathedObject(a,c,d){THREE.Geometry.call(this);c=c||12;d=d||2*Math.PI;c=d/c;for(var e=[],f=[],b=[],h=[],k=0;k<a.length;k++){this.vertices.push(new THREE.Vertex(a[k]));f[k]=this.vertices.length-1;e[k]=new THREE.Vector3(a[k].x,a[k].y,a[k].z)}for(var g=THREE.Matrix4.rotationZMatrix(c),m=0;m<=d+0.0010;m+=c){for(k=0;k<e.length;k++)if(m<d){e[k]=g.multiplyVector3(e[k].clone());this.vertices.push(new THREE.Vertex(e[k]));b[k]=this.vertices.length-1}else b=h;if(m==0)h=f;for(k=0;k<f.length-1;k++){this.faces.push(new THREE.Face4(b[k],
+b[k+1],f[k+1],f[k]));this.uvs.push([new THREE.UV(m/d,k/a.length),new THREE.UV(m/d,(k+1)/a.length),new THREE.UV((m-c)/d,(k+1)/a.length),new THREE.UV((m-c)/d,k/a.length)])}f=b;b=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
+THREE.MarchingCubes=function(a,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(d){this.isolation=80;this.size=d;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=true;this.maxCount=4096;this.count=
+0;this.hasNormal=this.hasPos=false;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(d,e,f){return d+(e-d)*f};this.VIntX=function(d,e,f,b,h,k,g,m,q,A){h=(h-q)/(A-q);q=this.normal_cache;e[b]=k+h*this.delta;e[b+1]=g;e[b+2]=m;f[b]=this.lerp(q[d],q[d+3],h);f[b+1]=this.lerp(q[d+1],q[d+4],h);f[b+2]=this.lerp(q[d+2],q[d+5],h)};this.VIntY=function(d,e,f,b,h,k,g,m,q,A){h=(h-q)/(A-q);q=this.normal_cache;e[b]=k;e[b+1]=g+h*this.delta;e[b+
+2]=m;e=d+this.yd*3;f[b]=this.lerp(q[d],q[e],h);f[b+1]=this.lerp(q[d+1],q[e+1],h);f[b+2]=this.lerp(q[d+2],q[e+2],h)};this.VIntZ=function(d,e,f,b,h,k,g,m,q,A){h=(h-q)/(A-q);q=this.normal_cache;e[b]=k;e[b+1]=g;e[b+2]=m+h*this.delta;e=d+this.zd*3;f[b]=this.lerp(q[d],q[e],h);f[b+1]=this.lerp(q[d+1],q[e+1],h);f[b+2]=this.lerp(q[d+2],q[e+2],h)};this.compNorm=function(d){var e=d*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[d-1]-this.field[d+1];this.normal_cache[e+1]=this.field[d-this.yd]-
+this.field[d+this.yd];this.normal_cache[e+2]=this.field[d-this.zd]-this.field[d+this.zd]}};this.polygonize=function(d,e,f,b,h,k){var g=b+1,m=b+this.yd,q=b+this.zd,A=g+this.yd,v=g+this.zd,n=b+this.yd+this.zd,z=g+this.yd+this.zd,C=0,G=this.field[b],w=this.field[g],H=this.field[m],o=this.field[A],l=this.field[q],u=this.field[v],t=this.field[n],j=this.field[z];if(G<h)C|=1;if(w<h)C|=2;if(H<h)C|=8;if(o<h)C|=4;if(l<h)C|=16;if(u<h)C|=32;if(t<h)C|=128;if(j<h)C|=64;var p=THREE.edgeTable[C];if(p==0)return 0;
+var x=this.delta,y=d+x,F=e+x;x=f+x;if(p&1){this.compNorm(b);this.compNorm(g);this.VIntX(b*3,this.vlist,this.nlist,0,h,d,e,f,G,w)}if(p&2){this.compNorm(g);this.compNorm(A);this.VIntY(g*3,this.vlist,this.nlist,3,h,y,e,f,w,o)}if(p&4){this.compNorm(m);this.compNorm(A);this.VIntX(m*3,this.vlist,this.nlist,6,h,d,F,f,H,o)}if(p&8){this.compNorm(b);this.compNorm(m);this.VIntY(b*3,this.vlist,this.nlist,9,h,d,e,f,G,H)}if(p&16){this.compNorm(q);this.compNorm(v);this.VIntX(q*3,this.vlist,this.nlist,12,h,d,e,x,
+l,u)}if(p&32){this.compNorm(v);this.compNorm(z);this.VIntY(v*3,this.vlist,this.nlist,15,h,y,e,x,u,j)}if(p&64){this.compNorm(n);this.compNorm(z);this.VIntX(n*3,this.vlist,this.nlist,18,h,d,F,x,t,j)}if(p&128){this.compNorm(q);this.compNorm(n);this.VIntY(q*3,this.vlist,this.nlist,21,h,d,e,x,l,t)}if(p&256){this.compNorm(b);this.compNorm(q);this.VIntZ(b*3,this.vlist,this.nlist,24,h,d,e,f,G,l)}if(p&512){this.compNorm(g);this.compNorm(v);this.VIntZ(g*3,this.vlist,this.nlist,27,h,y,e,f,w,u)}if(p&1024){this.compNorm(A);
+this.compNorm(z);this.VIntZ(A*3,this.vlist,this.nlist,30,h,y,F,f,o,j)}if(p&2048){this.compNorm(m);this.compNorm(n);this.VIntZ(m*3,this.vlist,this.nlist,33,h,d,F,f,H,t)}C<<=4;for(h=b=0;THREE.triTable[C+h]!=-1;){d=C+h;e=d+1;f=d+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[d],3*THREE.triTable[e],3*THREE.triTable[f],k);h+=3;b++}return b};this.posnormtriv=function(d,e,f,b,h,k){var g=this.count*3;this.positionArray[g]=d[f];this.positionArray[g+1]=d[f+1];this.positionArray[g+2]=d[f+2];this.positionArray[g+
+3]=d[b];this.positionArray[g+4]=d[b+1];this.positionArray[g+5]=d[b+2];this.positionArray[g+6]=d[h];this.positionArray[g+7]=d[h+1];this.positionArray[g+8]=d[h+2];this.normalArray[g]=e[f];this.normalArray[g+1]=e[f+1];this.normalArray[g+2]=e[f+2];this.normalArray[g+3]=e[b];this.normalArray[g+4]=e[b+1];this.normalArray[g+5]=e[b+2];this.normalArray[g+6]=e[h];this.normalArray[g+7]=e[h+1];this.normalArray[g+8]=e[h+2];this.hasNormal=this.hasPos=true;this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=
+function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(d){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;d(this)}};this.addBall=function(d,e,f,b,h){var k=this.size*Math.sqrt(b/h),g=f*this.size,m=e*this.size,q=d*this.size,A=Math.floor(g-k);if(A<1)A=1;g=Math.floor(g+k);if(g>this.size-1)g=this.size-1;var v=Math.floor(m-k);if(v<1)v=1;m=Math.floor(m+k);if(m>this.size-1)m=this.size-1;var n=Math.floor(q-k);if(n<1)n=1;k=Math.floor(q+k);
+if(k>this.size-1)k=this.size-1;var z,C,G,w,H,o;for(A=A;A<g;A++){q=this.size*this.size*A;C=A/this.size-f;H=C*C;for(C=v;C<m;C++){G=q+this.size*C;z=C/this.size-e;o=z*z;for(z=n;z<k;z++){w=z/this.size-d;w=b/(1.0E-6+w*w+o+H)-h;if(w>0)this.field[G+z]+=w}}}};this.addPlaneX=function(d,e){var f,b,h,k,g,m=this.size,q=this.yd,A=this.zd,v=this.field,n=m*Math.sqrt(d/e);if(n>m)n=m;for(f=0;f<n;f++){b=f/m;b=b*b;k=d/(1.0E-4+b)-e;if(k>0)for(b=0;b<m;b++){g=f+b*q;for(h=0;h<m;h++)v[A*h+g]+=k}}};this.addPlaneY=function(d,
+e){var f,b,h,k,g,m,q=this.size,A=this.yd,v=this.zd,n=this.field,z=q*Math.sqrt(d/e);if(z>q)z=q;for(b=0;b<z;b++){f=b/q;f=f*f;k=d/(1.0E-4+f)-e;if(k>0){g=b*A;for(f=0;f<q;f++){m=g+f;for(h=0;h<q;h++)n[v*h+m]+=k}}}};this.addPlaneZ=function(d,e){var f,b,h,k,g,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(d/e);if(dist>size)dist=size;for(h=0;h<dist;h++){f=h/size;f=f*f;k=d/(1.0E-4+f)-e;if(k>0){g=zd*h;for(b=0;b<size;b++){m=g+b*yd;for(f=0;f<size;f++)field[m+f]+=k}}}};this.reset=function(){var d;
+for(d=0;d<this.size3;d++){this.normal_cache[d*3]=0;this.field[d]=0}};this.render=function(d){this.begin();var e,f,b,h,k,g,m,q,A,v=this.size-2;for(h=1;h<v;h++){A=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(b=1;b<v;b++){q=A+this.size*b;g=(b-this.halfsize)/this.halfsize;for(f=1;f<v;f++){k=(f-this.halfsize)/this.halfsize;e=q+f;this.polygonize(k,g,m,e,this.isolation,d)}}}this.end(d)};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
+THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
+1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
+419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]);
+THREE.triTable=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,
+-1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,
+-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,
+-1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,
+8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,
+-1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,
+5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,
+-1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,
+10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,
+6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,
+8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,
+2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,
+-1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,
+-1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,
+-1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,
+-1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,
+2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,
+4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,
+-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,
+2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
 THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var c="Loaded ";c+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
 c},loadAsciiOld:function(a,c){var d=document.createElement("script");d.type="text/javascript";d.onload=c;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a){var c=a.model,d=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);c.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,d,e)};c.postMessage(a)},loadBinary:function(a){var c=a.model,d=a.callback,e=a.texture_path?a.texture_path:
-THREE.Loader.prototype.extractUrlbase(c),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var b=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(l){THREE.Loader.prototype.loadAjaxBuffers(l.data.buffers,l.data.materials,d,f,e,b)};c.onerror=function(l){alert("worker.onerror: "+l.message+"\n"+l.data);l.preventDefault()};c.postMessage(a)},loadAjaxBuffers:function(a,c,d,e,f,b){var l=new XMLHttpRequest,h=e+"/"+a,g=0;
-l.onreadystatechange=function(){if(l.readyState==4)l.status==200||l.status==0?THREE.Loader.prototype.createBinModel(l.responseText,d,f,c):alert("Couldn't load ["+h+"] ["+l.status+"]");else if(l.readyState==3){if(b){if(g==0)g=l.getResponseHeader("Content-Length");b({total:g,loaded:l.responseText.length})}}else if(l.readyState==2)g=l.getResponseHeader("Content-Length")};l.open("GET",h,true);l.overrideMimeType("text/plain; charset=x-user-defined");l.setRequestHeader("Content-Type","text/plain");l.send(null)},
-createBinModel:function(a,c,d,e){var f=function(b){function l(E,L){var J=y(E,L),X=y(E,L+1),ea=y(E,L+2),ja=y(E,L+3),ia=(ja<<1&255|ea>>7)-127;J=(ea&127)<<16|X<<8|J;if(J==0&&ia==-127)return 0;return(1-2*(ja>>7))*(1+J*Math.pow(2,-23))*Math.pow(2,ia)}function h(E,L){var J=y(E,L),X=y(E,L+1),ea=y(E,L+2);return(y(E,L+3)<<24)+(ea<<16)+(X<<8)+J}function g(E,L){var J=y(E,L);return(y(E,L+1)<<8)+J}function m(E,L){var J=y(E,L);return J>127?J-256:J}function y(E,L){return E.charCodeAt(L)&255}function C(E){var L,
-J,X;L=h(a,E);J=h(a,E+q);X=h(a,E+j);E=g(a,E+v);THREE.Loader.prototype.f3(u,L,J,X,E)}function w(E){var L,J,X,ea,ja,ia;L=h(a,E);J=h(a,E+q);X=h(a,E+j);ea=g(a,E+v);ja=h(a,E+t);ia=h(a,E+x);E=h(a,E+A);THREE.Loader.prototype.f3n(u,k,L,J,X,ea,ja,ia,E)}function p(E){var L,J,X,ea;L=h(a,E);J=h(a,E+D);X=h(a,E+B);ea=h(a,E+I);E=g(a,E+P);THREE.Loader.prototype.f4(u,L,J,X,ea,E)}function z(E){var L,J,X,ea,ja,ia,qa,la;L=h(a,E);J=h(a,E+D);X=h(a,E+B);ea=h(a,E+I);ja=g(a,E+P);ia=h(a,E+O);qa=h(a,E+Q);la=h(a,E+T);E=h(a,E+
-U);THREE.Loader.prototype.f4n(u,k,L,J,X,ea,ja,ia,qa,la,E)}function F(E){var L,J;L=h(a,E);J=h(a,E+ba);E=h(a,E+ca);THREE.Loader.prototype.uv3(u.uvs,o[L*2],o[L*2+1],o[J*2],o[J*2+1],o[E*2],o[E*2+1])}function G(E){var L,J,X;L=h(a,E);J=h(a,E+S);X=h(a,E+K);E=h(a,E+Z);THREE.Loader.prototype.uv4(u.uvs,o[L*2],o[L*2+1],o[J*2],o[J*2+1],o[X*2],o[X*2+1],o[E*2],o[E*2+1])}var u=this,H=0,n,k=[],o=[],q,j,v,t,x,A,D,B,I,P,O,Q,T,U,ba,ca,S,K,Z,V,N,W,$,da,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(u,
-e,b);n={signature:a.substr(H,8),header_bytes:y(a,H+8),vertex_coordinate_bytes:y(a,H+9),normal_coordinate_bytes:y(a,H+10),uv_coordinate_bytes:y(a,H+11),vertex_index_bytes:y(a,H+12),normal_index_bytes:y(a,H+13),uv_index_bytes:y(a,H+14),material_index_bytes:y(a,H+15),nvertices:h(a,H+16),nnormals:h(a,H+16+4),nuvs:h(a,H+16+8),ntri_flat:h(a,H+16+12),ntri_smooth:h(a,H+16+16),ntri_flat_uv:h(a,H+16+20),ntri_smooth_uv:h(a,H+16+24),nquad_flat:h(a,H+16+28),nquad_smooth:h(a,H+16+32),nquad_flat_uv:h(a,H+16+36),
-nquad_smooth_uv:h(a,H+16+40)};H+=n.header_bytes;q=n.vertex_index_bytes;j=n.vertex_index_bytes*2;v=n.vertex_index_bytes*3;t=n.vertex_index_bytes*3+n.material_index_bytes;x=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;A=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;D=n.vertex_index_bytes;B=n.vertex_index_bytes*2;I=n.vertex_index_bytes*3;P=n.vertex_index_bytes*4;O=n.vertex_index_bytes*4+n.material_index_bytes;Q=n.vertex_index_bytes*4+n.material_index_bytes+
-n.normal_index_bytes;T=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;U=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;ba=n.uv_index_bytes;ca=n.uv_index_bytes*2;S=n.uv_index_bytes;K=n.uv_index_bytes*2;Z=n.uv_index_bytes*3;b=n.vertex_index_bytes*3+n.material_index_bytes;ha=n.vertex_index_bytes*4+n.material_index_bytes;V=n.ntri_flat*b;N=n.ntri_smooth*(b+n.normal_index_bytes*3);W=n.ntri_flat_uv*(b+n.uv_index_bytes*3);$=n.ntri_smooth_uv*(b+n.normal_index_bytes*
-3+n.uv_index_bytes*3);da=n.nquad_flat*ha;b=n.nquad_smooth*(ha+n.normal_index_bytes*4);ha=n.nquad_flat_uv*(ha+n.uv_index_bytes*4);H+=function(E){var L,J,X,ea=n.vertex_coordinate_bytes*3,ja=E+n.nvertices*ea;for(E=E;E<ja;E+=ea){L=l(a,E);J=l(a,E+n.vertex_coordinate_bytes);X=l(a,E+n.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(u,L,J,X)}return n.nvertices*ea}(H);H+=function(E){var L,J,X,ea=n.normal_coordinate_bytes*3,ja=E+n.nnormals*ea;for(E=E;E<ja;E+=ea){L=m(a,E);J=m(a,E+n.normal_coordinate_bytes);
-X=m(a,E+n.normal_coordinate_bytes*2);k.push(L/127,J/127,X/127)}return n.nnormals*ea}(H);H+=function(E){var L,J,X=n.uv_coordinate_bytes*2,ea=E+n.nuvs*X;for(E=E;E<ea;E+=X){L=l(a,E);J=l(a,E+n.uv_coordinate_bytes);o.push(L,J)}return n.nuvs*X}(H);H=H;V=H+V;N=V+N;W=N+W;$=W+$;da=$+da;b=da+b;ha=b+ha;(function(E){var L,J=n.vertex_index_bytes*3+n.material_index_bytes,X=J+n.uv_index_bytes*3,ea=E+n.ntri_flat_uv*X;for(L=E;L<ea;L+=X){C(L);F(L+J)}return ea-E})(N);(function(E){var L,J=n.vertex_index_bytes*3+n.material_index_bytes+
-n.normal_index_bytes*3,X=J+n.uv_index_bytes*3,ea=E+n.ntri_smooth_uv*X;for(L=E;L<ea;L+=X){w(L);F(L+J)}return ea-E})(W);(function(E){var L,J=n.vertex_index_bytes*4+n.material_index_bytes,X=J+n.uv_index_bytes*4,ea=E+n.nquad_flat_uv*X;for(L=E;L<ea;L+=X){p(L);G(L+J)}return ea-E})(b);(function(E){var L,J=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,X=J+n.uv_index_bytes*4,ea=E+n.nquad_smooth_uv*X;for(L=E;L<ea;L+=X){z(L);G(L+J)}return ea-E})(ha);(function(E){var L,J=n.vertex_index_bytes*
-3+n.material_index_bytes,X=E+n.ntri_flat*J;for(L=E;L<X;L+=J)C(L);return X-E})(H);(function(E){var L,J=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,X=E+n.ntri_smooth*J;for(L=E;L<X;L+=J)w(L);return X-E})(V);(function(E){var L,J=n.vertex_index_bytes*4+n.material_index_bytes,X=E+n.nquad_flat*J;for(L=E;L<X;L+=J)p(L);return X-E})($);(function(E){var L,J=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,X=E+n.nquad_smooth*J;for(L=E;L<X;L+=J)z(L);return X-E})(da);
-this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f(d))},createModel:function(a,c,d){var e=function(f){var b=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(b,a.materials,f);(function(){var l,h,g,m,y;l=0;for(h=a.vertices.length;l<h;l+=3){g=a.vertices[l];m=a.vertices[l+1];y=a.vertices[l+2];THREE.Loader.prototype.v(b,g,m,y)}})();(function(){function l(z,F){THREE.Loader.prototype.f3(b,z[F],
-z[F+1],z[F+2],z[F+3])}function h(z,F){THREE.Loader.prototype.f3n(b,a.normals,z[F],z[F+1],z[F+2],z[F+3],z[F+4],z[F+5],z[F+6])}function g(z,F){THREE.Loader.prototype.f4(b,z[F],z[F+1],z[F+2],z[F+3],z[F+4])}function m(z,F){THREE.Loader.prototype.f4n(b,a.normals,z[F],z[F+1],z[F+2],z[F+3],z[F+4],z[F+5],z[F+6],z[F+7],z[F+8])}function y(z,F){var G,u,H,n,k,o,q,j,v;G=z[F];u=z[F+1];H=z[F+2];n=a.uvs[G*2];q=a.uvs[G*2+1];k=a.uvs[u*2];j=a.uvs[u*2+1];o=a.uvs[H*2];v=a.uvs[H*2+1];THREE.Loader.prototype.uv3(b.uvs,n,
-q,k,j,o,v);if(a.uvs2){n=a.uvs2[G*2];q=a.uvs2[G*2+1];k=a.uvs2[u*2];j=a.uvs2[u*2+1];o=a.uvs2[H*2];v=a.uvs2[H*2+1];THREE.Loader.prototype.uv3(b.uvs2,n,1-q,k,1-j,o,1-v)}}function C(z,F){var G,u,H,n,k,o,q,j,v,t,x,A;G=z[F];u=z[F+1];H=z[F+2];n=z[F+3];k=a.uvs[G*2];v=a.uvs[G*2+1];o=a.uvs[u*2];t=a.uvs[u*2+1];q=a.uvs[H*2];x=a.uvs[H*2+1];j=a.uvs[n*2];A=a.uvs[n*2+1];THREE.Loader.prototype.uv4(b.uvs,k,v,o,t,q,x,j,A);if(a.uvs2){k=a.uvs2[G*2];v=a.uvs2[G*2+1];o=a.uvs2[u*2];t=a.uvs2[u*2+1];q=a.uvs2[H*2];x=a.uvs2[H*
-2+1];j=a.uvs2[n*2];A=a.uvs2[n*2+1];THREE.Loader.prototype.uv4(b.uvs2,k,1-v,o,1-t,q,1-x,j,1-A)}}var w,p;w=0;for(p=a.triangles_uv.length;w<p;w+=7){l(a.triangles_uv,w);y(a.triangles_uv,w+4)}w=0;for(p=a.triangles_n_uv.length;w<p;w+=10){h(a.triangles_n_uv,w);y(a.triangles_n_uv,w+7)}w=0;for(p=a.quads_uv.length;w<p;w+=9){g(a.quads_uv,w);C(a.quads_uv,w+5)}w=0;for(p=a.quads_n_uv.length;w<p;w+=13){m(a.quads_n_uv,w);C(a.quads_n_uv,w+9)}w=0;for(p=a.triangles.length;w<p;w+=4)l(a.triangles,w);w=0;for(p=a.triangles_n.length;w<
-p;w+=7)h(a.triangles_n,w);w=0;for(p=a.quads.length;w<p;w+=5)g(a.quads,w);w=0;for(p=a.quads_n.length;w<p;w+=9)m(a.quads_n,w)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;c(new e(d))},v:function(a,c,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,d,e)))},f3:function(a,c,d,e,f){a.faces.push(new THREE.Face3(c,d,e,null,a.materials[f]))},f4:function(a,c,d,e,f,b){a.faces.push(new THREE.Face4(c,d,e,f,null,
-a.materials[b]))},f3n:function(a,c,d,e,f,b,l,h,g){b=a.materials[b];var m=c[h*3],y=c[h*3+1];h=c[h*3+2];var C=c[g*3],w=c[g*3+1];g=c[g*3+2];a.faces.push(new THREE.Face3(d,e,f,[new THREE.Vector3(c[l*3],c[l*3+1],c[l*3+2]),new THREE.Vector3(m,y,h),new THREE.Vector3(C,w,g)],b))},f4n:function(a,c,d,e,f,b,l,h,g,m,y){l=a.materials[l];var C=c[g*3],w=c[g*3+1];g=c[g*3+2];var p=c[m*3],z=c[m*3+1];m=c[m*3+2];var F=c[y*3],G=c[y*3+1];y=c[y*3+2];a.faces.push(new THREE.Face4(d,e,f,b,[new THREE.Vector3(c[h*3],c[h*3+1],
-c[h*3+2]),new THREE.Vector3(C,w,g),new THREE.Vector3(p,z,m),new THREE.Vector3(F,G,y)],l))},uv3:function(a,c,d,e,f,b,l){var h=[];h.push(new THREE.UV(c,d));h.push(new THREE.UV(e,f));h.push(new THREE.UV(b,l));a.push(h)},uv4:function(a,c,d,e,f,b,l,h,g){var m=[];m.push(new THREE.UV(c,d));m.push(new THREE.UV(e,f));m.push(new THREE.UV(b,l));m.push(new THREE.UV(h,g));a.push(m)},init_materials:function(a,c,d){a.materials=[];for(var e=0;e<c.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(c[e],
-d)]},createMaterial:function(a,c){function d(l){l=Math.log(l)/Math.LN2;return Math.floor(l)==l}function e(l,h){var g=new Image;g.onload=function(){if(!d(this.width)||!d(this.height)){var m=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),y=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));l.image.width=m;l.image.height=y;l.image.getContext("2d").drawImage(this,0,0,m,y)}else l.image=this;l.image.loaded=1};g.src=h}var f,b;if(a.map_diffuse&&c){b=document.createElement("canvas");f=new THREE.MeshLambertMaterial({map:new THREE.Texture(b)});
+THREE.Loader.prototype.extractUrlbase(c),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var b=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,d,f,e,b)};c.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};c.postMessage(a)},loadAjaxBuffers:function(a,c,d,e,f,b){var h=new XMLHttpRequest,k=e+"/"+a,g=0;
+h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,d,f,c):alert("Couldn't load ["+k+"] ["+h.status+"]");else if(h.readyState==3){if(b){if(g==0)g=h.getResponseHeader("Content-Length");b({total:g,loaded:h.responseText.length})}}else if(h.readyState==2)g=h.getResponseHeader("Content-Length")};h.open("GET",k,true);h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)},
+createBinModel:function(a,c,d,e){var f=function(b){function h(E,L){var J=q(E,L),X=q(E,L+1),ea=q(E,L+2),ja=q(E,L+3),ia=(ja<<1&255|ea>>7)-127;J=(ea&127)<<16|X<<8|J;if(J==0&&ia==-127)return 0;return(1-2*(ja>>7))*(1+J*Math.pow(2,-23))*Math.pow(2,ia)}function k(E,L){var J=q(E,L),X=q(E,L+1),ea=q(E,L+2);return(q(E,L+3)<<24)+(ea<<16)+(X<<8)+J}function g(E,L){var J=q(E,L);return(q(E,L+1)<<8)+J}function m(E,L){var J=q(E,L);return J>127?J-256:J}function q(E,L){return E.charCodeAt(L)&255}function A(E){var L,
+J,X;L=k(a,E);J=k(a,E+t);X=k(a,E+j);E=g(a,E+p);THREE.Loader.prototype.f3(w,L,J,X,E)}function v(E){var L,J,X,ea,ja,ia;L=k(a,E);J=k(a,E+t);X=k(a,E+j);ea=g(a,E+p);ja=k(a,E+x);ia=k(a,E+y);E=k(a,E+F);THREE.Loader.prototype.f3n(w,l,L,J,X,ea,ja,ia,E)}function n(E){var L,J,X,ea;L=k(a,E);J=k(a,E+B);X=k(a,E+D);ea=k(a,E+I);E=g(a,E+N);THREE.Loader.prototype.f4(w,L,J,X,ea,E)}function z(E){var L,J,X,ea,ja,ia,qa,la;L=k(a,E);J=k(a,E+B);X=k(a,E+D);ea=k(a,E+I);ja=g(a,E+N);ia=k(a,E+O);qa=k(a,E+Q);la=k(a,E+T);E=k(a,E+
+U);THREE.Loader.prototype.f4n(w,l,L,J,X,ea,ja,ia,qa,la,E)}function C(E){var L,J;L=k(a,E);J=k(a,E+ba);E=k(a,E+ca);THREE.Loader.prototype.uv3(w.uvs,u[L*2],u[L*2+1],u[J*2],u[J*2+1],u[E*2],u[E*2+1])}function G(E){var L,J,X;L=k(a,E);J=k(a,E+S);X=k(a,E+K);E=k(a,E+Z);THREE.Loader.prototype.uv4(w.uvs,u[L*2],u[L*2+1],u[J*2],u[J*2+1],u[X*2],u[X*2+1],u[E*2],u[E*2+1])}var w=this,H=0,o,l=[],u=[],t,j,p,x,y,F,B,D,I,N,O,Q,T,U,ba,ca,S,K,Z,V,P,W,$,da,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,
+e,b);o={signature:a.substr(H,8),header_bytes:q(a,H+8),vertex_coordinate_bytes:q(a,H+9),normal_coordinate_bytes:q(a,H+10),uv_coordinate_bytes:q(a,H+11),vertex_index_bytes:q(a,H+12),normal_index_bytes:q(a,H+13),uv_index_bytes:q(a,H+14),material_index_bytes:q(a,H+15),nvertices:k(a,H+16),nnormals:k(a,H+16+4),nuvs:k(a,H+16+8),ntri_flat:k(a,H+16+12),ntri_smooth:k(a,H+16+16),ntri_flat_uv:k(a,H+16+20),ntri_smooth_uv:k(a,H+16+24),nquad_flat:k(a,H+16+28),nquad_smooth:k(a,H+16+32),nquad_flat_uv:k(a,H+16+36),
+nquad_smooth_uv:k(a,H+16+40)};H+=o.header_bytes;t=o.vertex_index_bytes;j=o.vertex_index_bytes*2;p=o.vertex_index_bytes*3;x=o.vertex_index_bytes*3+o.material_index_bytes;y=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;F=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;B=o.vertex_index_bytes;D=o.vertex_index_bytes*2;I=o.vertex_index_bytes*3;N=o.vertex_index_bytes*4;O=o.vertex_index_bytes*4+o.material_index_bytes;Q=o.vertex_index_bytes*4+o.material_index_bytes+
+o.normal_index_bytes;T=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*2;U=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*3;ba=o.uv_index_bytes;ca=o.uv_index_bytes*2;S=o.uv_index_bytes;K=o.uv_index_bytes*2;Z=o.uv_index_bytes*3;b=o.vertex_index_bytes*3+o.material_index_bytes;ha=o.vertex_index_bytes*4+o.material_index_bytes;V=o.ntri_flat*b;P=o.ntri_smooth*(b+o.normal_index_bytes*3);W=o.ntri_flat_uv*(b+o.uv_index_bytes*3);$=o.ntri_smooth_uv*(b+o.normal_index_bytes*
+3+o.uv_index_bytes*3);da=o.nquad_flat*ha;b=o.nquad_smooth*(ha+o.normal_index_bytes*4);ha=o.nquad_flat_uv*(ha+o.uv_index_bytes*4);H+=function(E){var L,J,X,ea=o.vertex_coordinate_bytes*3,ja=E+o.nvertices*ea;for(E=E;E<ja;E+=ea){L=h(a,E);J=h(a,E+o.vertex_coordinate_bytes);X=h(a,E+o.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(w,L,J,X)}return o.nvertices*ea}(H);H+=function(E){var L,J,X,ea=o.normal_coordinate_bytes*3,ja=E+o.nnormals*ea;for(E=E;E<ja;E+=ea){L=m(a,E);J=m(a,E+o.normal_coordinate_bytes);
+X=m(a,E+o.normal_coordinate_bytes*2);l.push(L/127,J/127,X/127)}return o.nnormals*ea}(H);H+=function(E){var L,J,X=o.uv_coordinate_bytes*2,ea=E+o.nuvs*X;for(E=E;E<ea;E+=X){L=h(a,E);J=h(a,E+o.uv_coordinate_bytes);u.push(L,J)}return o.nuvs*X}(H);H=H;V=H+V;P=V+P;W=P+W;$=W+$;da=$+da;b=da+b;ha=b+ha;(function(E){var L,J=o.vertex_index_bytes*3+o.material_index_bytes,X=J+o.uv_index_bytes*3,ea=E+o.ntri_flat_uv*X;for(L=E;L<ea;L+=X){A(L);C(L+J)}return ea-E})(P);(function(E){var L,J=o.vertex_index_bytes*3+o.material_index_bytes+
+o.normal_index_bytes*3,X=J+o.uv_index_bytes*3,ea=E+o.ntri_smooth_uv*X;for(L=E;L<ea;L+=X){v(L);C(L+J)}return ea-E})(W);(function(E){var L,J=o.vertex_index_bytes*4+o.material_index_bytes,X=J+o.uv_index_bytes*4,ea=E+o.nquad_flat_uv*X;for(L=E;L<ea;L+=X){n(L);G(L+J)}return ea-E})(b);(function(E){var L,J=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,X=J+o.uv_index_bytes*4,ea=E+o.nquad_smooth_uv*X;for(L=E;L<ea;L+=X){z(L);G(L+J)}return ea-E})(ha);(function(E){var L,J=o.vertex_index_bytes*
+3+o.material_index_bytes,X=E+o.ntri_flat*J;for(L=E;L<X;L+=J)A(L);return X-E})(H);(function(E){var L,J=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*3,X=E+o.ntri_smooth*J;for(L=E;L<X;L+=J)v(L);return X-E})(V);(function(E){var L,J=o.vertex_index_bytes*4+o.material_index_bytes,X=E+o.nquad_flat*J;for(L=E;L<X;L+=J)n(L);return X-E})($);(function(E){var L,J=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,X=E+o.nquad_smooth*J;for(L=E;L<X;L+=J)z(L);return X-E})(da);
+this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f(d))},createModel:function(a,c,d){var e=function(f){var b=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(b,a.materials,f);(function(){var h,k,g,m,q;h=0;for(k=a.vertices.length;h<k;h+=3){g=a.vertices[h];m=a.vertices[h+1];q=a.vertices[h+2];THREE.Loader.prototype.v(b,g,m,q)}})();(function(){function h(z,C){THREE.Loader.prototype.f3(b,z[C],
+z[C+1],z[C+2],z[C+3])}function k(z,C){THREE.Loader.prototype.f3n(b,a.normals,z[C],z[C+1],z[C+2],z[C+3],z[C+4],z[C+5],z[C+6])}function g(z,C){THREE.Loader.prototype.f4(b,z[C],z[C+1],z[C+2],z[C+3],z[C+4])}function m(z,C){THREE.Loader.prototype.f4n(b,a.normals,z[C],z[C+1],z[C+2],z[C+3],z[C+4],z[C+5],z[C+6],z[C+7],z[C+8])}function q(z,C){var G,w,H,o,l,u,t,j,p;G=z[C];w=z[C+1];H=z[C+2];o=a.uvs[G*2];t=a.uvs[G*2+1];l=a.uvs[w*2];j=a.uvs[w*2+1];u=a.uvs[H*2];p=a.uvs[H*2+1];THREE.Loader.prototype.uv3(b.uvs,o,
+t,l,j,u,p);if(a.uvs2){o=a.uvs2[G*2];t=a.uvs2[G*2+1];l=a.uvs2[w*2];j=a.uvs2[w*2+1];u=a.uvs2[H*2];p=a.uvs2[H*2+1];THREE.Loader.prototype.uv3(b.uvs2,o,1-t,l,1-j,u,1-p)}}function A(z,C){var G,w,H,o,l,u,t,j,p,x,y,F;G=z[C];w=z[C+1];H=z[C+2];o=z[C+3];l=a.uvs[G*2];p=a.uvs[G*2+1];u=a.uvs[w*2];x=a.uvs[w*2+1];t=a.uvs[H*2];y=a.uvs[H*2+1];j=a.uvs[o*2];F=a.uvs[o*2+1];THREE.Loader.prototype.uv4(b.uvs,l,p,u,x,t,y,j,F);if(a.uvs2){l=a.uvs2[G*2];p=a.uvs2[G*2+1];u=a.uvs2[w*2];x=a.uvs2[w*2+1];t=a.uvs2[H*2];y=a.uvs2[H*
+2+1];j=a.uvs2[o*2];F=a.uvs2[o*2+1];THREE.Loader.prototype.uv4(b.uvs2,l,1-p,u,1-x,t,1-y,j,1-F)}}var v,n;v=0;for(n=a.triangles_uv.length;v<n;v+=7){h(a.triangles_uv,v);q(a.triangles_uv,v+4)}v=0;for(n=a.triangles_n_uv.length;v<n;v+=10){k(a.triangles_n_uv,v);q(a.triangles_n_uv,v+7)}v=0;for(n=a.quads_uv.length;v<n;v+=9){g(a.quads_uv,v);A(a.quads_uv,v+5)}v=0;for(n=a.quads_n_uv.length;v<n;v+=13){m(a.quads_n_uv,v);A(a.quads_n_uv,v+9)}v=0;for(n=a.triangles.length;v<n;v+=4)h(a.triangles,v);v=0;for(n=a.triangles_n.length;v<
+n;v+=7)k(a.triangles_n,v);v=0;for(n=a.quads.length;v<n;v+=5)g(a.quads,v);v=0;for(n=a.quads_n.length;v<n;v+=9)m(a.quads_n,v)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;c(new e(d))},v:function(a,c,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,d,e)))},f3:function(a,c,d,e,f){a.faces.push(new THREE.Face3(c,d,e,null,a.materials[f]))},f4:function(a,c,d,e,f,b){a.faces.push(new THREE.Face4(c,d,e,f,null,
+a.materials[b]))},f3n:function(a,c,d,e,f,b,h,k,g){b=a.materials[b];var m=c[k*3],q=c[k*3+1];k=c[k*3+2];var A=c[g*3],v=c[g*3+1];g=c[g*3+2];a.faces.push(new THREE.Face3(d,e,f,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(m,q,k),new THREE.Vector3(A,v,g)],b))},f4n:function(a,c,d,e,f,b,h,k,g,m,q){h=a.materials[h];var A=c[g*3],v=c[g*3+1];g=c[g*3+2];var n=c[m*3],z=c[m*3+1];m=c[m*3+2];var C=c[q*3],G=c[q*3+1];q=c[q*3+2];a.faces.push(new THREE.Face4(d,e,f,b,[new THREE.Vector3(c[k*3],c[k*3+1],
+c[k*3+2]),new THREE.Vector3(A,v,g),new THREE.Vector3(n,z,m),new THREE.Vector3(C,G,q)],h))},uv3:function(a,c,d,e,f,b,h){var k=[];k.push(new THREE.UV(c,d));k.push(new THREE.UV(e,f));k.push(new THREE.UV(b,h));a.push(k)},uv4:function(a,c,d,e,f,b,h,k,g){var m=[];m.push(new THREE.UV(c,d));m.push(new THREE.UV(e,f));m.push(new THREE.UV(b,h));m.push(new THREE.UV(k,g));a.push(m)},init_materials:function(a,c,d){a.materials=[];for(var e=0;e<c.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(c[e],
+d)]},createMaterial:function(a,c){function d(h){h=Math.log(h)/Math.LN2;return Math.floor(h)==h}function e(h,k){var g=new Image;g.onload=function(){if(!d(this.width)||!d(this.height)){var m=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),q=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));h.image.width=m;h.image.height=q;h.image.getContext("2d").drawImage(this,0,0,m,q)}else h.image=this;h.image.loaded=1};g.src=k}var f,b;if(a.map_diffuse&&c){b=document.createElement("canvas");f=new THREE.MeshLambertMaterial({map:new THREE.Texture(b)});
 e(f.map,c+"/"+a.map_diffuse)}else if(a.col_diffuse){f=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;f=new THREE.MeshLambertMaterial({color:f,opacity:a.transparency})}else f=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):new THREE.MeshLambertMaterial({color:15658734});if(a.map_lightmap&&c){b=document.createElement("canvas");f.light_map=new THREE.Texture(b);e(f.light_map,c+"/"+a.map_lightmap)}return f},extractUrlbase:function(a){a=a.split("/");a.pop();
 return a.join("/")}};

+ 7 - 2
src/extras/ShaderUtils.js

@@ -403,7 +403,8 @@ var ShaderUtils = {
 		'film': {
 
 		uniforms: { tDiffuse: { type: "t", value: 0, texture: null },
-					time: { type: "f", value: 0.0 }
+					time: { type: "f", value: 0.0 },
+					grayscale: { type: "i", value: 1 }
 				  },
 
 		vertex_shader: [
@@ -426,6 +427,8 @@ var ShaderUtils = {
 		
 		// control parameter
 		"uniform float time;",
+		
+		"uniform bool grayscale;",
 
 		// noise effect intensity value (0 = no effect, 1 = full effect)
 		"const float fNintensity = 0.35;",
@@ -459,7 +462,9 @@ var ShaderUtils = {
 			"cResult = cTextureScreen.rgb + clamp( fNintensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );",
 
 			// convert to grayscale if desired
-			"cResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );",
+			"if( grayscale ) {",
+				"cResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );",
+			"}",
 
 			"gl_FragColor =  vec4( cResult, cTextureScreen.a );",
 		

+ 909 - 0
src/extras/objects/MarchingCubes.js

@@ -0,0 +1,909 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ * Port of greggman's ThreeD version of marching cubes to Three.js
+ * http://webglsamples.googlecode.com/hg/blob/blob.html
+ */
+
+// do not crash if somebody includes the file in oldie browser
+
+if ( !window.Int32Array ) {
+  
+	window.Int32Array = Array;
+	window.Float32Array = Array;
+
+}
+
+
+THREE.MarchingCubes = function ( resolution, materials ) {
+
+	THREE.Object3D.call( this );
+
+	this.materials = materials instanceof Array ? materials : [ materials ];	
+
+	// functions have to be object properties
+	// prototype functions kill performance
+	// (tested and it was 4x slower !!!)
+	
+	this.init = function( resolution ) {
+	
+		// parameters
+		
+		this.isolation = 80.0;
+		
+		// size of field, 32 is pushing it in Javascript :)
+		
+		this.size = resolution;
+		this.size2 = this.size * this.size;
+		this.size3 = this.size2 * this.size;
+		this.halfsize = this.size / 2.0;
+		
+		// deltas
+		
+		this.delta = 2.0 / this.size;
+		this.yd = this.size;
+		this.zd = this.size2;
+
+		this.field = new Float32Array( this.size3 );
+		this.normal_cache = new Float32Array( this.size3 * 3 );
+
+		// temp buffers used in polygonize
+		
+		this.vlist = new Float32Array( 12 * 3 );
+		this.nlist = new Float32Array( 12 * 3 );
+		
+		this.firstDraw = true;
+		
+		// immediate render mode simulator
+		
+		this.maxCount = 4096; // TODO: find the fastest size for this buffer
+		this.count = 0;
+		this.hasPos = false;
+		this.hasNormal = false;
+		
+		this.positionArray = new Float32Array( this.maxCount * 3 );
+		this.normalArray   = new Float32Array( this.maxCount * 3 );		
+		
+	};
+
+	///////////////////////
+	// Polygonization
+	///////////////////////
+	
+	this.lerp = function( a, b, t ) { return a + ( b - a ) * t; };
+
+	this.VIntX = function( q, pout, nout, offset, isol, x, y, z, valp1, valp2 ) {
+
+		var mu = ( isol - valp1 ) / ( valp2 - valp1 ),
+		nc = this.normal_cache;
+		
+		pout[ offset ] 	   = x + mu * this.delta;
+		pout[ offset + 1 ] = y;
+		pout[ offset + 2 ] = z;
+		
+		nout[ offset ] 	   = this.lerp( nc[ q ],     nc[ q + 3 ], mu );
+		nout[ offset + 1 ] = this.lerp( nc[ q + 1 ], nc[ q + 4 ], mu );
+		nout[ offset + 2 ] = this.lerp( nc[ q + 2 ], nc[ q + 5 ], mu );
+		
+	};
+
+	this.VIntY = function( q, pout, nout, offset, isol, x, y, z, valp1, valp2 ) {
+		
+		var mu = ( isol - valp1 ) / ( valp2 - valp1 ),
+		nc = this.normal_cache;
+		
+		pout[ offset ] 	   = x;
+		pout[ offset + 1 ] = y + mu * this.delta;
+		pout[ offset + 2 ] = z;
+		
+		var q2 = q + this.yd * 3;
+
+		nout[ offset ] 	   = this.lerp( nc[ q ],     nc[ q2 ],     mu );
+		nout[ offset + 1 ] = this.lerp( nc[ q + 1 ], nc[ q2 + 1 ], mu );
+		nout[ offset + 2 ] = this.lerp( nc[ q + 2 ], nc[ q2 + 2 ], mu );
+		
+	};
+
+	this.VIntZ = function( q, pout, nout, offset, isol, x, y, z, valp1, valp2 ) {
+		
+		var mu = ( isol - valp1 ) / ( valp2 - valp1 ),
+		nc = this.normal_cache;
+		
+		pout[ offset ] 	   = x;
+		pout[ offset + 1 ] = y;
+		pout[ offset + 2 ] = z + mu * this.delta;
+		
+		var q2 = q + this.zd * 3;
+		
+		nout[ offset ] 	   = this.lerp( nc[ q ],     nc[ q2 ],     mu );
+		nout[ offset + 1 ] = this.lerp( nc[ q + 1 ], nc[ q2 + 1 ], mu );
+		nout[ offset + 2 ] = this.lerp( nc[ q + 2 ], nc[ q2 + 2 ], mu );
+		
+	};
+
+	this.compNorm = function( q ) {
+
+		var q3 = q * 3;
+		
+		if ( this.normal_cache [ q3 ] == 0.0 ) {
+			
+			this.normal_cache[ q3     ] = this.field[ q - 1  ] 	    - this.field[ q + 1 ];
+			this.normal_cache[ q3 + 1 ] = this.field[ q - this.yd ] - this.field[ q + this.yd ];
+			this.normal_cache[ q3 + 2 ] = this.field[ q - this.zd ] - this.field[ q + this.zd ];
+			
+		}
+		
+	};	
+	
+	// Returns total number of triangles. Fills triangles.
+	// (this is where most of time is spent - it's inner work of O(n3) loop )
+	
+	this.polygonize = function( fx, fy, fz, q, isol, render_callback ) {
+		
+		// cache indices
+		var q1 = q + 1,
+			qy = q + this.yd,
+			qz = q + this.zd,
+			q1y = q1 + this.yd,
+			q1z = q1 + this.zd,
+			qyz = q + this.yd + this.zd,
+			q1yz = q1 + this.yd + this.zd;
+
+		var cubeindex = 0,
+			field0 = this.field[ q ],
+			field1 = this.field[ q1 ],
+			field2 = this.field[ qy ],
+			field3 = this.field[ q1y ],
+			field4 = this.field[ qz ],
+			field5 = this.field[ q1z ],
+			field6 = this.field[ qyz ],
+			field7 = this.field[ q1yz ];
+		
+
+		if ( field0 < isol ) cubeindex |= 1;
+		if ( field1 < isol ) cubeindex |= 2;
+		if ( field2 < isol ) cubeindex |= 8;
+		if ( field3 < isol ) cubeindex |= 4;
+		if ( field4 < isol ) cubeindex |= 16;
+		if ( field5 < isol ) cubeindex |= 32;
+		if ( field6 < isol ) cubeindex |= 128;
+		if ( field7 < isol ) cubeindex |= 64;
+
+		// if cube is entirely in/out of the surface - bail, nothing to draw
+		
+		var bits = THREE.edgeTable[ cubeindex ];
+		if ( bits == 0 ) return 0;
+
+		var d = this.delta,
+			fx2 = fx + d, 
+			fy2 = fy + d, 
+			fz2 = fz + d;
+		
+		// top of the cube
+		
+		if ( bits & 1 ) { 
+			
+			this.compNorm( q );      
+			this.compNorm( q1 );       
+			this.VIntX( q * 3, this.vlist, this.nlist, 0, isol, fx, fy, fz, field0, field1 );
+			
+		};
+		
+		if ( bits & 2 ) { 
+			
+			this.compNorm( q1 );  
+			this.compNorm( q1y );  
+			this.VIntY( q1 * 3, this.vlist, this.nlist, 3, isol, fx2, fy, fz, field1, field3 );
+			
+		};
+		
+		if ( bits & 4 ) { 
+			
+			this.compNorm( qy ); 
+			this.compNorm( q1y );  
+			this.VIntX( qy * 3, this.vlist, this.nlist, 6, isol, fx, fy2, fz, field2, field3 ); 
+			
+		};
+		
+		if ( bits & 8 ) { 
+			
+			this.compNorm( q );      
+			this.compNorm( qy );      
+			this.VIntY( q * 3, this.vlist, this.nlist, 9, isol, fx, fy, fz, field0, field2 );
+			
+		};
+
+		// bottom of the cube
+			
+		if ( bits & 16 )  { 
+			
+			this.compNorm( qz );      
+			this.compNorm( q1z );      
+			this.VIntX( qz * 3, this.vlist, this.nlist, 12, isol, fx, fy, fz2, field4, field5 ); 
+			
+		};
+		
+		if ( bits & 32 )  { 
+			
+			this.compNorm( q1z );  
+			this.compNorm( q1yz ); 
+			this.VIntY( q1z * 3,  this.vlist, this.nlist, 15, isol, fx2, fy, fz2, field5, field7 ); 
+			
+		};
+		
+		if ( bits & 64 )  { 
+			
+			this.compNorm( qyz ); 
+			this.compNorm( q1yz ); 
+			this.VIntX( qyz * 3, this.vlist, this.nlist, 18, isol, fx, fy2, fz2, field6, field7 ); 
+			
+		};
+		
+		if ( bits & 128 ) { 
+			
+			this.compNorm( qz );      
+			this.compNorm( qyz );     
+			this.VIntY( qz * 3,  this.vlist, this.nlist, 21, isol, fx, fy, fz2, field4, field6 ); 
+			
+		};
+			
+		// vertical lines of the cube
+			
+		if ( bits & 256 )  { 
+			
+			this.compNorm( q );          
+			this.compNorm( qz );          
+			this.VIntZ( q * 3, this.vlist, this.nlist, 24, isol, fx, fy, fz, field0, field4 );
+			
+		};
+		
+		if ( bits & 512 )  { 
+			
+			this.compNorm( q1 );      
+			this.compNorm( q1z );      
+			this.VIntZ( q1 * 3,  this.vlist, this.nlist, 27, isol, fx2, fy,  fz, field1, field5 ); 
+			
+		};
+		
+		if ( bits & 1024 ) { 
+			
+			this.compNorm( q1y ); 
+			this.compNorm( q1yz ); 
+			this.VIntZ( q1y * 3, this.vlist, this.nlist, 30, isol, fx2, fy2, fz, field3, field7 ); 
+			
+		};
+		
+		if ( bits & 2048 ) { 
+			
+			this.compNorm( qy );     
+			this.compNorm( qyz );     
+			this.VIntZ( qy * 3, this.vlist, this.nlist, 33, isol, fx,  fy2, fz, field2, field6 ); 
+			
+		};
+
+		cubeindex <<= 4;  // re-purpose cubeindex into an offset into triTable
+		
+		var o1, o2, o3, numtris = 0, i = 0;
+			
+		// here is where triangles are created
+
+		while ( THREE.triTable[ cubeindex + i ] != -1 ) {
+	  
+			o1 = cubeindex + i;
+			o2 = o1 + 1;
+			o3 = o1 + 2;
+			
+			this.posnormtriv( this.vlist, this.nlist,
+							  3 * THREE.triTable[ o1 ],
+							  3 * THREE.triTable[ o2 ],
+							  3 * THREE.triTable[ o3 ],
+							  render_callback );
+
+			i += 3;
+			numtris ++;
+		
+		}
+
+		return numtris;
+		
+	};
+
+	/////////////////////////////////////
+	// Immediate render mode simulator
+	/////////////////////////////////////
+	
+	this.posnormtriv = function( pos, norm, o1, o2, o3,render_callback ) {
+		
+		var c = this.count * 3;
+		
+		this.positionArray[ c ] 	= pos[ o1 ];
+		this.positionArray[ c + 1 ] = pos[ o1 + 1 ];
+		this.positionArray[ c + 2 ] = pos[ o1 + 2 ];
+		  
+		this.positionArray[ c + 3 ] = pos[ o2 ];
+		this.positionArray[ c + 4 ] = pos[ o2 + 1 ];
+		this.positionArray[ c + 5 ] = pos[ o2 + 2 ];
+		  
+		this.positionArray[ c + 6 ] = pos[ o3 ];
+		this.positionArray[ c + 7 ] = pos[ o3 + 1 ];
+		this.positionArray[ c + 8 ] = pos[ o3 + 2 ];
+		  
+		this.normalArray[ c ] 	  = norm[ o1 ]; 
+		this.normalArray[ c + 1 ] = norm[ o1 + 1 ];
+		this.normalArray[ c + 2 ] = norm[ o1 + 2 ];
+		  
+		this.normalArray[ c + 3 ] = norm[ o2 ]; 
+		this.normalArray[ c + 4 ] = norm[ o2 + 1 ];
+		this.normalArray[ c + 5 ] = norm[ o2 + 2 ];
+		  
+		this.normalArray[ c + 6 ] = norm[ o3 ]; 
+		this.normalArray[ c + 7 ] = norm[ o3 + 1 ];
+		this.normalArray[ c + 8 ] = norm[ o3 + 2 ];
+		
+		this.hasPos = true;
+		this.hasNormal = true;
+		
+		this.count += 3;
+		
+		if ( this.count >= this.maxCount - 3 ) {
+		
+			render_callback( this );
+		
+		}
+		
+	};
+
+	this.begin = function( ) {
+		
+		this.count = 0;
+		this.hasPos = false;
+		this.hasNormal = false;
+	  
+	};
+
+	this.end = function( render_callback ) {
+		
+		if ( this.count == 0 )
+			return;
+		
+		for ( var i = this.count * 3; i < this.positionArray.length; i++ )
+			this.positionArray[ i ] = 0.0;
+		
+		render_callback( this );
+		
+	};
+
+	/////////////////////////////////////
+	// Metaballs
+	/////////////////////////////////////
+	
+	// Adds a reciprocal ball (nice and blobby) that, to be fast, fades to zero after
+	// a fixed distance, determined by strength and subtract.
+
+	this.addBall = function( ballx, bally, ballz, strength, subtract ) {
+		
+		// Let's solve the equation to find the radius:
+		// 1.0 / (0.000001 + radius^2) * strength - subtract = 0
+		// strength / (radius^2) = subtract
+		// strength = subtract * radius^2
+		// radius^2 = strength / subtract
+		// radius = sqrt(strength / subtract)
+		
+		var radius = this.size * Math.sqrt( strength / subtract ),
+			zs = ballz * this.size,
+			ys = bally * this.size,
+			xs = ballx * this.size;
+		
+		var min_z = Math.floor( zs - radius ); if ( min_z < 1 ) min_z = 1;
+		var max_z = Math.floor( zs + radius ); if ( max_z > this.size - 1 ) max_z = this.size - 1;
+		var min_y = Math.floor( ys - radius ); if ( min_y < 1 ) min_y = 1;
+		var max_y = Math.floor( ys + radius ); if ( max_y > this.size - 1 ) max_y = this.size - 1;
+		var min_x = Math.floor( xs - radius ); if ( min_x < 1  ) min_x = 1;
+		var max_x = Math.floor( xs + radius ); if ( max_x > this.size - 1 ) max_x = this.size - 1;
+		
+
+		// Don't polygonize in the outer layer because normals aren't
+		// well-defined there.
+
+		var x, y, z, y_offset, z_offset, fx, fy, fz, fz2, fy2, val;
+		
+		for ( z = min_z; z < max_z; z++ ) {
+	  
+			z_offset = this.size * this.size * z,
+			fz = z / this.size - ballz,
+			fz2 = fz * fz;
+			
+			for ( y = min_y; y < max_y; y++ ) {
+			
+				y_offset = z_offset + this.size * y;
+				fy = y / this.size - bally;
+				fy2 = fy * fy;
+				
+				for ( x = min_x; x < max_x; x++ ) {
+					
+					fx = x / this.size - ballx;
+					val = strength / ( 0.000001 + fx*fx + fy2 + fz2 ) - subtract;
+					if ( val > 0.0 ) this.field[ y_offset + x ] += val;
+					
+				}
+				
+			}
+			
+		}
+		
+	};
+
+	this.addPlaneX = function( strength, subtract ) {
+		
+		var x, y, z, xx, val, xdiv, cxy,
+			
+			// cache attribute lookups
+			size = this.size,
+			yd = this.yd,
+			zd = this.zd,
+			field = this.field,
+			
+			dist = size * Math.sqrt( strength / subtract );
+		
+		if ( dist > size ) dist = size;
+		
+		for ( x = 0; x < dist; x++ ) {
+			
+			xdiv = x / size;
+			xx = xdiv * xdiv;
+			val = strength / ( 0.0001 + xx ) - subtract;
+			
+			if ( val > 0.0 ) {
+				
+				for ( y = 0; y < size; y++ ) {
+					
+					cxy = x + y * yd;
+					
+					for ( z = 0; z < size; z++ )
+						field[ zd * z + cxy ] += val;
+					
+				}
+				
+			}
+			
+		}
+
+	};
+
+	this.addPlaneY = function( strength, subtract ) {
+		
+		var x, y, z, yy, val, ydiv, cy, cxy,
+			
+			// cache attribute lookups
+			size = this.size,
+			yd = this.yd,
+			zd = this.zd,
+			field = this.field,
+			
+			dist = size * Math.sqrt( strength / subtract );
+		
+		if ( dist > size ) dist = size;
+		
+		for ( y = 0; y < dist; y++ ) {
+			
+			ydiv = y / size;
+			yy = ydiv * ydiv;
+			val = strength / ( 0.0001 + yy ) - subtract;
+			
+			if ( val > 0.0 ) {
+				
+				cy = y * yd;
+				
+				for ( x = 0; x < size; x++ ) {
+					
+					cxy = cy + x;
+					
+					for ( z = 0; z < size; z++ )
+						field[ zd * z + cxy ] += val;
+					
+				}
+				
+			}
+			
+		}
+
+	};
+
+	this.addPlaneZ = function( strength, subtract ) {
+		
+		var x, y, z, zz, val, zdiv, cz, cyz;
+		
+			// cache attribute lookups
+			size = this.size,
+			yd = this.yd,
+			zd = this.zd,
+			field = this.field,
+		
+			dist = size * Math.sqrt( strength / subtract );
+		
+		if ( dist > size ) dist = size;
+		
+		for ( z = 0; z < dist; z++ ) {
+		
+			zdiv = z / size;
+			zz = zdiv * zdiv;
+			val = strength / ( 0.0001 + zz ) - subtract;
+			if ( val > 0.0 ) {
+		
+				cz = zd * z;
+				
+				for ( y = 0; y < size; y++ ) {
+						
+						cyz = cz + y * yd;
+					
+						for ( x = 0; x < size; x++ )					
+							field[ cyz + x ] += val;
+					
+				}
+				
+			}
+			
+		}
+
+	};
+
+	/////////////////////////////////////
+	// Updates
+	/////////////////////////////////////
+
+	this.reset = function() {
+		
+		var i;
+		
+		// wipe the normal cache
+		
+		for ( i = 0; i < this.size3; i++ ) {
+			
+			this.normal_cache[ i * 3 ] = 0.0;
+			this.field[ i ] = 0.0;
+			
+		}		
+
+	};
+	
+	this.render = function( render_callback ) {		
+		
+		this.begin();
+		
+		// Triangulate. Yeah, this is slow.
+		
+		var q, x, y, z, fx, fy, fz, y_offset, z_offset, smin2 = this.size - 2;
+		
+		for ( z = 1; z < smin2; z++ ) {
+			
+			z_offset = this.size2 * z;
+			fz = ( z - this.halfsize ) / this.halfsize; //+ 1
+			
+			for ( y = 1; y < smin2; y++ ) {
+			
+				y_offset = z_offset + this.size * y;
+				fy = ( y - this.halfsize ) / this.halfsize; //+ 1
+		
+				for ( x = 1; x < smin2; x++ ) {
+					
+					fx = ( x - this.halfsize ) / this.halfsize; //+ 1
+					q = y_offset + x;
+					
+					this.polygonize( fx, fy, fz, q, this.isolation, render_callback );
+				
+				}
+				
+			}
+		}
+		
+		this.end( render_callback );
+	
+	};
+	
+	this.init( resolution );
+
+};
+
+THREE.MarchingCubes.prototype = new THREE.Object3D();
+THREE.MarchingCubes.prototype.constructor = THREE.MarchingCubes;
+
+
+/////////////////////////////////////
+// Marching cubes lookup tables
+/////////////////////////////////////
+
+// These tables are straight from Paul Bourke's page:
+// http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/
+// who in turn got them from Cory Gene Bloyd.
+
+THREE.edgeTable = new Int32Array([
+0x0  , 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
+0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
+0x190, 0x99 , 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,
+0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,
+0x230, 0x339, 0x33 , 0x13a, 0x636, 0x73f, 0x435, 0x53c,
+0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,
+0x3a0, 0x2a9, 0x1a3, 0xaa , 0x7a6, 0x6af, 0x5a5, 0x4ac,
+0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,
+0x460, 0x569, 0x663, 0x76a, 0x66 , 0x16f, 0x265, 0x36c,
+0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,
+0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff , 0x3f5, 0x2fc,
+0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,
+0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55 , 0x15c,
+0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,
+0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc ,
+0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,
+0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,
+0xcc , 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
+0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,
+0x15c, 0x55 , 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
+0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,
+0x2fc, 0x3f5, 0xff , 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
+0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,
+0x36c, 0x265, 0x16f, 0x66 , 0x76a, 0x663, 0x569, 0x460,
+0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,
+0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa , 0x1a3, 0x2a9, 0x3a0,
+0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,
+0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33 , 0x339, 0x230,
+0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,
+0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99 , 0x190,
+0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,
+0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0])
+
+THREE.triTable = new Int32Array([
+-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1,
+3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1,
+3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1,
+3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1,
+9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1,
+1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1,
+9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,
+2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1,
+8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1,
+9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,
+4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1,
+3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1,
+1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1,
+4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1,
+4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1,
+9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1,
+1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,
+5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1,
+2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1,
+9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,
+0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,
+2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1,
+10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1,
+4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1,
+5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1,
+5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1,
+9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1,
+0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1,
+1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1,
+10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1,
+8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1,
+2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1,
+7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1,
+9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1,
+2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1,
+11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1,
+9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1,
+5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1,
+11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1,
+11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,
+1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1,
+9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1,
+5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1,
+2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,
+0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,
+5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1,
+6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1,
+0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1,
+3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1,
+6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1,
+5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1,
+1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,
+10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1,
+6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1,
+1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1,
+8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1,
+7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1,
+3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,
+5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1,
+0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1,
+9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1,
+8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1,
+5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1,
+0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1,
+6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1,
+10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1,
+10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1,
+8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1,
+1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1,
+3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1,
+0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1,
+10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1,
+0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1,
+3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1,
+6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1,
+9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1,
+8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1,
+3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1,
+6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1,
+0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1,
+10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1,
+10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1,
+1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1,
+2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1,
+7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1,
+7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1,
+2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1,
+1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1,
+11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1,
+8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1,
+0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1,
+7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,
+10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,
+2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,
+6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1,
+7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1,
+2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1,
+1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1,
+10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1,
+10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1,
+0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1,
+7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1,
+6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1,
+8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1,
+9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1,
+6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1,
+1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1,
+4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1,
+10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1,
+8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1,
+0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1,
+1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1,
+8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1,
+10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1,
+4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1,
+10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,
+5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,
+11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1,
+9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,
+6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1,
+7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1,
+3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1,
+7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1,
+9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1,
+3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1,
+6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1,
+9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1,
+1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1,
+4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1,
+7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1,
+6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1,
+3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1,
+0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1,
+6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1,
+1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1,
+0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1,
+11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1,
+6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1,
+5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1,
+9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1,
+1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1,
+1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1,
+10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1,
+0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1,
+5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1,
+10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1,
+11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1,
+0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1,
+9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1,
+7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1,
+2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1,
+8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1,
+9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1,
+9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1,
+1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1,
+9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1,
+9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1,
+5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1,
+0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1,
+10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1,
+2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1,
+0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1,
+0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1,
+9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1,
+5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1,
+3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1,
+5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1,
+8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1,
+0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1,
+9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1,
+0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1,
+1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1,
+3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1,
+4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1,
+9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1,
+11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1,
+11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1,
+2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1,
+9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1,
+3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1,
+1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1,
+4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1,
+4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1,
+0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1,
+3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1,
+3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1,
+0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1,
+9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1,
+1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]);

+ 104 - 10
src/renderers/WebGLRenderer.js

@@ -180,7 +180,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		geometryChunk.__webGLLineBuffer = _gl.createBuffer();
 
 	};
-
+	
 	this.initLineBuffers = function( geometry ) {
 
 		var nvertices = geometry.vertices.length;
@@ -997,13 +997,11 @@ THREE.WebGLRenderer = function ( parameters ) {
 		
 	};
 	
-	this.renderBuffer = function ( camera, lights, fog, material, geometryChunk, object ) {
-
-		var program, u, identifiers, attributes, parameters, maxLightCount, linewidth, primitives;
-
+	this.setProgram = function( camera, lights, fog, material, object ) {
+		
 		this.initMaterial( material, lights, fog );
 
-		program = material.program;
+		var program = material.program;
 
 		if( program != _oldProgram ) {
 
@@ -1055,9 +1053,19 @@ THREE.WebGLRenderer = function ( parameters ) {
 			material.uniforms.mFar.value = camera.far;
 			
 		}
-		
+	
 		setUniforms( program, material.uniforms );
 
+		return program;
+		
+	};
+	
+	this.renderBuffer = function ( camera, lights, fog, material, geometryChunk, object ) {
+
+		var program, attributes, linewidth, primitives;
+
+		program = this.setProgram( camera, lights, fog, material, object );
+		
 		attributes = program.attributes;
 
 		// vertices
@@ -1163,6 +1171,35 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
+	function renderBufferImmediate( object, program ) {
+		
+		if ( ! object.__webGLVertexBuffer ) object.__webGLVertexBuffer = _gl.createBuffer();
+		if ( ! object.__webGLNormalBuffer ) object.__webGLNormalBuffer = _gl.createBuffer();
+		
+		if ( object.hasPos ) {
+			
+		  _gl.bindBuffer( _gl.ARRAY_BUFFER, object.__webGLVertexBuffer );
+		  _gl.bufferData( _gl.ARRAY_BUFFER, object.positionArray, _gl.DYNAMIC_DRAW );
+		  _gl.enableVertexAttribArray( program.attributes.position );
+		  _gl.vertexAttribPointer( program.attributes.position, 3, _gl.FLOAT, false, 0, 0 );
+		
+		}
+		
+		if ( object.hasNormal ) {
+			
+		  _gl.bindBuffer( _gl.ARRAY_BUFFER, object.__webGLNormalBuffer );
+		  _gl.bufferData( _gl.ARRAY_BUFFER, object.normalArray, _gl.DYNAMIC_DRAW );
+		  _gl.enableVertexAttribArray( program.attributes.normal );
+		  _gl.vertexAttribPointer( program.attributes.normal, 3, _gl.FLOAT, false, 0, 0 );
+		
+		}
+		
+		_gl.drawArrays( _gl.TRIANGLES, 0, object.count );
+		
+		object.count = 0;
+		
+	};
+	
 	this.renderPass = function ( camera, lights, fog, object, geometryChunk, blending, transparent ) {
 
 		var i, l, m, ml, material, meshMaterial;
@@ -1202,6 +1239,27 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
+	this.renderPassImmediate = function ( camera, lights, fog, object, blending, transparent ) {
+
+		var i, l, m, ml, material, program;
+
+		for ( m = 0, ml = object.materials.length; m < ml; m++ ) {
+
+			material = object.materials[ m ];
+
+			if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) {
+
+				this.setBlending( material.blending );
+				program = this.setProgram( camera, lights, fog, material, object );
+				
+				object.render( function( object ) { renderBufferImmediate( object, program ); } );
+
+			}
+
+		}
+
+	};
+	
 	this.render = function( scene, camera, renderTarget, clear ) {
 
 		var o, ol, webGLObject, object, buffer,
@@ -1227,7 +1285,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		// set matrices and faces
 		
 		ol = scene.__webGLObjects.length;
-		
+	
 		for ( o = 0; o < ol; o++ ) {
 
 			webGLObject = scene.__webGLObjects[ o ];
@@ -1261,9 +1319,10 @@ THREE.WebGLRenderer = function ( parameters ) {
 				}
 			
 			}
-			
+		
 		}
 
+
 		// opaque pass
 
 		for ( o = 0; o < ol; o++ ) {
@@ -1275,6 +1334,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			if ( object.visible ) {
 			
+				object.autoUpdateMatrix && object.updateMatrix();
+				
 				this.setupMatrices( object, camera );
 				this.renderPass( camera, lights, fog, object, buffer, THREE.NormalBlending, false );
 
@@ -1282,6 +1343,22 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		}
 
+		// opaque pass (immediate simulator)
+		
+		for ( o = 0; o < scene.__webGLObjectsImmediate.length; o++ ) {
+			
+			webGLObject = scene.__webGLObjectsImmediate[ o ];
+			object = webGLObject.object;
+			
+			if ( object.visible ) {
+			
+				this.setupMatrices( object, camera );
+				this.renderPassImmediate( camera, lights, fog, object, THREE.NormalBlending, false );
+			
+			}
+			
+		}
+
 		// transparent pass
 
 		for ( o = 0; o < ol; o++ ) {
@@ -1340,6 +1417,17 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		};
 
+		function add_buffer_immediate( objmap, id, object ) {
+
+			if ( objmap[ id ] == undefined ) {
+
+				scene.__webGLObjectsImmediate.push( { object: object } );
+				objmap[ id ] = 1;
+
+			}
+
+		};
+
 		var o, ol, object, g, geometry, geometryChunk, objmap;
 
 		if ( !scene.__webGLObjects ) {
@@ -1347,6 +1435,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 			scene.__webGLObjects = [];
 			scene.__webGLObjectsMap = {};
 
+			scene.__webGLObjectsImmediate = [];
+
 		}
 
 		for ( o = 0, ol = scene.objects.length; o < ol; o++ ) {
@@ -1454,6 +1544,10 @@ THREE.WebGLRenderer = function ( parameters ) {
 				geometry.__dirtyElements = false;
 
 
+			} else if ( object instanceof THREE.MarchingCubes ) {
+				
+				add_buffer_immediate( objmap, 0, object );
+				
 			}/*else if ( object instanceof THREE.Particle ) {
 
 			}*/
@@ -1600,7 +1694,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			_gl = _canvas.getContext( 'experimental-webgl', { antialias: antialias } );
 
-		} catch(e) { }
+		} catch(e) { console.log(e) }
 
 		if (!_gl) {
 

+ 1 - 0
utils/build.py

@@ -84,6 +84,7 @@ EXTRAS_FILES = [
 'extras/primitives/Torus.js',
 'extras/primitives/Icosahedron.js',
 'extras/primitives/LathedObject.js',
+'extras/objects/MarchingCubes.js',
 'extras/io/Loader.js'
 ]