Browse Source

Changed particles to use drawArrays instead of drawElements.

There shouldn't be performance difference, just less memory used (indices were not used anyways).
alteredq 14 years ago
parent
commit
27ee81d4a1
4 changed files with 351 additions and 378 deletions
  1. 123 124
      build/Three.js
  2. 123 124
      build/ThreeDebug.js
  3. 103 104
      build/ThreeExtras.js
  4. 2 26
      src/renderers/WebGLRenderer.js

+ 123 - 124
build/Three.js

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

+ 123 - 124
build/ThreeDebug.js

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

+ 103 - 104
build/ThreeExtras.js

@@ -25,11 +25,11 @@ THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n
 a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var e=THREE.Matrix4.__tmpVec1,j=THREE.Matrix4.__tmpVec2,g=THREE.Matrix4.__tmpVec3;g.sub(a,c).normalize();e.cross(d,g).normalize();j.cross(g,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);
 this.n31=g.x;this.n32=g.y;this.n33=g.z;this.n34=-g.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,e=a.z,j=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*j;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*j;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*j;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,j=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*j;a.y=this.n21*c+this.n22*d+this.n23*
 e+this.n24*j;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*j;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*j;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,e=a.n12,j=a.n13,g=a.n14,b=a.n21,m=a.n22,k=a.n23,n=a.n24,o=a.n31,
