Browse Source

Added "depth_test" parameter to materials.

This is to be able to control depth buffer writing / testing on per geometry chunk level (before it was possible just to hack it on per scene level via exposed GL context).

Disabling depth test is useful for example for additively blended particles, handling of transparency or for having background textured quad.

Another option would be to have it on per object level, but then this could prevent different handling of objects with both transparent and opaque parts.

Also in this commit:

- more progress towards mesh vertex colors
- less matrix multiplications in render call
- fixed ugly bug in doubleSided / flipSided handling
- cleanup of materials
    - added a lot of missing stuff in debug strings and parameters handlers
    - normal and depth materials now have opacity parameter
    - wrote comments for non-obvious things
alteredq 14 years ago
parent
commit
ad51a48fcd

+ 180 - 175
build/Three.js

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

+ 181 - 176
build/ThreeDebug.js

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

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


+ 0 - 2
examples/particles_billboards_colors_gl.html

@@ -114,8 +114,6 @@
 				}
 				}
 				
 				
 				geometry.colors = colors;
 				geometry.colors = colors;
-				
-				console.log( colors[0] );
 
 
 				material = new THREE.ParticleBasicMaterial( { size: 35, map: sprite, blending: THREE.BillboardBlending, vertex_colors: true } );
 				material = new THREE.ParticleBasicMaterial( { size: 35, map: sprite, blending: THREE.BillboardBlending, vertex_colors: true } );
 				material.color.setHSV( 1.0, 0.2, 0.8 );
 				material.color.setHSV( 1.0, 0.2, 0.8 );

+ 1 - 3
examples/particles_sprites_gl.html

@@ -120,7 +120,7 @@
 					sprite = parameters[i][1];
 					sprite = parameters[i][1];
 					size   = parameters[i][2];
 					size   = parameters[i][2];
 					
 					
-					materials[i] = new THREE.ParticleBasicMaterial( { size: size, map: sprite, blending: THREE.AdditiveBlending } );
+					materials[i] = new THREE.ParticleBasicMaterial( { size: size, map: sprite, blending: THREE.AdditiveBlending, depth_test: false } );
 					materials[i].color.setHSV( color[0], color[1], color[2] );
 					materials[i].color.setHSV( color[0], color[1], color[2] );
 
 
 					particles = new THREE.ParticleSystem( geometry, materials[i] );
 					particles = new THREE.ParticleSystem( geometry, materials[i] );
@@ -134,8 +134,6 @@
 				renderer = new THREE.WebGLRenderer( { clearAlpha: 1 });
 				renderer = new THREE.WebGLRenderer( { clearAlpha: 1 });
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				container.appendChild( renderer.domElement );
 				container.appendChild( renderer.domElement );
-				
-				renderer.context.disable( renderer.context.DEPTH_TEST );
 
 
 				stats = new Stats();
 				stats = new Stats();
 				stats.domElement.style.position = 'absolute';
 				stats.domElement.style.position = 'absolute';

+ 3 - 4
examples/postprocessing.html

@@ -139,8 +139,9 @@
 
 
                     uniforms: { time: { type: "f", value: 0.0 } },
                     uniforms: { time: { type: "f", value: 0.0 } },
                     vertex_shader: getText( 'vs-generic' ),
                     vertex_shader: getText( 'vs-generic' ),
-                    fragment_shader: getText( 'fs-colors' )
-
+                    fragment_shader: getText( 'fs-colors' ),
+					depth_test: false
+					
                 } );
                 } );
 
 
 				var screen_shader = ShaderUtils.lib["screen"];
 				var screen_shader = ShaderUtils.lib["screen"];
@@ -298,9 +299,7 @@
 				
 				
 				// background 
 				// background 
 				
 				
-				renderer.context.disable( renderer.context.DEPTH_TEST );
 				renderer.render( sceneBG, cameraOrtho, rtTexture1 );
 				renderer.render( sceneBG, cameraOrtho, rtTexture1 );
-				renderer.context.enable( renderer.context.DEPTH_TEST );
 				
 				
 				// model
 				// model
 				
 				

+ 31 - 6
src/materials/LineBasicMaterial.js

@@ -1,22 +1,35 @@
 /**
 /**
  * @author mr.doob / http://mrdoob.com/
  * @author mr.doob / http://mrdoob.com/
+ * @author alteredq / http://alteredqualia.com/
  *
  *
  * parameters = {
  * parameters = {
  *  color: <hex>,
  *  color: <hex>,
  *  opacity: <float>,
  *  opacity: <float>,
+ 
  *  blending: THREE.NormalBlending,
  *  blending: THREE.NormalBlending,
- *  linewidth: <float>
+ *  depth_test: <bool>,
+ 
+ *  linewidth: <float>,
+ *  linecap: "round",  
+ *  linejoin: "round",
+ 
+ *  vertex_colors: <bool>
  * }
  * }
  */
  */
 
 
 THREE.LineBasicMaterial = function ( parameters ) {
 THREE.LineBasicMaterial = function ( parameters ) {
 
 
+	this.id = THREE.LineBasicMaterialCounter.value ++;
+	
 	this.color = new THREE.Color( 0xffffff );
 	this.color = new THREE.Color( 0xffffff );
-	this.opacity = 1;
+	this.opacity = 1.0;
+	
 	this.blending = THREE.NormalBlending;
 	this.blending = THREE.NormalBlending;
-	this.linewidth = 1;
-	this.linecap = 'round';
-	this.linejoin = 'round';
+	this.depth_test = true;
+	
+	this.linewidth = 1.0;
+	this.linecap = 'round';	 	// implemented just in CanvasRenderer
+	this.linejoin = 'round';	// implemented just in CanvasRenderer	
 
 
 	this.vertex_colors = false;
 	this.vertex_colors = false;
 	
 	
@@ -24,10 +37,14 @@ THREE.LineBasicMaterial = function ( parameters ) {
 
 
 		if ( parameters.color !== undefined ) this.color.setHex( parameters.color );
 		if ( parameters.color !== undefined ) this.color.setHex( parameters.color );
 		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
 		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
+		
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
+		if ( parameters.depth_test !== undefined ) this.depth_test = parameters.depth_test;
+		
 		if ( parameters.linewidth !== undefined ) this.linewidth = parameters.linewidth;
 		if ( parameters.linewidth !== undefined ) this.linewidth = parameters.linewidth;
 		if ( parameters.linecap !== undefined ) this.linecap = parameters.linecap;
 		if ( parameters.linecap !== undefined ) this.linecap = parameters.linecap;
 		if ( parameters.linejoin !== undefined ) this.linejoin = parameters.linejoin;
 		if ( parameters.linejoin !== undefined ) this.linejoin = parameters.linejoin;
+		
 		if ( parameters.vertex_colors !== undefined ) this.vertex_colors = parameters.vertex_colors;
 		if ( parameters.vertex_colors !== undefined ) this.vertex_colors = parameters.vertex_colors;
 		
 		
 	}
 	}
@@ -39,15 +56,23 @@ THREE.LineBasicMaterial.prototype = {
 	toString: function () {
 	toString: function () {
 
 
 		return 'THREE.LineBasicMaterial (<br/>' +
 		return 'THREE.LineBasicMaterial (<br/>' +
+			'id: ' + this.id + '<br/>' +
+		
 			'color: ' + this.color + '<br/>' +
 			'color: ' + this.color + '<br/>' +
 			'opacity: ' + this.opacity + '<br/>' +
 			'opacity: ' + this.opacity + '<br/>' +
+		
 			'blending: ' + this.blending + '<br/>' +
 			'blending: ' + this.blending + '<br/>' +
+			'depth_test: ' + this.depth_test + '<br/>' +
+		
 			'linewidth: ' + this.linewidth +'<br/>' +
 			'linewidth: ' + this.linewidth +'<br/>' +
 			'linecap: ' + this.linecap +'<br/>' +
 			'linecap: ' + this.linecap +'<br/>' +
 			'linejoin: ' + this.linejoin +'<br/>' +
 			'linejoin: ' + this.linejoin +'<br/>' +
+		
 			'vertex_colors: ' + this.vertex_colors + '<br/>' +
 			'vertex_colors: ' + this.vertex_colors + '<br/>' +
 			')';
 			')';
 
 
 	}
 	}
 
 
-}
+};
+
+THREE.LineBasicMaterialCounter = { value: 0 };

