// Three.js r37 - http://github.com/mrdoob/three.js var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)}; THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,b){var d,f,g,h,k,m;if(b==0)d=f=g=0;else{h=Math.floor(a*6);k=a*6-h;a=b*(1-c);m=b*(1-c*k);c=b*(1-c*(1-k));switch(h){case 1:d=m;f=b;g=a;break;case 2:d=a;f=b;g=c;break;case 3:d=a;f=m;g=b;break;case 4:d=c;f=a;g=b;break;case 5:d=b;f=a; g=m;break;case 6:case 0:d=b;f=c;g=a}}this.r=d;this.g=f;this.b=g;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* 255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,c){this.set(a||0,c||0)}; THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/ this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,c,b){this.set(a||0,c||0,b||0)}; THREE.Vector3.prototype={set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a, c){this.set(a.y*c.z-a.z*c.y,a.z*c.x-a.x*c.z,a.x*c.y-a.y*c.x);return this},crossSelf:function(a){var c=this.x,b=this.y,d=this.z;this.set(b*a.z-d*a.y,d*a.x-c*a.z,c*a.y-b*a.x);return this},multiply:function(a,c){this.set(a.x*c.x,a.y*c.y,a.z*c.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/ a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var c=this.x-a.x,b=this.y-a.y;a=this.z-a.z;return c*c+b*b+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a= this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){this.y=Math.asin(a.n13);var c=Math.cos(this.y);if(Math.abs(c)>1.0E-5){this.x=Math.atan2(-a.n23/c,a.n33/c);this.z=Math.atan2(-a.n13/c,a.n11/c)}else{this.x=0;this.z=Math.atan2(a.n21,a.n22)}},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)< 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,c,b,d){this.set(a||0,c||0,b||0,d||1)}; THREE.Vector4.prototype={set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z,a.w+c.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z,a.w-c.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,c){this.set(this.x+(a.x-this.x)*c,this.y+(a.y-this.y)*c,this.z+(a.z-this.z)*c,this.w+(a.w-this.w)*c)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3}; THREE.Ray.prototype={intersectScene:function(a){var c,b,d=a.objects,f=[];a=0;for(c=d.length;a0&&I>0&&P+I<1}var b,d,f,g,h,k,m,n,q,x, z,p=a.geometry,A=p.vertices,G=[];b=0;for(d=p.faces.length;bm?d:m;f=f>n?f:n}a()}; this.add3Points=function(m,n,q,x,z,p){if(k){k=!1;c=mq?m>z?m:z:q>z?q:z;f=n>x?n>p?n:p:x>p?x:p}else{c=mq?m>z?m>d?m:d:z>d?z:d:q>z?q>d?q:d:z>d?z:d;f=n>x?n>p?n>f?n:f:p>f?p:f:x>p?x>f?x:f:p>f?p:f}a()};this.addRectangle=function(m){if(k){k=!1;c=m.getLeft();b=m.getTop();d=m.getRight();f=m.getBottom()}else{c=cm.getRight()? d:m.getRight();f=f>m.getBottom()?f:m.getBottom()}a()};this.inflate=function(m){c-=m;b-=m;d+=m;f+=m;a()};this.minSelf=function(m){c=c>m.getLeft()?c:m.getLeft();b=b>m.getTop()?b:m.getTop();d=d=0&&Math.min(f,m.getBottom())-Math.max(b,m.getTop())>=0};this.empty=function(){k=!0;f=d=b=c=0;a()};this.isEmpty=function(){return k}}; THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}}; THREE.Matrix4=function(a,c,b,d,f,g,h,k,m,n,q,x,z,p,A,G){this.set(a||1,c||0,b||0,d||0,f||0,g||1,h||0,k||0,m||0,n||0,q||1,x||0,z||0,p||0,A||0,G||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; THREE.Matrix4.prototype={set:function(a,c,b,d,f,g,h,k,m,n,q,x,z,p,A,G){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=f;this.n22=g;this.n23=h;this.n24=k;this.n31=m;this.n32=n;this.n33=q;this.n34=x;this.n41=z;this.n42=p;this.n43=A;this.n44=G;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,c,b){var d=THREE.Matrix4.__v1, f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,c).normalize();if(g.length()===0)g.z=1;d.cross(b,g).normalize();if(d.length()===0){g.x+=1.0E-4;d.cross(b,g).normalize()}f.cross(g,d).normalize();this.n11=d.x;this.n12=f.x;this.n13=g.x;this.n21=d.y;this.n22=f.y;this.n23=g.y;this.n31=d.z;this.n32=f.z;this.n33=g.z;return this},multiplyVector3:function(a){var c=a.x,b=a.y,d=a.z,f=1/(this.n41*c+this.n42*b+this.n43*d+this.n44);a.x=(this.n11*c+this.n12*b+this.n13*d+this.n14)*f;a.y=(this.n21*c+this.n22*b+this.n23* d+this.n24)*f;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*f;return a},multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,f=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*f;a.y=this.n21*c+this.n22*b+this.n23*d+this.n24*f;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*f;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*f;return a},rotateAxis:function(a){var c=a.x,b=a.y,d=a.z;a.x=c*this.n11+b*this.n12+d*this.n13;a.y=c*this.n21+b*this.n22+d*this.n23;a.z=c*this.n31+b*this.n32+d*this.n33;a.normalize(); return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var b=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,m=a.n23,n=a.n24,q=a.n31,x=a.n32,z=a.n33,p=a.n34,A=a.n41,G=a.n42,I=a.n43,C=a.n44,J=c.n11,B=c.n12,U=c.n13,P=c.n14,O=c.n21,V=c.n22, Y=c.n23,e=c.n24,ja=c.n31,X=c.n32,W=c.n33,wa=c.n34;this.n11=b*J+d*O+f*ja;this.n12=b*B+d*V+f*X;this.n13=b*U+d*Y+f*W;this.n14=b*P+d*e+f*wa+g;this.n21=h*J+k*O+m*ja;this.n22=h*B+k*V+m*X;this.n23=h*U+k*Y+m*W;this.n24=h*P+k*e+m*wa+n;this.n31=q*J+x*O+z*ja;this.n32=q*B+x*V+z*X;this.n33=q*U+x*Y+z*W;this.n34=q*P+x*e+z*wa+p;this.n41=A*J+G*O+I*ja;this.n42=A*B+G*V+I*X;this.n43=A*U+G*Y+I*W;this.n44=A*P+G*e+I*wa+C;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]=this.n31; b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=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},determinant:function(){var a= this.n11,c=this.n12,b=this.n13,d=this.n14,f=this.n21,g=this.n22,h=this.n23,k=this.n24,m=this.n31,n=this.n32,q=this.n33,x=this.n34,z=this.n41,p=this.n42,A=this.n43,G=this.n44;return d*h*n*z-b*k*n*z-d*g*q*z+c*k*q*z+b*g*x*z-c*h*x*z-d*h*m*p+b*k*m*p+d*f*q*p-a*k*q*p-b*f*x*p+a*h*x*p+d*g*m*A-c*k*m*A-d*f*n*A+a*k*n*A+c*f*x*A-a*g*x*A-b*g*m*G+c*h*m*G+b*f*n*G-a*h*n*G-c*f*q*G+a*g*q*G},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32= this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;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]=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,c){a[c]=this.n11;a[c+1]=this.n21;a[c+2]=this.n31;a[c+3]=this.n41;a[c+4]=this.n12;a[c+5]=this.n22;a[c+6]=this.n32;a[c+7]=this.n42;a[c+8]=this.n13;a[c+9]=this.n23;a[c+10]=this.n33;a[c+11]=this.n43;a[c+12]=this.n14;a[c+13]=this.n24;a[c+14]=this.n34;a[c+15]=this.n44;return a},setTranslation:function(a,c,b){this.set(1,0,0,a,0,1,0,c,0,0,1,b,0,0,0,1);return this},setScale:function(a, c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0,0,1);return this},setRotationX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotationY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotationZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,c){var b=Math.cos(c),d=Math.sin(c),f=1-b,g=a.x,h=a.y,k=a.z,m=f*g,n=f*h;this.set(m* g+b,m*h-d*k,m*k+d*h,0,m*h+d*k,n*h+b,n*k-d*g,0,m*k-d*h,n*k+d*g,f*k*k+b,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var c=a.x,b=a.y,d=a.z;a=Math.cos(c);c=Math.sin(c);var f=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var h=a*b,k=c*b;this.n11=f*g;this.n12=-f*d;this.n13=b;this.n21=k*g+a*d;this.n22=-k*d+a*g;this.n23=-c*f;this.n31=-h*g+c*d;this.n32=h*d+c*g;this.n33=a*f;return this},setRotationFromQuaternion:function(a){var c= a.x,b=a.y,d=a.z,f=a.w,g=c+c,h=b+b,k=d+d;a=c*g;var m=c*h;c*=k;var n=b*h;b*=k;d*=k;g*=f;h*=f;f*=k;this.n11=1-(n+d);this.n12=m-f;this.n13=c+h;this.n21=m+f;this.n22=1-(a+d);this.n23=b-g;this.n31=c-h;this.n32=b+g;this.n33=1-(a+n);return this},scale:function(a){var c=a.x,b=a.y;a=a.z;this.n11*=c;this.n12*=b;this.n13*=a;this.n21*=c;this.n22*=b;this.n23*=a;this.n31*=c;this.n32*=b;this.n33*=a;this.n41*=c;this.n42*=b;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34= a.n34},extractRotation:function(a,c){var b=1/c.x,d=1/c.y,f=1/c.z;this.n11=a.n11*b;this.n21=a.n21*b;this.n31=a.n31*b;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*f;this.n23=a.n23*f;this.n33=a.n33*f}}; THREE.Matrix4.makeInvert=function(a,c){var b=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,m=a.n23,n=a.n24,q=a.n31,x=a.n32,z=a.n33,p=a.n34,A=a.n41,G=a.n42,I=a.n43,C=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=m*p*G-n*z*G+n*x*I-k*p*I-m*x*C+k*z*C;c.n12=g*z*G-f*p*G-g*x*I+d*p*I+f*x*C-d*z*C;c.n13=f*n*G-g*m*G+g*k*I-d*n*I-f*k*C+d*m*C;c.n14=g*m*x-f*n*x-g*k*z+d*n*z+f*k*p-d*m*p;c.n21=n*z*A-m*p*A-n*q*I+h*p*I+m*q*C-h*z*C;c.n22=f*p*A-g*z*A+g*q*I-b*p*I-f*q*C+b*z*C;c.n23=g*m*A-f*n*A-g*h*I+b*n*I+f*h*C-b*m*C; c.n24=f*n*q-g*m*q+g*h*z-b*n*z-f*h*p+b*m*p;c.n31=k*p*A-n*x*A+n*q*G-h*p*G-k*q*C+h*x*C;c.n32=g*x*A-d*p*A-g*q*G+b*p*G+d*q*C-b*x*C;c.n33=f*n*A-g*k*A+g*h*G-b*n*G-d*h*C+b*k*C;c.n34=g*k*q-d*n*q-g*h*x+b*n*x+d*h*p-b*k*p;c.n41=m*x*A-k*z*A-m*q*G+h*z*G+k*q*I-h*x*I;c.n42=d*z*A-f*x*A+f*q*G-b*z*G-d*q*I+b*x*I;c.n43=f*k*A-d*m*A-f*h*G+b*m*G+d*h*I-b*k*I;c.n44=d*m*q-f*k*q+f*h*x-b*m*x-d*h*z+b*k*z;c.multiplyScalar(1/a.determinant());return c}; THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,b=c.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,m=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,q=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*n;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*d;b[1]=a*f;b[2]=a*g;b[3]=a*h;b[4]=a*k;b[5]=a*m;b[6]=a*n;b[7]=a*q;b[8]=a*x;return c}; THREE.Matrix4.makeFrustum=function(a,c,b,d,f,g){var h;h=new THREE.Matrix4;h.n11=2*f/(c-a);h.n12=0;h.n13=(c+a)/(c-a);h.n14=0;h.n21=0;h.n22=2*f/(d-b);h.n23=(d+b)/(d-b);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+f)/(g-f);h.n34=-2*g*f/(g-f);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,b,d){var f;a=b*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,b,d)}; THREE.Matrix4.makeOrtho=function(a,c,b,d,f,g){var h,k,m,n;h=new THREE.Matrix4;k=c-a;m=b-d;n=g-f;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-((c+a)/k);h.n21=0;h.n22=2/m;h.n23=0;h.n24=-((b+d)/m);h.n31=0;h.n32=0;h.n33=-2/n;h.n34=-((g+f)/n);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.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible= !0;this._vector=new THREE.Vector3}; THREE.Object3D.prototype={translate:function(a,c){this.matrix.rotateAxis(c);this.position.addSelf(c.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(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!== undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var c=this;c instanceof THREE.Scene===!1&&c!==undefined;)c=c.parent;c!==undefined&&c.addChildRecurse(a)}},removeChild:function(a){var c=this.children.indexOf(a);if(c!==-1){a.parent=undefined;this.children.splice(c,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!== 1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}this.matrixWorldNeedsUpdate=!0},update:function(a,c,b){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||c){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;c=!0}a=0;for(var d=this.children.length;a=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(f),h=Math.sqrt(1-f*f);if(Math.abs(h)<0.0010){b.w=0.5*(a.w+c.w);b.x=0.5*(a.x+c.x);b.y=0.5*(a.y+c.y);b.z=0.5*(a.z+c.z);return b}f=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*f+c.w*d;b.x=a.x*f+c.x*d;b.y=a.y*f+c.y*d;b.z=a.z*f+c.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,c,b,d,f,g){this.a=a;this.b=c;this.c=b;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3}; THREE.Face4=function(a,c,b,d,f,g,h){this.a=a;this.b=c;this.c=b;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.set(a||0,c||0)}; THREE.UV.prototype={set:function(a,c){this.u=a;this.v=c;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1}; THREE.Geometry.prototype={computeCentroids:function(){var a,c,b;a=0;for(c=this.faces.length;a0){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 c=1,b=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,b=this.vertices.length;cthis.points.length-2?g:g+1;b[3]=g>this.points.length-3?g:g+2;n=this.points[b[0]];q=this.points[b[1]]; x=this.points[b[2]];z=this.points[b[3]];k=h*h;m=h*k;d.x=c(n.x,q.x,x.x,z.x,h,k,m);d.y=c(n.y,q.y,x.y,z.y,h,k,m);d.z=c(n.z,q.z,x.z,z.z,h,k,m);return d};this.getControlPointsArray=function(){var p,A,G=this.points.length,I=[];for(p=0;p1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+p);d=d<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=f[0]+(g[0]-f[0])*d;b.y=f[1]+(g[1]-f[1])*d;b.z=f[2]+(g[2]-f[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= this.getPrevKeyWith("pos",p,h.index-1).pos;this.points[1]=f;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",p,k.index+1).pos;d=d*0.33+0.33;f=this.interpolateCatmullRom(this.points,d);b.x=f[0];b.y=f[1];b.z=f[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){d=this.interpolateCatmullRom(this.points,d*1.01);this.target.set(d[0],d[1],d[2]);this.target.subSelf(b);this.target.y=0;this.target.normalize();d=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,d,0)}}}else if(b=== "rot")THREE.Quaternion.slerp(f,g,a.quaternion,d);else if(b==="scl"){b=a.scale;b.x=f[0]+(g[0]-f[0])*d;b.y=f[1]+(g[1]-f[1])*d;b.z=f[2]+(g[2]-f[2])*d}}}}if(this.JITCompile&&q[0][n]===undefined){this.hierarchy[0].update(undefined,!0);for(p=0;pa.length-2?g:g+1;b[3]=g>a.length-3?g:g+2;g=a[b[0]];k=a[b[1]];m=a[b[2]];n=a[b[3]];b=f*f;h=f*b;d[0]=this.interpolate(g[0],k[0],m[0],n[0],f,b,h);d[1]=this.interpolate(g[1],k[1],m[1],n[1],f,b,h);d[2]=this.interpolate(g[2],k[2],m[2],n[2],f,b,h);return d}; THREE.Animation.prototype.interpolate=function(a,c,b,d,f,g,h){a=(b-a)*0.5;d=(d-c)*0.5;return(2*(c-b)+a+d)*h+(-3*(c-b)-2*a-d)*g+a*f+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)b=b0?b:0:b>=0?b:b+d.length;b>=0;b--)if(d[b][a]!==undefined)return d[b];return this.data.hierarchy[c].keys[d.length-1]}; THREE.Camera=function(a,c,b,d,f){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=b||0.1;this.far=d||2E3;this.target=f||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype; THREE.Camera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)}; THREE.Camera.prototype.update=function(a,c,b){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);c=!0}else{this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate= !1;c=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a1){a=b.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 d=1;d=this.LODs[d].visibleAtDistance){this.LODs[d-1].object3D.visible= !1;this.LODs[d].object3D.visible=!0}else break;for(;d=0&&ka>=0&&oa>=0&&ma>=0)return!0;else if(Aa<0&&ka<0||oa<0&&ma<0)return!1;else{if(Aa<0)wa=Math.max(wa,Aa/(Aa-ka));else ka<0&&(ha=Math.min(ha,Aa/(Aa-ka)));if(oa<0)wa=Math.max(wa,oa/(oa-ma));else ma<0&&(ha=Math.min(ha,oa/(oa-ma)));if(haAa&&h.positionScreen.z0&&P.z<1){Ca=B[J]=B[J]||new THREE.RenderableParticle;J++;C=Ca;C.x=P.x/P.w;C.y=P.y/P.w;C.z=P.z;C.rotation=xa.rotation.z;C.scale.x=xa.scale.x*Math.abs(C.x-(P.x+W.projectionMatrix.n11)/(P.w+W.projectionMatrix.n14));C.scale.y=xa.scale.y*Math.abs(C.y-(P.y+W.projectionMatrix.n22)/(P.w+W.projectionMatrix.n24));C.materials=xa.materials;ha.push(C)}}}}wa&&ha.sort(c);return ha}}; THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,f,g;this.domElement=document.createElement("div");this.setSize=function(h,k){b=h;d=k;f=b/2;g=d/2};this.render=function(h,k){var m,n,q,x,z,p,A,G;a=c.projectScene(h,k);m=0;for(n=a.length;m0){aa.r+=ea.r*za;aa.g+=ea.g*za;aa.b+=ea.b*za}}else if(za instanceof THREE.PointLight){T.sub(za.position,Z);T.normalize();za=na.dot(T)*$;if(za>0){aa.r+= ea.r*za;aa.g+=ea.g*za;aa.b+=ea.b*za}}}}function eb(L,Z,na){a(na.opacity);c(na.blending);var aa,ta,za,ea,$,Ka;if(na instanceof THREE.ParticleBasicMaterial){if(na.map){ea=na.map.image;$=ea.width>>1;Ka=ea.height>>1;na=Z.scale.x*k;za=Z.scale.y*m;aa=na*$;ta=za*Ka;E.set(L.x-aa,L.y-ta,L.x+aa,L.y+ta);if(o.instersects(E)){n.save();n.translate(L.x,L.y);n.rotate(-Z.rotation);n.scale(na,-za);n.translate(-$,-Ka);n.drawImage(ea,0,0);n.restore()}}}else if(na instanceof THREE.ParticleCanvasMaterial){if(K){F.r=D.r+ Q.r+H.r;F.g=D.g+Q.g+H.g;F.b=D.b+Q.b+H.b;ca.r=na.color.r*F.r;ca.g=na.color.g*F.g;ca.b=na.color.b*F.b;ca.updateStyleString()}else ca.__styleString=na.color.__styleString;aa=Z.scale.x*k;ta=Z.scale.y*m;E.set(L.x-aa,L.y-ta,L.x+aa,L.y+ta);if(o.instersects(E)){n.save();n.translate(L.x,L.y);n.rotate(-Z.rotation);n.scale(aa,ta);na.program(n,ca);n.restore()}}}function Ta(L,Z,na,aa){a(aa.opacity);c(aa.blending);n.beginPath();n.moveTo(L.positionScreen.x,L.positionScreen.y);n.lineTo(Z.positionScreen.x,Z.positionScreen.y); n.closePath();if(aa instanceof THREE.LineBasicMaterial){ca.__styleString=aa.color.__styleString;L=aa.linewidth;if(I!=L)n.lineWidth=I=L;L=ca.__styleString;if(A!=L)n.strokeStyle=A=L;n.stroke();E.inflate(aa.linewidth*2)}}function Ia(L,Z,na,aa,ta,za,ea,$,Ka){a($.opacity);c($.blending);V=L.positionScreen.x;Y=L.positionScreen.y;e=Z.positionScreen.x;ja=Z.positionScreen.y;X=na.positionScreen.x;W=na.positionScreen.y;bb(V,Y,e,ja,X,W);if($ instanceof THREE.MeshBasicMaterial)if($.map){if($.map.mapping instanceof THREE.UVMapping){Ca=ea.uvs[0];Da(V,Y,e,ja,X,W,$.map.image,Ca[aa].u,Ca[aa].v,Ca[ta].u,Ca[ta].v,Ca[za].u,Ca[za].v)}}else if($.envMap){if($.envMap.mapping instanceof THREE.SphericalReflectionMapping){L=ia.matrixWorldInverse;T.copy(ea.vertexNormalsWorld[0]);Za=(T.x*L.n11+T.y*L.n12+T.z*L.n13)*0.5+0.5;$a=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;T.copy(ea.vertexNormalsWorld[1]);Ha=(T.x*L.n11+T.y*L.n12+T.z*L.n13)*0.5+0.5;j=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;T.copy(ea.vertexNormalsWorld[2]);w=(T.x*L.n11+ T.y*L.n12+T.z*L.n13)*0.5+0.5;t=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;Da(V,Y,e,ja,X,W,$.envMap.image,Za,$a,Ha,j,w,t)}}else $.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&!$.wireframe){if($.map.mapping instanceof THREE.UVMapping){Ca=ea.uvs[0];Da(V,Y,e,ja,X,W,$.map.image,Ca[aa].u,Ca[aa].v,Ca[ta].u,Ca[ta].v,Ca[za].u,Ca[za].v)}c(THREE.SubtractiveBlending)}if(K)if(!$.wireframe&&$.shading==THREE.SmoothShading&& ea.vertexNormalsWorld.length==3){S.r=M.r=fa.r=D.r;S.g=M.g=fa.g=D.g;S.b=M.b=fa.b=D.b;Ga(Ka,ea.v1.positionWorld,ea.vertexNormalsWorld[0],S);Ga(Ka,ea.v2.positionWorld,ea.vertexNormalsWorld[1],M);Ga(Ka,ea.v3.positionWorld,ea.vertexNormalsWorld[2],fa);ra.r=(M.r+fa.r)*0.5;ra.g=(M.g+fa.g)*0.5;ra.b=(M.b+fa.b)*0.5;xa=Va(S,M,fa,ra);Da(V,Y,e,ja,X,W,xa,0,0,1,0,0,1)}else{F.r=D.r;F.g=D.g;F.b=D.b;Ga(Ka,ea.centroidWorld,ea.normalWorld,F);ca.r=$.color.r*F.r;ca.g=$.color.g*F.g;ca.b=$.color.b*F.b;ca.updateStyleString(); $.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else $.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){la=ia.near;qa=ia.far;S.r=S.g=S.b=1-Ma(L.positionScreen.z,la,qa);M.r=M.g=M.b=1-Ma(Z.positionScreen.z,la,qa);fa.r=fa.g=fa.b=1-Ma(na.positionScreen.z,la,qa);ra.r=(M.r+fa.r)*0.5;ra.g=(M.g+fa.g)*0.5;ra.b=(M.b+fa.b)*0.5;xa=Va(S,M,fa,ra);Da(V,Y,e,ja,X,W,xa,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){ca.r= N(ea.normalWorld.x);ca.g=N(ea.normalWorld.y);ca.b=N(ea.normalWorld.z);ca.updateStyleString();$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}}function Ra(L,Z,na,aa,ta,za,ea,$,Ka){a($.opacity);c($.blending);if($.map||$.envMap){Ia(L,Z,aa,0,1,3,ea,$,Ka);Ia(ta,na,za,1,2,3,ea,$,Ka)}else{V=L.positionScreen.x;Y=L.positionScreen.y;e=Z.positionScreen.x;ja=Z.positionScreen.y;X=na.positionScreen.x;W=na.positionScreen.y;wa=aa.positionScreen.x;ha=aa.positionScreen.y;Aa=ta.positionScreen.x; ka=ta.positionScreen.y;oa=za.positionScreen.x;ma=za.positionScreen.y;if($ instanceof THREE.MeshBasicMaterial){db(V,Y,e,ja,X,W,wa,ha);$.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshLambertMaterial)if(K)if(!$.wireframe&&$.shading==THREE.SmoothShading&&ea.vertexNormalsWorld.length==4){S.r=M.r=fa.r=ra.r=D.r;S.g=M.g=fa.g=ra.g=D.g;S.b=M.b=fa.b=ra.b=D.b;Ga(Ka,ea.v1.positionWorld,ea.vertexNormalsWorld[0],S);Ga(Ka,ea.v2.positionWorld,ea.vertexNormalsWorld[1], M);Ga(Ka,ea.v4.positionWorld,ea.vertexNormalsWorld[3],fa);Ga(Ka,ea.v3.positionWorld,ea.vertexNormalsWorld[2],ra);xa=Va(S,M,fa,ra);bb(V,Y,e,ja,wa,ha);Da(V,Y,e,ja,wa,ha,xa,0,0,1,0,0,1);bb(Aa,ka,X,W,oa,ma);Da(Aa,ka,X,W,oa,ma,xa,1,0,1,1,0,1)}else{F.r=D.r;F.g=D.g;F.b=D.b;Ga(Ka,ea.centroidWorld,ea.normalWorld,F);ca.r=$.color.r*F.r;ca.g=$.color.g*F.g;ca.b=$.color.b*F.b;ca.updateStyleString();db(V,Y,e,ja,X,W,wa,ha);$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else{db(V,Y,e,ja, X,W,wa,ha);$.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshNormalMaterial){ca.r=N(ea.normalWorld.x);ca.g=N(ea.normalWorld.y);ca.b=N(ea.normalWorld.z);ca.updateStyleString();db(V,Y,e,ja,X,W,wa,ha);$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){la=ia.near;qa=ia.far;S.r=S.g=S.b=1-Ma(L.positionScreen.z,la,qa);M.r=M.g=M.b=1-Ma(Z.positionScreen.z,la,qa);fa.r=fa.g= fa.b=1-Ma(aa.positionScreen.z,la,qa);ra.r=ra.g=ra.b=1-Ma(na.positionScreen.z,la,qa);xa=Va(S,M,fa,ra);bb(V,Y,e,ja,wa,ha);Da(V,Y,e,ja,wa,ha,xa,0,0,1,0,0,1);bb(Aa,ka,X,W,oa,ma);Da(Aa,ka,X,W,oa,ma,xa,1,0,1,1,0,1)}}}function bb(L,Z,na,aa,ta,za){n.beginPath();n.moveTo(L,Z);n.lineTo(na,aa);n.lineTo(ta,za);n.lineTo(L,Z);n.closePath()}function db(L,Z,na,aa,ta,za,ea,$){n.beginPath();n.moveTo(L,Z);n.lineTo(na,aa);n.lineTo(ta,za);n.lineTo(ea,$);n.lineTo(L,Z);n.closePath()}function Pa(L,Z){if(A!=L)n.strokeStyle= A=L;if(I!=Z)n.lineWidth=I=Z;n.stroke();E.inflate(Z*2)}function Ua(L){if(G!=L)n.fillStyle=G=L;n.fill()}function Da(L,Z,na,aa,ta,za,ea,$,Ka,Xa,Ya,cb,gb){var ab,Wa;ab=ea.width-1;Wa=ea.height-1;$*=ab;Ka*=Wa;Xa*=ab;Ya*=Wa;cb*=ab;gb*=Wa;na-=L;aa-=Z;ta-=L;za-=Z;Xa-=$;Ya-=Ka;cb-=$;gb-=Ka;ab=Xa*gb-cb*Ya;if(ab!=0){Wa=1/ab;ab=(gb*na-Ya*ta)*Wa;Ya=(gb*aa-Ya*za)*Wa;na=(Xa*ta-cb*na)*Wa;aa=(Xa*za-cb*aa)*Wa;L=L-ab*$-na*Ka;Z=Z-Ya*$-aa*Ka;n.save();n.transform(ab,Ya,na,aa,L,Z);n.clip();n.drawImage(ea,0,0);n.restore()}} function Va(L,Z,na,aa){var ta=~~(L.r*255),za=~~(L.g*255);L=~~(L.b*255);var ea=~~(Z.r*255),$=~~(Z.g*255);Z=~~(Z.b*255);var Ka=~~(na.r*255),Xa=~~(na.g*255);na=~~(na.b*255);var Ya=~~(aa.r*255),cb=~~(aa.g*255);aa=~~(aa.b*255);ya[0]=ta<0?0:ta>255?255:ta;ya[1]=za<0?0:za>255?255:za;ya[2]=L<0?0:L>255?255:L;ya[4]=ea<0?0:ea>255?255:ea;ya[5]=$<0?0:$>255?255:$;ya[6]=Z<0?0:Z>255?255:Z;ya[8]=Ka<0?0:Ka>255?255:Ka;ya[9]=Xa<0?0:Xa>255?255:Xa;ya[10]=na<0?0:na>255?255:na;ya[12]=Ya<0?0:Ya>255?255:Ya;ya[13]=cb<0?0:cb> 255?255:cb;ya[14]=aa<0?0:aa>255?255:aa;pa.putImageData(sa,0,0);Ea.drawImage(ga,0,0);return ua}function Ma(L,Z,na){L=(L-Z)/(na-Z);return L*L*(3-2*L)}function N(L){L=(L+1)*0.5;return L<0?0:L>1?1:L}function Na(L,Z){var na=Z.x-L.x,aa=Z.y-L.y,ta=1/Math.sqrt(na*na+aa*aa);na*=ta;aa*=ta;Z.x+=na;Z.y+=aa;L.x-=na;L.y-=aa}var Qa,ib,Ba,Sa,Fa,Oa,Ja,va;this.autoClear?this.clear():n.setTransform(1,0,0,-1,k,m);b=d.projectScene(R,ia,this.sortElements);(K=R.lights.length>0)&&La(R);Qa=0;for(ib=b.length;Qa0){ma.r+=M.color.r*fa;ma.g+=M.color.g*fa;ma.b+=M.color.b*fa}}else if(M instanceof THREE.PointLight){e.sub(M.position,oa.centroidWorld);e.normalize();fa=oa.normalWorld.dot(e)*M.intensity;if(fa>0){ma.r+=M.color.r*fa;ma.g+=M.color.g*fa;ma.b+=M.color.b*fa}}}}function c(ka,oa,ma,ca,S,M){W=d(wa++); W.setAttribute("d","M "+ka.positionScreen.x+" "+ka.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+ma.positionScreen.x+","+ma.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)B.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(J){U.r=P.r;U.g=P.g;U.b=P.b;a(M,ca,U);B.r=S.color.r*U.r;B.g=S.color.g*U.g;B.b=S.color.b*U.b;B.updateStyleString()}else B.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){Y= 1-S.__2near/(S.__farPlusNear-ca.z*S.__farMinusNear);B.setRGB(Y,Y,Y)}else S instanceof THREE.MeshNormalMaterial&&B.setRGB(f(ca.normalWorld.x),f(ca.normalWorld.y),f(ca.normalWorld.z));S.wireframe?W.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+S.wireframeLinewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframeLinecap+"; stroke-linejoin: "+S.wireframeLinejoin):W.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+S.opacity);k.appendChild(W)} function b(ka,oa,ma,ca,S,M,fa){W=d(wa++);W.setAttribute("d","M "+ka.positionScreen.x+" "+ka.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+ma.positionScreen.x+","+ma.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)B.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(J){U.r=P.r;U.g=P.g;U.b=P.b;a(fa,S,U);B.r=M.color.r*U.r;B.g=M.color.g*U.g;B.b=M.color.b*U.b;B.updateStyleString()}else B.__styleString= M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){Y=1-M.__2near/(M.__farPlusNear-S.z*M.__farMinusNear);B.setRGB(Y,Y,Y)}else M instanceof THREE.MeshNormalMaterial&&B.setRGB(f(S.normalWorld.x),f(S.normalWorld.y),f(S.normalWorld.z));M.wireframe?W.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+M.wireframeLinewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframeLinecap+"; stroke-linejoin: "+M.wireframeLinejoin):W.setAttribute("style","fill: "+ B.__styleString+"; fill-opacity: "+M.opacity);k.appendChild(W)}function d(ka){if(ja[ka]==null){ja[ka]=document.createElementNS("http://www.w3.org/2000/svg","path");Aa==0&&ja[ka].setAttribute("shape-rendering","crispEdges")}return ja[ka]}function f(ka){return ka<0?Math.min((1+ka)*0.5,0.5):0.5+Math.min(ka*0.5,0.5)}var g=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,n,q,x,z,p,A,G,I=new THREE.Rectangle,C=new THREE.Rectangle,J=!1,B=new THREE.Color(16777215), U=new THREE.Color(16777215),P=new THREE.Color(0),O=new THREE.Color(0),V=new THREE.Color(0),Y,e=new THREE.Vector3,ja=[],X=[],W,wa,ha,Aa=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ka){switch(ka){case "high":Aa=1;break;case "low":Aa=0}};this.setSize=function(ka,oa){m=ka;n=oa;q=m/2;x=n/2;k.setAttribute("viewBox",-q+" "+-x+" "+m+" "+n);k.setAttribute("width",m);k.setAttribute("height",n);I.set(-q,-x,q,x)};this.clear=function(){for(;k.childNodes.length> 0;)k.removeChild(k.childNodes[0])};this.render=function(ka,oa){var ma,ca,S,M,fa,ra,la,qa;this.autoClear&&this.clear();g=h.projectScene(ka,oa,this.sortElements);ha=wa=0;if(J=ka.lights.length>0){la=ka.lights;P.setRGB(0,0,0);O.setRGB(0,0,0);V.setRGB(0,0,0);ma=0;for(ca=la.length;ma 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 ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif", lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}", lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;", color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#endif", 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", default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"}; THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)},morphTargetInfluences:{type:"f", value:0}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",value:1},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)}}}; THREE.ShaderLib={shadowPost:{vertexShader:"uniform \tmat4 \tprojectionMatrix;\nattribute \tvec3 \tposition;\nvoid main(void)\n{\ngl_Position = projectionMatrix * vec4( position, 1.0 );\n}",fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nvoid main( void )\n{\ngl_FragColor = vec4( 0, 0, 0, 0.5 );\n}"},shadowVolumeDynamic:{uniforms:{directionalLightDirection:{type:"fv",value:[]}},vertexShader:"uniform \tvec3 \tdirectionalLightDirection;\nvoid main() {\nvec3 pos = ( objectMatrix * vec4( position, 1.0 )).xyz;\nvec3 norm = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz) * normal;// normalMatrix * normal;\nvec4 final = vec4( pos + directionalLightDirection * 5000.0 * step( 0.0, dot( directionalLightDirection, norm )), 1.0 );\ngl_Position = projectionMatrix * viewMatrix * final;\n}",fragmentShader:"void main() {\ngl_FragColor = vec4( 1, 1, 1, 1 );\n}"}, depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},fragmentShader:"uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}",vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f",value:1}}, fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,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,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:[THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex, THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;", THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["varying vec3 vLightWeighting;", THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );", THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;", THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.lights_fragment,THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"), vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex, THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;", THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}}; THREE.WebGLRenderer=function(a){function c(j,w,t){var o,y,E,K=j.vertices,F=K.length,D=j.colors,Q=D.length,H=j.__vertexArray,T=j.__colorArray,ga=j.__sortArray,pa=j.__dirtyVertices,sa=j.__dirtyColors;if(t.sortParticles){fa.multiplySelf(t.matrixWorld);for(o=0;oD){Q=H;D=F[Q]}e.bindBuffer(e.ARRAY_BUFFER,y.__webGLMorphTargetsBuffers[Q]);e.vertexAttribPointer(w["morphTarget"+t],3,e.FLOAT,!1,0,0);E.__webGLMorphTargetInfluences[t]=D;K[Q]=1;D=-1;t++}}e.uniform1fv(o.program.uniforms.morphTargetInfluences,E.__webGLMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,y.__webGLVertexBuffer);e.vertexAttribPointer(j.position,3, e.FLOAT,!1,0,0)}if(j.color>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLColorBuffer);e.vertexAttribPointer(j.color,3,e.FLOAT,!1,0,0)}if(j.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLNormalBuffer);e.vertexAttribPointer(j.normal,3,e.FLOAT,!1,0,0)}if(j.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLTangentBuffer);e.vertexAttribPointer(j.tangent,4,e.FLOAT,!1,0,0)}if(j.uv>=0)if(y.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLUVBuffer);e.vertexAttribPointer(j.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(j.uv)}else e.disableVertexAttribArray(j.uv); if(j.uv2>=0)if(y.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLUV2Buffer);e.vertexAttribPointer(j.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(j.uv2)}else e.disableVertexAttribArray(j.uv2);if(o.skinning&&j.skinVertexA>=0&&j.skinVertexB>=0&&j.skinIndex>=0&&j.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinVertexABuffer);e.vertexAttribPointer(j.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinVertexBBuffer);e.vertexAttribPointer(j.skinVertexB,4,e.FLOAT,!1,0, 0);e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinIndicesBuffer);e.vertexAttribPointer(j.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinWeightsBuffer);e.vertexAttribPointer(j.skinWeight,4,e.FLOAT,!1,0,0)}if(E instanceof THREE.Mesh)if(o.wireframe){e.lineWidth(o.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,y.__webGLLineBuffer);e.drawElements(e.LINES,y.__webGLLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,y.__webGLFaceBuffer);e.drawElements(e.TRIANGLES, y.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else if(E instanceof THREE.Line){E=E.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(o.linewidth);e.drawArrays(E,0,y.__webGLLineCount)}else if(E instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,0,y.__webGLParticleCount);else E instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,y.__webGLVertexCount)}}function g(j,w){if(!j.__webGLVertexBuffer)j.__webGLVertexBuffer=e.createBuffer();if(!j.__webGLNormalBuffer)j.__webGLNormalBuffer=e.createBuffer(); if(j.hasPos){e.bindBuffer(e.ARRAY_BUFFER,j.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,j.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(w.attributes.position);e.vertexAttribPointer(w.attributes.position,3,e.FLOAT,!1,0,0)}if(j.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,j.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,j.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(w.attributes.normal);e.vertexAttribPointer(w.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,j.count); j.count=0}function h(j){if(wa!=j.doubleSided){j.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);wa=j.doubleSided}if(ha!=j.flipSided){j.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);ha=j.flipSided}}function k(j){if(ka!=j){j?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);ka=j}}function m(j){M[0].set(j.n41-j.n11,j.n42-j.n12,j.n43-j.n13,j.n44-j.n14);M[1].set(j.n41+j.n11,j.n42+j.n12,j.n43+j.n13,j.n44+j.n14);M[2].set(j.n41+j.n21,j.n42+j.n22,j.n43+j.n23,j.n44+j.n24);M[3].set(j.n41-j.n21,j.n42- j.n22,j.n43-j.n23,j.n44-j.n24);M[4].set(j.n41-j.n31,j.n42-j.n32,j.n43-j.n33,j.n44-j.n34);M[5].set(j.n41+j.n31,j.n42+j.n32,j.n43+j.n33,j.n44+j.n34);var w;for(j=0;j<6;j++){w=M[j];w.divideScalar(Math.sqrt(w.x*w.x+w.y*w.y+w.z*w.z))}}function n(j){for(var w=j.matrixWorld,t=-j.geometry.boundingSphere.radius*Math.max(j.scale.x,Math.max(j.scale.y,j.scale.z)),o=0;o<6;o++){j=M[o].x*w.n14+M[o].y*w.n24+M[o].z*w.n34+M[o].w;if(j<=t)return!1}return!0}function q(j,w){j.list[j.count]=w;j.count+=1}function x(j){var w, t,o=j.object,y=j.opaque,E=j.transparent;E.count=0;j=y.count=0;for(w=o.materials.length;j0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,Oa,y)}if(Ya){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,Sa,y)}if(cb&&ea.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLTangentBuffer);e.bufferData(e.ARRAY_BUFFER,Fa,y)}if(Xa&&bb>0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,ib,y)}if(Xa&&db>0){e.bindBuffer(e.ARRAY_BUFFER, o.__webGLUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Ba,y)}if(Ka){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,aa,y);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ta,y)}if(N>0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,Ja,y);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,va,y);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer); e.bufferData(e.ARRAY_BUFFER,L,y);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,Z,y)}}}t.__dirtyVertices=!1;t.__dirtyMorphTargets=!1;t.__dirtyElements=!1;t.__dirtyUvs=!1;t.__dirtyNormals=!1;t.__dirtyTangents=!1;t.__dirtyColors=!1}else if(j instanceof THREE.Ribbon){t=j.geometry;if(t.__dirtyVertices||t.__dirtyColors){j=t;w=e.DYNAMIC_DRAW;ya=j.vertices;y=j.colors;ua=ya.length;E=y.length;Ea=j.__vertexArray;K=j.__colorArray;Ia=j.__dirtyColors;if(j.__dirtyVertices){for(pa= 0;pa65535){H[D].counter+=1;Q=H[D].hash+"_"+H[D].counter;j.geometryGroups[Q]==undefined&&(j.geometryGroups[Q]={faces:[],materials:F,vertices:0,numMorphTargets:T})}j.geometryGroups[Q].faces.push(y);j.geometryGroups[Q].vertices+=K}}function C(j,w,t){j.push({buffer:w,object:t,opaque:{list:[],count:0},transparent:{list:[], count:0}})}function J(j){if(j!=Aa){switch(j){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE);break;case THREE.SubtractiveBlending:e.blendFunc(e.DST_COLOR,e.ZERO);break;case THREE.BillboardBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:e.blendEquation(e.FUNC_REVERSE_SUBTRACT);e.blendFunc(e.ONE,e.ONE);break;default:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}Aa= j}}function B(j,w,t){if((t.width&t.width-1)==0&&(t.height&t.height-1)==0){e.texParameteri(j,e.TEXTURE_WRAP_S,V(w.wrapS));e.texParameteri(j,e.TEXTURE_WRAP_T,V(w.wrapT));e.texParameteri(j,e.TEXTURE_MAG_FILTER,V(w.magFilter));e.texParameteri(j,e.TEXTURE_MIN_FILTER,V(w.minFilter));e.generateMipmap(j)}else{e.texParameteri(j,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(j,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(j,e.TEXTURE_MAG_FILTER,O(w.magFilter));e.texParameteri(j,e.TEXTURE_MIN_FILTER, O(w.minFilter))}}function U(j){if(j&&!j.__webGLFramebuffer){j.__webGLFramebuffer=e.createFramebuffer();j.__webGLRenderbuffer=e.createRenderbuffer();j.__webGLTexture=e.createTexture();e.bindRenderbuffer(e.RENDERBUFFER,j.__webGLRenderbuffer);e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,j.width,j.height);e.bindTexture(e.TEXTURE_2D,j.__webGLTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,V(j.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,V(j.wrapT));e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER,V(j.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,V(j.minFilter));e.texImage2D(e.TEXTURE_2D,0,V(j.format),j.width,j.height,0,V(j.format),V(j.type),null);e.bindFramebuffer(e.FRAMEBUFFER,j.__webGLFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,j.__webGLTexture,0);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,j.__webGLRenderbuffer);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null); e.bindFramebuffer(e.FRAMEBUFFER,null)}var w,t;if(j){w=j.__webGLFramebuffer;t=j.width;j=j.height}else{w=null;t=ca;j=S}if(w!=X){e.bindFramebuffer(e.FRAMEBUFFER,w);e.viewport(oa,ma,t,j);X=w}}function P(j,w){var t;if(j=="fragment")t=e.createShader(e.FRAGMENT_SHADER);else j=="vertex"&&(t=e.createShader(e.VERTEX_SHADER));e.shaderSource(t,w);e.compileShader(t);if(!e.getShaderParameter(t,e.COMPILE_STATUS)){console.error(e.getShaderInfoLog(t));console.error(w);return null}return t}function O(j){switch(j){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST; default:return e.LINEAR}}function V(j){switch(j){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;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;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 Y=document.createElement("canvas"),e,ja=null,X=null,W=this,wa=null,ha=null,Aa=null,ka=null,oa=0,ma=0,ca=0,S=0,M=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],fa=new THREE.Matrix4,ra=new Float32Array(16),la=new Float32Array(16),qa=new THREE.Vector4,xa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},Ca=!0,Za=new THREE.Color(0),$a=0;if(a){if(a.antialias!==undefined)Ca=a.antialias; a.clearColor!==undefined&&Za.setHex(a.clearColor);if(a.clearAlpha!==undefined)$a=a.clearAlpha}this.maxMorphTargets=8;this.domElement=Y;this.autoClear=!0;this.sortObjects=!0;(function(j,w,t){try{if(!(e=Y.getContext("experimental-webgl",{antialias:j,stencil:!0})))throw"Error creating WebGL context.";}catch(o){console.error(o)}e.clearColor(0,0,0,1);e.clearDepth(1);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.blendFunc(e.ONE, e.ONE_MINUS_SRC_ALPHA);e.clearColor(w.r,w.g,w.b,t)})(Ca,Za,$a);this.context=e;var Ha={};a=[];Ca=[];a[0]=-2;a[1]=-1;a[2]=-1;a[3]=2;a[4]=-1;a[5]=-1;a[6]=2;a[7]=1;a[8]=-1;a[9]=-2;a[10]=1;a[11]=-1;Ca[0]=0;Ca[1]=1;Ca[2]=2;Ca[3]=0;Ca[4]=2;Ca[5]=3;Ha.vertexBuffer=e.createBuffer();Ha.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,Ha.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,new Float32Array(a),e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,Ha.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER, new Uint16Array(Ca),e.STATIC_DRAW);Ha.program=e.createProgram();e.attachShader(Ha.program,P("fragment",THREE.ShaderLib.shadowPost.fragmentShader));e.attachShader(Ha.program,P("vertex",THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(Ha.program);Ha.vertexLocation=e.getAttribLocation(Ha.program,"position");Ha.projectionLocation=e.getUniformLocation(Ha.program,"projectionMatrix");this.setSize=function(j,w){Y.width=j;Y.height=w;this.setViewport(0,0,Y.width,Y.height)};this.setViewport=function(j, w,t,o){oa=j;ma=w;ca=t;S=o;e.viewport(oa,ma,ca,S)};this.setScissor=function(j,w,t,o){e.scissor(j,w,t,o)};this.enableScissorTest=function(j){j?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(j){e.depthMask(j)};this.setClearColorHex=function(j,w){var t=new THREE.Color(j);e.clearColor(t.r,t.g,t.b,w)};this.setClearColor=function(j,w){e.clearColor(j.r,j.g,j.b,w)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.initMaterial= function(j,w,t,o){var y,E,K;if(j instanceof THREE.MeshDepthMaterial)b(j,THREE.ShaderLib.depth);else if(j instanceof THREE.ShadowVolumeDynamicMaterial)b(j,THREE.ShaderLib.shadowVolumeDynamic);else if(j instanceof THREE.MeshNormalMaterial)b(j,THREE.ShaderLib.normal);else if(j instanceof THREE.MeshBasicMaterial)b(j,THREE.ShaderLib.basic);else if(j instanceof THREE.MeshLambertMaterial)b(j,THREE.ShaderLib.lambert);else if(j instanceof THREE.MeshPhongMaterial)b(j,THREE.ShaderLib.phong);else if(j instanceof THREE.LineBasicMaterial)b(j,THREE.ShaderLib.basic);else j instanceof THREE.ParticleBasicMaterial&&b(j,THREE.ShaderLib.particle_basic);var F,D,Q,H;K=Q=H=0;for(F=w.length;K0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+F.maxDirLights,"#define MAX_POINT_LIGHTS "+F.maxPointLights,"#define MAX_BONES "+F.maxBones,F.map?"#define USE_MAP":"",F.envMap?"#define USE_ENVMAP":"",F.lightMap?"#define USE_LIGHTMAP":"",F.vertexColors?"#define USE_COLOR":"",F.skinning?"#define USE_SKINNING":"",F.morphTargets?"#define USE_MORPHTARGETS":"",F.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 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); e.attachShader(t,P("fragment",K+H));e.attachShader(t,P("vertex",F+w));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={};j.program=t;t=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(y in j.uniforms)t.push(y); y=j.program;H=0;for(w=t.length;H=0&&e.enableVertexAttribArray(E.color);E.normal>=0&&e.enableVertexAttribArray(E.normal); E.tangent>=0&&e.enableVertexAttribArray(E.tangent);if(j.skinning&&E.skinVertexA>=0&&E.skinVertexB>=0&&E.skinIndex>=0&&E.skinWeight>=0){e.enableVertexAttribArray(E.skinVertexA);e.enableVertexAttribArray(E.skinVertexB);e.enableVertexAttribArray(E.skinIndex);e.enableVertexAttribArray(E.skinWeight)}if(j.morphTargets){j.numSupportedMorphTargets=0;if(E.morphTarget0>=0){e.enableVertexAttribArray(E.morphTarget0);j.numSupportedMorphTargets++}if(E.morphTarget1>=0){e.enableVertexAttribArray(E.morphTarget1); j.numSupportedMorphTargets++}if(E.morphTarget2>=0){e.enableVertexAttribArray(E.morphTarget2);j.numSupportedMorphTargets++}if(E.morphTarget3>=0){e.enableVertexAttribArray(E.morphTarget3);j.numSupportedMorphTargets++}if(E.morphTarget4>=0){e.enableVertexAttribArray(E.morphTarget4);j.numSupportedMorphTargets++}if(E.morphTarget5>=0){e.enableVertexAttribArray(E.morphTarget5);j.numSupportedMorphTargets++}if(E.morphTarget6>=0){e.enableVertexAttribArray(E.morphTarget6);j.numSupportedMorphTargets++}if(E.morphTarget7>= 0){e.enableVertexAttribArray(E.morphTarget7);j.numSupportedMorphTargets++}o.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(y=0;y0||ya.faceVertexUvs.length>0)K.__uvArray=new Float32Array(D*2);if(ya.faceUvs.length>1||ya.faceVertexUvs.length>1)K.__uv2Array=new Float32Array(D*2)}if(F.geometry.skinWeights.length&&F.geometry.skinIndices.length){K.__skinVertexAArray= new Float32Array(D*4);K.__skinVertexBArray=new Float32Array(D*4);K.__skinIndexArray=new Float32Array(D*4);K.__skinWeightArray=new Float32Array(D*4)}K.__faceArray=new Uint16Array(ga*3+(F.geometry.edgeFaces?F.geometry.edgeFaces.length*6:0));K.__lineArray=new Uint16Array(pa*2);if(K.numMorphTargets){ya=void 0;ua=void 0;K.__morphTargetsArrays=[];ya=0;for(ua=K.numMorphTargets;ya=0;y--){o=t.__webglObjects[y].object;w==o&&t.__webglObjects.splice(y,1)}j.__objectsRemoved.splice(0,1)}w=0;for(t=j.__webglObjects.length;w0}}; THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,c,b){b&&a.update(undefined,!1,c);b=a.sounds;var d,f=b.length;for(d=0;d= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}", vertexShader:"attribute vec4 tangent;\nuniform vec3 uPointLightPos;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"}, cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"},convolution:{uniforms:{tDiffuse:{type:"t", value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i25&&(g=25);f=(g-1)*0.5;b=Array(g);for(c=d=0;cthis.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&&this.translateZ(-(this.movementSpeed+this.autoSpeedFactor));this.moveBackward&&this.translateZ(this.movementSpeed);this.moveLeft&&this.translateX(-this.movementSpeed);this.moveRight&&this.translateX(this.movementSpeed); var b=this.lookSpeed;this.dragToLook&&!this.mouseDragOn&&(b=0);this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;b=this.target.position;var d=this.position;b.x=d.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=d.y+100*Math.cos(this.phi);b.z=d.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()}, !1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype; THREE.QuakeCamera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))}; THREE.PathCamera=function(a){function c(n,q,x,z){var p={name:x,fps:0.6,length:z,hierarchy:[]},A,G=q.getControlPointsArray(),I=q.getLength(),C=G.length,J=0;A=C-1;q={parent:-1,keys:[]};q.keys[0]={time:0,pos:G[0],rot:[0,0,0,1],scl:[1,1,1]};q.keys[A]={time:z,pos:G[A],rot:[0,0,0,1],scl:[1,1,1]};for(A=1;A=0?z:z+f;z=this.verticalAngleMap.srcRange;p=this.verticalAngleMap.dstRange; this.phi=(this.phi-z[0])*(p[1]-p[0])/(z[1]-z[0])+p[0];z=this.horizontalAngleMap.srcRange;p=this.horizontalAngleMap.dstRange;this.theta=(this.theta-z[0])*(p[1]-p[0])/(z[1]-z[0])+p[0];z=this.target.position;z.x=100*Math.sin(this.phi)*Math.cos(this.theta);z.y=100*Math.cos(this.phi);z.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,n,q,x)};this.onMouseMove=function(n){this.mouseX=n.clientX-this.windowHalfX;this.mouseY=n.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints); this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var h=new THREE.MeshLambertMaterial({color:65280}),k=new Cube(10,10,20),m=new Cube(2,2,10);this.animationParent=new THREE.Mesh(k,a);a=new THREE.Mesh(m,h);a.position.set(0,10,0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation= c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&d(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(n,q){return function(){q.apply(n,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; var Cube=function(a,c,b,d,f,g,h,k,m){function n(I,C,J,B,U,P,O,V){var Y,e,ja=d||1,X=f||1,W=U/2,wa=P/2,ha=q.vertices.length;if(I=="x"&&C=="y"||I=="y"&&C=="x")Y="z";else if(I=="x"&&C=="z"||I=="z"&&C=="x"){Y="y";X=g||1}else if(I=="z"&&C=="y"||I=="y"&&C=="z"){Y="x";ja=g||1}var Aa=ja+1,ka=X+1;U/=ja;var oa=P/X;for(e=0;e0){h(0,0,-n-(g||0));for(d=a;d0){h(0,0,n+(f||0)); for(d=a+a/2;d<2*a;d++)k.faces.push(new THREE.Face4(2*a+1,(2*d-2*a+2)%a+a,(2*d-2*a+1)%a+a,(2*d-2*a)%a+a))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder; var Icosahedron=function(a){function c(x,z,p){var A=Math.sqrt(x*x+z*z+p*p);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(x/A,z/A,p/A)))-1}function b(x,z,p,A){A.faces.push(new THREE.Face3(x,z,p))}function d(x,z){var p=f.vertices[x].position,A=f.vertices[z].position;return c((p.x+A.x)/2,(p.y+A.y)/2,(p.z+A.z)/2)}var f=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0, 1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,g);b(0,5,1,g);b(0,1,7,g);b(0,7,10,g);b(0,10,11,g);b(1,5,9,g);b(5,11,4,g);b(11,10,2,g);b(10,7,6,g);b(7,1,8,g);b(3,9,4,g);b(3,4,2,g);b(3,2,6,g);b(3,6,8,g);b(3,8,9,g);b(4,9,5,g);b(2,4,11,g);b(6,2,10,g);b(8,6,7,g);b(9,8,1,g);for(a=0;a0||(q=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,z)))-1);n.push(q)}c.push(n)}var p,A,G;f=c.length;for(b=0;b0)for(d=0;d1){p=this.vertices[h].position.clone(); A=this.vertices[m].position.clone();G=this.vertices[n].position.clone();p.normalize();A.normalize();G.normalize();this.faces.push(new THREE.Face3(h,m,n,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([q,x,I])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; var Torus=function(a,c,b,d){this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){d=b/this.segmentsT*2*Math.PI;var f=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(d),(this.radius+this.tube*Math.cos(f))*Math.sin(d),this.tube*Math.sin(f))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b= 1;b<=this.segmentsT;++b){d=(this.segmentsT+1)*c+b;f=(this.segmentsT+1)*c+b-1;var g=(this.segmentsT+1)*(c-1)+b-1,h=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(d,f,g,h));this.faceVertexUvs[0].push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; var TorusKnot=function(a,c,b,d,f,g,h){function k(x,z,p,A,G,I){z=p/A*x;p=Math.cos(z);return new THREE.Vector3(G*(2+p)*0.5*Math.cos(x),G*(2+p)*Math.sin(x)*0.5,I*G*Math.sin(z)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=d||8;this.p=f||2;this.q=g||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;d=new THREE.Vector3;g=new THREE.Vector3;for(a=0;a>7)-127;t|=(y&127)<<16|o<<8;if(t==0&&K==-127)return 0;return(1-2*(E>>7))*(1+t*Math.pow(2,-23))*Math.pow(2,K)}function k(j,w){var t=q(j,w),o=q(j,w+1),y=q(j,w+2);return(q(j,w+3)<<24)+(y<<16)+(o<<8)+t}function m(j,w){var t=q(j,w);return(q(j,w+1)<<8)+t}function n(j,w){var t=q(j,w);return t>127?t-256:t}function q(j, w){return j.charCodeAt(w)&255}function x(j){var w,t,o;w=k(a,j);t=k(a,j+O);o=k(a,j+V);j=m(a,j+Y);THREE.BinaryLoader.prototype.f3(C,w,t,o,j)}function z(j){var w,t,o,y,E,K;w=k(a,j);t=k(a,j+O);o=k(a,j+V);y=m(a,j+Y);E=k(a,j+e);K=k(a,j+ja);j=k(a,j+X);THREE.BinaryLoader.prototype.f3n(C,U,w,t,o,y,E,K,j)}function p(j){var w,t,o,y;w=k(a,j);t=k(a,j+W);o=k(a,j+wa);y=k(a,j+ha);j=m(a,j+Aa);THREE.BinaryLoader.prototype.f4(C,w,t,o,y,j)}function A(j){var w,t,o,y,E,K,F,D;w=k(a,j);t=k(a,j+W);o=k(a,j+wa);y=k(a,j+ha); E=m(a,j+Aa);K=k(a,j+ka);F=k(a,j+oa);D=k(a,j+ma);j=k(a,j+ca);THREE.BinaryLoader.prototype.f4n(C,U,w,t,o,y,E,K,F,D,j)}function G(j){var w,t;w=k(a,j);t=k(a,j+S);j=k(a,j+M);THREE.BinaryLoader.prototype.uv3(C.faceVertexUvs[0],P[w*2],P[w*2+1],P[t*2],P[t*2+1],P[j*2],P[j*2+1])}function I(j){var w,t,o;w=k(a,j);t=k(a,j+fa);o=k(a,j+ra);j=k(a,j+la);THREE.BinaryLoader.prototype.uv4(C.faceVertexUvs[0],P[w*2],P[w*2+1],P[t*2],P[t*2+1],P[o*2],P[o*2+1],P[j*2],P[j*2+1])}var C=this,J=0,B,U=[],P=[],O,V,Y,e,ja,X,W,wa, ha,Aa,ka,oa,ma,ca,S,M,fa,ra,la,qa,xa,Ca,Za,$a,Ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(C,d,g);B={signature:a.substr(J,8),header_bytes:q(a,J+8),vertex_coordinate_bytes:q(a,J+9),normal_coordinate_bytes:q(a,J+10),uv_coordinate_bytes:q(a,J+11),vertex_index_bytes:q(a,J+12),normal_index_bytes:q(a,J+13),uv_index_bytes:q(a,J+14),material_index_bytes:q(a,J+15),nvertices:k(a,J+16),nnormals:k(a,J+16+4),nuvs:k(a,J+16+8),ntri_flat:k(a,J+16+12),ntri_smooth:k(a,J+16+16),ntri_flat_uv:k(a, J+16+20),ntri_smooth_uv:k(a,J+16+24),nquad_flat:k(a,J+16+28),nquad_smooth:k(a,J+16+32),nquad_flat_uv:k(a,J+16+36),nquad_smooth_uv:k(a,J+16+40)};J+=B.header_bytes;O=B.vertex_index_bytes;V=B.vertex_index_bytes*2;Y=B.vertex_index_bytes*3;e=B.vertex_index_bytes*3+B.material_index_bytes;ja=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes;X=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*2;W=B.vertex_index_bytes;wa=B.vertex_index_bytes*2;ha=B.vertex_index_bytes*3;Aa= B.vertex_index_bytes*4;ka=B.vertex_index_bytes*4+B.material_index_bytes;oa=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes;ma=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*2;ca=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*3;S=B.uv_index_bytes;M=B.uv_index_bytes*2;fa=B.uv_index_bytes;ra=B.uv_index_bytes*2;la=B.uv_index_bytes*3;g=B.vertex_index_bytes*3+B.material_index_bytes;Ha=B.vertex_index_bytes*4+B.material_index_bytes;qa=B.ntri_flat* g;xa=B.ntri_smooth*(g+B.normal_index_bytes*3);Ca=B.ntri_flat_uv*(g+B.uv_index_bytes*3);Za=B.ntri_smooth_uv*(g+B.normal_index_bytes*3+B.uv_index_bytes*3);$a=B.nquad_flat*Ha;g=B.nquad_smooth*(Ha+B.normal_index_bytes*4);Ha=B.nquad_flat_uv*(Ha+B.uv_index_bytes*4);J+=function(j){for(var w,t,o,y=B.vertex_coordinate_bytes*3,E=j+B.nvertices*y;j=this.maxCount-3&&k(this)};this.begin= function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var d=this.count*3;dthis.size-1&&(m=this.size-1);var z=Math.floor(n-k);z<1&&(z=1);n=Math.floor(n+k);n>this.size-1&&(n=this.size-1);var p=Math.floor(q-k);p<1&&(p=1);k=Math.floor(q+k); k>this.size-1&&(k=this.size-1);for(var A,G,I,C,J,B;x0&&(this.field[I+A]+=C)}}}};this.addPlaneX=function(b,d){var f,g,h,k,m,n=this.size,q=this.yd,x=this.zd,z=this.field,p=n*Math.sqrt(b/d);p>n&&(p=n);for(f=0;f0)for(g=0;gq&&(A=q);for(g=0;g0){m=g*x;for(f=0;fsize&&(dist=size);for(h=0;h0){m=zd*h;for(g=0;g