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