+ 24 - 10
src/materials/MeshBasicMaterial.js

@@ -4,6 +4,7 @@
  *
  *
  * parameters = {
  * parameters = {
  *  color: <hex>,
  *  color: <hex>,
+ *  opacity: <float>,
  *  map: new THREE.Texture( <Image> ),
  *  map: new THREE.Texture( <Image> ),
 
 
  *  light_map: new THREE.Texture( <Image> ),
  *  light_map: new THREE.Texture( <Image> ),
@@ -13,11 +14,14 @@
  *  reflectivity: <float>,
  *  reflectivity: <float>,
  *  refraction_ratio: <float>,
  *  refraction_ratio: <float>,
  
  
- *  opacity: <float>,
  *  shading: THREE.SmoothShading,
  *  shading: THREE.SmoothShading,
  *  blending: THREE.NormalBlending,
  *  blending: THREE.NormalBlending,
+ *  depth_test: <bool>,
+ 
  *  wireframe: <boolean>,
  *  wireframe: <boolean>,
- *  wireframe_linewidth: <float>
+ *  wireframe_linewidth: <float>,
+ 
+ *  vertex_colors: <bool>
  * }
  * }
  */
  */
 
 
@@ -26,29 +30,33 @@ THREE.MeshBasicMaterial = function ( parameters ) {
 	this.id = THREE.MeshBasicMaterialCounter.value ++;
 	this.id = THREE.MeshBasicMaterialCounter.value ++;
 
 
 	this.color = new THREE.Color( 0xffffff );
 	this.color = new THREE.Color( 0xffffff );
+	this.opacity = 1.0;
 	this.map = null;
 	this.map = null;
 
 
 	this.light_map = null;
 	this.light_map = null;
 
 
 	this.env_map = null;
 	this.env_map = null;
 	this.combine = THREE.MultiplyOperation;
 	this.combine = THREE.MultiplyOperation;
-	this.reflectivity = 1;
+	this.reflectivity = 1.0;
 	this.refraction_ratio = 0.98;
 	this.refraction_ratio = 0.98;
 
 
-	this.fog = true;
+	this.fog = true; // implemented just in WebGLRenderer2
 
 
-	this.opacity = 1;
 	this.shading = THREE.SmoothShading;
 	this.shading = THREE.SmoothShading;
 	this.blending = THREE.NormalBlending;
 	this.blending = THREE.NormalBlending;
+	this.depth_test = true;
 
 
 	this.wireframe = false;
 	this.wireframe = false;
-	this.wireframe_linewidth = 1;
-	this.wireframe_linecap = 'round';
-	this.wireframe_linejoin = 'round';
+	this.wireframe_linewidth = 1.0;
+	this.wireframe_linecap = 'round';	// implemented just in CanvasRenderer
+	this.wireframe_linejoin = 'round';	// implemented just in CanvasRenderer
 
 
+	this.vertex_colors = false;
+	
 	if ( parameters ) {
 	if ( parameters ) {
 
 
 		if ( parameters.color !== undefined ) this.color.setHex( parameters.color );
 		if ( parameters.color !== undefined ) this.color.setHex( parameters.color );
+		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
 		if ( parameters.map !== undefined ) this.map = parameters.map;
 		if ( parameters.map !== undefined ) this.map = parameters.map;
 
 
 		if ( parameters.light_map !== undefined ) this.light_map = parameters.light_map;
 		if ( parameters.light_map !== undefined ) this.light_map = parameters.light_map;
@@ -60,14 +68,16 @@ THREE.MeshBasicMaterial = function ( parameters ) {
 
 
 		if ( parameters.fog !== undefined ) this.fog  = parameters.fog;
 		if ( parameters.fog !== undefined ) this.fog  = parameters.fog;
 
 
-		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
 		if ( parameters.shading !== undefined ) this.shading = parameters.shading;
 		if ( parameters.shading !== undefined ) this.shading = parameters.shading;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
+		if ( parameters.depth_test !== undefined ) this.depth_test = parameters.depth_test;
 
 
 		if ( parameters.wireframe !== undefined ) this.wireframe = parameters.wireframe;
 		if ( parameters.wireframe !== undefined ) this.wireframe = parameters.wireframe;
 		if ( parameters.wireframe_linewidth !== undefined ) this.wireframe_linewidth = parameters.wireframe_linewidth;
 		if ( parameters.wireframe_linewidth !== undefined ) this.wireframe_linewidth = parameters.wireframe_linewidth;
 		if ( parameters.wireframe_linecap !== undefined ) this.wireframe_linecap = parameters.wireframe_linecap;
 		if ( parameters.wireframe_linecap !== undefined ) this.wireframe_linecap = parameters.wireframe_linecap;
 		if ( parameters.wireframe_linejoin !== undefined ) this.wireframe_linejoin = parameters.wireframe_linejoin;
 		if ( parameters.wireframe_linejoin !== undefined ) this.wireframe_linejoin = parameters.wireframe_linejoin;
+		
+		if ( parameters.vertex_colors !== undefined ) this.vertex_colors = parameters.vertex_colors;
 
 
 	}
 	}
 
 
@@ -79,7 +89,9 @@ THREE.MeshBasicMaterial.prototype = {
 
 
 		return 'THREE.MeshBasicMaterial (<br/>' +
 		return 'THREE.MeshBasicMaterial (<br/>' +
 			'id: ' + this.id + '<br/>' +
 			'id: ' + this.id + '<br/>' +
+		
 			'color: ' + this.color + '<br/>' +
 			'color: ' + this.color + '<br/>' +
+			'opacity: ' + this.opacity + '<br/>' +
 			'map: ' + this.map + '<br/>' +
 			'map: ' + this.map + '<br/>' +
 
 
 			'light_map: ' + this.light_map + '<br/>' +
 			'light_map: ' + this.light_map + '<br/>' +
@@ -89,13 +101,15 @@ THREE.MeshBasicMaterial.prototype = {
 			'reflectivity: ' + this.reflectivity + '<br/>' +
 			'reflectivity: ' + this.reflectivity + '<br/>' +
 			'refraction_ratio: ' + this.refraction_ratio + '<br/>' +
 			'refraction_ratio: ' + this.refraction_ratio + '<br/>' +
 
 
-			'opacity: ' + this.opacity + '<br/>' +
 			'blending: ' + this.blending + '<br/>' +
 			'blending: ' + this.blending + '<br/>' +
+			'depth_test: ' + this.depth_test + '<br/>' +
 
 
 			'wireframe: ' + this.wireframe + '<br/>' +
 			'wireframe: ' + this.wireframe + '<br/>' +
 			'wireframe_linewidth: ' + this.wireframe_linewidth +'<br/>' +
 			'wireframe_linewidth: ' + this.wireframe_linewidth +'<br/>' +
 			'wireframe_linecap: ' + this.wireframe_linecap +'<br/>' +
 			'wireframe_linecap: ' + this.wireframe_linecap +'<br/>' +
 			'wireframe_linejoin: ' + this.wireframe_linejoin +'<br/>' +
 			'wireframe_linejoin: ' + this.wireframe_linejoin +'<br/>' +
+			
+			'vertex_colors: ' + this.vertex_colors + '<br/>' +
 			')';
 			')';
 
 
 	}
 	}

+ 33 - 8
src/materials/MeshDepthMaterial.js

@@ -1,28 +1,42 @@
 /**
 /**
  * @author mr.doob / http://mrdoob.com/
  * @author mr.doob / http://mrdoob.com/
+ * @author alteredq / http://alteredqualia.com/
  *
  *
  * parameters = {
  * parameters = {
  *  opacity: <float>,
  *  opacity: <float>,
- *  blending: THREE.NormalBlending
+ 
+ *  blending: THREE.NormalBlending,
+ *  depth_test: <bool>,
+ 
+ *  wireframe: <boolean>,
+ *  wireframe_linewidth: <float>
  * } 
  * } 
  */
  */
 
 
 THREE.MeshDepthMaterial = function ( parameters ) {
 THREE.MeshDepthMaterial = function ( parameters ) {
 
 
-	this.opacity = 1;
-	this.shading = THREE.SmoothShading;
+	this.id = THREE.MeshDepthMaterialCounter.value ++;
+	
+	this.opacity = 1.0;
+	
+	this.shading = THREE.SmoothShading; // doesn't really apply here, normals are not used
 	this.blending = THREE.NormalBlending;
 	this.blending = THREE.NormalBlending;
-
+	this.depth_test = true;
+	
 	this.wireframe = false;
 	this.wireframe = false;
-	this.wireframe_linewidth = 1;
-	this.wireframe_linecap = 'round';
-	this.wireframe_linejoin = 'round';
+	this.wireframe_linewidth = 1.0;
 
 
 	if ( parameters ) {
 	if ( parameters ) {
 
 
 		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
 		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
+		
+		if ( parameters.shading !== undefined ) this.shading  = parameters.shading;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
+		if ( parameters.depth_test !== undefined ) this.depth_test = parameters.depth_test;
 
 
+		if ( parameters.wireframe !== undefined ) this.wireframe = parameters.wireframe;
+		if ( parameters.wireframe_linewidth !== undefined ) this.wireframe_linewidth = parameters.wireframe_linewidth;
+		
 	}
 	}
 
 
 };
 };
@@ -31,8 +45,19 @@ THREE.MeshDepthMaterial.prototype = {
 
 
 	toString: function () {
 	toString: function () {
 
 
-		return 'THREE.MeshDepthMaterial';
+		return 'THREE.MeshDepthMaterial (<br/>' +
+			'id: ' + this.id + '<br/>' +
+		
+			'opacity: ' + this.opacity + '<br/>' +
+			'blending: ' + this.blending + '<br/>' +
+			'depth_test: ' + this.depth_test + '<br/>' +
+		
+			'wireframe: ' + this.wireframe + '<br/>' +
+			'wireframe_linewidth: ' + this.wireframe_linewidth + '<br/>' +
+		')';
 
 
 	}
 	}
 
 
 };
 };
+
+THREE.MeshDepthMaterialCounter = { value: 0 };

+ 27 - 11
src/materials/MeshLambertMaterial.js

@@ -4,6 +4,7 @@
  *
  *
  * parameters = {
  * parameters = {
  *  color: <hex>,
  *  color: <hex>,
+ *  opacity: <float>,
  *  map: new THREE.Texture( <Image> ),
  *  map: new THREE.Texture( <Image> ),
  
  
  *  light_map: new THREE.Texture( <Image> ),
  *  light_map: new THREE.Texture( <Image> ),
@@ -13,11 +14,14 @@
  *  reflectivity: <float>,
  *  reflectivity: <float>,
  *  refraction_ratio: <float>,
  *  refraction_ratio: <float>,
  
  
- *  opacity: <float>,
  *  shading: THREE.SmoothShading,
  *  shading: THREE.SmoothShading,
  *  blending: THREE.NormalBlending,
  *  blending: THREE.NormalBlending,
+ *  depth_test: <bool>,
+ 
  *  wireframe: <boolean>,
  *  wireframe: <boolean>,
- *  wireframe_linewidth: <float>
+ *  wireframe_linewidth: <float>,
+ 
+ *  vertex_colors: <bool>
  * }
  * }
  */
  */
 
 
@@ -26,29 +30,33 @@ THREE.MeshLambertMaterial = function ( parameters ) {
 	this.id = THREE.MeshLambertMaterialCounter.value ++;
 	this.id = THREE.MeshLambertMaterialCounter.value ++;
 
 
 	this.color = new THREE.Color( 0xffffff );
 	this.color = new THREE.Color( 0xffffff );
+	this.opacity = 1.0;
 	this.map = null;
 	this.map = null;
 
 
 	this.light_map = null;
 	this.light_map = null;
 	
 	
 	this.env_map = null;
 	this.env_map = null;
 	this.combine = THREE.MultiplyOperation;
 	this.combine = THREE.MultiplyOperation;
-	this.reflectivity = 1;
+	this.reflectivity = 1.0;
 	this.refraction_ratio = 0.98;
 	this.refraction_ratio = 0.98;
 
 
-	this.fog = true;
+	this.fog = true; // implemented just in WebGLRenderer2
 
 
-	this.opacity = 1;
 	this.shading = THREE.SmoothShading;
 	this.shading = THREE.SmoothShading;
 	this.blending = THREE.NormalBlending;
 	this.blending = THREE.NormalBlending;
+	this.depth_test = true;
 
 
 	this.wireframe = false;
 	this.wireframe = false;
-	this.wireframe_linewidth = 1;
-	this.wireframe_linecap = 'round';
-	this.wireframe_linejoin = 'round';
+	this.wireframe_linewidth = 1.0;
+	this.wireframe_linecap = 'round';	// implemented just in CanvasRenderer
+	this.wireframe_linejoin = 'round';	// implemented just in CanvasRenderer
 
 
+	this.vertex_colors = false;
+	
 	if ( parameters ) {
 	if ( parameters ) {
 
 
 		if ( parameters.color !== undefined ) this.color.setHex( parameters.color );
 		if ( parameters.color !== undefined ) this.color.setHex( parameters.color );
+		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
 		if ( parameters.map !== undefined ) this.map = parameters.map;
 		if ( parameters.map !== undefined ) this.map = parameters.map;
 
 
 		if ( parameters.light_map !== undefined ) this.light_map = parameters.light_map;
 		if ( parameters.light_map !== undefined ) this.light_map = parameters.light_map;
@@ -60,15 +68,17 @@ THREE.MeshLambertMaterial = function ( parameters ) {
 
 
 		if ( parameters.fog !== undefined ) this.fog  = parameters.fog;
 		if ( parameters.fog !== undefined ) this.fog  = parameters.fog;
 
 
-		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
 		if ( parameters.shading !== undefined ) this.shading = parameters.shading;
 		if ( parameters.shading !== undefined ) this.shading = parameters.shading;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
-
+		if ( parameters.depth_test !== undefined ) this.depth_test = parameters.depth_test;
+		
 		if ( parameters.wireframe !== undefined ) this.wireframe = parameters.wireframe;
 		if ( parameters.wireframe !== undefined ) this.wireframe = parameters.wireframe;
 		if ( parameters.wireframe_linewidth !== undefined ) this.wireframe_linewidth = parameters.wireframe_linewidth;
 		if ( parameters.wireframe_linewidth !== undefined ) this.wireframe_linewidth = parameters.wireframe_linewidth;
 		if ( parameters.wireframe_linecap !== undefined ) this.wireframe_linecap = parameters.wireframe_linecap;
 		if ( parameters.wireframe_linecap !== undefined ) this.wireframe_linecap = parameters.wireframe_linecap;
 		if ( parameters.wireframe_linejoin !== undefined ) this.wireframe_linejoin = parameters.wireframe_linejoin;
 		if ( parameters.wireframe_linejoin !== undefined ) this.wireframe_linejoin = parameters.wireframe_linejoin;
 
 
+		if ( parameters.vertex_colors !== undefined ) this.vertex_colors = parameters.vertex_colors;
+		
 	}
 	}
 
 
 };
 };
@@ -79,22 +89,28 @@ THREE.MeshLambertMaterial.prototype = {
 
 
 		return 'THREE.MeshLambertMaterial (<br/>' +
 		return 'THREE.MeshLambertMaterial (<br/>' +
 			'id: ' + this.id + '<br/>' +
 			'id: ' + this.id + '<br/>' +
+		
 			'color: ' + this.color + '<br/>' +
 			'color: ' + this.color + '<br/>' +
+			'opacity: ' + this.opacity + '<br/>' +
 			'map: ' + this.map + '<br/>' +
 			'map: ' + this.map + '<br/>' +
+		
+			'light_map: ' + this.light_map + '<br/>' +
 
 
 			'env_map: ' + this.env_map + '<br/>' +
 			'env_map: ' + this.env_map + '<br/>' +
 			'combine: ' + this.combine + '<br/>' +
 			'combine: ' + this.combine + '<br/>' +
 			'reflectivity: ' + this.reflectivity + '<br/>' +
 			'reflectivity: ' + this.reflectivity + '<br/>' +
 			'refraction_ratio: ' + this.refraction_ratio + '<br/>' +
 			'refraction_ratio: ' + this.refraction_ratio + '<br/>' +
 
 
-			'opacity: ' + this.opacity + '<br/>' +
 			'shading: ' + this.shading + '<br/>' +
 			'shading: ' + this.shading + '<br/>' +
 			'blending: ' + this.blending + '<br/>' +
 			'blending: ' + this.blending + '<br/>' +
+			'depth_test: ' + this.depth_test + '<br/>' +
 
 
 			'wireframe: ' + this.wireframe + '<br/>' +
 			'wireframe: ' + this.wireframe + '<br/>' +
 			'wireframe_linewidth: ' + this.wireframe_linewidth +'<br/>' +
 			'wireframe_linewidth: ' + this.wireframe_linewidth +'<br/>' +
 			'wireframe_linecap: ' + this.wireframe_linecap +'<br/>' +
 			'wireframe_linecap: ' + this.wireframe_linecap +'<br/>' +
 			'wireframe_linejoin: ' + this.wireframe_linejoin +'<br/>' +
 			'wireframe_linejoin: ' + this.wireframe_linejoin +'<br/>' +
+			
+			'vertex_colors: ' + this.vertex_colors + '<br/>' +
 			' )';
 			' )';
 
 
 	}
 	}

