浏览代码

More optimizations of WebGLRenderer.

On my notebook WebGLRenderer now 35% faster than WebGLRenderer2 (in OpenGL, in ANGLE it's still 15% slower, go figure).
alteredq 14 年之前
父节点
当前提交
be527d9f81
共有 4 个文件被更改,包括 668 次插入668 次删除
  1. 154 155
      build/Three.js
  2. 155 156
      build/ThreeDebug.js
  3. 154 155
      build/ThreeExtras.js
  4. 205 202
      src/renderers/WebGLRenderer.js

+ 154 - 155
build/Three.js

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

+ 155 - 156
build/ThreeDebug.js

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

文件差异内容过多而无法显示
+ 154 - 155
build/ThreeExtras.js


+ 205 - 202
src/renderers/WebGLRenderer.js

@@ -24,6 +24,11 @@ THREE.WebGLRenderer = function ( parameters ) {
 	_oldProgram = null,
 	_oldFramebuffer = null,	
 
+	// gl state cache
+	
+	_cullEnabled,
+	_oldBlending = null,
+	
 	// camera matrices caches
 	
 	_frustum = [ 
@@ -903,206 +908,173 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function refreshUniformsCommon( material, fog ) {
+	function refreshUniformsCommon( uniforms, material ) {
 
 		// premultiply alpha
-		material.uniforms.diffuse.value.setRGB( material.color.r * material.opacity, material.color.g * material.opacity, material.color.b * material.opacity );
+		uniforms.diffuse.value.setRGB( material.color.r * material.opacity, material.color.g * material.opacity, material.color.b * material.opacity );
 
 		// pure color
-		//material.uniforms.color.value.setHex( material.color.hex );
+		//uniforms.color.value.setHex( material.color.hex );
 
-		material.uniforms.opacity.value = material.opacity;
-		material.uniforms.map.texture = material.map;
+		uniforms.opacity.value = material.opacity;
+		uniforms.map.texture = material.map;
 		
-		material.uniforms.light_map.texture = material.light_map;
-
-		material.uniforms.env_map.texture = material.env_map;
-		material.uniforms.reflectivity.value = material.reflectivity;
-		material.uniforms.refraction_ratio.value = material.refraction_ratio;
-		material.uniforms.combine.value = material.combine;
-		material.uniforms.useRefract.value = material.env_map && material.env_map.mapping instanceof THREE.CubeRefractionMapping;
-
-		if ( fog ) {
-
-			material.uniforms.fogColor.value.setHex( fog.color.hex );
-
-			if ( fog instanceof THREE.Fog ) {
-
-				material.uniforms.fogNear.value = fog.near;
-				material.uniforms.fogFar.value = fog.far;
-
-			} else if ( fog instanceof THREE.FogExp2 ) {
-
-				material.uniforms.fogDensity.value = fog.density;
+		uniforms.light_map.texture = material.light_map;
 
-			}
-
-		}
+		uniforms.env_map.texture = material.env_map;
+		uniforms.reflectivity.value = material.reflectivity;
+		uniforms.refraction_ratio.value = material.refraction_ratio;
+		uniforms.combine.value = material.combine;
+		uniforms.useRefract.value = material.env_map && material.env_map.mapping instanceof THREE.CubeRefractionMapping;
 
 	};
 
-	function refreshUniformsLine( material, fog ) {
-
-		material.uniforms.diffuse.value.setRGB( material.color.r * material.opacity, material.color.g * material.opacity, material.color.b * material.opacity );
-		material.uniforms.opacity.value = material.opacity;
-
-		if ( fog ) {
-
-			material.uniforms.fogColor.value.setHex( fog.color.hex );
-
-			if ( fog instanceof THREE.Fog ) {
-
-				material.uniforms.fogNear.value = fog.near;
-				material.uniforms.fogFar.value = fog.far;
-
-			} else if ( fog instanceof THREE.FogExp2 ) {
+	function refreshUniformsLine( uniforms, material ) {
 
-				material.uniforms.fogDensity.value = fog.density;
-
-			}
-
-		}
+		uniforms.diffuse.value.setRGB( material.color.r * material.opacity, material.color.g * material.opacity, material.color.b * material.opacity );
+		uniforms.opacity.value = material.opacity;
 
 	};
 
-	function refreshUniformsParticle( material, fog ) {
-
-		material.uniforms.psColor.value.setRGB( material.color.r * material.opacity, material.color.g * material.opacity, material.color.b * material.opacity );
-		material.uniforms.opacity.value = material.opacity;
-		material.uniforms.size.value = material.size;
-		material.uniforms.map.texture = material.map;
+	function refreshUniformsParticle( uniforms, material ) {
 
-		if ( fog ) {
+		uniforms.psColor.value.setRGB( material.color.r * material.opacity, material.color.g * material.opacity, material.color.b * material.opacity );
+		uniforms.opacity.value = material.opacity;
+		uniforms.size.value = material.size;
+		uniforms.map.texture = material.map;
 
-			material.uniforms.fogColor.value.setHex( fog.color.hex );
-
-			if ( fog instanceof THREE.Fog ) {
+	};
+	
+	function refreshUniformsFog( uniforms, fog ) {
+	
+		uniforms.fogColor.value.setHex( fog.color.hex );
 
-				material.uniforms.fogNear.value = fog.near;
-				material.uniforms.fogFar.value = fog.far;
+		if ( fog instanceof THREE.Fog ) {
 
-			} else if ( fog instanceof THREE.FogExp2 ) {
+			uniforms.fogNear.value = fog.near;
+			uniforms.fogFar.value = fog.far;
 
-				material.uniforms.fogDensity.value = fog.density;
+		} else if ( fog instanceof THREE.FogExp2 ) {
 
-			}
+			uniforms.fogDensity.value = fog.density;
 
 		}
-
+	
 	};
 
-	function refreshUniformsPhong( material ) {
+	function refreshUniformsPhong( uniforms, material ) {
 
-		//material.uniforms.ambient.value.setHex( material.ambient.hex );
-		//material.uniforms.specular.value.setHex( material.specular.hex );
-		material.uniforms.ambient.value.setRGB( material.ambient.r, material.ambient.g, material.ambient.b );
-		material.uniforms.specular.value.setRGB( material.specular.r, material.specular.g, material.specular.b );
-		material.uniforms.shininess.value = material.shininess;
+		//uniforms.ambient.value.setHex( material.ambient.hex );
+		//uniforms.specular.value.setHex( material.specular.hex );
+		uniforms.ambient.value.setRGB( material.ambient.r, material.ambient.g, material.ambient.b );
+		uniforms.specular.value.setRGB( material.specular.r, material.specular.g, material.specular.b );
+		uniforms.shininess.value = material.shininess;
 
 	};
 
 
-	function refreshLights( material, lights ) {
+	function refreshUniformsLights( uniforms, lights ) {
 
-		material.uniforms.enableLighting.value = lights.directional.length + lights.point.length;
-		material.uniforms.ambientLightColor.value = lights.ambient;
-		material.uniforms.directionalLightColor.value = lights.directional.colors;
-		material.uniforms.directionalLightDirection.value = lights.directional.positions;
-		material.uniforms.pointLightColor.value = lights.point.colors;
-		material.uniforms.pointLightPosition.value = lights.point.positions;
+		uniforms.enableLighting.value = lights.directional.length + lights.point.length;
+		uniforms.ambientLightColor.value = lights.ambient;
+		uniforms.directionalLightColor.value = lights.directional.colors;
+		uniforms.directionalLightDirection.value = lights.directional.positions;
+		uniforms.pointLightColor.value = lights.point.colors;
+		uniforms.pointLightPosition.value = lights.point.positions;
 
 	};
 
 	this.initMaterial = function( material, lights, fog ) {
-		
-		if ( !material.program ) {
 
-			var u, identifiers, parameters, maxLightCount;
-			
-			if ( material instanceof THREE.MeshDepthMaterial ) {
+		var u, identifiers, parameters, maxLightCount;
+		
+		if ( material instanceof THREE.MeshDepthMaterial ) {
 
-				setMaterialShaders( material, THREE.ShaderLib[ 'depth' ] );
+			setMaterialShaders( material, THREE.ShaderLib[ 'depth' ] );
 
-			} else if ( material instanceof THREE.MeshNormalMaterial ) {
+		} else if ( material instanceof THREE.MeshNormalMaterial ) {
 
-				setMaterialShaders( material, THREE.ShaderLib[ 'normal' ] );
+			setMaterialShaders( material, THREE.ShaderLib[ 'normal' ] );
 
-			} else if ( material instanceof THREE.MeshBasicMaterial ) {
+		} else if ( material instanceof THREE.MeshBasicMaterial ) {
 
-				setMaterialShaders( material, THREE.ShaderLib[ 'basic' ] );
+			setMaterialShaders( material, THREE.ShaderLib[ 'basic' ] );
 
-			} else if ( material instanceof THREE.MeshLambertMaterial ) {
+		} else if ( material instanceof THREE.MeshLambertMaterial ) {
 
-				setMaterialShaders( material, THREE.ShaderLib[ 'lambert' ] );
+			setMaterialShaders( material, THREE.ShaderLib[ 'lambert' ] );
 
-			} else if ( material instanceof THREE.MeshPhongMaterial ) {
+		} else if ( material instanceof THREE.MeshPhongMaterial ) {
 
-				setMaterialShaders( material, THREE.ShaderLib[ 'phong' ] );
+			setMaterialShaders( material, THREE.ShaderLib[ 'phong' ] );
 
-			} else if ( material instanceof THREE.LineBasicMaterial ) {
+		} else if ( material instanceof THREE.LineBasicMaterial ) {
 
-				setMaterialShaders( material, THREE.ShaderLib[ 'basic' ] );
+			setMaterialShaders( material, THREE.ShaderLib[ 'basic' ] );
 
-			} else if ( material instanceof THREE.ParticleBasicMaterial ) {
-				
-				setMaterialShaders( material, THREE.ShaderLib[ 'particle_basic' ] );
-				
-			}
+		} else if ( material instanceof THREE.ParticleBasicMaterial ) {
+			
+			setMaterialShaders( material, THREE.ShaderLib[ 'particle_basic' ] );
+			
+		}
 
-			// heuristics to create shader parameters according to lights in the scene
-			// (not to blow over maxLights budget)
+		// heuristics to create shader parameters according to lights in the scene
+		// (not to blow over maxLights budget)
 
-			maxLightCount = allocateLights( lights, 4 );
+		maxLightCount = allocateLights( lights, 4 );
 
-			parameters = { fog: fog, map: material.map, env_map: material.env_map, light_map: material.light_map, vertex_colors: material.vertex_colors,
-						   maxDirLights: maxLightCount.directional, maxPointLights: maxLightCount.point };
-			material.program = buildProgram( material.fragment_shader, material.vertex_shader, parameters );
+		parameters = { fog: fog, map: material.map, env_map: material.env_map, light_map: material.light_map, vertex_colors: material.vertex_colors,
+					   maxDirLights: maxLightCount.directional, maxPointLights: maxLightCount.point };
+		material.program = buildProgram( material.fragment_shader, material.vertex_shader, parameters );
 
-			identifiers = [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition' ];
-			for( u in material.uniforms ) {
+		identifiers = [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition' ];
+		for( u in material.uniforms ) {
 
-				identifiers.push(u);
+			identifiers.push(u);
 
-			}
+		}
 
-			cacheUniformLocations( material.program, identifiers );
-			cacheAttributeLocations( material.program, [ "position", "normal", "uv", "uv2", "tangent", "color" ] );
+		cacheUniformLocations( material.program, identifiers );
+		cacheAttributeLocations( material.program, [ "position", "normal", "uv", "uv2", "tangent", "color" ] );
 
-		}
-		
 	};
 	
 	this.setProgram = function( camera, lights, fog, material, object ) {
 		
-		this.initMaterial( material, lights, fog );
+		if ( !material.program ) this.initMaterial( material, lights, fog );
 
-		var program = material.program;
+		var program = material.program, 
+			p_uniforms = program.uniforms,
+			m_uniforms = material.uniforms;
 
 		if( program != _oldProgram ) {
 
 			_gl.useProgram( program );
 			_oldProgram = program;
+			
+			_gl.uniformMatrix4fv( p_uniforms.projectionMatrix, false, _projectionMatrixArray );
 
 		}
-
-		// only Phong and environment mapping use cameraPosition uniform
-		// shader material also gets it for the sake of genericity
 		
-		if ( material instanceof THREE.MeshShaderMaterial ||
+		// refresh uniforms common to several materials
+		
+		if ( fog && ( 
+			 material instanceof THREE.MeshBasicMaterial ||
+			 material instanceof THREE.MeshLambertMaterial ||
 			 material instanceof THREE.MeshPhongMaterial ||
-			 material.env_map ) {
+			 material instanceof THREE.LineBasicMaterial ||
+			 material instanceof THREE.ParticleBasicMaterial )
+			) {
 			
-			this.loadCamera( program, camera );
+			refreshUniformsFog( m_uniforms, fog );
 			
-		}
-		
-		this.loadMatrices( program, object );
+		}		
 
 		if ( material instanceof THREE.MeshPhongMaterial ||
 			 material instanceof THREE.MeshLambertMaterial ) {
 
 			this.setupLights( program, lights );
-			refreshLights( material, this.lights );
+			refreshUniformsLights( m_uniforms, this.lights );
 
 		}
 
@@ -1110,44 +1082,67 @@ THREE.WebGLRenderer = function ( parameters ) {
 			 material instanceof THREE.MeshLambertMaterial ||
 			 material instanceof THREE.MeshPhongMaterial ) {
 
-			refreshUniformsCommon( material, fog );
+			refreshUniformsCommon( m_uniforms, material );
 
 		}
 
+		// refresh single material specific uniforms
+		
 		if ( material instanceof THREE.LineBasicMaterial ) {
 
-			refreshUniformsLine( material, fog );
+			refreshUniformsLine( m_uniforms, material );
 			
-		}
+		} else if ( material instanceof THREE.ParticleBasicMaterial ) {
 
-		if ( material instanceof THREE.ParticleBasicMaterial ) {
-
-			refreshUniformsParticle( material, fog );
+			refreshUniformsParticle( m_uniforms, material );
 			
-		}
+		} else if ( material instanceof THREE.MeshPhongMaterial ) {
 
-		if ( material instanceof THREE.MeshPhongMaterial ) {
+			refreshUniformsPhong( m_uniforms, material );
 
-			refreshUniformsPhong( material );
+		} else if ( material instanceof THREE.MeshDepthMaterial ) {
 
-		}
-
-		if ( material instanceof THREE.MeshDepthMaterial ) {
+			m_uniforms.mNear.value = camera.near;
+			m_uniforms.mFar.value = camera.far;
+			m_uniforms.opacity.value = material.opacity;
+			
+		} else if ( material instanceof THREE.MeshNormalMaterial ) {
 
-			material.uniforms.mNear.value = camera.near;
-			material.uniforms.mFar.value = camera.far;
-			material.uniforms.opacity.value = material.opacity;
+			m_uniforms.opacity.value = material.opacity;
 			
 		}
+		
+		// load common uniforms
+		
+		loadUniformsGeneric( program, m_uniforms );
+		loadUniformsMatrices( p_uniforms, object );
 
-		if ( material instanceof THREE.MeshNormalMaterial ) {
-
-			material.uniforms.opacity.value = material.opacity;
+		// load material specific uniforms
+		// (shader material also gets them for the sake of genericity)
+		
+		if ( material instanceof THREE.MeshShaderMaterial ||
+			 material instanceof THREE.MeshPhongMaterial ||
+			 material.env_map ) {
+			
+			_gl.uniform3f( p_uniforms.cameraPosition, camera.position.x, camera.position.y, camera.position.z );
 			
 		}
 		
-		setUniforms( program, material.uniforms );
+		if ( material instanceof THREE.MeshShaderMaterial ||
+			 material.env_map) {
+				 
+			_gl.uniformMatrix4fv( p_uniforms.objectMatrix, false, object._objectMatrixArray );
+		
+		}
 
+		if ( material instanceof THREE.MeshPhongMaterial ||
+			 material instanceof THREE.MeshLambertMaterial ||
+			 material instanceof THREE.MeshShaderMaterial ) {
+			 
+			_gl.uniformMatrix4fv( p_uniforms.viewMatrix, false, _viewMatrixArray );
+			
+		}
+		
 		return program;
 		
 	};
@@ -1317,7 +1312,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 					if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) {
 
-						this.setBlending( material.blending );
+						setBlending( material.blending );
 						this.setDepthTest( material.depth_test );
 						
 						this.renderBuffer( camera, lights, fog, material, geometryChunk, object );
@@ -1331,7 +1326,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 				material = meshMaterial;
 				if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) {
 
-					this.setBlending( material.blending );
+					setBlending( material.blending );
 					this.setDepthTest( material.depth_test );
 					
 					this.renderBuffer( camera, lights, fog, material, geometryChunk, object );
@@ -1354,7 +1349,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) {
 
-				this.setBlending( material.blending );
+				setBlending( material.blending );
 				this.setDepthTest( material.depth_test );
 				
 				program = this.setProgram( camera, lights, fog, material, object );
@@ -1371,11 +1366,21 @@ THREE.WebGLRenderer = function ( parameters ) {
 		
 		if( object.doubleSided ) {
 
-			_gl.disable( _gl.CULL_FACE );
+			if ( _cullEnabled ) {
+			
+				_gl.disable( _gl.CULL_FACE );
+				_cullEnabled = false;
+				
+			}
 
 		} else {
 
-			_gl.enable( _gl.CULL_FACE );
+			if ( ! _cullEnabled ) {
+			
+				_gl.enable( _gl.CULL_FACE );
+				_cullEnabled = true;
+			
+			}
 
 			if( object.flipSided ) {
 
@@ -1782,23 +1787,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	this.loadMatrices = function ( program, object ) {
-
-		_gl.uniformMatrix4fv( program.uniforms.viewMatrix, false, _viewMatrixArray );
-		_gl.uniformMatrix4fv( program.uniforms.projectionMatrix, false, _projectionMatrixArray );
-		
-		_gl.uniformMatrix4fv( program.uniforms.modelViewMatrix, false, object._modelViewMatrixArray );
-		_gl.uniformMatrix3fv( program.uniforms.normalMatrix, false, object._normalMatrixArray );
-		_gl.uniformMatrix4fv( program.uniforms.objectMatrix, false, object._objectMatrixArray );
-
-	};
-
-	this.loadCamera = function( program, camera ) {
-
-		_gl.uniform3f( program.uniforms.cameraPosition, camera.position.x, camera.position.y, camera.position.z );
-
-	};
-
 	this.setDepthTest = function( test ) {
 		
 		if( test ) {
@@ -1812,42 +1800,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 		}
 		
 	};
-	
-	this.setBlending = function( blending ) {
-
-		switch ( blending ) {
-
-			case THREE.AdditiveBlending:
-
-				_gl.blendEquation( _gl.FUNC_ADD );
-				_gl.blendFunc( _gl.ONE, _gl.ONE );
-
-				break;
-
-			case THREE.SubtractiveBlending:
-
-				//_gl.blendEquation( _gl.FUNC_SUBTRACT );
-				_gl.blendFunc( _gl.DST_COLOR, _gl.ZERO );
-
-				break;
-
-			case THREE.BillboardBlending:
-
-				_gl.blendEquation( _gl.FUNC_ADD );
-				_gl.blendFunc( _gl.SRC_ALPHA, _gl.ONE_MINUS_SRC_ALPHA);
-
-				break;
-
-			default:
-
-				_gl.blendEquation( _gl.FUNC_ADD );
-				_gl.blendFunc( _gl.ONE, _gl.ONE_MINUS_SRC_ALPHA );
-
-				break;
-		
-		}
-
-	};
 
 	this.setFaceCulling = function ( cullFace, frontFace ) {
 
@@ -1927,6 +1879,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 		_gl.enable( _gl.BLEND );
 		_gl.blendFunc( _gl.ONE, _gl.ONE_MINUS_SRC_ALPHA );
 		_gl.clearColor( clearColor.r, clearColor.g, clearColor.b, clearAlpha );
+		
+		_cullEnabled = true;
 
 	};
 
@@ -2005,7 +1959,14 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function setUniforms( program, uniforms ) {
+	function loadUniformsMatrices( uniforms, object ) {
+		
+		_gl.uniformMatrix4fv( uniforms.modelViewMatrix, false, object._modelViewMatrixArray );
+		_gl.uniformMatrix3fv( uniforms.normalMatrix, false, object._normalMatrixArray );
+
+	};
+	
+	function loadUniformsGeneric( program, uniforms ) {
 
 		var u, uniform, value, type, location, texture;
 
@@ -2071,6 +2032,48 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
+	function setBlending( blending ) {
+
+		if ( blending != _oldBlending ) {
+		
+			switch ( blending ) {
+
+				case THREE.AdditiveBlending:
+
+					_gl.blendEquation( _gl.FUNC_ADD );
+					_gl.blendFunc( _gl.ONE, _gl.ONE );
+
+					break;
+
+				case THREE.SubtractiveBlending:
+
+					//_gl.blendEquation( _gl.FUNC_SUBTRACT );
+					_gl.blendFunc( _gl.DST_COLOR, _gl.ZERO );
+
+					break;
+
+				case THREE.BillboardBlending:
+
+					_gl.blendEquation( _gl.FUNC_ADD );
+					_gl.blendFunc( _gl.SRC_ALPHA, _gl.ONE_MINUS_SRC_ALPHA);
+
+					break;
+
+				default:
+
+					_gl.blendEquation( _gl.FUNC_ADD );
+					_gl.blendFunc( _gl.ONE, _gl.ONE_MINUS_SRC_ALPHA );
+
+					break;
+			
+			}
+			
+			_oldBlending = blending;
+		
+		}
+
+	};
+	
 	function setCubeTexture( texture, slot ) {
 
 		if ( texture.image.length == 6 ) {

部分文件因为文件数量过多而无法显示