// Three.js r41/ROME - http://github.com/mrdoob/three.js var THREE=THREE||{};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}THREE.Color=function(b){this.setHex(b)}; THREE.Color.prototype={copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex},setHex:function(b){this.hex=~~b&16777215;this.updateRGB()},setRGB:function(b,d,c){this.r=b;this.g=d;this.b=c;this.updateHex()},setHSV:function(b,d,c){var f,g,h,j,k,m;if(c==0)f=g=h=0;else{j=Math.floor(b*6);k=b*6-j;b=c*(1-d);m=c*(1-d*k);d=c*(1-d*(1-k));switch(j){case 1:f=m;g=c;h=b;break;case 2:f=b;g=c;h=d;break;case 3:f=b;g=m;h=c;break;case 4:f=d;g=b;h=c;break;case 5:f=c;g=b;h=m;break;case 6:case 0:f=c;g=d;h=b}}this.setRGB(f, g,h)},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},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(b,d){this.set(b||0,d||0)}; THREE.Vector2.prototype={set:function(b,d){this.x=b;this.y=d;return this},copy:function(b){this.set(b.x,b.y);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y);return this},multiplyScalar:function(b){this.set(this.x*b,this.y*b);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(b,d,c){this.set(b||0,d||0,c||0)}; THREE.Vector3.prototype={set:function(b,d,c){this.x=b;this.y=d;this.z=c;return this},copy:function(b){this.set(b.x,b.y,b.z);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y,b.z+d.z);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z);return this},addScalar:function(b){this.set(this.x+b,this.y+b,this.z+b);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y,b.z-d.z);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z);return this},cross:function(b, d){this.set(b.y*d.z-b.z*d.y,b.z*d.x-b.x*d.z,b.x*d.y-b.y*d.x);return this},crossSelf:function(b){var d=this.x,c=this.y,f=this.z;this.set(c*b.z-f*b.y,f*b.x-d*b.z,d*b.y-c*b.x);return this},multiply:function(b,d){this.set(b.x*d.x,b.y*d.y,b.z*d.z);return this},multiplySelf:function(b){this.set(this.x*b.x,this.y*b.y,this.z*b.z);return this},multiplyScalar:function(b){this.set(this.x*b,this.y*b,this.z*b);return this},divideSelf:function(b){this.set(this.x/b.x,this.y/b.y,this.z/b.z);return this},divideScalar:function(b){this.set(this.x/ b,this.y/b,this.z/b);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var d=this.x-b.x,c=this.y-b.y;b=this.z-b.z;return d*d+c*c+b*b},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 b= this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPositionFromMatrix:function(b){this.x=b.n14;this.y=b.n24;this.z=b.n34},setRotationFromMatrix:function(b){var d=Math.cos(this.y);this.y=Math.asin(b.n13);if(Math.abs(d)>1.0E-5){this.x=Math.atan2(-b.n23/d,b.n33/d);this.z=Math.atan2(-b.n12/d,b.n11/d)}else{this.x=0;this.z=Math.atan2(b.n21,b.n22)}},setLength:function(b){return this.normalize().multiplyScalar(b)},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(b,d,c,f){this.set(b||0,d||0,c||0,f||1)}; THREE.Vector4.prototype={set:function(b,d,c,f){this.x=b;this.y=d;this.z=c;this.w=f;return this},copy:function(b){this.set(b.x,b.y,b.z,b.w||1);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y,b.z+d.z,b.w+d.w);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z,this.w+b.w);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y,b.z-d.z,b.w-d.w);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z,this.w-b.w);return this},multiplyScalar:function(b){this.set(this.x* b,this.y*b,this.z*b,this.w*b);return this},divideScalar:function(b){this.set(this.x/b,this.y/b,this.z/b,this.w/b);return this},lerpSelf:function(b,d){this.set(this.x+(b.x-this.x)*d,this.y+(b.y-this.y)*d,this.z+(b.z-this.z)*d,this.w+(b.w-this.w)*d)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(b,d){this.origin=b||new THREE.Vector3;this.direction=d||new THREE.Vector3}; THREE.Ray.prototype={intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var d,c,f,g=[];d=0;for(c=b.length;d0&&H>0&&O+H<1}var c,f,g,h,j,k,m,o,p,x,y,t=b.geometry,u=t.vertices,I=[];c=0;for(f=t.faces.length;c0:p<0)){o=o.dot((new THREE.Vector3).sub(h,x))/p;x=x.addSelf(y.multiplyScalar(o));if(g instanceof THREE.Face3){if(d(x,h,j,k)){g={distance:this.origin.distanceTo(x),point:x,face:g,object:b};I.push(g)}}else if(g instanceof THREE.Face4&&(d(x,h,j,m)||d(x,j,k,m))){g={distance:this.origin.distanceTo(x),point:x,face:g,object:b};I.push(g)}}}return I}}; THREE.Rectangle=function(){function b(){h=f-d;j=g-c}var d,c,f,g,h,j,k=!0;this.getX=function(){return d};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return j};this.getLeft=function(){return d};this.getTop=function(){return c};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(m,o,p,x){k=!1;d=m;c=o;f=p;g=x;b()};this.addPoint=function(m,o){if(k){k=!1;d=m;c=o;f=m;g=o}else{d=dm?f:m;g=g>o?g:o}b()}; this.add3Points=function(m,o,p,x,y,t){if(k){k=!1;d=mp?m>y?m:y:p>y?p:y;g=o>x?o>t?o:t:x>t?x:t}else{d=mp?m>y?m>f?m:f:y>f?y:f:p>y?p>f?p:f:y>f?y:f;g=o>x?o>t?o>g?o:g:t>g?t:g:x>t?x>g?x:g:t>g?t:g}b()};this.addRectangle=function(m){if(k){k=!1;d=m.getLeft();c=m.getTop();f=m.getRight();g=m.getBottom()}else{d=dm.getRight()? f:m.getRight();g=g>m.getBottom()?g:m.getBottom()}b()};this.inflate=function(m){d-=m;c-=m;f+=m;g+=m;b()};this.minSelf=function(m){d=d>m.getLeft()?d:m.getLeft();c=c>m.getTop()?c:m.getTop();f=f=0&&Math.min(g,m.getBottom())-Math.max(c,m.getTop())>=0};this.empty=function(){k=!0;g=f=c=d=0;b()};this.isEmpty=function(){return k}}; THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var b,d=this.m;b=d[1];d[1]=d[3];d[3]=b;b=d[2];d[2]=d[6];d[6]=b;b=d[5];d[5]=d[7];d[7]=b;return this},transposeIntoArray:function(b){var d=this.m;b[0]=d[0];b[1]=d[3];b[2]=d[6];b[3]=d[1];b[4]=d[4];b[5]=d[7];b[6]=d[2];b[7]=d[5];b[8]=d[8];return this}}; THREE.Matrix4=function(b,d,c,f,g,h,j,k,m,o,p,x,y,t,u,I){this.set(b||1,d||0,c||0,f||0,g||0,h||1,j||0,k||0,m||0,o||0,p||1,x||0,y||0,t||0,u||0,I||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; THREE.Matrix4.prototype={set:function(b,d,c,f,g,h,j,k,m,o,p,x,y,t,u,I){this.n11=b;this.n12=d;this.n13=c;this.n14=f;this.n21=g;this.n22=h;this.n23=j;this.n24=k;this.n31=m;this.n32=o;this.n33=p;this.n34=x;this.n41=y;this.n42=t;this.n43=u;this.n44=I;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(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,d,c){var f=THREE.Matrix4.__v1, g=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(b,d).normalize();if(h.length()===0)h.z=1;f.cross(c,h).normalize();if(f.length()===0){h.x+=1.0E-4;f.cross(c,h).normalize()}g.cross(h,f).normalize();this.n11=f.x;this.n12=g.x;this.n13=h.x;this.n21=f.y;this.n22=g.y;this.n23=h.y;this.n31=f.z;this.n32=g.z;this.n33=h.z;return this},multiplyVector3:function(b){var d=b.x,c=b.y,f=b.z,g=1/(this.n41*d+this.n42*c+this.n43*f+this.n44);b.x=(this.n11*d+this.n12*c+this.n13*f+this.n14)*g;b.y=(this.n21*d+this.n22*c+this.n23* f+this.n24)*g;b.z=(this.n31*d+this.n32*c+this.n33*f+this.n34)*g;return b},multiplyVector4:function(b){var d=b.x,c=b.y,f=b.z,g=b.w;b.x=this.n11*d+this.n12*c+this.n13*f+this.n14*g;b.y=this.n21*d+this.n22*c+this.n23*f+this.n24*g;b.z=this.n31*d+this.n32*c+this.n33*f+this.n34*g;b.w=this.n41*d+this.n42*c+this.n43*f+this.n44*g;return b},rotateAxis:function(b){var d=b.x,c=b.y,f=b.z;b.x=d*this.n11+c*this.n12+f*this.n13;b.y=d*this.n21+c*this.n22+f*this.n23;b.z=d*this.n31+c*this.n32+f*this.n33;b.normalize(); return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,o=b.n24,p=b.n31,x=b.n32,y=b.n33,t=b.n34,u=b.n41,I=b.n42,H=b.n43,C=b.n44,S=d.n11,E=d.n12,T=d.n13,O=d.n14,Q=d.n21,ya=d.n22, aa=d.n23,ga=d.n24,X=d.n31,ha=d.n32,e=d.n33,Ja=d.n34;this.n11=c*S+f*Q+g*X;this.n12=c*E+f*ya+g*ha;this.n13=c*T+f*aa+g*e;this.n14=c*O+f*ga+g*Ja+h;this.n21=j*S+k*Q+m*X;this.n22=j*E+k*ya+m*ha;this.n23=j*T+k*aa+m*e;this.n24=j*O+k*ga+m*Ja+o;this.n31=p*S+x*Q+y*X;this.n32=p*E+x*ya+y*ha;this.n33=p*T+x*aa+y*e;this.n34=p*O+x*ga+y*Ja+t;this.n41=u*S+I*Q+H*X;this.n42=u*E+I*ya+H*ha;this.n43=u*T+I*aa+H*e;this.n44=u*O+I*ga+H*Ja+C;return this},multiplyToArray:function(b,d,c){this.multiply(b,d);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(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this}, determinant:function(){var b=this.n11,d=this.n12,c=this.n13,f=this.n14,g=this.n21,h=this.n22,j=this.n23,k=this.n24,m=this.n31,o=this.n32,p=this.n33,x=this.n34,y=this.n41,t=this.n42,u=this.n43,I=this.n44;return f*j*o*y-c*k*o*y-f*h*p*y+d*k*p*y+c*h*x*y-d*j*x*y-f*j*m*t+c*k*m*t+f*g*p*t-b*k*p*t-c*g*x*t+b*j*x*t+f*h*m*u-d*k*m*u-f*g*o*u+b*k*o*u+d*g*x*u-b*h*x*u-c*h*m*I+d*j*m*I+c*g*o*I-b*j*o*I-d*g*p*I+b*h*p*I},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13= b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=this.n11; this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13; b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,d){b[d]=this.n11;b[d+1]=this.n21;b[d+2]=this.n31;b[d+3]=this.n41;b[d+4]=this.n12;b[d+5]=this.n22;b[d+6]=this.n32;b[d+7]=this.n42;b[d+8]=this.n13;b[d+9]=this.n23;b[d+10]=this.n33;b[d+11]=this.n43;b[d+12]=this.n14;b[d+13]=this.n24;b[d+14]=this.n34;b[d+15]=this.n44;return b},setTranslation:function(b,d,c){this.set(1,0,0,b,0,1,0,d,0,0,1,c,0,0,0,1);return this}, setScale:function(b,d,c){this.set(b,0,0,0,0,d,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(1,0,0,0,0,d,-b,0,0,b,d,0,0,0,0,1);return this},setRotationY:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(d,0,b,0,0,1,0,0,-b,0,d,0,0,0,0,1);return this},setRotationZ:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(d,-b,0,0,b,d,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,d){var c=Math.cos(d),f=Math.sin(d),g=1-c,h=b.x,j=b.y,k= b.z,m=g*h,o=g*j;this.set(m*h+c,m*j-f*k,m*k+f*j,0,m*j+f*k,o*j+c,o*k-f*h,0,m*k-f*j,o*k+f*h,g*k*k+c,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX=new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY= new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b){var d=b.x,c=b.y,f=b.z;b=Math.cos(d);d=Math.sin(d);var g=Math.cos(c);c=Math.sin(c);var h=Math.cos(f);f=Math.sin(f);var j=b*c,k=d*c;this.n11=g*h;this.n12=-g*f;this.n13=c;this.n21=k*h+b*f;this.n22=-k*f+b*h;this.n23=-d*g;this.n31=-j*h+d*f;this.n32=j*f+ d*h;this.n33=b*g;return this},setRotationFromQuaternion:function(b){var d=b.x,c=b.y,f=b.z,g=b.w,h=d+d,j=c+c,k=f+f;b=d*h;var m=d*j;d*=k;var o=c*j;c*=k;f*=k;h*=g;j*=g;g*=k;this.n11=1-(o+f);this.n12=m-g;this.n13=d+j;this.n21=m+g;this.n22=1-(b+f);this.n23=c-h;this.n31=d-j;this.n32=c+h;this.n33=1-(b+o);return this},scale:function(b){var d=b.x,c=b.y;b=b.z;this.n11*=d;this.n12*=c;this.n13*=b;this.n21*=d;this.n22*=c;this.n23*=b;this.n31*=d;this.n32*=c;this.n33*=b;this.n41*=d;this.n42*=c;this.n43*=b;return this}, extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,d){var c=1/d.x,f=1/d.y,g=1/d.z;this.n11=b.n11*c;this.n21=b.n21*c;this.n31=b.n31*c;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*g;this.n23=b.n23*g;this.n33=b.n33*g}}; THREE.Matrix4.makeInvert=function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,o=b.n24,p=b.n31,x=b.n32,y=b.n33,t=b.n34,u=b.n41,I=b.n42,H=b.n43,C=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=m*t*I-o*y*I+o*x*H-k*t*H-m*x*C+k*y*C;d.n12=h*y*I-g*t*I-h*x*H+f*t*H+g*x*C-f*y*C;d.n13=g*o*I-h*m*I+h*k*H-f*o*H-g*k*C+f*m*C;d.n14=h*m*x-g*o*x-h*k*y+f*o*y+g*k*t-f*m*t;d.n21=o*y*u-m*t*u-o*p*H+j*t*H+m*p*C-j*y*C;d.n22=g*t*u-h*y*u+h*p*H-c*t*H-g*p*C+c*y*C;d.n23=h*m*u-g*o*u-h*j*H+c*o*H+g*j*C-c*m*C; d.n24=g*o*p-h*m*p+h*j*y-c*o*y-g*j*t+c*m*t;d.n31=k*t*u-o*x*u+o*p*I-j*t*I-k*p*C+j*x*C;d.n32=h*x*u-f*t*u-h*p*I+c*t*I+f*p*C-c*x*C;d.n33=g*o*u-h*k*u+h*j*I-c*o*I-f*j*C+c*k*C;d.n34=h*k*p-f*o*p-h*j*x+c*o*x+f*j*t-c*k*t;d.n41=m*x*u-k*y*u-m*p*I+j*y*I+k*p*H-j*x*H;d.n42=f*y*u-g*x*u+g*p*I-c*y*I-f*p*H+c*x*H;d.n43=g*k*u-f*m*u-g*j*I+c*m*I+f*j*H-c*k*H;d.n44=f*m*p-g*k*p+g*j*x-c*m*x-f*j*y+c*k*y;d.multiplyScalar(1/b.determinant());return d}; THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,c=d.m,f=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,h=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,k=b.n33*b.n11-b.n31*b.n13,m=-b.n32*b.n11+b.n31*b.n12,o=b.n23*b.n12-b.n22*b.n13,p=-b.n23*b.n11+b.n21*b.n13,x=b.n22*b.n11-b.n21*b.n12;b=b.n11*f+b.n21*j+b.n31*o;if(b==0)throw"matrix not invertible";b=1/b;c[0]=b*f;c[1]=b*g;c[2]=b*h;c[3]=b*j;c[4]=b*k;c[5]=b*m;c[6]=b*o;c[7]=b*p;c[8]=b*x;return d}; THREE.Matrix4.makeFrustum=function(b,d,c,f,g,h){var j;j=new THREE.Matrix4;j.n11=2*g/(d-b);j.n12=0;j.n13=(d+b)/(d-b);j.n14=0;j.n21=0;j.n22=2*g/(f-c);j.n23=(f+c)/(f-c);j.n24=0;j.n31=0;j.n32=0;j.n33=-(h+g)/(h-g);j.n34=-2*h*g/(h-g);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,d,c,f){var g;b=c*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*d,b*d,g,b,c,f)}; THREE.Matrix4.makeOrtho=function(b,d,c,f,g,h){var j,k,m,o;j=new THREE.Matrix4;k=d-b;m=c-f;o=h-g;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((d+b)/k);j.n21=0;j.n22=2/m;j.n23=0;j.n24=-((c+f)/m);j.n31=0;j.n32=0;j.n33=-2/o;j.n34=-((h+g)/o);j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.dynamic=!1;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale= 1;this.visible=!0;this._vector=new THREE.Vector3;this.name=""}; THREE.Object3D.prototype={translate:function(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(b,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(b){if(this.children.indexOf(b)=== -1){b.parent!==undefined&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var d=this;d.parent!==undefined;)d=d.parent;d!==undefined&&d instanceof THREE.Scene&&d.addChildRecurse(b)}},removeChild:function(b){var d=this.children.indexOf(b);if(d!==-1){b.parent=undefined;this.children.splice(d,1)}},getChildByName:function(b,d){var c,f,g;c=0;for(f=this.children.length;c=1){c.w=b.w;c.x=b.x;c.y=b.y;c.z=b.z;return c}var h=Math.acos(g),j=Math.sqrt(1-g*g);if(Math.abs(j)<0.001){c.w=0.5*(b.w+d.w);c.x=0.5*(b.x+d.x);c.y=0.5*(b.y+d.y);c.z=0.5*(b.z+d.z);return c}g=Math.sin((1-f)*h)/j;f=Math.sin(f*h)/j;c.w=b.w*g+d.w*f;c.x=b.x*g+d.x*f;c.y=b.y*g+d.y*f;c.z=b.z*g+d.z*f;return c};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; THREE.Face3=function(b,d,c,f,g,h){this.a=b;this.b=d;this.c=c;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3}; THREE.Face4=function(b,d,c,f,g,h,j){this.a=b;this.b=d;this.c=c;this.d=f;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)}; THREE.UV.prototype={set:function(b,d){this.u=b;this.v=d;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1}; THREE.Geometry.prototype={computeCentroids:function(){var b,d,c;b=0;for(d=this.faces.length;b0){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 d=1,c=this.vertices.length;dthis.boundingBox.x[1])this.boundingBox.x[1]=b.position.x; if(b.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=this.boundingSphere===null?0:this.boundingSphere.radius,d=0,c=this.vertices.length;dthis.points.length-2?h:h+1;c[3]=h>this.points.length-3?h:h+2;o=this.points[c[0]];p=this.points[c[1]]; x=this.points[c[2]];y=this.points[c[3]];k=j*j;m=j*k;f.x=d(o.x,p.x,x.x,y.x,j,k,m);f.y=d(o.y,p.y,x.y,y.y,j,k,m);f.z=d(o.z,p.z,x.z,y.z,j,k,m);return f};this.getControlPointsArray=function(){var t,u,I=this.points.length,H=[];for(t=0;t1){b=c.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var f=1;f=this.LODs[f].visibleAtDistance){this.LODs[f-1].object3D.visible= !1;this.LODs[f].object3D.visible=!0}else break;for(;fx){c=p;p=x;x=c}}else if(pt){c=y;y=t;t=c}}else if(y=0&&ca>=0&&ua>=0&&da>=0)return!0;else if(Da<0&&ca<0||ua<0&&da<0)return!1;else{if(Da<0)Ja=Math.max(Ja,Da/(Da-ca));else ca<0&&(ta=Math.min(ta,Da/(Da-ca)));if(ua<0)Ja=Math.max(Ja,ua/(ua-da));else da<0&&(ta=Math.min(ta,ua/(ua-da)));if(taDa&&j.positionScreen.z0&&O.z<1){xa=E[S]=E[S]||new THREE.RenderableParticle;S++;C=xa;C.x=O.x/O.w;C.y=O.y/O.w;C.z=O.z;C.rotation=fa.rotation.z;C.scale.x=fa.scale.x*Math.abs(C.x-(O.x+e.projectionMatrix.n11)/(O.w+e.projectionMatrix.n14));C.scale.y=fa.scale.y*Math.abs(C.y-(O.y+e.projectionMatrix.n22)/(O.w+e.projectionMatrix.n24));C.materials=fa.materials;ta.push(C)}}}}Ja&&ta.sort(d);return ta}}; THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,d=new THREE.Projector,c,f,g,h;this.domElement=document.createElement("div");this.setSize=function(j,k){c=j;f=k;g=c/2;h=f/2};this.render=function(j,k){var m,o,p,x,y,t,u,I;b=d.projectScene(j,k);m=0;for(o=b.length;m>1;za=ma.height>>1;va=pa.scale.x*y;wa=pa.scale.y*t;qa=va*N;Ia=wa*za;D.set(R.x-qa,R.y-Ia,R.x+qa,R.y+Ia);if(lb.instersects(D)){u.save();u.translate(R.x,R.y);u.rotate(-pa.rotation);u.scale(va,-wa);u.translate(-N,-za);u.drawImage(ma,0,0);u.restore()}}}else if(va instanceof THREE.ParticleCanvasMaterial){qa=pa.scale.x*y;Ia=pa.scale.y*t;D.set(R.x-qa,R.y-Ia,R.x+qa,R.y+Ia);if(lb.instersects(D)){f(va.color);g(va.color);u.save(); u.translate(R.x,R.y);u.rotate(-pa.rotation);u.scale(qa,Ia);va.program(u);u.restore()}}}function kb(R,pa,va,qa){d(qa.opacity);c(qa.blending);u.beginPath();u.moveTo(R.positionScreen.x,R.positionScreen.y);u.lineTo(pa.positionScreen.x,pa.positionScreen.y);u.closePath();if(qa instanceof THREE.LineBasicMaterial){R=qa.linewidth;if(O!=R)u.lineWidth=O=R;R=qa.linecap;if(Q!=R)u.lineCap=Q=R;R=qa.linejoin;if(ya!=R)u.lineJoin=ya=R;f(qa.color);u.stroke();D.inflate(qa.linewidth*2)}}function Ca(R,pa,va,qa,Ia,wa,ma, N,za){j.data.vertices+=3;j.data.faces++;d(N.opacity);c(N.blending);ta=R.positionScreen.x;Da=R.positionScreen.y;ca=pa.positionScreen.x;ua=pa.positionScreen.y;da=va.positionScreen.x;sa=va.positionScreen.y;Ea(ta,Da,ca,ua,da,sa);if(N instanceof THREE.MeshBasicMaterial)if(N.map){if(N.map.mapping instanceof THREE.UVMapping){la=ma.uvs[0];w(ta,Da,ca,ua,da,sa,N.map.image,la[qa].u,la[qa].v,la[Ia].u,la[Ia].v,la[wa].u,la[wa].v)}}else if(N.envMap){if(N.envMap.mapping instanceof THREE.SphericalReflectionMapping){R= Ka.matrixWorldInverse;G.copy(ma.vertexNormalsWorld[0]);Na=(G.x*R.n11+G.y*R.n12+G.z*R.n13)*0.5+0.5;fb=-(G.x*R.n21+G.y*R.n22+G.z*R.n23)*0.5+0.5;G.copy(ma.vertexNormalsWorld[1]);hb=(G.x*R.n11+G.y*R.n12+G.z*R.n13)*0.5+0.5;Ga=-(G.x*R.n21+G.y*R.n22+G.z*R.n23)*0.5+0.5;G.copy(ma.vertexNormalsWorld[2]);ka=(G.x*R.n11+G.y*R.n12+G.z*R.n13)*0.5+0.5;ub=-(G.x*R.n21+G.y*R.n22+G.z*R.n23)*0.5+0.5;w(ta,Da,ca,ua,da,sa,N.envMap.image,Na,fb,hb,Ga,ka,ub)}}else N.wireframe?F(N.color,N.wireframeLinewidth,N.wireframeLinecap, N.wireframeLinejoin):$(N.color);else if(N instanceof THREE.MeshLambertMaterial){if(N.map&&!N.wireframe){if(N.map.mapping instanceof THREE.UVMapping){la=ma.uvs[0];w(ta,Da,ca,ua,da,sa,N.map.image,la[qa].u,la[qa].v,la[Ia].u,la[Ia].v,la[wa].u,la[wa].v)}c(THREE.SubtractiveBlending)}if(z)if(!N.wireframe&&N.shading==THREE.SmoothShading&&ma.vertexNormalsWorld.length==3){xa.r=Ma.r=Qa.r=A.r;xa.g=Ma.g=Qa.g=A.g;xa.b=Ma.b=Qa.b=A.b;La(za,ma.v1.positionWorld,ma.vertexNormalsWorld[0],xa);La(za,ma.v2.positionWorld, ma.vertexNormalsWorld[1],Ma);La(za,ma.v3.positionWorld,ma.vertexNormalsWorld[2],Qa);Ua.r=(Ma.r+Qa.r)*0.5;Ua.g=(Ma.g+Qa.g)*0.5;Ua.b=(Ma.b+Qa.b)*0.5;ja=cb(xa,Ma,Qa,Ua);w(ta,Da,ca,ua,da,sa,ja,0,0,1,0,0,1)}else{v.r=A.r;v.g=A.g;v.b=A.b;La(za,ma.centroidWorld,ma.normalWorld,v);fa.r=Math.max(0,Math.min(N.color.r*v.r,1));fa.g=Math.max(0,Math.min(N.color.g*v.g,1));fa.b=Math.max(0,Math.min(N.color.b*v.b,1));fa.updateHex();N.wireframe?F(fa,N.wireframeLinewidth,N.wireframeLinecap,N.wireframeLinejoin):$(fa)}else N.wireframe? F(N.color,N.wireframeLinewidth,N.wireframeLinecap,N.wireframeLinejoin):$(N.color)}else if(N instanceof THREE.MeshDepthMaterial){L=Ka.near;Z=Ka.far;xa.r=xa.g=xa.b=1-gb(R.positionScreen.z,L,Z);Ma.r=Ma.g=Ma.b=1-gb(pa.positionScreen.z,L,Z);Qa.r=Qa.g=Qa.b=1-gb(va.positionScreen.z,L,Z);Ua.r=(Ma.r+Qa.r)*0.5;Ua.g=(Ma.g+Qa.g)*0.5;Ua.b=(Ma.b+Qa.b)*0.5;ja=cb(xa,Ma,Qa,Ua);w(ta,Da,ca,ua,da,sa,ja,0,0,1,0,0,1)}else if(N instanceof THREE.MeshNormalMaterial){fa.r=Va(ma.normalWorld.x);fa.g=Va(ma.normalWorld.y);fa.b= Va(ma.normalWorld.z);fa.updateHex();N.wireframe?F(fa,N.wireframeLinewidth,N.wireframeLinecap,N.wireframeLinejoin):$(fa)}}function Ha(R,pa,va,qa,Ia,wa,ma,N,za){j.data.vertices+=4;j.data.faces++;d(N.opacity);c(N.blending);if(N.map||N.envMap){Ca(R,pa,qa,0,1,3,ma,N,za);Ca(Ia,va,wa,1,2,3,ma,N,za)}else{ta=R.positionScreen.x;Da=R.positionScreen.y;ca=pa.positionScreen.x;ua=pa.positionScreen.y;da=va.positionScreen.x;sa=va.positionScreen.y;na=qa.positionScreen.x;ra=qa.positionScreen.y;oa=Ia.positionScreen.x; ea=Ia.positionScreen.y;Aa=wa.positionScreen.x;Oa=wa.positionScreen.y;if(N instanceof THREE.MeshBasicMaterial){Ta(ta,Da,ca,ua,da,sa,na,ra);N.wireframe?F(N.color,N.wireframeLinewidth,N.wireframeLinecap,N.wireframeLinejoin):$(N.color)}else if(N instanceof THREE.MeshLambertMaterial)if(z)if(!N.wireframe&&N.shading==THREE.SmoothShading&&ma.vertexNormalsWorld.length==4){xa.r=Ma.r=Qa.r=Ua.r=A.r;xa.g=Ma.g=Qa.g=Ua.g=A.g;xa.b=Ma.b=Qa.b=Ua.b=A.b;La(za,ma.v1.positionWorld,ma.vertexNormalsWorld[0],xa);La(za,ma.v2.positionWorld, ma.vertexNormalsWorld[1],Ma);La(za,ma.v4.positionWorld,ma.vertexNormalsWorld[3],Qa);La(za,ma.v3.positionWorld,ma.vertexNormalsWorld[2],Ua);ja=cb(xa,Ma,Qa,Ua);Ea(ta,Da,ca,ua,na,ra);w(ta,Da,ca,ua,na,ra,ja,0,0,1,0,0,1);Ea(oa,ea,da,sa,Aa,Oa);w(oa,ea,da,sa,Aa,Oa,ja,1,0,1,1,0,1)}else{v.r=A.r;v.g=A.g;v.b=A.b;La(za,ma.centroidWorld,ma.normalWorld,v);fa.r=Math.max(0,Math.min(N.color.r*v.r,1));fa.g=Math.max(0,Math.min(N.color.g*v.g,1));fa.b=Math.max(0,Math.min(N.color.b*v.b,1));fa.updateHex();Ta(ta,Da,ca,ua, da,sa,na,ra);N.wireframe?F(fa,N.wireframeLinewidth,N.wireframeLinecap,N.wireframeLinejoin):$(fa)}else{Ta(ta,Da,ca,ua,da,sa,na,ra);N.wireframe?F(N.color,N.wireframeLinewidth,N.wireframeLinecap,N.wireframeLinejoin):$(N.color)}else if(N instanceof THREE.MeshNormalMaterial){fa.r=Va(ma.normalWorld.x);fa.g=Va(ma.normalWorld.y);fa.b=Va(ma.normalWorld.z);fa.updateHex();Ta(ta,Da,ca,ua,da,sa,na,ra);N.wireframe?F(fa,N.wireframeLinewidth,N.wireframeLinecap,N.wireframeLinejoin):$(fa)}else if(N instanceof THREE.MeshDepthMaterial){L= Ka.near;Z=Ka.far;xa.r=xa.g=xa.b=1-gb(R.positionScreen.z,L,Z);Ma.r=Ma.g=Ma.b=1-gb(pa.positionScreen.z,L,Z);Qa.r=Qa.g=Qa.b=1-gb(qa.positionScreen.z,L,Z);Ua.r=Ua.g=Ua.b=1-gb(va.positionScreen.z,L,Z);ja=cb(xa,Ma,Qa,Ua);Ea(ta,Da,ca,ua,na,ra);w(ta,Da,ca,ua,na,ra,ja,0,0,1,0,0,1);Ea(oa,ea,da,sa,Aa,Oa);w(oa,ea,da,sa,Aa,Oa,ja,1,0,1,1,0,1)}}}function Ea(R,pa,va,qa,Ia,wa){u.beginPath();u.moveTo(R,pa);u.lineTo(va,qa);u.lineTo(Ia,wa);u.lineTo(R,pa);u.closePath()}function Ta(R,pa,va,qa,Ia,wa,ma,N){u.beginPath(); u.moveTo(R,pa);u.lineTo(va,qa);u.lineTo(Ia,wa);u.lineTo(ma,N);u.lineTo(R,pa);u.closePath()}function F(R,pa,va,qa){if(O!=pa)u.lineWidth=O=pa;if(Q!=va)u.lineCap=Q=va;if(ya!=qa)u.lineJoin=ya=qa;f(R);u.stroke();D.inflate(pa*2)}function $(R){g(R);u.fill()}function w(R,pa,va,qa,Ia,wa,ma,N,za,Ra,Pa,ib,eb){var Za,$a;Za=ma.width-1;$a=ma.height-1;N*=Za;za*=$a;Ra*=Za;Pa*=$a;ib*=Za;eb*=$a;va-=R;qa-=pa;Ia-=R;wa-=pa;Ra-=N;Pa-=za;ib-=N;eb-=za;Za=Ra*eb-ib*Pa;if(Za!=0){$a=1/Za;Za=(eb*va-Pa*Ia)*$a;Pa=(eb*qa-Pa*wa)* $a;va=(Ra*Ia-ib*va)*$a;qa=(Ra*wa-ib*qa)*$a;R=R-Za*N-va*za;pa=pa-Pa*N-qa*za;u.save();u.transform(Za,Pa,va,qa,R,pa);u.clip();u.drawImage(ma,0,0);u.restore()}}function cb(R,pa,va,qa){var Ia=~~(R.r*255),wa=~~(R.g*255);R=~~(R.b*255);var ma=~~(pa.r*255),N=~~(pa.g*255);pa=~~(pa.b*255);var za=~~(va.r*255),Ra=~~(va.g*255);va=~~(va.b*255);var Pa=~~(qa.r*255),ib=~~(qa.g*255);qa=~~(qa.b*255);K[0]=Ia<0?0:Ia>255?255:Ia;K[1]=wa<0?0:wa>255?255:wa;K[2]=R<0?0:R>255?255:R;K[4]=ma<0?0:ma>255?255:ma;K[5]=N<0?0:N>255? 255:N;K[6]=pa<0?0:pa>255?255:pa;K[8]=za<0?0:za>255?255:za;K[9]=Ra<0?0:Ra>255?255:Ra;K[10]=va<0?0:va>255?255:va;K[12]=Pa<0?0:Pa>255?255:Pa;K[13]=ib<0?0:ib>255?255:ib;K[14]=qa<0?0:qa>255?255:qa;Y.putImageData(B,0,0);ia.drawImage(U,0,0);return W}function gb(R,pa,va){R=(R-pa)/(va-pa);return R*R*(3-2*R)}function Va(R){R=(R+1)*0.5;return R<0?0:R>1?1:R}function Wa(R,pa){var va=pa.x-R.x,qa=pa.y-R.y,Ia=1/Math.sqrt(va*va+qa*qa);va*=Ia;qa*=Ia;pa.x+=va;pa.y+=qa;R.x-=va;R.y-=qa}var jb,mb,Fa,Xa,Sa,ab,Ya,P;this.autoClear? this.clear():u.setTransform(1,0,0,-1,y,t);j.data.vertices=0;j.data.faces=0;k=m.projectScene(V,Ka,this.sortElements);(z=V.lights.length>0)&&Ba(V);jb=0;for(mb=k.length;jb0){na.r+=ea.color.r*Aa;na.g+=ea.color.g*Aa;na.b+=ea.color.b*Aa}}else if(ea instanceof THREE.PointLight){ha.sub(ea.position,sa.centroidWorld);ha.normalize();Aa=sa.normalWorld.dot(ha)*ea.intensity;if(Aa>0){na.r+=ea.color.r*Aa;na.g+=ea.color.g*Aa;na.b+=ea.color.b*Aa}}}}function d(da,sa, na,ra,oa,ea){j.data.vertices+=3;j.data.faces++;ta=f(Da++);ta.setAttribute("d","M "+da.positionScreen.x+" "+da.positionScreen.y+" L "+sa.positionScreen.x+" "+sa.positionScreen.y+" L "+na.positionScreen.x+","+na.positionScreen.y+"z");if(oa instanceof THREE.MeshBasicMaterial)O.hex=oa.color.hex;else if(oa instanceof THREE.MeshLambertMaterial)if(T){Q.r=ya.r;Q.g=ya.g;Q.b=ya.b;b(ea,ra,Q);O.r=Math.max(0,Math.min(oa.color.r*Q.r,1));O.g=Math.max(0,Math.min(oa.color.g*Q.g,1));O.b=Math.max(0,Math.min(oa.color.b* Q.b,1));O.updateHex()}else O.hex=oa.color.hex;else if(oa instanceof THREE.MeshDepthMaterial){X=1-oa.__2near/(oa.__farPlusNear-ra.z*oa.__farMinusNear);O.setRGB(X,X,X)}else oa instanceof THREE.MeshNormalMaterial&&O.setRGB(g(ra.normalWorld.x),g(ra.normalWorld.y),g(ra.normalWorld.z));oa.wireframe?ta.setAttribute("style","fill: none; stroke: #"+h(O.hex.toString(16))+"; stroke-width: "+oa.wireframeLinewidth+"; stroke-opacity: "+oa.opacity+"; stroke-linecap: "+oa.wireframeLinecap+"; stroke-linejoin: "+oa.wireframeLinejoin): ta.setAttribute("style","fill: #"+h(O.hex.toString(16))+"; fill-opacity: "+oa.opacity);o.appendChild(ta)}function c(da,sa,na,ra,oa,ea,Aa){j.data.vertices+=4;j.data.faces++;ta=f(Da++);ta.setAttribute("d","M "+da.positionScreen.x+" "+da.positionScreen.y+" L "+sa.positionScreen.x+" "+sa.positionScreen.y+" L "+na.positionScreen.x+","+na.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+"z");if(ea instanceof THREE.MeshBasicMaterial)O.hex=ea.color.hex;else if(ea instanceof THREE.MeshLambertMaterial)if(T){Q.r= ya.r;Q.g=ya.g;Q.b=ya.b;b(Aa,oa,Q);O.r=Math.max(0,Math.min(ea.color.r*Q.r,1));O.g=Math.max(0,Math.min(ea.color.g*Q.g,1));O.b=Math.max(0,Math.min(ea.color.b*Q.b,1));O.updateHex()}else O.hex=ea.color.hex;else if(ea instanceof THREE.MeshDepthMaterial){X=1-ea.__2near/(ea.__farPlusNear-oa.z*ea.__farMinusNear);O.setRGB(X,X,X)}else ea instanceof THREE.MeshNormalMaterial&&O.setRGB(g(oa.normalWorld.x),g(oa.normalWorld.y),g(oa.normalWorld.z));ea.wireframe?ta.setAttribute("style","fill: none; stroke: #"+h(O.hex.toString(16))+ "; stroke-width: "+ea.wireframeLinewidth+"; stroke-opacity: "+ea.opacity+"; stroke-linecap: "+ea.wireframeLinecap+"; stroke-linejoin: "+ea.wireframeLinejoin):ta.setAttribute("style","fill: #"+h(O.hex.toString(16))+"; fill-opacity: "+ea.opacity);o.appendChild(ta)}function f(da){if(e[da]==null){e[da]=document.createElementNS("http://www.w3.org/2000/svg","path");ua==0&&e[da].setAttribute("shape-rendering","crispEdges")}return e[da]}function g(da){da=(da+1)*0.5;return da<0?0:da>1?1:da}function h(da){for(;da.length< 6;)da="0"+da;return da}var j=this,k=null,m=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,x,y,t,u,I,H,C,S=new THREE.Rectangle,E=new THREE.Rectangle,T=!1,O=new THREE.Color(16777215),Q=new THREE.Color(16777215),ya=new THREE.Color(0),aa=new THREE.Color(0),ga=new THREE.Color(0),X,ha=new THREE.Vector3,e=[],Ja=[],ta,Da,ca,ua=1;this.domElement=o;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data={vertices:0,faces:0};this.setQuality=function(da){switch(da){case "high":ua= 1;break;case "low":ua=0}};this.setSize=function(da,sa){p=da;x=sa;y=p/2;t=x/2;o.setAttribute("viewBox",-y+" "+-t+" "+p+" "+x);o.setAttribute("width",p);o.setAttribute("height",x);S.set(-y,-t,y,t)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=function(da,sa){var na,ra,oa,ea,Aa,Oa,fa,xa;this.autoClear&&this.clear();j.data.vertices=0;j.data.faces=0;k=m.projectScene(da,sa,this.sortElements);ca=Da=0;if(T=da.lights.length>0){fa=da.lights;ya.setRGB(0,0,0); aa.setRGB(0,0,0);ga.setRGB(0,0,0);na=0;for(ra=fa.length;na 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec4 vPointLight[ 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 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nfloat pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;\n#ifdef PHONG\nvPointLight[ i ] = vec4( lVector, lDistance );\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 vec4 vPointLight[ 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( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + vViewPosition );\nfloat pointDistance = vPointLight[ i ].w;\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 * pointDistance;\npointSpecular += mSpecular * pointSpecularWeight * pointDistance;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;", color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#endif", morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInfluences[ 8 ];\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0, 0.0, 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif", default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"};THREE.UniformsUtils={merge:function(b){var d,c,f,g={};for(d=0;d=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglVertexBuffer);e.vertexAttribPointer(n.position,3,e.FLOAT,!1,0,0)}else{D=v.program.attributes;if(M.morphTargetBase!==-1){e.bindBuffer(e.ARRAY_BUFFER,A.__webglMorphTargetsBuffers[M.morphTargetBase]); e.vertexAttribPointer(D.position,3,e.FLOAT,!1,0,0)}else if(D.position>=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglVertexBuffer);e.vertexAttribPointer(D.position,3,e.FLOAT,!1,0,0)}if(M.morphTargetForcedOrder.length){z=0;for(var G=M.morphTargetForcedOrder,U=M.morphTargetInfluences;zY){B=K;Y=U[B]}e.bindBuffer(e.ARRAY_BUFFER,A.__webglMorphTargetsBuffers[B]);e.vertexAttribPointer(D["morphTarget"+z],3,e.FLOAT,!1,0,0);M.__webglMorphTargetInfluences[z]=Y;G[B]=1;Y=-1;z++}}v.program.uniforms.morphTargetInfluences!==null&&e.uniform1fv(v.program.uniforms.morphTargetInfluences,M.__webglMorphTargetInfluences)}if(v.attributes)for(J in v.attributes)if(n[J]!== undefined&&n[J]>=0){D=v.attributes[J];if(D.buffer){e.bindBuffer(e.ARRAY_BUFFER,D.buffer);e.vertexAttribPointer(n[J],D.size,e.FLOAT,!1,0,0)}}if(n.color>=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglColorBuffer);e.vertexAttribPointer(n.color,3,e.FLOAT,!1,0,0)}if(n.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglNormalBuffer);e.vertexAttribPointer(n.normal,3,e.FLOAT,!1,0,0)}if(n.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglTangentBuffer);e.vertexAttribPointer(n.tangent,4,e.FLOAT,!1,0,0)}if(n.uv>=0)if(A.__webglUVBuffer){e.bindBuffer(e.ARRAY_BUFFER, A.__webglUVBuffer);e.vertexAttribPointer(n.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(n.uv)}else e.disableVertexAttribArray(n.uv);if(n.uv2>=0)if(A.__webglUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,A.__webglUV2Buffer);e.vertexAttribPointer(n.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(n.uv2)}else e.disableVertexAttribArray(n.uv2);if(v.skinning&&n.skinVertexA>=0&&n.skinVertexB>=0&&n.skinIndex>=0&&n.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglSkinVertexABuffer);e.vertexAttribPointer(n.skinVertexA, 4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,A.__webglSkinVertexBBuffer);e.vertexAttribPointer(n.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,A.__webglSkinIndicesBuffer);e.vertexAttribPointer(n.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,A.__webglSkinWeightsBuffer);e.vertexAttribPointer(n.skinWeight,4,e.FLOAT,!1,0,0)}if(M instanceof THREE.Mesh){if(v.wireframe){e.lineWidth(v.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,A.__webglLineBuffer);e.drawElements(e.LINES, A.__webglLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,A.__webglFaceBuffer);e.drawElements(e.TRIANGLES,A.__webglFaceCount,e.UNSIGNED_SHORT,0)}ha.data.vertices+=A.__webglFaceCount;ha.data.faces+=A.__webglFaceCount/3;ha.data.drawCalls++}else if(M instanceof THREE.Line){M=M.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(v.linewidth);e.drawArrays(M,0,A.__webglLineCount);ha.data.drawCalls++}else if(M instanceof THREE.ParticleSystem){e.drawArrays(e.POINTS,0,A.__webglParticleCount); ha.data.drawCalls++}else if(M instanceof THREE.Ribbon){e.drawArrays(e.TRIANGLE_STRIP,0,A.__webglVertexCount);ha.data.drawCalls++}}}function g(n,D,z){if(!n.__webglVertexBuffer)n.__webglVertexBuffer=e.createBuffer();if(!n.__webglNormalBuffer)n.__webglNormalBuffer=e.createBuffer();if(n.hasPos){e.bindBuffer(e.ARRAY_BUFFER,n.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,n.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(D.attributes.position);e.vertexAttribPointer(D.attributes.position,3,e.FLOAT, !1,0,0)}if(n.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,n.__webglNormalBuffer);if(z==THREE.FlatShading){var v,A,M,J,G,U,Y,B,K,W,ia=n.count*3;for(W=0;W0&&Ka[0]0&&Ka[1]< Aa){e.bindTexture(e.TEXTURE_2D,ka.tempTexture);e.copyTexImage2D(e.TEXTURE_2D,0,e.RGB,Ka[0]-8,Ka[1]-8,16,16,0);e.uniform1i(Ba.renderType,0);e.uniform2fv(Ba.scale,ia);e.uniform3fv(Ba.screenPosition,V);e.disable(e.BLEND);e.enable(e.DEPTH_TEST);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0);e.bindTexture(e.TEXTURE_2D,ka.occlusionTexture);e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,Ka[0]-8,Ka[1]-8,16,16,0);e.uniform1i(Ba.renderType,1);e.disable(e.DEPTH_TEST);e.bindTexture(e.TEXTURE_2D,ka.tempTexture);e.drawElements(e.TRIANGLES, 6,e.UNSIGNED_SHORT,0);z.positionScreen.x=V[0];z.positionScreen.y=V[1];z.positionScreen.z=V[2];z.customUpdateCallback?z.customUpdateCallback(z):z.updateLensFlares();e.uniform1i(Ba.renderType,2);e.enable(e.BLEND);M=0;for(J=z.lensFlares.length;M0.001&&G.scale>0.001){V[0]=G.x;V[1]=G.y;V[2]=G.z;W=G.size*G.scale/Aa;ia[0]=W*Y;ia[1]=W;e.uniform3fv(Ba.screenPosition,V);e.uniform2fv(Ba.scale,ia);e.uniform1f(Ba.rotation,G.rotation);e.uniform1f(Ba.opacity,G.opacity);T(G.blending); Q(G.texture,1);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}}}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(ca)}function H(n,D){n._modelViewMatrix.multiplyToArray(D.matrixWorldInverse,n.matrixWorld,n._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(n._modelViewMatrix).transposeIntoArray(n._normalMatrixArray)}function C(n){var D,z,v,A,M;if(n instanceof THREE.Mesh){z=n.geometry;for(D in z.geometryGroups){v=z.geometryGroups[D];M=!1;for(A in v.__webglCustomAttributes)if(v.__webglCustomAttributes[A].needsUpdate){M= !0;break}if(z.__dirtyVertices||z.__dirtyMorphTargets||z.__dirtyElements||z.__dirtyUvs||z.__dirtyNormals||z.__dirtyColors||z.__dirtyTangents||M){M=n;var J=e.DYNAMIC_DRAW;if(v.__inittedArrays){var G=void 0,U=void 0,Y=void 0,B=void 0;Y=void 0;var K=void 0,W=void 0,ia=void 0,V=void 0,Ka=void 0,Ba=void 0,La=void 0,bb=void 0,kb=void 0,Ca=void 0,Ha=void 0,Ea=void 0,Ta=void 0;W=void 0;ia=void 0;B=void 0;V=void 0;B=void 0;var F=void 0,$=void 0;W=void 0;F=void 0;$=void 0;var w=void 0,cb=void 0;F=void 0;$=void 0; w=void 0;cb=void 0;F=void 0;$=void 0;w=void 0;cb=void 0;F=void 0;$=void 0;w=void 0;B=void 0;V=void 0;K=void 0;Y=void 0;Y=void 0;F=void 0;$=void 0;w=void 0;var gb=void 0,Va=0,Wa=0,jb=0,mb=0,Fa=0,Xa=0,Sa=0,ab=0,Ya=0,P=0,R=0;$=F=0;var pa=v.__vertexArray,va=v.__uvArray,qa=v.__uv2Array,Ia=v.__normalArray,wa=v.__tangentArray,ma=v.__colorArray,N=v.__skinVertexAArray,za=v.__skinVertexBArray,Ra=v.__skinIndexArray,Pa=v.__skinWeightArray,ib=v.__morphTargetsArrays,eb=v.__webglCustomAttributes;w=void 0;var Za= v.__faceArray,$a=v.__lineArray,Bb=v.__needsSmoothNormals;Ba=v.__vertexColorType;Ka=v.__uvType;La=v.__normalType;var db=M.geometry,vb=db.__dirtyVertices,wb=db.__dirtyElements,tb=db.__dirtyUvs,xb=db.__dirtyNormals,yb=db.__dirtyTangents,zb=db.__dirtyColors,Ab=db.__dirtyMorphTargets,pb=db.vertices,Cb=v.faces,Fb=db.faces,Db=db.faceVertexUvs[0],Eb=db.faceVertexUvs[1],qb=db.skinVerticesA,rb=db.skinVerticesB,sb=db.skinIndices,nb=db.skinWeights,ob=M instanceof THREE.ShadowVolume?db.edgeFaces:undefined;morphTargets= db.morphTargets;if(eb)for(gb in eb){eb[gb].offset=0;eb[gb].offsetSrc=0}G=0;for(U=Cb.length;G0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,ma,J)}if(xb){e.bindBuffer(e.ARRAY_BUFFER,v.__webglNormalBuffer);e.bufferData(e.ARRAY_BUFFER,Ia,J)}if(yb&&db.hasTangents){e.bindBuffer(e.ARRAY_BUFFER, v.__webglTangentBuffer);e.bufferData(e.ARRAY_BUFFER,wa,J)}if(tb&&jb>0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglUVBuffer);e.bufferData(e.ARRAY_BUFFER,va,J)}if(tb&&mb>0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglUV2Buffer);e.bufferData(e.ARRAY_BUFFER,qa,J)}if(wb){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,v.__webglFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Za,J);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,v.__webglLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,$a,J)}if(P>0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinVertexABuffer); e.bufferData(e.ARRAY_BUFFER,N,J);e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,za,J);e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,Ra,J);e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,Pa,J)}if(!M.dynamic){delete v.__inittedArrays;delete v.__colorArray;delete v.__normalArray;delete v.__tangentArray;delete v.__uvArray;delete v.__uv2Array;delete v.__faceArray;delete v.__vertexArray;delete v.__lineArray; delete v.__skinVertexAArray;delete v.__skinVertexBArray;delete v.__skinIndexArray;delete v.__skinWeightArray}}}}z.__dirtyVertices=!1;z.__dirtyMorphTargets=!1;z.__dirtyElements=!1;z.__dirtyUvs=!1;z.__dirtyNormals=!1;z.__dirtyTangents=!1;z.__dirtyColors=!1}else if(n instanceof THREE.Ribbon){z=n.geometry;if(z.__dirtyVertices||z.__dirtyColors){n=z;D=e.DYNAMIC_DRAW;Ka=n.vertices;v=n.colors;Ba=Ka.length;M=v.length;La=n.__vertexArray;J=n.__colorArray;bb=n.__dirtyColors;if(n.__dirtyVertices){for(G=0;G65535){B[U].counter+=1;Y=B[U].hash+"_"+B[U].counter;n.geometryGroups[Y]==undefined&&(n.geometryGroups[Y]={faces:[],materials:G,vertices:0,numMorphTargets:K})}n.geometryGroups[Y].faces.push(A);n.geometryGroups[Y].vertices+=J}}function E(n,D,z){n.push({buffer:D,object:z,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function T(n){if(n!=sa){switch(n){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD); e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD);e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}sa=n}}function O(n,D,z){if((z.width&z.width-1)==0&&(z.height&z.height-1)==0){e.texParameteri(n,e.TEXTURE_WRAP_S,X(D.wrapS));e.texParameteri(n, e.TEXTURE_WRAP_T,X(D.wrapT));e.texParameteri(n,e.TEXTURE_MAG_FILTER,X(D.magFilter));e.texParameteri(n,e.TEXTURE_MIN_FILTER,X(D.minFilter));e.generateMipmap(n)}else{e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(n,e.TEXTURE_MAG_FILTER,ga(D.magFilter));e.texParameteri(n,e.TEXTURE_MIN_FILTER,ga(D.minFilter))}}function Q(n,D){if(n.needsUpdate){if(n.__webglTexture)n.__webglTexture=e.deleteTexture(n.__webglTexture);n.__webglTexture= e.createTexture();e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n.image);O(e.TEXTURE_2D,n,n.image);e.bindTexture(e.TEXTURE_2D,null);n.needsUpdate=!1}e.activeTexture(e.TEXTURE0+D);e.bindTexture(e.TEXTURE_2D,n.__webglTexture)}function ya(n){if(n&&!n.__webglFramebuffer){if(n.depthBuffer===undefined)n.depthBuffer=!0;if(n.stencilBuffer===undefined)n.stencilBuffer=!0;n.__webglFramebuffer=e.createFramebuffer();n.__webglRenderbuffer=e.createRenderbuffer(); n.__webglTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,X(n.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,X(n.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,X(n.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,X(n.minFilter));e.texImage2D(e.TEXTURE_2D,0,X(n.format),n.width,n.height,0,X(n.format),X(n.type),null);e.bindRenderbuffer(e.RENDERBUFFER,n.__webglRenderbuffer);e.bindFramebuffer(e.FRAMEBUFFER, n.__webglFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n.__webglTexture,0);if(n.depthBuffer&&!n.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,n.__webglRenderbuffer)}else if(n.depthBuffer&&n.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER, n.__webglRenderbuffer)}else e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,n.width,n.height);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var D,z;if(n){D=n.__webglFramebuffer;z=n.width;n=n.height}else{D=null;z=ea;n=Aa}if(D!=Da){e.bindFramebuffer(e.FRAMEBUFFER,D);e.viewport(ra,oa,z,n);Da=D}}function aa(n,D){var z;if(n=="fragment")z=e.createShader(e.FRAGMENT_SHADER);else n=="vertex"&&(z=e.createShader(e.VERTEX_SHADER));e.shaderSource(z, D);e.compileShader(z);if(!e.getShaderParameter(z,e.COMPILE_STATUS)){console.error(e.getShaderInfoLog(z));console.error(D);return null}return z}function ga(n){switch(n){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;default:return e.LINEAR}}function X(n){switch(n){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST; case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT; case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var ha=this,e,Ja=[],ta=null,Da=null,ca=!0,ua=null,da=null,sa=null,na=null,ra=0,oa=0,ea=0,Aa=0,Oa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4], fa=new THREE.Matrix4,xa=new Float32Array(16),Ma=new Float32Array(16),Qa=new THREE.Vector4,Ua={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};b=b||{};var L=b.canvas!==undefined?b.canvas:document.createElement("canvas"),Z=b.stencil!==undefined?b.stencil:!0,ja=b.antialias!==undefined?b.antialias:!1,la=b.clearColor!==undefined?new THREE.Color(b.clearColor):new THREE.Color(0),Na=b.clearAlpha!==undefined?b.clearAlpha:0;this.data={vertices:0, faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=L;this.autoClear=!0;this.sortObjects=!0;try{if(!(e=L.getContext("experimental-webgl",{antialias:ja,stencil:Z})))throw"Error creating WebGL context.";}catch(fb){console.error(fb)}console.log(navigator.userAgent+" | "+e.getParameter(e.VERSION)+" | "+e.getParameter(e.VENDOR)+" | "+e.getParameter(e.RENDERER)+" | "+e.getParameter(e.SHADING_LANGUAGE_VERSION));e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW); e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);e.clearColor(la.r,la.g,la.b,Na);this.context=e;var hb=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(Z){var Ga={};Ga.vertices=new Float32Array(12);Ga.faces=new Uint16Array(6);Ga.darkness=0.5;Ga.vertices[0]=-20;Ga.vertices[1]=-20;Ga.vertices[2]=-1;Ga.vertices[3]=20;Ga.vertices[4]=-20;Ga.vertices[5]=-1;Ga.vertices[6]=20;Ga.vertices[7]=20;Ga.vertices[8]=-1;Ga.vertices[9]= -20;Ga.vertices[10]=20;Ga.vertices[11]=-1;Ga.faces[0]=0;Ga.faces[1]=1;Ga.faces[2]=2;Ga.faces[3]=0;Ga.faces[4]=2;Ga.faces[5]=3;Ga.vertexBuffer=e.createBuffer();Ga.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,Ga.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,Ga.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,Ga.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ga.faces,e.STATIC_DRAW);Ga.program=e.createProgram();e.attachShader(Ga.program,aa("fragment",THREE.ShaderLib.shadowPost.fragmentShader)); e.attachShader(Ga.program,aa("vertex",THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(Ga.program);Ga.vertexLocation=e.getAttribLocation(Ga.program,"position");Ga.projectionLocation=e.getUniformLocation(Ga.program,"projectionMatrix");Ga.darknessLocation=e.getUniformLocation(Ga.program,"darkness")}var ka={};ka.vertices=new Float32Array(16);ka.faces=new Uint16Array(6);b=0;ka.vertices[b++]=-1;ka.vertices[b++]=-1;ka.vertices[b++]=0;ka.vertices[b++]=0;ka.vertices[b++]=1;ka.vertices[b++]=-1;ka.vertices[b++]= 1;ka.vertices[b++]=0;ka.vertices[b++]=1;ka.vertices[b++]=1;ka.vertices[b++]=1;ka.vertices[b++]=1;ka.vertices[b++]=-1;ka.vertices[b++]=1;ka.vertices[b++]=0;ka.vertices[b++]=1;b=0;ka.faces[b++]=0;ka.faces[b++]=1;ka.faces[b++]=2;ka.faces[b++]=0;ka.faces[b++]=2;ka.faces[b++]=3;ka.vertexBuffer=e.createBuffer();ka.elementBuffer=e.createBuffer();ka.tempTexture=e.createTexture();ka.occlusionTexture=e.createTexture();e.bindBuffer(e.ARRAY_BUFFER,ka.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,ka.vertices,e.STATIC_DRAW); e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,ka.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ka.faces,e.STATIC_DRAW);e.bindTexture(e.TEXTURE_2D,ka.tempTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGB,16,16,0,e.RGB,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);e.bindTexture(e.TEXTURE_2D, ka.occlusionTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,16,16,0,e.RGBA,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);if(e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){ka.hasVertexTexture=!1;ka.program=e.createProgram();e.attachShader(ka.program,aa("fragment",THREE.ShaderLib.lensFlare.fragmentShader)); e.attachShader(ka.program,aa("vertex",THREE.ShaderLib.lensFlare.vertexShader))}else{ka.hasVertexTexture=!0;ka.program=e.createProgram();e.attachShader(ka.program,aa("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader));e.attachShader(ka.program,aa("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader))}e.linkProgram(ka.program);ka.attributes={};ka.uniforms={};ka.attributes.vertex=e.getAttribLocation(ka.program,"position");ka.attributes.uv=e.getAttribLocation(ka.program,"UV");ka.uniforms.renderType= e.getUniformLocation(ka.program,"renderType");ka.uniforms.map=e.getUniformLocation(ka.program,"map");ka.uniforms.occlusionMap=e.getUniformLocation(ka.program,"occlusionMap");ka.uniforms.opacity=e.getUniformLocation(ka.program,"opacity");ka.uniforms.scale=e.getUniformLocation(ka.program,"scale");ka.uniforms.rotation=e.getUniformLocation(ka.program,"rotation");ka.uniforms.screenPosition=e.getUniformLocation(ka.program,"screenPosition");var ub=!1;_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces= new Uint16Array(6);b=0;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]= 2;_sprite.faces[b++]=3;_sprite.vertexBuffer=e.createBuffer();_sprite.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,_sprite.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,_sprite.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,_sprite.faces,e.STATIC_DRAW);_sprite.program=e.createProgram();e.attachShader(_sprite.program,aa("fragment",THREE.ShaderLib.sprite.fragmentShader));e.attachShader(_sprite.program,aa("vertex",THREE.ShaderLib.sprite.vertexShader)); e.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=e.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=e.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=e.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=e.getUniformLocation(_sprite.program,"uvScale");_sprite.uniforms.rotation=e.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=e.getUniformLocation(_sprite.program,"scale"); _sprite.uniforms.alignment=e.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=e.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=e.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=e.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=e.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=e.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix= e.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=e.getUniformLocation(_sprite.program,"projectionMatrix");var lb=!1;this.setSize=function(n,D){L.width=n;L.height=D;this.setViewport(0,0,L.width,L.height)};this.setViewport=function(n,D,z,v){ra=n;oa=D;ea=z;Aa=v;e.viewport(ra,oa,ea,Aa)};this.setScissor=function(n,D,z,v){e.scissor(n,D,z,v)};this.enableScissorTest=function(n){n?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(n){ca= n;e.depthMask(n)};this.setClearColorHex=function(n,D){la.setHex(n);Na=D;e.clearColor(la.r,la.g,la.b,Na)};this.setClearColor=function(n,D){la.copy(n);Na=D;e.clearColor(la.r,la.g,la.b,Na)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(n){Ga.darkness=n};this.getContext=function(){return e};this.initMaterial=function(n,D,z,v){var A,M,J;if(n instanceof THREE.MeshDepthMaterial)J="depth";else if(n instanceof THREE.ShadowVolumeDynamicMaterial)J= "shadowVolumeDynamic";else if(n instanceof THREE.MeshNormalMaterial)J="normal";else if(n instanceof THREE.MeshBasicMaterial)J="basic";else if(n instanceof THREE.MeshLambertMaterial)J="lambert";else if(n instanceof THREE.MeshPhongMaterial)J="phong";else if(n instanceof THREE.LineBasicMaterial)J="basic";else n instanceof THREE.ParticleBasicMaterial&&(J="particle_basic");if(J){var G=THREE.ShaderLib[J];n.uniforms=THREE.UniformsUtils.clone(G.uniforms);n.vertexShader=G.vertexShader;n.fragmentShader=G.fragmentShader}var U, Y,B;U=B=G=0;for(Y=D.length;U=0&&e.enableVertexAttribArray(K.position);K.color>=0&&e.enableVertexAttribArray(K.color); K.normal>=0&&e.enableVertexAttribArray(K.normal);K.tangent>=0&&e.enableVertexAttribArray(K.tangent);if(n.skinning&&K.skinVertexA>=0&&K.skinVertexB>=0&&K.skinIndex>=0&&K.skinWeight>=0){e.enableVertexAttribArray(K.skinVertexA);e.enableVertexAttribArray(K.skinVertexB);e.enableVertexAttribArray(K.skinIndex);e.enableVertexAttribArray(K.skinWeight)}if(n.attributes)for(A in n.attributes)K[A]!==undefined&&K[A]>=0&&e.enableVertexAttribArray(K[A]);if(n.morphTargets){n.numSupportedMorphTargets=0;if(K.morphTarget0>= 0){e.enableVertexAttribArray(K.morphTarget0);n.numSupportedMorphTargets++}if(K.morphTarget1>=0){e.enableVertexAttribArray(K.morphTarget1);n.numSupportedMorphTargets++}if(K.morphTarget2>=0){e.enableVertexAttribArray(K.morphTarget2);n.numSupportedMorphTargets++}if(K.morphTarget3>=0){e.enableVertexAttribArray(K.morphTarget3);n.numSupportedMorphTargets++}if(K.morphTarget4>=0){e.enableVertexAttribArray(K.morphTarget4);n.numSupportedMorphTargets++}if(K.morphTarget5>=0){e.enableVertexAttribArray(K.morphTarget5); n.numSupportedMorphTargets++}if(K.morphTarget6>=0){e.enableVertexAttribArray(K.morphTarget6);n.numSupportedMorphTargets++}if(K.morphTarget7>=0){e.enableVertexAttribArray(K.morphTarget7);n.numSupportedMorphTargets++}v.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);n=0;for(A=this.maxMorphTargets;n0||W.faceVertexUvs.length>0)J.__uvArray=new Float32Array(U*2);if(W.faceUvs.length>1||W.faceVertexUvs.length> 1)J.__uv2Array=new Float32Array(U*2)}if(G.geometry.skinWeights.length&&G.geometry.skinIndices.length){J.__skinVertexAArray=new Float32Array(U*4);J.__skinVertexBArray=new Float32Array(U*4);J.__skinIndexArray=new Float32Array(U*4);J.__skinWeightArray=new Float32Array(U*4)}J.__faceArray=new Uint16Array(V*3+(G.geometry.edgeFaces?G.geometry.edgeFaces.length*6:0));J.__lineArray=new Uint16Array(Ka*2);if(J.numMorphTargets){J.__morphTargetsArrays=[];W=0;for(ia=J.numMorphTargets;W=0;A--){v=z.__webglObjects[A].object;if(D==v){z.__webglObjects.splice(A,1);break}}else if(D instanceof THREE.Sprite)for(A=z.__webglSprites.length- 1;A>=0;A--){v=z.__webglSprites[A];if(D==v){z.__webglSprites.splice(A,1);break}}n.__objectsRemoved.splice(0,1)}D=0;for(z=n.__webglObjects.length;D1&&(c-=1)}d===undefined&&(d={h:0,s:0,v:0});d.h=c;d.s=j;d.v=h;return d}, clamp:function(b,d,c){return bc?c:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; var GeometryUtils={merge:function(b,d){var c=d instanceof THREE.Mesh,f=b.vertices.length,g=c?d.geometry:d,h=b.vertices,j=g.vertices,k=b.faces,m=g.faces,o=b.faceVertexUvs[0];g=g.faceVertexUvs[0];c&&d.matrixAutoUpdate&&d.updateMatrix();for(var p=0,x=j.length;p= 0.0 )\npointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight * pointDiffuseWeight;\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 = specularTex.r * pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight * dirDiffuseWeight;\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&&(h=25);g=(h-1)*0.5;c=Array(h);for(d=f=0;d1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+t);f=f<0?0:1}if(c==="pos"){c=b.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= this.getPrevKeyWith("pos",t,j.index-1).pos;this.points[1]=g;this.points[2]=h;this.points[3]=this.getNextKeyWith("pos",t,k.index+1).pos;f=f*0.33+0.33;g=this.interpolateCatmullRom(this.points,f);c.x=g[0];c.y=g[1];c.z=g[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){f=this.interpolateCatmullRom(this.points,f*1.01);this.target.set(f[0],f[1],f[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();f=Math.atan2(this.target.x,this.target.z);b.rotation.set(0,f,0)}}}else if(c=== "rot")THREE.Quaternion.slerp(g,h,b.quaternion,f);else if(c==="scl"){c=b.scale;c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}}}}if(this.JITCompile&&p[0][o]===undefined){this.hierarchy[0].update(undefined,!0);for(t=0;tb.length-2?h:h+1;c[3]=h>b.length-3?h:h+2;h=b[c[0]];k=b[c[1]];m=b[c[2]];o=b[c[3]];c=g*g;j=g*c;f[0]=this.interpolate(h[0],k[0],m[0],o[0],g,c,j);f[1]=this.interpolate(h[1],k[1],m[1],o[1],g,c,j);f[2]=this.interpolate(h[2],k[2],m[2],o[2],g,c,j);return f}; THREE.Animation.prototype.interpolate=function(b,d,c,f,g,h,j){b=(c-b)*0.5;f=(f-d)*0.5;return(2*(d-c)+b+f)*j+(-3*(d-c)-2*b-f)*h+b*g+d};THREE.Animation.prototype.getNextKeyWith=function(b,d,c){var f=this.data.hierarchy[d].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)c=c0?c:0:c>=0?c:c+f.length;c>=0;c--)if(f[c][b]!==undefined)return f[c];return this.data.hierarchy[d].keys[f.length-1]}; THREE.QuakeCamera=function(b){function d(c,f){return function(){f.apply(c,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(b){if(b.movementSpeed!==undefined)this.movementSpeed= b.movementSpeed;if(b.lookSpeed!==undefined)this.lookSpeed=b.lookSpeed;if(b.noFly!==undefined)this.noFly=b.noFly;if(b.lookVertical!==undefined)this.lookVertical=b.lookVertical;if(b.autoForward!==undefined)this.autoForward=b.autoForward;if(b.activeLook!==undefined)this.activeLook=b.activeLook;if(b.heightSpeed!==undefined)this.heightSpeed=b.heightSpeed;if(b.heightCoef!==undefined)this.heightCoef=b.heightCoef;if(b.heightMin!==undefined)this.heightMin=b.heightMin;if(b.heightMax!==undefined)this.heightMax= b.heightMax;if(b.constrainVertical!==undefined)this.constrainVertical=b.constrainVertical;if(b.verticalMin!==undefined)this.verticalMin=b.verticalMin;if(b.verticalMax!==undefined)this.verticalMax=b.verticalMax;if(b.domElement!==undefined)this.domElement=b.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.freeze=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY= window.innerHeight/2;this.onMouseDown=function(c){c.preventDefault();c.stopPropagation();if(this.activeLook)switch(c.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(c){c.preventDefault();c.stopPropagation();if(this.activeLook)switch(c.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(c){this.mouseX=c.clientX-this.windowHalfX;this.mouseY=c.clientY-this.windowHalfY};this.onKeyDown= function(c){switch(c.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;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(c){switch(c.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(){var c=(new Date).getTime();this.tdiff=(c-this.lastUpdate)/ 1E3;this.lastUpdate=c;if(!this.freeze){this.autoSpeedFactor=this.heightSpeed?this.tdiff*((this.position.ythis.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var f=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(f+this.autoSpeedFactor));this.moveBackward&&this.translateZ(f);this.moveLeft&&this.translateX(-f);this.moveRight&&this.translateX(f);f=this.tdiff*this.lookSpeed; this.activeLook||(f=0);this.lon+=this.mouseX*f;this.lookVertical&&(this.lat-=this.mouseY*f);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;c=this.target.position;var g=this.position;c.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);c.y=g.y+100*Math.cos(this.phi);c.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*f;this.lookVertical&&(this.lat-=this.mouseY*f);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;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;c=this.target.position;g=this.position;c.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);c.y=g.y+100*Math.cos(this.phi);c.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(c){c.preventDefault()},!1);this.domElement.addEventListener("mousemove",d(this, this.onMouseMove),!1);this.domElement.addEventListener("mousedown",d(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",d(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",d(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",d(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype; THREE.QuakeCamera.prototype.translate=function(b,d){this.matrix.rotateAxis(d);if(this.noFly)d.y=0;this.position.addSelf(d.multiplyScalar(b));this.target.position.addSelf(d.multiplyScalar(b))}; THREE.PathCamera=function(b){function d(o,p,x,y){var t={name:x,fps:0.6,length:y,hierarchy:[]},u,I=p.getControlPointsArray(),H=p.getLength(),C=I.length,S=0;u=C-1;p={parent:-1,keys:[]};p.keys[0]={time:0,pos:I[0],rot:[0,0,0,1],scl:[1,1,1]};p.keys[u]={time:y,pos:I[u],rot:[0,0,0,1],scl:[1,1,1]};for(u=1;u=0?y:y+g;y=this.verticalAngleMap.srcRange;t=this.verticalAngleMap.dstRange; var u=t[1]-t[0];this.phi=TWEEN.Easing.Quadratic.EaseInOut(((this.phi-y[0])*(t[1]-t[0])/(y[1]-y[0])+t[0]-t[0])/u)*u+t[0];y=this.horizontalAngleMap.srcRange;t=this.horizontalAngleMap.dstRange;u=t[1]-t[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-y[0])*(t[1]-t[0])/(y[1]-y[0])+t[0]-t[0])/u)*u+t[0];y=this.target.position;y.x=100*Math.sin(this.phi)*Math.cos(this.theta);y.y=100*Math.cos(this.phi);y.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,o,p,x)};this.onMouseMove= function(o){this.mouseX=o.clientX-this.windowHalfX;this.mouseY=o.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){b=new THREE.MeshLambertMaterial({color:30719});var j=new THREE.MeshLambertMaterial({color:65280}),k=new THREE.Cube(10,10,20),m=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(k,b);b=new THREE.Mesh(m,j);b.position.set(0,10, 0);this.animation=d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else{this.animation=d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(o,p){return function(){p.apply(o,arguments)}}(this, this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; THREE.FlyCamera=function(b){function d(c,f){return function(){f.apply(c,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.005;this.dragToLook=!1;this.autoForward=!1;this.domElement=document;if(b){if(b.movementSpeed!==undefined)this.movementSpeed=b.movementSpeed;if(b.rollSpeed!==undefined)this.rollSpeed=b.rollSpeed;if(b.dragToLook!==undefined)this.dragToLook=b.dragToLook;if(b.autoForward!==undefined)this.autoForward= b.autoForward;if(b.domElement!==undefined)this.domElement=b.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=-1;this.tdiff=0;this.handleEvent=function(c){if(typeof this[c.type]=="function")this[c.type](c)};this.keydown=function(c){if(!c.altKey){switch(c.keyCode){case 16:this.movementSpeedMultiplier= 0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}}; this.keyup=function(c){switch(c.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break; case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(c){c.preventDefault();c.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(c.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(c){if(!this.dragToLook||this.mouseStatus>0){var f=this.getContainerDimensions(),g=f.size[0]/2,h=f.size[1]/2;this.moveState.yawLeft=-(c.clientX-f.offset[0]-g)/g;this.moveState.pitchDown=(c.clientY- f.offset[1]-h)/h;this.updateRotationVector()}};this.mouseup=function(c){c.preventDefault();c.stopPropagation();if(this.dragToLook){this.mouseStatus--;this.moveState.yawLeft=this.moveState.pitchDown=0}else switch(c.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var c=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=c;this.tdiff=(c-this.lastUpdate)/1E3;this.lastUpdate=c;c=this.tdiff*this.movementSpeed;var f=this.tdiff* this.rollSpeed;this.translateX(this.moveVector.x*c);this.translateY(this.moveVector.y*c);this.translateZ(this.moveVector.z*c);this.tmpQuaternion.set(this.rotationVector.x*f,this.rotationVector.y*f,this.rotationVector.z*f,1).normalize();this.quaternion.multiplySelf(this.tmpQuaternion);this.matrix.setPosition(this.position);this.matrix.setRotationFromQuaternion(this.quaternion);this.matrixWorldNeedsUpdate=!0;this.supr.update.call(this)};this.updateMovementVector=function(){var c=this.moveState.forward|| this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-c+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!= document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",d(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",d(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",d(this,this.mouseup),!1);window.addEventListener("keydown",d(this,this.keydown),!1);window.addEventListener("keyup",d(this, this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};THREE.FlyCamera.prototype=new THREE.Camera;THREE.FlyCamera.prototype.constructor=THREE.FlyCamera;THREE.FlyCamera.prototype.supr=THREE.Camera.prototype; THREE.RollCamera=function(b,d,c,f){THREE.Camera.call(this,b,d,c,f);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.useTarget=!1;this.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var g=new THREE.Vector3,h=new THREE.Vector3,j=new THREE.Vector3,k=new THREE.Matrix4,m=!1,o=1,p=0,x=0,y=0,t=0,u=0,I=window.innerWidth/2,H=window.innerHeight/2;this.update= function(){var C=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=C;this.delta=(C-this.lastUpdate)/1E3;this.lastUpdate=C;if(this.mouseLook){C=this.delta*this.lookSpeed;this.rotateHorizontally(C*t);this.rotateVertically(C*u)}C=this.delta*this.movementSpeed;this.translateZ(C*(p>0||this.autoForward&&!(p<0)?1:p));this.translateX(C*x);this.translateY(C*y);m&&(this.roll+=this.rollSpeed*this.delta*o);if(this.forward.y>this.constrainVertical[1]){this.forward.y=this.constrainVertical[1];this.forward.normalize()}else if(this.forward.y< this.constrainVertical[0]){this.forward.y=this.constrainVertical[0];this.forward.normalize()}j.copy(this.forward);h.set(0,1,0);g.cross(h,j).normalize();h.cross(j,g).normalize();this.matrix.n11=g.x;this.matrix.n12=h.x;this.matrix.n13=j.x;this.matrix.n21=g.y;this.matrix.n22=h.y;this.matrix.n23=j.y;this.matrix.n31=g.z;this.matrix.n32=h.z;this.matrix.n33=j.z;k.identity();k.n11=Math.cos(this.roll);k.n12=-Math.sin(this.roll);k.n21=Math.sin(this.roll);k.n22=Math.cos(this.roll);this.matrix.multiplySelf(k); this.matrixWorldNeedsUpdate=!0;this.matrix.n14=this.position.x;this.matrix.n24=this.position.y;this.matrix.n34=this.position.z;this.supr.update.call(this)};this.translateX=function(C){this.position.x+=this.matrix.n11*C;this.position.y+=this.matrix.n21*C;this.position.z+=this.matrix.n31*C};this.translateY=function(C){this.position.x+=this.matrix.n12*C;this.position.y+=this.matrix.n22*C;this.position.z+=this.matrix.n32*C};this.translateZ=function(C){this.position.x-=this.matrix.n13*C;this.position.y-= this.matrix.n23*C;this.position.z-=this.matrix.n33*C};this.rotateHorizontally=function(C){g.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);g.multiplyScalar(C);this.forward.subSelf(g);this.forward.normalize()};this.rotateVertically=function(C){h.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);h.multiplyScalar(C);this.forward.addSelf(h);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(C){C.preventDefault()},!1);this.domElement.addEventListener("mousemove", function(C){t=(C.clientX-I)/window.innerWidth;u=(C.clientY-H)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(C){C.preventDefault();C.stopPropagation();switch(C.button){case 0:p=1;break;case 2:p=-1}},!1);this.domElement.addEventListener("mouseup",function(C){C.preventDefault();C.stopPropagation();switch(C.button){case 0:p=0;break;case 2:p=0}},!1);this.domElement.addEventListener("keydown",function(C){switch(C.keyCode){case 38:case 87:p=1;break;case 37:case 65:x=-1;break; case 40:case 83:p=-1;break;case 39:case 68:x=1;break;case 81:m=!0;o=1;break;case 69:m=!0;o=-1;break;case 82:y=1;break;case 70:y=-1}},!1);this.domElement.addEventListener("keyup",function(C){switch(C.keyCode){case 38:case 87:p=0;break;case 37:case 65:x=0;break;case 40:case 83:p=0;break;case 39:case 68:x=0;break;case 81:m=!1;break;case 69:m=!1;break;case 82:y=0;break;case 70:y=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera; THREE.RollCamera.prototype.supr=THREE.Camera.prototype; THREE.Cube=function(b,d,c,f,g,h,j,k,m){function o(H,C,S,E,T,O,Q,ya){var aa,ga,X=f||1,ha=g||1,e=T/2,Ja=O/2,ta=p.vertices.length;if(H=="x"&&C=="y"||H=="y"&&C=="x")aa="z";else if(H=="x"&&C=="z"||H=="z"&&C=="x"){aa="y";ha=h||1}else if(H=="z"&&C=="y"||H=="y"&&C=="z"){aa="x";X=h||1}var Da=X+1,ca=ha+1;T/=X;var ua=O/ha;for(ga=0;ga0){j(0,0,-p-(h||0));for(m=b;m0){j(0,0,p+(g||0)); for(m=b+b/2;m<2*b;m++)k.faces.push(new THREE.Face4(2*b+1,(2*m-2*b+2)%b+b,(2*m-2*b+1)%b+b,(2*m-2*b)%b+b))}m=0;for(b=this.faces.length;m0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,y)))-1);o.push(p)}d.push(o)}var t,u,I;g=d.length;for(c=0;c0)for(f=0;f1){t=this.vertices[j].position.clone(); u=this.vertices[m].position.clone();I=this.vertices[o].position.clone();t.normalize();u.normalize();I.normalize();this.faces.push(new THREE.Face3(j,m,o,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(I.x,I.y,I.z)]));this.faceVertexUvs[0].push([p,x,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere; THREE.Torus=function(b,d,c,f){THREE.Geometry.call(this);this.radius=b||100;this.tube=d||40;this.segmentsR=c||8;this.segmentsT=f||6;b=[];for(d=0;d<=this.segmentsR;++d)for(c=0;c<=this.segmentsT;++c){f=c/this.segmentsT*2*Math.PI;var g=d/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(f),(this.radius+this.tube*Math.cos(g))*Math.sin(f),this.tube*Math.sin(g))));b.push([c/this.segmentsT,1-d/this.segmentsR])}for(d=1;d<=this.segmentsR;++d)for(c= 1;c<=this.segmentsT;++c){f=(this.segmentsT+1)*d+c;g=(this.segmentsT+1)*d+c-1;var h=(this.segmentsT+1)*(d-1)+c-1,j=(this.segmentsT+1)*(d-1)+c;this.faces.push(new THREE.Face4(f,g,h,j));this.faceVertexUvs[0].push([new THREE.UV(b[f][0],b[f][1]),new THREE.UV(b[g][0],b[g][1]),new THREE.UV(b[h][0],b[h][1]),new THREE.UV(b[j][0],b[j][1])])}delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus; THREE.TorusKnot=function(b,d,c,f,g,h,j){function k(x,y,t,u,I,H){y=t/u*x;t=Math.cos(y);return new THREE.Vector3(I*(2+t)*0.5*Math.cos(x),I*(2+t)*Math.sin(x)*0.5,H*I*Math.sin(y)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=d||40;this.segmentsR=c||64;this.segmentsT=f||8;this.p=g||2;this.q=h||3;this.heightScale=j||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;f=new THREE.Vector3;h=new THREE.Vector3;for(b=0;b>7)-127;ja|=(Na&127)<<16|la<<8;if(ja==0&&hb==-127)return 0;return(1-2*(fb>>7))*(1+ja*Math.pow(2,-23))*Math.pow(2,hb)}function k(L,Z){var ja=p(L,Z),la=p(L,Z+1),Na=p(L,Z+2);return(p(L,Z+3)<<24)+(Na<<16)+(la<<8)+ja}function m(L,Z){var ja=p(L,Z);return(p(L,Z+1)<<8)+ja}function o(L,Z){var ja=p(L,Z);return ja> 127?ja-256:ja}function p(L,Z){return L.charCodeAt(Z)&255}function x(L){var Z,ja,la;Z=k(b,L);ja=k(b,L+Q);la=k(b,L+ya);L=m(b,L+aa);THREE.BinaryLoader.prototype.f3(C,Z,ja,la,L)}function y(L){var Z,ja,la,Na,fb,hb;Z=k(b,L);ja=k(b,L+Q);la=k(b,L+ya);Na=m(b,L+aa);fb=k(b,L+ga);hb=k(b,L+X);L=k(b,L+ha);THREE.BinaryLoader.prototype.f3n(C,T,Z,ja,la,Na,fb,hb,L)}function t(L){var Z,ja,la,Na;Z=k(b,L);ja=k(b,L+e);la=k(b,L+Ja);Na=k(b,L+ta);L=m(b,L+Da);THREE.BinaryLoader.prototype.f4(C,Z,ja,la,Na,L)}function u(L){var Z, ja,la,Na,fb,hb,Ga,ka;Z=k(b,L);ja=k(b,L+e);la=k(b,L+Ja);Na=k(b,L+ta);fb=m(b,L+Da);hb=k(b,L+ca);Ga=k(b,L+ua);ka=k(b,L+da);L=k(b,L+sa);THREE.BinaryLoader.prototype.f4n(C,T,Z,ja,la,Na,fb,hb,Ga,ka,L)}function I(L){var Z,ja;Z=k(b,L);ja=k(b,L+na);L=k(b,L+ra);THREE.BinaryLoader.prototype.uv3(C.faceVertexUvs[0],O[Z*2],O[Z*2+1],O[ja*2],O[ja*2+1],O[L*2],O[L*2+1])}function H(L){var Z,ja,la;Z=k(b,L);ja=k(b,L+oa);la=k(b,L+ea);L=k(b,L+Aa);THREE.BinaryLoader.prototype.uv4(C.faceVertexUvs[0],O[Z*2],O[Z*2+1],O[ja* 2],O[ja*2+1],O[la*2],O[la*2+1],O[L*2],O[L*2+1])}var C=this,S=0,E,T=[],O=[],Q,ya,aa,ga,X,ha,e,Ja,ta,Da,ca,ua,da,sa,na,ra,oa,ea,Aa,Oa,fa,xa,Ma,Qa,Ua;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(C,f,h);E={signature:b.substr(S,8),header_bytes:p(b,S+8),vertex_coordinate_bytes:p(b,S+9),normal_coordinate_bytes:p(b,S+10),uv_coordinate_bytes:p(b,S+11),vertex_index_bytes:p(b,S+12),normal_index_bytes:p(b,S+13),uv_index_bytes:p(b,S+14),material_index_bytes:p(b,S+15),nvertices:k(b,S+16),nnormals:k(b, S+16+4),nuvs:k(b,S+16+8),ntri_flat:k(b,S+16+12),ntri_smooth:k(b,S+16+16),ntri_flat_uv:k(b,S+16+20),ntri_smooth_uv:k(b,S+16+24),nquad_flat:k(b,S+16+28),nquad_smooth:k(b,S+16+32),nquad_flat_uv:k(b,S+16+36),nquad_smooth_uv:k(b,S+16+40)};S+=E.header_bytes;Q=E.vertex_index_bytes;ya=E.vertex_index_bytes*2;aa=E.vertex_index_bytes*3;ga=E.vertex_index_bytes*3+E.material_index_bytes;X=E.vertex_index_bytes*3+E.material_index_bytes+E.normal_index_bytes;ha=E.vertex_index_bytes*3+E.material_index_bytes+E.normal_index_bytes* 2;e=E.vertex_index_bytes;Ja=E.vertex_index_bytes*2;ta=E.vertex_index_bytes*3;Da=E.vertex_index_bytes*4;ca=E.vertex_index_bytes*4+E.material_index_bytes;ua=E.vertex_index_bytes*4+E.material_index_bytes+E.normal_index_bytes;da=E.vertex_index_bytes*4+E.material_index_bytes+E.normal_index_bytes*2;sa=E.vertex_index_bytes*4+E.material_index_bytes+E.normal_index_bytes*3;na=E.uv_index_bytes;ra=E.uv_index_bytes*2;oa=E.uv_index_bytes;ea=E.uv_index_bytes*2;Aa=E.uv_index_bytes*3;h=E.vertex_index_bytes*3+E.material_index_bytes; Ua=E.vertex_index_bytes*4+E.material_index_bytes;Oa=E.ntri_flat*h;fa=E.ntri_smooth*(h+E.normal_index_bytes*3);xa=E.ntri_flat_uv*(h+E.uv_index_bytes*3);Ma=E.ntri_smooth_uv*(h+E.normal_index_bytes*3+E.uv_index_bytes*3);Qa=E.nquad_flat*Ua;h=E.nquad_smooth*(Ua+E.normal_index_bytes*4);Ua=E.nquad_flat_uv*(Ua+E.uv_index_bytes*4);S+=function(L){for(var Z,ja,la,Na=E.vertex_coordinate_bytes*3,fb=L+E.nvertices*Na;L1&&(ga=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(Q,ga);object.name=t;object.position.set(E[0],E[1],E[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=S.visible;ca.scene.addObject(object);ca.objects[t]=object;if(S.meshCollider){var na=THREE.CollisionUtils.MeshColliderWBox(object);ca.scene.collisions.colliders.push(na)}if(S.castsShadow){na= new THREE.ShadowVolume(Q);ca.scene.addChild(na);na.position=object.position;na.rotation=object.rotation;na.scale=object.scale}if(S.trigger&&S.trigger.toLowerCase()!="none"){na={type:S.trigger,object:S};ca.triggers[object.name]=na}}}else{E=S.position;r=S.rotation;q=S.quaternion;s=S.scale;q=0;object=new THREE.Object3D;object.name=t;object.position.set(E[0],E[1],E[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0], s[1],s[2]);object.visible=S.visible!==undefined?S.visible:!1;ca.scene.addObject(object);ca.objects[t]=object;ca.empties[t]=object;if(S.trigger&&S.trigger.toLowerCase()!="none"){na={type:S.trigger,object:S};ca.triggers[object.name]=na}}}}function m(na){return function(ra){ca.geometries[na]=ra;k();e-=1;c.onLoadComplete();p()}}function o(na){return function(ra){ca.geometries[na]=ra}}function p(){c.callbackProgress({totalModels:ta,totalTextures:Da,loadedModels:ta-e,loadedTextures:Da-Ja},ca);c.onLoadProgress(); e==0&&Ja==0&&d(ca)}var x,y,t,u,I,H,C,S,E,T,O,Q,ya,aa,ga,X,ha,e,Ja,ta,Da,ca;X=h.data;h=new THREE.BinaryLoader;ha=new THREE.JSONLoader;Ja=e=0;ca={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};var ua=!1;for(t in X.objects){S=X.objects[t];if(S.meshCollider){ua=!0;break}}if(ua)ca.scene.collisions=new THREE.CollisionSystem;if(X.transform){ua=X.transform.position;T=X.transform.rotation;var da=X.transform.scale;ua&&ca.scene.position.set(ua[0], ua[1],ua[2]);T&&ca.scene.rotation.set(T[0],T[1],T[2]);da&&ca.scene.scale.set(da[0],da[1],da[2]);(ua||T||da)&&ca.scene.updateMatrix()}ua=function(){Ja-=1;p();c.onLoadComplete()};for(I in X.cameras){T=X.cameras[I];if(T.type=="perspective")ya=new THREE.Camera(T.fov,T.aspect,T.near,T.far);else if(T.type=="ortho"){ya=new THREE.Camera;ya.projectionMatrix=THREE.Matrix4.makeOrtho(T.left,T.right,T.top,T.bottom,T.near,T.far)}E=T.position;T=T.target;ya.position.set(E[0],E[1],E[2]);ya.target.position.set(T[0], T[1],T[2]);ca.cameras[I]=ya}for(u in X.lights){I=X.lights[u];ya=I.color!==undefined?I.color:16777215;T=I.intensity!==undefined?I.intensity:1;if(I.type=="directional"){E=I.direction;light=new THREE.DirectionalLight(ya,T);light.position.set(E[0],E[1],E[2]);light.position.normalize()}else if(I.type=="point"){E=I.position;light=new THREE.PointLight(ya,T);light.position.set(E[0],E[1],E[2])}ca.scene.addLight(light);ca.lights[u]=light}for(H in X.fogs){u=X.fogs[H];if(u.type=="linear")aa=new THREE.Fog(0,u.near, u.far);else u.type=="exp2"&&(aa=new THREE.FogExp2(0,u.density));T=u.color;aa.color.setRGB(T[0],T[1],T[2]);ca.fogs[H]=aa}if(ca.cameras&&X.defaults.camera)ca.currentCamera=ca.cameras[X.defaults.camera];if(ca.fogs&&X.defaults.fog)ca.scene.fog=ca.fogs[X.defaults.fog];T=X.defaults.bgcolor;ca.bgColor=new THREE.Color;ca.bgColor.setRGB(T[0],T[1],T[2]);ca.bgColorAlpha=X.defaults.bgalpha;for(x in X.geometries){H=X.geometries[x];if(H.type=="bin_mesh"||H.type=="ascii_mesh"){e+=1;c.onLoadStart()}}ta=e;for(x in X.geometries){H= X.geometries[x];if(H.type=="cube"){Q=new THREE.Cube(H.width,H.height,H.depth,H.segmentsWidth,H.segmentsHeight,H.segmentsDepth,null,H.flipped,H.sides);ca.geometries[x]=Q}else if(H.type=="plane"){Q=new THREE.Plane(H.width,H.height,H.segmentsWidth,H.segmentsHeight);ca.geometries[x]=Q}else if(H.type=="sphere"){Q=new THREE.Sphere(H.radius,H.segmentsWidth,H.segmentsHeight);ca.geometries[x]=Q}else if(H.type=="cylinder"){Q=new THREE.Cylinder(H.numSegs,H.topRad,H.botRad,H.height,H.topOffset,H.botOffset);ca.geometries[x]= Q}else if(H.type=="torus"){Q=new THREE.Torus(H.radius,H.tube,H.segmentsR,H.segmentsT);ca.geometries[x]=Q}else if(H.type=="icosahedron"){Q=new THREE.Icosahedron(H.subdivisions);ca.geometries[x]=Q}else if(H.type=="bin_mesh")h.load({model:j(H.url,X.urlBaseType),callback:m(x)});else if(H.type=="ascii_mesh")ha.load({model:j(H.url,X.urlBaseType),callback:m(x)});else if(H.type=="embedded_mesh")(H=X.embeds[H.id])&&ha.createModel(H,o(x),"")}for(C in X.textures){x=X.textures[C];if(x.url instanceof Array){Ja+= x.url.length;for(h=0;h=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 f=this.count*3;fthis.size-1&&(m=this.size-1);var y=Math.floor(o-k);y<1&&(y=1);o=Math.floor(o+k);o>this.size-1&&(o= this.size-1);var t=Math.floor(p-k);t<1&&(t=1);k=Math.floor(p+k);k>this.size-1&&(k=this.size-1);for(var u,I,H,C,S,E;x0&&(this.field[H+u]+=C)}}}};this.addPlaneX=function(c,f){var g,h,j,k,m,o=this.size,p=this.yd,x=this.zd,y=this.field,t=o*Math.sqrt(c/f);t>o&&(t=o);for(g=0;g0)for(h=0;hp&&(u=p);for(h=0;h0){m=h*x;for(g=0;gsize&&(dist=size);for(j=0;j0){m=zd*j;for(h=0;hh?this.hits.push(g):this.hits.unshift(g);h=f}}return this.hits}; THREE.CollisionSystem.prototype.rayCastNearest=function(b){var d=this.rayCastAll(b);if(d.length==0)return null;for(var c=0;d[c]instanceof THREE.MeshCollider;){var f=this.rayMesh(b,d[c]);if(f.distd.length)return null;return d[c]}; THREE.CollisionSystem.prototype.rayCast=function(b,d){if(d instanceof THREE.PlaneCollider)return this.rayPlane(b,d);else if(d instanceof THREE.SphereCollider)return this.raySphere(b,d);else if(d instanceof THREE.BoxCollider)return this.rayBox(b,d);else if(d instanceof THREE.MeshCollider&&d.box)return this.rayBox(b,d.box)}; THREE.CollisionSystem.prototype.rayMesh=function(b,d){for(var c=this.makeRayLocal(b,d.mesh),f=Number.MAX_VALUE,g,h=0;h=k*g))return Number.MAX_VALUE;j/=k;k=THREE.CollisionSystem.__v3;k.copy(b.direction);k.multiplyScalar(j);k.addSelf(b.origin);if(Math.abs(h.x)>Math.abs(h.y))if(Math.abs(h.x)>Math.abs(h.z)){b=k.y-d.y;h=c.y- d.y;g=f.y-d.y;k=k.z-d.z;c=c.z-d.z;f=f.z-d.z}else{b=k.x-d.x;h=c.x-d.x;g=f.x-d.x;k=k.y-d.y;c=c.y-d.y;f=f.y-d.y}else if(Math.abs(h.y)>Math.abs(h.z)){b=k.x-d.x;h=c.x-d.x;g=f.x-d.x;k=k.z-d.z;c=c.z-d.z;f=f.z-d.z}else{b=k.x-d.x;h=c.x-d.x;g=f.x-d.x;k=k.y-d.y;c=c.y-d.y;f=f.y-d.y}d=h*f-c*g;if(d==0)return Number.MAX_VALUE;d=1/d;f=(b*f-k*g)*d;if(!(f>=0))return Number.MAX_VALUE;d*=h*k-c*b;if(!(d>=0))return Number.MAX_VALUE;if(!(1-f-d>=0))return Number.MAX_VALUE;return j}; THREE.CollisionSystem.prototype.makeRayLocal=function(b,d){var c=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(d.matrixWorld,c);var f=THREE.CollisionSystem.__r;f.origin.copy(b.origin);f.direction.copy(b.direction);c.multiplyVector3(f.origin);c.rotateAxis(f.direction);f.direction.normalize();return f}; THREE.CollisionSystem.prototype.rayBox=function(b,d){var c;if(d.dynamic&&d.mesh&&d.mesh.matrixWorld)c=this.makeRayLocal(b,d.mesh);else{c=THREE.CollisionSystem.__r;c.origin.copy(b.origin);c.direction.copy(b.direction)}var f=0,g=0,h=0,j=0,k=0,m=0,o=!0;if(c.origin.xd.max.x){f=d.max.x-c.origin.x;f/=c.direction.x;o=!1;j=1}if(c.origin.yd.max.y){g=d.max.y- c.origin.y;g/=c.direction.y;o=!1;k=1}if(c.origin.zd.max.z){h=d.max.z-c.origin.z;h/=c.direction.z;o=!1;m=1}if(o)return-1;o=0;if(g>f){o=1;f=g}if(h>f){o=2;f=h}switch(o){case 0:k=c.origin.y+c.direction.y*f;if(kd.max.y)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*f;if(cd.max.z)return Number.MAX_VALUE;d.normal.set(j,0,0);break;case 1:j=c.origin.x+c.direction.x*f;if(jd.max.x)return Number.MAX_VALUE; c=c.origin.z+c.direction.z*f;if(cd.max.z)return Number.MAX_VALUE;d.normal.set(0,k,0);break;case 2:j=c.origin.x+c.direction.x*f;if(jd.max.x)return Number.MAX_VALUE;k=c.origin.y+c.direction.y*f;if(kd.max.y)return Number.MAX_VALUE;d.normal.set(0,0,m)}return f};THREE.CollisionSystem.prototype.rayPlane=function(b,d){var c=b.direction.dot(d.normal),f=d.point.dot(d.normal);if(c<0)c=(f-b.origin.dot(d.normal))/c;else return Number.MAX_VALUE;return c>0?c:Number.MAX_VALUE}; THREE.CollisionSystem.prototype.raySphere=function(b,d){var c=d.center.clone().subSelf(b.origin);if(c.lengthSq=0)return Math.abs(f)-Math.sqrt(c);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4; THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(b){b.geometry.computeBoundingBox();var d=b.geometry.boundingBox,c=new THREE.Vector3(d.x[0],d.y[0],d.z[0]);d=new THREE.Vector3(d.x[1],d.y[1],d.z[1]);c=new THREE.BoxCollider(c,d);c.mesh=b;return c};THREE.CollisionUtils.MeshAABB=function(b){var d=THREE.CollisionUtils.MeshOBB(b);d.min.addSelf(b.position);d.max.addSelf(b.position);d.dynamic=!1;return d}; THREE.CollisionUtils.MeshColliderWBox=function(b){return new THREE.MeshCollider(b,THREE.CollisionUtils.MeshOBB(b))};