ThreeWebGL.js 149 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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,h,f;if(c===0)this.r=this.g=this.b=0;else switch(e=Math.floor(a*6),h=a*6-e,a=c*(1-b),f=c*(1-
  4. b*h),b=c*(1-b*(1-h)),e){case 1:this.r=f;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=f;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=f;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,D){e.copy(D).subSelf(b);
  18. h.copy(c).subSelf(b);f.copy(a).subSelf(b);i=e.dot(e);k=e.dot(h);r=e.dot(f);n=h.dot(h);l=h.dot(f);t=1/(i*n-k*k);B=(n*r-k*l)*t;C=(i*l-k*r)*t;return B>=0&&C>=0&&B+C<1}for(var e=new THREE.Vector3,h=new THREE.Vector3,f=new THREE.Vector3,i,k,r,n,l,t,B,C,D,G=[],F=0,ra=a.children.length;F<ra;F++)Array.prototype.push.apply(G,this.intersectObject(a.children[F]));if(a instanceof THREE.Particle){F=b(this.origin,this.direction,a.matrixWorld.getPosition());if(F===null||F>a.scale.x)return[];D={distance:F,point:a.position,
  19. face:null,object:a};G.push(D)}else if(a instanceof THREE.Mesh){F=b(this.origin,this.direction,a.matrixWorld.getPosition());if(F===null||F>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return G;var O,la,na,S,da,K,V,Y,J=a.geometry,W=J.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);F=0;for(ra=J.faces.length;F<ra;F++)if(D=J.faces[F],V=this.origin.clone(),Y=this.direction.clone(),S=a.matrixWorld,O=S.multiplyVector3(D.centroid.clone()).subSelf(V),K=O.dot(Y),
  20. !(K<=0)&&(O=S.multiplyVector3(W[D.a].position.clone()),la=S.multiplyVector3(W[D.b].position.clone()),na=S.multiplyVector3(W[D.c].position.clone()),S=D instanceof THREE.Face4?S.multiplyVector3(W[D.d].position.clone()):null,da=a.matrixRotationWorld.multiplyVector3(D.normal.clone()),K=Y.dot(da),a.doubleSided||(a.flipSided?K>0:K<0)))if(K=da.dot((new THREE.Vector3).sub(O,V))/K,V=V.addSelf(Y.multiplyScalar(K)),D instanceof THREE.Face3)c(V,O,la,na)&&(D={distance:this.origin.distanceTo(V),point:V,face:D,
  21. object:a},G.push(D));else if(D instanceof THREE.Face4&&(c(V,O,la,S)||c(V,la,na,S)))D={distance:this.origin.distanceTo(V),point:V,face:D,object:a},G.push(D)}return G}};
  22. THREE.Rectangle=function(){function a(){f=e-b;i=h-c}var b,c,e,h,f,i,k=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return i};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return h};this.set=function(f,i,l,t){k=!1;b=f;c=i;e=l;h=t;a()};this.addPoint=function(f,i){k?(k=!1,b=f,c=i,e=f,h=i):(b=b<f?b:f,c=c<i?c:i,e=e>f?e:f,h=h>i?h:i);a()};this.add3Points=
  23. function(f,i,l,t,B,C){k?(k=!1,b=f<l?f<B?f:B:l<B?l:B,c=i<t?i<C?i:C:t<C?t:C,e=f>l?f>B?f:B:l>B?l:B,h=i>t?i>C?i:C:t>C?t:C):(b=f<l?f<B?f<b?f:b:B<b?B:b:l<B?l<b?l:b:B<b?B:b,c=i<t?i<C?i<c?i:c:C<c?C:c:t<C?t<c?t:c:C<c?C:c,e=f>l?f>B?f>e?f:e:B>e?B:e:l>B?l>e?l:e:B>e?B:e,h=i>t?i>C?i>h?i:h:C>h?C:h:t>C?t>h?t:h:C>h?C:h);a()};this.addRectangle=function(f){k?(k=!1,b=f.getLeft(),c=f.getTop(),e=f.getRight(),h=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),e=e>f.getRight()?e:f.getRight(),h=h>
  24. f.getBottom()?h:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;e+=f;h+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();e=e<f.getRight()?e:f.getRight();h=h<f.getBottom()?h:f.getBottom();a()};this.intersects=function(a){return Math.min(e,a.getRight())-Math.max(b,a.getLeft())>=0&&Math.min(h,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){k=!0;h=e=c=b=0;a()};this.isEmpty=function(){return k}};
  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,h){return e+(a-b)*(h-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,h,f,i,k,r,n,l,t,B,C,D,G){this.set(a!==void 0?a:1,b||0,c||0,e||0,h||0,f!==void 0?f:1,i||0,k||0,r||0,n||0,l!==void 0?l:1,t||0,B||0,C||0,D||0,G!==void 0?G:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
  28. THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,e,h,f,i,k,r,n,l,t,B,C,D,G){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=h;this.n22=f;this.n23=i;this.n24=k;this.n31=r;this.n32=n;this.n33=l;this.n34=t;this.n41=B;this.n42=C;this.n43=D;this.n44=G;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,h=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();if(f.length()===0)f.z=1;e.cross(c,f).normalize();e.length()===0&&(f.x+=1.0E-4,e.cross(c,f).normalize());h.cross(f,e).normalize();this.n11=e.x;this.n12=h.x;this.n13=f.x;this.n21=e.y;this.n22=h.y;this.n23=f.y;this.n31=e.z;this.n32=h.z;this.n33=f.z;return this},multiply:function(a,b){var c=a.n11,e=a.n12,h=a.n13,f=a.n14,i=a.n21,k=a.n22,r=a.n23,n=a.n24,l=a.n31,t=a.n32,B=a.n33,C=a.n34,D=a.n41,G=a.n42,F=a.n43,
  30. ra=a.n44,O=b.n11,la=b.n12,na=b.n13,S=b.n14,da=b.n21,K=b.n22,V=b.n23,Y=b.n24,J=b.n31,W=b.n32,aa=b.n33,ma=b.n34,xa=b.n41,ka=b.n42,N=b.n43,d=b.n44;this.n11=c*O+e*da+h*J+f*xa;this.n12=c*la+e*K+h*W+f*ka;this.n13=c*na+e*V+h*aa+f*N;this.n14=c*S+e*Y+h*ma+f*d;this.n21=i*O+k*da+r*J+n*xa;this.n22=i*la+k*K+r*W+n*ka;this.n23=i*na+k*V+r*aa+n*N;this.n24=i*S+k*Y+r*ma+n*d;this.n31=l*O+t*da+B*J+C*xa;this.n32=l*la+t*K+B*W+C*ka;this.n33=l*na+t*V+B*aa+C*N;this.n34=l*S+t*Y+B*ma+C*d;this.n41=D*O+G*da+F*J+ra*xa;this.n42=
  31. D*la+G*K+F*W+ra*ka;this.n43=D*na+G*V+F*aa+ra*N;this.n44=D*S+G*Y+F*ma+ra*d;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,h=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)*h;a.y=(this.n21*b+this.n22*c+this.n23*e+this.n24)*h;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,h=a.w;a.x=this.n11*b+this.n12*c+this.n13*
  33. e+this.n14*h;a.y=this.n21*b+this.n22*c+this.n23*e+this.n24*h;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*h;a.w=this.n41*b+this.n42*c+this.n43*e+this.n44*h;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,h=this.n21,f=this.n22,i=this.n23,k=this.n24,r=this.n31,n=this.n32,l=this.n33,t=this.n34,B=this.n41,C=this.n42,D=this.n43,G=this.n44;return e*i*n*B-c*k*n*B-e*f*l*B+b*k*l*B+c*f*t*B-b*i*t*B-e*i*r*C+c*k*r*C+e*h*l*C-a*k*l*C-c*h*t*C+a*i*t*C+e*f*r*D-b*k*r*D-e*h*n*D+a*k*n*D+b*h*t*D-a*f*t*D-c*f*r*G+b*i*r*G+
  35. c*h*n*G-a*i*n*G-b*h*l*G+a*f*l*G},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),h=1-c,f=a.x,i=a.y,k=a.z,r=h*f,n=h*i;this.set(r*f+c,r*i-e*k,r*k+e*i,0,r*i+e*k,n*i+c,n*k-e*f,0,r*k-e*i,n*k+e*f,h*k*k+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,h=a.n14,f=a.n21,i=a.n22,k=a.n23,r=a.n24,n=a.n31,l=a.n32,t=a.n33,B=a.n34,C=a.n41,D=a.n42,G=a.n43,F=a.n44;this.n11=k*B*D-r*t*D+r*l*G-i*B*G-k*l*F+i*t*F;this.n12=h*t*D-e*B*D-h*l*G+c*B*G+e*l*F-c*t*F;this.n13=e*r*D-h*k*D+h*i*G-c*r*G-e*i*F+c*k*F;this.n14=h*k*l-e*r*l-h*i*t+c*r*t+e*i*B-c*k*B;this.n21=r*t*C-k*B*C-r*n*G+f*B*G+k*n*F-f*t*F;this.n22=e*B*C-h*t*C+
  41. h*n*G-b*B*G-e*n*F+b*t*F;this.n23=h*k*C-e*r*C-h*f*G+b*r*G+e*f*F-b*k*F;this.n24=e*r*n-h*k*n+h*f*t-b*r*t-e*f*B+b*k*B;this.n31=i*B*C-r*l*C+r*n*D-f*B*D-i*n*F+f*l*F;this.n32=h*l*C-c*B*C-h*n*D+b*B*D+c*n*F-b*l*F;this.n33=e*r*C-h*i*C+h*f*D-b*r*D-c*f*F+b*i*F;this.n34=h*i*n-c*r*n-h*f*l+b*r*l+c*f*B-b*i*B;this.n41=k*l*C-i*t*C-k*n*D+f*t*D+i*n*G-f*l*G;this.n42=c*t*C-e*l*C+e*n*D-b*t*D-c*n*G+b*l*G;this.n43=e*i*C-c*k*C-e*f*D+b*k*D+c*f*G-b*i*G;this.n44=c*k*n-e*i*n+e*f*l-b*k*l-c*f*t+b*i*t;this.multiplyScalar(1/a.determinant());
  42. return this},setRotationFromEuler:function(a,b){var c=a.x,e=a.y,h=a.z,f=Math.cos(c),c=Math.sin(c),i=Math.cos(e),e=Math.sin(e),k=Math.cos(h),h=Math.sin(h);switch(b){case "YXZ":var r=i*k,n=i*h,l=e*k,t=e*h;this.n11=r+t*c;this.n12=l*c-n;this.n13=f*e;this.n21=f*h;this.n22=f*k;this.n23=-c;this.n31=n*c-l;this.n32=t+r*c;this.n33=f*i;break;case "ZXY":r=i*k;n=i*h;l=e*k;t=e*h;this.n11=r-t*c;this.n12=-f*h;this.n13=l+n*c;this.n21=n+l*c;this.n22=f*k;this.n23=t-r*c;this.n31=-f*e;this.n32=c;this.n33=f*i;break;case "ZYX":r=
  43. f*k;n=f*h;l=c*k;t=c*h;this.n11=i*k;this.n12=l*e-n;this.n13=r*e+t;this.n21=i*h;this.n22=t*e+r;this.n23=n*e-l;this.n31=-e;this.n32=c*i;this.n33=f*i;break;case "YZX":r=f*i;n=f*e;l=c*i;t=c*e;this.n11=i*k;this.n12=t-r*h;this.n13=l*h+n;this.n21=h;this.n22=f*k;this.n23=-c*k;this.n31=-e*k;this.n32=n*h+l;this.n33=r-t*h;break;case "XZY":r=f*i;n=f*e;l=c*i;t=c*e;this.n11=i*k;this.n12=-h;this.n13=e*k;this.n21=r*h+t;this.n22=f*k;this.n23=n*h-l;this.n31=l*h-n;this.n32=c*k;this.n33=t*h+r;break;default:r=f*k,n=f*
  44. h,l=c*k,t=c*h,this.n11=i*k,this.n12=-i*h,this.n13=e,this.n21=n+l*e,this.n22=r-t*e,this.n23=-c*i,this.n31=t-r*e,this.n32=l+n*e,this.n33=f*i}return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,e=a.z,h=a.w,f=b+b,i=c+c,k=e+e,a=b*f,r=b*i;b*=k;var n=c*i;c*=k;e*=k;f*=h;i*=h;h*=k;this.n11=1-(n+e);this.n12=r-h;this.n13=b+i;this.n21=r+h;this.n22=1-(a+e);this.n23=c-f;this.n31=b-i;this.n32=c+f;this.n33=1-(a+n);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,h=THREE.Matrix4.__m2;e.identity();e.setRotationFromQuaternion(b);h.setScale(c.x,c.y,c.z);this.multiply(e,h);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var e=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;e.set(this.n11,this.n21,this.n31);h.set(this.n12,this.n22,this.n32);f.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=h.length();c.z=f.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,h=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,i=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,r=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,l=-a.n23*a.n11+a.n21*a.n13,t=a.n22*a.n11-a.n21*a.n12,a=a.n11*e+a.n21*i+a.n31*n;a===0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*e;c[1]=a*h;c[2]=a*f;c[3]=a*i;c[4]=a*k;c[5]=a*r;c[6]=a*n;c[7]=a*l;c[8]=a*t;return b};
  49. THREE.Matrix4.makeFrustum=function(a,b,c,e,h,f){var i;i=new THREE.Matrix4;i.n11=2*h/(b-a);i.n12=0;i.n13=(b+a)/(b-a);i.n14=0;i.n21=0;i.n22=2*h/(e-c);i.n23=(e+c)/(e-c);i.n24=0;i.n31=0;i.n32=0;i.n33=-(f+h)/(f-h);i.n34=-2*f*h/(f-h);i.n41=0;i.n42=0;i.n43=-1;i.n44=0;return i};THREE.Matrix4.makePerspective=function(a,b,c,e){var h,a=c*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,c,e)};
  50. THREE.Matrix4.makeOrtho=function(a,b,c,e,h,f){var i,k,r,n;i=new THREE.Matrix4;k=b-a;r=c-e;n=f-h;i.n11=2/k;i.n12=0;i.n13=0;i.n14=-((b+a)/k);i.n21=0;i.n22=2/r;i.n23=0;i.n24=-((c+e)/r);i.n31=0;i.n32=0;i.n33=-2/n;i.n34=-((f+h)/n);i.n41=0;i.n42=0;i.n43=0;i.n44=1;return i};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,h;c=0;for(e=this.children.length;c<e;c++){h=this.children[c];if(h.name===a)return h;
  55. if(b&&(h=h.getChildByName(a,b),h!==void 0))return h}},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=i[f]=i[f]||new THREE.RenderableObject;f++;return a}function b(){var a=n[r]=n[r]||new THREE.RenderableVertex;r++;return a}function c(a,b){return b.z-a.z}function e(a,b){var c=0,e=1,d=a.z+a.w,f=b.z+b.w,h=-a.z+a.w,i=-b.z+b.w;return d>=0&&f>=0&&h>=0&&i>=0?!0:d<0&&f<0||h<0&&i<0?!1:(d<0?c=Math.max(c,d/(d-f)):f<0&&(e=Math.min(e,d/(d-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 h,f,i=[],k,r,n=[],
  58. l,t,B=[],C,D=[],G,F,ra=[],O,la,na=[],S={objects:[],sprites:[],lights:[],elements:[]},da=new THREE.Vector3,K=new THREE.Vector4,V=new THREE.Matrix4,Y=new THREE.Matrix4,J=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],W=new THREE.Vector4,aa=new THREE.Vector4;this.computeFrustum=function(a){J[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);J[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);J[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+
  59. a.n23,a.n44+a.n24);J[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);J[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);J[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=J[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);V.multiply(b.projectionMatrix,b.matrixWorldInverse);V.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);
  60. V.multiply(b.matrixWorld,b.projectionMatrixInverse);V.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){f=0;S.objects.length=0;S.sprites.length=0;S.lights.length=0;var i=function(b){if(b.visible!==!1){var d;if(d=b instanceof THREE.Mesh||b instanceof THREE.Line)if(!(d=b.frustumCulled===!1))a:{for(var c=b.matrixWorld,
  61. e=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),f=0;f<6;f++)if(d=J[f].x*c.n14+J[f].y*c.n24+J[f].z*c.n34+J[f].w,d<=e){d=!1;break a}d=!0}d?(V.multiplyVector3(da.copy(b.position)),h=a(),h.object=b,h.z=da.z,S.objects.push(h)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(V.multiplyVector3(da.copy(b.position)),h=a(),h.object=b,h.z=da.z,S.sprites.push(h)):b instanceof THREE.Light&&S.lights.push(b);d=0;for(c=b.children.length;d<c;d++)i(b.children[d])}};i(b);
  62. e&&S.objects.sort(c);return S};this.projectScene=function(a,f,h){var i=f.near,d=f.far,J,da,ja,sa,H,qa,ga,ta,P,oa,ua,Fa,Ja,Ga,Aa,ya;la=F=C=t=0;S.elements.length=0;f.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),a.add(f));a.updateMatrixWorld();f.matrixWorldInverse.getInverse(f.matrixWorld);V.multiply(f.projectionMatrix,f.matrixWorldInverse);this.computeFrustum(V);S=this.projectGraph(a,!1);a=0;for(J=S.objects.length;a<J;a++)if(P=S.objects[a].object,oa=
  63. P.matrixWorld,Fa=P.material,r=0,P instanceof THREE.Mesh){ua=P.geometry;Ja=P.geometry.materials;sa=ua.vertices;Ga=ua.faces;Aa=ua.faceVertexUvs;ua=P.matrixRotationWorld.extractRotation(oa);da=0;for(ja=sa.length;da<ja;da++)k=b(),k.positionWorld.copy(sa[da].position),oa.multiplyVector3(k.positionWorld),k.positionScreen.copy(k.positionWorld),V.multiplyVector4(k.positionScreen),k.positionScreen.x/=k.positionScreen.w,k.positionScreen.y/=k.positionScreen.w,k.visible=k.positionScreen.z>i&&k.positionScreen.z<
  64. d;sa=0;for(da=Ga.length;sa<da;sa++){ja=Ga[sa];if(ja instanceof THREE.Face3)if(H=n[ja.a],qa=n[ja.b],ga=n[ja.c],H.visible&&qa.visible&&ga.visible&&(P.doubleSided||P.flipSided!=(ga.positionScreen.x-H.positionScreen.x)*(qa.positionScreen.y-H.positionScreen.y)-(ga.positionScreen.y-H.positionScreen.y)*(qa.positionScreen.x-H.positionScreen.x)<0))ta=B[t]=B[t]||new THREE.RenderableFace3,t++,l=ta,l.v1.copy(H),l.v2.copy(qa),l.v3.copy(ga);else continue;else if(ja instanceof THREE.Face4)if(H=n[ja.a],qa=n[ja.b],
  65. ga=n[ja.c],ta=n[ja.d],H.visible&&qa.visible&&ga.visible&&ta.visible&&(P.doubleSided||P.flipSided!=((ta.positionScreen.x-H.positionScreen.x)*(qa.positionScreen.y-H.positionScreen.y)-(ta.positionScreen.y-H.positionScreen.y)*(qa.positionScreen.x-H.positionScreen.x)<0||(qa.positionScreen.x-ga.positionScreen.x)*(ta.positionScreen.y-ga.positionScreen.y)-(qa.positionScreen.y-ga.positionScreen.y)*(ta.positionScreen.x-ga.positionScreen.x)<0)))ya=D[C]=D[C]||new THREE.RenderableFace4,C++,l=ya,l.v1.copy(H),l.v2.copy(qa),
  66. l.v3.copy(ga),l.v4.copy(ta);else continue;l.normalWorld.copy(ja.normal);ua.multiplyVector3(l.normalWorld);l.centroidWorld.copy(ja.centroid);oa.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);V.multiplyVector3(l.centroidScreen);ga=ja.vertexNormals;H=0;for(qa=ga.length;H<qa;H++)ta=l.vertexNormalsWorld[H],ta.copy(ga[H]),ua.multiplyVector3(ta);H=0;for(qa=Aa.length;H<qa;H++)if(ya=Aa[H][sa]){ga=0;for(ta=ya.length;ga<ta;ga++)l.uvs[H][ga]=ya[ga]}l.material=Fa;l.faceMaterial=ja.materialIndex!==
  67. null?Ja[ja.materialIndex]:null;l.z=l.centroidScreen.z;S.elements.push(l)}}else if(P instanceof THREE.Line){Y.multiply(V,oa);sa=P.geometry.vertices;H=b();H.positionScreen.copy(sa[0].position);Y.multiplyVector4(H.positionScreen);da=1;for(ja=sa.length;da<ja;da++)if(H=b(),H.positionScreen.copy(sa[da].position),Y.multiplyVector4(H.positionScreen),qa=n[r-2],W.copy(H.positionScreen),aa.copy(qa.positionScreen),e(W,aa))W.multiplyScalar(1/W.w),aa.multiplyScalar(1/aa.w),P=ra[F]=ra[F]||new THREE.RenderableLine,
  68. F++,G=P,G.v1.positionScreen.copy(W),G.v2.positionScreen.copy(aa),G.z=Math.max(W.z,aa.z),G.material=Fa,S.elements.push(G)}a=0;for(J=S.sprites.length;a<J;a++)if(P=S.sprites[a].object,oa=P.matrixWorld,P instanceof THREE.Particle&&(K.set(oa.n14,oa.n24,oa.n34,1),V.multiplyVector4(K),K.z/=K.w,K.z>0&&K.z<1))i=na[la]=na[la]||new THREE.RenderableParticle,la++,O=i,O.x=K.x/K.w,O.y=K.y/K.w,O.z=K.z,O.rotation=P.rotation.z,O.scale.x=P.scale.x*Math.abs(O.x-(K.x+f.projectionMatrix.n11)/(K.w+f.projectionMatrix.n14)),
  69. O.scale.y=P.scale.y*Math.abs(O.y-(K.y+f.projectionMatrix.n22)/(K.w+f.projectionMatrix.n24)),O.material=P.material,S.elements.push(O);h&&S.elements.sort(c);return S}};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,h=a.z*b,a=Math.cos(e),e=Math.sin(e),b=Math.cos(-h),h=Math.sin(-h),f=Math.cos(c),c=Math.sin(c),i=a*b,k=e*h;this.w=i*f-k*c;this.x=i*c+k*f;this.y=e*b*f+a*h*c;this.z=a*h*f-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,h=this.w,f=a.x,i=a.y,k=a.z,a=a.w;this.x=b*a+h*f+c*k-e*i;this.y=c*a+h*i+e*f-b*k;this.z=e*a+h*k+b*i-c*f;this.w=h*a-b*f-c*i-e*k;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,h=a.z,f=this.x,i=this.y,k=this.z,r=this.w,n=r*c+i*h-k*e,l=r*e+k*c-f*h,t=r*h+f*e-i*c,c=-f*
  74. c-i*e-k*h;b.x=n*r+c*-f+l*-k-t*-i;b.y=l*r+c*-i+t*-f-n*-k;b.z=t*r+c*-k+n*-i-l*-f;return b}};
  75. THREE.Quaternion.slerp=function(a,b,c,e){var h=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;h<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,h=-h):c.copy(b);if(Math.abs(h)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(h),h=Math.sqrt(1-h*h);if(Math.abs(h)<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)*f)/h;e=Math.sin(e*f)/h;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,h,f){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=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};
  77. THREE.Face4=function(a,b,c,e,h,f,i){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=i;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 h=this.faces[c];b.multiplyVector3(h.normal);for(var f=0,i=h.vertexNormals.length;f<i;f++)b.multiplyVector3(h.vertexNormals[f]);a.multiplyVector3(h.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,h,f,i,k=new THREE.Vector3,r=new THREE.Vector3;e=0;for(h=this.faces.length;e<h;e++){f=this.faces[e];if(a&&f.vertexNormals.length){k.set(0,0,0);b=0;for(c=f.vertexNormals.length;b<c;b++)k.addSelf(f.vertexNormals[b]);k.divideScalar(3)}else b=this.vertices[f.a],c=this.vertices[f.b],i=this.vertices[f.c],k.sub(i.position,c.position),r.sub(b.position,c.position),k.crossSelf(r);k.isZero()||k.normalize();f.normal.copy(k)}},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,f,h,N){k=a.vertices[b].position;r=a.vertices[c].position;n=a.vertices[e].position;l=i[f];t=i[h];B=i[N];C=r.x-k.x;D=n.x-k.x;G=r.y-k.y;F=n.y-k.y;ra=r.z-k.z;O=n.z-k.z;la=t.u-l.u;na=B.u-l.u;S=t.v-l.v;da=B.v-l.v;K=1/(la*da-na*S);W.set((da*C-S*D)*K,(da*G-S*F)*K,(da*ra-S*O)*K);aa.set((la*D-na*C)*K,(la*F-na*G)*K,(la*O-na*ra)*K);Y[b].addSelf(W);Y[c].addSelf(W);Y[e].addSelf(W);
  86. J[b].addSelf(aa);J[c].addSelf(aa);J[e].addSelf(aa)}var b,c,e,h,f,i,k,r,n,l,t,B,C,D,G,F,ra,O,la,na,S,da,K,V,Y=[],J=[],W=new THREE.Vector3,aa=new THREE.Vector3,ma=new THREE.Vector3,xa=new THREE.Vector3,ka=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)Y[b]=new THREE.Vector3,J[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)f=this.faces[b],i=this.faceVertexUvs[0][b],f instanceof THREE.Face3?a(this,f.a,f.b,f.c,0,1,2):f instanceof THREE.Face4&&(a(this,f.a,f.b,f.c,0,1,2),a(this,f.a,f.b,
  87. f.d,0,1,3));var N=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];for(e=0;e<f.vertexNormals.length;e++)ka.copy(f.vertexNormals[e]),h=f[N[e]],V=Y[h],ma.copy(V),ma.subSelf(ka.multiplyScalar(ka.dot(V))).normalize(),xa.cross(f.vertexNormals[e],V),h=xa.dot(J[h]),h=h<0?-1:1,f.vertexTangents[e]=new THREE.Vector4(ma.x,ma.y,ma.z,h)}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],
  88. y:[this.vertices[0].position.y,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<
  89. this.boundingBox.z[0])this.boundingBox.z[0]=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,h=Math.pow(10,4),f,i;f=0;for(i=this.vertices.length;f<i;f++)e=this.vertices[f].position,e=[Math.round(e.x*h),Math.round(e.y*h),Math.round(e.z*h)].join("_"),
  90. a[e]===void 0?(a[e]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[e]];f=0;for(i=this.faces.length;f<i;f++)if(a=this.faces[f],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,f,h,i){a=(c-a)*0.5;e=(e-b)*0.5;return(2*(b-c)+a+e)*i+(-3*(b-c)-2*a-e)*h+a*f+b}this.points=a;var c=[],e={x:0,y:0,z:0},h,f,i,k,r,n,l,t,B;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){h=(this.points.length-1)*a;f=Math.floor(h);i=h-f;c[0]=f===0?f:f-1;c[1]=f;c[2]=f>this.points.length-2?f:f+1;c[3]=f>this.points.length-3?f:f+2;n=this.points[c[0]];l=this.points[c[1]];
  92. t=this.points[c[2]];B=this.points[c[3]];k=i*i;r=i*k;e.x=b(n.x,l.x,t.x,B.x,i,k,r);e.y=b(n.y,l.y,t.y,B.y,i,k,r);e.z=b(n.z,l.z,t.z,B.z,i,k,r);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=b=b=0,f=new THREE.Vector3,h=new THREE.Vector3,i=[],k=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,position=this.getPoint(b),h.copy(position),
  93. k+=h.distanceTo(f),f.copy(position),b*=this.points.length-1,b=Math.floor(b),b!=e&&(i[b]=k,e=b);i[i.length]=k;return{chunks:i,total:k}};this.reparametrizeByArcLength=function(a){var b,c,e,f,h,i,k=[],l=new THREE.Vector3,r=this.getLength();k.push(l.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=r.chunks[b]-r.chunks[b-1];i=Math.ceil(a*c/r.total);f=(b-1)/(this.points.length-1);h=b/(this.points.length-1);for(c=1;c<i-1;c++)e=f+c*(1/i)*(h-f),position=this.getPoint(e),k.push(l.copy(position).clone());
  94. k.push(l.copy(this.points[b]).clone())}this.points=k}};THREE.Edge=function(a,b,c,e){this.vertices=[a,b];this.vertexIndices=[c,e];this.faces=[];this.faceIndices=[]};
  95. 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};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
  96. 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,h,f){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=e;this.near=h!==void 0?h:0.1;this.far=f!==void 0?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;
  97. 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;THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;
  98. 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,h,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=e;this.width=h;this.height=f;this.updateProjectionMatrix()};
  99. 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,
  100. 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;
  101. 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;
  102. 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;
  103. 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=
  104. 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;
  105. 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;
  106. 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:
  107. !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:
  108. !1};THREE.MeshBasicMaterial.prototype=new THREE.Material;THREE.MeshBasicMaterial.prototype.constructor=THREE.MeshBasicMaterial;
  109. 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=
  110. 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=
  111. 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;
  112. 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=
  113. 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=
  114. 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;
  115. 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;
  116. 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(){};
  117. THREE.MeshShaderMaterial=function(a){console.warn("DEPRECATED: MeshShaderMaterial() is now ShaderMaterial().");return new THREE.ShaderMaterial(a)};
  118. 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;
  119. 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!==
  120. 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;
  121. THREE.Texture=function(a,b,c,e,h,f){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=h!==void 0?h:THREE.LinearFilter;this.minFilter=f!==void 0?f:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.needsUpdate=!1};
  122. 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(){};
  123. 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;
  124. 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,h,f,i,k,r){THREE.Texture.call(this,null,h,f,i,k,r);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;
  125. 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};
  126. 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;
  127. 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={};
  128. 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;
  129. 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;
  130. 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)};
  131. THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var c,e,h,f,i,k;if(this.geometry.bones!==void 0){for(c=0;c<this.geometry.bones.length;c++)h=this.geometry.bones[c],f=h.pos,i=h.rotq,k=h.scl,e=this.addBone(),e.name=h.name,e.position.set(f[0],f[1],f[2]),e.quaternion.set(i[0],i[1],i[2],i[3]),e.useQuaternion=!0,k!==void 0?e.scale.set(k[0],k[1],k[2]):e.scale.set(1,1,1);for(c=0;c<this.bones.length;c++)h=this.geometry.bones[c],
  132. e=this.bones[c],h.parent===-1?this.add(e):this.bones[h.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};
  133. 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)}b=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(a=0;a<b;a++)ba[a].skinMatrix.flattenToArrayOffset(bm,
  134. a*16)};
  135. 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,h=this.geometry.skinIndices[a].x,f=this.geometry.skinIndices[a].y,e=
  136. new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesA.push(b[h].multiplyVector3(e));e=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesB.push(b[f].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};
  137. 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)};
  138. 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}};
  139. 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:
  140. !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;
  141. 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);
  142. 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);
  143. 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;
  144. 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])};
  145. 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])};
  146. 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};
  147. 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",
  148. 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",
  149. 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",
  150. 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",
  151. 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}",
  152. 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",
  153. 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;",
  154. 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",
  155. 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",
  156. 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",
  157. 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",
  158. 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",
  159. 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"};
  160. THREE.UniformsUtils={merge:function(a){var b,c,e,h={};for(b=0;b<a.length;b++)for(c in e=this.clone(a[b]),e)h[c]=e[c];return h},clone:function(a){var b,c,e,h={};for(b in a)for(c in h[b]={},a[b])e=a[b][c],h[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 h}};
  161. 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",
  162. 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",
  163. 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}}};
  164. 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}"},
  165. 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}},
  166. 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,
  167. 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,
  168. 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,
  169. 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,
  170. 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 );",
  171. 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 );",
  172. 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",
  173. 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 );",
  174. 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,
  175. "}"].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,
  176. 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,
  177. 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,
  178. 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,
  179. 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}"}};
  180. 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 f in e.attributes){var h=e.attributes[f];if(!h.__webglInitialized||h.createUniqueBuffers){h.__webglInitialized=!0;var i=1;h.type==="v2"?i=2:h.type==="v3"?i=3:h.type==="v4"?i=4:h.type==="c"&&(i=3);h.size=i;h.array=new Float32Array(c*i);h.buffer=d.createBuffer();h.buffer.belongsToAttribute=f;h.needsUpdate=!0}a.__webglCustomAttributesList.push(h)}}}
  181. 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,f,h,i=a.vertices,o=i.length,s=a.colors,k=s.length,m=a.__vertexArray,q=a.__colorArray,l=a.__sortArray,x=a.__dirtyVertices,r=a.__dirtyColors,n=a.__webglCustomAttributesList;if(c.sortParticles){Ba.multiplySelf(c.matrixWorld);for(e=0;e<o;e++)f=i[e].position,Ha.copy(f),Ba.multiplyVector3(Ha),l[e]=[Ha.z,e];l.sort(function(a,
  182. b){return b[0]-a[0]});for(e=0;e<o;e++)f=i[l[e][1]].position,h=e*3,m[h]=f.x,m[h+1]=f.y,m[h+2]=f.z;for(e=0;e<k;e++)h=e*3,color=s[l[e][1]],q[h]=color.r,q[h+1]=color.g,q[h+2]=color.b;if(n){s=0;for(k=n.length;s<k;s++)if(o=n[s],o.boundTo===void 0||o.boundTo==="vertices")if(h=0,f=o.value.length,o.size===1)for(e=0;e<f;e++)index=l[e][1],o.array[e]=o.value[index];else if(o.size===2)for(e=0;e<f;e++)index=l[e][1],i=o.value[index],o.array[h]=i.x,o.array[h+1]=i.y,h+=2;else if(o.size===3)if(o.type==="c")for(e=0;e<
  183. f;e++)index=l[e][1],i=o.value[index],o.array[h]=i.r,o.array[h+1]=i.g,o.array[h+2]=i.b,h+=3;else for(e=0;e<f;e++)index=l[e][1],i=o.value[index],o.array[h]=i.x,o.array[h+1]=i.y,o.array[h+2]=i.z,h+=3;else if(o.size===4)for(e=0;e<f;e++)index=l[e][1],i=o.value[index],o.array[h]=i.x,o.array[h+1]=i.y,o.array[h+2]=i.z,o.array[h+3]=i.w,h+=4}}else{if(x)for(e=0;e<o;e++)f=i[e].position,h=e*3,m[h]=f.x,m[h+1]=f.y,m[h+2]=f.z;if(r)for(e=0;e<k;e++)color=s[e],h=e*3,q[h]=color.r,q[h+1]=color.g,q[h+2]=color.b;if(n){s=
  184. 0;for(k=n.length;s<k;s++)if(o=n[s],o.needsUpdate&&(o.boundTo===void 0||o.boundTo==="vertices"))if(f=o.value.length,h=0,o.size===1)for(e=0;e<f;e++)o.array[e]=o.value[e];else if(o.size===2)for(e=0;e<f;e++)i=o.value[e],o.array[h]=i.x,o.array[h+1]=i.y,h+=2;else if(o.size===3)if(o.type==="c")for(e=0;e<f;e++)i=o.value[e],o.array[h]=i.r,o.array[h+1]=i.g,o.array[h+2]=i.b,h+=3;else for(e=0;e<f;e++)i=o.value[e],o.array[h]=i.x,o.array[h+1]=i.y,o.array[h+2]=i.z,h+=3;else if(o.size===4)for(e=0;e<f;e++)i=o.value[e],
  185. o.array[h]=i.x,o.array[h+1]=i.y,o.array[h+2]=i.z,o.array[h+3]=i.w,h+=4}}if(x||c.sortParticles)d.bindBuffer(d.ARRAY_BUFFER,a.__webglVertexBuffer),d.bufferData(d.ARRAY_BUFFER,m,b);if(r||c.sortParticles)d.bindBuffer(d.ARRAY_BUFFER,a.__webglColorBuffer),d.bufferData(d.ARRAY_BUFFER,q,b);if(n){s=0;for(k=n.length;s<k;s++)if(o=n[s],o.needsUpdate||c.sortParticles)d.bindBuffer(d.ARRAY_BUFFER,o.buffer),d.bufferData(d.ARRAY_BUFFER,o.array,b)}}function h(a,b,c,e,h){e.program||N.initMaterial(e,b,c,h);if(e.morphTargets&&
  186. !h.__webglMorphTargetInfluences){h.__webglMorphTargetInfluences=new Float32Array(N.maxMorphTargets);for(var f=0,i=N.maxMorphTargets;f<i;f++)h.__webglMorphTargetInfluences[f]=0}var o=!1,f=e.program,i=f.uniforms,s=e.uniforms;f!==Qa&&(d.useProgram(f),Qa=f,o=!0);if(e.id!==sa)sa=e.id,o=!0;if(o){d.uniformMatrix4fv(i.projectionMatrix,!1,Na);if(c&&e.fog)if(s.fogColor.value=c.color,c instanceof THREE.Fog)s.fogNear.value=c.near,s.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)s.fogDensity.value=c.density;
  187. if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e.lights){for(var k,m,q=0,l=0,x=0,r,n,t,u=Ta,B=u.directional.colors,w=u.directional.positions,v=u.point.colors,C=u.point.positions,D=u.point.distances,G=0,R=0,c=k=t=0,o=b.length;c<o;c++)if(k=b[c],m=k.color,r=k.position,n=k.intensity,t=k.distance,k instanceof THREE.AmbientLight)N.gammaInput?(q+=m.r*m.r,l+=m.g*m.g,x+=m.b*m.b):(q+=m.r,l+=m.g,x+=m.b);else if(k instanceof THREE.DirectionalLight)t=G*3,N.gammaInput?(B[t]=m.r*
  188. m.r*n*n,B[t+1]=m.g*m.g*n*n,B[t+2]=m.b*m.b*n*n):(B[t]=m.r*n,B[t+1]=m.g*n,B[t+2]=m.b*n),w[t]=r.x,w[t+1]=r.y,w[t+2]=r.z,G+=1;else if(k instanceof THREE.SpotLight)t=G*3,N.gammaInput?(B[t]=m.r*m.r*n*n,B[t+1]=m.g*m.g*n*n,B[t+2]=m.b*m.b*n*n):(B[t]=m.r*n,B[t+1]=m.g*n,B[t+2]=m.b*n),m=1/r.length(),w[t]=r.x*m,w[t+1]=r.y*m,w[t+2]=r.z*m,G+=1;else if(k instanceof THREE.PointLight)k=R*3,N.gammaInput?(v[k]=m.r*m.r*n*n,v[k+1]=m.g*m.g*n*n,v[k+2]=m.b*m.b*n*n):(v[k]=m.r*n,v[k+1]=m.g*n,v[k+2]=m.b*n),C[k]=r.x,C[k+1]=r.y,
  189. C[k+2]=r.z,D[R]=t,R+=1;c=G*3;for(o=B.length;c<o;c++)B[c]=0;c=R*3;for(o=v.length;c<o;c++)v[c]=0;u.point.length=R;u.directional.length=G;u.ambient[0]=q;u.ambient[1]=l;u.ambient[2]=x;b=Ta;s.enableLighting.value=b.directional.length+b.point.length;s.ambientLightColor.value=b.ambient;s.directionalLightColor.value=b.directional.colors;s.directionalLightDirection.value=b.directional.positions;s.pointLightColor.value=b.point.colors;s.pointLightPosition.value=b.point.positions;s.pointLightDistance.value=b.point.distances}if(e instanceof
  190. THREE.MeshBasicMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshPhongMaterial)s.opacity.value=e.opacity,N.gammaInput?s.diffuse.value.copyGammaToLinear(e.color):s.diffuse.value=e.color,(s.map.texture=e.map)&&s.offsetRepeat.value.set(e.map.offset.x,e.map.offset.y,e.map.repeat.x,e.map.repeat.y),s.lightMap.texture=e.lightMap,s.envMap.texture=e.envMap,s.flipEnvMap.value=e.envMap instanceof THREE.WebGLRenderTargetCube?1:-1,s.reflectivity.value=e.reflectivity,s.refractionRatio.value=
  191. e.refractionRatio,s.combine.value=e.combine,s.useRefract.value=e.envMap&&e.envMap.mapping instanceof THREE.CubeRefractionMapping;if(e instanceof THREE.LineBasicMaterial)s.diffuse.value=e.color,s.opacity.value=e.opacity;else if(e instanceof THREE.ParticleBasicMaterial)s.psColor.value=e.color,s.opacity.value=e.opacity,s.size.value=e.size,s.scale.value=Ca.height/2,s.map.texture=e.map;else if(e instanceof THREE.MeshPhongMaterial)s.shininess.value=e.shininess,N.gammaInput?(s.ambient.value.copyGammaToLinear(e.ambient),
  192. s.specular.value.copyGammaToLinear(e.specular)):(s.ambient.value=e.ambient,s.specular.value=e.specular);else if(e instanceof THREE.MeshLambertMaterial)N.gammaInput?s.ambient.value.copyGammaToLinear(e.ambient):s.ambient.value=e.ambient;else if(e instanceof THREE.MeshDepthMaterial)s.mNear.value=a.near,s.mFar.value=a.far,s.opacity.value=e.opacity;else if(e instanceof THREE.MeshNormalMaterial)s.opacity.value=e.opacity;if(h.receiveShadow&&!e._shadowPass&&s.shadowMatrix){for(b=0;b<La.length;b++)s.shadowMatrix.value[b]=
  193. La[b],s.shadowMap.texture[b]=N.shadowMap[b];s.shadowDarkness.value=N.shadowMapDarkness;s.shadowBias.value=N.shadowMapBias}b=e.uniformsList;s=0;for(c=b.length;s<c;s++)if(l=f.uniforms[b[s][1]])if(q=b[s][0],x=q.type,o=q.value,x==="i")d.uniform1i(l,o);else if(x==="f")d.uniform1f(l,o);else if(x==="v2")d.uniform2f(l,o.x,o.y);else if(x==="v3")d.uniform3f(l,o.x,o.y,o.z);else if(x==="v4")d.uniform4f(l,o.x,o.y,o.z,o.w);else if(x==="c")d.uniform3f(l,o.r,o.g,o.b);else if(x==="fv1")d.uniform1fv(l,o);else if(x===
  194. "fv")d.uniform3fv(l,o);else if(x==="v3v"){if(!q._array)q._array=new Float32Array(3*o.length);x=0;for(r=o.length;x<r;x++)u=x*3,q._array[u]=o[x].x,q._array[u+1]=o[x].y,q._array[u+2]=o[x].z;d.uniform3fv(l,q._array)}else if(x==="m4"){if(!q._array)q._array=new Float32Array(16);o.flattenToArray(q._array);d.uniformMatrix4fv(l,!1,q._array)}else if(x==="m4v"){if(!q._array)q._array=new Float32Array(16*o.length);x=0;for(r=o.length;x<r;x++)o[x].flattenToArrayOffset(q._array,x*16);d.uniformMatrix4fv(l,!1,q._array)}else if(x===
  195. "t"){if(d.uniform1i(l,o),l=q.texture)if(l.image instanceof Array&&l.image.length===6){if(q=l,q.image.length===6)if(q.needsUpdate){if(!q.image.__webglTextureCube)q.image.__webglTextureCube=d.createTexture();d.activeTexture(d.TEXTURE0+o);d.bindTexture(d.TEXTURE_CUBE_MAP,q.image.__webglTextureCube);for(o=0;o<6;o++)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,q.image[o]);V(d.TEXTURE_CUBE_MAP,q,q.image[0]);q.needsUpdate=!1}else d.activeTexture(d.TEXTURE0+o),d.bindTexture(d.TEXTURE_CUBE_MAP,
  196. q.image.__webglTextureCube)}else l instanceof THREE.WebGLRenderTargetCube?(q=l,d.activeTexture(d.TEXTURE0+o),d.bindTexture(d.TEXTURE_CUBE_MAP,q.__webglTexture)):Y(l,o)}else if(x==="tv"){if(!q._array){q._array=[];x=0;for(r=q.texture.length;x<r;x++)q._array[x]=o+x}d.uniform1iv(l,q._array);x=0;for(r=q.texture.length;x<r;x++)(l=q.texture[x])&&Y(l,q._array[x])}(e instanceof THREE.ShaderMaterial||e instanceof THREE.MeshPhongMaterial||e.envMap)&&i.cameraPosition!==null&&d.uniform3f(i.cameraPosition,a.position.x,
  197. a.position.y,a.position.z);(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.ShaderMaterial||e.skinning)&&i.viewMatrix!==null&&d.uniformMatrix4fv(i.viewMatrix,!1,Oa);e.skinning&&(d.uniformMatrix4fv(i.cameraInverseMatrix,!1,Oa),d.uniformMatrix4fv(i.boneGlobalMatrices,!1,h.boneMatrices))}d.uniformMatrix4fv(i.modelViewMatrix,!1,h._modelViewMatrixArray);i.normalMatrix&&d.uniformMatrix3fv(i.normalMatrix,!1,h._normalMatrixArray);(e instanceof THREE.ShaderMaterial||
  198. e.envMap||e.skinning||h.receiveShadow)&&i.objectMatrix!==null&&d.uniformMatrix4fv(i.objectMatrix,!1,h._objectMatrixArray);return f}function f(a,b,c,e,f,i){if(e.opacity!==0){var k,o,c=h(a,b,c,e,i),b=c.attributes,a=!1,c=f.id*16777215+c.id*2+(e.wireframe?1:0);c!==H&&(H=c,a=!0);if(!e.morphTargets&&b.position>=0)a&&(d.bindBuffer(d.ARRAY_BUFFER,f.__webglVertexBuffer),d.vertexAttribPointer(b.position,3,d.FLOAT,!1,0,0));else if(i.morphTargetBase){c=e.program.attributes;i.morphTargetBase!==-1?(d.bindBuffer(d.ARRAY_BUFFER,
  199. f.__webglMorphTargetsBuffers[i.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(i.morphTargetForcedOrder.length){k=0;var s=i.morphTargetForcedOrder;for(o=i.morphTargetInfluences;k<e.numSupportedMorphTargets&&k<s.length;)d.bindBuffer(d.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[s[k]]),d.vertexAttribPointer(c["morphTarget"+k],3,d.FLOAT,!1,0,0),i.__webglMorphTargetInfluences[k]=
  200. o[s[k]],k++}else{var s=[],l=-1,m=0;o=i.morphTargetInfluences;var q,n=o.length;k=0;for(i.morphTargetBase!==-1&&(s[i.morphTargetBase]=!0);k<e.numSupportedMorphTargets;){for(q=0;q<n;q++)!s[q]&&o[q]>l&&(m=q,l=o[m]);d.bindBuffer(d.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[m]);d.vertexAttribPointer(c["morphTarget"+k],3,d.FLOAT,!1,0,0);i.__webglMorphTargetInfluences[k]=l;s[m]=1;l=-1;k++}}e.program.uniforms.morphTargetInfluences!==null&&d.uniform1fv(e.program.uniforms.morphTargetInfluences,i.__webglMorphTargetInfluences)}if(a){if(f.__webglCustomAttributesList){k=
  201. 0;for(o=f.__webglCustomAttributesList.length;k<o;k++)c=f.__webglCustomAttributesList[k],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,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,
  202. 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),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>=
  203. 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,4,d.FLOAT,!1,0,0),d.bindBuffer(d.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),d.vertexAttribPointer(b.skinWeight,4,d.FLOAT,!1,0,0))}i instanceof THREE.Mesh?(e.wireframe?
  204. (e=e.wireframeLinewidth,e!==Aa&&(d.lineWidth(e),Aa=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)),N.info.render.calls++,N.info.render.vertices+=f.__webglFaceCount,N.info.render.faces+=f.__webglFaceCount/3):i instanceof THREE.Line?(i=i.type===THREE.LineStrip?d.LINE_STRIP:d.LINES,e=e.linewidth,e!==
  205. Aa&&(d.lineWidth(e),Aa=e),d.drawArrays(i,0,f.__webglLineCount),N.info.render.calls++):i instanceof THREE.ParticleSystem?(d.drawArrays(d.POINTS,0,f.__webglParticleCount),N.info.render.calls++):i instanceof THREE.Ribbon&&(d.drawArrays(d.TRIANGLE_STRIP,0,f.__webglVertexCount),N.info.render.calls++)}}function i(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=d.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=d.createBuffer();a.hasPos&&(d.bindBuffer(d.ARRAY_BUFFER,a.__webglVertexBuffer),
  206. 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,h,i,o,k,l,m,q,n,x=a.count*3;for(n=0;n<x;n+=9)c=a.normalArray,e=c[n],f=c[n+1],h=c[n+2],i=c[n+3],k=c[n+4],m=c[n+5],o=c[n+6],l=c[n+7],q=c[n+8],e=(e+i+o)/3,f=(f+k+l)/3,h=(h+m+q)/3,c[n]=e,c[n+1]=f,c[n+2]=h,c[n+3]=e,c[n+4]=f,c[n+5]=h,
  207. c[n+6]=e,c[n+7]=f,c[n+8]=h}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 k(a){if(ga!==a.doubleSided)a.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE),ga=a.doubleSided;if(ta!==a.flipSided)a.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW),ta=a.flipSided}function r(a){oa!==a&&(a?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST),
  208. oa=a)}function n(a){ua!==a&&(d.depthMask(a),ua=a)}function l(a,b,c){Fa!==a&&(a?d.enable(d.POLYGON_OFFSET_FILL):d.disable(d.POLYGON_OFFSET_FILL),Fa=a);if(a&&(Ja!==b||Ga!==c))d.polygonOffset(b,c),Ja=b,Ga=c}function t(a){va[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);va[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);va[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);va[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);va[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-
  209. a.n34);va[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=va[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}function B(a){for(var b=a.matrixWorld,d=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)),c=0;c<6;c++)if(a=va[c].x*b.n14+va[c].y*b.n24+va[c].z*b.n34+va[c].w,a<=d)return!1;return!0}function C(a){var b=a.object.material;b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}function D(a){var b=a.object,
  210. 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 G(a,b){return b.z-a.z}function F(a){var b,c,e,l=0,U,n,o,s,Q=a.lights;pa||(pa=new THREE.PerspectiveCamera(N.shadowCameraFov,N.shadowMapWidth/N.shadowMapHeight,N.shadowCameraNear,N.shadowCameraFar));b=0;for(c=
  211. Q.length;b<c;b++)if(e=Q[b],e instanceof THREE.SpotLight&&e.castShadow){sa=-1;N.shadowMap[l]||(N.shadowMap[l]=new THREE.WebGLRenderTarget(N.shadowMapWidth,N.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}));La[l]||(La[l]=new THREE.Matrix4);U=N.shadowMap[l];n=La[l];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();
  212. pa.matrixWorldInverse.getInverse(pa.matrixWorld);n.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);n.multiplySelf(pa.projectionMatrix);n.multiplySelf(pa.matrixWorldInverse);pa.matrixWorldInverse.flattenToArray(Oa);pa.projectionMatrix.flattenToArray(Na);Ba.multiply(pa.projectionMatrix,pa.matrixWorldInverse);t(Ba);W(U);d.clearColor(1,1,1,1);N.clear();d.clearColor(wa.r,wa.g,wa.b,Da);n=a.__webglObjects.length;e=a.__webglObjectsImmediate.length;for(U=0;U<n;U++)o=a.__webglObjects[U],s=o.object,s.visible&&
  213. s.castShadow?!(s instanceof THREE.Mesh)||!s.frustumCulled||B(s)?(s.matrixWorld.flattenToArray(s._objectMatrixArray),O(s,pa,!1),o.render=!0):o.render=!1:o.render=!1;r(!0);K(THREE.NormalBlending);for(U=0;U<n;U++)if(o=a.__webglObjects[U],o.render)s=o.object,buffer=o.buffer,k(s),o=s.customDepthMaterial?s.customDepthMaterial:s.geometry.morphTargets.length?Ua:Pa,f(pa,Q,null,o,buffer,s);for(U=0;U<e;U++)o=a.__webglObjectsImmediate[U],s=o.object,s.visible&&s.castShadow&&(s.matrixAutoUpdate&&s.matrixWorld.flattenToArray(s._objectMatrixArray),
  214. H=-1,O(s,pa,!1),k(s),program=h(pa,Q,null,Pa,s),s.immediateRenderCallback?s.immediateRenderCallback(program,d,va):s.render(function(a){i(a,program,Pa.shading)}));l++}}function ra(a,b){var c,e,f;c=w.attributes;var h=w.uniforms,i=Ia/Ma,o,k=[],l=Ma*0.5,m=Ia*0.5,q=!0;d.useProgram(w.program);Qa=w.program;H=oa=P=-1;Va||(d.enableVertexAttribArray(w.attributes.position),d.enableVertexAttribArray(w.attributes.uv),Va=!0);d.disable(d.CULL_FACE);d.enable(d.BLEND);d.depthMask(!0);d.bindBuffer(d.ARRAY_BUFFER,w.vertexBuffer);
  215. 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,w.elementBuffer);d.uniformMatrix4fv(h.projectionMatrix,!1,Na);d.activeTexture(d.TEXTURE0);d.uniform1i(h.map,0);c=0;for(e=a.__webglSprites.length;c<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);
  216. a.__webglSprites.sort(G);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(h.useScreenCoordinates,1),d.uniform3f(h.screenPosition,(f.position.x-l)/l,(m-f.position.y)/m,Math.max(0,Math.min(1,f.position.z)))):(d.uniform1i(h.useScreenCoordinates,0),d.uniform1i(h.affectedByDistance,f.affectedByDistance?1:0),d.uniformMatrix4fv(h.modelViewMatrix,!1,f._modelViewMatrixArray)),o=f.map.image.width/
  217. (f.scaleByViewport?Ia:1),k[0]=o*i*f.scale.x,k[1]=o*f.scale.y,d.uniform2f(h.uvScale,f.uvScale.x,f.uvScale.y),d.uniform2f(h.uvOffset,f.uvOffset.x,f.uvOffset.y),d.uniform2f(h.alignment,f.alignment.x,f.alignment.y),d.uniform1f(h.opacity,f.opacity),d.uniform3f(h.color,f.color.r,f.color.g,f.color.b),d.uniform1f(h.rotation,f.rotation),d.uniform2fv(h.scale,k),f.mergeWith3D&&!q?(d.enable(d.DEPTH_TEST),q=!0):!f.mergeWith3D&&q&&(d.disable(d.DEPTH_TEST),q=!1),K(f.blending),Y(f.map,0),d.drawElements(d.TRIANGLES,
  218. 6,d.UNSIGNED_SHORT,0));d.enable(d.CULL_FACE);d.enable(d.DEPTH_TEST);d.depthMask(ua)}function O(a,b,d){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);d&&THREE.Matrix4.makeInvert3x3(a._modelViewMatrix).transposeIntoArray(a._normalMatrixArray)}function la(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function na(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function S(a,b){for(var d=a.length-1;d>=0;d--)a[d].object===
  219. b&&a.splice(d,1)}function da(a,b,d){a.push({buffer:b,object:d,opaque:null,transparent:null})}function K(a){if(a!==P){switch(a){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);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,
  220. d.ONE_MINUS_SRC_ALPHA,d.ONE,d.ONE_MINUS_SRC_ALPHA)}P=a}}function V(a,b,c){(c.width&c.width-1)===0&&(c.height&c.height-1)===0?(d.texParameteri(a,d.TEXTURE_WRAP_S,ka(b.wrapS)),d.texParameteri(a,d.TEXTURE_WRAP_T,ka(b.wrapT)),d.texParameteri(a,d.TEXTURE_MAG_FILTER,ka(b.magFilter)),d.texParameteri(a,d.TEXTURE_MIN_FILTER,ka(b.minFilter)),d.generateMipmap(a)):(d.texParameteri(a,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(a,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.texParameteri(a,d.TEXTURE_MAG_FILTER,xa(b.magFilter)),
  221. d.texParameteri(a,d.TEXTURE_MIN_FILTER,xa(b.minFilter)))}function Y(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=d.createTexture(),N.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,ka(a.format),a.image.width,a.image.height,0,ka(a.format),d.UNSIGNED_BYTE,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=
  222. !1}else d.activeTexture(d.TEXTURE0+b),d.bindTexture(d.TEXTURE_2D,a.__webglTexture)}function J(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,d.DEPTH_STENCIL,b.width,b.height),d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_STENCIL_ATTACHMENT,d.RENDERBUFFER,
  223. a)):d.renderbufferStorage(d.RENDERBUFFER,d.RGBA4,b.width,b.height)}function W(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);V(d.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=d.createFramebuffer();a.__webglRenderbuffer[c]=
  224. d.createRenderbuffer();d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,ka(a.format),a.width,a.height,0,ka(a.format),ka(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);J(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=d.createFramebuffer(),a.__webglRenderbuffer=d.createRenderbuffer(),d.bindTexture(d.TEXTURE_2D,a.__webglTexture),V(d.TEXTURE_2D,a,a),d.texImage2D(d.TEXTURE_2D,
  225. 0,ka(a.format),a.width,a.height,0,ka(a.format),ka(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),J(a.__webglRenderbuffer,a);b?d.bindTexture(d.TEXTURE_CUBE_MAP,null):d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,
  226. c=a.width,a=a.height,f=e=0):(b=null,c=Ma,a=Ia,e=ya,f=Ra);b!==ja&&(d.bindFramebuffer(d.FRAMEBUFFER,b),d.viewport(e,f,c,a),ja=b)}function aa(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),d.generateMipmap(d.TEXTURE_2D),d.bindTexture(d.TEXTURE_2D,null))}function ma(a,b){var c;a==="fragment"?c=d.createShader(d.FRAGMENT_SHADER):a===
  227. "vertex"&&(c=d.createShader(d.VERTEX_SHADER));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 xa(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return d.NEAREST;default:return d.LINEAR}}function ka(a){switch(a){case THREE.RepeatWrapping:return d.REPEAT;case THREE.ClampToEdgeWrapping:return d.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return d.MIRRORED_REPEAT;
  228. case THREE.NearestFilter:return d.NEAREST;case THREE.NearestMipMapNearestFilter:return d.NEAREST_MIPMAP_NEAREST;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;
  229. case THREE.IntType:return d.INT;case THREE.UnsignedShortType:return d.UNSIGNED_INT;case THREE.FloatType:return d.FLOAT;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 N=this,d,Ea=[],Qa=null,ja=null,sa=-1,H=null,qa=0,ga=null,ta=null,P=null,oa=null,ua=null,Fa=null,Ja=null,Ga=null,Aa=null,ya=0,Ra=0,Ma=0,Ia=0,va=[new THREE.Vector4,
  230. new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ba=new THREE.Matrix4,Na=new Float32Array(16),Oa=new Float32Array(16),Ha=new THREE.Vector4,Ta={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},a=a||{},Ca=a.canvas!==void 0?a.canvas:document.createElement("canvas"),T=a.stencil!==void 0?a.stencil:!0,Ya=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,Za=a.antialias!==void 0?a.antialias:
  231. !1,wa=a.clearColor!==void 0?new THREE.Color(a.clearColor):new THREE.Color(0),Da=a.clearAlpha!==void 0?a.clearAlpha:0,Sa=a.maxLights!==void 0?a.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=Ca;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapBias=
  232. 0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=this.shadowMapAutoUpdate=!0;var pa,La=[],a=THREE.ShaderLib.depthRGBA,Wa=THREE.UniformsUtils.clone(a.uniforms),Pa=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:Wa}),Ua=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,
  233. uniforms:Wa,morphTargets:!0});Pa._shadowPass=!0;Ua._shadowPass=!0;try{if(!(d=Ca.getContext("experimental-webgl",{antialias:Za,stencil:T,preserveDrawingBuffer:Ya})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+d.getParameter(d.VERSION)+" | "+d.getParameter(d.VENDOR)+" | "+d.getParameter(d.RENDERER)+" | "+d.getParameter(d.SHADING_LANGUAGE_VERSION))}catch($a){console.error($a)}d.clearColor(0,0,0,1);d.clearDepth(1);d.clearStencil(0);d.enable(d.DEPTH_TEST);d.depthFunc(d.LEQUAL);
  234. 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(wa.r,wa.g,wa.b,Da);this.context=d;var Xa=d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,w={};w.vertices=new Float32Array(16);w.faces=new Uint16Array(6);T=0;w.vertices[T++]=-1;w.vertices[T++]=-1;w.vertices[T++]=0;w.vertices[T++]=1;w.vertices[T++]=1;w.vertices[T++]=-1;w.vertices[T++]=1;w.vertices[T++]=1;w.vertices[T++]=1;w.vertices[T++]=
  235. 1;w.vertices[T++]=1;w.vertices[T++]=0;w.vertices[T++]=-1;w.vertices[T++]=1;w.vertices[T++]=0;T=w.vertices[T++]=0;w.faces[T++]=0;w.faces[T++]=1;w.faces[T++]=2;w.faces[T++]=0;w.faces[T++]=2;w.faces[T++]=3;w.vertexBuffer=d.createBuffer();w.elementBuffer=d.createBuffer();d.bindBuffer(d.ARRAY_BUFFER,w.vertexBuffer);d.bufferData(d.ARRAY_BUFFER,w.vertices,d.STATIC_DRAW);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,w.elementBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,w.faces,d.STATIC_DRAW);w.program=d.createProgram();
  236. d.attachShader(w.program,ma("fragment",THREE.ShaderLib.sprite.fragmentShader));d.attachShader(w.program,ma("vertex",THREE.ShaderLib.sprite.vertexShader));d.linkProgram(w.program);w.attributes={};w.uniforms={};w.attributes.position=d.getAttribLocation(w.program,"position");w.attributes.uv=d.getAttribLocation(w.program,"uv");w.uniforms.uvOffset=d.getUniformLocation(w.program,"uvOffset");w.uniforms.uvScale=d.getUniformLocation(w.program,"uvScale");w.uniforms.rotation=d.getUniformLocation(w.program,"rotation");
  237. w.uniforms.scale=d.getUniformLocation(w.program,"scale");w.uniforms.alignment=d.getUniformLocation(w.program,"alignment");w.uniforms.color=d.getUniformLocation(w.program,"color");w.uniforms.map=d.getUniformLocation(w.program,"map");w.uniforms.opacity=d.getUniformLocation(w.program,"opacity");w.uniforms.useScreenCoordinates=d.getUniformLocation(w.program,"useScreenCoordinates");w.uniforms.affectedByDistance=d.getUniformLocation(w.program,"affectedByDistance");w.uniforms.screenPosition=d.getUniformLocation(w.program,
  238. "screenPosition");w.uniforms.modelViewMatrix=d.getUniformLocation(w.program,"modelViewMatrix");w.uniforms.projectionMatrix=d.getUniformLocation(w.program,"projectionMatrix");var Va=!1;this.setSize=function(a,b){Ca.width=a;Ca.height=b;this.setViewport(0,0,Ca.width,Ca.height)};this.setViewport=function(a,b,c,e){ya=a;Ra=b;Ma=c;Ia=e;d.viewport(ya,Ra,Ma,Ia)};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)};this.setClearColorHex=
  239. function(a,b){wa.setHex(a);Da=b;d.clearColor(wa.r,wa.g,wa.b,Da)};this.setClearColor=function(a,b){wa.copy(a);Da=b;d.clearColor(wa.r,wa.g,wa.b,Da)};this.getClearColor=function(){return wa};this.getClearAlpha=function(){return Da};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.getContext=function(){return d};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=!1,
  240. delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(g in a.geometry.geometryGroups){var b=a.geometry.geometryGroups[g];d.deleteBuffer(b.__webglVertexBuffer);d.deleteBuffer(b.__webglNormalBuffer);d.deleteBuffer(b.__webglTangentBuffer);d.deleteBuffer(b.__webglColorBuffer);d.deleteBuffer(b.__webglUVBuffer);d.deleteBuffer(b.__webglUV2Buffer);d.deleteBuffer(b.__webglSkinVertexABuffer);d.deleteBuffer(b.__webglSkinVertexBBuffer);
  241. d.deleteBuffer(b.__webglSkinIndicesBuffer);d.deleteBuffer(b.__webglSkinWeightsBuffer);d.deleteBuffer(b.__webglFaceBuffer);d.deleteBuffer(b.__webglLineBuffer);if(b.numMorphTargets)for(var c=0,e=b.numMorphTargets;c<e;c++)d.deleteBuffer(b.__webglMorphTargetsBuffers[c]);N.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,d.deleteBuffer(a.__webglVertexBuffer),d.deleteBuffer(a.__webglColorBuffer),N.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,d.deleteBuffer(a.__webglVertexBuffer),
  242. d.deleteBuffer(a.__webglColorBuffer),N.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,d.deleteBuffer(a.__webglVertexBuffer),d.deleteBuffer(a.__webglColorBuffer),N.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,d.deleteTexture(a.__webglTexture),N.info.memory.textures--};this.initMaterial=function(a,b,c,e){var f,h,i,o;a instanceof THREE.MeshDepthMaterial?o="depth":a instanceof THREE.MeshNormalMaterial?o="normal":a instanceof
  243. THREE.MeshBasicMaterial?o="basic":a instanceof THREE.MeshLambertMaterial?o="lambert":a instanceof THREE.MeshPhongMaterial?o="phong":a instanceof THREE.LineBasicMaterial?o="basic":a instanceof THREE.ParticleBasicMaterial&&(o="particle_basic");if(o){var k=THREE.ShaderLib[o];a.uniforms=THREE.UniformsUtils.clone(k.uniforms);a.vertexShader=k.vertexShader;a.fragmentShader=k.fragmentShader}var l,m,q;l=q=k=0;for(m=b.length;l<m;l++)i=b[l],i instanceof THREE.SpotLight&&q++,i instanceof THREE.DirectionalLight&&
  244. q++,i instanceof THREE.PointLight&&k++;k+q<=Sa?l=q:(l=Math.ceil(Sa*q/(k+q)),k=Sa-l);i={directional:l,point:k};k=q=0;for(l=b.length;k<l;k++)m=b[k],m instanceof THREE.SpotLight&&m.castShadow&&q++;var n=50;if(e!==void 0&&e instanceof THREE.SkinnedMesh)n=e.bones.length;var x;a:{l=a.fragmentShader;m=a.vertexShader;var k=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,
  245. maxMorphTargets:this.maxMorphTargets,maxDirLights:i.directional,maxPointLights:i.point,maxBones:n,shadowMapEnabled:this.shadowMapEnabled&&e.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:q,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel},r,e=[];o?e.push(o):(e.push(l),e.push(m));for(r in c)e.push(r),e.push(c[r]);o=e.join();r=0;for(e=Ea.length;r<e;r++)if(Ea[r].code===o){x=Ea[r].program;break a}r=d.createProgram();
  246. e=[Xa?"#define VERTEX_TEXTURES":"",N.gammaInput?"#define GAMMA_INPUT":"",N.gammaOutput?"#define GAMMA_OUTPUT":"",N.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":"",
  247. c.morphTargets?"#define USE_MORPHTARGETS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",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");
  248. i=["#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:"",N.gammaInput?"#define GAMMA_INPUT":"",N.gammaOutput?"#define GAMMA_OUTPUT":"",N.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":
  249. "",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(r,ma("fragment",i+l));d.attachShader(r,
  250. ma("vertex",e+m));d.linkProgram(r);d.getProgramParameter(r,d.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+d.getProgramParameter(r,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");r.uniforms={};r.attributes={};var t,e=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(t in k)e.push(t);t=e;e=0;for(k=t.length;e<k;e++)l=t[e],r.uniforms[l]=d.getUniformLocation(r,
  251. l);e=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(t=0;t<c.maxMorphTargets;t++)e.push("morphTarget"+t);for(x in b)e.push(x);x=e;t=0;for(b=x.length;t<b;t++)c=x[t],r.attributes[c]=d.getAttribLocation(r,c);r.id=Ea.length;Ea.push({program:r,code:o});N.info.memory.programs=Ea.length;x=r}a.program=x;x=a.program.attributes;x.position>=0&&d.enableVertexAttribArray(x.position);x.color>=0&&d.enableVertexAttribArray(x.color);x.normal>=0&&d.enableVertexAttribArray(x.normal);
  252. x.tangent>=0&&d.enableVertexAttribArray(x.tangent);a.skinning&&x.skinVertexA>=0&&x.skinVertexB>=0&&x.skinIndex>=0&&x.skinWeight>=0&&(d.enableVertexAttribArray(x.skinVertexA),d.enableVertexAttribArray(x.skinVertexB),d.enableVertexAttribArray(x.skinIndex),d.enableVertexAttribArray(x.skinWeight));if(a.attributes)for(h in a.attributes)x[h]!==void 0&&x[h]>=0&&d.enableVertexAttribArray(x[h]);if(a.morphTargets)for(h=a.numSupportedMorphTargets=0;h<this.maxMorphTargets;h++)t="morphTarget"+h,x[t]>=0&&(d.enableVertexAttribArray(x[t]),
  253. a.numSupportedMorphTargets++);a.uniformsList=[];for(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};this.clearTarget=function(a,b,c,d){W(a);this.clear(b,c,d)};this.updateShadowMap=function(a,b){F(a,b)};this.render=function(a,b,c,e){var w,U,Ka,o,s,Q,m,q=a.lights,S=a.fog;sa=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);this.shadowMapEnabled&&this.shadowMapAutoUpdate&&F(a,b);N.info.render.calls=0;N.info.render.vertices=0;N.info.render.faces=0;b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
  254. a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(Oa);b.projectionMatrix.flattenToArray(Na);Ba.multiply(b.projectionMatrix,b.matrixWorldInverse);t(Ba);W(c);(this.autoClear||e)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);Ka=a.__webglObjects.length;for(e=0;e<Ka;e++)if(s=a.__webglObjects[e],Q=s.object,Q.visible)if(!(Q instanceof THREE.Mesh)||!Q.frustumCulled||B(Q)){if(Q.matrixWorld.flattenToArray(Q._objectMatrixArray),
  255. O(Q,b,!0),D(s),s.render=!0,this.sortObjects)Q.renderDepth?s.z=Q.renderDepth:(Ha.copy(Q.position),Ba.multiplyVector3(Ha),s.z=Ha.z)}else s.render=!1;else s.render=!1;this.sortObjects&&a.__webglObjects.sort(G);o=a.__webglObjectsImmediate.length;for(e=0;e<o;e++)s=a.__webglObjectsImmediate[e],Q=s.object,Q.visible&&(Q.matrixAutoUpdate&&Q.matrixWorld.flattenToArray(Q._objectMatrixArray),O(Q,b,!0),C(s));if(a.overrideMaterial){r(a.overrideMaterial.depthTest);K(a.overrideMaterial.blending);for(e=0;e<Ka;e++)if(s=
  256. a.__webglObjects[e],s.render)Q=s.object,m=s.buffer,k(Q),f(b,q,S,a.overrideMaterial,m,Q);for(e=0;e<o;e++)s=a.__webglObjectsImmediate[e],Q=s.object,Q.visible&&(H=-1,k(Q),w=h(b,q,S,a.overrideMaterial,Q),Q.immediateRenderCallback?Q.immediateRenderCallback(w,d,va):Q.render(function(b){i(b,w,a.overrideMaterial.shading)}))}else{K(THREE.NormalBlending);for(e=Ka-1;e>=0;e--)if(s=a.__webglObjects[e],s.render&&(Q=s.object,m=s.buffer,U=s.opaque))k(Q),r(U.depthTest),n(U.depthWrite),l(U.polygonOffset,U.polygonOffsetFactor,
  257. U.polygonOffsetUnits),f(b,q,S,U,m,Q);for(e=0;e<o;e++)if(s=a.__webglObjectsImmediate[e],Q=s.object,Q.visible&&(H=-1,U=s.opaque))k(Q),r(U.depthTest),n(U.depthWrite),l(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),w=h(b,q,S,U,Q),Q.immediateRenderCallback?Q.immediateRenderCallback(w,d,va):Q.render(function(a){i(a,w,U.shading)});for(e=0;e<Ka;e++)if(s=a.__webglObjects[e],s.render&&(Q=s.object,m=s.buffer,U=s.transparent))k(Q),K(U.blending),r(U.depthTest),n(U.depthWrite),l(U.polygonOffset,U.polygonOffsetFactor,
  258. U.polygonOffsetUnits),f(b,q,S,U,m,Q);for(e=0;e<o;e++)if(s=a.__webglObjectsImmediate[e],Q=s.object,Q.visible&&(H=-1,U=s.transparent))k(Q),K(U.blending),r(U.depthTest),n(U.depthWrite),l(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),w=h(b,q,S,U,Q),Q.immediateRenderCallback?Q.immediateRenderCallback(w,d,va):Q.render(function(a){i(a,w,U.shading)})}a.__webglSprites.length&&ra(a,b);c&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&aa(c)};this.initWebGLObjects=function(a){if(!a.__webglObjects)a.__webglObjects=
  259. [],a.__webglObjectsImmediate=[],a.__webglSprites=[];for(;a.__objectsAdded.length;){var f=a.__objectsAdded[0],h=a,i=void 0,k=void 0,l=void 0;if(!f.__webglInit)if(f.__webglInit=!0,f._modelViewMatrix=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){k=f.geometry;if(k.geometryGroups===void 0){var l=k,n=void 0,o=void 0,s=void 0,r=void 0,
  260. m=void 0,q=void 0,t=void 0,x={},w=l.morphTargets.length;l.geometryGroups={};n=0;for(o=l.faces.length;n<o;n++)s=l.faces[n],r=s.materialIndex,q=r!==void 0?r:-1,x[q]===void 0&&(x[q]={hash:q,counter:0}),t=x[q].hash+"_"+x[q].counter,l.geometryGroups[t]===void 0&&(l.geometryGroups[t]={faces3:[],faces4:[],materialIndex:r,vertices:0,numMorphTargets:w}),m=s instanceof THREE.Face3?3:4,l.geometryGroups[t].vertices+m>65535&&(x[q].counter+=1,t=x[q].hash+"_"+x[q].counter,l.geometryGroups[t]===void 0&&(l.geometryGroups[t]=
  261. {faces3:[],faces4:[],materialIndex:r,vertices:0,numMorphTargets:w})),s instanceof THREE.Face3?l.geometryGroups[t].faces3.push(n):l.geometryGroups[t].faces4.push(n),l.geometryGroups[t].vertices+=m;l.geometryGroupsList=[];n=void 0;for(n in l.geometryGroups)l.geometryGroups[n].id=qa++,l.geometryGroupsList.push(l.geometryGroups[n])}for(i in k.geometryGroups)if(l=k.geometryGroups[i],!l.__webglVertexBuffer){n=l;n.__webglVertexBuffer=d.createBuffer();n.__webglNormalBuffer=d.createBuffer();n.__webglTangentBuffer=
  262. d.createBuffer();n.__webglColorBuffer=d.createBuffer();n.__webglUVBuffer=d.createBuffer();n.__webglUV2Buffer=d.createBuffer();n.__webglSkinVertexABuffer=d.createBuffer();n.__webglSkinVertexBBuffer=d.createBuffer();n.__webglSkinIndicesBuffer=d.createBuffer();n.__webglSkinWeightsBuffer=d.createBuffer();n.__webglFaceBuffer=d.createBuffer();n.__webglLineBuffer=d.createBuffer();if(n.numMorphTargets){s=o=void 0;n.__webglMorphTargetsBuffers=[];o=0;for(s=n.numMorphTargets;o<s;o++)n.__webglMorphTargetsBuffers.push(d.createBuffer())}N.info.memory.geometries++;
  263. r=f;m=r.geometry;o=l.faces3;q=l.faces4;n=o.length*3+q.length*4;s=o.length*1+q.length*2;q=o.length*3+q.length*4;o=c(r,l);t=o.map||o.lightMap||o instanceof THREE.ShaderMaterial?!0:!1;x=o instanceof THREE.MeshBasicMaterial&&!o.envMap||o instanceof THREE.MeshDepthMaterial?!1:o&&o.shading!==void 0&&o.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;w=o.vertexColors?o.vertexColors:!1;l.__vertexArray=new Float32Array(n*3);if(x)l.__normalArray=new Float32Array(n*3);if(m.hasTangents)l.__tangentArray=
  264. new Float32Array(n*4);if(w)l.__colorArray=new Float32Array(n*3);if(t){if(m.faceUvs.length>0||m.faceVertexUvs.length>0)l.__uvArray=new Float32Array(n*2);if(m.faceUvs.length>1||m.faceVertexUvs.length>1)l.__uv2Array=new Float32Array(n*2)}if(r.geometry.skinWeights.length&&r.geometry.skinIndices.length)l.__skinVertexAArray=new Float32Array(n*4),l.__skinVertexBArray=new Float32Array(n*4),l.__skinIndexArray=new Float32Array(n*4),l.__skinWeightArray=new Float32Array(n*4);l.__faceArray=new Uint16Array(s*3);
  265. l.__lineArray=new Uint16Array(q*2);if(l.numMorphTargets){l.__morphTargetsArrays=[];r=0;for(m=l.numMorphTargets;r<m;r++)l.__morphTargetsArrays.push(new Float32Array(n*3))}l.__needsSmoothNormals=x===THREE.SmoothShading;l.__uvType=t;l.__vertexColorType=w;l.__normalType=x;l.__webglFaceCount=s*3;l.__webglLineCount=q*2;if(o.attributes){if(l.__webglCustomAttributesList===void 0)l.__webglCustomAttributesList=[];s=void 0;for(s in o.attributes){var r=o.attributes[s],m={},B;for(B in r)m[B]=r[B];if(!m.__webglInitialized||
  266. m.createUniqueBuffers)m.__webglInitialized=!0,q=1,m.type==="v2"?q=2:m.type==="v3"?q=3:m.type==="v4"?q=4:m.type==="c"&&(q=3),m.size=q,m.array=new Float32Array(n*q),m.buffer=d.createBuffer(),m.buffer.belongsToAttribute=s,r.needsUpdate=!0,m.__original=r;l.__webglCustomAttributesList.push(m)}}l.__inittedArrays=!0;k.__dirtyVertices=!0;k.__dirtyMorphTargets=!0;k.__dirtyElements=!0;k.__dirtyUvs=!0;k.__dirtyNormals=!0;k.__dirtyTangents=!0;k.__dirtyColors=!0}}else if(f instanceof THREE.Ribbon){if(k=f.geometry,
  267. !k.__webglVertexBuffer)l=k,l.__webglVertexBuffer=d.createBuffer(),l.__webglColorBuffer=d.createBuffer(),N.info.memory.geometries++,l=k,n=l.vertices.length,l.__vertexArray=new Float32Array(n*3),l.__colorArray=new Float32Array(n*3),l.__webglVertexCount=n,k.__dirtyVertices=!0,k.__dirtyColors=!0}else if(f instanceof THREE.Line){if(k=f.geometry,!k.__webglVertexBuffer)l=k,l.__webglVertexBuffer=d.createBuffer(),l.__webglColorBuffer=d.createBuffer(),N.info.memory.geometries++,l=k,n=f,o=l.vertices.length,
  268. l.__vertexArray=new Float32Array(o*3),l.__colorArray=new Float32Array(o*3),l.__webglLineCount=o,b(l,n),k.__dirtyVertices=!0,k.__dirtyColors=!0}else if(f instanceof THREE.ParticleSystem&&(k=f.geometry,!k.__webglVertexBuffer))l=k,l.__webglVertexBuffer=d.createBuffer(),l.__webglColorBuffer=d.createBuffer(),N.info.geometries++,l=k,n=f,o=l.vertices.length,l.__vertexArray=new Float32Array(o*3),l.__colorArray=new Float32Array(o*3),l.__sortArray=[],l.__webglParticleCount=o,b(l,n),k.__dirtyVertices=!0,k.__dirtyColors=
  269. !0;if(!f.__webglActive){if(f instanceof THREE.Mesh)for(i in k=f.geometry,k.geometryGroups)l=k.geometryGroups[i],da(h.__webglObjects,l,f);else f instanceof THREE.Ribbon||f instanceof THREE.Line||f instanceof THREE.ParticleSystem?(k=f.geometry,da(h.__webglObjects,k,f)):THREE.MarchingCubes!==void 0&&f instanceof THREE.MarchingCubes||f.immediateRenderCallback?h.__webglObjectsImmediate.push({object:f,opaque:null,transparent:null}):f instanceof THREE.Sprite&&h.__webglSprites.push(f);f.__webglActive=!0}a.__objectsAdded.splice(0,
  270. 1)}for(;a.__objectsRemoved.length;){f=a.__objectsRemoved[0];h=a;if(f instanceof THREE.Mesh||f instanceof THREE.ParticleSystem||f instanceof THREE.Ribbon||f instanceof THREE.Line)S(h.__webglObjects,f);else if(f instanceof THREE.Sprite){h=h.__webglSprites;i=f;for(k=h.length-1;k>=0;k--)h[k]===i&&h.splice(k,1)}else(f instanceof THREE.MarchingCubes||f.immediateRenderCallback)&&S(h.__webglObjectsImmediate,f);f.__webglActive=!1;a.__objectsRemoved.splice(0,1)}f=0;for(h=a.__webglObjects.length;f<h;f++)if(B=
  271. a.__webglObjects[f].object,i=B.geometry,k=s=o=void 0,B instanceof THREE.Mesh){l=0;for(n=i.geometryGroupsList.length;l<n;l++)if(o=i.geometryGroupsList[l],k=c(B,o),s=k.attributes&&la(k),i.__dirtyVertices||i.__dirtyMorphTargets||i.__dirtyElements||i.__dirtyUvs||i.__dirtyNormals||i.__dirtyColors||i.__dirtyTangents||s)if(s=d.DYNAMIC_DRAW,r=!i.dynamic,o.__inittedArrays){var C=q=m=void 0,u=void 0,D=void 0,G=void 0,v=void 0,F=void 0,K=void 0,V=void 0,R=C=G=K=void 0,y=void 0,z=void 0,A=void 0,M=void 0,H=void 0,
  272. J=u=void 0,Z=u=K=void 0,$=void 0,L=u=A=z=y=M=A=z=y=M=A=z=y=M=A=z=y=v=void 0,ca=void 0,O=G=void 0,X=C=void 0,ha=void 0,P=void 0,E=R=X=ca=0,W=0,ea=L=C=0,T=v=H=0,p=0,I=0,Y=void 0,ha=o.__vertexArray,ga=o.__uvArray,p=o.__uv2Array,O=o.__normalArray,D=o.__tangentArray,J=o.__colorArray,Z=o.__skinVertexAArray,$=o.__skinVertexBArray,F=o.__skinIndexArray,ia=o.__skinWeightArray,ja=o.__morphTargetsArrays,t=o.__webglCustomAttributesList,j=void 0,j=o.__faceArray,I=o.__lineArray,ka=o.__needsSmoothNormals,K=o.__vertexColorType,
  273. V=o.__uvType,G=o.__normalType,aa=B.geometry,Y=aa.__dirtyElements,pa=aa.__dirtyUvs,ra=aa.__dirtyNormals,sa=aa.__dirtyTangents,ta=aa.__dirtyColors,P=aa.__dirtyMorphTargets,ma=aa.vertices,x=o.faces3,w=o.faces4,fa=aa.faces,va=aa.faceVertexUvs[0],wa=aa.faceVertexUvs[1],oa=aa.skinVerticesA,ua=aa.skinVerticesB,xa=aa.skinIndices,ya=aa.skinWeights,za=aa.morphTargets;if(aa.__dirtyVertices){m=0;for(q=x.length;m<q;m++)u=fa[x[m]],y=ma[u.a].position,z=ma[u.b].position,A=ma[u.c].position,ha[X]=y.x,ha[X+1]=y.y,ha[X+
  274. 2]=y.z,ha[X+3]=z.x,ha[X+4]=z.y,ha[X+5]=z.z,ha[X+6]=A.x,ha[X+7]=A.y,ha[X+8]=A.z,X+=9;m=0;for(q=w.length;m<q;m++)u=fa[w[m]],y=ma[u.a].position,z=ma[u.b].position,A=ma[u.c].position,M=ma[u.d].position,ha[X]=y.x,ha[X+1]=y.y,ha[X+2]=y.z,ha[X+3]=z.x,ha[X+4]=z.y,ha[X+5]=z.z,ha[X+6]=A.x,ha[X+7]=A.y,ha[X+8]=A.z,ha[X+9]=M.x,ha[X+10]=M.y,ha[X+11]=M.z,X+=12;d.bindBuffer(d.ARRAY_BUFFER,o.__webglVertexBuffer);d.bufferData(d.ARRAY_BUFFER,ha,s)}if(P){m=0;for(q=x.length;m<q;m++){u=fa[x[m]];X=0;for(ha=za.length;X<
  275. ha;X++)y=za[X].vertices[u.a].position,z=za[X].vertices[u.b].position,A=za[X].vertices[u.c].position,P=ja[X],P[T]=y.x,P[T+1]=y.y,P[T+2]=y.z,P[T+3]=z.x,P[T+4]=z.y,P[T+5]=z.z,P[T+6]=A.x,P[T+7]=A.y,P[T+8]=A.z;T+=9}m=0;for(q=w.length;m<q;m++){u=fa[w[m]];X=0;for(ha=za.length;X<ha;X++)y=za[X].vertices[u.a].position,z=za[X].vertices[u.b].position,A=za[X].vertices[u.c].position,M=za[X].vertices[u.d].position,P=ja[X],P[T]=y.x,P[T+1]=y.y,P[T+2]=y.z,P[T+3]=z.x,P[T+4]=z.y,P[T+5]=z.z,P[T+6]=A.x,P[T+7]=A.y,P[T+
  276. 8]=A.z,P[T+9]=M.x,P[T+10]=M.y,P[T+11]=M.z;T+=12}X=0;for(ha=za.length;X<ha;X++)d.bindBuffer(d.ARRAY_BUFFER,o.__webglMorphTargetsBuffers[X]),d.bufferData(d.ARRAY_BUFFER,ja[X],s)}if(ya.length){m=0;for(q=x.length;m<q;m++)u=fa[x[m]],y=ya[u.a],z=ya[u.b],A=ya[u.c],ia[v]=y.x,ia[v+1]=y.y,ia[v+2]=y.z,ia[v+3]=y.w,ia[v+4]=z.x,ia[v+5]=z.y,ia[v+6]=z.z,ia[v+7]=z.w,ia[v+8]=A.x,ia[v+9]=A.y,ia[v+10]=A.z,ia[v+11]=A.w,y=xa[u.a],z=xa[u.b],A=xa[u.c],F[v]=y.x,F[v+1]=y.y,F[v+2]=y.z,F[v+3]=y.w,F[v+4]=z.x,F[v+5]=z.y,F[v+6]=
  277. z.z,F[v+7]=z.w,F[v+8]=A.x,F[v+9]=A.y,F[v+10]=A.z,F[v+11]=A.w,y=oa[u.a],z=oa[u.b],A=oa[u.c],Z[v]=y.x,Z[v+1]=y.y,Z[v+2]=y.z,Z[v+3]=1,Z[v+4]=z.x,Z[v+5]=z.y,Z[v+6]=z.z,Z[v+7]=1,Z[v+8]=A.x,Z[v+9]=A.y,Z[v+10]=A.z,Z[v+11]=1,y=ua[u.a],z=ua[u.b],A=ua[u.c],$[v]=y.x,$[v+1]=y.y,$[v+2]=y.z,$[v+3]=1,$[v+4]=z.x,$[v+5]=z.y,$[v+6]=z.z,$[v+7]=1,$[v+8]=A.x,$[v+9]=A.y,$[v+10]=A.z,$[v+11]=1,v+=12;m=0;for(q=w.length;m<q;m++)u=fa[w[m]],y=ya[u.a],z=ya[u.b],A=ya[u.c],M=ya[u.d],ia[v]=y.x,ia[v+1]=y.y,ia[v+2]=y.z,ia[v+3]=y.w,
  278. ia[v+4]=z.x,ia[v+5]=z.y,ia[v+6]=z.z,ia[v+7]=z.w,ia[v+8]=A.x,ia[v+9]=A.y,ia[v+10]=A.z,ia[v+11]=A.w,ia[v+12]=M.x,ia[v+13]=M.y,ia[v+14]=M.z,ia[v+15]=M.w,y=xa[u.a],z=xa[u.b],A=xa[u.c],M=xa[u.d],F[v]=y.x,F[v+1]=y.y,F[v+2]=y.z,F[v+3]=y.w,F[v+4]=z.x,F[v+5]=z.y,F[v+6]=z.z,F[v+7]=z.w,F[v+8]=A.x,F[v+9]=A.y,F[v+10]=A.z,F[v+11]=A.w,F[v+12]=M.x,F[v+13]=M.y,F[v+14]=M.z,F[v+15]=M.w,y=oa[u.a],z=oa[u.b],A=oa[u.c],M=oa[u.d],Z[v]=y.x,Z[v+1]=y.y,Z[v+2]=y.z,Z[v+3]=1,Z[v+4]=z.x,Z[v+5]=z.y,Z[v+6]=z.z,Z[v+7]=1,Z[v+8]=A.x,
  279. Z[v+9]=A.y,Z[v+10]=A.z,Z[v+11]=1,Z[v+12]=M.x,Z[v+13]=M.y,Z[v+14]=M.z,Z[v+15]=1,y=ua[u.a],z=ua[u.b],A=ua[u.c],u=ua[u.d],$[v]=y.x,$[v+1]=y.y,$[v+2]=y.z,$[v+3]=1,$[v+4]=z.x,$[v+5]=z.y,$[v+6]=z.z,$[v+7]=1,$[v+8]=A.x,$[v+9]=A.y,$[v+10]=A.z,$[v+11]=1,$[v+12]=u.x,$[v+13]=u.y,$[v+14]=u.z,$[v+15]=1,v+=16;v>0&&(d.bindBuffer(d.ARRAY_BUFFER,o.__webglSkinVertexABuffer),d.bufferData(d.ARRAY_BUFFER,Z,s),d.bindBuffer(d.ARRAY_BUFFER,o.__webglSkinVertexBBuffer),d.bufferData(d.ARRAY_BUFFER,$,s),d.bindBuffer(d.ARRAY_BUFFER,
  280. o.__webglSkinIndicesBuffer),d.bufferData(d.ARRAY_BUFFER,F,s),d.bindBuffer(d.ARRAY_BUFFER,o.__webglSkinWeightsBuffer),d.bufferData(d.ARRAY_BUFFER,ia,s))}if(ta&&K){m=0;for(q=x.length;m<q;m++)u=fa[x[m]],v=u.vertexColors,F=u.color,v.length===3&&K===THREE.VertexColors?(u=v[0],Z=v[1],$=v[2]):$=Z=u=F,J[H]=u.r,J[H+1]=u.g,J[H+2]=u.b,J[H+3]=Z.r,J[H+4]=Z.g,J[H+5]=Z.b,J[H+6]=$.r,J[H+7]=$.g,J[H+8]=$.b,H+=9;m=0;for(q=w.length;m<q;m++)u=fa[w[m]],v=u.vertexColors,F=u.color,v.length===4&&K===THREE.VertexColors?(u=
  281. v[0],Z=v[1],$=v[2],v=v[3]):v=$=Z=u=F,J[H]=u.r,J[H+1]=u.g,J[H+2]=u.b,J[H+3]=Z.r,J[H+4]=Z.g,J[H+5]=Z.b,J[H+6]=$.r,J[H+7]=$.g,J[H+8]=$.b,J[H+9]=v.r,J[H+10]=v.g,J[H+11]=v.b,H+=12;H>0&&(d.bindBuffer(d.ARRAY_BUFFER,o.__webglColorBuffer),d.bufferData(d.ARRAY_BUFFER,J,s))}if(sa&&aa.hasTangents){m=0;for(q=x.length;m<q;m++)u=fa[x[m]],K=u.vertexTangents,H=K[0],u=K[1],J=K[2],D[L]=H.x,D[L+1]=H.y,D[L+2]=H.z,D[L+3]=H.w,D[L+4]=u.x,D[L+5]=u.y,D[L+6]=u.z,D[L+7]=u.w,D[L+8]=J.x,D[L+9]=J.y,D[L+10]=J.z,D[L+11]=J.w,L+=
  282. 12;m=0;for(q=w.length;m<q;m++)u=fa[w[m]],K=u.vertexTangents,H=K[0],u=K[1],J=K[2],K=K[3],D[L]=H.x,D[L+1]=H.y,D[L+2]=H.z,D[L+3]=H.w,D[L+4]=u.x,D[L+5]=u.y,D[L+6]=u.z,D[L+7]=u.w,D[L+8]=J.x,D[L+9]=J.y,D[L+10]=J.z,D[L+11]=J.w,D[L+12]=K.x,D[L+13]=K.y,D[L+14]=K.z,D[L+15]=K.w,L+=16;d.bindBuffer(d.ARRAY_BUFFER,o.__webglTangentBuffer);d.bufferData(d.ARRAY_BUFFER,D,s)}if(ra&&G){m=0;for(q=x.length;m<q;m++)if(u=fa[x[m]],D=u.vertexNormals,G=u.normal,D.length===3&&ka)for(L=0;L<3;L++)G=D[L],O[C]=G.x,O[C+1]=G.y,O[C+
  283. 2]=G.z,C+=3;else for(L=0;L<3;L++)O[C]=G.x,O[C+1]=G.y,O[C+2]=G.z,C+=3;m=0;for(q=w.length;m<q;m++)if(u=fa[w[m]],D=u.vertexNormals,G=u.normal,D.length===4&&ka)for(L=0;L<4;L++)G=D[L],O[C]=G.x,O[C+1]=G.y,O[C+2]=G.z,C+=3;else for(L=0;L<4;L++)O[C]=G.x,O[C+1]=G.y,O[C+2]=G.z,C+=3;d.bindBuffer(d.ARRAY_BUFFER,o.__webglNormalBuffer);d.bufferData(d.ARRAY_BUFFER,O,s)}if(pa&&va&&V){m=0;for(q=x.length;m<q;m++)if(C=x[m],C=va[C],C!==void 0)for(L=0;L<3;L++)O=C[L],ga[R]=O.u,ga[R+1]=O.v,R+=2;m=0;for(q=w.length;m<q;m++)if(C=
  284. w[m],C=va[C],C!==void 0)for(L=0;L<4;L++)O=C[L],ga[R]=O.u,ga[R+1]=O.v,R+=2;R>0&&(d.bindBuffer(d.ARRAY_BUFFER,o.__webglUVBuffer),d.bufferData(d.ARRAY_BUFFER,ga,s))}if(pa&&wa&&V){m=0;for(q=x.length;m<q;m++)if(C=x[m],R=wa[C],R!==void 0)for(L=0;L<3;L++)C=R[L],p[E]=C.u,p[E+1]=C.v,E+=2;m=0;for(q=w.length;m<q;m++)if(C=w[m],R=wa[C],R!==void 0)for(L=0;L<4;L++)C=R[L],p[E]=C.u,p[E+1]=C.v,E+=2;E>0&&(d.bindBuffer(d.ARRAY_BUFFER,o.__webglUV2Buffer),d.bufferData(d.ARRAY_BUFFER,p,s))}if(Y){m=0;for(q=x.length;m<q;m++)j[W]=
  285. ca,j[W+1]=ca+1,j[W+2]=ca+2,W+=3,I[ea]=ca,I[ea+1]=ca+1,I[ea+2]=ca,I[ea+3]=ca+2,I[ea+4]=ca+1,I[ea+5]=ca+2,ea+=6,ca+=3;m=0;for(q=w.length;m<q;m++)j[W]=ca,j[W+1]=ca+1,j[W+2]=ca+3,j[W+3]=ca+1,j[W+4]=ca+2,j[W+5]=ca+3,W+=6,I[ea]=ca,I[ea+1]=ca+1,I[ea+2]=ca,I[ea+3]=ca+3,I[ea+4]=ca+1,I[ea+5]=ca+2,I[ea+6]=ca+2,I[ea+7]=ca+3,ea+=8,ca+=4;d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,o.__webglFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,j,s);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,o.__webglLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,
  286. I,s)}if(t){L=0;for(ca=t.length;L<ca;L++)if(j=t[L],j.__original.needsUpdate){I=p=0;if(j.size===1)if(j.boundTo===void 0||j.boundTo==="vertices"){m=0;for(q=x.length;m<q;m++)u=fa[x[m]],j.array[p]=j.value[u.a],j.array[p+1]=j.value[u.b],j.array[p+2]=j.value[u.c],p+=3;m=0;for(q=w.length;m<q;m++)u=fa[w[m]],j.array[p]=j.value[u.a],j.array[p+1]=j.value[u.b],j.array[p+2]=j.value[u.c],j.array[p+3]=j.value[u.d],p+=4}else if(j.boundTo==="faces"){m=0;for(q=x.length;m<q;m++)Y=j.value[I],j.array[p]=Y,j.array[p+1]=
  287. Y,j.array[p+2]=Y,p+=3,I+=1;m=0;for(q=w.length;m<q;m++)Y=j.value[I],j.array[p]=Y,j.array[p+1]=Y,j.array[p+2]=Y,j.array[p+3]=Y,p+=4,I+=1}else{if(j.boundTo==="faceVertices"){m=0;for(q=x.length;m<q;m++)j.array[p]=j.value[I],j.array[p+1]=j.value[I+1],j.array[p+2]=j.value[I+2],p+=3,I+=3;m=0;for(q=w.length;m<q;m++)j.array[p]=j.value[I],j.array[p+1]=j.value[I+1],j.array[p+2]=j.value[I+2],j.array[p+3]=j.value[I+3],p+=4,I+=4}}else if(j.size===2)if(j.boundTo===void 0||j.boundTo==="vertices"){m=0;for(q=x.length;m<
  288. q;m++)u=fa[x[m]],y=j.value[u.a],z=j.value[u.b],A=j.value[u.c],j.array[p]=y.x,j.array[p+1]=y.y,j.array[p+2]=z.x,j.array[p+3]=z.y,j.array[p+4]=A.x,j.array[p+5]=A.y,p+=6;m=0;for(q=w.length;m<q;m++)u=fa[w[m]],y=j.value[u.a],z=j.value[u.b],A=j.value[u.c],M=j.value[u.d],j.array[p]=y.x,j.array[p+1]=y.y,j.array[p+2]=z.x,j.array[p+3]=z.y,j.array[p+4]=A.x,j.array[p+5]=A.y,j.array[p+6]=M.x,j.array[p+7]=M.y,p+=8}else if(j.boundTo==="faces"){m=0;for(q=x.length;m<q;m++)A=z=y=Y=j.value[I],j.array[p]=y.x,j.array[p+
  289. 1]=y.y,j.array[p+2]=z.x,j.array[p+3]=z.y,j.array[p+4]=A.x,j.array[p+5]=A.y,p+=6,I+=1;m=0;for(q=w.length;m<q;m++)M=A=z=y=Y=j.value[I],j.array[p]=y.x,j.array[p+1]=y.y,j.array[p+2]=z.x,j.array[p+3]=z.y,j.array[p+4]=A.x,j.array[p+5]=A.y,j.array[p+6]=M.x,j.array[p+7]=M.y,p+=8,I+=1}else{if(j.boundTo==="faceVertices"){m=0;for(q=x.length;m<q;m++)y=j.value[I],z=j.value[I+1],A=j.value[I+2],j.array[p]=y.x,j.array[p+1]=y.y,j.array[p+2]=z.x,j.array[p+3]=z.y,j.array[p+4]=A.x,j.array[p+5]=A.y,p+=6,I+=3;m=0;for(q=
  290. w.length;m<q;m++)y=j.value[I],z=j.value[I+1],A=j.value[I+2],M=j.value[I+3],j.array[p]=y.x,j.array[p+1]=y.y,j.array[p+2]=z.x,j.array[p+3]=z.y,j.array[p+4]=A.x,j.array[p+5]=A.y,j.array[p+6]=M.x,j.array[p+7]=M.y,p+=8,I+=4}}else if(j.size===3)if(E=j.type==="c"?["r","g","b"]:["x","y","z"],j.boundTo===void 0||j.boundTo==="vertices"){m=0;for(q=x.length;m<q;m++)u=fa[x[m]],y=j.value[u.a],z=j.value[u.b],A=j.value[u.c],j.array[p]=y[E[0]],j.array[p+1]=y[E[1]],j.array[p+2]=y[E[2]],j.array[p+3]=z[E[0]],j.array[p+
  291. 4]=z[E[1]],j.array[p+5]=z[E[2]],j.array[p+6]=A[E[0]],j.array[p+7]=A[E[1]],j.array[p+8]=A[E[2]],p+=9;m=0;for(q=w.length;m<q;m++)u=fa[w[m]],y=j.value[u.a],z=j.value[u.b],A=j.value[u.c],M=j.value[u.d],j.array[p]=y[E[0]],j.array[p+1]=y[E[1]],j.array[p+2]=y[E[2]],j.array[p+3]=z[E[0]],j.array[p+4]=z[E[1]],j.array[p+5]=z[E[2]],j.array[p+6]=A[E[0]],j.array[p+7]=A[E[1]],j.array[p+8]=A[E[2]],j.array[p+9]=M[E[0]],j.array[p+10]=M[E[1]],j.array[p+11]=M[E[2]],p+=12,I+=1}else if(j.boundTo==="faces"){m=0;for(q=x.length;m<
  292. q;m++)A=z=y=Y=j.value[I],j.array[p]=y[E[0]],j.array[p+1]=y[E[1]],j.array[p+2]=y[E[2]],j.array[p+3]=z[E[0]],j.array[p+4]=z[E[1]],j.array[p+5]=z[E[2]],j.array[p+6]=A[E[0]],j.array[p+7]=A[E[1]],j.array[p+8]=A[E[2]],p+=9,I+=1;m=0;for(q=w.length;m<q;m++)M=A=z=y=Y=j.value[I],j.array[p]=y[E[0]],j.array[p+1]=y[E[1]],j.array[p+2]=y[E[2]],j.array[p+3]=z[E[0]],j.array[p+4]=z[E[1]],j.array[p+5]=z[E[2]],j.array[p+6]=A[E[0]],j.array[p+7]=A[E[1]],j.array[p+8]=A[E[2]],j.array[p+9]=M[E[0]],j.array[p+10]=M[E[1]],j.array[p+
  293. 11]=M[E[2]],p+=12,I+=1}else{if(j.boundTo==="faceVertices"){m=0;for(q=x.length;m<q;m++)y=j.value[I],z=j.value[I+1],A=j.value[I+2],j.array[p]=y[E[0]],j.array[p+1]=y[E[1]],j.array[p+2]=y[E[2]],j.array[p+3]=z[E[0]],j.array[p+4]=z[E[1]],j.array[p+5]=z[E[2]],j.array[p+6]=A[E[0]],j.array[p+7]=A[E[1]],j.array[p+8]=A[E[2]],p+=9,I+=3;m=0;for(q=w.length;m<q;m++)y=j.value[I],z=j.value[I+1],A=j.value[I+2],M=j.value[I+3],j.array[p]=y[E[0]],j.array[p+1]=y[E[1]],j.array[p+2]=y[E[2]],j.array[p+3]=z[E[0]],j.array[p+
  294. 4]=z[E[1]],j.array[p+5]=z[E[2]],j.array[p+6]=A[E[0]],j.array[p+7]=A[E[1]],j.array[p+8]=A[E[2]],j.array[p+9]=M[E[0]],j.array[p+10]=M[E[1]],j.array[p+11]=M[E[2]],p+=12,I+=4}}else if(j.size===4)if(j.boundTo===void 0||j.boundTo==="vertices"){m=0;for(q=x.length;m<q;m++)u=fa[x[m]],y=j.value[u.a],z=j.value[u.b],A=j.value[u.c],j.array[p]=y.x,j.array[p+1]=y.y,j.array[p+2]=y.z,j.array[p+3]=y.w,j.array[p+4]=z.x,j.array[p+5]=z.y,j.array[p+6]=z.z,j.array[p+7]=z.w,j.array[p+8]=A.x,j.array[p+9]=A.y,j.array[p+10]=
  295. A.z,j.array[p+11]=A.w,p+=12;m=0;for(q=w.length;m<q;m++)u=fa[w[m]],y=j.value[u.a],z=j.value[u.b],A=j.value[u.c],M=j.value[u.d],j.array[p]=y.x,j.array[p+1]=y.y,j.array[p+2]=y.z,j.array[p+3]=y.w,j.array[p+4]=z.x,j.array[p+5]=z.y,j.array[p+6]=z.z,j.array[p+7]=z.w,j.array[p+8]=A.x,j.array[p+9]=A.y,j.array[p+10]=A.z,j.array[p+11]=A.w,j.array[p+12]=M.x,j.array[p+13]=M.y,j.array[p+14]=M.z,j.array[p+15]=M.w,p+=16}else if(j.boundTo==="faces"){m=0;for(q=x.length;m<q;m++)A=z=y=Y=j.value[I],j.array[p]=y.x,j.array[p+
  296. 1]=y.y,j.array[p+2]=y.z,j.array[p+3]=y.w,j.array[p+4]=z.x,j.array[p+5]=z.y,j.array[p+6]=z.z,j.array[p+7]=z.w,j.array[p+8]=A.x,j.array[p+9]=A.y,j.array[p+10]=A.z,j.array[p+11]=A.w,p+=12,I+=1;m=0;for(q=w.length;m<q;m++)M=A=z=y=Y=j.value[I],j.array[p]=y.x,j.array[p+1]=y.y,j.array[p+2]=y.z,j.array[p+3]=y.w,j.array[p+4]=z.x,j.array[p+5]=z.y,j.array[p+6]=z.z,j.array[p+7]=z.w,j.array[p+8]=A.x,j.array[p+9]=A.y,j.array[p+10]=A.z,j.array[p+11]=A.w,j.array[p+12]=M.x,j.array[p+13]=M.y,j.array[p+14]=M.z,j.array[p+
  297. 15]=M.w,p+=16,I+=1}else if(j.boundTo==="faceVertices"){m=0;for(q=x.length;m<q;m++)y=j.value[I],z=j.value[I+1],A=j.value[I+2],j.array[p]=y.x,j.array[p+1]=y.y,j.array[p+2]=y.z,j.array[p+3]=y.w,j.array[p+4]=z.x,j.array[p+5]=z.y,j.array[p+6]=z.z,j.array[p+7]=z.w,j.array[p+8]=A.x,j.array[p+9]=A.y,j.array[p+10]=A.z,j.array[p+11]=A.w,p+=12,I+=3;m=0;for(q=w.length;m<q;m++)y=j.value[I],z=j.value[I+1],A=j.value[I+2],M=j.value[I+3],j.array[p]=y.x,j.array[p+1]=y.y,j.array[p+2]=y.z,j.array[p+3]=y.w,j.array[p+
  298. 4]=z.x,j.array[p+5]=z.y,j.array[p+6]=z.z,j.array[p+7]=z.w,j.array[p+8]=A.x,j.array[p+9]=A.y,j.array[p+10]=A.z,j.array[p+11]=A.w,j.array[p+12]=M.x,j.array[p+13]=M.y,j.array[p+14]=M.z,j.array[p+15]=M.w,p+=16,I+=4}d.bindBuffer(d.ARRAY_BUFFER,j.buffer);d.bufferData(d.ARRAY_BUFFER,j.array,s)}}r&&(delete o.__inittedArrays,delete o.__colorArray,delete o.__normalArray,delete o.__tangentArray,delete o.__uvArray,delete o.__uv2Array,delete o.__faceArray,delete o.__vertexArray,delete o.__lineArray,delete o.__skinVertexAArray,
  299. delete o.__skinVertexBArray,delete o.__skinIndexArray,delete o.__skinWeightArray)}i.__dirtyVertices=!1;i.__dirtyMorphTargets=!1;i.__dirtyElements=!1;i.__dirtyUvs=!1;i.__dirtyNormals=!1;i.__dirtyColors=!1;i.__dirtyTangents=!1;k.attributes&&na(k)}else if(B instanceof THREE.Ribbon){if(i.__dirtyVertices||i.__dirtyColors){k=i;B=d.DYNAMIC_DRAW;l=m=r=r=void 0;q=k.vertices;n=k.colors;t=q.length;o=n.length;x=k.__vertexArray;s=k.__colorArray;w=k.__dirtyColors;if(k.__dirtyVertices){for(r=0;r<t;r++)m=q[r].position,
  300. l=r*3,x[l]=m.x,x[l+1]=m.y,x[l+2]=m.z;d.bindBuffer(d.ARRAY_BUFFER,k.__webglVertexBuffer);d.bufferData(d.ARRAY_BUFFER,x,B)}if(w){for(r=0;r<o;r++)color=n[r],l=r*3,s[l]=color.r,s[l+1]=color.g,s[l+2]=color.b;d.bindBuffer(d.ARRAY_BUFFER,k.__webglColorBuffer);d.bufferData(d.ARRAY_BUFFER,s,B)}}i.__dirtyVertices=!1;i.__dirtyColors=!1}else if(B instanceof THREE.Line){k=c(B,o);s=k.attributes&&la(k);if(i.__dirtyVertices||i.__dirtyColors||s){B=i;l=d.DYNAMIC_DRAW;n=ca=q=fa=void 0;q=B.vertices;o=B.colors;t=q.length;
  301. s=o.length;x=B.__vertexArray;r=B.__colorArray;w=B.__dirtyColors;m=B.__webglCustomAttributesList;R=ea=W=E=ca=fa=void 0;if(B.__dirtyVertices){for(fa=0;fa<t;fa++)ca=q[fa].position,n=fa*3,x[n]=ca.x,x[n+1]=ca.y,x[n+2]=ca.z;d.bindBuffer(d.ARRAY_BUFFER,B.__webglVertexBuffer);d.bufferData(d.ARRAY_BUFFER,x,l)}if(w){for(q=0;q<s;q++)color=o[q],n=q*3,r[n]=color.r,r[n+1]=color.g,r[n+2]=color.b;d.bindBuffer(d.ARRAY_BUFFER,B.__webglColorBuffer);d.bufferData(d.ARRAY_BUFFER,r,l)}if(m){fa=0;for(ca=m.length;fa<ca;fa++)if(R=
  302. m[fa],R.needsUpdate&&(R.boundTo===void 0||R.boundTo==="vertices")){n=0;W=R.value.length;if(R.size===1)for(E=0;E<W;E++)R.array[E]=R.value[E];else if(R.size===2)for(E=0;E<W;E++)ea=R.value[E],R.array[n]=ea.x,R.array[n+1]=ea.y,n+=2;else if(R.size===3)if(R.type==="c")for(E=0;E<W;E++)ea=R.value[E],R.array[n]=ea.r,R.array[n+1]=ea.g,R.array[n+2]=ea.b,n+=3;else for(E=0;E<W;E++)ea=R.value[E],R.array[n]=ea.x,R.array[n+1]=ea.y,R.array[n+2]=ea.z,n+=3;else if(R.size===4)for(E=0;E<W;E++)ea=R.value[E],R.array[n]=
  303. ea.x,R.array[n+1]=ea.y,R.array[n+2]=ea.z,R.array[n+3]=ea.w,n+=4;d.bindBuffer(d.ARRAY_BUFFER,R.buffer);d.bufferData(d.ARRAY_BUFFER,R.array,l)}}}i.__dirtyVertices=!1;i.__dirtyColors=!1;k.attributes&&na(k)}else if(B instanceof THREE.ParticleSystem)k=c(B,o),s=k.attributes&&la(k),(i.__dirtyVertices||i.__dirtyColors||B.sortParticles||s)&&e(i,d.DYNAMIC_DRAW,B),i.__dirtyVertices=!1,i.__dirtyColors=!1,k.attributes&&na(k)};this.setFaceCulling=function(a,b){a?(!b||b==="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW),
  304. 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)};this.supportsVertexTextures=function(){return Xa}};
  305. 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:
  306. THREE.UnsignedByteType;this.depthBuffer=c.depthBuffer!==void 0?c.depthBuffer:!0;this.stencilBuffer=c.stencilBuffer!==void 0?c.stencilBuffer:!0};
  307. 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};
  308. THREE.WebGLRenderTargetCube.prototype=new THREE.WebGLRenderTarget;THREE.WebGLRenderTargetCube.prototype.constructor=THREE.WebGLRenderTargetCube;