// Three.js r33 - http://github.com/mrdoob/three.js var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)}; THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var d,f,g,h,k,j;if(c==0)d=f=g=0;else{h=Math.floor(a*6);k=a*6-h;a=c*(1-b);j=c*(1-b*k);b=c*(1-b*(1-k));switch(h){case 1:d=j;f=c;g=a;break;case 2:d=a;f=c;g=b;break;case 3:d=a;f=j;g=c;break;case 4:d=b;f=a;g=c;break;case 5:d=c;f=a;g=j;break;case 6:case 0:d=c;f=b;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,b){this.set(a||0,b||0)}; THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;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,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.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,b,c){this.set(a||0,b||0,c||0)}; THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.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,b){this.set(a.x-b.x,a.y-b.y,a.z-b.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, b){this.set(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.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.set(c*a.z-d*a.y,d*a.x-b*a.z,b*a.y-c*a.x);return this},multiply:function(a,b){this.set(a.x*b.x,a.y*b.y,a.z*b.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 b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+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},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,b,c,d){this.set(a||0,b||0,c||0,d||1)}; THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.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,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.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,b){this.set(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)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,f=[];a=0;for(b=d.length;a0&&H>0&&e+H<1}var c,d,f,g,h,k,j,l,n,v, p,q=a.geometry,w=q.vertices,B=[];c=0;for(d=q.faces.length;cj?d:j;f=f>l?f:l}a()}; this.add3Points=function(j,l,n,v,p,q){if(k){k=!1;b=jn?j>p?j:p:n>p?n:p;f=l>v?l>q?l:q:v>q?v:q}else{b=jn?j>p?j>d?j:d:p>d?p:d:n>p?n>d?n:d:p>d?p:d;f=l>v?l>q?l>f?l:f:q>f?q:f:v>q?v>f?v:f:q>f?q:f}a()};this.addRectangle=function(j){if(k){k=!1;b=j.getLeft();c=j.getTop();d=j.getRight();f=j.getBottom()}else{b=bj.getRight()? d:j.getRight();f=f>j.getBottom()?f:j.getBottom()}a()};this.inflate=function(j){b-=j;c-=j;d+=j;f+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();c=c>j.getTop()?c:j.getTop();d=d=0&&Math.min(f,j.getBottom())-Math.max(c,j.getTop())>=0};this.empty=function(){k=!0;f=d=c=b=0;a()};this.isEmpty=function(){return k}}; THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={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}}; THREE.Matrix4=function(a,b,c,d,f,g,h,k,j,l,n,v,p,q,w,B){this.set(a||1,b||0,c||0,d||0,f||0,g||1,h||0,k||0,j||0,l||0,n||1,v||0,p||0,q||0,w||0,B||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; THREE.Matrix4.prototype={set:function(a,b,c,d,f,g,h,k,j,l,n,v,p,q,w,B){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=f;this.n22=g;this.n23=h;this.n24=k;this.n31=j;this.n32=l;this.n33=n;this.n34=v;this.n41=p;this.n42=q;this.n43=w;this.n44=B;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,b,c){var d=THREE.Matrix4.__tmpVec1, f=THREE.Matrix4.__tmpVec2,g=THREE.Matrix4.__tmpVec3;g.sub(a,b).normalize();d.cross(c,g).normalize();f.cross(g,d).normalize();this.n11=d.x;this.n12=f.x;this.n13=g.x;this.n14=a.x;this.n21=d.y;this.n22=f.y;this.n23=g.y;this.n24=a.y;this.n31=d.z;this.n32=f.z;this.n33=g.z;this.n34=a.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,f=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)*f;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*f;a.z=(this.n31* b+this.n32*c+this.n33*d+this.n34)*f;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,f=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*f;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*f;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*f;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*f;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*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},multiply:function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,l=a.n24,n=a.n31,v=a.n32,p=a.n33,q=a.n34,w=a.n41,B=a.n42,H=a.n43,u=a.n44,I=b.n11,o=b.n12,M=b.n13,e=b.n14,ba=b.n21,O=b.n22,P=b.n23,V=b.n24,T=b.n31,Y=b.n32,da=b.n33,J=b.n34;this.n11= c*I+d*ba+f*T;this.n12=c*o+d*O+f*Y;this.n13=c*M+d*P+f*da;this.n14=c*e+d*V+f*J+g;this.n21=h*I+k*ba+j*T;this.n22=h*o+k*O+j*Y;this.n23=h*M+k*P+j*da;this.n24=h*e+k*V+j*J+l;this.n31=n*I+v*ba+p*T;this.n32=n*o+v*O+p*Y;this.n33=n*M+v*P+p*da;this.n34=n*e+v*V+p*J+q;this.n41=w*I+B*ba+H*T;this.n42=w*o+B*O+H*Y;this.n43=w*M+B*P+H*da;this.n44=w*e+B*V+H*J+u;return this},multiplyToArray:function(a,b,c){var d=a.n11,f=a.n12,g=a.n13,h=a.n14,k=a.n21,j=a.n22,l=a.n23,n=a.n24,v=a.n31,p=a.n32,q=a.n33,w=a.n34,B=a.n41,H=a.n42, u=a.n43;a=a.n44;var I=b.n11,o=b.n12,M=b.n13,e=b.n14,ba=b.n21,O=b.n22,P=b.n23,V=b.n24,T=b.n31,Y=b.n32,da=b.n33,J=b.n34,$=b.n41,ra=b.n42,Z=b.n43;b=b.n44;this.n11=d*I+f*ba+g*T+h*$;this.n12=d*o+f*O+g*Y+h*ra;this.n13=d*M+f*P+g*da+h*Z;this.n14=d*e+f*V+g*J+h*b;this.n21=k*I+j*ba+l*T+n*$;this.n22=k*o+j*O+l*Y+n*ra;this.n23=k*M+j*P+l*da+n*Z;this.n24=k*e+j*V+l*J+n*b;this.n31=v*I+p*ba+q*T+w*$;this.n32=v*o+p*O+q*Y+w*ra;this.n33=v*M+p*P+q*da+w*Z;this.n34=v*e+p*V+q*J+w*b;this.n41=B*I+H*ba+u*T+a*$;this.n42=B*o+H* O+u*Y+a*ra;this.n43=B*M+H*P+u*da+a*Z;this.n44=B*e+H*V+u*J+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},multiplySelf:function(a){var b=this.n11,c=this.n12,d=this.n13,f=this.n14,g=this.n21,h=this.n22,k=this.n23,j=this.n24,l=this.n31,n=this.n32,v=this.n33,p=this.n34,q=this.n41,w=this.n42,B=this.n43,H= this.n44,u=a.n11,I=a.n21,o=a.n31,M=a.n12,e=a.n22,ba=a.n32,O=a.n13,P=a.n23,V=a.n33,T=a.n14,Y=a.n24;a=a.n34;this.n11=b*u+c*I+d*o;this.n12=b*M+c*e+d*ba;this.n13=b*O+c*P+d*V;this.n14=b*T+c*Y+d*a+f;this.n21=g*u+h*I+k*o;this.n22=g*M+h*e+k*ba;this.n23=g*O+h*P+k*V;this.n24=g*T+h*Y+k*a+j;this.n31=l*u+n*I+v*o;this.n32=l*M+n*e+v*ba;this.n33=l*O+n*P+v*V;this.n34=l*T+n*Y+v*a+p;this.n41=q*u+w*I+B*o;this.n42=q*M+w*e+B*ba;this.n43=q*O+w*P+B*V;this.n44=q*T+w*Y+B*a+H;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,b=this.n12,c=this.n13,d=this.n14,f=this.n21,g=this.n22,h=this.n23,k=this.n24,j=this.n31,l=this.n32,n=this.n33,v=this.n34,p=this.n41,q=this.n42,w=this.n43,B=this.n44;return d*h*l*p-c*k*l*p-d*g*n*p+b*k*n*p+c*g*v*p-b*h*v*p-d*h*j*q+c*k*j*q+d*f*n*q-a*k*n*q-c*f*v*q+a*h*v*q+ d*g*j*w-b*k*j*w-d*f*l*w+a*k*l*w+b*f*v*w-a*g*v*w-c*g*j*B+b*h*j*B+c*f*l*B-a*h*l*B-b*f*n*B+a*g*n*B},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.flattenToArray(this.flat);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, 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]=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},setRotX: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},setRotY: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},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,g=a.x,h=a.y,k=a.z,j=f*g,l=f*h;this.set(j*g+c,j*h-d*k,j*k+d*h,0,j*h+d*k,l*h+c,l*k-d*g,0,j*k-d*h,l*k+d*g,f*k*k+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24= a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var f=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var h=a*c,k=b*c;this.n11=f*g;this.n12=-f*d;this.n13=c;this.n21=k*g+a*d;this.n22=-k*d+a*g;this.n23=-b*f;this.n31=-h*g+b*d;this.n32=h*d+b*g;this.n33=a*f},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,f=a.w,g=b+b,h=c+c,k=d+d;a=b*g;var j=b*h;b*=k;var l=c*h;c*=k;d*=k;g*=f;h*=f;f*=k;this.n11=1-(l+d);this.n12=j-f;this.n13= b+h;this.n21=j+f;this.n22=1-(a+d);this.n23=c-g;this.n31=b-h;this.n32=c+g;this.n33=1-(a+l)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=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}};THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d}; THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c}; THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,l=a.n24,n=a.n31,v=a.n32,p=a.n33,q=a.n34,w=a.n41,B=a.n42,H=a.n43,u=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=j*q*B-l*p*B+l*v*H-k*q*H-j*v*u+k*p*u;b.n12=g*p*B-f*q*B-g*v*H+d*q*H+f*v*u-d*p*u;b.n13=f*l*B-g*j*B+g*k*H-d*l*H-f*k*u+d*j*u;b.n14=g*j*v-f*l*v-g*k*p+d*l*p+f*k*q-d*j*q;b.n21=l*p*w-j*q*w-l*n*H+h*q*H+j*n*u-h*p*u;b.n22=f*q*w-g*p*w+g*n*H-c*q*H-f*n*u+c*p*u;b.n23=g*j*w-f*l*w-g*h*H+c*l*H+f*h*u-c*j*u; b.n24=f*l*n-g*j*n+g*h*p-c*l*p-f*h*q+c*j*q;b.n31=k*q*w-l*v*w+l*n*B-h*q*B-k*n*u+h*v*u;b.n32=g*v*w-d*q*w-g*n*B+c*q*B+d*n*u-c*v*u;b.n33=f*l*w-g*k*w+g*h*B-c*l*B-d*h*u+c*k*u;b.n34=g*k*n-d*l*n-g*h*v+c*l*v+d*h*q-c*k*q;b.n41=j*v*w-k*p*w-j*n*B+h*p*B+k*n*H-h*v*H;b.n42=d*p*w-f*v*w+f*n*B-c*p*B-d*n*H+c*v*H;b.n43=f*k*w-d*j*w-f*h*B+c*j*B+d*h*H-c*k*H;b.n44=d*j*n-f*k*n+f*h*v-c*j*v-d*h*p+c*k*p;b.multiplyScalar(1/a.determinant());return b}; THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.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,j=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,v=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*l;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*g;c[3]=a*h;c[4]=a*k;c[5]=a*j;c[6]=a*l;c[7]=a*n;c[8]=a*v;return b}; THREE.Matrix4.makeFrustum=function(a,b,c,d,f,g){var h;h=new THREE.Matrix4;h.n11=2*f/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*f/(d-c);h.n23=(d+c)/(d-c);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+f)/(g-f);h.n34=-2*g*f/(g-f);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,d){var f;a=c*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,c,d)}; THREE.Matrix4.makeOrtho=function(a,b,c,d,f,g){var h,k,j,l;h=new THREE.Matrix4;k=b-a;j=c-d;l=g-f;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-((b+a)/k);h.n21=0;h.n22=2/j;h.n23=0;h.n24=-((c+d)/j);h.n31=0;h.n32=0;h.n33=-2/l;h.n34=-((g+f)/l);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixNeedsUpdate=!0;this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1; this.visible=!0}; THREE.Object3D.prototype={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 b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,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))}return!0},update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);b=1/this.scale.x;a=1/this.scale.y;var d=1/this.scale.z;this.matrixRotationWorld.n11=this.matrixWorld.n11*b;this.matrixRotationWorld.n21= this.matrixWorld.n21*b;this.matrixRotationWorld.n31=this.matrixWorld.n31*b;this.matrixRotationWorld.n12=this.matrixWorld.n12*a;this.matrixRotationWorld.n22=this.matrixWorld.n22*a;this.matrixRotationWorld.n32=this.matrixWorld.n32*a;this.matrixRotationWorld.n13=this.matrixWorld.n13*d;this.matrixRotationWorld.n23=this.matrixWorld.n23*d;this.matrixRotationWorld.n33=this.matrixWorld.n33*d;this.matrixNeedsUpdate=!1;b=!0}a=0;for(d=this.children.length;a=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(f),h=Math.sqrt(1-f*f);if(Math.abs(h)<0.001){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);return c}f=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;c.w=a.w*f+b.w*d;c.x=a.x*f+b.x*d;c.y=a.y*f+b.y*d;c.z=a.z*f+b.z*d;return c}; THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0}; THREE.Face3=function(a,b,c,d,f){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=f instanceof Array?f:[f]};THREE.Face4=function(a,b,c,d,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=g instanceof Array?g:[g]}; THREE.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=!1}; THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=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 b=1,c=this.vertices.length;bthis.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.z this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b65535){l[k].counter+=1;j=l[k].hash+"_"+l[k].counter;this.geometryChunks[j]==undefined&&(this.geometryChunks[j]={faces:[],materials:h,vertices:0})}this.geometryChunks[j].faces.push(d);this.geometryChunks[j].vertices+=g}}};THREE.GeometryIdCounter=0; THREE.Spline=function(){function a(p,q,w,B,H,u,I){p=(w-p)*0.5;B=(B-q)*0.5;return(2*(q-w)+p+B)*I+(-3*(q-w)-2*p-B)*u+p*H+q}var b=[],c={x:0,y:0,z:0},d,f,g,h,k,j,l,n,v;this.get2DPoint=function(p,q){d=(p.length-1)*q;f=Math.floor(d);g=d-f;b[0]=f==0?f:f-1;b[1]=f;b[2]=f>p.length-2?f:f+1;b[3]=f>p.length-3?f:f+2;j=p[b[0]];l=p[b[1]];n=p[b[2]];v=p[b[3]];h=g*g;k=g*h;c.x=a(j.x,l.x,n.x,v.x,g,h,k);c.y=a(j.y,l.y,n.y,v.y,g,h,k);c.z=a(j.z,l.z,n.z,v.z,g,h,k);return c}}; THREE.AnimationHandler=function(){var a=[],b={};b.update=function(c){for(var d=0;dthis.data.length){for(;j>this.data.length;)j-=this.data.length;this.startTime=(new Date).getTime()*0.001-j;j=(new Date).getTime()*0.001-this.startTime}h=Math.min(parseInt(j*this.data.fps),parseInt(this.data.length*this.data.fps));for(var n=0,v=this.hierarchy.length;n1){console.log("Scale out of bounds:"+b);b=b<0?0:1}THREE.Quaternion.slerp(d,f,g.quaternion,b)}else{c=c==="pos"?g.position:g.scale;c.x=d[0]+(f[0]-d[0])*b;c.y=d[1]+(f[1]-d[1])*b;c.z=d[2]+(f[2]-d[2])*b}}}if(k[0][h]===undefined){this.hierarchy[0].update(undefined,!0);for(n=0;nc?c:a} THREE.QuakeCamera=function(a){THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=a.noFly;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.autoForward!== undefined)this.autoForward=a.autoForward;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=a.heightMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phy=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.windowHalfX= window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}};this.onMouseMove=function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward= !0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1}};this.update=function(){this.autoSpeedFactor=this.heightSpeed?(clamp(this.position.y,this.heightMin,this.heightMax)-this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&& this.translateZ(-(this.movementSpeed+this.autoSpeedFactor),this.noFly);this.moveBackward&&this.translateZ(this.movementSpeed,this.noFly);this.moveLeft&&this.translateX(-this.movementSpeed,this.noFly);this.moveRight&&this.translateX(this.movementSpeed,this.noFly);this.lon+=this.mouseX*this.lookSpeed;this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);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;var b=this.target.position,c=this.position; b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.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",bind(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",bind(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",bind(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown", bind(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",bind(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;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;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight; THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){}; THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){}; THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.linewidth!==undefined)this.linewidth= a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}}; THREE.MeshBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;if(a){a.color!==undefined&& this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.lightMap!==undefined)this.lightMap=a.lightMap;if(a.envMap!==undefined)this.envMap=a.envMap;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refractionRatio!==undefined)this.refractionRatio=a.refractionRatio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending= a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!==undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning}}; THREE.MeshLambertMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;if(a){a.color!==undefined&& this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.lightMap!==undefined)this.lightMap=a.lightMap;if(a.envMap!==undefined)this.envMap=a.envMap;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refractionRatio!==undefined)this.refractionRatio=a.refractionRatio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending= a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!==undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning}}; THREE.MeshPhongMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin= this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.lightMap!==undefined)this.lightMap=a.lightMap;if(a.map!==undefined)this.map=a.map;if(a.envMap!==undefined)this.envMap=a.envMap;if(a.combine!== undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refractionRatio!==undefined)this.refractionRatio=a.refractionRatio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!== undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!==undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning}}; THREE.MeshDepthMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!== undefined)this.wireframeLinewidth=a.wireframeLinewidth}}; THREE.MeshNormalMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!== undefined)this.wireframeLinewidth=a.wireframeLinewidth}};THREE.MeshFaceMaterial=function(){}; THREE.MeshShaderMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.vertexShader=this.fragmentShader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;if(a){if(a.fragmentShader!==undefined)this.fragmentShader=a.fragmentShader;if(a.vertexShader!==undefined)this.vertexShader= a.vertexShader;if(a.uniforms!==undefined)this.uniforms=a.uniforms;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!== undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning}}; THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.offset=new THREE.Vector2;this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!== undefined)this.depthTest=a.depthTest;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};THREE.ParticleCircleMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}}; THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};THREE.Texture=function(a,b,c,d,f,g){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrapS=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrapT=d!==undefined?d:THREE.ClampToEdgeWrapping;this.magFilter=f!==undefined?f:THREE.LinearFilter;this.minFilter=g!==undefined?g:THREE.LinearMipMapLinearFilter;this.needsUpdate=!1}; THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10; THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20; THREE.RenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=c.wrapS!==undefined?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=c.wrapT!==undefined?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=c.magFilter!==undefined?c.magFilter:THREE.LinearFilter;this.minFilter=c.minFilter!==undefined?c.minFilter:THREE.LinearMipMapLinearFilter;this.format=c.format!==undefined?c.format:THREE.RGBFormat;this.type=c.type!==undefined?c.type:THREE.UnsignedByteType}; var Uniforms={clone:function(a){var b,c,d,f={};for(b in a){f[b]={};for(c in a[b]){d=a[b][c];f[b][c]=d instanceof THREE.Color||d instanceof THREE.Vector3||d instanceof THREE.Texture?d.clone():d}}return f},merge:function(a){var b,c,d,f={};for(b=0;b1){a=c.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&&da>=0&&J>=0&&$>=0)return!0;else if(Y<0&&da<0||J<0&&$<0)return!1;else{if(Y<0)V=Math.max(V,Y/(Y-da));else da<0&&(T=Math.min(T,Y/(Y-da)));if(J<0)V=Math.max(V,J/(J-$));else $<0&&(T=Math.min(T,J/(J-$)));if(TY&&Z.z0&&H.z<1){p=w[q]=w[q]||new THREE.RenderableParticle;p.x=H.x/H.w;p.y=H.y/H.w;p.z=H.z;p.rotation=fa.rotation.z;p.scale.x=fa.scale.x*Math.abs(p.x-(H.x+P.projectionMatrix.n11)/ (H.w+P.projectionMatrix.n14));p.scale.y=fa.scale.y*Math.abs(p.y-(H.y+P.projectionMatrix.n22)/(H.w+P.projectionMatrix.n24));p.materials=fa.materials;T.push(p);q++}}}}V&&T.sort(a);return T};this.unprojectVector=function(O,P){var V=P.matrixWorld.clone();V.multiplySelf(THREE.Matrix4.makeInvert(P.projectionMatrix));V.multiplyVector3(O);return O}}; THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,f,g;this.domElement=document.createElement("div");this.setSize=function(h,k){c=h;d=k;f=c/2;g=d/2};this.render=function(h,k){var j,l,n,v,p,q,w,B;a=b.projectScene(h,k);j=0;for(l=a.length;j0){S.r+=Aa.r*qa;S.g+=Aa.g*qa;S.b+=Aa.b*qa}}else if(qa instanceof THREE.PointLight){L.sub(qa.position,ga);L.normalize();qa= ha.dot(L)*Ga;if(qa>0){S.r+=Aa.r*qa;S.g+=Aa.g*qa;S.b+=Aa.b*qa}}}}function Ka(R,ga,ha){if(ha.opacity!=0){a(ha.opacity);b(ha.blending);var S,ea,qa,Aa,Ga,Ha;if(ha instanceof THREE.ParticleBasicMaterial){if(ha.map){Aa=ha.map.image;Ga=Aa.width>>1;Ha=Aa.height>>1;ea=ga.scale.x*k;qa=ga.scale.y*j;ha=ea*Ga;S=qa*Ha;C.set(R.x-ha,R.y-S,R.x+ha,R.y+S);if(t.instersects(C)){l.save();l.translate(R.x,R.y);l.rotate(-ga.rotation);l.scale(ea,-qa);l.translate(-Ga,-Ha);l.drawImage(Aa,0,0);l.restore()}}}else if(ha instanceof THREE.ParticleCircleMaterial){if(D){E.r=K.r+W.r+z.r;E.g=K.g+W.g+z.g;E.b=K.b+W.b+z.b;T.r=ha.color.r*E.r;T.g=ha.color.g*E.g;T.b=ha.color.b*E.b;T.updateStyleString()}else T.__styleString=ha.color.__styleString;ha=ga.scale.x*k;S=ga.scale.y*j;C.set(R.x-ha,R.y-S,R.x+ha,R.y+S);if(t.instersects(C)){ea=T.__styleString;if(B!=ea)l.fillStyle=B=ea;l.save();l.translate(R.x,R.y);l.rotate(-ga.rotation);l.scale(ha,S);l.beginPath();l.arc(0,0,1,0,F,!0);l.closePath();l.fill();l.restore()}}}}function ca(R,ga,ha,S){if(S.opacity!= 0){a(S.opacity);b(S.blending);l.beginPath();l.moveTo(R.positionScreen.x,R.positionScreen.y);l.lineTo(ga.positionScreen.x,ga.positionScreen.y);l.closePath();if(S instanceof THREE.LineBasicMaterial){T.__styleString=S.color.__styleString;R=S.linewidth;if(H!=R)l.lineWidth=H=R;R=T.__styleString;if(w!=R)l.strokeStyle=w=R;l.stroke();C.inflate(S.linewidth*2)}}}function aa(R,ga,ha,S,ea,qa){if(ea.opacity!=0){a(ea.opacity);b(ea.blending);M=R.positionScreen.x;e=R.positionScreen.y;ba=ga.positionScreen.x;O=ga.positionScreen.y; P=ha.positionScreen.x;V=ha.positionScreen.y;l.beginPath();l.moveTo(M,e);l.lineTo(ba,O);l.lineTo(P,V);l.lineTo(M,e);l.closePath();if(ea instanceof THREE.MeshBasicMaterial)if(ea.map)ea.map.mapping instanceof THREE.UVMapping&&Fa(M,e,ba,O,P,V,ea.map.image,S.uvs[0].u,S.uvs[0].v,S.uvs[1].u,S.uvs[1].v,S.uvs[2].u,S.uvs[2].v);else if(ea.envMap){if(ea.envMap.mapping instanceof THREE.SphericalReflectionMapping){R=Q.matrixWorldInverse;L.copy(S.vertexNormalsWorld[0]);ja=(L.x*R.n11+L.y*R.n12+L.z*R.n13)*0.5+0.5; fa=-(L.x*R.n21+L.y*R.n22+L.z*R.n23)*0.5+0.5;L.copy(S.vertexNormalsWorld[1]);sa=(L.x*R.n11+L.y*R.n12+L.z*R.n13)*0.5+0.5;m=-(L.x*R.n21+L.y*R.n22+L.z*R.n23)*0.5+0.5;L.copy(S.vertexNormalsWorld[2]);A=(L.x*R.n11+L.y*R.n12+L.z*R.n13)*0.5+0.5;x=-(L.x*R.n21+L.y*R.n22+L.z*R.n23)*0.5+0.5;Fa(M,e,ba,O,P,V,ea.envMap.image,ja,fa,sa,m,A,x)}}else ea.wireframe?X(ea.color.__styleString,ea.wireframeLinewidth):ta(ea.color.__styleString);else if(ea instanceof THREE.MeshLambertMaterial){if(ea.map&&!ea.wireframe){ea.map.mapping instanceof THREE.UVMapping&&Fa(M,e,ba,O,P,V,ea.map.image,S.uvs[0].u,S.uvs[0].v,S.uvs[1].u,S.uvs[1].v,S.uvs[2].u,S.uvs[2].v);b(THREE.SubtractiveBlending)}if(D)if(!ea.wireframe&&ea.shading==THREE.SmoothShading&&S.vertexNormalsWorld.length==3){Y.r=da.r=J.r=K.r;Y.g=da.g=J.g=K.g;Y.b=da.b=J.b=K.b;Ea(qa,S.v1.positionWorld,S.vertexNormalsWorld[0],Y);Ea(qa,S.v2.positionWorld,S.vertexNormalsWorld[1],da);Ea(qa,S.v3.positionWorld,S.vertexNormalsWorld[2],J);$.r=(da.r+J.r)*0.5;$.g=(da.g+J.g)*0.5;$.b=(da.b+J.b)*0.5;la=Ca(Y, da,J,$);Fa(M,e,ba,O,P,V,la,0,0,1,0,0,1)}else{E.r=K.r;E.g=K.g;E.b=K.b;Ea(qa,S.centroidWorld,S.normalWorld,E);T.r=ea.color.r*E.r;T.g=ea.color.g*E.g;T.b=ea.color.b*E.b;T.updateStyleString();ea.wireframe?X(T.__styleString,ea.wireframeLinewidth):ta(T.__styleString)}else ea.wireframe?X(ea.color.__styleString,ea.wireframeLinewidth):ta(ea.color.__styleString)}else if(ea instanceof THREE.MeshDepthMaterial){ra=Q.near;Z=Q.far;Y.r=Y.g=Y.b=1-N(R.positionScreen.z,ra,Z);da.r=da.g=da.b=1-N(ga.positionScreen.z,ra, Z);J.r=J.g=J.b=1-N(ha.positionScreen.z,ra,Z);$.r=(da.r+J.r)*0.5;$.g=(da.g+J.g)*0.5;$.b=(da.b+J.b)*0.5;la=Ca(Y,da,J,$);Fa(M,e,ba,O,P,V,la,0,0,1,0,0,1)}else if(ea instanceof THREE.MeshNormalMaterial){T.r=Da(S.normalWorld.x);T.g=Da(S.normalWorld.y);T.b=Da(S.normalWorld.z);T.updateStyleString();ea.wireframe?X(T.__styleString,ea.wireframeLinewidth):ta(T.__styleString)}}}function X(R,ga){if(w!=R)l.strokeStyle=w=R;if(H!=ga)l.lineWidth=H=ga;l.stroke();C.inflate(ga*2)}function ta(R){if(B!=R)l.fillStyle=B= R;l.fill()}function Fa(R,ga,ha,S,ea,qa,Aa,Ga,Ha,La,Ba,Ma,Ta){var Na,Oa;Na=Aa.width-1;Oa=Aa.height-1;Ga*=Na;Ha*=Oa;La*=Na;Ba*=Oa;Ma*=Na;Ta*=Oa;ha-=R;S-=ga;ea-=R;qa-=ga;La-=Ga;Ba-=Ha;Ma-=Ga;Ta-=Ha;Na=La*Ta-Ma*Ba;if(Na!=0){Oa=1/Na;Na=(Ta*ha-Ba*ea)*Oa;Ba=(Ta*S-Ba*qa)*Oa;ha=(La*ea-Ma*ha)*Oa;S=(La*qa-Ma*S)*Oa;R=R-Na*Ga-ha*Ha;ga=ga-Ba*Ga-S*Ha;l.save();l.transform(Na,Ba,ha,S,R,ga);l.clip();l.drawImage(Aa,0,0);l.restore()}}function Ca(R,ga,ha,S){var ea=~~(R.r*255),qa=~~(R.g*255);R=~~(R.b*255);var Aa=~~(ga.r* 255),Ga=~~(ga.g*255);ga=~~(ga.b*255);var Ha=~~(ha.r*255),La=~~(ha.g*255);ha=~~(ha.b*255);var Ba=~~(S.r*255),Ma=~~(S.g*255);S=~~(S.b*255);ka[0]=ea<0?0:ea>255?255:ea;ka[1]=qa<0?0:qa>255?255:qa;ka[2]=R<0?0:R>255?255:R;ka[4]=Aa<0?0:Aa>255?255:Aa;ka[5]=Ga<0?0:Ga>255?255:Ga;ka[6]=ga<0?0:ga>255?255:ga;ka[8]=Ha<0?0:Ha>255?255:Ha;ka[9]=La<0?0:La>255?255:La;ka[10]=ha<0?0:ha>255?255:ha;ka[12]=Ba<0?0:Ba>255?255:Ba;ka[13]=Ma<0?0:Ma>255?255:Ma;ka[14]=S<0?0:S>255?255:S;U.putImageData(pa,0,0);na.drawImage(G,0,0); return oa}function N(R,ga,ha){R=(R-ga)/(ha-ga);return R*R*(3-2*R)}function Da(R){R=(R+1)*0.5;return R<0?0:R>1?1:R}function Ra(R,ga){var ha=ga.x-R.x,S=ga.y-R.y,ea=1/Math.sqrt(ha*ha+S*S);ha*=ea;S*=ea;ga.x+=ha;ga.y+=S;R.x-=ha;R.y-=S}var Pa,Ja,ia,xa,ua,ya,za,wa;this.autoClear?this.clear():l.setTransform(1,0,0,-1,k,j);c=d.projectScene(va,Q,this.sortElements);(D=va.lights.length>0)&&Ia(va);Pa=0;for(Ja=c.length;Pa0){sa.r+=x.color.r*t;sa.g+=x.color.g*t;sa.b+=x.color.b*t}}else if(x instanceof THREE.PointLight){V.sub(x.position,fa.centroidWorld);V.normalize();t=fa.normalWorld.dot(V)*x.intensity;if(t>0){sa.r+=x.color.r*t;sa.g+=x.color.g*t;sa.b+=x.color.b*t}}}}function b(ja,fa,sa,m,A,x){J=d($++);J.setAttribute("d", "M "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+fa.positionScreen.x+" "+fa.positionScreen.y+" L "+sa.positionScreen.x+","+sa.positionScreen.y+"z");if(A instanceof THREE.MeshBasicMaterial)o.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshLambertMaterial)if(I){M.r=e.r;M.g=e.g;M.b=e.b;a(x,m,M);o.r=A.color.r*M.r;o.g=A.color.g*M.g;o.b=A.color.b*M.b;o.updateStyleString()}else o.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshDepthMaterial){P=1-A.__2near/(A.__farPlusNear- m.z*A.__farMinusNear);o.setRGB(P,P,P)}else A instanceof THREE.MeshNormalMaterial&&o.setRGB(f(m.normalWorld.x),f(m.normalWorld.y),f(m.normalWorld.z));A.wireframe?J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+A.wireframeLinewidth+"; stroke-opacity: "+A.opacity+"; stroke-linecap: "+A.wireframeLinecap+"; stroke-linejoin: "+A.wireframeLinejoin):J.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+A.opacity);k.appendChild(J)}function c(ja,fa,sa,m,A,x,t){J= d($++);J.setAttribute("d","M "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+fa.positionScreen.x+" "+fa.positionScreen.y+" L "+sa.positionScreen.x+","+sa.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");if(x instanceof THREE.MeshBasicMaterial)o.__styleString=x.color.__styleString;else if(x instanceof THREE.MeshLambertMaterial)if(I){M.r=e.r;M.g=e.g;M.b=e.b;a(t,A,M);o.r=x.color.r*M.r;o.g=x.color.g*M.g;o.b=x.color.b*M.b;o.updateStyleString()}else o.__styleString=x.color.__styleString; else if(x instanceof THREE.MeshDepthMaterial){P=1-x.__2near/(x.__farPlusNear-A.z*x.__farMinusNear);o.setRGB(P,P,P)}else x instanceof THREE.MeshNormalMaterial&&o.setRGB(f(A.normalWorld.x),f(A.normalWorld.y),f(A.normalWorld.z));x.wireframe?J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+x.wireframeLinewidth+"; stroke-opacity: "+x.opacity+"; stroke-linecap: "+x.wireframeLinecap+"; stroke-linejoin: "+x.wireframeLinejoin):J.setAttribute("style","fill: "+o.__styleString+ "; fill-opacity: "+x.opacity);k.appendChild(J)}function d(ja){if(T[ja]==null){T[ja]=document.createElementNS("http://www.w3.org/2000/svg","path");la==0&&T[ja].setAttribute("shape-rendering","crispEdges")}return T[ja]}function f(ja){return ja<0?Math.min((1+ja)*0.5,0.5):0.5+Math.min(ja*0.5,0.5)}var g=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,l,n,v,p,q,w,B,H=new THREE.Rectangle,u=new THREE.Rectangle,I=!1,o=new THREE.Color(16777215),M=new THREE.Color(16777215), e=new THREE.Color(0),ba=new THREE.Color(0),O=new THREE.Color(0),P,V=new THREE.Vector3,T=[],Y=[],da=[],J,$,ra,Z,la=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ja){switch(ja){case "high":la=1;break;case "low":la=0}};this.setSize=function(ja,fa){j=ja;l=fa;n=j/2;v=l/2;k.setAttribute("viewBox",-n+" "+-v+" "+j+" "+l);k.setAttribute("width",j);k.setAttribute("height",l);H.set(-n,-v,n,v)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])}; this.render=function(ja,fa){var sa,m,A,x,t,y,C,D;this.autoClear&&this.clear();g=h.projectScene(ja,fa,this.sortElements);Z=ra=$=0;if(I=ja.lights.length>0){C=ja.lights;e.setRGB(0,0,0);ba.setRGB(0,0,0);O.setRGB(0,0,0);sa=0;for(m=C.length;sa=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLColorBuffer);e.vertexAttribPointer(m.color,3,e.FLOAT,!1,0,0)}if(m.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLNormalBuffer);e.vertexAttribPointer(m.normal,3, e.FLOAT,!1,0,0)}if(m.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLTangentBuffer);e.vertexAttribPointer(m.tangent,4,e.FLOAT,!1,0,0)}if(m.uv>=0)if(y.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLUVBuffer);e.vertexAttribPointer(m.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(m.uv)}else e.disableVertexAttribArray(m.uv);if(m.uv2>=0)if(y.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLUV2Buffer);e.vertexAttribPointer(m.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(m.uv2)}else e.disableVertexAttribArray(m.uv2); if(t.skinning&&m.skinVertexA>=0&&m.skinVertexB>=0&&m.skinIndex>=0&&m.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinVertexABuffer);e.vertexAttribPointer(m.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinVertexBBuffer);e.vertexAttribPointer(m.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinIndicesBuffer);e.vertexAttribPointer(m.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinWeightsBuffer);e.vertexAttribPointer(m.skinWeight, 4,e.FLOAT,!1,0,0)}if(C instanceof THREE.Mesh)if(t.wireframe){e.lineWidth(t.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(C instanceof THREE.Line){C=C.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(t.linewidth);e.drawArrays(C,0,y.__webGLLineCount)}else if(C instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,0,y.__webGLParticleCount);else C instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,y.__webGLVertexCount)}function g(m,A){if(!m.__webGLVertexBuffer)m.__webGLVertexBuffer=e.createBuffer();if(!m.__webGLNormalBuffer)m.__webGLNormalBuffer=e.createBuffer();if(m.hasPos){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,m.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(A.attributes.position);e.vertexAttribPointer(A.attributes.position, 3,e.FLOAT,!1,0,0)}if(m.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,m.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(A.attributes.normal);e.vertexAttribPointer(A.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,m.count);m.count=0}function h(m){if(V!=m.doubleSided){m.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);V=m.doubleSided}if(T!=m.flipSided){m.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);T=m.flipSided}}function k(m){if(da!= m){m?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);da=m}}function j(m){J[0].set(m.n41-m.n11,m.n42-m.n12,m.n43-m.n13,m.n44-m.n14);J[1].set(m.n41+m.n11,m.n42+m.n12,m.n43+m.n13,m.n44+m.n14);J[2].set(m.n41+m.n21,m.n42+m.n22,m.n43+m.n23,m.n44+m.n24);J[3].set(m.n41-m.n21,m.n42-m.n22,m.n43-m.n23,m.n44-m.n24);J[4].set(m.n41-m.n31,m.n42-m.n32,m.n43-m.n33,m.n44-m.n34);J[5].set(m.n41+m.n31,m.n42+m.n32,m.n43+m.n33,m.n44+m.n34);var A;for(m=0;m<6;m++){A=J[m];A.divideScalar(Math.sqrt(A.x*A.x+A.y*A.y+A.z*A.z))}} function l(m){for(var A=m.matrixWorld,x=-m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)),t=0;t<6;t++){m=J[t].x*A.n14+J[t].y*A.n24+J[t].z*A.n34+J[t].w;if(m<=x)return!1}return!0}function n(m,A){m.list[m.count]=A;m.count+=1}function v(m){var A,x,t=m.object,y=m.opaque,C=m.transparent;C.count=0;m=y.count=0;for(A=t.materials.length;m0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+C.maxDirLights,"#define MAX_POINT_LIGHTS "+C.maxPointLights,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":"","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 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(x,I("fragment",y+K));e.attachShader(x,I("vertex",C+A));e.linkProgram(x);e.getProgramParameter(x,e.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+e.getProgramParameter(x,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");x.uniforms={};x.attributes={};m.program=x;x=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(t in m.uniforms)x.push(t);t=m.program;K=0;for(A=x.length;K< A;K++){y=x[K];t.uniforms[y]=e.getUniformLocation(t,y)}t=m.program;x=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];K=0;for(A=x.length;K=0&&e.enableVertexAttribArray(t.color);t.normal>=0&&e.enableVertexAttribArray(t.normal);t.tangent>=0&&e.enableVertexAttribArray(t.tangent);if(m.skinning&&t.skinVertexA>=0&&t.skinVertexB>= 0&&t.skinIndex>=0&&t.skinWeight>=0){e.enableVertexAttribArray(t.skinVertexA);e.enableVertexAttribArray(t.skinVertexB);e.enableVertexAttribArray(t.skinIndex);e.enableVertexAttribArray(t.skinWeight)}};this.render=function(m,A,x,t){var y,C,D,E,K,W,z,F,L=m.lights,G=m.fog;A.matrixAutoUpdate&&A.update();A.matrixWorldInverse.flattenToArray(Z);A.projectionMatrix.flattenToArray(ra);$.multiply(A.projectionMatrix,A.matrixWorldInverse);j($);THREE.AnimationHandler&&THREE.AnimationHandler.update();m.update(undefined, !1,A);this.initWebGLObjects(m,A);u(x,t!==undefined?t:!0);this.autoClear&&this.clear();K=m.__webGLObjects.length;for(t=0;t0){e.bindBuffer(e.ARRAY_BUFFER,D.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,Ra,C)}if(Aa&&ka>0){e.bindBuffer(e.ARRAY_BUFFER,D.__webGLUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Pa,C)}if(qa){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,D.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,R,C);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,D.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ga,C)}if(N>0){e.bindBuffer(e.ARRAY_BUFFER,D.__webGLSkinVertexABuffer); e.bufferData(e.ARRAY_BUFFER,ua,C);e.bindBuffer(e.ARRAY_BUFFER,D.__webGLSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,ya,C);e.bindBuffer(e.ARRAY_BUFFER,D.__webGLSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,za,C);e.bindBuffer(e.ARRAY_BUFFER,D.__webGLSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,wa,C)}}w(objlist,z,E,W,y)}K.__dirtyVertices=!1;K.__dirtyElements=!1;K.__dirtyUvs=!1;K.__dirtyNormals=!1;K.__dirtyTangents=!1;K.__dirtyColors=!1}else if(y instanceof THREE.Ribbon){if(!K.__webGLVertexBuffer){E= K;E.__webGLVertexBuffer=e.createBuffer();E.__webGLColorBuffer=e.createBuffer();E=K;W=E.vertices.length;E.__vertexArray=new Float32Array(W*3);E.__colorArray=new Float32Array(W*3);E.__webGLVertexCount=W;K.__dirtyVertices=!0;K.__dirtyColors=!0}if(K.__dirtyVertices||K.__dirtyColors){E=K;W=e.DYNAMIC_DRAW;G=void 0;G=void 0;F=void 0;D=void 0;U=E.vertices;C=E.colors;ka=U.length;pa=C.length;oa=E.__vertexArray;L=E.__colorArray;na=E.__dirtyColors;if(E.__dirtyVertices){for(G=0;G=0;x--){t=m.__webGLObjects[x].object; A==t&&m.__webGLObjects.splice(x,1)}};this.setFaceCulling=function(m,A){if(m){!A||A=="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW);if(m=="back")e.cullFace(e.BACK);else m=="front"?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK);e.enable(e.CULL_FACE)}else e.disable(e.CULL_FACE)};this.supportsVertexTextures=function(){return e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; THREE.Snippets={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 int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif", envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif", map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",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_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\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[20];\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#else\ngl_Position = projectionMatrix * mvPosition;\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)}},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},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={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.Snippets.color_pars_fragment, THREE.Snippets.map_pars_fragment,THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertexShader:[THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,THREE.Snippets.envmap_pars_vertex,THREE.Snippets.color_pars_vertex, THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_pars_fragment, THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertexShader:["varying vec3 vLightWeighting;",THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex, THREE.Snippets.envmap_pars_vertex,THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.Snippets.lights_vertex,THREE.Snippets.skinning_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.Snippets.color_pars_fragment,THREE.Snippets.map_pars_fragment,THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment, THREE.Snippets.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.Snippets.lights_fragment,THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,THREE.Snippets.envmap_pars_vertex, THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.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.Snippets.lights_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_particle_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.Snippets.map_particle_fragment,THREE.Snippets.color_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;", THREE.Snippets.color_pars_vertex,"void main() {",THREE.Snippets.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\ngl_PointSize = size;\n}"].join("\n")}}; 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,b,c){c&&a.update(undefined,!1,b);c=a.sounds;var d,f=c.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;c=Array(g);for(b=d=0;b0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(v,k,p)))-1);l.push(n)}b.push(l)}var q,w,B;f=b.length;for(c=0;c0)for(d=0;d1){q=this.vertices[h].position.clone(); w=this.vertices[j].position.clone();B=this.vertices[l].position.clone();q.normalize();w.normalize();B.normalize();this.faces.push(new THREE.Face3(h,j,l,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(B.x,B.y,B.z)]));this.uvs.push([n,v,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; var Torus=function(a,b,c,d){this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){d=c/this.segmentsT*2*Math.PI;var f=b/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([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c= 1;c<=this.segmentsT;++c){d=(this.segmentsT+1)*b+c;f=(this.segmentsT+1)*b+c-1;var g=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(d,f,g,h));this.uvs.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();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; var Icosahedron=function(a){function b(v,p,q){var w=Math.sqrt(v*v+p*p+q*q);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(v/w,p/w,q/w)))-1}function c(v,p,q,w){w.faces.push(new THREE.Face3(v,p,q))}function d(v,p){var q=f.vertices[v].position,w=f.vertices[p].position;return b((q.x+w.x)/2,(q.y+w.y)/2,(q.z+w.z)/2)}var f=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0, 1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,g);c(0,5,1,g);c(0,1,7,g);c(0,7,10,g);c(0,10,11,g);c(1,5,9,g);c(5,11,4,g);c(11,10,2,g);c(10,7,6,g);c(7,1,8,g);c(3,9,4,g);c(3,4,2,g);c(3,2,6,g);c(3,6,8,g);c(3,8,9,g);c(4,9,5,g);c(2,4,11,g);c(6,2,10,g);c(8,6,7,g);c(9,8,1,g);for(a=0;a=this.maxCount-3&&k(this)};this.begin= function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var d=this.count*3;dthis.size-1&&(j=this.size-1);var p=Math.floor(l-k);p<1&&(p=1);l=Math.floor(l+k);l>this.size-1&&(l=this.size-1);var q=Math.floor(n-k);q<1&&(q=1);k=Math.floor(n+k); k>this.size-1&&(k=this.size-1);for(var w,B,H,u,I,o;v0&&(this.field[H+w]+=u)}}}};this.addPlaneX=function(c,d){var f,g,h,k,j,l=this.size,n=this.yd,v=this.zd,p=this.field,q=l*Math.sqrt(c/d);q>l&&(q=l);for(f=0;f0)for(g=0;gn&&(w=n);for(g=0;g0){j=g*v;for(f=0;fsize&&(dist=size);for(h=0;h0){j=zd*h;for(g=0;g>7)-127;L|=(U&127)<<16|G<<8;if(L==0&&ka==-127)return 0;return(1-2*(pa>>7))*(1+L*Math.pow(2,-23))*Math.pow(2,ka)}function k(z,F){var L=n(z,F),G=n(z,F+1),U=n(z,F+2);return(n(z,F+3)<<24)+(U<<16)+(G<<8)+L}function j(z,F){var L=n(z,F);return(n(z,F+1)<<8)+L}function l(z,F){var L=n(z,F);return L>127?L-256:L}function n(z,F){return z.charCodeAt(F)&255}function v(z){var F,L,G;F= k(a,z);L=k(a,z+ba);G=k(a,z+O);z=j(a,z+P);THREE.Loader.prototype.f3(u,F,L,G,z)}function p(z){var F,L,G,U,pa,ka;F=k(a,z);L=k(a,z+ba);G=k(a,z+O);U=j(a,z+P);pa=k(a,z+V);ka=k(a,z+T);z=k(a,z+Y);THREE.Loader.prototype.f3n(u,M,F,L,G,U,pa,ka,z)}function q(z){var F,L,G,U;F=k(a,z);L=k(a,z+da);G=k(a,z+J);U=k(a,z+$);z=j(a,z+ra);THREE.Loader.prototype.f4(u,F,L,G,U,z)}function w(z){var F,L,G,U,pa,ka,oa,na;F=k(a,z);L=k(a,z+da);G=k(a,z+J);U=k(a,z+$);pa=j(a,z+ra);ka=k(a,z+Z);oa=k(a,z+la);na=k(a,z+ja);z=k(a,z+fa);THREE.Loader.prototype.f4n(u, M,F,L,G,U,pa,ka,oa,na,z)}function B(z){var F,L;F=k(a,z);L=k(a,z+sa);z=k(a,z+m);THREE.Loader.prototype.uv3(u.uvs,e[F*2],e[F*2+1],e[L*2],e[L*2+1],e[z*2],e[z*2+1])}function H(z){var F,L,G;F=k(a,z);L=k(a,z+A);G=k(a,z+x);z=k(a,z+t);THREE.Loader.prototype.uv4(u.uvs,e[F*2],e[F*2+1],e[L*2],e[L*2+1],e[G*2],e[G*2+1],e[z*2],e[z*2+1])}var u=this,I=0,o,M=[],e=[],ba,O,P,V,T,Y,da,J,$,ra,Z,la,ja,fa,sa,m,A,x,t,y,C,D,E,K,W;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(u,d,g);o={signature:a.substr(I, 8),header_bytes:n(a,I+8),vertex_coordinate_bytes:n(a,I+9),normal_coordinate_bytes:n(a,I+10),uv_coordinate_bytes:n(a,I+11),vertex_index_bytes:n(a,I+12),normal_index_bytes:n(a,I+13),uv_index_bytes:n(a,I+14),material_index_bytes:n(a,I+15),nvertices:k(a,I+16),nnormals:k(a,I+16+4),nuvs:k(a,I+16+8),ntri_flat:k(a,I+16+12),ntri_smooth:k(a,I+16+16),ntri_flat_uv:k(a,I+16+20),ntri_smooth_uv:k(a,I+16+24),nquad_flat:k(a,I+16+28),nquad_smooth:k(a,I+16+32),nquad_flat_uv:k(a,I+16+36),nquad_smooth_uv:k(a,I+16+40)}; I+=o.header_bytes;ba=o.vertex_index_bytes;O=o.vertex_index_bytes*2;P=o.vertex_index_bytes*3;V=o.vertex_index_bytes*3+o.material_index_bytes;T=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;Y=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;da=o.vertex_index_bytes;J=o.vertex_index_bytes*2;$=o.vertex_index_bytes*3;ra=o.vertex_index_bytes*4;Z=o.vertex_index_bytes*4+o.material_index_bytes;la=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes;ja= o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*2;fa=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*3;sa=o.uv_index_bytes;m=o.uv_index_bytes*2;A=o.uv_index_bytes;x=o.uv_index_bytes*2;t=o.uv_index_bytes*3;g=o.vertex_index_bytes*3+o.material_index_bytes;W=o.vertex_index_bytes*4+o.material_index_bytes;y=o.ntri_flat*g;C=o.ntri_smooth*(g+o.normal_index_bytes*3);D=o.ntri_flat_uv*(g+o.uv_index_bytes*3);E=o.ntri_smooth_uv*(g+o.normal_index_bytes*3+o.uv_index_bytes*3); K=o.nquad_flat*W;g=o.nquad_smooth*(W+o.normal_index_bytes*4);W=o.nquad_flat_uv*(W+o.uv_index_bytes*4);I+=function(z){for(var F,L,G,U=o.vertex_coordinate_bytes*3,pa=z+o.nvertices*U;z