ThreeWebGL.js 143 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. // ThreeWebGL.js r45dev - http://github.com/mrdoob/three.js
  2. var THREE=THREE||{};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;THREE.Color=function(b){b!==void 0&&this.setHex(b);return this};
  3. THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;return this},setRGB:function(b,c,d){this.r=b;this.g=c;this.b=d;return this},setHSV:function(b,c,d){var e,j,h;if(d==0)this.r=this.g=this.b=0;else switch(e=Math.floor(b*6),j=b*6-e,b=d*(1-c),h=d*(1-c*j),c=d*(1-c*(1-j)),e){case 1:this.r=h;this.g=d;this.b=b;break;case 2:this.r=b;this.g=d;this.b=c;break;case 3:this.r=b;this.g=h;this.b=d;break;case 4:this.r=c;this.g=b;this.b=d;break;case 5:this.r=
  4. d;this.g=b;this.b=h;break;case 6:case 0:this.r=d,this.g=c,this.b=b}return this},setHex:function(b){b=Math.floor(b);this.r=(b>>16&255)/255;this.g=(b>>8&255)/255;this.b=(b&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};
  5. THREE.Vector2=function(b,c){this.x=b||0;this.y=c||0};
  6. THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(b,c){this.x=b;this.y=c;return this},copy:function(b){this.x=b.x;this.y=b.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;return this},
  7. divideScalar:function(b){b?(this.x/=b,this.y/=b):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var c=this.x-b.x,b=this.y-b.y;return c*c+b*b},setLength:function(b){return this.normalize().multiplyScalar(b)},
  8. equals:function(b){return b.x==this.x&&b.y==this.y}};THREE.Vector3=function(b,c,d){this.x=b||0;this.y=c||0;this.z=d||0};
  9. THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(b,c,d){this.x=b;this.y=c;this.z=d;return this},setX:function(b){this.x=b;return this},setY:function(b){this.y=b;return this},setZ:function(b){this.z=b;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;return this},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;return this},
  10. addScalar:function(b){this.x+=b;this.y+=b;this.z+=b;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z=b.z-c.z;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;this.z-=b.z;return this},multiply:function(b,c){this.x=b.x*c.x;this.y=b.y*c.y;this.z=b.z*c.z;return this},multiplySelf:function(b){this.x*=b.x;this.y*=b.y;this.z*=b.z;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;return this},divideSelf:function(b){this.x/=b.x;this.y/=b.y;this.z/=b.z;return this},
  11. divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b):this.set(0,0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){return this.divideScalar(this.length())},setLength:function(b){return this.normalize().multiplyScalar(b)},
  12. cross:function(b,c){this.x=b.y*c.z-b.z*c.y;this.y=b.z*c.x-b.x*c.z;this.z=b.x*c.y-b.y*c.x;return this},crossSelf:function(b){return this.set(this.y*b.z-this.z*b.y,this.z*b.x-this.x*b.z,this.x*b.y-this.y*b.x)},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){return(new THREE.Vector3).sub(this,b).lengthSq()},setPositionFromMatrix:function(b){this.x=b.n14;this.y=b.n24;this.z=b.n34},setRotationFromMatrix:function(b){var c=Math.cos(this.y);this.y=Math.asin(b.n13);
  13. Math.abs(c)>1.0E-5?(this.x=Math.atan2(-b.n23/c,b.n33/c),this.z=Math.atan2(-b.n12/c,b.n11/c)):(this.x=0,this.z=Math.atan2(b.n21,b.n22))},isZero:function(){return this.lengthSq()<1.0E-4}};THREE.Vector4=function(b,c,d,e){this.x=b||0;this.y=c||0;this.z=d||0;this.w=e||1};
  14. THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(b,c,d,e){this.x=b;this.y=c;this.z=d;this.w=e;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w||1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;this.w=b.w+c.w;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;this.w+=b.w;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z=b.z-c.z;this.w=
  15. b.w-c.w;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;this.z-=b.z;this.w-=b.w;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;this.w*=b;return this},divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b,this.w/=b):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z+this.w*b.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},
  16. normalize:function(){return this.divideScalar(this.length())},setLength:function(b){return this.normalize().multiplyScalar(b)},lerpSelf:function(b,c){this.x+=(b.x-this.x)*c;this.y+=(b.y-this.y)*c;this.z+=(b.z-this.z)*c;this.w+=(b.w-this.w)*c;return this}};THREE.Ray=function(b,c){this.origin=b||new THREE.Vector3;this.direction=c||new THREE.Vector3};
  17. THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var c,d,e=[];c=0;for(d=b.length;c<d;c++)e=e.concat(this.intersectObject(b[c]));e.sort(function(b,c){return b.distance-c.distance});return e},intersectObject:function(b){function c(b,c,d){var e;e=d.clone().subSelf(b).dot(c);if(e<=0)return null;b=b.clone().addSelf(c.clone().multiplyScalar(e));return d.distanceTo(b)}function d(b,c,d,e){var e=e.clone().subSelf(c),
  18. d=d.clone().subSelf(c),j=b.clone().subSelf(c),b=e.dot(e),c=e.dot(d),e=e.dot(j),h=d.dot(d),d=d.dot(j),j=1/(b*h-c*c),h=(h*e-c*d)*j,b=(b*d-c*e)*j;return h>0&&b>0&&h+b<1}if(b instanceof THREE.Particle){var e=c(this.origin,this.direction,b.matrixWorld.getPosition());if(e==null||e>b.scale.x)return[];return[{distance:e,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){e=c(this.origin,this.direction,b.matrixWorld.getPosition());if(e==null||e>b.geometry.boundingSphere.radius*Math.max(b.scale.x,
  19. Math.max(b.scale.y,b.scale.z)))return[];var j,h,k,m,r,p,u,n,s,v,B=b.geometry,y=B.vertices,E=[],e=0;for(j=B.faces.length;e<j;e++)if(h=B.faces[e],s=this.origin.clone(),v=this.direction.clone(),p=b.matrixWorld,k=p.multiplyVector3(h.centroid.clone()).subSelf(s),n=k.dot(v),!(n<=0)&&(k=p.multiplyVector3(y[h.a].position.clone()),m=p.multiplyVector3(y[h.b].position.clone()),r=p.multiplyVector3(y[h.c].position.clone()),p=h instanceof THREE.Face4?p.multiplyVector3(y[h.d].position.clone()):null,u=b.matrixRotationWorld.multiplyVector3(h.normal.clone()),
  20. n=v.dot(u),b.doubleSided||(b.flipSided?n>0:n<0)))if(n=u.dot((new THREE.Vector3).sub(k,s))/n,s=s.addSelf(v.multiplyScalar(n)),h instanceof THREE.Face3)d(s,k,m,r)&&(h={distance:this.origin.distanceTo(s),point:s,face:h,object:b},E.push(h));else if(h instanceof THREE.Face4&&(d(s,k,m,p)||d(s,m,r,p)))h={distance:this.origin.distanceTo(s),point:s,face:h,object:b},E.push(h);E.sort(function(b,c){return b.distance-c.distance});return E}else return[]}};
  21. THREE.Rectangle=function(){function b(){h=e-c;k=j-d}var c,d,e,j,h,k,m=!0;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return h};this.getHeight=function(){return k};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return j};this.set=function(h,k,u,n){m=!1;c=h;d=k;e=u;j=n;b()};this.addPoint=function(h,k){m?(m=!1,c=h,d=k,e=h,j=k):(c=c<h?c:h,d=d<k?d:k,e=e>h?e:h,j=j>k?j:k);b()};this.add3Points=
  22. function(h,k,u,n,s,v){m?(m=!1,c=h<u?h<s?h:s:u<s?u:s,d=k<n?k<v?k:v:n<v?n:v,e=h>u?h>s?h:s:u>s?u:s,j=k>n?k>v?k:v:n>v?n:v):(c=h<u?h<s?h<c?h:c:s<c?s:c:u<s?u<c?u:c:s<c?s:c,d=k<n?k<v?k<d?k:d:v<d?v:d:n<v?n<d?n:d:v<d?v:d,e=h>u?h>s?h>e?h:e:s>e?s:e:u>s?u>e?u:e:s>e?s:e,j=k>n?k>v?k>j?k:j:v>j?v:j:n>v?n>j?n:j:v>j?v:j);b()};this.addRectangle=function(h){m?(m=!1,c=h.getLeft(),d=h.getTop(),e=h.getRight(),j=h.getBottom()):(c=c<h.getLeft()?c:h.getLeft(),d=d<h.getTop()?d:h.getTop(),e=e>h.getRight()?e:h.getRight(),j=j>
  23. h.getBottom()?j:h.getBottom());b()};this.inflate=function(h){c-=h;d-=h;e+=h;j+=h;b()};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();j=j<h.getBottom()?j:h.getBottom();b()};this.instersects=function(b){return Math.min(e,b.getRight())-Math.max(c,b.getLeft())>=0&&Math.min(j,b.getBottom())-Math.max(d,b.getTop())>=0};this.empty=function(){m=!0;j=e=d=c=0;b()};this.isEmpty=function(){return m}};THREE.Matrix3=function(){this.m=[]};
  24. THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}};THREE.Matrix4=function(b,c,d,e,j,h,k,m,r,p,u,n,s,v,B,y){this.set(b||1,c||0,d||0,e||0,j||0,h||1,k||0,m||0,r||0,p||0,u||1,n||0,s||0,v||0,B||0,y||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
  25. THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,d,e,j,h,k,m,r,p,u,n,s,v,B,y){this.n11=b;this.n12=c;this.n13=d;this.n14=e;this.n21=j;this.n22=h;this.n23=k;this.n24=m;this.n31=r;this.n32=p;this.n33=u;this.n34=n;this.n41=s;this.n42=v;this.n43=B;this.n44=y;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,
  26. c,d){var e=THREE.Matrix4.__v1,j=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(b,c).normalize();if(h.length()===0)h.z=1;e.cross(d,h).normalize();e.length()===0&&(h.x+=1.0E-4,e.cross(d,h).normalize());j.cross(h,e).normalize();this.n11=e.x;this.n12=j.x;this.n13=h.x;this.n21=e.y;this.n22=j.y;this.n23=h.y;this.n31=e.z;this.n32=j.z;this.n33=h.z;return this},multiplyVector3:function(b){var c=b.x,d=b.y,e=b.z,j=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);b.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*j;
  27. b.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*j;b.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*j;return b},multiplyVector4:function(b){var c=b.x,d=b.y,e=b.z,j=b.w;b.x=this.n11*c+this.n12*d+this.n13*e+this.n14*j;b.y=this.n21*c+this.n22*d+this.n23*e+this.n24*j;b.z=this.n31*c+this.n32*d+this.n33*e+this.n34*j;b.w=this.n41*c+this.n42*d+this.n43*e+this.n44*j;return b},rotateAxis:function(b){var c=b.x,d=b.y,e=b.z;b.x=c*this.n11+d*this.n12+e*this.n13;b.y=c*this.n21+d*this.n22+e*this.n23;b.z=c*this.n31+
  28. d*this.n32+e*this.n33;b.normalize();return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var d=b.n11,e=b.n12,j=b.n13,h=b.n14,k=b.n21,m=b.n22,r=b.n23,p=b.n24,u=b.n31,n=b.n32,s=b.n33,v=b.n34,B=b.n41,y=b.n42,E=b.n43,C=b.n44,xa=c.n11,ya=
  29. c.n12,pa=c.n13,ra=c.n14,fa=c.n21,F=c.n22,w=c.n23,ia=c.n24,L=c.n31,ja=c.n32,Y=c.n33,ua=c.n34,Q=c.n41,M=c.n42,f=c.n43,Da=c.n44;this.n11=d*xa+e*fa+j*L+h*Q;this.n12=d*ya+e*F+j*ja+h*M;this.n13=d*pa+e*w+j*Y+h*f;this.n14=d*ra+e*ia+j*ua+h*Da;this.n21=k*xa+m*fa+r*L+p*Q;this.n22=k*ya+m*F+r*ja+p*M;this.n23=k*pa+m*w+r*Y+p*f;this.n24=k*ra+m*ia+r*ua+p*Da;this.n31=u*xa+n*fa+s*L+v*Q;this.n32=u*ya+n*F+s*ja+v*M;this.n33=u*pa+n*w+s*Y+v*f;this.n34=u*ra+n*ia+s*ua+v*Da;this.n41=B*xa+y*fa+E*L+C*Q;this.n42=B*ya+y*F+E*ja+
  30. C*M;this.n43=B*pa+y*w+E*Y+C*f;this.n44=B*ra+y*ia+E*ua+C*Da;return this},multiplyToArray:function(b,c,d){this.multiply(b,c);d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;
  31. this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},determinant:function(){var b=this.n11,c=this.n12,d=this.n13,e=this.n14,j=this.n21,h=this.n22,k=this.n23,m=this.n24,r=this.n31,p=this.n32,u=this.n33,n=this.n34,s=this.n41,v=this.n42,B=this.n43,y=this.n44;return e*k*p*s-d*m*p*s-e*h*u*s+c*m*u*s+d*h*n*s-c*k*n*s-e*k*r*v+d*m*r*v+e*j*u*v-b*m*u*v-d*j*n*v+b*k*n*v+e*h*r*B-c*m*r*B-e*j*p*B+b*m*p*B+c*j*n*
  32. B-b*h*n*B-d*h*r*y+c*k*r*y+d*j*p*y-b*k*p*y-c*j*u*y+b*h*u*y},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=
  33. this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;
  34. return this.flat},flattenToArray:function(b){b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,c){b[c]=this.n11;b[c+1]=this.n21;b[c+2]=this.n31;b[c+3]=this.n41;b[c+4]=this.n12;b[c+5]=this.n22;b[c+6]=this.n32;b[c+7]=this.n42;b[c+8]=this.n13;b[c+9]=this.n23;b[c+10]=this.n33;b[c+11]=
  35. this.n43;b[c+12]=this.n14;b[c+13]=this.n24;b[c+14]=this.n34;b[c+15]=this.n44;return b},setTranslation:function(b,c,d){this.set(1,0,0,b,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(b,c,d){this.set(b,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotationX:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,c,-b,0,0,b,c,0,0,0,0,1);return this},setRotationY:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,0,b,0,0,1,0,0,-b,0,c,0,0,0,0,1);return this},setRotationZ:function(b){var c=
  36. Math.cos(b),b=Math.sin(b);this.set(c,-b,0,0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var d=Math.cos(c),e=Math.sin(c),j=1-d,h=b.x,k=b.y,m=b.z,r=j*h,p=j*k;this.set(r*h+d,r*k-e*m,r*m+e*k,0,r*k+e*m,p*k+d,p*m-e*h,0,r*m-e*k,p*m+e*h,j*m*m+d,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},
  37. getColumnX:function(){if(!this.columnX)this.columnX=new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b,c){var d=b.x,e=b.y,j=b.z,h=Math.cos(d),d=Math.sin(d),k=Math.cos(e),
  38. e=Math.sin(e),m=Math.cos(j),j=Math.sin(j);switch(c){case "YXZ":var r=k*m,p=k*j,u=e*m,n=e*j;this.n11=r+n*d;this.n12=u*d-p;this.n13=h*e;this.n21=h*j;this.n22=h*m;this.n23=-d;this.n31=p*d-u;this.n32=n+r*d;this.n33=h*k;break;case "ZXY":r=k*m;p=k*j;u=e*m;n=e*j;this.n11=r-n*d;this.n12=-h*j;this.n13=u+p*d;this.n21=p+u*d;this.n22=h*m;this.n23=n-r*d;this.n31=-h*e;this.n32=d;this.n33=h*k;break;case "ZYX":r=h*m;p=h*j;u=d*m;n=d*j;this.n11=k*m;this.n12=u*e-p;this.n13=r*e+n;this.n21=k*j;this.n22=n*e+r;this.n23=
  39. p*e-u;this.n31=-e;this.n32=d*k;this.n33=h*k;break;case "YZX":r=h*k;p=h*e;u=d*k;n=d*e;this.n11=k*m;this.n12=n-r*j;this.n13=u*j+p;this.n21=j;this.n22=h*m;this.n23=-d*m;this.n31=-e*m;this.n32=p*j+u;this.n33=r-n*j;break;case "XZY":r=h*k;p=h*e;u=d*k;n=d*e;this.n11=k*m;this.n12=-j;this.n13=e*m;this.n21=r*j+n;this.n22=h*m;this.n23=p*j-u;this.n31=u*j-p;this.n32=d*m;this.n33=n*j+r;break;default:r=h*m,p=h*j,u=d*m,n=d*j,this.n11=k*m,this.n12=-k*j,this.n13=e,this.n21=p+u*e,this.n22=r-n*e,this.n23=-d*k,this.n31=
  40. n-r*e,this.n32=u+p*e,this.n33=h*k}return this},setRotationFromQuaternion:function(b){var c=b.x,d=b.y,e=b.z,j=b.w,h=c+c,k=d+d,m=e+e,b=c*h,r=c*k;c*=m;var p=d*k;d*=m;e*=m;h*=j;k*=j;j*=m;this.n11=1-(p+e);this.n12=r-j;this.n13=c+k;this.n21=r+j;this.n22=1-(b+e);this.n23=d-h;this.n31=c-k;this.n32=d+h;this.n33=1-(b+p);return this},scale:function(b){var c=b.x,d=b.y,b=b.z;this.n11*=c;this.n12*=d;this.n13*=b;this.n21*=c;this.n22*=d;this.n23*=b;this.n31*=c;this.n32*=d;this.n33*=b;this.n41*=c;this.n42*=d;this.n43*=
  41. b;return this},compose:function(b,c,d){var e=THREE.Matrix4.__m1,j=THREE.Matrix4.__m2;e.identity();e.setRotationFromQuaternion(c);j.setScale(d.x,d.y,d.z);this.multiply(e,j);this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},decompose:function(b,c,d){var e=THREE.Matrix4.__v1,j=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;e.set(this.n11,this.n21,this.n31);j.set(this.n12,this.n22,this.n32);h.set(this.n13,this.n23,this.n33);b=b instanceof THREE.Vector3?b:new THREE.Vector3;c=c instanceof THREE.Quaternion?c:
  42. new THREE.Quaternion;d=d instanceof THREE.Vector3?d:new THREE.Vector3;d.x=e.length();d.y=j.length();d.z=h.length();b.x=this.n14;b.y=this.n24;b.z=this.n34;e=THREE.Matrix4.__m1;e.copy(this);e.n11/=d.x;e.n21/=d.x;e.n31/=d.x;e.n12/=d.y;e.n22/=d.y;e.n32/=d.y;e.n13/=d.z;e.n23/=d.z;e.n33/=d.z;c.setFromRotationMatrix(e);return[b,c,d]},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,c){var d=1/c.x,e=1/c.y,j=1/c.z;this.n11=b.n11*d;this.n21=b.n21*d;this.n31=
  43. b.n31*d;this.n12=b.n12*e;this.n22=b.n22*e;this.n32=b.n32*e;this.n13=b.n13*j;this.n23=b.n23*j;this.n33=b.n33*j}};
  44. THREE.Matrix4.makeInvert=function(b,c){var d=b.n11,e=b.n12,j=b.n13,h=b.n14,k=b.n21,m=b.n22,r=b.n23,p=b.n24,u=b.n31,n=b.n32,s=b.n33,v=b.n34,B=b.n41,y=b.n42,E=b.n43,C=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=r*v*y-p*s*y+p*n*E-m*v*E-r*n*C+m*s*C;c.n12=h*s*y-j*v*y-h*n*E+e*v*E+j*n*C-e*s*C;c.n13=j*p*y-h*r*y+h*m*E-e*p*E-j*m*C+e*r*C;c.n14=h*r*n-j*p*n-h*m*s+e*p*s+j*m*v-e*r*v;c.n21=p*s*B-r*v*B-p*u*E+k*v*E+r*u*C-k*s*C;c.n22=j*v*B-h*s*B+h*u*E-d*v*E-j*u*C+d*s*C;c.n23=h*r*B-j*p*B-h*k*E+d*p*E+j*k*C-d*r*C;c.n24=
  45. j*p*u-h*r*u+h*k*s-d*p*s-j*k*v+d*r*v;c.n31=m*v*B-p*n*B+p*u*y-k*v*y-m*u*C+k*n*C;c.n32=h*n*B-e*v*B-h*u*y+d*v*y+e*u*C-d*n*C;c.n33=j*p*B-h*m*B+h*k*y-d*p*y-e*k*C+d*m*C;c.n34=h*m*u-e*p*u-h*k*n+d*p*n+e*k*v-d*m*v;c.n41=r*n*B-m*s*B-r*u*y+k*s*y+m*u*E-k*n*E;c.n42=e*s*B-j*n*B+j*u*y-d*s*y-e*u*E+d*n*E;c.n43=j*m*B-e*r*B-j*k*y+d*r*y+e*k*E-d*m*E;c.n44=e*r*u-j*m*u+j*k*n-d*r*n-e*k*s+d*m*s;c.multiplyScalar(1/b.determinant());return c};
  46. THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,d=c.m,e=b.n33*b.n22-b.n32*b.n23,j=-b.n33*b.n21+b.n31*b.n23,h=b.n32*b.n21-b.n31*b.n22,k=-b.n33*b.n12+b.n32*b.n13,m=b.n33*b.n11-b.n31*b.n13,r=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,u=-b.n23*b.n11+b.n21*b.n13,n=b.n22*b.n11-b.n21*b.n12,b=b.n11*e+b.n21*k+b.n31*p;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;d[0]=b*e;d[1]=b*j;d[2]=b*h;d[3]=b*k;d[4]=b*m;d[5]=b*r;d[6]=b*p;d[7]=b*u;d[8]=b*n;return c};
  47. THREE.Matrix4.makeFrustum=function(b,c,d,e,j,h){var k;k=new THREE.Matrix4;k.n11=2*j/(c-b);k.n12=0;k.n13=(c+b)/(c-b);k.n14=0;k.n21=0;k.n22=2*j/(e-d);k.n23=(e+d)/(e-d);k.n24=0;k.n31=0;k.n32=0;k.n33=-(h+j)/(h-j);k.n34=-2*h*j/(h-j);k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(b,c,d,e){var j,b=d*Math.tan(b*Math.PI/360);j=-b;return THREE.Matrix4.makeFrustum(j*c,b*c,j,b,d,e)};
  48. THREE.Matrix4.makeOrtho=function(b,c,d,e,j,h){var k,m,r,p;k=new THREE.Matrix4;m=c-b;r=d-e;p=h-j;k.n11=2/m;k.n12=0;k.n13=0;k.n14=-((c+b)/m);k.n21=0;k.n22=2/r;k.n23=0;k.n24=-((d+e)/r);k.n31=0;k.n32=0;k.n33=-2/p;k.n34=-((h+j)/p);k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
  49. THREE.Object3D=function(){this.id=THREE.Object3DCount++;this.name="";this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=
  50. !0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this._vector=new THREE.Vector3};
  51. THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(b,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(b,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},add:function(b){if(this.children.indexOf(b)===
  52. -1){b.parent!==void 0&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var c=this;c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.addChildRecurse(b)}},remove:function(b){var c=this.children.indexOf(b);if(c!==-1)b.parent=void 0,this.children.splice(c,1)},getChildByName:function(b,c){var d,e,j;d=0;for(e=this.children.length;d<e;d++){j=this.children[d];if(j.name===b)return j;if(c&&(j=j.getChildByName(b,c),j!==void 0))return j}},updateMatrix:function(){this.matrix.setPosition(this.position);
  53. this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(b,c,d){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||c)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),
  54. this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,c=!0;for(var b=0,e=this.children.length;b<e;b++)this.children[b].update(this.matrixWorld,c,d)},addChild:function(b){console.warn("DEPRECATED: Object3D.addChild() is now Object3D.add()");this.add(b)},removeChild:function(b){console.warn("DEPRECATED: Object3D.removeChild() is now Object3D.remove()");this.remove(b)}};THREE.Object3DCount=0;
  55. THREE.Projector=function(){function b(){var b=r[m]=r[m]||new THREE.RenderableVertex;m++;return b}function c(b,c){return c.z-b.z}function d(b,c){var d=0,f=1,e=b.z+b.w,j=c.z+c.w,h=-b.z+b.w,k=-c.z+c.w;return e>=0&&j>=0&&h>=0&&k>=0?!0:e<0&&j<0||h<0&&k<0?!1:(e<0?d=Math.max(d,e/(e-j)):j<0&&(f=Math.min(f,e/(e-j))),h<0?d=Math.max(d,h/(h-k)):k<0&&(f=Math.min(f,h/(h-k))),f<d?!1:(b.lerpSelf(c,d),c.lerpSelf(b,1-f),!0))}var e,j,h=[],k,m,r=[],p,u,n=[],s,v=[],B,y,E=[],C,xa,ya=[],pa=[],ra=[],fa=new THREE.Vector4,
  56. F=new THREE.Vector4,w=new THREE.Matrix4,ia=new THREE.Matrix4,L=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ja=new THREE.Vector4,Y=new THREE.Vector4;this.projectVector=function(b,c){w.multiply(c.projectionMatrix,c.matrixWorldInverse);w.multiplyVector3(b);return b};this.unprojectVector=function(b,c){w.multiply(c.matrixWorld,THREE.Matrix4.makeInvert(c.projectionMatrix));w.multiplyVector3(b);return b};this.projectObjects=function(b,d,k){var f,
  57. m;j=pa.length=0;f=b.objects;b=0;for(d=f.length;b<d;b++){m=f[b];var p;if(!(p=!m.visible))if(p=m instanceof THREE.Mesh)if(p=m.frustumCulled){a:{p=void 0;for(var r=m.matrixWorld,u=-m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)),n=0;n<6;n++)if(p=L[n].x*r.n14+L[n].y*r.n24+L[n].z*r.n34+L[n].w,p<=u){p=!1;break a}p=!0}p=!p}if(!p)p=h[j]=h[j]||new THREE.RenderableObject,j++,e=p,fa.copy(m.position),w.multiplyVector3(fa),e.object=m,e.z=fa.z,pa.push(e)}k&&pa.sort(c);return pa};
  58. this.projectScene=function(e,j,h){var f=j.near,pa=j.far,fa,va,T,Z,J,W,S,V,wa,P,sa,Ga,za,Ea,R,Aa,Ca;xa=y=s=u=ra.length=0;j.matrixAutoUpdate&&j.update(void 0,!0);e.update(void 0,!1,j);w.multiply(j.projectionMatrix,j.matrixWorldInverse);L[0].set(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);L[1].set(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);L[2].set(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);L[3].set(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);L[4].set(w.n41-w.n31,w.n42-w.n32,w.n43-
  59. w.n33,w.n44-w.n34);L[5].set(w.n41+w.n31,w.n42+w.n32,w.n43+w.n33,w.n44+w.n34);for(fa=0;fa<6;fa++)wa=L[fa],wa.divideScalar(Math.sqrt(wa.x*wa.x+wa.y*wa.y+wa.z*wa.z));wa=this.projectObjects(e,j,!0);e=0;for(fa=wa.length;e<fa;e++)if(P=wa[e].object,P.visible)if(sa=P.matrixWorld,Ga=P.matrixRotationWorld,za=P.materials,Ea=P.overdraw,m=0,P instanceof THREE.Mesh){R=P.geometry;Z=R.vertices;Aa=R.faces;R=R.faceVertexUvs;va=0;for(T=Z.length;va<T;va++)k=b(),k.positionWorld.copy(Z[va].position),sa.multiplyVector3(k.positionWorld),
  60. k.positionScreen.copy(k.positionWorld),w.multiplyVector4(k.positionScreen),k.positionScreen.x/=k.positionScreen.w,k.positionScreen.y/=k.positionScreen.w,k.visible=k.positionScreen.z>f&&k.positionScreen.z<pa;Z=0;for(va=Aa.length;Z<va;Z++){T=Aa[Z];if(T instanceof THREE.Face3)if(J=r[T.a],W=r[T.b],S=r[T.c],J.visible&&W.visible&&S.visible&&(P.doubleSided||P.flipSided!=(S.positionScreen.x-J.positionScreen.x)*(W.positionScreen.y-J.positionScreen.y)-(S.positionScreen.y-J.positionScreen.y)*(W.positionScreen.x-
  61. J.positionScreen.x)<0))V=n[u]=n[u]||new THREE.RenderableFace3,u++,p=V,p.v1.copy(J),p.v2.copy(W),p.v3.copy(S);else continue;else if(T instanceof THREE.Face4)if(J=r[T.a],W=r[T.b],S=r[T.c],V=r[T.d],J.visible&&W.visible&&S.visible&&V.visible&&(P.doubleSided||P.flipSided!=((V.positionScreen.x-J.positionScreen.x)*(W.positionScreen.y-J.positionScreen.y)-(V.positionScreen.y-J.positionScreen.y)*(W.positionScreen.x-J.positionScreen.x)<0||(W.positionScreen.x-S.positionScreen.x)*(V.positionScreen.y-S.positionScreen.y)-
  62. (W.positionScreen.y-S.positionScreen.y)*(V.positionScreen.x-S.positionScreen.x)<0)))Ca=v[s]=v[s]||new THREE.RenderableFace4,s++,p=Ca,p.v1.copy(J),p.v2.copy(W),p.v3.copy(S),p.v4.copy(V);else continue;p.normalWorld.copy(T.normal);Ga.multiplyVector3(p.normalWorld);p.centroidWorld.copy(T.centroid);sa.multiplyVector3(p.centroidWorld);p.centroidScreen.copy(p.centroidWorld);w.multiplyVector3(p.centroidScreen);S=T.vertexNormals;J=0;for(W=S.length;J<W;J++)V=p.vertexNormalsWorld[J],V.copy(S[J]),Ga.multiplyVector3(V);
  63. J=0;for(W=R.length;J<W;J++)if(Ca=R[J][Z]){S=0;for(V=Ca.length;S<V;S++)p.uvs[J][S]=Ca[S]}p.meshMaterials=za;p.faceMaterials=T.materials;p.overdraw=Ea;p.z=p.centroidScreen.z;ra.push(p)}}else if(P instanceof THREE.Line){ia.multiply(w,sa);Z=P.geometry.vertices;J=b();J.positionScreen.copy(Z[0].position);ia.multiplyVector4(J.positionScreen);va=1;for(T=Z.length;va<T;va++)if(J=b(),J.positionScreen.copy(Z[va].position),ia.multiplyVector4(J.positionScreen),W=r[m-2],ja.copy(J.positionScreen),Y.copy(W.positionScreen),
  64. d(ja,Y))ja.multiplyScalar(1/ja.w),Y.multiplyScalar(1/Y.w),sa=E[y]=E[y]||new THREE.RenderableLine,y++,B=sa,B.v1.positionScreen.copy(ja),B.v2.positionScreen.copy(Y),B.z=Math.max(ja.z,Y.z),B.materials=P.materials,ra.push(B)}else if(P instanceof THREE.Particle&&(F.set(P.matrixWorld.n14,P.matrixWorld.n24,P.matrixWorld.n34,1),w.multiplyVector4(F),F.z/=F.w,F.z>0&&F.z<1))sa=ya[xa]=ya[xa]||new THREE.RenderableParticle,xa++,C=sa,C.x=F.x/F.w,C.y=F.y/F.w,C.z=F.z,C.rotation=P.rotation.z,C.scale.x=P.scale.x*Math.abs(C.x-
  65. (F.x+j.projectionMatrix.n11)/(F.w+j.projectionMatrix.n14)),C.scale.y=P.scale.y*Math.abs(C.y-(F.y+j.projectionMatrix.n22)/(F.w+j.projectionMatrix.n24)),C.materials=P.materials,ra.push(C);h&&ra.sort(c);return ra}};THREE.Quaternion=function(b,c,d,e){this.set(b||0,c||0,d||0,e!==void 0?e:1)};
  66. THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,c,d,e){this.x=b;this.y=c;this.z=d;this.w=e;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var c=0.5*Math.PI/360,d=b.x*c,e=b.y*c,j=b.z*c,b=Math.cos(e),e=Math.sin(e),c=Math.cos(-j),j=Math.sin(-j),h=Math.cos(d),d=Math.sin(d),k=b*c,m=e*j;this.w=k*h-m*d;this.x=k*d+m*h;this.y=e*c*h+b*j*d;this.z=b*j*h-e*c*d;return this},setFromAxisAngle:function(b,c){var d=c/2,e=Math.sin(d);
  67. this.x=b.x*e;this.y=b.y*e;this.z=b.z*e;this.w=Math.cos(d);return this},setFromRotationMatrix:function(b){var c=Math.pow(b.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+b.n11+b.n22+b.n33))/2;this.x=Math.sqrt(Math.max(0,c+b.n11-b.n22-b.n33))/2;this.y=Math.sqrt(Math.max(0,c-b.n11+b.n22-b.n33))/2;this.z=Math.sqrt(Math.max(0,c-b.n11-b.n22+b.n33))/2;this.x=b.n32-b.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=b.n13-b.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=b.n21-b.n12<0?-Math.abs(this.z):Math.abs(this.z);
  68. this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);b==0?this.w=this.z=this.y=this.x=0:(b=1/b,this.x*=b,this.y*=b,this.z*=b,this.w*=b);return this},multiplySelf:function(b){var c=
  69. this.x,d=this.y,e=this.z,j=this.w,h=b.x,k=b.y,m=b.z,b=b.w;this.x=c*b+j*h+d*m-e*k;this.y=d*b+j*k+e*h-c*m;this.z=e*b+j*m+c*k-d*h;this.w=j*b-c*h-d*k-e*m;return this},multiply:function(b,c){this.x=b.x*c.w+b.y*c.z-b.z*c.y+b.w*c.x;this.y=-b.x*c.z+b.y*c.w+b.z*c.x+b.w*c.y;this.z=b.x*c.y-b.y*c.x+b.z*c.w+b.w*c.z;this.w=-b.x*c.x-b.y*c.y-b.z*c.z+b.w*c.w;return this},multiplyVector3:function(b,c){c||(c=b);var d=b.x,e=b.y,j=b.z,h=this.x,k=this.y,m=this.z,r=this.w,p=r*d+k*j-m*e,u=r*e+m*d-h*j,n=r*j+h*e-k*d,d=-h*
  70. d-k*e-m*j;c.x=p*r+d*-h+u*-m-n*-k;c.y=u*r+d*-k+n*-h-p*-m;c.z=n*r+d*-m+p*-k-u*-h;return c}};THREE.Quaternion.slerp=function(b,c,d,e){var j=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(j)>=1)return d.w=b.w,d.x=b.x,d.y=b.y,d.z=b.z,d;var h=Math.acos(j),k=Math.sqrt(1-j*j);if(Math.abs(k)<0.0010)return d.w=0.5*(b.w+c.w),d.x=0.5*(b.x+c.x),d.y=0.5*(b.y+c.y),d.z=0.5*(b.z+c.z),d;j=Math.sin((1-e)*h)/k;e=Math.sin(e*h)/k;d.w=b.w*j+c.w*e;d.x=b.x*j+c.x*e;d.y=b.y*j+c.y*e;d.z=b.z*j+c.z*e;return d};
  71. THREE.Vertex=function(b){this.position=b||new THREE.Vector3};THREE.Face3=function(b,c,d,e,j,h){this.a=b;this.b=c;this.c=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=j instanceof THREE.Color?j:new THREE.Color;this.vertexColors=j instanceof Array?j:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};
  72. THREE.Face4=function(b,c,d,e,j,h,k){this.a=b;this.b=c;this.c=d;this.d=e;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=k instanceof Array?k:[k];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.u=b||0;this.v=c||0};
  73. THREE.UV.prototype={constructor:THREE.UV,set:function(b,c){this.u=b;this.v=c;return this},copy:function(b){this.u=b.u;this.v=b.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
  74. THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1};
  75. THREE.Geometry.prototype={constructor:THREE.Geometry,computeCentroids:function(){var b,c,d;b=0;for(c=this.faces.length;b<c;b++)d=this.faces[b],d.centroid.set(0,0,0),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)):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),
  76. d.centroid.addSelf(this.vertices[d.d].position),d.centroid.divideScalar(4))},computeFaceNormals:function(b){var c,d,e,j,h,k,m=new THREE.Vector3,r=new THREE.Vector3;e=0;for(j=this.faces.length;e<j;e++){h=this.faces[e];if(b&&h.vertexNormals.length){m.set(0,0,0);c=0;for(d=h.vertexNormals.length;c<d;c++)m.addSelf(h.vertexNormals[c]);m.divideScalar(3)}else c=this.vertices[h.a],d=this.vertices[h.b],k=this.vertices[h.c],m.sub(k.position,d.position),r.sub(c.position,d.position),m.crossSelf(r);m.isZero()||
  77. m.normalize();h.normal.copy(m)}},computeVertexNormals:function(){var b,c,d,e;if(this.__tmpVertices==void 0){e=this.__tmpVertices=Array(this.vertices.length);b=0;for(c=this.vertices.length;b<c;b++)e[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)if(d=this.faces[b],d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{e=
  78. this.__tmpVertices;b=0;for(c=this.vertices.length;b<c;b++)e[b].set(0,0,0)}b=0;for(c=this.faces.length;b<c;b++)d=this.faces[b],d instanceof THREE.Face3?(e[d.a].addSelf(d.normal),e[d.b].addSelf(d.normal),e[d.c].addSelf(d.normal)):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));b=0;for(c=this.vertices.length;b<c;b++)e[b].normalize();b=0;for(c=this.faces.length;b<c;b++)d=this.faces[b],d instanceof THREE.Face3?(d.vertexNormals[0].copy(e[d.a]),
  79. d.vertexNormals[1].copy(e[d.b]),d.vertexNormals[2].copy(e[d.c])):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 b(b,f,c,d,e,j,h){m=b.vertices[f].position;r=b.vertices[c].position;p=b.vertices[d].position;u=k[e];n=k[j];s=k[h];v=r.x-m.x;B=p.x-m.x;y=r.y-m.y;E=p.y-m.y;C=r.z-m.z;xa=p.z-m.z;ya=n.u-u.u;pa=s.u-u.u;ra=n.v-u.v;fa=s.v-u.v;F=1/(ya*fa-pa*ra);ja.set((fa*
  80. v-ra*B)*F,(fa*y-ra*E)*F,(fa*C-ra*xa)*F);Y.set((ya*B-pa*v)*F,(ya*E-pa*y)*F,(ya*xa-pa*C)*F);ia[f].addSelf(ja);ia[c].addSelf(ja);ia[d].addSelf(ja);L[f].addSelf(Y);L[c].addSelf(Y);L[d].addSelf(Y)}var c,d,e,j,h,k,m,r,p,u,n,s,v,B,y,E,C,xa,ya,pa,ra,fa,F,w,ia=[],L=[],ja=new THREE.Vector3,Y=new THREE.Vector3,ua=new THREE.Vector3,Q=new THREE.Vector3,M=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++)ia[c]=new THREE.Vector3,L[c]=new THREE.Vector3;c=0;for(d=this.faces.length;c<d;c++)h=this.faces[c],k=
  81. this.faceVertexUvs[0][c],h instanceof THREE.Face3?b(this,h.a,h.b,h.c,0,1,2):h instanceof THREE.Face4&&(b(this,h.a,h.b,h.c,0,1,2),b(this,h.a,h.b,h.d,0,1,3));var f=["a","b","c","d"];c=0;for(d=this.faces.length;c<d;c++){h=this.faces[c];for(e=0;e<h.vertexNormals.length;e++)M.copy(h.vertexNormals[e]),j=h[f[e]],w=ia[j],ua.copy(w),ua.subSelf(M.multiplyScalar(M.dot(w))).normalize(),Q.cross(h.vertexNormals[e],w),j=Q.dot(L[j]),j=j<0?-1:1,h.vertexTangents[e]=new THREE.Vector4(ua.x,ua.y,ua.z,j)}this.hasTangents=
  82. !0},computeBoundingBox:function(){var b;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.vertices.length;c<d;c++){b=this.vertices[c];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=
  83. b.position.y;else if(b.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,d=this.vertices.length;c<d;c++)b=Math.max(b,this.vertices[c].position.length());this.boundingSphere={radius:b}},computeEdgeFaces:function(){function b(b,c){return Math.min(b,c)+"_"+Math.max(b,c)}function c(b,
  84. c,d){b[c]===void 0?(b[c]={set:{},array:[]},b[c].set[d]=1,b[c].array.push(d)):b[c].set[d]===void 0&&(b[c].set[d]=1,b[c].array.push(d))}var d,e,j,h,k,m={};d=0;for(e=this.faces.length;d<e;d++)k=this.faces[d],k instanceof THREE.Face3?(j=b(k.a,k.b),c(m,j,d),j=b(k.b,k.c),c(m,j,d),j=b(k.a,k.c),c(m,j,d)):k instanceof THREE.Face4&&(j=b(k.b,k.d),c(m,j,d),j=b(k.a,k.b),c(m,j,d),j=b(k.a,k.d),c(m,j,d),j=b(k.b,k.c),c(m,j,d),j=b(k.c,k.d),c(m,j,d));d=0;for(e=this.edges.length;d<e;d++){k=this.edges[d];j=k.vertexIndices[0];
  85. h=k.vertexIndices[1];k.faceIndices=m[b(j,h)].array;for(j=0;j<k.faceIndices.length;j++)h=k.faceIndices[j],k.faces.push(this.faces[h])}}};THREE.GeometryCount=0;
  86. THREE.Spline=function(b){function c(b,c,d,e,j,h,k){b=(d-b)*0.5;e=(e-c)*0.5;return(2*(c-d)+b+e)*k+(-3*(c-d)-2*b-e)*h+b*j+c}this.points=b;var d=[],e={x:0,y:0,z:0},j,h,k,m,r,p,u,n,s;this.initFromArray=function(b){this.points=[];for(var c=0;c<b.length;c++)this.points[c]={x:b[c][0],y:b[c][1],z:b[c][2]}};this.getPoint=function(b){j=(this.points.length-1)*b;h=Math.floor(j);k=j-h;d[0]=h==0?h:h-1;d[1]=h;d[2]=h>this.points.length-2?h:h+1;d[3]=h>this.points.length-3?h:h+2;p=this.points[d[0]];u=this.points[d[1]];
  87. n=this.points[d[2]];s=this.points[d[3]];m=k*k;r=k*m;e.x=c(p.x,u.x,n.x,s.x,k,m,r);e.y=c(p.y,u.y,n.y,s.y,k,m,r);e.z=c(p.z,u.z,n.z,s.z,k,m,r);return e};this.getControlPointsArray=function(){var b,c,d=this.points.length,e=[];for(b=0;b<d;b++)c=this.points[b],e[b]=[c.x,c.y,c.z];return e};this.getLength=function(b){var c,d,e=c=c=0,j=new THREE.Vector3,h=new THREE.Vector3,k=[],m=0;k[0]=0;b||(b=100);d=this.points.length*b;j.copy(this.points[0]);for(b=1;b<d;b++)c=b/d,position=this.getPoint(c),h.copy(position),
  88. m+=h.distanceTo(j),j.copy(position),c*=this.points.length-1,c=Math.floor(c),c!=e&&(k[c]=m,e=c);k[k.length]=m;return{chunks:k,total:m}};this.reparametrizeByArcLength=function(b){var c,d,e,j,h,k,m=[],p=new THREE.Vector3,r=this.getLength();m.push(p.copy(this.points[0]).clone());for(c=1;c<this.points.length;c++){d=r.chunks[c]-r.chunks[c-1];k=Math.ceil(b*d/r.total);j=(c-1)/(this.points.length-1);h=c/(this.points.length-1);for(d=1;d<k-1;d++)e=j+d*(1/k)*(h-j),position=this.getPoint(e),m.push(p.copy(position).clone());
  89. m.push(p.copy(this.points[c]).clone())}this.points=m}};THREE.Edge=function(b,c,d,e){this.vertices=[b,c];this.vertexIndices=[d,e];this.faces=[];this.faceIndices=[]};THREE.Camera=function(b,c,d,e,j){THREE.Object3D.call(this);this.fov=b||50;this.aspect=c||1;this.near=d||0.1;this.far=e||2E3;this.target=j||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;
  90. THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(b,c){this.matrix.rotateAxis(c);c.multiplyScalar(b);this.position.addSelf(c);this.target.position.addSelf(c)};
  91. THREE.Camera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var b=this.fullWidth/this.fullHeight,c=Math.tan(this.fov*Math.PI/360)*this.near,d=-c,e=b*d,b=Math.abs(b*c-e),d=Math.abs(c-d);this.projectionMatrix=THREE.Matrix4.makeFrustum(e+this.x*b/this.fullWidth,e+(this.x+this.width)*b/this.fullWidth,c-(this.y+this.height)*d/this.fullHeight,c-this.y*d/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
  92. THREE.Camera.prototype.setViewOffset=function(b,c,d,e,j,h){this.fullWidth=b;this.fullHeight=c;this.x=d;this.y=e;this.width=j;this.height=h;this.updateProjectionMatrix()};
  93. THREE.Camera.prototype.update=function(b,c,d){if(this.useTarget)this.matrix.lookAt(this.position,this.target.position,this.up),this.matrix.setPosition(this.position),b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse),c=!0;else if(this.matrixAutoUpdate&&this.updateMatrix(),c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=
  94. !1,c=!0,THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,c,d)};THREE.OrthoCamera=function(b,c,d,e,j,h,k){THREE.Camera.call(this,45,1,j,h,k);this.left=b;this.right=c;this.top=d;this.bottom=e;this.updateProjectionMatrix()};THREE.OrthoCamera.prototype=new THREE.Camera;THREE.OrthoCamera.prototype.constructor=THREE.OrthoCamera;
  95. THREE.OrthoCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};THREE.Light=function(b){THREE.Object3D.call(this);this.color=new THREE.Color(b)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(b){THREE.Light.call(this,b)};THREE.AmbientLight.prototype=new THREE.Light;
  96. THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(b,c,d,e){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1;this.distance=d||0;this.castShadow=e!==void 0?e:!1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(b,c,d){THREE.Light.call(this,b);this.position=new THREE.Vector3;this.intensity=c||1;this.distance=d||0};
  97. THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.SpotLight=function(b,c,d,e){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=c||1;this.distance=d||0;this.castShadow=e!==void 0?e:!1};THREE.SpotLight.prototype=new THREE.Light;THREE.SpotLight.prototype.constructor=THREE.SpotLight;
  98. THREE.Material=function(b){this.id=THREE.MaterialCount++;b=b||{};this.opacity=b.opacity!==void 0?b.opacity:1;this.transparent=b.transparent!==void 0?b.transparent:!1;this.blending=b.blending!==void 0?b.blending:THREE.NormalBlending;this.depthTest=b.depthTest!==void 0?b.depthTest:!0;this.depthWrite=b.depthWrite!==void 0?b.depthWrite:!0;this.polygonOffset=b.polygonOffset!==void 0?b.polygonOffset:!1;this.polygonOffsetFactor=b.polygonOffsetFactor!==void 0?b.polygonOffsetFactor:0;this.polygonOffsetUnits=
  99. b.polygonOffsetUnits!==void 0?b.polygonOffsetUnits:0;this.alphaTest=b.alphaTest!==void 0?b.alphaTest:0};THREE.MaterialCount=0;THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.MultiplyBlending=3;THREE.AdditiveAlphaBlending=4;
  100. THREE.LineBasicMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.linewidth=b.linewidth!==void 0?b.linewidth:1;this.linecap=b.linecap!==void 0?b.linecap:"round";this.linejoin=b.linejoin!==void 0?b.linejoin:"round";this.vertexColors=b.vertexColors?b.vertexColors:!1};THREE.LineBasicMaterial.prototype=new THREE.Material;THREE.LineBasicMaterial.prototype.constructor=THREE.LineBasicMaterial;
  101. THREE.MeshBasicMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.map=b.map!==void 0?b.map:null;this.lightMap=b.lightMap!==void 0?b.lightMap:null;this.envMap=b.envMap!==void 0?b.envMap:null;this.combine=b.combine!==void 0?b.combine:THREE.MultiplyOperation;this.reflectivity=b.reflectivity!==void 0?b.reflectivity:1;this.refractionRatio=b.refractionRatio!==void 0?b.refractionRatio:0.98;this.shading=b.shading!==
  102. void 0?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==void 0?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth!==void 0?b.wireframeLinewidth:1;this.wireframeLinecap=b.wireframeLinecap!==void 0?b.wireframeLinecap:"round";this.wireframeLinejoin=b.wireframeLinejoin!==void 0?b.wireframeLinejoin:"round";this.vertexColors=b.vertexColors!==void 0?b.vertexColors:!1;this.skinning=b.skinning!==void 0?b.skinning:!1;this.morphTargets=b.morphTargets!==void 0?b.morphTargets:!1};
  103. THREE.MeshBasicMaterial.prototype=new THREE.Material;THREE.MeshBasicMaterial.prototype.constructor=THREE.MeshBasicMaterial;
  104. THREE.MeshLambertMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.map=b.map!==void 0?b.map:null;this.lightMap=b.lightMap!==void 0?b.lightMap:null;this.envMap=b.envMap!==void 0?b.envMap:null;this.combine=b.combine!==void 0?b.combine:THREE.MultiplyOperation;this.reflectivity=b.reflectivity!==void 0?b.reflectivity:1;this.refractionRatio=b.refractionRatio!==void 0?b.refractionRatio:0.98;this.shading=b.shading!==
  105. void 0?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==void 0?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth!==void 0?b.wireframeLinewidth:1;this.wireframeLinecap=b.wireframeLinecap!==void 0?b.wireframeLinecap:"round";this.wireframeLinejoin=b.wireframeLinejoin!==void 0?b.wireframeLinejoin:"round";this.vertexColors=b.vertexColors!==void 0?b.vertexColors:!1;this.skinning=b.skinning!==void 0?b.skinning:!1;this.morphTargets=b.morphTargets!==void 0?b.morphTargets:!1};
  106. THREE.MeshLambertMaterial.prototype=new THREE.Material;THREE.MeshLambertMaterial.prototype.constructor=THREE.MeshLambertMaterial;
  107. THREE.MeshPhongMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.ambient=b.ambient!==void 0?new THREE.Color(b.ambient):new THREE.Color(328965);this.specular=b.specular!==void 0?new THREE.Color(b.specular):new THREE.Color(1118481);this.shininess=b.shininess!==void 0?b.shininess:30;this.map=b.map!==void 0?b.map:null;this.lightMap=b.lightMap!==void 0?b.lightMap:null;this.envMap=b.envMap!==void 0?b.envMap:null;
  108. this.combine=b.combine!==void 0?b.combine:THREE.MultiplyOperation;this.reflectivity=b.reflectivity!==void 0?b.reflectivity:1;this.refractionRatio=b.refractionRatio!==void 0?b.refractionRatio:0.98;this.shading=b.shading!==void 0?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==void 0?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth!==void 0?b.wireframeLinewidth:1;this.wireframeLinecap=b.wireframeLinecap!==void 0?b.wireframeLinecap:"round";this.wireframeLinejoin=b.wireframeLinejoin!==
  109. void 0?b.wireframeLinejoin:"round";this.vertexColors=b.vertexColors!==void 0?b.vertexColors:!1;this.skinning=b.skinning!==void 0?b.skinning:!1;this.morphTargets=b.morphTargets!==void 0?b.morphTargets:!1};THREE.MeshPhongMaterial.prototype=new THREE.Material;THREE.MeshPhongMaterial.prototype.constructor=THREE.MeshPhongMaterial;
  110. THREE.MeshDepthMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.shading=b.shading!==void 0?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==void 0?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth!==void 0?b.wireframeLinewidth:1};THREE.MeshDepthMaterial.prototype=new THREE.Material;THREE.MeshDepthMaterial.prototype.constructor=THREE.MeshDepthMaterial;
  111. THREE.MeshNormalMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.shading=b.shading?b.shading:THREE.FlatShading;this.wireframe=b.wireframe?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth?b.wireframeLinewidth:1};THREE.MeshNormalMaterial.prototype=new THREE.Material;THREE.MeshNormalMaterial.prototype.constructor=THREE.MeshNormalMaterial;THREE.MeshFaceMaterial=function(){};
  112. THREE.MeshShaderMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.fragmentShader=b.fragmentShader!==void 0?b.fragmentShader:"void main() {}";this.vertexShader=b.vertexShader!==void 0?b.vertexShader:"void main() {}";this.uniforms=b.uniforms!==void 0?b.uniforms:{};this.attributes=b.attributes;this.shading=b.shading!==void 0?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==void 0?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth!==void 0?b.wireframeLinewidth:1;this.fog=
  113. b.fog!==void 0?b.fog:!1;this.lights=b.lights!==void 0?b.lights:!1;this.vertexColors=b.vertexColors!==void 0?b.vertexColors:!1;this.skinning=b.skinning!==void 0?b.skinning:!1;this.morphTargets=b.morphTargets!==void 0?b.morphTargets:!1};THREE.MeshShaderMaterial.prototype=new THREE.Material;THREE.MeshShaderMaterial.prototype.constructor=THREE.MeshShaderMaterial;
  114. THREE.ParticleBasicMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.map=b.map!==void 0?b.map:null;this.size=b.size!==void 0?b.size:1;this.sizeAttenuation=b.sizeAttenuation!==void 0?b.sizeAttenuation:!0;this.vertexColors=b.vertexColors!==void 0?b.vertexColors:!1};THREE.ParticleBasicMaterial.prototype=new THREE.Material;THREE.ParticleBasicMaterial.prototype.constructor=THREE.ParticleBasicMaterial;
  115. THREE.Texture=function(b,c,d,e,j,h){this.id=THREE.TextureCount++;this.image=b;this.mapping=c!==void 0?c:new THREE.UVMapping;this.wrapS=d!==void 0?d:THREE.ClampToEdgeWrapping;this.wrapT=e!==void 0?e:THREE.ClampToEdgeWrapping;this.magFilter=j!==void 0?j:THREE.LinearFilter;this.minFilter=h!==void 0?h:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.needsUpdate=!1};
  116. THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var b=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);b.offset.copy(this.offset);b.repeat.copy(this.repeat);return b}};THREE.TextureCount=0;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
  117. THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;
  118. THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.Particle=function(b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b]};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c];this.sortParticles=!1};
  119. THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(b,c,d){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c];this.type=d!=void 0?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
  120. THREE.Mesh=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c&&c.length?c:[c];this.overdraw=!1;if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=b.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var d=0;d<this.geometry.morphTargets.length;d++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[d].name]=
  121. d}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;THREE.Mesh.prototype.getMorphTargetIndexByName=function(b){if(this.morphTargetDictionary[b]!==void 0)return this.morphTargetDictionary[b];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+b+" does not exist. Returning 0.");return 0};
  122. THREE.Bone=function(b){THREE.Object3D.call(this);this.skin=b;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
  123. THREE.Bone.prototype.update=function(b,c,d){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.skinMatrix.multiply(b,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;var e,j=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(e=0;e<j;e++)b=this.children[e],b instanceof THREE.Bone?b.update(this.skinMatrix,c,d):b.update(this.matrixWorld,!0,d)}else for(e=0;e<j;e++)this.children[e].update(this.skinMatrix,
  124. c,d)};THREE.Bone.prototype.addChild=function(b){if(this.children.indexOf(b)===-1&&(b.parent!==void 0&&b.parent.removeChild(b),b.parent=this,this.children.push(b),!(b instanceof THREE.Bone)))this.hasNoneBoneChildren=!0};
  125. THREE.SkinnedMesh=function(b,c){THREE.Mesh.call(this,b,c);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var d,e,j,h,k,m;if(this.geometry.bones!==void 0){for(d=0;d<this.geometry.bones.length;d++)j=this.geometry.bones[d],h=j.pos,k=j.rotq,m=j.scl,e=this.addBone(),e.name=j.name,e.position.set(h[0],h[1],h[2]),e.quaternion.set(k[0],k[1],k[2],k[3]),e.useQuaternion=!0,m!==void 0?e.scale.set(m[0],m[1],m[2]):e.scale.set(1,1,1);for(d=0;d<this.bones.length;d++)j=this.geometry.bones[d],
  126. e=this.bones[d],j.parent===-1?this.addChild(e):this.bones[j.parent].addChild(e);this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
  127. THREE.SkinnedMesh.prototype.update=function(b,c,d){if(this.visible){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;var e,j=this.children.length;for(e=0;e<j;e++)b=this.children[e],b instanceof THREE.Bone?b.update(this.identityMatrix,!1,d):b.update(this.matrixWorld,c,d);d=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(c=0;c<d;c++)ba[c].skinMatrix.flattenToArrayOffset(bm,
  128. c*16)}};THREE.SkinnedMesh.prototype.addBone=function(b){b===void 0&&(b=new THREE.Bone(this));this.bones.push(b);return b};
  129. THREE.SkinnedMesh.prototype.pose=function(){this.update(void 0,!0);for(var b,c=[],d=0;d<this.bones.length;d++)b=this.bones[d],c.push(THREE.Matrix4.makeInvert(b.skinMatrix)),b.skinMatrix.flattenToArrayOffset(this.boneMatrices,d*16);if(this.geometry.skinVerticesA===void 0){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var e;for(b=0;b<this.geometry.skinIndices.length;b++){var d=this.geometry.vertices[b].position,j=this.geometry.skinIndices[b].x,h=this.geometry.skinIndices[b].y;e=new THREE.Vector3(d.x,
  130. d.y,d.z);this.geometry.skinVerticesA.push(c[j].multiplyVector3(e));e=new THREE.Vector3(d.x,d.y,d.z);this.geometry.skinVerticesB.push(c[h].multiplyVector3(e));this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y!==1&&(d=(1-(this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y))*0.5,this.geometry.skinWeights[b].x+=d,this.geometry.skinWeights[b].y+=d)}}};THREE.Ribbon=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c]};
  131. THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.addLevel=function(b,c){c===void 0&&(c=0);for(var c=Math.abs(c),d=0;d<this.LODs.length;d++)if(c<this.LODs[d].visibleAtDistance)break;this.LODs.splice(d,0,{visibleAtDistance:c,object3D:b});this.add(b)};
  132. THREE.LOD.prototype.update=function(b,c,d){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;if(this.LODs.length>1){b=d.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var e=1;e<this.LODs.length;e++)if(b>=this.LODs[e].visibleAtDistance)this.LODs[e-1].object3D.visible=!1,
  133. this.LODs[e].object3D.visible=!0;else break;for(;e<this.LODs.length;e++)this.LODs[e].object3D.visible=!1}for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,c,d)};
  134. THREE.Sprite=function(b){THREE.Object3D.call(this);if(b.material!==void 0)this.material=b.material,this.map=void 0,this.blending=material.blending;else if(b.map!==void 0)this.map=b.map instanceof THREE.Texture?b.map:THREE.ImageUtils.loadTexture(b.map),this.material=void 0,this.blending=b.blending!==void 0?b.blending:THREE.NormalBlending;this.useScreenCoordinates=b.useScreenCoordinates!==void 0?b.useScreenCoordinates:!0;this.mergeWith3D=b.mergeWith3D!==void 0?b.mergeWith3D:!this.useScreenCoordinates;
  135. this.affectedByDistance=b.affectedByDistance!==void 0?b.affectedByDistance:!this.useScreenCoordinates;this.scaleByViewport=b.scaleByViewport!==void 0?b.scaleByViewport:!this.affectedByDistance;this.alignment=b.alignment instanceof THREE.Vector2?b.alignment:THREE.SpriteAlignment.center;this.rotation3d=this.rotation;this.rotation=0;this.opacity=1;this.uvOffset=new THREE.Vector2(0,0);this.uvScale=new THREE.Vector2(1,1)};THREE.Sprite.prototype=new THREE.Object3D;THREE.Sprite.prototype.constructor=THREE.Sprite;
  136. THREE.Sprite.prototype.supr=THREE.Object3D.prototype;THREE.Sprite.prototype.updateMatrix=function(){this.matrix.setPosition(this.position);this.rotation3d.set(0,0,this.rotation);this.matrix.setRotationFromEuler(this.rotation3d);if(this.scale.x!==1||this.scale.y!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,this.scale.y);this.matrixWorldNeedsUpdate=!0};THREE.SpriteAlignment={};THREE.SpriteAlignment.topLeft=new THREE.Vector2(1,-1);
  137. THREE.SpriteAlignment.topCenter=new THREE.Vector2(0,-1);THREE.SpriteAlignment.topRight=new THREE.Vector2(-1,-1);THREE.SpriteAlignment.centerLeft=new THREE.Vector2(1,0);THREE.SpriteAlignment.center=new THREE.Vector2(0,0);THREE.SpriteAlignment.centerRight=new THREE.Vector2(-1,0);THREE.SpriteAlignment.bottomLeft=new THREE.Vector2(1,1);THREE.SpriteAlignment.bottomCenter=new THREE.Vector2(0,1);THREE.SpriteAlignment.bottomRight=new THREE.Vector2(-1,1);
  138. THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.collisions=this.overrideMaterial=this.fog=null;this.objects=[];this.lights=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.add=function(b){this.supr.add.call(this,b);this.addChildRecurse(b)};
  139. THREE.Scene.prototype.addChildRecurse=function(b){if(b instanceof THREE.Light)this.lights.indexOf(b)===-1&&this.lights.push(b);else if(!(b instanceof THREE.Camera||b instanceof THREE.Bone)&&this.objects.indexOf(b)===-1)this.objects.push(b),this.__objectsAdded.push(b);for(var c=0;c<b.children.length;c++)this.addChildRecurse(b.children[c])};THREE.Scene.prototype.remove=function(b){this.supr.remove.call(this,b);this.removeChildRecurse(b)};
  140. THREE.Scene.prototype.removeChildRecurse=function(b){if(b instanceof THREE.Light){var c=this.lights.indexOf(b);c!==-1&&this.lights.splice(c,1)}else b instanceof THREE.Camera||(c=this.objects.indexOf(b),c!==-1&&(this.objects.splice(c,1),this.__objectsRemoved.push(b)));for(c=0;c<b.children.length;c++)this.removeChildRecurse(b.children[c])};THREE.Scene.prototype.addChild=function(b){console.warn("DEPRECATED: Scene.addChild() is now Scene.add()");this.add(b)};
  141. THREE.Scene.prototype.addObject=function(b){console.warn("DEPRECATED: Scene.addObject() is now Scene.add()");this.add(b)};THREE.Scene.prototype.addLight=function(b){console.warn("DEPRECATED: Scene.addLight() is now Scene.add()");this.add(b)};THREE.Scene.prototype.removeChild=function(b){console.warn("DEPRECATED: Scene.removeChild() is now Scene.remove()");this.remove(b)};THREE.Scene.prototype.removeObject=function(b){console.warn("DEPRECATED: Scene.removeObject() is now Scene.remove()");this.remove(b)};
  142. THREE.Scene.prototype.removeLight=function(b){console.warn("DEPRECATED: Scene.removeLight() is now Scene.remove()");this.remove(b)};THREE.Fog=function(b,c,d){this.color=new THREE.Color(b);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(b,c){this.color=new THREE.Color(b);this.density=c!==void 0?c:2.5E-4};
  143. THREE.ShaderChunk={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, gl_FragColor.w ), fogFactor );\n#endif",
  144. envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",
  145. 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 ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
  146. map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform vec4 offsetRepeat;\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",
  147. lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\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 ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
  148. 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 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nfloat pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;\n#ifdef PHONG\nvPointLight[ i ] = vec4( lVector, lDistance );\n#endif\n}\n#endif\n}",
  149. lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( vec3( 0.0 ), 1.0 );\nvec4 pointSpecular = vec4( vec3( 0.0 ), 1.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );\nfloat pointDistance = vPointLight[ i ].w;\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 * pointDistance;\npointSpecular += mSpecular * pointSpecularWeight * pointDistance;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( vec3( 0.0 ), 1.0 );\nvec4 dirSpecular = vec4( vec3( 0.0 ), 1.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 + viewPosition );\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\ngl_FragColor = gl_FragColor * totalLight;",
  150. color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#endif",
  151. morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInfluences[ 8 ];\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0, 0.0, 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif",
  152. default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\nuniform sampler2D shadowMap[ MAX_SHADOWS ];\nuniform float shadowDarkness;\nuniform float shadowBias;\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nfloat unpackDepth( const in vec4 rgba_depth ) {\nconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\nfloat depth = dot( rgba_depth, bit_shift );\nreturn depth;\n}\n#endif",
  153. shadowmap_fragment:"#ifdef USE_SHADOWMAP\n#ifdef SHADOWMAP_SOFT\nconst float xPixelOffset = 1.0 / SHADOWMAP_WIDTH;\nconst float yPixelOffset = 1.0 / SHADOWMAP_HEIGHT;\n#endif\nvec4 shadowColor = vec4( 1.0 );\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nif ( shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 ) {\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nfor ( float y = -1.25; y <= 1.25; y += 1.25 )\nfor ( float x = -1.25; x <= 1.25; x += 1.25 ) {\nvec4 rgbaDepth = texture2D( shadowMap[ i ], vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < ( shadowCoord.z + shadowBias ) )\nshadow += 1.0;\n}\nshadow /= 9.0;\nshadowColor = shadowColor * vec4( vec3( ( 1.0 - shadowDarkness * shadow ) ), 1.0 );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < ( shadowCoord.z + shadowBias ) )\nshadowColor = shadowColor * vec4( vec3( shadowDarkness ), 1.0 );\n#endif\n}\n}\ngl_FragColor = gl_FragColor * shadowColor;\n#endif",
  154. shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif"};
  155. THREE.UniformsUtils={merge:function(b){var c,d,e,j={};for(c=0;c<b.length;c++)for(d in e=this.clone(b[c]),e)j[d]=e[d];return j},clone:function(b){var c,d,e,j={};for(c in b)for(d in j[c]={},b[c])e=b[c][d],j[c][d]=e instanceof THREE.Color||e instanceof THREE.Vector2||e instanceof THREE.Vector3||e instanceof THREE.Vector4||e instanceof THREE.Matrix4||e instanceof THREE.Texture?e.clone():e instanceof Array?e.slice():e;return j}};
  156. THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},offsetRepeat:{type:"v4",value:new THREE.Vector4(0,0,1,1)},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},morphTargetInfluences:{type:"f",value:0}},fog:{fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",
  157. value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightDistance:{type:"fv1",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",
  158. value:1},map:{type:"t",value:0,texture:null},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)}},shadowmap:{shadowMap:{type:"tv",value:3,texture:[]},shadowMatrix:{type:"m4v",value:[]},shadowBias:{type:"f",value:0.0039},shadowDarkness:{type:"f",value:0.2}}};
  159. THREE.ShaderLib={lensFlareVertexTexture:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nuniform sampler2D occlusionMap;\nattribute vec2 position;\nattribute vec2 UV;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nvUV = UV;\nvec2 pos = position;\nif( renderType == 2 ) {\nvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.5 ) );\nvVisibility = ( visibility.r / 9.0 ) *\n( 1.0 - visibility.g / 9.0 ) *\n( visibility.b / 9.0 ) *\n( 1.0 - visibility.a / 9.0 );\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D map;\nuniform float opacity;\nuniform int renderType;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nvec4 color = texture2D( map, vUV );\ncolor.a *= opacity * vVisibility;\ngl_FragColor = color;\n}\n}"},
  160. lensFlare:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nattribute vec2 position;\nattribute vec2 UV;\nvarying vec2 vUV;\nvoid main() {\nvUV = UV;\nvec2 pos = position;\nif( renderType == 2 ) {\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D map;\nuniform sampler2D occlusionMap;\nuniform float opacity;\nuniform int renderType;\nvarying vec2 vUV;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( texture2D( map, vUV ).rgb, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nfloat visibility = texture2D( occlusionMap, vec2( 0.5, 0.1 ) ).a +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 ) ).a +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 ) ).a +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 ) ).a;\nvisibility = ( 1.0 - visibility / 4.0 );\nvec4 color = texture2D( map, vUV );\ncolor.a *= opacity * visibility;\ngl_FragColor = color;\n}\n}"},
  161. sprite:{vertexShader:"uniform int useScreenCoordinates;\nuniform int affectedByDistance;\nuniform vec3 screenPosition;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 alignment;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position + alignment;\nvec2 rotatedPosition;\nrotatedPosition.x = ( cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y ) * scale.x;\nrotatedPosition.y = ( sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y ) * scale.y;\nvec4 finalPosition;\nif( useScreenCoordinates != 0 ) {\nfinalPosition = vec4( screenPosition.xy + rotatedPosition, screenPosition.z, 1.0 );\n} else {\nfinalPosition = projectionMatrix * modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition * ( affectedByDistance == 1 ? 1.0 : finalPosition.z );\n}\ngl_Position = finalPosition;\n}",
  162. fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D map;\nuniform float opacity;\nvarying vec2 vUV;\nvoid main() {\nvec4 color = texture2D( map, vUV );\ncolor.a *= opacity;\ngl_FragColor = color;\n}"},shadowPost:{vertexShader:"uniform \tmat4 \tprojectionMatrix;\nattribute \tvec3 \tposition;\nvoid main() {\ngl_Position = projectionMatrix * vec4( position, 1.0 );\n}",fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform \tfloat \tdarkness;\nvoid main() {\ngl_FragColor = vec4( 0, 0, 0, darkness );\n}"},
  163. shadowVolumeDynamic:{uniforms:{directionalLightDirection:{type:"fv",value:[]}},vertexShader:"uniform \tvec3 \tdirectionalLightDirection;\nvoid main() {\nvec4 pos = objectMatrix * vec4( position, 1.0 );\nvec3 norm = mat3( objectMatrix[ 0 ].xyz, objectMatrix[ 1 ].xyz, objectMatrix[ 2 ].xyz ) * normal;\nvec4 extruded = vec4( directionalLightDirection * 5000.0 * step( 0.0, dot( directionalLightDirection, norm ) ), 0.0 );\ngl_Position = projectionMatrix * viewMatrix * ( pos + extruded );\n}",
  164. fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0 );\n}"},depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},fragmentShader:"uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}",vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},
  165. normal:{uniforms:{opacity:{type:"f",value:1}},fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.shadowmap]),
  166. fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,
  167. THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:[THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
  168. THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,
  169. THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,"gl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,
  170. "}"].join("\n"),vertexShader:["varying vec3 vLightWeighting;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
  171. THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(328965)},
  172. specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,
  173. "void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.lights_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,
  174. THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = -mvPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",
  175. THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.particle,THREE.UniformsLib.shadowmap]),fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,
  176. "void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;",
  177. THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},depthRGBA:{uniforms:{},fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}",vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,
  178. "void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")}};
  179. THREE.WebGLRenderer=function(b){function c(b,c,d){var e,j,h,k=b.vertices,m=k.length,H=b.colors,I=H.length,D=b.__vertexArray,p=b.__colorArray,r=b.__sortArray,n=b.__dirtyVertices,u=b.__dirtyColors,s=b.__webglCustomAttributes,w,q;if(s)for(w in s)s[w].offset=0;if(d.sortParticles){Aa.multiplySelf(d.matrixWorld);for(e=0;e<m;e++)j=k[e].position,Ia.copy(j),Aa.multiplyVector3(Ia),r[e]=[Ia.z,e];r.sort(function(b,c){return c[0]-b[0]});for(e=0;e<m;e++)j=k[r[e][1]].position,h=e*3,D[h]=j.x,D[h+1]=j.y,D[h+2]=j.z;
  180. for(e=0;e<I;e++)h=e*3,color=H[r[e][1]],p[h]=color.r,p[h+1]=color.g,p[h+2]=color.b;if(s)for(w in s){e=s[w];H=e.value.length;for(h=0;h<H;h++){index=r[h][1];I=e.offset;if(e.size===1){if(e.boundTo===void 0||e.boundTo==="vertices")e.array[I]=e.value[index]}else{if(e.boundTo===void 0||e.boundTo==="vertices")q=e.value[index];e.size===2?(e.array[I]=q.x,e.array[I+1]=q.y):e.size===3?e.type==="c"?(e.array[I]=q.r,e.array[I+1]=q.g,e.array[I+2]=q.b):(e.array[I]=q.x,e.array[I+1]=q.y,e.array[I+2]=q.z):(e.array[I]=
  181. q.x,e.array[I+1]=q.y,e.array[I+2]=q.z,e.array[I+3]=q.w)}e.offset+=e.size}}}else{if(n)for(e=0;e<m;e++)j=k[e].position,h=e*3,D[h]=j.x,D[h+1]=j.y,D[h+2]=j.z;if(u)for(e=0;e<I;e++)color=H[e],h=e*3,p[h]=color.r,p[h+1]=color.g,p[h+2]=color.b;if(s)for(w in s)if(e=s[w],e.__original.needsUpdate){H=e.value.length;for(h=0;h<H;h++){I=e.offset;if(e.size===1){if(e.boundTo===void 0||e.boundTo==="vertices")e.array[I]=e.value[h]}else{if(e.boundTo===void 0||e.boundTo==="vertices")q=e.value[h];e.size===2?(e.array[I]=
  182. q.x,e.array[I+1]=q.y):e.size===3?e.type==="c"?(e.array[I]=q.r,e.array[I+1]=q.g,e.array[I+2]=q.b):(e.array[I]=q.x,e.array[I+1]=q.y,e.array[I+2]=q.z):(e.array[I]=q.x,e.array[I+1]=q.y,e.array[I+2]=q.z,e.array[I+3]=q.w)}e.offset+=e.size}}}if(n||d.sortParticles)f.bindBuffer(f.ARRAY_BUFFER,b.__webglVertexBuffer),f.bufferData(f.ARRAY_BUFFER,D,c);if(u||d.sortParticles)f.bindBuffer(f.ARRAY_BUFFER,b.__webglColorBuffer),f.bufferData(f.ARRAY_BUFFER,p,c);if(s)for(w in s)if(e=s[w],e.__original.needsUpdate||d.sortParticles)f.bindBuffer(f.ARRAY_BUFFER,
  183. e.buffer),f.bufferData(f.ARRAY_BUFFER,e.array,c)}function d(b,c,d,e,j){e.program||M.initMaterial(e,c,d,j);if(e.morphTargets&&!j.__webglMorphTargetInfluences){j.__webglMorphTargetInfluences=new Float32Array(M.maxMorphTargets);for(var h=0,k=M.maxMorphTargets;h<k;h++)j.__webglMorphTargetInfluences[h]=0}var h=e.program,k=h.uniforms,m=e.uniforms;h!=Va&&(f.useProgram(h),Va=h);f.uniformMatrix4fv(k.projectionMatrix,!1,Ca);if(d&&(e instanceof THREE.MeshBasicMaterial||e instanceof THREE.MeshLambertMaterial||
  184. e instanceof THREE.MeshPhongMaterial||e instanceof THREE.LineBasicMaterial||e instanceof THREE.ParticleBasicMaterial||e.fog))if(m.fogColor.value=d.color,d instanceof THREE.Fog)m.fogNear.value=d.near,m.fogFar.value=d.far;else if(d instanceof THREE.FogExp2)m.fogDensity.value=d.density;if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e.lights){var H,p,D,r=0,n=0,u=0,q,s,v,B=Wa,G=B.directional.colors,K=B.directional.positions,y=B.point.colors,A=B.point.positions,C=B.point.distances,
  185. E=0,F=0,d=p=v=0;for(H=c.length;d<H;d++)if(p=c[d],D=p.color,q=p.position,s=p.intensity,v=p.distance,p instanceof THREE.AmbientLight)r+=D.r,n+=D.g,u+=D.b;else if(p instanceof THREE.DirectionalLight)v=E*3,G[v]=D.r*s,G[v+1]=D.g*s,G[v+2]=D.b*s,K[v]=q.x,K[v+1]=q.y,K[v+2]=q.z,E+=1;else if(p instanceof THREE.SpotLight)v=E*3,G[v]=D.r*s,G[v+1]=D.g*s,G[v+2]=D.b*s,D=1/q.length(),K[v]=q.x*D,K[v+1]=q.y*D,K[v+2]=q.z*D,E+=1;else if(p instanceof THREE.PointLight)p=F*3,y[p]=D.r*s,y[p+1]=D.g*s,y[p+2]=D.b*s,A[p]=q.x,
  186. A[p+1]=q.y,A[p+2]=q.z,C[F]=v,F+=1;for(d=E*3;d<G.length;d++)G[d]=0;for(d=F*3;d<y.length;d++)y[d]=0;B.point.length=F;B.directional.length=E;B.ambient[0]=r;B.ambient[1]=n;B.ambient[2]=u;c=Wa;m.enableLighting.value=c.directional.length+c.point.length;m.ambientLightColor.value=c.ambient;m.directionalLightColor.value=c.directional.colors;m.directionalLightDirection.value=c.directional.positions;m.pointLightColor.value=c.point.colors;m.pointLightPosition.value=c.point.positions;m.pointLightDistance.value=
  187. c.point.distances}if(e instanceof THREE.MeshBasicMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshPhongMaterial)m.diffuse.value=e.color,m.opacity.value=e.opacity,(m.map.texture=e.map)&&m.offsetRepeat.value.set(e.map.offset.x,e.map.offset.y,e.map.repeat.x,e.map.repeat.y),m.lightMap.texture=e.lightMap,m.envMap.texture=e.envMap,m.reflectivity.value=e.reflectivity,m.refractionRatio.value=e.refractionRatio,m.combine.value=e.combine,m.useRefract.value=e.envMap&&e.envMap.mapping instanceof
  188. THREE.CubeRefractionMapping;if(e instanceof THREE.LineBasicMaterial)m.diffuse.value=e.color,m.opacity.value=e.opacity;else if(e instanceof THREE.ParticleBasicMaterial)m.psColor.value=e.color,m.opacity.value=e.opacity,m.size.value=e.size,m.scale.value=Ja.height/2,m.map.texture=e.map;else if(e instanceof THREE.MeshPhongMaterial)m.ambient.value=e.ambient,m.specular.value=e.specular,m.shininess.value=e.shininess;else if(e instanceof THREE.MeshDepthMaterial)m.mNear.value=b.near,m.mFar.value=b.far,m.opacity.value=
  189. e.opacity;else if(e instanceof THREE.MeshNormalMaterial)m.opacity.value=e.opacity;if(j.receiveShadow&&!e._shadowPass&&m.shadowMatrix){for(c=0;c<Sa.length;c++)m.shadowMatrix.value[c]=Sa[c],m.shadowMap.texture[c]=M.shadowMap[c];m.shadowDarkness.value=M.shadowMapDarkness;m.shadowBias.value=M.shadowMapBias}for(var N in m)if(H=h.uniforms[N])if(d=m[N],r=d.type,c=d.value,r=="i")f.uniform1i(H,c);else if(r=="f")f.uniform1f(H,c);else if(r=="v2")f.uniform2f(H,c.x,c.y);else if(r=="v3")f.uniform3f(H,c.x,c.y,c.z);
  190. else if(r=="v4")f.uniform4f(H,c.x,c.y,c.z,c.w);else if(r=="c")f.uniform3f(H,c.r,c.g,c.b);else if(r=="fv1")f.uniform1fv(H,c);else if(r=="fv")f.uniform3fv(H,c);else if(r=="v3v"){if(!d._array)d._array=new Float32Array(3*c.length);r=0;for(n=c.length;r<n;r++)u=r*3,d._array[u]=c[r].x,d._array[u+1]=c[r].y,d._array[u+2]=c[r].z;f.uniform3fv(H,d._array)}else if(r=="m4"){if(!d._array)d._array=new Float32Array(16);c.flattenToArray(d._array);f.uniformMatrix4fv(H,!1,d._array)}else if(r=="m4v"){if(!d._array)d._array=
  191. new Float32Array(16*c.length);r=0;for(n=c.length;r<n;r++)c[r].flattenToArrayOffset(d._array,r*16);f.uniformMatrix4fv(H,!1,d._array)}else if(r=="t"){if(f.uniform1i(H,c),H=d.texture)if(H.image instanceof Array&&H.image.length==6){if(d=H,d.image.length==6)if(d.needsUpdate){if(!d.image.__webglTextureCube)d.image.__webglTextureCube=f.createTexture();f.activeTexture(f.TEXTURE0+c);f.bindTexture(f.TEXTURE_CUBE_MAP,d.image.__webglTextureCube);for(c=0;c<6;c++)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,
  192. f.RGBA,f.RGBA,f.UNSIGNED_BYTE,d.image[c]);w(f.TEXTURE_CUBE_MAP,d,d.image[0]);d.needsUpdate=!1}else f.activeTexture(f.TEXTURE0+c),f.bindTexture(f.TEXTURE_CUBE_MAP,d.image.__webglTextureCube)}else H instanceof THREE.WebGLRenderTargetCube?(d=H,f.activeTexture(f.TEXTURE0+c),f.bindTexture(f.TEXTURE_CUBE_MAP,d.__webglTexture)):ia(H,c)}else if(r=="tv"){if(!d._array){d._array=[];r=0;for(n=d.texture.length;r<n;r++)d._array[r]=c+r}f.uniform1iv(H,d._array);r=0;for(n=d.texture.length;r<n;r++)(H=d.texture[r])&&
  193. ia(H,d._array[r])}f.uniformMatrix4fv(k.modelViewMatrix,!1,j._modelViewMatrixArray);k.normalMatrix&&f.uniformMatrix3fv(k.normalMatrix,!1,j._normalMatrixArray);(e instanceof THREE.MeshShaderMaterial||e instanceof THREE.MeshPhongMaterial||e.envMap)&&k.cameraPosition!==null&&f.uniform3f(k.cameraPosition,b.position.x,b.position.y,b.position.z);(e instanceof THREE.MeshShaderMaterial||e.envMap||e.skinning||j.receiveShadow)&&k.objectMatrix!==null&&f.uniformMatrix4fv(k.objectMatrix,!1,j._objectMatrixArray);
  194. (e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshShaderMaterial||e.skinning)&&k.viewMatrix!==null&&f.uniformMatrix4fv(k.viewMatrix,!1,Ta);e.skinning&&(f.uniformMatrix4fv(k.cameraInverseMatrix,!1,Ta),f.uniformMatrix4fv(k.boneGlobalMatrices,!1,j.boneMatrices));return h}function e(b,c,e,j,h,k){if(j.opacity!=0){var m,b=d(b,c,e,j,k).attributes;if(!j.morphTargets&&b.position>=0)f.bindBuffer(f.ARRAY_BUFFER,h.__webglVertexBuffer),f.vertexAttribPointer(b.position,
  195. 3,f.FLOAT,!1,0,0);else if(k.morphTargetBase){c=j.program.attributes;k.morphTargetBase!==-1?(f.bindBuffer(f.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[k.morphTargetBase]),f.vertexAttribPointer(c.position,3,f.FLOAT,!1,0,0)):c.position>=0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglVertexBuffer),f.vertexAttribPointer(c.position,3,f.FLOAT,!1,0,0));if(k.morphTargetForcedOrder.length)for(var e=0,p=k.morphTargetForcedOrder,H=k.morphTargetInfluences;e<j.numSupportedMorphTargets&&e<p.length;)f.bindBuffer(f.ARRAY_BUFFER,
  196. h.__webglMorphTargetsBuffers[p[e]]),f.vertexAttribPointer(c["morphTarget"+e],3,f.FLOAT,!1,0,0),k.__webglMorphTargetInfluences[e]=H[p[e]],e++;else{var p=[],r=-1,D=0,H=k.morphTargetInfluences,n,q=H.length,e=0;for(k.morphTargetBase!==-1&&(p[k.morphTargetBase]=!0);e<j.numSupportedMorphTargets;){for(n=0;n<q;n++)!p[n]&&H[n]>r&&(D=n,r=H[D]);f.bindBuffer(f.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[D]);f.vertexAttribPointer(c["morphTarget"+e],3,f.FLOAT,!1,0,0);k.__webglMorphTargetInfluences[e]=r;p[D]=1;r=
  197. -1;e++}}j.program.uniforms.morphTargetInfluences!==null&&f.uniform1fv(j.program.uniforms.morphTargetInfluences,k.__webglMorphTargetInfluences)}if(h.__webglCustomAttributes)for(m in h.__webglCustomAttributes)b[m]>=0&&(c=h.__webglCustomAttributes[m],f.bindBuffer(f.ARRAY_BUFFER,c.buffer),f.vertexAttribPointer(b[m],c.size,f.FLOAT,!1,0,0));b.color>=0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglColorBuffer),f.vertexAttribPointer(b.color,3,f.FLOAT,!1,0,0));b.normal>=0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglNormalBuffer),
  198. f.vertexAttribPointer(b.normal,3,f.FLOAT,!1,0,0));b.tangent>=0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglTangentBuffer),f.vertexAttribPointer(b.tangent,4,f.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(f.bindBuffer(f.ARRAY_BUFFER,h.__webglUVBuffer),f.vertexAttribPointer(b.uv,2,f.FLOAT,!1,0,0),f.enableVertexAttribArray(b.uv)):f.disableVertexAttribArray(b.uv));b.uv2>=0&&(h.__webglUV2Buffer?(f.bindBuffer(f.ARRAY_BUFFER,h.__webglUV2Buffer),f.vertexAttribPointer(b.uv2,2,f.FLOAT,!1,0,0),f.enableVertexAttribArray(b.uv2)):
  199. f.disableVertexAttribArray(b.uv2));j.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglSkinVertexABuffer),f.vertexAttribPointer(b.skinVertexA,4,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),f.vertexAttribPointer(b.skinVertexB,4,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),f.vertexAttribPointer(b.skinIndex,4,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),
  200. f.vertexAttribPointer(b.skinWeight,4,f.FLOAT,!1,0,0));k instanceof THREE.Mesh?(j.wireframe?(f.lineWidth(j.wireframeLinewidth),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),f.drawElements(f.LINES,h.__webglLineCount,f.UNSIGNED_SHORT,0)):(f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),f.drawElements(f.TRIANGLES,h.__webglFaceCount,f.UNSIGNED_SHORT,0)),M.data.vertices+=h.__webglFaceCount,M.data.faces+=h.__webglFaceCount/3,M.data.drawCalls++):k instanceof THREE.Line?(k=k.type==THREE.LineStrip?
  201. f.LINE_STRIP:f.LINES,f.lineWidth(j.linewidth),f.drawArrays(k,0,h.__webglLineCount),M.data.drawCalls++):k instanceof THREE.ParticleSystem?(f.drawArrays(f.POINTS,0,h.__webglParticleCount),M.data.drawCalls++):k instanceof THREE.Ribbon&&(f.drawArrays(f.TRIANGLE_STRIP,0,h.__webglVertexCount),M.data.drawCalls++)}}function j(b,c,d){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=f.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=f.createBuffer();b.hasPos&&(f.bindBuffer(f.ARRAY_BUFFER,b.__webglVertexBuffer),
  202. f.bufferData(f.ARRAY_BUFFER,b.positionArray,f.DYNAMIC_DRAW),f.enableVertexAttribArray(c.attributes.position),f.vertexAttribPointer(c.attributes.position,3,f.FLOAT,!1,0,0));if(b.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,b.__webglNormalBuffer);if(d==THREE.FlatShading){var e,h,j,k,m,H,p,r,n,q,u=b.count*3;for(q=0;q<u;q+=9)d=b.normalArray,e=d[q],h=d[q+1],j=d[q+2],k=d[q+3],H=d[q+4],r=d[q+5],m=d[q+6],p=d[q+7],n=d[q+8],e=(e+k+m)/3,h=(h+H+p)/3,j=(j+r+n)/3,d[q]=e,d[q+1]=h,d[q+2]=j,d[q+3]=e,d[q+4]=h,d[q+5]=j,d[q+
  203. 6]=e,d[q+7]=h,d[q+8]=j}f.bufferData(f.ARRAY_BUFFER,b.normalArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(c.attributes.normal);f.vertexAttribPointer(c.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,b.count);b.count=0}function h(b){if(T!=b.doubleSided)b.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE),T=b.doubleSided;if(Z!=b.flipSided)b.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW),Z=b.flipSided}function k(b){W!=b&&(b?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST),W=b)}function m(b){S!=
  204. b&&(f.depthMask(b),S=b)}function r(b,c,d){V!=b&&(b?f.enable(f.POLYGON_OFFSET_FILL):f.disable(f.POLYGON_OFFSET_FILL),V=b);if(b&&(wa!=c||P!=d))f.polygonOffset(c,d),wa=c,P=d}function p(b){R[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-b.n14);R[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);R[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);R[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);R[4].set(b.n41-b.n31,b.n42-b.n32,b.n43-b.n33,b.n44-b.n34);R[5].set(b.n41+b.n31,b.n42+
  205. b.n32,b.n43+b.n33,b.n44+b.n34);for(var c,b=0;b<6;b++)c=R[b],c.divideScalar(Math.sqrt(c.x*c.x+c.y*c.y+c.z*c.z))}function u(b){for(var c=b.matrixWorld,f=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),d=0;d<6;d++)if(b=R[d].x*c.n14+R[d].y*c.n24+R[d].z*c.n34+R[d].w,b<=f)return!1;return!0}function n(b,c){b.list[b.count]=c;b.count+=1}function s(b){var c,d,f=b.object,e=b.opaque,h=b.transparent;h.count=0;b=e.count=0;for(c=f.materials.length;b<c;b++)d=f.materials[b],d.transparent?
  206. n(h,d):n(e,d)}function v(b){var c,d,f,e,h=b.object,j=b.buffer,k=b.opaque,m=b.transparent;m.count=0;b=k.count=0;for(f=h.materials.length;b<f;b++)if(c=h.materials[b],c instanceof THREE.MeshFaceMaterial){c=0;for(d=j.materials.length;c<d;c++)(e=j.materials[c])&&(e.transparent?n(m,e):n(k,e))}else(e=c)&&(e.transparent?n(m,e):n(k,e))}function B(b,c){return c.z-b.z}function y(b,c){var m,r,Ma,q=0,n,s,H,I,D=b.lights;qa||(qa=new THREE.Camera(M.shadowCameraFov,c.aspect,M.shadowCameraNear,M.shadowCameraFar));
  207. m=0;for(r=D.length;m<r;m++)if(Ma=D[m],Ma instanceof THREE.SpotLight&&Ma.castShadow){M.shadowMap[q]||(M.shadowMap[q]=new THREE.WebGLRenderTarget(M.shadowMapWidth,M.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}));Sa[q]||(Sa[q]=new THREE.Matrix4);n=M.shadowMap[q];s=Sa[q];qa.position.copy(Ma.position);qa.target.position.copy(Ma.target.position);qa.update(void 0,!0);b.update(void 0,!1,qa);s.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);s.multiplySelf(qa.projectionMatrix);
  208. s.multiplySelf(qa.matrixWorldInverse);qa.matrixWorldInverse.flattenToArray(Ta);qa.projectionMatrix.flattenToArray(Ca);Aa.multiply(qa.projectionMatrix,qa.matrixWorldInverse);p(Aa);M.initWebGLObjects(b);L(n);f.clearColor(1,1,1,1);M.clear();f.clearColor(ga.r,ga.g,ga.b,Ka);s=b.__webglObjects.length;Ma=b.__webglObjectsImmediate.length;for(n=0;n<s;n++)H=b.__webglObjects[n],I=H.object,I.visible&&I.castShadow?!(I instanceof THREE.Mesh)||!I.frustumCulled||u(I)?(I.matrixWorld.flattenToArray(I._objectMatrixArray),
  209. C(I,qa,!1),H.render=!0):H.render=!1:H.render=!1;k(!0);F(THREE.NormalBlending);for(n=0;n<s;n++)if(H=b.__webglObjects[n],H.render)I=H.object,buffer=H.buffer,h(I),H=I.customDepthMaterial?I.customDepthMaterial:I.geometry.morphTargets.length?Xa:Ua,e(qa,D,null,H,buffer,I);for(n=0;n<Ma;n++)H=b.__webglObjectsImmediate[n],I=H.object,I.visible&&I.castShadow&&(I.matrixAutoUpdate&&I.matrixWorld.flattenToArray(I._objectMatrixArray),C(I,qa,!1),h(I),program=d(qa,D,null,Ua,I),I.render(function(b){j(b,program,Ua.shading)}));
  210. q++}}function E(b,c){var d,e,h;d=q.attributes;var j=q.uniforms,k=Ea/za,m,p=[],r=za*0.5,n=Ea*0.5,s=!0;f.useProgram(q.program);Va=q.program;W=J=-1;Ya||(f.enableVertexAttribArray(q.attributes.position),f.enableVertexAttribArray(q.attributes.uv),Ya=!0);f.disable(f.CULL_FACE);f.enable(f.BLEND);f.depthMask(!0);f.bindBuffer(f.ARRAY_BUFFER,q.vertexBuffer);f.vertexAttribPointer(d.position,2,f.FLOAT,!1,16,0);f.vertexAttribPointer(d.uv,2,f.FLOAT,!1,16,8);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,q.elementBuffer);
  211. f.uniformMatrix4fv(j.projectionMatrix,!1,Ca);f.activeTexture(f.TEXTURE0);f.uniform1i(j.map,0);d=0;for(e=b.__webglSprites.length;d<e;d++)h=b.__webglSprites[d],h.useScreenCoordinates?h.z=-h.position.z:(h._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,h.matrixWorld,h._modelViewMatrixArray),h.z=-h._modelViewMatrix.n34);b.__webglSprites.sort(B);d=0;for(e=b.__webglSprites.length;d<e;d++)h=b.__webglSprites[d],h.material===void 0&&h.map&&h.map.image&&h.map.image.width&&(h.useScreenCoordinates?(f.uniform1i(j.useScreenCoordinates,
  212. 1),f.uniform3f(j.screenPosition,(h.position.x-r)/r,(n-h.position.y)/n,Math.max(0,Math.min(1,h.position.z)))):(f.uniform1i(j.useScreenCoordinates,0),f.uniform1i(j.affectedByDistance,h.affectedByDistance?1:0),f.uniformMatrix4fv(j.modelViewMatrix,!1,h._modelViewMatrixArray)),m=h.map.image.width/(h.scaleByViewport?Ea:1),p[0]=m*k*h.scale.x,p[1]=m*h.scale.y,f.uniform2f(j.uvScale,h.uvScale.x,h.uvScale.y),f.uniform2f(j.uvOffset,h.uvOffset.x,h.uvOffset.y),f.uniform2f(j.alignment,h.alignment.x,h.alignment.y),
  213. f.uniform1f(j.opacity,h.opacity),f.uniform1f(j.rotation,h.rotation),f.uniform2fv(j.scale,p),h.mergeWith3D&&!s?(f.enable(f.DEPTH_TEST),s=!0):!h.mergeWith3D&&s&&(f.disable(f.DEPTH_TEST),s=!1),F(h.blending),ia(h.map,0),f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0));f.enable(f.CULL_FACE);f.enable(f.DEPTH_TEST);f.depthMask(S)}function C(b,c,d){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);d&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}
  214. function xa(b){var c,d,f,e;e=b.__materials;b=0;for(d=e.length;b<d;b++)if(f=e[b],f.attributes)for(c in f.attributes)if(f.attributes[c].needsUpdate)return!0;return!1}function ya(b){var c,d,f,e;e=b.__materials;b=0;for(d=e.length;b<d;b++)if(f=e[b],f.attributes)for(c in f.attributes)f.attributes[c].needsUpdate=!1}function pa(b,c){var d;for(d=b.length-1;d>=0;d--)b[d].object==c&&b.splice(d,1)}function ra(b){function c(b){var e=[];d=0;for(f=b.length;d<f;d++)b[d]==void 0?e.push("undefined"):e.push(b[d].id);
  215. return e.join("_")}var d,f,e,h,j,k,m,p,r={},n=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};e=0;for(h=b.faces.length;e<h;e++)j=b.faces[e],k=j.materials,m=c(k),r[m]==void 0&&(r[m]={hash:m,counter:0}),p=r[m].hash+"_"+r[m].counter,b.geometryGroups[p]==void 0&&(b.geometryGroups[p]={faces:[],materials:k,vertices:0,numMorphTargets:n}),j=j instanceof THREE.Face3?3:4,b.geometryGroups[p].vertices+j>65535&&(r[m].counter+=1,p=r[m].hash+"_"+r[m].counter,b.geometryGroups[p]==void 0&&(b.geometryGroups[p]=
  216. {faces:[],materials:k,vertices:0,numMorphTargets:n})),b.geometryGroups[p].faces.push(e),b.geometryGroups[p].vertices+=j;b.geometryGroupsList=[];for(var q in b.geometryGroups)b.geometryGroupsList.push(b.geometryGroups[q])}function fa(b,c,d){b.push({buffer:c,object:d,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function F(b){if(b!=J){switch(b){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE);break;case THREE.SubtractiveBlending:f.blendEquation(f.FUNC_ADD);
  217. f.blendFunc(f.ZERO,f.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ZERO,f.SRC_COLOR);break;default:f.blendEquationSeparate(f.FUNC_ADD,f.FUNC_ADD),f.blendFuncSeparate(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA,f.ONE,f.ONE_MINUS_SRC_ALPHA)}J=b}}function w(b,c,d){(d.width&d.width-1)==0&&(d.height&d.height-1)==0?(f.texParameteri(b,f.TEXTURE_WRAP_S,Q(c.wrapS)),f.texParameteri(b,f.TEXTURE_WRAP_T,Q(c.wrapT)),f.texParameteri(b,f.TEXTURE_MAG_FILTER,Q(c.magFilter)),
  218. f.texParameteri(b,f.TEXTURE_MIN_FILTER,Q(c.minFilter)),f.generateMipmap(b)):(f.texParameteri(b,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE),f.texParameteri(b,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE),f.texParameteri(b,f.TEXTURE_MAG_FILTER,ua(c.magFilter)),f.texParameteri(b,f.TEXTURE_MIN_FILTER,ua(c.minFilter)))}function ia(b,c){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=f.createTexture();f.activeTexture(f.TEXTURE0+c);f.bindTexture(f.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture?
  219. f.texImage2D(f.TEXTURE_2D,0,Q(b.format),b.image.width,b.image.height,0,Q(b.format),f.UNSIGNED_BYTE,b.image.data):f.texImage2D(f.TEXTURE_2D,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,b.image);w(f.TEXTURE_2D,b,b.image);b.needsUpdate=!1}else f.activeTexture(f.TEXTURE0+c),f.bindTexture(f.TEXTURE_2D,b.__webglTexture)}function L(b){var c=b instanceof THREE.WebGLRenderTargetCube;if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglRenderbuffer=
  220. f.createRenderbuffer();b.__webglTexture=f.createTexture();if(c){f.bindTexture(f.TEXTURE_CUBE_MAP,b.__webglTexture);w(f.TEXTURE_CUBE_MAP,b,b);b.__webglFramebuffer=[];for(var d=0;d<6;d++)b.__webglFramebuffer[d]=f.createFramebuffer(),f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+d,0,Q(b.format),b.width,b.height,0,Q(b.format),Q(b.type),null)}else b.__webglFramebuffer=f.createFramebuffer(),f.bindTexture(f.TEXTURE_2D,b.__webglTexture),w(f.TEXTURE_2D,b,b),f.texImage2D(f.TEXTURE_2D,0,Q(b.format),b.width,b.height,
  221. 0,Q(b.format),Q(b.type),null);f.bindRenderbuffer(f.RENDERBUFFER,b.__webglRenderbuffer);if(c)for(d=0;d<6;++d)f.bindFramebuffer(f.FRAMEBUFFER,b.__webglFramebuffer[d]),f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_CUBE_MAP_POSITIVE_X+d,b.__webglTexture,0);else f.bindFramebuffer(f.FRAMEBUFFER,b.__webglFramebuffer),f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,
  222. b.width,b.height),f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_STENCIL,b.width,b.height),f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_STENCIL_ATTACHMENT,f.RENDERBUFFER,b.__webglRenderbuffer)):f.renderbufferStorage(f.RENDERBUFFER,f.RGBA4,b.width,b.height);c?f.bindTexture(f.TEXTURE_CUBE_MAP,null):f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);
  223. f.bindFramebuffer(f.FRAMEBUFFER,null)}var e,h;b?(c=c?b.__webglFramebuffer[b.activeCubeFace]:b.__webglFramebuffer,d=b.width,b=b.height,h=e=0):(c=null,d=za,b=Ea,e=sa,h=Ga);c!=va&&(f.bindFramebuffer(f.FRAMEBUFFER,c),f.viewport(e,h,d,b),va=c)}function ja(b){b instanceof THREE.WebGLRenderTargetCube?(f.bindTexture(f.TEXTURE_CUBE_MAP,b.__webglTexture),f.generateMipmap(f.TEXTURE_CUBE_MAP),f.bindTexture(f.TEXTURE_CUBE_MAP,null)):(f.bindTexture(f.TEXTURE_2D,b.__webglTexture),f.generateMipmap(f.TEXTURE_2D),
  224. f.bindTexture(f.TEXTURE_2D,null))}function Y(b,c){var d;b=="fragment"?d=f.createShader(f.FRAGMENT_SHADER):b=="vertex"&&(d=f.createShader(f.VERTEX_SHADER));f.shaderSource(d,c);f.compileShader(d);if(!f.getShaderParameter(d,f.COMPILE_STATUS))return console.error(f.getShaderInfoLog(d)),console.error(c),null;return d}function ua(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;default:return f.LINEAR}}function Q(b){switch(b){case THREE.RepeatWrapping:return f.REPEAT;
  225. case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT;case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return f.BYTE;
  226. case THREE.UnsignedByteType:return f.UNSIGNED_BYTE;case THREE.ShortType:return f.SHORT;case THREE.UnsignedShortType:return f.UNSIGNED_SHORT;case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0}var M=this,f,Da=[],Va=
  227. null,va=null,T=null,Z=null,J=null,W=null,S=null,V=null,wa=null,P=null,sa=0,Ga=0,za=0,Ea=0,R=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Aa=new THREE.Matrix4,Ca=new Float32Array(16),Ta=new Float32Array(16),Ia=new THREE.Vector4,Wa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},Ja=b.canvas!==void 0?b.canvas:document.createElement("canvas"),ab=b.stencil!==void 0?
  228. b.stencil:!0,bb=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,cb=b.antialias!==void 0?b.antialias:!1,ga=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),Ka=b.clearAlpha!==void 0?b.clearAlpha:0;_maxLights=b.maxLights!==void 0?b.maxLights:4;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=Ja;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=
  229. 1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var qa,Sa=[],b=THREE.ShaderLib.depthRGBA,Za=THREE.UniformsUtils.clone(b.uniforms),Ua=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Za}),Xa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Za,morphTargets:!0});Ua._shadowPass=!0;Xa._shadowPass=!0;try{if(!(f=Ja.getContext("experimental-webgl",
  230. {antialias:cb,stencil:ab,preserveDrawingBuffer:bb})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+f.getParameter(f.VERSION)+" | "+f.getParameter(f.VENDOR)+" | "+f.getParameter(f.RENDERER)+" | "+f.getParameter(f.SHADING_LANGUAGE_VERSION))}catch(db){console.error(db)}f.clearColor(0,0,0,1);f.clearDepth(1);f.clearStencil(0);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);f.enable(f.BLEND);f.blendEquation(f.FUNC_ADD);
  231. f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);f.clearColor(ga.r,ga.g,ga.b,Ka);this.context=f;var $a=f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,q={};q.vertices=new Float32Array(16);q.faces=new Uint16Array(6);i=0;q.vertices[i++]=-1;q.vertices[i++]=-1;q.vertices[i++]=0;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=-1;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=0;q.vertices[i++]=-1;q.vertices[i++]=1;q.vertices[i++]=0;i=q.vertices[i++]=
  232. 0;q.faces[i++]=0;q.faces[i++]=1;q.faces[i++]=2;q.faces[i++]=0;q.faces[i++]=2;q.faces[i++]=3;q.vertexBuffer=f.createBuffer();q.elementBuffer=f.createBuffer();f.bindBuffer(f.ARRAY_BUFFER,q.vertexBuffer);f.bufferData(f.ARRAY_BUFFER,q.vertices,f.STATIC_DRAW);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,q.elementBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,q.faces,f.STATIC_DRAW);q.program=f.createProgram();f.attachShader(q.program,Y("fragment",THREE.ShaderLib.sprite.fragmentShader));f.attachShader(q.program,Y("vertex",
  233. THREE.ShaderLib.sprite.vertexShader));f.linkProgram(q.program);q.attributes={};q.uniforms={};q.attributes.position=f.getAttribLocation(q.program,"position");q.attributes.uv=f.getAttribLocation(q.program,"uv");q.uniforms.uvOffset=f.getUniformLocation(q.program,"uvOffset");q.uniforms.uvScale=f.getUniformLocation(q.program,"uvScale");q.uniforms.rotation=f.getUniformLocation(q.program,"rotation");q.uniforms.scale=f.getUniformLocation(q.program,"scale");q.uniforms.alignment=f.getUniformLocation(q.program,
  234. "alignment");q.uniforms.map=f.getUniformLocation(q.program,"map");q.uniforms.opacity=f.getUniformLocation(q.program,"opacity");q.uniforms.useScreenCoordinates=f.getUniformLocation(q.program,"useScreenCoordinates");q.uniforms.affectedByDistance=f.getUniformLocation(q.program,"affectedByDistance");q.uniforms.screenPosition=f.getUniformLocation(q.program,"screenPosition");q.uniforms.modelViewMatrix=f.getUniformLocation(q.program,"modelViewMatrix");q.uniforms.projectionMatrix=f.getUniformLocation(q.program,
  235. "projectionMatrix");var Ya=!1;this.setSize=function(b,c){Ja.width=b;Ja.height=c;this.setViewport(0,0,Ja.width,Ja.height)};this.setViewport=function(b,c,d,e){sa=b;Ga=c;za=d;Ea=e;f.viewport(sa,Ga,za,Ea)};this.setScissor=function(b,c,d,e){f.scissor(b,c,d,e)};this.enableScissorTest=function(b){b?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.setClearColorHex=function(b,c){ga.setHex(b);Ka=c;f.clearColor(ga.r,ga.g,ga.b,Ka)};this.setClearColor=function(b,c){ga.copy(b);Ka=c;f.clearColor(ga.r,ga.g,
  236. ga.b,Ka)};this.getClearColor=function(b){b.copy(ga)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT|f.STENCIL_BUFFER_BIT)};this.getContext=function(){return f};this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix,delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var c=b.geometry.geometryGroups[g];f.deleteBuffer(c.__webglVertexBuffer);f.deleteBuffer(c.__webglNormalBuffer);
  237. f.deleteBuffer(c.__webglTangentBuffer);f.deleteBuffer(c.__webglColorBuffer);f.deleteBuffer(c.__webglUVBuffer);f.deleteBuffer(c.__webglUV2Buffer);f.deleteBuffer(c.__webglSkinVertexABuffer);f.deleteBuffer(c.__webglSkinVertexBBuffer);f.deleteBuffer(c.__webglSkinIndicesBuffer);f.deleteBuffer(c.__webglSkinWeightsBuffer);f.deleteBuffer(c.__webglFaceBuffer);f.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,e=c.numMorphTargets;d<e;d++)f.deleteBuffer(c.__webglMorphTargetsBuffers[d])}else if(b instanceof
  238. THREE.Ribbon)b=b.geometry,f.deleteBuffer(b.__webglVertexBuffer),f.deleteBuffer(b.__webglColorBuffer);else if(b instanceof THREE.Line)b=b.geometry,f.deleteBuffer(b.__webglVertexBuffer),f.deleteBuffer(b.__webglColorBuffer);else if(b instanceof THREE.ParticleSystem)b=b.geometry,f.deleteBuffer(b.__webglVertexBuffer),f.deleteBuffer(b.__webglColorBuffer)};this.deallocateTexture=function(b){if(b.__webglInit)b.__webglInit=!1,f.deleteTexture(b.__webglTexture)};this.initMaterial=function(b,c,d,e){var h,j,k;
  239. b instanceof THREE.MeshDepthMaterial?k="depth":b instanceof THREE.MeshNormalMaterial?k="normal":b instanceof THREE.MeshBasicMaterial?k="basic":b instanceof THREE.MeshLambertMaterial?k="lambert":b instanceof THREE.MeshPhongMaterial?k="phong":b instanceof THREE.LineBasicMaterial?k="basic":b instanceof THREE.ParticleBasicMaterial&&(k="particle_basic");if(k){var m=THREE.ShaderLib[k];b.uniforms=THREE.UniformsUtils.clone(m.uniforms);b.vertexShader=m.vertexShader;b.fragmentShader=m.fragmentShader}var p,
  240. r,n;p=n=m=0;for(r=c.length;p<r;p++)j=c[p],j instanceof THREE.SpotLight&&n++,j instanceof THREE.DirectionalLight&&n++,j instanceof THREE.PointLight&&m++;m+n<=_maxLights?p=n:(p=Math.ceil(_maxLights*n/(m+n)),m=_maxLights-p);j={directional:p,point:m};m=n=0;for(p=c.length;m<p;m++)r=c[m],r instanceof THREE.SpotLight&&r.castShadow&&n++;var q=50;if(e!==void 0&&e instanceof THREE.SkinnedMesh)q=e.bones.length;var s;a:{p=b.fragmentShader;r=b.vertexShader;var m=b.uniforms,c=b.attributes,d={map:!!b.map,envMap:!!b.envMap,
  241. lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:d,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:j.directional,maxPointLights:j.point,maxBones:q,shadowMapEnabled:this.shadowMapEnabled&&e.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:n,alphaTest:b.alphaTest},u,e=[];k?e.push(k):(e.push(p),e.push(r));for(u in d)e.push(u),e.push(d[u]);
  242. k=e.join();u=0;for(e=Da.length;u<e;u++)if(Da[u].code==k){s=Da[u].program;break a}u=f.createProgram();e=[$a?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+d.maxDirLights,"#define MAX_POINT_LIGHTS "+d.maxPointLights,"#define MAX_SHADOWS "+d.maxShadows,"#define MAX_BONES "+d.maxBones,d.map?"#define USE_MAP":"",d.envMap?"#define USE_ENVMAP":"",d.lightMap?"#define USE_LIGHTMAP":"",d.vertexColors?"#define USE_COLOR":"",d.skinning?"#define USE_SKINNING":"",d.morphTargets?"#define USE_MORPHTARGETS":
  243. "",d.shadowMapEnabled?"#define USE_SHADOWMAP":"",d.shadowMapSoft?"#define SHADOWMAP_SOFT":"",d.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
  244. j=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+d.maxDirLights,"#define MAX_POINT_LIGHTS "+d.maxPointLights,"#define MAX_SHADOWS "+d.maxShadows,d.alphaTest?"#define ALPHATEST "+d.alphaTest:"",d.fog?"#define USE_FOG":"",d.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",d.map?"#define USE_MAP":"",d.envMap?"#define USE_ENVMAP":"",d.lightMap?"#define USE_LIGHTMAP":"",d.vertexColors?"#define USE_COLOR":"",d.shadowMapEnabled?"#define USE_SHADOWMAP":"",d.shadowMapSoft?"#define SHADOWMAP_SOFT":
  245. "",d.shadowMapSoft?"#define SHADOWMAP_WIDTH "+d.shadowMapWidth.toFixed(1):"",d.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+d.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");f.attachShader(u,Y("fragment",j+p));f.attachShader(u,Y("vertex",e+r));f.linkProgram(u);f.getProgramParameter(u,f.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+f.getProgramParameter(u,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");u.uniforms=
  246. {};u.attributes={};var v,e=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(v in m)e.push(v);v=e;e=0;for(m=v.length;e<m;e++)p=v[e],u.uniforms[p]=f.getUniformLocation(u,p);e=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(v=0;v<d.maxMorphTargets;v++)e.push("morphTarget"+v);for(s in c)e.push(s);s=e;v=0;for(c=s.length;v<c;v++)d=
  247. s[v],u.attributes[d]=f.getAttribLocation(u,d);Da.push({program:u,code:k});s=u}b.program=s;s=b.program.attributes;s.position>=0&&f.enableVertexAttribArray(s.position);s.color>=0&&f.enableVertexAttribArray(s.color);s.normal>=0&&f.enableVertexAttribArray(s.normal);s.tangent>=0&&f.enableVertexAttribArray(s.tangent);b.skinning&&s.skinVertexA>=0&&s.skinVertexB>=0&&s.skinIndex>=0&&s.skinWeight>=0&&(f.enableVertexAttribArray(s.skinVertexA),f.enableVertexAttribArray(s.skinVertexB),f.enableVertexAttribArray(s.skinIndex),
  248. f.enableVertexAttribArray(s.skinWeight));if(b.attributes)for(h in b.attributes)s[h]!==void 0&&s[h]>=0&&f.enableVertexAttribArray(s[h]);if(b.morphTargets)for(h=b.numSupportedMorphTargets=0;h<this.maxMorphTargets;h++)v="morphTarget"+h,s[v]>=0&&(f.enableVertexAttribArray(s[v]),b.numSupportedMorphTargets++)};this.clearTarget=function(b,c,d,e){L(b);b=0;c&&(b|=f.COLOR_BUFFER_BIT);d&&(b|=f.DEPTH_BUFFER_BIT);e&&(b|=f.STENCIL_BUFFER_BIT);f.clear(b)};this.render=function(b,c,f,n){var q,w,Fa,U,H,I,D,Qa,J=b.lights,
  249. Ra=b.fog;this.shadowMapEnabled&&y(b,c);M.data.vertices=0;M.data.faces=0;M.data.drawCalls=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(Ta);c.projectionMatrix.flattenToArray(Ca);Aa.multiply(c.projectionMatrix,c.matrixWorldInverse);p(Aa);this.initWebGLObjects(b);L(f);(this.autoClear||n)&&this.clear();H=b.__webglObjects.length;for(n=0;n<H;n++)if(q=b.__webglObjects[n],D=q.object,D.visible)if(!(D instanceof THREE.Mesh)||!D.frustumCulled||u(D)){if(D.matrixWorld.flattenToArray(D._objectMatrixArray),
  250. C(D,c,!0),v(q),q.render=!0,this.sortObjects)q.object.renderDepth?q.z=q.object.renderDepth:(Ia.copy(D.position),Aa.multiplyVector3(Ia),q.z=Ia.z)}else q.render=!1;else q.render=!1;this.sortObjects&&b.__webglObjects.sort(B);I=b.__webglObjectsImmediate.length;for(n=0;n<I;n++)q=b.__webglObjectsImmediate[n],D=q.object,D.visible&&(D.matrixAutoUpdate&&D.matrixWorld.flattenToArray(D._objectMatrixArray),C(D,c,!0),s(q));if(b.overrideMaterial){k(b.overrideMaterial.depthTest);F(b.overrideMaterial.blending);for(n=
  251. 0;n<H;n++)if(q=b.__webglObjects[n],q.render)D=q.object,Qa=q.buffer,h(D),e(c,J,Ra,b.overrideMaterial,Qa,D);for(n=0;n<I;n++)q=b.__webglObjectsImmediate[n],D=q.object,D.visible&&(h(D),w=d(c,J,Ra,b.overrideMaterial,D),D.render(function(c){j(c,w,b.overrideMaterial.shading)}))}else{F(THREE.NormalBlending);for(n=H-1;n>=0;n--)if(q=b.__webglObjects[n],q.render){D=q.object;Qa=q.buffer;Fa=q.opaque;h(D);for(q=0;q<Fa.count;q++)U=Fa.list[q],k(U.depthTest),m(U.depthWrite),r(U.polygonOffset,U.polygonOffsetFactor,
  252. U.polygonOffsetUnits),e(c,J,Ra,U,Qa,D)}for(n=0;n<I;n++)if(q=b.__webglObjectsImmediate[n],D=q.object,D.visible){Fa=q.opaque;h(D);for(q=0;q<Fa.count;q++)U=Fa.list[q],k(U.depthTest),m(U.depthWrite),r(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),w=d(c,J,Ra,U,D),D.render(function(b){j(b,w,U.shading)})}for(n=0;n<H;n++)if(q=b.__webglObjects[n],q.render){D=q.object;Qa=q.buffer;Fa=q.transparent;h(D);for(q=0;q<Fa.count;q++)U=Fa.list[q],F(U.blending),k(U.depthTest),m(U.depthWrite),r(U.polygonOffset,
  253. U.polygonOffsetFactor,U.polygonOffsetUnits),e(c,J,Ra,U,Qa,D)}for(n=0;n<I;n++)if(q=b.__webglObjectsImmediate[n],D=q.object,D.visible){Fa=q.transparent;h(D);for(q=0;q<Fa.count;q++)U=Fa.list[q],F(U.blending),k(U.depthTest),m(U.depthWrite),r(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),w=d(c,J,Ra,U,D),D.render(function(b){j(b,w,U.shading)})}}b.__webglSprites.length&&E(b,c);f&&f.minFilter!==THREE.NearestFilter&&f.minFilter!==THREE.LinearFilter&&ja(f)};this.initWebGLObjects=function(b){if(!b.__webglObjects)b.__webglObjects=
  254. [],b.__webglObjectsImmediate=[],b.__webglSprites=[];for(;b.__objectsAdded.length;){var d=b.__objectsAdded[0],e=b,h=void 0,j=void 0,k=void 0;if(!d.__webglInit)if(d.__webglInit=!0,d._modelViewMatrix=new THREE.Matrix4,d._normalMatrixArray=new Float32Array(9),d._modelViewMatrixArray=new Float32Array(16),d._objectMatrixArray=new Float32Array(16),d.matrixWorld.flattenToArray(d._objectMatrixArray),d instanceof THREE.Mesh)for(h in j=d.geometry,j.geometryGroups==void 0&&ra(j),j.geometryGroups){k=j.geometryGroups[h];
  255. if(!k.__webglVertexBuffer){var m=k;m.__webglVertexBuffer=f.createBuffer();m.__webglNormalBuffer=f.createBuffer();m.__webglTangentBuffer=f.createBuffer();m.__webglColorBuffer=f.createBuffer();m.__webglUVBuffer=f.createBuffer();m.__webglUV2Buffer=f.createBuffer();m.__webglSkinVertexABuffer=f.createBuffer();m.__webglSkinVertexBBuffer=f.createBuffer();m.__webglSkinIndicesBuffer=f.createBuffer();m.__webglSkinWeightsBuffer=f.createBuffer();m.__webglFaceBuffer=f.createBuffer();m.__webglLineBuffer=f.createBuffer();
  256. if(m.numMorphTargets){var p=void 0,n=void 0;m.__webglMorphTargetsBuffers=[];p=0;for(n=m.numMorphTargets;p<n;p++)m.__webglMorphTargetsBuffers.push(f.createBuffer())}for(var m=k,p=d,q=void 0,r=void 0,s=void 0,u=s=void 0,v=void 0,w=void 0,B=w=n=0,y=s=r=void 0,C=y=r=q=void 0,s=void 0,u=p.geometry,v=u.faces,y=m.faces,q=0,r=y.length;q<r;q++)s=y[q],s=v[s],s instanceof THREE.Face3?(n+=3,w+=1,B+=3):s instanceof THREE.Face4&&(n+=4,w+=2,B+=4);for(var q=m,r=p,G=y=v=void 0,K=void 0,G=void 0,s=[],v=0,y=r.materials.length;v<
  257. y;v++)if(G=r.materials[v],G instanceof THREE.MeshFaceMaterial){G=0;for(l=q.materials.length;G<l;G++)(K=q.materials[G])&&s.push(K)}else(K=G)&&s.push(K);q=s;m.__materials=q;a:{v=r=void 0;y=q.length;for(r=0;r<y;r++)if(v=q[r],v.map||v.lightMap||v instanceof THREE.MeshShaderMaterial){r=!0;break a}r=!1}a:{y=v=void 0;s=q.length;for(v=0;v<s;v++)if(y=q[v],!(y instanceof THREE.MeshBasicMaterial&&!y.envMap||y instanceof THREE.MeshDepthMaterial)){y=y&&y.shading!=void 0&&y.shading==THREE.SmoothShading?THREE.SmoothShading:
  258. THREE.FlatShading;break a}y=!1}a:{s=v=void 0;G=q.length;for(v=0;v<G;v++)if(s=q[v],s.vertexColors){s=s.vertexColors;break a}s=!1}m.__vertexArray=new Float32Array(n*3);if(y)m.__normalArray=new Float32Array(n*3);if(u.hasTangents)m.__tangentArray=new Float32Array(n*4);if(s)m.__colorArray=new Float32Array(n*3);if(r){if(u.faceUvs.length>0||u.faceVertexUvs.length>0)m.__uvArray=new Float32Array(n*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)m.__uv2Array=new Float32Array(n*2)}if(p.geometry.skinWeights.length&&
  259. p.geometry.skinIndices.length)m.__skinVertexAArray=new Float32Array(n*4),m.__skinVertexBArray=new Float32Array(n*4),m.__skinIndexArray=new Float32Array(n*4),m.__skinWeightArray=new Float32Array(n*4);m.__faceArray=new Uint16Array(w*3+(p.geometry.edgeFaces?p.geometry.edgeFaces.length*6:0));m.__lineArray=new Uint16Array(B*2);if(m.numMorphTargets){m.__morphTargetsArrays=[];u=0;for(v=m.numMorphTargets;u<v;u++)m.__morphTargetsArrays.push(new Float32Array(n*3))}m.__needsSmoothNormals=y==THREE.SmoothShading;
  260. m.__uvType=r;m.__vertexColorType=s;m.__normalType=y;m.__webglFaceCount=w*3+(p.geometry.edgeFaces?p.geometry.edgeFaces.length*6:0);m.__webglLineCount=B*2;u=0;for(v=q.length;u<v;u++)if(r=q[u],r.attributes){if(m.__webglCustomAttributes===void 0)m.__webglCustomAttributes={};for(a in r.attributes){s=r.attributes[a];y={};for(C in s)y[C]=s[C];if(!y.__webglInitialized||y.createUniqueBuffers)y.__webglInitialized=!0,w=1,y.type==="v2"?w=2:y.type==="v3"?w=3:y.type==="v4"?w=4:y.type==="c"&&(w=3),y.size=w,y.array=
  261. new Float32Array(n*w),y.buffer=f.createBuffer(),y.buffer.belongsToAttribute=a,s.needsUpdate=!0,y.__original=s;m.__webglCustomAttributes[a]=y}}m.__inittedArrays=!0;j.__dirtyVertices=!0;j.__dirtyMorphTargets=!0;j.__dirtyElements=!0;j.__dirtyUvs=!0;j.__dirtyNormals=!0;j.__dirtyTangents=!0;j.__dirtyColors=!0}fa(e.__webglObjects,k,d)}else if(d instanceof THREE.Ribbon){j=d.geometry;if(!j.__webglVertexBuffer)h=j,h.__webglVertexBuffer=f.createBuffer(),h.__webglColorBuffer=f.createBuffer(),h=j,k=h.vertices.length,
  262. h.__vertexArray=new Float32Array(k*3),h.__colorArray=new Float32Array(k*3),h.__webglVertexCount=k,j.__dirtyVertices=!0,j.__dirtyColors=!0;fa(e.__webglObjects,j,d)}else if(d instanceof THREE.Line){j=d.geometry;if(!j.__webglVertexBuffer)h=j,h.__webglVertexBuffer=f.createBuffer(),h.__webglColorBuffer=f.createBuffer(),h=j,k=h.vertices.length,h.__vertexArray=new Float32Array(k*3),h.__colorArray=new Float32Array(k*3),h.__webglLineCount=k,j.__dirtyVertices=!0,j.__dirtyColors=!0;fa(e.__webglObjects,j,d)}else if(d instanceof
  263. THREE.ParticleSystem){j=d.geometry;if(!j.__webglVertexBuffer){h=j;h.__webglVertexBuffer=f.createBuffer();h.__webglColorBuffer=f.createBuffer();h=j;k=d;m=h.vertices.length;h.__vertexArray=new Float32Array(m*3);h.__colorArray=new Float32Array(m*3);h.__sortArray=[];h.__webglParticleCount=m;h.__materials=k.materials;C=n=p=void 0;p=0;for(n=k.materials.length;p<n;p++)if(C=k.materials[p],C.attributes){if(h.__webglCustomAttributes===void 0)h.__webglCustomAttributes={};for(a in C.attributes){originalAttribute=
  264. C.attributes[a];attribute={};for(property in originalAttribute)attribute[property]=originalAttribute[property];if(!attribute.__webglInitialized||attribute.createUniqueBuffers)attribute.__webglInitialized=!0,size=1,attribute.type==="v2"?size=2:attribute.type==="v3"?size=3:attribute.type==="v4"?size=4:attribute.type==="c"&&(size=3),attribute.size=size,attribute.array=new Float32Array(m*size),attribute.buffer=f.createBuffer(),attribute.buffer.belongsToAttribute=a,originalAttribute.needsUpdate=!0,attribute.__original=
  265. originalAttribute;h.__webglCustomAttributes[a]=attribute}}j.__dirtyVertices=!0;j.__dirtyColors=!0}fa(e.__webglObjects,j,d)}else THREE.MarchingCubes!==void 0&&d instanceof THREE.MarchingCubes?e.__webglObjectsImmediate.push({object:d,opaque:{list:[],count:0},transparent:{list:[],count:0}}):d instanceof THREE.Sprite&&e.__webglSprites.push(d);b.__objectsAdded.splice(0,1)}for(;b.__objectsRemoved.length;){e=b.__objectsRemoved[0];d=b;if(e instanceof THREE.Mesh||e instanceof THREE.ParticleSystem||e instanceof
  266. THREE.Ribbon||e instanceof THREE.Line)pa(d.__webglObjects,e);else if(e instanceof THREE.Sprite){d=d.__webglSprites;j=void 0;for(j=d.length-1;j>=0;j--)d[j]==e&&d.splice(j,1)}else e instanceof THREE.MarchingCubes&&pa(d.__webglObjectsImmediate,e);b.__objectsRemoved.splice(0,1)}d=0;for(e=b.__webglObjects.length;d<e;d++)if(h=b.__webglObjects[d].object,n=k=j=void 0,h instanceof THREE.Mesh){j=h.geometry;m=0;for(p=j.geometryGroupsList.length;m<p;m++)if(k=j.geometryGroupsList[m],n=xa(k),j.__dirtyVertices||
  267. j.__dirtyMorphTargets||j.__dirtyElements||j.__dirtyUvs||j.__dirtyNormals||j.__dirtyColors||j.__dirtyTangents||n)if(n=k,C=f.DYNAMIC_DRAW,w=!j.dynamic,n.__inittedArrays){var E=u=B=void 0,A=void 0,J=E=void 0,F=void 0,M=void 0,N=void 0,O=K=G=s=y=v=r=q=void 0,L=void 0,t=A=N=A=M=F=void 0,o=void 0,z=o=t=F=void 0,P=void 0,S=z=o=t=E=E=J=N=A=z=o=t=P=z=o=t=P=z=o=t=void 0,ha=0,la=0,W=0,Y=0,T=0,Q=0,X=0,R=0,ka=0,x=0,ma=0,z=t=0,z=void 0,na=n.__vertexArray,ia=n.__uvArray,ja=n.__uv2Array,V=n.__normalArray,$=n.__tangentArray,
  268. oa=n.__colorArray,aa=n.__skinVertexAArray,ca=n.__skinVertexBArray,da=n.__skinIndexArray,ea=n.__skinWeightArray,qa=n.__morphTargetsArrays,Z=n.__webglCustomAttributes,o=void 0,ga=n.__faceArray,Ba=n.__lineArray,wa=n.__needsSmoothNormals,r=n.__vertexColorType,q=n.__uvType,v=n.__normalType,ta=h.geometry,ua=ta.__dirtyVertices,va=ta.__dirtyElements,sa=ta.__dirtyUvs,Aa=ta.__dirtyNormals,Ca=ta.__dirtyTangents,Da=ta.__dirtyColors,Ea=ta.__dirtyMorphTargets,za=ta.vertices,Ga=n.faces,Ja=ta.faces,Ia=ta.faceVertexUvs[0],
  269. Ka=ta.faceVertexUvs[1],Na=ta.skinVerticesA,Oa=ta.skinVerticesB,Pa=ta.skinIndices,La=ta.skinWeights,Ha=ta.morphTargets;if(Z)for(S in Z)Z[S].offset=0,Z[S].offsetSrc=0;B=0;for(u=Ga.length;B<u;B++)if(E=Ga[B],A=Ja[E],Ia&&(y=Ia[E]),Ka&&(s=Ka[E]),E=A.vertexNormals,J=A.normal,F=A.vertexColors,M=A.color,N=A.vertexTangents,A instanceof THREE.Face3){if(ua)G=za[A.a].position,K=za[A.b].position,O=za[A.c].position,na[la]=G.x,na[la+1]=G.y,na[la+2]=G.z,na[la+3]=K.x,na[la+4]=K.y,na[la+5]=K.z,na[la+6]=O.x,na[la+7]=
  270. O.y,na[la+8]=O.z,la+=9;if(Z)for(S in Z)if(o=Z[S],o.__original.needsUpdate)t=o.offset,z=o.offsetSrc,o.size===1?(o.boundTo===void 0||o.boundTo==="vertices"?(o.array[t]=o.value[A.a],o.array[t+1]=o.value[A.b],o.array[t+2]=o.value[A.c]):o.boundTo==="faces"?(z=o.value[z],o.array[t]=z,o.array[t+1]=z,o.array[t+2]=z,o.offsetSrc++):o.boundTo==="faceVertices"&&(o.array[t]=o.value[z],o.array[t+1]=o.value[z+1],o.array[t+2]=o.value[z+2],o.offsetSrc+=3),o.offset+=3):(o.boundTo===void 0||o.boundTo==="vertices"?(G=
  271. o.value[A.a],K=o.value[A.b],O=o.value[A.c]):o.boundTo==="faces"?(O=K=G=z=o.value[z],o.offsetSrc++):o.boundTo==="faceVertices"&&(G=o.value[z],K=o.value[z+1],O=o.value[z+2],o.offsetSrc+=3),o.size===2?(o.array[t]=G.x,o.array[t+1]=G.y,o.array[t+2]=K.x,o.array[t+3]=K.y,o.array[t+4]=O.x,o.array[t+5]=O.y,o.offset+=6):o.size===3?(o.type==="c"?(o.array[t]=G.r,o.array[t+1]=G.g,o.array[t+2]=G.b,o.array[t+3]=K.r,o.array[t+4]=K.g,o.array[t+5]=K.b,o.array[t+6]=O.r,o.array[t+7]=O.g,o.array[t+8]=O.b):(o.array[t]=
  272. G.x,o.array[t+1]=G.y,o.array[t+2]=G.z,o.array[t+3]=K.x,o.array[t+4]=K.y,o.array[t+5]=K.z,o.array[t+6]=O.x,o.array[t+7]=O.y,o.array[t+8]=O.z),o.offset+=9):(o.array[t]=G.x,o.array[t+1]=G.y,o.array[t+2]=G.z,o.array[t+3]=G.w,o.array[t+4]=K.x,o.array[t+5]=K.y,o.array[t+6]=K.z,o.array[t+7]=K.w,o.array[t+8]=O.x,o.array[t+9]=O.y,o.array[t+10]=O.z,o.array[t+11]=O.w,o.offset+=12));if(Ea){t=0;for(o=Ha.length;t<o;t++)G=Ha[t].vertices[A.a].position,K=Ha[t].vertices[A.b].position,O=Ha[t].vertices[A.c].position,
  273. z=qa[t],z[ma]=G.x,z[ma+1]=G.y,z[ma+2]=G.z,z[ma+3]=K.x,z[ma+4]=K.y,z[ma+5]=K.z,z[ma+6]=O.x,z[ma+7]=O.y,z[ma+8]=O.z;ma+=9}if(La.length)t=La[A.a],o=La[A.b],z=La[A.c],ea[x]=t.x,ea[x+1]=t.y,ea[x+2]=t.z,ea[x+3]=t.w,ea[x+4]=o.x,ea[x+5]=o.y,ea[x+6]=o.z,ea[x+7]=o.w,ea[x+8]=z.x,ea[x+9]=z.y,ea[x+10]=z.z,ea[x+11]=z.w,t=Pa[A.a],o=Pa[A.b],z=Pa[A.c],da[x]=t.x,da[x+1]=t.y,da[x+2]=t.z,da[x+3]=t.w,da[x+4]=o.x,da[x+5]=o.y,da[x+6]=o.z,da[x+7]=o.w,da[x+8]=z.x,da[x+9]=z.y,da[x+10]=z.z,da[x+11]=z.w,t=Na[A.a],o=Na[A.b],
  274. z=Na[A.c],aa[x]=t.x,aa[x+1]=t.y,aa[x+2]=t.z,aa[x+3]=1,aa[x+4]=o.x,aa[x+5]=o.y,aa[x+6]=o.z,aa[x+7]=1,aa[x+8]=z.x,aa[x+9]=z.y,aa[x+10]=z.z,aa[x+11]=1,t=Oa[A.a],o=Oa[A.b],z=Oa[A.c],ca[x]=t.x,ca[x+1]=t.y,ca[x+2]=t.z,ca[x+3]=1,ca[x+4]=o.x,ca[x+5]=o.y,ca[x+6]=o.z,ca[x+7]=1,ca[x+8]=z.x,ca[x+9]=z.y,ca[x+10]=z.z,ca[x+11]=1,x+=12;if(Da&&r)F.length==3&&r==THREE.VertexColors?(A=F[0],t=F[1],o=F[2]):o=t=A=M,oa[ka]=A.r,oa[ka+1]=A.g,oa[ka+2]=A.b,oa[ka+3]=t.r,oa[ka+4]=t.g,oa[ka+5]=t.b,oa[ka+6]=o.r,oa[ka+7]=o.g,oa[ka+
  275. 8]=o.b,ka+=9;if(Ca&&ta.hasTangents)F=N[0],M=N[1],A=N[2],$[X]=F.x,$[X+1]=F.y,$[X+2]=F.z,$[X+3]=F.w,$[X+4]=M.x,$[X+5]=M.y,$[X+6]=M.z,$[X+7]=M.w,$[X+8]=A.x,$[X+9]=A.y,$[X+10]=A.z,$[X+11]=A.w,X+=12;if(Aa&&v)if(E.length==3&&wa)for(N=0;N<3;N++)J=E[N],V[Q]=J.x,V[Q+1]=J.y,V[Q+2]=J.z,Q+=3;else for(N=0;N<3;N++)V[Q]=J.x,V[Q+1]=J.y,V[Q+2]=J.z,Q+=3;if(sa&&y!==void 0&&q)for(N=0;N<3;N++)E=y[N],ia[W]=E.u,ia[W+1]=E.v,W+=2;if(sa&&s!==void 0&&q)for(N=0;N<3;N++)E=s[N],ja[Y]=E.u,ja[Y+1]=E.v,Y+=2;va&&(ga[T]=ha,ga[T+1]=
  276. ha+1,ga[T+2]=ha+2,T+=3,Ba[R]=ha,Ba[R+1]=ha+1,Ba[R+2]=ha,Ba[R+3]=ha+2,Ba[R+4]=ha+1,Ba[R+5]=ha+2,R+=6,ha+=3)}else if(A instanceof THREE.Face4){if(ua)G=za[A.a].position,K=za[A.b].position,O=za[A.c].position,L=za[A.d].position,na[la]=G.x,na[la+1]=G.y,na[la+2]=G.z,na[la+3]=K.x,na[la+4]=K.y,na[la+5]=K.z,na[la+6]=O.x,na[la+7]=O.y,na[la+8]=O.z,na[la+9]=L.x,na[la+10]=L.y,na[la+11]=L.z,la+=12;if(Z)for(S in Z)if(o=Z[S],o.__original.needsUpdate)t=o.offset,z=o.offsetSrc,o.size===1?(o.boundTo===void 0||o.boundTo===
  277. "vertices"?(o.array[t]=o.value[A.a],o.array[t+1]=o.value[A.b],o.array[t+2]=o.value[A.c],o.array[t+3]=o.value[A.d]):o.boundTo==="faces"?(z=o.value[z],o.array[t]=z,o.array[t+1]=z,o.array[t+2]=z,o.array[t+3]=z,o.offsetSrc++):o.boundTo==="faceVertices"&&(o.array[t]=o.value[z],o.array[t+1]=o.value[z+1],o.array[t+2]=o.value[z+2],o.array[t+3]=o.value[z+3],o.offsetSrc+=4),o.offset+=4):(o.boundTo===void 0||o.boundTo==="vertices"?(G=o.value[A.a],K=o.value[A.b],O=o.value[A.c],L=o.value[A.d]):o.boundTo==="faces"?
  278. (L=O=K=G=z=o.value[z],o.offsetSrc++):o.boundTo==="faceVertices"&&(G=o.value[z],K=o.value[z+1],O=o.value[z+2],L=o.value[z+3],o.offsetSrc+=4),o.size===2?(o.array[t]=G.x,o.array[t+1]=G.y,o.array[t+2]=K.x,o.array[t+3]=K.y,o.array[t+4]=O.x,o.array[t+5]=O.y,o.array[t+6]=L.x,o.array[t+7]=L.y,o.offset+=8):o.size===3?(o.type==="c"?(o.array[t]=G.r,o.array[t+1]=G.g,o.array[t+2]=G.b,o.array[t+3]=K.r,o.array[t+4]=K.g,o.array[t+5]=K.b,o.array[t+6]=O.r,o.array[t+7]=O.g,o.array[t+8]=O.b,o.array[t+9]=L.r,o.array[t+
  279. 10]=L.g,o.array[t+11]=L.b):(o.array[t]=G.x,o.array[t+1]=G.y,o.array[t+2]=G.z,o.array[t+3]=K.x,o.array[t+4]=K.y,o.array[t+5]=K.z,o.array[t+6]=O.x,o.array[t+7]=O.y,o.array[t+8]=O.z,o.array[t+9]=L.x,o.array[t+10]=L.y,o.array[t+11]=L.z),o.offset+=12):(o.array[t]=G.x,o.array[t+1]=G.y,o.array[t+2]=G.z,o.array[t+3]=G.w,o.array[t+4]=K.x,o.array[t+5]=K.y,o.array[t+6]=K.z,o.array[t+7]=K.w,o.array[t+8]=O.x,o.array[t+9]=O.y,o.array[t+10]=O.z,o.array[t+11]=O.w,o.array[t+12]=L.x,o.array[t+13]=L.y,o.array[t+14]=
  280. L.z,o.array[t+15]=L.w,o.offset+=16));if(Ea){t=0;for(o=Ha.length;t<o;t++)G=Ha[t].vertices[A.a].position,K=Ha[t].vertices[A.b].position,O=Ha[t].vertices[A.c].position,L=Ha[t].vertices[A.d].position,z=qa[t],z[ma]=G.x,z[ma+1]=G.y,z[ma+2]=G.z,z[ma+3]=K.x,z[ma+4]=K.y,z[ma+5]=K.z,z[ma+6]=O.x,z[ma+7]=O.y,z[ma+8]=O.z,z[ma+9]=L.x,z[ma+10]=L.y,z[ma+11]=L.z;ma+=12}if(La.length)t=La[A.a],o=La[A.b],z=La[A.c],P=La[A.d],ea[x]=t.x,ea[x+1]=t.y,ea[x+2]=t.z,ea[x+3]=t.w,ea[x+4]=o.x,ea[x+5]=o.y,ea[x+6]=o.z,ea[x+7]=o.w,
  281. ea[x+8]=z.x,ea[x+9]=z.y,ea[x+10]=z.z,ea[x+11]=z.w,ea[x+12]=P.x,ea[x+13]=P.y,ea[x+14]=P.z,ea[x+15]=P.w,t=Pa[A.a],o=Pa[A.b],z=Pa[A.c],P=Pa[A.d],da[x]=t.x,da[x+1]=t.y,da[x+2]=t.z,da[x+3]=t.w,da[x+4]=o.x,da[x+5]=o.y,da[x+6]=o.z,da[x+7]=o.w,da[x+8]=z.x,da[x+9]=z.y,da[x+10]=z.z,da[x+11]=z.w,da[x+12]=P.x,da[x+13]=P.y,da[x+14]=P.z,da[x+15]=P.w,t=Na[A.a],o=Na[A.b],z=Na[A.c],P=Na[A.d],aa[x]=t.x,aa[x+1]=t.y,aa[x+2]=t.z,aa[x+3]=1,aa[x+4]=o.x,aa[x+5]=o.y,aa[x+6]=o.z,aa[x+7]=1,aa[x+8]=z.x,aa[x+9]=z.y,aa[x+10]=
  282. z.z,aa[x+11]=1,aa[x+12]=P.x,aa[x+13]=P.y,aa[x+14]=P.z,aa[x+15]=1,t=Oa[A.a],o=Oa[A.b],z=Oa[A.c],A=Oa[A.d],ca[x]=t.x,ca[x+1]=t.y,ca[x+2]=t.z,ca[x+3]=1,ca[x+4]=o.x,ca[x+5]=o.y,ca[x+6]=o.z,ca[x+7]=1,ca[x+8]=z.x,ca[x+9]=z.y,ca[x+10]=z.z,ca[x+11]=1,ca[x+12]=A.x,ca[x+13]=A.y,ca[x+14]=A.z,ca[x+15]=1,x+=16;if(Da&&r)F.length==4&&r==THREE.VertexColors?(A=F[0],t=F[1],o=F[2],F=F[3]):F=o=t=A=M,oa[ka]=A.r,oa[ka+1]=A.g,oa[ka+2]=A.b,oa[ka+3]=t.r,oa[ka+4]=t.g,oa[ka+5]=t.b,oa[ka+6]=o.r,oa[ka+7]=o.g,oa[ka+8]=o.b,oa[ka+
  283. 9]=F.r,oa[ka+10]=F.g,oa[ka+11]=F.b,ka+=12;if(Ca&&ta.hasTangents)F=N[0],M=N[1],A=N[2],N=N[3],$[X]=F.x,$[X+1]=F.y,$[X+2]=F.z,$[X+3]=F.w,$[X+4]=M.x,$[X+5]=M.y,$[X+6]=M.z,$[X+7]=M.w,$[X+8]=A.x,$[X+9]=A.y,$[X+10]=A.z,$[X+11]=A.w,$[X+12]=N.x,$[X+13]=N.y,$[X+14]=N.z,$[X+15]=N.w,X+=16;if(Aa&&v)if(E.length==4&&wa)for(N=0;N<4;N++)J=E[N],V[Q]=J.x,V[Q+1]=J.y,V[Q+2]=J.z,Q+=3;else for(N=0;N<4;N++)V[Q]=J.x,V[Q+1]=J.y,V[Q+2]=J.z,Q+=3;if(sa&&y!==void 0&&q)for(N=0;N<4;N++)E=y[N],ia[W]=E.u,ia[W+1]=E.v,W+=2;if(sa&&s!==
  284. void 0&&q)for(N=0;N<4;N++)E=s[N],ja[Y]=E.u,ja[Y+1]=E.v,Y+=2;va&&(ga[T]=ha,ga[T+1]=ha+1,ga[T+2]=ha+3,ga[T+3]=ha+1,ga[T+4]=ha+2,ga[T+5]=ha+3,T+=6,Ba[R]=ha,Ba[R+1]=ha+1,Ba[R+2]=ha,Ba[R+3]=ha+3,Ba[R+4]=ha+1,Ba[R+5]=ha+2,Ba[R+6]=ha+2,Ba[R+7]=ha+3,R+=8,ha+=4)}ua&&(f.bindBuffer(f.ARRAY_BUFFER,n.__webglVertexBuffer),f.bufferData(f.ARRAY_BUFFER,na,C));if(Z)for(S in Z)o=Z[S],o.__original.needsUpdate&&(f.bindBuffer(f.ARRAY_BUFFER,o.buffer),f.bufferData(f.ARRAY_BUFFER,o.array,C));if(Ea){t=0;for(o=Ha.length;t<
  285. o;t++)f.bindBuffer(f.ARRAY_BUFFER,n.__webglMorphTargetsBuffers[t]),f.bufferData(f.ARRAY_BUFFER,qa[t],C)}Da&&ka>0&&(f.bindBuffer(f.ARRAY_BUFFER,n.__webglColorBuffer),f.bufferData(f.ARRAY_BUFFER,oa,C));Aa&&(f.bindBuffer(f.ARRAY_BUFFER,n.__webglNormalBuffer),f.bufferData(f.ARRAY_BUFFER,V,C));Ca&&ta.hasTangents&&(f.bindBuffer(f.ARRAY_BUFFER,n.__webglTangentBuffer),f.bufferData(f.ARRAY_BUFFER,$,C));sa&&W>0&&(f.bindBuffer(f.ARRAY_BUFFER,n.__webglUVBuffer),f.bufferData(f.ARRAY_BUFFER,ia,C));sa&&Y>0&&(f.bindBuffer(f.ARRAY_BUFFER,
  286. n.__webglUV2Buffer),f.bufferData(f.ARRAY_BUFFER,ja,C));va&&(f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,n.__webglFaceBuffer),f.bufferData(f.ELEMENT_ARRAY_BUFFER,ga,C),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,n.__webglLineBuffer),f.bufferData(f.ELEMENT_ARRAY_BUFFER,Ba,C));x>0&&(f.bindBuffer(f.ARRAY_BUFFER,n.__webglSkinVertexABuffer),f.bufferData(f.ARRAY_BUFFER,aa,C),f.bindBuffer(f.ARRAY_BUFFER,n.__webglSkinVertexBBuffer),f.bufferData(f.ARRAY_BUFFER,ca,C),f.bindBuffer(f.ARRAY_BUFFER,n.__webglSkinIndicesBuffer),
  287. f.bufferData(f.ARRAY_BUFFER,da,C),f.bindBuffer(f.ARRAY_BUFFER,n.__webglSkinWeightsBuffer),f.bufferData(f.ARRAY_BUFFER,ea,C));w&&(delete n.__inittedArrays,delete n.__colorArray,delete n.__normalArray,delete n.__tangentArray,delete n.__uvArray,delete n.__uv2Array,delete n.__faceArray,delete n.__vertexArray,delete n.__lineArray,delete n.__skinVertexAArray,delete n.__skinVertexBArray,delete n.__skinIndexArray,delete n.__skinWeightArray)}j.__dirtyVertices=!1;j.__dirtyMorphTargets=!1;j.__dirtyElements=
  288. !1;j.__dirtyUvs=!1;j.__dirtyNormals=!1;j.__dirtyTangents=!1;j.__dirtyColors=!1;ya(k)}else if(h instanceof THREE.Ribbon){j=h.geometry;if(j.__dirtyVertices||j.__dirtyColors){h=j;k=f.DYNAMIC_DRAW;m=B=w=w=void 0;u=h.vertices;p=h.colors;q=u.length;n=p.length;r=h.__vertexArray;C=h.__colorArray;v=h.__dirtyColors;if(h.__dirtyVertices){for(w=0;w<q;w++)B=u[w].position,m=w*3,r[m]=B.x,r[m+1]=B.y,r[m+2]=B.z;f.bindBuffer(f.ARRAY_BUFFER,h.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,r,k)}if(v){for(w=0;w<n;w++)color=
  289. p[w],m=w*3,C[m]=color.r,C[m+1]=color.g,C[m+2]=color.b;f.bindBuffer(f.ARRAY_BUFFER,h.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,C,k)}}j.__dirtyVertices=!1;j.__dirtyColors=!1}else if(h instanceof THREE.Line){j=h.geometry;if(j.__dirtyVertices||j.__dirtyColors){h=j;k=f.DYNAMIC_DRAW;m=B=w=w=void 0;u=h.vertices;p=h.colors;q=u.length;n=p.length;r=h.__vertexArray;C=h.__colorArray;v=h.__dirtyColors;if(h.__dirtyVertices){for(w=0;w<q;w++)B=u[w].position,m=w*3,r[m]=B.x,r[m+1]=B.y,r[m+2]=B.z;f.bindBuffer(f.ARRAY_BUFFER,
  290. h.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,r,k)}if(v){for(w=0;w<n;w++)color=p[w],m=w*3,C[m]=color.r,C[m+1]=color.g,C[m+2]=color.b;f.bindBuffer(f.ARRAY_BUFFER,h.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,C,k)}}j.__dirtyVertices=!1;j.__dirtyColors=!1}else if(h instanceof THREE.ParticleSystem)j=h.geometry,n=xa(j),(j.__dirtyVertices||j.__dirtyColors||h.sortParticles||n)&&c(j,f.DYNAMIC_DRAW,h),j.__dirtyVertices=!1,j.__dirtyColors=!1,ya(j)};this.setFaceCulling=function(b,c){b?(!c||c=="ccw"?
  291. f.frontFace(f.CCW):f.frontFace(f.CW),b=="back"?f.cullFace(f.BACK):b=="front"?f.cullFace(f.FRONT):f.cullFace(f.FRONT_AND_BACK),f.enable(f.CULL_FACE)):f.disable(f.CULL_FACE)};this.supportsVertexTextures=function(){return $a}};
  292. THREE.WebGLRenderTarget=function(b,c,d){this.width=b;this.height=c;d=d||{};this.wrapS=d.wrapS!==void 0?d.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=d.wrapT!==void 0?d.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=d.magFilter!==void 0?d.magFilter:THREE.LinearFilter;this.minFilter=d.minFilter!==void 0?d.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=d.format!==void 0?d.format:THREE.RGBAFormat;this.type=d.type!==void 0?d.type:
  293. THREE.UnsignedByteType;this.depthBuffer=d.depthBuffer!==void 0?d.depthBuffer:!0;this.stencilBuffer=d.stencilBuffer!==void 0?d.stencilBuffer:!0};
  294. THREE.WebGLRenderTarget.prototype.clone=function(){var b=new THREE.WebGLRenderTarget(this.width,this.height);b.wrapS=this.wrapS;b.wrapT=this.wrapT;b.magFilter=this.magFilter;b.minFilter=this.minFilter;b.offset.copy(this.offset);b.repeat.copy(this.repeat);b.format=this.format;b.type=this.type;b.depthBuffer=this.depthBuffer;b.stencilBuffer=this.stencilBuffer;return b};THREE.WebGLRenderTargetCube=function(b,c,d){THREE.WebGLRenderTarget.call(this,b,c,d);this.activeCubeFace=0};
  295. THREE.WebGLRenderTargetCube.prototype=new THREE.WebGLRenderTarget;THREE.WebGLRenderTargetCube.prototype.constructor=THREE.WebGLRenderTargetCube;