| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- // 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,b,d){this.r=a;this.g=b;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+
- ","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
- THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;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,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.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,b,d){this.x=a||0;this.y=b||0;this.z=d||0};
- THREE.Vector3.prototype={set:function(a,b,d){this.x=a;this.y=b;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,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.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,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
- cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-b*a.z;this.z=b*a.y-d*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.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 b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+d*d+a*a)},distanceToSquared:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+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,b,d,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1};
- THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;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,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.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,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.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,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},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,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
- THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){d=e[a];if(d instanceof THREE.Mesh)g=g.concat(this.intersectObject(d))}g.sort(function(f,j){return f.distance-j.distance});return g},intersectObject:function(a){function b(L,t,J,m){m=m.clone().subSelf(t);J=J.clone().subSelf(t);var h=L.clone().subSelf(t);L=m.dot(m);t=m.dot(J);m=m.dot(h);var p=J.dot(J);J=J.dot(h);h=1/(L*p-t*t);p=(p*m-t*J)*h;L=(L*J-t*m)*h;return p>0&&L>0&&p+L<1}var d,e,g,f,j,c,k,l,n,B,
- o,u=a.geometry,v=u.vertices,w=[];d=0;for(e=u.faces.length;d<e;d++){g=u.faces[d];B=this.origin.clone();o=this.direction.clone();f=a.matrix.multiplyVector3(v[g.a].position.clone());j=a.matrix.multiplyVector3(v[g.b].position.clone());c=a.matrix.multiplyVector3(v[g.c].position.clone());k=g instanceof THREE.Face4?a.matrix.multiplyVector3(v[g.d].position.clone()):null;l=a.rotationMatrix.multiplyVector3(g.normal.clone());n=o.dot(l);if(n<0){l=l.dot((new THREE.Vector3).sub(f,B))/n;B=B.addSelf(o.multiplyScalar(l));
- if(g instanceof THREE.Face3){if(b(B,f,j,c)){g={distance:this.origin.distanceTo(B),point:B,face:g,object:a};w.push(g)}}else if(g instanceof THREE.Face4)if(b(B,f,j,k)||b(B,j,c,k)){g={distance:this.origin.distanceTo(B),point:B,face:g,object:a};w.push(g)}}}return w}};
- THREE.Rectangle=function(){function a(){f=e-b;j=g-d}var b,d,e,g,f,j,c=true;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return f};this.getHeight=function(){return j};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(k,l,n,B){c=false;b=k;d=l;e=n;g=B;a()};this.addPoint=function(k,l){if(c){c=false;b=k;d=l;e=k;g=l}else{b=b<k?b:k;d=d<l?d:l;e=e>k?e:k;g=g>l?
- g:l}a()};this.add3Points=function(k,l,n,B,o,u){if(c){c=false;b=k<n?k<o?k:o:n<o?n:o;d=l<B?l<u?l:u:B<u?B:u;e=k>n?k>o?k:o:n>o?n:o;g=l>B?l>u?l:u:B>u?B:u}else{b=k<n?k<o?k<b?k:b:o<b?o:b:n<o?n<b?n:b:o<b?o:b;d=l<B?l<u?l<d?l:d:u<d?u:d:B<u?B<d?B:d:u<d?u:d;e=k>n?k>o?k>e?k:e:o>e?o:e:n>o?n>e?n:e:o>e?o:e;g=l>B?l>u?l>g?l:g:u>g?u:g:B>u?B>g?B:g:u>g?u:g}a()};this.addRectangle=function(k){if(c){c=false;b=k.getLeft();d=k.getTop();e=k.getRight();g=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();d=d<k.getTop()?d:k.getTop();
- e=e>k.getRight()?e:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;d-=k;e+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();d=d>k.getTop()?d:k.getTop();e=e<k.getRight()?e:k.getRight();g=g<k.getBottom()?g:k.getBottom();a()};this.instersects=function(k){return Math.min(e,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(g,k.getBottom())-Math.max(d,k.getTop())>=0};this.empty=function(){c=true;g=e=d=b=0;a()};this.isEmpty=function(){return c};this.toString=
- function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+g+", width: "+f+", height: "+j+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this}};
- THREE.Matrix4=function(a,b,d,e,g,f,j,c,k,l,n,B,o,u,v,w){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=g||0;this.n22=f||1;this.n23=j||0;this.n24=c||0;this.n31=k||0;this.n32=l||0;this.n33=n||1;this.n34=B||0;this.n41=o||0;this.n42=u||0;this.n43=v||0;this.n44=w||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,b,d,e,g,f,j,c,k,l,n,B,o,u,v,w){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=g;this.n22=f;this.n23=j;this.n24=c;this.n31=k;this.n32=l;this.n33=n;this.n34=B;this.n41=o;this.n42=u;this.n43=v;this.n44=w;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,b,d){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();e.cross(d,f).normalize();g.cross(f,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);
- this.n31=f.x;this.n32=f.y;this.n33=f.z;this.n34=-f.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,g=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*d+this.n23*
- e+this.n24*g;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,g=a.n13,f=a.n14,j=a.n21,c=a.n22,k=a.n23,l=a.n24,n=a.n31,
- B=a.n32,o=a.n33,u=a.n34,v=a.n41,w=a.n42,L=a.n43,t=a.n44,J=b.n11,m=b.n12,h=b.n13,p=b.n14,C=b.n21,q=b.n22,A=b.n23,N=b.n24,x=b.n31,D=b.n32,G=b.n33,E=b.n34,z=b.n41,I=b.n42,F=b.n43,T=b.n44;this.n11=d*J+e*C+g*x+f*z;this.n12=d*m+e*q+g*D+f*I;this.n13=d*h+e*A+g*G+f*F;this.n14=d*p+e*N+g*E+f*T;this.n21=j*J+c*C+k*x+l*z;this.n22=j*m+c*q+k*D+l*I;this.n23=j*h+c*A+k*G+l*F;this.n24=j*p+c*N+k*E+l*T;this.n31=n*J+B*C+o*x+u*z;this.n32=n*m+B*q+o*D+u*I;this.n33=n*h+B*A+o*G+u*F;this.n34=n*p+B*N+o*E+u*T;this.n41=v*J+w*C+
- L*x+t*z;this.n42=v*m+w*q+L*D+t*I;this.n43=v*h+w*A+L*G+t*F;this.n44=v*p+w*N+L*E+t*T;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,g=this.n14,f=this.n21,j=this.n22,c=this.n23,k=this.n24,l=this.n31,n=this.n32,B=this.n33,o=this.n34,u=this.n41,v=this.n42,w=this.n43,L=this.n44,t=a.n11,J=a.n21,m=a.n31,h=a.n41,p=a.n12,C=a.n22,q=a.n32,A=a.n42,N=a.n13,x=a.n23,D=a.n33,G=a.n43,E=a.n14,z=a.n24,I=a.n34;a=a.n44;this.n11=b*t+d*J+e*m+g*h;this.n12=b*p+d*C+e*q+g*A;this.n13=b*N+d*x+e*D+g*
- G;this.n14=b*E+d*z+e*I+g*a;this.n21=f*t+j*J+c*m+k*h;this.n22=f*p+j*C+c*q+k*A;this.n23=f*N+j*x+c*D+k*G;this.n24=f*E+j*z+c*I+k*a;this.n31=l*t+n*J+B*m+o*h;this.n32=l*p+n*C+B*q+o*A;this.n33=l*N+n*x+B*D+o*G;this.n34=l*E+n*z+B*I+o*a;this.n41=u*t+v*J+w*m+L*h;this.n42=u*p+v*C+w*q+L*A;this.n43=u*N+v*x+w*D+L*G;this.n44=u*E+v*z+w*I+L*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=
- a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,d=this.n13,e=this.n14,g=this.n21,f=this.n22,j=this.n23,c=this.n24,k=this.n31,l=this.n32,n=this.n33,B=this.n34,o=this.n41,u=this.n42,v=this.n43,w=this.n44;return e*j*l*o-d*c*l*o-e*f*n*o+b*c*n*o+d*f*B*o-b*j*B*o-e*j*k*u+d*c*k*u+e*g*n*u-a*c*n*u-d*g*B*u+a*j*B*u+e*f*k*v-b*c*k*v-e*g*l*v+a*c*l*v+b*g*B*v-a*f*B*v-d*f*k*w+b*j*k*w+d*g*l*w-a*j*l*w-b*g*n*w+a*f*n*w},transpose:function(){function a(b,d,
- e){var g=b[d];b[d]=b[e];b[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){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,b,d){this.set(1,0,0,a,0,1,0,b,0,0,1,d,0,0,0,1);return this},setScale:function(a,b,d){this.set(a,0,0,0,0,b,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=
- Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var d=Math.cos(b),e=Math.sin(b),g=1-d,f=a.x,j=a.y,c=a.z,k=g*f,l=g*j;this.set(k*f+d,k*j-e*c,k*c+e*j,0,k*j+e*c,l*j+d,l*c-e*f,0,k*c-e*j,l*c+e*f,g*c*c+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,b,d){var e=new THREE.Matrix4;e.setTranslation(a,b,d);return e};THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.setScale(a,b,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};
- THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4;d.setRotAxis(a,b);return d};
- THREE.Matrix4.makeInvert=function(a){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,j=a.n22,c=a.n23,k=a.n24,l=a.n31,n=a.n32,B=a.n33,o=a.n34,u=a.n41,v=a.n42,w=a.n43,L=a.n44,t=new THREE.Matrix4;t.n11=c*o*v-k*B*v+k*n*w-j*o*w-c*n*L+j*B*L;t.n12=g*B*v-e*o*v-g*n*w+d*o*w+e*n*L-d*B*L;t.n13=e*k*v-g*c*v+g*j*w-d*k*w-e*j*L+d*c*L;t.n14=g*c*n-e*k*n-g*j*B+d*k*B+e*j*o-d*c*o;t.n21=k*B*u-c*o*u-k*l*w+f*o*w+c*l*L-f*B*L;t.n22=e*o*u-g*B*u+g*l*w-b*o*w-e*l*L+b*B*L;t.n23=g*c*u-e*k*u-g*f*w+b*k*w+e*f*L-b*c*L;t.n24=e*k*l-g*c*l+
- g*f*B-b*k*B-e*f*o+b*c*o;t.n31=j*o*u-k*n*u+k*l*v-f*o*v-j*l*L+f*n*L;t.n32=g*n*u-d*o*u-g*l*v+b*o*v+d*l*L-b*n*L;t.n33=e*k*u-g*j*u+g*f*v-b*k*v-d*f*L+b*j*L;t.n34=g*j*l-d*k*l-g*f*n+b*k*n+d*f*o-b*j*o;t.n41=c*n*u-j*B*u-c*l*v+f*B*v+j*l*w-f*n*w;t.n42=d*B*u-e*n*u+e*l*v-b*B*v-d*l*w+b*n*w;t.n43=e*j*u-d*c*u-e*f*v+b*c*v+d*f*w-b*j*w;t.n44=d*c*l-e*j*l+e*f*n-b*c*n-d*f*B+b*j*B;t.multiplyScalar(1/a.determinant());return t};
- THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=a.m33;var d=a.m,e=b[10]*b[5]-b[6]*b[9],g=-b[10]*b[1]+b[2]*b[9],f=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],c=b[10]*b[0]-b[2]*b[8],k=-b[6]*b[0]+b[2]*b[4],l=b[9]*b[4]-b[5]*b[8],n=-b[9]*b[0]+b[1]*b[8],B=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*j+b[2]*l;if(b==0)throw"matrix not invertible";b=1/b;d[0]=b*e;d[1]=b*g;d[2]=b*f;d[3]=b*j;d[4]=b*c;d[5]=b*k;d[6]=b*l;d[7]=b*n;d[8]=b*B;return a};
- THREE.Matrix4.makeFrustum=function(a,b,d,e,g,f){var j,c,k;j=new THREE.Matrix4;c=2*g/(b-a);k=2*g/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(f+g)/(f-g);g=-2*f*g/(f-g);j.n11=c;j.n12=0;j.n13=a;j.n14=0;j.n21=0;j.n22=k;j.n23=d;j.n24=0;j.n31=0;j.n32=0;j.n33=e;j.n34=g;j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(a,b,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,d,e)};
- THREE.Matrix4.makeOrtho=function(a,b,d,e,g,f){var j,c,k,l;j=new THREE.Matrix4;c=b-a;k=d-e;l=f-g;a=(b+a)/c;d=(d+e)/k;g=(f+g)/l;j.n11=2/c;j.n12=0;j.n13=0;j.n14=-a;j.n21=0;j.n22=2/k;j.n23=0;j.n24=-d;j.n31=0;j.n32=0;j.n33=-2/l;j.n34=-g;j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
- THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||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,b,d,e,g){this.a=a;this.b=b;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=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
- THREE.Face4=function(a,b,d,e,g,f){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=f instanceof Array?f:[f]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
- THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
- THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a<b;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 b,d,e,g,f,j,c=new THREE.Vector3,k=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){f=this.vertices[e];f.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];if(a&&f.vertexNormals.length){c.set(0,0,0);b=0;for(d=f.normal.length;b<d;b++)c.addSelf(f.vertexNormals[b]);c.divideScalar(3)}else{b=this.vertices[f.a];d=this.vertices[f.b];j=this.vertices[f.c];c.sub(j.position,
- d.position);k.sub(b.position,d.position);c.crossSelf(k)}c.isZero()||c.normalize();f.normal.copy(c)}},computeVertexNormals:function(){var a,b,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)e[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;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(b=this.vertices.length;a<b;a++)e[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;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(b=this.vertices.length;a<b;a++)e[a].normalize();a=0;for(b=this.faces.length;a<
- b;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(E,z,I,F,T,V,P){f=E.vertices[z].position;j=E.vertices[I].position;c=E.vertices[F].position;k=g[T];l=g[V];n=g[P];B=j.x-f.x;o=c.x-f.x;u=j.y-f.y;v=c.y-f.y;
- w=j.z-f.z;L=c.z-f.z;t=l.u-k.u;J=n.u-k.u;m=l.v-k.v;h=n.v-k.v;p=1/(t*h-J*m);A.set((h*B-m*o)*p,(h*u-m*v)*p,(h*w-m*L)*p);N.set((t*o-J*B)*p,(t*v-J*u)*p,(t*L-J*w)*p);C[z].addSelf(A);C[I].addSelf(A);C[F].addSelf(A);q[z].addSelf(N);q[I].addSelf(N);q[F].addSelf(N)}var b,d,e,g,f,j,c,k,l,n,B,o,u,v,w,L,t,J,m,h,p,C=[],q=[],A=new THREE.Vector3,N=new THREE.Vector3,x=new THREE.Vector3,D=new THREE.Vector3,G=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++){C[b]=new THREE.Vector3;q[b]=new THREE.Vector3}b=0;
- for(d=this.faces.length;b<d;b++){e=this.faces[b];g=this.uvs[b];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])}}b=0;for(d=this.vertices.length;b<d;b++){G.copy(this.vertices[b].normal);e=C[b];x.copy(e);x.subSelf(G.multiplyScalar(G.dot(e))).normalize();D.cross(this.vertices[b].normal,e);e=D.dot(q[b]);e=e<0?-1:1;this.vertices[b].tangent.set(x.x,x.y,x.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 b=1,d=this.vertices.length;b<d;b++){a=this.vertices[b];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,b=0,d=this.vertices.length;b<d;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(n){var B=[];b=0;for(d=n.length;b<d;b++)n[b]==undefined?B.push("undefined"):B.push(n[b].toString());return B.join("_")}var b,d,e,g,f,j,c,k,l={};e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];
- j=f.materials;c=a(j);if(l[c]==undefined)l[c]={hash:c,counter:0};k=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:j,vertices:0};f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+f>65535){l[c].counter+=1;k=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:j,vertices:0}}this.geometryChunks[k].faces.push(e);this.geometryChunks[k].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+
- this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
- THREE.Camera=function(a,b,d,e){this.fov=a;this.aspect=b;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(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
- this.translateZ=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);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,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;
- THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||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,b=this.rotation,d=this.scale,e=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(b.x);if(b.y!=0){e.setRotY(b.y);this.rotationMatrix.multiplySelf(e)}if(b.z!=0){e.setRotZ(b.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,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.autoUpdateMatrix=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
- THREE.Line=function(a,b,d){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];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,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
- THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
- THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}};
- THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>)"}};
- THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_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.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/>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.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.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.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.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.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
- THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
- THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
- THREE.Texture=function(a,b,d,e,g,f){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=f!==undefined?f: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,b,d){this.width=a;this.height=b;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 b,d,e,g={};for(b in a){g[b]={};for(d in a[b]){e=a[b][d];g[b][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var b,d,e,g={};for(b=0;b<a.length;b++){e=this.clone(a[b]);for(d in e)g[d]=e[d]}return g}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
- THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
- THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
- THREE.Fog=function(a,b,d){this.color=new THREE.Color(a);this.near=b||1;this.far=d||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
- THREE.Projector=function(){function a(q,A){return A.z-q.z}function b(q,A){var N=0,x=1,D=q.z+q.w,G=A.z+A.w,E=-q.z+q.w,z=-A.z+A.w;if(D>=0&&G>=0&&E>=0&&z>=0)return true;else if(D<0&&G<0||E<0&&z<0)return false;else{if(D<0)N=Math.max(N,D/(D-G));else if(G<0)x=Math.min(x,D/(D-G));if(E<0)N=Math.max(N,E/(E-z));else if(z<0)x=Math.min(x,E/(E-z));if(x<N)return false;else{q.lerpSelf(A,N);A.lerpSelf(q,1-x);return true}}}var d,e,g=[],f,j,c,k=[],l,n,B=[],o,u,v=[],w=new THREE.Vector4,L=new THREE.Vector4,t=new THREE.Matrix4,
- J=new THREE.Matrix4,m=[],h=new THREE.Vector4,p=new THREE.Vector4,C;this.projectObjects=function(q,A,N){var x=[],D,G;e=0;t.multiply(A.projectionMatrix,A.matrix);m[0]=new THREE.Vector4(t.n41-t.n11,t.n42-t.n12,t.n43-t.n13,t.n44-t.n14);m[1]=new THREE.Vector4(t.n41+t.n11,t.n42+t.n12,t.n43+t.n13,t.n44+t.n14);m[2]=new THREE.Vector4(t.n41+t.n21,t.n42+t.n22,t.n43+t.n23,t.n44+t.n24);m[3]=new THREE.Vector4(t.n41-t.n21,t.n42-t.n22,t.n43-t.n23,t.n44-t.n24);m[4]=new THREE.Vector4(t.n41-t.n31,t.n42-t.n32,t.n43-
- t.n33,t.n44-t.n34);m[5]=new THREE.Vector4(t.n41+t.n31,t.n42+t.n32,t.n43+t.n33,t.n44+t.n34);A=0;for(D=m.length;A<D;A++){G=m[A];G.divideScalar(Math.sqrt(G.x*G.x+G.y*G.y+G.z*G.z))}D=q.objects;q=0;for(A=D.length;q<A;q++){G=D[q];var E;if(!(E=!G.visible)){if(E=G instanceof THREE.Mesh){a:{E=void 0;for(var z=G.position,I=-G.geometry.boundingSphere.radius*Math.max(G.scale.x,Math.max(G.scale.y,G.scale.z)),F=0;F<6;F++){E=m[F].x*z.x+m[F].y*z.y+m[F].z*z.z+m[F].w;if(E<=I){E=false;break a}}E=true}E=!E}E=E}if(!E){d=
- g[e]=g[e]||new THREE.RenderableObject;w.copy(G.position);t.multiplyVector3(w);d.object=G;d.z=w.z;x.push(d);e++}}N&&x.sort(a);return x};this.projectScene=function(q,A,N){var x=[],D=A.near,G=A.far,E,z,I,F,T,V,P,da,X,R,U,ba,Y,H,S,W;c=n=u=0;A.autoUpdateMatrix&&A.updateMatrix();t.multiply(A.projectionMatrix,A.matrix);V=this.projectObjects(q,A,true);q=0;for(E=V.length;q<E;q++){P=V[q].object;if(P.visible){P.autoUpdateMatrix&&P.updateMatrix();da=P.matrix;X=P.rotationMatrix;R=P.materials;U=P.overdraw;if(P instanceof
- THREE.Mesh){ba=P.geometry;Y=ba.vertices;z=0;for(I=Y.length;z<I;z++){H=Y[z];H.positionWorld.copy(H.position);da.multiplyVector3(H.positionWorld);F=H.positionScreen;F.copy(H.positionWorld);t.multiplyVector4(F);F.x/=F.w;F.y/=F.w;H.__visible=F.z>D&&F.z<G}ba=ba.faces;z=0;for(I=ba.length;z<I;z++){H=ba[z];if(H instanceof THREE.Face3){F=Y[H.a];T=Y[H.b];S=Y[H.c];if(F.__visible&&T.__visible&&S.__visible)if(P.doubleSided||P.flipSided!=(S.positionScreen.x-F.positionScreen.x)*(T.positionScreen.y-F.positionScreen.y)-
- (S.positionScreen.y-F.positionScreen.y)*(T.positionScreen.x-F.positionScreen.x)<0){f=k[c]=k[c]||new THREE.RenderableFace3;f.v1.positionWorld.copy(F.positionWorld);f.v2.positionWorld.copy(T.positionWorld);f.v3.positionWorld.copy(S.positionWorld);f.v1.positionScreen.copy(F.positionScreen);f.v2.positionScreen.copy(T.positionScreen);f.v3.positionScreen.copy(S.positionScreen);f.normalWorld.copy(H.normal);X.multiplyVector3(f.normalWorld);f.centroidWorld.copy(H.centroid);da.multiplyVector3(f.centroidWorld);
- f.centroidScreen.copy(f.centroidWorld);t.multiplyVector3(f.centroidScreen);S=H.vertexNormals;C=f.vertexNormalsWorld;F=0;for(T=S.length;F<T;F++){W=C[F]=C[F]||new THREE.Vector3;W.copy(S[F]);X.multiplyVector3(W)}f.z=f.centroidScreen.z;f.meshMaterials=R;f.faceMaterials=H.materials;f.overdraw=U;if(P.geometry.uvs[z]){f.uvs[0]=P.geometry.uvs[z][0];f.uvs[1]=P.geometry.uvs[z][1];f.uvs[2]=P.geometry.uvs[z][2]}x.push(f);c++}}else if(H instanceof THREE.Face4){F=Y[H.a];T=Y[H.b];S=Y[H.c];W=Y[H.d];if(F.__visible&&
- T.__visible&&S.__visible&&W.__visible)if(P.doubleSided||P.flipSided!=((W.positionScreen.x-F.positionScreen.x)*(T.positionScreen.y-F.positionScreen.y)-(W.positionScreen.y-F.positionScreen.y)*(T.positionScreen.x-F.positionScreen.x)<0||(T.positionScreen.x-S.positionScreen.x)*(W.positionScreen.y-S.positionScreen.y)-(T.positionScreen.y-S.positionScreen.y)*(W.positionScreen.x-S.positionScreen.x)<0)){f=k[c]=k[c]||new THREE.RenderableFace3;f.v1.positionWorld.copy(F.positionWorld);f.v2.positionWorld.copy(T.positionWorld);
- f.v3.positionWorld.copy(W.positionWorld);f.v1.positionScreen.copy(F.positionScreen);f.v2.positionScreen.copy(T.positionScreen);f.v3.positionScreen.copy(W.positionScreen);f.normalWorld.copy(H.normal);X.multiplyVector3(f.normalWorld);f.centroidWorld.copy(H.centroid);da.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);t.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=R;f.faceMaterials=H.materials;f.overdraw=U;if(P.geometry.uvs[z]){f.uvs[0]=P.geometry.uvs[z][0];
- f.uvs[1]=P.geometry.uvs[z][1];f.uvs[2]=P.geometry.uvs[z][3]}x.push(f);c++;j=k[c]=k[c]||new THREE.RenderableFace3;j.v1.positionWorld.copy(T.positionWorld);j.v2.positionWorld.copy(S.positionWorld);j.v3.positionWorld.copy(W.positionWorld);j.v1.positionScreen.copy(T.positionScreen);j.v2.positionScreen.copy(S.positionScreen);j.v3.positionScreen.copy(W.positionScreen);j.normalWorld.copy(f.normalWorld);j.centroidWorld.copy(f.centroidWorld);j.centroidScreen.copy(f.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=
- R;j.faceMaterials=H.materials;j.overdraw=U;if(P.geometry.uvs[z]){j.uvs[0]=P.geometry.uvs[z][1];j.uvs[1]=P.geometry.uvs[z][2];j.uvs[2]=P.geometry.uvs[z][3]}x.push(j);c++}}}}else if(P instanceof THREE.Line){J.multiply(t,da);Y=P.geometry.vertices;H=Y[0];H.positionScreen.copy(H.position);J.multiplyVector4(H.positionScreen);z=1;for(I=Y.length;z<I;z++){F=Y[z];F.positionScreen.copy(F.position);J.multiplyVector4(F.positionScreen);T=Y[z-1];h.copy(F.positionScreen);p.copy(T.positionScreen);if(b(h,p)){h.multiplyScalar(1/
- h.w);p.multiplyScalar(1/p.w);l=B[n]=B[n]||new THREE.RenderableLine;l.v1.positionScreen.copy(h);l.v2.positionScreen.copy(p);l.z=Math.max(h.z,p.z);l.materials=P.materials;x.push(l);n++}}}else if(P instanceof THREE.Particle){L.set(P.position.x,P.position.y,P.position.z,1);t.multiplyVector4(L);L.z/=L.w;if(L.z>0&&L.z<1){o=v[u]=v[u]||new THREE.RenderableParticle;o.x=L.x/L.w;o.y=L.y/L.w;o.z=L.z;o.rotation=P.rotation.z;o.scale.x=P.scale.x*Math.abs(o.x-(L.x+A.projectionMatrix.n11)/(L.w+A.projectionMatrix.n14));
- o.scale.y=P.scale.y*Math.abs(o.y-(L.y+A.projectionMatrix.n22)/(L.w+A.projectionMatrix.n24));o.materials=P.materials;x.push(o);u++}}}}N&&x.sort(a);return x};this.unprojectVector=function(q,A){var N=THREE.Matrix4.makeInvert(A.matrix);N.multiplySelf(THREE.Matrix4.makeInvert(A.projectionMatrix));N.multiplyVector3(q);return q}};
- THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,g,f;this.domElement=document.createElement("div");this.setSize=function(j,c){d=j;e=c;g=d/2;f=e/2};this.render=function(j,c){var k,l,n,B,o,u,v,w;a=b.projectScene(j,c);k=0;for(l=a.length;k<l;k++){o=a[k];if(o instanceof THREE.RenderableParticle){v=o.x*g+g;w=o.y*f+f;n=0;for(B=o.material.length;n<B;n++){u=o.material[n];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=v+"px";u.style.top=w+"px"}}}}}};
- THREE.CanvasRenderer=function(){function a(ma){if(o!=ma)l.globalAlpha=o=ma}function b(ma){if(u!=ma){switch(ma){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}u=ma}}var d=null,e=new THREE.Projector,g=document.createElement("canvas"),f,j,c,k,l=g.getContext("2d"),n=null,B=null,o=1,u=0,v=null,w=null,L=1,t,J,m,h,p,C,q,A,N,x=new THREE.Color,
- D=new THREE.Color,G=new THREE.Color,E=new THREE.Color,z=new THREE.Color,I,F,T,V,P,da,X,R,U,ba=new THREE.Rectangle,Y=new THREE.Rectangle,H=new THREE.Rectangle,S=false,W=new THREE.Color,ia=new THREE.Color,ha=new THREE.Color,y=new THREE.Color,M=Math.PI*2,K=new THREE.Vector3,Z,ca,ga,ja,qa,sa,ya=16;Z=document.createElement("canvas");Z.width=Z.height=2;ca=Z.getContext("2d");ca.fillStyle="rgba(0,0,0,1)";ca.fillRect(0,0,2,2);ga=ca.getImageData(0,0,2,2);ja=ga.data;qa=document.createElement("canvas");qa.width=
- qa.height=ya;sa=qa.getContext("2d");sa.translate(-ya/2,-ya/2);sa.scale(ya,ya);ya--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ma,wa){f=ma;j=wa;c=f/2;k=j/2;g.width=f;g.height=j;ba.set(-c,-k,c,k);o=1;u=0;w=v=null;L=1};this.setClearColor=function(ma,wa){n=ma!==null?new THREE.Color(ma):null;B=wa;Y.set(-c,-k,c,k);l.setTransform(1,0,0,-1,c,k);this.clear()};this.clear=function(){if(!Y.isEmpty()){Y.inflate(1);Y.minSelf(ba);if(n!==null){b(THREE.NormalBlending);
- a(1);l.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+B+")";l.fillRect(Y.getX(),Y.getY(),Y.getWidth(),Y.getHeight())}else l.clearRect(Y.getX(),Y.getY(),Y.getWidth(),Y.getHeight());Y.empty()}};this.render=function(ma,wa){function Pa(O){var ea,aa,Q,$=O.lights;ia.setRGB(0,0,0);ha.setRGB(0,0,0);y.setRGB(0,0,0);O=0;for(ea=$.length;O<ea;O++){aa=$[O];Q=aa.color;if(aa instanceof THREE.AmbientLight){ia.r+=Q.r;ia.g+=Q.g;ia.b+=Q.b}else if(aa instanceof THREE.DirectionalLight){ha.r+=
- Q.r;ha.g+=Q.g;ha.b+=Q.b}else if(aa instanceof THREE.PointLight){y.r+=Q.r;y.g+=Q.g;y.b+=Q.b}}}function Da(O,ea,aa,Q){var $,fa,la,na,oa=O.lights;O=0;for($=oa.length;O<$;O++){fa=oa[O];la=fa.color;na=fa.intensity;if(fa instanceof THREE.DirectionalLight){fa=aa.dot(fa.position)*na;if(fa>0){Q.r+=la.r*fa;Q.g+=la.g*fa;Q.b+=la.b*fa}}else if(fa instanceof THREE.PointLight){K.sub(fa.position,ea);K.normalize();fa=aa.dot(K)*na;if(fa>0){Q.r+=la.r*fa;Q.g+=la.g*fa;Q.b+=la.b*fa}}}}function Qa(O,ea,aa){if(aa.opacity!=
- 0){a(aa.opacity);b(aa.blending);var Q,$,fa,la,na,oa;if(aa instanceof THREE.ParticleBasicMaterial){if(aa.map){la=aa.map;na=la.width>>1;oa=la.height>>1;$=ea.scale.x*c;fa=ea.scale.y*k;aa=$*na;Q=fa*oa;H.set(O.x-aa,O.y-Q,O.x+aa,O.y+Q);if(ba.instersects(H)){l.save();l.translate(O.x,O.y);l.rotate(-ea.rotation);l.scale($,-fa);l.translate(-na,-oa);l.drawImage(la,0,0);l.restore()}}}else if(aa instanceof THREE.ParticleCircleMaterial){if(S){W.r=ia.r+ha.r+y.r;W.g=ia.g+ha.g+y.g;W.b=ia.b+ha.b+y.b;x.r=aa.color.r*
- W.r;x.g=aa.color.g*W.g;x.b=aa.color.b*W.b;x.updateStyleString()}else x.__styleString=aa.color.__styleString;aa=ea.scale.x*c;Q=ea.scale.y*k;H.set(O.x-aa,O.y-Q,O.x+aa,O.y+Q);if(ba.instersects(H)){$=x.__styleString;if(w!=$)l.fillStyle=w=$;l.save();l.translate(O.x,O.y);l.rotate(-ea.rotation);l.scale(aa,Q);l.beginPath();l.arc(0,0,1,0,M,true);l.closePath();l.fill();l.restore()}}}}function Ra(O,ea,aa,Q){if(Q.opacity!=0){a(Q.opacity);b(Q.blending);l.beginPath();l.moveTo(O.positionScreen.x,O.positionScreen.y);
- l.lineTo(ea.positionScreen.x,ea.positionScreen.y);l.closePath();if(Q instanceof THREE.LineBasicMaterial){x.__styleString=Q.color.__styleString;O=Q.linewidth;if(L!=O)l.lineWidth=L=O;O=x.__styleString;if(v!=O)l.strokeStyle=v=O;l.stroke();H.inflate(Q.linewidth*2)}}}function La(O,ea,aa,Q,$,fa){if($.opacity!=0){a($.opacity);b($.blending);h=O.positionScreen.x;p=O.positionScreen.y;C=ea.positionScreen.x;q=ea.positionScreen.y;A=aa.positionScreen.x;N=aa.positionScreen.y;l.beginPath();l.moveTo(h,p);l.lineTo(C,
- q);l.lineTo(A,N);l.lineTo(h,p);l.closePath();if($ instanceof THREE.MeshBasicMaterial)if($.map)$.map.image.loaded&&$.map.mapping instanceof THREE.UVMapping&&Aa(h,p,C,q,A,N,$.map.image,Q.uvs[0].u,Q.uvs[0].v,Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);else if($.env_map){if($.env_map.image.loaded)if($.env_map.mapping instanceof THREE.SphericalReflectionMapping){O=wa.matrix;K.copy(Q.vertexNormalsWorld[0]);V=(K.x*O.n11+K.y*O.n12+K.z*O.n13)*0.5+0.5;P=-(K.x*O.n21+K.y*O.n22+K.z*O.n23)*0.5+0.5;K.copy(Q.vertexNormalsWorld[1]);
- da=(K.x*O.n11+K.y*O.n12+K.z*O.n13)*0.5+0.5;X=-(K.x*O.n21+K.y*O.n22+K.z*O.n23)*0.5+0.5;K.copy(Q.vertexNormalsWorld[2]);R=(K.x*O.n11+K.y*O.n12+K.z*O.n13)*0.5+0.5;U=-(K.x*O.n21+K.y*O.n22+K.z*O.n23)*0.5+0.5;Aa(h,p,C,q,A,N,$.env_map.image,V,P,da,X,R,U)}}else $.wireframe?Ea($.color.__styleString,$.wireframe_linewidth):Fa($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&!$.wireframe){$.map.mapping instanceof THREE.UVMapping&&Aa(h,p,C,q,A,N,$.map.image,Q.uvs[0].u,Q.uvs[0].v,
- Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);b(THREE.SubtractiveBlending)}if(S)if(!$.wireframe&&$.shading==THREE.SmoothShading&&Q.vertexNormalsWorld.length==3){D.r=G.r=E.r=ia.r;D.g=G.g=E.g=ia.g;D.b=G.b=E.b=ia.b;Da(fa,Q.v1.positionWorld,Q.vertexNormalsWorld[0],D);Da(fa,Q.v2.positionWorld,Q.vertexNormalsWorld[1],G);Da(fa,Q.v3.positionWorld,Q.vertexNormalsWorld[2],E);z.r=(G.r+E.r)*0.5;z.g=(G.g+E.g)*0.5;z.b=(G.b+E.b)*0.5;T=Ma(D,G,E,z);Aa(h,p,C,q,A,N,T,0,0,1,0,0,1)}else{W.r=ia.r;W.g=ia.g;W.b=ia.b;Da(fa,
- Q.centroidWorld,Q.normalWorld,W);x.r=$.color.r*W.r;x.g=$.color.g*W.g;x.b=$.color.b*W.b;x.updateStyleString();$.wireframe?Ea(x.__styleString,$.wireframe_linewidth):Fa(x.__styleString)}else $.wireframe?Ea($.color.__styleString,$.wireframe_linewidth):Fa($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){I=wa.near;F=wa.far;D.r=D.g=D.b=1-Ha(O.positionScreen.z,I,F);G.r=G.g=G.b=1-Ha(ea.positionScreen.z,I,F);E.r=E.g=E.b=1-Ha(aa.positionScreen.z,I,F);z.r=(G.r+E.r)*0.5;z.g=(G.g+E.g)*0.5;z.b=
- (G.b+E.b)*0.5;T=Ma(D,G,E,z);Aa(h,p,C,q,A,N,T,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){x.r=Ia(Q.normalWorld.x);x.g=Ia(Q.normalWorld.y);x.b=Ia(Q.normalWorld.z);x.updateStyleString();$.wireframe?Ea(x.__styleString,$.wireframe_linewidth):Fa(x.__styleString)}}}function Ea(O,ea){if(v!=O)l.strokeStyle=v=O;if(L!=ea)l.lineWidth=L=ea;l.stroke();H.inflate(ea*2)}function Fa(O){if(w!=O)l.fillStyle=w=O;l.fill()}function Aa(O,ea,aa,Q,$,fa,la,na,oa,ta,pa,ua,Ba){var xa,va;xa=la.width-1;va=la.height-
- 1;na*=xa;oa*=va;ta*=xa;pa*=va;ua*=xa;Ba*=va;aa-=O;Q-=ea;$-=O;fa-=ea;ta-=na;pa-=oa;ua-=na;Ba-=oa;va=1/(ta*Ba-ua*pa);xa=(Ba*aa-pa*$)*va;pa=(Ba*Q-pa*fa)*va;aa=(ta*$-ua*aa)*va;Q=(ta*fa-ua*Q)*va;O=O-xa*na-aa*oa;ea=ea-pa*na-Q*oa;l.save();l.transform(xa,pa,aa,Q,O,ea);l.clip();l.drawImage(la,0,0);l.restore()}function Ma(O,ea,aa,Q){var $=~~(O.r*255),fa=~~(O.g*255);O=~~(O.b*255);var la=~~(ea.r*255),na=~~(ea.g*255);ea=~~(ea.b*255);var oa=~~(aa.r*255),ta=~~(aa.g*255);aa=~~(aa.b*255);var pa=~~(Q.r*255),ua=~~(Q.g*
- 255);Q=~~(Q.b*255);ja[0]=$<0?0:$>255?255:$;ja[1]=fa<0?0:fa>255?255:fa;ja[2]=O<0?0:O>255?255:O;ja[4]=la<0?0:la>255?255:la;ja[5]=na<0?0:na>255?255:na;ja[6]=ea<0?0:ea>255?255:ea;ja[8]=oa<0?0:oa>255?255:oa;ja[9]=ta<0?0:ta>255?255:ta;ja[10]=aa<0?0:aa>255?255:aa;ja[12]=pa<0?0:pa>255?255:pa;ja[13]=ua<0?0:ua>255?255:ua;ja[14]=Q<0?0:Q>255?255:Q;ca.putImageData(ga,0,0);sa.drawImage(Z,0,0);return qa}function Ha(O,ea,aa){O=(O-ea)/(aa-ea);return O*O*(3-2*O)}function Ia(O){O=(O+1)*0.5;return O<0?0:O>1?1:O}function Ja(O,
- ea){var aa=ea.x-O.x,Q=ea.y-O.y,$=1/Math.sqrt(aa*aa+Q*Q);aa*=$;Q*=$;ea.x+=aa;ea.y+=Q;O.x-=aa;O.y-=Q}var Ga,Na,ka,ra,za,Ka,Oa,Ca;l.setTransform(1,0,0,-1,c,k);this.autoClear&&this.clear();d=e.projectScene(ma,wa,this.sortElements);(S=ma.lights.length>0)&&Pa(ma);Ga=0;for(Na=d.length;Ga<Na;Ga++){ka=d[Ga];H.empty();if(ka instanceof THREE.RenderableParticle){t=ka;t.x*=c;t.y*=k;ra=0;for(za=ka.materials.length;ra<za;ra++)Qa(t,ka,ka.materials[ra],ma)}else if(ka instanceof THREE.RenderableLine){t=ka.v1;J=ka.v2;
- t.positionScreen.x*=c;t.positionScreen.y*=k;J.positionScreen.x*=c;J.positionScreen.y*=k;H.addPoint(t.positionScreen.x,t.positionScreen.y);H.addPoint(J.positionScreen.x,J.positionScreen.y);if(ba.instersects(H)){ra=0;for(za=ka.materials.length;ra<za;)Ra(t,J,ka,ka.materials[ra++],ma)}}else if(ka instanceof THREE.RenderableFace3){t=ka.v1;J=ka.v2;m=ka.v3;t.positionScreen.x*=c;t.positionScreen.y*=k;J.positionScreen.x*=c;J.positionScreen.y*=k;m.positionScreen.x*=c;m.positionScreen.y*=k;if(ka.overdraw){Ja(t.positionScreen,
- J.positionScreen);Ja(J.positionScreen,m.positionScreen);Ja(m.positionScreen,t.positionScreen)}H.add3Points(t.positionScreen.x,t.positionScreen.y,J.positionScreen.x,J.positionScreen.y,m.positionScreen.x,m.positionScreen.y);if(ba.instersects(H)){ra=0;for(za=ka.meshMaterials.length;ra<za;){Ca=ka.meshMaterials[ra++];if(Ca instanceof THREE.MeshFaceMaterial){Ka=0;for(Oa=ka.faceMaterials.length;Ka<Oa;)(Ca=ka.faceMaterials[Ka++])&&La(t,J,m,ka,Ca,ma)}else La(t,J,m,ka,Ca,ma)}}}Y.addRectangle(H)}l.setTransform(1,
- 0,0,1,0,0)}};
- THREE.SVGRenderer=function(){function a(V,P,da){var X,R,U,ba;X=0;for(R=V.lights.length;X<R;X++){U=V.lights[X];if(U instanceof THREE.DirectionalLight){ba=P.normalWorld.dot(U.position)*U.intensity;if(ba>0){da.r+=U.color.r*ba;da.g+=U.color.g*ba;da.b+=U.color.b*ba}}else if(U instanceof THREE.PointLight){N.sub(U.position,P.centroidWorld);N.normalize();ba=P.normalWorld.dot(N)*U.intensity;if(ba>0){da.r+=U.color.r*ba;da.g+=U.color.g*ba;da.b+=U.color.b*ba}}}}function b(V,P,da,X,R,U){E=e(z++);E.setAttribute("d",
- "M "+V.positionScreen.x+" "+V.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+"z");if(R instanceof THREE.MeshBasicMaterial)m.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshLambertMaterial)if(J){h.r=p.r;h.g=p.g;h.b=p.b;a(U,X,h);m.r=R.color.r*h.r;m.g=R.color.g*h.g;m.b=R.color.b*h.b;m.updateStyleString()}else m.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshDepthMaterial){A=1-R.__2near/(R.__farPlusNear-
- X.z*R.__farMinusNear);m.setRGB(A,A,A)}else R instanceof THREE.MeshNormalMaterial&&m.setRGB(g(X.normalWorld.x),g(X.normalWorld.y),g(X.normalWorld.z));R.wireframe?E.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+R.wireframe_linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.wireframe_linecap+"; stroke-linejoin: "+R.wireframe_linejoin):E.setAttribute("style","fill: "+m.__styleString+"; fill-opacity: "+R.opacity);c.appendChild(E)}function d(V,P,da,X,R,U,ba){E=
- e(z++);E.setAttribute("d","M "+V.positionScreen.x+" "+V.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(U instanceof THREE.MeshBasicMaterial)m.__styleString=U.color.__styleString;else if(U instanceof THREE.MeshLambertMaterial)if(J){h.r=p.r;h.g=p.g;h.b=p.b;a(ba,R,h);m.r=U.color.r*h.r;m.g=U.color.g*h.g;m.b=U.color.b*h.b;m.updateStyleString()}else m.__styleString=U.color.__styleString;
- else if(U instanceof THREE.MeshDepthMaterial){A=1-U.__2near/(U.__farPlusNear-R.z*U.__farMinusNear);m.setRGB(A,A,A)}else U instanceof THREE.MeshNormalMaterial&&m.setRGB(g(R.normalWorld.x),g(R.normalWorld.y),g(R.normalWorld.z));U.wireframe?E.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+U.wireframe_linewidth+"; stroke-opacity: "+U.opacity+"; stroke-linecap: "+U.wireframe_linecap+"; stroke-linejoin: "+U.wireframe_linejoin):E.setAttribute("style","fill: "+m.__styleString+
- "; fill-opacity: "+U.opacity);c.appendChild(E)}function e(V){if(x[V]==null){x[V]=document.createElementNS("http://www.w3.org/2000/svg","path");T==0&&x[V].setAttribute("shape-rendering","crispEdges");return x[V]}return x[V]}function g(V){return V<0?Math.min((1+V)*0.5,0.5):0.5+Math.min(V*0.5,0.5)}var f=null,j=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,l,n,B,o,u,v,w,L=new THREE.Rectangle,t=new THREE.Rectangle,J=false,m=new THREE.Color(16777215),h=new THREE.Color(16777215),
- p=new THREE.Color(0),C=new THREE.Color(0),q=new THREE.Color(0),A,N=new THREE.Vector3,x=[],D=[],G=[],E,z,I,F,T=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(V){switch(V){case "high":T=1;break;case "low":T=0}};this.setSize=function(V,P){k=V;l=P;n=k/2;B=l/2;c.setAttribute("viewBox",-n+" "+-B+" "+k+" "+l);c.setAttribute("width",k);c.setAttribute("height",l);L.set(-n,-B,n,B)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};
- this.render=function(V,P){var da,X,R,U,ba,Y,H,S;this.autoClear&&this.clear();f=j.projectScene(V,P,this.sortElements);F=I=z=0;if(J=V.lights.length>0){H=V.lights;p.setRGB(0,0,0);C.setRGB(0,0,0);q.setRGB(0,0,0);da=0;for(X=H.length;da<X;da++){R=H[da];U=R.color;if(R instanceof THREE.AmbientLight){p.r+=U.r;p.g+=U.g;p.b+=U.b}else if(R instanceof THREE.DirectionalLight){C.r+=U.r;C.g+=U.g;C.b+=U.b}else if(R instanceof THREE.PointLight){q.r+=U.r;q.g+=U.g;q.b+=U.b}}}da=0;for(X=f.length;da<X;da++){H=f[da];t.empty();
- if(H instanceof THREE.RenderableParticle){o=H;o.x*=n;o.y*=-B;R=0;for(U=H.materials.length;R<U;R++)if(S=H.materials[R]){ba=o;Y=H;S=S;var W=I++;if(D[W]==null){D[W]=document.createElementNS("http://www.w3.org/2000/svg","circle");T==0&&D[W].setAttribute("shape-rendering","crispEdges")}E=D[W];E.setAttribute("cx",ba.x);E.setAttribute("cy",ba.y);E.setAttribute("r",Y.scale.x*n);if(S instanceof THREE.ParticleCircleMaterial){if(J){h.r=p.r+C.r+q.r;h.g=p.g+C.g+q.g;h.b=p.b+C.b+q.b;m.r=S.color.r*h.r;m.g=S.color.g*
- h.g;m.b=S.color.b*h.b;m.updateStyleString()}else m=S.color;E.setAttribute("style","fill: "+m.__styleString)}c.appendChild(E)}}else if(H instanceof THREE.RenderableLine){o=H.v1;u=H.v2;o.positionScreen.x*=n;o.positionScreen.y*=-B;u.positionScreen.x*=n;u.positionScreen.y*=-B;t.addPoint(o.positionScreen.x,o.positionScreen.y);t.addPoint(u.positionScreen.x,u.positionScreen.y);if(L.instersects(t)){R=0;for(U=H.materials.length;R<U;)if(S=H.materials[R++]){ba=o;Y=u;S=S;W=F++;if(G[W]==null){G[W]=document.createElementNS("http://www.w3.org/2000/svg",
- "line");T==0&&G[W].setAttribute("shape-rendering","crispEdges")}E=G[W];E.setAttribute("x1",ba.positionScreen.x);E.setAttribute("y1",ba.positionScreen.y);E.setAttribute("x2",Y.positionScreen.x);E.setAttribute("y2",Y.positionScreen.y);if(S instanceof THREE.LineBasicMaterial){m.__styleString=S.color.__styleString;E.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+S.linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.linecap+"; stroke-linejoin: "+S.linejoin);
- c.appendChild(E)}}}}else if(H instanceof THREE.RenderableFace3){o=H.v1;u=H.v2;v=H.v3;o.positionScreen.x*=n;o.positionScreen.y*=-B;u.positionScreen.x*=n;u.positionScreen.y*=-B;v.positionScreen.x*=n;v.positionScreen.y*=-B;t.addPoint(o.positionScreen.x,o.positionScreen.y);t.addPoint(u.positionScreen.x,u.positionScreen.y);t.addPoint(v.positionScreen.x,v.positionScreen.y);if(L.instersects(t)){R=0;for(U=H.meshMaterials.length;R<U;){S=H.meshMaterials[R++];if(S instanceof THREE.MeshFaceMaterial){ba=0;for(Y=
- H.faceMaterials.length;ba<Y;)(S=H.faceMaterials[ba++])&&b(o,u,v,H,S,V)}else S&&b(o,u,v,H,S,V)}}}else if(H instanceof THREE.RenderableFace4){o=H.v1;u=H.v2;v=H.v3;w=H.v4;o.positionScreen.x*=n;o.positionScreen.y*=-B;u.positionScreen.x*=n;u.positionScreen.y*=-B;v.positionScreen.x*=n;v.positionScreen.y*=-B;w.positionScreen.x*=n;w.positionScreen.y*=-B;t.addPoint(o.positionScreen.x,o.positionScreen.y);t.addPoint(u.positionScreen.x,u.positionScreen.y);t.addPoint(v.positionScreen.x,v.positionScreen.y);t.addPoint(w.positionScreen.x,
- w.positionScreen.y);if(L.instersects(t)){R=0;for(U=H.meshMaterials.length;R<U;){S=H.meshMaterials[R++];if(S instanceof THREE.MeshFaceMaterial){ba=0;for(Y=H.faceMaterials.length;ba<Y;)(S=H.faceMaterials[ba++])&&d(o,u,v,w,H,S,V)}else S&&d(o,u,v,w,H,S,V)}}}}}};
- THREE.WebGLRenderer=function(a){function b(h,p){h.fragment_shader=p.fragment_shader;h.vertex_shader=p.vertex_shader;h.uniforms=Uniforms.clone(p.uniforms)}function d(h,p){h.uniforms.color.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);h.uniforms.opacity.value=h.opacity;h.uniforms.map.texture=h.map;h.uniforms.env_map.texture=h.env_map;h.uniforms.reflectivity.value=h.reflectivity;h.uniforms.refraction_ratio.value=h.refraction_ratio;h.uniforms.combine.value=h.combine;h.uniforms.useRefract.value=
- h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping;if(p){h.uniforms.fogColor.value.setHex(p.color.hex);if(p instanceof THREE.Fog){h.uniforms.fogNear.value=p.near;h.uniforms.fogFar.value=p.far}else if(p instanceof THREE.FogExp2)h.uniforms.fogDensity.value=p.density}}function e(h,p){h.uniforms.color.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);h.uniforms.opacity.value=h.opacity;if(p){h.uniforms.fogColor.value.setHex(p.color.hex);if(p instanceof THREE.Fog){h.uniforms.fogNear.value=
- p.near;h.uniforms.fogFar.value=p.far}else if(p instanceof THREE.FogExp2)h.uniforms.fogDensity.value=p.density}}function g(h,p){var C;if(h=="fragment")C=c.createShader(c.FRAGMENT_SHADER);else if(h=="vertex")C=c.createShader(c.VERTEX_SHADER);c.shaderSource(C,p);c.compileShader(C);if(!c.getShaderParameter(C,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(C));return null}return C}function f(h){switch(h){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;
- case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE;case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;
- case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var j=document.createElement("canvas"),c,k=null,l=null,n=new THREE.Matrix4,B,o=new Float32Array(16),u=new Float32Array(16),v=new Float32Array(16),w=new Float32Array(9),
- L=new Float32Array(16),t=true,J=new THREE.Color(0),m=0;if(a){if(a.antialias!==undefined)t=a.antialias;a.clearColor!==undefined&&J.setHex(a.clearColor);if(a.clearAlpha!==undefined)m=a.clearAlpha}this.domElement=j;this.autoClear=true;(function(h,p,C){try{c=j.getContext("experimental-webgl",{antialias:h})}catch(q){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);
- c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(p.r,p.g,p.b,C)})(t,J,m);this.context=c;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(h,p){j.width=h;j.height=p;c.viewport(0,0,j.width,j.height)};this.setClearColor=function(h,p){var C=new THREE.Color(h);c.clearColor(C.r,C.g,C.b,p)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=
- function(h,p){var C,q,A,N=0,x=0,D=0,G,E,z,I=this.lights,F=I.directional.colors,T=I.directional.positions,V=I.point.colors,P=I.point.positions,da=0,X=0;C=0;for(q=p.length;C<q;C++){A=p[C];G=A.color;E=A.position;z=A.intensity;if(A instanceof THREE.AmbientLight){N+=G.r;x+=G.g;D+=G.b}else if(A instanceof THREE.DirectionalLight){F[da*3]=G.r*z;F[da*3+1]=G.g*z;F[da*3+2]=G.b*z;T[da*3]=E.x;T[da*3+1]=E.y;T[da*3+2]=E.z;da+=1}else if(A instanceof THREE.PointLight){V[X*3]=G.r*z;V[X*3+1]=G.g*z;V[X*3+2]=G.b*z;P[X*
- 3]=E.x;P[X*3+1]=E.y;P[X*3+2]=E.z;X+=1}}I.point.length=X;I.directional.length=da;I.ambient[0]=N;I.ambient[1]=x;I.ambient[2]=D};this.createParticleBuffers=function(h){h.__webGLVertexBuffer=c.createBuffer();h.__webGLFaceBuffer=c.createBuffer()};this.createLineBuffers=function(h){h.__webGLVertexBuffer=c.createBuffer();h.__webGLLineBuffer=c.createBuffer()};this.createMeshBuffers=function(h){h.__webGLVertexBuffer=c.createBuffer();h.__webGLNormalBuffer=c.createBuffer();h.__webGLTangentBuffer=c.createBuffer();
- h.__webGLUVBuffer=c.createBuffer();h.__webGLFaceBuffer=c.createBuffer();h.__webGLLineBuffer=c.createBuffer()};this.initLineBuffers=function(h){var p=h.vertices.length;h.__vertexArray=new Float32Array(p*3);h.__lineArray=new Uint16Array(p);h.__webGLLineCount=p};this.initMeshBuffers=function(h,p){var C,q,A=0,N=0,x=0,D=p.geometry.faces,G=h.faces;C=0;for(q=G.length;C<q;C++){fi=G[C];face=D[fi];if(face instanceof THREE.Face3){A+=3;N+=1;x+=3}else if(face instanceof THREE.Face4){A+=4;N+=2;x+=4}}h.__vertexArray=
- new Float32Array(A*3);h.__normalArray=new Float32Array(A*3);h.__tangentArray=new Float32Array(A*4);h.__uvArray=new Float32Array(A*2);h.__faceArray=new Uint16Array(N*3);h.__lineArray=new Uint16Array(x*2);A=false;C=0;for(q=p.materials.length;C<q;C++){D=p.materials[C];if(D instanceof THREE.MeshFaceMaterial){D=0;for(G=h.materials.length;D<G;D++)if(h.materials[D]&&h.materials[D].shading!=undefined&&h.materials[D].shading==THREE.SmoothShading){A=true;break}}else if(D&&D.shading!=undefined&&D.shading==THREE.SmoothShading){A=
- true;break}if(A)break}h.__needsSmoothNormals=A;h.__webGLFaceCount=N*3;h.__webGLLineCount=x*2};this.setMeshBuffers=function(h,p,C,q,A,N,x,D){var G,E,z,I,F,T,V,P,da,X=0,R=0,U=0,ba=0,Y=0,H=0,S=0,W=h.__vertexArray,ia=h.__uvArray,ha=h.__normalArray,y=h.__tangentArray,M=h.__faceArray,K=h.__lineArray,Z=h.__needsSmoothNormals,ca=p.geometry,ga=ca.vertices,ja=h.faces,qa=ca.faces,sa=ca.uvs;p=0;for(G=ja.length;p<G;p++){E=ja[p];z=qa[E];E=sa[E];I=z.vertexNormals;F=z.normal;if(z instanceof THREE.Face3){if(q){T=
- ga[z.a].position;V=ga[z.b].position;P=ga[z.c].position;W[R]=T.x;W[R+1]=T.y;W[R+2]=T.z;W[R+3]=V.x;W[R+4]=V.y;W[R+5]=V.z;W[R+6]=P.x;W[R+7]=P.y;W[R+8]=P.z;R+=9}if(D&&ca.hasTangents){T=ga[z.a].tangent;V=ga[z.b].tangent;P=ga[z.c].tangent;y[H]=T.x;y[H+1]=T.y;y[H+2]=T.z;y[H+3]=T.w;y[H+4]=V.x;y[H+5]=V.y;y[H+6]=V.z;y[H+7]=V.w;y[H+8]=P.x;y[H+9]=P.y;y[H+10]=P.z;y[H+11]=P.w;H+=12}if(x)if(I.length==3&&Z)for(z=0;z<3;z++){F=I[z];ha[Y]=F.x;ha[Y+1]=F.y;ha[Y+2]=F.z;Y+=3}else for(z=0;z<3;z++){ha[Y]=F.x;ha[Y+1]=F.y;
- ha[Y+2]=F.z;Y+=3}if(N&&E)for(z=0;z<3;z++){I=E[z];ia[U]=I.u;ia[U+1]=I.v;U+=2}if(A){M[ba]=X;M[ba+1]=X+1;M[ba+2]=X+2;ba+=3;K[S]=X;K[S+1]=X+1;K[S+2]=X;K[S+3]=X+2;K[S+4]=X+1;K[S+5]=X+2;S+=6;X+=3}}else if(z instanceof THREE.Face4){if(q){T=ga[z.a].position;V=ga[z.b].position;P=ga[z.c].position;da=ga[z.d].position;W[R]=T.x;W[R+1]=T.y;W[R+2]=T.z;W[R+3]=V.x;W[R+4]=V.y;W[R+5]=V.z;W[R+6]=P.x;W[R+7]=P.y;W[R+8]=P.z;W[R+9]=da.x;W[R+10]=da.y;W[R+11]=da.z;R+=12}if(D&&ca.hasTangents){T=ga[z.a].tangent;V=ga[z.b].tangent;
- P=ga[z.c].tangent;z=ga[z.d].tangent;y[H]=T.x;y[H+1]=T.y;y[H+2]=T.z;y[H+3]=T.w;y[H+4]=V.x;y[H+5]=V.y;y[H+6]=V.z;y[H+7]=V.w;y[H+8]=P.x;y[H+9]=P.y;y[H+10]=P.z;y[H+11]=P.w;y[H+12]=z.x;y[H+13]=z.y;y[H+14]=z.z;y[H+15]=z.w;H+=16}if(x)if(I.length==4&&Z)for(z=0;z<4;z++){F=I[z];ha[Y]=F.x;ha[Y+1]=F.y;ha[Y+2]=F.z;Y+=3}else for(z=0;z<4;z++){ha[Y]=F.x;ha[Y+1]=F.y;ha[Y+2]=F.z;Y+=3}if(N&&E)for(z=0;z<4;z++){I=E[z];ia[U]=I.u;ia[U+1]=I.v;U+=2}if(A){M[ba]=X;M[ba+1]=X+1;M[ba+2]=X+2;M[ba+3]=X;M[ba+4]=X+2;M[ba+5]=X+3;ba+=
- 6;K[S]=X;K[S+1]=X+1;K[S+2]=X;K[S+3]=X+3;K[S+4]=X+1;K[S+5]=X+2;K[S+6]=X+2;K[S+7]=X+3;S+=8;X+=4}}}if(q){c.bindBuffer(c.ARRAY_BUFFER,h.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,W,C)}if(x){c.bindBuffer(c.ARRAY_BUFFER,h.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,ha,C)}if(D&&ca.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,h.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,y,C)}if(N&&U>0){c.bindBuffer(c.ARRAY_BUFFER,h.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,ia,C)}if(A){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
- h.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,M,C);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,K,C)}};this.setLineBuffers=function(h,p,C,q){var A,N,x=h.vertices,D=x.length,G=h.__vertexArray,E=h.__lineArray;if(C)for(C=0;C<D;C++){A=x[C].position;N=C*3;G[N]=A.x;G[N+1]=A.y;G[N+2]=A.z}if(q)for(C=0;C<D;C++)E[C]=C;c.bindBuffer(c.ARRAY_BUFFER,h.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,G,p);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webGLLineBuffer);
- c.bufferData(c.ELEMENT_ARRAY_BUFFER,E,p)};this.setParticleBuffers=function(){};this.renderBuffer=function(h,p,C,q,A,N){var x,D,G,E;if(!q.program){if(q instanceof THREE.MeshDepthMaterial){b(q,THREE.ShaderLib.depth);q.uniforms.mNear.value=h.near;q.uniforms.mFar.value=h.far}else if(q instanceof THREE.MeshNormalMaterial)b(q,THREE.ShaderLib.normal);else if(q instanceof THREE.MeshBasicMaterial){b(q,THREE.ShaderLib.basic);d(q,C)}else if(q instanceof THREE.MeshLambertMaterial){b(q,THREE.ShaderLib.lambert);
- d(q,C)}else if(q instanceof THREE.MeshPhongMaterial){b(q,THREE.ShaderLib.phong);d(q,C)}else if(q instanceof THREE.LineBasicMaterial){b(q,THREE.ShaderLib.basic);e(q,C)}var z,I,F;z=E=D=0;for(I=p.length;z<I;z++){F=p[z];F instanceof THREE.DirectionalLight&&E++;F instanceof THREE.PointLight&&D++}if(D+E<=4){z=E;D=D}else{z=Math.ceil(4*E/(D+E));D=4-z}D={directional:z,point:D};E={fog:C,map:q.map,env_map:q.env_map,maxDirLights:D.directional,maxPointLights:D.point};D=q.fragment_shader;z=q.vertex_shader;I=c.createProgram();
- F=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+E.maxDirLights,"#define MAX_POINT_LIGHTS "+E.maxPointLights,E.fog?"#define USE_FOG":"",E.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",E.map?"#define USE_MAP":"",E.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");E=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+E.maxDirLights,"#define MAX_POINT_LIGHTS "+E.maxPointLights,
- E.map?"#define USE_MAP":"",E.env_map?"#define USE_ENVMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(I,g("fragment",F+D));c.attachShader(I,g("vertex",E+z));c.linkProgram(I);c.getProgramParameter(I,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+
- c.getProgramParameter(I,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");I.uniforms={};I.attributes={};q.program=I;D=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(x in q.uniforms)D.push(x);x=q.program;z=0;for(I=D.length;z<I;z++){F=D[z];x.uniforms[F]=c.getUniformLocation(x,F)}x=q.program;D=["position","normal","uv","tangent"];z=0;for(I=D.length;z<I;z++){F=D[z];x.attributes[F]=c.getAttribLocation(x,F)}}x=q.program;if(x!=k){c.useProgram(x);
- k=x}this.loadCamera(x,h);this.loadMatrices(x);if(q instanceof THREE.MeshPhongMaterial||q instanceof THREE.MeshLambertMaterial){this.setupLights(x,p);h=this.lights;q.uniforms.enableLighting.value=h.directional.length+h.point.length;q.uniforms.ambientLightColor.value=h.ambient;q.uniforms.directionalLightColor.value=h.directional.colors;q.uniforms.directionalLightDirection.value=h.directional.positions;q.uniforms.pointLightColor.value=h.point.colors;q.uniforms.pointLightPosition.value=h.point.positions}if(q instanceof
- THREE.MeshBasicMaterial||q instanceof THREE.MeshLambertMaterial||q instanceof THREE.MeshPhongMaterial)d(q,C);q instanceof THREE.LineBasicMaterial&&e(q,C);if(q instanceof THREE.MeshPhongMaterial){q.uniforms.ambient.value.setRGB(q.ambient.r,q.ambient.g,q.ambient.b);q.uniforms.specular.value.setRGB(q.specular.r,q.specular.g,q.specular.b);q.uniforms.shininess.value=q.shininess}C=q.uniforms;for(G in C)if(z=x.uniforms[G]){p=C[G];D=p.type;h=p.value;if(D=="i")c.uniform1i(z,h);else if(D=="f")c.uniform1f(z,
- h);else if(D=="fv1")c.uniform1fv(z,h);else if(D=="fv")c.uniform3fv(z,h);else if(D=="v2")c.uniform2f(z,h.x,h.y);else if(D=="v3")c.uniform3f(z,h.x,h.y,h.z);else if(D=="c")c.uniform3f(z,h.r,h.g,h.b);else if(D=="t"){c.uniform1i(z,h);if(p=p.texture)if(p.image instanceof Array&&p.image.length==6){p=p;h=h;if(p.image.length==6){if(!p.image.__webGLTextureCube&&!p.image.__cubeMapInitialized&&p.image.loadCount==6){p.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube);
- c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(D=0;D<6;++D)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,p.image[D]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);p.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+
- h);c.bindTexture(c.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube)}}else{p=p;h=h;if(!p.__webGLTexture&&p.image.loaded){p.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,p.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,p.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,f(p.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,f(p.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,f(p.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,f(p.min_filter));
- c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+h);c.bindTexture(c.TEXTURE_2D,p.__webGLTexture)}}}G=x.attributes;c.bindBuffer(c.ARRAY_BUFFER,A.__webGLVertexBuffer);c.vertexAttribPointer(G.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(G.position);if(G.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,A.__webGLNormalBuffer);c.vertexAttribPointer(G.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(G.normal)}if(G.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,A.__webGLTangentBuffer);
- c.vertexAttribPointer(G.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(G.tangent)}if(G.uv>=0)if(A.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,A.__webGLUVBuffer);c.vertexAttribPointer(G.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(G.uv)}else c.disableVertexAttribArray(G.uv);if(q.wireframe||q instanceof THREE.LineBasicMaterial){G=q.wireframe_linewidth!==undefined?q.wireframe_linewidth:q.linewidth!==undefined?q.linewidth:1;q=q instanceof THREE.LineBasicMaterial&&N.type==THREE.LineStrip?
- c.LINE_STRIP:c.LINES;c.lineWidth(G);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.__webGLLineBuffer);c.drawElements(q,A.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,A.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(h,p,C,q,A,N,x){var D,G,E,z,I;E=0;for(z=q.materials.length;E<z;E++){D=q.materials[E];if(D instanceof THREE.MeshFaceMaterial){D=0;for(G=A.materials.length;D<G;D++)if((I=A.materials[D])&&I.blending==N&&
- I.opacity<1==x){this.setBlending(I.blending);this.renderBuffer(h,p,C,I,A,q)}}else if((I=D)&&I.blending==N&&I.opacity<1==x){this.setBlending(I.blending);this.renderBuffer(h,p,C,I,A,q)}}};this.render=function(h,p,C,q){var A,N,x,D=h.lights,G=h.fog;this.initWebGLObjects(h);q=q!==undefined?q:true;if(C&&!C.__webGLFramebuffer){C.__webGLFramebuffer=c.createFramebuffer();C.__webGLRenderbuffer=c.createRenderbuffer();C.__webGLTexture=c.createTexture();c.bindRenderbuffer(c.RENDERBUFFER,C.__webGLRenderbuffer);
- c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,C.width,C.height);c.bindTexture(c.TEXTURE_2D,C.__webGLTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,f(C.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,f(C.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,f(C.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,f(C.min_filter));c.texImage2D(c.TEXTURE_2D,0,f(C.format),C.width,C.height,0,f(C.format),f(C.type),null);c.bindFramebuffer(c.FRAMEBUFFER,C.__webGLFramebuffer);
- c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,C.__webGLTexture,0);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,C.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}if(C){A=C.__webGLFramebuffer;x=C.width;N=C.height}else{A=null;x=j.width;N=j.height}if(A!=l){c.bindFramebuffer(c.FRAMEBUFFER,A);c.viewport(0,0,x,N);q&&c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT);l=A}this.autoClear&&
- this.clear();p.autoUpdateMatrix&&p.updateMatrix();o.set(p.matrix.flatten());v.set(p.projectionMatrix.flatten());q=0;for(A=h.__webGLObjects.length;q<A;q++){N=h.__webGLObjects[q];x=N.object;N=N.buffer;if(x.visible){this.setupMatrices(x,p);this.renderPass(p,D,G,x,N,THREE.NormalBlending,false)}}q=0;for(A=h.__webGLObjects.length;q<A;q++){N=h.__webGLObjects[q];x=N.object;N=N.buffer;if(x.visible){this.setupMatrices(x,p);if(x.doubleSided)c.disable(c.CULL_FACE);else{c.enable(c.CULL_FACE);x.flipSided?c.frontFace(c.CW):
- c.frontFace(c.CCW)}this.renderPass(p,D,G,x,N,THREE.AdditiveBlending,false);this.renderPass(p,D,G,x,N,THREE.SubtractiveBlending,false);this.renderPass(p,D,G,x,N,THREE.AdditiveBlending,true);this.renderPass(p,D,G,x,N,THREE.SubtractiveBlending,true);this.renderPass(p,D,G,x,N,THREE.NormalBlending,true)}}if(C&&C.min_filter!==THREE.NearestFilter&&C.min_filter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,C.__webGLTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}};this.initWebGLObjects=
- function(h){function p(E,z,I,F){if(E[z]==undefined){h.__webGLObjects.push({buffer:I,object:F});E[z]=1}}var C,q,A,N,x,D,G;if(!h.__webGLObjects){h.__webGLObjects=[];h.__webGLObjectsMap={}}C=0;for(q=h.objects.length;C<q;C++){A=h.objects[C];x=A.geometry;if(h.__webGLObjectsMap[A.id]==undefined)h.__webGLObjectsMap[A.id]={};G=h.__webGLObjectsMap[A.id];if(A instanceof THREE.Mesh){for(N in x.geometryChunks){D=x.geometryChunks[N];if(!D.__webGLVertexBuffer){this.createMeshBuffers(D);this.initMeshBuffers(D,A);
- x.__dirtyVertices=true;x.__dirtyElements=true;x.__dirtyUvs=true;x.__dirtyNormals=true;x.__dirtyTangents=true}if(x.__dirtyVertices||x.__dirtyElements||x.__dirtyUvs)this.setMeshBuffers(D,A,c.DYNAMIC_DRAW,x.__dirtyVertices,x.__dirtyElements,x.__dirtyUvs,x.__dirtyNormals,x.__dirtyTangents);p(G,N,D,A)}x.__dirtyVertices=false;x.__dirtyElements=false;x.__dirtyUvs=false;x.__dirtyNormals=false;x.__dirtyTangents=false}else if(A instanceof THREE.Line){if(!x.__webGLVertexBuffer){this.createLineBuffers(x);this.initLineBuffers(x);
- x.__dirtyVertices=true;x.__dirtyElements=true}x.__dirtyVertices&&this.setLineBuffers(x,c.DYNAMIC_DRAW,x.__dirtyVertices,x.__dirtyElements);p(G,0,x,A);x.__dirtyVertices=false;x.__dirtyElements=false}else if(A instanceof THREE.ParticleSystem){x.__webGLVertexBuffer||this.createParticleBuffers(x);p(G,0,x,A)}}};this.removeObject=function(h,p){var C,q;for(C=h.__webGLObjects.length-1;C>=0;C--){q=h.__webGLObjects[C].object;p==q&&h.__webGLObjects.splice(C,1)}};this.setupMatrices=function(h,p){h.autoUpdateMatrix&&
- h.updateMatrix();n.multiply(p.matrix,h.matrix);u.set(n.flatten());B=THREE.Matrix4.makeInvert3x3(n).transpose();w.set(B.m);L.set(h.matrix.flatten())};this.loadMatrices=function(h){c.uniformMatrix4fv(h.uniforms.viewMatrix,false,o);c.uniformMatrix4fv(h.uniforms.modelViewMatrix,false,u);c.uniformMatrix4fv(h.uniforms.projectionMatrix,false,v);c.uniformMatrix3fv(h.uniforms.normalMatrix,false,w);c.uniformMatrix4fv(h.uniforms.objectMatrix,false,L)};this.loadCamera=function(h,p){c.uniform3f(h.uniforms.cameraPosition,
- p.position.x,p.position.y,p.position.z)};this.setBlending=function(h){switch(h){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(h,p){if(h){!p||p=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(h=="back")c.cullFace(c.BACK);else h=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);
- c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
- THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
- envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
- map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
- 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"};
- THREE.UniformsLib={common:{color:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,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:[]}}};
- 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 color;\nuniform float opacity;",THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",
- THREE.Snippets.map_fragment,"gl_FragColor = mColor * mapColor;",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:[THREE.Snippets.map_pars_vertex,THREE.Snippets.envmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.envmap_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragment_shader:["uniform vec3 color;\nuniform float opacity;\nvarying vec3 vLightWeighting;",
- THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",THREE.Snippets.map_fragment,"gl_FragColor = mColor * mapColor * 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.envmap_pars_vertex,
- THREE.Snippets.lights_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_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 color;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,THREE.Snippets.lights_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",THREE.Snippets.map_fragment,THREE.Snippets.lights_fragment,
- "gl_FragColor = mapColor * 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.envmap_pars_vertex,THREE.Snippets.lights_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_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")}};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,b){var d=b instanceof THREE.Mesh,e=a.vertices.length,g=d?b.geometry:b,f=a.vertices,j=g.vertices,c=a.faces,k=g.faces,l=a.uvs;g=g.uvs;d&&b.autoUpdateMatrix&&b.updateMatrix();for(var n=0,B=j.length;n<B;n++){var o=new THREE.Vertex(j[n].position.clone());d&&b.matrix.multiplyVector3(o.position);f.push(o)}n=0;for(B=k.length;n<B;n++){j=k[n];var u,v=j.vertexNormals;if(j instanceof THREE.Face3)u=new THREE.Face3(j.a+e,j.b+e,j.c+e);else if(j instanceof THREE.Face4)u=new THREE.Face4(j.a+
- e,j.b+e,j.c+e,j.d+e);u.centroid.copy(j.centroid);u.normal.copy(j.normal);d=0;for(f=v.length;d<f;d++){o=v[d];u.vertexNormals.push(o.clone())}u.materials=j.materials.slice();c.push(u)}n=0;for(B=g.length;n<B;n++){e=g[n];c=[];d=0;for(f=e.length;d<f;d++)c.push(new THREE.UV(e[d].u,e[d].v));l.push(c)}}},ImageUtils={loadTexture:function(a,b){var d=new Image;d.onload=function(){this.loaded=true};d.src=a;return new THREE.Texture(d,b)},loadArray:function(a){var b,d,e=[];b=e.loadCount=0;for(d=a.length;b<d;++b){e[b]=
- new Image;e[b].loaded=0;e[b].onload=function(){e.loadCount+=1;this.loaded=true};e[b].src=a[b]}return e}},SceneUtils={loadScene:function(a,b,d){var e,g,f,j,c,k,l,n,B,o,u,v,w,L,t,J,m,h,p,C,q,A,N,x,D;a=new Worker(a);D=new THREE.Loader;a.onmessage=function(G){function E(){for(f in I.objects)if(!F.objects[f]){B=I.objects[f];if(h=F.geometries[B.geometry]){x=[];for(i=0;i<B.materials.length;i++)x[i]=F.materials[B.materials[i]];v=B.position;r=B.rotation;s=B.scale;object=new THREE.Mesh(h,x);object.position.set(v[0],
- v[1],v[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=B.visible;F.scene.addObject(object);F.objects[f]=object}}}function z(V){return function(P){F.geometries[V]=P;E();T-=1;T==0&&d(F)}}var I=G.data,F={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}},T=0;for(e in I.geometries){n=I.geometries[e];if(n.type=="bin_mesh"||n.type=="ascii_mesh")T+=1}for(e in I.geometries){n=I.geometries[e];if(n.type=="cube"){h=new Cube(n.width,
- n.height,n.depth,n.segments_width,n.segments_height,null,n.flipped,n.sides);F.geometries[e]=h}else if(n.type=="plane"){h=new Plane(n.width,n.height,n.segments_width,n.segments_height);F.geometries[e]=h}else if(n.type=="sphere"){h=new Sphere(n.radius,n.segments_width,n.segments_height);F.geometries[e]=h}else if(n.type=="cylinder"){h=new Cylinder(n.numSegs,n.topRad,n.botRad,n.height,n.topOffset,n.botOffset);F.geometries[e]=h}else if(n.type=="torus"){h=new Torus(n.radius,n.tube,n.segmentsR,n.segmentsT);
- F.geometries[e]=h}else if(n.type=="icosahedron"){h=new Icosahedron(n.subdivisions);F.geometries[e]=h}else if(n.type=="bin_mesh")D.loadBinary({model:n.url,callback:z(e)});else n.type=="ascii_mesh"&&D.loadAscii({model:n.url,callback:z(e)})}for(l in I.textures){J=I.textures[l];if(J.url instanceof Array){N=ImageUtils.loadArray(J.url);A=new THREE.Texture(N)}else{A=ImageUtils.loadTexture(J.url);if(THREE[J.min_filter]!=undefined)A.min_filter=THREE[J.min_filter];if(THREE[J.mag_filter]!=undefined)A.mag_filter=
- THREE[J.mag_filter]}F.textures[l]=A}for(g in I.materials){o=I.materials[g];for(m in o.parameters)if(m=="env_map"||m=="map")o.parameters[m]=F.textures[o.parameters[m]];else if(m=="shading")o.parameters[m]=o.parameters[m]=="flat"?THREE.FlatShading:THREE.SmoothShading;p=new THREE[o.type](o.parameters);F.materials[g]=p}E();for(j in I.lights){u=I.lights[j];if(u.type=="directional"){v=u.direction;light=new THREE.DirectionalLight;light.position.set(v[0],v[1],v[2]);light.position.normalize()}else if(u.type==
- "point"){v=u.position;light=new THREE.PointLight;light.position.set(v[0],v[1],v[2])}w=u.color;light.color.setRGB(w[0],w[1],w[2]);F.scene.addLight(light);F.lights[j]=light}for(c in I.cameras){w=I.cameras[c];if(w.type=="perspective")C=new THREE.Camera(w.fov,w.aspect,w.near,w.far);else if(w.type=="ortho"){C=new THREE.Camera;C.projectionMatrix=THREE.Matrix4.makeOrtho(w.left,w.right,w.top,w.bottom,w.near,w.far)}v=w.position;L=w.target;C.position.set(v[0],v[1],v[2]);C.target.position.set(L[0],L[1],L[2]);
- F.cameras[c]=C}for(k in I.fogs){t=I.fogs[k];if(t.type=="linear")q=new THREE.Fog(0,t.near,t.far);else if(t.type=="exp2")q=new THREE.FogExp2(0,t.density);w=t.color;q.color.setRGB(w[0],w[1],w[2]);F.fogs[k]=q}F.currentCamera=F.cameras[I.defaults.camera];if(F.fogs&&I.defaults.fog)F.scene.fog=F.fogs[I.defaults.fog];w=I.defaults.bgcolor;F.bgColor=new THREE.Color;F.bgColor.setRGB(w[0],w[1],w[2]);F.bgColorAlpha=I.defaults.bgalpha;b(F)};a.postMessage(0)},addMesh:function(a,b,d,e,g,f,j,c,k,l){b=new THREE.Mesh(b,
- l);b.scale.x=b.scale.y=b.scale.z=d;b.position.x=e;b.position.y=g;b.position.z=f;b.rotation.x=j;b.rotation.y=c;b.rotation.z=k;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,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});b=new THREE.Mesh(new Cube(b,b,b,1,1,null,true),d);a.addObject(b);return b},addPanoramaCube:function(a,b,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])}));b=new THREE.Mesh(new Cube(b,b,b,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(b);return b},addPanoramaCubePlanes:function(a,b,d){var e=b/2;b=new Plane(b,b);var g=
- Math.PI/2,f=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));SceneUtils.addMesh(a,b,1,-e,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,b,1,e,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,b,1,0,e,0,g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));SceneUtils.addMesh(a,b,1,0,-e,0,-g,0,f,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(void) {\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}"},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}"}}},Cube=function(a,b,d,e,g,f,j,c){function k(w,L,t,J,m,h,p,C){var q,A,N=e||1,x=g||1,D=N+1,G=x+1,E=m/2,z=h/2;m=m/N;var I=h/x,F=l.vertices.length;if(w=="x"&&L=="y"||w=="y"&&L=="x")q="z";else if(w=="x"&&L=="z"||w=="z"&&L=="x")q="y";else if(w=="z"&&L=="y"||w=="y"&&L=="z")q="x";for(A=0;A<G;A++)for(h=0;h<D;h++){var T=new THREE.Vector3;
- T[w]=(h*m-E)*t;T[L]=(A*I-z)*J;T[q]=p;l.vertices.push(new THREE.Vertex(T))}for(A=0;A<x;A++)for(h=0;h<N;h++){l.faces.push(new THREE.Face4(h+D*A+F,h+D*(A+1)+F,h+1+D*(A+1)+F,h+1+D*A+F,null,C));l.uvs.push([new THREE.UV(h/N,A/x),new THREE.UV(h/N,(A+1)/x),new THREE.UV((h+1)/N,(A+1)/x),new THREE.UV((h+1)/N,A/x)])}}THREE.Geometry.call(this);var l=this,n=a/2,B=b/2,o=d/2;j=j?-1:1;if(f!==undefined)if(f instanceof Array)this.materials=f;else{this.materials=[];for(var u=0;u<6;u++)this.materials.push([f])}else this.materials=
- [];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(c!=undefined)for(var v in c)if(this.sides[v]!=undefined)this.sides[v]=c[v];this.sides.px&&k("z","y",1*j,-1,d,b,-n,this.materials[0]);this.sides.nx&&k("z","y",-1*j,-1,d,b,n,this.materials[1]);this.sides.py&&k("x","z",1*j,1,a,d,B,this.materials[2]);this.sides.ny&&k("x","z",1*j,-1,a,d,-B,this.materials[3]);this.sides.pz&&k("x","y",1*j,-1,a,b,o,this.materials[4]);this.sides.nz&&k("x","y",-1*j,-1,a,b,-o,this.materials[5]);(function(){for(var w=
- [],L=[],t=0,J=l.vertices.length;t<J;t++){for(var m=l.vertices[t],h=false,p=0,C=w.length;p<C;p++){var q=w[p];if(m.position.x==q.position.x&&m.position.y==q.position.y&&m.position.z==q.position.z){L[t]=p;h=true;break}}if(!h){L[t]=w.length;w.push(new THREE.Vertex(m.position.clone()))}}t=0;for(J=l.faces.length;t<J;t++){m=l.faces[t];m.a=L[m.a];m.b=L[m.b];m.c=L[m.c];m.d=L[m.d]}l.vertices=w})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;
- Cube.prototype.constructor=Cube;
- var Cylinder=function(a,b,d,e,g){function f(l,n,B){j.vertices.push(new THREE.Vertex(new THREE.Vector3(l,n,B)))}THREE.Geometry.call(this);var j=this,c=Math.PI,k;for(k=0;k<a;k++)f(Math.sin(2*c*k/a)*b,Math.cos(2*c*k/a)*b,0);for(k=0;k<a;k++)f(Math.sin(2*c*k/a)*d,Math.cos(2*c*k/a)*d,e);for(k=0;k<a;k++)j.faces.push(new THREE.Face4(k,k+a,a+(k+1)%a,(k+1)%a));if(d!=0){f(0,0,-g);for(k=a;k<a+a/2;k++)j.faces.push(new THREE.Face4(2*a,(2*k-2*a)%a,(2*k-2*a+1)%a,(2*k-2*a+2)%a))}if(b!=0){f(0,0,e+g);for(k=a+a/2;k<
- 2*a;k++)j.faces.push(new THREE.Face4((2*k-2*a+2)%a+a,(2*k-2*a+1)%a+a,(2*k-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,b,d,e){THREE.Geometry.call(this);var g,f=a/2,j=b/2;d=d||1;e=e||1;var c=d+1,k=e+1;a=a/d;var l=b/e;for(g=0;g<k;g++)for(b=0;b<c;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-f,-(g*l-j),0)));for(g=0;g<e;g++)for(b=0;b<d;b++){this.faces.push(new THREE.Face4(b+c*g,b+c*(g+1),b+1+c*(g+1),b+1+c*g));this.uvs.push([new THREE.UV(b/d,g/e),new THREE.UV(b/d,(g+1)/e),new THREE.UV((b+1)/d,(g+1)/e),new THREE.UV((b+1)/d,g/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
- Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
- var Sphere=function(a,b,d){THREE.Geometry.call(this);var e,g=Math.PI,f=Math.max(3,b||8),j=Math.max(2,d||6);b=[];for(d=0;d<j+1;d++){e=d/j;var c=a*Math.cos(e*g),k=a*Math.sin(e*g),l=[],n=0;for(e=0;e<f;e++){var B=2*e/f,o=k*Math.sin(B*g);B=k*Math.cos(B*g);(d==0||d==j)&&e>0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(B,c,o)))-1);l.push(n)}b.push(l)}var u,v,w;g=b.length;for(d=0;d<g;d++){f=b[d].length;if(d>0)for(e=0;e<f;e++){l=e==f-1;j=b[d][l?0:e+1];c=b[d][l?f-1:e];k=b[d-1][l?f-1:e];l=b[d-1][l?
- 0:e+1];o=d/(g-1);u=(d-1)/(g-1);v=(e+1)/f;B=e/f;n=new THREE.UV(1-v,o);o=new THREE.UV(1-B,o);B=new THREE.UV(1-B,u);var L=new THREE.UV(1-v,u);if(d<b.length-1){u=this.vertices[j].position.clone();v=this.vertices[c].position.clone();w=this.vertices[k].position.clone();u.normalize();v.normalize();w.normalize();this.faces.push(new THREE.Face3(j,c,k,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(w.x,w.y,w.z)]));this.uvs.push([n,o,B])}if(d>1){u=this.vertices[j].position.clone();
- v=this.vertices[k].position.clone();w=this.vertices[l].position.clone();u.normalize();v.normalize();w.normalize();this.faces.push(new THREE.Face3(j,k,l,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(w.x,w.y,w.z)]));this.uvs.push([n,B,L])}}}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,b,d,e){this.radius=a||100;this.tube=b||40;this.segmentsR=d||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(d=0;d<=this.segmentsT;++d){e=d/this.segmentsT*2*Math.PI;var g=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(e),(this.radius+this.tube*Math.cos(g))*Math.sin(e),this.tube*Math.sin(g))));a.push([d/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(d=
- 1;d<=this.segmentsT;++d){e=(this.segmentsT+1)*b+d;g=(this.segmentsT+1)*b+d-1;var f=(this.segmentsT+1)*(b-1)+d-1,j=(this.segmentsT+1)*(b-1)+d;this.faces.push(new THREE.Face4(e,g,f,j));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[j][0],a[j][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 b(B,o,u){var v=Math.sqrt(B*B+o*o+u*u);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(B/v,o/v,u/v)))-1}function d(B,o,u,v){v.faces.push(new THREE.Face3(B,o,u))}function e(B,o){var u=g.vertices[B].position,v=g.vertices[o].position;return b((u.x+v.x)/2,(u.y+v.y)/2,(u.z+v.z)/2)}var g=this,f=new THREE.Geometry,j;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0,
- 1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);d(0,11,5,f);d(0,5,1,f);d(0,1,7,f);d(0,7,10,f);d(0,10,11,f);d(1,5,9,f);d(5,11,4,f);d(11,10,2,f);d(10,7,6,f);d(7,1,8,f);d(3,9,4,f);d(3,4,2,f);d(3,2,6,f);d(3,6,8,f);d(3,8,9,f);d(4,9,5,f);d(2,4,11,f);d(6,2,10,f);d(8,6,7,f);d(9,8,1,f);for(a=0;a<this.subdivisions;a++){j=new THREE.Geometry;for(var c in f.faces){var k=e(f.faces[c].a,f.faces[c].b),l=e(f.faces[c].b,f.faces[c].c),n=e(f.faces[c].c,f.faces[c].a);d(f.faces[c].a,k,n,j);d(f.faces[c].b,l,k,j);d(f.faces[c].c,
- n,l,j);d(k,l,n,j)}f.faces=j.faces}g.faces=f.faces;delete f;delete j;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
- function LathedObject(a,b,d){THREE.Geometry.call(this);b=b||12;d=d||2*Math.PI;b=d/b;for(var e=[],g=[],f=[],j=[],c=0;c<a.length;c++){this.vertices.push(new THREE.Vertex(a[c]));g[c]=this.vertices.length-1;e[c]=new THREE.Vector3(a[c].x,a[c].y,a[c].z)}for(var k=THREE.Matrix4.rotationZMatrix(b),l=0;l<=d+0.0010;l+=b){for(c=0;c<e.length;c++)if(l<d){e[c]=k.multiplyVector3(e[c].clone());this.vertices.push(new THREE.Vertex(e[c]));f[c]=this.vertices.length-1}else f=j;if(l==0)j=g;for(c=0;c<g.length-1;c++){this.faces.push(new THREE.Face4(f[c],
- f[c+1],g[c+1],g[c]));this.uvs.push([new THREE.UV(l/d,c/a.length),new THREE.UV(l/d,(c+1)/a.length),new THREE.UV((l-b)/d,(c+1)/a.length),new THREE.UV((l-b)/d,c/a.length)])}g=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;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 b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
- b},loadAsciiOld:function(a,b){var d=document.createElement("script");d.type="text/javascript";d.onload=b;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a){var b=a.model,d=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);b.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,d,e)};b.postMessage(a)},loadBinary:function(a){var b=a.model,d=a.callback,e=a.texture_path?a.texture_path:
- THREE.Loader.prototype.extractUrlbase(b),g=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers,j.data.materials,d,g,e,f)};b.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,d,e,g,f){var j=new XMLHttpRequest,c=e+"/"+a,k=0;
- j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.Loader.prototype.createBinModel(j.responseText,d,g,b):alert("Couldn't load ["+c+"] ["+j.status+"]");else if(j.readyState==3){if(f){if(k==0)k=j.getResponseHeader("Content-Length");f({total:k,loaded:j.responseText.length})}}else if(j.readyState==2)k=j.getResponseHeader("Content-Length")};j.open("GET",c,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)},
- createBinModel:function(a,b,d,e){var g=function(f){function j(y,M){var K=n(y,M),Z=n(y,M+1),ca=n(y,M+2),ga=n(y,M+3),ja=(ga<<1&255|ca>>7)-127;K=(ca&127)<<16|Z<<8|K;if(K==0&&ja==-127)return 0;return(1-2*(ga>>7))*(1+K*Math.pow(2,-23))*Math.pow(2,ja)}function c(y,M){var K=n(y,M),Z=n(y,M+1),ca=n(y,M+2);return(n(y,M+3)<<24)+(ca<<16)+(Z<<8)+K}function k(y,M){var K=n(y,M);return(n(y,M+1)<<8)+K}function l(y,M){var K=n(y,M);return K>127?K-256:K}function n(y,M){return y.charCodeAt(M)&255}function B(y){var M,
- K,Z;M=c(a,y);K=c(a,y+C);Z=c(a,y+q);y=k(a,y+A);THREE.Loader.prototype.f3(t,M,K,Z,y)}function o(y){var M,K,Z,ca,ga,ja;M=c(a,y);K=c(a,y+C);Z=c(a,y+q);ca=k(a,y+A);ga=c(a,y+N);ja=c(a,y+x);y=c(a,y+D);THREE.Loader.prototype.f3n(t,h,M,K,Z,ca,ga,ja,y)}function u(y){var M,K,Z,ca;M=c(a,y);K=c(a,y+G);Z=c(a,y+E);ca=c(a,y+z);y=k(a,y+I);THREE.Loader.prototype.f4(t,M,K,Z,ca,y)}function v(y){var M,K,Z,ca,ga,ja,qa,sa;M=c(a,y);K=c(a,y+G);Z=c(a,y+E);ca=c(a,y+z);ga=k(a,y+I);ja=c(a,y+F);qa=c(a,y+T);sa=c(a,y+V);y=c(a,y+
- P);THREE.Loader.prototype.f4n(t,h,M,K,Z,ca,ga,ja,qa,sa,y)}function w(y){var M,K;M=c(a,y);K=c(a,y+da);y=c(a,y+X);THREE.Loader.prototype.uv3(t,p[M*2],p[M*2+1],p[K*2],p[K*2+1],p[y*2],p[y*2+1])}function L(y){var M,K,Z;M=c(a,y);K=c(a,y+R);Z=c(a,y+U);y=c(a,y+ba);THREE.Loader.prototype.uv4(t,p[M*2],p[M*2+1],p[K*2],p[K*2+1],p[Z*2],p[Z*2+1],p[y*2],p[y*2+1])}var t=this,J=0,m,h=[],p=[],C,q,A,N,x,D,G,E,z,I,F,T,V,P,da,X,R,U,ba,Y,H,S,W,ia,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(t,e,f);
- m={signature:a.substr(J,8),header_bytes:n(a,J+8),vertex_coordinate_bytes:n(a,J+9),normal_coordinate_bytes:n(a,J+10),uv_coordinate_bytes:n(a,J+11),vertex_index_bytes:n(a,J+12),normal_index_bytes:n(a,J+13),uv_index_bytes:n(a,J+14),material_index_bytes:n(a,J+15),nvertices:c(a,J+16),nnormals:c(a,J+16+4),nuvs:c(a,J+16+8),ntri_flat:c(a,J+16+12),ntri_smooth:c(a,J+16+16),ntri_flat_uv:c(a,J+16+20),ntri_smooth_uv:c(a,J+16+24),nquad_flat:c(a,J+16+28),nquad_smooth:c(a,J+16+32),nquad_flat_uv:c(a,J+16+36),nquad_smooth_uv:c(a,
- J+16+40)};J+=m.header_bytes;C=m.vertex_index_bytes;q=m.vertex_index_bytes*2;A=m.vertex_index_bytes*3;N=m.vertex_index_bytes*3+m.material_index_bytes;x=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes;D=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*2;G=m.vertex_index_bytes;E=m.vertex_index_bytes*2;z=m.vertex_index_bytes*3;I=m.vertex_index_bytes*4;F=m.vertex_index_bytes*4+m.material_index_bytes;T=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes;
- V=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*2;P=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*3;da=m.uv_index_bytes;X=m.uv_index_bytes*2;R=m.uv_index_bytes;U=m.uv_index_bytes*2;ba=m.uv_index_bytes*3;f=m.vertex_index_bytes*3+m.material_index_bytes;ha=m.vertex_index_bytes*4+m.material_index_bytes;Y=m.ntri_flat*f;H=m.ntri_smooth*(f+m.normal_index_bytes*3);S=m.ntri_flat_uv*(f+m.uv_index_bytes*3);W=m.ntri_smooth_uv*(f+m.normal_index_bytes*3+m.uv_index_bytes*
- 3);ia=m.nquad_flat*ha;f=m.nquad_smooth*(ha+m.normal_index_bytes*4);ha=m.nquad_flat_uv*(ha+m.uv_index_bytes*4);J+=function(y){var M,K,Z,ca=m.vertex_coordinate_bytes*3,ga=y+m.nvertices*ca;for(y=y;y<ga;y+=ca){M=j(a,y);K=j(a,y+m.vertex_coordinate_bytes);Z=j(a,y+m.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(t,M,K,Z)}return m.nvertices*ca}(J);J+=function(y){var M,K,Z,ca=m.normal_coordinate_bytes*3,ga=y+m.nnormals*ca;for(y=y;y<ga;y+=ca){M=l(a,y);K=l(a,y+m.normal_coordinate_bytes);Z=l(a,y+m.normal_coordinate_bytes*
- 2);h.push(M/127,K/127,Z/127)}return m.nnormals*ca}(J);J+=function(y){var M,K,Z=m.uv_coordinate_bytes*2,ca=y+m.nuvs*Z;for(y=y;y<ca;y+=Z){M=j(a,y);K=j(a,y+m.uv_coordinate_bytes);p.push(M,K)}return m.nuvs*Z}(J);J=J;Y=J+Y;H=Y+H;S=H+S;W=S+W;ia=W+ia;f=ia+f;ha=f+ha;(function(y){var M,K=m.vertex_index_bytes*3+m.material_index_bytes,Z=K+m.uv_index_bytes*3,ca=y+m.ntri_flat_uv*Z;for(M=y;M<ca;M+=Z){B(M);w(M+K)}return ca-y})(H);(function(y){var M,K=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*
- 3,Z=K+m.uv_index_bytes*3,ca=y+m.ntri_smooth_uv*Z;for(M=y;M<ca;M+=Z){o(M);w(M+K)}return ca-y})(S);(function(y){var M,K=m.vertex_index_bytes*4+m.material_index_bytes,Z=K+m.uv_index_bytes*4,ca=y+m.nquad_flat_uv*Z;for(M=y;M<ca;M+=Z){u(M);L(M+K)}return ca-y})(f);(function(y){var M,K=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,Z=K+m.uv_index_bytes*4,ca=y+m.nquad_smooth_uv*Z;for(M=y;M<ca;M+=Z){v(M);L(M+K)}return ca-y})(ha);(function(y){var M,K=m.vertex_index_bytes*3+m.material_index_bytes,
- Z=y+m.ntri_flat*K;for(M=y;M<Z;M+=K)B(M);return Z-y})(J);(function(y){var M,K=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*3,Z=y+m.ntri_smooth*K;for(M=y;M<Z;M+=K)o(M);return Z-y})(Y);(function(y){var M,K=m.vertex_index_bytes*4+m.material_index_bytes,Z=y+m.nquad_flat*K;for(M=y;M<Z;M+=K)u(M);return Z-y})(W);(function(y){var M,K=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,Z=y+m.nquad_smooth*K;for(M=y;M<Z;M+=K)v(M);return Z-y})(ia);this.computeCentroids();
- this.computeFaceNormals();this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g(d))},createModel:function(a,b,d){var e=function(g){var f=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,a.materials,g);(function(){var j,c,k,l,n;j=0;for(c=a.vertices.length;j<c;j+=3){k=a.vertices[j];l=a.vertices[j+1];n=a.vertices[j+2];THREE.Loader.prototype.v(f,k,l,n)}})();(function(){function j(v,w){THREE.Loader.prototype.f3(f,v[w],v[w+1],v[w+2],v[w+3])}function c(v,
- w){THREE.Loader.prototype.f3n(f,a.normals,v[w],v[w+1],v[w+2],v[w+3],v[w+4],v[w+5],v[w+6])}function k(v,w){THREE.Loader.prototype.f4(f,v[w],v[w+1],v[w+2],v[w+3],v[w+4])}function l(v,w){THREE.Loader.prototype.f4n(f,a.normals,v[w],v[w+1],v[w+2],v[w+3],v[w+4],v[w+5],v[w+6],v[w+7],v[w+8])}function n(v,w){var L,t,J;L=v[w];t=v[w+1];J=v[w+2];THREE.Loader.prototype.uv3(f,a.uvs[L*2],a.uvs[L*2+1],a.uvs[t*2],a.uvs[t*2+1],a.uvs[J*2],a.uvs[J*2+1])}function B(v,w){var L,t,J,m;L=v[w];t=v[w+1];J=v[w+2];m=v[w+3];THREE.Loader.prototype.uv4(f,
- a.uvs[L*2],a.uvs[L*2+1],a.uvs[t*2],a.uvs[t*2+1],a.uvs[J*2],a.uvs[J*2+1],a.uvs[m*2],a.uvs[m*2+1])}var o,u;o=0;for(u=a.triangles_uv.length;o<u;o+=7){j(a.triangles_uv,o);n(a.triangles_uv,o+4)}o=0;for(u=a.triangles_n_uv.length;o<u;o+=10){c(a.triangles_n_uv,o);n(a.triangles_n_uv,o+7)}o=0;for(u=a.quads_uv.length;o<u;o+=9){k(a.quads_uv,o);B(a.quads_uv,o+5)}o=0;for(u=a.quads_n_uv.length;o<u;o+=13){l(a.quads_n_uv,o);B(a.quads_n_uv,o+9)}o=0;for(u=a.triangles.length;o<u;o+=4)j(a.triangles,o);o=0;for(u=a.triangles_n.length;o<
- u;o+=7)c(a.triangles_n,o);o=0;for(u=a.quads.length;o<u;o+=5)k(a.quads,o);o=0;for(u=a.quads_n.length;o<u;o+=9)l(a.quads_n,o)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(d))},v:function(a,b,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,d,e)))},f3:function(a,b,d,e,g){a.faces.push(new THREE.Face3(b,d,e,null,a.materials[g]))},f4:function(a,b,d,e,g,f){a.faces.push(new THREE.Face4(b,d,e,g,null,
- a.materials[f]))},f3n:function(a,b,d,e,g,f,j,c,k){f=a.materials[f];var l=b[c*3],n=b[c*3+1];c=b[c*3+2];var B=b[k*3],o=b[k*3+1];k=b[k*3+2];a.faces.push(new THREE.Face3(d,e,g,[new THREE.Vector3(b[j*3],b[j*3+1],b[j*3+2]),new THREE.Vector3(l,n,c),new THREE.Vector3(B,o,k)],f))},f4n:function(a,b,d,e,g,f,j,c,k,l,n){j=a.materials[j];var B=b[k*3],o=b[k*3+1];k=b[k*3+2];var u=b[l*3],v=b[l*3+1];l=b[l*3+2];var w=b[n*3],L=b[n*3+1];n=b[n*3+2];a.faces.push(new THREE.Face4(d,e,g,f,[new THREE.Vector3(b[c*3],b[c*3+1],
- b[c*3+2]),new THREE.Vector3(B,o,k),new THREE.Vector3(u,v,l),new THREE.Vector3(w,L,n)],j))},uv3:function(a,b,d,e,g,f,j){var c=[];c.push(new THREE.UV(b,d));c.push(new THREE.UV(e,g));c.push(new THREE.UV(f,j));a.uvs.push(c)},uv4:function(a,b,d,e,g,f,j,c,k){var l=[];l.push(new THREE.UV(b,d));l.push(new THREE.UV(e,g));l.push(new THREE.UV(f,j));l.push(new THREE.UV(c,k));a.uvs.push(l)},init_materials:function(a,b,d){a.materials=[];for(var e=0;e<b.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(b[e],
- d)]},createMaterial:function(a,b){function d(f){f=Math.log(f)/Math.LN2;return Math.floor(f)==f}var e,g;if(a.map_diffuse&&b){g=document.createElement("canvas");e=new THREE.MeshLambertMaterial({map:new THREE.Texture(g)});g=new Image;g.onload=function(){if(!d(this.width)||!d(this.height)){var f=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),j=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));e.map.image.width=f;e.map.image.height=j;e.map.image.getContext("2d").drawImage(this,0,0,f,j)}else e.map.image=
- this;e.map.image.loaded=1};g.src=b+"/"+a.map_diffuse}else if(a.col_diffuse){g=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;e=new THREE.MeshLambertMaterial({color:g,opacity:a.transparency})}else e=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):new THREE.MeshLambertMaterial({color:15658734});return e},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
|