ThreeWebGL.js 149 KB

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