ThreeExtras.js 105 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. // ThreeExtras.js r31 - http://github.com/mrdoob/three.js
  2. var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
  3. THREE.Color.prototype={setRGB:function(a,b,e){this.r=a;this.g=b;this.b=e;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+
  4. ","+~~(this.g*255)+","+~~(this.b*255)+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
  5. 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*
  6. this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,e){this.x=a||0;this.y=b||0;this.z=e||0};
  7. THREE.Vector3.prototype={set:function(a,b,e){this.x=a;this.y=b;this.z=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
  8. cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,e=this.y,d=this.z;this.x=e*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-e*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=
  9. a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+e*e+a*a)},distanceToSquared:function(a){var b=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return b*b+e*e+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=
  10. 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+" )"}};
  11. THREE.Vector4=function(a,b,e,d){this.x=a||0;this.y=b||0;this.z=e||0;this.w=d||1};
  12. THREE.Vector4.prototype={set:function(a,b,e,d){this.x=a;this.y=b;this.z=e;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
  13. 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+")"}};
  14. THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
  15. THREE.Ray.prototype={intersectScene:function(a){var b,e,d=a.objects,g=[];a=0;for(b=d.length;a<b;a++){e=d[a];if(e instanceof THREE.Mesh)g=g.concat(this.intersectObject(e))}g.sort(function(l,h){return l.distance-h.distance});return g},intersectObject:function(a){function b(J,H,D,n){n=n.clone().subSelf(H);D=D.clone().subSelf(H);var i=J.clone().subSelf(H);J=n.dot(n);H=n.dot(D);n=n.dot(i);var p=D.dot(D);D=D.dot(i);i=1/(J*p-H*H);p=(p*n-H*D)*i;J=(J*D-H*n)*i;return p>0&&J>0&&p+J<1}var e,d,g,l,h,f,j,c,t,y,
  16. s,q=a.geometry,x=q.vertices,B=[];e=0;for(d=q.faces.length;e<d;e++){g=q.faces[e];y=this.origin.clone();s=this.direction.clone();l=a.matrix.multiplyVector3(x[g.a].position.clone());h=a.matrix.multiplyVector3(x[g.b].position.clone());f=a.matrix.multiplyVector3(x[g.c].position.clone());j=g instanceof THREE.Face4?a.matrix.multiplyVector3(x[g.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(g.normal.clone());t=s.dot(c);if(t<0){c=c.dot((new THREE.Vector3).sub(l,y))/t;y=y.addSelf(s.multiplyScalar(c));
  17. if(g instanceof THREE.Face3){if(b(y,l,h,f)){g={distance:this.origin.distanceTo(y),point:y,face:g,object:a};B.push(g)}}else if(g instanceof THREE.Face4)if(b(y,l,h,j)||b(y,h,f,j)){g={distance:this.origin.distanceTo(y),point:y,face:g,object:a};B.push(g)}}}return B}};
  18. THREE.Rectangle=function(){function a(){l=d-b;h=g-e}var b,e,d,g,l,h,f=true;this.getX=function(){return b};this.getY=function(){return e};this.getWidth=function(){return l};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return e};this.getRight=function(){return d};this.getBottom=function(){return g};this.set=function(j,c,t,y){f=false;b=j;e=c;d=t;g=y;a()};this.addPoint=function(j,c){if(f){f=false;b=j;e=c;d=j;g=c}else{b=b<j?b:j;e=e<c?e:c;d=d>j?d:j;g=g>c?
  19. g:c}a()};this.add3Points=function(j,c,t,y,s,q){if(f){f=false;b=j<t?j<s?j:s:t<s?t:s;e=c<y?c<q?c:q:y<q?y:q;d=j>t?j>s?j:s:t>s?t:s;g=c>y?c>q?c:q:y>q?y:q}else{b=j<t?j<s?j<b?j:b:s<b?s:b:t<s?t<b?t:b:s<b?s:b;e=c<y?c<q?c<e?c:e:q<e?q:e:y<q?y<e?y:e:q<e?q:e;d=j>t?j>s?j>d?j:d:s>d?s:d:t>s?t>d?t:d:s>d?s:d;g=c>y?c>q?c>g?c:g:q>g?q:g:y>q?y>g?y:g:q>g?q:g}a()};this.addRectangle=function(j){if(f){f=false;b=j.getLeft();e=j.getTop();d=j.getRight();g=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();e=e<j.getTop()?e:j.getTop();
  20. d=d>j.getRight()?d:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){b-=j;e-=j;d+=j;g+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();e=e>j.getTop()?e:j.getTop();d=d<j.getRight()?d:j.getRight();g=g<j.getBottom()?g:j.getBottom();a()};this.instersects=function(j){return Math.min(d,j.getRight())-Math.max(b,j.getLeft())>=0&&Math.min(g,j.getBottom())-Math.max(e,j.getTop())>=0};this.empty=function(){f=true;g=d=e=b=0;a()};this.isEmpty=function(){return f};this.toString=
  21. function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+e+", bottom: "+g+", width: "+l+", height: "+h+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
  22. THREE.Matrix4=function(a,b,e,d,g,l,h,f,j,c,t,y,s,q,x,B){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=d||0;this.n21=g||0;this.n22=l||1;this.n23=h||0;this.n24=f||0;this.n31=j||0;this.n32=c||0;this.n33=t||1;this.n34=y||0;this.n41=s||0;this.n42=q||0;this.n43=x||0;this.n44=B||1};
  23. THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,e,d,g,l,h,f,j,c,t,y,s,q,x,B){this.n11=a;this.n12=b;this.n13=e;this.n14=d;this.n21=g;this.n22=l;this.n23=h;this.n24=f;this.n31=j;this.n32=c;this.n33=t;this.n34=y;this.n41=s;this.n42=q;this.n43=x;this.n44=B;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
  24. a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,e){var d=new THREE.Vector3,g=new THREE.Vector3,l=new THREE.Vector3;l.sub(a,b).normalize();d.cross(e,l).normalize();g.cross(l,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=l.x;
  25. this.n32=l.y;this.n33=l.z;this.n34=-l.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,e=a.y,d=a.z,g=1/(this.n41*b+this.n42*e+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*e+this.n13*d+this.n14)*g;a.y=(this.n21*b+this.n22*e+this.n23*d+this.n24)*g;a.z=(this.n31*b+this.n32*e+this.n33*d+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,e=a.y,d=a.z,g=a.w;a.x=this.n11*b+this.n12*e+this.n13*d+this.n14*g;a.y=this.n21*b+this.n22*e+this.n23*d+this.n24*
  26. g;a.z=this.n31*b+this.n32*e+this.n33*d+this.n34*g;a.w=this.n41*b+this.n42*e+this.n43*d+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var e=a.n11,d=a.n12,g=a.n13,l=a.n14,h=a.n21,f=a.n22,j=a.n23,c=a.n24,t=a.n31,y=a.n32,
  27. s=a.n33,q=a.n34,x=a.n41,B=a.n42,J=a.n43,H=a.n44,D=b.n11,n=b.n12,i=b.n13,p=b.n14,k=b.n21,w=b.n22,o=b.n23,m=b.n24,v=b.n31,L=b.n32,C=b.n33,A=b.n34,P=b.n41,I=b.n42,M=b.n43,W=b.n44;this.n11=e*D+d*k+g*v+l*P;this.n12=e*n+d*w+g*L+l*I;this.n13=e*i+d*o+g*C+l*M;this.n14=e*p+d*m+g*A+l*W;this.n21=h*D+f*k+j*v+c*P;this.n22=h*n+f*w+j*L+c*I;this.n23=h*i+f*o+j*C+c*M;this.n24=h*p+f*m+j*A+c*W;this.n31=t*D+y*k+s*v+q*P;this.n32=t*n+y*w+s*L+q*I;this.n33=t*i+y*o+s*C+q*M;this.n34=t*p+y*m+s*A+q*W;this.n41=x*D+B*k+J*v+H*P;
  28. this.n42=x*n+B*w+J*L+H*I;this.n43=x*i+B*o+J*C+H*M;this.n44=x*p+B*m+J*A+H*W;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,d=this.n13,g=this.n14,l=this.n21,h=this.n22,f=this.n23,j=this.n24,c=this.n31,t=this.n32,y=this.n33,s=this.n34,q=this.n41,x=this.n42,B=this.n43,J=this.n44,H=a.n11,D=a.n21,n=a.n31,i=a.n41,p=a.n12,k=a.n22,w=a.n32,o=a.n42,m=a.n13,v=a.n23,L=a.n33,C=a.n43,A=a.n14,P=a.n24,I=a.n34;a=a.n44;this.n11=b*H+e*D+d*n+g*i;this.n12=b*p+e*k+d*w+g*o;this.n13=b*m+e*v+d*L+g*C;this.n14=
  29. b*A+e*P+d*I+g*a;this.n21=l*H+h*D+f*n+j*i;this.n22=l*p+h*k+f*w+j*o;this.n23=l*m+h*v+f*L+j*C;this.n24=l*A+h*P+f*I+j*a;this.n31=c*H+t*D+y*n+s*i;this.n32=c*p+t*k+y*w+s*o;this.n33=c*m+t*v+y*L+s*C;this.n34=c*A+t*P+y*I+s*a;this.n41=q*H+x*D+B*n+J*i;this.n42=q*p+x*k+B*w+J*o;this.n43=q*m+x*v+B*L+J*C;this.n44=q*A+x*P+B*I+J*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*=
  30. a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*
  31. this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,e,d){var g=b[e];b[e]=b[d];
  32. b[d]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
  33. this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,e){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=e;return d};
  34. THREE.Matrix4.scaleMatrix=function(a,b,e){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=e;return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b};
  35. THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var e=new THREE.Matrix4,d=Math.cos(b),g=Math.sin(b),l=1-d,h=a.x,f=a.y,j=a.z;e.n11=l*h*h+d;e.n12=l*h*f-g*j;e.n13=l*h*j+g*f;e.n21=l*h*f+g*j;e.n22=l*f*f+d;e.n23=l*f*j-g*h;e.n31=l*h*j-g*f;e.n32=l*f*j+g*h;e.n33=l*j*j+d;return e};
  36. THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
  37. a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
  38. a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
  39. a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b};
  40. THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var e=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],l=-b[10]*b[4]+b[6]*b[8],h=b[10]*b[0]-b[2]*b[8],f=-b[6]*b[0]+b[2]*b[4],j=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],t=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*l+b[2]*j;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*e;a.m[1]=b*d;a.m[2]=b*g;a.m[3]=b*l;a.m[4]=b*h;a.m[5]=b*f;a.m[6]=b*j;a.m[7]=b*c;a.m[8]=b*t;return a};
  41. THREE.Matrix4.makeFrustum=function(a,b,e,d,g,l){var h,f,j;h=new THREE.Matrix4;f=2*g/(b-a);j=2*g/(d-e);a=(b+a)/(b-a);e=(d+e)/(d-e);d=-(l+g)/(l-g);g=-2*l*g/(l-g);h.n11=f;h.n12=0;h.n13=a;h.n14=0;h.n21=0;h.n22=j;h.n23=e;h.n24=0;h.n31=0;h.n32=0;h.n33=d;h.n34=g;h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,e,d){var g;a=e*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,e,d)};
  42. THREE.Matrix4.makeOrtho=function(a,b,e,d,g,l){var h,f,j,c;h=new THREE.Matrix4;f=b-a;j=e-d;c=l-g;a=(b+a)/f;e=(e+d)/j;g=(l+g)/c;h.n11=2/f;h.n12=0;h.n13=0;h.n14=-a;h.n21=0;h.n22=2/j;h.n23=0;h.n24=-e;h.n31=0;h.n32=0;h.n33=-2/c;h.n34=-g;h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};
  43. 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+" )"}};
  44. THREE.Face3=function(a,b,e,d,g){this.a=a;this.b=b;this.c=e;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.material=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
  45. THREE.Face4=function(a,b,e,d,g,l){this.a=a;this.b=b;this.c=e;this.d=d;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.material=l instanceof Array?l:[l]};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};
  46. THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.geometryChunks={};this.hasTangents=false};
  47. THREE.Geometry.prototype={computeCentroids:function(){var a,b,e;a=0;for(b=this.faces.length;a<b;a++){e=this.faces[a];e.centroid.set(0,0,0);if(e instanceof THREE.Face3){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);e.centroid.divideScalar(3)}else if(e instanceof THREE.Face4){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);
  48. e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,e,d,g,l,h,f=new THREE.Vector3,j=new THREE.Vector3;d=0;for(g=this.vertices.length;d<g;d++){l=this.vertices[d];l.normal.set(0,0,0)}d=0;for(g=this.faces.length;d<g;d++){l=this.faces[d];if(a&&l.vertexNormals.length){f.set(0,0,0);b=0;for(e=l.normal.length;b<e;b++)f.addSelf(l.vertexNormals[b]);f.divideScalar(3)}else{b=this.vertices[l.a];e=this.vertices[l.b];h=this.vertices[l.c];f.sub(h.position,
  49. e.position);j.sub(b.position,e.position);f.crossSelf(j)}f.isZero()||f.normalize();l.normal.copy(f)}},computeVertexNormals:function(){var a,b=[],e,d;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(e=this.faces.length;a<e;a++){d=this.faces[a];if(d instanceof THREE.Face3){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal);b[d.d].addSelf(d.normal)}}a=
  50. 0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(e=this.faces.length;a<e;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone()}else if(d instanceof THREE.Face4){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone();d.vertexNormals[3]=b[d.d].clone()}}},computeTangents:function(){function a(A,P,I,M){l=A.vertices[P].position;h=A.vertices[I].position;
  51. f=A.vertices[M].position;j=g[0];c=g[1];t=g[2];y=h.x-l.x;s=f.x-l.x;q=h.y-l.y;x=f.y-l.y;B=h.z-l.z;J=f.z-l.z;H=c.u-j.u;D=t.u-j.u;n=c.v-j.v;i=t.v-j.v;p=1/(H*i-D*n);m.set((i*y-n*s)*p,(i*q-n*x)*p,(i*B-n*J)*p);v.set((H*s-D*y)*p,(H*x-D*q)*p,(H*J-D*B)*p);w[P].addSelf(m);w[I].addSelf(m);w[M].addSelf(m);o[P].addSelf(v);o[I].addSelf(v);o[M].addSelf(v)}var b,e,d,g,l,h,f,j,c,t,y,s,q,x,B,J,H,D,n,i,p,k,w=[],o=[],m=new THREE.Vector3,v=new THREE.Vector3,L=new THREE.Vector3,C=new THREE.Vector3;k=new THREE.Vector3;b=
  52. 0;for(e=this.vertices.length;b<e;b++){w[b]=new THREE.Vector3;o[b]=new THREE.Vector3}b=0;for(e=this.faces.length;b<e;b++){d=this.faces[b];g=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);
  53. this.vertices[d.c].normal.copy(d.vertexNormals[2]);this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(e=this.vertices.length;b<e;b++){k.copy(this.vertices[b].normal);d=w[b];L.copy(d);L.subSelf(k.multiplyScalar(k.dot(d))).normalize();C.cross(this.vertices[b].normal,d);test=C.dot(o[b]);d=test<0?-1:1;this.vertices[b].tangent.set(L.x,L.y,L.z,d)}this.hasTangents=true},computeBoundingBox:function(){if(this.vertices.length>0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x],
  54. y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var a=1,b=this.vertices.length;a<b;a++){vertex=this.vertices[a];if(vertex.position.x<this.bbox.x[0])this.bbox.x[0]=vertex.position.x;else if(vertex.position.x>this.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.y<this.bbox.y[0])this.bbox.y[0]=vertex.position.y;else if(vertex.position.y>this.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.z<this.bbox.z[0])this.bbox.z[0]=
  55. vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(t){var y=[];b=0;for(e=t.length;b<e;b++)t[b]==undefined?y.push("undefined"):y.push(t[b].toString());return y.join("_")}var b,e,d,g,l,h,f,j,c={};d=0;for(g=this.faces.length;d<g;d++){l=this.faces[d];h=l.material;f=a(h);if(c[f]==undefined)c[f]={hash:f,counter:0};j=c[f].hash+"_"+c[f].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],material:h,
  56. vertices:0};l=l instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+l>65535){c[f].counter+=1;j=c[f].hash+"_"+c[f].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],material:h,vertices:0}}this.geometryChunks[j].faces.push(d);this.geometryChunks[j].vertices+=l}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
  57. THREE.Camera=function(a,b,e,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,e,d);this.autoUpdateMatrix=true;this.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);
  58. this.position.subSelf(g);this.target.position.subSelf(g)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
  59. THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
  60. THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);
  61. this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};
  62. THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
  63. THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.computeBoundingBox()};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;
  64. THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}this.toString=function(){return"THREE.LineBasicMaterial (<br/>color: "+
  65. this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>)"}};
  66. THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
  67. a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=
  68. a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>blending: "+
  69. 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};
  70. THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
  71. a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=
  72. a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+
  73. 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};
  74. THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.env_map=this.specular_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap=
  75. "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=
  76. a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=
  77. a.wireframe_linejoin}this.toString=function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>map: "+this.map+"<br/>specular_map: "+this.specular_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+
  78. 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};
  79. THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1E3;this.opacity=1;this.blending=THREE.NormalBlending;if(a){if(a.near!==undefined)this.near=a.near;if(a.far!==undefined)this.far=a.far;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=this.far-this.near;this.toString=function(){return"THREE.MeshDepthMaterial"}};
  80. THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){this.toString=function(){return"THREE.MeshFaceMaterial"}};
  81. THREE.MeshCubeMaterial=function(a){this.id=THREE.MeshCubeMaterial.value++;this.env_map=null;this.blending=THREE.NormalBlending;if(a)if(a.env_map!==undefined)this.env_map=a.env_map;this.toString=function(){return"THREE.MeshCubeMaterial( id: "+this.id+"<br/>env_map: "+this.env_map+" )"}};THREE.MeshCubeMaterialCounter={value:0};
  82. 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!==
  83. undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+
  84. "<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};
  85. THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+
  86. this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
  87. THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
  88. THREE.Texture=function(a,b,e,d,g,l){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=l!==undefined?l:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+
  89. this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
  90. THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
  91. THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
  92. THREE.Projector=function(){function a(k,w){var o=0,m=1,v=k.z+k.w,L=w.z+w.w,C=-k.z+k.w,A=-w.z+w.w;if(v>=0&&L>=0&&C>=0&&A>=0)return true;else if(v<0&&L<0||C<0&&A<0)return false;else{if(v<0)o=Math.max(o,v/(v-L));else if(L<0)m=Math.min(m,v/(v-L));if(C<0)o=Math.max(o,C/(C-A));else if(A<0)m=Math.min(m,C/(C-A));if(m<o)return false;else{k.lerpSelf(w,o);w.lerpSelf(k,1-m);return true}}}function b(k,w){return w.z-k.z}var e=null,d,g,l=[],h,f,j,c=[],t,y,s=[],q,x,B=[],J=new THREE.Vector4,H=new THREE.Matrix4,D=
  93. new THREE.Matrix4,n=new THREE.Vector4,i=new THREE.Vector4,p;this.projectObjects=function(k,w){var o,m,v,L;e=[];g=0;H.multiply(w.projectionMatrix,w.matrix);v=k.objects;o=0;for(m=v.length;o<m;o++){L=v[o];if(L.visible!==false){d=l[g]=l[g]||new THREE.RenderableObject;J.copy(L.position);H.multiplyVector4(J);d.object=L;d.z=J.z;e.push(d);g++}}e.sort(b);return e};this.projectScene=function(k,w){var o,m,v,L,C,A,P,I,M,W,S,$,V,N,z,F,T;e=[];j=y=x=0;w.autoUpdateMatrix&&w.updateMatrix();H.multiply(w.projectionMatrix,
  94. w.matrix);P=k.objects;o=0;for(m=P.length;o<m;o++){I=P[o];if(I.visible!==false){I.autoUpdateMatrix&&I.updateMatrix();M=I.matrix;W=I.rotationMatrix;S=I.material;$=I.overdraw;if(I instanceof THREE.Mesh){V=I.geometry;N=V.vertices;v=0;for(L=N.length;v<L;v++){z=N[v];z.positionWorld.copy(z.position);M.multiplyVector3(z.positionWorld);C=z.positionScreen;C.copy(z.positionWorld);H.multiplyVector4(C);C.multiplyScalar(1/C.w);z.__visible=C.z>0&&C.z<1}V=V.faces;v=0;for(L=V.length;v<L;v++){z=V[v];if(z instanceof
  95. THREE.Face3){C=N[z.a];A=N[z.b];F=N[z.c];if(C.__visible&&A.__visible&&F.__visible)if(I.doubleSided||I.flipSided!=(F.positionScreen.x-C.positionScreen.x)*(A.positionScreen.y-C.positionScreen.y)-(F.positionScreen.y-C.positionScreen.y)*(A.positionScreen.x-C.positionScreen.x)<0){h=c[j]=c[j]||new THREE.RenderableFace3;h.v1.positionWorld.copy(C.positionWorld);h.v2.positionWorld.copy(A.positionWorld);h.v3.positionWorld.copy(F.positionWorld);h.v1.positionScreen.copy(C.positionScreen);h.v2.positionScreen.copy(A.positionScreen);
  96. h.v3.positionScreen.copy(F.positionScreen);h.normalWorld.copy(z.normal);W.multiplyVector3(h.normalWorld);h.centroidWorld.copy(z.centroid);M.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);H.multiplyVector3(h.centroidScreen);F=z.vertexNormals;p=h.vertexNormalsWorld;C=0;for(A=F.length;C<A;C++){T=p[C]=p[C]||new THREE.Vector3;T.copy(F[C]);W.multiplyVector3(T)}h.z=h.centroidScreen.z;h.meshMaterial=S;h.faceMaterial=z.material;h.overdraw=$;if(I.geometry.uvs[v]){h.uvs[0]=I.geometry.uvs[v][0];
  97. h.uvs[1]=I.geometry.uvs[v][1];h.uvs[2]=I.geometry.uvs[v][2]}e.push(h);j++}}else if(z instanceof THREE.Face4){C=N[z.a];A=N[z.b];F=N[z.c];T=N[z.d];if(C.__visible&&A.__visible&&F.__visible&&T.__visible)if(I.doubleSided||I.flipSided!=((T.positionScreen.x-C.positionScreen.x)*(A.positionScreen.y-C.positionScreen.y)-(T.positionScreen.y-C.positionScreen.y)*(A.positionScreen.x-C.positionScreen.x)<0||(A.positionScreen.x-F.positionScreen.x)*(T.positionScreen.y-F.positionScreen.y)-(A.positionScreen.y-F.positionScreen.y)*
  98. (T.positionScreen.x-F.positionScreen.x)<0)){h=c[j]=c[j]||new THREE.RenderableFace3;h.v1.positionWorld.copy(C.positionWorld);h.v2.positionWorld.copy(A.positionWorld);h.v3.positionWorld.copy(T.positionWorld);h.v1.positionScreen.copy(C.positionScreen);h.v2.positionScreen.copy(A.positionScreen);h.v3.positionScreen.copy(T.positionScreen);h.normalWorld.copy(z.normal);W.multiplyVector3(h.normalWorld);h.centroidWorld.copy(z.centroid);M.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);
  99. H.multiplyVector3(h.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterial=S;h.faceMaterial=z.material;h.overdraw=$;if(I.geometry.uvs[v]){h.uvs[0]=I.geometry.uvs[v][0];h.uvs[1]=I.geometry.uvs[v][1];h.uvs[2]=I.geometry.uvs[v][3]}e.push(h);j++;f=c[j]=c[j]||new THREE.RenderableFace3;f.v1.positionWorld.copy(A.positionWorld);f.v2.positionWorld.copy(F.positionWorld);f.v3.positionWorld.copy(T.positionWorld);f.v1.positionScreen.copy(A.positionScreen);f.v2.positionScreen.copy(F.positionScreen);f.v3.positionScreen.copy(T.positionScreen);
  100. f.normalWorld.copy(h.normalWorld);f.centroidWorld.copy(h.centroidWorld);f.centroidScreen.copy(h.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterial=S;f.faceMaterial=z.material;f.overdraw=$;if(I.geometry.uvs[v]){f.uvs[0]=I.geometry.uvs[v][1];f.uvs[1]=I.geometry.uvs[v][2];f.uvs[2]=I.geometry.uvs[v][3]}e.push(f);j++}}}}else if(I instanceof THREE.Line){D.multiply(H,M);N=I.geometry.vertices;z=N[0];z.positionScreen.copy(z.position);D.multiplyVector4(z.positionScreen);v=1;for(L=N.length;v<L;v++){C=N[v];
  101. C.positionScreen.copy(C.position);D.multiplyVector4(C.positionScreen);A=N[v-1];n.copy(C.positionScreen);i.copy(A.positionScreen);if(a(n,i)){n.multiplyScalar(1/n.w);i.multiplyScalar(1/i.w);t=s[y]=s[y]||new THREE.RenderableLine;t.v1.positionScreen.copy(n);t.v2.positionScreen.copy(i);t.z=Math.max(n.z,i.z);t.material=I.material;e.push(t);y++}}}else if(I instanceof THREE.Particle){J.set(I.position.x,I.position.y,I.position.z,1);H.multiplyVector4(J);J.z/=J.w;if(J.z>0&&J.z<1){q=B[x]=B[x]||new THREE.RenderableParticle;
  102. q.x=J.x/J.w;q.y=J.y/J.w;q.z=J.z;q.rotation=I.rotation.z;q.scale.x=I.scale.x*Math.abs(q.x-(J.x+w.projectionMatrix.n11)/(J.w+w.projectionMatrix.n14));q.scale.y=I.scale.y*Math.abs(q.y-(J.y+w.projectionMatrix.n22)/(J.w+w.projectionMatrix.n24));q.material=I.material;e.push(q);x++}}}}e.sort(b);return e};this.unprojectVector=function(k,w){var o=new THREE.Matrix4;o.multiply(THREE.Matrix4.makeInvert(w.matrix),THREE.Matrix4.makeInvert(w.projectionMatrix));o.multiplyVector3(k);return k}};
  103. THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,d,g,l;this.domElement=document.createElement("div");this.setSize=function(h,f){e=h;d=f;g=e/2;l=d/2};this.render=function(h,f){var j,c,t,y,s,q,x,B;a=b.projectScene(h,f);j=0;for(c=a.length;j<c;j++){s=a[j];if(s instanceof THREE.RenderableParticle){x=s.x*g+g;B=s.y*l+l;t=0;for(y=s.material.length;t<y;t++){q=s.material[t];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=x+"px";q.style.top=B+"px"}}}}}};
  104. THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,e=document.createElement("canvas"),d,g,l,h,f=e.getContext("2d"),j=1,c=0,t=null,y=null,s=1,q,x,B,J,H,D,n,i,p,k=new THREE.Color,w=new THREE.Color,o=new THREE.Color,m=new THREE.Color,v=new THREE.Color,L,C,A,P,I,M,W,S,$,V,N=new THREE.Rectangle,z=new THREE.Rectangle,F=new THREE.Rectangle,T=false,r=new THREE.Color,u=new THREE.Color,E=new THREE.Color,O=new THREE.Color,X=Math.PI*2,Y=new THREE.Vector3,ea,ma,oa,fa,ra,va,pa=16;ea=document.createElement("canvas");
  105. ea.width=ea.height=2;ma=ea.getContext("2d");ma.fillStyle="rgba(0,0,0,1)";ma.fillRect(0,0,2,2);oa=ma.getImageData(0,0,2,2);fa=oa.data;ra=document.createElement("canvas");ra.width=ra.height=pa;va=ra.getContext("2d");va.translate(-pa/2,-pa/2);va.scale(pa,pa);pa--;this.domElement=e;this.autoClear=true;this.setSize=function(ia,wa){d=ia;g=wa;l=d/2;h=g/2;e.width=d;e.height=g;N.set(-l,-h,l,h)};this.clear=function(){if(!z.isEmpty()){z.inflate(1);z.minSelf(N);f.clearRect(z.getX(),z.getY(),z.getWidth(),z.getHeight());
  106. z.empty()}};this.render=function(ia,wa){function Ka(G){var U,R,K,Q=G.lights;u.setRGB(0,0,0);E.setRGB(0,0,0);O.setRGB(0,0,0);G=0;for(U=Q.length;G<U;G++){R=Q[G];K=R.color;if(R instanceof THREE.AmbientLight){u.r+=K.r;u.g+=K.g;u.b+=K.b}else if(R instanceof THREE.DirectionalLight){E.r+=K.r;E.g+=K.g;E.b+=K.b}else if(R instanceof THREE.PointLight){O.r+=K.r;O.g+=K.g;O.b+=K.b}}}function xa(G,U,R,K){var Q,Z,ba,ca,da=G.lights;G=0;for(Q=da.length;G<Q;G++){Z=da[G];ba=Z.color;ca=Z.intensity;if(Z instanceof THREE.DirectionalLight){Z=
  107. R.dot(Z.position)*ca;if(Z>0){K.r+=ba.r*Z;K.g+=ba.g*Z;K.b+=ba.b*Z}}else if(Z instanceof THREE.PointLight){Y.sub(Z.position,U);Y.normalize();Z=R.dot(Y)*ca;if(Z>0){K.r+=ba.r*Z;K.g+=ba.g*Z;K.b+=ba.b*Z}}}}function La(G,U,R){if(R.opacity!=0){Ca(R.opacity);ya(R.blending);var K,Q,Z,ba,ca,da;if(R instanceof THREE.ParticleBasicMaterial){if(R.map){ba=R.map;ca=ba.width>>1;da=ba.height>>1;Q=U.scale.x*l;Z=U.scale.y*h;R=Q*ca;K=Z*da;F.set(G.x-R,G.y-K,G.x+R,G.y+K);if(N.instersects(F)){f.save();f.translate(G.x,G.y);
  108. f.rotate(-U.rotation);f.scale(Q,-Z);f.translate(-ca,-da);f.drawImage(ba,0,0);f.restore()}}}else if(R instanceof THREE.ParticleCircleMaterial){if(T){r.r=u.r+E.r+O.r;r.g=u.g+E.g+O.g;r.b=u.b+E.b+O.b;k.r=R.color.r*r.r;k.g=R.color.g*r.g;k.b=R.color.b*r.b;k.updateStyleString()}else k.__styleString=R.color.__styleString;R=U.scale.x*l;K=U.scale.y*h;F.set(G.x-R,G.y-K,G.x+R,G.y+K);if(N.instersects(F)){Q=k.__styleString;if(y!=Q)f.fillStyle=y=Q;f.save();f.translate(G.x,G.y);f.rotate(-U.rotation);f.scale(R,K);
  109. f.beginPath();f.arc(0,0,1,0,X,true);f.closePath();f.fill();f.restore()}}}}function Ma(G,U,R,K){if(K.opacity!=0){Ca(K.opacity);ya(K.blending);f.beginPath();f.moveTo(G.positionScreen.x,G.positionScreen.y);f.lineTo(U.positionScreen.x,U.positionScreen.y);f.closePath();if(K instanceof THREE.LineBasicMaterial){k.__styleString=K.color.__styleString;G=K.linewidth;if(s!=G)f.lineWidth=s=G;G=k.__styleString;if(t!=G)f.strokeStyle=t=G;f.stroke();F.inflate(K.linewidth*2)}}}function Ga(G,U,R,K,Q,Z){if(Q.opacity!=
  110. 0){Ca(Q.opacity);ya(Q.blending);J=G.positionScreen.x;H=G.positionScreen.y;D=U.positionScreen.x;n=U.positionScreen.y;i=R.positionScreen.x;p=R.positionScreen.y;f.beginPath();f.moveTo(J,H);f.lineTo(D,n);f.lineTo(i,p);f.lineTo(J,H);f.closePath();if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&sa(J,H,D,n,i,p,Q.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);else if(Q.env_map){if(Q.env_map.image.loaded)if(Q.env_map.mapping instanceof
  111. THREE.SphericalReflectionMapping){G=wa.matrix;Y.copy(K.vertexNormalsWorld[0]);I=(Y.x*G.n11+Y.y*G.n12+Y.z*G.n13)*0.5+0.5;M=-(Y.x*G.n21+Y.y*G.n22+Y.z*G.n23)*0.5+0.5;Y.copy(K.vertexNormalsWorld[1]);W=(Y.x*G.n11+Y.y*G.n12+Y.z*G.n13)*0.5+0.5;S=-(Y.x*G.n21+Y.y*G.n22+Y.z*G.n23)*0.5+0.5;Y.copy(K.vertexNormalsWorld[2]);$=(Y.x*G.n11+Y.y*G.n12+Y.z*G.n13)*0.5+0.5;V=-(Y.x*G.n21+Y.y*G.n22+Y.z*G.n23)*0.5+0.5;sa(J,H,D,n,i,p,Q.env_map.image,I,M,W,S,$,V)}}else Q.wireframe?za(Q.color.__styleString,Q.wireframe_linewidth):
  112. Aa(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&!Q.wireframe){Q.map.mapping instanceof THREE.UVMapping&&sa(J,H,D,n,i,p,Q.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);ya(THREE.SubtractiveBlending)}if(T)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&K.vertexNormalsWorld.length==3){w.r=o.r=m.r=u.r;w.g=o.g=m.g=u.g;w.b=o.b=m.b=u.b;xa(Z,K.v1.positionWorld,K.vertexNormalsWorld[0],w);xa(Z,K.v2.positionWorld,K.vertexNormalsWorld[1],o);xa(Z,
  113. K.v3.positionWorld,K.vertexNormalsWorld[2],m);v.r=(o.r+m.r)*0.5;v.g=(o.g+m.g)*0.5;v.b=(o.b+m.b)*0.5;P=Ha(w,o,m,v);sa(J,H,D,n,i,p,P,0,0,1,0,0,1)}else{r.r=u.r;r.g=u.g;r.b=u.b;xa(Z,K.centroidWorld,K.normalWorld,r);k.r=Q.color.r*r.r;k.g=Q.color.g*r.g;k.b=Q.color.b*r.b;k.updateStyleString();Q.wireframe?za(k.__styleString,Q.wireframe_linewidth):Aa(k.__styleString)}else Q.wireframe?za(Q.color.__styleString,Q.wireframe_linewidth):Aa(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){L=Q.__2near;
  114. C=Q.__farPlusNear;A=Q.__farMinusNear;w.r=w.g=w.b=1-L/(C-G.positionScreen.z*A);o.r=o.g=o.b=1-L/(C-U.positionScreen.z*A);m.r=m.g=m.b=1-L/(C-R.positionScreen.z*A);v.r=(o.r+m.r)*0.5;v.g=(o.g+m.g)*0.5;v.b=(o.b+m.b)*0.5;P=Ha(w,o,m,v);sa(J,H,D,n,i,p,P,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){k.r=Da(K.normalWorld.x);k.g=Da(K.normalWorld.y);k.b=Da(K.normalWorld.z);k.updateStyleString();Q.wireframe?za(k.__styleString,Q.wireframe_linewidth):Aa(k.__styleString)}}}function za(G,U){if(t!=G)f.strokeStyle=
  115. t=G;if(s!=U)f.lineWidth=s=U;f.stroke();F.inflate(U*2)}function Aa(G){if(y!=G)f.fillStyle=y=G;f.fill()}function sa(G,U,R,K,Q,Z,ba,ca,da,ja,ga,ka,ta){var na,la;na=ba.width-1;la=ba.height-1;ca*=na;da*=la;ja*=na;ga*=la;ka*=na;ta*=la;R-=G;K-=U;Q-=G;Z-=U;ja-=ca;ga-=da;ka-=ca;ta-=da;la=1/(ja*ta-ka*ga);na=(ta*R-ga*Q)*la;ga=(ta*K-ga*Z)*la;R=(ja*Q-ka*R)*la;K=(ja*Z-ka*K)*la;G=G-na*ca-R*da;U=U-ga*ca-K*da;f.save();f.transform(na,ga,R,K,G,U);f.clip();f.drawImage(ba,0,0);f.restore()}function Ca(G){if(j!=G)f.globalAlpha=
  116. j=G}function ya(G){if(c!=G){switch(G){case THREE.NormalBlending:f.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:f.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:f.globalCompositeOperation="darker"}c=G}}function Ha(G,U,R,K){var Q=~~(G.r*255),Z=~~(G.g*255);G=~~(G.b*255);var ba=~~(U.r*255),ca=~~(U.g*255);U=~~(U.b*255);var da=~~(R.r*255),ja=~~(R.g*255);R=~~(R.b*255);var ga=~~(K.r*255),ka=~~(K.g*255);K=~~(K.b*255);fa[0]=Q<0?0:Q>255?255:Q;fa[1]=Z<0?0:
  117. Z>255?255:Z;fa[2]=G<0?0:G>255?255:G;fa[4]=ba<0?0:ba>255?255:ba;fa[5]=ca<0?0:ca>255?255:ca;fa[6]=U<0?0:U>255?255:U;fa[8]=da<0?0:da>255?255:da;fa[9]=ja<0?0:ja>255?255:ja;fa[10]=R<0?0:R>255?255:R;fa[12]=ga<0?0:ga>255?255:ga;fa[13]=ka<0?0:ka>255?255:ka;fa[14]=K<0?0:K>255?255:K;ma.putImageData(oa,0,0);va.drawImage(ea,0,0);return ra}function Da(G){G=(G+1)*0.5;return G<0?0:G>1?1:G}function Ea(G,U){var R=U.x-G.x,K=U.y-G.y,Q=1/Math.sqrt(R*R+K*K);R*=Q;K*=Q;U.x+=R;U.y+=K;G.x-=R;G.y-=K}var Ba,Ia,aa,ha,qa,Fa,
  118. Ja,ua;f.setTransform(1,0,0,-1,l,h);this.autoClear&&this.clear();a=b.projectScene(ia,wa);(T=ia.lights.length>0)&&Ka(ia);Ba=0;for(Ia=a.length;Ba<Ia;Ba++){aa=a[Ba];F.empty();if(aa instanceof THREE.RenderableParticle){q=aa;q.x*=l;q.y*=h;ha=0;for(qa=aa.material.length;ha<qa;ha++)La(q,aa,aa.material[ha],ia)}else if(aa instanceof THREE.RenderableLine){q=aa.v1;x=aa.v2;q.positionScreen.x*=l;q.positionScreen.y*=h;x.positionScreen.x*=l;x.positionScreen.y*=h;F.addPoint(q.positionScreen.x,q.positionScreen.y);
  119. F.addPoint(x.positionScreen.x,x.positionScreen.y);if(N.instersects(F)){ha=0;for(qa=aa.material.length;ha<qa;)Ma(q,x,aa,aa.material[ha++],ia)}}else if(aa instanceof THREE.RenderableFace3){q=aa.v1;x=aa.v2;B=aa.v3;q.positionScreen.x*=l;q.positionScreen.y*=h;x.positionScreen.x*=l;x.positionScreen.y*=h;B.positionScreen.x*=l;B.positionScreen.y*=h;if(aa.overdraw){Ea(q.positionScreen,x.positionScreen);Ea(x.positionScreen,B.positionScreen);Ea(B.positionScreen,q.positionScreen)}F.add3Points(q.positionScreen.x,
  120. q.positionScreen.y,x.positionScreen.x,x.positionScreen.y,B.positionScreen.x,B.positionScreen.y);if(N.instersects(F)){ha=0;for(qa=aa.meshMaterial.length;ha<qa;){ua=aa.meshMaterial[ha++];if(ua instanceof THREE.MeshFaceMaterial){Fa=0;for(Ja=aa.faceMaterial.length;Fa<Ja;)(ua=aa.faceMaterial[Fa++])&&Ga(q,x,B,aa,ua,ia)}else Ga(q,x,B,aa,ua,ia)}}}z.addRectangle(F)}f.setTransform(1,0,0,1,0,0)}};
  121. THREE.SVGRenderer=function(){function a(S,$,V){var N,z,F,T;N=0;for(z=S.lights.length;N<z;N++){F=S.lights[N];if(F instanceof THREE.DirectionalLight){T=$.normalWorld.dot(F.position)*F.intensity;if(T>0){V.r+=F.color.r*T;V.g+=F.color.g*T;V.b+=F.color.b*T}}else if(F instanceof THREE.PointLight){m.sub(F.position,$.centroidWorld);m.normalize();T=$.normalWorld.dot(m)*F.intensity;if(T>0){V.r+=F.color.r*T;V.g+=F.color.g*T;V.b+=F.color.b*T}}}}function b(S,$,V,N,z,F){A=d(P++);A.setAttribute("d","M "+S.positionScreen.x+
  122. " "+S.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(z instanceof THREE.MeshBasicMaterial)n.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshLambertMaterial)if(D){i.r=p.r;i.g=p.g;i.b=p.b;a(F,N,i);n.r=z.color.r*i.r;n.g=z.color.g*i.g;n.b=z.color.b*i.b;n.updateStyleString()}else n.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshDepthMaterial){o=1-z.__2near/(z.__farPlusNear-N.z*z.__farMinusNear);
  123. n.setRGB(o,o,o)}else z instanceof THREE.MeshNormalMaterial&&n.setRGB(g(N.normalWorld.x),g(N.normalWorld.y),g(N.normalWorld.z));z.wireframe?A.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+z.wireframe_linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.wireframe_linecap+"; stroke-linejoin: "+z.wireframe_linejoin):A.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+z.opacity);f.appendChild(A)}function e(S,$,V,N,z,F,T){A=d(P++);A.setAttribute("d",
  124. "M "+S.positionScreen.x+" "+S.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)n.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(D){i.r=p.r;i.g=p.g;i.b=p.b;a(T,z,i);n.r=F.color.r*i.r;n.g=F.color.g*i.g;n.b=F.color.b*i.b;n.updateStyleString()}else n.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){o=
  125. 1-F.__2near/(F.__farPlusNear-z.z*F.__farMinusNear);n.setRGB(o,o,o)}else F instanceof THREE.MeshNormalMaterial&&n.setRGB(g(z.normalWorld.x),g(z.normalWorld.y),g(z.normalWorld.z));F.wireframe?A.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):A.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+F.opacity);f.appendChild(A)}
  126. function d(S){if(v[S]==null){v[S]=document.createElementNS("http://www.w3.org/2000/svg","path");W==0&&v[S].setAttribute("shape-rendering","crispEdges");return v[S]}return v[S]}function g(S){return S<0?Math.min((1+S)*0.5,0.5):0.5+Math.min(S*0.5,0.5)}var l=null,h=new THREE.Projector,f=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,c,t,y,s,q,x,B,J=new THREE.Rectangle,H=new THREE.Rectangle,D=false,n=new THREE.Color(16777215),i=new THREE.Color(16777215),p=new THREE.Color(0),k=new THREE.Color(0),
  127. w=new THREE.Color(0),o,m=new THREE.Vector3,v=[],L=[],C=[],A,P,I,M,W=1;this.domElement=f;this.autoClear=true;this.setQuality=function(S){switch(S){case "high":W=1;break;case "low":W=0}};this.setSize=function(S,$){j=S;c=$;t=j/2;y=c/2;f.setAttribute("viewBox",-t+" "+-y+" "+j+" "+c);f.setAttribute("width",j);f.setAttribute("height",c);J.set(-t,-y,t,y)};this.clear=function(){for(;f.childNodes.length>0;)f.removeChild(f.childNodes[0])};this.render=function(S,$){var V,N,z,F,T,r,u,E;this.autoClear&&this.clear();
  128. l=h.projectScene(S,$);M=I=P=0;if(D=S.lights.length>0){u=S.lights;p.setRGB(0,0,0);k.setRGB(0,0,0);w.setRGB(0,0,0);V=0;for(N=u.length;V<N;V++){z=u[V];F=z.color;if(z instanceof THREE.AmbientLight){p.r+=F.r;p.g+=F.g;p.b+=F.b}else if(z instanceof THREE.DirectionalLight){k.r+=F.r;k.g+=F.g;k.b+=F.b}else if(z instanceof THREE.PointLight){w.r+=F.r;w.g+=F.g;w.b+=F.b}}}V=0;for(N=l.length;V<N;V++){u=l[V];H.empty();if(u instanceof THREE.RenderableParticle){s=u;s.x*=t;s.y*=-y;z=0;for(F=u.material.length;z<F;z++)if(E=
  129. u.material[z]){T=s;r=u;E=E;var O=I++;if(L[O]==null){L[O]=document.createElementNS("http://www.w3.org/2000/svg","circle");W==0&&L[O].setAttribute("shape-rendering","crispEdges")}A=L[O];A.setAttribute("cx",T.x);A.setAttribute("cy",T.y);A.setAttribute("r",r.scale.x*t);if(E instanceof THREE.ParticleCircleMaterial){if(D){i.r=p.r+k.r+w.r;i.g=p.g+k.g+w.g;i.b=p.b+k.b+w.b;n.r=E.color.r*i.r;n.g=E.color.g*i.g;n.b=E.color.b*i.b;n.updateStyleString()}else n=E.color;A.setAttribute("style","fill: "+n.__styleString)}f.appendChild(A)}}else if(u instanceof
  130. THREE.RenderableLine){s=u.v1;q=u.v2;s.positionScreen.x*=t;s.positionScreen.y*=-y;q.positionScreen.x*=t;q.positionScreen.y*=-y;H.addPoint(s.positionScreen.x,s.positionScreen.y);H.addPoint(q.positionScreen.x,q.positionScreen.y);if(J.instersects(H)){z=0;for(F=u.material.length;z<F;)if(E=u.material[z++]){T=s;r=q;E=E;O=M++;if(C[O]==null){C[O]=document.createElementNS("http://www.w3.org/2000/svg","line");W==0&&C[O].setAttribute("shape-rendering","crispEdges")}A=C[O];A.setAttribute("x1",T.positionScreen.x);
  131. A.setAttribute("y1",T.positionScreen.y);A.setAttribute("x2",r.positionScreen.x);A.setAttribute("y2",r.positionScreen.y);if(E instanceof THREE.LineBasicMaterial){n.__styleString=E.color.__styleString;A.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+E.linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.linecap+"; stroke-linejoin: "+E.linejoin);f.appendChild(A)}}}}else if(u instanceof THREE.RenderableFace3){s=u.v1;q=u.v2;x=u.v3;s.positionScreen.x*=t;s.positionScreen.y*=
  132. -y;q.positionScreen.x*=t;q.positionScreen.y*=-y;x.positionScreen.x*=t;x.positionScreen.y*=-y;H.addPoint(s.positionScreen.x,s.positionScreen.y);H.addPoint(q.positionScreen.x,q.positionScreen.y);H.addPoint(x.positionScreen.x,x.positionScreen.y);if(J.instersects(H)){z=0;for(F=u.meshMaterial.length;z<F;){E=u.meshMaterial[z++];if(E instanceof THREE.MeshFaceMaterial){T=0;for(r=u.faceMaterial.length;T<r;)(E=u.faceMaterial[T++])&&b(s,q,x,u,E,S)}else E&&b(s,q,x,u,E,S)}}}else if(u instanceof THREE.RenderableFace4){s=
  133. u.v1;q=u.v2;x=u.v3;B=u.v4;s.positionScreen.x*=t;s.positionScreen.y*=-y;q.positionScreen.x*=t;q.positionScreen.y*=-y;x.positionScreen.x*=t;x.positionScreen.y*=-y;B.positionScreen.x*=t;B.positionScreen.y*=-y;H.addPoint(s.positionScreen.x,s.positionScreen.y);H.addPoint(q.positionScreen.x,q.positionScreen.y);H.addPoint(x.positionScreen.x,x.positionScreen.y);H.addPoint(B.positionScreen.x,B.positionScreen.y);if(J.instersects(H)){z=0;for(F=u.meshMaterial.length;z<F;){E=u.meshMaterial[z++];if(E instanceof
  134. THREE.MeshFaceMaterial){T=0;for(r=u.faceMaterial.length;T<r;)(E=u.faceMaterial[T++])&&e(s,q,x,B,u,E,S)}else E&&e(s,q,x,B,u,E,S)}}}}}};
  135. THREE.WebGLRenderer=function(a){function b(i,p){var k=c.createProgram(),w=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(k,h("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+
  136. i));c.attachShader(k,h("vertex",w+p));c.linkProgram(k);c.getProgramParameter(k,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(k,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");k.uniforms={};k.attributes={};return k}function e(i,p){if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,
  137. c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var k=0;k<6;++k)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image[k]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);i.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+p);c.bindTexture(c.TEXTURE_CUBE_MAP,
  138. i.image.__webGLTextureCube)}}function d(i,p){if(!i.__webGLTexture&&i.image.loaded){i.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,i.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,f(i.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,f(i.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,f(i.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,f(i.min_filter));c.generateMipmap(c.TEXTURE_2D);
  139. c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+p);c.bindTexture(c.TEXTURE_2D,i.__webGLTexture)}function g(i,p){var k,w,o;k=0;for(w=p.length;k<w;k++){o=p[k];i.uniforms[o]=c.getUniformLocation(i,o)}}function l(i,p){var k,w,o;k=0;for(w=p.length;k<w;k++){o=p[k];i.attributes[o]=c.getAttribLocation(i,o);i.attributes[o]>=0&&c.enableVertexAttribArray(i.attributes[o])}}function h(i,p){var k;if(i=="fragment")k=c.createShader(c.FRAGMENT_SHADER);else if(i=="vertex")k=c.createShader(c.VERTEX_SHADER);
  140. c.shaderSource(k,p);c.compileShader(k);if(!c.getShaderParameter(k,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(k));return null}return k}function f(i){switch(i){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;
  141. case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var j=document.createElement("canvas"),c,t,y,s=new THREE.Matrix4,q,x=new Float32Array(16),B=new Float32Array(16),J=new Float32Array(16),H=new Float32Array(9),D=new Float32Array(16);a=function(i,p){if(i){var k,w,o,m=pointLights=maxDirLights=maxPointLights=0;k=0;for(w=i.lights.length;k<w;k++){o=i.lights[k];o instanceof THREE.DirectionalLight&&m++;o instanceof
  142. THREE.PointLight&&pointLights++}if(pointLights+m<=p){maxDirLights=m;maxPointLights=pointLights}else{maxDirLights=Math.ceil(p*m/(pointLights+m));maxPointLights=p-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:p-1}}(a,4);this.domElement=j;this.autoClear=true;try{c=j.getContext("experimental-webgl",{antialias:true})}catch(n){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);
  143. c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(0,0,0,0);t=y=function(i,p){var k=[i?"#define MAX_DIR_LIGHTS "+i:"",p?"#define MAX_POINT_LIGHTS "+p:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",i?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",i?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":
  144. "",p?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",p?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",p?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
  145. i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",i?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",i?"}":"",p?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",p?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",p?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
  146. "",p?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",p?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",p?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
  147. w=[i?"#define MAX_DIR_LIGHTS "+i:"",p?"#define MAX_POINT_LIGHTS "+p:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\nuniform float m2Near;\nuniform float mFarPlusNear;\nuniform float mFarMinusNear;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
  148. i?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",p?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform vec3 cameraPosition;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 5 ) { \nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( -wPos.x, wPos.yz ) );\n} else if ( material == 4 ) { \ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, mOpacity );\n} else if ( material == 3 ) { \nfloat w = 0.5;\ngl_FragColor = vec4( w, w, w, mOpacity );\n} else if ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
  149. p?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",p?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",p?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",p?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",p?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",p?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",p?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",p?"float pointSpecularWeight = 0.0;":"",p?"if ( pointDotNormalHalf >= 0.0 )":
  150. "",p?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",p?"pointDiffuse += mColor * pointDiffuseWeight;":"",p?"pointSpecular += mSpecular * pointSpecularWeight;":"",p?"}":"",i?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"vec3 dirVector = normalize( lDirection.xyz );":"",i?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
  151. "",i?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",i?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",i?"float dirSpecularWeight = 0.0;":"",i?"if ( dirDotNormalHalf >= 0.0 )":"",i?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",i?"dirDiffuse += mColor * dirDiffuseWeight;":"",i?"dirSpecular += mSpecular * dirSpecularWeight;":"",i?"}":"","vec4 totalLight = mAmbient;",i?"totalLight += dirDiffuse + dirSpecular;":"",p?"totalLight += pointDiffuse + pointSpecular;":
  152. "","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n");
  153. k=b(w,k);c.useProgram(k);g(k,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);i&&g(k,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);p&&g(k,["pointLightNumber","pointLightColor",
  154. "pointLightPosition"]);c.uniform1i(k.uniforms.enableMap,0);c.uniform1i(k.uniforms.tMap,0);c.uniform1i(k.uniforms.enableCubeMap,0);c.uniform1i(k.uniforms.tCube,1);c.uniform1i(k.uniforms.mixEnvMap,0);c.uniform1i(k.uniforms.useRefract,0);l(k,["position","normal","uv"]);return k}(a.directional,a.point);this.setSize=function(i,p){j.width=i;j.height=p;c.viewport(0,0,j.width,j.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(i,p){var k,w,o,m,v,L=[],
  155. C=[],A=[];m=[];v=[];c.uniform1i(i.uniforms.enableLighting,p.length);k=0;for(w=p.length;k<w;k++){o=p[k];if(o instanceof THREE.AmbientLight)L.push(o);else if(o instanceof THREE.DirectionalLight)A.push(o);else o instanceof THREE.PointLight&&C.push(o)}k=o=m=v=0;for(w=L.length;k<w;k++){o+=L[k].color.r;m+=L[k].color.g;v+=L[k].color.b}c.uniform3f(i.uniforms.ambientLightColor,o,m,v);m=[];v=[];k=0;for(w=A.length;k<w;k++){o=A[k];m.push(o.color.r*o.intensity);m.push(o.color.g*o.intensity);m.push(o.color.b*o.intensity);
  156. v.push(o.position.x);v.push(o.position.y);v.push(o.position.z)}if(A.length){c.uniform1i(i.uniforms.directionalLightNumber,A.length);c.uniform3fv(i.uniforms.directionalLightDirection,v);c.uniform3fv(i.uniforms.directionalLightColor,m)}m=[];v=[];k=0;for(w=C.length;k<w;k++){o=C[k];m.push(o.color.r*o.intensity);m.push(o.color.g*o.intensity);m.push(o.color.b*o.intensity);v.push(o.position.x);v.push(o.position.y);v.push(o.position.z)}if(C.length){c.uniform1i(i.uniforms.pointLightNumber,C.length);c.uniform3fv(i.uniforms.pointLightPosition,
  157. v);c.uniform3fv(i.uniforms.pointLightColor,m)}};this.createBuffers=function(i,p){var k,w,o,m,v,L,C,A,P,I=[],M=[],W=[],S=[],$=[],V=[],N=0,z=i.geometry.geometryChunks[p],F;o=false;k=0;for(w=i.material.length;k<w;k++){meshMaterial=i.material[k];if(meshMaterial instanceof THREE.MeshFaceMaterial){v=0;for(F=z.material.length;v<F;v++)if(z.material[v]&&z.material[v].shading!=undefined&&z.material[v].shading==THREE.SmoothShading){o=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
  158. THREE.SmoothShading){o=true;break}if(o)break}F=o;k=0;for(w=z.faces.length;k<w;k++){o=z.faces[k];m=i.geometry.faces[o];v=m.vertexNormals;faceNormal=m.normal;o=i.geometry.uvs[o];if(m instanceof THREE.Face3){L=i.geometry.vertices[m.a].position;C=i.geometry.vertices[m.b].position;A=i.geometry.vertices[m.c].position;W.push(L.x,L.y,L.z);W.push(C.x,C.y,C.z);W.push(A.x,A.y,A.z);if(i.geometry.hasTangents){L=i.geometry.vertices[m.a].tangent;C=i.geometry.vertices[m.b].tangent;A=i.geometry.vertices[m.c].tangent;
  159. $.push(L.x,L.y,L.z,L.w);$.push(C.x,C.y,C.z,C.w);$.push(A.x,A.y,A.z,A.w)}if(v.length==3&&F)for(m=0;m<3;m++)S.push(v[m].x,v[m].y,v[m].z);else for(m=0;m<3;m++)S.push(faceNormal.x,faceNormal.y,faceNormal.z);if(o)for(m=0;m<3;m++)V.push(o[m].u,o[m].v);I.push(N,N+1,N+2);M.push(N,N+1);M.push(N,N+2);M.push(N+1,N+2);N+=3}else if(m instanceof THREE.Face4){L=i.geometry.vertices[m.a].position;C=i.geometry.vertices[m.b].position;A=i.geometry.vertices[m.c].position;P=i.geometry.vertices[m.d].position;W.push(L.x,
  160. L.y,L.z);W.push(C.x,C.y,C.z);W.push(A.x,A.y,A.z);W.push(P.x,P.y,P.z);if(i.geometry.hasTangents){L=i.geometry.vertices[m.a].tangent;C=i.geometry.vertices[m.b].tangent;A=i.geometry.vertices[m.c].tangent;m=i.geometry.vertices[m.d].tangent;$.push(L.x,L.y,L.z,L.w);$.push(C.x,C.y,C.z,C.w);$.push(A.x,A.y,A.z,A.w);$.push(m.x,m.y,m.z,m.w)}if(v.length==4&&F)for(m=0;m<4;m++)S.push(v[m].x,v[m].y,v[m].z);else for(m=0;m<4;m++)S.push(faceNormal.x,faceNormal.y,faceNormal.z);if(o)for(m=0;m<4;m++)V.push(o[m].u,o[m].v);
  161. I.push(N,N+1,N+2);I.push(N,N+2,N+3);M.push(N,N+1);M.push(N,N+2);M.push(N,N+3);M.push(N+1,N+2);M.push(N+2,N+3);N+=4}}if(W.length){z.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,z.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(W),c.STATIC_DRAW);z.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,z.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(S),c.STATIC_DRAW);if(i.geometry.hasTangents){z.__webGLTangentBuffer=c.createBuffer();
  162. c.bindBuffer(c.ARRAY_BUFFER,z.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array($),c.STATIC_DRAW)}if(V.length>0){z.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,z.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW)}z.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,z.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(I),c.STATIC_DRAW);z.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
  163. z.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(M),c.STATIC_DRAW);z.__webGLFaceCount=I.length;z.__webGLLineCount=M.length}};this.renderBuffer=function(i,p,k,w){var o,m,v,L,C,A,P,I,M;if(k instanceof THREE.MeshShaderMaterial){if(!k.program){k.program=b(k.fragment_shader,k.vertex_shader);P=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(M in k.uniforms)P.push(M);g(k.program,P);l(k.program,["position","normal","uv","tangent"])}M=
  164. k.program}else M=y;if(M!=t){c.useProgram(M);t=M}M==y&&this.setupLights(M,p);this.loadCamera(M,i);this.loadMatrices(M);if(k instanceof THREE.MeshShaderMaterial){v=k.wireframe;L=k.wireframe_linewidth;i=M;p=k.uniforms;var W;for(o in p){I=p[o].type;P=p[o].value;W=i.uniforms[o];if(I=="i")c.uniform1i(W,P);else if(I=="f")c.uniform1f(W,P);else if(I=="v3")c.uniform3f(W,P.x,P.y,P.z);else if(I=="c")c.uniform3f(W,P.r,P.g,P.b);else if(I=="t"){c.uniform1i(W,P);if(I=p[o].texture)I.image instanceof Array&&I.image.length==
  165. 6?e(I,P):d(I,P)}}}if(k instanceof THREE.MeshPhongMaterial||k instanceof THREE.MeshLambertMaterial||k instanceof THREE.MeshBasicMaterial){o=k.color;m=k.opacity;v=k.wireframe;L=k.wireframe_linewidth;C=k.map;A=k.env_map;p=k.combine==THREE.MixOperation;i=k.reflectivity;I=k.env_map&&k.env_map.mapping instanceof THREE.CubeRefractionMapping;P=k.refraction_ratio;c.uniform4f(M.uniforms.mColor,o.r*m,o.g*m,o.b*m,m);c.uniform1i(M.uniforms.mixEnvMap,p);c.uniform1f(M.uniforms.mReflectivity,i);c.uniform1i(M.uniforms.useRefract,
  166. I);c.uniform1f(M.uniforms.mRefractionRatio,P)}if(k instanceof THREE.MeshNormalMaterial){m=k.opacity;c.uniform1f(M.uniforms.mOpacity,m);c.uniform1i(M.uniforms.material,4)}else if(k instanceof THREE.MeshDepthMaterial){m=k.opacity;v=k.wireframe;L=k.wireframe_linewidth;c.uniform1f(M.uniforms.mOpacity,m);c.uniform1f(M.uniforms.m2Near,k.__2near);c.uniform1f(M.uniforms.mFarPlusNear,k.__farPlusNear);c.uniform1f(M.uniforms.mFarMinusNear,k.__farMinusNear);c.uniform1i(M.uniforms.material,3)}else if(k instanceof
  167. THREE.MeshPhongMaterial){o=k.ambient;i=k.specular;k=k.shininess;c.uniform4f(M.uniforms.mAmbient,o.r,o.g,o.b,m);c.uniform4f(M.uniforms.mSpecular,i.r,i.g,i.b,m);c.uniform1f(M.uniforms.mShininess,k);c.uniform1i(M.uniforms.material,2)}else if(k instanceof THREE.MeshLambertMaterial)c.uniform1i(M.uniforms.material,1);else if(k instanceof THREE.MeshBasicMaterial)c.uniform1i(M.uniforms.material,0);else if(k instanceof THREE.MeshCubeMaterial){c.uniform1i(M.uniforms.material,5);A=k.env_map}if(C){d(C,0);c.uniform1i(M.uniforms.tMap,
  168. 0);c.uniform1i(M.uniforms.enableMap,1)}else c.uniform1i(M.uniforms.enableMap,0);if(A){e(A,1);c.uniform1i(M.uniforms.tCube,1);c.uniform1i(M.uniforms.enableCubeMap,1)}else c.uniform1i(M.uniforms.enableCubeMap,0);m=M.attributes;c.bindBuffer(c.ARRAY_BUFFER,w.__webGLVertexBuffer);c.vertexAttribPointer(m.position,3,c.FLOAT,false,0,0);if(m.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,w.__webGLNormalBuffer);c.vertexAttribPointer(m.normal,3,c.FLOAT,false,0,0)}if(m.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,w.__webGLTangentBuffer);
  169. c.vertexAttribPointer(m.tangent,4,c.FLOAT,false,0,0)}if(m.uv>=0)if(w.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,w.__webGLUVBuffer);c.enableVertexAttribArray(m.uv);c.vertexAttribPointer(m.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(m.uv);if(v){c.lineWidth(L);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.__webGLLineBuffer);c.drawElements(c.LINES,w.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,w.__webGLFaceCount,c.UNSIGNED_SHORT,
  170. 0)}};this.renderPass=function(i,p,k,w,o,m){var v,L,C,A,P;C=0;for(A=k.material.length;C<A;C++){v=k.material[C];if(v instanceof THREE.MeshFaceMaterial){v=0;for(L=w.material.length;v<L;v++)if((P=w.material[v])&&P.blending==o&&P.opacity<1==m){this.setBlending(P.blending);this.renderBuffer(i,p,P,w)}}else if((P=v)&&P.blending==o&&P.opacity<1==m){this.setBlending(P.blending);this.renderBuffer(i,p,P,w)}}};this.render=function(i,p){var k,w,o,m,v=i.lights;this.initWebGLObjects(i);this.autoClear&&this.clear();
  171. p.autoUpdateMatrix&&p.updateMatrix();x.set(p.matrix.flatten());J.set(p.projectionMatrix.flatten());k=0;for(w=i.__webGLObjects.length;k<w;k++){o=i.__webGLObjects[k];m=o.object;o=o.buffer;if(m.visible){this.setupMatrices(m,p);this.renderPass(p,v,m,o,THREE.NormalBlending,false)}}k=0;for(w=i.__webGLObjects.length;k<w;k++){o=i.__webGLObjects[k];m=o.object;o=o.buffer;if(m.visible){this.setupMatrices(m,p);this.renderPass(p,v,m,o,THREE.AdditiveBlending,false);this.renderPass(p,v,m,o,THREE.SubtractiveBlending,
  172. false);this.renderPass(p,v,m,o,THREE.AdditiveBlending,true);this.renderPass(p,v,m,o,THREE.SubtractiveBlending,true);this.renderPass(p,v,m,o,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(i){var p,k,w,o,m,v;if(!i.__webGLObjects){i.__webGLObjects=[];i.__webGLObjectsMap={}}p=0;for(k=i.objects.length;p<k;p++){w=i.objects[p];if(i.__webGLObjectsMap[w.id]==undefined)i.__webGLObjectsMap[w.id]={};v=i.__webGLObjectsMap[w.id];if(w instanceof THREE.Mesh)for(m in w.geometry.geometryChunks){o=w.geometry.geometryChunks[m];
  173. o.__webGLVertexBuffer||this.createBuffers(w,m);if(v[m]==undefined){o={buffer:o,object:w};i.__webGLObjects.push(o);v[m]=1}}}};this.removeObject=function(i,p){var k,w;for(k=i.__webGLObjects.length-1;k>=0;k--){w=i.__webGLObjects[k].object;p==w&&i.__webGLObjects.splice(k,1)}};this.setupMatrices=function(i,p){i.autoUpdateMatrix&&i.updateMatrix();s.multiply(p.matrix,i.matrix);B.set(s.flatten());q=THREE.Matrix4.makeInvert3x3(s).transpose();H.set(q.m);D.set(i.matrix.flatten())};this.loadMatrices=function(i){c.uniformMatrix4fv(i.uniforms.viewMatrix,
  174. false,x);c.uniformMatrix4fv(i.uniforms.modelViewMatrix,false,B);c.uniformMatrix4fv(i.uniforms.projectionMatrix,false,J);c.uniformMatrix3fv(i.uniforms.normalMatrix,false,H);c.uniformMatrix4fv(i.uniforms.objectMatrix,false,D)};this.loadCamera=function(i,p){c.uniform3f(i.uniforms.cameraPosition,p.position.x,p.position.y,p.position.z)};this.setBlending=function(i){switch(i){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,
  175. c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(i,p){if(i){!p||p=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(i=="back")c.cullFace(c.BACK);else i=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
  176. THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};
  177. THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null};
  178. var GeometryUtils={merge:function(a,b){var e=b instanceof THREE.Mesh,d=a.vertices.length,g=e?b.geometry:b,l=a.vertices,h=g.vertices,f=a.faces,j=g.faces,c=a.uvs;g=g.uvs;e&&b.updateMatrix();for(var t=0,y=h.length;t<y;t++){var s=new THREE.Vertex(h[t].position.clone());e&&b.matrix.multiplyVector3(s.position);l.push(s)}t=0;for(y=j.length;t<y;t++){h=j[t];var q,x=h.vertexNormals;if(h instanceof THREE.Face3)q=new THREE.Face3(h.a+d,h.b+d,h.c+d);else if(h instanceof THREE.Face4)q=new THREE.Face4(h.a+d,h.b+
  179. d,h.c+d,h.d+d);q.centroid.copy(h.centroid);q.normal.copy(h.normal);e=0;for(l=x.length;e<l;e++){s=x[e];q.vertexNormals.push(s.clone())}q.material=h.material.slice();f.push(q)}t=0;for(y=g.length;t<y;t++){d=g[t];f=[];e=0;for(l=d.length;e<l;e++)f.push(new THREE.UV(d[e].u,d[e].v));c.push(f)}}},ImageUtils={loadTexture:function(a,b){var e=new Image;e.onload=function(){this.loaded=true};e.src=a;return new THREE.Texture(e,b)},loadArray:function(a){var b,e,d=[];b=d.loadCount=0;for(e=a.length;b<e;++b){d[b]=
  180. new Image;d[b].loaded=0;d[b].onload=function(){d.loadCount+=1;this.loaded=true};d[b].src=a[b]}return d}},SceneUtils={addMesh:function(a,b,e,d,g,l,h,f,j,c){b=new THREE.Mesh(b,c);b.scale.x=b.scale.y=b.scale.z=e;b.position.x=d;b.position.y=g;b.position.z=l;b.rotation.x=h;b.rotation.y=f;b.rotation.z=j;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,e){e=new THREE.MeshCubeMaterial({env_map:e});b=new THREE.Mesh(new Cube(b,b,b,1,1,null,true),e);a.addObject(b);return b},addPanoramaCube:function(a,
  181. b,e){var d=[];d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[0])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[1])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[2])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[3])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[4])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[5])}));mesh=new THREE.Mesh(new Cube(b,b,b,1,1,d,true),new THREE.MeshFaceMaterial);a.addObject(mesh);
  182. return mesh},addPanoramaCubePlanes:function(a,b,e){var d=b/2;b=new Plane(b,b);var g=Math.PI/2,l=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-d,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[5])}));SceneUtils.addMesh(a,b,1,-d,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[0])}));SceneUtils.addMesh(a,b,1,d,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[1])}));SceneUtils.addMesh(a,b,1,0,d,0,g,0,l,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[2])}));SceneUtils.addMesh(a,
  183. b,1,0,-d,0,-g,0,l,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
  184. 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}"},
  185. normal:{uniforms:{tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},tDisplacement:{type:"t",value:4,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",value:new THREE.Color(15658734)},uDirLightPos:{type:"v3",value:new THREE.Vector3},uDirLightColor:{type:"c",value:new THREE.Color(15658734)},uAmbientLightColor:{type:"c",value:new THREE.Color(328965)},uDiffuseColor:{type:"c",
  186. value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30}},fragment_shader:"uniform vec3 uDirLightPos;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightPos;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 normalTex = normalize( texture2D( tNormal, vUv ).xyz * 2.0 - 1.0 );\nvec3 aoTex = texture2D( tAO, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec3 pointVector = normalize( vPointLightVector );\nvec3 pointHalfVector = normalize( vPointLightVector + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientColor, 1.0 );\ntotalLight += dirDiffuse + dirSpecular;\ntotalLight += pointDiffuse + pointSpecular;\ngl_FragColor = vec4( totalLight.xyz * vLightWeighting * aoTex, 1.0 );\n}",
  187. vertex_shader:"attribute vec4 tangent;\nuniform vec3 uDirLightPos;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightPos;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientLightColor;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvLightWeighting = uAmbientLightColor;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( vNormal, vPointLightVector ), 0.0 );\nvLightWeighting += uPointLightColor * pointLightWeighting;\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nfloat directionalLightWeighting = max( dot( vNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += uDirLightColor * directionalLightWeighting;\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"},
  188. 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,e,d,g,l,h,f){function j(B,J,H,D,n,i,p,k){var w,o=d||1,m=g||1,v=o+1,L=m+1,C=n/2,A=i/2;n=n/o;i=i/m;var P=c.vertices.length;if(B=="x"&&J=="y"||B=="y"&&J=="x")w="z";else if(B=="x"&&J=="z"||B=="z"&&J=="x")w="y";else if(B=="z"&&J=="y"||B=="y"&&J=="z")w="x";for(iy=0;iy<L;iy++)for(ix=
  189. 0;ix<v;ix++){var I=new THREE.Vector3;I[B]=(ix*n-C)*H;I[J]=(iy*i-A)*D;I[w]=p;c.vertices.push(new THREE.Vertex(I))}for(iy=0;iy<m;iy++)for(ix=0;ix<o;ix++){c.faces.push(new THREE.Face4(ix+v*iy+P,ix+v*(iy+1)+P,ix+1+v*(iy+1)+P,ix+1+v*iy+P,null,k));c.uvs.push([new THREE.UV(ix/o,iy/m),new THREE.UV(ix/o,(iy+1)/m),new THREE.UV((ix+1)/o,(iy+1)/m),new THREE.UV((ix+1)/o,iy/m)])}}THREE.Geometry.call(this);var c=this,t=a/2,y=b/2,s=e/2;h=h?-1:1;if(l!==undefined)if(l instanceof Array)this.materials=l;else{this.materials=
  190. [];for(var q=0;q<6;q++)this.materials.push([l])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(f!=undefined)for(var x in f)if(this.sides[x]!=undefined)this.sides[x]=f[x];this.sides.px&&j("z","y",1*h,-1,e,b,-t,this.materials[0]);this.sides.nx&&j("z","y",-1*h,-1,e,b,t,this.materials[1]);this.sides.py&&j("x","z",1*h,1,a,e,y,this.materials[2]);this.sides.ny&&j("x","z",1*h,-1,a,e,-y,this.materials[3]);this.sides.pz&&j("x","y",1*h,-1,a,b,s,this.materials[4]);this.sides.nz&&
  191. j("x","y",-1*h,-1,a,b,-s,this.materials[5]);(function(){for(var B=[],J=[],H=0,D=c.vertices.length;H<D;H++){for(var n=c.vertices[H],i=false,p=0,k=B.length;p<k;p++){var w=B[p];if(n.position.x==w.position.x&&n.position.y==w.position.y&&n.position.z==w.position.z){J[H]=p;i=true;break}}if(!i){J[H]=B.length;B.push(new THREE.Vertex(n.position.clone()))}}H=0;for(D=c.faces.length;H<D;H++){n=c.faces[H];n.a=J[n.a];n.b=J[n.b];n.c=J[n.c];n.d=J[n.d]}c.vertices=B})();this.computeCentroids();this.computeFaceNormals();
  192. this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
  193. var Cylinder=function(a,b,e,d,g){function l(c,t,y){h.vertices.push(new THREE.Vertex(new THREE.Vector3(c,t,y)))}THREE.Geometry.call(this);var h=this,f=Math.PI,j;for(j=0;j<a;j++)l(Math.sin(2*f*j/a)*b,Math.cos(2*f*j/a)*b,0);for(j=0;j<a;j++)l(Math.sin(2*f*j/a)*e,Math.cos(2*f*j/a)*e,d);for(j=0;j<a;j++)h.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(e!=0){l(0,0,-g);for(j=a;j<a+a/2;j++)h.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){l(0,0,d+g);for(j=a+a/2;j<
  194. 2*a;j++)h.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;
  195. var Plane=function(a,b,e,d){THREE.Geometry.call(this);var g,l=a/2,h=b/2;e=e||1;d=d||1;var f=e+1,j=d+1;a=a/e;var c=b/d;for(g=0;g<j;g++)for(b=0;b<f;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-l,-(g*c-h),0)));for(g=0;g<d;g++)for(b=0;b<e;b++){this.faces.push(new THREE.Face4(b+f*g,b+f*(g+1),b+1+f*(g+1),b+1+f*g));this.uvs.push([new THREE.UV(b/e,g/d),new THREE.UV(b/e,(g+1)/d),new THREE.UV((b+1)/e,(g+1)/d),new THREE.UV((b+1)/e,g/d)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
  196. Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
  197. var Sphere=function(a,b,e){THREE.Geometry.call(this);var d,g=Math.PI,l=Math.max(3,b||8),h=Math.max(2,e||6);b=[];for(e=0;e<h+1;e++){d=e/h;var f=a*Math.cos(d*g),j=a*Math.sin(d*g),c=[],t=0;for(d=0;d<l;d++){var y=2*d/l,s=j*Math.sin(y*g);y=j*Math.cos(y*g);(e==0||e==h)&&d>0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,f,s)))-1);c.push(t)}b.push(c)}var q,x;a=b.length;for(e=0;e<a;e++){g=b[e].length;if(e>0)for(d=0;d<g;d++){j=d==g-1;l=b[e][j?0:d+1];h=b[e][j?g-1:d];f=b[e-1][j?g-1:d];j=b[e-1][j?
  198. 0:d+1];t=e/(a-1);y=(e-1)/(a-1);q=(d+1)/g;s=d/g;c=new THREE.UV(1-q,t);t=new THREE.UV(1-s,t);s=new THREE.UV(1-s,y);var B=new THREE.UV(1-q,y);if(e<b.length-1){y=this.vertices[l].position.clone();q=this.vertices[h].position.clone();x=this.vertices[f].position.clone();y.normalize();q.normalize();x.normalize();this.faces.push(new THREE.Face3(l,h,f,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(x.x,x.y,x.z)]));this.uvs.push([c,t,s])}if(e>1){y=this.vertices[l].position.clone();
  199. q=this.vertices[f].position.clone();x=this.vertices[j].position.clone();y.normalize();q.normalize();x.normalize();this.faces.push(new THREE.Face3(l,f,j,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(x.x,x.y,x.z)]));this.uvs.push([c,s,B])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
  200. THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
  201. 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=
  202. b},loadAsciiOld:function(a,b){var e=document.createElement("script");e.type="text/javascript";e.onload=b;e.src=a;document.getElementsByTagName("head")[0].appendChild(e)},loadAscii:function(a,b,e){var d=(new Date).getTime();a=new Worker(a);a.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,b,e)};a.postMessage(d)},loadBinary:function(a,b,e){var d=(new Date).getTime();a=new Worker(a);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(l){THREE.Loader.prototype.loadAjaxBuffers(l.data.buffers,
  203. l.data.materials,b,e,g)};a.onerror=function(l){alert("worker.onerror: "+l.message+"\n"+l.data);l.preventDefault()};a.postMessage(d)},loadAjaxBuffers:function(a,b,e,d,g){var l=new XMLHttpRequest,h=d+"/"+a,f=0;l.onreadystatechange=function(){if(l.readyState==4)l.status==200||l.status==0?THREE.Loader.prototype.createBinModel(l.responseText,e,d,b):alert("Couldn't load ["+h+"] ["+l.status+"]");else if(l.readyState==3){if(g){if(f==0)f=l.getResponseHeader("Content-Length");g({total:f,loaded:l.responseText.length})}}else if(l.readyState==
  204. 2)f=l.getResponseHeader("Content-Length")};l.open("GET",h,true);l.overrideMimeType("text/plain; charset=x-user-defined");l.setRequestHeader("Content-Type","text/plain");l.send(null)},createBinModel:function(a,b,e,d){var g=function(l){function h(r,u){var E=t(r,u),O=t(r,u+1),X=t(r,u+2),Y=t(r,u+3),ea=(Y<<1&255|X>>7)-127;E=(X&127)<<16|O<<8|E;if(E==0&&ea==-127)return 0;return(1-2*(Y>>7))*(1+E*Math.pow(2,-23))*Math.pow(2,ea)}function f(r,u){var E=t(r,u),O=t(r,u+1),X=t(r,u+2);return(t(r,u+3)<<24)+(X<<16)+
  205. (O<<8)+E}function j(r,u){var E=t(r,u);return(t(r,u+1)<<8)+E}function c(r,u){var E=t(r,u);return E>127?E-256:E}function t(r,u){return r.charCodeAt(u)&255}function y(r){var u,E,O;u=f(a,r);E=f(a,r+k);O=f(a,r+w);r=j(a,r+o);THREE.Loader.prototype.f3(H,u,E,O,r)}function s(r){var u,E,O,X,Y,ea;u=f(a,r);E=f(a,r+k);O=f(a,r+w);X=j(a,r+o);Y=f(a,r+m);ea=f(a,r+v);r=f(a,r+L);THREE.Loader.prototype.f3n(H,i,u,E,O,X,Y,ea,r)}function q(r){var u,E,O,X;u=f(a,r);E=f(a,r+C);O=f(a,r+A);X=f(a,r+P);r=j(a,r+I);THREE.Loader.prototype.f4(H,
  206. u,E,O,X,r)}function x(r){var u,E,O,X,Y,ea,ma,oa;u=f(a,r);E=f(a,r+C);O=f(a,r+A);X=f(a,r+P);Y=j(a,r+I);ea=f(a,r+M);ma=f(a,r+W);oa=f(a,r+S);r=f(a,r+$);THREE.Loader.prototype.f4n(H,i,u,E,O,X,Y,ea,ma,oa,r)}function B(r){var u,E;u=f(a,r);E=f(a,r+V);r=f(a,r+N);THREE.Loader.prototype.uv3(H,p[u*2],p[u*2+1],p[E*2],p[E*2+1],p[r*2],p[r*2+1])}function J(r){var u,E,O;u=f(a,r);E=f(a,r+z);O=f(a,r+F);r=f(a,r+T);THREE.Loader.prototype.uv4(H,p[u*2],p[u*2+1],p[E*2],p[E*2+1],p[O*2],p[O*2+1],p[r*2],p[r*2+1])}var H=this,
  207. D=0,n,i=[],p=[],k,w,o,m,v,L,C,A,P,I,M,W,S,$,V,N,z,F,T;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(H,d,l);n={signature:a.substr(D,8),header_bytes:t(a,D+8),vertex_coordinate_bytes:t(a,D+9),normal_coordinate_bytes:t(a,D+10),uv_coordinate_bytes:t(a,D+11),vertex_index_bytes:t(a,D+12),normal_index_bytes:t(a,D+13),uv_index_bytes:t(a,D+14),material_index_bytes:t(a,D+15),nvertices:f(a,D+16),nnormals:f(a,D+16+4),nuvs:f(a,D+16+8),ntri_flat:f(a,D+16+12),ntri_smooth:f(a,D+16+16),ntri_flat_uv:f(a,
  208. D+16+20),ntri_smooth_uv:f(a,D+16+24),nquad_flat:f(a,D+16+28),nquad_smooth:f(a,D+16+32),nquad_flat_uv:f(a,D+16+36),nquad_smooth_uv:f(a,D+16+40)};D+=n.header_bytes;k=n.vertex_index_bytes;w=n.vertex_index_bytes*2;o=n.vertex_index_bytes*3;m=n.vertex_index_bytes*3+n.material_index_bytes;v=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;L=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;C=n.vertex_index_bytes;A=n.vertex_index_bytes*2;P=n.vertex_index_bytes*3;I=n.vertex_index_bytes*
  209. 4;M=n.vertex_index_bytes*4+n.material_index_bytes;W=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;S=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;$=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;V=n.uv_index_bytes;N=n.uv_index_bytes*2;z=n.uv_index_bytes;F=n.uv_index_bytes*2;T=n.uv_index_bytes*3;D+=function(r){var u,E,O,X=n.vertex_coordinate_bytes*3,Y=r+n.nvertices*X;for(r=r;r<Y;r+=X){u=h(a,r);E=h(a,r+n.vertex_coordinate_bytes);O=h(a,
  210. r+n.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(H,u,E,O)}return n.nvertices*X}(D);D+=function(r){var u,E,O,X=n.normal_coordinate_bytes*3,Y=r+n.nnormals*X;for(r=r;r<Y;r+=X){u=c(a,r);E=c(a,r+n.normal_coordinate_bytes);O=c(a,r+n.normal_coordinate_bytes*2);i.push(u/127,E/127,O/127)}return n.nnormals*X}(D);D+=function(r){var u,E,O=n.uv_coordinate_bytes*2,X=r+n.nuvs*O;for(r=r;r<X;r+=O){u=h(a,r);E=h(a,r+n.uv_coordinate_bytes);p.push(u,E)}return n.nuvs*O}(D);D+=function(r){var u,E=n.vertex_index_bytes*
  211. 3+n.material_index_bytes,O=r+n.ntri_flat*E;for(u=r;u<O;u+=E)y(u);return O-r}(D);D+=function(r){var u,E=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,O=r+n.ntri_smooth*E;for(u=r;u<O;u+=E)s(u);return O-r}(D);D+=function(r){var u,E=n.vertex_index_bytes*3+n.material_index_bytes,O=E+n.uv_index_bytes*3,X=r+n.ntri_flat_uv*O;for(u=r;u<X;u+=O){y(u);B(u+E)}return X-r}(D);D+=function(r){var u,E=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,O=E+n.uv_index_bytes*3,
  212. X=r+n.ntri_smooth_uv*O;for(u=r;u<X;u+=O){s(u);B(u+E)}return X-r}(D);D+=function(r){var u,E=n.vertex_index_bytes*4+n.material_index_bytes,O=r+n.nquad_flat*E;for(u=r;u<O;u+=E)q(u);return O-r}(D);D+=function(r){var u,E=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,O=r+n.nquad_smooth*E;for(u=r;u<O;u+=E)x(u);return O-r}(D);D+=function(r){var u,E=n.vertex_index_bytes*4+n.material_index_bytes,O=E+n.uv_index_bytes*4,X=r+n.nquad_flat_uv*O;for(u=r;u<X;u+=O){q(u);J(u+E)}return X-r}(D);
  213. D+=function(r){var u,E=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,O=E+n.uv_index_bytes*4,X=r+n.nquad_smooth_uv*O;for(u=r;u<X;u+=O){x(u);J(u+E)}return X-r}(D);this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g(e))},createModel:function(a,b,e){var d=function(g){var l=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(l,a.materials,g);(function(){var h,f,j,c,t;h=0;for(f=
  214. a.vertices.length;h<f;h+=3){j=a.vertices[h];c=a.vertices[h+1];t=a.vertices[h+2];THREE.Loader.prototype.v(l,j,c,t)}})();(function(){function h(x,B){THREE.Loader.prototype.f3(l,x[B],x[B+1],x[B+2],x[B+3])}function f(x,B){THREE.Loader.prototype.f3n(l,a.normals,x[B],x[B+1],x[B+2],x[B+3],x[B+4],x[B+5],x[B+6])}function j(x,B){THREE.Loader.prototype.f4(l,x[B],x[B+1],x[B+2],x[B+3],x[B+4])}function c(x,B){THREE.Loader.prototype.f4n(l,a.normals,x[B],x[B+1],x[B+2],x[B+3],x[B+4],x[B+5],x[B+6],x[B+7],x[B+8])}function t(x,
  215. B){var J,H,D;J=x[B];H=x[B+1];D=x[B+2];THREE.Loader.prototype.uv3(l,a.uvs[J*2],a.uvs[J*2+1],a.uvs[H*2],a.uvs[H*2+1],a.uvs[D*2],a.uvs[D*2+1])}function y(x,B){var J,H,D,n;J=x[B];H=x[B+1];D=x[B+2];n=x[B+3];THREE.Loader.prototype.uv4(l,a.uvs[J*2],a.uvs[J*2+1],a.uvs[H*2],a.uvs[H*2+1],a.uvs[D*2],a.uvs[D*2+1],a.uvs[n*2],a.uvs[n*2+1])}var s,q;s=0;for(q=a.triangles.length;s<q;s+=4)h(a.triangles,s);s=0;for(q=a.triangles_uv.length;s<q;s+=7){h(a.triangles_uv,s);t(a.triangles_uv,s+4)}s=0;for(q=a.triangles_n.length;s<
  216. q;s+=7)f(a.triangles_n,s);s=0;for(q=a.triangles_n_uv.length;s<q;s+=10){f(a.triangles_n_uv,s);t(a.triangles_n_uv,s+7)}s=0;for(q=a.quads.length;s<q;s+=5)j(a.quads,s);s=0;for(q=a.quads_uv.length;s<q;s+=9){j(a.quads_uv,s);y(a.quads_uv,s+5)}s=0;for(q=a.quads_n.length;s<q;s+=9)c(a.quads_n,s);s=0;for(q=a.quads_n_uv.length;s<q;s+=13){c(a.quads_n_uv,s);y(a.quads_n_uv,s+9)}})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};d.prototype=new THREE.Geometry;d.prototype.constructor=
  217. d;b(new d(e))},v:function(a,b,e,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,e,d)))},f3:function(a,b,e,d,g){a.faces.push(new THREE.Face3(b,e,d,null,a.materials[g]))},f4:function(a,b,e,d,g,l){a.faces.push(new THREE.Face4(b,e,d,g,null,a.materials[l]))},f3n:function(a,b,e,d,g,l,h,f,j){l=a.materials[l];var c=b[f*3],t=b[f*3+1];f=b[f*3+2];var y=b[j*3],s=b[j*3+1];j=b[j*3+2];a.faces.push(new THREE.Face3(e,d,g,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(c,t,f),new THREE.Vector3(y,
  218. s,j)],l))},f4n:function(a,b,e,d,g,l,h,f,j,c,t){h=a.materials[h];var y=b[j*3],s=b[j*3+1];j=b[j*3+2];var q=b[c*3],x=b[c*3+1];c=b[c*3+2];var B=b[t*3],J=b[t*3+1];t=b[t*3+2];a.faces.push(new THREE.Face4(e,d,g,l,[new THREE.Vector3(b[f*3],b[f*3+1],b[f*3+2]),new THREE.Vector3(y,s,j),new THREE.Vector3(q,x,c),new THREE.Vector3(B,J,t)],h))},uv3:function(a,b,e,d,g,l,h){var f=[];f.push(new THREE.UV(b,e));f.push(new THREE.UV(d,g));f.push(new THREE.UV(l,h));a.uvs.push(f)},uv4:function(a,b,e,d,g,l,h,f,j){var c=[];
  219. c.push(new THREE.UV(b,e));c.push(new THREE.UV(d,g));c.push(new THREE.UV(l,h));c.push(new THREE.UV(f,j));a.uvs.push(c)},init_materials:function(a,b,e){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=[THREE.Loader.prototype.createMaterial(b[d],e)]},createMaterial:function(a,b){function e(l){l=Math.log(l)/Math.LN2;return Math.floor(l)==l}var d,g;if(a.map_diffuse&&b){g=document.createElement("canvas");d=new THREE.MeshLambertMaterial({map:new THREE.Texture(g)});g=new Image;g.onload=function(){if(!e(this.width)||
  220. !e(this.height)){var l=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),h=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));d.map.image.width=l;d.map.image.height=h;d.map.image.getContext("2d").drawImage(this,0,0,l,h)}else d.map.image=this;d.map.image.loaded=1};g.src=b+"/"+a.map_diffuse}else if(a.col_diffuse){g=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;d=new THREE.MeshLambertMaterial({color:g,opacity:a.transparency})}else d=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):
  221. new THREE.MeshLambertMaterial({color:15658734});return d}};
粤ICP备19079148号