ThreeWebGL.js 144 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. // ThreeWebGL.js r41/ROME - 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={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,g,i,h,j,o;if(e==0)f=g=i=0;else switch(h=Math.floor(b*6),j=b*6-h,b=e*(1-d),o=e*(1-d*j),d=e*(1-d*(1-j)),h){case 1:f=o;g=e;i=b;break;case 2:f=b;g=e;i=d;break;case 3:f=b;g=o;i=e;break;case 4:f=d;g=b;i=e;break;case 5:f=e;g=b;i=o;break;case 6:case 0:f=e,g=d,i=b}this.setRGB(f,
  4. g,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={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},divideScalar:function(b){b?
  6. (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={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=b.z-d.z;return this},subSelf:function(b){this.x-=
  9. 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.y;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)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*
  10. 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*b.z-this.z*b.y,this.z*b.x-this.x*b.z,this.x*
  11. 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()<1.0E-4}};
  12. THREE.Vector4=function(b,d,e,f){this.set(b||0,d||0,e||0,f||1)};
  13. THREE.Vector4.prototype={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},subSelf:function(b){this.x-=
  14. 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={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;f=e.position.clone().subSelf(b).dot(d);b=b.clone().addSelf(d.clone().multiplyScalar(f));return e.position.distanceTo(b)}function e(b,d,e,f){var f=f.clone().subSelf(d),e=e.clone().subSelf(d),
  17. g=b.clone().subSelf(d),b=f.dot(f),d=f.dot(e),f=f.dot(g),h=e.dot(e),e=e.dot(g),g=1/(b*h-d*d),h=(h*f-d*e)*g,b=(b*e-d*f)*g;return h>0&&b>0&&h+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 g,i,h,j,o,m,n,q,t,r,D=b.geometry,
  18. x=D.vertices,z=[],f=0;for(g=D.faces.length;f<g;f++)if(i=D.faces[f],t=this.origin.clone(),r=this.direction.clone(),m=b.matrixWorld,h=m.multiplyVector3(x[i.a].position.clone()),j=m.multiplyVector3(x[i.b].position.clone()),o=m.multiplyVector3(x[i.c].position.clone()),m=i instanceof THREE.Face4?m.multiplyVector3(x[i.d].position.clone()):null,n=b.matrixRotationWorld.multiplyVector3(i.normal.clone()),q=r.dot(n),b.doubleSided||(b.flipSided?q>0:q<0))if(n=n.dot((new THREE.Vector3).sub(h,t))/q,t=t.addSelf(r.multiplyScalar(n)),
  19. i instanceof THREE.Face3)e(t,h,j,o)&&(i={distance:this.origin.distanceTo(t),point:t,face:i,object:b},z.push(i));else if(i instanceof THREE.Face4&&(e(t,h,j,m)||e(t,j,o,m)))i={distance:this.origin.distanceTo(t),point:t,face:i,object:b},z.push(i);return z}else return[]}};
  20. THREE.Rectangle=function(){function b(){i=f-d;h=g-e}var d,e,f,g,i,h,j=!0;this.getX=function(){return d};this.getY=function(){return e};this.getWidth=function(){return i};this.getHeight=function(){return h};this.getLeft=function(){return d};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(h,i,n,q){j=!1;d=h;e=i;f=n;g=q;b()};this.addPoint=function(h,i){j?(j=!1,d=h,e=i,f=h,g=i):(d=d<h?d:h,e=e<i?e:i,f=f>h?f:h,g=g>i?g:i);b()};this.add3Points=
  21. function(h,i,n,q,t,r){j?(j=!1,d=h<n?h<t?h:t:n<t?n:t,e=i<q?i<r?i:r:q<r?q:r,f=h>n?h>t?h:t:n>t?n:t,g=i>q?i>r?i:r:q>r?q:r):(d=h<n?h<t?h<d?h:d:t<d?t:d:n<t?n<d?n:d:t<d?t: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=h>n?h>t?h>f?h:f:t>f?t:f:n>t?n>f?n:f:t>f?t:f,g=i>q?i>r?i>g?i:g:r>g?r:g:q>r?q>g?q:g:r>g?r:g);b()};this.addRectangle=function(h){j?(j=!1,d=h.getLeft(),e=h.getTop(),f=h.getRight(),g=h.getBottom()):(d=d<h.getLeft()?d:h.getLeft(),e=e<h.getTop()?e:h.getTop(),f=f>h.getRight()?f:h.getRight(),g=g>
  22. h.getBottom()?g:h.getBottom());b()};this.inflate=function(h){d-=h;e-=h;f+=h;g+=h;b()};this.minSelf=function(h){d=d>h.getLeft()?d:h.getLeft();e=e>h.getTop()?e:h.getTop();f=f<h.getRight()?f:h.getRight();g=g<h.getBottom()?g:h.getBottom();b()};this.instersects=function(b){return Math.min(f,b.getRight())-Math.max(d,b.getLeft())>=0&&Math.min(g,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){j=!0;g=f=e=d=0;b()};this.isEmpty=function(){return j}};THREE.Matrix3=function(){this.m=[]};
  23. THREE.Matrix3.prototype={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,g,i,h,j,o,m,n,q,t,r,D,x){this.set(b||1,d||0,e||0,f||0,g||0,i||1,h||0,j||0,o||0,m||0,n||1,q||0,t||0,r||0,D||0,x||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
  24. THREE.Matrix4.prototype={set:function(b,d,e,f,g,i,h,j,o,m,n,q,t,r,D,x){this.n11=b;this.n12=d;this.n13=e;this.n14=f;this.n21=g;this.n22=i;this.n23=h;this.n24=j;this.n31=o;this.n32=m;this.n33=n;this.n34=q;this.n41=t;this.n42=r;this.n43=D;this.n44=x;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,d,e){var f=THREE.Matrix4.__v1,
  25. g=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());g.cross(i,f).normalize();this.n11=f.x;this.n12=g.x;this.n13=i.x;this.n21=f.y;this.n22=g.y;this.n23=i.y;this.n31=f.z;this.n32=g.z;this.n33=i.z;return this},multiplyVector3:function(b){var d=b.x,e=b.y,f=b.z,g=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)*g;b.y=(this.n21*d+this.n22*e+this.n23*
  26. f+this.n24)*g;b.z=(this.n31*d+this.n32*e+this.n33*f+this.n34)*g;return b},multiplyVector4:function(b){var d=b.x,e=b.y,f=b.z,g=b.w;b.x=this.n11*d+this.n12*e+this.n13*f+this.n14*g;b.y=this.n21*d+this.n22*e+this.n23*f+this.n24*g;b.z=this.n31*d+this.n32*e+this.n33*f+this.n34*g;b.w=this.n41*d+this.n42*e+this.n43*f+this.n44*g;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+e*this.n32+f*this.n33;b.normalize();
  27. 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,g=b.n13,i=b.n14,h=b.n21,j=b.n22,o=b.n23,m=b.n24,n=b.n31,q=b.n32,t=b.n33,r=b.n34,D=b.n41,x=b.n42,z=b.n43,B=b.n44,ea=d.n11,M=d.n12,N=d.n13,F=d.n14,y=d.n21,Y=d.n22,
  28. C=d.n23,Z=d.n24,K=d.n31,ka=d.n32,S=d.n33,P=d.n34;this.n11=e*ea+f*y+g*K;this.n12=e*M+f*Y+g*ka;this.n13=e*N+f*C+g*S;this.n14=e*F+f*Z+g*P+i;this.n21=h*ea+j*y+o*K;this.n22=h*M+j*Y+o*ka;this.n23=h*N+j*C+o*S;this.n24=h*F+j*Z+o*P+m;this.n31=n*ea+q*y+t*K;this.n32=n*M+q*Y+t*ka;this.n33=n*N+q*C+t*S;this.n34=n*F+q*Z+t*P+r;this.n41=D*ea+x*y+z*K;this.n42=D*M+x*Y+z*ka;this.n43=D*N+x*C+z*S;this.n44=D*F+x*Z+z*P+B;return this},multiplyToArray:function(b,d,e){this.multiply(b,d);e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;
  29. 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*=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=
  30. this.n11,d=this.n12,e=this.n13,f=this.n14,g=this.n21,i=this.n22,h=this.n23,j=this.n24,o=this.n31,m=this.n32,n=this.n33,q=this.n34,t=this.n41,r=this.n42,D=this.n43,x=this.n44;return f*h*m*t-e*j*m*t-f*i*n*t+d*j*n*t+e*i*q*t-d*h*q*t-f*h*o*r+e*j*o*r+f*g*n*r-b*j*n*r-e*g*q*r+b*h*q*r+f*i*o*D-d*j*o*D-f*g*m*D+b*j*m*D+d*g*q*D-b*i*q*D-e*i*o*x+d*h*o*x+e*g*m*x-b*h*m*x-d*g*n*x+b*i*n*x},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=
  31. 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=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;
  32. 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]=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]=
  33. 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]=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,
  34. 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,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),g=1-e,i=b.x,h=b.y,j=b.z,o=g*i,m=g*h;this.set(o*
  35. i+e,o*h-f*j,o*j+f*h,0,o*h+f*j,m*h+e,m*j-f*i,0,o*j-f*h,m*j+f*i,g*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=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;
  36. 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){var d=b.x,e=b.y,f=b.z,b=Math.cos(d),d=Math.sin(d),g=Math.cos(e),e=Math.sin(e),i=Math.cos(f),f=Math.sin(f),h=b*e,j=d*e;this.n11=g*i;this.n12=-g*f;this.n13=e;this.n21=j*i+b*f;this.n22=-j*f+b*i;this.n23=-d*g;this.n31=-h*i+d*f;this.n32=h*f+d*i;this.n33=b*g;return this},
  37. setRotationFromQuaternion:function(b){var d=b.x,e=b.y,f=b.z,g=b.w,i=d+d,h=e+e,j=f+f,b=d*i,o=d*h;d*=j;var m=e*h;e*=j;f*=j;i*=g;h*=g;g*=j;this.n11=1-(m+f);this.n12=o-g;this.n13=d+h;this.n21=o+g;this.n22=1-(b+f);this.n23=e-i;this.n31=d-h;this.n32=e+i;this.n33=1-(b+m);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=
  38. b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,d){var e=1/d.x,f=1/d.y,g=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*g;this.n23=b.n23*g;this.n33=b.n33*g}};
  39. THREE.Matrix4.makeInvert=function(b,d){var e=b.n11,f=b.n12,g=b.n13,i=b.n14,h=b.n21,j=b.n22,o=b.n23,m=b.n24,n=b.n31,q=b.n32,t=b.n33,r=b.n34,D=b.n41,x=b.n42,z=b.n43,B=b.n44;d===void 0&&(d=new THREE.Matrix4);d.n11=o*r*x-m*t*x+m*q*z-j*r*z-o*q*B+j*t*B;d.n12=i*t*x-g*r*x-i*q*z+f*r*z+g*q*B-f*t*B;d.n13=g*m*x-i*o*x+i*j*z-f*m*z-g*j*B+f*o*B;d.n14=i*o*q-g*m*q-i*j*t+f*m*t+g*j*r-f*o*r;d.n21=m*t*D-o*r*D-m*n*z+h*r*z+o*n*B-h*t*B;d.n22=g*r*D-i*t*D+i*n*z-e*r*z-g*n*B+e*t*B;d.n23=i*o*D-g*m*D-i*h*z+e*m*z+g*h*B-e*o*B;d.n24=
  40. g*m*n-i*o*n+i*h*t-e*m*t-g*h*r+e*o*r;d.n31=j*r*D-m*q*D+m*n*x-h*r*x-j*n*B+h*q*B;d.n32=i*q*D-f*r*D-i*n*x+e*r*x+f*n*B-e*q*B;d.n33=g*m*D-i*j*D+i*h*x-e*m*x-f*h*B+e*j*B;d.n34=i*j*n-f*m*n-i*h*q+e*m*q+f*h*r-e*j*r;d.n41=o*q*D-j*t*D-o*n*x+h*t*x+j*n*z-h*q*z;d.n42=f*t*D-g*q*D+g*n*x-e*t*x-f*n*z+e*q*z;d.n43=g*j*D-f*o*D-g*h*x+e*o*x+f*h*z-e*j*z;d.n44=f*o*n-g*j*n+g*h*q-e*o*q-f*h*t+e*j*t;d.multiplyScalar(1/b.determinant());return d};
  41. THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,e=d.m,f=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,i=b.n32*b.n21-b.n31*b.n22,h=-b.n33*b.n12+b.n32*b.n13,j=b.n33*b.n11-b.n31*b.n13,o=-b.n32*b.n11+b.n31*b.n12,m=b.n23*b.n12-b.n22*b.n13,n=-b.n23*b.n11+b.n21*b.n13,q=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*h+b.n31*m;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*g;e[2]=b*i;e[3]=b*h;e[4]=b*j;e[5]=b*o;e[6]=b*m;e[7]=b*n;e[8]=b*q;return d};
  42. THREE.Matrix4.makeFrustum=function(b,d,e,f,g,i){var h;h=new THREE.Matrix4;h.n11=2*g/(d-b);h.n12=0;h.n13=(d+b)/(d-b);h.n14=0;h.n21=0;h.n22=2*g/(f-e);h.n23=(f+e)/(f-e);h.n24=0;h.n31=0;h.n32=0;h.n33=-(i+g)/(i-g);h.n34=-2*i*g/(i-g);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(b,d,e,f){var g,b=e*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*d,b*d,g,b,e,f)};
  43. THREE.Matrix4.makeOrtho=function(b,d,e,f,g,i){var h,j,o,m;h=new THREE.Matrix4;j=d-b;o=e-f;m=i-g;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-((d+b)/j);h.n21=0;h.n22=2/o;h.n23=0;h.n24=-((e+f)/o);h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-((i+g)/m);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
  44. 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.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;this.useQuaternion=
  45. !1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this._vector=new THREE.Vector3;this.name=""};
  46. THREE.Object3D.prototype={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)===
  47. -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,g;e=0;for(f=this.children.length;e<f;e++){g=this.children[e];if(g.name===b)return g;if(d&&(g=g.getChildByName(b,d),g!==void 0))return g}},updateMatrix:function(){this.matrix.setPosition(this.position);
  48. this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);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),this.matrixRotationWorld.extractRotation(this.matrixWorld,
  49. 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)};
  50. THREE.Quaternion.prototype={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,g=b.z*d,b=Math.cos(f),f=Math.sin(f),d=Math.cos(-g),g=Math.sin(-g),i=Math.cos(e),e=Math.sin(e),h=b*d,j=f*g;this.w=h*i-j*e;this.x=h*e+j*i;this.y=f*d*i+b*g*e;this.z=b*g*i-f*d*e;return this},setFromAxisAngle:function(b,d){var e=d/2,f=Math.sin(e);this.x=b.x*f;this.y=b.y*
  51. 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*=b,this.w*=b);return this},
  52. multiplySelf:function(b){var d=this.x,e=this.y,f=this.z,g=this.w,i=b.x,h=b.y,j=b.z,b=b.w;this.x=d*b+g*i+e*j-f*h;this.y=e*b+g*h+f*i-d*j;this.z=f*b+g*j+d*h-e*i;this.w=g*b-d*i-e*h-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,g=b.z,i=this.x,h=this.y,j=this.z,o=this.w,m=o*e+h*g-j*f,n=
  53. o*f+j*e-i*g,q=o*g+i*f-h*e,e=-i*e-h*f-j*g;d.x=m*o+e*-i+n*-j-q*-h;d.y=n*o+e*-h+q*-i-m*-j;d.z=q*o+e*-j+m*-h-n*-i;return d}};
  54. THREE.Quaternion.slerp=function(b,d,e,f){var g=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(g)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var i=Math.acos(g),h=Math.sqrt(1-g*g);if(Math.abs(h)<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;g=Math.sin((1-f)*i)/h;f=Math.sin(f*i)/h;e.w=b.w*g+d.w*f;e.x=b.x*g+d.x*f;e.y=b.y*g+d.y*f;e.z=b.z*g+d.z*f;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
  55. THREE.Face3=function(b,d,e,f,g,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=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=i instanceof Array?i:[i];this.centroid=new THREE.Vector3};
  56. THREE.Face4=function(b,d,e,f,g,i,h){this.a=b;this.b=d;this.c=e;this.d=f;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=i instanceof THREE.Color?i:new THREE.Color;this.vertexColors=i instanceof Array?i:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)};
  57. THREE.UV.prototype={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};
  58. THREE.Geometry.prototype={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),
  59. e.centroid.addSelf(this.vertices[e.d].position),e.centroid.divideScalar(4))},computeFaceNormals:function(b){var d,e,f,g,i,h,j=new THREE.Vector3,o=new THREE.Vector3;f=0;for(g=this.faces.length;f<g;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],h=this.vertices[i.c],j.sub(h.position,e.position),o.sub(d.position,e.position),j.crossSelf(o);j.isZero()||
  60. 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=
  61. 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]),
  62. 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,c,d,e,f,g,i){j=b.vertices[c].position;o=b.vertices[d].position;m=b.vertices[e].position;n=h[f];q=h[g];t=h[i];r=o.x-j.x;D=m.x-j.x;x=o.y-j.y;z=m.y-j.y;B=o.z-j.z;ea=m.z-j.z;M=q.u-n.u;N=t.u-n.u;F=q.v-n.v;y=t.v-n.v;Y=1/(M*y-N*F);ka.set((y*r-F*D)*
  63. Y,(y*x-F*z)*Y,(y*B-F*ea)*Y);S.set((M*D-N*r)*Y,(M*z-N*x)*Y,(M*ea-N*B)*Y);Z[c].addSelf(ka);Z[d].addSelf(ka);Z[e].addSelf(ka);K[c].addSelf(S);K[d].addSelf(S);K[e].addSelf(S)}var d,e,f,g,i,h,j,o,m,n,q,t,r,D,x,z,B,ea,M,N,F,y,Y,C,Z=[],K=[],ka=new THREE.Vector3,S=new THREE.Vector3,P=new THREE.Vector3,c=new THREE.Vector3,na=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++)Z[d]=new THREE.Vector3,K[d]=new THREE.Vector3;d=0;for(e=this.faces.length;d<e;d++)i=this.faces[d],h=this.faceVertexUvs[0][d],i instanceof
  64. 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 ia=["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++)na.copy(i.vertexNormals[f]),g=i[ia[f]],C=Z[g],P.copy(C),P.subSelf(na.multiplyScalar(na.dot(C))).normalize(),c.cross(i.vertexNormals[f],C),g=c.dot(K[g]),g=g<0?-1:1,i.vertexTangents[f]=new THREE.Vector4(P.x,P.y,P.z,g)}this.hasTangents=!0},computeBoundingBox:function(){var b;
  65. 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;
  66. 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]===
  67. 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,g,i,h,j={};e=0;for(f=this.faces.length;e<f;e++)h=this.faces[e],h instanceof THREE.Face3?(g=b(h.a,h.b),d(j,g,e),g=b(h.b,h.c),d(j,g,e),g=b(h.a,h.c),d(j,g,e)):h instanceof THREE.Face4&&(g=b(h.b,h.d),d(j,g,e),g=b(h.a,h.b),d(j,g,e),g=b(h.a,h.d),d(j,g,e),g=b(h.b,h.c),d(j,g,e),g=b(h.c,h.d),d(j,g,e));e=0;for(f=this.edges.length;e<f;e++){h=this.edges[e];g=h.vertexIndices[0];i=h.vertexIndices[1];
  68. h.faceIndices=j[b(g,i)].array;for(g=0;g<h.faceIndices.length;g++)i=h.faceIndices[g],h.faces.push(this.faces[i])}}};THREE.GeometryIdCounter=0;
  69. THREE.Spline=function(b){function d(b,d,e,f,g,h,i){b=(e-b)*0.5;f=(f-d)*0.5;return(2*(d-e)+b+f)*i+(-3*(d-e)-2*b-f)*h+b*g+d}this.points=b;var e=[],f={x:0,y:0,z:0},g,i,h,j,o,m,n,q,t;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){g=(this.points.length-1)*b;i=Math.floor(g);h=g-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;m=this.points[e[0]];n=this.points[e[1]];
  70. q=this.points[e[2]];t=this.points[e[3]];j=h*h;o=h*j;f.x=d(m.x,n.x,q.x,t.x,h,j,o);f.y=d(m.y,n.y,q.y,t.y,h,j,o);f.z=d(m.z,n.z,q.z,t.z,h,j,o);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,g=new THREE.Vector3,h=new THREE.Vector3,i=[],j=0;i[0]=0;b||(b=100);e=this.points.length*b;g.copy(this.points[0]);for(b=1;b<e;b++)d=b/e,position=this.getPoint(d),h.copy(position),
  71. j+=h.distanceTo(g),g.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,g,h,i,j=[],o=new THREE.Vector3,m=this.getLength();j.push(o.copy(this.points[0]).clone());for(d=1;d<this.points.length;d++){e=m.chunks[d]-m.chunks[d-1];i=Math.ceil(b*e/m.total);g=(d-1)/(this.points.length-1);h=d/(this.points.length-1);for(e=1;e<i-1;e++)f=g+e*(1/i)*(h-g),position=this.getPoint(f),j.push(o.copy(position).clone());
  72. j.push(o.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,g){THREE.Object3D.call(this);this.fov=b||50;this.aspect=d||1;this.near=e||0.1;this.far=f||2E3;this.target=g||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;
  73. 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)};
  74. 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)};
  75. THREE.Camera.prototype.setViewOffset=function(b,d,e,f,g,i){this.fullWidth=b;this.fullHeight=d;this.x=e;this.y=f;this.width=g;this.height=i;this.updateProjectionMatrix()};
  76. 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=
  77. !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;
  78. 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};
  79. THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;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;
  80. 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})};
  81. THREE.LensFlare.prototype.updateLensFlares=function(){var b,d=this.lensFlares.length,e,f=-this.positionScreen.x*2,g=-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+g*e.distance,e.wantedRotation=e.x*Math.PI*0.25,e.rotation+=(e.wantedRotation-e.rotation)*0.25};
  82. 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:
  83. 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(){};THREE.SphericalReflectionMapping=function(){};
  84. 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};THREE.LineBasicMaterial.prototype=new THREE.Material;
  85. THREE.LineBasicMaterial.prototype.constructor=THREE.LineBasicMaterial;
  86. 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!==
  87. 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};
  88. THREE.MeshBasicMaterial.prototype=new THREE.Material;THREE.MeshBasicMaterial.prototype.constructor=THREE.MeshBasicMaterial;
  89. 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!==
  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.MeshLambertMaterial.prototype=new THREE.Material;THREE.MeshLambertMaterial.prototype.constructor=THREE.MeshLambertMaterial;
  92. 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;
  93. 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!==
  94. 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;
  95. 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;
  96. 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(){};
  97. 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=
  98. 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;
  99. 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;
  100. 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!==
  101. 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};
  102. THREE.ShadowVolumeDynamicMaterial.prototype=new THREE.Material;THREE.ShadowVolumeDynamicMaterial.prototype.constructor=THREE.ShadowVolumeDynamicMaterial;
  103. THREE.Texture=function(b,d,e,f,g,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=g!==void 0?g: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};
  104. THREE.Texture.prototype={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;THREE.UnsignedByteType=10;
  105. 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;
  106. 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;
  107. THREE.Line.prototype.constructor=THREE.Line;
  108. 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]=
  109. 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};
  110. 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;
  111. 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,g=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(f=0;f<g;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<g;f++)this.children[f].update(this.skinMatrix,
  112. 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};
  113. THREE.SkinnedMesh=function(b,d){THREE.Mesh.call(this,b,d);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var e,f,g,i,h,j;if(this.geometry.bones!==void 0){for(e=0;e<this.geometry.bones.length;e++)g=this.geometry.bones[e],i=g.pos,h=g.rotq,j=g.scl,f=this.addBone(),f.name=g.name,f.position.set(i[0],i[1],i[2]),f.quaternion.set(h[0],h[1],h[2],h[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++)g=this.geometry.bones[e],
  114. f=this.bones[e],g.parent===-1?this.addChild(f):this.bones[g.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;
  115. 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,g=this.children.length;for(f=0;f<g;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,
  116. d*16)}};THREE.SkinnedMesh.prototype.addBone=function(b){b===void 0&&(b=new THREE.Bone(this));this.bones.push(b);return b};
  117. 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,g=this.geometry.skinIndices[b].x,i=this.geometry.skinIndices[b].y;f=new THREE.Vector3(e.x,
  118. e.y,e.z);this.geometry.skinVerticesA.push(d[g].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]};
  119. THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;
  120. THREE.Sound=function(b,d,e,f){THREE.Object3D.call(this);this.isPlaying=this.isAddedToDOM=this.isLoaded=!1;this.duration=-1;this.radius=d!==void 0?Math.abs(d):100;this.volume=Math.min(1,Math.max(0,e!==void 0?e:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=f!==void 0?f:!0;this.sources=b instanceof Array?b:[b];for(var g,e=this.sources.length,b=0;b<e;b++)if(d=this.sources[b],d.toLowerCase(),d.indexOf(".mp3")!==-1?g="audio/mpeg":
  121. d.indexOf(".ogg")!==-1?g="audio/ogg":d.indexOf(".wav")!==-1&&(g="audio/wav"),this.domElement.canPlayType(g)){g=document.createElement("source");g.src=this.sources[b];this.domElement.THREESound=this;this.domElement.appendChild(g);this.domElement.addEventListener("canplay",this.onLoad,!0);this.domElement.load();break}};THREE.Sound.prototype=new THREE.Object3D;THREE.Sound.prototype.constructor=THREE.Sound;THREE.Sound.prototype.supr=THREE.Object3D.prototype;
  122. THREE.Sound.prototype.onLoad=function(){var b=this.THREESound;if(!b.isLoaded)this.removeEventListener("canplay",this.onLoad,!0),b.isLoaded=!0,b.duration=this.duration,b.isPlaying&&b.play()};THREE.Sound.prototype.addToDOM=function(b){this.isAddedToDOM=!0;b.appendChild(this.domElement)};THREE.Sound.prototype.play=function(b){this.isPlaying=!0;if(this.isLoaded&&(this.domElement.play(),b))this.domElement.currentTime=b%this.duration};THREE.Sound.prototype.pause=function(){this.isPlaying=!1;this.domElement.pause()};
  123. THREE.Sound.prototype.stop=function(){this.isPlaying=!1;this.domElement.pause();this.domElement.currentTime=0};THREE.Sound.prototype.calculateVolumeAndPan=function(b){b=b.length();this.domElement.volume=b<=this.radius?this.volume*(1-b/this.radius):0};
  124. THREE.Sound.prototype.update=function(b,d,e){this.matrixAutoUpdate&&(this.matrix.setPosition(this.position),d=!0);if(d||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,d=!0;for(var f=this.children.length,b=0;b<f;b++)this.children[b].update(this.matrixWorld,d,e)};THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;
  125. 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)};
  126. 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,
  127. 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()};
  128. THREE.ShadowVolume.prototype=new THREE.Mesh;THREE.ShadowVolume.prototype.constructor=THREE.ShadowVolume;THREE.ShadowVolume.prototype.supr=THREE.Mesh.prototype;
  129. THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(){if(this.geometry.edges&&this.geometry.edges.length){var b,d,e,f,g,i,h,j,o,m,n,q,t,r,D=new THREE.Geometry;D.vertices=this.geometry.vertices;f=D.faces=this.geometry.faces;var x=D.egdes=this.geometry.edges,z=D.edgeFaces=[];g=0;var B=[];b=0;for(d=f.length;b<d;b++)if(e=f[b],B.push(g),g+=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]=
  130. e.normal;b=0;for(d=x.length;b<d;b++)j=x[b],e=j.faces[0],f=j.faces[1],g=j.faceIndices[0],i=j.faceIndices[1],h=j.vertexIndices[0],j=j.vertexIndices[1],e.a===h?(o="a",n=B[g]+0):e.b===h?(o="b",n=B[g]+1):e.c===h?(o="c",n=B[g]+2):e.d===h&&(o="d",n=B[g]+3),e.a===j?(o+="a",q=B[g]+0):e.b===j?(o+="b",q=B[g]+1):e.c===j?(o+="c",q=B[g]+2):e.d===j&&(o+="d",q=B[g]+3),f.a===h?(m="a",t=B[i]+0):f.b===h?(m="b",t=B[i]+1):f.c===h?(m="c",t=B[i]+2):f.d===h&&(m="d",t=B[i]+3),f.a===j?(m+="a",r=B[i]+0):f.b===j?(m+="b",r=B[i]+
  131. 1):f.c===j?(m+="c",r=B[i]+2):f.d===j&&(m+="d",r=B[i]+3),o==="ac"||o==="ad"||o==="ca"||o==="da"?n>q&&(e=n,n=q,q=e):n<q&&(e=n,n=q,q=e),m==="ac"||m==="ad"||m==="ca"||m==="da"?t>r&&(e=t,t=r,r=e):t<r&&(e=t,t=r,r=e),e=new THREE.Face4(n,q,t,r),e.normal.set(1,0,0),z.push(e);this.geometry=D}else this.calculateShadowVolumeGeometryWithoutEdgeInfo(this.geometry)};
  132. 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,g=b.faces,b=b.vertices,i=g.length,h,j,o,m,n,q=["a","b","c","d"];for(o=0;o<i;o++){j=d.length;h=g[o];h instanceof THREE.Face4?(m=4,j=new THREE.Face4(j,j+1,j+2,j+3)):(m=3,j=new THREE.Face3(j,j+1,j+2));j.normal.copy(h.normal);e.push(j);
  133. for(j=0;j<m;j++)n=b[h[q[j]]],d.push(new THREE.Vertex(n.position.clone()))}for(i=0;i<g.length-1;i++){b=e[i];for(h=i+1;h<g.length;h++)j=e[h],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))}};
  134. THREE.ShadowVolume.prototype.facesShareEdge=function(b,d,e){var f,g,i,h,j,o,m,n,q,t,r,D,x,z=0,B=["a","b","c","d"];f=d instanceof THREE.Face4?4:3;g=e instanceof THREE.Face4?4:3;for(D=0;D<f;D++){i=d[B[D]];j=b[i];for(x=0;x<g;x++)if(h=e[B[x]],o=b[h],Math.abs(j.position.x-o.position.x)<1.0E-4&&Math.abs(j.position.y-o.position.y)<1.0E-4&&Math.abs(j.position.z-o.position.z)<1.0E-4&&(z++,z===1&&(m=j,n=o,q=i,t=h,r=B[D]),z===2))return r+=B[D],r==="ad"||r==="ac"?{faces:[d,e],vertices:[m,n,o,j],indices:[q,t,
  135. h,i],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[d,e],vertices:[m,j,o,n],indices:[q,i,h,t],vertexTypes:[1,1,2,2],extrudable:!0}}};
  136. 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;
  137. 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;
  138. 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);
  139. 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);
  140. THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.collisions=this.fog=null;this.objects=[];this.lights=[];this.sounds=[];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)};
  141. 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.Sound)this.sounds.indexOf(b)===-1&&this.sounds.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])};
  142. THREE.Scene.prototype.removeChild=function(b){this.supr.removeChild.call(this,b);this.removeChildRecurse(b)};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.Sound?(d=this.sounds.indexOf(b),d!==-1&&this.sounds.splice(d,1)):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])};
  143. THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;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};
  144. THREE.Projector=function(){function b(){var b=o[j]=o[j]||new THREE.RenderableVertex;j++;return b}function d(b,d){return d.z-b.z}function e(b,d){var e=0,c=1,f=b.z+b.w,g=d.z+d.w,h=-b.z+b.w,i=-d.z+d.w;return f>=0&&g>=0&&h>=0&&i>=0?!0:f<0&&g<0||h<0&&i<0?!1:(f<0?e=Math.max(e,f/(f-g)):g<0&&(c=Math.min(c,f/(f-g))),h<0?e=Math.max(e,h/(h-i)):i<0&&(c=Math.min(c,h/(h-i))),c<e?!1:(b.lerpSelf(d,e),d.lerpSelf(b,1-c),!0))}var f,g,i=[],h,j,o=[],m,n,q=[],t,r=[],D,x,z=[],B,ea,M=[],N=new THREE.Vector4,F=new THREE.Vector4,
  145. y=new THREE.Matrix4,Y=new THREE.Matrix4,C=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Z=new THREE.Vector4,K=new THREE.Vector4;this.projectVector=function(b,d){y.multiply(d.projectionMatrix,d.matrixWorldInverse);y.multiplyVector3(b);return b};this.unprojectVector=function(b,d){y.multiply(d.matrixWorld,THREE.Matrix4.makeInvert(d.projectionMatrix));y.multiplyVector3(b);return b};this.projectObjects=function(b,e,h){var e=[],c,j,o;g=0;j=
  146. b.objects;b=0;for(c=j.length;b<c;b++){o=j[b];var m;if(!(m=!o.visible))if(m=o instanceof THREE.Mesh){a:{m=void 0;for(var n=o.matrixWorld,t=-o.geometry.boundingSphere.radius*Math.max(o.scale.x,Math.max(o.scale.y,o.scale.z)),q=0;q<6;q++)if(m=C[q].x*n.n14+C[q].y*n.n24+C[q].z*n.n34+C[q].w,m<=t){m=!1;break a}m=!0}m=!m}if(!m)m=i[g]=i[g]||new THREE.RenderableObject,g++,f=m,N.copy(o.position),y.multiplyVector3(N),f.object=o,f.z=N.z,e.push(f)}h&&e.sort(d);return e};this.projectScene=function(f,g,i){var c=[],
  147. N=g.near,ia=g.far,ma,O,J,ha,E,L,G,Q,ja,v,u,pa,ra,Ca,ua,Ba,za;ea=x=t=n=0;g.matrixAutoUpdate&&g.update(void 0,!0);f.update(void 0,!1,g);y.multiply(g.projectionMatrix,g.matrixWorldInverse);C[0].set(y.n41-y.n11,y.n42-y.n12,y.n43-y.n13,y.n44-y.n14);C[1].set(y.n41+y.n11,y.n42+y.n12,y.n43+y.n13,y.n44+y.n14);C[2].set(y.n41+y.n21,y.n42+y.n22,y.n43+y.n23,y.n44+y.n24);C[3].set(y.n41-y.n21,y.n42-y.n22,y.n43-y.n23,y.n44-y.n24);C[4].set(y.n41-y.n31,y.n42-y.n32,y.n43-y.n33,y.n44-y.n34);C[5].set(y.n41+y.n31,y.n42+
  148. y.n32,y.n43+y.n33,y.n44+y.n34);for(ma=0;ma<6;ma++)ja=C[ma],ja.divideScalar(Math.sqrt(ja.x*ja.x+ja.y*ja.y+ja.z*ja.z));ja=this.projectObjects(f,g,!0);f=0;for(ma=ja.length;f<ma;f++)if(v=ja[f].object,v.visible)if(u=v.matrixWorld,pa=v.matrixRotationWorld,ra=v.materials,Ca=v.overdraw,j=0,v instanceof THREE.Mesh){ua=v.geometry;ha=ua.vertices;Ba=ua.faces;ua=ua.faceVertexUvs;O=0;for(J=ha.length;O<J;O++)h=b(),h.positionWorld.copy(ha[O].position),u.multiplyVector3(h.positionWorld),h.positionScreen.copy(h.positionWorld),
  149. y.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>N&&h.positionScreen.z<ia;ha=0;for(O=Ba.length;ha<O;ha++){J=Ba[ha];if(J instanceof THREE.Face3)if(E=o[J.a],L=o[J.b],G=o[J.c],E.visible&&L.visible&&G.visible&&(v.doubleSided||v.flipSided!=(G.positionScreen.x-E.positionScreen.x)*(L.positionScreen.y-E.positionScreen.y)-(G.positionScreen.y-E.positionScreen.y)*(L.positionScreen.x-E.positionScreen.x)<0))Q=q[n]=q[n]||
  150. new THREE.RenderableFace3,n++,m=Q,m.v1.copy(E),m.v2.copy(L),m.v3.copy(G);else continue;else if(J instanceof THREE.Face4)if(E=o[J.a],L=o[J.b],G=o[J.c],Q=o[J.d],E.visible&&L.visible&&G.visible&&Q.visible&&(v.doubleSided||v.flipSided!=((Q.positionScreen.x-E.positionScreen.x)*(L.positionScreen.y-E.positionScreen.y)-(Q.positionScreen.y-E.positionScreen.y)*(L.positionScreen.x-E.positionScreen.x)<0||(L.positionScreen.x-G.positionScreen.x)*(Q.positionScreen.y-G.positionScreen.y)-(L.positionScreen.y-G.positionScreen.y)*
  151. (Q.positionScreen.x-G.positionScreen.x)<0)))za=r[t]=r[t]||new THREE.RenderableFace4,t++,m=za,m.v1.copy(E),m.v2.copy(L),m.v3.copy(G),m.v4.copy(Q);else continue;m.normalWorld.copy(J.normal);pa.multiplyVector3(m.normalWorld);m.centroidWorld.copy(J.centroid);u.multiplyVector3(m.centroidWorld);m.centroidScreen.copy(m.centroidWorld);y.multiplyVector3(m.centroidScreen);G=J.vertexNormals;E=0;for(L=G.length;E<L;E++)Q=m.vertexNormalsWorld[E],Q.copy(G[E]),pa.multiplyVector3(Q);E=0;for(L=ua.length;E<L;E++)if(za=
  152. ua[E][ha]){G=0;for(Q=za.length;G<Q;G++)m.uvs[E][G]=za[G]}m.meshMaterials=ra;m.faceMaterials=J.materials;m.overdraw=Ca;m.z=m.centroidScreen.z;c.push(m)}}else if(v instanceof THREE.Line){Y.multiply(y,u);ha=v.geometry.vertices;E=b();E.positionScreen.copy(ha[0].position);Y.multiplyVector4(E.positionScreen);O=1;for(J=ha.length;O<J;O++)if(E=b(),E.positionScreen.copy(ha[O].position),Y.multiplyVector4(E.positionScreen),L=o[j-2],Z.copy(E.positionScreen),K.copy(L.positionScreen),e(Z,K))Z.multiplyScalar(1/Z.w),
  153. K.multiplyScalar(1/K.w),u=z[x]=z[x]||new THREE.RenderableLine,x++,D=u,D.v1.positionScreen.copy(Z),D.v2.positionScreen.copy(K),D.z=Math.max(Z.z,K.z),D.materials=v.materials,c.push(D)}else if(v instanceof THREE.Particle&&(F.set(v.matrixWorld.n14,v.matrixWorld.n24,v.matrixWorld.n34,1),y.multiplyVector4(F),F.z/=F.w,F.z>0&&F.z<1))u=M[ea]=M[ea]||new THREE.RenderableParticle,ea++,B=u,B.x=F.x/F.w,B.y=F.y/F.w,B.z=F.z,B.rotation=v.rotation.z,B.scale.x=v.scale.x*Math.abs(B.x-(F.x+g.projectionMatrix.n11)/(F.w+
  154. g.projectionMatrix.n14)),B.scale.y=v.scale.y*Math.abs(B.y-(F.y+g.projectionMatrix.n22)/(F.w+g.projectionMatrix.n24)),B.materials=v.materials,c.push(B);i&&c.sort(d);return c}};
  155. THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(b,d,e){e&&b.update(void 0,!1,d);var e=b.sounds,f,g=e.length;for(f=0;f<g;f++)b=e[f],this.soundPosition.set(b.matrixWorld.n14,b.matrixWorld.n24,b.matrixWorld.n34),this.soundPosition.subSelf(d.position),b.isPlaying&&b.isLoaded&&(b.isAddedToDOM||b.addToDOM(this.domElement),b.calculateVolumeAndPan(this.soundPosition))}};
  156. 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",
  157. envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",
  158. envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
  159. map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform vec4 offsetRepeat;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",
  160. 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",
  161. 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}",
  162. 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( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + vViewPosition );\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( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
  163. 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",
  164. 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",
  165. default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"};THREE.UniformsUtils={merge:function(b){var d,e,f,g={};for(d=0;d<b.length;d++)for(e in f=this.clone(b[d]),f)g[e]=f[e];return g},clone:function(b){var d,e,f,g={};for(d in b)for(e in g[d]={},b[d])f=b[d][e],g[d][e]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f;return g}};
  166. 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},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",
  167. value:new THREE.Color(16777215)},morphTargetInfluences:{type:"f",value:0}},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",value:1},
  168. 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)}}};
  169. THREE.ShaderLib={lensFlareVertexTexture:{vertexShader:"uniform \tvec3 \tscreenPosition;\nuniform\tvec2\tscale;\nuniform\tfloat\trotation;\nuniform int renderType;\nuniform\tsampler2D\tocclusionMap;\nattribute \tvec2 \tposition;\nattribute vec2\tUV;\nvarying\tvec2\tvUV;\nvarying\tfloat\tvVisibility;\nvoid main(void)\n{\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\tsampler2D\tmap;\nuniform\tfloat\t\topacity;\nuniform int renderType;\nvarying\tvec2\t\tvUV;\nvarying\tfloat\t\tvVisibility;\nvoid main( void )\n{\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}"},
  170. lensFlare:{vertexShader:"uniform \tvec3 \tscreenPosition;\nuniform\tvec2\tscale;\nuniform\tfloat\trotation;\nuniform int renderType;\nattribute \tvec2 \tposition;\nattribute vec2\tUV;\nvarying\tvec2\tvUV;\nvoid main(void)\n{\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}",
  171. fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform\tsampler2D\tmap;\nuniform\tsampler2D\tocclusionMap;\nuniform\tfloat\t\topacity;\nuniform int renderType;\nvarying\tvec2\t\tvUV;\nvoid main( void )\n{\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}"},
  172. sprite:{vertexShader:"uniform\tint\t\tuseScreenCoordinates;\nuniform int affectedByDistance;\nuniform\tvec3\tscreenPosition;\nuniform \tmat4 \tmodelViewMatrix;\nuniform \tmat4 \tprojectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 alignment;\nuniform vec2 uvOffset;\nuniform\tvec2 uvScale;\nattribute \tvec2 \tposition;\nattribute vec2\tuv;\nvarying\tvec2\tvUV;\nvoid main(void)\n{\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}",
  173. fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform\tsampler2D\tmap;\nuniform\tfloat\t\topacity;\nvarying\tvec2\t\tvUV;\nvoid main( void )\n{\nvec4 color = texture2D( map, vUV );\ncolor.a *= opacity;\ngl_FragColor = color;\n}"},shadowPost:{vertexShader:"uniform \tmat4 \tprojectionMatrix;\nattribute \tvec3 \tposition;\nvoid main(void)\n{\ngl_Position = projectionMatrix * vec4( position, 1.0 );\n}",fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform \tfloat \tdarkness;\nvoid main( void )\n{\ngl_FragColor = vec4( 0, 0, 0, darkness );\n}"},
  174. 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}",fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0 );\n}"},
  175. 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}"},normal:{uniforms:{opacity:{type:"f",value:1}},
  176. 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.UniformsLib.common,fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",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,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_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,
  178. THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_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,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),
  179. fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\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,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,
  180. THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].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,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
  181. 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,"}"].join("\n")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),
  182. 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,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.lights_fragment,THREE.ShaderChunk.map_fragment,
  183. THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_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,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,
  184. "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;",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,
  185. THREE.ShaderChunk.default_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",
  186. THREE.ShaderChunk.color_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;\n}"].join("\n")}};
  187. THREE.WebGLRenderer=function(b){function d(b,d,e){var f,g,h,i=b.vertices,j=i.length,m=b.colors,o=m.length,p=b.__vertexArray,H=b.__colorArray,Aa=b.__sortArray,n=b.__dirtyVertices,q=b.__dirtyColors;if(e.sortParticles){_projScreenMatrix.multiplySelf(e.matrixWorld);for(f=0;f<j;f++)g=i[f].position,_vector3.copy(g),_projScreenMatrix.multiplyVector3(_vector3),Aa[f]=[_vector3.z,f];Aa.sort(function(b,c){return c[0]-b[0]});for(f=0;f<j;f++)g=i[Aa[f][1]].position,h=f*3,p[h]=g.x,p[h+1]=g.y,p[h+2]=g.z;for(f=0;f<
  188. o;f++)h=f*3,color=m[Aa[f][1]],H[h]=color.r,H[h+1]=color.g,H[h+2]=color.b}else{if(n)for(f=0;f<j;f++)g=i[f].position,h=f*3,p[h]=g.x,p[h+1]=g.y,p[h+2]=g.z;if(q)for(f=0;f<o;f++)color=m[f],h=f*3,H[h]=color.r,H[h+1]=color.g,H[h+2]=color.b}if(n||e.sortParticles)c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer),c.bufferData(c.ARRAY_BUFFER,p,d);if(q||e.sortParticles)c.bindBuffer(c.ARRAY_BUFFER,b.__webglColorBuffer),c.bufferData(c.ARRAY_BUFFER,H,d)}function e(b,d,e,f,g){f.program||P.initMaterial(f,d,e,g);
  189. var h=f.program,i=h.uniforms,j=f.uniforms;h!=ia&&(c.useProgram(h),ia=h);c.uniformMatrix4fv(i.projectionMatrix,!1,_projectionMatrixArray);if(e&&(f instanceof THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||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;
  190. if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f.lights){var m,o,p=0,H=0,n=0,q,t,u,r,y=_lights,v=y.directional.colors,D=y.directional.positions,B=y.point.colors,x=y.point.positions,I=y.point.distances,z=0,s=0,e=o=r=0;for(m=d.length;e<m;e++)if(o=d[e],q=o.color,t=o.position,u=o.intensity,r=o.distance,o instanceof THREE.AmbientLight)p+=q.r,H+=q.g,n+=q.b;else if(o instanceof THREE.DirectionalLight)r=z*3,v[r]=q.r*u,v[r+1]=q.g*u,v[r+2]=q.b*u,D[r]=t.x,D[r+1]=t.y,D[r+2]=
  191. t.z,z+=1;else if(o instanceof THREE.PointLight)o=s*3,B[o]=q.r*u,B[o+1]=q.g*u,B[o+2]=q.b*u,x[o]=t.x,x[o+1]=t.y,x[o+2]=t.z,I[s]=r,s+=1;for(e=z*3;e<v.length;e++)v[e]=0;for(e=s*3;e<B.length;e++)B[e]=0;y.point.length=s;y.directional.length=z;y.ambient[0]=p;y.ambient[1]=H;y.ambient[2]=n;e=_lights;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=
  192. e.point.colors;j.pointLightPosition.value=e.point.positions;j.pointLightDistance.value=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,
  193. j.combine.value=f.combine,j.useRefract.value=f.envMap&&f.envMap.mapping instanceof 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=_canvas.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
  194. THREE.MeshDepthMaterial)j.mNear.value=b.near,j.mFar.value=b.far,j.opacity.value=f.opacity;else if(f instanceof THREE.MeshNormalMaterial)j.opacity.value=f.opacity;for(var A in j)if(H=h.uniforms[A])if(m=j[A],p=m.type,e=m.value,p=="i")c.uniform1i(H,e);else if(p=="f")c.uniform1f(H,e);else if(p=="fv1")c.uniform1fv(H,e);else if(p=="fv")c.uniform3fv(H,e);else if(p=="v2")c.uniform2f(H,e.x,e.y);else if(p=="v3")c.uniform3f(H,e.x,e.y,e.z);else if(p=="v4")c.uniform4f(H,e.x,e.y,e.z,e.w);else if(p=="c")c.uniform3f(H,
  195. e.r,e.g,e.b);else if(p=="t"&&(c.uniform1i(H,e),m=m.texture))if(m.image instanceof Array&&m.image.length==6){if(m.image.length==6){if(m.needsUpdate){if(m.__webglInit){c.bindTexture(c.TEXTURE_CUBE_MAP,m.image.__webglTextureCube);for(p=0;p<6;++p)c.texSubImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,0,0,c.RGBA,c.UNSIGNED_BYTE,m.image[p])}else{m.image.__webglTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,m.image.__webglTextureCube);for(p=0;p<6;++p)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+
  196. p,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,m.image[p]);m.__webglInit=!0}Y(c.TEXTURE_CUBE_MAP,m,m.image[0]);c.bindTexture(c.TEXTURE_CUBE_MAP,null);m.needsUpdate=!1}c.activeTexture(c.TEXTURE0+e);c.bindTexture(c.TEXTURE_CUBE_MAP,m.image.__webglTextureCube)}}else C(m,e);c.uniformMatrix4fv(i.modelViewMatrix,!1,g._modelViewMatrixArray);c.uniformMatrix3fv(i.normalMatrix,!1,g._normalMatrixArray);(f instanceof THREE.MeshShaderMaterial||f instanceof THREE.MeshPhongMaterial||f.envMap)&&i.cameraPosition!==null&&c.uniform3f(i.cameraPosition,
  197. b.position.x,b.position.y,b.position.z);(f instanceof THREE.MeshShaderMaterial||f.envMap||f.skinning)&&i.objectMatrix!==null&&c.uniformMatrix4fv(i.objectMatrix,!1,g._objectMatrixArray);(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshShaderMaterial||f.skinning)&&i.viewMatrix!==null&&c.uniformMatrix4fv(i.viewMatrix,!1,_viewMatrixArray);if(f instanceof THREE.ShadowVolumeDynamicMaterial)b=j.directionalLightDirection.value,b[0]=-d[1].position.x,b[1]=
  198. -d[1].position.y,b[2]=-d[1].position.z,c.uniform3fv(i.directionalLightDirection,b),c.uniformMatrix4fv(i.objectMatrix,!1,g._objectMatrixArray),c.uniformMatrix4fv(i.viewMatrix,!1,_viewMatrixArray);f.skinning&&(c.uniformMatrix4fv(i.cameraInverseMatrix,!1,_viewMatrixArray),c.uniformMatrix4fv(i.boneGlobalMatrices,!1,g.boneMatrices));return h}function f(b,d,f,g,h,i){if(g.opacity!=0){var j,b=e(b,d,f,g,i).attributes;if(!g.morphTargets&&b.position>=0)c.bindBuffer(c.ARRAY_BUFFER,h.__webglVertexBuffer),c.vertexAttribPointer(b.position,
  199. 3,c.FLOAT,!1,0,0);else{d=g.program.attributes;i.morphTargetBase!==-1?(c.bindBuffer(c.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[i.morphTargetBase]),c.vertexAttribPointer(d.position,3,c.FLOAT,!1,0,0)):d.position>=0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglVertexBuffer),c.vertexAttribPointer(d.position,3,c.FLOAT,!1,0,0));if(i.morphTargetForcedOrder.length)for(var f=0,m=i.morphTargetForcedOrder,o=i.morphTargetInfluences;f<g.numSupportedMorphTargets&&f<m.length;)c.bindBuffer(c.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[m[f]]),
  200. c.vertexAttribPointer(d["morphTarget"+f],3,c.FLOAT,!1,0,0),i.__webglMorphTargetInfluences[f]=o[m[f]],f++;else{var m=[],n=-1,p=0,o=i.morphTargetInfluences,H,q=o.length,f=0;for(i.morphTargetBase!==-1&&(m[i.morphTargetBase]=!0);f<g.numSupportedMorphTargets;){for(H=0;H<q;H++)!m[H]&&o[H]>n&&(p=H,n=o[p]);c.bindBuffer(c.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[p]);c.vertexAttribPointer(d["morphTarget"+f],3,c.FLOAT,!1,0,0);i.__webglMorphTargetInfluences[f]=n;m[p]=1;n=-1;f++}}g.program.uniforms.morphTargetInfluences!==
  201. null&&c.uniform1fv(g.program.uniforms.morphTargetInfluences,i.__webglMorphTargetInfluences)}if(h.__webglCustomAttributes)for(j in h.__webglCustomAttributes)b[j]>=0&&(d=h.__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,h.__webglColorBuffer),c.vertexAttribPointer(b.color,3,c.FLOAT,!1,0,0));b.normal>=0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglNormalBuffer),c.vertexAttribPointer(b.normal,3,c.FLOAT,
  202. !1,0,0));b.tangent>=0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglTangentBuffer),c.vertexAttribPointer(b.tangent,4,c.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(c.bindBuffer(c.ARRAY_BUFFER,h.__webglUVBuffer),c.vertexAttribPointer(b.uv,2,c.FLOAT,!1,0,0),c.enableVertexAttribArray(b.uv)):c.disableVertexAttribArray(b.uv));b.uv2>=0&&(h.__webglUV2Buffer?(c.bindBuffer(c.ARRAY_BUFFER,h.__webglUV2Buffer),c.vertexAttribPointer(b.uv2,2,c.FLOAT,!1,0,0),c.enableVertexAttribArray(b.uv2)):c.disableVertexAttribArray(b.uv2));
  203. g.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinVertexABuffer),c.vertexAttribPointer(b.skinVertexA,4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),c.vertexAttribPointer(b.skinVertexB,4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),c.vertexAttribPointer(b.skinIndex,4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),c.vertexAttribPointer(b.skinWeight,
  204. 4,c.FLOAT,!1,0,0));i instanceof THREE.Mesh?(g.wireframe?(c.lineWidth(g.wireframeLinewidth),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),c.drawElements(c.LINES,h.__webglLineCount,c.UNSIGNED_SHORT,0)):(c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),c.drawElements(c.TRIANGLES,h.__webglFaceCount,c.UNSIGNED_SHORT,0)),P.data.vertices+=h.__webglFaceCount,P.data.faces+=h.__webglFaceCount/3,P.data.drawCalls++):i instanceof THREE.Line?(i=i.type==THREE.LineStrip?c.LINE_STRIP:c.LINES,c.lineWidth(g.linewidth),
  205. c.drawArrays(i,0,h.__webglLineCount),P.data.drawCalls++):i instanceof THREE.ParticleSystem?(c.drawArrays(c.POINTS,0,h.__webglParticleCount),P.data.drawCalls++):i instanceof THREE.Ribbon&&(c.drawArrays(c.TRIANGLE_STRIP,0,h.__webglVertexCount),P.data.drawCalls++)}}function g(b,d,e){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=c.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=c.createBuffer();b.hasPos&&(c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer),c.bufferData(c.ARRAY_BUFFER,
  206. 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,h,g,i,j,m,o,p,H,n,q=b.count*3;for(n=0;n<q;n+=9)e=b.normalArray,f=e[n],h=e[n+1],g=e[n+2],i=e[n+3],m=e[n+4],p=e[n+5],j=e[n+6],o=e[n+7],H=e[n+8],f=(f+i+j)/3,h=(h+m+o)/3,g=(g+p+H)/3,e[n]=f,e[n+1]=h,e[n+2]=g,e[n+3]=f,e[n+4]=h,e[n+5]=g,e[n+6]=f,e[n+7]=h,e[n+8]=g}c.bufferData(c.ARRAY_BUFFER,
  207. 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(J!=b.doubleSided)b.doubleSided?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE),J=b.doubleSided;if(ha!=b.flipSided)b.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW),ha=b.flipSided}function h(b){L!=b&&(b?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST),L=b)}function j(b,d,e){G!=b&&(b?c.enable(c.POLYGON_OFFSET_FILL):
  208. c.disable(c.POLYGON_OFFSET_FILL),G=b);if(b&&(_oldPolygonOffsetFactor!=d||_oldPolygonOffsetUnits!=e))c.polygonOffset(d,e),_oldPolygonOffsetFactor=d,_oldPolygonOffsetUnits=e}function o(b){_frustum[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-b.n14);_frustum[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);_frustum[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);_frustum[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);_frustum[4].set(b.n41-b.n31,b.n42-b.n32,b.n43-b.n33,b.n44-
  209. b.n34);_frustum[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=_frustum[b],c.divideScalar(Math.sqrt(c.x*c.x+c.y*c.y+c.z*c.z))}function m(b){for(var c=b.matrixWorld,d=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),e=0;e<6;e++)if(b=_frustum[e].x*c.n14+_frustum[e].y*c.n24+_frustum[e].z*c.n34+_frustum[e].w,b<=d)return!1;return!0}function n(b,c){b.list[b.count]=c;b.count+=1}function q(b){var c,d,e=b.object,f=b.opaque,h=b.transparent;
  210. h.count=0;b=f.count=0;for(c=e.materials.length;b<c;b++)d=e.materials[b],d.transparent?n(h,d):n(f,d)}function t(b){var c,d,e,f,h=b.object,g=b.buffer,i=b.opaque,j=b.transparent;j.count=0;b=i.count=0;for(e=h.materials.length;b<e;b++)if(c=h.materials[b],c instanceof THREE.MeshFaceMaterial){c=0;for(d=g.materials.length;c<d;c++)(f=g.materials[c])&&(f.transparent?n(j,f):n(i,f))}else(f=c)&&(f.transparent?n(j,f):n(i,f))}function r(b,c){return c.z-b.z}function D(b){c.enable(c.POLYGON_OFFSET_FILL);c.polygonOffset(0.1,
  211. 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,h=b.lights,g=[],i,j,m,o,p,n=b.__webglShadowVolumes.length;for(d=0;d<e;d++)if(f=b.lights[d],f instanceof THREE.DirectionalLight&&f.castShadow){g[0]=-f.position.x;g[1]=-f.position.y;g[2]=-f.position.z;for(p=0;p<n;p++)f=b.__webglShadowVolumes[p].object,i=b.__webglShadowVolumes[p].buffer,
  212. j=f.materials[0],j.program||P.initMaterial(j,h,void 0,f),j=j.program,m=j.uniforms,o=j.attributes,ia!==j&&(c.useProgram(j),ia=j,c.uniformMatrix4fv(m.projectionMatrix,!1,_projectionMatrixArray),c.uniformMatrix4fv(m.viewMatrix,!1,_viewMatrixArray),c.uniform3fv(m.directionalLightDirection,g)),f.matrixWorld.flattenToArray(f._objectMatrixArray),c.uniformMatrix4fv(m.objectMatrix,!1,f._objectMatrixArray),c.bindBuffer(c.ARRAY_BUFFER,i.__webglVertexBuffer),c.vertexAttribPointer(o.position,3,c.FLOAT,!1,0,0),
  213. c.bindBuffer(c.ARRAY_BUFFER,i.__webglNormalBuffer),c.vertexAttribPointer(o.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,c.KEEP,c.KEEP);c.disable(c.DEPTH_TEST);E=-1;ia=v.program;c.useProgram(v.program);
  214. c.uniformMatrix4fv(v.projectionLocation,!1,_projectionMatrixArray);c.uniform1f(v.darknessLocation,v.darkness);c.bindBuffer(c.ARRAY_BUFFER,v.vertexBuffer);c.vertexAttribPointer(v.vertexLocation,3,c.FLOAT,!1,0,0);c.enableVertexAttribArray(v.vertexLocation);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.blendEquation(c.FUNC_ADD);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.elementBuffer);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.disable(c.STENCIL_TEST);c.enable(c.DEPTH_TEST);c.depthMask(O)}function x(b,
  215. d){var e,f,h;e=_sprite.attributes;var g=_sprite.uniforms,i=_viewportHeight/_viewportWidth,j,m=[],o=_viewportWidth*0.5,p=_viewportHeight*0.5,n=!0;c.useProgram(_sprite.program);ia=_sprite.program;E=-1;ra||(c.enableVertexAttribArray(_sprite.attributes.position),c.enableVertexAttribArray(_sprite.attributes.uv),ra=!0);c.disable(c.CULL_FACE);c.enable(c.BLEND);c.depthMask(!0);c.bindBuffer(c.ARRAY_BUFFER,_sprite.vertexBuffer);c.vertexAttribPointer(e.position,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(e.uv,
  216. 2,c.FLOAT,!1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);c.uniformMatrix4fv(g.projectionMatrix,!1,_projectionMatrixArray);c.activeTexture(c.TEXTURE0);c.uniform1i(g.map,0);e=0;for(f=b.__webglSprites.length;e<f;e++)h=b.__webglSprites[e],h.useScreenCoordinates?h.z=-h.position.z:(h._modelViewMatrix.multiplyToArray(d.matrixWorldInverse,h.matrixWorld,h._modelViewMatrixArray),h.z=-h._modelViewMatrix.n34);b.__webglSprites.sort(r);e=0;for(f=b.__webglSprites.length;e<f;e++)h=b.__webglSprites[e],
  217. h.material===void 0&&h.map&&h.map.image&&h.map.image.width&&(h.useScreenCoordinates?(c.uniform1i(g.useScreenCoordinates,1),c.uniform3f(g.screenPosition,(h.position.x-o)/o,(p-h.position.y)/p,Math.max(0,Math.min(1,h.position.z)))):(c.uniform1i(g.useScreenCoordinates,0),c.uniform1i(g.affectedByDistance,h.affectedByDistance?1:0),c.uniformMatrix4fv(g.modelViewMatrix,!1,h._modelViewMatrixArray)),j=h.map.image.width/(h.scaleByViewport?_viewportHeight:1),m[0]=j*i*h.scale.x,m[1]=j*h.scale.y,c.uniform2f(g.uvScale,
  218. h.uvScale.x,h.uvScale.y),c.uniform2f(g.uvOffset,h.uvOffset.x,h.uvOffset.y),c.uniform2f(g.alignment,h.alignment.x,h.alignment.y),c.uniform1f(g.opacity,h.opacity),c.uniform1f(g.rotation,h.rotation),c.uniform2fv(g.scale,m),h.mergeWith3D&&!n?(c.enable(c.DEPTH_TEST),n=!0):!h.mergeWith3D&&n&&(c.disable(c.DEPTH_TEST),n=!1),y(h.blending),C(h.map,0),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0));c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(O)}function z(b,d){var e,f,h=b.__webglLensFlares.length,
  219. g,i,j,m=new THREE.Vector3,o=_viewportHeight/_viewportWidth,p=_viewportWidth*0.5,n=_viewportHeight*0.5,q=16/_viewportHeight,t=[q*o,q],r=[1,1,0],v=[1,1],B=u.uniforms;e=u.attributes;c.useProgram(u.program);ia=u.program;E=-1;pa||(c.enableVertexAttribArray(u.attributes.vertex),c.enableVertexAttribArray(u.attributes.uv),pa=!0);c.uniform1i(B.occlusionMap,0);c.uniform1i(B.map,1);c.bindBuffer(c.ARRAY_BUFFER,u.vertexBuffer);c.vertexAttribPointer(e.vertex,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(e.uv,2,c.FLOAT,
  220. !1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.elementBuffer);c.disable(c.CULL_FACE);c.depthMask(!1);c.activeTexture(c.TEXTURE0);c.bindTexture(c.TEXTURE_2D,u.occlusionTexture);c.activeTexture(c.TEXTURE1);for(f=0;f<h;f++)if(e=b.__webglLensFlares[f].object,m.set(e.matrixWorld.n14,e.matrixWorld.n24,e.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(m),d.projectionMatrix.multiplyVector3(m),r[0]=m.x,r[1]=m.y,r[2]=m.z,v[0]=r[0]*p+p,v[1]=r[1]*n+n,u.hasVertexTexture||v[0]>0&&v[0]<_viewportWidth&&v[1]>
  221. 0&&v[1]<_viewportHeight){c.bindTexture(c.TEXTURE_2D,u.tempTexture);c.copyTexImage2D(c.TEXTURE_2D,0,c.RGB,v[0]-8,v[1]-8,16,16,0);c.uniform1i(B.renderType,0);c.uniform2fv(B.scale,t);c.uniform3fv(B.screenPosition,r);c.disable(c.BLEND);c.enable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.bindTexture(c.TEXTURE_2D,u.occlusionTexture);c.copyTexImage2D(c.TEXTURE_2D,0,c.RGBA,v[0]-8,v[1]-8,16,16,0);c.uniform1i(B.renderType,1);c.disable(c.DEPTH_TEST);c.bindTexture(c.TEXTURE_2D,u.tempTexture);
  222. c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);e.positionScreen.x=r[0];e.positionScreen.y=r[1];e.positionScreen.z=r[2];e.customUpdateCallback?e.customUpdateCallback(e):e.updateLensFlares();c.uniform1i(B.renderType,2);c.enable(c.BLEND);g=0;for(i=e.lensFlares.length;g<i;g++)if(j=e.lensFlares[g],j.opacity>0.001&&j.scale>0.001)r[0]=j.x,r[1]=j.y,r[2]=j.z,q=j.size*j.scale/_viewportHeight,t[0]=q*o,t[1]=q,c.uniform3fv(B.screenPosition,r),c.uniform2fv(B.scale,t),c.uniform1f(B.rotation,j.rotation),c.uniform1f(B.opacity,
  223. j.opacity),y(j.blending),C(j.texture,1),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(O)}function B(b,c){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function ea(b){var e,f,h,g;if(b instanceof THREE.Mesh){f=b.geometry;for(e in f.geometryGroups){h=f.geometryGroups[e];a:{for(var i=g=void 0,j=void 0,m=void 0,
  224. o=void 0,o=h.__materials,i=0,j=o.length;i<j;i++)if(m=o[i],m.attributes)for(g in m.attributes)if(m.attributes[g].needsUpdate){g=!0;break a}g=!1}if(f.__dirtyVertices||f.__dirtyMorphTargets||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents||g)if(g=h,i=b,j=c.DYNAMIC_DRAW,g.__inittedArrays){var n=o=m=void 0,p=void 0,H=n=void 0,q=void 0,t=void 0,r=void 0,u=void 0,v=void 0,y=void 0,B=void 0,D=void 0,x=void 0,z=void 0,I=void 0,E=void 0,s=p=r=p=t=q=void 0,A=void 0,k=A=
  225. s=q=void 0,F=void 0,K=k=A=s=n=n=H=r=p=k=A=s=F=k=A=s=F=k=A=s=void 0,C=0,G=0,P=0,S=0,J=0,L=0,R=0,M=0,$=0,w=0,aa=0,A=s=0,ca=g.__vertexArray,Y=g.__uvArray,Z=g.__uv2Array,N=g.__normalArray,T=g.__tangentArray,da=g.__colorArray,U=g.__skinVertexAArray,V=g.__skinVertexBArray,W=g.__skinIndexArray,X=g.__skinWeightArray,ea=g.__morphTargetsArrays,Q=g.__webglCustomAttributes,k=void 0,la=g.__faceArray,O=g.__lineArray,ha=g.__needsSmoothNormals,v=g.__vertexColorType,u=g.__uvType,y=g.__normalType,fa=i.geometry,ja=
  226. fa.__dirtyVertices,ka=fa.__dirtyElements,ia=fa.__dirtyUvs,ma=fa.__dirtyNormals,na=fa.__dirtyTangents,pa=fa.__dirtyColors,ra=fa.__dirtyMorphTargets,va=fa.vertices,Da=g.faces,Ga=fa.faces,Ea=fa.faceVertexUvs[0],Fa=fa.faceVertexUvs[1],wa=fa.skinVerticesA,xa=fa.skinVerticesB,ya=fa.skinIndices,sa=fa.skinWeights,ta=i instanceof THREE.ShadowVolume?fa.edgeFaces:void 0,qa=fa.morphTargets;if(Q)for(K in Q)Q[K].offset=0,Q[K].offsetSrc=0;m=0;for(o=Da.length;m<o;m++)if(n=Da[m],p=Ga[n],Ea&&(B=Ea[n]),Fa&&(D=Fa[n]),
  227. n=p.vertexNormals,H=p.normal,q=p.vertexColors,t=p.color,r=p.vertexTangents,p instanceof THREE.Face3){if(ja)x=va[p.a].position,z=va[p.b].position,I=va[p.c].position,ca[G]=x.x,ca[G+1]=x.y,ca[G+2]=x.z,ca[G+3]=z.x,ca[G+4]=z.y,ca[G+5]=z.z,ca[G+6]=I.x,ca[G+7]=I.y,ca[G+8]=I.z,G+=9;if(Q)for(K in Q)if(k=Q[K],k.__original.needsUpdate)s=k.offset,A=k.offsetSrc,k.size===1?(k.boundTo===void 0||k.boundTo==="vertices"?(k.array[s+0]=k.value[p.a],k.array[s+1]=k.value[p.b],k.array[s+2]=k.value[p.c]):k.boundTo==="faces"?
  228. (k.array[s+0]=k.value[A],k.array[s+1]=k.value[A],k.array[s+2]=k.value[A],k.offsetSrc++):k.boundTo==="faceVertices"&&(k.array[s+0]=k.value[A+0],k.array[s+1]=k.value[A+1],k.array[s+2]=k.value[A+2],k.offsetSrc+=3),k.offset+=3):(k.boundTo===void 0||k.boundTo==="vertices"?(x=k.value[p.a],z=k.value[p.b],I=k.value[p.c]):k.boundTo==="faces"?(x=k.value[A],z=k.value[A],I=k.value[A],k.offsetSrc++):k.boundTo==="faceVertices"&&(x=k.value[A+0],z=k.value[A+1],I=k.value[A+2],k.offsetSrc+=3),k.size===2?(k.array[s+
  229. 0]=x.x,k.array[s+1]=x.y,k.array[s+2]=z.x,k.array[s+3]=z.y,k.array[s+4]=I.x,k.array[s+5]=I.y,k.offset+=6):k.size===3?(k.type==="c"?(k.array[s+0]=x.r,k.array[s+1]=x.g,k.array[s+2]=x.b,k.array[s+3]=z.r,k.array[s+4]=z.g,k.array[s+5]=z.b,k.array[s+6]=I.r,k.array[s+7]=I.g,k.array[s+8]=I.b):(k.array[s+0]=x.x,k.array[s+1]=x.y,k.array[s+2]=x.z,k.array[s+3]=z.x,k.array[s+4]=z.y,k.array[s+5]=z.z,k.array[s+6]=I.x,k.array[s+7]=I.y,k.array[s+8]=I.z),k.offset+=9):(k.array[s+0]=x.x,k.array[s+1]=x.y,k.array[s+2]=
  230. x.z,k.array[s+3]=x.w,k.array[s+4]=z.x,k.array[s+5]=z.y,k.array[s+6]=z.z,k.array[s+7]=z.w,k.array[s+8]=I.x,k.array[s+9]=I.y,k.array[s+10]=I.z,k.array[s+11]=I.w,k.offset+=12));if(ra){s=0;for(A=qa.length;s<A;s++)x=qa[s].vertices[p.a].position,z=qa[s].vertices[p.b].position,I=qa[s].vertices[p.c].position,k=ea[s],k[aa+0]=x.x,k[aa+1]=x.y,k[aa+2]=x.z,k[aa+3]=z.x,k[aa+4]=z.y,k[aa+5]=z.z,k[aa+6]=I.x,k[aa+7]=I.y,k[aa+8]=I.z;aa+=9}if(sa.length)s=sa[p.a],A=sa[p.b],k=sa[p.c],X[w]=s.x,X[w+1]=s.y,X[w+2]=s.z,X[w+
  231. 3]=s.w,X[w+4]=A.x,X[w+5]=A.y,X[w+6]=A.z,X[w+7]=A.w,X[w+8]=k.x,X[w+9]=k.y,X[w+10]=k.z,X[w+11]=k.w,s=ya[p.a],A=ya[p.b],k=ya[p.c],W[w]=s.x,W[w+1]=s.y,W[w+2]=s.z,W[w+3]=s.w,W[w+4]=A.x,W[w+5]=A.y,W[w+6]=A.z,W[w+7]=A.w,W[w+8]=k.x,W[w+9]=k.y,W[w+10]=k.z,W[w+11]=k.w,s=wa[p.a],A=wa[p.b],k=wa[p.c],U[w]=s.x,U[w+1]=s.y,U[w+2]=s.z,U[w+3]=1,U[w+4]=A.x,U[w+5]=A.y,U[w+6]=A.z,U[w+7]=1,U[w+8]=k.x,U[w+9]=k.y,U[w+10]=k.z,U[w+11]=1,s=xa[p.a],A=xa[p.b],k=xa[p.c],V[w]=s.x,V[w+1]=s.y,V[w+2]=s.z,V[w+3]=1,V[w+4]=A.x,V[w+5]=
  232. A.y,V[w+6]=A.z,V[w+7]=1,V[w+8]=k.x,V[w+9]=k.y,V[w+10]=k.z,V[w+11]=1,w+=12;if(pa&&v)q.length==3&&v==THREE.VertexColors?(p=q[0],s=q[1],A=q[2]):A=s=p=t,da[$]=p.r,da[$+1]=p.g,da[$+2]=p.b,da[$+3]=s.r,da[$+4]=s.g,da[$+5]=s.b,da[$+6]=A.r,da[$+7]=A.g,da[$+8]=A.b,$+=9;if(na&&fa.hasTangents)q=r[0],t=r[1],p=r[2],T[R]=q.x,T[R+1]=q.y,T[R+2]=q.z,T[R+3]=q.w,T[R+4]=t.x,T[R+5]=t.y,T[R+6]=t.z,T[R+7]=t.w,T[R+8]=p.x,T[R+9]=p.y,T[R+10]=p.z,T[R+11]=p.w,R+=12;if(ma&&y)if(n.length==3&&ha)for(r=0;r<3;r++)H=n[r],N[L]=H.x,
  233. N[L+1]=H.y,N[L+2]=H.z,L+=3;else for(r=0;r<3;r++)N[L]=H.x,N[L+1]=H.y,N[L+2]=H.z,L+=3;if(ia&&B!==void 0&&u)for(r=0;r<3;r++)n=B[r],Y[P]=n.u,Y[P+1]=n.v,P+=2;if(ia&&D!==void 0&&u)for(r=0;r<3;r++)n=D[r],Z[S]=n.u,Z[S+1]=n.v,S+=2;ka&&(la[J]=C,la[J+1]=C+1,la[J+2]=C+2,J+=3,O[M]=C,O[M+1]=C+1,O[M+2]=C,O[M+3]=C+2,O[M+4]=C+1,O[M+5]=C+2,M+=6,C+=3)}else if(p instanceof THREE.Face4){if(ja)x=va[p.a].position,z=va[p.b].position,I=va[p.c].position,E=va[p.d].position,ca[G]=x.x,ca[G+1]=x.y,ca[G+2]=x.z,ca[G+3]=z.x,ca[G+
  234. 4]=z.y,ca[G+5]=z.z,ca[G+6]=I.x,ca[G+7]=I.y,ca[G+8]=I.z,ca[G+9]=E.x,ca[G+10]=E.y,ca[G+11]=E.z,G+=12;if(Q)for(K in Q)if(k=Q[K],k.__original.needsUpdate)s=k.offset,A=k.offsetSrc,k.size===1?(k.boundTo===void 0||k.boundTo==="vertices"?(k.array[s+0]=k.value[p.a],k.array[s+1]=k.value[p.b],k.array[s+2]=k.value[p.c],k.array[s+3]=k.value[p.d]):k.boundTo==="faces"?(k.array[s+0]=k.value[A],k.array[s+1]=k.value[A],k.array[s+2]=k.value[A],k.array[s+3]=k.value[A],k.offsetSrc++):k.boundTo==="faceVertices"&&(k.array[s+
  235. 0]=k.value[A+0],k.array[s+1]=k.value[A+1],k.array[s+2]=k.value[A+2],k.array[s+3]=k.value[A+3],k.offsetSrc+=4),k.offset+=4):(k.boundTo===void 0||k.boundTo==="vertices"?(x=k.value[p.a],z=k.value[p.b],I=k.value[p.c],E=k.value[p.d]):k.boundTo==="faces"?(x=k.value[A],z=k.value[A],I=k.value[A],E=k.value[A],k.offsetSrc++):k.boundTo==="faceVertices"&&(x=k.value[A+0],z=k.value[A+1],I=k.value[A+2],E=k.value[A+3],k.offsetSrc+=4),k.size===2?(k.array[s+0]=x.x,k.array[s+1]=x.y,k.array[s+2]=z.x,k.array[s+3]=z.y,
  236. k.array[s+4]=I.x,k.array[s+5]=I.y,k.array[s+6]=E.x,k.array[s+7]=E.y,k.offset+=8):k.size===3?(k.type==="c"?(k.array[s+0]=x.r,k.array[s+1]=x.g,k.array[s+2]=x.b,k.array[s+3]=z.r,k.array[s+4]=z.g,k.array[s+5]=z.b,k.array[s+6]=I.r,k.array[s+7]=I.g,k.array[s+8]=I.b,k.array[s+9]=E.r,k.array[s+10]=E.g,k.array[s+11]=E.b):(k.array[s+0]=x.x,k.array[s+1]=x.y,k.array[s+2]=x.z,k.array[s+3]=z.x,k.array[s+4]=z.y,k.array[s+5]=z.z,k.array[s+6]=I.x,k.array[s+7]=I.y,k.array[s+8]=I.z,k.array[s+9]=E.x,k.array[s+10]=E.y,
  237. k.array[s+11]=E.z),k.offset+=12):(k.array[s+0]=x.x,k.array[s+1]=x.y,k.array[s+2]=x.z,k.array[s+3]=x.w,k.array[s+4]=z.x,k.array[s+5]=z.y,k.array[s+6]=z.z,k.array[s+7]=z.w,k.array[s+8]=I.x,k.array[s+9]=I.y,k.array[s+10]=I.z,k.array[s+11]=I.w,k.array[s+12]=E.x,k.array[s+13]=E.y,k.array[s+14]=E.z,k.array[s+15]=E.w,k.offset+=16));if(ra){s=0;for(A=qa.length;s<A;s++)x=qa[s].vertices[p.a].position,z=qa[s].vertices[p.b].position,I=qa[s].vertices[p.c].position,E=qa[s].vertices[p.d].position,k=ea[s],k[aa+0]=
  238. x.x,k[aa+1]=x.y,k[aa+2]=x.z,k[aa+3]=z.x,k[aa+4]=z.y,k[aa+5]=z.z,k[aa+6]=I.x,k[aa+7]=I.y,k[aa+8]=I.z,k[aa+9]=E.x,k[aa+10]=E.y,k[aa+11]=E.z;aa+=12}if(sa.length)s=sa[p.a],A=sa[p.b],k=sa[p.c],F=sa[p.d],X[w]=s.x,X[w+1]=s.y,X[w+2]=s.z,X[w+3]=s.w,X[w+4]=A.x,X[w+5]=A.y,X[w+6]=A.z,X[w+7]=A.w,X[w+8]=k.x,X[w+9]=k.y,X[w+10]=k.z,X[w+11]=k.w,X[w+12]=F.x,X[w+13]=F.y,X[w+14]=F.z,X[w+15]=F.w,s=ya[p.a],A=ya[p.b],k=ya[p.c],F=ya[p.d],W[w]=s.x,W[w+1]=s.y,W[w+2]=s.z,W[w+3]=s.w,W[w+4]=A.x,W[w+5]=A.y,W[w+6]=A.z,W[w+7]=A.w,
  239. W[w+8]=k.x,W[w+9]=k.y,W[w+10]=k.z,W[w+11]=k.w,W[w+12]=F.x,W[w+13]=F.y,W[w+14]=F.z,W[w+15]=F.w,s=wa[p.a],A=wa[p.b],k=wa[p.c],F=wa[p.d],U[w]=s.x,U[w+1]=s.y,U[w+2]=s.z,U[w+3]=1,U[w+4]=A.x,U[w+5]=A.y,U[w+6]=A.z,U[w+7]=1,U[w+8]=k.x,U[w+9]=k.y,U[w+10]=k.z,U[w+11]=1,U[w+12]=F.x,U[w+13]=F.y,U[w+14]=F.z,U[w+15]=1,s=xa[p.a],A=xa[p.b],k=xa[p.c],p=xa[p.d],V[w]=s.x,V[w+1]=s.y,V[w+2]=s.z,V[w+3]=1,V[w+4]=A.x,V[w+5]=A.y,V[w+6]=A.z,V[w+7]=1,V[w+8]=k.x,V[w+9]=k.y,V[w+10]=k.z,V[w+11]=1,V[w+12]=p.x,V[w+13]=p.y,V[w+14]=
  240. p.z,V[w+15]=1,w+=16;if(pa&&v)q.length==4&&v==THREE.VertexColors?(p=q[0],s=q[1],A=q[2],q=q[3]):q=A=s=p=t,da[$]=p.r,da[$+1]=p.g,da[$+2]=p.b,da[$+3]=s.r,da[$+4]=s.g,da[$+5]=s.b,da[$+6]=A.r,da[$+7]=A.g,da[$+8]=A.b,da[$+9]=q.r,da[$+10]=q.g,da[$+11]=q.b,$+=12;if(na&&fa.hasTangents)q=r[0],t=r[1],p=r[2],r=r[3],T[R]=q.x,T[R+1]=q.y,T[R+2]=q.z,T[R+3]=q.w,T[R+4]=t.x,T[R+5]=t.y,T[R+6]=t.z,T[R+7]=t.w,T[R+8]=p.x,T[R+9]=p.y,T[R+10]=p.z,T[R+11]=p.w,T[R+12]=r.x,T[R+13]=r.y,T[R+14]=r.z,T[R+15]=r.w,R+=16;if(ma&&y)if(n.length==
  241. 4&&ha)for(r=0;r<4;r++)H=n[r],N[L]=H.x,N[L+1]=H.y,N[L+2]=H.z,L+=3;else for(r=0;r<4;r++)N[L]=H.x,N[L+1]=H.y,N[L+2]=H.z,L+=3;if(ia&&B!==void 0&&u)for(r=0;r<4;r++)n=B[r],Y[P]=n.u,Y[P+1]=n.v,P+=2;if(ia&&D!==void 0&&u)for(r=0;r<4;r++)n=D[r],Z[S]=n.u,Z[S+1]=n.v,S+=2;ka&&(la[J]=C,la[J+1]=C+1,la[J+2]=C+3,la[J+3]=C+1,la[J+4]=C+2,la[J+5]=C+3,J+=6,O[M]=C,O[M+1]=C+1,O[M+2]=C,O[M+3]=C+3,O[M+4]=C+1,O[M+5]=C+2,O[M+6]=C+2,O[M+7]=C+3,M+=8,C+=4)}if(ta){m=0;for(o=ta.length;m<o;m++)la[J]=ta[m].a,la[J+1]=ta[m].b,la[J+
  242. 2]=ta[m].c,la[J+3]=ta[m].a,la[J+4]=ta[m].c,la[J+5]=ta[m].d,J+=6}ja&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglVertexBuffer),c.bufferData(c.ARRAY_BUFFER,ca,j));if(Q)for(K in Q)k=Q[K],k.__original.needsUpdate&&(c.bindBuffer(c.ARRAY_BUFFER,k.buffer),c.bufferData(c.ARRAY_BUFFER,k.array,j));if(ra){s=0;for(A=qa.length;s<A;s++)c.bindBuffer(c.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[s]),c.bufferData(c.ARRAY_BUFFER,ea[s],j)}pa&&$>0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglColorBuffer),c.bufferData(c.ARRAY_BUFFER,
  243. da,j));ma&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglNormalBuffer),c.bufferData(c.ARRAY_BUFFER,N,j));na&&fa.hasTangents&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglTangentBuffer),c.bufferData(c.ARRAY_BUFFER,T,j));ia&&P>0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglUVBuffer),c.bufferData(c.ARRAY_BUFFER,Y,j));ia&&S>0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglUV2Buffer),c.bufferData(c.ARRAY_BUFFER,Z,j));ka&&(c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,la,j),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
  244. g.__webglLineBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,O,j));w>0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinVertexABuffer),c.bufferData(c.ARRAY_BUFFER,U,j),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),c.bufferData(c.ARRAY_BUFFER,V,j),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),c.bufferData(c.ARRAY_BUFFER,W,j),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),c.bufferData(c.ARRAY_BUFFER,X,j));i.dynamic||(delete g.__inittedArrays,delete g.__colorArray,delete g.__normalArray,
  245. delete g.__tangentArray,delete g.__uvArray,delete g.__uv2Array,delete g.__faceArray,delete g.__vertexArray,delete g.__lineArray,delete g.__skinVertexAArray,delete g.__skinVertexBArray,delete g.__skinIndexArray,delete g.__skinWeightArray)}}f.__dirtyVertices=!1;f.__dirtyMorphTargets=!1;f.__dirtyElements=!1;f.__dirtyUvs=!1;f.__dirtyNormals=!1;f.__dirtyTangents=!1;f.__dirtyColors=!1;var ga;h=h.__materials;f=0;for(b=h.length;f<b;f++)if(e=h[f],e.attributes)for(ga in e.attributes)e.attributes[ga].needsUpdate=
  246. !1}else if(b instanceof THREE.Ribbon){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){ga=f;b=c.DYNAMIC_DRAW;o=ga.vertices;h=ga.colors;u=o.length;g=h.length;v=ga.__vertexArray;i=ga.__colorArray;y=ga.__dirtyColors;if(ga.__dirtyVertices){for(j=0;j<u;j++)m=o[j].position,e=j*3,v[e]=m.x,v[e+1]=m.y,v[e+2]=m.z;c.bindBuffer(c.ARRAY_BUFFER,ga.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,v,b)}if(y){for(j=0;j<g;j++)color=h[j],e=j*3,i[e]=color.r,i[e+1]=color.g,i[e+2]=color.b;c.bindBuffer(c.ARRAY_BUFFER,
  247. ga.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,i,b)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(b instanceof THREE.Line){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){ga=f;b=c.DYNAMIC_DRAW;o=ga.vertices;h=ga.colors;u=o.length;g=h.length;v=ga.__vertexArray;i=ga.__colorArray;y=ga.__dirtyColors;if(ga.__dirtyVertices){for(j=0;j<u;j++)m=o[j].position,e=j*3,v[e]=m.x,v[e+1]=m.y,v[e+2]=m.z;c.bindBuffer(c.ARRAY_BUFFER,ga.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,v,b)}if(y){for(j=0;j<
  248. g;j++)color=h[j],e=j*3,i[e]=color.r,i[e+1]=color.g,i[e+2]=color.b;c.bindBuffer(c.ARRAY_BUFFER,ga.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,i,b)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(b instanceof THREE.ParticleSystem)f=b.geometry,(f.__dirtyVertices||f.__dirtyColors||b.sortParticles)&&d(f,c.DYNAMIC_DRAW,b),f.__dirtyVertices=!1,f.__dirtyColors=!1}function M(b,c){var e;for(e=b.length-1;e>=0;e--)b[e].object==c&&b.splice(e,1)}function N(b){function c(b){var f=[];e=0;for(d=b.length;e<d;e++)b[e]==
  249. void 0?f.push("undefined"):f.push(b[e].id);return f.join("_")}var e,d,f,g,h,i,j,m,p={},o=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};f=0;for(g=b.faces.length;f<g;f++)h=b.faces[f],i=h.materials,j=c(i),p[j]==void 0&&(p[j]={hash:j,counter:0}),m=p[j].hash+"_"+p[j].counter,b.geometryGroups[m]==void 0&&(b.geometryGroups[m]={faces:[],materials:i,vertices:0,numMorphTargets:o}),h=h instanceof THREE.Face3?3:4,b.geometryGroups[m].vertices+h>65535&&(p[j].counter+=1,m=p[j].hash+"_"+p[j].counter,
  250. b.geometryGroups[m]==void 0&&(b.geometryGroups[m]={faces:[],materials:i,vertices:0,numMorphTargets:o})),b.geometryGroups[m].faces.push(f),b.geometryGroups[m].vertices+=h}function F(b,c,e){b.push({buffer:c,object:e,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function y(b){if(b!=E){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;
  251. 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)}E=b}}function Y(b,e,d){(d.width&d.width-1)==0&&(d.height&d.height-1)==0?(c.texParameteri(b,c.TEXTURE_WRAP_S,S(e.wrapS)),c.texParameteri(b,c.TEXTURE_WRAP_T,S(e.wrapT)),c.texParameteri(b,c.TEXTURE_MAG_FILTER,S(e.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,S(e.minFilter)),
  252. 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,ka(e.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,ka(e.minFilter)))}function C(b,e){if(b.needsUpdate)b.__webglInit?(c.bindTexture(c.TEXTURE_2D,b.__webglTexture),c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,b.image)):(b.__webglTexture=c.createTexture(),c.bindTexture(c.TEXTURE_2D,b.__webglTexture),c.texImage2D(c.TEXTURE_2D,
  253. 0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,b.image),b.__webglInit=!0),Y(c.TEXTURE_2D,b,b.image),c.bindTexture(c.TEXTURE_2D,null),b.needsUpdate=!1;c.activeTexture(c.TEXTURE0+e);c.bindTexture(c.TEXTURE_2D,b.__webglTexture)}function Z(b){if(b&&!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);
  254. c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,S(b.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,S(b.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,S(b.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,S(b.minFilter));c.texImage2D(c.TEXTURE_2D,0,S(b.format),b.width,b.height,0,S(b.format),S(b.type),null);c.bindRenderbuffer(c.RENDERBUFFER,b.__webglRenderbuffer);c.bindFramebuffer(c.FRAMEBUFFER,b.__webglFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,
  255. 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)):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,
  256. b.height);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var e,d;b?(e=b.__webglFramebuffer,d=b.width,b=b.height):(e=null,d=_viewportWidth,b=_viewportHeight);e!=ma&&(c.bindFramebuffer(c.FRAMEBUFFER,e),c.viewport(_viewportX,_viewportY,d,b),ma=e)}function K(b,e){var d;b=="fragment"?d=c.createShader(c.FRAGMENT_SHADER):b=="vertex"&&(d=c.createShader(c.VERTEX_SHADER));c.shaderSource(d,e);c.compileShader(d);if(!c.getShaderParameter(d,c.COMPILE_STATUS))return console.error(c.getShaderInfoLog(d)),
  257. console.error(e),null;return d}function ka(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;default:return c.LINEAR}}function S(b){switch(b){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;
  258. case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE;case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;
  259. 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 P=this,c,na=[],ia=null,ma=null,O=!0,J=null,ha=null,E=null,L=null,G=null;_oldPolygonOffsetUnits=_oldPolygonOffsetFactor=null;_cullEnabled=!0;_viewportHeight=_viewportWidth=_viewportY=_viewportX=0;_frustum=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4];_projScreenMatrix=
  260. new THREE.Matrix4;_projectionMatrixArray=new Float32Array(16);_viewMatrixArray=new Float32Array(16);_vector3=new THREE.Vector4;_lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};b=b||{};_canvas=b.canvas!==void 0?b.canvas:document.createElement("canvas");_stencil=b.stencil!==void 0?b.stencil:!0;_antialias=b.antialias!==void 0?b.antialias:!1;_clearColor=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0);_clearAlpha=
  261. b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=_canvas;this.sortObjects=this.autoClear=!0;try{if(!(c=_canvas.getContext("experimental-webgl",{antialias:_antialias,stencil:_stencil})))throw"Error creating WebGL context.";}catch(Q){console.error(Q)}console.log(navigator.userAgent+" | "+c.getParameter(c.VERSION)+" | "+c.getParameter(c.VENDOR)+" | "+c.getParameter(c.RENDERER)+" | "+c.getParameter(c.SHADING_LANGUAGE_VERSION));c.clearColor(0,
  262. 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(_clearColor.r,_clearColor.g,_clearColor.b,_clearAlpha);_cullEnabled=!0;this.context=c;var ja=c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(_stencil){var v={};v.vertices=new Float32Array(12);v.faces=new Uint16Array(6);v.darkness=0.5;v.vertices[0]=-20;v.vertices[1]=
  263. -20;v.vertices[2]=-1;v.vertices[3]=20;v.vertices[4]=-20;v.vertices[5]=-1;v.vertices[6]=20;v.vertices[7]=20;v.vertices[8]=-1;v.vertices[9]=-20;v.vertices[10]=20;v.vertices[11]=-1;v.faces[0]=0;v.faces[1]=1;v.faces[2]=2;v.faces[3]=0;v.faces[4]=2;v.faces[5]=3;v.vertexBuffer=c.createBuffer();v.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,v.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,v.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,
  264. v.faces,c.STATIC_DRAW);v.program=c.createProgram();c.attachShader(v.program,K("fragment",THREE.ShaderLib.shadowPost.fragmentShader));c.attachShader(v.program,K("vertex",THREE.ShaderLib.shadowPost.vertexShader));c.linkProgram(v.program);v.vertexLocation=c.getAttribLocation(v.program,"position");v.projectionLocation=c.getUniformLocation(v.program,"projectionMatrix");v.darknessLocation=c.getUniformLocation(v.program,"darkness")}var u={};u.vertices=new Float32Array(16);u.faces=new Uint16Array(6);b=0;
  265. u.vertices[b++]=-1;u.vertices[b++]=-1;u.vertices[b++]=0;u.vertices[b++]=0;u.vertices[b++]=1;u.vertices[b++]=-1;u.vertices[b++]=1;u.vertices[b++]=0;u.vertices[b++]=1;u.vertices[b++]=1;u.vertices[b++]=1;u.vertices[b++]=1;u.vertices[b++]=-1;u.vertices[b++]=1;u.vertices[b++]=0;u.vertices[b++]=1;b=0;u.faces[b++]=0;u.faces[b++]=1;u.faces[b++]=2;u.faces[b++]=0;u.faces[b++]=2;u.faces[b++]=3;u.vertexBuffer=c.createBuffer();u.elementBuffer=c.createBuffer();u.tempTexture=c.createTexture();u.occlusionTexture=
  266. c.createTexture();c.bindBuffer(c.ARRAY_BUFFER,u.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,u.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,u.faces,c.STATIC_DRAW);c.bindTexture(c.TEXTURE_2D,u.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,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,
  267. c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);c.bindTexture(c.TEXTURE_2D,u.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,c.NEAREST);c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0?(u.hasVertexTexture=
  268. !1,u.program=c.createProgram(),c.attachShader(u.program,K("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),c.attachShader(u.program,K("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(u.hasVertexTexture=!0,u.program=c.createProgram(),c.attachShader(u.program,K("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),c.attachShader(u.program,K("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));c.linkProgram(u.program);u.attributes={};u.uniforms={};u.attributes.vertex=
  269. c.getAttribLocation(u.program,"position");u.attributes.uv=c.getAttribLocation(u.program,"UV");u.uniforms.renderType=c.getUniformLocation(u.program,"renderType");u.uniforms.map=c.getUniformLocation(u.program,"map");u.uniforms.occlusionMap=c.getUniformLocation(u.program,"occlusionMap");u.uniforms.opacity=c.getUniformLocation(u.program,"opacity");u.uniforms.scale=c.getUniformLocation(u.program,"scale");u.uniforms.rotation=c.getUniformLocation(u.program,"rotation");u.uniforms.screenPosition=c.getUniformLocation(u.program,
  270. "screenPosition");var pa=!1;_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6);b=0;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;
  271. b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]=2;_sprite.faces[b++]=3;_sprite.vertexBuffer=c.createBuffer();_sprite.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,_sprite.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,_sprite.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,_sprite.faces,c.STATIC_DRAW);_sprite.program=c.createProgram();c.attachShader(_sprite.program,
  272. K("fragment",THREE.ShaderLib.sprite.fragmentShader));c.attachShader(_sprite.program,K("vertex",THREE.ShaderLib.sprite.vertexShader));c.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=c.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=c.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=c.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=c.getUniformLocation(_sprite.program,"uvScale");_sprite.uniforms.rotation=
  273. c.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=c.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment=c.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=c.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=c.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=c.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=c.getUniformLocation(_sprite.program,
  274. "affectedByDistance");_sprite.uniforms.screenPosition=c.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=c.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=c.getUniformLocation(_sprite.program,"projectionMatrix");var ra=!1;this.setSize=function(b,c){_canvas.width=b;_canvas.height=c;this.setViewport(0,0,_canvas.width,_canvas.height)};this.setViewport=function(b,e,d,f){_viewportX=b;_viewportY=e;_viewportWidth=d;_viewportHeight=
  275. f;c.viewport(_viewportX,_viewportY,_viewportWidth,_viewportHeight)};this.setScissor=function(b,e,d,f){c.scissor(b,e,d,f)};this.enableScissorTest=function(b){b?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){O=b;c.depthMask(b)};this.setClearColorHex=function(b,e){_clearColor.setHex(b);_clearAlpha=e;c.clearColor(_clearColor.r,_clearColor.g,_clearColor.b,_clearAlpha)};this.setClearColor=function(b,e){_clearColor.copy(b);_clearAlpha=e;c.clearColor(_clearColor.r,
  276. _clearColor.g,_clearColor.b,_clearAlpha)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT|c.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){v.darkness=b};this.getContext=function(){return c};this.initMaterial=function(b,e,d,f){var g,h,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?
  277. i="lambert":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 m,o,p;m=p=j=0;for(o=e.length;m<o;m++)h=e[m],h instanceof THREE.DirectionalLight&&p++,h instanceof THREE.PointLight&&j++;j+p<=4?e=p:(e=Math.ceil(4*p/(j+p)),j=4-e);h={directional:e,point:j};
  278. p=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)p=f.bones.length;var n;a:{m=b.fragmentShader;o=b.vertexShader;var j=b.uniforms,e=b.attributes,d={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:d,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:h.directional,maxPointLights:h.point,maxBones:p},r;h=[];i?h.push(i):(h.push(m),h.push(o));for(r in d)h.push(r),h.push(d[r]);i=h.join();
  279. r=0;for(h=na.length;r<h;r++)if(na[r].code==i){n=na[r].program;break a}r=c.createProgram();h=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+d.maxDirLights,"#define MAX_POINT_LIGHTS "+d.maxPointLights,d.fog?"#define USE_FOG":"",d.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",d.map?"#define USE_MAP":"",d.envMap?"#define USE_ENVMAP":"",d.lightMap?"#define USE_LIGHTMAP":"",d.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");
  280. p=[ja?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+d.maxDirLights,"#define MAX_POINT_LIGHTS "+d.maxPointLights,"#define MAX_BONES "+d.maxBones,d.map?"#define USE_MAP":"",d.envMap?"#define USE_ENVMAP":"",d.lightMap?"#define USE_LIGHTMAP":"",d.vertexColors?"#define USE_COLOR":"",d.skinning?"#define USE_SKINNING":"",d.morphTargets?"#define USE_MORPHTARGETS":"",d.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
  281. c.attachShader(r,K("fragment",h+m));c.attachShader(r,K("vertex",p+o));c.linkProgram(r);c.getProgramParameter(r,c.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+c.getProgramParameter(r,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");r.uniforms={};r.attributes={};var q;m=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(q in j)m.push(q);q=m;j=0;for(m=
  282. q.length;j<m;j++)o=q[j],r.uniforms[o]=c.getUniformLocation(r,o);m=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(q=0;q<d.maxMorphTargets;q++)m.push("morphTarget"+q);for(n in e)m.push(n);n=m;q=0;for(e=n.length;q<e;q++)d=n[q],r.attributes[d]=c.getAttribLocation(r,d);na.push({program:r,code:i});n=r}b.program=n;n=b.program.attributes;n.position>=0&&c.enableVertexAttribArray(n.position);n.color>=0&&c.enableVertexAttribArray(n.color);n.normal>=
  283. 0&&c.enableVertexAttribArray(n.normal);n.tangent>=0&&c.enableVertexAttribArray(n.tangent);b.skinning&&n.skinVertexA>=0&&n.skinVertexB>=0&&n.skinIndex>=0&&n.skinWeight>=0&&(c.enableVertexAttribArray(n.skinVertexA),c.enableVertexAttribArray(n.skinVertexB),c.enableVertexAttribArray(n.skinIndex),c.enableVertexAttribArray(n.skinWeight));if(b.attributes)for(g in b.attributes)n[g]!==void 0&&n[g]>=0&&c.enableVertexAttribArray(n[g]);if(b.morphTargets){b.numSupportedMorphTargets=0;n.morphTarget0>=0&&(c.enableVertexAttribArray(n.morphTarget0),
  284. b.numSupportedMorphTargets++);n.morphTarget1>=0&&(c.enableVertexAttribArray(n.morphTarget1),b.numSupportedMorphTargets++);n.morphTarget2>=0&&(c.enableVertexAttribArray(n.morphTarget2),b.numSupportedMorphTargets++);n.morphTarget3>=0&&(c.enableVertexAttribArray(n.morphTarget3),b.numSupportedMorphTargets++);n.morphTarget4>=0&&(c.enableVertexAttribArray(n.morphTarget4),b.numSupportedMorphTargets++);n.morphTarget5>=0&&(c.enableVertexAttribArray(n.morphTarget5),b.numSupportedMorphTargets++);n.morphTarget6>=
  285. 0&&(c.enableVertexAttribArray(n.morphTarget6),b.numSupportedMorphTargets++);n.morphTarget7>=0&&(c.enableVertexAttribArray(n.morphTarget7),b.numSupportedMorphTargets++);f.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);b=0;for(g=this.maxMorphTargets;b<g;b++)f.__webglMorphTargetInfluences[b]=0}};this.render=function(b,d,n,v){var u,E,oa,C,F,G,p,H,J=b.lights,K=b.fog;P.data.vertices=0;P.data.faces=0;P.data.drawCalls=0;d.matrixAutoUpdate&&d.update(void 0,!0);b.update(void 0,!1,d);d.matrixWorldInverse.flattenToArray(_viewMatrixArray);
  286. d.projectionMatrix.flattenToArray(_projectionMatrixArray);_projScreenMatrix.multiply(d.projectionMatrix,d.matrixWorldInverse);o(_projScreenMatrix);this.initWebGLObjects(b);Z(n);(this.autoClear||v)&&this.clear();F=b.__webglObjects.length;for(v=0;v<F;v++)if(u=b.__webglObjects[v],p=u.object,p.visible)if(!(p instanceof THREE.Mesh)||m(p)){if(p.matrixWorld.flattenToArray(p._objectMatrixArray),B(p,d),t(u),u.render=!0,this.sortObjects)u.object.renderDepth?u.z=u.object.renderDepth:(_vector3.copy(p.position),
  287. _projScreenMatrix.multiplyVector3(_vector3),u.z=_vector3.z)}else u.render=!1;else u.render=!1;this.sortObjects&&b.__webglObjects.sort(r);G=b.__webglObjectsImmediate.length;for(v=0;v<G;v++)u=b.__webglObjectsImmediate[v],p=u.object,p.visible&&(p.matrixAutoUpdate&&p.matrixWorld.flattenToArray(p._objectMatrixArray),B(p,d),q(u));y(THREE.NormalBlending);for(v=0;v<F;v++)if(u=b.__webglObjects[v],u.render){p=u.object;H=u.buffer;oa=u.opaque;i(p);for(u=0;u<oa.count;u++)C=oa.list[u],h(C.depthTest),j(C.polygonOffset,
  288. C.polygonOffsetFactor,C.polygonOffsetUnits),f(d,J,K,C,H,p)}for(v=0;v<G;v++)if(u=b.__webglObjectsImmediate[v],p=u.object,p.visible){oa=u.opaque;i(p);for(u=0;u<oa.count;u++)C=oa.list[u],h(C.depthTest),j(C.polygonOffset,C.polygonOffsetFactor,C.polygonOffsetUnits),E=e(d,J,K,C,p),p.render(function(b){g(b,E,C.shading)})}for(v=0;v<F;v++)if(u=b.__webglObjects[v],u.render){p=u.object;H=u.buffer;oa=u.transparent;i(p);for(u=0;u<oa.count;u++)C=oa.list[u],y(C.blending),h(C.depthTest),j(C.polygonOffset,C.polygonOffsetFactor,
  289. C.polygonOffsetUnits),f(d,J,K,C,H,p)}for(v=0;v<G;v++)if(u=b.__webglObjectsImmediate[v],p=u.object,p.visible){oa=u.transparent;i(p);for(u=0;u<oa.count;u++)C=oa.list[u],y(C.blending),h(C.depthTest),j(C.polygonOffset,C.polygonOffsetFactor,C.polygonOffsetUnits),E=e(d,J,K,C,p),p.render(function(b){g(b,E,C.shading)})}b.__webglSprites.length&&x(b,d);_stencil&&b.__webglShadowVolumes.length&&b.lights.length&&D(b);b.__webglLensFlares.length&&z(b,d);n&&n.minFilter!==THREE.NearestFilter&&n.minFilter!==THREE.LinearFilter&&
  290. (c.bindTexture(c.TEXTURE_2D,n.__webglTexture),c.generateMipmap(c.TEXTURE_2D),c.bindTexture(c.TEXTURE_2D,null))};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=
  291. new Float32Array(16),d._objectMatrixArray=new Float32Array(16),d.matrixWorld.flattenToArray(d._objectMatrixArray);if(d instanceof THREE.Mesh)for(f in g=d.geometry,g.geometryGroups==void 0&&N(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=
  292. c.createBuffer();i.__webglSkinVertexBBuffer=c.createBuffer();i.__webglSkinIndicesBuffer=c.createBuffer();i.__webglSkinWeightsBuffer=c.createBuffer();i.__webglFaceBuffer=c.createBuffer();i.__webglLineBuffer=c.createBuffer();if(i.numMorphTargets){var j=void 0,m=void 0;i.__webglMorphTargetsBuffers=[];j=0;for(m=i.numMorphTargets;j<m;j++)i.__webglMorphTargetsBuffers.push(c.createBuffer())}for(var i=h,j=d,n=void 0,p=void 0,o=void 0,r=o=void 0,q=void 0,u=void 0,v=u=m=0,t=o=p=void 0,x=t=p=n=void 0,o=void 0,
  293. r=j.geometry,q=r.faces,t=i.faces,n=0,p=t.length;n<p;n++)o=t[n],o=q[o],o instanceof THREE.Face3?(m+=3,u+=1,v+=3):o instanceof THREE.Face4&&(m+=4,u+=2,v+=4);for(var n=i,p=j,y=t=q=void 0,z=void 0,y=void 0,o=[],q=0,t=p.materials.length;q<t;q++)if(y=p.materials[q],y instanceof THREE.MeshFaceMaterial){y=0;for(l=n.materials.length;y<l;y++)(z=n.materials[y])&&o.push(z)}else(z=y)&&o.push(z);n=o;i.__materials=n;a:{q=p=void 0;t=n.length;for(p=0;p<t;p++)if(q=n[p],q.map||q.lightMap||q instanceof THREE.MeshShaderMaterial){p=
  294. !0;break a}p=!1}a:{t=q=void 0;o=n.length;for(q=0;q<o;q++)if(t=n[q],!(t instanceof THREE.MeshBasicMaterial&&!t.envMap||t instanceof THREE.MeshDepthMaterial)){t=t&&t.shading!=void 0&&t.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}t=!1}a:{o=q=void 0;y=n.length;for(q=0;q<y;q++)if(o=n[q],o.vertexColors){o=o.vertexColors;break a}o=!1}i.__vertexArray=new Float32Array(m*3);if(t)i.__normalArray=new Float32Array(m*3);if(r.hasTangents)i.__tangentArray=new Float32Array(m*4);if(o)i.__colorArray=
  295. new Float32Array(m*3);if(p){if(r.faceUvs.length>0||r.faceVertexUvs.length>0)i.__uvArray=new Float32Array(m*2);if(r.faceUvs.length>1||r.faceVertexUvs.length>1)i.__uv2Array=new Float32Array(m*2)}if(j.geometry.skinWeights.length&&j.geometry.skinIndices.length)i.__skinVertexAArray=new Float32Array(m*4),i.__skinVertexBArray=new Float32Array(m*4),i.__skinIndexArray=new Float32Array(m*4),i.__skinWeightArray=new Float32Array(m*4);i.__faceArray=new Uint16Array(u*3+(j.geometry.edgeFaces?j.geometry.edgeFaces.length*
  296. 6:0));i.__lineArray=new Uint16Array(v*2);if(i.numMorphTargets){i.__morphTargetsArrays=[];r=0;for(q=i.numMorphTargets;r<q;r++)i.__morphTargetsArrays.push(new Float32Array(m*3))}i.__needsSmoothNormals=t==THREE.SmoothShading;i.__uvType=p;i.__vertexColorType=o;i.__normalType=t;i.__webglFaceCount=u*3+(j.geometry.edgeFaces?j.geometry.edgeFaces.length*6:0);i.__webglLineCount=v*2;r=0;for(q=n.length;r<q;r++)if(p=n[r],p.attributes)for(a in i.__webglCustomAttributes={},p.attributes){o=p.attributes[a];t={};for(x in o)t[x]=
  297. o[x];if(!t.__webglInitialized||t.createUniqueBuffers)t.__webglInitialized=!0,u=1,t.type==="v2"?u=2:t.type==="v3"?u=3:t.type==="v4"?u=4:t.type==="c"&&(u=3),t.size=u,t.array=new Float32Array(m*u),t.buffer=c.createBuffer(),t.buffer.belongsToAttribute=a,o.needsUpdate=!0,t.__original=o;i.__webglCustomAttributes[a]=t}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?
  298. F(e.__webglShadowVolumes,h,d):F(e.__webglObjects,h,d)}else if(d instanceof THREE.LensFlare)F(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;F(e.__webglObjects,g,d)}else if(d instanceof THREE.Line){g=d.geometry;
  299. 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.__webglLineCount=h,g.__dirtyVertices=!0,g.__dirtyColors=!0;F(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=f.vertices.length,f.__vertexArray=new Float32Array(h*
  300. 3),f.__colorArray=new Float32Array(h*3),f.__sortArray=[],f.__webglParticleCount=h,g.__dirtyVertices=!0,g.__dirtyColors=!0;F(e.__webglObjects,g,d)}else THREE.MarchingCubes!==void 0&&d instanceof THREE.MarchingCubes?e.__webglObjectsImmediate.push({object:d,opaque:{list:[],count:0},transparent:{list:[],count:0}}):d instanceof THREE.Sprite&&e.__webglSprites.push(d);b.__objectsAdded.splice(0,1)}for(;b.__objectsRemoved.length;)d=b.__objectsRemoved[0],e=b,d instanceof THREE.ShadowVolume?M(e.__webglShadowVolumes,
  301. d):d instanceof THREE.Mesh||d instanceof THREE.ParticleSystem||d instanceof THREE.Ribbon||d instanceof THREE.Line?M(e.__webglObjects,d):d instanceof THREE.Sprite?M(e.__webglSprites,d):d instanceof THREE.LensFlare?M(e.__webglLensFlares,d):d instanceof THREE.MarchingCubes&&M(e.__webglObjectsImmediate,d),b.__objectsRemoved.splice(0,1);d=0;for(e=b.__webglObjects.length;d<e;d++)ea(b.__webglObjects[d].object,b);d=0;for(e=b.__webglShadowVolumes.length;d<e;d++)ea(b.__webglShadowVolumes[d].object,b);d=0;for(e=
  302. b.__webglLensFlares.length;d<e;d++)ea(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"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK),c.enable(c.CULL_FACE)):c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return ja}};
  303. 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:
  304. THREE.UnsignedByteType;this.depthBuffer=e.depthBuffer!==void 0?e.depthBuffer:!0;this.stencilBuffer=e.stencilBuffer!==void 0?e.stencilBuffer:!0};