123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- // ThreeExtras.js r32 - http://github.com/mrdoob/three.js
- var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
- THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var e,f,b,h,j,g;if(d==0)e=f=b=0;else{h=Math.floor(a*6);j=a*6-h;a=d*(1-c);g=d*(1-c*j);c=d*(1-c*(1-j));switch(h){case 1:e=g;f=d;b=a;break;case 2:e=a;f=d;b=c;break;case 3:e=a;f=g;b=d;break;case 4:e=c;f=a;b=d;break;case 5:e=d;f=a;b=g;break;case 6:case 0:e=d;f=c;b=a}}this.r=e;this.g=f;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
- setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+
- this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0};
- THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
- this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,d){this.x=a||0;this.y=c||0;this.z=d||0};
- THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
- cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
- a.z;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+d*d+a*a)},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=
- -this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};
- THREE.Vector4=function(a,c,d,e){this.x=a||0;this.y=c||0;this.z=d||0;this.w=e||1};
- THREE.Vector4.prototype={set:function(a,c,d,e){this.x=a;this.y=c;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
- return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
- THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
- THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,f=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)f=f.concat(this.intersectObject(d))}f.sort(function(b,h){return b.distance-h.distance});return f},intersectObject:function(a){function c(H,x,I,q){q=q.clone().subSelf(x);I=I.clone().subSelf(x);var k=H.clone().subSelf(x);H=q.dot(q);x=q.dot(I);q=q.dot(k);var v=I.dot(I);I=I.dot(k);k=1/(H*v-x*x);v=(v*q-x*I)*k;H=(H*I-x*q)*k;return v>0&&H>0&&v+H<1}var d,e,f,b,h,j,g,m,n,z,
- u,p=a.geometry,A=p.vertices,D=[];d=0;for(e=p.faces.length;d<e;d++){f=p.faces[d];z=this.origin.clone();u=this.direction.clone();b=a.matrix.multiplyVector3(A[f.a].position.clone());h=a.matrix.multiplyVector3(A[f.b].position.clone());j=a.matrix.multiplyVector3(A[f.c].position.clone());g=f instanceof THREE.Face4?a.matrix.multiplyVector3(A[f.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(f.normal.clone());n=u.dot(m);if(n<0){m=m.dot((new THREE.Vector3).sub(b,z))/n;z=z.addSelf(u.multiplyScalar(m));
- if(f instanceof THREE.Face3){if(c(z,b,h,j)){f={distance:this.origin.distanceTo(z),point:z,face:f,object:a};D.push(f)}}else if(f instanceof THREE.Face4)if(c(z,b,h,g)||c(z,h,j,g)){f={distance:this.origin.distanceTo(z),point:z,face:f,object:a};D.push(f)}}}return D}};
- THREE.Rectangle=function(){function a(){b=e-c;h=f-d}var c,d,e,f,b,h,j=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return b};this.getHeight=function(){return h};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(g,m,n,z){j=false;c=g;d=m;e=n;f=z;a()};this.addPoint=function(g,m){if(j){j=false;c=g;d=m;e=g;f=m}else{c=c<g?c:g;d=d<m?d:m;e=e>g?e:g;f=f>m?
- f:m}a()};this.add3Points=function(g,m,n,z,u,p){if(j){j=false;c=g<n?g<u?g:u:n<u?n:u;d=m<z?m<p?m:p:z<p?z:p;e=g>n?g>u?g:u:n>u?n:u;f=m>z?m>p?m:p:z>p?z:p}else{c=g<n?g<u?g<c?g:c:u<c?u:c:n<u?n<c?n:c:u<c?u:c;d=m<z?m<p?m<d?m:d:p<d?p:d:z<p?z<d?z:d:p<d?p:d;e=g>n?g>u?g>e?g:e:u>e?u:e:n>u?n>e?n:e:u>e?u:e;f=m>z?m>p?m>f?m:f:p>f?p:f:z>p?z>f?z:f:p>f?p:f}a()};this.addRectangle=function(g){if(j){j=false;c=g.getLeft();d=g.getTop();e=g.getRight();f=g.getBottom()}else{c=c<g.getLeft()?c:g.getLeft();d=d<g.getTop()?d:g.getTop();
- e=e>g.getRight()?e:g.getRight();f=f>g.getBottom()?f:g.getBottom()}a()};this.inflate=function(g){c-=g;d-=g;e+=g;f+=g;a()};this.minSelf=function(g){c=c>g.getLeft()?c:g.getLeft();d=d>g.getTop()?d:g.getTop();e=e<g.getRight()?e:g.getRight();f=f<g.getBottom()?f:g.getBottom();a()};this.instersects=function(g){return Math.min(e,g.getRight())-Math.max(c,g.getLeft())>=0&&Math.min(f,g.getBottom())-Math.max(d,g.getTop())>=0};this.empty=function(){j=true;f=e=d=c=0;a()};this.isEmpty=function(){return j};this.toString=
- function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+f+", width: "+b+", height: "+h+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this}};
- THREE.Matrix4=function(a,c,d,e,f,b,h,j,g,m,n,z,u,p,A,D){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=f||0;this.n22=b||1;this.n23=h||0;this.n24=j||0;this.n31=g||0;this.n32=m||0;this.n33=n||1;this.n34=z||0;this.n41=u||0;this.n42=p||0;this.n43=A||0;this.n44=D||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
- THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,d,e,f,b,h,j,g,m,n,z,u,p,A,D){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=f;this.n22=b;this.n23=h;this.n24=j;this.n31=g;this.n32=m;this.n33=n;this.n34=z;this.n41=u;this.n42=p;this.n43=A;this.n44=D;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
- a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var e=THREE.Matrix4.__tmpVec1,f=THREE.Matrix4.__tmpVec2,b=THREE.Matrix4.__tmpVec3;b.sub(a,c).normalize();e.cross(d,b).normalize();f.cross(b,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);
- this.n31=b.x;this.n32=b.y;this.n33=b.z;this.n34=-b.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,e=a.z,f=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*f;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*c+this.n22*d+this.n23*
- e+this.n24*f;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*f;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,e=a.n12,f=a.n13,b=a.n14,h=a.n21,j=a.n22,g=a.n23,m=a.n24,n=a.n31,
- z=a.n32,u=a.n33,p=a.n34,A=a.n41,D=a.n42,H=a.n43,x=a.n44,I=c.n11,q=c.n12,k=c.n13,v=c.n14,t=c.n21,l=c.n22,o=c.n23,w=c.n24,y=c.n31,G=c.n32,B=c.n33,C=c.n34,F=c.n41,L=c.n42,O=c.n43,Q=c.n44;this.n11=d*I+e*t+f*y+b*F;this.n12=d*q+e*l+f*G+b*L;this.n13=d*k+e*o+f*B+b*O;this.n14=d*v+e*w+f*C+b*Q;this.n21=h*I+j*t+g*y+m*F;this.n22=h*q+j*l+g*G+m*L;this.n23=h*k+j*o+g*B+m*O;this.n24=h*v+j*w+g*C+m*Q;this.n31=n*I+z*t+u*y+p*F;this.n32=n*q+z*l+u*G+p*L;this.n33=n*k+z*o+u*B+p*O;this.n34=n*v+z*w+u*C+p*Q;this.n41=A*I+D*t+
- H*y+x*F;this.n42=A*q+D*l+H*G+x*L;this.n43=A*k+D*o+H*B+x*O;this.n44=A*v+D*w+H*C+x*Q;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,f=this.n14,b=this.n21,h=this.n22,j=this.n23,g=this.n24,m=this.n31,n=this.n32,z=this.n33,u=this.n34,p=this.n41,A=this.n42,D=this.n43,H=this.n44,x=a.n11,I=a.n21,q=a.n31,k=a.n41,v=a.n12,t=a.n22,l=a.n32,o=a.n42,w=a.n13,y=a.n23,G=a.n33,B=a.n43,C=a.n14,F=a.n24,L=a.n34;a=a.n44;this.n11=c*x+d*I+e*q+f*k;this.n12=c*v+d*t+e*l+f*o;this.n13=c*w+d*y+e*G+f*
- B;this.n14=c*C+d*F+e*L+f*a;this.n21=b*x+h*I+j*q+g*k;this.n22=b*v+h*t+j*l+g*o;this.n23=b*w+h*y+j*G+g*B;this.n24=b*C+h*F+j*L+g*a;this.n31=m*x+n*I+z*q+u*k;this.n32=m*v+n*t+z*l+u*o;this.n33=m*w+n*y+z*G+u*B;this.n34=m*C+n*F+z*L+u*a;this.n41=p*x+A*I+D*q+H*k;this.n42=p*v+A*t+D*l+H*o;this.n43=p*w+A*y+D*G+H*B;this.n44=p*C+A*F+D*L+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,f=this.n21,b=this.n22,h=this.n23,j=this.n24,g=this.n31,m=this.n32,n=this.n33,z=this.n34,u=this.n41,p=this.n42,A=this.n43,D=this.n44;return e*h*m*u-d*j*m*u-e*b*n*u+c*j*n*u+d*b*z*u-c*h*z*u-e*h*g*p+d*j*g*p+e*f*n*p-a*j*n*p-d*f*z*p+a*h*z*p+e*b*g*A-c*j*g*A-e*f*m*A+a*j*m*A+c*f*z*A-a*b*z*A-d*b*g*D+c*h*g*D+d*f*m*D-a*h*m*D-c*f*n*D+a*b*n*D},transpose:function(){function a(c,d,
- e){var f=c[d];c[d]=c[e];c[e]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;
- a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=
- Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),f=1-d,b=a.x,h=a.y,j=a.z,g=f*b,m=f*h;this.set(g*b+d,g*h-e*j,g*j+e*h,0,g*h+e*j,m*h+d,m*j-e*b,0,g*j-e*h,m*j+e*b,f*j*j+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+
- this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setTranslation(a,c,d);return e};THREE.Matrix4.scaleMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setScale(a,c,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};
- THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
- THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,b=a.n21,h=a.n22,j=a.n23,g=a.n24,m=a.n31,n=a.n32,z=a.n33,u=a.n34,p=a.n41,A=a.n42,D=a.n43,H=a.n44,x=new THREE.Matrix4;x.n11=j*u*A-g*z*A+g*n*D-h*u*D-j*n*H+h*z*H;x.n12=f*z*A-e*u*A-f*n*D+d*u*D+e*n*H-d*z*H;x.n13=e*g*A-f*j*A+f*h*D-d*g*D-e*h*H+d*j*H;x.n14=f*j*n-e*g*n-f*h*z+d*g*z+e*h*u-d*j*u;x.n21=g*z*p-j*u*p-g*m*D+b*u*D+j*m*H-b*z*H;x.n22=e*u*p-f*z*p+f*m*D-c*u*D-e*m*H+c*z*H;x.n23=f*j*p-e*g*p-f*b*D+c*g*D+e*b*H-c*j*H;x.n24=e*g*m-f*j*m+
- f*b*z-c*g*z-e*b*u+c*j*u;x.n31=h*u*p-g*n*p+g*m*A-b*u*A-h*m*H+b*n*H;x.n32=f*n*p-d*u*p-f*m*A+c*u*A+d*m*H-c*n*H;x.n33=e*g*p-f*h*p+f*b*A-c*g*A-d*b*H+c*h*H;x.n34=f*h*m-d*g*m-f*b*n+c*g*n+d*b*u-c*h*u;x.n41=j*n*p-h*z*p-j*m*A+b*z*A+h*m*D-b*n*D;x.n42=d*z*p-e*n*p+e*m*A-c*z*A-d*m*D+c*n*D;x.n43=e*h*p-d*j*p-e*b*A+c*j*A+d*b*D-c*h*D;x.n44=d*j*m-e*h*m+e*b*n-c*j*n-d*b*z+c*h*z;x.multiplyScalar(1/a.determinant());return x};
- THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],f=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],h=-c[10]*c[4]+c[6]*c[8],j=c[10]*c[0]-c[2]*c[8],g=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],n=-c[9]*c[0]+c[1]*c[8],z=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*h+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*f;d[2]=c*b;d[3]=c*h;d[4]=c*j;d[5]=c*g;d[6]=c*m;d[7]=c*n;d[8]=c*z;return a};
- THREE.Matrix4.makeFrustum=function(a,c,d,e,f,b){var h,j,g;h=new THREE.Matrix4;j=2*f/(c-a);g=2*f/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(b+f)/(b-f);f=-2*b*f/(b-f);h.n11=j;h.n12=0;h.n13=a;h.n14=0;h.n21=0;h.n22=g;h.n23=d;h.n24=0;h.n31=0;h.n32=0;h.n33=e;h.n34=f;h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,d,e)};
- THREE.Matrix4.makeOrtho=function(a,c,d,e,f,b){var h,j,g,m;h=new THREE.Matrix4;j=c-a;g=d-e;m=b-f;a=(c+a)/j;d=(d+e)/g;f=(b+f)/m;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-a;h.n21=0;h.n22=2/g;h.n23=0;h.n24=-d;h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-f;h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
- THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
- THREE.Face3=function(a,c,d,e,f){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
- THREE.Face4=function(a,c,d,e,f,b){this.a=a;this.b=c;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=b instanceof Array?b:[b]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
- THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
- THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
- d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,e,f,b,h,j=new THREE.Vector3,g=new THREE.Vector3;e=0;for(f=this.vertices.length;e<f;e++){b=this.vertices[e];b.normal.set(0,0,0)}e=0;for(f=this.faces.length;e<f;e++){b=this.faces[e];if(a&&b.vertexNormals.length){j.set(0,0,0);c=0;for(d=b.normal.length;c<d;c++)j.addSelf(b.vertexNormals[c]);j.divideScalar(3)}else{c=this.vertices[b.a];d=this.vertices[b.b];h=this.vertices[b.c];j.sub(h.position,
- d.position);g.sub(c.position,d.position);j.crossSelf(g)}j.isZero()||j.normalize();b.normal.copy(j)}},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(C,F,L,O,Q,T,U){b=C.vertices[F].position;h=C.vertices[L].position;j=C.vertices[O].position;g=f[Q];m=f[T];n=f[U];z=h.x-b.x;u=j.x-b.x;p=h.y-b.y;A=j.y-b.y;
- D=h.z-b.z;H=j.z-b.z;x=m.u-g.u;I=n.u-g.u;q=m.v-g.v;k=n.v-g.v;v=1/(x*k-I*q);o.set((k*z-q*u)*v,(k*p-q*A)*v,(k*D-q*H)*v);w.set((x*u-I*z)*v,(x*A-I*p)*v,(x*H-I*D)*v);t[F].addSelf(o);t[L].addSelf(o);t[O].addSelf(o);l[F].addSelf(w);l[L].addSelf(w);l[O].addSelf(w)}var c,d,e,f,b,h,j,g,m,n,z,u,p,A,D,H,x,I,q,k,v,t=[],l=[],o=new THREE.Vector3,w=new THREE.Vector3,y=new THREE.Vector3,G=new THREE.Vector3,B=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){t[c]=new THREE.Vector3;l[c]=new THREE.Vector3}c=0;
- for(d=this.faces.length;c<d;c++){e=this.faces[c];f=this.uvs[c];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
- this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){B.copy(this.vertices[c].normal);e=t[c];y.copy(e);y.subSelf(B.multiplyScalar(B.dot(e))).normalize();G.cross(this.vertices[c].normal,e);e=G.dot(l[c]);e=e<0?-1:1;this.vertices[c].tangent.set(y.x,y.y,y.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
- z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
- this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(n){var z=[];c=0;for(d=n.length;c<d;c++)n[c]==undefined?z.push("undefined"):z.push(n[c].toString());return z.join("_")}var c,d,e,f,b,h,j,g,m={};e=0;for(f=this.faces.length;e<f;e++){b=this.faces[e];
- h=b.materials;j=a(h);if(m[j]==undefined)m[j]={hash:j,counter:0};g=m[j].hash+"_"+m[j].counter;if(this.geometryChunks[g]==undefined)this.geometryChunks[g]={faces:[],materials:h,vertices:0};b=b instanceof THREE.Face3?3:4;if(this.geometryChunks[g].vertices+b>65535){m[j].counter+=1;g=m[j].hash+"_"+m[j].counter;if(this.geometryChunks[g]==undefined)this.geometryChunks[g]={faces:[],materials:h,vertices:0}}this.geometryChunks[g].faces.push(e);this.geometryChunks[g].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+
- this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
- THREE.Camera=function(a,c,d,e){this.fov=a;this.aspect=c;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(f){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
- this.translateZ=function(f){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
- THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;
- THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
- THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
- THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,e=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){e.setRotY(c.y);this.rotationMatrix.multiplySelf(e)}if(c.z!=0){e.setRotZ(c.z);this.rotationMatrix.multiplySelf(e)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){e.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(e)}}};THREE.Object3DCounter={value:0};
- THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
- THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
- THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;
- THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=false;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;
- if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};
- THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==
- undefined)this.map=a.map;if(a.light_map!==undefined)this.light_map=a.light_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==
- undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
- THREE.MeshBasicMaterial.prototype={toString:function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>light_map: "+this.light_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+
- this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
- THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);
- if(a.map!==undefined)this.map=a.map;if(a.light_map!==undefined)this.light_map=a.light_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;
- if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
- THREE.MeshLambertMaterial.prototype={toString:function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+
- this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
- THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.env_map=this.light_map=this.specular_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=
- 1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.light_map!==undefined)this.light_map=a.light_map;if(a.map!==undefined)this.map=a.map;if(a.specular_map!==undefined)this.specular_map=a.specular_map;if(a.env_map!==undefined)this.env_map=a.env_map;
- if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;
- if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
- THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>map: "+this.map+"<br/>specular_map: "+this.specular_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+
- this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshPhongMaterialCounter={value:0};
- THREE.MeshDepthMaterial=function(a){this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial"}};
- THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}};
- THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!==
- undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
- THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshShaderMaterialCounter={value:0};
- THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.size=this.opacity=1;this.vertex_colors=false;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
- THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>size: "+this.size+"<br/>blending: "+this.blending+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};
- THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
- THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,e,f,b){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=f!==undefined?f:THREE.LinearFilter;this.min_filter=b!==undefined?b:THREE.LinearMipMapLinearFilter};
- THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},toString:function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;
- THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
- THREE.RenderTarget=function(a,c,d){this.width=a;this.height=c;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType};
- var Uniforms={clone:function(a){var c,d,e,f={};for(c in a){f[c]={};for(d in a[c]){e=a[c][d];f[c][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return f},merge:function(a){var c,d,e,f={};for(c=0;c<a.length;c++){e=this.clone(a[c]);for(d in e)f[d]=e[d]}return f}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
- THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
- THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
- THREE.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
- THREE.Projector=function(){function a(l,o){return o.z-l.z}function c(l,o){var w=0,y=1,G=l.z+l.w,B=o.z+o.w,C=-l.z+l.w,F=-o.z+o.w;if(G>=0&&B>=0&&C>=0&&F>=0)return true;else if(G<0&&B<0||C<0&&F<0)return false;else{if(G<0)w=Math.max(w,G/(G-B));else if(B<0)y=Math.min(y,G/(G-B));if(C<0)w=Math.max(w,C/(C-F));else if(F<0)y=Math.min(y,C/(C-F));if(y<w)return false;else{l.lerpSelf(o,w);o.lerpSelf(l,1-y);return true}}}var d,e,f=[],b,h,j,g=[],m,n,z=[],u,p,A=[],D=new THREE.Vector4,H=new THREE.Vector4,x=new THREE.Matrix4,
- I=new THREE.Matrix4,q=[],k=new THREE.Vector4,v=new THREE.Vector4,t;this.projectObjects=function(l,o,w){var y=[],G,B;e=0;x.multiply(o.projectionMatrix,o.matrix);q[0]=new THREE.Vector4(x.n41-x.n11,x.n42-x.n12,x.n43-x.n13,x.n44-x.n14);q[1]=new THREE.Vector4(x.n41+x.n11,x.n42+x.n12,x.n43+x.n13,x.n44+x.n14);q[2]=new THREE.Vector4(x.n41+x.n21,x.n42+x.n22,x.n43+x.n23,x.n44+x.n24);q[3]=new THREE.Vector4(x.n41-x.n21,x.n42-x.n22,x.n43-x.n23,x.n44-x.n24);q[4]=new THREE.Vector4(x.n41-x.n31,x.n42-x.n32,x.n43-
- x.n33,x.n44-x.n34);q[5]=new THREE.Vector4(x.n41+x.n31,x.n42+x.n32,x.n43+x.n33,x.n44+x.n34);o=0;for(G=q.length;o<G;o++){B=q[o];B.divideScalar(Math.sqrt(B.x*B.x+B.y*B.y+B.z*B.z))}G=l.objects;l=0;for(o=G.length;l<o;l++){B=G[l];var C;if(!(C=!B.visible)){if(C=B instanceof THREE.Mesh){a:{C=void 0;for(var F=B.position,L=-B.geometry.boundingSphere.radius*Math.max(B.scale.x,Math.max(B.scale.y,B.scale.z)),O=0;O<6;O++){C=q[O].x*F.x+q[O].y*F.y+q[O].z*F.z+q[O].w;if(C<=L){C=false;break a}}C=true}C=!C}C=C}if(!C){d=
- f[e]=f[e]||new THREE.RenderableObject;D.copy(B.position);x.multiplyVector3(D);d.object=B;d.z=D.z;y.push(d);e++}}w&&y.sort(a);return y};this.projectScene=function(l,o,w){var y=[],G=o.near,B=o.far,C,F,L,O,Q,T,U,ba,ca,S,N,Z,V,J,W,da;j=n=p=0;o.autoUpdateMatrix&&o.updateMatrix();x.multiply(o.projectionMatrix,o.matrix);T=this.projectObjects(l,o,true);l=0;for(C=T.length;l<C;l++){U=T[l].object;if(U.visible){U.autoUpdateMatrix&&U.updateMatrix();ba=U.matrix;ca=U.rotationMatrix;S=U.materials;N=U.overdraw;if(U instanceof
- THREE.Mesh){Z=U.geometry;V=Z.vertices;F=0;for(L=V.length;F<L;F++){J=V[F];J.positionWorld.copy(J.position);ba.multiplyVector3(J.positionWorld);O=J.positionScreen;O.copy(J.positionWorld);x.multiplyVector4(O);O.x/=O.w;O.y/=O.w;J.__visible=O.z>G&&O.z<B}Z=Z.faces;F=0;for(L=Z.length;F<L;F++){J=Z[F];if(J instanceof THREE.Face3){O=V[J.a];Q=V[J.b];W=V[J.c];if(O.__visible&&Q.__visible&&W.__visible)if(U.doubleSided||U.flipSided!=(W.positionScreen.x-O.positionScreen.x)*(Q.positionScreen.y-O.positionScreen.y)-
- (W.positionScreen.y-O.positionScreen.y)*(Q.positionScreen.x-O.positionScreen.x)<0){b=g[j]=g[j]||new THREE.RenderableFace3;b.v1.positionWorld.copy(O.positionWorld);b.v2.positionWorld.copy(Q.positionWorld);b.v3.positionWorld.copy(W.positionWorld);b.v1.positionScreen.copy(O.positionScreen);b.v2.positionScreen.copy(Q.positionScreen);b.v3.positionScreen.copy(W.positionScreen);b.normalWorld.copy(J.normal);ca.multiplyVector3(b.normalWorld);b.centroidWorld.copy(J.centroid);ba.multiplyVector3(b.centroidWorld);
- b.centroidScreen.copy(b.centroidWorld);x.multiplyVector3(b.centroidScreen);W=J.vertexNormals;t=b.vertexNormalsWorld;O=0;for(Q=W.length;O<Q;O++){da=t[O]=t[O]||new THREE.Vector3;da.copy(W[O]);ca.multiplyVector3(da)}b.z=b.centroidScreen.z;b.meshMaterials=S;b.faceMaterials=J.materials;b.overdraw=N;if(U.geometry.uvs[F]){b.uvs[0]=U.geometry.uvs[F][0];b.uvs[1]=U.geometry.uvs[F][1];b.uvs[2]=U.geometry.uvs[F][2]}y.push(b);j++}}else if(J instanceof THREE.Face4){O=V[J.a];Q=V[J.b];W=V[J.c];da=V[J.d];if(O.__visible&&
- Q.__visible&&W.__visible&&da.__visible)if(U.doubleSided||U.flipSided!=((da.positionScreen.x-O.positionScreen.x)*(Q.positionScreen.y-O.positionScreen.y)-(da.positionScreen.y-O.positionScreen.y)*(Q.positionScreen.x-O.positionScreen.x)<0||(Q.positionScreen.x-W.positionScreen.x)*(da.positionScreen.y-W.positionScreen.y)-(Q.positionScreen.y-W.positionScreen.y)*(da.positionScreen.x-W.positionScreen.x)<0)){b=g[j]=g[j]||new THREE.RenderableFace3;b.v1.positionWorld.copy(O.positionWorld);b.v2.positionWorld.copy(Q.positionWorld);
- b.v3.positionWorld.copy(da.positionWorld);b.v1.positionScreen.copy(O.positionScreen);b.v2.positionScreen.copy(Q.positionScreen);b.v3.positionScreen.copy(da.positionScreen);b.normalWorld.copy(J.normal);ca.multiplyVector3(b.normalWorld);b.centroidWorld.copy(J.centroid);ba.multiplyVector3(b.centroidWorld);b.centroidScreen.copy(b.centroidWorld);x.multiplyVector3(b.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterials=S;b.faceMaterials=J.materials;b.overdraw=N;if(U.geometry.uvs[F]){b.uvs[0]=U.geometry.uvs[F][0];
- b.uvs[1]=U.geometry.uvs[F][1];b.uvs[2]=U.geometry.uvs[F][3]}y.push(b);j++;h=g[j]=g[j]||new THREE.RenderableFace3;h.v1.positionWorld.copy(Q.positionWorld);h.v2.positionWorld.copy(W.positionWorld);h.v3.positionWorld.copy(da.positionWorld);h.v1.positionScreen.copy(Q.positionScreen);h.v2.positionScreen.copy(W.positionScreen);h.v3.positionScreen.copy(da.positionScreen);h.normalWorld.copy(b.normalWorld);h.centroidWorld.copy(b.centroidWorld);h.centroidScreen.copy(b.centroidScreen);h.z=h.centroidScreen.z;
- h.meshMaterials=S;h.faceMaterials=J.materials;h.overdraw=N;if(U.geometry.uvs[F]){h.uvs[0]=U.geometry.uvs[F][1];h.uvs[1]=U.geometry.uvs[F][2];h.uvs[2]=U.geometry.uvs[F][3]}y.push(h);j++}}}}else if(U instanceof THREE.Line){I.multiply(x,ba);V=U.geometry.vertices;J=V[0];J.positionScreen.copy(J.position);I.multiplyVector4(J.positionScreen);F=1;for(L=V.length;F<L;F++){O=V[F];O.positionScreen.copy(O.position);I.multiplyVector4(O.positionScreen);Q=V[F-1];k.copy(O.positionScreen);v.copy(Q.positionScreen);
- if(c(k,v)){k.multiplyScalar(1/k.w);v.multiplyScalar(1/v.w);m=z[n]=z[n]||new THREE.RenderableLine;m.v1.positionScreen.copy(k);m.v2.positionScreen.copy(v);m.z=Math.max(k.z,v.z);m.materials=U.materials;y.push(m);n++}}}else if(U instanceof THREE.Particle){H.set(U.position.x,U.position.y,U.position.z,1);x.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){u=A[p]=A[p]||new THREE.RenderableParticle;u.x=H.x/H.w;u.y=H.y/H.w;u.z=H.z;u.rotation=U.rotation.z;u.scale.x=U.scale.x*Math.abs(u.x-(H.x+o.projectionMatrix.n11)/
- (H.w+o.projectionMatrix.n14));u.scale.y=U.scale.y*Math.abs(u.y-(H.y+o.projectionMatrix.n22)/(H.w+o.projectionMatrix.n24));u.materials=U.materials;y.push(u);p++}}}}w&&y.sort(a);return y};this.unprojectVector=function(l,o){var w=THREE.Matrix4.makeInvert(o.matrix);w.multiplySelf(THREE.Matrix4.makeInvert(o.projectionMatrix));w.multiplyVector3(l);return l}};
- THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,f,b;this.domElement=document.createElement("div");this.setSize=function(h,j){d=h;e=j;f=d/2;b=e/2};this.render=function(h,j){var g,m,n,z,u,p,A,D;a=c.projectScene(h,j);g=0;for(m=a.length;g<m;g++){u=a[g];if(u instanceof THREE.RenderableParticle){A=u.x*f+f;D=u.y*b+b;n=0;for(z=u.material.length;n<z;n++){p=u.material[n];if(p instanceof THREE.ParticleDOMMaterial){p=p.domElement;p.style.left=A+"px";p.style.top=D+"px"}}}}}};
- THREE.CanvasRenderer=function(){function a(ka){if(u!=ka)m.globalAlpha=u=ka}function c(ka){if(p!=ka){switch(ka){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}p=ka}}var d=null,e=new THREE.Projector,f=document.createElement("canvas"),b,h,j,g,m=f.getContext("2d"),n=new THREE.Color(0),z=0,u=1,p=0,A=null,D=null,H=1,x,I,q,k,v,t,l,o,w,y=new THREE.Color,
- G=new THREE.Color,B=new THREE.Color,C=new THREE.Color,F=new THREE.Color,L,O,Q,T,U,ba,ca,S,N,Z=new THREE.Rectangle,V=new THREE.Rectangle,J=new THREE.Rectangle,W=false,da=new THREE.Color,ha=new THREE.Color,ea=new THREE.Color,E=new THREE.Color,M=Math.PI*2,K=new THREE.Vector3,X,$,ma,ia,qa,ta,ua=16;X=document.createElement("canvas");X.width=X.height=2;$=X.getContext("2d");$.fillStyle="rgba(0,0,0,1)";$.fillRect(0,0,2,2);ma=$.getImageData(0,0,2,2);ia=ma.data;qa=document.createElement("canvas");qa.width=
- qa.height=ua;ta=qa.getContext("2d");ta.translate(-ua/2,-ua/2);ta.scale(ua,ua);ua--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ka,ja){b=ka;h=ja;j=b/2;g=h/2;f.width=b;f.height=h;Z.set(-j,-g,j,g);u=1;p=0;D=A=null;H=1};this.setClearColor=function(ka,ja){n=ka;z=ja;V.set(-j,-g,j,g);m.setTransform(1,0,0,-1,j,g);this.clear()};this.setClearColorHex=function(ka,ja){n.setHex(ka);z=ja;V.set(-j,-g,j,g);m.setTransform(1,0,0,-1,j,g);this.clear()};this.clear=function(){m.setTransform(1,
- 0,0,-1,j,g);if(!V.isEmpty()){V.inflate(1);V.minSelf(Z);if(n.hex==0&&z==0)m.clearRect(V.getX(),V.getY(),V.getWidth(),V.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+z+")";m.fillRect(V.getX(),V.getY(),V.getWidth(),V.getHeight())}V.empty()}};this.render=function(ka,ja){function Fa(P){var fa,aa,R,Y=P.lights;ha.setRGB(0,0,0);ea.setRGB(0,0,0);E.setRGB(0,0,0);P=0;for(fa=Y.length;P<fa;P++){aa=Y[P];R=aa.color;if(aa instanceof
- THREE.AmbientLight){ha.r+=R.r;ha.g+=R.g;ha.b+=R.b}else if(aa instanceof THREE.DirectionalLight){ea.r+=R.r;ea.g+=R.g;ea.b+=R.b}else if(aa instanceof THREE.PointLight){E.r+=R.r;E.g+=R.g;E.b+=R.b}}}function Aa(P,fa,aa,R){var Y,ga,na,oa,pa=P.lights;P=0;for(Y=pa.length;P<Y;P++){ga=pa[P];na=ga.color;oa=ga.intensity;if(ga instanceof THREE.DirectionalLight){ga=aa.dot(ga.position)*oa;if(ga>0){R.r+=na.r*ga;R.g+=na.g*ga;R.b+=na.b*ga}}else if(ga instanceof THREE.PointLight){K.sub(ga.position,fa);K.normalize();
- ga=aa.dot(K)*oa;if(ga>0){R.r+=na.r*ga;R.g+=na.g*ga;R.b+=na.b*ga}}}}function Ja(P,fa,aa){if(aa.opacity!=0){a(aa.opacity);c(aa.blending);var R,Y,ga,na,oa,pa;if(aa instanceof THREE.ParticleBasicMaterial){if(aa.map&&aa.map.image.loaded){na=aa.map.image;oa=na.width>>1;pa=na.height>>1;Y=fa.scale.x*j;ga=fa.scale.y*g;aa=Y*oa;R=ga*pa;J.set(P.x-aa,P.y-R,P.x+aa,P.y+R);if(Z.instersects(J)){m.save();m.translate(P.x,P.y);m.rotate(-fa.rotation);m.scale(Y,-ga);m.translate(-oa,-pa);m.drawImage(na,0,0);m.restore()}}}else if(aa instanceof
- THREE.ParticleCircleMaterial){if(W){da.r=ha.r+ea.r+E.r;da.g=ha.g+ea.g+E.g;da.b=ha.b+ea.b+E.b;y.r=aa.color.r*da.r;y.g=aa.color.g*da.g;y.b=aa.color.b*da.b;y.updateStyleString()}else y.__styleString=aa.color.__styleString;aa=fa.scale.x*j;R=fa.scale.y*g;J.set(P.x-aa,P.y-R,P.x+aa,P.y+R);if(Z.instersects(J)){Y=y.__styleString;if(D!=Y)m.fillStyle=D=Y;m.save();m.translate(P.x,P.y);m.rotate(-fa.rotation);m.scale(aa,R);m.beginPath();m.arc(0,0,1,0,M,true);m.closePath();m.fill();m.restore()}}}}function Ka(P,
- fa,aa,R){if(R.opacity!=0){a(R.opacity);c(R.blending);m.beginPath();m.moveTo(P.positionScreen.x,P.positionScreen.y);m.lineTo(fa.positionScreen.x,fa.positionScreen.y);m.closePath();if(R instanceof THREE.LineBasicMaterial){y.__styleString=R.color.__styleString;P=R.linewidth;if(H!=P)m.lineWidth=H=P;P=y.__styleString;if(A!=P)m.strokeStyle=A=P;m.stroke();J.inflate(R.linewidth*2)}}}function ra(P,fa,aa,R,Y,ga){if(Y.opacity!=0){a(Y.opacity);c(Y.blending);k=P.positionScreen.x;v=P.positionScreen.y;t=fa.positionScreen.x;
- l=fa.positionScreen.y;o=aa.positionScreen.x;w=aa.positionScreen.y;m.beginPath();m.moveTo(k,v);m.lineTo(t,l);m.lineTo(o,w);m.lineTo(k,v);m.closePath();if(Y instanceof THREE.MeshBasicMaterial)if(Y.map)Y.map.image.loaded&&Y.map.mapping instanceof THREE.UVMapping&&Ca(k,v,t,l,o,w,Y.map.image,R.uvs[0].u,R.uvs[0].v,R.uvs[1].u,R.uvs[1].v,R.uvs[2].u,R.uvs[2].v);else if(Y.env_map){if(Y.env_map.image.loaded)if(Y.env_map.mapping instanceof THREE.SphericalReflectionMapping){P=ja.matrix;K.copy(R.vertexNormalsWorld[0]);
- T=(K.x*P.n11+K.y*P.n12+K.z*P.n13)*0.5+0.5;U=-(K.x*P.n21+K.y*P.n22+K.z*P.n23)*0.5+0.5;K.copy(R.vertexNormalsWorld[1]);ba=(K.x*P.n11+K.y*P.n12+K.z*P.n13)*0.5+0.5;ca=-(K.x*P.n21+K.y*P.n22+K.z*P.n23)*0.5+0.5;K.copy(R.vertexNormalsWorld[2]);S=(K.x*P.n11+K.y*P.n12+K.z*P.n13)*0.5+0.5;N=-(K.x*P.n21+K.y*P.n22+K.z*P.n23)*0.5+0.5;Ca(k,v,t,l,o,w,Y.env_map.image,T,U,ba,ca,S,N)}}else Y.wireframe?Ga(Y.color.__styleString,Y.wireframe_linewidth):Ha(Y.color.__styleString);else if(Y instanceof THREE.MeshLambertMaterial){if(Y.map&&
- !Y.wireframe){Y.map.mapping instanceof THREE.UVMapping&&Ca(k,v,t,l,o,w,Y.map.image,R.uvs[0].u,R.uvs[0].v,R.uvs[1].u,R.uvs[1].v,R.uvs[2].u,R.uvs[2].v);c(THREE.SubtractiveBlending)}if(W)if(!Y.wireframe&&Y.shading==THREE.SmoothShading&&R.vertexNormalsWorld.length==3){G.r=B.r=C.r=ha.r;G.g=B.g=C.g=ha.g;G.b=B.b=C.b=ha.b;Aa(ga,R.v1.positionWorld,R.vertexNormalsWorld[0],G);Aa(ga,R.v2.positionWorld,R.vertexNormalsWorld[1],B);Aa(ga,R.v3.positionWorld,R.vertexNormalsWorld[2],C);F.r=(B.r+C.r)*0.5;F.g=(B.g+C.g)*
- 0.5;F.b=(B.b+C.b)*0.5;Q=Pa(G,B,C,F);Ca(k,v,t,l,o,w,Q,0,0,1,0,0,1)}else{da.r=ha.r;da.g=ha.g;da.b=ha.b;Aa(ga,R.centroidWorld,R.normalWorld,da);y.r=Y.color.r*da.r;y.g=Y.color.g*da.g;y.b=Y.color.b*da.b;y.updateStyleString();Y.wireframe?Ga(y.__styleString,Y.wireframe_linewidth):Ha(y.__styleString)}else Y.wireframe?Ga(Y.color.__styleString,Y.wireframe_linewidth):Ha(Y.color.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){L=ja.near;O=ja.far;G.r=G.g=G.b=1-La(P.positionScreen.z,L,O);B.r=B.g=B.b=
- 1-La(fa.positionScreen.z,L,O);C.r=C.g=C.b=1-La(aa.positionScreen.z,L,O);F.r=(B.r+C.r)*0.5;F.g=(B.g+C.g)*0.5;F.b=(B.b+C.b)*0.5;Q=Pa(G,B,C,F);Ca(k,v,t,l,o,w,Q,0,0,1,0,0,1)}else if(Y instanceof THREE.MeshNormalMaterial){y.r=Ma(R.normalWorld.x);y.g=Ma(R.normalWorld.y);y.b=Ma(R.normalWorld.z);y.updateStyleString();Y.wireframe?Ga(y.__styleString,Y.wireframe_linewidth):Ha(y.__styleString)}}}function Ga(P,fa){if(A!=P)m.strokeStyle=A=P;if(H!=fa)m.lineWidth=H=fa;m.stroke();J.inflate(fa*2)}function Ha(P){if(D!=
- P)m.fillStyle=D=P;m.fill()}function Ca(P,fa,aa,R,Y,ga,na,oa,pa,wa,sa,xa,Da){var za,ya;za=na.width-1;ya=na.height-1;oa*=za;pa*=ya;wa*=za;sa*=ya;xa*=za;Da*=ya;aa-=P;R-=fa;Y-=P;ga-=fa;wa-=oa;sa-=pa;xa-=oa;Da-=pa;ya=1/(wa*Da-xa*sa);za=(Da*aa-sa*Y)*ya;sa=(Da*R-sa*ga)*ya;aa=(wa*Y-xa*aa)*ya;R=(wa*ga-xa*R)*ya;P=P-za*oa-aa*pa;fa=fa-sa*oa-R*pa;m.save();m.transform(za,sa,aa,R,P,fa);m.clip();m.drawImage(na,0,0);m.restore()}function Pa(P,fa,aa,R){var Y=~~(P.r*255),ga=~~(P.g*255);P=~~(P.b*255);var na=~~(fa.r*255),
- oa=~~(fa.g*255);fa=~~(fa.b*255);var pa=~~(aa.r*255),wa=~~(aa.g*255);aa=~~(aa.b*255);var sa=~~(R.r*255),xa=~~(R.g*255);R=~~(R.b*255);ia[0]=Y<0?0:Y>255?255:Y;ia[1]=ga<0?0:ga>255?255:ga;ia[2]=P<0?0:P>255?255:P;ia[4]=na<0?0:na>255?255:na;ia[5]=oa<0?0:oa>255?255:oa;ia[6]=fa<0?0:fa>255?255:fa;ia[8]=pa<0?0:pa>255?255:pa;ia[9]=wa<0?0:wa>255?255:wa;ia[10]=aa<0?0:aa>255?255:aa;ia[12]=sa<0?0:sa>255?255:sa;ia[13]=xa<0?0:xa>255?255:xa;ia[14]=R<0?0:R>255?255:R;$.putImageData(ma,0,0);ta.drawImage(X,0,0);return qa}
- function La(P,fa,aa){P=(P-fa)/(aa-fa);return P*P*(3-2*P)}function Ma(P){P=(P+1)*0.5;return P<0?0:P>1?1:P}function Na(P,fa){var aa=fa.x-P.x,R=fa.y-P.y,Y=1/Math.sqrt(aa*aa+R*R);aa*=Y;R*=Y;fa.x+=aa;fa.y+=R;P.x-=aa;P.y-=R}var Ia,Qa,la,va,Ba,Oa,Ra,Ea;this.autoClear?this.clear():m.setTransform(1,0,0,-1,j,g);d=e.projectScene(ka,ja,this.sortElements);(W=ka.lights.length>0)&&Fa(ka);Ia=0;for(Qa=d.length;Ia<Qa;Ia++){la=d[Ia];J.empty();if(la instanceof THREE.RenderableParticle){x=la;x.x*=j;x.y*=g;va=0;for(Ba=
- la.materials.length;va<Ba;va++)Ja(x,la,la.materials[va],ka)}else if(la instanceof THREE.RenderableLine){x=la.v1;I=la.v2;x.positionScreen.x*=j;x.positionScreen.y*=g;I.positionScreen.x*=j;I.positionScreen.y*=g;J.addPoint(x.positionScreen.x,x.positionScreen.y);J.addPoint(I.positionScreen.x,I.positionScreen.y);if(Z.instersects(J)){va=0;for(Ba=la.materials.length;va<Ba;)Ka(x,I,la,la.materials[va++],ka)}}else if(la instanceof THREE.RenderableFace3){x=la.v1;I=la.v2;q=la.v3;x.positionScreen.x*=j;x.positionScreen.y*=
- g;I.positionScreen.x*=j;I.positionScreen.y*=g;q.positionScreen.x*=j;q.positionScreen.y*=g;if(la.overdraw){Na(x.positionScreen,I.positionScreen);Na(I.positionScreen,q.positionScreen);Na(q.positionScreen,x.positionScreen)}J.add3Points(x.positionScreen.x,x.positionScreen.y,I.positionScreen.x,I.positionScreen.y,q.positionScreen.x,q.positionScreen.y);if(Z.instersects(J)){va=0;for(Ba=la.meshMaterials.length;va<Ba;){Ea=la.meshMaterials[va++];if(Ea instanceof THREE.MeshFaceMaterial){Oa=0;for(Ra=la.faceMaterials.length;Oa<
- Ra;)(Ea=la.faceMaterials[Oa++])&&ra(x,I,q,la,Ea,ka)}else ra(x,I,q,la,Ea,ka)}}}V.addRectangle(J)}m.setTransform(1,0,0,1,0,0)}};
- THREE.SVGRenderer=function(){function a(T,U,ba){var ca,S,N,Z;ca=0;for(S=T.lights.length;ca<S;ca++){N=T.lights[ca];if(N instanceof THREE.DirectionalLight){Z=U.normalWorld.dot(N.position)*N.intensity;if(Z>0){ba.r+=N.color.r*Z;ba.g+=N.color.g*Z;ba.b+=N.color.b*Z}}else if(N instanceof THREE.PointLight){w.sub(N.position,U.centroidWorld);w.normalize();Z=U.normalWorld.dot(w)*N.intensity;if(Z>0){ba.r+=N.color.r*Z;ba.g+=N.color.g*Z;ba.b+=N.color.b*Z}}}}function c(T,U,ba,ca,S,N){C=e(F++);C.setAttribute("d",
- "M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)q.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(I){k.r=v.r;k.g=v.g;k.b=v.b;a(N,ca,k);q.r=S.color.r*k.r;q.g=S.color.g*k.g;q.b=S.color.b*k.b;q.updateStyleString()}else q.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){o=1-S.__2near/(S.__farPlusNear-
- ca.z*S.__farMinusNear);q.setRGB(o,o,o)}else S instanceof THREE.MeshNormalMaterial&&q.setRGB(f(ca.normalWorld.x),f(ca.normalWorld.y),f(ca.normalWorld.z));S.wireframe?C.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+S.wireframe_linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframe_linecap+"; stroke-linejoin: "+S.wireframe_linejoin):C.setAttribute("style","fill: "+q.__styleString+"; fill-opacity: "+S.opacity);j.appendChild(C)}function d(T,U,ba,ca,S,
- N,Z){C=e(F++);C.setAttribute("d","M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");if(N instanceof THREE.MeshBasicMaterial)q.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshLambertMaterial)if(I){k.r=v.r;k.g=v.g;k.b=v.b;a(Z,S,k);q.r=N.color.r*k.r;q.g=N.color.g*k.g;q.b=N.color.b*k.b;q.updateStyleString()}else q.__styleString=N.color.__styleString;
- else if(N instanceof THREE.MeshDepthMaterial){o=1-N.__2near/(N.__farPlusNear-S.z*N.__farMinusNear);q.setRGB(o,o,o)}else N instanceof THREE.MeshNormalMaterial&&q.setRGB(f(S.normalWorld.x),f(S.normalWorld.y),f(S.normalWorld.z));N.wireframe?C.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+N.wireframe_linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.wireframe_linecap+"; stroke-linejoin: "+N.wireframe_linejoin):C.setAttribute("style","fill: "+q.__styleString+
- "; fill-opacity: "+N.opacity);j.appendChild(C)}function e(T){if(y[T]==null){y[T]=document.createElementNS("http://www.w3.org/2000/svg","path");Q==0&&y[T].setAttribute("shape-rendering","crispEdges");return y[T]}return y[T]}function f(T){return T<0?Math.min((1+T)*0.5,0.5):0.5+Math.min(T*0.5,0.5)}var b=null,h=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),g,m,n,z,u,p,A,D,H=new THREE.Rectangle,x=new THREE.Rectangle,I=false,q=new THREE.Color(16777215),k=new THREE.Color(16777215),
- v=new THREE.Color(0),t=new THREE.Color(0),l=new THREE.Color(0),o,w=new THREE.Vector3,y=[],G=[],B=[],C,F,L,O,Q=1;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(T){switch(T){case "high":Q=1;break;case "low":Q=0}};this.setSize=function(T,U){g=T;m=U;n=g/2;z=m/2;j.setAttribute("viewBox",-n+" "+-z+" "+g+" "+m);j.setAttribute("width",g);j.setAttribute("height",m);H.set(-n,-z,n,z)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])};
- this.render=function(T,U){var ba,ca,S,N,Z,V,J,W;this.autoClear&&this.clear();b=h.projectScene(T,U,this.sortElements);O=L=F=0;if(I=T.lights.length>0){J=T.lights;v.setRGB(0,0,0);t.setRGB(0,0,0);l.setRGB(0,0,0);ba=0;for(ca=J.length;ba<ca;ba++){S=J[ba];N=S.color;if(S instanceof THREE.AmbientLight){v.r+=N.r;v.g+=N.g;v.b+=N.b}else if(S instanceof THREE.DirectionalLight){t.r+=N.r;t.g+=N.g;t.b+=N.b}else if(S instanceof THREE.PointLight){l.r+=N.r;l.g+=N.g;l.b+=N.b}}}ba=0;for(ca=b.length;ba<ca;ba++){J=b[ba];
- x.empty();if(J instanceof THREE.RenderableParticle){u=J;u.x*=n;u.y*=-z;S=0;for(N=J.materials.length;S<N;S++)if(W=J.materials[S]){Z=u;V=J;W=W;var da=L++;if(G[da]==null){G[da]=document.createElementNS("http://www.w3.org/2000/svg","circle");Q==0&&G[da].setAttribute("shape-rendering","crispEdges")}C=G[da];C.setAttribute("cx",Z.x);C.setAttribute("cy",Z.y);C.setAttribute("r",V.scale.x*n);if(W instanceof THREE.ParticleCircleMaterial){if(I){k.r=v.r+t.r+l.r;k.g=v.g+t.g+l.g;k.b=v.b+t.b+l.b;q.r=W.color.r*k.r;
- q.g=W.color.g*k.g;q.b=W.color.b*k.b;q.updateStyleString()}else q=W.color;C.setAttribute("style","fill: "+q.__styleString)}j.appendChild(C)}}else if(J instanceof THREE.RenderableLine){u=J.v1;p=J.v2;u.positionScreen.x*=n;u.positionScreen.y*=-z;p.positionScreen.x*=n;p.positionScreen.y*=-z;x.addPoint(u.positionScreen.x,u.positionScreen.y);x.addPoint(p.positionScreen.x,p.positionScreen.y);if(H.instersects(x)){S=0;for(N=J.materials.length;S<N;)if(W=J.materials[S++]){Z=u;V=p;W=W;da=O++;if(B[da]==null){B[da]=
- document.createElementNS("http://www.w3.org/2000/svg","line");Q==0&&B[da].setAttribute("shape-rendering","crispEdges")}C=B[da];C.setAttribute("x1",Z.positionScreen.x);C.setAttribute("y1",Z.positionScreen.y);C.setAttribute("x2",V.positionScreen.x);C.setAttribute("y2",V.positionScreen.y);if(W instanceof THREE.LineBasicMaterial){q.__styleString=W.color.__styleString;C.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+W.linewidth+"; stroke-opacity: "+W.opacity+"; stroke-linecap: "+
- W.linecap+"; stroke-linejoin: "+W.linejoin);j.appendChild(C)}}}}else if(J instanceof THREE.RenderableFace3){u=J.v1;p=J.v2;A=J.v3;u.positionScreen.x*=n;u.positionScreen.y*=-z;p.positionScreen.x*=n;p.positionScreen.y*=-z;A.positionScreen.x*=n;A.positionScreen.y*=-z;x.addPoint(u.positionScreen.x,u.positionScreen.y);x.addPoint(p.positionScreen.x,p.positionScreen.y);x.addPoint(A.positionScreen.x,A.positionScreen.y);if(H.instersects(x)){S=0;for(N=J.meshMaterials.length;S<N;){W=J.meshMaterials[S++];if(W instanceof
- THREE.MeshFaceMaterial){Z=0;for(V=J.faceMaterials.length;Z<V;)(W=J.faceMaterials[Z++])&&c(u,p,A,J,W,T)}else W&&c(u,p,A,J,W,T)}}}else if(J instanceof THREE.RenderableFace4){u=J.v1;p=J.v2;A=J.v3;D=J.v4;u.positionScreen.x*=n;u.positionScreen.y*=-z;p.positionScreen.x*=n;p.positionScreen.y*=-z;A.positionScreen.x*=n;A.positionScreen.y*=-z;D.positionScreen.x*=n;D.positionScreen.y*=-z;x.addPoint(u.positionScreen.x,u.positionScreen.y);x.addPoint(p.positionScreen.x,p.positionScreen.y);x.addPoint(A.positionScreen.x,
- A.positionScreen.y);x.addPoint(D.positionScreen.x,D.positionScreen.y);if(H.instersects(x)){S=0;for(N=J.meshMaterials.length;S<N;){W=J.meshMaterials[S++];if(W instanceof THREE.MeshFaceMaterial){Z=0;for(V=J.faceMaterials.length;Z<V;)(W=J.faceMaterials[Z++])&&d(u,p,A,D,J,W,T)}else W&&d(u,p,A,D,J,W,T)}}}}}};
- THREE.WebGLRenderer=function(a){function c(k,v){k.fragment_shader=v.fragment_shader;k.vertex_shader=v.vertex_shader;k.uniforms=Uniforms.clone(v.uniforms)}function d(k,v){var t;if(k=="fragment")t=b.createShader(b.FRAGMENT_SHADER);else if(k=="vertex")t=b.createShader(b.VERTEX_SHADER);b.shaderSource(t,v);b.compileShader(t);if(!b.getShaderParameter(t,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(t));return null}return t}function e(k){switch(k){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;
- case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;
- case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var f=document.createElement("canvas"),b,h=null,j=null,g=new THREE.Matrix4,m,n=new Float32Array(16),z=new Float32Array(16),
- u=new Float32Array(16),p=new Float32Array(9),A=new Float32Array(16),D=new THREE.Matrix4,H=new THREE.Vector4,x=true,I=new THREE.Color(0),q=0;if(a){if(a.antialias!==undefined)x=a.antialias;a.clearColor!==undefined&&I.setHex(a.clearColor);if(a.clearAlpha!==undefined)q=a.clearAlpha}this.domElement=f;this.autoClear=true;(function(k,v,t){try{b=f.getContext("experimental-webgl",{antialias:k})}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(v.r,v.g,v.b,t)})(x,I,q);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(k,v){f.width=k;f.height=v;b.viewport(0,0,f.width,f.height)};this.setClearColorHex=function(k,v){var t=new THREE.Color(k);b.clearColor(t.r,
- t.g,t.b,v)};this.setClearColor=function(k,v){b.clearColor(k.r,k.g,k.b,v)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(k,v){var t,l,o,w=0,y=0,G=0,B,C,F,L=this.lights,O=L.directional.colors,Q=L.directional.positions,T=L.point.colors,U=L.point.positions,ba=0,ca=0;t=0;for(l=v.length;t<l;t++){o=v[t];B=o.color;C=o.position;F=o.intensity;if(o instanceof THREE.AmbientLight){w+=B.r;y+=B.g;G+=B.b}else if(o instanceof THREE.DirectionalLight){O[ba*3]=B.r*F;
- O[ba*3+1]=B.g*F;O[ba*3+2]=B.b*F;Q[ba*3]=C.x;Q[ba*3+1]=C.y;Q[ba*3+2]=C.z;ba+=1}else if(o instanceof THREE.PointLight){T[ca*3]=B.r*F;T[ca*3+1]=B.g*F;T[ca*3+2]=B.b*F;U[ca*3]=C.x;U[ca*3+1]=C.y;U[ca*3+2]=C.z;ca+=1}}L.point.length=ca;L.directional.length=ba;L.ambient[0]=w;L.ambient[1]=y;L.ambient[2]=G};this.createParticleBuffers=function(k){k.__webGLVertexBuffer=b.createBuffer();k.__webGLColorBuffer=b.createBuffer();k.__webGLParticleBuffer=b.createBuffer()};this.createLineBuffers=function(k){k.__webGLVertexBuffer=
- b.createBuffer();k.__webGLColorBuffer=b.createBuffer();k.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=function(k){k.__webGLVertexBuffer=b.createBuffer();k.__webGLNormalBuffer=b.createBuffer();k.__webGLTangentBuffer=b.createBuffer();k.__webGLColorBuffer=b.createBuffer();k.__webGLUVBuffer=b.createBuffer();k.__webGLUV2Buffer=b.createBuffer();k.__webGLFaceBuffer=b.createBuffer();k.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(k){var v=k.vertices.length;k.__vertexArray=
- new Float32Array(v*3);k.__colorArray=new Float32Array(v*3);k.__lineArray=new Uint16Array(v);k.__webGLLineCount=v};this.initParticleBuffers=function(k){var v=k.vertices.length;k.__vertexArray=new Float32Array(v*3);k.__colorArray=new Float32Array(v*3);k.__particleArray=new Uint16Array(v);k.__sortArray=[];k.__webGLParticleCount=v};this.initMeshBuffers=function(k,v){var t,l,o=0,w=0,y=0,G=v.geometry.faces,B=k.faces;t=0;for(l=B.length;t<l;t++){fi=B[t];face=G[fi];if(face instanceof THREE.Face3){o+=3;w+=
- 1;y+=3}else if(face instanceof THREE.Face4){o+=4;w+=2;y+=4}}k.__vertexArray=new Float32Array(o*3);k.__normalArray=new Float32Array(o*3);k.__tangentArray=new Float32Array(o*4);k.__colorArray=new Float32Array(o*3);k.__uvArray=new Float32Array(o*2);k.__uv2Array=new Float32Array(o*2);k.__faceArray=new Uint16Array(w*3);k.__lineArray=new Uint16Array(y*2);o=false;t=0;for(l=v.materials.length;t<l;t++){G=v.materials[t];if(G instanceof THREE.MeshFaceMaterial){G=0;for(B=k.materials.length;G<B;G++)if(k.materials[G]&&
- k.materials[G].shading!=undefined&&k.materials[G].shading==THREE.SmoothShading){o=true;break}}else if(G&&G.shading!=undefined&&G.shading==THREE.SmoothShading){o=true;break}if(o)break}k.__needsSmoothNormals=o;k.__webGLFaceCount=w*3;k.__webGLLineCount=y*2};this.setMeshBuffers=function(k,v,t){var l,o,w,y,G,B,C,F,L,O,Q=0,T=0,U=0,ba=0,ca=0,S=0,N=0,Z=0,V=0,J=k.__vertexArray,W=k.__uvArray,da=k.__uv2Array,ha=k.__normalArray,ea=k.__tangentArray,E=k.__colorArray,M=k.__faceArray,K=k.__lineArray,X=k.__needsSmoothNormals,
- $=v.geometry,ma=$.__dirtyVertices,ia=$.__dirtyElements,qa=$.__dirtyUvs,ta=$.__dirtyNormals,ua=$.__dirtyTangents,ka=$.__dirtyColors,ja=$.vertices,Fa=k.faces,Aa=$.faces,Ja=$.uvs,Ka=$.uvs2,ra=$.colors;v=0;for(l=Fa.length;v<l;v++){o=Fa[v];w=Aa[o];B=Ja[o];o=Ka[o];y=w.vertexNormals;G=w.normal;if(w instanceof THREE.Face3){if(ma){C=ja[w.a].position;F=ja[w.b].position;L=ja[w.c].position;J[T]=C.x;J[T+1]=C.y;J[T+2]=C.z;J[T+3]=F.x;J[T+4]=F.y;J[T+5]=F.z;J[T+6]=L.x;J[T+7]=L.y;J[T+8]=L.z;T+=9}if(ka&&ra.length){C=
- ra[w.a];F=ra[w.b];L=ra[w.c];E[V]=C.r;E[V+1]=C.g;E[V+2]=C.b;E[V+3]=F.r;E[V+4]=F.g;E[V+5]=F.b;E[V+6]=L.r;E[V+7]=L.g;E[V+8]=L.b;V+=9}if(ua&&$.hasTangents){C=ja[w.a].tangent;F=ja[w.b].tangent;L=ja[w.c].tangent;ea[N]=C.x;ea[N+1]=C.y;ea[N+2]=C.z;ea[N+3]=C.w;ea[N+4]=F.x;ea[N+5]=F.y;ea[N+6]=F.z;ea[N+7]=F.w;ea[N+8]=L.x;ea[N+9]=L.y;ea[N+10]=L.z;ea[N+11]=L.w;N+=12}if(ta)if(y.length==3&&X)for(w=0;w<3;w++){G=y[w];ha[S]=G.x;ha[S+1]=G.y;ha[S+2]=G.z;S+=3}else for(w=0;w<3;w++){ha[S]=G.x;ha[S+1]=G.y;ha[S+2]=G.z;S+=
- 3}if(qa&&B)for(w=0;w<3;w++){y=B[w];W[U]=y.u;W[U+1]=y.v;U+=2}if(qa&&o)for(w=0;w<3;w++){B=o[w];da[ba]=B.u;da[ba+1]=B.v;ba+=2}if(ia){M[ca]=Q;M[ca+1]=Q+1;M[ca+2]=Q+2;ca+=3;K[Z]=Q;K[Z+1]=Q+1;K[Z+2]=Q;K[Z+3]=Q+2;K[Z+4]=Q+1;K[Z+5]=Q+2;Z+=6;Q+=3}}else if(w instanceof THREE.Face4){if(ma){C=ja[w.a].position;F=ja[w.b].position;L=ja[w.c].position;O=ja[w.d].position;J[T]=C.x;J[T+1]=C.y;J[T+2]=C.z;J[T+3]=F.x;J[T+4]=F.y;J[T+5]=F.z;J[T+6]=L.x;J[T+7]=L.y;J[T+8]=L.z;J[T+9]=O.x;J[T+10]=O.y;J[T+11]=O.z;T+=12}if(ka&&
- ra.length){C=ra[w.a];F=ra[w.b];L=ra[w.d];E[V]=C.r;E[V+1]=C.g;E[V+2]=C.b;E[V+3]=F.r;E[V+4]=F.g;E[V+5]=F.b;E[V+6]=L.r;E[V+7]=L.g;E[V+8]=L.b;E[V+9]=(void 0).r;E[V+10]=(void 0).g;E[V+11]=(void 0).b;V+=12}if(ua&&$.hasTangents){C=ja[w.a].tangent;F=ja[w.b].tangent;L=ja[w.c].tangent;w=ja[w.d].tangent;ea[N]=C.x;ea[N+1]=C.y;ea[N+2]=C.z;ea[N+3]=C.w;ea[N+4]=F.x;ea[N+5]=F.y;ea[N+6]=F.z;ea[N+7]=F.w;ea[N+8]=L.x;ea[N+9]=L.y;ea[N+10]=L.z;ea[N+11]=L.w;ea[N+12]=w.x;ea[N+13]=w.y;ea[N+14]=w.z;ea[N+15]=w.w;N+=16}if(ta)if(y.length==
- 4&&X)for(w=0;w<4;w++){G=y[w];ha[S]=G.x;ha[S+1]=G.y;ha[S+2]=G.z;S+=3}else for(w=0;w<4;w++){ha[S]=G.x;ha[S+1]=G.y;ha[S+2]=G.z;S+=3}if(qa&&B)for(w=0;w<4;w++){y=B[w];W[U]=y.u;W[U+1]=y.v;U+=2}if(qa&&o)for(w=0;w<4;w++){B=o[w];da[ba]=B.u;da[ba+1]=B.v;ba+=2}if(ia){M[ca]=Q;M[ca+1]=Q+1;M[ca+2]=Q+2;M[ca+3]=Q;M[ca+4]=Q+2;M[ca+5]=Q+3;ca+=6;K[Z]=Q;K[Z+1]=Q+1;K[Z+2]=Q;K[Z+3]=Q+3;K[Z+4]=Q+1;K[Z+5]=Q+2;K[Z+6]=Q+2;K[Z+7]=Q+3;Z+=8;Q+=4}}}if(ma){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,
- J,t)}if(ka&&ra.length){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,E,t)}if(ta){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ha,t)}if(ua&&$.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,ea,t)}if(qa&&U>0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,W,t)}if(qa&&ba>0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,da,t)}if(ia){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
- k.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,M,t);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,K,t)}};this.setLineBuffers=function(k,v){var t,l,o,w=k.vertices,y=k.colors,G=w.length,B=y.length,C=k.__vertexArray,F=k.__colorArray,L=k.__lineArray,O=k.__dirtyColors,Q=k.__dirtyElements;if(k.__dirtyVertices){for(t=0;t<G;t++){l=w[t].position;o=t*3;C[o]=l.x;C[o+1]=l.y;C[o+2]=l.z}b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,
- C,v)}if(O){for(t=0;t<B;t++){color=y[t];o=t*3;F[o]=color.r;F[o+1]=color.g;F[o+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,k.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,F,v)}if(Q){for(t=0;t<G;t++)L[t]=t;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,L,v)}};this.setParticleBuffers=function(k,v,t,l){var o,w,y;w=k.vertices;var G=w.length,B=k.colors,C=B.length,F=k.__vertexArray,L=k.__particleArray,O=k.__colorArray,Q=k.__sortArray,T=k.__dirtyVertices,U=k.__dirtyElements,
- ba=k.__dirtyColors;if(t.sortParticles){D.multiply(l.projectionMatrix,l.matrix);D.multiplySelf(t.matrix);for(o=0;o<G;o++){y=w[o].position;H.copy(y);D.multiplyVector3(H);Q[o]=[H.z,o]}Q.sort(function(ca,S){return S[0]-ca[0]});for(o=0;o<G;o++){y=w[Q[o][1]].position;l=o*3;F[l]=y.x;F[l+1]=y.y;F[l+2]=y.z}for(w=0;w<C;w++){l=w*3;color=B[Q[w][1]];O[l]=color.r;O[l+1]=color.g;O[l+2]=color.b}}else{if(T)for(o=0;o<G;o++){y=w[o].position;l=o*3;F[l]=y.x;F[l+1]=y.y;F[l+2]=y.z}if(ba)for(w=0;w<C;w++){color=B[w];l=w*
- 3;O[l]=color.r;O[l+1]=color.g;O[l+2]=color.b}}if(U){for(o=0;o<G;o++)L[o]=o;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,L,v)}if(T||t.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,F,v)}if(ba||t.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,O,v)}};this.initMaterial=function(k,v,t){if(!k.program){var l,o;if(k instanceof THREE.MeshDepthMaterial)c(k,THREE.ShaderLib.depth);
- else if(k instanceof THREE.MeshNormalMaterial)c(k,THREE.ShaderLib.normal);else if(k instanceof THREE.MeshBasicMaterial)c(k,THREE.ShaderLib.basic);else if(k instanceof THREE.MeshLambertMaterial)c(k,THREE.ShaderLib.lambert);else if(k instanceof THREE.MeshPhongMaterial)c(k,THREE.ShaderLib.phong);else if(k instanceof THREE.LineBasicMaterial)c(k,THREE.ShaderLib.basic);else k instanceof THREE.ParticleBasicMaterial&&c(k,THREE.ShaderLib.particle_basic);var w,y,G,B;o=G=B=0;for(w=v.length;o<w;o++){y=v[o];y instanceof
- THREE.DirectionalLight&&G++;y instanceof THREE.PointLight&&B++}if(B+G<=4){v=G;B=B}else{v=Math.ceil(4*G/(B+G));B=4-v}o={directional:v,point:B};B=k.fragment_shader;v=k.vertex_shader;w={fog:t,map:k.map,env_map:k.env_map,light_map:k.light_map,vertex_colors:k.vertex_colors,maxDirLights:o.directional,maxPointLights:o.point};t=b.createProgram();o=["#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(t,d("fragment",o+B));b.attachShader(t,d("vertex",w+v));b.linkProgram(t);b.getProgramParameter(t,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+
- b.getProgramParameter(t,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");t.uniforms={};t.attributes={};k.program=t;t=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(l in k.uniforms)t.push(l);l=k.program;B=0;for(v=t.length;B<v;B++){o=t[B];l.uniforms[o]=b.getUniformLocation(l,o)}k=k.program;l=["position","normal","uv","uv2","tangent","color"];t=0;for(B=l.length;t<B;t++){v=l[t];k.attributes[v]=b.getAttribLocation(k,v)}}};this.setProgram=function(k,
- v,t,l){this.initMaterial(l,v,t);var o=l.program;if(o!=h){b.useProgram(o);h=o}this.loadCamera(o,k);this.loadMatrices(o);if(l instanceof THREE.MeshPhongMaterial||l instanceof THREE.MeshLambertMaterial){this.setupLights(o,v);v=this.lights;l.uniforms.enableLighting.value=v.directional.length+v.point.length;l.uniforms.ambientLightColor.value=v.ambient;l.uniforms.directionalLightColor.value=v.directional.colors;l.uniforms.directionalLightDirection.value=v.directional.positions;l.uniforms.pointLightColor.value=
- v.point.colors;l.uniforms.pointLightPosition.value=v.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(t){l.uniforms.fogColor.value.setHex(t.color.hex);if(t instanceof THREE.Fog){l.uniforms.fogNear.value=t.near;l.uniforms.fogFar.value=t.far}else if(t instanceof THREE.FogExp2)l.uniforms.fogDensity.value=t.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(t){l.uniforms.fogColor.value.setHex(t.color.hex);if(t instanceof THREE.Fog){l.uniforms.fogNear.value=t.near;l.uniforms.fogFar.value=t.far}else if(t instanceof THREE.FogExp2)l.uniforms.fogDensity.value=t.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(t){l.uniforms.fogColor.value.setHex(t.color.hex);
- if(t instanceof THREE.Fog){l.uniforms.fogNear.value=t.near;l.uniforms.fogFar.value=t.far}else if(t instanceof THREE.FogExp2)l.uniforms.fogDensity.value=t.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=k.near;l.uniforms.mFar.value=k.far}k=l.uniforms;var w,
- y;for(w in k)if(y=o.uniforms[w]){l=k[w];v=l.type;t=l.value;if(v=="i")b.uniform1i(y,t);else if(v=="f")b.uniform1f(y,t);else if(v=="fv1")b.uniform1fv(y,t);else if(v=="fv")b.uniform3fv(y,t);else if(v=="v2")b.uniform2f(y,t.x,t.y);else if(v=="v3")b.uniform3f(y,t.x,t.y,t.z);else if(v=="c")b.uniform3f(y,t.r,t.g,t.b);else if(v=="t"){b.uniform1i(y,t);if(l=l.texture)if(l.image instanceof Array&&l.image.length==6){l=l;t=t;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(v=0;v<6;++v)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,l.image[v]);b.generateMipmap(b.TEXTURE_CUBE_MAP);
- b.bindTexture(b.TEXTURE_CUBE_MAP,null);l.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+t);b.bindTexture(b.TEXTURE_CUBE_MAP,l.image.__webGLTextureCube)}}else{l=l;t=t;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,e(l.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,e(l.wrap_t));b.texParameteri(b.TEXTURE_2D,
- b.TEXTURE_MAG_FILTER,e(l.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e(l.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+t);b.bindTexture(b.TEXTURE_2D,l.__webGLTexture)}}}return o};this.renderBuffer=function(k,v,t,l,o,w){k=this.setProgram(k,v,t,l,w).attributes;b.bindBuffer(b.ARRAY_BUFFER,o.__webGLVertexBuffer);b.vertexAttribPointer(k.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.position);if(k.color>=0){b.bindBuffer(b.ARRAY_BUFFER,
- o.__webGLColorBuffer);b.vertexAttribPointer(k.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.color)}if(k.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,o.__webGLNormalBuffer);b.vertexAttribPointer(k.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.normal)}if(k.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,o.__webGLTangentBuffer);b.vertexAttribPointer(k.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.tangent)}if(k.uv>=0)if(o.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,o.__webGLUVBuffer);
- b.vertexAttribPointer(k.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.uv)}else b.disableVertexAttribArray(k.uv);if(k.uv2>=0)if(o.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,o.__webGLUV2Buffer);b.vertexAttribPointer(k.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.uv2)}else b.disableVertexAttribArray(k.uv2);if(l.wireframe||l instanceof THREE.LineBasicMaterial){k=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(k);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);b.drawElements(l,o.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(l instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,o.__webGLParticleBuffer);b.drawElements(b.POINTS,o.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,o.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(k,
- v,t,l,o,w,y){var G,B,C,F,L;C=0;for(F=l.materials.length;C<F;C++){G=l.materials[C];if(G instanceof THREE.MeshFaceMaterial){G=0;for(B=o.materials.length;G<B;G++)if((L=o.materials[G])&&L.blending==w&&L.opacity<1==y){this.setBlending(L.blending);this.renderBuffer(k,v,t,L,o,l)}}else if((L=G)&&L.blending==w&&L.opacity<1==y){this.setBlending(L.blending);this.renderBuffer(k,v,t,L,o,l)}}};this.renderPassImmediate=function(k,v,t,l,o,w){var y,G,B,C;y=0;for(G=l.materials.length;y<G;y++)if((B=l.materials[y])&&
- B.blending==o&&B.opacity<1==w){this.setBlending(B.blending);C=this.setProgram(k,v,t,B,l);l.render(function(F){var L=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(L.attributes.position);b.vertexAttribPointer(L.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(L.attributes.normal);b.vertexAttribPointer(L.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,F.count);F.count=0})}};this.render=function(k,v,t,l){var o,w,y,G=k.lights,B=k.fog;v.autoUpdateMatrix&&v.updateMatrix();n.set(v.matrix.flatten());u.set(v.projectionMatrix.flatten());this.initWebGLObjects(k,v);l=l!==undefined?l:true;if(t&&!t.__webGLFramebuffer){t.__webGLFramebuffer=b.createFramebuffer();
- t.__webGLRenderbuffer=b.createRenderbuffer();t.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,t.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,t.width,t.height);b.bindTexture(b.TEXTURE_2D,t.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,e(t.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,e(t.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,e(t.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e(t.min_filter));
- b.texImage2D(b.TEXTURE_2D,0,e(t.format),t.width,t.height,0,e(t.format),e(t.type),null);b.bindFramebuffer(b.FRAMEBUFFER,t.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,t.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,t.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(t){o=t.__webGLFramebuffer;y=t.width;w=t.height}else{o=null;
- y=f.width;w=f.height}if(o!=j){b.bindFramebuffer(b.FRAMEBUFFER,o);b.viewport(0,0,y,w);l&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);j=o}this.autoClear&&this.clear();o=k.__webGLObjects.length;for(l=0;l<o;l++){w=k.__webGLObjects[l];y=w.object;if(y.visible){y.autoUpdateMatrix&&y.updateMatrix();if(y.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);y.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}}for(l=0;l<o;l++){w=k.__webGLObjects[l];y=w.object;w=w.buffer;if(y.visible){y.autoUpdateMatrix&&
- y.updateMatrix();this.setupMatrices(y,v);this.renderPass(v,G,B,y,w,THREE.NormalBlending,false)}}for(l=0;l<k.__webGLObjectsImmediate.length;l++){w=k.__webGLObjectsImmediate[l];y=w.object;if(y.visible){y.autoUpdateMatrix&&y.updateMatrix();this.setupMatrices(y,v);this.renderPassImmediate(v,G,B,y,THREE.NormalBlending,false)}}for(l=0;l<o;l++){w=k.__webGLObjects[l];y=w.object;w=w.buffer;if(y.visible){this.setupMatrices(y,v);this.renderPass(v,G,B,y,w,THREE.AdditiveBlending,false);this.renderPass(v,G,B,y,
- w,THREE.SubtractiveBlending,false);this.renderPass(v,G,B,y,w,THREE.AdditiveBlending,true);this.renderPass(v,G,B,y,w,THREE.SubtractiveBlending,true);this.renderPass(v,G,B,y,w,THREE.NormalBlending,true);this.renderPass(v,G,B,y,w,THREE.BillboardBlending,false)}}for(l=0;l<k.__webGLObjectsImmediate.length;l++){w=k.__webGLObjectsImmediate[l];y=w.object;if(y.visible){y.autoUpdateMatrix&&y.updateMatrix();this.setupMatrices(y,v);this.renderPassImmediate(v,G,B,y,THREE.NormalBlending,true)}}if(t&&t.min_filter!==
- THREE.NearestFilter&&t.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,t.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(k,v){function t(L,O,Q,T){if(L[O]==undefined){k.__webGLObjects.push({buffer:Q,object:T});L[O]=1}}function l(L,O,Q){if(L[O]==undefined){k.__webGLObjectsImmediate.push({object:Q});L[O]=1}}var o,w,y,G,B,C,F;if(!k.__webGLObjects){k.__webGLObjects=[];k.__webGLObjectsMap={};k.__webGLObjectsImmediate=[]}o=0;for(w=
- k.objects.length;o<w;o++){y=k.objects[o];B=y.geometry;if(k.__webGLObjectsMap[y.id]==undefined)k.__webGLObjectsMap[y.id]={};F=k.__webGLObjectsMap[y.id];if(y instanceof THREE.Mesh){for(G in B.geometryChunks){C=B.geometryChunks[G];if(!C.__webGLVertexBuffer){this.createMeshBuffers(C);this.initMeshBuffers(C,y);B.__dirtyVertices=true;B.__dirtyElements=true;B.__dirtyUvs=true;B.__dirtyNormals=true;B.__dirtyTangents=true;B.__dirtyColors=true}if(B.__dirtyVertices||B.__dirtyElements||B.__dirtyUvs||B.__dirtyNormals||
- B.__dirtyColors||B.__dirtyTangents)this.setMeshBuffers(C,y,b.DYNAMIC_DRAW);t(F,G,C,y)}B.__dirtyVertices=false;B.__dirtyElements=false;B.__dirtyUvs=false;B.__dirtyNormals=false;B.__dirtyTangents=false;B.__dirtyColors=false}else if(y instanceof THREE.Line){if(!B.__webGLVertexBuffer){this.createLineBuffers(B);this.initLineBuffers(B);B.__dirtyVertices=true;B.__dirtyElements=true;B.__dirtyColors=true}if(B.__dirtyVertices||B.__dirtyColors)this.setLineBuffers(B,b.DYNAMIC_DRAW);t(F,0,B,y);B.__dirtyVertices=
- false;B.__dirtyElements=false}else if(y instanceof THREE.ParticleSystem){if(!B.__webGLVertexBuffer){this.createParticleBuffers(B);this.initParticleBuffers(B);B.__dirtyVertices=true;B.__dirtyColors=true;B.__dirtyElements=true}if(B.__dirtyVertices||B.__dirtyColors||y.sortParticles)this.setParticleBuffers(B,b.DYNAMIC_DRAW,y,v);t(F,0,B,y);B.__dirtyVertices=false;B.__dirtyColors=false;B.__dirtyElements=false}else y instanceof THREE.MarchingCubes&&l(F,0,y)}};this.removeObject=function(k,v){var t,l;for(t=
- k.__webGLObjects.length-1;t>=0;t--){l=k.__webGLObjects[t].object;v==l&&k.__webGLObjects.splice(t,1)}};this.setupMatrices=function(k,v){g.multiply(v.matrix,k.matrix);z.set(g.flatten());m=THREE.Matrix4.makeInvert3x3(g).transpose();p.set(m.m);A.set(k.matrix.flatten())};this.loadMatrices=function(k){b.uniformMatrix4fv(k.uniforms.viewMatrix,false,n);b.uniformMatrix4fv(k.uniforms.modelViewMatrix,false,z);b.uniformMatrix4fv(k.uniforms.projectionMatrix,false,u);b.uniformMatrix3fv(k.uniforms.normalMatrix,
- false,p);b.uniformMatrix4fv(k.uniforms.objectMatrix,false,A)};this.loadCamera=function(k,v){b.uniform3f(k.uniforms.cameraPosition,v.position.x,v.position.y,v.position.z)};this.setBlending=function(k){switch(k){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);
- b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(k,v){if(k){!v||v=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(k=="back")b.cullFace(b.BACK);else k=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
- THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
- envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",
- envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
- map_particle_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",
- lightmap_fragment:"#ifdef USE_LIGHTMAP\nlightmapColor = texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
- lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
- lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif",
- color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\nvertexColor = vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif"};
- THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},light_map:{type:"t",value:2,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",
- value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
- THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}",vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{},fragment_shader:"varying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );\n}",
- vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragment_shader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_pars_fragment,THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 lightmapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );\nvec4 vertexColor = vec4( 1.0 );",
- THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,"gl_FragColor = mColor * mapColor * lightmapColor * vertexColor;",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:[THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,THREE.Snippets.envmap_pars_vertex,THREE.Snippets.color_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,
- THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragment_shader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",THREE.Snippets.map_pars_fragment,THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 lightmapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",
- THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,"gl_FragColor = mColor * mapColor * lightmapColor * vec4( vLightWeighting, 1.0 );",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["varying vec3 vLightWeighting;",THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,THREE.Snippets.envmap_pars_vertex,THREE.Snippets.lights_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,
- THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),fragment_shader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",
- THREE.Snippets.map_pars_fragment,THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,THREE.Snippets.lights_pars_fragment,"void main() {\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 lightmapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",THREE.Snippets.map_fragment,THREE.Snippets.lights_fragment,THREE.Snippets.lightmap_fragment,"gl_FragColor = mapColor * lightmapColor * totalLight * vec4( vLightWeighting, 1.0 );",
- THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,THREE.Snippets.envmap_pars_vertex,THREE.Snippets.lights_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",
- THREE.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragment_shader:["uniform vec3 psColor;\nuniform float opacity;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_particle_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( psColor, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 vertexColor = vec4( 1.0 );",THREE.Snippets.map_particle_fragment,THREE.Snippets.color_fragment,
- "gl_FragColor = mColor * mapColor * vertexColor;",THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["uniform float size;",THREE.Snippets.color_pars_vertex,"void main() {",THREE.Snippets.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\ngl_PointSize = size;\n}"].join("\n")}};THREE.RenderableObject=function(){this.z=this.object=null};
- THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=false;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};
- THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
- var GeometryUtils={merge:function(a,c){var d=c instanceof THREE.Mesh,e=a.vertices.length,f=d?c.geometry:c,b=a.vertices,h=f.vertices,j=a.faces,g=f.faces,m=a.uvs;f=f.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var n=0,z=h.length;n<z;n++){var u=new THREE.Vertex(h[n].position.clone());d&&c.matrix.multiplyVector3(u.position);b.push(u)}n=0;for(z=g.length;n<z;n++){h=g[n];var p,A=h.vertexNormals;if(h instanceof THREE.Face3)p=new THREE.Face3(h.a+e,h.b+e,h.c+e);else if(h instanceof THREE.Face4)p=new THREE.Face4(h.a+
- e,h.b+e,h.c+e,h.d+e);p.centroid.copy(h.centroid);p.normal.copy(h.normal);d=0;for(b=A.length;d<b;d++){u=A[d];p.vertexNormals.push(u.clone())}p.materials=h.materials.slice();j.push(p)}n=0;for(z=f.length;n<z;n++){e=f[n];j=[];d=0;for(b=e.length;d<b;d++)j.push(new THREE.UV(e[d].u,e[d].v));m.push(j)}}},ImageUtils={loadTexture:function(a,c,d){var e=new Image;e.onload=function(){this.loaded=true;d&&d(this)};e.src=a;return new THREE.Texture(e,c)},loadArray:function(a,c){var d,e,f=[];d=f.loadCount=0;for(e=
- a.length;d<e;++d){f[d]=new Image;f[d].loaded=0;f[d].onload=function(){f.loadCount+=1;this.loaded=true;c&&c(this)};f[d].src=a[d]}return f}},SceneUtils={loadScene:function(a,c,d,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(f){function b(){for(n in l.objects)if(!C.objects[n]){D=l.objects[n];if(q=C.geometries[D.geometry]){t=[];for(i=0;i<D.materials.length;i++)t[i]=C.materials[D.materials[i]];H=D.position;r=D.rotation;s=D.scale;object=new THREE.Mesh(q,t);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=D.visible;C.scene.addObject(object);C.objects[n]=object}}}function h(F){return function(L){C.geometries[F]=L;b();w-=1;j()}}function j(){e({total_models:G,total_textures:B,loaded_models:G-w,loaded_textures:B-y},C);w==0&&y==0&&d(C)}var g,m,n,z,u,p,A,D,H,x,I,q,k,v,t,l,o,w,y,G,B,C;l=f.data;o=new THREE.Loader;y=w=0;C={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
- f=function(){y-=1;j()};for(u in l.cameras){x=l.cameras[u];if(x.type=="perspective")k=new THREE.Camera(x.fov,x.aspect,x.near,x.far);else if(x.type=="ortho"){k=new THREE.Camera;k.projectionMatrix=THREE.Matrix4.makeOrtho(x.left,x.right,x.top,x.bottom,x.near,x.far)}H=x.position;x=x.target;k.position.set(H[0],H[1],H[2]);k.target.position.set(x[0],x[1],x[2]);C.cameras[u]=k}for(z in l.lights){u=l.lights[z];if(u.type=="directional"){H=u.direction;light=new THREE.DirectionalLight;light.position.set(H[0],H[1],
- H[2]);light.position.normalize()}else if(u.type=="point"){H=u.position;light=new THREE.PointLight;light.position.set(H[0],H[1],H[2])}x=u.color;i=u.intensity||1;light.color.setRGB(x[0]*i,x[1]*i,x[2]*i);C.scene.addLight(light);C.lights[z]=light}for(p in l.fogs){z=l.fogs[p];if(z.type=="linear")v=new THREE.Fog(0,z.near,z.far);else if(z.type=="exp2")v=new THREE.FogExp2(0,z.density);x=z.color;v.color.setRGB(x[0],x[1],x[2]);C.fogs[p]=v}if(C.cameras&&l.defaults.camera)C.currentCamera=C.cameras[l.defaults.camera];
- if(C.fogs&&l.defaults.fog)C.scene.fog=C.fogs[l.defaults.fog];x=l.defaults.bgcolor;C.bgColor=new THREE.Color;C.bgColor.setRGB(x[0],x[1],x[2]);C.bgColorAlpha=l.defaults.bgalpha;for(g in l.geometries){p=l.geometries[g];if(p.type=="bin_mesh"||p.type=="ascii_mesh")w+=1}G=w;for(g in l.geometries){p=l.geometries[g];if(p.type=="cube"){q=new Cube(p.width,p.height,p.depth,p.segments_width,p.segments_height,null,p.flipped,p.sides);C.geometries[g]=q}else if(p.type=="plane"){q=new Plane(p.width,p.height,p.segments_width,
- p.segments_height);C.geometries[g]=q}else if(p.type=="sphere"){q=new Sphere(p.radius,p.segments_width,p.segments_height);C.geometries[g]=q}else if(p.type=="cylinder"){q=new Cylinder(p.numSegs,p.topRad,p.botRad,p.height,p.topOffset,p.botOffset);C.geometries[g]=q}else if(p.type=="torus"){q=new Torus(p.radius,p.tube,p.segmentsR,p.segmentsT);C.geometries[g]=q}else if(p.type=="icosahedron"){q=new Icosahedron(p.subdivisions);C.geometries[g]=q}else if(p.type=="bin_mesh")o.loadBinary({model:p.url,callback:h(g)});
- else p.type=="ascii_mesh"&&o.loadAscii({model:p.url,callback:h(g)})}for(A in l.textures){g=l.textures[A];y+=g.url instanceof Array?g.url.length:1}B=y;for(A in l.textures){g=l.textures[A];if(g.mapping!=undefined&&THREE[g.mapping]!=undefined)g.mapping=new THREE[g.mapping];if(g.url instanceof Array){p=ImageUtils.loadArray(g.url,f);p=new THREE.Texture(p,g.mapping)}else{p=ImageUtils.loadTexture(g.url,g.mapping,f);if(THREE[g.min_filter]!=undefined)p.min_filter=THREE[g.min_filter];if(THREE[g.mag_filter]!=
- undefined)p.mag_filter=THREE[g.mag_filter]}C.textures[A]=p}for(m in l.materials){A=l.materials[m];for(I in A.parameters)if(I=="env_map"||I=="map"||I=="light_map")A.parameters[I]=C.textures[A.parameters[I]];else if(I=="shading")A.parameters[I]=A.parameters[I]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(I=="blending")A.parameters[I]=THREE[A.parameters[I]]?THREE[A.parameters[I]]:THREE.NormalBlending;else if(I=="combine")A.parameters[I]=A.parameters[I]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
- A=new THREE[A.type](A.parameters);C.materials[m]=A}b();c(C)}},addMesh:function(a,c,d,e,f,b,h,j,g,m){c=new THREE.Mesh(c,m);c.scale.x=c.scale.y=c.scale.z=d;c.position.x=e;c.position.y=f;c.position.z=b;c.rotation.x=h;c.rotation.y=j;c.rotation.z=g;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,d){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=d;d=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,uniforms:e.uniforms});c=new THREE.Mesh(new Cube(c,
- c,c,1,1,null,true),d);a.addObject(c);return c},addPanoramaCube:function(a,c,d){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));c=new THREE.Mesh(new Cube(c,
- c,c,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(c);return c},addPanoramaCubePlanes:function(a,c,d){var e=c/2;c=new Plane(c,c);var f=Math.PI/2,b=Math.PI;SceneUtils.addMesh(a,c,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));SceneUtils.addMesh(a,c,1,-e,0,0,0,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,c,1,e,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,c,1,0,e,0,f,0,b,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));
- SceneUtils.addMesh(a,c,1,0,-e,0,-f,0,b,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
- vertex_shader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
- normal:{uniforms:{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:4,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",value:new THREE.Color(15658734)},uDirLightPos:{type:"v3",value:new THREE.Vector3},
- uDirLightColor:{type:"c",value:new THREE.Color(15658734)},uAmbientLightColor:{type:"c",value:new THREE.Color(328965)},uDiffuseColor:{type:"c",value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30}},fragment_shader:"uniform vec3 uDirLightPos;\nuniform vec3 uAmbientLightColor;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform bool enableDiffuse;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nuniform float uNormalScale;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 diffuseTex = vec3( 1.0, 1.0, 1.0 );\nvec3 aoTex = vec3( 1.0, 1.0, 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ndiffuseTex = texture2D( tDiffuse, vUv ).xyz;\nif( enableAO )\naoTex = texture2D( tAO, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec3 pointVector = normalize( vPointLightVector );\nvec3 pointHalfVector = normalize( vPointLightVector + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}",
- vertex_shader:"attribute vec4 tangent;\nuniform vec3 uPointLightPos;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"},
- cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"},convolution:{uniforms:{tDiffuse:{type:"t",
- value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertex_shader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
- film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},grayscale:{type:"i",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nconst float fNintensity = 0.35;\nconst float fSintensity = 0.35;\nconst float fScount = 4096.0;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time * 1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin(vUv.y * fScount), cos(vUv.y * fScount) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * fSintensity;\ncResult = cTextureScreen.rgb + clamp( fNintensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor = vec4( cResult, cTextureScreen.a );\n}"},
- screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
- fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,d,e,f,b=2*Math.ceil(a*3)+1;if(b>25)b=25;f=(b-1)*0.5;d=Array(b);for(c=e=0;c<b;++c){d[c]=Math.exp(-((c-f)*(c-f))/(2*a*a));e+=d[c]}for(c=0;c<b;++c)d[c]/=e;return d}},Cube=function(a,c,d,e,f,b,h,j){function g(D,H,x,I,q,k,v,t){var l,o,w=e||1,y=f||1,G=w+1,B=y+1,C=q/2,F=k/2;q=q/w;var L=k/y,O=m.vertices.length;if(D=="x"&&H=="y"||D=="y"&&H=="x")l="z";else if(D=="x"&&H=="z"||D=="z"&&H=="x")l="y";else if(D==
- "z"&&H=="y"||D=="y"&&H=="z")l="x";for(o=0;o<B;o++)for(k=0;k<G;k++){var Q=new THREE.Vector3;Q[D]=(k*q-C)*x;Q[H]=(o*L-F)*I;Q[l]=v;m.vertices.push(new THREE.Vertex(Q))}for(o=0;o<y;o++)for(k=0;k<w;k++){m.faces.push(new THREE.Face4(k+G*o+O,k+G*(o+1)+O,k+1+G*(o+1)+O,k+1+G*o+O,null,t));m.uvs.push([new THREE.UV(k/w,o/y),new THREE.UV(k/w,(o+1)/y),new THREE.UV((k+1)/w,(o+1)/y),new THREE.UV((k+1)/w,o/y)])}}THREE.Geometry.call(this);var m=this,n=a/2,z=c/2,u=d/2;h=h?-1:1;if(b!==undefined)if(b instanceof Array)this.materials=
- b;else{this.materials=[];for(var p=0;p<6;p++)this.materials.push([b])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(j!=undefined)for(var A in j)if(this.sides[A]!=undefined)this.sides[A]=j[A];this.sides.px&&g("z","y",1*h,-1,d,c,-n,this.materials[0]);this.sides.nx&&g("z","y",-1*h,-1,d,c,n,this.materials[1]);this.sides.py&&g("x","z",1*h,1,a,d,z,this.materials[2]);this.sides.ny&&g("x","z",1*h,-1,a,d,-z,this.materials[3]);this.sides.pz&&g("x","y",1*h,-1,a,c,u,this.materials[4]);
- this.sides.nz&&g("x","y",-1*h,-1,a,c,-u,this.materials[5]);(function(){for(var D=[],H=[],x=0,I=m.vertices.length;x<I;x++){for(var q=m.vertices[x],k=false,v=0,t=D.length;v<t;v++){var l=D[v];if(q.position.x==l.position.x&&q.position.y==l.position.y&&q.position.z==l.position.z){H[x]=v;k=true;break}}if(!k){H[x]=D.length;D.push(new THREE.Vertex(q.position.clone()))}}x=0;for(I=m.faces.length;x<I;x++){q=m.faces[x];q.a=H[q.a];q.b=H[q.b];q.c=H[q.c];q.d=H[q.d]}m.vertices=D})();this.computeCentroids();this.computeFaceNormals();
- this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
- var Cylinder=function(a,c,d,e,f){function b(m,n,z){h.vertices.push(new THREE.Vertex(new THREE.Vector3(m,n,z)))}THREE.Geometry.call(this);var h=this,j=Math.PI,g;for(g=0;g<a;g++)b(Math.sin(2*j*g/a)*c,Math.cos(2*j*g/a)*c,0);for(g=0;g<a;g++)b(Math.sin(2*j*g/a)*d,Math.cos(2*j*g/a)*d,e);for(g=0;g<a;g++)h.faces.push(new THREE.Face4(g,g+a,a+(g+1)%a,(g+1)%a));if(d!=0){b(0,0,-f);for(g=a;g<a+a/2;g++)h.faces.push(new THREE.Face4(2*a,(2*g-2*a)%a,(2*g-2*a+1)%a,(2*g-2*a+2)%a))}if(c!=0){b(0,0,e+f);for(g=a+a/2;g<
- 2*a;g++)h.faces.push(new THREE.Face4((2*g-2*a+2)%a+a,(2*g-2*a+1)%a+a,(2*g-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
- var Plane=function(a,c,d,e){THREE.Geometry.call(this);var f,b=a/2,h=c/2;d=d||1;e=e||1;var j=d+1,g=e+1;a=a/d;var m=c/e;for(f=0;f<g;f++)for(c=0;c<j;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-b,-(f*m-h),0)));for(f=0;f<e;f++)for(c=0;c<d;c++){this.faces.push(new THREE.Face4(c+j*f,c+j*(f+1),c+1+j*(f+1),c+1+j*f));this.uvs.push([new THREE.UV(c/d,f/e),new THREE.UV(c/d,(f+1)/e),new THREE.UV((c+1)/d,(f+1)/e),new THREE.UV((c+1)/d,f/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
- Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
- var Sphere=function(a,c,d){THREE.Geometry.call(this);var e,f=Math.PI,b=Math.max(3,c||8),h=Math.max(2,d||6);c=[];for(d=0;d<h+1;d++){e=d/h;var j=a*Math.cos(e*f),g=a*Math.sin(e*f),m=[],n=0;for(e=0;e<b;e++){var z=2*e/b,u=g*Math.sin(z*f);z=g*Math.cos(z*f);(d==0||d==h)&&e>0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(z,j,u)))-1);m.push(n)}c.push(m)}var p,A,D;f=c.length;for(d=0;d<f;d++){b=c[d].length;if(d>0)for(e=0;e<b;e++){m=e==b-1;h=c[d][m?0:e+1];j=c[d][m?b-1:e];g=c[d-1][m?b-1:e];m=c[d-1][m?
- 0:e+1];u=d/(f-1);p=(d-1)/(f-1);A=(e+1)/b;z=e/b;n=new THREE.UV(1-A,u);u=new THREE.UV(1-z,u);z=new THREE.UV(1-z,p);var H=new THREE.UV(1-A,p);if(d<c.length-1){p=this.vertices[h].position.clone();A=this.vertices[j].position.clone();D=this.vertices[g].position.clone();p.normalize();A.normalize();D.normalize();this.faces.push(new THREE.Face3(h,j,g,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(D.x,D.y,D.z)]));this.uvs.push([n,u,z])}if(d>1){p=this.vertices[h].position.clone();
- A=this.vertices[g].position.clone();D=this.vertices[m].position.clone();p.normalize();A.normalize();D.normalize();this.faces.push(new THREE.Face3(h,g,m,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(D.x,D.y,D.z)]));this.uvs.push([n,z,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
- var Torus=function(a,c,d,e){this.radius=a||100;this.tube=c||40;this.segmentsR=d||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(d=0;d<=this.segmentsT;++d){e=d/this.segmentsT*2*Math.PI;var f=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(e),(this.radius+this.tube*Math.cos(f))*Math.sin(e),this.tube*Math.sin(f))));a.push([d/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(d=
- 1;d<=this.segmentsT;++d){e=(this.segmentsT+1)*c+d;f=(this.segmentsT+1)*c+d-1;var b=(this.segmentsT+1)*(c-1)+d-1,h=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,f,b,h));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[b][0],a[b][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
- var Icosahedron=function(a){function c(z,u,p){var A=Math.sqrt(z*z+u*u+p*p);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(z/A,u/A,p/A)))-1}function d(z,u,p,A){A.faces.push(new THREE.Face3(z,u,p))}function e(z,u){var p=f.vertices[z].position,A=f.vertices[u].position;return c((p.x+A.x)/2,(p.y+A.y)/2,(p.z+A.z)/2)}var f=this,b=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
- 1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);d(0,11,5,b);d(0,5,1,b);d(0,1,7,b);d(0,7,10,b);d(0,10,11,b);d(1,5,9,b);d(5,11,4,b);d(11,10,2,b);d(10,7,6,b);d(7,1,8,b);d(3,9,4,b);d(3,4,2,b);d(3,2,6,b);d(3,6,8,b);d(3,8,9,b);d(4,9,5,b);d(2,4,11,b);d(6,2,10,b);d(8,6,7,b);d(9,8,1,b);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var j in b.faces){var g=e(b.faces[j].a,b.faces[j].b),m=e(b.faces[j].b,b.faces[j].c),n=e(b.faces[j].c,b.faces[j].a);d(b.faces[j].a,g,n,h);d(b.faces[j].b,m,g,h);d(b.faces[j].c,
- n,m,h);d(g,m,n,h)}b.faces=h.faces}f.faces=b.faces;delete b;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
- function LathedObject(a,c,d){THREE.Geometry.call(this);c=c||12;d=d||2*Math.PI;c=d/c;for(var e=[],f=[],b=[],h=[],j=0;j<a.length;j++){this.vertices.push(new THREE.Vertex(a[j]));f[j]=this.vertices.length-1;e[j]=new THREE.Vector3(a[j].x,a[j].y,a[j].z)}for(var g=THREE.Matrix4.rotationZMatrix(c),m=0;m<=d+0.0010;m+=c){for(j=0;j<e.length;j++)if(m<d){e[j]=g.multiplyVector3(e[j].clone());this.vertices.push(new THREE.Vertex(e[j]));b[j]=this.vertices.length-1}else b=h;if(m==0)h=f;for(j=0;j<f.length-1;j++){this.faces.push(new THREE.Face4(b[j],
- b[j+1],f[j+1],f[j]));this.uvs.push([new THREE.UV(m/d,j/a.length),new THREE.UV(m/d,(j+1)/a.length),new THREE.UV((m-c)/d,(j+1)/a.length),new THREE.UV((m-c)/d,j/a.length)])}f=b;b=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
- THREE.MarchingCubes=function(a,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(d){this.isolation=80;this.size=d;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=true;this.maxCount=4096;this.count=
- 0;this.hasNormal=this.hasPos=false;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(d,e,f){return d+(e-d)*f};this.VIntX=function(d,e,f,b,h,j,g,m,n,z){h=(h-n)/(z-n);n=this.normal_cache;e[b]=j+h*this.delta;e[b+1]=g;e[b+2]=m;f[b]=this.lerp(n[d],n[d+3],h);f[b+1]=this.lerp(n[d+1],n[d+4],h);f[b+2]=this.lerp(n[d+2],n[d+5],h)};this.VIntY=function(d,e,f,b,h,j,g,m,n,z){h=(h-n)/(z-n);n=this.normal_cache;e[b]=j;e[b+1]=g+h*this.delta;e[b+
- 2]=m;e=d+this.yd*3;f[b]=this.lerp(n[d],n[e],h);f[b+1]=this.lerp(n[d+1],n[e+1],h);f[b+2]=this.lerp(n[d+2],n[e+2],h)};this.VIntZ=function(d,e,f,b,h,j,g,m,n,z){h=(h-n)/(z-n);n=this.normal_cache;e[b]=j;e[b+1]=g;e[b+2]=m+h*this.delta;e=d+this.zd*3;f[b]=this.lerp(n[d],n[e],h);f[b+1]=this.lerp(n[d+1],n[e+1],h);f[b+2]=this.lerp(n[d+2],n[e+2],h)};this.compNorm=function(d){var e=d*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[d-1]-this.field[d+1];this.normal_cache[e+1]=this.field[d-this.yd]-
- this.field[d+this.yd];this.normal_cache[e+2]=this.field[d-this.zd]-this.field[d+this.zd]}};this.polygonize=function(d,e,f,b,h,j){var g=b+1,m=b+this.yd,n=b+this.zd,z=g+this.yd,u=g+this.zd,p=b+this.yd+this.zd,A=g+this.yd+this.zd,D=0,H=this.field[b],x=this.field[g],I=this.field[m],q=this.field[z],k=this.field[n],v=this.field[u],t=this.field[p],l=this.field[A];if(H<h)D|=1;if(x<h)D|=2;if(I<h)D|=8;if(q<h)D|=4;if(k<h)D|=16;if(v<h)D|=32;if(t<h)D|=128;if(l<h)D|=64;var o=THREE.edgeTable[D];if(o==0)return 0;
- var w=this.delta,y=d+w,G=e+w;w=f+w;if(o&1){this.compNorm(b);this.compNorm(g);this.VIntX(b*3,this.vlist,this.nlist,0,h,d,e,f,H,x)}if(o&2){this.compNorm(g);this.compNorm(z);this.VIntY(g*3,this.vlist,this.nlist,3,h,y,e,f,x,q)}if(o&4){this.compNorm(m);this.compNorm(z);this.VIntX(m*3,this.vlist,this.nlist,6,h,d,G,f,I,q)}if(o&8){this.compNorm(b);this.compNorm(m);this.VIntY(b*3,this.vlist,this.nlist,9,h,d,e,f,H,I)}if(o&16){this.compNorm(n);this.compNorm(u);this.VIntX(n*3,this.vlist,this.nlist,12,h,d,e,w,
- k,v)}if(o&32){this.compNorm(u);this.compNorm(A);this.VIntY(u*3,this.vlist,this.nlist,15,h,y,e,w,v,l)}if(o&64){this.compNorm(p);this.compNorm(A);this.VIntX(p*3,this.vlist,this.nlist,18,h,d,G,w,t,l)}if(o&128){this.compNorm(n);this.compNorm(p);this.VIntY(n*3,this.vlist,this.nlist,21,h,d,e,w,k,t)}if(o&256){this.compNorm(b);this.compNorm(n);this.VIntZ(b*3,this.vlist,this.nlist,24,h,d,e,f,H,k)}if(o&512){this.compNorm(g);this.compNorm(u);this.VIntZ(g*3,this.vlist,this.nlist,27,h,y,e,f,x,v)}if(o&1024){this.compNorm(z);
- this.compNorm(A);this.VIntZ(z*3,this.vlist,this.nlist,30,h,y,G,f,q,l)}if(o&2048){this.compNorm(m);this.compNorm(p);this.VIntZ(m*3,this.vlist,this.nlist,33,h,d,G,f,I,t)}D<<=4;for(h=b=0;THREE.triTable[D+h]!=-1;){d=D+h;e=d+1;f=d+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[d],3*THREE.triTable[e],3*THREE.triTable[f],j);h+=3;b++}return b};this.posnormtriv=function(d,e,f,b,h,j){var g=this.count*3;this.positionArray[g]=d[f];this.positionArray[g+1]=d[f+1];this.positionArray[g+2]=d[f+2];this.positionArray[g+
- 3]=d[b];this.positionArray[g+4]=d[b+1];this.positionArray[g+5]=d[b+2];this.positionArray[g+6]=d[h];this.positionArray[g+7]=d[h+1];this.positionArray[g+8]=d[h+2];this.normalArray[g]=e[f];this.normalArray[g+1]=e[f+1];this.normalArray[g+2]=e[f+2];this.normalArray[g+3]=e[b];this.normalArray[g+4]=e[b+1];this.normalArray[g+5]=e[b+2];this.normalArray[g+6]=e[h];this.normalArray[g+7]=e[h+1];this.normalArray[g+8]=e[h+2];this.hasNormal=this.hasPos=true;this.count+=3;this.count>=this.maxCount-3&&j(this)};this.begin=
- function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(d){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;d(this)}};this.addBall=function(d,e,f,b,h){var j=this.size*Math.sqrt(b/h),g=f*this.size,m=e*this.size,n=d*this.size,z=Math.floor(g-j);if(z<1)z=1;g=Math.floor(g+j);if(g>this.size-1)g=this.size-1;var u=Math.floor(m-j);if(u<1)u=1;m=Math.floor(m+j);if(m>this.size-1)m=this.size-1;var p=Math.floor(n-j);if(p<1)p=1;j=Math.floor(n+j);
- if(j>this.size-1)j=this.size-1;var A,D,H,x,I,q;for(z=z;z<g;z++){n=this.size2*z;D=z/this.size-f;I=D*D;for(D=u;D<m;D++){H=n+this.size*D;A=D/this.size-e;q=A*A;for(A=p;A<j;A++){x=A/this.size-d;x=b/(1.0E-6+x*x+q+I)-h;if(x>0)this.field[H+A]+=x}}}};this.addPlaneX=function(d,e){var f,b,h,j,g,m=this.size,n=this.yd,z=this.zd,u=this.field,p=m*Math.sqrt(d/e);if(p>m)p=m;for(f=0;f<p;f++){b=f/m;b=b*b;j=d/(1.0E-4+b)-e;if(j>0)for(b=0;b<m;b++){g=f+b*n;for(h=0;h<m;h++)u[z*h+g]+=j}}};this.addPlaneY=function(d,e){var f,
- b,h,j,g,m,n=this.size,z=this.yd,u=this.zd,p=this.field,A=n*Math.sqrt(d/e);if(A>n)A=n;for(b=0;b<A;b++){f=b/n;f=f*f;j=d/(1.0E-4+f)-e;if(j>0){g=b*z;for(f=0;f<n;f++){m=g+f;for(h=0;h<n;h++)p[u*h+m]+=j}}}};this.addPlaneZ=function(d,e){var f,b,h,j,g,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(d/e);if(dist>size)dist=size;for(h=0;h<dist;h++){f=h/size;f=f*f;j=d/(1.0E-4+f)-e;if(j>0){g=zd*h;for(b=0;b<size;b++){m=g+b*yd;for(f=0;f<size;f++)field[m+f]+=j}}}};this.reset=function(){var d;
- for(d=0;d<this.size3;d++){this.normal_cache[d*3]=0;this.field[d]=0}};this.render=function(d){this.begin();var e,f,b,h,j,g,m,n,z,u=this.size-2;for(h=1;h<u;h++){z=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(b=1;b<u;b++){n=z+this.size*b;g=(b-this.halfsize)/this.halfsize;for(f=1;f<u;f++){j=(f-this.halfsize)/this.halfsize;e=n+f;this.polygonize(j,g,m,e,this.isolation,d)}}}this.end(d)};this.generateGeometry=function(){var d=0,e=new THREE.Geometry;this.render(function(f){var b,h,j,g,m,n,z,u;for(b=
- 0;b<f.count;b++){m=b*3;z=m+1;u=m+2;h=f.positionArray[m];j=f.positionArray[z];g=f.positionArray[u];n=new THREE.Vector3(h,j,g);h=f.normalArray[m];j=f.normalArray[z];g=f.normalArray[u];m=new THREE.Vector3(h,j,g);m.normalize();m=new THREE.Vertex(n,m);e.vertices.push(m)}nfaces=f.count/3;for(b=0;b<nfaces;b++){m=(d+b)*3;z=m+1;u=m+2;n=e.vertices[m].normal;h=e.vertices[z].normal;j=e.vertices[u].normal;m=new THREE.Face3(m,z,u,[n,h,j]);e.faces.push(m)}d+=nfaces;f.count=0});e.sortFacesByMaterial();return e};
- this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
- THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
- 1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
- 419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]);
- THREE.triTable=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,
- -1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,
- 8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,
- -1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,
- 5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,
- -1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,
- 10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,
- 6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,
- 8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,
- 2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,
- -1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,
- -1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,
- -1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- 1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,
- -1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,
- 2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,
- 4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,
- 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
- THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var c="Loaded ";c+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
- c},loadAsciiOld:function(a,c){var d=document.createElement("script");d.type="text/javascript";d.onload=c;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a){var c=a.model,d=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);c.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,d,e)};c.postMessage(a)},loadBinary:function(a){var c=a.model,d=a.callback,e=a.texture_path?a.texture_path:
- THREE.Loader.prototype.extractUrlbase(c),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var b=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,d,f,e,b)};c.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};c.postMessage(a)},loadAjaxBuffers:function(a,c,d,e,f,b){var h=new XMLHttpRequest,j=e+"/"+a,g=0;
- h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,d,f,c):alert("Couldn't load ["+j+"] ["+h.status+"]");else if(h.readyState==3){if(b){if(g==0)g=h.getResponseHeader("Content-Length");b({total:g,loaded:h.responseText.length})}}else if(h.readyState==2)g=h.getResponseHeader("Content-Length")};h.open("GET",j,true);h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)},
- createBinModel:function(a,c,d,e){var f=function(b){function h(E,M){var K=n(E,M),X=n(E,M+1),$=n(E,M+2),ma=n(E,M+3),ia=(ma<<1&255|$>>7)-127;K=($&127)<<16|X<<8|K;if(K==0&&ia==-127)return 0;return(1-2*(ma>>7))*(1+K*Math.pow(2,-23))*Math.pow(2,ia)}function j(E,M){var K=n(E,M),X=n(E,M+1),$=n(E,M+2);return(n(E,M+3)<<24)+($<<16)+(X<<8)+K}function g(E,M){var K=n(E,M);return(n(E,M+1)<<8)+K}function m(E,M){var K=n(E,M);return K>127?K-256:K}function n(E,M){return E.charCodeAt(M)&255}function z(E){var M,K,X;M=
- j(a,E);K=j(a,E+t);X=j(a,E+l);E=g(a,E+o);THREE.Loader.prototype.f3(x,M,K,X,E)}function u(E){var M,K,X,$,ma,ia;M=j(a,E);K=j(a,E+t);X=j(a,E+l);$=g(a,E+o);ma=j(a,E+w);ia=j(a,E+y);E=j(a,E+G);THREE.Loader.prototype.f3n(x,k,M,K,X,$,ma,ia,E)}function p(E){var M,K,X,$;M=j(a,E);K=j(a,E+B);X=j(a,E+C);$=j(a,E+F);E=g(a,E+L);THREE.Loader.prototype.f4(x,M,K,X,$,E)}function A(E){var M,K,X,$,ma,ia,qa,ta;M=j(a,E);K=j(a,E+B);X=j(a,E+C);$=j(a,E+F);ma=g(a,E+L);ia=j(a,E+O);qa=j(a,E+Q);ta=j(a,E+T);E=j(a,E+U);THREE.Loader.prototype.f4n(x,
- k,M,K,X,$,ma,ia,qa,ta,E)}function D(E){var M,K;M=j(a,E);K=j(a,E+ba);E=j(a,E+ca);THREE.Loader.prototype.uv3(x.uvs,v[M*2],v[M*2+1],v[K*2],v[K*2+1],v[E*2],v[E*2+1])}function H(E){var M,K,X;M=j(a,E);K=j(a,E+S);X=j(a,E+N);E=j(a,E+Z);THREE.Loader.prototype.uv4(x.uvs,v[M*2],v[M*2+1],v[K*2],v[K*2+1],v[X*2],v[X*2+1],v[E*2],v[E*2+1])}var x=this,I=0,q,k=[],v=[],t,l,o,w,y,G,B,C,F,L,O,Q,T,U,ba,ca,S,N,Z,V,J,W,da,ha,ea;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(x,e,b);q={signature:a.substr(I,
- 8),header_bytes:n(a,I+8),vertex_coordinate_bytes:n(a,I+9),normal_coordinate_bytes:n(a,I+10),uv_coordinate_bytes:n(a,I+11),vertex_index_bytes:n(a,I+12),normal_index_bytes:n(a,I+13),uv_index_bytes:n(a,I+14),material_index_bytes:n(a,I+15),nvertices:j(a,I+16),nnormals:j(a,I+16+4),nuvs:j(a,I+16+8),ntri_flat:j(a,I+16+12),ntri_smooth:j(a,I+16+16),ntri_flat_uv:j(a,I+16+20),ntri_smooth_uv:j(a,I+16+24),nquad_flat:j(a,I+16+28),nquad_smooth:j(a,I+16+32),nquad_flat_uv:j(a,I+16+36),nquad_smooth_uv:j(a,I+16+40)};
- I+=q.header_bytes;t=q.vertex_index_bytes;l=q.vertex_index_bytes*2;o=q.vertex_index_bytes*3;w=q.vertex_index_bytes*3+q.material_index_bytes;y=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes;G=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes*2;B=q.vertex_index_bytes;C=q.vertex_index_bytes*2;F=q.vertex_index_bytes*3;L=q.vertex_index_bytes*4;O=q.vertex_index_bytes*4+q.material_index_bytes;Q=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes;T=q.vertex_index_bytes*
- 4+q.material_index_bytes+q.normal_index_bytes*2;U=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*3;ba=q.uv_index_bytes;ca=q.uv_index_bytes*2;S=q.uv_index_bytes;N=q.uv_index_bytes*2;Z=q.uv_index_bytes*3;b=q.vertex_index_bytes*3+q.material_index_bytes;ea=q.vertex_index_bytes*4+q.material_index_bytes;V=q.ntri_flat*b;J=q.ntri_smooth*(b+q.normal_index_bytes*3);W=q.ntri_flat_uv*(b+q.uv_index_bytes*3);da=q.ntri_smooth_uv*(b+q.normal_index_bytes*3+q.uv_index_bytes*3);ha=q.nquad_flat*ea;
- b=q.nquad_smooth*(ea+q.normal_index_bytes*4);ea=q.nquad_flat_uv*(ea+q.uv_index_bytes*4);I+=function(E){var M,K,X,$=q.vertex_coordinate_bytes*3,ma=E+q.nvertices*$;for(E=E;E<ma;E+=$){M=h(a,E);K=h(a,E+q.vertex_coordinate_bytes);X=h(a,E+q.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(x,M,K,X)}return q.nvertices*$}(I);I+=function(E){var M,K,X,$=q.normal_coordinate_bytes*3,ma=E+q.nnormals*$;for(E=E;E<ma;E+=$){M=m(a,E);K=m(a,E+q.normal_coordinate_bytes);X=m(a,E+q.normal_coordinate_bytes*2);k.push(M/
- 127,K/127,X/127)}return q.nnormals*$}(I);I+=function(E){var M,K,X=q.uv_coordinate_bytes*2,$=E+q.nuvs*X;for(E=E;E<$;E+=X){M=h(a,E);K=h(a,E+q.uv_coordinate_bytes);v.push(M,K)}return q.nuvs*X}(I);I=I;V=I+V;J=V+J;W=J+W;da=W+da;ha=da+ha;b=ha+b;ea=b+ea;(function(E){var M,K=q.vertex_index_bytes*3+q.material_index_bytes,X=K+q.uv_index_bytes*3,$=E+q.ntri_flat_uv*X;for(M=E;M<$;M+=X){z(M);D(M+K)}return $-E})(J);(function(E){var M,K=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes*3,X=K+q.uv_index_bytes*
- 3,$=E+q.ntri_smooth_uv*X;for(M=E;M<$;M+=X){u(M);D(M+K)}return $-E})(W);(function(E){var M,K=q.vertex_index_bytes*4+q.material_index_bytes,X=K+q.uv_index_bytes*4,$=E+q.nquad_flat_uv*X;for(M=E;M<$;M+=X){p(M);H(M+K)}return $-E})(b);(function(E){var M,K=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*4,X=K+q.uv_index_bytes*4,$=E+q.nquad_smooth_uv*X;for(M=E;M<$;M+=X){A(M);H(M+K)}return $-E})(ea);(function(E){var M,K=q.vertex_index_bytes*3+q.material_index_bytes,X=E+q.ntri_flat*K;for(M=
- E;M<X;M+=K)z(M);return X-E})(I);(function(E){var M,K=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes*3,X=E+q.ntri_smooth*K;for(M=E;M<X;M+=K)u(M);return X-E})(V);(function(E){var M,K=q.vertex_index_bytes*4+q.material_index_bytes,X=E+q.nquad_flat*K;for(M=E;M<X;M+=K)p(M);return X-E})(da);(function(E){var M,K=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*4,X=E+q.nquad_smooth*K;for(M=E;M<X;M+=K)A(M);return X-E})(ha);this.computeCentroids();this.computeFaceNormals();
- this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f(d))},createModel:function(a,c,d){var e=function(f){var b=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(b,a.materials,f);(function(){var h,j,g,m,n;h=0;for(j=a.vertices.length;h<j;h+=3){g=a.vertices[h];m=a.vertices[h+1];n=a.vertices[h+2];THREE.Loader.prototype.v(b,g,m,n)}})();(function(){function h(A,D){THREE.Loader.prototype.f3(b,A[D],A[D+1],A[D+2],A[D+3])}function j(A,D){THREE.Loader.prototype.f3n(b,
- a.normals,A[D],A[D+1],A[D+2],A[D+3],A[D+4],A[D+5],A[D+6])}function g(A,D){THREE.Loader.prototype.f4(b,A[D],A[D+1],A[D+2],A[D+3],A[D+4])}function m(A,D){THREE.Loader.prototype.f4n(b,a.normals,A[D],A[D+1],A[D+2],A[D+3],A[D+4],A[D+5],A[D+6],A[D+7],A[D+8])}function n(A,D){var H,x,I,q,k,v,t,l,o;H=A[D];x=A[D+1];I=A[D+2];q=a.uvs[H*2];t=a.uvs[H*2+1];k=a.uvs[x*2];l=a.uvs[x*2+1];v=a.uvs[I*2];o=a.uvs[I*2+1];THREE.Loader.prototype.uv3(b.uvs,q,t,k,l,v,o);if(a.uvs2){q=a.uvs2[H*2];t=a.uvs2[H*2+1];k=a.uvs2[x*2];
- l=a.uvs2[x*2+1];v=a.uvs2[I*2];o=a.uvs2[I*2+1];THREE.Loader.prototype.uv3(b.uvs2,q,1-t,k,1-l,v,1-o)}}function z(A,D){var H,x,I,q,k,v,t,l,o,w,y,G;H=A[D];x=A[D+1];I=A[D+2];q=A[D+3];k=a.uvs[H*2];o=a.uvs[H*2+1];v=a.uvs[x*2];w=a.uvs[x*2+1];t=a.uvs[I*2];y=a.uvs[I*2+1];l=a.uvs[q*2];G=a.uvs[q*2+1];THREE.Loader.prototype.uv4(b.uvs,k,o,v,w,t,y,l,G);if(a.uvs2){k=a.uvs2[H*2];o=a.uvs2[H*2+1];v=a.uvs2[x*2];w=a.uvs2[x*2+1];t=a.uvs2[I*2];y=a.uvs2[I*2+1];l=a.uvs2[q*2];G=a.uvs2[q*2+1];THREE.Loader.prototype.uv4(b.uvs2,
- k,1-o,v,1-w,t,1-y,l,1-G)}}var u,p;u=0;for(p=a.triangles_uv.length;u<p;u+=7){h(a.triangles_uv,u);n(a.triangles_uv,u+4)}u=0;for(p=a.triangles_n_uv.length;u<p;u+=10){j(a.triangles_n_uv,u);n(a.triangles_n_uv,u+7)}u=0;for(p=a.quads_uv.length;u<p;u+=9){g(a.quads_uv,u);z(a.quads_uv,u+5)}u=0;for(p=a.quads_n_uv.length;u<p;u+=13){m(a.quads_n_uv,u);z(a.quads_n_uv,u+9)}u=0;for(p=a.triangles.length;u<p;u+=4)h(a.triangles,u);u=0;for(p=a.triangles_n.length;u<p;u+=7)j(a.triangles_n,u);u=0;for(p=a.quads.length;u<
- p;u+=5)g(a.quads,u);u=0;for(p=a.quads_n.length;u<p;u+=9)m(a.quads_n,u)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;c(new e(d))},v:function(a,c,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,d,e)))},f3:function(a,c,d,e,f){a.faces.push(new THREE.Face3(c,d,e,null,a.materials[f]))},f4:function(a,c,d,e,f,b){a.faces.push(new THREE.Face4(c,d,e,f,null,a.materials[b]))},f3n:function(a,c,d,e,f,b,h,j,g){b=
- a.materials[b];var m=c[j*3],n=c[j*3+1];j=c[j*3+2];var z=c[g*3],u=c[g*3+1];g=c[g*3+2];a.faces.push(new THREE.Face3(d,e,f,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(m,n,j),new THREE.Vector3(z,u,g)],b))},f4n:function(a,c,d,e,f,b,h,j,g,m,n){h=a.materials[h];var z=c[g*3],u=c[g*3+1];g=c[g*3+2];var p=c[m*3],A=c[m*3+1];m=c[m*3+2];var D=c[n*3],H=c[n*3+1];n=c[n*3+2];a.faces.push(new THREE.Face4(d,e,f,b,[new THREE.Vector3(c[j*3],c[j*3+1],c[j*3+2]),new THREE.Vector3(z,u,g),new THREE.Vector3(p,
- A,m),new THREE.Vector3(D,H,n)],h))},uv3:function(a,c,d,e,f,b,h){var j=[];j.push(new THREE.UV(c,d));j.push(new THREE.UV(e,f));j.push(new THREE.UV(b,h));a.push(j)},uv4:function(a,c,d,e,f,b,h,j,g){var m=[];m.push(new THREE.UV(c,d));m.push(new THREE.UV(e,f));m.push(new THREE.UV(b,h));m.push(new THREE.UV(j,g));a.push(m)},init_materials:function(a,c,d){a.materials=[];for(var e=0;e<c.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(c[e],d)]},createMaterial:function(a,c){function d(h){h=Math.log(h)/
- Math.LN2;return Math.floor(h)==h}function e(h,j){var g=new Image;g.onload=function(){if(!d(this.width)||!d(this.height)){var m=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),n=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));h.image.width=m;h.image.height=n;h.image.getContext("2d").drawImage(this,0,0,m,n)}else h.image=this;h.image.loaded=1};g.src=j}var f,b;if(a.map_diffuse&&c){b=document.createElement("canvas");f=new THREE.MeshLambertMaterial({map:new THREE.Texture(b)});e(f.map,c+"/"+
- a.map_diffuse)}else if(a.col_diffuse){f=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;f=new THREE.MeshLambertMaterial({color:f,opacity:a.transparency})}else f=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):new THREE.MeshLambertMaterial({color:15658734});if(a.map_lightmap&&c){b=document.createElement("canvas");f.light_map=new THREE.Texture(b);e(f.light_map,c+"/"+a.map_lightmap)}return f},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
|