+ 32 - 4
src/materials/MeshNormalMaterial.js

@@ -3,23 +3,40 @@
  *
  *
  * parameters = {
  * parameters = {
  *  opacity: <float>,
  *  opacity: <float>,
+ 
  *  shading: THREE.FlatShading,
  *  shading: THREE.FlatShading,
- *  blending: THREE.NormalBlending
+ *  blending: THREE.NormalBlending,
+ *  depth_test: <bool>,
+ 
+ *  wireframe: <boolean>,
+ *  wireframe_linewidth: <float>
  * }
  * }
  */
  */
 
 
 THREE.MeshNormalMaterial = function ( parameters ) {
 THREE.MeshNormalMaterial = function ( parameters ) {
 
 
-	this.opacity = 1;
+	this.id = THREE.MeshNormalMaterialCounter.value ++;
+	
+	this.opacity = 1.0;
+	
 	this.shading = THREE.FlatShading;
 	this.shading = THREE.FlatShading;
 	this.blending = THREE.NormalBlending;
 	this.blending = THREE.NormalBlending;
+	this.depth_test = true;
 
 
+	this.wireframe = false;
+	this.wireframe_linewidth = 1.0;
+	
 	if ( parameters ) {
 	if ( parameters ) {
 
 
 		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
 		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
+		
 		if ( parameters.shading !== undefined ) this.shading  = parameters.shading;
 		if ( parameters.shading !== undefined ) this.shading  = parameters.shading;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
+		if ( parameters.depth_test !== undefined ) this.depth_test = parameters.depth_test;
 
 
+		if ( parameters.wireframe !== undefined ) this.wireframe = parameters.wireframe;
+		if ( parameters.wireframe_linewidth !== undefined ) this.wireframe_linewidth = parameters.wireframe_linewidth;
+		
 	}
 	}
 
 
 };
 };
