ThreeWebGL.js 149 KB

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