// ThreeExtras.js r32 - http://github.com/mrdoob/three.js var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=!0;this.setHex(a)}; THREE.Color.prototype={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.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA: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)},toString:function(){return"THREE.Color ( r: "+ this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0}; THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x* this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=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.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this}, cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/= a.z;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+c*c+a*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.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+ this.y+this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);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)},toString:function(){return"THREE.Vector3 ( "+ this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=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.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"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&&F>0&&R+F<1}var c,d,f,g,h,k,j,m,n,w, t,p=a.geometry,x=p.vertices,z=[];c=0;for(d=p.faces.length;cj?d:j;f=f>m?f:m}a()}; this.add3Points=function(j,m,n,w,t,p){if(k){k=!1;b=jn?j>t?j:t:n>t?n:t;f=m>w?m>p?m:p:w>p?w:p}else{b=jn?j>t?j>d?j:d:t>d?t:d:n>t?n>d?n:d:t>d?t:d;f=m>w?m>p?m>f?m:f:p>f?p:f:w>p?w>f?w:f:p>f?p: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};this.toString=function(){return"THREE.Rectangle ( left: "+ b+", right: "+d+", top: "+c+", bottom: "+f+", width: "+g+", height: "+h+" )"}};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,m,n,w,t,p,x,z){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=d||0;this.n21=f||0;this.n22=g||1;this.n23=h||0;this.n24=k||0;this.n31=j||0;this.n32=m||0;this.n33=n||1;this.n34=w||0;this.n41=t||0;this.n42=p||0;this.n43=x||0;this.n44=z||1;this.flat=Array(16);this.m33=new THREE.Matrix3}; THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,c,d,f,g,h,k,j,m,n,w,t,p,x,z){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=m;this.n33=n;this.n34=w;this.n41=t;this.n42=p;this.n43=x;this.n44=z;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=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=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a); this.n31=g.x;this.n32=g.y;this.n33=g.z;this.n34=-g.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;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,m=a.n24,n=a.n31,w=a.n32,t=a.n33,p=a.n34,x=a.n41,z=a.n42,F=a.n43,u=a.n44,e=b.n11,q=b.n12,O=b.n13,R=b.n14,ea=b.n21,L=b.n22,I=b.n23,Y=b.n24,V=b.n31,ca=b.n32,da=b.n33,G=b.n34,$=b.n41,na=b.n42,aa=b.n43,l=b.n44;this.n11=c*e+d*ea+f*V+g*$;this.n12=c*q+d*L+f*ca+g*na;this.n13=c*O+d*I+f*da+g*aa;this.n14=c*R+d*Y+f*G+g*l;this.n21=h*e+k*ea+j*V+m*$;this.n22=h*q+k*L+j*ca+m*na; this.n23=h*O+k*I+j*da+m*aa;this.n24=h*R+k*Y+j*G+m*l;this.n31=n*e+w*ea+t*V+p*$;this.n32=n*q+w*L+t*ca+p*na;this.n33=n*O+w*I+t*da+p*aa;this.n34=n*R+w*Y+t*G+p*l;this.n41=x*e+z*ea+F*V+u*$;this.n42=x*q+z*L+F*ca+u*na;this.n43=x*O+z*I+F*da+u*aa;this.n44=x*R+z*Y+F*G+u*l;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,m=a.n23,n=a.n24,w=a.n31,t=a.n32,p=a.n33,x=a.n34,z=a.n41,F=a.n42,u=a.n43;a=a.n44;var e=b.n11,q=b.n12,O=b.n13,R=b.n14,ea=b.n21,L=b.n22,I=b.n23,Y= b.n24,V=b.n31,ca=b.n32,da=b.n33,G=b.n34,$=b.n41,na=b.n42,aa=b.n43;b=b.n44;this.n11=d*e+f*ea+g*V+h*$;this.n12=d*q+f*L+g*ca+h*na;this.n13=d*O+f*I+g*da+h*aa;this.n14=d*R+f*Y+g*G+h*b;this.n21=k*e+j*ea+m*V+n*$;this.n22=k*q+j*L+m*ca+n*na;this.n23=k*O+j*I+m*da+n*aa;this.n24=k*R+j*Y+m*G+n*b;this.n31=w*e+t*ea+p*V+x*$;this.n32=w*q+t*L+p*ca+x*na;this.n33=w*O+t*I+p*da+x*aa;this.n34=w*R+t*Y+p*G+x*b;this.n41=z*e+F*ea+u*V+a*$;this.n42=z*q+F*L+u*ca+a*na;this.n43=z*O+F*I+u*da+a*aa;this.n44=z*R+F*Y+u*G+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,m=this.n31,n=this.n32,w=this.n33,t=this.n34,p=this.n41,x=this.n42,z=this.n43,F=this.n44,u=a.n11,e=a.n21,q=a.n31,O=a.n41,R=a.n12,ea=a.n22,L=a.n32,I=a.n42,Y= a.n13,V=a.n23,ca=a.n33,da=a.n43,G=a.n14,$=a.n24,na=a.n34;a=a.n44;this.n11=b*u+c*e+d*q+f*O;this.n12=b*R+c*ea+d*L+f*I;this.n13=b*Y+c*V+d*ca+f*da;this.n14=b*G+c*$+d*na+f*a;this.n21=g*u+h*e+k*q+j*O;this.n22=g*R+h*ea+k*L+j*I;this.n23=g*Y+h*V+k*ca+j*da;this.n24=g*G+h*$+k*na+j*a;this.n31=m*u+n*e+w*q+t*O;this.n32=m*R+n*ea+w*L+t*I;this.n33=m*Y+n*V+w*ca+t*da;this.n34=m*G+n*$+w*na+t*a;this.n41=p*u+x*e+z*q+F*O;this.n42=p*R+x*ea+z*L+F*I;this.n43=p*Y+x*V+z*ca+F*da;this.n44=p*G+x*$+z*na+F*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,b=this.n12,c=this.n13,d=this.n14,f=this.n21,g=this.n22,h=this.n23,k=this.n24,j=this.n31,m=this.n32,n=this.n33,w=this.n34,t=this.n41,p=this.n42,x=this.n43,z=this.n44;return d*h*m*t-c*k*m*t-d*g*n*t+b*k*n*t+c*g*w*t-b*h*w*t-d*h*j*p+c*k*j*p+d*f*n*p-a*k*n*p-c*f*w*p+a*h*w*p+ d*g*j*x-b*k*j*x-d*f*m*x+a*k*m*x+b*f*w*x-a*g*w*x-c*g*j*z+b*h*j*z+c*f*m*z-a*h*m*z-b*f*n*z+a*g*n*z},transpose:function(){function a(b,c,d){var f=b[c];b[c]=b[d];b[d]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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(){var a=this.flat;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},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,m=f*h;this.set(j*g+c,j*h-d*k,j*k+d*h,0,j*h+d*k,m*h+c,m*k-d*g,0,j*k-d*h,m*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(c);c=Math.sin(c);var f=Math.cos(-d);d=Math.sin(-d);var g=Math.cos(b);b=Math.sin(b);var h=a*d,k=c*d;this.n11=a*f;this.n12=c*b-h*g;this.n13=h*b+c*g;this.n21=d;this.n22=f*g;this.n23=-f*b;this.n31=-c*f;this.n32=k*g+a*b;this.n33=-k*b+a*g},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 m=c*h;c*=k;d*=k;g*=f;h*=f;f*=k;this.n11=1-(m+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+m)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=b;this.n13*=b;this.n21*=c;this.n22*=c;this.n23*=c;this.n31*=a;this.n32*=a;this.n33*=a;return this},extractRotationMatrix:function(a){a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=0;a.n21=this.n21;a.n22=this.n22; a.n23=this.n23;a.n24=0;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=0;a.n41=0;a.n42=0;a.n43=0;a.n44=1},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};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,m=a.n24,n=a.n31,w=a.n32,t=a.n33,p=a.n34,x=a.n41,z=a.n42,F=a.n43,u=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=j*p*z-m*t*z+m*w*F-k*p*F-j*w*u+k*t*u;b.n12=g*t*z-f*p*z-g*w*F+d*p*F+f*w*u-d*t*u;b.n13=f*m*z-g*j*z+g*k*F-d*m*F-f*k*u+d*j*u;b.n14=g*j*w-f*m*w-g*k*t+d*m*t+f*k*p-d*j*p;b.n21=m*t*x-j*p*x-m*n*F+h*p*F+j*n*u-h*t*u;b.n22=f*p*x-g*t*x+g*n*F-c*p*F-f*n*u+c*t*u;b.n23=g*j*x-f*m*x-g*h*F+c*m*F+f*h*u-c*j*u; b.n24=f*m*n-g*j*n+g*h*t-c*m*t-f*h*p+c*j*p;b.n31=k*p*x-m*w*x+m*n*z-h*p*z-k*n*u+h*w*u;b.n32=g*w*x-d*p*x-g*n*z+c*p*z+d*n*u-c*w*u;b.n33=f*m*x-g*k*x+g*h*z-c*m*z-d*h*u+c*k*u;b.n34=g*k*n-d*m*n-g*h*w+c*m*w+d*h*p-c*k*p;b.n41=j*w*x-k*t*x-j*n*z+h*t*z+k*n*F-h*w*F;b.n42=d*t*x-f*w*x+f*n*z-c*t*z-d*n*F+c*w*F;b.n43=f*k*x-d*j*x-f*h*z+c*j*z+d*h*F-c*k*F;b.n44=d*j*n-f*k*n+f*h*w-c*j*w-d*h*t+c*k*t;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,m=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*m;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*m;c[7]=a*n;c[8]=a*w;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,m;h=new THREE.Matrix4;k=b-a;j=c-d;m=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/m;h.n34=-((g+f)/m);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.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d!==undefined?d:1;this.api={isDirty:!1,that:this,get x(){return this.that.x},get y(){return this.that.y},get z(){return this.that.z},get w(){return this.that.w},set x(f){this.that.x=f;this.isDirty=!0},set y(f){this.that.y=f;this.isDirty=!0},set z(f){this.that.z=f;this.isDirty=!0},set w(f){this.that.w=f;this.isDirty=!0}};this.api.__proto__=THREE.Quaternion.prototype;return this.api}; THREE.Quaternion.prototype.set=function(a,b,c,d){var f=this.that;f.x=a;f.y=b;f.z=c;f.w=d;this.isDirty=!0;return this};THREE.Quaternion.prototype.setFromEuler=function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,f=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-f);f=Math.sin(-f);var g=Math.cos(c);c=Math.sin(c);var h=a*b,k=d*f,j=this.that;j.w=h*g-k*c;j.x=h*c+k*g;j.y=d*b*g+a*f*c;j.z=a*f*g-d*b*c;this.isDirty=!0;return this}; THREE.Quaternion.prototype.calculateW=function(){var a=this.that,b=a.x,c=a.y,d=a.z;a.w=-Math.sqrt(Math.abs(1-b*b-c*c-d*d));this.isDirty=!0;return this};THREE.Quaternion.prototype.inverse=function(){var a=this.that;a.x*=-1;a.y*=-1;a.z*=-1;this.isDirty=!0;return this};THREE.Quaternion.prototype.length=function(){var a=this.that;return Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z+a.w*a.w)}; THREE.Quaternion.prototype.normalize=function(){var a=this.that,b=a.x,c=a.y,d=a.z,f=a.w,g=Math.sqrt(b*b+c*c+d*d+f*f);if(g==0){a.x=0;a.y=0;a.z=0;a.w=0;this.isDirty=!0;return this}g=1/g;a.x=b*g;a.y=c*g;a.z=d*g;a.w=f*g;this.isDirty=!0;return this}; THREE.Quaternion.prototype.multiplySelf=function(a){var b=this.that;qax=b.x;qay=b.y;qaz=b.z;qaw=b.w;qbx=a.x;qby=a.y;qbz=a.z;qbw=a.w;b.x=qax*qbw+qaw*qbx+qay*qbz-qaz*qby;b.y=qay*qbw+qaw*qby+qaz*qbx-qax*qbz;b.z=qaz*qbw+qaw*qbz+qax*qby-qay*qbx;b.w=qaw*qbw-qax*qbx-qay*qby-qaz*qbz;this.isDirty=!0;return this}; THREE.Quaternion.prototype.multiplyVector3=function(a,b){b||(b=a);var c=this.that,d=a.x,f=a.y,g=a.z,h=c.x,k=c.y,j=c.z;c=c.w;var m=c*d+k*g-j*f,n=c*f+j*d-h*g,w=c*g+h*f-k*d;d=-h*d-k*f-j*g;b.x=m*c+d*-h+n*-j-w*-k;b.y=n*c+d*-k+w*-h-m*-j;b.z=w*c+d*-j+m*-k-n*-h;return b};THREE.Quaternion.prototype.toMatrix3=function(){};THREE.Quaternion.prototype.toMatrix4=function(){}; THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(f)>=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.0010){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.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; 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.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; 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.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};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){m[k].counter+=1;j=m[k].hash+"_"+m[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}},toString:function(){return"THREE.Geometry ( vertices: "+ this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.visible=!0;this.autoUpdateMatrix=!0;this.matrixNeedsToUpdate=!0;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale=1;this.rotationMatrix= new THREE.Matrix4};THREE.Object3D.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}var d=this.children.length;for(a=0;athis.data.length){for(;j>this.data.length;)j-=this.data.length;this.startTime=(new Date).getTime()*0.0010-j;j=(new Date).getTime()*0.0010-this.startTime}h=Math.min(parseInt(j*this.data.fps),parseInt(this.data.length*this.data.fps));for(var n=0,w=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;n-this.zNear)return!1;if(h+g<-this.zFar)return!1;h-=g;var k=this.projectionMatrix,j=1/(k.n43*h),m=j*this.screenCenterX,n=(f.n11*b+f.n12*c+f.n13*d+f.n14)*k.n11*m;g=k.n11*g*m;if(n+g<-this.screenCenterX)return!1;if(n-g>this.screenCenterX)return!1;b=(f.n21*b+f.n22*c+f.n23*d+f.n24)*k.n22*j*this.screenCenterY; if(b+g<-this.screenCenterY)return!1;if(b-g>this.screenCenterY)return!1;a.screenPosition.set(n,b,h,g);return!0};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.MaterialCounter={value:0}; THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=!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.depth_test!==undefined)this.depth_test=a.depth_test;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.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}}; THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (
id: "+this.id+"
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
depth_test: "+this.depth_test+"
linewidth: "+this.linewidth+"
linecap: "+this.linecap+"
linejoin: "+this.linejoin+"
vertex_colors: "+this.vertex_colors+"
)"}}; THREE.MeshBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=!0;this.wireframe=!1;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";this.vertex_colors=!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.light_map!==undefined)this.light_map=a.light_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;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.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors;if(a.skinning!==undefined)this.skinning=a.skinning}}; THREE.MeshBasicMaterial.prototype={toString:function(){return"THREE.MeshBasicMaterial (
id: "+this.id+"
color: "+this.color+"
opacity: "+this.opacity+"
map: "+this.map+"
light_map: "+this.light_map+"
env_map: "+this.env_map+"
combine: "+this.combine+"
reflectivity: "+this.reflectivity+"
refraction_ratio: "+this.refraction_ratio+"
blending: "+this.blending+"
depth_test: "+this.depth_test+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+ "
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
vertex_colors: "+this.vertex_colors+"
skinning: "+this.skinning+"
)"}}; THREE.MeshLambertMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=!0;this.wireframe=!1;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";this.vertex_colors=!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.light_map!==undefined)this.light_map=a.light_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;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.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors;if(a.skinning!==undefined)this.skinning=a.skinning}}; THREE.MeshLambertMaterial.prototype={toString:function(){return"THREE.MeshLambertMaterial (
id: "+this.id+"
color: "+this.color+"
opacity: "+this.opacity+"
map: "+this.map+"
light_map: "+this.light_map+"
env_map: "+this.env_map+"
combine: "+this.combine+"
reflectivity: "+this.reflectivity+"
refraction_ratio: "+this.refraction_ratio+"
shading: "+this.shading+"
blending: "+this.blending+"
depth_test: "+this.depth_test+"
wireframe: "+this.wireframe+ "
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
vertex_colors: "+this.vertex_colors+"
skinning: "+this.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.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=!0;this.wireframe=!1;this.wireframe_linewidth=1;this.wireframe_linejoin= this.wireframe_linecap="round";this.vertex_colors=!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.light_map!==undefined)this.light_map=a.light_map;if(a.map!==undefined)this.map=a.map;if(a.env_map!==undefined)this.env_map=a.env_map; if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;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.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth; if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors;if(a.skinning!==undefined)this.skinning=a.skinning}}; THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (
id: "+this.id+"
color: "+this.color+"
ambient: "+this.ambient+"
specular: "+this.specular+"
shininess: "+this.shininess+"
opacity: "+this.opacity+"
map: "+this.map+"
env_map: "+this.env_map+"
combine: "+this.combine+"
reflectivity: "+this.reflectivity+"
refraction_ratio: "+this.refraction_ratio+"
shading: "+this.shading+"
blending: "+this.blending+"
depth_test: "+ this.depth_test+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
vertex_colors: "+this.vertex_colors+"
skinning: "+this.skinning+"
)"}}; THREE.MeshDepthMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=!0;this.wireframe=!1;this.wireframe_linewidth=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.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!== undefined)this.wireframe_linewidth=a.wireframe_linewidth}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial (
id: "+this.id+"
opacity: "+this.opacity+"
blending: "+this.blending+"
depth_test: "+this.depth_test+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
)"}}; THREE.MeshNormalMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;this.depth_test=!0;this.wireframe=!1;this.wireframe_linewidth=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.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!== undefined)this.wireframe_linewidth=a.wireframe_linewidth}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial (
id: "+this.id+"
opacity: "+this.opacity+"
blending: "+this.blending+"
depth_test: "+this.depth_test+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
)"}};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}}; THREE.MeshShaderMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=!0;this.wireframe=!1;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";this.vertex_colors=!1;this.skinning=!1;if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader= a.vertex_shader;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.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!== undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors;if(a.skinning!==undefined)this.skinning=a.skinning}}; THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (
id: "+this.id+"
blending: "+this.blending+"
depth_test: "+this.depth_test+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
vertex_colors: "+this.vertex_colors+"
skinning: "+this.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.depth_test=!0;this.offset=new THREE.Vector2;this.vertex_colors=!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.depth_test!== undefined)this.depth_test=a.depth_test;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (
id: "+this.id+"
color: "+this.color+"
opacity: "+this.opacity+"
map: "+this.map+"
size: "+this.size+"
blending: "+this.blending+"
depth_test: "+this.depth_test+"
vertex_colors: "+this.vertex_colors+"
)"}}; 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.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}}; THREE.Texture=function(a,b,c,d,f,g){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=f!==undefined?f:THREE.LinearFilter;this.min_filter=g!==undefined?g:THREE.LinearMipMapLinearFilter}; THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},toString:function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
mag_filter: "+this.mag_filter+"
min_filter: "+this.min_filter+"
)"}};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.wrap_s=c.wrap_s!==undefined?c.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=c.wrap_t!==undefined?c.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=c.mag_filter!==undefined?c.mag_filter:THREE.LinearFilter;this.min_filter=c.min_filter!==undefined?c.min_filter: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;b=0&&da>=0&&G>=0&&$>=0)return!0;else if(ca<0&&da<0||G<0&&$<0)return!1;else{if(ca<0)Y=Math.max(Y,ca/(ca-da));else da<0&&(V=Math.min(V,ca/(ca-da)));if(G<0)Y=Math.max(Y,G/(G-$));else $<0&&(V=Math.min(V,G/(G-$)));if(Vca&&aa.z0&&F.z<1){t=x[p]=x[p]||new THREE.RenderableParticle;t.x=F.x/F.w;t.y=F.y/F.w;t.z=F.z;t.rotation=y.rotation.z;t.scale.x=y.scale.x*Math.abs(t.x- (F.x+I.projectionMatrix.n11)/(F.w+I.projectionMatrix.n14));t.scale.y=y.scale.y*Math.abs(t.y-(F.y+I.projectionMatrix.n22)/(F.w+I.projectionMatrix.n24));t.materials=y.materials;V.push(t);p++}}}Y&&V.sort(a);return V};this.unprojectVector=function(L,I){var Y=THREE.Matrix4.makeInvert(I.globalMatrix);Y.multiplySelf(THREE.Matrix4.makeInvert(I.projectionMatrix));Y.multiplyVector3(L);return L}}; 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,m,n,w,t,p,x,z;a=b.projectScene(h,k);j=0;for(m=a.length;j0){X.r+=ya.r*ma;X.g+=ya.g*ma;X.b+=ya.b*ma}}else if(ma instanceof THREE.PointLight){K.sub(ma.position,ka);K.normalize(); ma=ia.dot(K)*Fa;if(ma>0){X.r+=ya.r*ma;X.g+=ya.g*ma;X.b+=ya.b*ma}}}}function Ia(S,ka,ia){if(ia.opacity!=0){a(ia.opacity);b(ia.blending);var X,ha,ma,ya,Fa,Ha;if(ia instanceof THREE.ParticleBasicMaterial){if(ia.map&&ia.map.image.loaded){ya=ia.map.image;Fa=ya.width>>1;Ha=ya.height>>1;ha=ka.scale.x*k;ma=ka.scale.y*j;ia=ha*Fa;X=ma*Ha;D.set(S.x-ia,S.y-X,S.x+ia,S.y+X);if(H.instersects(D)){m.save();m.translate(S.x,S.y);m.rotate(-ka.rotation);m.scale(ha,-ma);m.translate(-Fa,-Ha);m.drawImage(ya,0,0);m.restore()}}}else if(ia instanceof THREE.ParticleCircleMaterial){if(J){P.r=ga.r+la.r+C.r;P.g=ga.g+la.g+C.g;P.b=ga.b+la.b+C.b;V.r=ia.color.r*P.r;V.g=ia.color.g*P.g;V.b=ia.color.b*P.b;V.updateStyleString()}else V.__styleString=ia.color.__styleString;ia=ka.scale.x*k;X=ka.scale.y*j;D.set(S.x-ia,S.y-X,S.x+ia,S.y+X);if(H.instersects(D)){ha=V.__styleString;if(z!=ha)m.fillStyle=z=ha;m.save();m.translate(S.x,S.y);m.rotate(-ka.rotation);m.scale(ia,X);m.beginPath();m.arc(0,0,1,0,Q,!0);m.closePath();m.fill();m.restore()}}}}function wa(S,ka,ia, X){if(X.opacity!=0){a(X.opacity);b(X.blending);m.beginPath();m.moveTo(S.positionScreen.x,S.positionScreen.y);m.lineTo(ka.positionScreen.x,ka.positionScreen.y);m.closePath();if(X instanceof THREE.LineBasicMaterial){V.__styleString=X.color.__styleString;S=X.linewidth;if(F!=S)m.lineWidth=F=S;S=V.__styleString;if(x!=S)m.strokeStyle=x=S;m.stroke();D.inflate(X.linewidth*2)}}}function M(S,ka,ia,X,ha,ma){if(ha.opacity!=0){a(ha.opacity);b(ha.blending);O=S.positionScreen.x;R=S.positionScreen.y;ea=ka.positionScreen.x; L=ka.positionScreen.y;I=ia.positionScreen.x;Y=ia.positionScreen.y;m.beginPath();m.moveTo(O,R);m.lineTo(ea,L);m.lineTo(I,Y);m.lineTo(O,R);m.closePath();if(ha instanceof THREE.MeshBasicMaterial)if(ha.map)ha.map.image.loaded&&ha.map.mapping instanceof THREE.UVMapping&&Na(O,R,ea,L,I,Y,ha.map.image,X.uvs[0].u,X.uvs[0].v,X.uvs[1].u,X.uvs[1].v,X.uvs[2].u,X.uvs[2].v);else if(ha.env_map){if(ha.env_map.image.loaded&&ha.env_map.mapping instanceof THREE.SphericalReflectionMapping){S=Z.globalMatrix;K.copy(X.vertexNormalsWorld[0]); A=(K.x*S.n11+K.y*S.n12+K.z*S.n13)*0.5+0.5;y=-(K.x*S.n21+K.y*S.n22+K.z*S.n23)*0.5+0.5;K.copy(X.vertexNormalsWorld[1]);v=(K.x*S.n11+K.y*S.n12+K.z*S.n13)*0.5+0.5;o=-(K.x*S.n21+K.y*S.n22+K.z*S.n23)*0.5+0.5;K.copy(X.vertexNormalsWorld[2]);B=(K.x*S.n11+K.y*S.n12+K.z*S.n13)*0.5+0.5;E=-(K.x*S.n21+K.y*S.n22+K.z*S.n23)*0.5+0.5;Na(O,R,ea,L,I,Y,ha.env_map.image,A,y,v,o,B,E)}}else ha.wireframe?ua(ha.color.__styleString,ha.wireframe_linewidth):Pa(ha.color.__styleString);else if(ha instanceof THREE.MeshLambertMaterial){if(ha.map&& !ha.wireframe){ha.map.mapping instanceof THREE.UVMapping&&Na(O,R,ea,L,I,Y,ha.map.image,X.uvs[0].u,X.uvs[0].v,X.uvs[1].u,X.uvs[1].v,X.uvs[2].u,X.uvs[2].v);b(THREE.SubtractiveBlending)}if(J)if(!ha.wireframe&&ha.shading==THREE.SmoothShading&&X.vertexNormalsWorld.length==3){ca.r=da.r=G.r=ga.r;ca.g=da.g=G.g=ga.g;ca.b=da.b=G.b=ga.b;oa(ma,X.v1.positionWorld,X.vertexNormalsWorld[0],ca);oa(ma,X.v2.positionWorld,X.vertexNormalsWorld[1],da);oa(ma,X.v3.positionWorld,X.vertexNormalsWorld[2],G);$.r=(da.r+G.r)* 0.5;$.g=(da.g+G.g)*0.5;$.b=(da.b+G.b)*0.5;l=La(ca,da,G,$);Na(O,R,ea,L,I,Y,l,0,0,1,0,0,1)}else{P.r=ga.r;P.g=ga.g;P.b=ga.b;oa(ma,X.centroidWorld,X.normalWorld,P);V.r=ha.color.r*P.r;V.g=ha.color.g*P.g;V.b=ha.color.b*P.b;V.updateStyleString();ha.wireframe?ua(V.__styleString,ha.wireframe_linewidth):Pa(V.__styleString)}else ha.wireframe?ua(ha.color.__styleString,ha.wireframe_linewidth):Pa(ha.color.__styleString)}else if(ha instanceof THREE.MeshDepthMaterial){na=Z.near;aa=Z.far;ca.r=ca.g=ca.b=1-qa(S.positionScreen.z, na,aa);da.r=da.g=da.b=1-qa(ka.positionScreen.z,na,aa);G.r=G.g=G.b=1-qa(ia.positionScreen.z,na,aa);$.r=(da.r+G.r)*0.5;$.g=(da.g+G.g)*0.5;$.b=(da.b+G.b)*0.5;l=La(ca,da,G,$);Na(O,R,ea,L,I,Y,l,0,0,1,0,0,1)}else if(ha instanceof THREE.MeshNormalMaterial){V.r=va(X.normalWorld.x);V.g=va(X.normalWorld.y);V.b=va(X.normalWorld.z);V.updateStyleString();ha.wireframe?ua(V.__styleString,ha.wireframe_linewidth):Pa(V.__styleString)}}}function ua(S,ka){if(x!=S)m.strokeStyle=x=S;if(F!=ka)m.lineWidth=F=ka;m.stroke(); D.inflate(ka*2)}function Pa(S){if(z!=S)m.fillStyle=z=S;m.fill()}function Na(S,ka,ia,X,ha,ma,ya,Fa,Ha,Oa,za,Ka,Ma){var Ja,Ga;Ja=ya.width-1;Ga=ya.height-1;Fa*=Ja;Ha*=Ga;Oa*=Ja;za*=Ga;Ka*=Ja;Ma*=Ga;ia-=S;X-=ka;ha-=S;ma-=ka;Oa-=Fa;za-=Ha;Ka-=Fa;Ma-=Ha;Ja=Oa*Ma-Ka*za;if(Ja!=0){Ga=1/Ja;Ja=(Ma*ia-za*ha)*Ga;za=(Ma*X-za*ma)*Ga;ia=(Oa*ha-Ka*ia)*Ga;X=(Oa*ma-Ka*X)*Ga;S=S-Ja*Fa-ia*Ha;ka=ka-za*Fa-X*Ha;m.save();m.transform(Ja,za,ia,X,S,ka);m.clip();m.drawImage(ya,0,0);m.restore()}}function La(S,ka,ia,X){var ha= ~~(S.r*255),ma=~~(S.g*255);S=~~(S.b*255);var ya=~~(ka.r*255),Fa=~~(ka.g*255);ka=~~(ka.b*255);var Ha=~~(ia.r*255),Oa=~~(ia.g*255);ia=~~(ia.b*255);var za=~~(X.r*255),Ka=~~(X.g*255);X=~~(X.b*255);N[0]=ha<0?0:ha>255?255:ha;N[1]=ma<0?0:ma>255?255:ma;N[2]=S<0?0:S>255?255:S;N[4]=ya<0?0:ya>255?255:ya;N[5]=Fa<0?0:Fa>255?255:Fa;N[6]=ka<0?0:ka>255?255:ka;N[8]=Ha<0?0:Ha>255?255:Ha;N[9]=Oa<0?0:Oa>255?255:Oa;N[10]=ia<0?0:ia>255?255:ia;N[12]=za<0?0:za>255?255:za;N[13]=Ka<0?0:Ka>255?255:Ka;N[14]=X<0?0:X>255?255: X;ba.putImageData(ta,0,0);xa.drawImage(U,0,0);return Ba}function qa(S,ka,ia){S=(S-ka)/(ia-ka);return S*S*(3-2*S)}function va(S){S=(S+1)*0.5;return S<0?0:S>1?1:S}function ra(S,ka){var ia=ka.x-S.x,X=ka.y-S.y,ha=1/Math.sqrt(ia*ia+X*X);ia*=ha;X*=ha;ka.x+=ia;ka.y+=X;S.x-=ia;S.y-=X}var pa,sa,ja,Ca,Aa,Ra,Da,Qa;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,j);c=d.projectScene(W,Z,this.sortElements);(J=W.lights.length>0)&&fa(W);pa=0;for(sa=c.length;pa0){v.r+=E.color.r*H;v.g+=E.color.g*H;v.b+=E.color.b*H}}else if(E instanceof THREE.PointLight){Y.sub(E.position,y.centroidWorld);Y.normalize();H=y.normalWorld.dot(Y)*E.intensity;if(H>0){v.r+=E.color.r*H;v.g+=E.color.g*H;v.b+=E.color.b*H}}}}function b(A,y,v,o,B,E){G=d($++);G.setAttribute("d","M "+A.positionScreen.x+ " "+A.positionScreen.y+" L "+y.positionScreen.x+" "+y.positionScreen.y+" L "+v.positionScreen.x+","+v.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)q.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(e){O.r=R.r;O.g=R.g;O.b=R.b;a(E,o,O);q.r=B.color.r*O.r;q.g=B.color.g*O.g;q.b=B.color.b*O.b;q.updateStyleString()}else q.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){I=1-B.__2near/(B.__farPlusNear-o.z*B.__farMinusNear); q.setRGB(I,I,I)}else B instanceof THREE.MeshNormalMaterial&&q.setRGB(f(o.normalWorld.x),f(o.normalWorld.y),f(o.normalWorld.z));B.wireframe?G.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):G.setAttribute("style","fill: "+q.__styleString+"; fill-opacity: "+B.opacity);k.appendChild(G)}function c(A,y,v,o,B,E,H){G=d($++);G.setAttribute("d", "M "+A.positionScreen.x+" "+A.positionScreen.y+" L "+y.positionScreen.x+" "+y.positionScreen.y+" L "+v.positionScreen.x+","+v.positionScreen.y+" L "+o.positionScreen.x+","+o.positionScreen.y+"z");if(E instanceof THREE.MeshBasicMaterial)q.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshLambertMaterial)if(e){O.r=R.r;O.g=R.g;O.b=R.b;a(H,B,O);q.r=E.color.r*O.r;q.g=E.color.g*O.g;q.b=E.color.b*O.b;q.updateStyleString()}else q.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshDepthMaterial){I= 1-E.__2near/(E.__farPlusNear-B.z*E.__farMinusNear);q.setRGB(I,I,I)}else E instanceof THREE.MeshNormalMaterial&&q.setRGB(f(B.normalWorld.x),f(B.normalWorld.y),f(B.normalWorld.z));E.wireframe?G.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframe_linecap+"; stroke-linejoin: "+E.wireframe_linejoin):G.setAttribute("style","fill: "+q.__styleString+"; fill-opacity: "+E.opacity);k.appendChild(G)} function d(A){if(V[A]==null){V[A]=document.createElementNS("http://www.w3.org/2000/svg","path");l==0&&V[A].setAttribute("shape-rendering","crispEdges")}return V[A]}function f(A){return A<0?Math.min((1+A)*0.5,0.5):0.5+Math.min(A*0.5,0.5)}var g=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,n,w,t,p,x,z,F=new THREE.Rectangle,u=new THREE.Rectangle,e=!1,q=new THREE.Color(16777215),O=new THREE.Color(16777215),R=new THREE.Color(0),ea=new THREE.Color(0),L=new THREE.Color(0), I,Y=new THREE.Vector3,V=[],ca=[],da=[],G,$,na,aa,l=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(A){switch(A){case "high":l=1;break;case "low":l=0}};this.setSize=function(A,y){j=A;m=y;n=j/2;w=m/2;k.setAttribute("viewBox",-n+" "+-w+" "+j+" "+m);k.setAttribute("width",j);k.setAttribute("height",m);F.set(-n,-w,n,w)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(A,y){var v,o,B,E,H,T,D,J; this.autoClear&&this.clear();g=h.projectScene(A,y,this.sortElements);aa=na=$=0;if(e=A.lights.length>0){D=A.lights;R.setRGB(0,0,0);ea.setRGB(0,0,0);L.setRGB(0,0,0);v=0;for(o=D.length;v0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+B.maxDirLights,"#define MAX_POINT_LIGHTS "+B.maxPointLights,B.map?"#define USE_MAP":"",B.env_map?"#define USE_ENVMAP":"",B.light_map?"#define USE_LIGHTMAP": "",B.vertex_colors?"#define USE_COLOR":"",B.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(y,z("fragment",o+T));e.attachShader(y,z("vertex",B+A));e.linkProgram(y);e.getProgramParameter(y,e.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+e.getProgramParameter(y,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");y.uniforms={};y.attributes={};l.program=y;y=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","uBoneGlobalMatrices"];for(v in l.uniforms)y.push(v);v=l.program;T=0;for(A=y.length;T< A;T++){o=y[T];v.uniforms[o]=e.getUniformLocation(v,o)}l=l.program;v=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];y=0;for(T=v.length;y=0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLColorBuffer);e.vertexAttribPointer(l.color,3,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.color)}if(l.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLNormalBuffer);e.vertexAttribPointer(l.normal,3,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.normal)}if(l.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLTangentBuffer);e.vertexAttribPointer(l.tangent,4,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.tangent)}if(l.uv>= 0)if(o.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLUVBuffer);e.vertexAttribPointer(l.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.uv)}else e.disableVertexAttribArray(l.uv);if(l.uv2>=0)if(o.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLUV2Buffer);e.vertexAttribPointer(l.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.uv2)}else e.disableVertexAttribArray(l.uv2);if(B instanceof THREE.SkinnedMesh){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexABuffer);e.vertexAttribPointer(l.skinVertexA, 4,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.skinVertexA);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);e.vertexAttribPointer(l.skinVertexB,4,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.skinVertexB);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer);e.vertexAttribPointer(l.skinIndex,4,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.skinIndex);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);e.vertexAttribPointer(l.skinWeight,4,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.skinWeight)}if(B instanceof THREE.Mesh)if(v.wireframe){e.lineWidth(v.wireframe_linewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);e.drawElements(e.LINES,o.__webGLLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);e.drawElements(e.TRIANGLES,o.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else if(B instanceof THREE.Line){B=B.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(v.linewidth);e.drawArrays(B,0,o.__webGLLineCount)}else B instanceof THREE.ParticleSystem&&e.drawArrays(e.POINTS, 0,o.__webGLParticleCount)};this.render=function(l,A,y,v){var o,B,E,H,T,D,J,P,ga=l.lights,la=l.fog;A.autoUpdateMatrix&&A.update();A.globalMatrix.flattenToArray(da);A.projectionMatrix.flattenToArray(V);A.inverseMatrix.flattenToArray(ca);Y.multiply(A.projectionMatrix,A.globalMatrix);g(Y);THREE.AnimationHandler&&THREE.AnimationHandler.update();l.update(undefined,!1,A);this.initWebGLObjects(l,A);x(y,v!==undefined?v:!0);this.autoClear&&this.clear();T=l.__webGLObjects.length;for(v=0;v0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,Pa,la)}if(ka&&Q>0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Na,la)}if(S){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ca,la);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Aa,la)}if(M>0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,ra,la); e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,pa,la);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,sa,la);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,ja,la)}}w(objlist,T,B,H,v)}E.__dirtyVertices=!1;E.__dirtyElements=!1;E.__dirtyUvs=!1;E.__dirtyNormals=!1;E.__dirtyTangents=!1;E.__dirtyColors=!1}else if(v instanceof THREE.Line){if(!E.__webGLVertexBuffer){B=E;B.__webGLVertexBuffer=e.createBuffer(); B.__webGLColorBuffer=e.createBuffer();B=E;H=B.vertices.length;B.__vertexArray=new Float32Array(H*3);B.__colorArray=new Float32Array(H*3);B.__webGLLineCount=H;E.__dirtyVertices=!0;E.__dirtyColors=!0}if(E.__dirtyVertices||E.__dirtyColors){B=E;H=e.DYNAMIC_DRAW;P=void 0;P=void 0;D=void 0;o=void 0;ga=B.vertices;la=B.colors;Q=ga.length;C=la.length;K=B.__vertexArray;J=B.__colorArray;U=B.__dirtyColors;if(B.__dirtyVertices){for(P=0;P=0;y--){v= l.__webGLObjects[y].object;A==v&&l.__webGLObjects.splice(y,1)}};this.addToRenderList=function(){};this.removeFromRenderList=function(){};this.setDepthTest=function(l){l?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST)};this.setFaceCulling=function(l,A){if(l){!A||A=="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW);if(l=="back")e.cullFace(e.BACK);else l=="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 env_map;\nuniform int combine;\n#endif", envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, 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 refraction_ratio;\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 ), refraction_ratio );\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 light_map;\n#endif", lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( light_map, 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 uBoneGlobalMatrices[20];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( uBoneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( uBoneGlobalMatrices[ 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},light_map:{type:"t",value:2,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{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}},fragment_shader:"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}",vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f", value:1}},fragment_shader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertex_shader:"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,fragment_shader:["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"),vertex_shader:[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]),fragment_shader:["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"),vertex_shader:["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}}]),fragment_shader:["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"),vertex_shader:["#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,fragment_shader:["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"),vertex_shader:["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.RenderableObject=function(){this.z=this.object=null}; THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null}; THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null}; THREE.Detector={canvas:!!document.createElement("canvas").getContext,webgl:window.Uint8Array!=undefined,workers:!!window.Worker,addGetWebGLMessage:function(a){var b=document.body,c="oldie";if(a){if(a.parent!==undefined)b=a.parent;if(a.id!==undefined)c=a.id}a=document.createElement("center");var d=document.createElement("div");d.innerHTML='Sorry, your browser doesn\'t support WebGL
\n
\nPlease try in\nChrome 9+ /\nFirefox 4+ /\nSafari OSX 10.6+';d.id= c;c=d.style;c.fontFamily="monospace";c.fontSize="13px";c.textAlign="center";c.background="#eee";c.color="#000";c.padding="1em";c.width="475px";c.margin="5em auto 0";a.appendChild(d);b.appendChild(a);return d}}; var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,d=a.vertices.length,f=c?b.geometry:b,g=a.vertices,h=f.vertices,k=a.faces,j=f.faces,m=a.uvs;f=f.uvs;c&&b.autoUpdateMatrix&&b.updateMatrix();for(var n=0,w=h.length;n= 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}", vertex_shader:"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}},vertex_shader:"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}",fragment_shader:"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:[]}},vertex_shader:"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}",fragment_shader:"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(w,k,t)))-1);m.push(n)}b.push(m)}var p,x,z;f=b.length;for(c=0;c0)for(d=0;d1){p=this.vertices[h].position.clone(); x=this.vertices[j].position.clone();z=this.vertices[m].position.clone();p.normalize();x.normalize();z.normalize();this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(z.x,z.y,z.z)]));this.uvs.push([n,w,F])}}}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(w,t,p){var x=Math.sqrt(w*w+t*t+p*p);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(w/x,t/x,p/x)))-1}function c(w,t,p,x){x.faces.push(new THREE.Face3(w,t,p))}function d(w,t){var p=f.vertices[w].position,x=f.vertices[t].position;return b((p.x+x.x)/2,(p.y+x.y)/2,(p.z+x.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 t=Math.floor(m-k);t<1&&(t=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var p=Math.floor(n-k);p<1&&(p=1);k=Math.floor(n+k); k>this.size-1&&(k=this.size-1);for(var x,z,F,u,e,q;w0&&(this.field[F+x]+=u)}}}};this.addPlaneX=function(c,d){var f,g,h,k,j,m=this.size,n=this.yd,w=this.zd,t=this.field,p=m*Math.sqrt(c/d);p>m&&(p=m);for(f=0;f0)for(g=0;gn&&(x=n);for(g=0;g0){j=g*w;for(f=0;fsize&&(dist=size);for(h=0;h0){j=zd*h;for(g=0;g>7)-127;K|=(ba&127)<<16|U<<8;if(K==0&&N==-127)return 0;return(1-2*(ta>>7))*(1+K*Math.pow(2,-23))*Math.pow(2,N)}function k(C,Q){var K=n(C,Q),U=n(C,Q+1),ba=n(C,Q+2);return(n(C,Q+3)<<24)+(ba<<16)+(U<<8)+K}function j(C,Q){var K=n(C,Q);return(n(C,Q+1)<<8)+K}function m(C,Q){var K=n(C,Q);return K>127?K-256:K}function n(C,Q){return C.charCodeAt(Q)&255}function w(C){var Q,K,U; Q=k(a,C);K=k(a,C+ea);U=k(a,C+L);C=j(a,C+I);THREE.Loader.prototype.f3(u,Q,K,U,C)}function t(C){var Q,K,U,ba,ta,N;Q=k(a,C);K=k(a,C+ea);U=k(a,C+L);ba=j(a,C+I);ta=k(a,C+Y);N=k(a,C+V);C=k(a,C+ca);THREE.Loader.prototype.f3n(u,O,Q,K,U,ba,ta,N,C)}function p(C){var Q,K,U,ba;Q=k(a,C);K=k(a,C+da);U=k(a,C+G);ba=k(a,C+$);C=j(a,C+na);THREE.Loader.prototype.f4(u,Q,K,U,ba,C)}function x(C){var Q,K,U,ba,ta,N,Ba,xa;Q=k(a,C);K=k(a,C+da);U=k(a,C+G);ba=k(a,C+$);ta=j(a,C+na);N=k(a,C+aa);Ba=k(a,C+l);xa=k(a,C+A);C=k(a,C+ y);THREE.Loader.prototype.f4n(u,O,Q,K,U,ba,ta,N,Ba,xa,C)}function z(C){var Q,K;Q=k(a,C);K=k(a,C+v);C=k(a,C+o);THREE.Loader.prototype.uv3(u.uvs,R[Q*2],R[Q*2+1],R[K*2],R[K*2+1],R[C*2],R[C*2+1])}function F(C){var Q,K,U;Q=k(a,C);K=k(a,C+B);U=k(a,C+E);C=k(a,C+H);THREE.Loader.prototype.uv4(u.uvs,R[Q*2],R[Q*2+1],R[K*2],R[K*2+1],R[U*2],R[U*2+1],R[C*2],R[C*2+1])}var u=this,e=0,q,O=[],R=[],ea,L,I,Y,V,ca,da,G,$,na,aa,l,A,y,v,o,B,E,H,T,D,J,P,ga,la;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(u, d,g);q={signature:a.substr(e,8),header_bytes:n(a,e+8),vertex_coordinate_bytes:n(a,e+9),normal_coordinate_bytes:n(a,e+10),uv_coordinate_bytes:n(a,e+11),vertex_index_bytes:n(a,e+12),normal_index_bytes:n(a,e+13),uv_index_bytes:n(a,e+14),material_index_bytes:n(a,e+15),nvertices:k(a,e+16),nnormals:k(a,e+16+4),nuvs:k(a,e+16+8),ntri_flat:k(a,e+16+12),ntri_smooth:k(a,e+16+16),ntri_flat_uv:k(a,e+16+20),ntri_smooth_uv:k(a,e+16+24),nquad_flat:k(a,e+16+28),nquad_smooth:k(a,e+16+32),nquad_flat_uv:k(a,e+16+36), nquad_smooth_uv:k(a,e+16+40)};e+=q.header_bytes;ea=q.vertex_index_bytes;L=q.vertex_index_bytes*2;I=q.vertex_index_bytes*3;Y=q.vertex_index_bytes*3+q.material_index_bytes;V=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes;ca=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes*2;da=q.vertex_index_bytes;G=q.vertex_index_bytes*2;$=q.vertex_index_bytes*3;na=q.vertex_index_bytes*4;aa=q.vertex_index_bytes*4+q.material_index_bytes;l=q.vertex_index_bytes*4+q.material_index_bytes+ q.normal_index_bytes;A=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*2;y=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*3;v=q.uv_index_bytes;o=q.uv_index_bytes*2;B=q.uv_index_bytes;E=q.uv_index_bytes*2;H=q.uv_index_bytes*3;g=q.vertex_index_bytes*3+q.material_index_bytes;la=q.vertex_index_bytes*4+q.material_index_bytes;T=q.ntri_flat*g;D=q.ntri_smooth*(g+q.normal_index_bytes*3);J=q.ntri_flat_uv*(g+q.uv_index_bytes*3);P=q.ntri_smooth_uv*(g+q.normal_index_bytes* 3+q.uv_index_bytes*3);ga=q.nquad_flat*la;g=q.nquad_smooth*(la+q.normal_index_bytes*4);la=q.nquad_flat_uv*(la+q.uv_index_bytes*4);e+=function(C){for(var Q,K,U,ba=q.vertex_coordinate_bytes*3,ta=C+q.nvertices*ba;C