@@ -27,9 +44,20 @@ THREE.MeshNormalMaterial = function ( parameters ) {
 THREE.MeshNormalMaterial.prototype = {
 THREE.MeshNormalMaterial.prototype = {
 
 
 	toString: function () {
 	toString: function () {
-
-		return 'THREE.MeshNormalMaterial';
+		
+		return 'THREE.MeshNormalMaterial (<br/>' +
+			'id: ' + this.id + '<br/>' +
+		
+			'opacity: ' + this.opacity + '<br/>' +
+			'blending: ' + this.blending + '<br/>' +
+			'depth_test: ' + this.depth_test + '<br/>' +
+		
+			'wireframe: ' + this.wireframe + '<br/>' +
+			'wireframe_linewidth: ' + this.wireframe_linewidth + '<br/>' +
+		')';
 
 
 	}
 	}
 
 
 };
 };
+
+THREE.MeshNormalMaterialCounter = { value: 0 };

+ 27 - 16
src/materials/MeshPhongMaterial.js

@@ -7,9 +7,9 @@
  *  ambient: <hex>,
  *  ambient: <hex>,
  *  specular: <hex>,
  *  specular: <hex>,
  *  shininess: <float>,
  *  shininess: <float>,
+ *  opacity: <float>,
 
 
  *  map: new THREE.Texture( <Image> ),
  *  map: new THREE.Texture( <Image> ),
- *  specular_map: new THREE.Texture( <Image> ),
 
 
  *  light_map: new THREE.Texture( <Image> ),
  *  light_map: new THREE.Texture( <Image> ),
 
 
@@ -18,11 +18,14 @@
  *  reflectivity: <float>,
  *  reflectivity: <float>,
  *  refraction_ratio: <float>,
  *  refraction_ratio: <float>,
 
 
- *  opacity: <float>,
  *  shading: THREE.SmoothShading,
  *  shading: THREE.SmoothShading,
  *  blending: THREE.NormalBlending,
  *  blending: THREE.NormalBlending,
+ *  depth_test: <bool>,
+ 
  *  wireframe: <boolean>,
  *  wireframe: <boolean>,
- *  wireframe_linewidth: <float>
+ *  wireframe_linewidth: <float>,
+ 
+ *  vertex_colors: <bool>
  * }
  * }
  */
  */
 
 