-y=a.n32,v=a.n33,q=a.n34,z=a.n41,B=a.n42,H=a.n43,f=a.n44,p=c.n11,h=c.n12,l=c.n13,t=c.n14,w=c.n21,x=c.n22,u=c.n23,A=c.n24,C=c.n31,E=c.n32,F=c.n33,D=c.n34,I=c.n41,S=c.n42,N=c.n43,X=c.n44;this.n11=d*p+e*w+j*C+g*I;this.n12=d*h+e*x+j*E+g*S;this.n13=d*l+e*u+j*F+g*N;this.n14=d*t+e*A+j*D+g*X;this.n21=b*p+m*w+k*C+n*I;this.n22=b*h+m*x+k*E+n*S;this.n23=b*l+m*u+k*F+n*N;this.n24=b*t+m*A+k*D+n*X;this.n31=o*p+y*w+v*C+q*I;this.n32=o*h+y*x+v*E+q*S;this.n33=o*l+y*u+v*F+q*N;this.n34=o*t+y*A+v*D+q*X;this.n41=z*p+B*w+
-H*C+f*I;this.n42=z*h+B*x+H*E+f*S;this.n43=z*l+B*u+H*F+f*N;this.n44=z*t+B*A+H*D+f*X;return this},multiplyToArray:function(a,c,d){var e=a.n11,j=a.n12,g=a.n13,b=a.n14,m=a.n21,k=a.n22,n=a.n23,o=a.n24,y=a.n31,v=a.n32,q=a.n33,z=a.n34,B=a.n41,H=a.n42,f=a.n43;a=a.n44;var p=c.n11,h=c.n12,l=c.n13,t=c.n14,w=c.n21,x=c.n22,u=c.n23,A=c.n24,C=c.n31,E=c.n32,F=c.n33,D=c.n34,I=c.n41,S=c.n42,N=c.n43;c=c.n44;this.n11=e*p+j*w+g*C+b*I;this.n12=e*h+j*x+g*E+b*S;this.n13=e*l+j*u+g*F+b*N;this.n14=e*t+j*A+g*D+b*c;this.n21=
-m*p+k*w+n*C+o*I;this.n22=m*h+k*x+n*E+o*S;this.n23=m*l+k*u+n*F+o*N;this.n24=m*t+k*A+n*D+o*c;this.n31=y*p+v*w+q*C+z*I;this.n32=y*h+v*x+q*E+z*S;this.n33=y*l+v*u+q*F+z*N;this.n34=y*t+v*A+q*D+z*c;this.n41=B*p+H*w+f*C+a*I;this.n42=B*h+H*x+f*E+a*S;this.n43=B*l+H*u+f*F+a*N;this.n44=B*t+H*A+f*D+a*c;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;
-d[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,j=this.n14,g=this.n21,b=this.n22,m=this.n23,k=this.n24,n=this.n31,o=this.n32,y=this.n33,v=this.n34,q=this.n41,z=this.n42,B=this.n43,H=this.n44,f=a.n11,p=a.n21,h=a.n31,l=a.n41,t=a.n12,w=a.n22,x=a.n32,u=a.n42,A=a.n13,C=a.n23,E=a.n33,F=a.n43,D=a.n14,I=a.n24,S=a.n34;a=a.n44;this.n11=c*f+d*p+e*h+j*l;this.n12=c*t+d*w+e*x+j*u;this.n13=c*A+d*C+e*E+j*F;this.n14=c*D+d*I+e*S+j*a;this.n21=g*f+b*p+m*h+k*l;this.n22=g*t+b*
-w+m*x+k*u;this.n23=g*A+b*C+m*E+k*F;this.n24=g*D+b*I+m*S+k*a;this.n31=n*f+o*p+y*h+v*l;this.n32=n*t+o*w+y*x+v*u;this.n33=n*A+o*C+y*E+v*F;this.n34=n*D+o*I+y*S+v*a;this.n41=q*f+z*p+B*h+H*l;this.n42=q*t+z*w+B*x+H*u;this.n43=q*A+z*C+B*E+H*F;this.n44=q*D+z*I+B*S+H*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},
+y=a.n32,v=a.n33,q=a.n34,z=a.n41,B=a.n42,H=a.n43,f=a.n44,p=c.n11,h=c.n12,l=c.n13,t=c.n14,w=c.n21,x=c.n22,u=c.n23,A=c.n24,C=c.n31,F=c.n32,E=c.n33,D=c.n34,I=c.n41,S=c.n42,N=c.n43,X=c.n44;this.n11=d*p+e*w+j*C+g*I;this.n12=d*h+e*x+j*F+g*S;this.n13=d*l+e*u+j*E+g*N;this.n14=d*t+e*A+j*D+g*X;this.n21=b*p+m*w+k*C+n*I;this.n22=b*h+m*x+k*F+n*S;this.n23=b*l+m*u+k*E+n*N;this.n24=b*t+m*A+k*D+n*X;this.n31=o*p+y*w+v*C+q*I;this.n32=o*h+y*x+v*F+q*S;this.n33=o*l+y*u+v*E+q*N;this.n34=o*t+y*A+v*D+q*X;this.n41=z*p+B*w+
+H*C+f*I;this.n42=z*h+B*x+H*F+f*S;this.n43=z*l+B*u+H*E+f*N;this.n44=z*t+B*A+H*D+f*X;return this},multiplyToArray:function(a,c,d){var e=a.n11,j=a.n12,g=a.n13,b=a.n14,m=a.n21,k=a.n22,n=a.n23,o=a.n24,y=a.n31,v=a.n32,q=a.n33,z=a.n34,B=a.n41,H=a.n42,f=a.n43;a=a.n44;var p=c.n11,h=c.n12,l=c.n13,t=c.n14,w=c.n21,x=c.n22,u=c.n23,A=c.n24,C=c.n31,F=c.n32,E=c.n33,D=c.n34,I=c.n41,S=c.n42,N=c.n43;c=c.n44;this.n11=e*p+j*w+g*C+b*I;this.n12=e*h+j*x+g*F+b*S;this.n13=e*l+j*u+g*E+b*N;this.n14=e*t+j*A+g*D+b*c;this.n21=
+m*p+k*w+n*C+o*I;this.n22=m*h+k*x+n*F+o*S;this.n23=m*l+k*u+n*E+o*N;this.n24=m*t+k*A+n*D+o*c;this.n31=y*p+v*w+q*C+z*I;this.n32=y*h+v*x+q*F+z*S;this.n33=y*l+v*u+q*E+z*N;this.n34=y*t+v*A+q*D+z*c;this.n41=B*p+H*w+f*C+a*I;this.n42=B*h+H*x+f*F+a*S;this.n43=B*l+H*u+f*E+a*N;this.n44=B*t+H*A+f*D+a*c;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;
+d[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,j=this.n14,g=this.n21,b=this.n22,m=this.n23,k=this.n24,n=this.n31,o=this.n32,y=this.n33,v=this.n34,q=this.n41,z=this.n42,B=this.n43,H=this.n44,f=a.n11,p=a.n21,h=a.n31,l=a.n41,t=a.n12,w=a.n22,x=a.n32,u=a.n42,A=a.n13,C=a.n23,F=a.n33,E=a.n43,D=a.n14,I=a.n24,S=a.n34;a=a.n44;this.n11=c*f+d*p+e*h+j*l;this.n12=c*t+d*w+e*x+j*u;this.n13=c*A+d*C+e*F+j*E;this.n14=c*D+d*I+e*S+j*a;this.n21=g*f+b*p+m*h+k*l;this.n22=g*t+b*
+w+m*x+k*u;this.n23=g*A+b*C+m*F+k*E;this.n24=g*D+b*I+m*S+k*a;this.n31=n*f+o*p+y*h+v*l;this.n32=n*t+o*w+y*x+v*u;this.n33=n*A+o*C+y*F+v*E;this.n34=n*D+o*I+y*S+v*a;this.n41=q*f+z*p+B*h+H*l;this.n42=q*t+z*w+B*x+H*u;this.n43=q*A+z*C+B*F+H*E;this.n44=q*D+z*I+B*S+H*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},
 determinant:function(){var a=this.n11,c=this.n12,d=this.n13,e=this.n14,j=this.n21,g=this.n22,b=this.n23,m=this.n24,k=this.n31,n=this.n32,o=this.n33,y=this.n34,v=this.n41,q=this.n42,z=this.n43,B=this.n44;return e*b*n*v-d*m*n*v-e*g*o*v+c*m*o*v+d*g*y*v-c*b*y*v-e*b*k*q+d*m*k*q+e*j*o*q-a*m*o*q-d*j*y*q+a*b*y*q+e*g*k*z-c*m*k*z-e*j*n*z+a*m*n*z+c*j*y*z-a*g*y*z-d*g*k*B+c*b*k*B+d*j*n*B-a*b*n*B-c*j*o*B+a*g*o*B},transpose:function(){function a(c,d,e){var j=c[d];c[d]=c[e];c[e]=j}a(this,"n21","n12");a(this,"n31",
 "n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=
 this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,
@@ -49,10 +49,10 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.f
 d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,e,j,g,b,m=new THREE.Vector3,k=new THREE.Vector3;e=0;for(j=this.vertices.length;e<j;e++){g=this.vertices[e];g.normal.set(0,0,0)}e=0;for(j=this.faces.length;e<j;e++){g=this.faces[e];if(a&&g.vertexNormals.length){m.set(0,0,0);c=0;for(d=g.normal.length;c<d;c++)m.addSelf(g.vertexNormals[c]);m.divideScalar(3)}else{c=this.vertices[g.a];d=this.vertices[g.b];b=this.vertices[g.c];m.sub(b.position,
 d.position);k.sub(c.position,d.position);m.crossSelf(k)}m.isZero()||m.normalize();g.normal.copy(m)}},computeVertexNormals:function(){var a,c,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)e[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
 new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)e[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal);e[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)e[a].normalize();a=0;for(c=this.faces.length;a<
-c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(D,I,S,N,X,Y,T){g=D.vertices[I].position;b=D.vertices[S].position;m=D.vertices[N].position;k=j[X];n=j[Y];o=j[T];y=b.x-g.x;v=m.x-g.x;q=b.y-g.y;z=m.y-g.y;
-B=b.z-g.z;H=m.z-g.z;f=n.u-k.u;p=o.u-k.u;h=n.v-k.v;l=o.v-k.v;t=1/(f*l-p*h);u.set((l*y-h*v)*t,(l*q-h*z)*t,(l*B-h*H)*t);A.set((f*v-p*y)*t,(f*z-p*q)*t,(f*H-p*B)*t);w[I].addSelf(u);w[S].addSelf(u);w[N].addSelf(u);x[I].addSelf(A);x[S].addSelf(A);x[N].addSelf(A)}var c,d,e,j,g,b,m,k,n,o,y,v,q,z,B,H,f,p,h,l,t,w=[],x=[],u=new THREE.Vector3,A=new THREE.Vector3,C=new THREE.Vector3,E=new THREE.Vector3,F=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){w[c]=new THREE.Vector3;x[c]=new THREE.Vector3}c=0;
+c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(D,I,S,N,X,Z,T){g=D.vertices[I].position;b=D.vertices[S].position;m=D.vertices[N].position;k=j[X];n=j[Z];o=j[T];y=b.x-g.x;v=m.x-g.x;q=b.y-g.y;z=m.y-g.y;
+B=b.z-g.z;H=m.z-g.z;f=n.u-k.u;p=o.u-k.u;h=n.v-k.v;l=o.v-k.v;t=1/(f*l-p*h);u.set((l*y-h*v)*t,(l*q-h*z)*t,(l*B-h*H)*t);A.set((f*v-p*y)*t,(f*z-p*q)*t,(f*H-p*B)*t);w[I].addSelf(u);w[S].addSelf(u);w[N].addSelf(u);x[I].addSelf(A);x[S].addSelf(A);x[N].addSelf(A)}var c,d,e,j,g,b,m,k,n,o,y,v,q,z,B,H,f,p,h,l,t,w=[],x=[],u=new THREE.Vector3,A=new THREE.Vector3,C=new THREE.Vector3,F=new THREE.Vector3,E=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){w[c]=new THREE.Vector3;x[c]=new THREE.Vector3}c=0;
 for(d=this.faces.length;c<d;c++){e=this.faces[c];j=this.uvs[c];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
-this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){F.copy(this.vertices[c].normal);e=w[c];C.copy(e);C.subSelf(F.multiplyScalar(F.dot(e))).normalize();E.cross(this.vertices[c].normal,e);e=E.dot(x[c]);e=e<0?-1:1;this.vertices[c].tangent.set(C.x,C.y,C.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
+this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){E.copy(this.vertices[c].normal);e=w[c];C.copy(e);C.subSelf(E.multiplyScalar(E.dot(e))).normalize();F.cross(this.vertices[c].normal,e);e=F.dot(x[c]);e=e<0?-1:1;this.vertices[c].tangent.set(C.x,C.y,C.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
 z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
 this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(o){var y=[];c=0;for(d=o.length;c<d;c++)o[c]==undefined?y.push("undefined"):y.push(o[c].toString());return y.join("_")}var c,d,e,j,g,b,m,k,n={};e=0;for(j=this.faces.length;e<j;e++){g=this.faces[e];
 b=g.materials;m=a(b);if(n[m]==undefined)n[m]={hash:m,counter:0};k=n[m].hash+"_"+n[m].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:b,vertices:0};g=g instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+g>65535){n[m].counter+=1;k=n[m].hash+"_"+n[m].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:b,vertices:0}}this.geometryChunks[k].faces.push(e);this.geometryChunks[k].vertices+=g}},toString:function(){return"THREE.Geometry ( vertices: "+
@@ -104,11 +104,11 @@ var Uniforms={clone:function(a){var c,d,e,j={};for(c in a){j[c]={};for(d in a[c]
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
 THREE.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
-THREE.Projector=function(){function a(x,u){return u.z-x.z}function c(x,u){var A=0,C=1,E=x.z+x.w,F=u.z+u.w,D=-x.z+x.w,I=-u.z+u.w;if(E>=0&&F>=0&&D>=0&&I>=0)return true;else if(E<0&&F<0||D<0&&I<0)return false;else{if(E<0)A=Math.max(A,E/(E-F));else if(F<0)C=Math.min(C,E/(E-F));if(D<0)A=Math.max(A,D/(D-I));else if(I<0)C=Math.min(C,D/(D-I));if(C<A)return false;else{x.lerpSelf(u,A);u.lerpSelf(x,1-C);return true}}}var d,e,j=[],g,b,m,k=[],n,o,y=[],v,q,z=[],B=new THREE.Vector4,H=new THREE.Vector4,f=new THREE.Matrix4,
-p=new THREE.Matrix4,h=[],l=new THREE.Vector4,t=new THREE.Vector4,w;this.projectObjects=function(x,u,A){var C=[],E,F;e=0;f.multiply(u.projectionMatrix,u.matrix);h[0]=new THREE.Vector4(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);h[1]=new THREE.Vector4(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);h[2]=new THREE.Vector4(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);h[3]=new THREE.Vector4(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);h[4]=new THREE.Vector4(f.n41-f.n31,f.n42-f.n32,f.n43-
-f.n33,f.n44-f.n34);h[5]=new THREE.Vector4(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);u=0;for(E=h.length;u<E;u++){F=h[u];F.divideScalar(Math.sqrt(F.x*F.x+F.y*F.y+F.z*F.z))}E=x.objects;x=0;for(u=E.length;x<u;x++){F=E[x];var D;if(!(D=!F.visible)){if(D=F instanceof THREE.Mesh){a:{D=void 0;for(var I=F.position,S=-F.geometry.boundingSphere.radius*Math.max(F.scale.x,Math.max(F.scale.y,F.scale.z)),N=0;N<6;N++){D=h[N].x*I.x+h[N].y*I.y+h[N].z*I.z+h[N].w;if(D<=S){D=false;break a}}D=true}D=!D}D=D}if(!D){d=
-j[e]=j[e]||new THREE.RenderableObject;B.copy(F.position);f.multiplyVector3(B);d.object=F;d.z=B.z;C.push(d);e++}}A&&C.sort(a);return C};this.projectScene=function(x,u,A){var C=[],E=u.near,F=u.far,D,I,S,N,X,Y,T,V,da,R,O,ba,aa,K,P,U;m=o=q=0;u.autoUpdateMatrix&&u.updateMatrix();f.multiply(u.projectionMatrix,u.matrix);Y=this.projectObjects(x,u,true);x=0;for(D=Y.length;x<D;x++){T=Y[x].object;if(T.visible){T.autoUpdateMatrix&&T.updateMatrix();V=T.matrix;da=T.rotationMatrix;R=T.materials;O=T.overdraw;if(T instanceof
-THREE.Mesh){ba=T.geometry;aa=ba.vertices;I=0;for(S=aa.length;I<S;I++){K=aa[I];K.positionWorld.copy(K.position);V.multiplyVector3(K.positionWorld);N=K.positionScreen;N.copy(K.positionWorld);f.multiplyVector4(N);N.x/=N.w;N.y/=N.w;K.__visible=N.z>E&&N.z<F}ba=ba.faces;I=0;for(S=ba.length;I<S;I++){K=ba[I];if(K instanceof THREE.Face3){N=aa[K.a];X=aa[K.b];P=aa[K.c];if(N.__visible&&X.__visible&&P.__visible)if(T.doubleSided||T.flipSided!=(P.positionScreen.x-N.positionScreen.x)*(X.positionScreen.y-N.positionScreen.y)-
+THREE.Projector=function(){function a(x,u){return u.z-x.z}function c(x,u){var A=0,C=1,F=x.z+x.w,E=u.z+u.w,D=-x.z+x.w,I=-u.z+u.w;if(F>=0&&E>=0&&D>=0&&I>=0)return true;else if(F<0&&E<0||D<0&&I<0)return false;else{if(F<0)A=Math.max(A,F/(F-E));else if(E<0)C=Math.min(C,F/(F-E));if(D<0)A=Math.max(A,D/(D-I));else if(I<0)C=Math.min(C,D/(D-I));if(C<A)return false;else{x.lerpSelf(u,A);u.lerpSelf(x,1-C);return true}}}var d,e,j=[],g,b,m,k=[],n,o,y=[],v,q,z=[],B=new THREE.Vector4,H=new THREE.Vector4,f=new THREE.Matrix4,
+p=new THREE.Matrix4,h=[],l=new THREE.Vector4,t=new THREE.Vector4,w;this.projectObjects=function(x,u,A){var C=[],F,E;e=0;f.multiply(u.projectionMatrix,u.matrix);h[0]=new THREE.Vector4(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);h[1]=new THREE.Vector4(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);h[2]=new THREE.Vector4(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);h[3]=new THREE.Vector4(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);h[4]=new THREE.Vector4(f.n41-f.n31,f.n42-f.n32,f.n43-
+f.n33,f.n44-f.n34);h[5]=new THREE.Vector4(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);u=0;for(F=h.length;u<F;u++){E=h[u];E.divideScalar(Math.sqrt(E.x*E.x+E.y*E.y+E.z*E.z))}F=x.objects;x=0;for(u=F.length;x<u;x++){E=F[x];var D;if(!(D=!E.visible)){if(D=E instanceof THREE.Mesh){a:{D=void 0;for(var I=E.position,S=-E.geometry.boundingSphere.radius*Math.max(E.scale.x,Math.max(E.scale.y,E.scale.z)),N=0;N<6;N++){D=h[N].x*I.x+h[N].y*I.y+h[N].z*I.z+h[N].w;if(D<=S){D=false;break a}}D=true}D=!D}D=D}if(!D){d=
+j[e]=j[e]||new THREE.RenderableObject;B.copy(E.position);f.multiplyVector3(B);d.object=E;d.z=B.z;C.push(d);e++}}A&&C.sort(a);return C};this.projectScene=function(x,u,A){var C=[],F=u.near,E=u.far,D,I,S,N,X,Z,T,V,da,R,O,ba,aa,K,P,U;m=o=q=0;u.autoUpdateMatrix&&u.updateMatrix();f.multiply(u.projectionMatrix,u.matrix);Z=this.projectObjects(x,u,true);x=0;for(D=Z.length;x<D;x++){T=Z[x].object;if(T.visible){T.autoUpdateMatrix&&T.updateMatrix();V=T.matrix;da=T.rotationMatrix;R=T.materials;O=T.overdraw;if(T instanceof
+THREE.Mesh){ba=T.geometry;aa=ba.vertices;I=0;for(S=aa.length;I<S;I++){K=aa[I];K.positionWorld.copy(K.position);V.multiplyVector3(K.positionWorld);N=K.positionScreen;N.copy(K.positionWorld);f.multiplyVector4(N);N.x/=N.w;N.y/=N.w;K.__visible=N.z>F&&N.z<E}ba=ba.faces;I=0;for(S=ba.length;I<S;I++){K=ba[I];if(K instanceof THREE.Face3){N=aa[K.a];X=aa[K.b];P=aa[K.c];if(N.__visible&&X.__visible&&P.__visible)if(T.doubleSided||T.flipSided!=(P.positionScreen.x-N.positionScreen.x)*(X.positionScreen.y-N.positionScreen.y)-
 (P.positionScreen.y-N.positionScreen.y)*(X.positionScreen.x-N.positionScreen.x)<0){g=k[m]=k[m]||new THREE.RenderableFace3;g.v1.positionWorld.copy(N.positionWorld);g.v2.positionWorld.copy(X.positionWorld);g.v3.positionWorld.copy(P.positionWorld);g.v1.positionScreen.copy(N.positionScreen);g.v2.positionScreen.copy(X.positionScreen);g.v3.positionScreen.copy(P.positionScreen);g.normalWorld.copy(K.normal);da.multiplyVector3(g.normalWorld);g.centroidWorld.copy(K.centroid);V.multiplyVector3(g.centroidWorld);
 g.centroidScreen.copy(g.centroidWorld);f.multiplyVector3(g.centroidScreen);P=K.vertexNormals;w=g.vertexNormalsWorld;N=0;for(X=P.length;N<X;N++){U=w[N]=w[N]||new THREE.Vector3;U.copy(P[N]);da.multiplyVector3(U)}g.z=g.centroidScreen.z;g.meshMaterials=R;g.faceMaterials=K.materials;g.overdraw=O;if(T.geometry.uvs[I]){g.uvs[0]=T.geometry.uvs[I][0];g.uvs[1]=T.geometry.uvs[I][1];g.uvs[2]=T.geometry.uvs[I][2]}C.push(g);m++}}else if(K instanceof THREE.Face4){N=aa[K.a];X=aa[K.b];P=aa[K.c];U=aa[K.d];if(N.__visible&&
 X.__visible&&P.__visible&&U.__visible)if(T.doubleSided||T.flipSided!=((U.positionScreen.x-N.positionScreen.x)*(X.positionScreen.y-N.positionScreen.y)-(U.positionScreen.y-N.positionScreen.y)*(X.positionScreen.x-N.positionScreen.x)<0||(X.positionScreen.x-P.positionScreen.x)*(U.positionScreen.y-P.positionScreen.y)-(X.positionScreen.y-P.positionScreen.y)*(U.positionScreen.x-P.positionScreen.x)<0)){g=k[m]=k[m]||new THREE.RenderableFace3;g.v1.positionWorld.copy(N.positionWorld);g.v2.positionWorld.copy(X.positionWorld);
@@ -119,94 +119,93 @@ l.w);t.multiplyScalar(1/t.w);n=y[o]=y[o]||new THREE.RenderableLine;n.v1.position
 v.scale.y=T.scale.y*Math.abs(v.y-(H.y+u.projectionMatrix.n22)/(H.w+u.projectionMatrix.n24));v.materials=T.materials;C.push(v);q++}}}}A&&C.sort(a);return C};this.unprojectVector=function(x,u){var A=THREE.Matrix4.makeInvert(u.matrix);A.multiplySelf(THREE.Matrix4.makeInvert(u.projectionMatrix));A.multiplyVector3(x);return x}};
 THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,j,g;this.domElement=document.createElement("div");this.setSize=function(b,m){d=b;e=m;j=d/2;g=e/2};this.render=function(b,m){var k,n,o,y,v,q,z,B;a=c.projectScene(b,m);k=0;for(n=a.length;k<n;k++){v=a[k];if(v instanceof THREE.RenderableParticle){z=v.x*j+j;B=v.y*g+g;o=0;for(y=v.material.length;o<y;o++){q=v.material[o];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=z+"px";q.style.top=B+"px"}}}}}};
 THREE.CanvasRenderer=function(){function a(ka){if(v!=ka)n.globalAlpha=v=ka}function c(ka){if(q!=ka){switch(ka){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}q=ka}}var d=null,e=new THREE.Projector,j=document.createElement("canvas"),g,b,m,k,n=j.getContext("2d"),o=new THREE.Color(0),y=0,v=1,q=0,z=null,B=null,H=1,f,p,h,l,t,w,x,u,A,C=new THREE.Color,
-E=new THREE.Color,F=new THREE.Color,D=new THREE.Color,I=new THREE.Color,S,N,X,Y,T,V,da,R,O,ba=new THREE.Rectangle,aa=new THREE.Rectangle,K=new THREE.Rectangle,P=false,U=new THREE.Color,ha=new THREE.Color,ga=new THREE.Color,G=new THREE.Color,J=Math.PI*2,L=new THREE.Vector3,W,ca,ma,ia,ra,la,wa=16;W=document.createElement("canvas");W.width=W.height=2;ca=W.getContext("2d");ca.fillStyle="rgba(0,0,0,1)";ca.fillRect(0,0,2,2);ma=ca.getImageData(0,0,2,2);ia=ma.data;ra=document.createElement("canvas");ra.width=
+F=new THREE.Color,E=new THREE.Color,D=new THREE.Color,I=new THREE.Color,S,N,X,Z,T,V,da,R,O,ba=new THREE.Rectangle,aa=new THREE.Rectangle,K=new THREE.Rectangle,P=false,U=new THREE.Color,ha=new THREE.Color,ga=new THREE.Color,G=new THREE.Color,J=Math.PI*2,L=new THREE.Vector3,W,ca,ma,ia,ra,la,wa=16;W=document.createElement("canvas");W.width=W.height=2;ca=W.getContext("2d");ca.fillStyle="rgba(0,0,0,1)";ca.fillRect(0,0,2,2);ma=ca.getImageData(0,0,2,2);ia=ma.data;ra=document.createElement("canvas");ra.width=
 ra.height=wa;la=ra.getContext("2d");la.translate(-wa/2,-wa/2);la.scale(wa,wa);wa--;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ka,sa){g=ka;b=sa;m=g/2;k=b/2;j.width=g;j.height=b;ba.set(-m,-k,m,k);v=1;q=0;B=z=null;H=1};this.setClearColor=function(ka,sa){o=ka;y=sa;aa.set(-m,-k,m,k);n.setTransform(1,0,0,-1,m,k);this.clear()};this.setClearColorHex=function(ka,sa){o.setHex(ka);y=sa;aa.set(-m,-k,m,k);n.setTransform(1,0,0,-1,m,k);this.clear()};this.clear=
-function(){n.setTransform(1,0,0,-1,m,k);if(!aa.isEmpty()){aa.inflate(1);aa.minSelf(ba);if(o.hex==0&&y==0)n.clearRect(aa.getX(),aa.getY(),aa.getWidth(),aa.getHeight());else{c(THREE.NormalBlending);a(1);n.fillStyle="rgba("+Math.floor(o.r*255)+","+Math.floor(o.g*255)+","+Math.floor(o.b*255)+","+y+")";n.fillRect(aa.getX(),aa.getY(),aa.getWidth(),aa.getHeight())}aa.empty()}};this.render=function(ka,sa){function Ha(M){var ea,$,Q,Z=M.lights;ha.setRGB(0,0,0);ga.setRGB(0,0,0);G.setRGB(0,0,0);M=0;for(ea=Z.length;M<
-ea;M++){$=Z[M];Q=$.color;if($ instanceof THREE.AmbientLight){ha.r+=Q.r;ha.g+=Q.g;ha.b+=Q.b}else if($ instanceof THREE.DirectionalLight){ga.r+=Q.r;ga.g+=Q.g;ga.b+=Q.b}else if($ instanceof THREE.PointLight){G.r+=Q.r;G.g+=Q.g;G.b+=Q.b}}}function qa(M,ea,$,Q){var Z,fa,na,oa,pa=M.lights;M=0;for(Z=pa.length;M<Z;M++){fa=pa[M];na=fa.color;oa=fa.intensity;if(fa instanceof THREE.DirectionalLight){fa=$.dot(fa.position)*oa;if(fa>0){Q.r+=na.r*fa;Q.g+=na.g*fa;Q.b+=na.b*fa}}else if(fa instanceof THREE.PointLight){L.sub(fa.position,
-ea);L.normalize();fa=$.dot(L)*oa;if(fa>0){Q.r+=na.r*fa;Q.g+=na.g*fa;Q.b+=na.b*fa}}}}function Qa(M,ea,$){if($.opacity!=0){a($.opacity);c($.blending);var Q,Z,fa,na,oa,pa;if($ instanceof THREE.ParticleBasicMaterial){if($.map&&$.map.image.loaded){na=$.map.image;oa=na.width>>1;pa=na.height>>1;Z=ea.scale.x*m;fa=ea.scale.y*k;$=Z*oa;Q=fa*pa;K.set(M.x-$,M.y-Q,M.x+$,M.y+Q);if(ba.instersects(K)){n.save();n.translate(M.x,M.y);n.rotate(-ea.rotation);n.scale(Z,-fa);n.translate(-oa,-pa);n.drawImage(na,0,0);n.restore()}}}else if($ instanceof
-THREE.ParticleCircleMaterial){if(P){U.r=ha.r+ga.r+G.r;U.g=ha.g+ga.g+G.g;U.b=ha.b+ga.b+G.b;C.r=$.color.r*U.r;C.g=$.color.g*U.g;C.b=$.color.b*U.b;C.updateStyleString()}else C.__styleString=$.color.__styleString;$=ea.scale.x*m;Q=ea.scale.y*k;K.set(M.x-$,M.y-Q,M.x+$,M.y+Q);if(ba.instersects(K)){Z=C.__styleString;if(B!=Z)n.fillStyle=B=Z;n.save();n.translate(M.x,M.y);n.rotate(-ea.rotation);n.scale($,Q);n.beginPath();n.arc(0,0,1,0,J,true);n.closePath();n.fill();n.restore()}}}}function Ra(M,ea,$,Q){if(Q.opacity!=
-0){a(Q.opacity);c(Q.blending);n.beginPath();n.moveTo(M.positionScreen.x,M.positionScreen.y);n.lineTo(ea.positionScreen.x,ea.positionScreen.y);n.closePath();if(Q instanceof THREE.LineBasicMaterial){C.__styleString=Q.color.__styleString;M=Q.linewidth;if(H!=M)n.lineWidth=H=M;M=C.__styleString;if(z!=M)n.strokeStyle=z=M;n.stroke();K.inflate(Q.linewidth*2)}}}function Ma(M,ea,$,Q,Z,fa){if(Z.opacity!=0){a(Z.opacity);c(Z.blending);l=M.positionScreen.x;t=M.positionScreen.y;w=ea.positionScreen.x;x=ea.positionScreen.y;
-u=$.positionScreen.x;A=$.positionScreen.y;n.beginPath();n.moveTo(l,t);n.lineTo(w,x);n.lineTo(u,A);n.lineTo(l,t);n.closePath();if(Z instanceof THREE.MeshBasicMaterial)if(Z.map)Z.map.image.loaded&&Z.map.mapping instanceof THREE.UVMapping&&Ba(l,t,w,x,u,A,Z.map.image,Q.uvs[0].u,Q.uvs[0].v,Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);else if(Z.env_map){if(Z.env_map.image.loaded)if(Z.env_map.mapping instanceof THREE.SphericalReflectionMapping){M=sa.matrix;L.copy(Q.vertexNormalsWorld[0]);Y=(L.x*M.n11+L.y*
-M.n12+L.z*M.n13)*0.5+0.5;T=-(L.x*M.n21+L.y*M.n22+L.z*M.n23)*0.5+0.5;L.copy(Q.vertexNormalsWorld[1]);V=(L.x*M.n11+L.y*M.n12+L.z*M.n13)*0.5+0.5;da=-(L.x*M.n21+L.y*M.n22+L.z*M.n23)*0.5+0.5;L.copy(Q.vertexNormalsWorld[2]);R=(L.x*M.n11+L.y*M.n12+L.z*M.n13)*0.5+0.5;O=-(L.x*M.n21+L.y*M.n22+L.z*M.n23)*0.5+0.5;Ba(l,t,w,x,u,A,Z.env_map.image,Y,T,V,da,R,O)}}else Z.wireframe?Ea(Z.color.__styleString,Z.wireframe_linewidth):Fa(Z.color.__styleString);else if(Z instanceof THREE.MeshLambertMaterial){if(Z.map&&!Z.wireframe){Z.map.mapping instanceof
-THREE.UVMapping&&Ba(l,t,w,x,u,A,Z.map.image,Q.uvs[0].u,Q.uvs[0].v,Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);c(THREE.SubtractiveBlending)}if(P)if(!Z.wireframe&&Z.shading==THREE.SmoothShading&&Q.vertexNormalsWorld.length==3){E.r=F.r=D.r=ha.r;E.g=F.g=D.g=ha.g;E.b=F.b=D.b=ha.b;qa(fa,Q.v1.positionWorld,Q.vertexNormalsWorld[0],E);qa(fa,Q.v2.positionWorld,Q.vertexNormalsWorld[1],F);qa(fa,Q.v3.positionWorld,Q.vertexNormalsWorld[2],D);I.r=(F.r+D.r)*0.5;I.g=(F.g+D.g)*0.5;I.b=(F.b+D.b)*0.5;X=Na(E,F,D,I);
-Ba(l,t,w,x,u,A,X,0,0,1,0,0,1)}else{U.r=ha.r;U.g=ha.g;U.b=ha.b;qa(fa,Q.centroidWorld,Q.normalWorld,U);C.r=Z.color.r*U.r;C.g=Z.color.g*U.g;C.b=Z.color.b*U.b;C.updateStyleString();Z.wireframe?Ea(C.__styleString,Z.wireframe_linewidth):Fa(C.__styleString)}else Z.wireframe?Ea(Z.color.__styleString,Z.wireframe_linewidth):Fa(Z.color.__styleString)}else if(Z instanceof THREE.MeshDepthMaterial){S=sa.near;N=sa.far;E.r=E.g=E.b=1-Ia(M.positionScreen.z,S,N);F.r=F.g=F.b=1-Ia(ea.positionScreen.z,S,N);D.r=D.g=D.b=
-1-Ia($.positionScreen.z,S,N);I.r=(F.r+D.r)*0.5;I.g=(F.g+D.g)*0.5;I.b=(F.b+D.b)*0.5;X=Na(E,F,D,I);Ba(l,t,w,x,u,A,X,0,0,1,0,0,1)}else if(Z instanceof THREE.MeshNormalMaterial){C.r=Ja(Q.normalWorld.x);C.g=Ja(Q.normalWorld.y);C.b=Ja(Q.normalWorld.z);C.updateStyleString();Z.wireframe?Ea(C.__styleString,Z.wireframe_linewidth):Fa(C.__styleString)}}}function Ea(M,ea){if(z!=M)n.strokeStyle=z=M;if(H!=ea)n.lineWidth=H=ea;n.stroke();K.inflate(ea*2)}function Fa(M){if(B!=M)n.fillStyle=B=M;n.fill()}function Ba(M,
-ea,$,Q,Z,fa,na,oa,pa,xa,ta,ya,Ca){var ua,za;ua=na.width-1;za=na.height-1;oa*=ua;pa*=za;xa*=ua;ta*=za;ya*=ua;Ca*=za;$-=M;Q-=ea;Z-=M;fa-=ea;xa-=oa;ta-=pa;ya-=oa;Ca-=pa;ua=xa*Ca-ya*ta;if(ua!=0){za=1/ua;ua=(Ca*$-ta*Z)*za;ta=(Ca*Q-ta*fa)*za;$=(xa*Z-ya*$)*za;Q=(xa*fa-ya*Q)*za;M=M-ua*oa-$*pa;ea=ea-ta*oa-Q*pa;n.save();n.transform(ua,ta,$,Q,M,ea);n.clip();n.drawImage(na,0,0);n.restore()}}function Na(M,ea,$,Q){var Z=~~(M.r*255),fa=~~(M.g*255);M=~~(M.b*255);var na=~~(ea.r*255),oa=~~(ea.g*255);ea=~~(ea.b*255);
-var pa=~~($.r*255),xa=~~($.g*255);$=~~($.b*255);var ta=~~(Q.r*255),ya=~~(Q.g*255);Q=~~(Q.b*255);ia[0]=Z<0?0:Z>255?255:Z;ia[1]=fa<0?0:fa>255?255:fa;ia[2]=M<0?0:M>255?255:M;ia[4]=na<0?0:na>255?255:na;ia[5]=oa<0?0:oa>255?255:oa;ia[6]=ea<0?0:ea>255?255:ea;ia[8]=pa<0?0:pa>255?255:pa;ia[9]=xa<0?0:xa>255?255:xa;ia[10]=$<0?0:$>255?255:$;ia[12]=ta<0?0:ta>255?255:ta;ia[13]=ya<0?0:ya>255?255:ya;ia[14]=Q<0?0:Q>255?255:Q;ca.putImageData(ma,0,0);la.drawImage(W,0,0);return ra}function Ia(M,ea,$){M=(M-ea)/($-ea);
-return M*M*(3-2*M)}function Ja(M){M=(M+1)*0.5;return M<0?0:M>1?1:M}function Ka(M,ea){var $=ea.x-M.x,Q=ea.y-M.y,Z=1/Math.sqrt($*$+Q*Q);$*=Z;Q*=Z;ea.x+=$;ea.y+=Q;M.x-=$;M.y-=Q}var Ga,Oa,ja,va,Aa,La,Pa,Da;this.autoClear?this.clear():n.setTransform(1,0,0,-1,m,k);d=e.projectScene(ka,sa,this.sortElements);(P=ka.lights.length>0)&&Ha(ka);Ga=0;for(Oa=d.length;Ga<Oa;Ga++){ja=d[Ga];K.empty();if(ja instanceof THREE.RenderableParticle){f=ja;f.x*=m;f.y*=k;va=0;for(Aa=ja.materials.length;va<Aa;va++)Qa(f,ja,ja.materials[va],
+function(){n.setTransform(1,0,0,-1,m,k);if(!aa.isEmpty()){aa.inflate(1);aa.minSelf(ba);if(o.hex==0&&y==0)n.clearRect(aa.getX(),aa.getY(),aa.getWidth(),aa.getHeight());else{c(THREE.NormalBlending);a(1);n.fillStyle="rgba("+Math.floor(o.r*255)+","+Math.floor(o.g*255)+","+Math.floor(o.b*255)+","+y+")";n.fillRect(aa.getX(),aa.getY(),aa.getWidth(),aa.getHeight())}aa.empty()}};this.render=function(ka,sa){function Ha(M){var ea,$,Q,Y=M.lights;ha.setRGB(0,0,0);ga.setRGB(0,0,0);G.setRGB(0,0,0);M=0;for(ea=Y.length;M<
+ea;M++){$=Y[M];Q=$.color;if($ instanceof THREE.AmbientLight){ha.r+=Q.r;ha.g+=Q.g;ha.b+=Q.b}else if($ instanceof THREE.DirectionalLight){ga.r+=Q.r;ga.g+=Q.g;ga.b+=Q.b}else if($ instanceof THREE.PointLight){G.r+=Q.r;G.g+=Q.g;G.b+=Q.b}}}function qa(M,ea,$,Q){var Y,fa,na,oa,pa=M.lights;M=0;for(Y=pa.length;M<Y;M++){fa=pa[M];na=fa.color;oa=fa.intensity;if(fa instanceof THREE.DirectionalLight){fa=$.dot(fa.position)*oa;if(fa>0){Q.r+=na.r*fa;Q.g+=na.g*fa;Q.b+=na.b*fa}}else if(fa instanceof THREE.PointLight){L.sub(fa.position,
+ea);L.normalize();fa=$.dot(L)*oa;if(fa>0){Q.r+=na.r*fa;Q.g+=na.g*fa;Q.b+=na.b*fa}}}}function Qa(M,ea,$){if($.opacity!=0){a($.opacity);c($.blending);var Q,Y,fa,na,oa,pa;if($ instanceof THREE.ParticleBasicMaterial){if($.map&&$.map.image.loaded){na=$.map.image;oa=na.width>>1;pa=na.height>>1;Y=ea.scale.x*m;fa=ea.scale.y*k;$=Y*oa;Q=fa*pa;K.set(M.x-$,M.y-Q,M.x+$,M.y+Q);if(ba.instersects(K)){n.save();n.translate(M.x,M.y);n.rotate(-ea.rotation);n.scale(Y,-fa);n.translate(-oa,-pa);n.drawImage(na,0,0);n.restore()}}}else if($ instanceof
+THREE.ParticleCircleMaterial){if(P){U.r=ha.r+ga.r+G.r;U.g=ha.g+ga.g+G.g;U.b=ha.b+ga.b+G.b;C.r=$.color.r*U.r;C.g=$.color.g*U.g;C.b=$.color.b*U.b;C.updateStyleString()}else C.__styleString=$.color.__styleString;$=ea.scale.x*m;Q=ea.scale.y*k;K.set(M.x-$,M.y-Q,M.x+$,M.y+Q);if(ba.instersects(K)){Y=C.__styleString;if(B!=Y)n.fillStyle=B=Y;n.save();n.translate(M.x,M.y);n.rotate(-ea.rotation);n.scale($,Q);n.beginPath();n.arc(0,0,1,0,J,true);n.closePath();n.fill();n.restore()}}}}function Ra(M,ea,$,Q){if(Q.opacity!=
+0){a(Q.opacity);c(Q.blending);n.beginPath();n.moveTo(M.positionScreen.x,M.positionScreen.y);n.lineTo(ea.positionScreen.x,ea.positionScreen.y);n.closePath();if(Q instanceof THREE.LineBasicMaterial){C.__styleString=Q.color.__styleString;M=Q.linewidth;if(H!=M)n.lineWidth=H=M;M=C.__styleString;if(z!=M)n.strokeStyle=z=M;n.stroke();K.inflate(Q.linewidth*2)}}}function Ma(M,ea,$,Q,Y,fa){if(Y.opacity!=0){a(Y.opacity);c(Y.blending);l=M.positionScreen.x;t=M.positionScreen.y;w=ea.positionScreen.x;x=ea.positionScreen.y;
+u=$.positionScreen.x;A=$.positionScreen.y;n.beginPath();n.moveTo(l,t);n.lineTo(w,x);n.lineTo(u,A);n.lineTo(l,t);n.closePath();if(Y instanceof THREE.MeshBasicMaterial)if(Y.map)Y.map.image.loaded&&Y.map.mapping instanceof THREE.UVMapping&&Ba(l,t,w,x,u,A,Y.map.image,Q.uvs[0].u,Q.uvs[0].v,Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);else if(Y.env_map){if(Y.env_map.image.loaded)if(Y.env_map.mapping instanceof THREE.SphericalReflectionMapping){M=sa.matrix;L.copy(Q.vertexNormalsWorld[0]);Z=(L.x*M.n11+L.y*
+M.n12+L.z*M.n13)*0.5+0.5;T=-(L.x*M.n21+L.y*M.n22+L.z*M.n23)*0.5+0.5;L.copy(Q.vertexNormalsWorld[1]);V=(L.x*M.n11+L.y*M.n12+L.z*M.n13)*0.5+0.5;da=-(L.x*M.n21+L.y*M.n22+L.z*M.n23)*0.5+0.5;L.copy(Q.vertexNormalsWorld[2]);R=(L.x*M.n11+L.y*M.n12+L.z*M.n13)*0.5+0.5;O=-(L.x*M.n21+L.y*M.n22+L.z*M.n23)*0.5+0.5;Ba(l,t,w,x,u,A,Y.env_map.image,Z,T,V,da,R,O)}}else Y.wireframe?Ea(Y.color.__styleString,Y.wireframe_linewidth):Fa(Y.color.__styleString);else if(Y instanceof THREE.MeshLambertMaterial){if(Y.map&&!Y.wireframe){Y.map.mapping instanceof
+THREE.UVMapping&&Ba(l,t,w,x,u,A,Y.map.image,Q.uvs[0].u,Q.uvs[0].v,Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);c(THREE.SubtractiveBlending)}if(P)if(!Y.wireframe&&Y.shading==THREE.SmoothShading&&Q.vertexNormalsWorld.length==3){F.r=E.r=D.r=ha.r;F.g=E.g=D.g=ha.g;F.b=E.b=D.b=ha.b;qa(fa,Q.v1.positionWorld,Q.vertexNormalsWorld[0],F);qa(fa,Q.v2.positionWorld,Q.vertexNormalsWorld[1],E);qa(fa,Q.v3.positionWorld,Q.vertexNormalsWorld[2],D);I.r=(E.r+D.r)*0.5;I.g=(E.g+D.g)*0.5;I.b=(E.b+D.b)*0.5;X=Na(F,E,D,I);
+Ba(l,t,w,x,u,A,X,0,0,1,0,0,1)}else{U.r=ha.r;U.g=ha.g;U.b=ha.b;qa(fa,Q.centroidWorld,Q.normalWorld,U);C.r=Y.color.r*U.r;C.g=Y.color.g*U.g;C.b=Y.color.b*U.b;C.updateStyleString();Y.wireframe?Ea(C.__styleString,Y.wireframe_linewidth):Fa(C.__styleString)}else Y.wireframe?Ea(Y.color.__styleString,Y.wireframe_linewidth):Fa(Y.color.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){S=sa.near;N=sa.far;F.r=F.g=F.b=1-Ia(M.positionScreen.z,S,N);E.r=E.g=E.b=1-Ia(ea.positionScreen.z,S,N);D.r=D.g=D.b=
+1-Ia($.positionScreen.z,S,N);I.r=(E.r+D.r)*0.5;I.g=(E.g+D.g)*0.5;I.b=(E.b+D.b)*0.5;X=Na(F,E,D,I);Ba(l,t,w,x,u,A,X,0,0,1,0,0,1)}else if(Y instanceof THREE.MeshNormalMaterial){C.r=Ja(Q.normalWorld.x);C.g=Ja(Q.normalWorld.y);C.b=Ja(Q.normalWorld.z);C.updateStyleString();Y.wireframe?Ea(C.__styleString,Y.wireframe_linewidth):Fa(C.__styleString)}}}function Ea(M,ea){if(z!=M)n.strokeStyle=z=M;if(H!=ea)n.lineWidth=H=ea;n.stroke();K.inflate(ea*2)}function Fa(M){if(B!=M)n.fillStyle=B=M;n.fill()}function Ba(M,
+ea,$,Q,Y,fa,na,oa,pa,xa,ta,ya,Ca){var ua,za;ua=na.width-1;za=na.height-1;oa*=ua;pa*=za;xa*=ua;ta*=za;ya*=ua;Ca*=za;$-=M;Q-=ea;Y-=M;fa-=ea;xa-=oa;ta-=pa;ya-=oa;Ca-=pa;ua=xa*Ca-ya*ta;if(ua!=0){za=1/ua;ua=(Ca*$-ta*Y)*za;ta=(Ca*Q-ta*fa)*za;$=(xa*Y-ya*$)*za;Q=(xa*fa-ya*Q)*za;M=M-ua*oa-$*pa;ea=ea-ta*oa-Q*pa;n.save();n.transform(ua,ta,$,Q,M,ea);n.clip();n.drawImage(na,0,0);n.restore()}}function Na(M,ea,$,Q){var Y=~~(M.r*255),fa=~~(M.g*255);M=~~(M.b*255);var na=~~(ea.r*255),oa=~~(ea.g*255);ea=~~(ea.b*255);
+var pa=~~($.r*255),xa=~~($.g*255);$=~~($.b*255);var ta=~~(Q.r*255),ya=~~(Q.g*255);Q=~~(Q.b*255);ia[0]=Y<0?0:Y>255?255:Y;ia[1]=fa<0?0:fa>255?255:fa;ia[2]=M<0?0:M>255?255:M;ia[4]=na<0?0:na>255?255:na;ia[5]=oa<0?0:oa>255?255:oa;ia[6]=ea<0?0:ea>255?255:ea;ia[8]=pa<0?0:pa>255?255:pa;ia[9]=xa<0?0:xa>255?255:xa;ia[10]=$<0?0:$>255?255:$;ia[12]=ta<0?0:ta>255?255:ta;ia[13]=ya<0?0:ya>255?255:ya;ia[14]=Q<0?0:Q>255?255:Q;ca.putImageData(ma,0,0);la.drawImage(W,0,0);return ra}function Ia(M,ea,$){M=(M-ea)/($-ea);
+return M*M*(3-2*M)}function Ja(M){M=(M+1)*0.5;return M<0?0:M>1?1:M}function Ka(M,ea){var $=ea.x-M.x,Q=ea.y-M.y,Y=1/Math.sqrt($*$+Q*Q);$*=Y;Q*=Y;ea.x+=$;ea.y+=Q;M.x-=$;M.y-=Q}var Ga,Oa,ja,va,Aa,La,Pa,Da;this.autoClear?this.clear():n.setTransform(1,0,0,-1,m,k);d=e.projectScene(ka,sa,this.sortElements);(P=ka.lights.length>0)&&Ha(ka);Ga=0;for(Oa=d.length;Ga<Oa;Ga++){ja=d[Ga];K.empty();if(ja instanceof THREE.RenderableParticle){f=ja;f.x*=m;f.y*=k;va=0;for(Aa=ja.materials.length;va<Aa;va++)Qa(f,ja,ja.materials[va],
 ka)}else if(ja instanceof THREE.RenderableLine){f=ja.v1;p=ja.v2;f.positionScreen.x*=m;f.positionScreen.y*=k;p.positionScreen.x*=m;p.positionScreen.y*=k;K.addPoint(f.positionScreen.x,f.positionScreen.y);K.addPoint(p.positionScreen.x,p.positionScreen.y);if(ba.instersects(K)){va=0;for(Aa=ja.materials.length;va<Aa;)Ra(f,p,ja,ja.materials[va++],ka)}}else if(ja instanceof THREE.RenderableFace3){f=ja.v1;p=ja.v2;h=ja.v3;f.positionScreen.x*=m;f.positionScreen.y*=k;p.positionScreen.x*=m;p.positionScreen.y*=
 k;h.positionScreen.x*=m;h.positionScreen.y*=k;if(ja.overdraw){Ka(f.positionScreen,p.positionScreen);Ka(p.positionScreen,h.positionScreen);Ka(h.positionScreen,f.positionScreen)}K.add3Points(f.positionScreen.x,f.positionScreen.y,p.positionScreen.x,p.positionScreen.y,h.positionScreen.x,h.positionScreen.y);if(ba.instersects(K)){va=0;for(Aa=ja.meshMaterials.length;va<Aa;){Da=ja.meshMaterials[va++];if(Da instanceof THREE.MeshFaceMaterial){La=0;for(Pa=ja.faceMaterials.length;La<Pa;)(Da=ja.faceMaterials[La++])&&
 Ma(f,p,h,ja,Da,ka)}else Ma(f,p,h,ja,Da,ka)}}}aa.addRectangle(K)}n.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(Y,T,V){var da,R,O,ba;da=0;for(R=Y.lights.length;da<R;da++){O=Y.lights[da];if(O instanceof THREE.DirectionalLight){ba=T.normalWorld.dot(O.position)*O.intensity;if(ba>0){V.r+=O.color.r*ba;V.g+=O.color.g*ba;V.b+=O.color.b*ba}}else if(O instanceof THREE.PointLight){A.sub(O.position,T.centroidWorld);A.normalize();ba=T.normalWorld.dot(A)*O.intensity;if(ba>0){V.r+=O.color.r*ba;V.g+=O.color.g*ba;V.b+=O.color.b*ba}}}}function c(Y,T,V,da,R,O){D=e(I++);D.setAttribute("d",
-"M "+Y.positionScreen.x+" "+Y.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(R instanceof THREE.MeshBasicMaterial)h.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshLambertMaterial)if(p){l.r=t.r;l.g=t.g;l.b=t.b;a(O,da,l);h.r=R.color.r*l.r;h.g=R.color.g*l.g;h.b=R.color.b*l.b;h.updateStyleString()}else h.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshDepthMaterial){u=1-R.__2near/(R.__farPlusNear-
-da.z*R.__farMinusNear);h.setRGB(u,u,u)}else R instanceof THREE.MeshNormalMaterial&&h.setRGB(j(da.normalWorld.x),j(da.normalWorld.y),j(da.normalWorld.z));R.wireframe?D.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+R.wireframe_linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.wireframe_linecap+"; stroke-linejoin: "+R.wireframe_linejoin):D.setAttribute("style","fill: "+h.__styleString+"; fill-opacity: "+R.opacity);m.appendChild(D)}function d(Y,T,V,da,R,
-O,ba){D=e(I++);D.setAttribute("d","M "+Y.positionScreen.x+" "+Y.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+"z");if(O instanceof THREE.MeshBasicMaterial)h.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshLambertMaterial)if(p){l.r=t.r;l.g=t.g;l.b=t.b;a(ba,R,l);h.r=O.color.r*l.r;h.g=O.color.g*l.g;h.b=O.color.b*l.b;h.updateStyleString()}else h.__styleString=O.color.__styleString;
+THREE.SVGRenderer=function(){function a(Z,T,V){var da,R,O,ba;da=0;for(R=Z.lights.length;da<R;da++){O=Z.lights[da];if(O instanceof THREE.DirectionalLight){ba=T.normalWorld.dot(O.position)*O.intensity;if(ba>0){V.r+=O.color.r*ba;V.g+=O.color.g*ba;V.b+=O.color.b*ba}}else if(O instanceof THREE.PointLight){A.sub(O.position,T.centroidWorld);A.normalize();ba=T.normalWorld.dot(A)*O.intensity;if(ba>0){V.r+=O.color.r*ba;V.g+=O.color.g*ba;V.b+=O.color.b*ba}}}}function c(Z,T,V,da,R,O){D=e(I++);D.setAttribute("d",
+"M "+Z.positionScreen.x+" "+Z.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(R instanceof THREE.MeshBasicMaterial)h.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshLambertMaterial)if(p){l.r=t.r;l.g=t.g;l.b=t.b;a(O,da,l);h.r=R.color.r*l.r;h.g=R.color.g*l.g;h.b=R.color.b*l.b;h.updateStyleString()}else h.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshDepthMaterial){u=1-R.__2near/(R.__farPlusNear-
+da.z*R.__farMinusNear);h.setRGB(u,u,u)}else R instanceof THREE.MeshNormalMaterial&&h.setRGB(j(da.normalWorld.x),j(da.normalWorld.y),j(da.normalWorld.z));R.wireframe?D.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+R.wireframe_linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.wireframe_linecap+"; stroke-linejoin: "+R.wireframe_linejoin):D.setAttribute("style","fill: "+h.__styleString+"; fill-opacity: "+R.opacity);m.appendChild(D)}function d(Z,T,V,da,R,
+O,ba){D=e(I++);D.setAttribute("d","M "+Z.positionScreen.x+" "+Z.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+"z");if(O instanceof THREE.MeshBasicMaterial)h.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshLambertMaterial)if(p){l.r=t.r;l.g=t.g;l.b=t.b;a(ba,R,l);h.r=O.color.r*l.r;h.g=O.color.g*l.g;h.b=O.color.b*l.b;h.updateStyleString()}else h.__styleString=O.color.__styleString;
 else if(O instanceof THREE.MeshDepthMaterial){u=1-O.__2near/(O.__farPlusNear-R.z*O.__farMinusNear);h.setRGB(u,u,u)}else O instanceof THREE.MeshNormalMaterial&&h.setRGB(j(R.normalWorld.x),j(R.normalWorld.y),j(R.normalWorld.z));O.wireframe?D.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+O.wireframe_linewidth+"; stroke-opacity: "+O.opacity+"; stroke-linecap: "+O.wireframe_linecap+"; stroke-linejoin: "+O.wireframe_linejoin):D.setAttribute("style","fill: "+h.__styleString+
-"; fill-opacity: "+O.opacity);m.appendChild(D)}function e(Y){if(C[Y]==null){C[Y]=document.createElementNS("http://www.w3.org/2000/svg","path");X==0&&C[Y].setAttribute("shape-rendering","crispEdges");return C[Y]}return C[Y]}function j(Y){return Y<0?Math.min((1+Y)*0.5,0.5):0.5+Math.min(Y*0.5,0.5)}var g=null,b=new THREE.Projector,m=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,n,o,y,v,q,z,B,H=new THREE.Rectangle,f=new THREE.Rectangle,p=false,h=new THREE.Color(16777215),l=new THREE.Color(16777215),
-t=new THREE.Color(0),w=new THREE.Color(0),x=new THREE.Color(0),u,A=new THREE.Vector3,C=[],E=[],F=[],D,I,S,N,X=1;this.domElement=m;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(Y){switch(Y){case "high":X=1;break;case "low":X=0}};this.setSize=function(Y,T){k=Y;n=T;o=k/2;y=n/2;m.setAttribute("viewBox",-o+" "+-y+" "+k+" "+n);m.setAttribute("width",k);m.setAttribute("height",n);H.set(-o,-y,o,y)};this.clear=function(){for(;m.childNodes.length>0;)m.removeChild(m.childNodes[0])};
-this.render=function(Y,T){var V,da,R,O,ba,aa,K,P;this.autoClear&&this.clear();g=b.projectScene(Y,T,this.sortElements);N=S=I=0;if(p=Y.lights.length>0){K=Y.lights;t.setRGB(0,0,0);w.setRGB(0,0,0);x.setRGB(0,0,0);V=0;for(da=K.length;V<da;V++){R=K[V];O=R.color;if(R instanceof THREE.AmbientLight){t.r+=O.r;t.g+=O.g;t.b+=O.b}else if(R instanceof THREE.DirectionalLight){w.r+=O.r;w.g+=O.g;w.b+=O.b}else if(R instanceof THREE.PointLight){x.r+=O.r;x.g+=O.g;x.b+=O.b}}}V=0;for(da=g.length;V<da;V++){K=g[V];f.empty();
-if(K instanceof THREE.RenderableParticle){v=K;v.x*=o;v.y*=-y;R=0;for(O=K.materials.length;R<O;R++)if(P=K.materials[R]){ba=v;aa=K;P=P;var U=S++;if(E[U]==null){E[U]=document.createElementNS("http://www.w3.org/2000/svg","circle");X==0&&E[U].setAttribute("shape-rendering","crispEdges")}D=E[U];D.setAttribute("cx",ba.x);D.setAttribute("cy",ba.y);D.setAttribute("r",aa.scale.x*o);if(P instanceof THREE.ParticleCircleMaterial){if(p){l.r=t.r+w.r+x.r;l.g=t.g+w.g+x.g;l.b=t.b+w.b+x.b;h.r=P.color.r*l.r;h.g=P.color.g*
-l.g;h.b=P.color.b*l.b;h.updateStyleString()}else h=P.color;D.setAttribute("style","fill: "+h.__styleString)}m.appendChild(D)}}else if(K instanceof THREE.RenderableLine){v=K.v1;q=K.v2;v.positionScreen.x*=o;v.positionScreen.y*=-y;q.positionScreen.x*=o;q.positionScreen.y*=-y;f.addPoint(v.positionScreen.x,v.positionScreen.y);f.addPoint(q.positionScreen.x,q.positionScreen.y);if(H.instersects(f)){R=0;for(O=K.materials.length;R<O;)if(P=K.materials[R++]){ba=v;aa=q;P=P;U=N++;if(F[U]==null){F[U]=document.createElementNS("http://www.w3.org/2000/svg",
-"line");X==0&&F[U].setAttribute("shape-rendering","crispEdges")}D=F[U];D.setAttribute("x1",ba.positionScreen.x);D.setAttribute("y1",ba.positionScreen.y);D.setAttribute("x2",aa.positionScreen.x);D.setAttribute("y2",aa.positionScreen.y);if(P instanceof THREE.LineBasicMaterial){h.__styleString=P.color.__styleString;D.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+P.linewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.linecap+"; stroke-linejoin: "+P.linejoin);
+"; fill-opacity: "+O.opacity);m.appendChild(D)}function e(Z){if(C[Z]==null){C[Z]=document.createElementNS("http://www.w3.org/2000/svg","path");X==0&&C[Z].setAttribute("shape-rendering","crispEdges");return C[Z]}return C[Z]}function j(Z){return Z<0?Math.min((1+Z)*0.5,0.5):0.5+Math.min(Z*0.5,0.5)}var g=null,b=new THREE.Projector,m=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,n,o,y,v,q,z,B,H=new THREE.Rectangle,f=new THREE.Rectangle,p=false,h=new THREE.Color(16777215),l=new THREE.Color(16777215),
+t=new THREE.Color(0),w=new THREE.Color(0),x=new THREE.Color(0),u,A=new THREE.Vector3,C=[],F=[],E=[],D,I,S,N,X=1;this.domElement=m;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(Z){switch(Z){case "high":X=1;break;case "low":X=0}};this.setSize=function(Z,T){k=Z;n=T;o=k/2;y=n/2;m.setAttribute("viewBox",-o+" "+-y+" "+k+" "+n);m.setAttribute("width",k);m.setAttribute("height",n);H.set(-o,-y,o,y)};this.clear=function(){for(;m.childNodes.length>0;)m.removeChild(m.childNodes[0])};
+this.render=function(Z,T){var V,da,R,O,ba,aa,K,P;this.autoClear&&this.clear();g=b.projectScene(Z,T,this.sortElements);N=S=I=0;if(p=Z.lights.length>0){K=Z.lights;t.setRGB(0,0,0);w.setRGB(0,0,0);x.setRGB(0,0,0);V=0;for(da=K.length;V<da;V++){R=K[V];O=R.color;if(R instanceof THREE.AmbientLight){t.r+=O.r;t.g+=O.g;t.b+=O.b}else if(R instanceof THREE.DirectionalLight){w.r+=O.r;w.g+=O.g;w.b+=O.b}else if(R instanceof THREE.PointLight){x.r+=O.r;x.g+=O.g;x.b+=O.b}}}V=0;for(da=g.length;V<da;V++){K=g[V];f.empty();
+if(K instanceof THREE.RenderableParticle){v=K;v.x*=o;v.y*=-y;R=0;for(O=K.materials.length;R<O;R++)if(P=K.materials[R]){ba=v;aa=K;P=P;var U=S++;if(F[U]==null){F[U]=document.createElementNS("http://www.w3.org/2000/svg","circle");X==0&&F[U].setAttribute("shape-rendering","crispEdges")}D=F[U];D.setAttribute("cx",ba.x);D.setAttribute("cy",ba.y);D.setAttribute("r",aa.scale.x*o);if(P instanceof THREE.ParticleCircleMaterial){if(p){l.r=t.r+w.r+x.r;l.g=t.g+w.g+x.g;l.b=t.b+w.b+x.b;h.r=P.color.r*l.r;h.g=P.color.g*
+l.g;h.b=P.color.b*l.b;h.updateStyleString()}else h=P.color;D.setAttribute("style","fill: "+h.__styleString)}m.appendChild(D)}}else if(K instanceof THREE.RenderableLine){v=K.v1;q=K.v2;v.positionScreen.x*=o;v.positionScreen.y*=-y;q.positionScreen.x*=o;q.positionScreen.y*=-y;f.addPoint(v.positionScreen.x,v.positionScreen.y);f.addPoint(q.positionScreen.x,q.positionScreen.y);if(H.instersects(f)){R=0;for(O=K.materials.length;R<O;)if(P=K.materials[R++]){ba=v;aa=q;P=P;U=N++;if(E[U]==null){E[U]=document.createElementNS("http://www.w3.org/2000/svg",
+"line");X==0&&E[U].setAttribute("shape-rendering","crispEdges")}D=E[U];D.setAttribute("x1",ba.positionScreen.x);D.setAttribute("y1",ba.positionScreen.y);D.setAttribute("x2",aa.positionScreen.x);D.setAttribute("y2",aa.positionScreen.y);if(P instanceof THREE.LineBasicMaterial){h.__styleString=P.color.__styleString;D.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+P.linewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.linecap+"; stroke-linejoin: "+P.linejoin);
 m.appendChild(D)}}}}else if(K instanceof THREE.RenderableFace3){v=K.v1;q=K.v2;z=K.v3;v.positionScreen.x*=o;v.positionScreen.y*=-y;q.positionScreen.x*=o;q.positionScreen.y*=-y;z.positionScreen.x*=o;z.positionScreen.y*=-y;f.addPoint(v.positionScreen.x,v.positionScreen.y);f.addPoint(q.positionScreen.x,q.positionScreen.y);f.addPoint(z.positionScreen.x,z.positionScreen.y);if(H.instersects(f)){R=0;for(O=K.meshMaterials.length;R<O;){P=K.meshMaterials[R++];if(P instanceof THREE.MeshFaceMaterial){ba=0;for(aa=
-K.faceMaterials.length;ba<aa;)(P=K.faceMaterials[ba++])&&c(v,q,z,K,P,Y)}else P&&c(v,q,z,K,P,Y)}}}else if(K instanceof THREE.RenderableFace4){v=K.v1;q=K.v2;z=K.v3;B=K.v4;v.positionScreen.x*=o;v.positionScreen.y*=-y;q.positionScreen.x*=o;q.positionScreen.y*=-y;z.positionScreen.x*=o;z.positionScreen.y*=-y;B.positionScreen.x*=o;B.positionScreen.y*=-y;f.addPoint(v.positionScreen.x,v.positionScreen.y);f.addPoint(q.positionScreen.x,q.positionScreen.y);f.addPoint(z.positionScreen.x,z.positionScreen.y);f.addPoint(B.positionScreen.x,
-B.positionScreen.y);if(H.instersects(f)){R=0;for(O=K.meshMaterials.length;R<O;){P=K.meshMaterials[R++];if(P instanceof THREE.MeshFaceMaterial){ba=0;for(aa=K.faceMaterials.length;ba<aa;)(P=K.faceMaterials[ba++])&&d(v,q,z,B,K,P,Y)}else P&&d(v,q,z,B,K,P,Y)}}}}}};
+K.faceMaterials.length;ba<aa;)(P=K.faceMaterials[ba++])&&c(v,q,z,K,P,Z)}else P&&c(v,q,z,K,P,Z)}}}else if(K instanceof THREE.RenderableFace4){v=K.v1;q=K.v2;z=K.v3;B=K.v4;v.positionScreen.x*=o;v.positionScreen.y*=-y;q.positionScreen.x*=o;q.positionScreen.y*=-y;z.positionScreen.x*=o;z.positionScreen.y*=-y;B.positionScreen.x*=o;B.positionScreen.y*=-y;f.addPoint(v.positionScreen.x,v.positionScreen.y);f.addPoint(q.positionScreen.x,q.positionScreen.y);f.addPoint(z.positionScreen.x,z.positionScreen.y);f.addPoint(B.positionScreen.x,
+B.positionScreen.y);if(H.instersects(f)){R=0;for(O=K.meshMaterials.length;R<O;){P=K.meshMaterials[R++];if(P instanceof THREE.MeshFaceMaterial){ba=0;for(aa=K.faceMaterials.length;ba<aa;)(P=K.faceMaterials[ba++])&&d(v,q,z,B,K,P,Z)}else P&&d(v,q,z,B,K,P,Z)}}}}}};
 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 e(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 j(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 g=document.createElement("canvas"),b,m=null,k=null,n=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],o=new THREE.Matrix4,y=new Float32Array(16),v=new Float32Array(16),q=new THREE.Vector4,z=true,B=new THREE.Color(0),H=0;if(a){if(a.antialias!==undefined)z=a.antialias;a.clearColor!==undefined&&B.setHex(a.clearColor);if(a.clearAlpha!==undefined)H=a.clearAlpha}this.domElement=g;this.autoClear=true;(function(f,p,h){try{b=g.getContext("experimental-webgl",
 {antialias:f})}catch(l){console.log(l)}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)})(z,B,H);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,
-p){g.width=f;g.height=p;b.viewport(0,0,g.width,g.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,l,t,w=0,x=0,u=0,A,C,E,F=this.lights,D=F.directional.colors,I=F.directional.positions,S=F.point.colors,N=F.point.positions,X=0,Y=0;h=t=t=0;for(l=p.length;h<l;h++){t=p[h];A=t.color;C=t.position;
-E=t.intensity;if(t instanceof THREE.AmbientLight){w+=A.r;x+=A.g;u+=A.b}else if(t instanceof THREE.DirectionalLight){t=X*3;D[t]=A.r*E;D[t+1]=A.g*E;D[t+2]=A.b*E;I[t]=C.x;I[t+1]=C.y;I[t+2]=C.z;X+=1}else if(t instanceof THREE.PointLight){t=Y*3;S[t]=A.r*E;S[t+1]=A.g*E;S[t+2]=A.b*E;N[t]=C.x;N[t+1]=C.y;N[t+2]=C.z;Y+=1}}for(h=X*3;h<D.length;h++)D[h]=0;for(h=Y*3;h<S.length;h++)S[h]=0;F.point.length=Y;F.directional.length=X;F.ambient[0]=w;F.ambient[1]=x;F.ambient[2]=u};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,l,t=0,w=0,x=0,u=p.geometry.faces,A=f.faces;h=0;for(l=A.length;h<l;h++){fi=A[h];face=u[fi];if(face instanceof THREE.Face3){t+=3;w+=1;x+=3}else if(face instanceof THREE.Face4){t+=4;w+=2;x+=4}}f.__vertexArray=new Float32Array(t*3);f.__normalArray=new Float32Array(t*3);f.__tangentArray=new Float32Array(t*4);f.__colorArray=new Float32Array(t*3);f.__uvArray=new Float32Array(t*2);f.__uv2Array=new Float32Array(t*2);f.__faceArray=new Uint16Array(w*3);f.__lineArray=new Uint16Array(x*2);t=false;h=0;
-for(l=p.materials.length;h<l;h++){u=p.materials[h];if(u instanceof THREE.MeshFaceMaterial){u=0;for(A=f.materials.length;u<A;u++)if(f.materials[u]&&f.materials[u].shading!=undefined&&f.materials[u].shading==THREE.SmoothShading){t=true;break}}else if(u&&u.shading!=undefined&&u.shading==THREE.SmoothShading){t=true;break}if(t)break}f.__needsSmoothNormals=t;f.__webGLFaceCount=w*3;f.__webGLLineCount=x*2};this.setMeshBuffers=function(f,p,h){var l,t,w,x,u,A,C,E,F,D,I=0,S=0,N=0,X=0,Y=0,T=0,V=0,da=0,R=0,O=
-f.__vertexArray,ba=f.__uvArray,aa=f.__uv2Array,K=f.__normalArray,P=f.__tangentArray,U=f.__colorArray,ha=f.__faceArray,ga=f.__lineArray,G=f.__needsSmoothNormals,J=p.geometry,L=J.__dirtyVertices,W=J.__dirtyElements,ca=J.__dirtyUvs,ma=J.__dirtyNormals,ia=J.__dirtyTangents,ra=J.__dirtyColors,la=J.vertices,wa=f.faces,ka=J.faces,sa=J.uvs,Ha=J.uvs2,qa=J.colors;p=0;for(l=wa.length;p<l;p++){t=wa[p];w=ka[t];A=sa[t];t=Ha[t];x=w.vertexNormals;u=w.normal;if(w instanceof THREE.Face3){if(L){C=la[w.a].position;E=
-la[w.b].position;F=la[w.c].position;O[S]=C.x;O[S+1]=C.y;O[S+2]=C.z;O[S+3]=E.x;O[S+4]=E.y;O[S+5]=E.z;O[S+6]=F.x;O[S+7]=F.y;O[S+8]=F.z;S+=9}if(ra&&qa.length){C=qa[w.a];E=qa[w.b];F=qa[w.c];U[R]=C.r;U[R+1]=C.g;U[R+2]=C.b;U[R+3]=E.r;U[R+4]=E.g;U[R+5]=E.b;U[R+6]=F.r;U[R+7]=F.g;U[R+8]=F.b;R+=9}if(ia&&J.hasTangents){C=la[w.a].tangent;E=la[w.b].tangent;F=la[w.c].tangent;P[V]=C.x;P[V+1]=C.y;P[V+2]=C.z;P[V+3]=C.w;P[V+4]=E.x;P[V+5]=E.y;P[V+6]=E.z;P[V+7]=E.w;P[V+8]=F.x;P[V+9]=F.y;P[V+10]=F.z;P[V+11]=F.w;V+=12}if(ma)if(x.length==
-3&&G)for(w=0;w<3;w++){u=x[w];K[T]=u.x;K[T+1]=u.y;K[T+2]=u.z;T+=3}else for(w=0;w<3;w++){K[T]=u.x;K[T+1]=u.y;K[T+2]=u.z;T+=3}if(ca&&A)for(w=0;w<3;w++){x=A[w];ba[N]=x.u;ba[N+1]=x.v;N+=2}if(ca&&t)for(w=0;w<3;w++){A=t[w];aa[X]=A.u;aa[X+1]=A.v;X+=2}if(W){ha[Y]=I;ha[Y+1]=I+1;ha[Y+2]=I+2;Y+=3;ga[da]=I;ga[da+1]=I+1;ga[da+2]=I;ga[da+3]=I+2;ga[da+4]=I+1;ga[da+5]=I+2;da+=6;I+=3}}else if(w instanceof THREE.Face4){if(L){C=la[w.a].position;E=la[w.b].position;F=la[w.c].position;D=la[w.d].position;O[S]=C.x;O[S+1]=
-C.y;O[S+2]=C.z;O[S+3]=E.x;O[S+4]=E.y;O[S+5]=E.z;O[S+6]=F.x;O[S+7]=F.y;O[S+8]=F.z;O[S+9]=D.x;O[S+10]=D.y;O[S+11]=D.z;S+=12}if(ra&&qa.length){C=qa[w.a];E=qa[w.b];F=qa[w.d];U[R]=C.r;U[R+1]=C.g;U[R+2]=C.b;U[R+3]=E.r;U[R+4]=E.g;U[R+5]=E.b;U[R+6]=F.r;U[R+7]=F.g;U[R+8]=F.b;U[R+9]=(void 0).r;U[R+10]=(void 0).g;U[R+11]=(void 0).b;R+=12}if(ia&&J.hasTangents){C=la[w.a].tangent;E=la[w.b].tangent;F=la[w.c].tangent;w=la[w.d].tangent;P[V]=C.x;P[V+1]=C.y;P[V+2]=C.z;P[V+3]=C.w;P[V+4]=E.x;P[V+5]=E.y;P[V+6]=E.z;P[V+
-7]=E.w;P[V+8]=F.x;P[V+9]=F.y;P[V+10]=F.z;P[V+11]=F.w;P[V+12]=w.x;P[V+13]=w.y;P[V+14]=w.z;P[V+15]=w.w;V+=16}if(ma)if(x.length==4&&G)for(w=0;w<4;w++){u=x[w];K[T]=u.x;K[T+1]=u.y;K[T+2]=u.z;T+=3}else for(w=0;w<4;w++){K[T]=u.x;K[T+1]=u.y;K[T+2]=u.z;T+=3}if(ca&&A)for(w=0;w<4;w++){x=A[w];ba[N]=x.u;ba[N+1]=x.v;N+=2}if(ca&&t)for(w=0;w<4;w++){A=t[w];aa[X]=A.u;aa[X+1]=A.v;X+=2}if(W){ha[Y]=I;ha[Y+1]=I+1;ha[Y+2]=I+2;ha[Y+3]=I;ha[Y+4]=I+2;ha[Y+5]=I+3;Y+=6;ga[da]=I;ga[da+1]=I+1;ga[da+2]=I;ga[da+3]=I+3;ga[da+4]=
-I+1;ga[da+5]=I+2;ga[da+6]=I+2;ga[da+7]=I+3;da+=8;I+=4}}}if(L){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,O,h)}if(ra&&qa.length){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,U,h)}if(ma){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,K,h)}if(ia&&J.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,P,h)}if(ca&&N>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUVBuffer);
-b.bufferData(b.ARRAY_BUFFER,ba,h)}if(ca&&X>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,aa,h)}if(W){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ha,h);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ga,h)}};this.setLineBuffers=function(f,p){var h,l,t,w=f.vertices,x=f.colors,u=w.length,A=x.length,C=f.__vertexArray,E=f.__colorArray,F=f.__lineArray,D=f.__dirtyColors,I=f.__dirtyElements;
-if(f.__dirtyVertices){for(h=0;h<u;h++){l=w[h].position;t=h*3;C[t]=l.x;C[t+1]=l.y;C[t+2]=l.z}b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,C,p)}if(D){for(h=0;h<A;h++){color=x[h];t=h*3;E[t]=color.r;E[t+1]=color.g;E[t+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,E,p)}if(I){for(h=0;h<u;h++)F[h]=h;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,F,p)}};this.setParticleBuffers=function(f,
-p,h){var l,t,w,x=f.vertices,u=x.length,A=f.colors,C=A.length,E=f.__vertexArray,F=f.__particleArray,D=f.__colorArray,I=f.__sortArray,S=f.__dirtyVertices,N=f.__dirtyElements,X=f.__dirtyColors;if(h.sortParticles){o.multiplySelf(h.matrix);for(l=0;l<u;l++){t=x[l].position;q.copy(t);o.multiplyVector3(q);I[l]=[q.z,l]}I.sort(function(Y,T){return T[0]-Y[0]});for(l=0;l<u;l++){t=x[I[l][1]].position;w=l*3;E[w]=t.x;E[w+1]=t.y;E[w+2]=t.z}for(l=0;l<C;l++){w=l*3;color=A[I[l][1]];D[w]=color.r;D[w+1]=color.g;D[w+2]=
-color.b}}else{if(S)for(l=0;l<u;l++){t=x[l].position;w=l*3;E[w]=t.x;E[w+1]=t.y;E[w+2]=t.z}if(X)for(l=0;l<C;l++){color=A[l];w=l*3;D[w]=color.r;D[w+1]=color.g;D[w+2]=color.b}}if(N){for(l=0;l<u;l++)F[l]=l;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,F,p)}if(S||h.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,E,p)}if(X||h.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,
-D,p)}};this.initMaterial=function(f,p,h){if(!f.program){var l,t;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 w,x,u,A;t=u=A=0;for(w=p.length;t<w;t++){x=p[t];x instanceof THREE.DirectionalLight&&u++;x instanceof THREE.PointLight&&A++}if(A+u<=4){p=u;A=A}else{p=Math.ceil(4*u/(A+u));A=4-p}t={directional:p,point:A};A=f.fragment_shader;p=f.vertex_shader;w={fog:h,map:f.map,env_map:f.env_map,light_map:f.light_map,vertex_colors:f.vertex_colors,maxDirLights:t.directional,maxPointLights:t.point};h=b.createProgram();t=["#ifdef GL_ES\nprecision highp float;\n#endif",
-"#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+w.maxPointLights,w.fog?"#define USE_FOG":"",w.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",w.map?"#define USE_MAP":"",w.env_map?"#define USE_ENVMAP":"",w.light_map?"#define USE_LIGHTMAP":"",w.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");w=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+
-w.maxPointLights,w.map?"#define USE_MAP":"",w.env_map?"#define USE_ENVMAP":"",w.light_map?"#define USE_LIGHTMAP":"",w.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,e("fragment",t+A));b.attachShader(h,
-e("vertex",w+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(l in f.uniforms)h.push(l);l=f.program;A=0;for(p=h.length;A<p;A++){t=h[A];l.uniforms[t]=b.getUniformLocation(l,t)}f=f.program;l=["position","normal",
-"uv","uv2","tangent","color"];h=0;for(A=l.length;h<A;h++){p=l[h];f.attributes[p]=b.getAttribLocation(f,p)}}};this.setProgram=function(f,p,h,l,t){this.initMaterial(l,p,h);var w=l.program;if(w!=m){b.useProgram(w);m=w}this.loadCamera(w,f);this.loadMatrices(w,t);if(l instanceof THREE.MeshPhongMaterial||l instanceof THREE.MeshLambertMaterial){this.setupLights(w,p);p=this.lights;l.uniforms.enableLighting.value=p.directional.length+p.point.length;l.uniforms.ambientLightColor.value=p.ambient;l.uniforms.directionalLightColor.value=
-p.directional.colors;l.uniforms.directionalLightDirection.value=p.directional.positions;l.uniforms.pointLightColor.value=p.point.colors;l.uniforms.pointLightPosition.value=p.point.positions}if(l instanceof THREE.MeshBasicMaterial||l instanceof THREE.MeshLambertMaterial||l instanceof THREE.MeshPhongMaterial){l.uniforms.diffuse.value.setRGB(l.color.r*l.opacity,l.color.g*l.opacity,l.color.b*l.opacity);l.uniforms.opacity.value=l.opacity;l.uniforms.map.texture=l.map;l.uniforms.light_map.texture=l.light_map;
-l.uniforms.env_map.texture=l.env_map;l.uniforms.reflectivity.value=l.reflectivity;l.uniforms.refraction_ratio.value=l.refraction_ratio;l.uniforms.combine.value=l.combine;l.uniforms.useRefract.value=l.env_map&&l.env_map.mapping instanceof THREE.CubeRefractionMapping;if(h){l.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){l.uniforms.fogNear.value=h.near;l.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)l.uniforms.fogDensity.value=h.density}}if(l instanceof THREE.LineBasicMaterial){l.uniforms.diffuse.value.setRGB(l.color.r*
-l.opacity,l.color.g*l.opacity,l.color.b*l.opacity);l.uniforms.opacity.value=l.opacity;if(h){l.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){l.uniforms.fogNear.value=h.near;l.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)l.uniforms.fogDensity.value=h.density}}if(l instanceof THREE.ParticleBasicMaterial){l.uniforms.psColor.value.setRGB(l.color.r*l.opacity,l.color.g*l.opacity,l.color.b*l.opacity);l.uniforms.opacity.value=l.opacity;l.uniforms.size.value=l.size;
-l.uniforms.map.texture=l.map;if(h){l.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){l.uniforms.fogNear.value=h.near;l.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)l.uniforms.fogDensity.value=h.density}}if(l instanceof THREE.MeshPhongMaterial){l.uniforms.ambient.value.setRGB(l.ambient.r,l.ambient.g,l.ambient.b);l.uniforms.specular.value.setRGB(l.specular.r,l.specular.g,l.specular.b);l.uniforms.shininess.value=l.shininess}if(l instanceof THREE.MeshDepthMaterial){l.uniforms.mNear.value=
-f.near;l.uniforms.mFar.value=f.far;l.uniforms.opacity.value=l.opacity}if(l instanceof THREE.MeshNormalMaterial)l.uniforms.opacity.value=l.opacity;f=l.uniforms;for(var x in f)if(t=w.uniforms[x]){l=f[x];p=l.type;h=l.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(l=l.texture)if(l.image instanceof Array&&l.image.length==6){l=l;h=h;if(l.image.length==6){if(!l.image.__webGLTextureCube&&!l.image.__cubeMapInitialized&&l.image.loadCount==6){l.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,l.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,l.image[p]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);l.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+h);b.bindTexture(b.TEXTURE_CUBE_MAP,l.image.__webGLTextureCube)}}else{l=l;h=h;if(!l.__webGLTexture&&l.image.loaded){l.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,l.__webGLTexture);b.texImage2D(b.TEXTURE_2D,
-0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,l.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,j(l.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,j(l.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,j(l.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,j(l.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+h);b.bindTexture(b.TEXTURE_2D,l.__webGLTexture)}}}return w};this.renderBuffer=function(f,p,h,l,t,w){f=this.setProgram(f,
-p,h,l,w).attributes;b.bindBuffer(b.ARRAY_BUFFER,t.__webGLVertexBuffer);b.vertexAttribPointer(f.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.position);if(f.color>=0){b.bindBuffer(b.ARRAY_BUFFER,t.__webGLColorBuffer);b.vertexAttribPointer(f.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.color)}if(f.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,t.__webGLNormalBuffer);b.vertexAttribPointer(f.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.normal)}if(f.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,
-t.__webGLTangentBuffer);b.vertexAttribPointer(f.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.tangent)}if(f.uv>=0)if(t.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,t.__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(t.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,t.__webGLUV2Buffer);b.vertexAttribPointer(f.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.uv2)}else b.disableVertexAttribArray(f.uv2);
-if(l.wireframe||l instanceof THREE.LineBasicMaterial){f=l.wireframe_linewidth!==undefined?l.wireframe_linewidth:l.linewidth!==undefined?l.linewidth:1;l=l instanceof THREE.LineBasicMaterial&&w.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(f);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,t.__webGLLineBuffer);b.drawElements(l,t.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(l instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,t.__webGLParticleBuffer);b.drawElements(b.POINTS,t.__webGLParticleCount,
-b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,t.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,t.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(f,p,h,l,t,w,x){var u,A,C,E,F;C=0;for(E=l.materials.length;C<E;C++){u=l.materials[C];if(u instanceof THREE.MeshFaceMaterial){u=0;for(A=t.materials.length;u<A;u++)if((F=t.materials[u])&&F.blending==w&&F.opacity<1==x){this.setBlending(F.blending);this.setDepthTest(F.depth_test);this.renderBuffer(f,p,h,F,t,l)}}else if((F=u)&&F.blending==
-w&&F.opacity<1==x){this.setBlending(F.blending);this.setDepthTest(F.depth_test);this.renderBuffer(f,p,h,F,t,l)}}};this.renderPassImmediate=function(f,p,h,l,t,w){var x,u,A,C;x=0;for(u=l.materials.length;x<u;x++)if((A=l.materials[x])&&A.blending==t&&A.opacity<1==w){this.setBlending(A.blending);this.setDepthTest(A.depth_test);C=this.setProgram(f,p,h,A,l);l.render(function(E){var F=C;if(!E.__webGLVertexBuffer)E.__webGLVertexBuffer=b.createBuffer();if(!E.__webGLNormalBuffer)E.__webGLNormalBuffer=b.createBuffer();
-if(E.hasPos){b.bindBuffer(b.ARRAY_BUFFER,E.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,E.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(F.attributes.position);b.vertexAttribPointer(F.attributes.position,3,b.FLOAT,false,0,0)}if(E.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,E.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,E.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(F.attributes.normal);b.vertexAttribPointer(F.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,E.count);
-E.count=0})}};this.render=function(f,p,h,l){var t,w,x,u,A=f.lights,C=f.fog;p.autoUpdateMatrix&&p.updateMatrix();v.set(p.matrix.flatten());y.set(p.projectionMatrix.flatten());o.multiply(p.projectionMatrix,p.matrix);n[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);n[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);n[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);n[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);n[4].set(o.n41-o.n31,o.n42-o.n32,o.n43-o.n33,o.n44-o.n34);
-n[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(t=0;t<5;t++){u=n[t];u.divideScalar(Math.sqrt(u.x*u.x+u.y*u.y+u.z*u.z))}this.initWebGLObjects(f,p);l=l!==undefined?l:true;if(h&&!h.__webGLFramebuffer){h.__webGLFramebuffer=b.createFramebuffer();h.__webGLRenderbuffer=b.createRenderbuffer();h.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,h.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,h.width,h.height);b.bindTexture(b.TEXTURE_2D,h.__webGLTexture);
-b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,j(h.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,j(h.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,j(h.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,j(h.min_filter));b.texImage2D(b.TEXTURE_2D,0,j(h.format),h.width,h.height,0,j(h.format),j(h.type),null);b.bindFramebuffer(b.FRAMEBUFFER,h.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,h.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,
-b.DEPTH_ATTACHMENT,b.RENDERBUFFER,h.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(h){t=h.__webGLFramebuffer;u=h.width;x=h.height}else{t=null;u=g.width;x=g.height}if(t!=k){b.bindFramebuffer(b.FRAMEBUFFER,t);b.viewport(0,0,u,x);l&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);k=t}this.autoClear&&this.clear();t=f.__webGLObjects.length;for(l=0;l<t;l++){x=f.__webGLObjects[l];u=x.object;if(w=u.visible){if(!(w=!(u instanceof
-THREE.Mesh)))a:{w=void 0;for(var E=u.matrix,F=-u.geometry.boundingSphere.radius*Math.max(u.scale.x,Math.max(u.scale.y,u.scale.z)),D=0;D<6;D++){w=n[D].x*E.n14+n[D].y*E.n24+n[D].z*E.n34+n[D].w;if(w<=F){w=false;break a}}w=true}w=w}if(w){if(u.autoUpdateMatrix){u.updateMatrix();u._objectMatrixArray.set(u.matrix.flatten())}this.setupMatrices(u,p);x.render=true}else x.render=false}w=f.__webGLObjectsImmediate.length;for(l=0;l<w;l++){u=f.__webGLObjectsImmediate[l].object;if(u.visible){if(u.autoUpdateMatrix){u.updateMatrix();
-u._objectMatrixArray.set(u.matrix.flatten())}this.setupMatrices(u,p)}}for(l=0;l<t;l++){x=f.__webGLObjects[l];if(x.render){u=x.object;x=x.buffer;d(u);this.renderPass(p,A,C,u,x,THREE.NormalBlending,false)}}for(l=0;l<w;l++){u=f.__webGLObjectsImmediate[l].object;if(u.visible){d(u);this.renderPassImmediate(p,A,C,u,THREE.NormalBlending,false)}}for(l=0;l<t;l++){x=f.__webGLObjects[l];if(x.render){u=x.object;x=x.buffer;d(u);this.renderPass(p,A,C,u,x,THREE.AdditiveBlending,false);this.renderPass(p,A,C,u,x,
-THREE.SubtractiveBlending,false);this.renderPass(p,A,C,u,x,THREE.AdditiveBlending,true);this.renderPass(p,A,C,u,x,THREE.SubtractiveBlending,true);this.renderPass(p,A,C,u,x,THREE.NormalBlending,true);this.renderPass(p,A,C,u,x,THREE.BillboardBlending,false)}}for(l=0;l<w;l++){u=f.__webGLObjectsImmediate[l].object;if(u.visible){d(u);this.renderPassImmediate(p,A,C,u,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(F,D,I,S){if(F[D]==undefined){f.__webGLObjects.push({buffer:I,object:S});F[D]=1}}function l(F,D,I){if(F[D]==undefined){f.__webGLObjectsImmediate.push({object:I});F[D]=1}}var t,w,x,u,A,C,E;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={};f.__webGLObjectsImmediate=[]}t=0;for(w=f.objects.length;t<w;t++){x=f.objects[t];A=x.geometry;if(f.__webGLObjectsMap[x.id]==undefined){f.__webGLObjectsMap[x.id]=
-{};x._modelViewMatrix=new THREE.Matrix4;x._normalMatrixArray=new Float32Array(9);x._modelViewMatrixArray=new Float32Array(16);x._objectMatrixArray=new Float32Array(16);x._objectMatrixArray.set(x.matrix.flatten())}E=f.__webGLObjectsMap[x.id];if(x instanceof THREE.Mesh){for(u in A.geometryChunks){C=A.geometryChunks[u];if(!C.__webGLVertexBuffer){this.createMeshBuffers(C);this.initMeshBuffers(C,x);A.__dirtyVertices=true;A.__dirtyElements=true;A.__dirtyUvs=true;A.__dirtyNormals=true;A.__dirtyTangents=
-true;A.__dirtyColors=true}if(A.__dirtyVertices||A.__dirtyElements||A.__dirtyUvs||A.__dirtyNormals||A.__dirtyColors||A.__dirtyTangents)this.setMeshBuffers(C,x,b.DYNAMIC_DRAW);h(E,u,C,x)}A.__dirtyVertices=false;A.__dirtyElements=false;A.__dirtyUvs=false;A.__dirtyNormals=false;A.__dirtyTangents=false;A.__dirtyColors=false}else if(x instanceof THREE.Line){if(!A.__webGLVertexBuffer){this.createLineBuffers(A);this.initLineBuffers(A);A.__dirtyVertices=true;A.__dirtyElements=true;A.__dirtyColors=true}if(A.__dirtyVertices||
-A.__dirtyColors)this.setLineBuffers(A,b.DYNAMIC_DRAW);h(E,0,A,x);A.__dirtyVertices=false;A.__dirtyElements=false;A.__dirtyColors=false}else if(x instanceof THREE.ParticleSystem){if(!A.__webGLVertexBuffer){this.createParticleBuffers(A);this.initParticleBuffers(A);A.__dirtyVertices=true;A.__dirtyColors=true;A.__dirtyElements=true}if(A.__dirtyVertices||A.__dirtyColors||x.sortParticles)this.setParticleBuffers(A,b.DYNAMIC_DRAW,x,p);h(E,0,A,x);A.__dirtyVertices=false;A.__dirtyColors=false;A.__dirtyElements=
-false}else x instanceof THREE.MarchingCubes&&l(E,0,x)}};this.removeObject=function(f,p){var h,l;for(h=f.__webGLObjects.length-1;h>=0;h--){l=f.__webGLObjects[h].object;p==l&&f.__webGLObjects.splice(h,1)}};this.setupMatrices=function(f,p){f._modelViewMatrix.multiplyToArray(p.matrix,f.matrix,f._modelViewMatrixArray);f._normalMatrix=THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)};this.loadMatrices=function(f,p){b.uniformMatrix4fv(f.uniforms.viewMatrix,false,v);
-b.uniformMatrix4fv(f.uniforms.projectionMatrix,false,y);b.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,p._modelViewMatrixArray);b.uniformMatrix3fv(f.uniforms.normalMatrix,false,p._normalMatrixArray);b.uniformMatrix4fv(f.uniforms.objectMatrix,false,p._objectMatrixArray)};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}};
+p){g.width=f;g.height=p;b.viewport(0,0,g.width,g.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,l,t,w=0,x=0,u=0,A,C,F,E=this.lights,D=E.directional.colors,I=E.directional.positions,S=E.point.colors,N=E.point.positions,X=0,Z=0;h=t=t=0;for(l=p.length;h<l;h++){t=p[h];A=t.color;C=t.position;
+F=t.intensity;if(t instanceof THREE.AmbientLight){w+=A.r;x+=A.g;u+=A.b}else if(t instanceof THREE.DirectionalLight){t=X*3;D[t]=A.r*F;D[t+1]=A.g*F;D[t+2]=A.b*F;I[t]=C.x;I[t+1]=C.y;I[t+2]=C.z;X+=1}else if(t instanceof THREE.PointLight){t=Z*3;S[t]=A.r*F;S[t+1]=A.g*F;S[t+2]=A.b*F;N[t]=C.x;N[t+1]=C.y;N[t+2]=C.z;Z+=1}}for(h=X*3;h<D.length;h++)D[h]=0;for(h=Z*3;h<S.length;h++)S[h]=0;E.point.length=Z;E.directional.length=X;E.ambient[0]=w;E.ambient[1]=x;E.ambient[2]=u};this.createParticleBuffers=function(f){f.__webGLVertexBuffer=
+b.createBuffer();f.__webGLColorBuffer=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.__sortArray=[];f.__webGLParticleCount=p};this.initMeshBuffers=function(f,p){var h,l,t=0,w=0,x=0,u=p.geometry.faces,A=f.faces;h=0;for(l=A.length;h<
+l;h++){fi=A[h];face=u[fi];if(face instanceof THREE.Face3){t+=3;w+=1;x+=3}else if(face instanceof THREE.Face4){t+=4;w+=2;x+=4}}f.__vertexArray=new Float32Array(t*3);f.__normalArray=new Float32Array(t*3);f.__tangentArray=new Float32Array(t*4);f.__colorArray=new Float32Array(t*3);f.__uvArray=new Float32Array(t*2);f.__uv2Array=new Float32Array(t*2);f.__faceArray=new Uint16Array(w*3);f.__lineArray=new Uint16Array(x*2);t=false;h=0;for(l=p.materials.length;h<l;h++){u=p.materials[h];if(u instanceof THREE.MeshFaceMaterial){u=
+0;for(A=f.materials.length;u<A;u++)if(f.materials[u]&&f.materials[u].shading!=undefined&&f.materials[u].shading==THREE.SmoothShading){t=true;break}}else if(u&&u.shading!=undefined&&u.shading==THREE.SmoothShading){t=true;break}if(t)break}f.__needsSmoothNormals=t;f.__webGLFaceCount=w*3;f.__webGLLineCount=x*2};this.setMeshBuffers=function(f,p,h){var l,t,w,x,u,A,C,F,E,D,I=0,S=0,N=0,X=0,Z=0,T=0,V=0,da=0,R=0,O=f.__vertexArray,ba=f.__uvArray,aa=f.__uv2Array,K=f.__normalArray,P=f.__tangentArray,U=f.__colorArray,
+ha=f.__faceArray,ga=f.__lineArray,G=f.__needsSmoothNormals,J=p.geometry,L=J.__dirtyVertices,W=J.__dirtyElements,ca=J.__dirtyUvs,ma=J.__dirtyNormals,ia=J.__dirtyTangents,ra=J.__dirtyColors,la=J.vertices,wa=f.faces,ka=J.faces,sa=J.uvs,Ha=J.uvs2,qa=J.colors;p=0;for(l=wa.length;p<l;p++){t=wa[p];w=ka[t];A=sa[t];t=Ha[t];x=w.vertexNormals;u=w.normal;if(w instanceof THREE.Face3){if(L){C=la[w.a].position;F=la[w.b].position;E=la[w.c].position;O[S]=C.x;O[S+1]=C.y;O[S+2]=C.z;O[S+3]=F.x;O[S+4]=F.y;O[S+5]=F.z;
+O[S+6]=E.x;O[S+7]=E.y;O[S+8]=E.z;S+=9}if(ra&&qa.length){C=qa[w.a];F=qa[w.b];E=qa[w.c];U[R]=C.r;U[R+1]=C.g;U[R+2]=C.b;U[R+3]=F.r;U[R+4]=F.g;U[R+5]=F.b;U[R+6]=E.r;U[R+7]=E.g;U[R+8]=E.b;R+=9}if(ia&&J.hasTangents){C=la[w.a].tangent;F=la[w.b].tangent;E=la[w.c].tangent;P[V]=C.x;P[V+1]=C.y;P[V+2]=C.z;P[V+3]=C.w;P[V+4]=F.x;P[V+5]=F.y;P[V+6]=F.z;P[V+7]=F.w;P[V+8]=E.x;P[V+9]=E.y;P[V+10]=E.z;P[V+11]=E.w;V+=12}if(ma)if(x.length==3&&G)for(w=0;w<3;w++){u=x[w];K[T]=u.x;K[T+1]=u.y;K[T+2]=u.z;T+=3}else for(w=0;w<
+3;w++){K[T]=u.x;K[T+1]=u.y;K[T+2]=u.z;T+=3}if(ca&&A)for(w=0;w<3;w++){x=A[w];ba[N]=x.u;ba[N+1]=x.v;N+=2}if(ca&&t)for(w=0;w<3;w++){A=t[w];aa[X]=A.u;aa[X+1]=A.v;X+=2}if(W){ha[Z]=I;ha[Z+1]=I+1;ha[Z+2]=I+2;Z+=3;ga[da]=I;ga[da+1]=I+1;ga[da+2]=I;ga[da+3]=I+2;ga[da+4]=I+1;ga[da+5]=I+2;da+=6;I+=3}}else if(w instanceof THREE.Face4){if(L){C=la[w.a].position;F=la[w.b].position;E=la[w.c].position;D=la[w.d].position;O[S]=C.x;O[S+1]=C.y;O[S+2]=C.z;O[S+3]=F.x;O[S+4]=F.y;O[S+5]=F.z;O[S+6]=E.x;O[S+7]=E.y;O[S+8]=E.z;
+O[S+9]=D.x;O[S+10]=D.y;O[S+11]=D.z;S+=12}if(ra&&qa.length){C=qa[w.a];F=qa[w.b];E=qa[w.d];U[R]=C.r;U[R+1]=C.g;U[R+2]=C.b;U[R+3]=F.r;U[R+4]=F.g;U[R+5]=F.b;U[R+6]=E.r;U[R+7]=E.g;U[R+8]=E.b;U[R+9]=(void 0).r;U[R+10]=(void 0).g;U[R+11]=(void 0).b;R+=12}if(ia&&J.hasTangents){C=la[w.a].tangent;F=la[w.b].tangent;E=la[w.c].tangent;w=la[w.d].tangent;P[V]=C.x;P[V+1]=C.y;P[V+2]=C.z;P[V+3]=C.w;P[V+4]=F.x;P[V+5]=F.y;P[V+6]=F.z;P[V+7]=F.w;P[V+8]=E.x;P[V+9]=E.y;P[V+10]=E.z;P[V+11]=E.w;P[V+12]=w.x;P[V+13]=w.y;P[V+
+14]=w.z;P[V+15]=w.w;V+=16}if(ma)if(x.length==4&&G)for(w=0;w<4;w++){u=x[w];K[T]=u.x;K[T+1]=u.y;K[T+2]=u.z;T+=3}else for(w=0;w<4;w++){K[T]=u.x;K[T+1]=u.y;K[T+2]=u.z;T+=3}if(ca&&A)for(w=0;w<4;w++){x=A[w];ba[N]=x.u;ba[N+1]=x.v;N+=2}if(ca&&t)for(w=0;w<4;w++){A=t[w];aa[X]=A.u;aa[X+1]=A.v;X+=2}if(W){ha[Z]=I;ha[Z+1]=I+1;ha[Z+2]=I+2;ha[Z+3]=I;ha[Z+4]=I+2;ha[Z+5]=I+3;Z+=6;ga[da]=I;ga[da+1]=I+1;ga[da+2]=I;ga[da+3]=I+3;ga[da+4]=I+1;ga[da+5]=I+2;ga[da+6]=I+2;ga[da+7]=I+3;da+=8;I+=4}}}if(L){b.bindBuffer(b.ARRAY_BUFFER,
+f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,O,h)}if(ra&&qa.length){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,U,h)}if(ma){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,K,h)}if(ia&&J.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,P,h)}if(ca&&N>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,ba,h)}if(ca&&X>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUV2Buffer);
+b.bufferData(b.ARRAY_BUFFER,aa,h)}if(W){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ha,h);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ga,h)}};this.setLineBuffers=function(f,p){var h,l,t,w=f.vertices,x=f.colors,u=w.length,A=x.length,C=f.__vertexArray,F=f.__colorArray,E=f.__lineArray,D=f.__dirtyColors,I=f.__dirtyElements;if(f.__dirtyVertices){for(h=0;h<u;h++){l=w[h].position;t=h*3;C[t]=l.x;C[t+1]=l.y;C[t+
+2]=l.z}b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,C,p)}if(D){for(h=0;h<A;h++){color=x[h];t=h*3;F[t]=color.r;F[t+1]=color.g;F[t+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,F,p)}if(I){for(h=0;h<u;h++)E[h]=h;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,E,p)}};this.setParticleBuffers=function(f,p,h){var l,t,w,x=f.vertices,u=x.length,A=f.colors,C=A.length,F=f.__vertexArray,E=
+f.__colorArray,D=f.__sortArray,I=f.__dirtyVertices,S=f.__dirtyColors;if(h.sortParticles){o.multiplySelf(h.matrix);for(l=0;l<u;l++){t=x[l].position;q.copy(t);o.multiplyVector3(q);D[l]=[q.z,l]}D.sort(function(N,X){return X[0]-N[0]});for(l=0;l<u;l++){t=x[D[l][1]].position;w=l*3;F[w]=t.x;F[w+1]=t.y;F[w+2]=t.z}for(l=0;l<C;l++){w=l*3;color=A[D[l][1]];E[w]=color.r;E[w+1]=color.g;E[w+2]=color.b}}else{if(I)for(l=0;l<u;l++){t=x[l].position;w=l*3;F[w]=t.x;F[w+1]=t.y;F[w+2]=t.z}if(S)for(l=0;l<C;l++){color=A[l];
+w=l*3;E[w]=color.r;E[w+1]=color.g;E[w+2]=color.b}}if(I||h.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,F,p)}if(S||h.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,E,p)}};this.initMaterial=function(f,p,h){if(!f.program){var l,t;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 w,x,u,A;t=u=A=0;for(w=p.length;t<w;t++){x=p[t];x instanceof THREE.DirectionalLight&&u++;x instanceof THREE.PointLight&&A++}if(A+u<=4){p=u;A=A}else{p=Math.ceil(4*u/(A+u));A=
+4-p}t={directional:p,point:A};A=f.fragment_shader;p=f.vertex_shader;w={fog:h,map:f.map,env_map:f.env_map,light_map:f.light_map,vertex_colors:f.vertex_colors,maxDirLights:t.directional,maxPointLights:t.point};h=b.createProgram();t=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+w.maxPointLights,w.fog?"#define USE_FOG":"",w.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",w.map?"#define USE_MAP":"",w.env_map?"#define USE_ENVMAP":
+"",w.light_map?"#define USE_LIGHTMAP":"",w.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");w=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+w.maxPointLights,w.map?"#define USE_MAP":"",w.env_map?"#define USE_ENVMAP":"",w.light_map?"#define USE_LIGHTMAP":"",w.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,e("fragment",t+A));b.attachShader(h,e("vertex",w+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(l in f.uniforms)h.push(l);l=f.program;A=0;for(p=h.length;A<p;A++){t=h[A];l.uniforms[t]=b.getUniformLocation(l,
+t)}f=f.program;l=["position","normal","uv","uv2","tangent","color"];h=0;for(A=l.length;h<A;h++){p=l[h];f.attributes[p]=b.getAttribLocation(f,p)}}};this.setProgram=function(f,p,h,l,t){this.initMaterial(l,p,h);var w=l.program;if(w!=m){b.useProgram(w);m=w}this.loadCamera(w,f);this.loadMatrices(w,t);if(l instanceof THREE.MeshPhongMaterial||l instanceof THREE.MeshLambertMaterial){this.setupLights(w,p);p=this.lights;l.uniforms.enableLighting.value=p.directional.length+p.point.length;l.uniforms.ambientLightColor.value=
+p.ambient;l.uniforms.directionalLightColor.value=p.directional.colors;l.uniforms.directionalLightDirection.value=p.directional.positions;l.uniforms.pointLightColor.value=p.point.colors;l.uniforms.pointLightPosition.value=p.point.positions}if(l instanceof THREE.MeshBasicMaterial||l instanceof THREE.MeshLambertMaterial||l instanceof THREE.MeshPhongMaterial){l.uniforms.diffuse.value.setRGB(l.color.r*l.opacity,l.color.g*l.opacity,l.color.b*l.opacity);l.uniforms.opacity.value=l.opacity;l.uniforms.map.texture=
+l.map;l.uniforms.light_map.texture=l.light_map;l.uniforms.env_map.texture=l.env_map;l.uniforms.reflectivity.value=l.reflectivity;l.uniforms.refraction_ratio.value=l.refraction_ratio;l.uniforms.combine.value=l.combine;l.uniforms.useRefract.value=l.env_map&&l.env_map.mapping instanceof THREE.CubeRefractionMapping;if(h){l.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){l.uniforms.fogNear.value=h.near;l.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)l.uniforms.fogDensity.value=
+h.density}}if(l instanceof THREE.LineBasicMaterial){l.uniforms.diffuse.value.setRGB(l.color.r*l.opacity,l.color.g*l.opacity,l.color.b*l.opacity);l.uniforms.opacity.value=l.opacity;if(h){l.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){l.uniforms.fogNear.value=h.near;l.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)l.uniforms.fogDensity.value=h.density}}if(l instanceof THREE.ParticleBasicMaterial){l.uniforms.psColor.value.setRGB(l.color.r*l.opacity,l.color.g*
+l.opacity,l.color.b*l.opacity);l.uniforms.opacity.value=l.opacity;l.uniforms.size.value=l.size;l.uniforms.map.texture=l.map;if(h){l.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){l.uniforms.fogNear.value=h.near;l.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)l.uniforms.fogDensity.value=h.density}}if(l instanceof THREE.MeshPhongMaterial){l.uniforms.ambient.value.setRGB(l.ambient.r,l.ambient.g,l.ambient.b);l.uniforms.specular.value.setRGB(l.specular.r,l.specular.g,
+l.specular.b);l.uniforms.shininess.value=l.shininess}if(l instanceof THREE.MeshDepthMaterial){l.uniforms.mNear.value=f.near;l.uniforms.mFar.value=f.far;l.uniforms.opacity.value=l.opacity}if(l instanceof THREE.MeshNormalMaterial)l.uniforms.opacity.value=l.opacity;f=l.uniforms;for(var x in f)if(t=w.uniforms[x]){l=f[x];p=l.type;h=l.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(l=l.texture)if(l.image instanceof Array&&l.image.length==6){l=l;h=h;if(l.image.length==6){if(!l.image.__webGLTextureCube&&!l.image.__cubeMapInitialized&&l.image.loadCount==6){l.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,l.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,l.image[p]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);l.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+h);b.bindTexture(b.TEXTURE_CUBE_MAP,l.image.__webGLTextureCube)}}else{l=l;h=h;if(!l.__webGLTexture&&
+l.image.loaded){l.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,l.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,l.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,j(l.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,j(l.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,j(l.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,j(l.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+
+h);b.bindTexture(b.TEXTURE_2D,l.__webGLTexture)}}}return w};this.renderBuffer=function(f,p,h,l,t,w){f=this.setProgram(f,p,h,l,w).attributes;b.bindBuffer(b.ARRAY_BUFFER,t.__webGLVertexBuffer);b.vertexAttribPointer(f.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.position);if(f.color>=0){b.bindBuffer(b.ARRAY_BUFFER,t.__webGLColorBuffer);b.vertexAttribPointer(f.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.color)}if(f.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,t.__webGLNormalBuffer);
+b.vertexAttribPointer(f.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.normal)}if(f.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,t.__webGLTangentBuffer);b.vertexAttribPointer(f.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.tangent)}if(f.uv>=0)if(t.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,t.__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(t.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,
+t.__webGLUV2Buffer);b.vertexAttribPointer(f.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.uv2)}else b.disableVertexAttribArray(f.uv2);if(l.wireframe||l instanceof THREE.LineBasicMaterial){f=l.wireframe_linewidth!==undefined?l.wireframe_linewidth:l.linewidth!==undefined?l.linewidth:1;l=l instanceof THREE.LineBasicMaterial&&w.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(f);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,t.__webGLLineBuffer);b.drawElements(l,t.__webGLLineCount,b.UNSIGNED_SHORT,
+0)}else if(l instanceof THREE.ParticleBasicMaterial)b.drawArrays(b.POINTS,0,t.__webGLParticleCount);else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,t.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,t.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(f,p,h,l,t,w,x){var u,A,C,F,E;C=0;for(F=l.materials.length;C<F;C++){u=l.materials[C];if(u instanceof THREE.MeshFaceMaterial){u=0;for(A=t.materials.length;u<A;u++)if((E=t.materials[u])&&E.blending==w&&E.opacity<1==x){this.setBlending(E.blending);this.setDepthTest(E.depth_test);
+this.renderBuffer(f,p,h,E,t,l)}}else if((E=u)&&E.blending==w&&E.opacity<1==x){this.setBlending(E.blending);this.setDepthTest(E.depth_test);this.renderBuffer(f,p,h,E,t,l)}}};this.renderPassImmediate=function(f,p,h,l,t,w){var x,u,A,C;x=0;for(u=l.materials.length;x<u;x++)if((A=l.materials[x])&&A.blending==t&&A.opacity<1==w){this.setBlending(A.blending);this.setDepthTest(A.depth_test);C=this.setProgram(f,p,h,A,l);l.render(function(F){var E=C;if(!F.__webGLVertexBuffer)F.__webGLVertexBuffer=b.createBuffer();
+if(!F.__webGLNormalBuffer)F.__webGLNormalBuffer=b.createBuffer();if(F.hasPos){b.bindBuffer(b.ARRAY_BUFFER,F.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,F.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(E.attributes.position);b.vertexAttribPointer(E.attributes.position,3,b.FLOAT,false,0,0)}if(F.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,F.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,F.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(E.attributes.normal);b.vertexAttribPointer(E.attributes.normal,
+3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,F.count);F.count=0})}};this.render=function(f,p,h,l){var t,w,x,u,A=f.lights,C=f.fog;p.autoUpdateMatrix&&p.updateMatrix();v.set(p.matrix.flatten());y.set(p.projectionMatrix.flatten());o.multiply(p.projectionMatrix,p.matrix);n[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);n[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);n[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);n[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);
+n[4].set(o.n41-o.n31,o.n42-o.n32,o.n43-o.n33,o.n44-o.n34);n[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(t=0;t<5;t++){u=n[t];u.divideScalar(Math.sqrt(u.x*u.x+u.y*u.y+u.z*u.z))}this.initWebGLObjects(f,p);l=l!==undefined?l:true;if(h&&!h.__webGLFramebuffer){h.__webGLFramebuffer=b.createFramebuffer();h.__webGLRenderbuffer=b.createRenderbuffer();h.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,h.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,
+h.width,h.height);b.bindTexture(b.TEXTURE_2D,h.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,j(h.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,j(h.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,j(h.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,j(h.min_filter));b.texImage2D(b.TEXTURE_2D,0,j(h.format),h.width,h.height,0,j(h.format),j(h.type),null);b.bindFramebuffer(b.FRAMEBUFFER,h.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,
+b.TEXTURE_2D,h.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,h.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(h){t=h.__webGLFramebuffer;u=h.width;x=h.height}else{t=null;u=g.width;x=g.height}if(t!=k){b.bindFramebuffer(b.FRAMEBUFFER,t);b.viewport(0,0,u,x);l&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);k=t}this.autoClear&&this.clear();t=f.__webGLObjects.length;for(l=
+0;l<t;l++){x=f.__webGLObjects[l];u=x.object;if(w=u.visible){if(!(w=!(u instanceof THREE.Mesh)))a:{w=void 0;for(var F=u.matrix,E=-u.geometry.boundingSphere.radius*Math.max(u.scale.x,Math.max(u.scale.y,u.scale.z)),D=0;D<6;D++){w=n[D].x*F.n14+n[D].y*F.n24+n[D].z*F.n34+n[D].w;if(w<=E){w=false;break a}}w=true}w=w}if(w){if(u.autoUpdateMatrix){u.updateMatrix();u._objectMatrixArray.set(u.matrix.flatten())}this.setupMatrices(u,p);x.render=true}else x.render=false}w=f.__webGLObjectsImmediate.length;for(l=0;l<
+w;l++){u=f.__webGLObjectsImmediate[l].object;if(u.visible){if(u.autoUpdateMatrix){u.updateMatrix();u._objectMatrixArray.set(u.matrix.flatten())}this.setupMatrices(u,p)}}for(l=0;l<t;l++){x=f.__webGLObjects[l];if(x.render){u=x.object;x=x.buffer;d(u);this.renderPass(p,A,C,u,x,THREE.NormalBlending,false)}}for(l=0;l<w;l++){u=f.__webGLObjectsImmediate[l].object;if(u.visible){d(u);this.renderPassImmediate(p,A,C,u,THREE.NormalBlending,false)}}for(l=0;l<t;l++){x=f.__webGLObjects[l];if(x.render){u=x.object;
+x=x.buffer;d(u);this.renderPass(p,A,C,u,x,THREE.AdditiveBlending,false);this.renderPass(p,A,C,u,x,THREE.SubtractiveBlending,false);this.renderPass(p,A,C,u,x,THREE.AdditiveBlending,true);this.renderPass(p,A,C,u,x,THREE.SubtractiveBlending,true);this.renderPass(p,A,C,u,x,THREE.NormalBlending,true);this.renderPass(p,A,C,u,x,THREE.BillboardBlending,false)}}for(l=0;l<w;l++){u=f.__webGLObjectsImmediate[l].object;if(u.visible){d(u);this.renderPassImmediate(p,A,C,u,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(E,D,I,S){if(E[D]==undefined){f.__webGLObjects.push({buffer:I,object:S});E[D]=1}}function l(E,D,I){if(E[D]==undefined){f.__webGLObjectsImmediate.push({object:I});E[D]=1}}var t,w,x,u,A,C,F;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={};f.__webGLObjectsImmediate=[]}t=0;for(w=
+f.objects.length;t<w;t++){x=f.objects[t];A=x.geometry;if(f.__webGLObjectsMap[x.id]==undefined){f.__webGLObjectsMap[x.id]={};x._modelViewMatrix=new THREE.Matrix4;x._normalMatrixArray=new Float32Array(9);x._modelViewMatrixArray=new Float32Array(16);x._objectMatrixArray=new Float32Array(16);x._objectMatrixArray.set(x.matrix.flatten())}F=f.__webGLObjectsMap[x.id];if(x instanceof THREE.Mesh){for(u in A.geometryChunks){C=A.geometryChunks[u];if(!C.__webGLVertexBuffer){this.createMeshBuffers(C);this.initMeshBuffers(C,
+x);A.__dirtyVertices=true;A.__dirtyElements=true;A.__dirtyUvs=true;A.__dirtyNormals=true;A.__dirtyTangents=true;A.__dirtyColors=true}if(A.__dirtyVertices||A.__dirtyElements||A.__dirtyUvs||A.__dirtyNormals||A.__dirtyColors||A.__dirtyTangents)this.setMeshBuffers(C,x,b.DYNAMIC_DRAW);h(F,u,C,x)}A.__dirtyVertices=false;A.__dirtyElements=false;A.__dirtyUvs=false;A.__dirtyNormals=false;A.__dirtyTangents=false;A.__dirtyColors=false}else if(x instanceof THREE.Line){if(!A.__webGLVertexBuffer){this.createLineBuffers(A);
+this.initLineBuffers(A);A.__dirtyVertices=true;A.__dirtyElements=true;A.__dirtyColors=true}if(A.__dirtyVertices||A.__dirtyColors)this.setLineBuffers(A,b.DYNAMIC_DRAW);h(F,0,A,x);A.__dirtyVertices=false;A.__dirtyElements=false;A.__dirtyColors=false}else if(x instanceof THREE.ParticleSystem){if(!A.__webGLVertexBuffer){this.createParticleBuffers(A);this.initParticleBuffers(A);A.__dirtyVertices=true;A.__dirtyColors=true}if(A.__dirtyVertices||A.__dirtyColors||x.sortParticles)this.setParticleBuffers(A,
+b.DYNAMIC_DRAW,x,p);h(F,0,A,x);A.__dirtyVertices=false;A.__dirtyColors=false}else x instanceof THREE.MarchingCubes&&l(F,0,x)}};this.removeObject=function(f,p){var h,l;for(h=f.__webGLObjects.length-1;h>=0;h--){l=f.__webGLObjects[h].object;p==l&&f.__webGLObjects.splice(h,1)}};this.setupMatrices=function(f,p){f._modelViewMatrix.multiplyToArray(p.matrix,f.matrix,f._modelViewMatrixArray);f._normalMatrix=THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)};this.loadMatrices=
+function(f,p){b.uniformMatrix4fv(f.uniforms.viewMatrix,false,v);b.uniformMatrix4fv(f.uniforms.projectionMatrix,false,y);b.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,p._modelViewMatrixArray);b.uniformMatrix3fv(f.uniforms.normalMatrix,false,p._normalMatrixArray);b.uniformMatrix4fv(f.uniforms.objectMatrix,false,p._objectMatrixArray)};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\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
 map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",
@@ -232,12 +231,12 @@ THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new
 var GeometryUtils={merge:function(a,c){var d=c instanceof THREE.Mesh,e=a.vertices.length,j=d?c.geometry:c,g=a.vertices,b=j.vertices,m=a.faces,k=j.faces,n=a.uvs;j=j.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var o=0,y=b.length;o<y;o++){var v=new THREE.Vertex(b[o].position.clone());d&&c.matrix.multiplyVector3(v.position);g.push(v)}o=0;for(y=k.length;o<y;o++){b=k[o];var q,z=b.vertexNormals;if(b instanceof THREE.Face3)q=new THREE.Face3(b.a+e,b.b+e,b.c+e);else if(b instanceof THREE.Face4)q=new THREE.Face4(b.a+
 e,b.b+e,b.c+e,b.d+e);q.centroid.copy(b.centroid);q.normal.copy(b.normal);d=0;for(g=z.length;d<g;d++){v=z[d];q.vertexNormals.push(v.clone())}q.materials=b.materials.slice();m.push(q)}o=0;for(y=j.length;o<y;o++){e=j[o];m=[];d=0;for(g=e.length;d<g;d++)m.push(new THREE.UV(e[d].u,e[d].v));n.push(m)}}},ImageUtils={loadTexture:function(a,c,d){var e=new Image;e.onload=function(){this.loaded=true;d&&d(this)};e.src=a;return new THREE.Texture(e,c)},loadArray:function(a,c){var d,e,j=[];d=j.loadCount=0;for(e=
 a.length;d<e;++d){j[d]=new Image;j[d].loaded=0;j[d].onload=function(){j.loadCount+=1;this.loaded=true;c&&c(this)};j[d].src=a[d]}return j}},SceneUtils={loadScene:function(a,c,d,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(j){function g(){for(o in x.objects)if(!D.objects[o]){B=x.objects[o];if(h=D.geometries[B.geometry]){w=[];for(i=0;i<B.materials.length;i++)w[i]=D.materials[B.materials[i]];H=B.position;r=B.rotation;s=B.scale;object=new THREE.Mesh(h,w);object.position.set(H[0],H[1],H[2]);
-object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=B.visible;D.scene.addObject(object);D.objects[o]=object}}}function b(I){return function(S){D.geometries[I]=S;g();A-=1;m()}}function m(){e({total_models:E,total_textures:F,loaded_models:E-A,loaded_textures:F-C},D);A==0&&C==0&&d(D)}var k,n,o,y,v,q,z,B,H,f,p,h,l,t,w,x,u,A,C,E,F,D;x=j.data;u=new THREE.Loader;C=A=0;D={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
+object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=B.visible;D.scene.addObject(object);D.objects[o]=object}}}function b(I){return function(S){D.geometries[I]=S;g();A-=1;m()}}function m(){e({total_models:F,total_textures:E,loaded_models:F-A,loaded_textures:E-C},D);A==0&&C==0&&d(D)}var k,n,o,y,v,q,z,B,H,f,p,h,l,t,w,x,u,A,C,F,E,D;x=j.data;u=new THREE.Loader;C=A=0;D={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
 j=function(){C-=1;m()};for(v in x.cameras){f=x.cameras[v];if(f.type=="perspective")l=new THREE.Camera(f.fov,f.aspect,f.near,f.far);else if(f.type=="ortho"){l=new THREE.Camera;l.projectionMatrix=THREE.Matrix4.makeOrtho(f.left,f.right,f.top,f.bottom,f.near,f.far)}H=f.position;f=f.target;l.position.set(H[0],H[1],H[2]);l.target.position.set(f[0],f[1],f[2]);D.cameras[v]=l}for(y in x.lights){v=x.lights[y];if(v.type=="directional"){H=v.direction;light=new THREE.DirectionalLight;light.position.set(H[0],H[1],
 H[2]);light.position.normalize()}else if(v.type=="point"){H=v.position;light=new THREE.PointLight;light.position.set(H[0],H[1],H[2])}f=v.color;i=v.intensity||1;light.color.setRGB(f[0]*i,f[1]*i,f[2]*i);D.scene.addLight(light);D.lights[y]=light}for(q in x.fogs){y=x.fogs[q];if(y.type=="linear")t=new THREE.Fog(0,y.near,y.far);else if(y.type=="exp2")t=new THREE.FogExp2(0,y.density);f=y.color;t.color.setRGB(f[0],f[1],f[2]);D.fogs[q]=t}if(D.cameras&&x.defaults.camera)D.currentCamera=D.cameras[x.defaults.camera];
-if(D.fogs&&x.defaults.fog)D.scene.fog=D.fogs[x.defaults.fog];f=x.defaults.bgcolor;D.bgColor=new THREE.Color;D.bgColor.setRGB(f[0],f[1],f[2]);D.bgColorAlpha=x.defaults.bgalpha;for(k in x.geometries){q=x.geometries[k];if(q.type=="bin_mesh"||q.type=="ascii_mesh")A+=1}E=A;for(k in x.geometries){q=x.geometries[k];if(q.type=="cube"){h=new Cube(q.width,q.height,q.depth,q.segments_width,q.segments_height,null,q.flipped,q.sides);D.geometries[k]=h}else if(q.type=="plane"){h=new Plane(q.width,q.height,q.segments_width,
+if(D.fogs&&x.defaults.fog)D.scene.fog=D.fogs[x.defaults.fog];f=x.defaults.bgcolor;D.bgColor=new THREE.Color;D.bgColor.setRGB(f[0],f[1],f[2]);D.bgColorAlpha=x.defaults.bgalpha;for(k in x.geometries){q=x.geometries[k];if(q.type=="bin_mesh"||q.type=="ascii_mesh")A+=1}F=A;for(k in x.geometries){q=x.geometries[k];if(q.type=="cube"){h=new Cube(q.width,q.height,q.depth,q.segments_width,q.segments_height,null,q.flipped,q.sides);D.geometries[k]=h}else if(q.type=="plane"){h=new Plane(q.width,q.height,q.segments_width,
 q.segments_height);D.geometries[k]=h}else if(q.type=="sphere"){h=new Sphere(q.radius,q.segments_width,q.segments_height);D.geometries[k]=h}else if(q.type=="cylinder"){h=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);D.geometries[k]=h}else if(q.type=="torus"){h=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);D.geometries[k]=h}else if(q.type=="icosahedron"){h=new Icosahedron(q.subdivisions);D.geometries[k]=h}else if(q.type=="bin_mesh")u.loadBinary({model:q.url,callback:b(k)});
-else q.type=="ascii_mesh"&&u.loadAscii({model:q.url,callback:b(k)})}for(z in x.textures){k=x.textures[z];C+=k.url instanceof Array?k.url.length:1}F=C;for(z in x.textures){k=x.textures[z];if(k.mapping!=undefined&&THREE[k.mapping]!=undefined)k.mapping=new THREE[k.mapping];if(k.url instanceof Array){q=ImageUtils.loadArray(k.url,j);q=new THREE.Texture(q,k.mapping)}else{q=ImageUtils.loadTexture(k.url,k.mapping,j);if(THREE[k.min_filter]!=undefined)q.min_filter=THREE[k.min_filter];if(THREE[k.mag_filter]!=
+else q.type=="ascii_mesh"&&u.loadAscii({model:q.url,callback:b(k)})}for(z in x.textures){k=x.textures[z];C+=k.url instanceof Array?k.url.length:1}E=C;for(z in x.textures){k=x.textures[z];if(k.mapping!=undefined&&THREE[k.mapping]!=undefined)k.mapping=new THREE[k.mapping];if(k.url instanceof Array){q=ImageUtils.loadArray(k.url,j);q=new THREE.Texture(q,k.mapping)}else{q=ImageUtils.loadTexture(k.url,k.mapping,j);if(THREE[k.min_filter]!=undefined)q.min_filter=THREE[k.min_filter];if(THREE[k.mag_filter]!=
 undefined)q.mag_filter=THREE[k.mag_filter]}D.textures[z]=q}for(n in x.materials){z=x.materials[n];for(p in z.parameters)if(p=="env_map"||p=="map"||p=="light_map")z.parameters[p]=D.textures[z.parameters[p]];else if(p=="shading")z.parameters[p]=z.parameters[p]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(p=="blending")z.parameters[p]=THREE[z.parameters[p]]?THREE[z.parameters[p]]:THREE.NormalBlending;else if(p=="combine")z.parameters[p]=z.parameters[p]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
 z=new THREE[z.type](z.parameters);D.materials[n]=z}g();c(D)}},addMesh:function(a,c,d,e,j,g,b,m,k,n){c=new THREE.Mesh(c,n);c.scale.x=c.scale.y=c.scale.z=d;c.position.x=e;c.position.y=j;c.position.z=g;c.rotation.x=b;c.rotation.y=m;c.rotation.z=k;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,d){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=d;d=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,uniforms:e.uniforms});c=new THREE.Mesh(new Cube(c,
 c,c,1,1,null,true),d);a.addObject(c);return c},addPanoramaCube:function(a,c,d){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));c=new THREE.Mesh(new Cube(c,
@@ -251,8 +250,8 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying ve
 value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertex_shader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
 film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},grayscale:{type:"i",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nconst float fNintensity = 0.35;\nconst float fSintensity = 0.35;\nconst float fScount = 4096.0;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time *  1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin(vUv.y * fScount), cos(vUv.y * fScount) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * fSintensity;\ncResult = cTextureScreen.rgb + clamp( fNintensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor =  vec4( cResult, cTextureScreen.a );\n}"},
 screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
-fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,d,e,j,g=2*Math.ceil(a*3)+1;if(g>25)g=25;j=(g-1)*0.5;d=Array(g);for(c=e=0;c<g;++c){d[c]=Math.exp(-((c-j)*(c-j))/(2*a*a));e+=d[c]}for(c=0;c<g;++c)d[c]/=e;return d}},Cube=function(a,c,d,e,j,g,b,m){function k(B,H,f,p,h,l,t,w){var x,u,A=e||1,C=j||1,E=A+1,F=C+1,D=h/2,I=l/2;h=h/A;var S=l/C,N=n.vertices.length;if(B=="x"&&H=="y"||B=="y"&&H=="x")x="z";else if(B=="x"&&H=="z"||B=="z"&&H=="x")x="y";else if(B==
-"z"&&H=="y"||B=="y"&&H=="z")x="x";for(u=0;u<F;u++)for(l=0;l<E;l++){var X=new THREE.Vector3;X[B]=(l*h-D)*f;X[H]=(u*S-I)*p;X[x]=t;n.vertices.push(new THREE.Vertex(X))}for(u=0;u<C;u++)for(l=0;l<A;l++){n.faces.push(new THREE.Face4(l+E*u+N,l+E*(u+1)+N,l+1+E*(u+1)+N,l+1+E*u+N,null,w));n.uvs.push([new THREE.UV(l/A,u/C),new THREE.UV(l/A,(u+1)/C),new THREE.UV((l+1)/A,(u+1)/C),new THREE.UV((l+1)/A,u/C)])}}THREE.Geometry.call(this);var n=this,o=a/2,y=c/2,v=d/2;b=b?-1:1;if(g!==undefined)if(g instanceof Array)this.materials=
+fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,d,e,j,g=2*Math.ceil(a*3)+1;if(g>25)g=25;j=(g-1)*0.5;d=Array(g);for(c=e=0;c<g;++c){d[c]=Math.exp(-((c-j)*(c-j))/(2*a*a));e+=d[c]}for(c=0;c<g;++c)d[c]/=e;return d}},Cube=function(a,c,d,e,j,g,b,m){function k(B,H,f,p,h,l,t,w){var x,u,A=e||1,C=j||1,F=A+1,E=C+1,D=h/2,I=l/2;h=h/A;var S=l/C,N=n.vertices.length;if(B=="x"&&H=="y"||B=="y"&&H=="x")x="z";else if(B=="x"&&H=="z"||B=="z"&&H=="x")x="y";else if(B==
+"z"&&H=="y"||B=="y"&&H=="z")x="x";for(u=0;u<E;u++)for(l=0;l<F;l++){var X=new THREE.Vector3;X[B]=(l*h-D)*f;X[H]=(u*S-I)*p;X[x]=t;n.vertices.push(new THREE.Vertex(X))}for(u=0;u<C;u++)for(l=0;l<A;l++){n.faces.push(new THREE.Face4(l+F*u+N,l+F*(u+1)+N,l+1+F*(u+1)+N,l+1+F*u+N,null,w));n.uvs.push([new THREE.UV(l/A,u/C),new THREE.UV(l/A,(u+1)/C),new THREE.UV((l+1)/A,(u+1)/C),new THREE.UV((l+1)/A,u/C)])}}THREE.Geometry.call(this);var n=this,o=a/2,y=c/2,v=d/2;b=b?-1:1;if(g!==undefined)if(g instanceof Array)this.materials=
 g;else{this.materials=[];for(var q=0;q<6;q++)this.materials.push([g])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(m!=undefined)for(var z in m)if(this.sides[z]!=undefined)this.sides[z]=m[z];this.sides.px&&k("z","y",1*b,-1,d,c,-o,this.materials[0]);this.sides.nx&&k("z","y",-1*b,-1,d,c,o,this.materials[1]);this.sides.py&&k("x","z",1*b,1,a,d,y,this.materials[2]);this.sides.ny&&k("x","z",1*b,-1,a,d,-y,this.materials[3]);this.sides.pz&&k("x","y",1*b,-1,a,c,v,this.materials[4]);
 this.sides.nz&&k("x","y",-1*b,-1,a,c,-v,this.materials[5]);(function(){for(var B=[],H=[],f=0,p=n.vertices.length;f<p;f++){for(var h=n.vertices[f],l=false,t=0,w=B.length;t<w;t++){var x=B[t];if(h.position.x==x.position.x&&h.position.y==x.position.y&&h.position.z==x.position.z){H[f]=t;l=true;break}}if(!l){H[f]=B.length;B.push(new THREE.Vertex(h.position.clone()))}}f=0;for(p=n.faces.length;f<p;f++){h=n.faces[f];h.a=H[h.a];h.b=H[h.b];h.c=H[h.c];h.d=H[h.d]}n.vertices=B})();this.computeCentroids();this.computeFaceNormals();
 this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
@@ -274,9 +273,9 @@ THREE.MarchingCubes=function(a,c){THREE.Object3D.call(this);this.materials=c ins
 0;this.hasNormal=this.hasPos=false;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(d,e,j){return d+(e-d)*j};this.VIntX=function(d,e,j,g,b,m,k,n,o,y){b=(b-o)/(y-o);o=this.normal_cache;e[g]=m+b*this.delta;e[g+1]=k;e[g+2]=n;j[g]=this.lerp(o[d],o[d+3],b);j[g+1]=this.lerp(o[d+1],o[d+4],b);j[g+2]=this.lerp(o[d+2],o[d+5],b)};this.VIntY=function(d,e,j,g,b,m,k,n,o,y){b=(b-o)/(y-o);o=this.normal_cache;e[g]=m;e[g+1]=k+b*this.delta;e[g+
 2]=n;e=d+this.yd*3;j[g]=this.lerp(o[d],o[e],b);j[g+1]=this.lerp(o[d+1],o[e+1],b);j[g+2]=this.lerp(o[d+2],o[e+2],b)};this.VIntZ=function(d,e,j,g,b,m,k,n,o,y){b=(b-o)/(y-o);o=this.normal_cache;e[g]=m;e[g+1]=k;e[g+2]=n+b*this.delta;e=d+this.zd*3;j[g]=this.lerp(o[d],o[e],b);j[g+1]=this.lerp(o[d+1],o[e+1],b);j[g+2]=this.lerp(o[d+2],o[e+2],b)};this.compNorm=function(d){var e=d*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[d-1]-this.field[d+1];this.normal_cache[e+1]=this.field[d-this.yd]-
 this.field[d+this.yd];this.normal_cache[e+2]=this.field[d-this.zd]-this.field[d+this.zd]}};this.polygonize=function(d,e,j,g,b,m){var k=g+1,n=g+this.yd,o=g+this.zd,y=k+this.yd,v=k+this.zd,q=g+this.yd+this.zd,z=k+this.yd+this.zd,B=0,H=this.field[g],f=this.field[k],p=this.field[n],h=this.field[y],l=this.field[o],t=this.field[v],w=this.field[q],x=this.field[z];if(H<b)B|=1;if(f<b)B|=2;if(p<b)B|=8;if(h<b)B|=4;if(l<b)B|=16;if(t<b)B|=32;if(w<b)B|=128;if(x<b)B|=64;var u=THREE.edgeTable[B];if(u==0)return 0;
-var A=this.delta,C=d+A,E=e+A;A=j+A;if(u&1){this.compNorm(g);this.compNorm(k);this.VIntX(g*3,this.vlist,this.nlist,0,b,d,e,j,H,f)}if(u&2){this.compNorm(k);this.compNorm(y);this.VIntY(k*3,this.vlist,this.nlist,3,b,C,e,j,f,h)}if(u&4){this.compNorm(n);this.compNorm(y);this.VIntX(n*3,this.vlist,this.nlist,6,b,d,E,j,p,h)}if(u&8){this.compNorm(g);this.compNorm(n);this.VIntY(g*3,this.vlist,this.nlist,9,b,d,e,j,H,p)}if(u&16){this.compNorm(o);this.compNorm(v);this.VIntX(o*3,this.vlist,this.nlist,12,b,d,e,A,
-l,t)}if(u&32){this.compNorm(v);this.compNorm(z);this.VIntY(v*3,this.vlist,this.nlist,15,b,C,e,A,t,x)}if(u&64){this.compNorm(q);this.compNorm(z);this.VIntX(q*3,this.vlist,this.nlist,18,b,d,E,A,w,x)}if(u&128){this.compNorm(o);this.compNorm(q);this.VIntY(o*3,this.vlist,this.nlist,21,b,d,e,A,l,w)}if(u&256){this.compNorm(g);this.compNorm(o);this.VIntZ(g*3,this.vlist,this.nlist,24,b,d,e,j,H,l)}if(u&512){this.compNorm(k);this.compNorm(v);this.VIntZ(k*3,this.vlist,this.nlist,27,b,C,e,j,f,t)}if(u&1024){this.compNorm(y);
-this.compNorm(z);this.VIntZ(y*3,this.vlist,this.nlist,30,b,C,E,j,h,x)}if(u&2048){this.compNorm(n);this.compNorm(q);this.VIntZ(n*3,this.vlist,this.nlist,33,b,d,E,j,p,w)}B<<=4;for(b=g=0;THREE.triTable[B+b]!=-1;){d=B+b;e=d+1;j=d+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[d],3*THREE.triTable[e],3*THREE.triTable[j],m);b+=3;g++}return g};this.posnormtriv=function(d,e,j,g,b,m){var k=this.count*3;this.positionArray[k]=d[j];this.positionArray[k+1]=d[j+1];this.positionArray[k+2]=d[j+2];this.positionArray[k+
+var A=this.delta,C=d+A,F=e+A;A=j+A;if(u&1){this.compNorm(g);this.compNorm(k);this.VIntX(g*3,this.vlist,this.nlist,0,b,d,e,j,H,f)}if(u&2){this.compNorm(k);this.compNorm(y);this.VIntY(k*3,this.vlist,this.nlist,3,b,C,e,j,f,h)}if(u&4){this.compNorm(n);this.compNorm(y);this.VIntX(n*3,this.vlist,this.nlist,6,b,d,F,j,p,h)}if(u&8){this.compNorm(g);this.compNorm(n);this.VIntY(g*3,this.vlist,this.nlist,9,b,d,e,j,H,p)}if(u&16){this.compNorm(o);this.compNorm(v);this.VIntX(o*3,this.vlist,this.nlist,12,b,d,e,A,
+l,t)}if(u&32){this.compNorm(v);this.compNorm(z);this.VIntY(v*3,this.vlist,this.nlist,15,b,C,e,A,t,x)}if(u&64){this.compNorm(q);this.compNorm(z);this.VIntX(q*3,this.vlist,this.nlist,18,b,d,F,A,w,x)}if(u&128){this.compNorm(o);this.compNorm(q);this.VIntY(o*3,this.vlist,this.nlist,21,b,d,e,A,l,w)}if(u&256){this.compNorm(g);this.compNorm(o);this.VIntZ(g*3,this.vlist,this.nlist,24,b,d,e,j,H,l)}if(u&512){this.compNorm(k);this.compNorm(v);this.VIntZ(k*3,this.vlist,this.nlist,27,b,C,e,j,f,t)}if(u&1024){this.compNorm(y);
+this.compNorm(z);this.VIntZ(y*3,this.vlist,this.nlist,30,b,C,F,j,h,x)}if(u&2048){this.compNorm(n);this.compNorm(q);this.VIntZ(n*3,this.vlist,this.nlist,33,b,d,F,j,p,w)}B<<=4;for(b=g=0;THREE.triTable[B+b]!=-1;){d=B+b;e=d+1;j=d+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[d],3*THREE.triTable[e],3*THREE.triTable[j],m);b+=3;g++}return g};this.posnormtriv=function(d,e,j,g,b,m){var k=this.count*3;this.positionArray[k]=d[j];this.positionArray[k+1]=d[j+1];this.positionArray[k+2]=d[j+2];this.positionArray[k+
 3]=d[g];this.positionArray[k+4]=d[g+1];this.positionArray[k+5]=d[g+2];this.positionArray[k+6]=d[b];this.positionArray[k+7]=d[b+1];this.positionArray[k+8]=d[b+2];this.normalArray[k]=e[j];this.normalArray[k+1]=e[j+1];this.normalArray[k+2]=e[j+2];this.normalArray[k+3]=e[g];this.normalArray[k+4]=e[g+1];this.normalArray[k+5]=e[g+2];this.normalArray[k+6]=e[b];this.normalArray[k+7]=e[b+1];this.normalArray[k+8]=e[b+2];this.hasNormal=this.hasPos=true;this.count+=3;this.count>=this.maxCount-3&&m(this)};this.begin=
 function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(d){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;d(this)}};this.addBall=function(d,e,j,g,b){var m=this.size*Math.sqrt(g/b),k=j*this.size,n=e*this.size,o=d*this.size,y=Math.floor(k-m);if(y<1)y=1;k=Math.floor(k+m);if(k>this.size-1)k=this.size-1;var v=Math.floor(n-m);if(v<1)v=1;n=Math.floor(n+m);if(n>this.size-1)n=this.size-1;var q=Math.floor(o-m);if(q<1)q=1;m=Math.floor(o+m);
 if(m>this.size-1)m=this.size-1;var z,B,H,f,p,h;for(y=y;y<k;y++){o=this.size2*y;B=y/this.size-j;p=B*B;for(B=v;B<n;B++){H=o+this.size*B;z=B/this.size-e;h=z*z;for(z=q;z<m;z++){f=z/this.size-d;f=g/(1.0E-6+f*f+h+p)-b;if(f>0)this.field[H+z]+=f}}}};this.addPlaneX=function(d,e){var j,g,b,m,k,n=this.size,o=this.yd,y=this.zd,v=this.field,q=n*Math.sqrt(d/e);if(q>n)q=n;for(j=0;j<q;j++){g=j/n;g=g*g;m=d/(1.0E-4+g)-e;if(m>0)for(g=0;g<n;g++){k=j+g*o;for(b=0;b<n;b++)v[y*b+k]+=m}}};this.addPlaneY=function(d,e){var j,
@@ -313,19 +312,19 @@ c},loadAsciiOld:function(a,c){var d=document.createElement("script");d.type="tex
 THREE.Loader.prototype.extractUrlbase(c),j=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(b){THREE.Loader.prototype.loadAjaxBuffers(b.data.buffers,b.data.materials,d,j,e,g)};c.onerror=function(b){alert("worker.onerror: "+b.message+"\n"+b.data);b.preventDefault()};c.postMessage(a)},loadAjaxBuffers:function(a,c,d,e,j,g){var b=new XMLHttpRequest,m=e+"/"+a,k=0;
 b.onreadystatechange=function(){if(b.readyState==4)b.status==200||b.status==0?THREE.Loader.prototype.createBinModel(b.responseText,d,j,c):alert("Couldn't load ["+m+"] ["+b.status+"]");else if(b.readyState==3){if(g){if(k==0)k=b.getResponseHeader("Content-Length");g({total:k,loaded:b.responseText.length})}}else if(b.readyState==2)k=b.getResponseHeader("Content-Length")};b.open("GET",m,true);b.overrideMimeType("text/plain; charset=x-user-defined");b.setRequestHeader("Content-Type","text/plain");b.send(null)},
 createBinModel:function(a,c,d,e){var j=function(g){function b(G,J){var L=o(G,J),W=o(G,J+1),ca=o(G,J+2),ma=o(G,J+3),ia=(ma<<1&255|ca>>7)-127;L=(ca&127)<<16|W<<8|L;if(L==0&&ia==-127)return 0;return(1-2*(ma>>7))*(1+L*Math.pow(2,-23))*Math.pow(2,ia)}function m(G,J){var L=o(G,J),W=o(G,J+1),ca=o(G,J+2);return(o(G,J+3)<<24)+(ca<<16)+(W<<8)+L}function k(G,J){var L=o(G,J);return(o(G,J+1)<<8)+L}function n(G,J){var L=o(G,J);return L>127?L-256:L}function o(G,J){return G.charCodeAt(J)&255}function y(G){var J,
-L,W;J=m(a,G);L=m(a,G+w);W=m(a,G+x);G=k(a,G+u);THREE.Loader.prototype.f3(f,J,L,W,G)}function v(G){var J,L,W,ca,ma,ia;J=m(a,G);L=m(a,G+w);W=m(a,G+x);ca=k(a,G+u);ma=m(a,G+A);ia=m(a,G+C);G=m(a,G+E);THREE.Loader.prototype.f3n(f,l,J,L,W,ca,ma,ia,G)}function q(G){var J,L,W,ca;J=m(a,G);L=m(a,G+F);W=m(a,G+D);ca=m(a,G+I);G=k(a,G+S);THREE.Loader.prototype.f4(f,J,L,W,ca,G)}function z(G){var J,L,W,ca,ma,ia,ra,la;J=m(a,G);L=m(a,G+F);W=m(a,G+D);ca=m(a,G+I);ma=k(a,G+S);ia=m(a,G+N);ra=m(a,G+X);la=m(a,G+Y);G=m(a,G+
-T);THREE.Loader.prototype.f4n(f,l,J,L,W,ca,ma,ia,ra,la,G)}function B(G){var J,L;J=m(a,G);L=m(a,G+V);G=m(a,G+da);THREE.Loader.prototype.uv3(f.uvs,t[J*2],t[J*2+1],t[L*2],t[L*2+1],t[G*2],t[G*2+1])}function H(G){var J,L,W;J=m(a,G);L=m(a,G+R);W=m(a,G+O);G=m(a,G+ba);THREE.Loader.prototype.uv4(f.uvs,t[J*2],t[J*2+1],t[L*2],t[L*2+1],t[W*2],t[W*2+1],t[G*2],t[G*2+1])}var f=this,p=0,h,l=[],t=[],w,x,u,A,C,E,F,D,I,S,N,X,Y,T,V,da,R,O,ba,aa,K,P,U,ha,ga;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,
+L,W;J=m(a,G);L=m(a,G+w);W=m(a,G+x);G=k(a,G+u);THREE.Loader.prototype.f3(f,J,L,W,G)}function v(G){var J,L,W,ca,ma,ia;J=m(a,G);L=m(a,G+w);W=m(a,G+x);ca=k(a,G+u);ma=m(a,G+A);ia=m(a,G+C);G=m(a,G+F);THREE.Loader.prototype.f3n(f,l,J,L,W,ca,ma,ia,G)}function q(G){var J,L,W,ca;J=m(a,G);L=m(a,G+E);W=m(a,G+D);ca=m(a,G+I);G=k(a,G+S);THREE.Loader.prototype.f4(f,J,L,W,ca,G)}function z(G){var J,L,W,ca,ma,ia,ra,la;J=m(a,G);L=m(a,G+E);W=m(a,G+D);ca=m(a,G+I);ma=k(a,G+S);ia=m(a,G+N);ra=m(a,G+X);la=m(a,G+Z);G=m(a,G+
+T);THREE.Loader.prototype.f4n(f,l,J,L,W,ca,ma,ia,ra,la,G)}function B(G){var J,L;J=m(a,G);L=m(a,G+V);G=m(a,G+da);THREE.Loader.prototype.uv3(f.uvs,t[J*2],t[J*2+1],t[L*2],t[L*2+1],t[G*2],t[G*2+1])}function H(G){var J,L,W;J=m(a,G);L=m(a,G+R);W=m(a,G+O);G=m(a,G+ba);THREE.Loader.prototype.uv4(f.uvs,t[J*2],t[J*2+1],t[L*2],t[L*2+1],t[W*2],t[W*2+1],t[G*2],t[G*2+1])}var f=this,p=0,h,l=[],t=[],w,x,u,A,C,F,E,D,I,S,N,X,Z,T,V,da,R,O,ba,aa,K,P,U,ha,ga;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,
 e,g);h={signature:a.substr(p,8),header_bytes:o(a,p+8),vertex_coordinate_bytes:o(a,p+9),normal_coordinate_bytes:o(a,p+10),uv_coordinate_bytes:o(a,p+11),vertex_index_bytes:o(a,p+12),normal_index_bytes:o(a,p+13),uv_index_bytes:o(a,p+14),material_index_bytes:o(a,p+15),nvertices:m(a,p+16),nnormals:m(a,p+16+4),nuvs:m(a,p+16+8),ntri_flat:m(a,p+16+12),ntri_smooth:m(a,p+16+16),ntri_flat_uv:m(a,p+16+20),ntri_smooth_uv:m(a,p+16+24),nquad_flat:m(a,p+16+28),nquad_smooth:m(a,p+16+32),nquad_flat_uv:m(a,p+16+36),
-nquad_smooth_uv:m(a,p+16+40)};p+=h.header_bytes;w=h.vertex_index_bytes;x=h.vertex_index_bytes*2;u=h.vertex_index_bytes*3;A=h.vertex_index_bytes*3+h.material_index_bytes;C=h.vertex_index_bytes*3+h.material_index_bytes+h.normal_index_bytes;E=h.vertex_index_bytes*3+h.material_index_bytes+h.normal_index_bytes*2;F=h.vertex_index_bytes;D=h.vertex_index_bytes*2;I=h.vertex_index_bytes*3;S=h.vertex_index_bytes*4;N=h.vertex_index_bytes*4+h.material_index_bytes;X=h.vertex_index_bytes*4+h.material_index_bytes+
-h.normal_index_bytes;Y=h.vertex_index_bytes*4+h.material_index_bytes+h.normal_index_bytes*2;T=h.vertex_index_bytes*4+h.material_index_bytes+h.normal_index_bytes*3;V=h.uv_index_bytes;da=h.uv_index_bytes*2;R=h.uv_index_bytes;O=h.uv_index_bytes*2;ba=h.uv_index_bytes*3;g=h.vertex_index_bytes*3+h.material_index_bytes;ga=h.vertex_index_bytes*4+h.material_index_bytes;aa=h.ntri_flat*g;K=h.ntri_smooth*(g+h.normal_index_bytes*3);P=h.ntri_flat_uv*(g+h.uv_index_bytes*3);U=h.ntri_smooth_uv*(g+h.normal_index_bytes*
+nquad_smooth_uv:m(a,p+16+40)};p+=h.header_bytes;w=h.vertex_index_bytes;x=h.vertex_index_bytes*2;u=h.vertex_index_bytes*3;A=h.vertex_index_bytes*3+h.material_index_bytes;C=h.vertex_index_bytes*3+h.material_index_bytes+h.normal_index_bytes;F=h.vertex_index_bytes*3+h.material_index_bytes+h.normal_index_bytes*2;E=h.vertex_index_bytes;D=h.vertex_index_bytes*2;I=h.vertex_index_bytes*3;S=h.vertex_index_bytes*4;N=h.vertex_index_bytes*4+h.material_index_bytes;X=h.vertex_index_bytes*4+h.material_index_bytes+
+h.normal_index_bytes;Z=h.vertex_index_bytes*4+h.material_index_bytes+h.normal_index_bytes*2;T=h.vertex_index_bytes*4+h.material_index_bytes+h.normal_index_bytes*3;V=h.uv_index_bytes;da=h.uv_index_bytes*2;R=h.uv_index_bytes;O=h.uv_index_bytes*2;ba=h.uv_index_bytes*3;g=h.vertex_index_bytes*3+h.material_index_bytes;ga=h.vertex_index_bytes*4+h.material_index_bytes;aa=h.ntri_flat*g;K=h.ntri_smooth*(g+h.normal_index_bytes*3);P=h.ntri_flat_uv*(g+h.uv_index_bytes*3);U=h.ntri_smooth_uv*(g+h.normal_index_bytes*
 3+h.uv_index_bytes*3);ha=h.nquad_flat*ga;g=h.nquad_smooth*(ga+h.normal_index_bytes*4);ga=h.nquad_flat_uv*(ga+h.uv_index_bytes*4);p+=function(G){var J,L,W,ca=h.vertex_coordinate_bytes*3,ma=G+h.nvertices*ca;for(G=G;G<ma;G+=ca){J=b(a,G);L=b(a,G+h.vertex_coordinate_bytes);W=b(a,G+h.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(f,J,L,W)}return h.nvertices*ca}(p);p+=function(G){var J,L,W,ca=h.normal_coordinate_bytes*3,ma=G+h.nnormals*ca;for(G=G;G<ma;G+=ca){J=n(a,G);L=n(a,G+h.normal_coordinate_bytes);
 W=n(a,G+h.normal_coordinate_bytes*2);l.push(J/127,L/127,W/127)}return h.nnormals*ca}(p);p+=function(G){var J,L,W=h.uv_coordinate_bytes*2,ca=G+h.nuvs*W;for(G=G;G<ca;G+=W){J=b(a,G);L=b(a,G+h.uv_coordinate_bytes);t.push(J,L)}return h.nuvs*W}(p);p=p;aa=p+aa;K=aa+K;P=K+P;U=P+U;ha=U+ha;g=ha+g;ga=g+ga;(function(G){var J,L=h.vertex_index_bytes*3+h.material_index_bytes,W=L+h.uv_index_bytes*3,ca=G+h.ntri_flat_uv*W;for(J=G;J<ca;J+=W){y(J);B(J+L)}return ca-G})(K);(function(G){var J,L=h.vertex_index_bytes*3+h.material_index_bytes+
 h.normal_index_bytes*3,W=L+h.uv_index_bytes*3,ca=G+h.ntri_smooth_uv*W;for(J=G;J<ca;J+=W){v(J);B(J+L)}return ca-G})(P);(function(G){var J,L=h.vertex_index_bytes*4+h.material_index_bytes,W=L+h.uv_index_bytes*4,ca=G+h.nquad_flat_uv*W;for(J=G;J<ca;J+=W){q(J);H(J+L)}return ca-G})(g);(function(G){var J,L=h.vertex_index_bytes*4+h.material_index_bytes+h.normal_index_bytes*4,W=L+h.uv_index_bytes*4,ca=G+h.nquad_smooth_uv*W;for(J=G;J<ca;J+=W){z(J);H(J+L)}return ca-G})(ga);(function(G){var J,L=h.vertex_index_bytes*
 3+h.material_index_bytes,W=G+h.ntri_flat*L;for(J=G;J<W;J+=L)y(J);return W-G})(p);(function(G){var J,L=h.vertex_index_bytes*3+h.material_index_bytes+h.normal_index_bytes*3,W=G+h.ntri_smooth*L;for(J=G;J<W;J+=L)v(J);return W-G})(aa);(function(G){var J,L=h.vertex_index_bytes*4+h.material_index_bytes,W=G+h.nquad_flat*L;for(J=G;J<W;J+=L)q(J);return W-G})(U);(function(G){var J,L=h.vertex_index_bytes*4+h.material_index_bytes+h.normal_index_bytes*4,W=G+h.nquad_smooth*L;for(J=G;J<W;J+=L)z(J);return W-G})(ha);
 this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};j.prototype=new THREE.Geometry;j.prototype.constructor=j;c(new j(d))},createModel:function(a,c,d){var e=function(j){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,a.materials,j);(function(){var b,m,k,n,o;b=0;for(m=a.vertices.length;b<m;b+=3){k=a.vertices[b];n=a.vertices[b+1];o=a.vertices[b+2];THREE.Loader.prototype.v(g,k,n,o)}})();(function(){function b(z,B){THREE.Loader.prototype.f3(g,z[B],
 z[B+1],z[B+2],z[B+3])}function m(z,B){THREE.Loader.prototype.f3n(g,a.normals,z[B],z[B+1],z[B+2],z[B+3],z[B+4],z[B+5],z[B+6])}function k(z,B){THREE.Loader.prototype.f4(g,z[B],z[B+1],z[B+2],z[B+3],z[B+4])}function n(z,B){THREE.Loader.prototype.f4n(g,a.normals,z[B],z[B+1],z[B+2],z[B+3],z[B+4],z[B+5],z[B+6],z[B+7],z[B+8])}function o(z,B){var H,f,p,h,l,t,w,x,u;H=z[B];f=z[B+1];p=z[B+2];h=a.uvs[H*2];w=a.uvs[H*2+1];l=a.uvs[f*2];x=a.uvs[f*2+1];t=a.uvs[p*2];u=a.uvs[p*2+1];THREE.Loader.prototype.uv3(g.uvs,h,
-w,l,x,t,u);if(a.uvs2){h=a.uvs2[H*2];w=a.uvs2[H*2+1];l=a.uvs2[f*2];x=a.uvs2[f*2+1];t=a.uvs2[p*2];u=a.uvs2[p*2+1];THREE.Loader.prototype.uv3(g.uvs2,h,1-w,l,1-x,t,1-u)}}function y(z,B){var H,f,p,h,l,t,w,x,u,A,C,E;H=z[B];f=z[B+1];p=z[B+2];h=z[B+3];l=a.uvs[H*2];u=a.uvs[H*2+1];t=a.uvs[f*2];A=a.uvs[f*2+1];w=a.uvs[p*2];C=a.uvs[p*2+1];x=a.uvs[h*2];E=a.uvs[h*2+1];THREE.Loader.prototype.uv4(g.uvs,l,u,t,A,w,C,x,E);if(a.uvs2){l=a.uvs2[H*2];u=a.uvs2[H*2+1];t=a.uvs2[f*2];A=a.uvs2[f*2+1];w=a.uvs2[p*2];C=a.uvs2[p*
-2+1];x=a.uvs2[h*2];E=a.uvs2[h*2+1];THREE.Loader.prototype.uv4(g.uvs2,l,1-u,t,1-A,w,1-C,x,1-E)}}var v,q;v=0;for(q=a.triangles_uv.length;v<q;v+=7){b(a.triangles_uv,v);o(a.triangles_uv,v+4)}v=0;for(q=a.triangles_n_uv.length;v<q;v+=10){m(a.triangles_n_uv,v);o(a.triangles_n_uv,v+7)}v=0;for(q=a.quads_uv.length;v<q;v+=9){k(a.quads_uv,v);y(a.quads_uv,v+5)}v=0;for(q=a.quads_n_uv.length;v<q;v+=13){n(a.quads_n_uv,v);y(a.quads_n_uv,v+9)}v=0;for(q=a.triangles.length;v<q;v+=4)b(a.triangles,v);v=0;for(q=a.triangles_n.length;v<
+w,l,x,t,u);if(a.uvs2){h=a.uvs2[H*2];w=a.uvs2[H*2+1];l=a.uvs2[f*2];x=a.uvs2[f*2+1];t=a.uvs2[p*2];u=a.uvs2[p*2+1];THREE.Loader.prototype.uv3(g.uvs2,h,1-w,l,1-x,t,1-u)}}function y(z,B){var H,f,p,h,l,t,w,x,u,A,C,F;H=z[B];f=z[B+1];p=z[B+2];h=z[B+3];l=a.uvs[H*2];u=a.uvs[H*2+1];t=a.uvs[f*2];A=a.uvs[f*2+1];w=a.uvs[p*2];C=a.uvs[p*2+1];x=a.uvs[h*2];F=a.uvs[h*2+1];THREE.Loader.prototype.uv4(g.uvs,l,u,t,A,w,C,x,F);if(a.uvs2){l=a.uvs2[H*2];u=a.uvs2[H*2+1];t=a.uvs2[f*2];A=a.uvs2[f*2+1];w=a.uvs2[p*2];C=a.uvs2[p*
+2+1];x=a.uvs2[h*2];F=a.uvs2[h*2+1];THREE.Loader.prototype.uv4(g.uvs2,l,1-u,t,1-A,w,1-C,x,1-F)}}var v,q;v=0;for(q=a.triangles_uv.length;v<q;v+=7){b(a.triangles_uv,v);o(a.triangles_uv,v+4)}v=0;for(q=a.triangles_n_uv.length;v<q;v+=10){m(a.triangles_n_uv,v);o(a.triangles_n_uv,v+7)}v=0;for(q=a.quads_uv.length;v<q;v+=9){k(a.quads_uv,v);y(a.quads_uv,v+5)}v=0;for(q=a.quads_n_uv.length;v<q;v+=13){n(a.quads_n_uv,v);y(a.quads_n_uv,v+9)}v=0;for(q=a.triangles.length;v<q;v+=4)b(a.triangles,v);v=0;for(q=a.triangles_n.length;v<
 q;v+=7)m(a.triangles_n,v);v=0;for(q=a.quads.length;v<q;v+=5)k(a.quads,v);v=0;for(q=a.quads_n.length;v<q;v+=9)n(a.quads_n,v)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;c(new e(d))},v:function(a,c,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,d,e)))},f3:function(a,c,d,e,j){a.faces.push(new THREE.Face3(c,d,e,null,a.materials[j]))},f4:function(a,c,d,e,j,g){a.faces.push(new THREE.Face4(c,d,e,j,null,
 a.materials[g]))},f3n:function(a,c,d,e,j,g,b,m,k){g=a.materials[g];var n=c[m*3],o=c[m*3+1];m=c[m*3+2];var y=c[k*3],v=c[k*3+1];k=c[k*3+2];a.faces.push(new THREE.Face3(d,e,j,[new THREE.Vector3(c[b*3],c[b*3+1],c[b*3+2]),new THREE.Vector3(n,o,m),new THREE.Vector3(y,v,k)],g))},f4n:function(a,c,d,e,j,g,b,m,k,n,o){b=a.materials[b];var y=c[k*3],v=c[k*3+1];k=c[k*3+2];var q=c[n*3],z=c[n*3+1];n=c[n*3+2];var B=c[o*3],H=c[o*3+1];o=c[o*3+2];a.faces.push(new THREE.Face4(d,e,j,g,[new THREE.Vector3(c[m*3],c[m*3+1],
 c[m*3+2]),new THREE.Vector3(y,v,k),new THREE.Vector3(q,z,n),new THREE.Vector3(B,H,o)],b))},uv3:function(a,c,d,e,j,g,b){var m=[];m.push(new THREE.UV(c,d));m.push(new THREE.UV(e,j));m.push(new THREE.UV(g,b));a.push(m)},uv4:function(a,c,d,e,j,g,b,m,k){var n=[];n.push(new THREE.UV(c,d));n.push(new THREE.UV(e,j));n.push(new THREE.UV(g,b));n.push(new THREE.UV(m,k));a.push(n)},init_materials:function(a,c,d){a.materials=[];for(var e=0;e<c.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(c[e],

+ 2 - 26
src/renderers/WebGLRenderer.js

@@ -184,7 +184,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		geometry.__webGLVertexBuffer = _gl.createBuffer();
 		geometry.__webGLColorBuffer = _gl.createBuffer();
-		geometry.__webGLParticleBuffer = _gl.createBuffer();
 
 	};
 
@@ -228,7 +227,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		geometry.__vertexArray = new Float32Array( nvertices * 3 );
 		geometry.__colorArray = new Float32Array( nvertices * 3 );
-		geometry.__particleArray = new Uint16Array( nvertices );
 		
 		geometry.__sortArray = [];
 
@@ -815,7 +813,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 			cl = colors.length,
 		
 			vertexArray = geometry.__vertexArray,
-			particleArray = geometry.__particleArray,
 			colorArray = geometry.__colorArray,
 		
 			sortArray = geometry.__sortArray,
@@ -902,24 +899,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		}
 		
-		
-		// yeah, this is silly as order of element indices is currently fixed
-		// though this could change if some use case arises
-		// (like depth-sorting of semi-opaque particles)
-		
-		if ( dirtyElements ) {
-
-			for ( v = 0; v < vl; v++ ) {
-
-				particleArray[ v ] = v;
-
-			}
-			
-			_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometry.__webGLParticleBuffer );
-			_gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, particleArray, hint );
-
-		}
-		
 		if ( dirtyVertices || object.sortParticles ) {
 		
 			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webGLVertexBuffer );
@@ -1279,9 +1258,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 		// render particles
 
 		} else if ( material instanceof THREE.ParticleBasicMaterial ) {
-
-			_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLParticleBuffer );
-			_gl.drawElements( _gl.POINTS, geometryChunk.__webGLParticleCount, _gl.UNSIGNED_SHORT, 0 );			
+			
+			_gl.drawArrays( _gl.POINTS, 0, geometryChunk.__webGLParticleCount );			
 
 		// render triangles
 			
@@ -1755,7 +1733,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 					geometry.__dirtyVertices = true;
 					geometry.__dirtyColors = true;
-					geometry.__dirtyElements = true;
 					
 				}
 
@@ -1769,7 +1746,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				geometry.__dirtyVertices = false;
 				geometry.__dirtyColors = false;
-				geometry.__dirtyElements = false;
 
 
 			} else if ( object instanceof THREE.MarchingCubes ) {