| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- // ThreeExtras.js r31 - 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,e){this.r=a;this.g=b;this.b=e;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+
- ","+~~(this.g*255)+","+~~(this.b*255)+")"},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,e){this.x=a||0;this.y=b||0;this.z=e||0};
- THREE.Vector3.prototype={set:function(a,b,e){this.x=a;this.y=b;this.z=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,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,e=this.y,d=this.z;this.x=e*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-e*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},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,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+e*e+a*a)},distanceToSquared:function(a){var b=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return b*b+e*e+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;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,e,d){this.x=a||0;this.y=b||0;this.z=e||0;this.w=d||1};
- THREE.Vector4.prototype={set:function(a,b,e,d){this.x=a;this.y=b;this.z=e;this.w=d;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,e,d=a.objects,f=[];a=0;for(b=d.length;a<b;a++){e=d[a];if(e instanceof THREE.Mesh)f=f.concat(this.intersectObject(e))}f.sort(function(g,l){return g.distance-l.distance});return f},intersectObject:function(a){function b(L,w,E,m){m=m.clone().subSelf(w);E=E.clone().subSelf(w);var N=L.clone().subSelf(w);L=m.dot(m);w=m.dot(E);m=m.dot(N);var i=E.dot(E);E=E.dot(N);N=1/(L*i-w*w);i=(i*m-w*E)*N;L=(L*E-w*m)*N;return i>0&&L>0&&i+L<1}var e,d,f,g,l,h,k,c,v,y,
- q,t=a.geometry,x=t.vertices,A=[];e=0;for(d=t.faces.length;e<d;e++){f=t.faces[e];y=this.origin.clone();q=this.direction.clone();g=a.matrix.multiplyVector3(x[f.a].position.clone());l=a.matrix.multiplyVector3(x[f.b].position.clone());h=a.matrix.multiplyVector3(x[f.c].position.clone());k=f instanceof THREE.Face4?a.matrix.multiplyVector3(x[f.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(f.normal.clone());v=q.dot(c);if(v<0){c=c.dot((new THREE.Vector3).sub(g,y))/v;y=y.addSelf(q.multiplyScalar(c));
- if(f instanceof THREE.Face3){if(b(y,g,l,h)){f={distance:this.origin.distanceTo(y),point:y,face:f,object:a};A.push(f)}}else if(f instanceof THREE.Face4)if(b(y,g,l,k)||b(y,l,h,k)){f={distance:this.origin.distanceTo(y),point:y,face:f,object:a};A.push(f)}}}return A}};
- THREE.Rectangle=function(){function a(){g=d-b;l=f-e}var b,e,d,f,g,l,h=true;this.getX=function(){return b};this.getY=function(){return e};this.getWidth=function(){return g};this.getHeight=function(){return l};this.getLeft=function(){return b};this.getTop=function(){return e};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(k,c,v,y){h=false;b=k;e=c;d=v;f=y;a()};this.addPoint=function(k,c){if(h){h=false;b=k;e=c;d=k;f=c}else{b=b<k?b:k;e=e<c?e:c;d=d>k?d:k;f=f>c?
- f:c}a()};this.add3Points=function(k,c,v,y,q,t){if(h){h=false;b=k<v?k<q?k:q:v<q?v:q;e=c<y?c<t?c:t:y<t?y:t;d=k>v?k>q?k:q:v>q?v:q;f=c>y?c>t?c:t:y>t?y:t}else{b=k<v?k<q?k<b?k:b:q<b?q:b:v<q?v<b?v:b:q<b?q:b;e=c<y?c<t?c<e?c:e:t<e?t:e:y<t?y<e?y:e:t<e?t:e;d=k>v?k>q?k>d?k:d:q>d?q:d:v>q?v>d?v:d:q>d?q:d;f=c>y?c>t?c>f?c:f:t>f?t:f:y>t?y>f?y:f:t>f?t:f}a()};this.addRectangle=function(k){if(h){h=false;b=k.getLeft();e=k.getTop();d=k.getRight();f=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();e=e<k.getTop()?e:k.getTop();
- d=d>k.getRight()?d:k.getRight();f=f>k.getBottom()?f:k.getBottom()}a()};this.inflate=function(k){b-=k;e-=k;d+=k;f+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();e=e>k.getTop()?e:k.getTop();d=d<k.getRight()?d:k.getRight();f=f<k.getBottom()?f:k.getBottom();a()};this.instersects=function(k){return Math.min(d,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(f,k.getBottom())-Math.max(e,k.getTop())>=0};this.empty=function(){h=true;f=d=e=b=0;a()};this.isEmpty=function(){return h};this.toString=
- function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+e+", bottom: "+f+", width: "+g+", height: "+l+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
- THREE.Matrix4=function(a,b,e,d,f,g,l,h,k,c,v,y,q,t,x,A){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=d||0;this.n21=f||0;this.n22=g||1;this.n23=l||0;this.n24=h||0;this.n31=k||0;this.n32=c||0;this.n33=v||1;this.n34=y||0;this.n41=q||0;this.n42=t||0;this.n43=x||0;this.n44=A||1};
- THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,e,d,f,g,l,h,k,c,v,y,q,t,x,A){this.n11=a;this.n12=b;this.n13=e;this.n14=d;this.n21=f;this.n22=g;this.n23=l;this.n24=h;this.n31=k;this.n32=c;this.n33=v;this.n34=y;this.n41=q;this.n42=t;this.n43=x;this.n44=A;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,e){var d=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3;g.sub(a,b).normalize();d.cross(e,g).normalize();f.cross(g,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);this.n31=g.x;
- this.n32=g.y;this.n33=g.z;this.n34=-g.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,e=a.y,d=a.z,f=1/(this.n41*b+this.n42*e+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*e+this.n13*d+this.n14)*f;a.y=(this.n21*b+this.n22*e+this.n23*d+this.n24)*f;a.z=(this.n31*b+this.n32*e+this.n33*d+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,e=a.y,d=a.z,f=a.w;a.x=this.n11*b+this.n12*e+this.n13*d+this.n14*f;a.y=this.n21*b+this.n22*e+this.n23*d+this.n24*
- f;a.z=this.n31*b+this.n32*e+this.n33*d+this.n34*f;a.w=this.n41*b+this.n42*e+this.n43*d+this.n44*f;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 e=a.n11,d=a.n12,f=a.n13,g=a.n14,l=a.n21,h=a.n22,k=a.n23,c=a.n24,v=a.n31,y=a.n32,
- q=a.n33,t=a.n34,x=a.n41,A=a.n42,L=a.n43,w=a.n44,E=b.n11,m=b.n12,N=b.n13,i=b.n14,r=b.n21,j=b.n22,u=b.n23,p=b.n24,n=b.n31,G=b.n32,z=b.n33,C=b.n34,B=b.n41,K=b.n42,T=b.n43,H=b.n44;this.n11=e*E+d*r+f*n+g*B;this.n12=e*m+d*j+f*G+g*K;this.n13=e*N+d*u+f*z+g*T;this.n14=e*i+d*p+f*C+g*H;this.n21=l*E+h*r+k*n+c*B;this.n22=l*m+h*j+k*G+c*K;this.n23=l*N+h*u+k*z+c*T;this.n24=l*i+h*p+k*C+c*H;this.n31=v*E+y*r+q*n+t*B;this.n32=v*m+y*j+q*G+t*K;this.n33=v*N+y*u+q*z+t*T;this.n34=v*i+y*p+q*C+t*H;this.n41=x*E+A*r+L*n+w*B;
- this.n42=x*m+A*j+L*G+w*K;this.n43=x*N+A*u+L*z+w*T;this.n44=x*i+A*p+L*C+w*H;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,d=this.n13,f=this.n14,g=this.n21,l=this.n22,h=this.n23,k=this.n24,c=this.n31,v=this.n32,y=this.n33,q=this.n34,t=this.n41,x=this.n42,A=this.n43,L=this.n44,w=a.n11,E=a.n21,m=a.n31,N=a.n41,i=a.n12,r=a.n22,j=a.n32,u=a.n42,p=a.n13,n=a.n23,G=a.n33,z=a.n43,C=a.n14,B=a.n24,K=a.n34;a=a.n44;this.n11=b*w+e*E+d*m+f*N;this.n12=b*i+e*r+d*j+f*u;this.n13=b*p+e*n+d*G+f*z;this.n14=
- b*C+e*B+d*K+f*a;this.n21=g*w+l*E+h*m+k*N;this.n22=g*i+l*r+h*j+k*u;this.n23=g*p+l*n+h*G+k*z;this.n24=g*C+l*B+h*K+k*a;this.n31=c*w+v*E+y*m+q*N;this.n32=c*i+v*r+y*j+q*u;this.n33=c*p+v*n+y*G+q*z;this.n34=c*C+v*B+y*K+q*a;this.n41=t*w+x*E+A*m+L*N;this.n42=t*i+x*r+A*j+L*u;this.n43=t*p+x*n+A*G+L*z;this.n44=t*C+x*B+A*K+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(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*
- this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,e,d){var f=b[e];b[e]=b[d];
- b[d]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
- this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,e){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=e;return d};
- THREE.Matrix4.scaleMatrix=function(a,b,e){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=e;return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b};
- THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var e=new THREE.Matrix4,d=Math.cos(b),f=Math.sin(b),g=1-d,l=a.x,h=a.y,k=a.z;e.n11=g*l*l+d;e.n12=g*l*h-f*k;e.n13=g*l*k+f*h;e.n21=g*l*h+f*k;e.n22=g*h*h+d;e.n23=g*h*k-f*l;e.n31=g*l*k-f*h;e.n32=g*h*k+f*l;e.n33=g*k*k+d;return e};
- THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
- a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
- a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
- a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b};
- THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var e=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],f=b[6]*b[1]-b[2]*b[5],g=-b[10]*b[4]+b[6]*b[8],l=b[10]*b[0]-b[2]*b[8],h=-b[6]*b[0]+b[2]*b[4],k=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],v=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*g+b[2]*k;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*e;a.m[1]=b*d;a.m[2]=b*f;a.m[3]=b*g;a.m[4]=b*l;a.m[5]=b*h;a.m[6]=b*k;a.m[7]=b*c;a.m[8]=b*v;return a};
- THREE.Matrix4.makeFrustum=function(a,b,e,d,f,g){var l,h,k;l=new THREE.Matrix4;h=2*f/(b-a);k=2*f/(d-e);a=(b+a)/(b-a);e=(d+e)/(d-e);d=-(g+f)/(g-f);f=-2*g*f/(g-f);l.n11=h;l.n12=0;l.n13=a;l.n14=0;l.n21=0;l.n22=k;l.n23=e;l.n24=0;l.n31=0;l.n32=0;l.n33=d;l.n34=f;l.n41=0;l.n42=0;l.n43=-1;l.n44=0;return l};THREE.Matrix4.makePerspective=function(a,b,e,d){var f;a=e*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,e,d)};
- THREE.Matrix4.makeOrtho=function(a,b,e,d,f,g){var l,h,k,c;l=new THREE.Matrix4;h=b-a;k=e-d;c=g-f;a=(b+a)/h;e=(e+d)/k;f=(g+f)/c;l.n11=2/h;l.n12=0;l.n13=0;l.n14=-a;l.n21=0;l.n22=2/k;l.n23=0;l.n24=-e;l.n31=0;l.n32=0;l.n33=-2/c;l.n34=-f;l.n41=0;l.n42=0;l.n43=0;l.n44=1;return l};
- 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,e,d,f){this.a=a;this.b=b;this.c=e;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.material=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
- THREE.Face4=function(a,b,e,d,f,g){this.a=a;this.b=b;this.c=e;this.d=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.material=g instanceof Array?g:[g]};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,e;a=0;for(b=this.faces.length;a<b;a++){e=this.faces[a];e.centroid.set(0,0,0);if(e instanceof THREE.Face3){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);e.centroid.divideScalar(3)}else if(e instanceof THREE.Face4){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);
- e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,e,d,f,g,l,h=new THREE.Vector3,k=new THREE.Vector3;d=0;for(f=this.vertices.length;d<f;d++){g=this.vertices[d];g.normal.set(0,0,0)}d=0;for(f=this.faces.length;d<f;d++){g=this.faces[d];if(a&&g.vertexNormals.length){h.set(0,0,0);b=0;for(e=g.normal.length;b<e;b++)h.addSelf(g.vertexNormals[b]);h.divideScalar(3)}else{b=this.vertices[g.a];e=this.vertices[g.b];l=this.vertices[g.c];h.sub(l.position,
- e.position);k.sub(b.position,e.position);h.crossSelf(k)}h.isZero()||h.normalize();g.normal.copy(h)}},computeVertexNormals:function(){var a,b=[],e,d;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(e=this.faces.length;a<e;a++){d=this.faces[a];if(d instanceof THREE.Face3){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal);b[d.d].addSelf(d.normal)}}a=
- 0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(e=this.faces.length;a<e;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone()}else if(d instanceof THREE.Face4){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone();d.vertexNormals[3]=b[d.d].clone()}}},computeTangents:function(){function a(C,B,K,T){g=C.vertices[B].position;l=C.vertices[K].position;
- h=C.vertices[T].position;k=f[0];c=f[1];v=f[2];y=l.x-g.x;q=h.x-g.x;t=l.y-g.y;x=h.y-g.y;A=l.z-g.z;L=h.z-g.z;w=c.u-k.u;E=v.u-k.u;m=c.v-k.v;N=v.v-k.v;i=1/(w*N-E*m);p.set((N*y-m*q)*i,(N*t-m*x)*i,(N*A-m*L)*i);n.set((w*q-E*y)*i,(w*x-E*t)*i,(w*L-E*A)*i);j[B].addSelf(p);j[K].addSelf(p);j[T].addSelf(p);u[B].addSelf(n);u[K].addSelf(n);u[T].addSelf(n)}var b,e,d,f,g,l,h,k,c,v,y,q,t,x,A,L,w,E,m,N,i,r,j=[],u=[],p=new THREE.Vector3,n=new THREE.Vector3,G=new THREE.Vector3,z=new THREE.Vector3;r=new THREE.Vector3;b=
- 0;for(e=this.vertices.length;b<e;b++){j[b]=new THREE.Vector3;u[b]=new THREE.Vector3}b=0;for(e=this.faces.length;b<e;b++){d=this.faces[b];f=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);
- this.vertices[d.c].normal.copy(d.vertexNormals[2]);this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(e=this.vertices.length;b<e;b++){r.copy(this.vertices[b].normal);d=j[b];G.copy(d);G.subSelf(r.multiplyScalar(r.dot(d))).normalize();z.cross(this.vertices[b].normal,d);test=z.dot(u[b]);d=test<0?-1:1;this.vertices[b].tangent.set(G.x,G.y,G.z,d)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.bbox={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,e=this.vertices.length;b<e;b++){a=this.vertices[b];if(a.position.x<this.bbox.x[0])this.bbox.x[0]=a.position.x;else if(a.position.x>this.bbox.x[1])this.bbox.x[1]=a.position.x;if(a.position.y<this.bbox.y[0])this.bbox.y[0]=a.position.y;else if(a.position.y>this.bbox.y[1])this.bbox.y[1]=a.position.y;if(a.position.z<this.bbox.z[0])this.bbox.z[0]=a.position.z;else if(a.position.z>
- this.bbox.z[1])this.bbox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,e=this.vertices.length;b<e;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(v){var y=[];b=0;for(e=v.length;b<e;b++)v[b]==undefined?y.push("undefined"):y.push(v[b].toString());return y.join("_")}var b,e,d,f,g,l,h,k,c={};d=0;for(f=this.faces.length;d<f;d++){g=this.faces[d];l=
- g.material;h=a(l);if(c[h]==undefined)c[h]={hash:h,counter:0};k=c[h].hash+"_"+c[h].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],material:l,vertices:0};g=g instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+g>65535){c[h].counter+=1;k=c[h].hash+"_"+c[h].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],material:l,vertices:0}}this.geometryChunks[k].faces.push(d);this.geometryChunks[k].vertices+=g}},toString:function(){return"THREE.Geometry ( vertices: "+
- this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
- THREE.Camera=function(a,b,e,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,e,d);this.autoUpdateMatrix=true;this.translateX=function(f){f=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(f);f.cross(f.clone(),this.up);this.position.addSelf(f);this.target.position.addSelf(f)};this.translateZ=function(f){f=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(f);
- this.position.subSelf(f);this.target.position.subSelf(f)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.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.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
- THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);
- this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};
- THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b]};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.material=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}this.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.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.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}this.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.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.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}this.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.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.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}this.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.near=1;this.far=1E3;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.near!==undefined)this.near=a.near;if(a.far!==undefined)this.far=a.far;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=
- this.far-this.near;this.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}this.toString=function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){this.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}this.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}this.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}this.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;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
- THREE.Texture=function(a,b,e,d,f,g){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=f!==undefined?f:THREE.LinearFilter;this.min_filter=g!==undefined?g:THREE.LinearMipMapLinearFilter;this.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.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.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.Projector=function(){function a(j,u){return u.z-j.z}function b(j,u){var p=0,n=1,G=j.z+j.w,z=u.z+u.w,C=-j.z+j.w,B=-u.z+u.w;if(G>=0&&z>=0&&C>=0&&B>=0)return true;else if(G<0&&z<0||C<0&&B<0)return false;else{if(G<0)p=Math.max(p,G/(G-z));else if(z<0)n=Math.min(n,G/(G-z));if(C<0)p=Math.max(p,C/(C-B));else if(B<0)n=Math.min(n,C/(C-B));if(n<p)return false;else{j.lerpSelf(u,p);u.lerpSelf(j,1-n);return true}}}var e,d,f=[],g,l,h,k=[],c,v,y=[],q,t,x=[],A=new THREE.Vector4,L=new THREE.Vector4,w=new THREE.Matrix4,
- E=new THREE.Matrix4,m=[],N=new THREE.Vector4,i=new THREE.Vector4,r;this.projectObjects=function(j,u,p){var n=[],G,z;d=0;w.multiply(u.projectionMatrix,u.matrix);m[0]=new THREE.Vector4(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);m[1]=new THREE.Vector4(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);m[2]=new THREE.Vector4(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);m[3]=new THREE.Vector4(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);m[4]=new THREE.Vector4(w.n41-w.n31,w.n42-w.n32,w.n43-
- w.n33,w.n44-w.n34);m[5]=new THREE.Vector4(w.n41+w.n31,w.n42+w.n32,w.n43+w.n33,w.n44+w.n34);u=0;for(G=m.length;u<G;u++){z=m[u];z.divideScalar(Math.sqrt(z.x*z.x+z.y*z.y+z.z*z.z))}G=j.objects;j=0;for(u=G.length;j<u;j++){z=G[j];var C;if(!(C=!z.visible)){a:{C=void 0;for(var B=z.position,K=-z.geometry.boundingSphere.radius*Math.max(z.scale.x,Math.max(z.scale.y,z.scale.z)),T=0;T<6;T++){C=m[T].x*B.x+m[T].y*B.y+m[T].z*B.z+m[T].w;if(C<=K){C=false;break a}}C=true}C=!C}if(!C){e=f[d]=f[d]||new THREE.RenderableObject;
- A.copy(z.position);w.multiplyVector3(A);e.object=z;e.z=A.z;n.push(e);d++}}p&&n.sort(a);return n};this.projectScene=function(j,u,p){var n=[],G,z,C,B,K,T,H,R,$,U,W,I,D,P,o,s;h=v=t=0;u.autoUpdateMatrix&&u.updateMatrix();w.multiply(u.projectionMatrix,u.matrix);T=j.objects;j=0;for(G=T.length;j<G;j++){H=T[j];if(H.visible){H.autoUpdateMatrix&&H.updateMatrix();R=H.matrix;$=H.rotationMatrix;U=H.material;W=H.overdraw;if(H instanceof THREE.Mesh){I=H.geometry;D=I.vertices;z=0;for(C=D.length;z<C;z++){P=D[z];P.positionWorld.copy(P.position);
- R.multiplyVector3(P.positionWorld);B=P.positionScreen;B.copy(P.positionWorld);w.multiplyVector4(B);B.multiplyScalar(1/B.w);P.__visible=B.z>0&&B.z<1}I=I.faces;z=0;for(C=I.length;z<C;z++){P=I[z];if(P instanceof THREE.Face3){B=D[P.a];K=D[P.b];o=D[P.c];if(B.__visible&&K.__visible&&o.__visible)if(H.doubleSided||H.flipSided!=(o.positionScreen.x-B.positionScreen.x)*(K.positionScreen.y-B.positionScreen.y)-(o.positionScreen.y-B.positionScreen.y)*(K.positionScreen.x-B.positionScreen.x)<0){g=k[h]=k[h]||new THREE.RenderableFace3;
- g.v1.positionWorld.copy(B.positionWorld);g.v2.positionWorld.copy(K.positionWorld);g.v3.positionWorld.copy(o.positionWorld);g.v1.positionScreen.copy(B.positionScreen);g.v2.positionScreen.copy(K.positionScreen);g.v3.positionScreen.copy(o.positionScreen);g.normalWorld.copy(P.normal);$.multiplyVector3(g.normalWorld);g.centroidWorld.copy(P.centroid);R.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);w.multiplyVector3(g.centroidScreen);o=P.vertexNormals;r=g.vertexNormalsWorld;B=0;
- for(K=o.length;B<K;B++){s=r[B]=r[B]||new THREE.Vector3;s.copy(o[B]);$.multiplyVector3(s)}g.z=g.centroidScreen.z;g.meshMaterial=U;g.faceMaterial=P.material;g.overdraw=W;if(H.geometry.uvs[z]){g.uvs[0]=H.geometry.uvs[z][0];g.uvs[1]=H.geometry.uvs[z][1];g.uvs[2]=H.geometry.uvs[z][2]}n.push(g);h++}}else if(P instanceof THREE.Face4){B=D[P.a];K=D[P.b];o=D[P.c];s=D[P.d];if(B.__visible&&K.__visible&&o.__visible&&s.__visible)if(H.doubleSided||H.flipSided!=((s.positionScreen.x-B.positionScreen.x)*(K.positionScreen.y-
- B.positionScreen.y)-(s.positionScreen.y-B.positionScreen.y)*(K.positionScreen.x-B.positionScreen.x)<0||(K.positionScreen.x-o.positionScreen.x)*(s.positionScreen.y-o.positionScreen.y)-(K.positionScreen.y-o.positionScreen.y)*(s.positionScreen.x-o.positionScreen.x)<0)){g=k[h]=k[h]||new THREE.RenderableFace3;g.v1.positionWorld.copy(B.positionWorld);g.v2.positionWorld.copy(K.positionWorld);g.v3.positionWorld.copy(s.positionWorld);g.v1.positionScreen.copy(B.positionScreen);g.v2.positionScreen.copy(K.positionScreen);
- g.v3.positionScreen.copy(s.positionScreen);g.normalWorld.copy(P.normal);$.multiplyVector3(g.normalWorld);g.centroidWorld.copy(P.centroid);R.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);w.multiplyVector3(g.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterial=U;g.faceMaterial=P.material;g.overdraw=W;if(H.geometry.uvs[z]){g.uvs[0]=H.geometry.uvs[z][0];g.uvs[1]=H.geometry.uvs[z][1];g.uvs[2]=H.geometry.uvs[z][3]}n.push(g);h++;l=k[h]=k[h]||new THREE.RenderableFace3;l.v1.positionWorld.copy(K.positionWorld);
- l.v2.positionWorld.copy(o.positionWorld);l.v3.positionWorld.copy(s.positionWorld);l.v1.positionScreen.copy(K.positionScreen);l.v2.positionScreen.copy(o.positionScreen);l.v3.positionScreen.copy(s.positionScreen);l.normalWorld.copy(g.normalWorld);l.centroidWorld.copy(g.centroidWorld);l.centroidScreen.copy(g.centroidScreen);l.z=l.centroidScreen.z;l.meshMaterial=U;l.faceMaterial=P.material;l.overdraw=W;if(H.geometry.uvs[z]){l.uvs[0]=H.geometry.uvs[z][1];l.uvs[1]=H.geometry.uvs[z][2];l.uvs[2]=H.geometry.uvs[z][3]}n.push(l);
- h++}}}}else if(H instanceof THREE.Line){E.multiply(w,R);D=H.geometry.vertices;P=D[0];P.positionScreen.copy(P.position);E.multiplyVector4(P.positionScreen);z=1;for(C=D.length;z<C;z++){B=D[z];B.positionScreen.copy(B.position);E.multiplyVector4(B.positionScreen);K=D[z-1];N.copy(B.positionScreen);i.copy(K.positionScreen);if(b(N,i)){N.multiplyScalar(1/N.w);i.multiplyScalar(1/i.w);c=y[v]=y[v]||new THREE.RenderableLine;c.v1.positionScreen.copy(N);c.v2.positionScreen.copy(i);c.z=Math.max(N.z,i.z);c.material=
- H.material;n.push(c);v++}}}else if(H instanceof THREE.Particle){L.set(H.position.x,H.position.y,H.position.z,1);w.multiplyVector4(L);L.z/=L.w;if(L.z>0&&L.z<1){q=x[t]=x[t]||new THREE.RenderableParticle;q.x=L.x/L.w;q.y=L.y/L.w;q.z=L.z;q.rotation=H.rotation.z;q.scale.x=H.scale.x*Math.abs(q.x-(L.x+u.projectionMatrix.n11)/(L.w+u.projectionMatrix.n14));q.scale.y=H.scale.y*Math.abs(q.y-(L.y+u.projectionMatrix.n22)/(L.w+u.projectionMatrix.n24));q.material=H.material;n.push(q);t++}}}}p&&n.sort(a);return n};
- this.unprojectVector=function(j,u){var p=new THREE.Matrix4;p.multiply(THREE.Matrix4.makeInvert(u.matrix),THREE.Matrix4.makeInvert(u.projectionMatrix));p.multiplyVector3(j);return j}};
- THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,d,f,g;this.domElement=document.createElement("div");this.setSize=function(l,h){e=l;d=h;f=e/2;g=d/2};this.render=function(l,h){var k,c,v,y,q,t,x,A;a=b.projectScene(l,h);k=0;for(c=a.length;k<c;k++){q=a[k];if(q instanceof THREE.RenderableParticle){x=q.x*f+f;A=q.y*g+g;v=0;for(y=q.material.length;v<y;v++){t=q.material[v];if(t instanceof THREE.ParticleDOMMaterial){t=t.domElement;t.style.left=x+"px";t.style.top=A+"px"}}}}}};
- THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,e=document.createElement("canvas"),d,f,g,l,h=e.getContext("2d"),k=1,c=0,v=null,y=null,q=1,t,x,A,L,w,E,m,N,i,r=new THREE.Color,j=new THREE.Color,u=new THREE.Color,p=new THREE.Color,n=new THREE.Color,G,z,C,B,K,T,H,R,$,U,W=new THREE.Rectangle,I=new THREE.Rectangle,D=new THREE.Rectangle,P=false,o=new THREE.Color,s=new THREE.Color,F=new THREE.Color,O=new THREE.Color,X=Math.PI*2,Y=new THREE.Vector3,ea,ma,oa,fa,ra,va,pa=16;ea=document.createElement("canvas");
- ea.width=ea.height=2;ma=ea.getContext("2d");ma.fillStyle="rgba(0,0,0,1)";ma.fillRect(0,0,2,2);oa=ma.getImageData(0,0,2,2);fa=oa.data;ra=document.createElement("canvas");ra.width=ra.height=pa;va=ra.getContext("2d");va.translate(-pa/2,-pa/2);va.scale(pa,pa);pa--;this.domElement=e;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ia,wa){d=ia;f=wa;g=d/2;l=f/2;e.width=d;e.height=f;W.set(-g,-l,g,l)};this.clear=function(){if(!I.isEmpty()){I.inflate(1);I.minSelf(W);h.clearRect(I.getX(),
- I.getY(),I.getWidth(),I.getHeight());I.empty()}};this.render=function(ia,wa){function Ka(J){var V,S,M,Q=J.lights;s.setRGB(0,0,0);F.setRGB(0,0,0);O.setRGB(0,0,0);J=0;for(V=Q.length;J<V;J++){S=Q[J];M=S.color;if(S instanceof THREE.AmbientLight){s.r+=M.r;s.g+=M.g;s.b+=M.b}else if(S instanceof THREE.DirectionalLight){F.r+=M.r;F.g+=M.g;F.b+=M.b}else if(S instanceof THREE.PointLight){O.r+=M.r;O.g+=M.g;O.b+=M.b}}}function xa(J,V,S,M){var Q,Z,ba,ca,da=J.lights;J=0;for(Q=da.length;J<Q;J++){Z=da[J];ba=Z.color;
- ca=Z.intensity;if(Z instanceof THREE.DirectionalLight){Z=S.dot(Z.position)*ca;if(Z>0){M.r+=ba.r*Z;M.g+=ba.g*Z;M.b+=ba.b*Z}}else if(Z instanceof THREE.PointLight){Y.sub(Z.position,V);Y.normalize();Z=S.dot(Y)*ca;if(Z>0){M.r+=ba.r*Z;M.g+=ba.g*Z;M.b+=ba.b*Z}}}}function La(J,V,S){if(S.opacity!=0){Ca(S.opacity);ya(S.blending);var M,Q,Z,ba,ca,da;if(S instanceof THREE.ParticleBasicMaterial){if(S.map){ba=S.map;ca=ba.width>>1;da=ba.height>>1;Q=V.scale.x*g;Z=V.scale.y*l;S=Q*ca;M=Z*da;D.set(J.x-S,J.y-M,J.x+S,
- J.y+M);if(W.instersects(D)){h.save();h.translate(J.x,J.y);h.rotate(-V.rotation);h.scale(Q,-Z);h.translate(-ca,-da);h.drawImage(ba,0,0);h.restore()}}}else if(S instanceof THREE.ParticleCircleMaterial){if(P){o.r=s.r+F.r+O.r;o.g=s.g+F.g+O.g;o.b=s.b+F.b+O.b;r.r=S.color.r*o.r;r.g=S.color.g*o.g;r.b=S.color.b*o.b;r.updateStyleString()}else r.__styleString=S.color.__styleString;S=V.scale.x*g;M=V.scale.y*l;D.set(J.x-S,J.y-M,J.x+S,J.y+M);if(W.instersects(D)){Q=r.__styleString;if(y!=Q)h.fillStyle=y=Q;h.save();
- h.translate(J.x,J.y);h.rotate(-V.rotation);h.scale(S,M);h.beginPath();h.arc(0,0,1,0,X,true);h.closePath();h.fill();h.restore()}}}}function Ma(J,V,S,M){if(M.opacity!=0){Ca(M.opacity);ya(M.blending);h.beginPath();h.moveTo(J.positionScreen.x,J.positionScreen.y);h.lineTo(V.positionScreen.x,V.positionScreen.y);h.closePath();if(M instanceof THREE.LineBasicMaterial){r.__styleString=M.color.__styleString;J=M.linewidth;if(q!=J)h.lineWidth=q=J;J=r.__styleString;if(v!=J)h.strokeStyle=v=J;h.stroke();D.inflate(M.linewidth*
- 2)}}}function Ga(J,V,S,M,Q,Z){if(Q.opacity!=0){Ca(Q.opacity);ya(Q.blending);L=J.positionScreen.x;w=J.positionScreen.y;E=V.positionScreen.x;m=V.positionScreen.y;N=S.positionScreen.x;i=S.positionScreen.y;h.beginPath();h.moveTo(L,w);h.lineTo(E,m);h.lineTo(N,i);h.lineTo(L,w);h.closePath();if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&sa(L,w,E,m,N,i,Q.map.image,M.uvs[0].u,M.uvs[0].v,M.uvs[1].u,M.uvs[1].v,M.uvs[2].u,M.uvs[2].v);else if(Q.env_map){if(Q.env_map.image.loaded)if(Q.env_map.mapping instanceof
- THREE.SphericalReflectionMapping){J=wa.matrix;Y.copy(M.vertexNormalsWorld[0]);K=(Y.x*J.n11+Y.y*J.n12+Y.z*J.n13)*0.5+0.5;T=-(Y.x*J.n21+Y.y*J.n22+Y.z*J.n23)*0.5+0.5;Y.copy(M.vertexNormalsWorld[1]);H=(Y.x*J.n11+Y.y*J.n12+Y.z*J.n13)*0.5+0.5;R=-(Y.x*J.n21+Y.y*J.n22+Y.z*J.n23)*0.5+0.5;Y.copy(M.vertexNormalsWorld[2]);$=(Y.x*J.n11+Y.y*J.n12+Y.z*J.n13)*0.5+0.5;U=-(Y.x*J.n21+Y.y*J.n22+Y.z*J.n23)*0.5+0.5;sa(L,w,E,m,N,i,Q.env_map.image,K,T,H,R,$,U)}}else Q.wireframe?za(Q.color.__styleString,Q.wireframe_linewidth):
- Aa(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&!Q.wireframe){Q.map.mapping instanceof THREE.UVMapping&&sa(L,w,E,m,N,i,Q.map.image,M.uvs[0].u,M.uvs[0].v,M.uvs[1].u,M.uvs[1].v,M.uvs[2].u,M.uvs[2].v);ya(THREE.SubtractiveBlending)}if(P)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&M.vertexNormalsWorld.length==3){j.r=u.r=p.r=s.r;j.g=u.g=p.g=s.g;j.b=u.b=p.b=s.b;xa(Z,M.v1.positionWorld,M.vertexNormalsWorld[0],j);xa(Z,M.v2.positionWorld,M.vertexNormalsWorld[1],u);xa(Z,
- M.v3.positionWorld,M.vertexNormalsWorld[2],p);n.r=(u.r+p.r)*0.5;n.g=(u.g+p.g)*0.5;n.b=(u.b+p.b)*0.5;B=Ha(j,u,p,n);sa(L,w,E,m,N,i,B,0,0,1,0,0,1)}else{o.r=s.r;o.g=s.g;o.b=s.b;xa(Z,M.centroidWorld,M.normalWorld,o);r.r=Q.color.r*o.r;r.g=Q.color.g*o.g;r.b=Q.color.b*o.b;r.updateStyleString();Q.wireframe?za(r.__styleString,Q.wireframe_linewidth):Aa(r.__styleString)}else Q.wireframe?za(Q.color.__styleString,Q.wireframe_linewidth):Aa(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){G=Q.__2near;
- z=Q.__farPlusNear;C=Q.__farMinusNear;j.r=j.g=j.b=1-G/(z-J.positionScreen.z*C);u.r=u.g=u.b=1-G/(z-V.positionScreen.z*C);p.r=p.g=p.b=1-G/(z-S.positionScreen.z*C);n.r=(u.r+p.r)*0.5;n.g=(u.g+p.g)*0.5;n.b=(u.b+p.b)*0.5;B=Ha(j,u,p,n);sa(L,w,E,m,N,i,B,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){r.r=Da(M.normalWorld.x);r.g=Da(M.normalWorld.y);r.b=Da(M.normalWorld.z);r.updateStyleString();Q.wireframe?za(r.__styleString,Q.wireframe_linewidth):Aa(r.__styleString)}}}function za(J,V){if(v!=J)h.strokeStyle=
- v=J;if(q!=V)h.lineWidth=q=V;h.stroke();D.inflate(V*2)}function Aa(J){if(y!=J)h.fillStyle=y=J;h.fill()}function sa(J,V,S,M,Q,Z,ba,ca,da,ja,ga,ka,ta){var na,la;na=ba.width-1;la=ba.height-1;ca*=na;da*=la;ja*=na;ga*=la;ka*=na;ta*=la;S-=J;M-=V;Q-=J;Z-=V;ja-=ca;ga-=da;ka-=ca;ta-=da;la=1/(ja*ta-ka*ga);na=(ta*S-ga*Q)*la;ga=(ta*M-ga*Z)*la;S=(ja*Q-ka*S)*la;M=(ja*Z-ka*M)*la;J=J-na*ca-S*da;V=V-ga*ca-M*da;h.save();h.transform(na,ga,S,M,J,V);h.clip();h.drawImage(ba,0,0);h.restore()}function Ca(J){if(k!=J)h.globalAlpha=
- k=J}function ya(J){if(c!=J){switch(J){case THREE.NormalBlending:h.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:h.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:h.globalCompositeOperation="darker"}c=J}}function Ha(J,V,S,M){var Q=~~(J.r*255),Z=~~(J.g*255);J=~~(J.b*255);var ba=~~(V.r*255),ca=~~(V.g*255);V=~~(V.b*255);var da=~~(S.r*255),ja=~~(S.g*255);S=~~(S.b*255);var ga=~~(M.r*255),ka=~~(M.g*255);M=~~(M.b*255);fa[0]=Q<0?0:Q>255?255:Q;fa[1]=Z<0?0:
- Z>255?255:Z;fa[2]=J<0?0:J>255?255:J;fa[4]=ba<0?0:ba>255?255:ba;fa[5]=ca<0?0:ca>255?255:ca;fa[6]=V<0?0:V>255?255:V;fa[8]=da<0?0:da>255?255:da;fa[9]=ja<0?0:ja>255?255:ja;fa[10]=S<0?0:S>255?255:S;fa[12]=ga<0?0:ga>255?255:ga;fa[13]=ka<0?0:ka>255?255:ka;fa[14]=M<0?0:M>255?255:M;ma.putImageData(oa,0,0);va.drawImage(ea,0,0);return ra}function Da(J){J=(J+1)*0.5;return J<0?0:J>1?1:J}function Ea(J,V){var S=V.x-J.x,M=V.y-J.y,Q=1/Math.sqrt(S*S+M*M);S*=Q;M*=Q;V.x+=S;V.y+=M;J.x-=S;J.y-=M}var Ba,Ia,aa,ha,qa,Fa,
- Ja,ua;h.setTransform(1,0,0,-1,g,l);this.autoClear&&this.clear();a=b.projectScene(ia,wa,this.sortElements);(P=ia.lights.length>0)&&Ka(ia);Ba=0;for(Ia=a.length;Ba<Ia;Ba++){aa=a[Ba];D.empty();if(aa instanceof THREE.RenderableParticle){t=aa;t.x*=g;t.y*=l;ha=0;for(qa=aa.material.length;ha<qa;ha++)La(t,aa,aa.material[ha],ia)}else if(aa instanceof THREE.RenderableLine){t=aa.v1;x=aa.v2;t.positionScreen.x*=g;t.positionScreen.y*=l;x.positionScreen.x*=g;x.positionScreen.y*=l;D.addPoint(t.positionScreen.x,t.positionScreen.y);
- D.addPoint(x.positionScreen.x,x.positionScreen.y);if(W.instersects(D)){ha=0;for(qa=aa.material.length;ha<qa;)Ma(t,x,aa,aa.material[ha++],ia)}}else if(aa instanceof THREE.RenderableFace3){t=aa.v1;x=aa.v2;A=aa.v3;t.positionScreen.x*=g;t.positionScreen.y*=l;x.positionScreen.x*=g;x.positionScreen.y*=l;A.positionScreen.x*=g;A.positionScreen.y*=l;if(aa.overdraw){Ea(t.positionScreen,x.positionScreen);Ea(x.positionScreen,A.positionScreen);Ea(A.positionScreen,t.positionScreen)}D.add3Points(t.positionScreen.x,
- t.positionScreen.y,x.positionScreen.x,x.positionScreen.y,A.positionScreen.x,A.positionScreen.y);if(W.instersects(D)){ha=0;for(qa=aa.meshMaterial.length;ha<qa;){ua=aa.meshMaterial[ha++];if(ua instanceof THREE.MeshFaceMaterial){Fa=0;for(Ja=aa.faceMaterial.length;Fa<Ja;)(ua=aa.faceMaterial[Fa++])&&Ga(t,x,A,aa,ua,ia)}else Ga(t,x,A,aa,ua,ia)}}}I.addRectangle(D)}h.setTransform(1,0,0,1,0,0)}};
- THREE.SVGRenderer=function(){function a(R,$,U){var W,I,D,P;W=0;for(I=R.lights.length;W<I;W++){D=R.lights[W];if(D instanceof THREE.DirectionalLight){P=$.normalWorld.dot(D.position)*D.intensity;if(P>0){U.r+=D.color.r*P;U.g+=D.color.g*P;U.b+=D.color.b*P}}else if(D instanceof THREE.PointLight){p.sub(D.position,$.centroidWorld);p.normalize();P=$.normalWorld.dot(p)*D.intensity;if(P>0){U.r+=D.color.r*P;U.g+=D.color.g*P;U.b+=D.color.b*P}}}}function b(R,$,U,W,I,D){C=d(B++);C.setAttribute("d","M "+R.positionScreen.x+
- " "+R.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(I instanceof THREE.MeshBasicMaterial)m.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshLambertMaterial)if(E){N.r=i.r;N.g=i.g;N.b=i.b;a(D,W,N);m.r=I.color.r*N.r;m.g=I.color.g*N.g;m.b=I.color.b*N.b;m.updateStyleString()}else m.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshDepthMaterial){u=1-I.__2near/(I.__farPlusNear-W.z*I.__farMinusNear);
- m.setRGB(u,u,u)}else I instanceof THREE.MeshNormalMaterial&&m.setRGB(f(W.normalWorld.x),f(W.normalWorld.y),f(W.normalWorld.z));I.wireframe?C.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+I.wireframe_linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: "+I.wireframe_linecap+"; stroke-linejoin: "+I.wireframe_linejoin):C.setAttribute("style","fill: "+m.__styleString+"; fill-opacity: "+I.opacity);h.appendChild(C)}function e(R,$,U,W,I,D,P){C=d(B++);C.setAttribute("d",
- "M "+R.positionScreen.x+" "+R.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(D instanceof THREE.MeshBasicMaterial)m.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshLambertMaterial)if(E){N.r=i.r;N.g=i.g;N.b=i.b;a(P,I,N);m.r=D.color.r*N.r;m.g=D.color.g*N.g;m.b=D.color.b*N.b;m.updateStyleString()}else m.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshDepthMaterial){u=
- 1-D.__2near/(D.__farPlusNear-I.z*D.__farMinusNear);m.setRGB(u,u,u)}else D instanceof THREE.MeshNormalMaterial&&m.setRGB(f(I.normalWorld.x),f(I.normalWorld.y),f(I.normalWorld.z));D.wireframe?C.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+D.wireframe_linewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.wireframe_linecap+"; stroke-linejoin: "+D.wireframe_linejoin):C.setAttribute("style","fill: "+m.__styleString+"; fill-opacity: "+D.opacity);h.appendChild(C)}
- function d(R){if(n[R]==null){n[R]=document.createElementNS("http://www.w3.org/2000/svg","path");H==0&&n[R].setAttribute("shape-rendering","crispEdges");return n[R]}return n[R]}function f(R){return R<0?Math.min((1+R)*0.5,0.5):0.5+Math.min(R*0.5,0.5)}var g=null,l=new THREE.Projector,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,c,v,y,q,t,x,A,L=new THREE.Rectangle,w=new THREE.Rectangle,E=false,m=new THREE.Color(16777215),N=new THREE.Color(16777215),i=new THREE.Color(0),r=new THREE.Color(0),
- j=new THREE.Color(0),u,p=new THREE.Vector3,n=[],G=[],z=[],C,B,K,T,H=1;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(R){switch(R){case "high":H=1;break;case "low":H=0}};this.setSize=function(R,$){k=R;c=$;v=k/2;y=c/2;h.setAttribute("viewBox",-v+" "+-y+" "+k+" "+c);h.setAttribute("width",k);h.setAttribute("height",c);L.set(-v,-y,v,y)};this.clear=function(){for(;h.childNodes.length>0;)h.removeChild(h.childNodes[0])};this.render=function(R,$){var U,W,
- I,D,P,o,s,F;this.autoClear&&this.clear();g=l.projectScene(R,$,this.sortElements);T=K=B=0;if(E=R.lights.length>0){s=R.lights;i.setRGB(0,0,0);r.setRGB(0,0,0);j.setRGB(0,0,0);U=0;for(W=s.length;U<W;U++){I=s[U];D=I.color;if(I instanceof THREE.AmbientLight){i.r+=D.r;i.g+=D.g;i.b+=D.b}else if(I instanceof THREE.DirectionalLight){r.r+=D.r;r.g+=D.g;r.b+=D.b}else if(I instanceof THREE.PointLight){j.r+=D.r;j.g+=D.g;j.b+=D.b}}}U=0;for(W=g.length;U<W;U++){s=g[U];w.empty();if(s instanceof THREE.RenderableParticle){q=
- s;q.x*=v;q.y*=-y;I=0;for(D=s.material.length;I<D;I++)if(F=s.material[I]){P=q;o=s;F=F;var O=K++;if(G[O]==null){G[O]=document.createElementNS("http://www.w3.org/2000/svg","circle");H==0&&G[O].setAttribute("shape-rendering","crispEdges")}C=G[O];C.setAttribute("cx",P.x);C.setAttribute("cy",P.y);C.setAttribute("r",o.scale.x*v);if(F instanceof THREE.ParticleCircleMaterial){if(E){N.r=i.r+r.r+j.r;N.g=i.g+r.g+j.g;N.b=i.b+r.b+j.b;m.r=F.color.r*N.r;m.g=F.color.g*N.g;m.b=F.color.b*N.b;m.updateStyleString()}else m=
- F.color;C.setAttribute("style","fill: "+m.__styleString)}h.appendChild(C)}}else if(s instanceof THREE.RenderableLine){q=s.v1;t=s.v2;q.positionScreen.x*=v;q.positionScreen.y*=-y;t.positionScreen.x*=v;t.positionScreen.y*=-y;w.addPoint(q.positionScreen.x,q.positionScreen.y);w.addPoint(t.positionScreen.x,t.positionScreen.y);if(L.instersects(w)){I=0;for(D=s.material.length;I<D;)if(F=s.material[I++]){P=q;o=t;F=F;O=T++;if(z[O]==null){z[O]=document.createElementNS("http://www.w3.org/2000/svg","line");H==
- 0&&z[O].setAttribute("shape-rendering","crispEdges")}C=z[O];C.setAttribute("x1",P.positionScreen.x);C.setAttribute("y1",P.positionScreen.y);C.setAttribute("x2",o.positionScreen.x);C.setAttribute("y2",o.positionScreen.y);if(F instanceof THREE.LineBasicMaterial){m.__styleString=F.color.__styleString;C.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+F.linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.linecap+"; stroke-linejoin: "+F.linejoin);h.appendChild(C)}}}}else if(s instanceof
- THREE.RenderableFace3){q=s.v1;t=s.v2;x=s.v3;q.positionScreen.x*=v;q.positionScreen.y*=-y;t.positionScreen.x*=v;t.positionScreen.y*=-y;x.positionScreen.x*=v;x.positionScreen.y*=-y;w.addPoint(q.positionScreen.x,q.positionScreen.y);w.addPoint(t.positionScreen.x,t.positionScreen.y);w.addPoint(x.positionScreen.x,x.positionScreen.y);if(L.instersects(w)){I=0;for(D=s.meshMaterial.length;I<D;){F=s.meshMaterial[I++];if(F instanceof THREE.MeshFaceMaterial){P=0;for(o=s.faceMaterial.length;P<o;)(F=s.faceMaterial[P++])&&
- b(q,t,x,s,F,R)}else F&&b(q,t,x,s,F,R)}}}else if(s instanceof THREE.RenderableFace4){q=s.v1;t=s.v2;x=s.v3;A=s.v4;q.positionScreen.x*=v;q.positionScreen.y*=-y;t.positionScreen.x*=v;t.positionScreen.y*=-y;x.positionScreen.x*=v;x.positionScreen.y*=-y;A.positionScreen.x*=v;A.positionScreen.y*=-y;w.addPoint(q.positionScreen.x,q.positionScreen.y);w.addPoint(t.positionScreen.x,t.positionScreen.y);w.addPoint(x.positionScreen.x,x.positionScreen.y);w.addPoint(A.positionScreen.x,A.positionScreen.y);if(L.instersects(w)){I=
- 0;for(D=s.meshMaterial.length;I<D;){F=s.meshMaterial[I++];if(F instanceof THREE.MeshFaceMaterial){P=0;for(o=s.faceMaterial.length;P<o;)(F=s.faceMaterial[P++])&&e(q,t,x,A,s,F,R)}else F&&e(q,t,x,A,s,F,R)}}}}}};
- THREE.WebGLRenderer=function(a){function b(i,r){var j=c.createProgram(),u=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","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(j,l("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"+
- i));c.attachShader(j,l("vertex",u+r));c.linkProgram(j);c.getProgramParameter(j,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(j,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");j.uniforms={};j.attributes={};return j}function e(i,r){if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,i.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(var j=0;j<6;++j)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image[j]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);i.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+r);c.bindTexture(c.TEXTURE_CUBE_MAP,
- i.image.__webGLTextureCube)}}function d(i,r){if(!i.__webGLTexture&&i.image.loaded){i.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,i.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,h(i.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,h(i.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(i.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,h(i.min_filter));c.generateMipmap(c.TEXTURE_2D);
- c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+r);c.bindTexture(c.TEXTURE_2D,i.__webGLTexture)}function f(i,r){var j,u,p;j=0;for(u=r.length;j<u;j++){p=r[j];i.uniforms[p]=c.getUniformLocation(i,p)}}function g(i,r){var j,u,p;j=0;for(u=r.length;j<u;j++){p=r[j];i.attributes[p]=c.getAttribLocation(i,p)}}function l(i,r){var j;if(i=="fragment")j=c.createShader(c.FRAGMENT_SHADER);else if(i=="vertex")j=c.createShader(c.VERTEX_SHADER);c.shaderSource(j,r);c.compileShader(j);if(!c.getShaderParameter(j,
- c.COMPILE_STATUS)){alert(c.getShaderInfoLog(j));return null}return j}function h(i){switch(i){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}return 0}var k=document.createElement("canvas"),c,v,y,q=new THREE.Matrix4,t,x=new Float32Array(16),A=new Float32Array(16),L=new Float32Array(16),w=new Float32Array(9),E=new Float32Array(16);a=function(i,r){if(i){var j,u,p,n=pointLights=maxDirLights=maxPointLights=0;j=0;for(u=i.lights.length;j<u;j++){p=i.lights[j];p instanceof THREE.DirectionalLight&&n++;p instanceof THREE.PointLight&&pointLights++}if(pointLights+n<=r){maxDirLights=
- n;maxPointLights=pointLights}else{maxDirLights=Math.ceil(r*n/(pointLights+n));maxPointLights=r-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:r-1}}(a,4);this.domElement=k;this.autoClear=true;try{c=k.getContext("experimental-webgl",{antialias:true})}catch(m){}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(0,0,0,0);v=y=function(i,r){var j=[i?"#define MAX_DIR_LIGHTS "+i:"",r?"#define MAX_POINT_LIGHTS "+r:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",i?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",i?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",r?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":
- "",r?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",r?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
- i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",i?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",i?"}":"",r?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",r?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",r?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
- "",r?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",r?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",r?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
- u=[i?"#define MAX_DIR_LIGHTS "+i:"",r?"#define MAX_POINT_LIGHTS "+r:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",i?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":
- "","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",r?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
- r?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",r?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",r?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",r?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",r?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",r?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",r?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",r?"float pointSpecularWeight = 0.0;":"",r?"if ( pointDotNormalHalf >= 0.0 )":
- "",r?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",r?"pointDiffuse += mColor * pointDiffuseWeight;":"",r?"pointSpecular += mSpecular * pointSpecularWeight;":"",r?"}":"",i?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"vec3 dirVector = normalize( lDirection.xyz );":"",i?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
- "",i?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",i?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",i?"float dirSpecularWeight = 0.0;":"",i?"if ( dirDotNormalHalf >= 0.0 )":"",i?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",i?"dirDiffuse += mColor * dirDiffuseWeight;":"",i?"dirSpecular += mSpecular * dirSpecularWeight;":"",i?"}":"","vec4 totalLight = mAmbient;",i?"totalLight += dirDiffuse + dirSpecular;":"",r?"totalLight += pointDiffuse + pointSpecular;":
- "","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n");
- j=b(u,j);c.useProgram(j);f(j,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);i&&f(j,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);r&&f(j,["pointLightNumber","pointLightColor","pointLightPosition"]);c.uniform1i(j.uniforms.enableMap,
- 0);c.uniform1i(j.uniforms.tMap,0);c.uniform1i(j.uniforms.enableCubeMap,0);c.uniform1i(j.uniforms.tCube,1);c.uniform1i(j.uniforms.mixEnvMap,0);c.uniform1i(j.uniforms.useRefract,0);g(j,["position","normal","uv"]);return j}(a.directional,a.point);this.setSize=function(i,r){k.width=i;k.height=r;c.viewport(0,0,k.width,k.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(i,r){var j,u,p,n,G,z=[],C=[],B=[];n=[];G=[];c.uniform1i(i.uniforms.enableLighting,
- r.length);j=0;for(u=r.length;j<u;j++){p=r[j];if(p instanceof THREE.AmbientLight)z.push(p);else if(p instanceof THREE.DirectionalLight)B.push(p);else p instanceof THREE.PointLight&&C.push(p)}j=p=n=G=0;for(u=z.length;j<u;j++){p+=z[j].color.r;n+=z[j].color.g;G+=z[j].color.b}c.uniform3f(i.uniforms.ambientLightColor,p,n,G);n=[];G=[];j=0;for(u=B.length;j<u;j++){p=B[j];n.push(p.color.r*p.intensity);n.push(p.color.g*p.intensity);n.push(p.color.b*p.intensity);G.push(p.position.x);G.push(p.position.y);G.push(p.position.z)}if(B.length){c.uniform1i(i.uniforms.directionalLightNumber,
- B.length);c.uniform3fv(i.uniforms.directionalLightDirection,G);c.uniform3fv(i.uniforms.directionalLightColor,n)}n=[];G=[];j=0;for(u=C.length;j<u;j++){p=C[j];n.push(p.color.r*p.intensity);n.push(p.color.g*p.intensity);n.push(p.color.b*p.intensity);G.push(p.position.x);G.push(p.position.y);G.push(p.position.z)}if(C.length){c.uniform1i(i.uniforms.pointLightNumber,C.length);c.uniform3fv(i.uniforms.pointLightPosition,G);c.uniform3fv(i.uniforms.pointLightColor,n)}};this.createBuffers=function(i,r){var j,
- u,p,n,G,z,C,B,K,T=[],H=[],R=[],$=[],U=[],W=[],I=0,D=i.geometry.geometryChunks[r],P;p=false;j=0;for(u=i.material.length;j<u;j++){meshMaterial=i.material[j];if(meshMaterial instanceof THREE.MeshFaceMaterial){G=0;for(P=D.material.length;G<P;G++)if(D.material[G]&&D.material[G].shading!=undefined&&D.material[G].shading==THREE.SmoothShading){p=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){p=true;break}if(p)break}P=p;j=0;for(u=D.faces.length;j<
- u;j++){p=D.faces[j];n=i.geometry.faces[p];G=n.vertexNormals;faceNormal=n.normal;p=i.geometry.uvs[p];if(n instanceof THREE.Face3){z=i.geometry.vertices[n.a].position;C=i.geometry.vertices[n.b].position;B=i.geometry.vertices[n.c].position;R.push(z.x,z.y,z.z);R.push(C.x,C.y,C.z);R.push(B.x,B.y,B.z);if(i.geometry.hasTangents){z=i.geometry.vertices[n.a].tangent;C=i.geometry.vertices[n.b].tangent;B=i.geometry.vertices[n.c].tangent;U.push(z.x,z.y,z.z,z.w);U.push(C.x,C.y,C.z,C.w);U.push(B.x,B.y,B.z,B.w)}if(G.length==
- 3&&P)for(n=0;n<3;n++)$.push(G[n].x,G[n].y,G[n].z);else for(n=0;n<3;n++)$.push(faceNormal.x,faceNormal.y,faceNormal.z);if(p)for(n=0;n<3;n++)W.push(p[n].u,p[n].v);T.push(I,I+1,I+2);H.push(I,I+1);H.push(I,I+2);H.push(I+1,I+2);I+=3}else if(n instanceof THREE.Face4){z=i.geometry.vertices[n.a].position;C=i.geometry.vertices[n.b].position;B=i.geometry.vertices[n.c].position;K=i.geometry.vertices[n.d].position;R.push(z.x,z.y,z.z);R.push(C.x,C.y,C.z);R.push(B.x,B.y,B.z);R.push(K.x,K.y,K.z);if(i.geometry.hasTangents){z=
- i.geometry.vertices[n.a].tangent;C=i.geometry.vertices[n.b].tangent;B=i.geometry.vertices[n.c].tangent;n=i.geometry.vertices[n.d].tangent;U.push(z.x,z.y,z.z,z.w);U.push(C.x,C.y,C.z,C.w);U.push(B.x,B.y,B.z,B.w);U.push(n.x,n.y,n.z,n.w)}if(G.length==4&&P)for(n=0;n<4;n++)$.push(G[n].x,G[n].y,G[n].z);else for(n=0;n<4;n++)$.push(faceNormal.x,faceNormal.y,faceNormal.z);if(p)for(n=0;n<4;n++)W.push(p[n].u,p[n].v);T.push(I,I+1,I+2);T.push(I,I+2,I+3);H.push(I,I+1);H.push(I,I+2);H.push(I,I+3);H.push(I+1,I+2);
- H.push(I+2,I+3);I+=4}}if(R.length){D.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,D.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(R),c.STATIC_DRAW);D.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,D.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array($),c.STATIC_DRAW);if(i.geometry.hasTangents){D.__webGLTangentBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,D.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(U),
- c.STATIC_DRAW)}if(W.length>0){D.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,D.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(W),c.STATIC_DRAW)}D.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,D.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(T),c.STATIC_DRAW);D.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,D.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(H),c.STATIC_DRAW);
- D.__webGLFaceCount=T.length;D.__webGLLineCount=H.length}};this.renderBuffer=function(i,r,j,u){var p,n,G,z,C,B,K,T,H;if(j instanceof THREE.MeshShaderMaterial||j instanceof THREE.MeshDepthMaterial||j instanceof THREE.MeshNormalMaterial){if(!j.program){if(j instanceof THREE.MeshDepthMaterial){K=N.depth;j.fragment_shader=K.fragment_shader;j.vertex_shader=K.vertex_shader;j.uniforms=K.uniforms;j.uniforms.mNear.value=j.near;j.uniforms.mFar.value=j.far}else if(j instanceof THREE.MeshNormalMaterial){K=N.normal;
- j.fragment_shader=K.fragment_shader;j.vertex_shader=K.vertex_shader;j.uniforms=K.uniforms}j.program=b(j.fragment_shader,j.vertex_shader);K=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(H in j.uniforms)K.push(H);f(j.program,K);g(j.program,["position","normal","uv","tangent"])}H=j.program}else H=y;if(H!=v){c.useProgram(H);v=H}H==y&&this.setupLights(H,r);this.loadCamera(H,i);this.loadMatrices(H);if(j instanceof THREE.MeshShaderMaterial||j instanceof
- THREE.MeshDepthMaterial||j instanceof THREE.MeshNormalMaterial){G=j.wireframe;z=j.wireframe_linewidth;i=H;r=j.uniforms;var R;for(p in r){T=r[p].type;K=r[p].value;R=i.uniforms[p];if(T=="i")c.uniform1i(R,K);else if(T=="f")c.uniform1f(R,K);else if(T=="v3")c.uniform3f(R,K.x,K.y,K.z);else if(T=="c")c.uniform3f(R,K.r,K.g,K.b);else if(T=="t"){c.uniform1i(R,K);if(T=r[p].texture)T.image instanceof Array&&T.image.length==6?e(T,K):d(T,K)}}}if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial||
- j instanceof THREE.MeshBasicMaterial){p=j.color;n=j.opacity;G=j.wireframe;z=j.wireframe_linewidth;C=j.map;B=j.env_map;r=j.combine==THREE.MixOperation;i=j.reflectivity;T=j.env_map&&j.env_map.mapping instanceof THREE.CubeRefractionMapping;K=j.refraction_ratio;c.uniform4f(H.uniforms.mColor,p.r*n,p.g*n,p.b*n,n);c.uniform1i(H.uniforms.mixEnvMap,r);c.uniform1f(H.uniforms.mReflectivity,i);c.uniform1i(H.uniforms.useRefract,T);c.uniform1f(H.uniforms.mRefractionRatio,K)}if(j instanceof THREE.MeshPhongMaterial){p=
- j.ambient;i=j.specular;j=j.shininess;c.uniform4f(H.uniforms.mAmbient,p.r,p.g,p.b,n);c.uniform4f(H.uniforms.mSpecular,i.r,i.g,i.b,n);c.uniform1f(H.uniforms.mShininess,j);c.uniform1i(H.uniforms.material,2)}else if(j instanceof THREE.MeshLambertMaterial)c.uniform1i(H.uniforms.material,1);else j instanceof THREE.MeshBasicMaterial&&c.uniform1i(H.uniforms.material,0);if(C){d(C,0);c.uniform1i(H.uniforms.tMap,0);c.uniform1i(H.uniforms.enableMap,1)}else c.uniform1i(H.uniforms.enableMap,0);if(B){e(B,1);c.uniform1i(H.uniforms.tCube,
- 1);c.uniform1i(H.uniforms.enableCubeMap,1)}else c.uniform1i(H.uniforms.enableCubeMap,0);n=H.attributes;c.bindBuffer(c.ARRAY_BUFFER,u.__webGLVertexBuffer);c.vertexAttribPointer(n.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(n.position);if(n.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,u.__webGLNormalBuffer);c.vertexAttribPointer(n.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(n.normal)}if(n.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,u.__webGLTangentBuffer);c.vertexAttribPointer(n.tangent,
- 4,c.FLOAT,false,0,0);c.enableVertexAttribArray(n.tangent)}if(n.uv>=0)if(u.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,u.__webGLUVBuffer);c.vertexAttribPointer(n.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(n.uv)}else c.disableVertexAttribArray(n.uv);if(G){c.lineWidth(z);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.__webGLLineBuffer);c.drawElements(c.LINES,u.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,u.__webGLFaceCount,
- c.UNSIGNED_SHORT,0)}};this.renderPass=function(i,r,j,u,p,n){var G,z,C,B,K;C=0;for(B=j.material.length;C<B;C++){G=j.material[C];if(G instanceof THREE.MeshFaceMaterial){G=0;for(z=u.material.length;G<z;G++)if((K=u.material[G])&&K.blending==p&&K.opacity<1==n){this.setBlending(K.blending);this.renderBuffer(i,r,K,u)}}else if((K=G)&&K.blending==p&&K.opacity<1==n){this.setBlending(K.blending);this.renderBuffer(i,r,K,u)}}};this.render=function(i,r){var j,u,p,n,G=i.lights;this.initWebGLObjects(i);this.autoClear&&
- this.clear();r.autoUpdateMatrix&&r.updateMatrix();x.set(r.matrix.flatten());L.set(r.projectionMatrix.flatten());j=0;for(u=i.__webGLObjects.length;j<u;j++){p=i.__webGLObjects[j];n=p.object;p=p.buffer;if(n.visible){this.setupMatrices(n,r);this.renderPass(r,G,n,p,THREE.NormalBlending,false)}}j=0;for(u=i.__webGLObjects.length;j<u;j++){p=i.__webGLObjects[j];n=p.object;p=p.buffer;if(n.visible){this.setupMatrices(n,r);this.renderPass(r,G,n,p,THREE.AdditiveBlending,false);this.renderPass(r,G,n,p,THREE.SubtractiveBlending,
- false);this.renderPass(r,G,n,p,THREE.AdditiveBlending,true);this.renderPass(r,G,n,p,THREE.SubtractiveBlending,true);this.renderPass(r,G,n,p,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(i){var r,j,u,p,n,G;if(!i.__webGLObjects){i.__webGLObjects=[];i.__webGLObjectsMap={}}r=0;for(j=i.objects.length;r<j;r++){u=i.objects[r];if(i.__webGLObjectsMap[u.id]==undefined)i.__webGLObjectsMap[u.id]={};G=i.__webGLObjectsMap[u.id];if(u instanceof THREE.Mesh)for(n in u.geometry.geometryChunks){p=u.geometry.geometryChunks[n];
- p.__webGLVertexBuffer||this.createBuffers(u,n);if(G[n]==undefined){p={buffer:p,object:u};i.__webGLObjects.push(p);G[n]=1}}}};this.removeObject=function(i,r){var j,u;for(j=i.__webGLObjects.length-1;j>=0;j--){u=i.__webGLObjects[j].object;r==u&&i.__webGLObjects.splice(j,1)}};this.setupMatrices=function(i,r){i.autoUpdateMatrix&&i.updateMatrix();q.multiply(r.matrix,i.matrix);A.set(q.flatten());t=THREE.Matrix4.makeInvert3x3(q).transpose();w.set(t.m);E.set(i.matrix.flatten())};this.loadMatrices=function(i){c.uniformMatrix4fv(i.uniforms.viewMatrix,
- false,x);c.uniformMatrix4fv(i.uniforms.modelViewMatrix,false,A);c.uniformMatrix4fv(i.uniforms.projectionMatrix,false,L);c.uniformMatrix3fv(i.uniforms.normalMatrix,false,w);c.uniformMatrix4fv(i.uniforms.objectMatrix,false,E)};this.loadCamera=function(i,r){c.uniform3f(i.uniforms.cameraPosition,r.position.x,r.position.y,r.position.z)};this.setBlending=function(i){switch(i){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(i,r){if(i){!r||r=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(i=="back")c.cullFace(c.BACK);else i=="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};var N={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}"}}};
- 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.faceMaterial=this.meshMaterial=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.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null};
- var GeometryUtils={merge:function(a,b){var e=b instanceof THREE.Mesh,d=a.vertices.length,f=e?b.geometry:b,g=a.vertices,l=f.vertices,h=a.faces,k=f.faces,c=a.uvs;f=f.uvs;e&&b.updateMatrix();for(var v=0,y=l.length;v<y;v++){var q=new THREE.Vertex(l[v].position.clone());e&&b.matrix.multiplyVector3(q.position);g.push(q)}v=0;for(y=k.length;v<y;v++){l=k[v];var t,x=l.vertexNormals;if(l instanceof THREE.Face3)t=new THREE.Face3(l.a+d,l.b+d,l.c+d);else if(l instanceof THREE.Face4)t=new THREE.Face4(l.a+d,l.b+
- d,l.c+d,l.d+d);t.centroid.copy(l.centroid);t.normal.copy(l.normal);e=0;for(g=x.length;e<g;e++){q=x[e];t.vertexNormals.push(q.clone())}t.material=l.material.slice();h.push(t)}v=0;for(y=f.length;v<y;v++){d=f[v];h=[];e=0;for(g=d.length;e<g;e++)h.push(new THREE.UV(d[e].u,d[e].v));c.push(h)}}},ImageUtils={loadTexture:function(a,b){var e=new Image;e.onload=function(){this.loaded=true};e.src=a;return new THREE.Texture(e,b)},loadArray:function(a){var b,e,d=[];b=d.loadCount=0;for(e=a.length;b<e;++b){d[b]=
- new Image;d[b].loaded=0;d[b].onload=function(){d.loadCount+=1;this.loaded=true};d[b].src=a[b]}return d}},SceneUtils={addMesh:function(a,b,e,d,f,g,l,h,k,c){b=new THREE.Mesh(b,c);b.scale.x=b.scale.y=b.scale.z=e;b.position.x=d;b.position.y=f;b.position.z=g;b.rotation.x=l;b.rotation.y=h;b.rotation.z=k;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,e){var d=ShaderUtils.lib.cube;d.uniforms.tCube.texture=e;e=new THREE.MeshShaderMaterial({fragment_shader:d.fragment_shader,vertex_shader:d.vertex_shader,
- uniforms:d.uniforms});b=new THREE.Mesh(new Cube(b,b,b,1,1,null,true),e);a.addObject(b);return b},addPanoramaCube:function(a,b,e){var d=[];d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[0])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[1])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[2])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[3])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[4])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[5])}));
- mesh=new THREE.Mesh(new Cube(b,b,b,1,1,d,true),new THREE.MeshFaceMaterial);a.addObject(mesh);return mesh},addPanoramaCubePlanes:function(a,b,e){var d=b/2;b=new Plane(b,b);var f=Math.PI/2,g=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-d,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[5])}));SceneUtils.addMesh(a,b,1,-d,0,0,0,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[0])}));SceneUtils.addMesh(a,b,1,d,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[1])}));SceneUtils.addMesh(a,
- b,1,0,d,0,f,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[2])}));SceneUtils.addMesh(a,b,1,0,-d,0,-f,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[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:{tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},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 uDirLightColor;\nuniform vec3 uPointLightPos;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 normalTex = normalize( texture2D( tNormal, vUv ).xyz * 2.0 - 1.0 );\nvec3 aoTex = 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( uAmbientColor, 1.0 );\ntotalLight += dirDiffuse + dirSpecular;\ntotalLight += pointDiffuse + pointSpecular;\ngl_FragColor = vec4( totalLight.xyz * vLightWeighting * aoTex, 1.0 );\n}",
- vertex_shader:"attribute vec4 tangent;\nuniform vec3 uDirLightPos;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightPos;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientLightColor;\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 vLightWeighting;\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;\nvLightWeighting = uAmbientLightColor;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( vNormal, vPointLightVector ), 0.0 );\nvLightWeighting += uPointLightColor * pointLightWeighting;\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nfloat directionalLightWeighting = max( dot( vNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += uDirLightColor * directionalLightWeighting;\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}"},
- 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:{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}"}}},Cube=function(a,b,e,d,f,g,l,h){function k(A,L,w,E,m,N,i,r){var j,u=d||1,p=f||1,n=u+1,G=p+1,z=m/2,C=N/2;m=m/u;N=N/p;var B=c.vertices.length;if(A=="x"&&L=="y"||A=="y"&&L=="x")j="z";else if(A=="x"&&L=="z"||A=="z"&&L=="x")j="y";else if(A=="z"&&L=="y"||A=="y"&&L=="z")j="x";for(iy=0;iy<G;iy++)for(ix=0;ix<
- n;ix++){var K=new THREE.Vector3;K[A]=(ix*m-z)*w;K[L]=(iy*N-C)*E;K[j]=i;c.vertices.push(new THREE.Vertex(K))}for(iy=0;iy<p;iy++)for(ix=0;ix<u;ix++){c.faces.push(new THREE.Face4(ix+n*iy+B,ix+n*(iy+1)+B,ix+1+n*(iy+1)+B,ix+1+n*iy+B,null,r));c.uvs.push([new THREE.UV(ix/u,iy/p),new THREE.UV(ix/u,(iy+1)/p),new THREE.UV((ix+1)/u,(iy+1)/p),new THREE.UV((ix+1)/u,iy/p)])}}THREE.Geometry.call(this);var c=this,v=a/2,y=b/2,q=e/2;l=l?-1:1;if(g!==undefined)if(g instanceof Array)this.materials=g;else{this.materials=
- [];for(var t=0;t<6;t++)this.materials.push([g])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(h!=undefined)for(var x in h)if(this.sides[x]!=undefined)this.sides[x]=h[x];this.sides.px&&k("z","y",1*l,-1,e,b,-v,this.materials[0]);this.sides.nx&&k("z","y",-1*l,-1,e,b,v,this.materials[1]);this.sides.py&&k("x","z",1*l,1,a,e,y,this.materials[2]);this.sides.ny&&k("x","z",1*l,-1,a,e,-y,this.materials[3]);this.sides.pz&&k("x","y",1*l,-1,a,b,q,this.materials[4]);this.sides.nz&&
- k("x","y",-1*l,-1,a,b,-q,this.materials[5]);(function(){for(var A=[],L=[],w=0,E=c.vertices.length;w<E;w++){for(var m=c.vertices[w],N=false,i=0,r=A.length;i<r;i++){var j=A[i];if(m.position.x==j.position.x&&m.position.y==j.position.y&&m.position.z==j.position.z){L[w]=i;N=true;break}}if(!N){L[w]=A.length;A.push(new THREE.Vertex(m.position.clone()))}}w=0;for(E=c.faces.length;w<E;w++){m=c.faces[w];m.a=L[m.a];m.b=L[m.b];m.c=L[m.c];m.d=L[m.d]}c.vertices=A})();this.computeCentroids();this.computeFaceNormals();
- this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
- var Cylinder=function(a,b,e,d,f){function g(c,v,y){l.vertices.push(new THREE.Vertex(new THREE.Vector3(c,v,y)))}THREE.Geometry.call(this);var l=this,h=Math.PI,k;for(k=0;k<a;k++)g(Math.sin(2*h*k/a)*b,Math.cos(2*h*k/a)*b,0);for(k=0;k<a;k++)g(Math.sin(2*h*k/a)*e,Math.cos(2*h*k/a)*e,d);for(k=0;k<a;k++)l.faces.push(new THREE.Face4(k,k+a,a+(k+1)%a,(k+1)%a));if(e!=0){g(0,0,-f);for(k=a;k<a+a/2;k++)l.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){g(0,0,d+f);for(k=a+a/2;k<
- 2*a;k++)l.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,e,d){THREE.Geometry.call(this);var f,g=a/2,l=b/2;e=e||1;d=d||1;var h=e+1,k=d+1;a=a/e;var c=b/d;for(f=0;f<k;f++)for(b=0;b<h;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-g,-(f*c-l),0)));for(f=0;f<d;f++)for(b=0;b<e;b++){this.faces.push(new THREE.Face4(b+h*f,b+h*(f+1),b+1+h*(f+1),b+1+h*f));this.uvs.push([new THREE.UV(b/e,f/d),new THREE.UV(b/e,(f+1)/d),new THREE.UV((b+1)/e,(f+1)/d),new THREE.UV((b+1)/e,f/d)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
- Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
- var Sphere=function(a,b,e){THREE.Geometry.call(this);var d,f=Math.PI,g=Math.max(3,b||8),l=Math.max(2,e||6);b=[];for(e=0;e<l+1;e++){d=e/l;var h=a*Math.cos(d*f),k=a*Math.sin(d*f),c=[],v=0;for(d=0;d<g;d++){var y=2*d/g,q=k*Math.sin(y*f);y=k*Math.cos(y*f);(e==0||e==l)&&d>0||(v=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,h,q)))-1);c.push(v)}b.push(c)}var t,x;a=b.length;for(e=0;e<a;e++){f=b[e].length;if(e>0)for(d=0;d<f;d++){k=d==f-1;g=b[e][k?0:d+1];l=b[e][k?f-1:d];h=b[e-1][k?f-1:d];k=b[e-1][k?
- 0:d+1];v=e/(a-1);y=(e-1)/(a-1);t=(d+1)/f;q=d/f;c=new THREE.UV(1-t,v);v=new THREE.UV(1-q,v);q=new THREE.UV(1-q,y);var A=new THREE.UV(1-t,y);if(e<b.length-1){y=this.vertices[g].position.clone();t=this.vertices[l].position.clone();x=this.vertices[h].position.clone();y.normalize();t.normalize();x.normalize();this.faces.push(new THREE.Face3(g,l,h,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(x.x,x.y,x.z)]));this.uvs.push([c,v,q])}if(e>1){y=this.vertices[g].position.clone();
- t=this.vertices[h].position.clone();x=this.vertices[k].position.clone();y.normalize();t.normalize();x.normalize();this.faces.push(new THREE.Face3(g,h,k,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(x.x,x.y,x.z)]));this.uvs.push([c,q,A])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
- 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 e=document.createElement("script");e.type="text/javascript";e.onload=b;e.src=a;document.getElementsByTagName("head")[0].appendChild(e)},loadAscii:function(a,b,e){var d=(new Date).getTime();a=new Worker(a);a.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,b,e)};a.postMessage(d)},loadBinary:function(a,b,e){var d=(new Date).getTime();a=new Worker(a);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(g){THREE.Loader.prototype.loadAjaxBuffers(g.data.buffers,
- g.data.materials,b,e,f)};a.onerror=function(g){alert("worker.onerror: "+g.message+"\n"+g.data);g.preventDefault()};a.postMessage(d)},loadAjaxBuffers:function(a,b,e,d,f){var g=new XMLHttpRequest,l=d+"/"+a,h=0;g.onreadystatechange=function(){if(g.readyState==4)g.status==200||g.status==0?THREE.Loader.prototype.createBinModel(g.responseText,e,d,b):alert("Couldn't load ["+l+"] ["+g.status+"]");else if(g.readyState==3){if(f){if(h==0)h=g.getResponseHeader("Content-Length");f({total:h,loaded:g.responseText.length})}}else if(g.readyState==
- 2)h=g.getResponseHeader("Content-Length")};g.open("GET",l,true);g.overrideMimeType("text/plain; charset=x-user-defined");g.setRequestHeader("Content-Type","text/plain");g.send(null)},createBinModel:function(a,b,e,d){var f=function(g){function l(o,s){var F=v(o,s),O=v(o,s+1),X=v(o,s+2),Y=v(o,s+3),ea=(Y<<1&255|X>>7)-127;F=(X&127)<<16|O<<8|F;if(F==0&&ea==-127)return 0;return(1-2*(Y>>7))*(1+F*Math.pow(2,-23))*Math.pow(2,ea)}function h(o,s){var F=v(o,s),O=v(o,s+1),X=v(o,s+2);return(v(o,s+3)<<24)+(X<<16)+
- (O<<8)+F}function k(o,s){var F=v(o,s);return(v(o,s+1)<<8)+F}function c(o,s){var F=v(o,s);return F>127?F-256:F}function v(o,s){return o.charCodeAt(s)&255}function y(o){var s,F,O;s=h(a,o);F=h(a,o+r);O=h(a,o+j);o=k(a,o+u);THREE.Loader.prototype.f3(w,s,F,O,o)}function q(o){var s,F,O,X,Y,ea;s=h(a,o);F=h(a,o+r);O=h(a,o+j);X=k(a,o+u);Y=h(a,o+p);ea=h(a,o+n);o=h(a,o+G);THREE.Loader.prototype.f3n(w,N,s,F,O,X,Y,ea,o)}function t(o){var s,F,O,X;s=h(a,o);F=h(a,o+z);O=h(a,o+C);X=h(a,o+B);o=k(a,o+K);THREE.Loader.prototype.f4(w,
- s,F,O,X,o)}function x(o){var s,F,O,X,Y,ea,ma,oa;s=h(a,o);F=h(a,o+z);O=h(a,o+C);X=h(a,o+B);Y=k(a,o+K);ea=h(a,o+T);ma=h(a,o+H);oa=h(a,o+R);o=h(a,o+$);THREE.Loader.prototype.f4n(w,N,s,F,O,X,Y,ea,ma,oa,o)}function A(o){var s,F;s=h(a,o);F=h(a,o+U);o=h(a,o+W);THREE.Loader.prototype.uv3(w,i[s*2],i[s*2+1],i[F*2],i[F*2+1],i[o*2],i[o*2+1])}function L(o){var s,F,O;s=h(a,o);F=h(a,o+I);O=h(a,o+D);o=h(a,o+P);THREE.Loader.prototype.uv4(w,i[s*2],i[s*2+1],i[F*2],i[F*2+1],i[O*2],i[O*2+1],i[o*2],i[o*2+1])}var w=this,
- E=0,m,N=[],i=[],r,j,u,p,n,G,z,C,B,K,T,H,R,$,U,W,I,D,P;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,d,g);m={signature:a.substr(E,8),header_bytes:v(a,E+8),vertex_coordinate_bytes:v(a,E+9),normal_coordinate_bytes:v(a,E+10),uv_coordinate_bytes:v(a,E+11),vertex_index_bytes:v(a,E+12),normal_index_bytes:v(a,E+13),uv_index_bytes:v(a,E+14),material_index_bytes:v(a,E+15),nvertices:h(a,E+16),nnormals:h(a,E+16+4),nuvs:h(a,E+16+8),ntri_flat:h(a,E+16+12),ntri_smooth:h(a,E+16+16),ntri_flat_uv:h(a,
- E+16+20),ntri_smooth_uv:h(a,E+16+24),nquad_flat:h(a,E+16+28),nquad_smooth:h(a,E+16+32),nquad_flat_uv:h(a,E+16+36),nquad_smooth_uv:h(a,E+16+40)};E+=m.header_bytes;r=m.vertex_index_bytes;j=m.vertex_index_bytes*2;u=m.vertex_index_bytes*3;p=m.vertex_index_bytes*3+m.material_index_bytes;n=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes;G=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*2;z=m.vertex_index_bytes;C=m.vertex_index_bytes*2;B=m.vertex_index_bytes*3;K=m.vertex_index_bytes*
- 4;T=m.vertex_index_bytes*4+m.material_index_bytes;H=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes;R=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*2;$=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*3;U=m.uv_index_bytes;W=m.uv_index_bytes*2;I=m.uv_index_bytes;D=m.uv_index_bytes*2;P=m.uv_index_bytes*3;E+=function(o){var s,F,O,X=m.vertex_coordinate_bytes*3,Y=o+m.nvertices*X;for(o=o;o<Y;o+=X){s=l(a,o);F=l(a,o+m.vertex_coordinate_bytes);O=l(a,
- o+m.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(w,s,F,O)}return m.nvertices*X}(E);E+=function(o){var s,F,O,X=m.normal_coordinate_bytes*3,Y=o+m.nnormals*X;for(o=o;o<Y;o+=X){s=c(a,o);F=c(a,o+m.normal_coordinate_bytes);O=c(a,o+m.normal_coordinate_bytes*2);N.push(s/127,F/127,O/127)}return m.nnormals*X}(E);E+=function(o){var s,F,O=m.uv_coordinate_bytes*2,X=o+m.nuvs*O;for(o=o;o<X;o+=O){s=l(a,o);F=l(a,o+m.uv_coordinate_bytes);i.push(s,F)}return m.nuvs*O}(E);E+=function(o){var s,F=m.vertex_index_bytes*
- 3+m.material_index_bytes,O=o+m.ntri_flat*F;for(s=o;s<O;s+=F)y(s);return O-o}(E);E+=function(o){var s,F=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*3,O=o+m.ntri_smooth*F;for(s=o;s<O;s+=F)q(s);return O-o}(E);E+=function(o){var s,F=m.vertex_index_bytes*3+m.material_index_bytes,O=F+m.uv_index_bytes*3,X=o+m.ntri_flat_uv*O;for(s=o;s<X;s+=O){y(s);A(s+F)}return X-o}(E);E+=function(o){var s,F=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*3,O=F+m.uv_index_bytes*3,
- X=o+m.ntri_smooth_uv*O;for(s=o;s<X;s+=O){q(s);A(s+F)}return X-o}(E);E+=function(o){var s,F=m.vertex_index_bytes*4+m.material_index_bytes,O=o+m.nquad_flat*F;for(s=o;s<O;s+=F)t(s);return O-o}(E);E+=function(o){var s,F=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,O=o+m.nquad_smooth*F;for(s=o;s<O;s+=F)x(s);return O-o}(E);E+=function(o){var s,F=m.vertex_index_bytes*4+m.material_index_bytes,O=F+m.uv_index_bytes*4,X=o+m.nquad_flat_uv*O;for(s=o;s<X;s+=O){t(s);L(s+F)}return X-o}(E);
- E+=function(o){var s,F=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,O=F+m.uv_index_bytes*4,X=o+m.nquad_smooth_uv*O;for(s=o;s<X;s+=O){x(s);L(s+F)}return X-o}(E);this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(e))},createModel:function(a,b,e){var d=function(f){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,a.materials,f);(function(){var l,h,k,c,v;l=0;for(h=
- a.vertices.length;l<h;l+=3){k=a.vertices[l];c=a.vertices[l+1];v=a.vertices[l+2];THREE.Loader.prototype.v(g,k,c,v)}})();(function(){function l(x,A){THREE.Loader.prototype.f3(g,x[A],x[A+1],x[A+2],x[A+3])}function h(x,A){THREE.Loader.prototype.f3n(g,a.normals,x[A],x[A+1],x[A+2],x[A+3],x[A+4],x[A+5],x[A+6])}function k(x,A){THREE.Loader.prototype.f4(g,x[A],x[A+1],x[A+2],x[A+3],x[A+4])}function c(x,A){THREE.Loader.prototype.f4n(g,a.normals,x[A],x[A+1],x[A+2],x[A+3],x[A+4],x[A+5],x[A+6],x[A+7],x[A+8])}function v(x,
- A){var L,w,E;L=x[A];w=x[A+1];E=x[A+2];THREE.Loader.prototype.uv3(g,a.uvs[L*2],a.uvs[L*2+1],a.uvs[w*2],a.uvs[w*2+1],a.uvs[E*2],a.uvs[E*2+1])}function y(x,A){var L,w,E,m;L=x[A];w=x[A+1];E=x[A+2];m=x[A+3];THREE.Loader.prototype.uv4(g,a.uvs[L*2],a.uvs[L*2+1],a.uvs[w*2],a.uvs[w*2+1],a.uvs[E*2],a.uvs[E*2+1],a.uvs[m*2],a.uvs[m*2+1])}var q,t;q=0;for(t=a.triangles.length;q<t;q+=4)l(a.triangles,q);q=0;for(t=a.triangles_uv.length;q<t;q+=7){l(a.triangles_uv,q);v(a.triangles_uv,q+4)}q=0;for(t=a.triangles_n.length;q<
- t;q+=7)h(a.triangles_n,q);q=0;for(t=a.triangles_n_uv.length;q<t;q+=10){h(a.triangles_n_uv,q);v(a.triangles_n_uv,q+7)}q=0;for(t=a.quads.length;q<t;q+=5)k(a.quads,q);q=0;for(t=a.quads_uv.length;q<t;q+=9){k(a.quads_uv,q);y(a.quads_uv,q+5)}q=0;for(t=a.quads_n.length;q<t;q+=9)c(a.quads_n,q);q=0;for(t=a.quads_n_uv.length;q<t;q+=13){c(a.quads_n_uv,q);y(a.quads_n_uv,q+9)}})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};d.prototype=new THREE.Geometry;d.prototype.constructor=
- d;b(new d(e))},v:function(a,b,e,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,e,d)))},f3:function(a,b,e,d,f){a.faces.push(new THREE.Face3(b,e,d,null,a.materials[f]))},f4:function(a,b,e,d,f,g){a.faces.push(new THREE.Face4(b,e,d,f,null,a.materials[g]))},f3n:function(a,b,e,d,f,g,l,h,k){g=a.materials[g];var c=b[h*3],v=b[h*3+1];h=b[h*3+2];var y=b[k*3],q=b[k*3+1];k=b[k*3+2];a.faces.push(new THREE.Face3(e,d,f,[new THREE.Vector3(b[l*3],b[l*3+1],b[l*3+2]),new THREE.Vector3(c,v,h),new THREE.Vector3(y,
- q,k)],g))},f4n:function(a,b,e,d,f,g,l,h,k,c,v){l=a.materials[l];var y=b[k*3],q=b[k*3+1];k=b[k*3+2];var t=b[c*3],x=b[c*3+1];c=b[c*3+2];var A=b[v*3],L=b[v*3+1];v=b[v*3+2];a.faces.push(new THREE.Face4(e,d,f,g,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(y,q,k),new THREE.Vector3(t,x,c),new THREE.Vector3(A,L,v)],l))},uv3:function(a,b,e,d,f,g,l){var h=[];h.push(new THREE.UV(b,e));h.push(new THREE.UV(d,f));h.push(new THREE.UV(g,l));a.uvs.push(h)},uv4:function(a,b,e,d,f,g,l,h,k){var c=[];
- c.push(new THREE.UV(b,e));c.push(new THREE.UV(d,f));c.push(new THREE.UV(g,l));c.push(new THREE.UV(h,k));a.uvs.push(c)},init_materials:function(a,b,e){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=[THREE.Loader.prototype.createMaterial(b[d],e)]},createMaterial:function(a,b){function e(g){g=Math.log(g)/Math.LN2;return Math.floor(g)==g}var d,f;if(a.map_diffuse&&b){f=document.createElement("canvas");d=new THREE.MeshLambertMaterial({map:new THREE.Texture(f)});f=new Image;f.onload=function(){if(!e(this.width)||
- !e(this.height)){var g=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),l=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));d.map.image.width=g;d.map.image.height=l;d.map.image.getContext("2d").drawImage(this,0,0,g,l)}else d.map.image=this;d.map.image.loaded=1};f.src=b+"/"+a.map_diffuse}else if(a.col_diffuse){f=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;d=new THREE.MeshLambertMaterial({color:f,opacity:a.transparency})}else d=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):
- new THREE.MeshLambertMaterial({color:15658734});return d}};
|