@@ -33,28 +36,30 @@ THREE.MeshPhongMaterial = function ( parameters ) {
 	this.color = new THREE.Color( 0xffffff );
 	this.color = new THREE.Color( 0xffffff );
 	this.ambient = new THREE.Color( 0x050505 );
 	this.ambient = new THREE.Color( 0x050505 );
 	this.specular = new THREE.Color( 0x111111 );
 	this.specular = new THREE.Color( 0x111111 );
-	this.shininess = 30;
+	this.shininess = 30.0;
+	this.opacity = 1.0;
 
 
 	this.map = null;
 	this.map = null;
-	this.specular_map = null;
 
 
 	this.light_map = null;
 	this.light_map = null;
 	
 	
 	this.env_map = null;
 	this.env_map = null;
 	this.combine = THREE.MultiplyOperation;
 	this.combine = THREE.MultiplyOperation;
-	this.reflectivity = 1;
+	this.reflectivity = 1.0;
 	this.refraction_ratio = 0.98;
 	this.refraction_ratio = 0.98;
 
 
-	this.fog = true;
+	this.fog = true; // implemented just in WebGLRenderer2
 
 
-	this.opacity = 1;
 	this.shading = THREE.SmoothShading;
 	this.shading = THREE.SmoothShading;
 	this.blending = THREE.NormalBlending;
 	this.blending = THREE.NormalBlending;
-
+	this.depth_test = true;
+	
 	this.wireframe = false;
 	this.wireframe = false;
-	this.wireframe_linewidth = 1;
-	this.wireframe_linecap = 'round';
-	this.wireframe_linejoin = 'round';
+	this.wireframe_linewidth = 1.0;
+	this.wireframe_linecap = 'round';	// implemented just in CanvasRenderer
+	this.wireframe_linejoin = 'round';	// implemented just in CanvasRenderer
+	
+	this.vertex_colors = false;
 
 
 	if ( parameters ) {
 	if ( parameters ) {
 
 
@@ -62,11 +67,11 @@ THREE.MeshPhongMaterial = function ( parameters ) {
 		if ( parameters.ambient !== undefined ) this.ambient = new THREE.Color( parameters.ambient );
 		if ( parameters.ambient !== undefined ) this.ambient = new THREE.Color( parameters.ambient );
 		if ( parameters.specular !== undefined ) this.specular = new THREE.Color( parameters.specular );
 		if ( parameters.specular !== undefined ) this.specular = new THREE.Color( parameters.specular );
 		if ( parameters.shininess !== undefined ) this.shininess = parameters.shininess;
 		if ( parameters.shininess !== undefined ) this.shininess = parameters.shininess;
+		if ( parameters.opacity !== undefined ) this.opacity = parameters.opacity;
 
 
 		if ( parameters.light_map !== undefined ) this.light_map = parameters.light_map;
 		if ( parameters.light_map !== undefined ) this.light_map = parameters.light_map;
 		
 		
 		if ( parameters.map !== undefined ) this.map = parameters.map;
 		if ( parameters.map !== undefined ) this.map = parameters.map;
-		if ( parameters.specular_map !== undefined ) this.specular_map = parameters.specular_map;
 
 
 		if ( parameters.env_map !== undefined ) this.env_map = parameters.env_map;
 		if ( parameters.env_map !== undefined ) this.env_map = parameters.env_map;
 		if ( parameters.combine !== undefined ) this.combine = parameters.combine;
 		if ( parameters.combine !== undefined ) this.combine = parameters.combine;
@@ -75,14 +80,16 @@ THREE.MeshPhongMaterial = function ( parameters ) {
 
 
 		if ( parameters.fog !== undefined ) this.fog  = parameters.fog;
 		if ( parameters.fog !== undefined ) this.fog  = parameters.fog;
 
 
-		if ( parameters.opacity !== undefined ) this.opacity = parameters.opacity;
 		if ( parameters.shading !== undefined ) this.shading = parameters.shading;
 		if ( parameters.shading !== undefined ) this.shading = parameters.shading;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
+		if ( parameters.depth_test !== undefined ) this.depth_test = parameters.depth_test;
 
 
 		if ( parameters.wireframe !== undefined ) this.wireframe = parameters.wireframe;
 		if ( parameters.wireframe !== undefined ) this.wireframe = parameters.wireframe;
 		if ( parameters.wireframe_linewidth !== undefined ) this.wireframe_linewidth = parameters.wireframe_linewidth;
 		if ( parameters.wireframe_linewidth !== undefined ) this.wireframe_linewidth = parameters.wireframe_linewidth;
 		if ( parameters.wireframe_linecap !== undefined ) this.wireframe_linecap = parameters.wireframe_linecap;
 		if ( parameters.wireframe_linecap !== undefined ) this.wireframe_linecap = parameters.wireframe_linecap;
 		if ( parameters.wireframe_linejoin !== undefined ) this.wireframe_linejoin = parameters.wireframe_linejoin;
 		if ( parameters.wireframe_linejoin !== undefined ) this.wireframe_linejoin = parameters.wireframe_linejoin;
+		
+		if ( parameters.vertex_colors !== undefined ) this.vertex_colors = parameters.vertex_colors;
 
 
 	}
 	}
 
 
@@ -94,26 +101,30 @@ THREE.MeshPhongMaterial.prototype = {
 
 
 		return 'THREE.MeshPhongMaterial (<br/>' +
 		return 'THREE.MeshPhongMaterial (<br/>' +
 			'id: ' + this.id + '<br/>' +
 			'id: ' + this.id + '<br/>' +
+		
 			'color: ' + this.color + '<br/>' +
 			'color: ' + this.color + '<br/>' +
 			'ambient: ' + this.ambient + '<br/>' +
 			'ambient: ' + this.ambient + '<br/>' +
 			'specular: ' + this.specular + '<br/>' +
 			'specular: ' + this.specular + '<br/>' +
 			'shininess: ' + this.shininess + '<br/>' +
 			'shininess: ' + this.shininess + '<br/>' +
+			'opacity: ' + this.opacity + '<br/>' +
 
 
 			'map: ' + this.map + '<br/>' +
 			'map: ' + this.map + '<br/>' +
-			'specular_map: ' + this.specular_map + '<br/>' +
 
 
 			'env_map: ' + this.env_map + '<br/>' +
 			'env_map: ' + this.env_map + '<br/>' +
 			'combine: ' + this.combine + '<br/>' +
 			'combine: ' + this.combine + '<br/>' +
 			'reflectivity: ' + this.reflectivity + '<br/>' +
 			'reflectivity: ' + this.reflectivity + '<br/>' +
 			'refraction_ratio: ' + this.refraction_ratio + '<br/>' +
 			'refraction_ratio: ' + this.refraction_ratio + '<br/>' +
 
 
-			'opacity: ' + this.opacity + '<br/>' +
 			'shading: ' + this.shading + '<br/>' +
 			'shading: ' + this.shading + '<br/>' +
+			'blending: ' + this.blending + '<br/>' +
+			'depth_test: ' + this.depth_test + '<br/>' +
 
 
 			'wireframe: ' + this.wireframe + '<br/>' +
 			'wireframe: ' + this.wireframe + '<br/>' +
 			'wireframe_linewidth: ' + this.wireframe_linewidth + '<br/>' +
 			'wireframe_linewidth: ' + this.wireframe_linewidth + '<br/>' +
 			'wireframe_linecap: ' + this.wireframe_linecap +'<br/>' +
 			'wireframe_linecap: ' + this.wireframe_linecap +'<br/>' +
 			'wireframe_linejoin: ' + this.wireframe_linejoin +'<br/>' +
 			'wireframe_linejoin: ' + this.wireframe_linejoin +'<br/>' +
+			
+			'vertex_colors: ' + this.vertex_colors + '<br/>' +
 			')';
 			')';
 
 
 	}
 	}

+ 24 - 5
src/materials/MeshShaderMaterial.js

@@ -4,11 +4,17 @@
  * parameters = {
  * parameters = {
  *  fragment_shader: <string>,
  *  fragment_shader: <string>,
  *  vertex_shader: <string>,
  *  vertex_shader: <string>,
+ 
  *  uniforms: { "parameter1": { type: "f", value: 1.0 }, "parameter2": { type: "i" value2: 2 } },
  *  uniforms: { "parameter1": { type: "f", value: 1.0 }, "parameter2": { type: "i" value2: 2 } },
+ 
  *  shading: THREE.SmoothShading,
  *  shading: THREE.SmoothShading,
  *  blending: THREE.NormalBlending,
  *  blending: THREE.NormalBlending,
+ *  depth_test: <bool>,
+ 
  *  wireframe: <boolean>,
  *  wireframe: <boolean>,
- *  wireframe_linewidth: <float>
+ *  wireframe_linewidth: <float>,
+ 
+ *  vertex_colors: <bool>
  * }
  * }
  */
  */
 
 
@@ -20,14 +26,18 @@ THREE.MeshShaderMaterial = function ( parameters ) {
 	this.vertex_shader = "void main() {}";
 	this.vertex_shader = "void main() {}";
 	this.uniforms = {};
 	this.uniforms = {};
 
 
-	this.opacity = 1;
+	this.opacity = 1.0; // set to < 1.0 to renderer in transparent batch
+	
 	this.shading = THREE.SmoothShading;
 	this.shading = THREE.SmoothShading;
 	this.blending = THREE.NormalBlending;
 	this.blending = THREE.NormalBlending;
+	this.depth_test = true;
 
 
 	this.wireframe = false;
 	this.wireframe = false;
-	this.wireframe_linewidth = 1;
-	this.wireframe_linecap = 'round';
-	this.wireframe_linejoin = 'round';
+	this.wireframe_linewidth = 1.0;
+	this.wireframe_linecap = 'round';	// doesn't make sense here
+	this.wireframe_linejoin = 'round';  // not implemented in WebGLRenderer (and this material doesn't make sense in CanvasRenderer)
+
+	this.vertex_colors = false; // must set this if shader wants to use "color" attribute stream
 
 
 	if ( parameters ) {
 	if ( parameters ) {
 
 
@@ -36,13 +46,18 @@ THREE.MeshShaderMaterial = function ( parameters ) {
 
 
 		if ( parameters.uniforms !== undefined ) this.uniforms = parameters.uniforms;
 		if ( parameters.uniforms !== undefined ) this.uniforms = parameters.uniforms;
 
 
+		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
+		
 		if ( parameters.shading !== undefined ) this.shading = parameters.shading;
 		if ( parameters.shading !== undefined ) this.shading = parameters.shading;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
+		if ( parameters.depth_test !== undefined ) this.depth_test = parameters.depth_test;
 
 
 		if ( parameters.wireframe !== undefined ) this.wireframe = parameters.wireframe;
 		if ( parameters.wireframe !== undefined ) this.wireframe = parameters.wireframe;
 		if ( parameters.wireframe_linewidth !== undefined ) this.wireframe_linewidth = parameters.wireframe_linewidth;
 		if ( parameters.wireframe_linewidth !== undefined ) this.wireframe_linewidth = parameters.wireframe_linewidth;
 		if ( parameters.wireframe_linecap !== undefined ) this.wireframe_linecap = parameters.wireframe_linecap;
 		if ( parameters.wireframe_linecap !== undefined ) this.wireframe_linecap = parameters.wireframe_linecap;
 		if ( parameters.wireframe_linejoin !== undefined ) this.wireframe_linejoin = parameters.wireframe_linejoin;
 		if ( parameters.wireframe_linejoin !== undefined ) this.wireframe_linejoin = parameters.wireframe_linejoin;
+		
+		if ( parameters.vertex_colors !== undefined ) this.vertex_colors = parameters.vertex_colors;
 
 
 	}
 	}
 
 
@@ -56,10 +71,14 @@ THREE.MeshShaderMaterial.prototype = {
 			'id: ' + this.id + '<br/>' +
 			'id: ' + this.id + '<br/>' +
 
 
 			'blending: ' + this.blending + '<br/>' +
 			'blending: ' + this.blending + '<br/>' +
+			'depth_test: ' + this.depth_test + '<br/>' +
+		
 			'wireframe: ' + this.wireframe + '<br/>' +
 			'wireframe: ' + this.wireframe + '<br/>' +
 			'wireframe_linewidth: ' + this.wireframe_linewidth +'<br/>' +
 			'wireframe_linewidth: ' + this.wireframe_linewidth +'<br/>' +
 			'wireframe_linecap: ' + this.wireframe_linecap +'<br/>' +
 			'wireframe_linecap: ' + this.wireframe_linecap +'<br/>' +
 			'wireframe_linejoin: ' + this.wireframe_linejoin +'<br/>' +
 			'wireframe_linejoin: ' + this.wireframe_linejoin +'<br/>' +
+		
+			'vertex_colors: ' + this.vertex_colors + '<br/>' +
 			')';
 			')';
 
 
 	}
 	}

+ 31 - 8
src/materials/ParticleBasicMaterial.js

@@ -1,34 +1,49 @@
 /**
 /**
  * @author mr.doob / http://mrdoob.com/
  * @author mr.doob / http://mrdoob.com/
+ * @author alteredq / http://alteredqualia.com/
  *
  *
  * parameters = {
  * parameters = {
  *  color: <hex>,
  *  color: <hex>,
- *  map: new THREE.Texture( <Image> ),
  *  opacity: <float>,
  *  opacity: <float>,
- *  blending: THREE.NormalBlending
+ *  map: new THREE.Texture( <Image> ),
+ 
+ *  size: <float>,
+ 
+ *  blending: THREE.NormalBlending,
+ *  depth_test: <bool>,
+ 
+ *  vertex_colors: <bool>
  * }
  * }
  */
  */
 
 
 THREE.ParticleBasicMaterial = function ( parameters ) {
 THREE.ParticleBasicMaterial = function ( parameters ) {
 
 
+	this.id = THREE.ParticleBasicMaterialCounter.value ++;
+	
 	this.color = new THREE.Color( 0xffffff );
 	this.color = new THREE.Color( 0xffffff );
+	this.opacity = 1.0;
 	this.map = null;
 	this.map = null;
-	this.opacity = 1;
-	this.size = 1;
 	
 	
-	this.vertex_colors = false;
+	this.size = 1.0;
 	
 	
 	this.blending = THREE.NormalBlending;
 	this.blending = THREE.NormalBlending;
+	this.depth_test = true;
+
+	this.offset = new THREE.Vector2(); // TODO: expose to parameters (implemented just in CanvasRenderer)
 
 
-	this.offset = new THREE.Vector2(); // TODO: expose to parameters
+	this.vertex_colors = false;
 
 
 	if ( parameters ) {
 	if ( parameters ) {
 
 
 		if ( parameters.color !== undefined ) this.color.setHex( parameters.color );
 		if ( parameters.color !== undefined ) this.color.setHex( parameters.color );
-		if ( parameters.map !== undefined ) this.map = parameters.map;
 		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
 		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
+		if ( parameters.map !== undefined ) this.map = parameters.map;
+		
 		if ( parameters.size !== undefined ) this.size = parameters.size;
 		if ( parameters.size !== undefined ) this.size = parameters.size;
+		
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
+		if ( parameters.depth_test !== undefined ) this.depth_test = parameters.depth_test;
+		
 		if ( parameters.vertex_colors !== undefined ) this.vertex_colors = parameters.vertex_colors;
 		if ( parameters.vertex_colors !== undefined ) this.vertex_colors = parameters.vertex_colors;
 
 
 	}
 	}
@@ -40,14 +55,22 @@ THREE.ParticleBasicMaterial.prototype = {
 	toString: function () {
 	toString: function () {
 
 
 		return 'THREE.ParticleBasicMaterial (<br/>' +
 		return 'THREE.ParticleBasicMaterial (<br/>' +
+			'id: ' + this.id + '<br/>' +
+		
 			'color: ' + this.color + '<br/>' +
 			'color: ' + this.color + '<br/>' +
-			'map: ' + this.map + '<br/>' +
 			'opacity: ' + this.opacity + '<br/>' +
 			'opacity: ' + this.opacity + '<br/>' +
+			'map: ' + this.map + '<br/>' +
+		
 			'size: ' + this.size + '<br/>' +
 			'size: ' + this.size + '<br/>' +
+		
 			'blending: ' + this.blending + '<br/>' +
 			'blending: ' + this.blending + '<br/>' +
+			'depth_test: ' + this.depth_test + '<br/>' +
+		
 			'vertex_colors: ' + this.vertex_colors + '<br/>' +
 			'vertex_colors: ' + this.vertex_colors + '<br/>' +
 			')';
 			')';
 
 
 	}
 	}
 
 
 };
 };
+
+THREE.ParticleBasicMaterialCounter = { value: 0 };

+ 88 - 37
src/renderers/WebGLRenderer.js

@@ -1147,9 +1147,16 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			material.uniforms.mNear.value = camera.near;
 			material.uniforms.mNear.value = camera.near;
 			material.uniforms.mFar.value = camera.far;
 			material.uniforms.mFar.value = camera.far;
+			material.uniforms.opacity.value = material.opacity;
 			
 			
 		}
 		}
-	
+
+		if ( material instanceof THREE.MeshNormalMaterial ) {
+
+			material.uniforms.opacity.value = material.opacity;
+			
+		}
+		
 		setUniforms( program, material.uniforms );
 		setUniforms( program, material.uniforms );
 
 
 		return program;
 		return program;
@@ -1313,6 +1320,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 					if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) {
 					if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) {
 
 
 						this.setBlending( material.blending );
 						this.setBlending( material.blending );
+						this.setDepthTest( material.depth_test );
+						
 						this.renderBuffer( camera, lights, fog, material, geometryChunk, object );
 						this.renderBuffer( camera, lights, fog, material, geometryChunk, object );
 
 
 					}
 					}
