Browse Source

Fixed discrepancy between ANGLE and OpenGL when rendering to texture.

Had to set viewport to make it work in OpenGL.

Also made it easier to see texture orientation in the example.

Now it's visible that there is indeed flipping. At least now it's consistent ;).
alteredq 14 years ago
parent
commit
9bc383e1ed
5 changed files with 446 additions and 410 deletions
  1. 133 133
      build/Three.js
  2. 134 134
      build/ThreeDebug.js
  3. 140 140
      build/ThreeExtras.js
  4. 14 1
      examples/render_to_texture.html
  5. 25 2
      src/renderers/WebGLRenderer.js

+ 133 - 133
build/Three.js

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

+ 134 - 134
build/ThreeDebug.js

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

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


+ 14 - 1
examples/render_to_texture.html

@@ -53,7 +53,13 @@
 			
             void main(void)
             {
-                gl_FragColor = vec4( time, vUv.x, vUv.y, 1.0 );
+                //gl_FragColor = vec4( time, vUv.x, vUv.y, 1.0 );
+				float r = vUv.x;
+				if( vUv.y < 0.5 ) r = 0.0;
+				float g = vUv.y;
+				if( vUv.x < 0.5 ) g = 0.0;
+				
+				gl_FragColor = vec4( r, g, 0.25, 1.0 );
             }
         </script>
 
@@ -94,6 +100,13 @@
 				light.position.normalize();
 				scene.addLight( light );
 
+				light = new THREE.DirectionalLight( 0xffaaaa, 0.5 );
+				light.position.x = -1;
+				light.position.y = 0;
+				light.position.z = -1;
+				light.position.normalize();
+				scene.addLight( light );
+
                 rtTexture = new THREE.RenderTarget( 256, 256 );
 
                 material = new THREE.MeshShaderMaterial( {

+ 25 - 2
src/renderers/WebGLRenderer.js

@@ -22,6 +22,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	var _canvas = document.createElement( 'canvas' ), _gl,
 	_oldProgram = null,
+	_oldFramebuffer = null,
 	_modelViewMatrix = new THREE.Matrix4(), _normalMatrix,
 
 	_viewMatrixArray = new Float32Array(16),
@@ -1484,8 +1485,30 @@ THREE.WebGLRenderer = function ( parameters ) {
 			
 		}
 
-		var framebuffer = renderTexture ? renderTexture.__webGLFramebuffer : null;
-		_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
+		var framebuffer, width, height;
+		
+		if ( renderTexture ) {
+			
+			framebuffer = renderTexture.__webGLFramebuffer;
+			width = renderTexture.width;
+			height = renderTexture.height;
+			
+		} else {
+			
+			framebuffer = null;
+			width = _canvas.width;
+			height = _canvas.height;
+			
+		}
+		
+		if( framebuffer != _oldFramebuffer ) {
+			
+			_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
+			_gl.viewport( 0, 0, width, height );
+			
+			_oldFramebuffer = framebuffer;
+			
+		}
 
 	};
 	

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