ThreeWebGL.js 151 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. // ThreeWebGL.js r42 - http://github.com/mrdoob/three.js
  2. var THREE=THREE||{};if(!window.Int32Array)window.Int32Array=Array,window.Float32Array=Array;THREE.Color=function(b){this.setHex(b)};
  3. THREE.Color.prototype={constructor:THREE.Color,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex},setHex:function(b){this.hex=~~b&16777215;this.updateRGB()},setRGB:function(b,d,e){this.r=b;this.g=d;this.b=e;this.updateHex()},setHSV:function(b,d,e){var f,h,i,g,j,k;if(e==0)f=h=i=0;else switch(g=Math.floor(b*6),j=b*6-g,b=e*(1-d),k=e*(1-d*j),d=e*(1-d*(1-j)),g){case 1:f=k;h=e;i=b;break;case 2:f=b;h=e;i=d;break;case 3:f=b;h=k;i=e;break;case 4:f=d;h=b;i=e;break;case 5:f=e;h=b;i=k;break;case 6:case 0:f=
  4. e,h=d,i=b}this.setRGB(f,h,i)},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(b,d){this.set(b||0,d||0)};
  5. THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(b,d){this.x=b;this.y=d;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,d){this.x=b.x+d.x;this.y=b.y+d.y;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;return this},sub:function(b,d){this.x=b.x-d.x;this.y=b.y-d.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},
  6. 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 d=this.x-b.x,b=this.y-b.y;return d*d+b*b},setLength:function(b){return this.normalize().multiplyScalar(b)},
  7. unit:function(){return this.normalize()},equals:function(b){return b.x==this.x&&b.y==this.y}};THREE.Vector3=function(b,d,e){this.set(b||0,d||0,e||0)};
  8. THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(b,d,e){this.x=b;this.y=d;this.z=e;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,d){this.x=b.x+d.x;this.y=b.y+d.y;this.z=b.z+d.z;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;return this},addScalar:function(b){this.x+=b;this.y+=b;this.z+=b;return this},sub:function(b,d){this.x=b.x-d.x;this.y=b.y-d.y;this.z=
  9. b.z-d.z;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;this.z-=b.z;return this},multiply:function(b,d){this.x=b.x*d.x;this.y=b.y*d.y;this.z=b.z*d.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){return this.divide(this,b)},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)},
  10. 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)},cross:function(b,d){this.x=b.y*d.z-b.z*d.y;this.y=b.z*d.x-b.x*d.z;this.z=b.x*d.y-b.y*d.x;return this},crossSelf:function(b){return this.set(this.y*
  11. 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 d=Math.cos(this.y);this.y=Math.asin(b.n13);Math.abs(d)>1.0E-5?(this.x=Math.atan2(-b.n23/d,b.n33/d),this.z=Math.atan2(-b.n12/d,b.n11/d)):(this.x=0,this.z=Math.atan2(b.n21,b.n22))},isZero:function(){return this.lengthSq()<
  12. 1.0E-4}};THREE.Vector4=function(b,d,e,f){this.set(b||0,d||0,e||0,f||1)};
  13. THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(b,d,e,f){this.x=b;this.y=d;this.z=e;this.w=f;return this},copy:function(b){return this.set(b.x,b.y,b.z,b.w||1)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(b,d){this.x=b.x+d.x;this.y=b.y+d.y;this.z=b.z+d.z;this.w=b.w+d.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,d){this.x=b.x-d.x;this.y=b.y-d.y;this.z=b.z-d.z;this.w=b.w-d.w;return this},
  14. 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.set(0,0,0,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())},normalize:function(){return this.divideScalar(this.length())},
  15. setLength:function(b){return this.normalize().multiplyScalar(b)},lerpSelf:function(b,d){this.x+=(b.x-this.x)*d;this.y+=(b.y-this.y)*d;this.z+=(b.z-this.z)*d;this.w+=(b.w-this.w)*d;return this}};THREE.Ray=function(b,d){this.origin=b||new THREE.Vector3;this.direction=d||new THREE.Vector3};
  16. THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var d,e,f=[];d=0;for(e=b.length;d<e;d++)f=f.concat(this.intersectObject(b[d]));f.sort(function(b,d){return b.distance-d.distance});return f},intersectObject:function(b){function d(b,d,e){var f,e=e.matrixWorld.getPosition();f=e.clone().subSelf(b).dot(d);b=b.clone().addSelf(d.clone().multiplyScalar(f));return e.distanceTo(b)}function e(b,d,e,f){var f=f.clone().subSelf(d),
  17. e=e.clone().subSelf(d),h=b.clone().subSelf(d),b=f.dot(f),d=f.dot(e),f=f.dot(h),g=e.dot(e),e=e.dot(h),h=1/(b*g-d*d),g=(g*f-d*e)*h,b=(b*e-d*f)*h;return g>0&&b>0&&g+b<1}if(b instanceof THREE.Particle){var f=d(this.origin,this.direction,b);if(!f||f>b.scale.x)return[];return[{distance:f,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){f=d(this.origin,this.direction,b);if(!f||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return[];var h,i,g,j,
  18. k,n,p,q,o,r,F=b.geometry,v=F.vertices,G=[],f=0;for(h=F.faces.length;f<h;f++)if(i=F.faces[f],o=this.origin.clone(),r=this.direction.clone(),n=b.matrixWorld,g=n.multiplyVector3(v[i.a].position.clone()),j=n.multiplyVector3(v[i.b].position.clone()),k=n.multiplyVector3(v[i.c].position.clone()),n=i instanceof THREE.Face4?n.multiplyVector3(v[i.d].position.clone()):null,p=b.matrixRotationWorld.multiplyVector3(i.normal.clone()),q=r.dot(p),b.doubleSided||(b.flipSided?q>0:q<0))if(p=p.dot((new THREE.Vector3).sub(g,
  19. o))/q,o=o.addSelf(r.multiplyScalar(p)),i instanceof THREE.Face3)e(o,g,j,k)&&(i={distance:this.origin.distanceTo(o),point:o,face:i,object:b},G.push(i));else if(i instanceof THREE.Face4&&(e(o,g,j,n)||e(o,j,k,n)))i={distance:this.origin.distanceTo(o),point:o,face:i,object:b},G.push(i);return G}else return[]}};
  20. THREE.Rectangle=function(){function b(){i=f-d;g=h-e}var d,e,f,h,i,g,j=!0;this.getX=function(){return d};this.getY=function(){return e};this.getWidth=function(){return i};this.getHeight=function(){return g};this.getLeft=function(){return d};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(g,i,p,q){j=!1;d=g;e=i;f=p;h=q;b()};this.addPoint=function(g,i){j?(j=!1,d=g,e=i,f=g,h=i):(d=d<g?d:g,e=e<i?e:i,f=f>g?f:g,h=h>i?h:i);b()};this.add3Points=
  21. function(g,i,p,q,o,r){j?(j=!1,d=g<p?g<o?g:o:p<o?p:o,e=i<q?i<r?i:r:q<r?q:r,f=g>p?g>o?g:o:p>o?p:o,h=i>q?i>r?i:r:q>r?q:r):(d=g<p?g<o?g<d?g:d:o<d?o:d:p<o?p<d?p:d:o<d?o:d,e=i<q?i<r?i<e?i:e:r<e?r:e:q<r?q<e?q:e:r<e?r:e,f=g>p?g>o?g>f?g:f:o>f?o:f:p>o?p>f?p:f:o>f?o:f,h=i>q?i>r?i>h?i:h:r>h?r:h:q>r?q>h?q:h:r>h?r:h);b()};this.addRectangle=function(g){j?(j=!1,d=g.getLeft(),e=g.getTop(),f=g.getRight(),h=g.getBottom()):(d=d<g.getLeft()?d:g.getLeft(),e=e<g.getTop()?e:g.getTop(),f=f>g.getRight()?f:g.getRight(),h=h>
  22. g.getBottom()?h:g.getBottom());b()};this.inflate=function(g){d-=g;e-=g;f+=g;h+=g;b()};this.minSelf=function(g){d=d>g.getLeft()?d:g.getLeft();e=e>g.getTop()?e:g.getTop();f=f<g.getRight()?f:g.getRight();h=h<g.getBottom()?h:g.getBottom();b()};this.instersects=function(b){return Math.min(f,b.getRight())-Math.max(d,b.getLeft())>=0&&Math.min(h,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){j=!0;h=f=e=d=0;b()};this.isEmpty=function(){return j}};THREE.Matrix3=function(){this.m=[]};
  23. THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var b,d=this.m;b=d[1];d[1]=d[3];d[3]=b;b=d[2];d[2]=d[6];d[6]=b;b=d[5];d[5]=d[7];d[7]=b;return this},transposeIntoArray:function(b){var d=this.m;b[0]=d[0];b[1]=d[3];b[2]=d[6];b[3]=d[1];b[4]=d[4];b[5]=d[7];b[6]=d[2];b[7]=d[5];b[8]=d[8];return this}};THREE.Matrix4=function(b,d,e,f,h,i,g,j,k,n,p,q,o,r,F,v){this.set(b||1,d||0,e||0,f||0,h||0,i||1,g||0,j||0,k||0,n||0,p||1,q||0,o||0,r||0,F||0,v||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
  24. THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,d,e,f,h,i,g,j,k,n,p,q,o,r,F,v){this.n11=b;this.n12=d;this.n13=e;this.n14=f;this.n21=h;this.n22=i;this.n23=g;this.n24=j;this.n31=k;this.n32=n;this.n33=p;this.n34=q;this.n41=o;this.n42=r;this.n43=F;this.n44=v;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,
  25. d,e){var f=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,i=THREE.Matrix4.__v3;i.sub(b,d).normalize();if(i.length()===0)i.z=1;f.cross(e,i).normalize();f.length()===0&&(i.x+=1.0E-4,f.cross(e,i).normalize());h.cross(i,f).normalize();this.n11=f.x;this.n12=h.x;this.n13=i.x;this.n21=f.y;this.n22=h.y;this.n23=i.y;this.n31=f.z;this.n32=h.z;this.n33=i.z;return this},multiplyVector3:function(b){var d=b.x,e=b.y,f=b.z,h=1/(this.n41*d+this.n42*e+this.n43*f+this.n44);b.x=(this.n11*d+this.n12*e+this.n13*f+this.n14)*h;
  26. b.y=(this.n21*d+this.n22*e+this.n23*f+this.n24)*h;b.z=(this.n31*d+this.n32*e+this.n33*f+this.n34)*h;return b},multiplyVector4:function(b){var d=b.x,e=b.y,f=b.z,h=b.w;b.x=this.n11*d+this.n12*e+this.n13*f+this.n14*h;b.y=this.n21*d+this.n22*e+this.n23*f+this.n24*h;b.z=this.n31*d+this.n32*e+this.n33*f+this.n34*h;b.w=this.n41*d+this.n42*e+this.n43*f+this.n44*h;return b},rotateAxis:function(b){var d=b.x,e=b.y,f=b.z;b.x=d*this.n11+e*this.n12+f*this.n13;b.y=d*this.n21+e*this.n22+f*this.n23;b.z=d*this.n31+
  27. e*this.n32+f*this.n33;b.normalize();return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var e=b.n11,f=b.n12,h=b.n13,i=b.n14,g=b.n21,j=b.n22,k=b.n23,n=b.n24,p=b.n31,q=b.n32,o=b.n33,r=b.n34,F=b.n41,v=b.n42,G=b.n43,D=b.n44,T=d.n11,sa=d.n12,
  28. ea=d.n13,H=d.n14,w=d.n21,O=d.n22,I=d.n23,L=d.n24,P=d.n31,qa=d.n32,ja=d.n33,$=d.n34,ua=d.n41,M=d.n42,J=d.n43,c=d.n44;this.n11=e*T+f*w+h*P+i*ua;this.n12=e*sa+f*O+h*qa+i*M;this.n13=e*ea+f*I+h*ja+i*J;this.n14=e*H+f*L+h*$+i*c;this.n21=g*T+j*w+k*P+n*ua;this.n22=g*sa+j*O+k*qa+n*M;this.n23=g*ea+j*I+k*ja+n*J;this.n24=g*H+j*L+k*$+n*c;this.n31=p*T+q*w+o*P+r*ua;this.n32=p*sa+q*O+o*qa+r*M;this.n33=p*ea+q*I+o*ja+r*J;this.n34=p*H+q*L+o*$+r*c;this.n41=F*T+v*w+G*P+D*ua;this.n42=F*sa+v*O+G*qa+D*M;this.n43=F*ea+v*I+
  29. G*ja+D*J;this.n44=F*H+v*L+G*$+D*c;return this},multiplyToArray:function(b,d,e){this.multiply(b,d);e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[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;this.n21*=b;this.n22*=b;this.n23*=
  30. 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,d=this.n12,e=this.n13,f=this.n14,h=this.n21,i=this.n22,g=this.n23,j=this.n24,k=this.n31,n=this.n32,p=this.n33,q=this.n34,o=this.n41,r=this.n42,F=this.n43,v=this.n44;return f*g*n*o-e*j*n*o-f*i*p*o+d*j*p*o+e*i*q*o-d*g*q*o-f*g*k*r+e*j*k*r+f*h*p*r-b*j*p*r-e*h*q*r+b*g*q*r+f*i*k*F-d*j*k*F-f*h*n*F+b*j*n*F+d*h*q*F-b*i*q*F-e*i*k*v+d*g*k*v+e*h*n*v-
  31. b*g*n*v-d*h*p*v+b*i*p*v},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=this.n31;b.n32=this.n32;b.n33=
  32. 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;return this.flat},flattenToArray:function(b){b[0]=
  33. 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,d){b[d]=this.n11;b[d+1]=this.n21;b[d+2]=this.n31;b[d+3]=this.n41;b[d+4]=this.n12;b[d+5]=this.n22;b[d+6]=this.n32;b[d+7]=this.n42;b[d+8]=this.n13;b[d+9]=this.n23;b[d+10]=this.n33;b[d+11]=this.n43;b[d+12]=this.n14;b[d+13]=this.n24;b[d+14]=
  34. this.n34;b[d+15]=this.n44;return b},setTranslation:function(b,d,e){this.set(1,0,0,b,0,1,0,d,0,0,1,e,0,0,0,1);return this},setScale:function(b,d,e){this.set(b,0,0,0,0,d,0,0,0,0,e,0,0,0,0,1);return this},setRotationX:function(b){var d=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,d,-b,0,0,b,d,0,0,0,0,1);return this},setRotationY:function(b){var d=Math.cos(b),b=Math.sin(b);this.set(d,0,b,0,0,1,0,0,-b,0,d,0,0,0,0,1);return this},setRotationZ:function(b){var d=Math.cos(b),b=Math.sin(b);this.set(d,-b,0,
  35. 0,b,d,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,d){var e=Math.cos(d),f=Math.sin(d),h=1-e,i=b.x,g=b.y,j=b.z,k=h*i,n=h*g;this.set(k*i+e,k*g-f*j,k*j+f*g,0,k*g+f*j,n*g+e,n*j-f*i,0,k*j-f*g,n*j+f*i,h*j*j+e,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},getColumnX:function(){if(!this.columnX)this.columnX=
  36. 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,d){var e=b.x,f=b.y,h=b.z,i=Math.cos(e),e=Math.sin(e),g=Math.cos(f),f=Math.sin(f),j=Math.cos(h),h=Math.sin(h);switch(d){case "YXZ":var k=
  37. g*j,n=g*h,p=f*j,q=f*h;this.n11=k+q*e;this.n12=p*e-n;this.n13=i*f;this.n21=i*h;this.n22=i*j;this.n23=-e;this.n31=n*e-p;this.n32=q+k*e;this.n33=i*g;break;case "ZXY":k=g*j;n=g*h;p=f*j;q=f*h;this.n11=k-q*e;this.n12=-i*h;this.n13=p+n*e;this.n21=n+p*e;this.n22=i*j;this.n23=q-k*e;this.n31=-i*f;this.n32=e;this.n33=i*g;break;case "ZYX":k=i*j;n=i*h;p=e*j;q=e*h;this.n11=g*j;this.n12=p*f-n;this.n13=k*f+q;this.n21=g*h;this.n22=q*f+k;this.n23=n*f-p;this.n31=-f;this.n32=e*g;this.n33=i*g;break;case "YZX":k=i*g;n=
  38. i*f;p=e*g;q=e*f;this.n11=g*j;this.n12=q-k*h;this.n13=p*h+n;this.n21=h;this.n22=i*j;this.n23=-e*j;this.n31=-f*j;this.n32=n*h+p;this.n33=k-q*h;break;case "XZY":k=i*g;n=i*f;p=e*g;q=e*f;this.n11=g*j;this.n12=-h;this.n13=f*j;this.n21=k*h+q;this.n22=i*j;this.n23=n*h-p;this.n31=p*h-n;this.n32=e*j;this.n33=q*h+k;break;default:k=i*j,n=i*h,p=e*j,q=e*h,this.n11=g*j,this.n12=-g*h,this.n13=f,this.n21=n+p*f,this.n22=k-q*f,this.n23=-e*g,this.n31=q-k*f,this.n32=p+n*f,this.n33=i*g}return this},setRotationFromQuaternion:function(b){var d=
  39. b.x,e=b.y,f=b.z,h=b.w,i=d+d,g=e+e,j=f+f,b=d*i,k=d*g;d*=j;var n=e*g;e*=j;f*=j;i*=h;g*=h;h*=j;this.n11=1-(n+f);this.n12=k-h;this.n13=d+g;this.n21=k+h;this.n22=1-(b+f);this.n23=e-i;this.n31=d-g;this.n32=e+i;this.n33=1-(b+n);return this},scale:function(b){var d=b.x,e=b.y,b=b.z;this.n11*=d;this.n12*=e;this.n13*=b;this.n21*=d;this.n22*=e;this.n23*=b;this.n31*=d;this.n32*=e;this.n33*=b;this.n41*=d;this.n42*=e;this.n43*=b;return this},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34},
  40. extractRotation:function(b,d){var e=1/d.x,f=1/d.y,h=1/d.z;this.n11=b.n11*e;this.n21=b.n21*e;this.n31=b.n31*e;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*h;this.n23=b.n23*h;this.n33=b.n33*h}};
  41. THREE.Matrix4.makeInvert=function(b,d){var e=b.n11,f=b.n12,h=b.n13,i=b.n14,g=b.n21,j=b.n22,k=b.n23,n=b.n24,p=b.n31,q=b.n32,o=b.n33,r=b.n34,F=b.n41,v=b.n42,G=b.n43,D=b.n44;d===void 0&&(d=new THREE.Matrix4);d.n11=k*r*v-n*o*v+n*q*G-j*r*G-k*q*D+j*o*D;d.n12=i*o*v-h*r*v-i*q*G+f*r*G+h*q*D-f*o*D;d.n13=h*n*v-i*k*v+i*j*G-f*n*G-h*j*D+f*k*D;d.n14=i*k*q-h*n*q-i*j*o+f*n*o+h*j*r-f*k*r;d.n21=n*o*F-k*r*F-n*p*G+g*r*G+k*p*D-g*o*D;d.n22=h*r*F-i*o*F+i*p*G-e*r*G-h*p*D+e*o*D;d.n23=i*k*F-h*n*F-i*g*G+e*n*G+h*g*D-e*k*D;d.n24=
  42. h*n*p-i*k*p+i*g*o-e*n*o-h*g*r+e*k*r;d.n31=j*r*F-n*q*F+n*p*v-g*r*v-j*p*D+g*q*D;d.n32=i*q*F-f*r*F-i*p*v+e*r*v+f*p*D-e*q*D;d.n33=h*n*F-i*j*F+i*g*v-e*n*v-f*g*D+e*j*D;d.n34=i*j*p-f*n*p-i*g*q+e*n*q+f*g*r-e*j*r;d.n41=k*q*F-j*o*F-k*p*v+g*o*v+j*p*G-g*q*G;d.n42=f*o*F-h*q*F+h*p*v-e*o*v-f*p*G+e*q*G;d.n43=h*j*F-f*k*F-h*g*v+e*k*v+f*g*G-e*j*G;d.n44=f*k*p-h*j*p+h*g*q-e*k*q-f*g*o+e*j*o;d.multiplyScalar(1/b.determinant());return d};
  43. THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,e=d.m,f=b.n33*b.n22-b.n32*b.n23,h=-b.n33*b.n21+b.n31*b.n23,i=b.n32*b.n21-b.n31*b.n22,g=-b.n33*b.n12+b.n32*b.n13,j=b.n33*b.n11-b.n31*b.n13,k=-b.n32*b.n11+b.n31*b.n12,n=b.n23*b.n12-b.n22*b.n13,p=-b.n23*b.n11+b.n21*b.n13,q=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*g+b.n31*n;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*h;e[2]=b*i;e[3]=b*g;e[4]=b*j;e[5]=b*k;e[6]=b*n;e[7]=b*p;e[8]=b*q;return d};
  44. THREE.Matrix4.makeFrustum=function(b,d,e,f,h,i){var g;g=new THREE.Matrix4;g.n11=2*h/(d-b);g.n12=0;g.n13=(d+b)/(d-b);g.n14=0;g.n21=0;g.n22=2*h/(f-e);g.n23=(f+e)/(f-e);g.n24=0;g.n31=0;g.n32=0;g.n33=-(i+h)/(i-h);g.n34=-2*i*h/(i-h);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(b,d,e,f){var h,b=e*Math.tan(b*Math.PI/360);h=-b;return THREE.Matrix4.makeFrustum(h*d,b*d,h,b,e,f)};
  45. THREE.Matrix4.makeOrtho=function(b,d,e,f,h,i){var g,j,k,n;g=new THREE.Matrix4;j=d-b;k=e-f;n=i-h;g.n11=2/j;g.n12=0;g.n13=0;g.n14=-((d+b)/j);g.n21=0;g.n22=2/k;g.n23=0;g.n24=-((e+f)/k);g.n31=0;g.n32=0;g.n33=-2/n;g.n34=-((i+h)/n);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
  46. THREE.Object3D=function(){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=!0;this.quaternion=new THREE.Quaternion;
  47. this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this._vector=new THREE.Vector3;this.name=""};
  48. THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.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)},addChild:function(b){if(this.children.indexOf(b)===
  49. -1){b.parent!==void 0&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var d=this;d.parent!==void 0;)d=d.parent;d!==void 0&&d instanceof THREE.Scene&&d.addChildRecurse(b)}},removeChild:function(b){var d=this.children.indexOf(b);if(d!==-1)b.parent=void 0,this.children.splice(d,1)},getChildByName:function(b,d){var e,f,h;e=0;for(f=this.children.length;e<f;e++){h=this.children[e];if(h.name===b)return h;if(d&&(h=h.getChildByName(b,d),h!==void 0))return h}},updateMatrix:function(){this.matrix.setPosition(this.position);
  50. 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,d,e){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||d)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),
  51. this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,d=!0;for(var b=0,f=this.children.length;b<f;b++)this.children[b].update(this.matrixWorld,d,e)}};THREE.Quaternion=function(b,d,e,f){this.set(b||0,d||0,e||0,f!==void 0?f:1)};
  52. THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,d,e,f){this.x=b;this.y=d;this.z=e;this.w=f;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 d=0.5*Math.PI/360,e=b.x*d,f=b.y*d,h=b.z*d,b=Math.cos(f),f=Math.sin(f),d=Math.cos(-h),h=Math.sin(-h),i=Math.cos(e),e=Math.sin(e),g=b*d,j=f*h;this.w=g*i-j*e;this.x=g*e+j*i;this.y=f*d*i+b*h*e;this.z=b*h*i-f*d*e;return this},setFromAxisAngle:function(b,d){var e=d/2,f=Math.sin(e);
  53. this.x=b.x*f;this.y=b.y*f;this.z=b.z*f;this.w=Math.cos(e);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*=
  54. b,this.w*=b);return this},multiplySelf:function(b){var d=this.x,e=this.y,f=this.z,h=this.w,i=b.x,g=b.y,j=b.z,b=b.w;this.x=d*b+h*i+e*j-f*g;this.y=e*b+h*g+f*i-d*j;this.z=f*b+h*j+d*g-e*i;this.w=h*b-d*i-e*g-f*j;return this},multiply:function(b,d){this.x=b.x*d.w+b.y*d.z-b.z*d.y+b.w*d.x;this.y=-b.x*d.z+b.y*d.w+b.z*d.x+b.w*d.y;this.z=b.x*d.y-b.y*d.x+b.z*d.w+b.w*d.z;this.w=-b.x*d.x-b.y*d.y-b.z*d.z+b.w*d.w;return this},multiplyVector3:function(b,d){d||(d=b);var e=b.x,f=b.y,h=b.z,i=this.x,g=this.y,j=this.z,
  55. k=this.w,n=k*e+g*h-j*f,p=k*f+j*e-i*h,q=k*h+i*f-g*e,e=-i*e-g*f-j*h;d.x=n*k+e*-i+p*-j-q*-g;d.y=p*k+e*-g+q*-i-n*-j;d.z=q*k+e*-j+n*-g-p*-i;return d}};
  56. THREE.Quaternion.slerp=function(b,d,e,f){var h=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(h)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var i=Math.acos(h),g=Math.sqrt(1-h*h);if(Math.abs(g)<0.001)return e.w=0.5*(b.w+d.w),e.x=0.5*(b.x+d.x),e.y=0.5*(b.y+d.y),e.z=0.5*(b.z+d.z),e;h=Math.sin((1-f)*i)/g;f=Math.sin(f*i)/g;e.w=b.w*h+d.w*f;e.x=b.x*h+d.x*f;e.y=b.y*h+d.y*f;e.z=b.z*h+d.z*f;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
  57. THREE.Face3=function(b,d,e,f,h,i){this.a=b;this.b=d;this.c=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=i instanceof Array?i:[i];this.centroid=new THREE.Vector3};
  58. THREE.Face4=function(b,d,e,f,h,i,g){this.a=b;this.b=d;this.c=e;this.d=f;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=i instanceof THREE.Color?i:new THREE.Color;this.vertexColors=i instanceof Array?i:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)};
  59. THREE.UV.prototype={constructor:THREE.UV,set:function(b,d){this.u=b;this.v=d;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;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.hasTangents=!1};
  60. THREE.Geometry.prototype={constructor:THREE.Geometry,computeCentroids:function(){var b,d,e;b=0;for(d=this.faces.length;b<d;b++)e=this.faces[b],e.centroid.set(0,0,0),e instanceof THREE.Face3?(e.centroid.addSelf(this.vertices[e.a].position),e.centroid.addSelf(this.vertices[e.b].position),e.centroid.addSelf(this.vertices[e.c].position),e.centroid.divideScalar(3)):e instanceof THREE.Face4&&(e.centroid.addSelf(this.vertices[e.a].position),e.centroid.addSelf(this.vertices[e.b].position),e.centroid.addSelf(this.vertices[e.c].position),
  61. e.centroid.addSelf(this.vertices[e.d].position),e.centroid.divideScalar(4))},computeFaceNormals:function(b){var d,e,f,h,i,g,j=new THREE.Vector3,k=new THREE.Vector3;f=0;for(h=this.faces.length;f<h;f++){i=this.faces[f];if(b&&i.vertexNormals.length){j.set(0,0,0);d=0;for(e=i.vertexNormals.length;d<e;d++)j.addSelf(i.vertexNormals[d]);j.divideScalar(3)}else d=this.vertices[i.a],e=this.vertices[i.b],g=this.vertices[i.c],j.sub(g.position,e.position),k.sub(d.position,e.position),j.crossSelf(k);j.isZero()||
  62. j.normalize();i.normal.copy(j)}},computeVertexNormals:function(){var b,d,e,f;if(this.__tmpVertices==void 0){f=this.__tmpVertices=Array(this.vertices.length);b=0;for(d=this.vertices.length;b<d;b++)f[b]=new THREE.Vector3;b=0;for(d=this.faces.length;b<d;b++)if(e=this.faces[b],e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{f=
  63. this.__tmpVertices;b=0;for(d=this.vertices.length;b<d;b++)f[b].set(0,0,0)}b=0;for(d=this.faces.length;b<d;b++)e=this.faces[b],e instanceof THREE.Face3?(f[e.a].addSelf(e.normal),f[e.b].addSelf(e.normal),f[e.c].addSelf(e.normal)):e instanceof THREE.Face4&&(f[e.a].addSelf(e.normal),f[e.b].addSelf(e.normal),f[e.c].addSelf(e.normal),f[e.d].addSelf(e.normal));b=0;for(d=this.vertices.length;b<d;b++)f[b].normalize();b=0;for(d=this.faces.length;b<d;b++)e=this.faces[b],e instanceof THREE.Face3?(e.vertexNormals[0].copy(f[e.a]),
  64. e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c])):e instanceof THREE.Face4&&(e.vertexNormals[0].copy(f[e.a]),e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c]),e.vertexNormals[3].copy(f[e.d]))},computeTangents:function(){function b(b,d,e,f,h,i,J){j=b.vertices[d].position;k=b.vertices[e].position;n=b.vertices[f].position;p=g[h];q=g[i];o=g[J];r=k.x-j.x;F=n.x-j.x;v=k.y-j.y;G=n.y-j.y;D=k.z-j.z;T=n.z-j.z;sa=q.u-p.u;ea=o.u-p.u;H=q.v-p.v;w=o.v-p.v;O=1/(sa*w-ea*H);qa.set((w*r-
  65. H*F)*O,(w*v-H*G)*O,(w*D-H*T)*O);ja.set((sa*F-ea*r)*O,(sa*G-ea*v)*O,(sa*T-ea*D)*O);L[d].addSelf(qa);L[e].addSelf(qa);L[f].addSelf(qa);P[d].addSelf(ja);P[e].addSelf(ja);P[f].addSelf(ja)}var d,e,f,h,i,g,j,k,n,p,q,o,r,F,v,G,D,T,sa,ea,H,w,O,I,L=[],P=[],qa=new THREE.Vector3,ja=new THREE.Vector3,$=new THREE.Vector3,ua=new THREE.Vector3,M=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++)L[d]=new THREE.Vector3,P[d]=new THREE.Vector3;d=0;for(e=this.faces.length;d<e;d++)i=this.faces[d],g=this.faceVertexUvs[0][d],
  66. i instanceof THREE.Face3?b(this,i.a,i.b,i.c,0,1,2):i instanceof THREE.Face4&&(b(this,i.a,i.b,i.c,0,1,2),b(this,i.a,i.b,i.d,0,1,3));var J=["a","b","c","d"];d=0;for(e=this.faces.length;d<e;d++){i=this.faces[d];for(f=0;f<i.vertexNormals.length;f++)M.copy(i.vertexNormals[f]),h=i[J[f]],I=L[h],$.copy(I),$.subSelf(M.multiplyScalar(M.dot(I))).normalize(),ua.cross(i.vertexNormals[f],I),h=ua.dot(P[h]),h=h<0?-1:1,i.vertexTangents[f]=new THREE.Vector4($.x,$.y,$.z,h)}this.hasTangents=!0},computeBoundingBox:function(){var b;
  67. 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 d=1,e=this.vertices.length;d<e;d++){b=this.vertices[d];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]=b.position.y;
  68. 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,d=0,e=this.vertices.length;d<e;d++)b=Math.max(b,this.vertices[d].position.length());this.boundingSphere={radius:b}},computeEdgeFaces:function(){function b(b,d){return Math.min(b,d)+"_"+Math.max(b,d)}function d(b,d,e){b[d]===
  69. void 0?(b[d]={set:{},array:[]},b[d].set[e]=1,b[d].array.push(e)):b[d].set[e]===void 0&&(b[d].set[e]=1,b[d].array.push(e))}var e,f,h,i,g,j={};e=0;for(f=this.faces.length;e<f;e++)g=this.faces[e],g instanceof THREE.Face3?(h=b(g.a,g.b),d(j,h,e),h=b(g.b,g.c),d(j,h,e),h=b(g.a,g.c),d(j,h,e)):g instanceof THREE.Face4&&(h=b(g.b,g.d),d(j,h,e),h=b(g.a,g.b),d(j,h,e),h=b(g.a,g.d),d(j,h,e),h=b(g.b,g.c),d(j,h,e),h=b(g.c,g.d),d(j,h,e));e=0;for(f=this.edges.length;e<f;e++){g=this.edges[e];h=g.vertexIndices[0];i=g.vertexIndices[1];
  70. g.faceIndices=j[b(h,i)].array;for(h=0;h<g.faceIndices.length;h++)i=g.faceIndices[h],g.faces.push(this.faces[i])}}};THREE.GeometryIdCounter=0;
  71. THREE.Spline=function(b){function d(b,d,e,f,h,g,i){b=(e-b)*0.5;f=(f-d)*0.5;return(2*(d-e)+b+f)*i+(-3*(d-e)-2*b-f)*g+b*h+d}this.points=b;var e=[],f={x:0,y:0,z:0},h,i,g,j,k,n,p,q,o;this.initFromArray=function(b){this.points=[];for(var d=0;d<b.length;d++)this.points[d]={x:b[d][0],y:b[d][1],z:b[d][2]}};this.getPoint=function(b){h=(this.points.length-1)*b;i=Math.floor(h);g=h-i;e[0]=i==0?i:i-1;e[1]=i;e[2]=i>this.points.length-2?i:i+1;e[3]=i>this.points.length-3?i:i+2;n=this.points[e[0]];p=this.points[e[1]];
  72. q=this.points[e[2]];o=this.points[e[3]];j=g*g;k=g*j;f.x=d(n.x,p.x,q.x,o.x,g,j,k);f.y=d(n.y,p.y,q.y,o.y,g,j,k);f.z=d(n.z,p.z,q.z,o.z,g,j,k);return f};this.getControlPointsArray=function(){var b,d,e=this.points.length,f=[];for(b=0;b<e;b++)d=this.points[b],f[b]=[d.x,d.y,d.z];return f};this.getLength=function(b){var d,e,f=d=d=0,h=new THREE.Vector3,g=new THREE.Vector3,i=[],j=0;i[0]=0;b||(b=100);e=this.points.length*b;h.copy(this.points[0]);for(b=1;b<e;b++)d=b/e,position=this.getPoint(d),g.copy(position),
  73. j+=g.distanceTo(h),h.copy(position),d*=this.points.length-1,d=Math.floor(d),d!=f&&(i[d]=j,f=d);i[i.length]=j;return{chunks:i,total:j}};this.reparametrizeByArcLength=function(b){var d,e,f,h,g,i,j=[],n=new THREE.Vector3,k=this.getLength();j.push(n.copy(this.points[0]).clone());for(d=1;d<this.points.length;d++){e=k.chunks[d]-k.chunks[d-1];i=Math.ceil(b*e/k.total);h=(d-1)/(this.points.length-1);g=d/(this.points.length-1);for(e=1;e<i-1;e++)f=h+e*(1/i)*(g-h),position=this.getPoint(f),j.push(n.copy(position).clone());
  74. j.push(n.copy(this.points[d]).clone())}this.points=j}};THREE.Edge=function(b,d,e,f){this.vertices=[b,d];this.vertexIndices=[e,f];this.faces=[];this.faceIndices=[]};THREE.Camera=function(b,d,e,f,h){THREE.Object3D.call(this);this.fov=b||50;this.aspect=d||1;this.near=e||0.1;this.far=f||2E3;this.target=h||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;
  75. THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(b,d){this.matrix.rotateAxis(d);d.multiplyScalar(b);this.position.addSelf(d);this.target.position.addSelf(d)};
  76. THREE.Camera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var b=this.fullWidth/this.fullHeight,d=Math.tan(this.fov*Math.PI/360)*this.near,e=-d,f=b*e,b=Math.abs(b*d-f),e=Math.abs(d-e);this.projectionMatrix=THREE.Matrix4.makeFrustum(f+this.x*b/this.fullWidth,f+(this.x+this.width)*b/this.fullWidth,d-(this.y+this.height)*e/this.fullHeight,d-this.y*e/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
  77. THREE.Camera.prototype.setViewOffset=function(b,d,e,f,h,i){this.fullWidth=b;this.fullHeight=d;this.x=e;this.y=f;this.width=h;this.height=i;this.updateProjectionMatrix()};
  78. THREE.Camera.prototype.update=function(b,d,e){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),d=!0;else if(this.matrixAutoUpdate&&this.updateMatrix(),d||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=
  79. !1,d=!0,THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,d,e)};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;
  80. THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(b,d,e,f){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.intensity=d||1;this.distance=e||0;this.castShadow=f!==void 0?f:!1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(b,d,e){THREE.Light.call(this,b);this.position=new THREE.Vector3;this.intensity=d||1;this.distance=e||0};
  81. THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.SpotLight=function(b,d,e,f){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=d||1;this.distance=e||0;this.castShadow=f!==void 0?f:!1};THREE.SpotLight.prototype=new THREE.Light;THREE.SpotLight.prototype.constructor=THREE.SpotLight;
  82. THREE.LensFlare=function(b,d,e,f){THREE.Object3D.call(this);this.positionScreen=new THREE.Vector3;this.lensFlares=[];this.customUpdateCallback=void 0;b!==void 0&&this.add(b,d,e,f)};THREE.LensFlare.prototype=new THREE.Object3D;THREE.LensFlare.prototype.constructor=THREE.LensFlare;THREE.LensFlare.prototype.supr=THREE.Object3D.prototype;
  83. THREE.LensFlare.prototype.add=function(b,d,e,f){d===void 0&&(d=-1);e===void 0&&(e=0);if(f===void 0)f=THREE.BillboardBlending;e=Math.min(e,Math.max(0,e));this.lensFlares.push({texture:b,size:d,distance:e,x:0,y:0,z:0,scale:1,rotation:1,opacity:1,blending:f})};
  84. THREE.LensFlare.prototype.updateLensFlares=function(){var b,d=this.lensFlares.length,e,f=-this.positionScreen.x*2,h=-this.positionScreen.y*2;for(b=0;b<d;b++)e=this.lensFlares[b],e.x=this.positionScreen.x+f*e.distance,e.y=this.positionScreen.y+h*e.distance,e.wantedRotation=e.x*Math.PI*0.25,e.rotation+=(e.wantedRotation-e.rotation)*0.25};
  85. THREE.Material=function(b){this.id=THREE.MaterialCounter.value++;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.polygonOffset=b.polygonOffset!==void 0?b.polygonOffset:!1;this.polygonOffsetFactor=b.polygonOffsetFactor!==void 0?b.polygonOffsetFactor:0;this.polygonOffsetUnits=b.polygonOffsetUnits!==void 0?b.polygonOffsetUnits:
  86. 0;this.alphaTest=b.alphaTest!==void 0?b.alphaTest: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;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
  87. THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};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};
  88. THREE.LineBasicMaterial.prototype=new THREE.Material;THREE.LineBasicMaterial.prototype.constructor=THREE.LineBasicMaterial;
  89. 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!==
  90. 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};
  91. THREE.MeshBasicMaterial.prototype=new THREE.Material;THREE.MeshBasicMaterial.prototype.constructor=THREE.MeshBasicMaterial;
  92. 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!==
  93. 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};
  94. THREE.MeshLambertMaterial.prototype=new THREE.Material;THREE.MeshLambertMaterial.prototype.constructor=THREE.MeshLambertMaterial;
  95. 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;
  96. 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!==
  97. 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;
  98. 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;
  99. 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(){};
  100. 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=
  101. 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;
  102. 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;
  103. THREE.ShadowVolumeDynamicMaterial=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!==
  104. 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};
  105. THREE.ShadowVolumeDynamicMaterial.prototype=new THREE.Material;THREE.ShadowVolumeDynamicMaterial.prototype.constructor=THREE.ShadowVolumeDynamicMaterial;
  106. THREE.Texture=function(b,d,e,f,h,i){this.image=b;this.mapping=d!==void 0?d:new THREE.UVMapping;this.wrapS=e!==void 0?e:THREE.ClampToEdgeWrapping;this.wrapT=f!==void 0?f:THREE.ClampToEdgeWrapping;this.magFilter=h!==void 0?h:THREE.LinearFilter;this.minFilter=i!==void 0?i:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.needsUpdate=!1};
  107. THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;
  108. THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.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;
  109. THREE.ParticleSystem=function(b,d){THREE.Object3D.call(this);this.geometry=b;this.materials=d instanceof Array?d:[d];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(b,d,e){THREE.Object3D.call(this);this.geometry=b;this.materials=d instanceof Array?d:[d];this.type=e!=void 0?e:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;
  110. THREE.Line.prototype.constructor=THREE.Line;
  111. THREE.Mesh=function(b,d){THREE.Object3D.call(this);this.geometry=b;this.materials=d&&d.length?d:[d];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 e=0;e<this.geometry.morphTargets.length;e++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[e].name]=
  112. e}};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};
  113. 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;
  114. THREE.Bone.prototype.update=function(b,d,e){this.matrixAutoUpdate&&(d|=this.updateMatrix());if(d||this.matrixWorldNeedsUpdate)b?this.skinMatrix.multiply(b,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,d=!0;var f,h=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(f=0;f<h;f++)b=this.children[f],b instanceof THREE.Bone?b.update(this.skinMatrix,d,e):b.update(this.matrixWorld,!0,e)}else for(f=0;f<h;f++)this.children[f].update(this.skinMatrix,
  115. d,e)};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};
  116. THREE.SkinnedMesh=function(b,d){THREE.Mesh.call(this,b,d);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var e,f,h,i,g,j;if(this.geometry.bones!==void 0){for(e=0;e<this.geometry.bones.length;e++)h=this.geometry.bones[e],i=h.pos,g=h.rotq,j=h.scl,f=this.addBone(),f.name=h.name,f.position.set(i[0],i[1],i[2]),f.quaternion.set(g[0],g[1],g[2],g[3]),f.useQuaternion=!0,j!==void 0?f.scale.set(j[0],j[1],j[2]):f.scale.set(1,1,1);for(e=0;e<this.bones.length;e++)h=this.geometry.bones[e],
  117. f=this.bones[e],h.parent===-1?this.addChild(f):this.bones[h.parent].addChild(f);this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
  118. THREE.SkinnedMesh.prototype.update=function(b,d,e){if(this.visible){this.matrixAutoUpdate&&(d|=this.updateMatrix());if(d||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,d=!0;var f,h=this.children.length;for(f=0;f<h;f++)b=this.children[f],b instanceof THREE.Bone?b.update(this.identityMatrix,!1,e):b.update(this.matrixWorld,d,e);e=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(d=0;d<e;d++)ba[d].skinMatrix.flattenToArrayOffset(bm,
  119. d*16)}};THREE.SkinnedMesh.prototype.addBone=function(b){b===void 0&&(b=new THREE.Bone(this));this.bones.push(b);return b};
  120. THREE.SkinnedMesh.prototype.pose=function(){this.update(void 0,!0);for(var b,d=[],e=0;e<this.bones.length;e++)b=this.bones[e],d.push(THREE.Matrix4.makeInvert(b.skinMatrix)),b.skinMatrix.flattenToArrayOffset(this.boneMatrices,e*16);if(this.geometry.skinVerticesA===void 0){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var f;for(b=0;b<this.geometry.skinIndices.length;b++){var e=this.geometry.vertices[b].position,h=this.geometry.skinIndices[b].x,i=this.geometry.skinIndices[b].y;f=new THREE.Vector3(e.x,
  121. e.y,e.z);this.geometry.skinVerticesA.push(d[h].multiplyVector3(f));f=new THREE.Vector3(e.x,e.y,e.z);this.geometry.skinVerticesB.push(d[i].multiplyVector3(f));this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y!==1&&(e=(1-(this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y))*0.5,this.geometry.skinWeights[b].x+=e,this.geometry.skinWeights[b].y+=e)}}};THREE.Ribbon=function(b,d){THREE.Object3D.call(this);this.geometry=b;this.materials=d instanceof Array?d:[d]};
  122. 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.add=function(b,d){d===void 0&&(d=0);for(var d=Math.abs(d),e=0;e<this.LODs.length;e++)if(d<this.LODs[e].visibleAtDistance)break;this.LODs.splice(e,0,{visibleAtDistance:d,object3D:b});this.addChild(b)};
  123. THREE.LOD.prototype.update=function(b,d,e){this.matrixAutoUpdate&&(d|=this.updateMatrix());if(d||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,d=!0;if(this.LODs.length>1){b=e.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 f=1;f<this.LODs.length;f++)if(b>=this.LODs[f].visibleAtDistance)this.LODs[f-1].object3D.visible=!1,
  124. this.LODs[f].object3D.visible=!0;else break;for(;f<this.LODs.length;f++)this.LODs[f].object3D.visible=!1}for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,d,e)};THREE.ShadowVolume=function(b,d){b instanceof THREE.Mesh?(THREE.Mesh.call(this,b.geometry,d?[new THREE.ShadowVolumeDynamicMaterial]:[new THREE.ShadowVolumeDynamicMaterial]),b.addChild(this)):THREE.Mesh.call(this,b,d?[new THREE.ShadowVolumeDynamicMaterial]:[new THREE.ShadowVolumeDynamicMaterial]);this.calculateShadowVolumeGeometry()};
  125. THREE.ShadowVolume.prototype=new THREE.Mesh;THREE.ShadowVolume.prototype.constructor=THREE.ShadowVolume;THREE.ShadowVolume.prototype.supr=THREE.Mesh.prototype;
  126. THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(){if(this.geometry.edges&&this.geometry.edges.length){var b,d,e,f,h,i,g,j,k,n,p,q,o,r,F=new THREE.Geometry;F.vertices=this.geometry.vertices;f=F.faces=this.geometry.faces;var v=F.egdes=this.geometry.edges,G=F.edgeFaces=[];h=0;var D=[];b=0;for(d=f.length;b<d;b++)if(e=f[b],D.push(h),h+=e instanceof THREE.Face3?3:4,e.vertexNormals[0]=e.normal,e.vertexNormals[1]=e.normal,e.vertexNormals[2]=e.normal,e instanceof THREE.Face4)e.vertexNormals[3]=
  127. e.normal;b=0;for(d=v.length;b<d;b++)j=v[b],e=j.faces[0],f=j.faces[1],h=j.faceIndices[0],i=j.faceIndices[1],g=j.vertexIndices[0],j=j.vertexIndices[1],e.a===g?(k="a",p=D[h]+0):e.b===g?(k="b",p=D[h]+1):e.c===g?(k="c",p=D[h]+2):e.d===g&&(k="d",p=D[h]+3),e.a===j?(k+="a",q=D[h]+0):e.b===j?(k+="b",q=D[h]+1):e.c===j?(k+="c",q=D[h]+2):e.d===j&&(k+="d",q=D[h]+3),f.a===g?(n="a",o=D[i]+0):f.b===g?(n="b",o=D[i]+1):f.c===g?(n="c",o=D[i]+2):f.d===g&&(n="d",o=D[i]+3),f.a===j?(n+="a",r=D[i]+0):f.b===j?(n+="b",r=D[i]+
  128. 1):f.c===j?(n+="c",r=D[i]+2):f.d===j&&(n+="d",r=D[i]+3),k==="ac"||k==="ad"||k==="ca"||k==="da"?p>q&&(e=p,p=q,q=e):p<q&&(e=p,p=q,q=e),n==="ac"||n==="ad"||n==="ca"||n==="da"?o>r&&(e=o,o=r,r=e):o<r&&(e=o,o=r,r=e),e=new THREE.Face4(p,q,o,r),e.normal.set(1,0,0),G.push(e);this.geometry=F}else this.calculateShadowVolumeGeometryWithoutEdgeInfo(this.geometry)};
  129. THREE.ShadowVolume.prototype.calculateShadowVolumeGeometryWithoutEdgeInfo=function(b){this.geometry=new THREE.Geometry;this.geometry.boundingSphere=b.boundingSphere;this.geometry.edgeFaces=[];var d=this.geometry.vertices,e=this.geometry.faces,f=this.geometry.edgeFaces,h=b.faces,b=b.vertices,i=h.length,g,j,k,n,p,q=["a","b","c","d"];for(k=0;k<i;k++){j=d.length;g=h[k];g instanceof THREE.Face4?(n=4,j=new THREE.Face4(j,j+1,j+2,j+3)):(n=3,j=new THREE.Face3(j,j+1,j+2));j.normal.copy(g.normal);e.push(j);
  130. for(j=0;j<n;j++)p=b[g[q[j]]],d.push(new THREE.Vertex(p.position.clone()))}for(i=0;i<h.length-1;i++){b=e[i];for(g=i+1;g<h.length;g++)j=e[g],j=this.facesShareEdge(d,b,j),j!==void 0&&(j=new THREE.Face4(j.indices[0],j.indices[3],j.indices[2],j.indices[1]),j.normal.set(1,0,0),f.push(j))}};
  131. THREE.ShadowVolume.prototype.facesShareEdge=function(b,d,e){var f,h,i,g,j,k,n,p,q,o,r,F,v,G=0,D=["a","b","c","d"];f=d instanceof THREE.Face4?4:3;h=e instanceof THREE.Face4?4:3;for(F=0;F<f;F++){i=d[D[F]];j=b[i];for(v=0;v<h;v++)if(g=e[D[v]],k=b[g],Math.abs(j.position.x-k.position.x)<1.0E-4&&Math.abs(j.position.y-k.position.y)<1.0E-4&&Math.abs(j.position.z-k.position.z)<1.0E-4&&(G++,G===1&&(n=j,p=k,q=i,o=g,r=D[F]),G===2))return r+=D[F],r==="ad"||r==="ac"?{faces:[d,e],vertices:[n,p,k,j],indices:[q,o,
  132. g,i],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[d,e],vertices:[n,j,k,p],indices:[q,i,g,o],vertexTypes:[1,1,2,2],extrudable:!0}}};
  133. 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;
  134. 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;
  135. 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);
  136. 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);
  137. 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.addChild=function(b){this.supr.addChild.call(this,b);this.addChildRecurse(b)};
  138. 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 d=0;d<b.children.length;d++)this.addChildRecurse(b.children[d])};THREE.Scene.prototype.removeChild=function(b){this.supr.removeChild.call(this,b);this.removeChildRecurse(b)};
  139. THREE.Scene.prototype.removeChildRecurse=function(b){if(b instanceof THREE.Light){var d=this.lights.indexOf(b);d!==-1&&this.lights.splice(d,1)}else b instanceof THREE.Camera||(d=this.objects.indexOf(b),d!==-1&&(this.objects.splice(d,1),this.__objectsRemoved.push(b)));for(d=0;d<b.children.length;d++)this.removeChildRecurse(b.children[d])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;
  140. THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(b,d,e){this.color=new THREE.Color(b);this.near=d||1;this.far=e||1E3};THREE.FogExp2=function(b,d){this.color=new THREE.Color(b);this.density=d!==void 0?d:2.5E-4};
  141. THREE.Projector=function(){function b(){var b=k[j]=k[j]||new THREE.RenderableVertex;j++;return b}function d(b,d){return d.z-b.z}function e(b,d){var e=0,f=1,h=b.z+b.w,g=d.z+d.w,c=-b.z+b.w,i=-d.z+d.w;return h>=0&&g>=0&&c>=0&&i>=0?!0:h<0&&g<0||c<0&&i<0?!1:(h<0?e=Math.max(e,h/(h-g)):g<0&&(f=Math.min(f,h/(h-g))),c<0?e=Math.max(e,c/(c-i)):i<0&&(f=Math.min(f,c/(c-i))),f<e?!1:(b.lerpSelf(d,e),d.lerpSelf(b,1-f),!0))}var f,h,i=[],g,j,k=[],n,p,q=[],o,r=[],F,v,G=[],D,T,sa=[],ea=new THREE.Vector4,H=new THREE.Vector4,
  142. w=new THREE.Matrix4,O=new THREE.Matrix4,I=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],L=new THREE.Vector4,P=new THREE.Vector4;this.projectVector=function(b,d){w.multiply(d.projectionMatrix,d.matrixWorldInverse);w.multiplyVector3(b);return b};this.unprojectVector=function(b,d){w.multiply(d.matrixWorld,THREE.Matrix4.makeInvert(d.projectionMatrix));w.multiplyVector3(b);return b};this.projectObjects=function(b,e,g){var e=[],j,n,k;h=0;n=
  143. b.objects;b=0;for(j=n.length;b<j;b++){k=n[b];var c;if(!(c=!k.visible))if(c=k instanceof THREE.Mesh){a:{c=void 0;for(var p=k.matrixWorld,q=-k.geometry.boundingSphere.radius*Math.max(k.scale.x,Math.max(k.scale.y,k.scale.z)),o=0;o<6;o++)if(c=I[o].x*p.n14+I[o].y*p.n24+I[o].z*p.n34+I[o].w,c<=q){c=!1;break a}c=!0}c=!c}if(!c)c=i[h]=i[h]||new THREE.RenderableObject,h++,f=c,ea.copy(k.position),w.multiplyVector3(ea),f.object=k,f.z=ea.z,e.push(f)}g&&e.sort(d);return e};this.projectScene=function(f,h,i){var ea=
  144. [],M=h.near,J=h.far,c,ga,Q,oa,K,aa,N,ca,S,R,ta,Ga,Ha,Ia,ka,pa,la;T=v=o=p=0;h.matrixAutoUpdate&&h.update(void 0,!0);f.update(void 0,!1,h);w.multiply(h.projectionMatrix,h.matrixWorldInverse);I[0].set(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);I[1].set(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);I[2].set(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);I[3].set(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);I[4].set(w.n41-w.n31,w.n42-w.n32,w.n43-w.n33,w.n44-w.n34);I[5].set(w.n41+w.n31,w.n42+
  145. w.n32,w.n43+w.n33,w.n44+w.n34);for(c=0;c<6;c++)S=I[c],S.divideScalar(Math.sqrt(S.x*S.x+S.y*S.y+S.z*S.z));S=this.projectObjects(f,h,!0);f=0;for(c=S.length;f<c;f++)if(R=S[f].object,R.visible)if(ta=R.matrixWorld,Ga=R.matrixRotationWorld,Ha=R.materials,Ia=R.overdraw,j=0,R instanceof THREE.Mesh){ka=R.geometry;oa=ka.vertices;pa=ka.faces;ka=ka.faceVertexUvs;ga=0;for(Q=oa.length;ga<Q;ga++)g=b(),g.positionWorld.copy(oa[ga].position),ta.multiplyVector3(g.positionWorld),g.positionScreen.copy(g.positionWorld),
  146. w.multiplyVector4(g.positionScreen),g.positionScreen.x/=g.positionScreen.w,g.positionScreen.y/=g.positionScreen.w,g.visible=g.positionScreen.z>M&&g.positionScreen.z<J;oa=0;for(ga=pa.length;oa<ga;oa++){Q=pa[oa];if(Q instanceof THREE.Face3)if(K=k[Q.a],aa=k[Q.b],N=k[Q.c],K.visible&&aa.visible&&N.visible&&(R.doubleSided||R.flipSided!=(N.positionScreen.x-K.positionScreen.x)*(aa.positionScreen.y-K.positionScreen.y)-(N.positionScreen.y-K.positionScreen.y)*(aa.positionScreen.x-K.positionScreen.x)<0))ca=q[p]=
  147. q[p]||new THREE.RenderableFace3,p++,n=ca,n.v1.copy(K),n.v2.copy(aa),n.v3.copy(N);else continue;else if(Q instanceof THREE.Face4)if(K=k[Q.a],aa=k[Q.b],N=k[Q.c],ca=k[Q.d],K.visible&&aa.visible&&N.visible&&ca.visible&&(R.doubleSided||R.flipSided!=((ca.positionScreen.x-K.positionScreen.x)*(aa.positionScreen.y-K.positionScreen.y)-(ca.positionScreen.y-K.positionScreen.y)*(aa.positionScreen.x-K.positionScreen.x)<0||(aa.positionScreen.x-N.positionScreen.x)*(ca.positionScreen.y-N.positionScreen.y)-(aa.positionScreen.y-
  148. N.positionScreen.y)*(ca.positionScreen.x-N.positionScreen.x)<0)))la=r[o]=r[o]||new THREE.RenderableFace4,o++,n=la,n.v1.copy(K),n.v2.copy(aa),n.v3.copy(N),n.v4.copy(ca);else continue;n.normalWorld.copy(Q.normal);Ga.multiplyVector3(n.normalWorld);n.centroidWorld.copy(Q.centroid);ta.multiplyVector3(n.centroidWorld);n.centroidScreen.copy(n.centroidWorld);w.multiplyVector3(n.centroidScreen);N=Q.vertexNormals;K=0;for(aa=N.length;K<aa;K++)ca=n.vertexNormalsWorld[K],ca.copy(N[K]),Ga.multiplyVector3(ca);K=
  149. 0;for(aa=ka.length;K<aa;K++)if(la=ka[K][oa]){N=0;for(ca=la.length;N<ca;N++)n.uvs[K][N]=la[N]}n.meshMaterials=Ha;n.faceMaterials=Q.materials;n.overdraw=Ia;n.z=n.centroidScreen.z;ea.push(n)}}else if(R instanceof THREE.Line){O.multiply(w,ta);oa=R.geometry.vertices;K=b();K.positionScreen.copy(oa[0].position);O.multiplyVector4(K.positionScreen);ga=1;for(Q=oa.length;ga<Q;ga++)if(K=b(),K.positionScreen.copy(oa[ga].position),O.multiplyVector4(K.positionScreen),aa=k[j-2],L.copy(K.positionScreen),P.copy(aa.positionScreen),
  150. e(L,P))L.multiplyScalar(1/L.w),P.multiplyScalar(1/P.w),ta=G[v]=G[v]||new THREE.RenderableLine,v++,F=ta,F.v1.positionScreen.copy(L),F.v2.positionScreen.copy(P),F.z=Math.max(L.z,P.z),F.materials=R.materials,ea.push(F)}else if(R instanceof THREE.Particle&&(H.set(R.matrixWorld.n14,R.matrixWorld.n24,R.matrixWorld.n34,1),w.multiplyVector4(H),H.z/=H.w,H.z>0&&H.z<1))ta=sa[T]=sa[T]||new THREE.RenderableParticle,T++,D=ta,D.x=H.x/H.w,D.y=H.y/H.w,D.z=H.z,D.rotation=R.rotation.z,D.scale.x=R.scale.x*Math.abs(D.x-
  151. (H.x+h.projectionMatrix.n11)/(H.w+h.projectionMatrix.n14)),D.scale.y=R.scale.y*Math.abs(D.y-(H.y+h.projectionMatrix.n22)/(H.w+h.projectionMatrix.n24)),D.materials=R.materials,ea.push(D);i&&ea.sort(d);return ea}};
  152. 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",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif",
  153. 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",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",
  154. map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",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",
  155. lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",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",
  156. 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}",
  157. 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;",
  158. 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",
  159. 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",
  160. 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",
  161. 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",
  162. 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"};
  163. THREE.UniformsUtils={merge:function(b){var d,e,f,h={};for(d=0;d<b.length;d++)for(e in f=this.clone(b[d]),f)h[e]=f[e];return h},clone:function(b){var d,e,f,h={};for(d in b)for(e in h[d]={},b[d])f=b[d][e],h[d][e]=f instanceof THREE.Color||f instanceof THREE.Vector2||f instanceof THREE.Vector3||f instanceof THREE.Vector4||f instanceof THREE.Matrix4||f instanceof THREE.Texture?f.clone():f instanceof Array?f.slice():f;return h}};
  164. 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",
  165. 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",
  166. 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}}};
  167. 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}"},
  168. 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}"},
  169. 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}",
  170. 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}"},
  171. 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}",
  172. 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}"},
  173. 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]),
  174. 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,
  175. 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,
  176. 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,
  177. 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,
  178. "}"].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,
  179. 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)},
  180. 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,
  181. "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,
  182. 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 = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",
  183. 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,
  184. "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;",
  185. 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,
  186. "void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")}};
  187. THREE.WebGLRenderer=function(b){function d(b,d,e){var f,h,g,i=b.vertices,j=i.length,Ca=b.colors,E=Ca.length,s=b.__vertexArray,k=b.__colorArray,B=b.__sortArray,n=b.__dirtyVertices,p=b.__dirtyColors,q=b.__webglCustomAttributes,o,r;if(q)for(o in q)q[o].offset=0;if(e.sortParticles){va.multiplySelf(e.matrixWorld);for(f=0;f<j;f++)h=i[f].position,Ja.copy(h),va.multiplyVector3(Ja),B[f]=[Ja.z,f];B.sort(function(b,c){return c[0]-b[0]});for(f=0;f<j;f++)h=i[B[f][1]].position,g=f*3,s[g]=h.x,s[g+1]=h.y,s[g+2]=
  188. h.z;for(f=0;f<E;f++)g=f*3,color=Ca[B[f][1]],k[g]=color.r,k[g+1]=color.g,k[g+2]=color.b;if(q)for(o in q){f=q[o];Ca=f.value.length;for(g=0;g<Ca;g++){index=B[g][1];E=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[E]=f.value[index]}else{if(f.boundTo===void 0||f.boundTo==="vertices")r=f.value[index];f.size===2?(f.array[E]=r.x,f.array[E+1]=r.y):f.size===3?f.type==="c"?(f.array[E]=r.r,f.array[E+1]=r.g,f.array[E+2]=r.b):(f.array[E]=r.x,f.array[E+1]=r.y,f.array[E+2]=r.z):(f.array[E]=
  189. r.x,f.array[E+1]=r.y,f.array[E+2]=r.z,f.array[E+3]=r.w)}f.offset+=f.size}}}else{if(n)for(f=0;f<j;f++)h=i[f].position,g=f*3,s[g]=h.x,s[g+1]=h.y,s[g+2]=h.z;if(p)for(f=0;f<E;f++)color=Ca[f],g=f*3,k[g]=color.r,k[g+1]=color.g,k[g+2]=color.b;if(q)for(o in q)if(f=q[o],f.__original.needsUpdate){Ca=f.value.length;for(g=0;g<Ca;g++){E=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[E]=f.value[g]}else{if(f.boundTo===void 0||f.boundTo==="vertices")r=f.value[g];f.size===2?(f.array[E]=
  190. r.x,f.array[E+1]=r.y):f.size===3?f.type==="c"?(f.array[E]=r.r,f.array[E+1]=r.g,f.array[E+2]=r.b):(f.array[E]=r.x,f.array[E+1]=r.y,f.array[E+2]=r.z):(f.array[E]=r.x,f.array[E+1]=r.y,f.array[E+2]=r.z,f.array[E+3]=r.w)}f.offset+=f.size}}}if(n||e.sortParticles)c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer),c.bufferData(c.ARRAY_BUFFER,s,d);if(p||e.sortParticles)c.bindBuffer(c.ARRAY_BUFFER,b.__webglColorBuffer),c.bufferData(c.ARRAY_BUFFER,k,d);if(q)for(o in q)if(f=q[o],f.__original.needsUpdate||e.sortParticles)c.bindBuffer(c.ARRAY_BUFFER,
  191. f.buffer),c.bufferData(c.ARRAY_BUFFER,f.array,d)}function e(b,d,e,f,h){f.program||J.initMaterial(f,d,e,h);if(f.morphTargets&&!h.__webglMorphTargetInfluences){h.__webglMorphTargetInfluences=new Float32Array(J.maxMorphTargets);for(var g=0,i=this.maxMorphTargets;g<i;g++)h.__webglMorphTargetInfluences[g]=0}var g=f.program,i=g.uniforms,j=f.uniforms;g!=Q&&(c.useProgram(g),Q=g);c.uniformMatrix4fv(i.projectionMatrix,!1,Ka);if(e&&(f instanceof THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||
  192. f instanceof THREE.MeshPhongMaterial||f instanceof THREE.LineBasicMaterial||f instanceof THREE.ParticleBasicMaterial||f.fog))if(j.fogColor.value=e.color,e instanceof THREE.Fog)j.fogNear.value=e.near,j.fogFar.value=e.far;else if(e instanceof THREE.FogExp2)j.fogDensity.value=e.density;if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f.lights){var k,E,s,n=0,B=0,p=0,q,o,r,z=Ra,w=z.directional.colors,x=z.directional.positions,D=z.point.colors,F=z.point.positions,v=z.point.distances,
  193. u=0,t=0,e=E=r=0;for(k=d.length;e<k;e++)if(E=d[e],s=E.color,q=E.position,o=E.intensity,r=E.distance,E instanceof THREE.AmbientLight)n+=s.r,B+=s.g,p+=s.b;else if(E instanceof THREE.DirectionalLight)r=u*3,w[r]=s.r*o,w[r+1]=s.g*o,w[r+2]=s.b*o,x[r]=q.x,x[r+1]=q.y,x[r+2]=q.z,u+=1;else if(E instanceof THREE.SpotLight)r=u*3,w[r]=s.r*o,w[r+1]=s.g*o,w[r+2]=s.b*o,s=1/q.length(),x[r]=q.x*s,x[r+1]=q.y*s,x[r+2]=q.z*s,u+=1;else if(E instanceof THREE.PointLight)E=t*3,D[E]=s.r*o,D[E+1]=s.g*o,D[E+2]=s.b*o,F[E]=q.x,
  194. F[E+1]=q.y,F[E+2]=q.z,v[t]=r,t+=1;for(e=u*3;e<w.length;e++)w[e]=0;for(e=t*3;e<D.length;e++)D[e]=0;z.point.length=t;z.directional.length=u;z.ambient[0]=n;z.ambient[1]=B;z.ambient[2]=p;e=Ra;j.enableLighting.value=e.directional.length+e.point.length;j.ambientLightColor.value=e.ambient;j.directionalLightColor.value=e.directional.colors;j.directionalLightDirection.value=e.directional.positions;j.pointLightColor.value=e.point.colors;j.pointLightPosition.value=e.point.positions;j.pointLightDistance.value=
  195. e.point.distances}if(f instanceof THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshPhongMaterial)j.diffuse.value=f.color,j.opacity.value=f.opacity,(j.map.texture=f.map)&&j.offsetRepeat.value.set(f.map.offset.x,f.map.offset.y,f.map.repeat.x,f.map.repeat.y),j.lightMap.texture=f.lightMap,j.envMap.texture=f.envMap,j.reflectivity.value=f.reflectivity,j.refractionRatio.value=f.refractionRatio,j.combine.value=f.combine,j.useRefract.value=f.envMap&&f.envMap.mapping instanceof
  196. THREE.CubeRefractionMapping;if(f instanceof THREE.LineBasicMaterial)j.diffuse.value=f.color,j.opacity.value=f.opacity;else if(f instanceof THREE.ParticleBasicMaterial)j.psColor.value=f.color,j.opacity.value=f.opacity,j.size.value=f.size,j.scale.value=wa.height/2,j.map.texture=f.map;else if(f instanceof THREE.MeshPhongMaterial)j.ambient.value=f.ambient,j.specular.value=f.specular,j.shininess.value=f.shininess;else if(f instanceof THREE.MeshDepthMaterial)j.mNear.value=b.near,j.mFar.value=b.far,j.opacity.value=
  197. f.opacity;else if(f instanceof THREE.MeshNormalMaterial)j.opacity.value=f.opacity;if(h.receiveShadow&&!f._shadowPass&&j.shadowMatrix){for(e=0;e<Na.length;e++)j.shadowMatrix.value[e]=Na[e],j.shadowMap.texture[e]=J.shadowMap[e];j.shadowDarkness.value=J.shadowMapDarkness;j.shadowBias.value=J.shadowMapBias}for(var C in j)if(n=g.uniforms[C])if(k=j[C],B=k.type,e=k.value,B=="i")c.uniform1i(n,e);else if(B=="f")c.uniform1f(n,e);else if(B=="fv1")c.uniform1fv(n,e);else if(B=="fv")c.uniform3fv(n,e);else if(B==
  198. "v2")c.uniform2f(n,e.x,e.y);else if(B=="v3")c.uniform3f(n,e.x,e.y,e.z);else if(B=="v4")c.uniform4f(n,e.x,e.y,e.z,e.w);else if(B=="m4"){if(!k._array)k._array=new Float32Array(16);e.flattenToArray(k._array);c.uniformMatrix4fv(n,!1,k._array)}else if(B=="m4v"){if(!k._array)k._array=new Float32Array(16*e.length);B=0;for(p=e.length;B<p;B++)e[B].flattenToArrayOffset(k._array,B*16);c.uniformMatrix4fv(n,!1,k._array)}else if(B=="c")c.uniform3f(n,e.r,e.g,e.b);else if(B=="t"){if(c.uniform1i(n,e),n=k.texture)if(n.image instanceof
  199. Array&&n.image.length==6){if(k=n,k.image.length==6){if(k.needsUpdate){if(k.__webglInit){c.bindTexture(c.TEXTURE_CUBE_MAP,k.image.__webglTextureCube);for(n=0;n<6;++n)c.texSubImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,0,0,c.RGBA,c.UNSIGNED_BYTE,k.image[n])}else{k.image.__webglTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,k.image.__webglTextureCube);for(n=0;n<6;++n)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,k.image[n]);k.__webglInit=!0}P(c.TEXTURE_CUBE_MAP,
  200. k,k.image[0]);c.bindTexture(c.TEXTURE_CUBE_MAP,null);k.needsUpdate=!1}c.activeTexture(c.TEXTURE0+e);c.bindTexture(c.TEXTURE_CUBE_MAP,k.image.__webglTextureCube)}}else qa(n,e)}else if(B=="tv"){if(!k._array){k._array=[];B=0;for(p=k.texture.length;B<p;B++)k._array[B]=e+B}c.uniform1iv(n,k._array);B=0;for(p=k.texture.length;B<p;B++)(n=k.texture[B])&&qa(n,k._array[B])}c.uniformMatrix4fv(i.modelViewMatrix,!1,h._modelViewMatrixArray);c.uniformMatrix3fv(i.normalMatrix,!1,h._normalMatrixArray);(f instanceof
  201. THREE.MeshShaderMaterial||f instanceof THREE.MeshPhongMaterial||f.envMap)&&i.cameraPosition!==null&&c.uniform3f(i.cameraPosition,b.position.x,b.position.y,b.position.z);(f instanceof THREE.MeshShaderMaterial||f.envMap||f.skinning||h.receiveShadow)&&i.objectMatrix!==null&&c.uniformMatrix4fv(i.objectMatrix,!1,h._objectMatrixArray);(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshShaderMaterial||f.skinning)&&i.viewMatrix!==null&&c.uniformMatrix4fv(i.viewMatrix,
  202. !1,La);if(f instanceof THREE.ShadowVolumeDynamicMaterial)b=j.directionalLightDirection.value,b[0]=-d[1].position.x,b[1]=-d[1].position.y,b[2]=-d[1].position.z,c.uniform3fv(i.directionalLightDirection,b),c.uniformMatrix4fv(i.objectMatrix,!1,h._objectMatrixArray),c.uniformMatrix4fv(i.viewMatrix,!1,La);f.skinning&&(c.uniformMatrix4fv(i.cameraInverseMatrix,!1,La),c.uniformMatrix4fv(i.boneGlobalMatrices,!1,h.boneMatrices));return g}function f(b,d,f,h,g,i){if(h.opacity!=0){var j,b=e(b,d,f,h,i).attributes;
  203. if(!h.morphTargets&&b.position>=0)c.bindBuffer(c.ARRAY_BUFFER,g.__webglVertexBuffer),c.vertexAttribPointer(b.position,3,c.FLOAT,!1,0,0);else if(i.morphTargetBase){d=h.program.attributes;i.morphTargetBase!==-1?(c.bindBuffer(c.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[i.morphTargetBase]),c.vertexAttribPointer(d.position,3,c.FLOAT,!1,0,0)):d.position>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglVertexBuffer),c.vertexAttribPointer(d.position,3,c.FLOAT,!1,0,0));if(i.morphTargetForcedOrder.length)for(var f=
  204. 0,k=i.morphTargetForcedOrder,n=i.morphTargetInfluences;f<h.numSupportedMorphTargets&&f<k.length;)c.bindBuffer(c.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[k[f]]),c.vertexAttribPointer(d["morphTarget"+f],3,c.FLOAT,!1,0,0),i.__webglMorphTargetInfluences[f]=n[k[f]],f++;else{var k=[],E=-1,s=0,n=i.morphTargetInfluences,p,B=n.length,f=0;for(i.morphTargetBase!==-1&&(k[i.morphTargetBase]=!0);f<h.numSupportedMorphTargets;){for(p=0;p<B;p++)!k[p]&&n[p]>E&&(s=p,E=n[s]);c.bindBuffer(c.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[s]);
  205. c.vertexAttribPointer(d["morphTarget"+f],3,c.FLOAT,!1,0,0);i.__webglMorphTargetInfluences[f]=E;k[s]=1;E=-1;f++}}h.program.uniforms.morphTargetInfluences!==null&&c.uniform1fv(h.program.uniforms.morphTargetInfluences,i.__webglMorphTargetInfluences)}if(g.__webglCustomAttributes)for(j in g.__webglCustomAttributes)b[j]>=0&&(d=g.__webglCustomAttributes[j],c.bindBuffer(c.ARRAY_BUFFER,d.buffer),c.vertexAttribPointer(b[j],d.size,c.FLOAT,!1,0,0));b.color>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglColorBuffer),
  206. c.vertexAttribPointer(b.color,3,c.FLOAT,!1,0,0));b.normal>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglNormalBuffer),c.vertexAttribPointer(b.normal,3,c.FLOAT,!1,0,0));b.tangent>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglTangentBuffer),c.vertexAttribPointer(b.tangent,4,c.FLOAT,!1,0,0));b.uv>=0&&(g.__webglUVBuffer?(c.bindBuffer(c.ARRAY_BUFFER,g.__webglUVBuffer),c.vertexAttribPointer(b.uv,2,c.FLOAT,!1,0,0),c.enableVertexAttribArray(b.uv)):c.disableVertexAttribArray(b.uv));b.uv2>=0&&(g.__webglUV2Buffer?(c.bindBuffer(c.ARRAY_BUFFER,
  207. g.__webglUV2Buffer),c.vertexAttribPointer(b.uv2,2,c.FLOAT,!1,0,0),c.enableVertexAttribArray(b.uv2)):c.disableVertexAttribArray(b.uv2));h.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinVertexABuffer),c.vertexAttribPointer(b.skinVertexA,4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),c.vertexAttribPointer(b.skinVertexB,4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),c.vertexAttribPointer(b.skinIndex,
  208. 4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),c.vertexAttribPointer(b.skinWeight,4,c.FLOAT,!1,0,0));i instanceof THREE.Mesh?(h.wireframe?(c.lineWidth(h.wireframeLinewidth),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),c.drawElements(c.LINES,g.__webglLineCount,c.UNSIGNED_SHORT,0)):(c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),c.drawElements(c.TRIANGLES,g.__webglFaceCount,c.UNSIGNED_SHORT,0)),J.data.vertices+=g.__webglFaceCount,J.data.faces+=g.__webglFaceCount/
  209. 3,J.data.drawCalls++):i instanceof THREE.Line?(i=i.type==THREE.LineStrip?c.LINE_STRIP:c.LINES,c.lineWidth(h.linewidth),c.drawArrays(i,0,g.__webglLineCount),J.data.drawCalls++):i instanceof THREE.ParticleSystem?(c.drawArrays(c.POINTS,0,g.__webglParticleCount),J.data.drawCalls++):i instanceof THREE.Ribbon&&(c.drawArrays(c.TRIANGLE_STRIP,0,g.__webglVertexCount),J.data.drawCalls++)}}function h(b,d,e){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=c.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=
  210. c.createBuffer();b.hasPos&&(c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer),c.bufferData(c.ARRAY_BUFFER,b.positionArray,c.DYNAMIC_DRAW),c.enableVertexAttribArray(d.attributes.position),c.vertexAttribPointer(d.attributes.position,3,c.FLOAT,!1,0,0));if(b.hasNormal){c.bindBuffer(c.ARRAY_BUFFER,b.__webglNormalBuffer);if(e==THREE.FlatShading){var f,g,h,i,j,k,n,s,p,B,q=b.count*3;for(B=0;B<q;B+=9)e=b.normalArray,f=e[B],g=e[B+1],h=e[B+2],i=e[B+3],k=e[B+4],s=e[B+5],j=e[B+6],n=e[B+7],p=e[B+8],f=(f+i+j)/
  211. 3,g=(g+k+n)/3,h=(h+s+p)/3,e[B]=f,e[B+1]=g,e[B+2]=h,e[B+3]=f,e[B+4]=g,e[B+5]=h,e[B+6]=f,e[B+7]=g,e[B+8]=h}c.bufferData(c.ARRAY_BUFFER,b.normalArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(d.attributes.normal);c.vertexAttribPointer(d.attributes.normal,3,c.FLOAT,!1,0,0)}c.drawArrays(c.TRIANGLES,0,b.count);b.count=0}function i(b){if(aa!=b.doubleSided)b.doubleSided?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE),aa=b.doubleSided;if(N!=b.flipSided)b.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW),N=b.flipSided}
  212. function g(b){S!=b&&(b?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST),S=b)}function j(b,e,d){R!=b&&(b?c.enable(c.POLYGON_OFFSET_FILL):c.disable(c.POLYGON_OFFSET_FILL),R=b);if(b&&(ta!=e||Ga!=d))c.polygonOffset(e,d),ta=e,Ga=d}function k(b){la[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-b.n14);la[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);la[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);la[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);la[4].set(b.n41-b.n31,b.n42-
  213. b.n32,b.n43-b.n33,b.n44-b.n34);la[5].set(b.n41+b.n31,b.n42+b.n32,b.n43+b.n33,b.n44+b.n34);for(var c,b=0;b<6;b++)c=la[b],c.divideScalar(Math.sqrt(c.x*c.x+c.y*c.y+c.z*c.z))}function n(b){for(var c=b.matrixWorld,e=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),d=0;d<6;d++)if(b=la[d].x*c.n14+la[d].y*c.n24+la[d].z*c.n34+la[d].w,b<=e)return!1;return!0}function p(b,c){b.list[b.count]=c;b.count+=1}function q(b){var c,d,e=b.object,f=b.opaque,g=b.transparent;g.count=0;b=
  214. f.count=0;for(c=e.materials.length;b<c;b++)d=e.materials[b],d.transparent?p(g,d):p(f,d)}function o(b){var c,d,e,f,g=b.object,h=b.buffer,i=b.opaque,j=b.transparent;j.count=0;b=i.count=0;for(e=g.materials.length;b<e;b++)if(c=g.materials[b],c instanceof THREE.MeshFaceMaterial){c=0;for(d=h.materials.length;c<d;c++)(f=h.materials[c])&&(f.transparent?p(j,f):p(i,f))}else(f=c)&&(f.transparent?p(j,f):p(i,f))}function r(b,c){return c.z-b.z}function F(b,d){var j,Qa,Aa,p=0,q,Ba,r,E,s=b.lights;ma||(ma=new THREE.Camera(J.shadowCameraFov,
  215. d.aspect,J.shadowCameraNear,J.shadowCameraFar));j=0;for(Qa=s.length;j<Qa;j++)if(Aa=s[j],Aa instanceof THREE.SpotLight&&Aa.castShadow){J.shadowMap[p]||(J.shadowMap[p]=new THREE.WebGLRenderTarget(J.shadowMapWidth,J.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}));Na[p]||(Na[p]=new THREE.Matrix4);q=J.shadowMap[p];Ba=Na[p];ma.position.copy(Aa.position);ma.target.position.copy(Aa.target.position);ma.update(void 0,!0);b.update(void 0,!1,ma);Ba.set(0.5,
  216. 0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);Ba.multiplySelf(ma.projectionMatrix);Ba.multiplySelf(ma.matrixWorldInverse);ma.matrixWorldInverse.flattenToArray(La);ma.projectionMatrix.flattenToArray(Ka);va.multiply(ma.projectionMatrix,ma.matrixWorldInverse);k(va);J.initWebGLObjects(b);ja(q);c.clearColor(1,1,1,1);J.clear();c.clearColor(ra.r,ra.g,ra.b,Ma);Ba=b.__webglObjects.length;Aa=b.__webglObjectsImmediate.length;for(q=0;q<Ba;q++)r=b.__webglObjects[q],E=r.object,E.visible&&E.castShadow?!(E instanceof
  217. THREE.Mesh)||n(E)?(E.matrixWorld.flattenToArray(E._objectMatrixArray),T(E,ma,!1),r.render=!0):r.render=!1:r.render=!1;g(!0);L(THREE.NormalBlending);for(q=0;q<Ba;q++)if(r=b.__webglObjects[q],r.render)E=r.object,buffer=r.buffer,i(E),r=E.geometry.morphTargets.length?Sa:Oa,f(ma,s,null,r,buffer,E);for(q=0;q<Aa;q++)r=b.__webglObjectsImmediate[q],E=r.object,E.visible&&E.castShadow&&(E.matrixAutoUpdate&&E.matrixWorld.flattenToArray(E._objectMatrixArray),T(E,ma,!1),i(E),program=e(ma,s,null,Oa,E),E.render(function(b){h(b,
  218. program,Oa.shading)}));p++}}function v(b){c.enable(c.POLYGON_OFFSET_FILL);c.polygonOffset(0.1,1);c.enable(c.STENCIL_TEST);c.enable(c.DEPTH_TEST);c.depthMask(!1);c.colorMask(!1,!1,!1,!1);c.stencilFunc(c.ALWAYS,1,255);c.stencilOpSeparate(c.BACK,c.KEEP,c.INCR,c.KEEP);c.stencilOpSeparate(c.FRONT,c.KEEP,c.DECR,c.KEEP);var d,e=b.lights.length,f,g=b.lights,h=[],i,j,k,n,s,p=b.__webglShadowVolumes.length;for(d=0;d<e;d++)if(f=b.lights[d],f instanceof THREE.DirectionalLight&&f.castShadow){h[0]=-f.position.x;
  219. h[1]=-f.position.y;h[2]=-f.position.z;for(s=0;s<p;s++)f=b.__webglShadowVolumes[s].object,i=b.__webglShadowVolumes[s].buffer,j=f.materials[0],j.program||J.initMaterial(j,g,void 0,f),j=j.program,k=j.uniforms,n=j.attributes,Q!==j&&(c.useProgram(j),Q=j,c.uniformMatrix4fv(k.projectionMatrix,!1,Ka),c.uniformMatrix4fv(k.viewMatrix,!1,La),c.uniform3fv(k.directionalLightDirection,h)),f.matrixWorld.flattenToArray(f._objectMatrixArray),c.uniformMatrix4fv(k.objectMatrix,!1,f._objectMatrixArray),c.bindBuffer(c.ARRAY_BUFFER,
  220. i.__webglVertexBuffer),c.vertexAttribPointer(n.position,3,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,i.__webglNormalBuffer),c.vertexAttribPointer(n.normal,3,c.FLOAT,!1,0,0),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webglFaceBuffer),c.cullFace(c.FRONT),c.drawElements(c.TRIANGLES,i.__webglFaceCount,c.UNSIGNED_SHORT,0),c.cullFace(c.BACK),c.drawElements(c.TRIANGLES,i.__webglFaceCount,c.UNSIGNED_SHORT,0)}c.disable(c.POLYGON_OFFSET_FILL);c.colorMask(!0,!0,!0,!0);c.stencilFunc(c.NOTEQUAL,0,255);c.stencilOp(c.KEEP,
  221. c.KEEP,c.KEEP);c.disable(c.DEPTH_TEST);S=ca=-1;Q=y.program;c.useProgram(y.program);c.uniformMatrix4fv(y.projectionLocation,!1,Ka);c.uniform1f(y.darknessLocation,y.darkness);c.bindBuffer(c.ARRAY_BUFFER,y.vertexBuffer);c.vertexAttribPointer(y.vertexLocation,3,c.FLOAT,!1,0,0);c.enableVertexAttribArray(y.vertexLocation);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.blendEquation(c.FUNC_ADD);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y.elementBuffer);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.disable(c.STENCIL_TEST);
  222. c.enable(c.DEPTH_TEST);c.depthMask(K)}function G(b,d){var e,f,g;e=x.attributes;var h=x.uniforms,i=pa/ka,j,k=[],n=ka*0.5,s=pa*0.5,p=!0;c.useProgram(x.program);Q=x.program;S=ca=-1;Ta||(c.enableVertexAttribArray(x.attributes.position),c.enableVertexAttribArray(x.attributes.uv),Ta=!0);c.disable(c.CULL_FACE);c.enable(c.BLEND);c.depthMask(!0);c.bindBuffer(c.ARRAY_BUFFER,x.vertexBuffer);c.vertexAttribPointer(e.position,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(e.uv,2,c.FLOAT,!1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
  223. x.elementBuffer);c.uniformMatrix4fv(h.projectionMatrix,!1,Ka);c.activeTexture(c.TEXTURE0);c.uniform1i(h.map,0);e=0;for(f=b.__webglSprites.length;e<f;e++)g=b.__webglSprites[e],g.useScreenCoordinates?g.z=-g.position.z:(g._modelViewMatrix.multiplyToArray(d.matrixWorldInverse,g.matrixWorld,g._modelViewMatrixArray),g.z=-g._modelViewMatrix.n34);b.__webglSprites.sort(r);e=0;for(f=b.__webglSprites.length;e<f;e++)g=b.__webglSprites[e],g.material===void 0&&g.map&&g.map.image&&g.map.image.width&&(g.useScreenCoordinates?
  224. (c.uniform1i(h.useScreenCoordinates,1),c.uniform3f(h.screenPosition,(g.position.x-n)/n,(s-g.position.y)/s,Math.max(0,Math.min(1,g.position.z)))):(c.uniform1i(h.useScreenCoordinates,0),c.uniform1i(h.affectedByDistance,g.affectedByDistance?1:0),c.uniformMatrix4fv(h.modelViewMatrix,!1,g._modelViewMatrixArray)),j=g.map.image.width/(g.scaleByViewport?pa:1),k[0]=j*i*g.scale.x,k[1]=j*g.scale.y,c.uniform2f(h.uvScale,g.uvScale.x,g.uvScale.y),c.uniform2f(h.uvOffset,g.uvOffset.x,g.uvOffset.y),c.uniform2f(h.alignment,
  225. g.alignment.x,g.alignment.y),c.uniform1f(h.opacity,g.opacity),c.uniform1f(h.rotation,g.rotation),c.uniform2fv(h.scale,k),g.mergeWith3D&&!p?(c.enable(c.DEPTH_TEST),p=!0):!g.mergeWith3D&&p&&(c.disable(c.DEPTH_TEST),p=!1),L(g.blending),qa(g.map,0),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0));c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(K)}function D(b,e){var d,f,g=b.__webglLensFlares.length,h,i,j,k=new THREE.Vector3,n=pa/ka,s=ka*0.5,p=pa*0.5,B=16/pa,q=[B*n,B],r=[1,1,0],o=[1,1],w=z.uniforms;
  226. d=z.attributes;c.useProgram(z.program);Q=z.program;S=ca=-1;Ua||(c.enableVertexAttribArray(z.attributes.vertex),c.enableVertexAttribArray(z.attributes.uv),Ua=!0);c.uniform1i(w.occlusionMap,0);c.uniform1i(w.map,1);c.bindBuffer(c.ARRAY_BUFFER,z.vertexBuffer);c.vertexAttribPointer(d.vertex,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(d.uv,2,c.FLOAT,!1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,z.elementBuffer);c.disable(c.CULL_FACE);c.depthMask(!1);c.activeTexture(c.TEXTURE0);c.bindTexture(c.TEXTURE_2D,z.occlusionTexture);
  227. c.activeTexture(c.TEXTURE1);for(f=0;f<g;f++)if(d=b.__webglLensFlares[f].object,k.set(d.matrixWorld.n14,d.matrixWorld.n24,d.matrixWorld.n34),e.matrixWorldInverse.multiplyVector3(k),e.projectionMatrix.multiplyVector3(k),r[0]=k.x,r[1]=k.y,r[2]=k.z,o[0]=r[0]*s+s,o[1]=r[1]*p+p,z.hasVertexTexture||o[0]>0&&o[0]<ka&&o[1]>0&&o[1]<pa){c.bindTexture(c.TEXTURE_2D,z.tempTexture);c.copyTexImage2D(c.TEXTURE_2D,0,c.RGB,o[0]-8,o[1]-8,16,16,0);c.uniform1i(w.renderType,0);c.uniform2fv(w.scale,q);c.uniform3fv(w.screenPosition,
  228. r);c.disable(c.BLEND);c.enable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.bindTexture(c.TEXTURE_2D,z.occlusionTexture);c.copyTexImage2D(c.TEXTURE_2D,0,c.RGBA,o[0]-8,o[1]-8,16,16,0);c.uniform1i(w.renderType,1);c.disable(c.DEPTH_TEST);c.bindTexture(c.TEXTURE_2D,z.tempTexture);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);d.positionScreen.x=r[0];d.positionScreen.y=r[1];d.positionScreen.z=r[2];d.customUpdateCallback?d.customUpdateCallback(d):d.updateLensFlares();c.uniform1i(w.renderType,
  229. 2);c.enable(c.BLEND);h=0;for(i=d.lensFlares.length;h<i;h++)if(j=d.lensFlares[h],j.opacity>0.001&&j.scale>0.001)r[0]=j.x,r[1]=j.y,r[2]=j.z,B=j.size*j.scale/pa,q[0]=B*n,q[1]=B,c.uniform3fv(w.screenPosition,r),c.uniform2fv(w.scale,q),c.uniform1f(w.rotation,j.rotation),c.uniform1f(w.opacity,j.opacity),L(j.blending),qa(j.texture,1),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(K)}function T(b,c,d){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,
  230. b.matrixWorld,b._modelViewMatrixArray);d&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function sa(b){var c,d,e,f;f=b.__materials;b=0;for(d=f.length;b<d;b++)if(e=f[b],e.attributes)for(c in e.attributes)if(e.attributes[c].needsUpdate)return!0;return!1}function ea(b){var c,d,e,f;f=b.__materials;b=0;for(d=f.length;b<d;b++)if(e=f[b],e.attributes)for(c in e.attributes)e.attributes[c].needsUpdate=!1}function H(b){var e,f,g,h;if(b instanceof THREE.Mesh){f=b.geometry;
  231. for(e in f.geometryGroups)if(g=f.geometryGroups[e],h=sa(g),f.__dirtyVertices||f.__dirtyMorphTargets||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents||h){h=g;var i=b,j=c.DYNAMIC_DRAW;if(h.__inittedArrays){var k=void 0,n=void 0,p=void 0,s=void 0,q=p=void 0,B=void 0,r=void 0,o=void 0,w=void 0,z=void 0,x=void 0,D=void 0,F=void 0,v=void 0,u=void 0,y=void 0,G=void 0,t=s=o=s=r=B=void 0,C=void 0,m=C=t=B=void 0,J=void 0,K=m=C=t=p=p=q=o=s=m=C=t=J=m=C=t=J=m=C=t=void 0,H=
  232. 0,I=0,Q=0,R=0,L=0,M=0,U=0,N=0,da=0,A=0,fa=0,C=t=0,ha=h.__vertexArray,$=h.__uvArray,aa=h.__uv2Array,P=h.__normalArray,V=h.__tangentArray,ia=h.__colorArray,W=h.__skinVertexAArray,X=h.__skinVertexBArray,Y=h.__skinIndexArray,Z=h.__skinWeightArray,ca=h.__morphTargetsArrays,T=h.__webglCustomAttributes,m=void 0,O=h.__faceArray,S=h.__lineArray,la=h.__needsSmoothNormals,z=h.__vertexColorType,w=h.__uvType,x=h.__normalType,na=i.geometry,ka=na.__dirtyVertices,ma=na.__dirtyElements,ga=na.__dirtyUvs,oa=na.__dirtyNormals,
  233. pa=na.__dirtyTangents,qa=na.__dirtyColors,ra=na.__dirtyMorphTargets,ja=na.vertices,ta=h.faces,ua=na.faces,va=na.faceVertexUvs[0],wa=na.faceVertexUvs[1],Da=na.skinVerticesA,Ea=na.skinVerticesB,Fa=na.skinIndices,ya=na.skinWeights,za=i instanceof THREE.ShadowVolume?na.edgeFaces:void 0,xa=na.morphTargets;if(T)for(K in T)T[K].offset=0,T[K].offsetSrc=0;k=0;for(n=ta.length;k<n;k++)if(p=ta[k],s=ua[p],va&&(D=va[p]),wa&&(F=wa[p]),p=s.vertexNormals,q=s.normal,B=s.vertexColors,r=s.color,o=s.vertexTangents,s instanceof
  234. THREE.Face3){if(ka)v=ja[s.a].position,u=ja[s.b].position,y=ja[s.c].position,ha[I]=v.x,ha[I+1]=v.y,ha[I+2]=v.z,ha[I+3]=u.x,ha[I+4]=u.y,ha[I+5]=u.z,ha[I+6]=y.x,ha[I+7]=y.y,ha[I+8]=y.z,I+=9;if(T)for(K in T)if(m=T[K],m.__original.needsUpdate)t=m.offset,C=m.offsetSrc,m.size===1?(m.boundTo===void 0||m.boundTo==="vertices"?(m.array[t+0]=m.value[s.a],m.array[t+1]=m.value[s.b],m.array[t+2]=m.value[s.c]):m.boundTo==="faces"?(m.array[t+0]=m.value[C],m.array[t+1]=m.value[C],m.array[t+2]=m.value[C],m.offsetSrc++):
  235. m.boundTo==="faceVertices"&&(m.array[t+0]=m.value[C+0],m.array[t+1]=m.value[C+1],m.array[t+2]=m.value[C+2],m.offsetSrc+=3),m.offset+=3):(m.boundTo===void 0||m.boundTo==="vertices"?(v=m.value[s.a],u=m.value[s.b],y=m.value[s.c]):m.boundTo==="faces"?(v=m.value[C],u=m.value[C],y=m.value[C],m.offsetSrc++):m.boundTo==="faceVertices"&&(v=m.value[C+0],u=m.value[C+1],y=m.value[C+2],m.offsetSrc+=3),m.size===2?(m.array[t+0]=v.x,m.array[t+1]=v.y,m.array[t+2]=u.x,m.array[t+3]=u.y,m.array[t+4]=y.x,m.array[t+5]=
  236. y.y,m.offset+=6):m.size===3?(m.type==="c"?(m.array[t+0]=v.r,m.array[t+1]=v.g,m.array[t+2]=v.b,m.array[t+3]=u.r,m.array[t+4]=u.g,m.array[t+5]=u.b,m.array[t+6]=y.r,m.array[t+7]=y.g,m.array[t+8]=y.b):(m.array[t+0]=v.x,m.array[t+1]=v.y,m.array[t+2]=v.z,m.array[t+3]=u.x,m.array[t+4]=u.y,m.array[t+5]=u.z,m.array[t+6]=y.x,m.array[t+7]=y.y,m.array[t+8]=y.z),m.offset+=9):(m.array[t+0]=v.x,m.array[t+1]=v.y,m.array[t+2]=v.z,m.array[t+3]=v.w,m.array[t+4]=u.x,m.array[t+5]=u.y,m.array[t+6]=u.z,m.array[t+7]=u.w,
  237. m.array[t+8]=y.x,m.array[t+9]=y.y,m.array[t+10]=y.z,m.array[t+11]=y.w,m.offset+=12));if(ra){t=0;for(C=xa.length;t<C;t++)v=xa[t].vertices[s.a].position,u=xa[t].vertices[s.b].position,y=xa[t].vertices[s.c].position,m=ca[t],m[fa+0]=v.x,m[fa+1]=v.y,m[fa+2]=v.z,m[fa+3]=u.x,m[fa+4]=u.y,m[fa+5]=u.z,m[fa+6]=y.x,m[fa+7]=y.y,m[fa+8]=y.z;fa+=9}if(ya.length)t=ya[s.a],C=ya[s.b],m=ya[s.c],Z[A]=t.x,Z[A+1]=t.y,Z[A+2]=t.z,Z[A+3]=t.w,Z[A+4]=C.x,Z[A+5]=C.y,Z[A+6]=C.z,Z[A+7]=C.w,Z[A+8]=m.x,Z[A+9]=m.y,Z[A+10]=m.z,Z[A+
  238. 11]=m.w,t=Fa[s.a],C=Fa[s.b],m=Fa[s.c],Y[A]=t.x,Y[A+1]=t.y,Y[A+2]=t.z,Y[A+3]=t.w,Y[A+4]=C.x,Y[A+5]=C.y,Y[A+6]=C.z,Y[A+7]=C.w,Y[A+8]=m.x,Y[A+9]=m.y,Y[A+10]=m.z,Y[A+11]=m.w,t=Da[s.a],C=Da[s.b],m=Da[s.c],W[A]=t.x,W[A+1]=t.y,W[A+2]=t.z,W[A+3]=1,W[A+4]=C.x,W[A+5]=C.y,W[A+6]=C.z,W[A+7]=1,W[A+8]=m.x,W[A+9]=m.y,W[A+10]=m.z,W[A+11]=1,t=Ea[s.a],C=Ea[s.b],m=Ea[s.c],X[A]=t.x,X[A+1]=t.y,X[A+2]=t.z,X[A+3]=1,X[A+4]=C.x,X[A+5]=C.y,X[A+6]=C.z,X[A+7]=1,X[A+8]=m.x,X[A+9]=m.y,X[A+10]=m.z,X[A+11]=1,A+=12;if(qa&&z)B.length==
  239. 3&&z==THREE.VertexColors?(s=B[0],t=B[1],C=B[2]):C=t=s=r,ia[da]=s.r,ia[da+1]=s.g,ia[da+2]=s.b,ia[da+3]=t.r,ia[da+4]=t.g,ia[da+5]=t.b,ia[da+6]=C.r,ia[da+7]=C.g,ia[da+8]=C.b,da+=9;if(pa&&na.hasTangents)B=o[0],r=o[1],s=o[2],V[U]=B.x,V[U+1]=B.y,V[U+2]=B.z,V[U+3]=B.w,V[U+4]=r.x,V[U+5]=r.y,V[U+6]=r.z,V[U+7]=r.w,V[U+8]=s.x,V[U+9]=s.y,V[U+10]=s.z,V[U+11]=s.w,U+=12;if(oa&&x)if(p.length==3&&la)for(o=0;o<3;o++)q=p[o],P[M]=q.x,P[M+1]=q.y,P[M+2]=q.z,M+=3;else for(o=0;o<3;o++)P[M]=q.x,P[M+1]=q.y,P[M+2]=q.z,M+=3;
  240. if(ga&&D!==void 0&&w)for(o=0;o<3;o++)p=D[o],$[Q]=p.u,$[Q+1]=p.v,Q+=2;if(ga&&F!==void 0&&w)for(o=0;o<3;o++)p=F[o],aa[R]=p.u,aa[R+1]=p.v,R+=2;ma&&(O[L]=H,O[L+1]=H+1,O[L+2]=H+2,L+=3,S[N]=H,S[N+1]=H+1,S[N+2]=H,S[N+3]=H+2,S[N+4]=H+1,S[N+5]=H+2,N+=6,H+=3)}else if(s instanceof THREE.Face4){if(ka)v=ja[s.a].position,u=ja[s.b].position,y=ja[s.c].position,G=ja[s.d].position,ha[I]=v.x,ha[I+1]=v.y,ha[I+2]=v.z,ha[I+3]=u.x,ha[I+4]=u.y,ha[I+5]=u.z,ha[I+6]=y.x,ha[I+7]=y.y,ha[I+8]=y.z,ha[I+9]=G.x,ha[I+10]=G.y,ha[I+
  241. 11]=G.z,I+=12;if(T)for(K in T)if(m=T[K],m.__original.needsUpdate)t=m.offset,C=m.offsetSrc,m.size===1?(m.boundTo===void 0||m.boundTo==="vertices"?(m.array[t+0]=m.value[s.a],m.array[t+1]=m.value[s.b],m.array[t+2]=m.value[s.c],m.array[t+3]=m.value[s.d]):m.boundTo==="faces"?(m.array[t+0]=m.value[C],m.array[t+1]=m.value[C],m.array[t+2]=m.value[C],m.array[t+3]=m.value[C],m.offsetSrc++):m.boundTo==="faceVertices"&&(m.array[t+0]=m.value[C+0],m.array[t+1]=m.value[C+1],m.array[t+2]=m.value[C+2],m.array[t+3]=
  242. m.value[C+3],m.offsetSrc+=4),m.offset+=4):(m.boundTo===void 0||m.boundTo==="vertices"?(v=m.value[s.a],u=m.value[s.b],y=m.value[s.c],G=m.value[s.d]):m.boundTo==="faces"?(v=m.value[C],u=m.value[C],y=m.value[C],G=m.value[C],m.offsetSrc++):m.boundTo==="faceVertices"&&(v=m.value[C+0],u=m.value[C+1],y=m.value[C+2],G=m.value[C+3],m.offsetSrc+=4),m.size===2?(m.array[t+0]=v.x,m.array[t+1]=v.y,m.array[t+2]=u.x,m.array[t+3]=u.y,m.array[t+4]=y.x,m.array[t+5]=y.y,m.array[t+6]=G.x,m.array[t+7]=G.y,m.offset+=8):
  243. m.size===3?(m.type==="c"?(m.array[t+0]=v.r,m.array[t+1]=v.g,m.array[t+2]=v.b,m.array[t+3]=u.r,m.array[t+4]=u.g,m.array[t+5]=u.b,m.array[t+6]=y.r,m.array[t+7]=y.g,m.array[t+8]=y.b,m.array[t+9]=G.r,m.array[t+10]=G.g,m.array[t+11]=G.b):(m.array[t+0]=v.x,m.array[t+1]=v.y,m.array[t+2]=v.z,m.array[t+3]=u.x,m.array[t+4]=u.y,m.array[t+5]=u.z,m.array[t+6]=y.x,m.array[t+7]=y.y,m.array[t+8]=y.z,m.array[t+9]=G.x,m.array[t+10]=G.y,m.array[t+11]=G.z),m.offset+=12):(m.array[t+0]=v.x,m.array[t+1]=v.y,m.array[t+2]=
  244. v.z,m.array[t+3]=v.w,m.array[t+4]=u.x,m.array[t+5]=u.y,m.array[t+6]=u.z,m.array[t+7]=u.w,m.array[t+8]=y.x,m.array[t+9]=y.y,m.array[t+10]=y.z,m.array[t+11]=y.w,m.array[t+12]=G.x,m.array[t+13]=G.y,m.array[t+14]=G.z,m.array[t+15]=G.w,m.offset+=16));if(ra){t=0;for(C=xa.length;t<C;t++)v=xa[t].vertices[s.a].position,u=xa[t].vertices[s.b].position,y=xa[t].vertices[s.c].position,G=xa[t].vertices[s.d].position,m=ca[t],m[fa+0]=v.x,m[fa+1]=v.y,m[fa+2]=v.z,m[fa+3]=u.x,m[fa+4]=u.y,m[fa+5]=u.z,m[fa+6]=y.x,m[fa+
  245. 7]=y.y,m[fa+8]=y.z,m[fa+9]=G.x,m[fa+10]=G.y,m[fa+11]=G.z;fa+=12}if(ya.length)t=ya[s.a],C=ya[s.b],m=ya[s.c],J=ya[s.d],Z[A]=t.x,Z[A+1]=t.y,Z[A+2]=t.z,Z[A+3]=t.w,Z[A+4]=C.x,Z[A+5]=C.y,Z[A+6]=C.z,Z[A+7]=C.w,Z[A+8]=m.x,Z[A+9]=m.y,Z[A+10]=m.z,Z[A+11]=m.w,Z[A+12]=J.x,Z[A+13]=J.y,Z[A+14]=J.z,Z[A+15]=J.w,t=Fa[s.a],C=Fa[s.b],m=Fa[s.c],J=Fa[s.d],Y[A]=t.x,Y[A+1]=t.y,Y[A+2]=t.z,Y[A+3]=t.w,Y[A+4]=C.x,Y[A+5]=C.y,Y[A+6]=C.z,Y[A+7]=C.w,Y[A+8]=m.x,Y[A+9]=m.y,Y[A+10]=m.z,Y[A+11]=m.w,Y[A+12]=J.x,Y[A+13]=J.y,Y[A+14]=
  246. J.z,Y[A+15]=J.w,t=Da[s.a],C=Da[s.b],m=Da[s.c],J=Da[s.d],W[A]=t.x,W[A+1]=t.y,W[A+2]=t.z,W[A+3]=1,W[A+4]=C.x,W[A+5]=C.y,W[A+6]=C.z,W[A+7]=1,W[A+8]=m.x,W[A+9]=m.y,W[A+10]=m.z,W[A+11]=1,W[A+12]=J.x,W[A+13]=J.y,W[A+14]=J.z,W[A+15]=1,t=Ea[s.a],C=Ea[s.b],m=Ea[s.c],s=Ea[s.d],X[A]=t.x,X[A+1]=t.y,X[A+2]=t.z,X[A+3]=1,X[A+4]=C.x,X[A+5]=C.y,X[A+6]=C.z,X[A+7]=1,X[A+8]=m.x,X[A+9]=m.y,X[A+10]=m.z,X[A+11]=1,X[A+12]=s.x,X[A+13]=s.y,X[A+14]=s.z,X[A+15]=1,A+=16;if(qa&&z)B.length==4&&z==THREE.VertexColors?(s=B[0],t=B[1],
  247. C=B[2],B=B[3]):B=C=t=s=r,ia[da]=s.r,ia[da+1]=s.g,ia[da+2]=s.b,ia[da+3]=t.r,ia[da+4]=t.g,ia[da+5]=t.b,ia[da+6]=C.r,ia[da+7]=C.g,ia[da+8]=C.b,ia[da+9]=B.r,ia[da+10]=B.g,ia[da+11]=B.b,da+=12;if(pa&&na.hasTangents)B=o[0],r=o[1],s=o[2],o=o[3],V[U]=B.x,V[U+1]=B.y,V[U+2]=B.z,V[U+3]=B.w,V[U+4]=r.x,V[U+5]=r.y,V[U+6]=r.z,V[U+7]=r.w,V[U+8]=s.x,V[U+9]=s.y,V[U+10]=s.z,V[U+11]=s.w,V[U+12]=o.x,V[U+13]=o.y,V[U+14]=o.z,V[U+15]=o.w,U+=16;if(oa&&x)if(p.length==4&&la)for(o=0;o<4;o++)q=p[o],P[M]=q.x,P[M+1]=q.y,P[M+2]=
  248. q.z,M+=3;else for(o=0;o<4;o++)P[M]=q.x,P[M+1]=q.y,P[M+2]=q.z,M+=3;if(ga&&D!==void 0&&w)for(o=0;o<4;o++)p=D[o],$[Q]=p.u,$[Q+1]=p.v,Q+=2;if(ga&&F!==void 0&&w)for(o=0;o<4;o++)p=F[o],aa[R]=p.u,aa[R+1]=p.v,R+=2;ma&&(O[L]=H,O[L+1]=H+1,O[L+2]=H+3,O[L+3]=H+1,O[L+4]=H+2,O[L+5]=H+3,L+=6,S[N]=H,S[N+1]=H+1,S[N+2]=H,S[N+3]=H+3,S[N+4]=H+1,S[N+5]=H+2,S[N+6]=H+2,S[N+7]=H+3,N+=8,H+=4)}if(za){k=0;for(n=za.length;k<n;k++)O[L]=za[k].a,O[L+1]=za[k].b,O[L+2]=za[k].c,O[L+3]=za[k].a,O[L+4]=za[k].c,O[L+5]=za[k].d,L+=6}ka&&
  249. (c.bindBuffer(c.ARRAY_BUFFER,h.__webglVertexBuffer),c.bufferData(c.ARRAY_BUFFER,ha,j));if(T)for(K in T)m=T[K],m.__original.needsUpdate&&(c.bindBuffer(c.ARRAY_BUFFER,m.buffer),c.bufferData(c.ARRAY_BUFFER,m.array,j));if(ra){t=0;for(C=xa.length;t<C;t++)c.bindBuffer(c.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[t]),c.bufferData(c.ARRAY_BUFFER,ca[t],j)}qa&&da>0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglColorBuffer),c.bufferData(c.ARRAY_BUFFER,ia,j));oa&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglNormalBuffer),c.bufferData(c.ARRAY_BUFFER,
  250. P,j));pa&&na.hasTangents&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglTangentBuffer),c.bufferData(c.ARRAY_BUFFER,V,j));ga&&Q>0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglUVBuffer),c.bufferData(c.ARRAY_BUFFER,$,j));ga&&R>0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglUV2Buffer),c.bufferData(c.ARRAY_BUFFER,aa,j));ma&&(c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,O,j),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,S,j));A>
  251. 0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinVertexABuffer),c.bufferData(c.ARRAY_BUFFER,W,j),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),c.bufferData(c.ARRAY_BUFFER,X,j),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),c.bufferData(c.ARRAY_BUFFER,Y,j),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),c.bufferData(c.ARRAY_BUFFER,Z,j));i.dynamic||(delete h.__inittedArrays,delete h.__colorArray,delete h.__normalArray,delete h.__tangentArray,delete h.__uvArray,delete h.__uv2Array,
  252. delete h.__faceArray,delete h.__vertexArray,delete h.__lineArray,delete h.__skinVertexAArray,delete h.__skinVertexBArray,delete h.__skinIndexArray,delete h.__skinWeightArray)}}f.__dirtyVertices=!1;f.__dirtyMorphTargets=!1;f.__dirtyElements=!1;f.__dirtyUvs=!1;f.__dirtyNormals=!1;f.__dirtyTangents=!1;f.__dirtyColors=!1;ea(g)}else if(b instanceof THREE.Ribbon){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=c.DYNAMIC_DRAW;w=b.vertices;h=b.colors;z=w.length;i=h.length;x=b.__vertexArray;j=b.__colorArray;
  253. D=b.__dirtyColors;if(b.__dirtyVertices){for(k=0;k<z;k++)n=w[k].position,g=k*3,x[g]=n.x,x[g+1]=n.y,x[g+2]=n.z;c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,x,e)}if(D){for(k=0;k<i;k++)color=h[k],g=k*3,j[g]=color.r,j[g+1]=color.g,j[g+2]=color.b;c.bindBuffer(c.ARRAY_BUFFER,b.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,j,e)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(b instanceof THREE.Line){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=c.DYNAMIC_DRAW;
  254. w=b.vertices;h=b.colors;z=w.length;i=h.length;x=b.__vertexArray;j=b.__colorArray;D=b.__dirtyColors;if(b.__dirtyVertices){for(k=0;k<z;k++)n=w[k].position,g=k*3,x[g]=n.x,x[g+1]=n.y,x[g+2]=n.z;c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,x,e)}if(D){for(k=0;k<i;k++)color=h[k],g=k*3,j[g]=color.r,j[g+1]=color.g,j[g+2]=color.b;c.bindBuffer(c.ARRAY_BUFFER,b.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,j,e)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(b instanceof THREE.ParticleSystem)f=
  255. b.geometry,h=sa(f),(f.__dirtyVertices||f.__dirtyColors||b.sortParticles||h)&&d(f,c.DYNAMIC_DRAW,b),f.__dirtyVertices=!1,f.__dirtyColors=!1,ea(f)}function w(b,c){var d;for(d=b.length-1;d>=0;d--)b[d].object==c&&b.splice(d,1)}function O(b){function c(b){var f=[];d=0;for(e=b.length;d<e;d++)b[d]==void 0?f.push("undefined"):f.push(b[d].id);return f.join("_")}var d,e,f,h,g,i,j,k,s={},n=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};f=0;for(h=b.faces.length;f<h;f++)g=b.faces[f],i=g.materials,
  256. j=c(i),s[j]==void 0&&(s[j]={hash:j,counter:0}),k=s[j].hash+"_"+s[j].counter,b.geometryGroups[k]==void 0&&(b.geometryGroups[k]={faces:[],materials:i,vertices:0,numMorphTargets:n}),g=g instanceof THREE.Face3?3:4,b.geometryGroups[k].vertices+g>65535&&(s[j].counter+=1,k=s[j].hash+"_"+s[j].counter,b.geometryGroups[k]==void 0&&(b.geometryGroups[k]={faces:[],materials:i,vertices:0,numMorphTargets:n})),b.geometryGroups[k].faces.push(f),b.geometryGroups[k].vertices+=g}function I(b,c,d){b.push({buffer:c,object:d,
  257. opaque:{list:[],count:0},transparent:{list:[],count:0}})}function L(b){if(b!=ca){switch(b){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE);break;case THREE.SubtractiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.SRC_COLOR);break;default:c.blendEquationSeparate(c.FUNC_ADD,c.FUNC_ADD),c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA)}ca=
  258. b}}function P(b,d,e){(e.width&e.width-1)==0&&(e.height&e.height-1)==0?(c.texParameteri(b,c.TEXTURE_WRAP_S,M(d.wrapS)),c.texParameteri(b,c.TEXTURE_WRAP_T,M(d.wrapT)),c.texParameteri(b,c.TEXTURE_MAG_FILTER,M(d.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,M(d.minFilter)),c.generateMipmap(b)):(c.texParameteri(b,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(b,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(b,c.TEXTURE_MAG_FILTER,ua(d.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,ua(d.minFilter)))}
  259. function qa(b,d){if(b.needsUpdate){if(!b.__webglInit)b.__webglTexture=c.createTexture(),b.__webglInit=!0;c.bindTexture(c.TEXTURE_2D,b.__webglTexture);b.image.data?c.texImage2D(c.TEXTURE_2D,0,M(b.format),b.image.width,b.image.height,0,M(b.format),c.UNSIGNED_BYTE,b.image.data):c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,b.image);P(c.TEXTURE_2D,b,b.image);c.bindTexture(c.TEXTURE_2D,null);b.needsUpdate=!1}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_2D,b.__webglTexture)}function ja(b){if(b&&
  260. !b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=c.createFramebuffer();b.__webglRenderbuffer=c.createRenderbuffer();b.__webglTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,b.__webglTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,M(b.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,M(b.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,M(b.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
  261. M(b.minFilter));c.texImage2D(c.TEXTURE_2D,0,M(b.format),b.width,b.height,0,M(b.format),M(b.type),null);c.bindRenderbuffer(c.RENDERBUFFER,b.__webglRenderbuffer);c.bindFramebuffer(c.FRAMEBUFFER,b.__webglFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,b.width,b.height),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,b.__webglRenderbuffer)):
  262. b.depthBuffer&&b.stencilBuffer?(c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_STENCIL,b.width,b.height),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_STENCIL_ATTACHMENT,c.RENDERBUFFER,b.__webglRenderbuffer)):c.renderbufferStorage(c.RENDERBUFFER,c.RGBA4,b.width,b.height);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var d,e;b?(d=b.__webglFramebuffer,e=b.width,b=b.height):(d=null,e=ka,b=pa);d!=oa&&(c.bindFramebuffer(c.FRAMEBUFFER,d),
  263. c.viewport(Ha,Ia,e,b),oa=d)}function $(b,d){var e;b=="fragment"?e=c.createShader(c.FRAGMENT_SHADER):b=="vertex"&&(e=c.createShader(c.VERTEX_SHADER));c.shaderSource(e,d);c.compileShader(e);if(!c.getShaderParameter(e,c.COMPILE_STATUS))return console.error(c.getShaderInfoLog(e)),console.error(d),null;return e}function ua(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;default:return c.LINEAR}}function M(b){switch(b){case THREE.RepeatWrapping:return c.REPEAT;
  264. case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE;
  265. case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var J=this,c,ga=[],Q=null,
  266. oa=null,K=!0,aa=null,N=null,ca=null,S=null,R=null,ta=null,Ga=null,Ha=0,Ia=0,ka=0,pa=0,la=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],va=new THREE.Matrix4,Ka=new Float32Array(16),La=new Float32Array(16),Ja=new THREE.Vector4,Ra={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},wa=b.canvas!==void 0?b.canvas:document.createElement("canvas"),Pa=b.stencil!==void 0?
  267. b.stencil:!0,u=b.antialias!==void 0?b.antialias:!1,ra=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),Ma=b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=wa;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=
  268. !0;var ma,Na=[],b=THREE.ShaderLib.depthRGBA,Va=THREE.UniformsUtils.clone(b.uniforms),Oa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Va}),Sa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Va,morphTargets:!0});Oa._shadowPass=!0;Sa._shadowPass=!0;try{if(!(c=wa.getContext("experimental-webgl",{antialias:u,stencil:Pa})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+c.getParameter(c.VERSION)+
  269. " | "+c.getParameter(c.VENDOR)+" | "+c.getParameter(c.RENDERER)+" | "+c.getParameter(c.SHADING_LANGUAGE_VERSION))}catch(Xa){console.error(Xa)}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);c.clearColor(ra.r,ra.g,ra.b,Ma);this.context=c;var Wa=c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(Pa){var y={};y.vertices=
  270. new Float32Array(12);y.faces=new Uint16Array(6);y.darkness=0.5;y.vertices[0]=-20;y.vertices[1]=-20;y.vertices[2]=-1;y.vertices[3]=20;y.vertices[4]=-20;y.vertices[5]=-1;y.vertices[6]=20;y.vertices[7]=20;y.vertices[8]=-1;y.vertices[9]=-20;y.vertices[10]=20;y.vertices[11]=-1;y.faces[0]=0;y.faces[1]=1;y.faces[2]=2;y.faces[3]=0;y.faces[4]=2;y.faces[5]=3;y.vertexBuffer=c.createBuffer();y.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,y.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,y.vertices,c.STATIC_DRAW);
  271. c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,y.faces,c.STATIC_DRAW);y.program=c.createProgram();c.attachShader(y.program,$("fragment",THREE.ShaderLib.shadowPost.fragmentShader));c.attachShader(y.program,$("vertex",THREE.ShaderLib.shadowPost.vertexShader));c.linkProgram(y.program);y.vertexLocation=c.getAttribLocation(y.program,"position");y.projectionLocation=c.getUniformLocation(y.program,"projectionMatrix");y.darknessLocation=c.getUniformLocation(y.program,
  272. "darkness")}var z={};z.vertices=new Float32Array(16);z.faces=new Uint16Array(6);u=0;z.vertices[u++]=-1;z.vertices[u++]=-1;z.vertices[u++]=0;z.vertices[u++]=0;z.vertices[u++]=1;z.vertices[u++]=-1;z.vertices[u++]=1;z.vertices[u++]=0;z.vertices[u++]=1;z.vertices[u++]=1;z.vertices[u++]=1;z.vertices[u++]=1;z.vertices[u++]=-1;z.vertices[u++]=1;z.vertices[u++]=0;z.vertices[u++]=1;u=0;z.faces[u++]=0;z.faces[u++]=1;z.faces[u++]=2;z.faces[u++]=0;z.faces[u++]=2;z.faces[u++]=3;z.vertexBuffer=c.createBuffer();
  273. z.elementBuffer=c.createBuffer();z.tempTexture=c.createTexture();z.occlusionTexture=c.createTexture();c.bindBuffer(c.ARRAY_BUFFER,z.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,z.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,z.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,z.faces,c.STATIC_DRAW);c.bindTexture(c.TEXTURE_2D,z.tempTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGB,16,16,0,c.RGB,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,
  274. c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);c.bindTexture(c.TEXTURE_2D,z.occlusionTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,16,16,0,c.RGBA,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
  275. c.NEAREST);c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0?(z.hasVertexTexture=!1,z.program=c.createProgram(),c.attachShader(z.program,$("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),c.attachShader(z.program,$("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(z.hasVertexTexture=!0,z.program=c.createProgram(),c.attachShader(z.program,$("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),c.attachShader(z.program,$("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));
  276. c.linkProgram(z.program);z.attributes={};z.uniforms={};z.attributes.vertex=c.getAttribLocation(z.program,"position");z.attributes.uv=c.getAttribLocation(z.program,"UV");z.uniforms.renderType=c.getUniformLocation(z.program,"renderType");z.uniforms.map=c.getUniformLocation(z.program,"map");z.uniforms.occlusionMap=c.getUniformLocation(z.program,"occlusionMap");z.uniforms.opacity=c.getUniformLocation(z.program,"opacity");z.uniforms.scale=c.getUniformLocation(z.program,"scale");z.uniforms.rotation=c.getUniformLocation(z.program,
  277. "rotation");z.uniforms.screenPosition=c.getUniformLocation(z.program,"screenPosition");var Ua=!1,x={};x.vertices=new Float32Array(16);x.faces=new Uint16Array(6);u=0;x.vertices[u++]=-1;x.vertices[u++]=-1;x.vertices[u++]=0;x.vertices[u++]=1;x.vertices[u++]=1;x.vertices[u++]=-1;x.vertices[u++]=1;x.vertices[u++]=1;x.vertices[u++]=1;x.vertices[u++]=1;x.vertices[u++]=1;x.vertices[u++]=0;x.vertices[u++]=-1;x.vertices[u++]=1;x.vertices[u++]=0;u=x.vertices[u++]=0;x.faces[u++]=0;x.faces[u++]=1;x.faces[u++]=
  278. 2;x.faces[u++]=0;x.faces[u++]=2;x.faces[u++]=3;x.vertexBuffer=c.createBuffer();x.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,x.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,x.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,x.faces,c.STATIC_DRAW);x.program=c.createProgram();c.attachShader(x.program,$("fragment",THREE.ShaderLib.sprite.fragmentShader));c.attachShader(x.program,$("vertex",THREE.ShaderLib.sprite.vertexShader));
  279. c.linkProgram(x.program);x.attributes={};x.uniforms={};x.attributes.position=c.getAttribLocation(x.program,"position");x.attributes.uv=c.getAttribLocation(x.program,"uv");x.uniforms.uvOffset=c.getUniformLocation(x.program,"uvOffset");x.uniforms.uvScale=c.getUniformLocation(x.program,"uvScale");x.uniforms.rotation=c.getUniformLocation(x.program,"rotation");x.uniforms.scale=c.getUniformLocation(x.program,"scale");x.uniforms.alignment=c.getUniformLocation(x.program,"alignment");x.uniforms.map=c.getUniformLocation(x.program,
  280. "map");x.uniforms.opacity=c.getUniformLocation(x.program,"opacity");x.uniforms.useScreenCoordinates=c.getUniformLocation(x.program,"useScreenCoordinates");x.uniforms.affectedByDistance=c.getUniformLocation(x.program,"affectedByDistance");x.uniforms.screenPosition=c.getUniformLocation(x.program,"screenPosition");x.uniforms.modelViewMatrix=c.getUniformLocation(x.program,"modelViewMatrix");x.uniforms.projectionMatrix=c.getUniformLocation(x.program,"projectionMatrix");var Ta=!1;this.setSize=function(b,
  281. c){wa.width=b;wa.height=c;this.setViewport(0,0,wa.width,wa.height)};this.setViewport=function(b,d,e,f){Ha=b;Ia=d;ka=e;pa=f;c.viewport(Ha,Ia,ka,pa)};this.setScissor=function(b,d,e,f){c.scissor(b,d,e,f)};this.enableScissorTest=function(b){b?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){K=b;c.depthMask(b)};this.setClearColorHex=function(b,d){ra.setHex(b);Ma=d;c.clearColor(ra.r,ra.g,ra.b,Ma)};this.setClearColor=function(b,d){ra.copy(b);Ma=d;c.clearColor(ra.r,
  282. ra.g,ra.b,Ma)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT|c.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){y.darkness=b};this.getContext=function(){return c};this.initMaterial=function(b,d,e,f){var h,g,i;b instanceof THREE.MeshDepthMaterial?i="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?i="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?i="normal":b instanceof THREE.MeshBasicMaterial?i="basic":b instanceof THREE.MeshLambertMaterial?i="lambert":
  283. b instanceof THREE.MeshPhongMaterial?i="phong":b instanceof THREE.LineBasicMaterial?i="basic":b instanceof THREE.ParticleBasicMaterial&&(i="particle_basic");if(i){var j=THREE.ShaderLib[i];b.uniforms=THREE.UniformsUtils.clone(j.uniforms);b.vertexShader=j.vertexShader;b.fragmentShader=j.fragmentShader}var k,n,s;k=s=j=0;for(n=d.length;k<n;k++)g=d[k],g instanceof THREE.SpotLight&&s++,g instanceof THREE.DirectionalLight&&s++,g instanceof THREE.PointLight&&j++;j+s<=4?k=s:(k=Math.ceil(4*s/(j+s)),j=4-k);
  284. g={directional:k,point:j};j=s=0;for(k=d.length;j<k;j++)n=d[j],n instanceof THREE.SpotLight&&n.castShadow&&s++;var p=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)p=f.bones.length;var o;a:{k=b.fragmentShader;n=b.vertexShader;var j=b.uniforms,d=b.attributes,e={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:e,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:g.directional,maxPointLights:g.point,
  285. maxBones:p,shadowMapEnabled:this.shadowMapEnabled&&f.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:s,alphaTest:b.alphaTest},q,f=[];i?f.push(i):(f.push(k),f.push(n));for(q in e)f.push(q),f.push(e[q]);i=f.join();q=0;for(f=ga.length;q<f;q++)if(ga[q].code==i){o=ga[q].program;break a}q=c.createProgram();f=[Wa?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+e.maxDirLights,"#define MAX_POINT_LIGHTS "+e.maxPointLights,
  286. "#define MAX_SHADOWS "+e.maxShadows,"#define MAX_BONES "+e.maxBones,e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.vertexColors?"#define USE_COLOR":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapSoft?"#define SHADOWMAP_SOFT":"",e.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");
  287. g=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+e.maxDirLights,"#define MAX_POINT_LIGHTS "+e.maxPointLights,"#define MAX_SHADOWS "+e.maxShadows,e.alphaTest?"#define ALPHATEST "+e.alphaTest:"",e.fog?"#define USE_FOG":"",e.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.vertexColors?"#define USE_COLOR":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapSoft?"#define SHADOWMAP_SOFT":
  288. "",e.shadowMapSoft?"#define SHADOWMAP_WIDTH "+e.shadowMapWidth.toFixed(1):"",e.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+e.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");c.attachShader(q,$("fragment",g+k));c.attachShader(q,$("vertex",f+n));c.linkProgram(q);c.getProgramParameter(q,c.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+c.getProgramParameter(q,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");q.uniforms=
  289. {};q.attributes={};var r,f=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(r in j)f.push(r);r=f;f=0;for(j=r.length;f<j;f++)k=r[f],q.uniforms[k]=c.getUniformLocation(q,k);f=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(r=0;r<e.maxMorphTargets;r++)f.push("morphTarget"+r);for(o in d)f.push(o);o=f;r=0;for(d=o.length;r<d;r++)e=
  290. o[r],q.attributes[e]=c.getAttribLocation(q,e);ga.push({program:q,code:i});o=q}b.program=o;o=b.program.attributes;o.position>=0&&c.enableVertexAttribArray(o.position);o.color>=0&&c.enableVertexAttribArray(o.color);o.normal>=0&&c.enableVertexAttribArray(o.normal);o.tangent>=0&&c.enableVertexAttribArray(o.tangent);b.skinning&&o.skinVertexA>=0&&o.skinVertexB>=0&&o.skinIndex>=0&&o.skinWeight>=0&&(c.enableVertexAttribArray(o.skinVertexA),c.enableVertexAttribArray(o.skinVertexB),c.enableVertexAttribArray(o.skinIndex),
  291. c.enableVertexAttribArray(o.skinWeight));if(b.attributes)for(h in b.attributes)o[h]!==void 0&&o[h]>=0&&c.enableVertexAttribArray(o[h]);if(b.morphTargets)b.numSupportedMorphTargets=0,o.morphTarget0>=0&&(c.enableVertexAttribArray(o.morphTarget0),b.numSupportedMorphTargets++),o.morphTarget1>=0&&(c.enableVertexAttribArray(o.morphTarget1),b.numSupportedMorphTargets++),o.morphTarget2>=0&&(c.enableVertexAttribArray(o.morphTarget2),b.numSupportedMorphTargets++),o.morphTarget3>=0&&(c.enableVertexAttribArray(o.morphTarget3),
  292. b.numSupportedMorphTargets++),o.morphTarget4>=0&&(c.enableVertexAttribArray(o.morphTarget4),b.numSupportedMorphTargets++),o.morphTarget5>=0&&(c.enableVertexAttribArray(o.morphTarget5),b.numSupportedMorphTargets++),o.morphTarget6>=0&&(c.enableVertexAttribArray(o.morphTarget6),b.numSupportedMorphTargets++),o.morphTarget7>=0&&(c.enableVertexAttribArray(o.morphTarget7),b.numSupportedMorphTargets++)};this.render=function(b,d,p,w){var u,z,y,x,H,E,s,I,B=b.lights,K=b.fog;this.shadowMapEnabled&&F(b,d);J.data.vertices=
  293. 0;J.data.faces=0;J.data.drawCalls=0;d.matrixAutoUpdate&&d.update(void 0,!0);b.update(void 0,!1,d);d.matrixWorldInverse.flattenToArray(La);d.projectionMatrix.flattenToArray(Ka);va.multiply(d.projectionMatrix,d.matrixWorldInverse);k(va);this.initWebGLObjects(b);ja(p);(this.autoClear||w)&&this.clear();H=b.__webglObjects.length;for(w=0;w<H;w++)if(u=b.__webglObjects[w],s=u.object,s.visible)if(!(s instanceof THREE.Mesh)||n(s)){if(s.matrixWorld.flattenToArray(s._objectMatrixArray),T(s,d,!0),o(u),u.render=
  294. !0,this.sortObjects)u.object.renderDepth?u.z=u.object.renderDepth:(Ja.copy(s.position),va.multiplyVector3(Ja),u.z=Ja.z)}else u.render=!1;else u.render=!1;this.sortObjects&&b.__webglObjects.sort(r);E=b.__webglObjectsImmediate.length;for(w=0;w<E;w++)u=b.__webglObjectsImmediate[w],s=u.object,s.visible&&(s.matrixAutoUpdate&&s.matrixWorld.flattenToArray(s._objectMatrixArray),T(s,d,!0),q(u));if(b.overrideMaterial){g(b.overrideMaterial.depthTest);L(b.overrideMaterial.blending);for(w=0;w<H;w++)if(u=b.__webglObjects[w],
  295. u.render)s=u.object,I=u.buffer,i(s),f(d,B,K,b.overrideMaterial,I,s);for(w=0;w<E;w++)u=b.__webglObjectsImmediate[w],s=u.object,s.visible&&(i(s),z=e(d,B,K,b.overrideMaterial,s),s.render(function(c){h(c,z,b.overrideMaterial.shading)}))}else{L(THREE.NormalBlending);for(w=0;w<H;w++)if(u=b.__webglObjects[w],u.render){s=u.object;I=u.buffer;y=u.opaque;i(s);for(u=0;u<y.count;u++)x=y.list[u],g(x.depthTest),j(x.polygonOffset,x.polygonOffsetFactor,x.polygonOffsetUnits),f(d,B,K,x,I,s)}for(w=0;w<E;w++)if(u=b.__webglObjectsImmediate[w],
  296. s=u.object,s.visible){y=u.opaque;i(s);for(u=0;u<y.count;u++)x=y.list[u],g(x.depthTest),j(x.polygonOffset,x.polygonOffsetFactor,x.polygonOffsetUnits),z=e(d,B,K,x,s),s.render(function(b){h(b,z,x.shading)})}for(w=0;w<H;w++)if(u=b.__webglObjects[w],u.render){s=u.object;I=u.buffer;y=u.transparent;i(s);for(u=0;u<y.count;u++)x=y.list[u],L(x.blending),g(x.depthTest),j(x.polygonOffset,x.polygonOffsetFactor,x.polygonOffsetUnits),f(d,B,K,x,I,s)}for(w=0;w<E;w++)if(u=b.__webglObjectsImmediate[w],s=u.object,s.visible){y=
  297. u.transparent;i(s);for(u=0;u<y.count;u++)x=y.list[u],L(x.blending),g(x.depthTest),j(x.polygonOffset,x.polygonOffsetFactor,x.polygonOffsetUnits),z=e(d,B,K,x,s),s.render(function(b){h(b,z,x.shading)})}}b.__webglSprites.length&&G(b,d);Pa&&b.__webglShadowVolumes.length&&b.lights.length&&v(b);b.__webglLensFlares.length&&D(b,d);p&&p.minFilter!==THREE.NearestFilter&&p.minFilter!==THREE.LinearFilter&&(c.bindTexture(c.TEXTURE_2D,p.__webglTexture),c.generateMipmap(c.TEXTURE_2D),c.bindTexture(c.TEXTURE_2D,null))};
  298. this.initWebGLObjects=function(b){if(!b.__webglObjects)b.__webglObjects=[],b.__webglObjectsImmediate=[],b.__webglShadowVolumes=[],b.__webglLensFlares=[],b.__webglSprites=[];for(;b.__objectsAdded.length;){var d=b.__objectsAdded[0],e=b,f=void 0,g=void 0,h=void 0;if(d._modelViewMatrix==void 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);
  299. if(d instanceof THREE.Mesh)for(f in g=d.geometry,g.geometryGroups==void 0&&O(g),g.geometryGroups){h=g.geometryGroups[f];if(!h.__webglVertexBuffer){var i=h;i.__webglVertexBuffer=c.createBuffer();i.__webglNormalBuffer=c.createBuffer();i.__webglTangentBuffer=c.createBuffer();i.__webglColorBuffer=c.createBuffer();i.__webglUVBuffer=c.createBuffer();i.__webglUV2Buffer=c.createBuffer();i.__webglSkinVertexABuffer=c.createBuffer();i.__webglSkinVertexBBuffer=c.createBuffer();i.__webglSkinIndicesBuffer=c.createBuffer();
  300. i.__webglSkinWeightsBuffer=c.createBuffer();i.__webglFaceBuffer=c.createBuffer();i.__webglLineBuffer=c.createBuffer();if(i.numMorphTargets){var j=void 0,k=void 0;i.__webglMorphTargetsBuffers=[];j=0;for(k=i.numMorphTargets;j<k;j++)i.__webglMorphTargetsBuffers.push(c.createBuffer())}for(var i=h,j=d,o=void 0,n=void 0,p=void 0,q=p=void 0,r=void 0,u=void 0,x=u=k=0,v=p=n=void 0,y=v=n=o=void 0,p=void 0,q=j.geometry,r=q.faces,v=i.faces,o=0,n=v.length;o<n;o++)p=v[o],p=r[p],p instanceof THREE.Face3?(k+=3,u+=
  301. 1,x+=3):p instanceof THREE.Face4&&(k+=4,u+=2,x+=4);for(var o=i,n=j,z=v=r=void 0,D=void 0,z=void 0,p=[],r=0,v=n.materials.length;r<v;r++)if(z=n.materials[r],z instanceof THREE.MeshFaceMaterial){z=0;for(l=o.materials.length;z<l;z++)(D=o.materials[z])&&p.push(D)}else(D=z)&&p.push(D);o=p;i.__materials=o;a:{r=n=void 0;v=o.length;for(n=0;n<v;n++)if(r=o[n],r.map||r.lightMap||r instanceof THREE.MeshShaderMaterial){n=!0;break a}n=!1}a:{v=r=void 0;p=o.length;for(r=0;r<p;r++)if(v=o[r],!(v instanceof THREE.MeshBasicMaterial&&
  302. !v.envMap||v instanceof THREE.MeshDepthMaterial)){v=v&&v.shading!=void 0&&v.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}v=!1}a:{p=r=void 0;z=o.length;for(r=0;r<z;r++)if(p=o[r],p.vertexColors){p=p.vertexColors;break a}p=!1}i.__vertexArray=new Float32Array(k*3);if(v)i.__normalArray=new Float32Array(k*3);if(q.hasTangents)i.__tangentArray=new Float32Array(k*4);if(p)i.__colorArray=new Float32Array(k*3);if(n){if(q.faceUvs.length>0||q.faceVertexUvs.length>0)i.__uvArray=new Float32Array(k*
  303. 2);if(q.faceUvs.length>1||q.faceVertexUvs.length>1)i.__uv2Array=new Float32Array(k*2)}if(j.geometry.skinWeights.length&&j.geometry.skinIndices.length)i.__skinVertexAArray=new Float32Array(k*4),i.__skinVertexBArray=new Float32Array(k*4),i.__skinIndexArray=new Float32Array(k*4),i.__skinWeightArray=new Float32Array(k*4);i.__faceArray=new Uint16Array(u*3+(j.geometry.edgeFaces?j.geometry.edgeFaces.length*6:0));i.__lineArray=new Uint16Array(x*2);if(i.numMorphTargets){i.__morphTargetsArrays=[];q=0;for(r=
  304. i.numMorphTargets;q<r;q++)i.__morphTargetsArrays.push(new Float32Array(k*3))}i.__needsSmoothNormals=v==THREE.SmoothShading;i.__uvType=n;i.__vertexColorType=p;i.__normalType=v;i.__webglFaceCount=u*3+(j.geometry.edgeFaces?j.geometry.edgeFaces.length*6:0);i.__webglLineCount=x*2;q=0;for(r=o.length;q<r;q++)if(n=o[q],n.attributes){if(i.__webglCustomAttributes===void 0)i.__webglCustomAttributes={};for(a in n.attributes){p=n.attributes[a];v={};for(y in p)v[y]=p[y];if(!v.__webglInitialized||v.createUniqueBuffers)v.__webglInitialized=
  305. !0,u=1,v.type==="v2"?u=2:v.type==="v3"?u=3:v.type==="v4"?u=4:v.type==="c"&&(u=3),v.size=u,v.array=new Float32Array(k*u),v.buffer=c.createBuffer(),v.buffer.belongsToAttribute=a,p.needsUpdate=!0,v.__original=p;i.__webglCustomAttributes[a]=v}}i.__inittedArrays=!0;g.__dirtyVertices=!0;g.__dirtyMorphTargets=!0;g.__dirtyElements=!0;g.__dirtyUvs=!0;g.__dirtyNormals=!0;g.__dirtyTangents=!0;g.__dirtyColors=!0}d instanceof THREE.ShadowVolume?I(e.__webglShadowVolumes,h,d):I(e.__webglObjects,h,d)}else if(d instanceof
  306. THREE.LensFlare)I(e.__webglLensFlares,void 0,d);else if(d instanceof THREE.Ribbon){g=d.geometry;if(!g.__webglVertexBuffer)f=g,f.__webglVertexBuffer=c.createBuffer(),f.__webglColorBuffer=c.createBuffer(),f=g,h=f.vertices.length,f.__vertexArray=new Float32Array(h*3),f.__colorArray=new Float32Array(h*3),f.__webglVertexCount=h,g.__dirtyVertices=!0,g.__dirtyColors=!0;I(e.__webglObjects,g,d)}else if(d instanceof THREE.Line){g=d.geometry;if(!g.__webglVertexBuffer)f=g,f.__webglVertexBuffer=c.createBuffer(),
  307. f.__webglColorBuffer=c.createBuffer(),f=g,h=f.vertices.length,f.__vertexArray=new Float32Array(h*3),f.__colorArray=new Float32Array(h*3),f.__webglLineCount=h,g.__dirtyVertices=!0,g.__dirtyColors=!0;I(e.__webglObjects,g,d)}else if(d instanceof THREE.ParticleSystem){g=d.geometry;if(!g.__webglVertexBuffer){f=g;f.__webglVertexBuffer=c.createBuffer();f.__webglColorBuffer=c.createBuffer();f=g;h=d;i=f.vertices.length;f.__vertexArray=new Float32Array(i*3);f.__colorArray=new Float32Array(i*3);f.__sortArray=
  308. [];f.__webglParticleCount=i;f.__materials=h.materials;y=k=j=void 0;j=0;for(k=h.materials.length;j<k;j++)if(y=h.materials[j],y.attributes){if(f.__webglCustomAttributes===void 0)f.__webglCustomAttributes={};for(a in y.attributes){originalAttribute=y.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===
  309. "v3"?size=3:attribute.type==="v4"?size=4:attribute.type==="c"&&(size=3),attribute.size=size,attribute.array=new Float32Array(i*size),attribute.buffer=c.createBuffer(),attribute.buffer.belongsToAttribute=a,originalAttribute.needsUpdate=!0,attribute.__original=originalAttribute;f.__webglCustomAttributes[a]=attribute}}g.__dirtyVertices=!0;g.__dirtyColors=!0}I(e.__webglObjects,g,d)}else THREE.MarchingCubes!==void 0&&d instanceof THREE.MarchingCubes?e.__webglObjectsImmediate.push({object:d,opaque:{list:[],
  310. 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.ShadowVolume)w(d.__webglShadowVolumes,e);else if(e instanceof THREE.Mesh||e instanceof THREE.ParticleSystem||e instanceof THREE.Ribbon||e instanceof THREE.Line)w(d.__webglObjects,e);else if(e instanceof THREE.Sprite){d=d.__webglSprites;g=void 0;for(g=d.length-1;g>=0;g--)d[g]==e&&d.splice(g,1)}else e instanceof
  311. THREE.LensFlare?w(d.__webglLensFlares,e):e instanceof THREE.MarchingCubes&&w(d.__webglObjectsImmediate,e);b.__objectsRemoved.splice(0,1)}d=0;for(e=b.__webglObjects.length;d<e;d++)H(b.__webglObjects[d].object,b);d=0;for(e=b.__webglShadowVolumes.length;d<e;d++)H(b.__webglShadowVolumes[d].object,b);d=0;for(e=b.__webglLensFlares.length;d<e;d++)H(b.__webglLensFlares[d].object,b)};this.setFaceCulling=function(b,d){b?(!d||d=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW),b=="back"?c.cullFace(c.BACK):b=="front"?
  312. c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK),c.enable(c.CULL_FACE)):c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return Wa}};
  313. THREE.WebGLRenderTarget=function(b,d,e){this.width=b;this.height=d;e=e||{};this.wrapS=e.wrapS!==void 0?e.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=e.wrapT!==void 0?e.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=e.magFilter!==void 0?e.magFilter:THREE.LinearFilter;this.minFilter=e.minFilter!==void 0?e.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=e.format!==void 0?e.format:THREE.RGBAFormat;this.type=e.type!==void 0?e.type:
  314. THREE.UnsignedByteType;this.depthBuffer=e.depthBuffer!==void 0?e.depthBuffer:!0;this.stencilBuffer=e.stencilBuffer!==void 0?e.stencilBuffer:!0};
粤ICP备19079148号