@@ -1325,6 +1334,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 				if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) {
 				if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) {
 
 
 					this.setBlending( material.blending );
 					this.setBlending( material.blending );
+					this.setDepthTest( material.depth_test );
+					
 					this.renderBuffer( camera, lights, fog, material, geometryChunk, object );
 					this.renderBuffer( camera, lights, fog, material, geometryChunk, object );
 
 
 				}
 				}
@@ -1346,6 +1357,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 			if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) {
 			if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) {
 
 
 				this.setBlending( material.blending );
 				this.setBlending( material.blending );
+				this.setDepthTest( material.depth_test );
+				
 				program = this.setProgram( camera, lights, fog, material, object );
 				program = this.setProgram( camera, lights, fog, material, object );
 				
 				
 				object.render( function( object ) { renderBufferImmediate( object, program ); } );
 				object.render( function( object ) { renderBufferImmediate( object, program ); } );
@@ -1356,9 +1369,34 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	};
 	};
 	
 	
+	function setObjectFaces( object ) {
+		
+		if( object.doubleSided ) {
+
+			_gl.disable( _gl.CULL_FACE );
+
+		} else {
+
+			_gl.enable( _gl.CULL_FACE );
+
+			if( object.flipSided ) {
+
+				_gl.frontFace( _gl.CW );
+
+			}
+			else {
+
+				_gl.frontFace( _gl.CCW );
+
+			}
+
+		}
+		
+	};
+	
 	this.render = function( scene, camera, renderTarget, clear ) {
 	this.render = function( scene, camera, renderTarget, clear ) {
 
 
-		var o, ol, webGLObject, object, buffer,
+		var o, ol, oil, webGLObject, object, buffer,
 			lights = scene.lights,
 			lights = scene.lights,
 			fog = scene.fog,
 			fog = scene.fog,
 			ol;
 			ol;
@@ -1391,33 +1429,26 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			if ( object.visible ) {
 			if ( object.visible ) {
 				
 				
-				object.autoUpdateMatrix && object.updateMatrix();				
-				
-				if( object.doubleSided ) {
-
-					_gl.disable( _gl.CULL_FACE );
-
-				} else {
-
-					_gl.enable( _gl.CULL_FACE );
-
-					if( object.flipSided ) {
-
-						_gl.frontFace( _gl.CW );
-
-					}
-					else {
-
-						_gl.frontFace( _gl.CCW );
-
-					}
-
-				}
+				object.autoUpdateMatrix && object.updateMatrix();
+			
+			}
+		
+		}
+		
+		oil = scene.__webGLObjectsImmediate.length;
+		
+		for ( o = 0; o < oil; o++ ) {
+			
+			webGLObject = scene.__webGLObjectsImmediate[ o ];
+			object = webGLObject.object;
+			
+			if ( object.visible ) {
+			
+				object.autoUpdateMatrix && object.updateMatrix();
 			
 			
 			}
 			}
 		
 		
 		}
 		}
