ThreeExtras.js 125 KB

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