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