-
 
 
 		// opaque pass
 		// opaque pass
 
 
@@ -1429,8 +1460,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 			buffer = webGLObject.buffer;
 			buffer = webGLObject.buffer;
 
 
 			if ( object.visible ) {
 			if ( object.visible ) {
-			
-				object.autoUpdateMatrix && object.updateMatrix();
+				
+				setObjectFaces( object );
 				
 				
 				this.setupMatrices( object, camera );
 				this.setupMatrices( object, camera );
 				this.renderPass( camera, lights, fog, object, buffer, THREE.NormalBlending, false );
 				this.renderPass( camera, lights, fog, object, buffer, THREE.NormalBlending, false );
@@ -1448,7 +1479,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			
 			
 			if ( object.visible ) {
 			if ( object.visible ) {
 			
 			
-				object.autoUpdateMatrix && object.updateMatrix();
+				setObjectFaces( object );
 				
 				
 				this.setupMatrices( object, camera );
 				this.setupMatrices( object, camera );
 				this.renderPassImmediate( camera, lights, fog, object, THREE.NormalBlending, false );
 				this.renderPassImmediate( camera, lights, fog, object, THREE.NormalBlending, false );
@@ -1468,6 +1499,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			if ( object.visible ) {
 			if ( object.visible ) {
 
 
+				setObjectFaces( object );
+				
 				this.setupMatrices( object, camera );
 				this.setupMatrices( object, camera );
 				
 				
 				// opaque blended materials
 				// opaque blended materials
@@ -1501,7 +1534,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			
 			
 			if ( object.visible ) {
 			if ( object.visible ) {
 			
 			
-				object.autoUpdateMatrix && object.updateMatrix();
+				setObjectFaces( object );
 				
 				
 				this.setupMatrices( object, camera );
 				this.setupMatrices( object, camera );
 				this.renderPassImmediate( camera, lights, fog, object, THREE.NormalBlending, true );
 				this.renderPassImmediate( camera, lights, fog, object, THREE.NormalBlending, true );
@@ -1722,6 +1755,20 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	};
 	};
 
 
+	this.setDepthTest = function( test ) {
+		
+		if( test ) {
+			
+			_gl.enable( _gl.DEPTH_TEST );
+			
+		} else {
+			
+			_gl.disable( _gl.DEPTH_TEST );
+			
+		}
+		
+	};
+	
 	this.setBlending = function( blending ) {
 	this.setBlending = function( blending ) {
 
 
 		switch ( blending ) {
 		switch ( blending ) {
@@ -2744,14 +2791,14 @@ THREE.UniformsLib = {
 	common: {
 	common: {
 
 
 	"diffuse" : { type: "c", value: new THREE.Color( 0xeeeeee ) },
 	"diffuse" : { type: "c", value: new THREE.Color( 0xeeeeee ) },
-	"opacity" : { type: "f", value: 1 },
+	"opacity" : { type: "f", value: 1.0 },
 	"map"     : { type: "t", value: 0, texture: null },
 	"map"     : { type: "t", value: 0, texture: null },
 
 
 	"light_map"       : { type: "t", value: 2, texture: null },
 	"light_map"       : { type: "t", value: 2, texture: null },
 
 
 	"env_map" 		  : { type: "t", value: 1, texture: null },
 	"env_map" 		  : { type: "t", value: 1, texture: null },
 	"useRefract"	  : { type: "i", value: 0 },
 	"useRefract"	  : { type: "i", value: 0 },
-	"reflectivity"    : { type: "f", value: 1 },
+	"reflectivity"    : { type: "f", value: 1.0 },
 	"refraction_ratio": { type: "f", value: 0.98 },
 	"refraction_ratio": { type: "f", value: 0.98 },
 	"combine"		  : { type: "i", value: 0 },
 	"combine"		  : { type: "i", value: 0 },
 
 
@@ -2776,8 +2823,8 @@ THREE.UniformsLib = {
 	particle: {
 	particle: {
 
 
 	"psColor"   : { type: "c", value: new THREE.Color( 0xeeeeee ) },
 	"psColor"   : { type: "c", value: new THREE.Color( 0xeeeeee ) },
-	"opacity" : { type: "f", value: 1 },
-	"size" 	  : { type: "f", value: 1 },
+	"opacity" : { type: "f", value: 1.0 },
+	"size" 	  : { type: "f", value: 1.0 },
 	"map"     : { type: "t", value: 0, texture: null },
 	"map"     : { type: "t", value: 0, texture: null },
 
 
 	"fogDensity": { type: "f", value: 0.00025 },
 	"fogDensity": { type: "f", value: 0.00025 },
@@ -2794,18 +2841,21 @@ THREE.ShaderLib = {
 	'depth': {
 	'depth': {
 
 
 		uniforms: { "mNear": { type: "f", value: 1.0 },
 		uniforms: { "mNear": { type: "f", value: 1.0 },
-					"mFar" : { type: "f", value: 2000.0 } },
+					"mFar" : { type: "f", value: 2000.0 },
+					"opacity" : { type: "f", value: 1.0 }					
+				  },
 
 
 		fragment_shader: [
 		fragment_shader: [
 
 
 			"uniform float mNear;",
 			"uniform float mNear;",
 			"uniform float mFar;",
 			"uniform float mFar;",
+			"uniform float opacity;",
 
 
 			"void main() {",
 			"void main() {",
 
 
 				"float depth = gl_FragCoord.z / gl_FragCoord.w;",
 				"float depth = gl_FragCoord.z / gl_FragCoord.w;",
 				"float color = 1.0 - smoothstep( mNear, mFar, depth );",
 				"float color = 1.0 - smoothstep( mNear, mFar, depth );",
-				"gl_FragColor = vec4( vec3( color ), 1.0 );",
+				"gl_FragColor = vec4( vec3( color ), opacity );",
 
 
 			"}"
 			"}"
 
 
@@ -2825,15 +2875,16 @@ THREE.ShaderLib = {
 
 
 	'normal': {
 	'normal': {
 
 
-		uniforms: { },
+		uniforms: { "opacity" : { type: "f", value: 1.0 } },
 
 
 		fragment_shader: [
 		fragment_shader: [
 
 
+			"uniform float opacity;",
 			"varying vec3 vNormal;",
 			"varying vec3 vNormal;",
 
 
 			"void main() {",
 			"void main() {",
 
 
-				"gl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );",
+				"gl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );",
 
 
 			"}"
 			"}"
 
 

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