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