diff --git a/build/Three.js b/build/Three.js index 14bf3259..8c983369 100755 --- a/build/Three.js +++ b/build/Three.js @@ -1,8 +1,7 @@ // Three.js r40 - 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={autoUpdate:!0,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex;this.__styleString=b.__styleString},setRGB:function(b,d,c){this.r=b;this.g=d;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},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.r=f;this.g=g;this.b=h;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(b){this.hex=~~b&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* -255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(b,d){this.set(b||0,d||0)}; +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, @@ -12,21 +11,21 @@ this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPosit 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){var d,c,f=b.objects,g=[];b=0;for(d=f.length;b0&&G>0&&L+G<1}var c,f,g,h,j,k,m,o,t,p, -y,u=b.geometry,z=u.vertices,H=[];c=0;for(f=u.faces.length;c0:t<0)){o=o.dot((new THREE.Vector3).sub(h,p))/ -t;p=p.addSelf(y.multiplyScalar(o));if(g instanceof THREE.Face3){if(d(p,h,j,k)){g={distance:this.origin.distanceTo(p),point:p,face:g,object:b};H.push(g)}}else if(g instanceof THREE.Face4&&(d(p,h,j,m)||d(p,j,k,m))){g={distance:this.origin.distanceTo(p),point:p,face:g,object:b};H.push(g)}}}return H}}; -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,t,p){k=!1;d=m;c=o;f=t;g=p;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,t,p,y,u){if(k){k=!1;d=mt?m>y?m:y:t>y?t:y;g=o>p?o>u?o:u:p>u?p:u}else{d=mt?m>y?m>f?m:f:y>f?y:f:t>y?t>f?t:f:y>f?y:f;g=o>p?o>u?o>g?o:g:u>g?u:g:p>u?p>g?p:g:u>g?u: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()? +THREE.Ray.prototype={intersectScene:function(b){var d,c,f=b.objects,g=[];b=0;for(d=f.length;b0&&F>0&&P+F<1}var c,f,g,h,j,k,m,o,t,u, +w,p=b.geometry,z=p.vertices,G=[];c=0;for(f=p.faces.length;c0:t<0)){o=o.dot((new THREE.Vector3).sub(h,u))/ +t;u=u.addSelf(w.multiplyScalar(o));if(g instanceof THREE.Face3){if(d(u,h,j,k)){g={distance:this.origin.distanceTo(u),point:u,face:g,object:b};G.push(g)}}else if(g instanceof THREE.Face4&&(d(u,h,j,m)||d(u,j,k,m))){g={distance:this.origin.distanceTo(u),point:u,face:g,object:b};G.push(g)}}}return G}}; +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,t,u){k=!1;d=m;c=o;f=t;g=u;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,t,u,w,p){if(k){k=!1;d=mt?m>w?m:w:t>w?t:w;g=o>u?o>p?o:p:u>p?u:p}else{d=mt?m>w?m>f?m:f:w>f?w:f:t>w?t>f?t:f:w>f?w:f;g=o>u?o>p?o>g?o:g:p>g?p:g:u>p?u>g?u:g:p>g?p: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,t,p,y,u,z,H){this.set(b||1,d||0,c||0,f||0,g||0,h||1,j||0,k||0,m||0,o||0,t||1,p||0,y||0,u||0,z||0,H||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,t,p,y,u,z,H){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=t;this.n34=p;this.n41=y;this.n42=u;this.n43=z;this.n44=H;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, +THREE.Matrix4=function(b,d,c,f,g,h,j,k,m,o,t,u,w,p,z,G){this.set(b||1,d||0,c||0,f||0,g||0,h||1,j||0,k||0,m||0,o||0,t||1,u||0,w||0,p||0,z||0,G||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,t,u,w,p,z,G){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=t;this.n34=u;this.n41=w;this.n42=p;this.n43=z;this.n44=G;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(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,t=b.n31,p=b.n32,y=b.n33,u=b.n34,z=b.n41,H=b.n42,G=b.n43,B=b.n44,R=d.n11,E=d.n12,P=d.n13,L=d.n14,O=d.n21,sa=d.n22, -oa=d.n23,ta=d.n24,ha=d.n31,fa=d.n32,e=d.n33,qa=d.n34;this.n11=c*R+f*O+g*ha;this.n12=c*E+f*sa+g*fa;this.n13=c*P+f*oa+g*e;this.n14=c*L+f*ta+g*qa+h;this.n21=j*R+k*O+m*ha;this.n22=j*E+k*sa+m*fa;this.n23=j*P+k*oa+m*e;this.n24=j*L+k*ta+m*qa+o;this.n31=t*R+p*O+y*ha;this.n32=t*E+p*sa+y*fa;this.n33=t*P+p*oa+y*e;this.n34=t*L+p*ta+y*qa+u;this.n41=z*R+H*O+G*ha;this.n42=z*E+H*sa+G*fa;this.n43=z*P+H*oa+G*e;this.n44=z*L+H*ta+G*qa+B;return this},multiplyToArray:function(b,d,c){this.multiply(b,d);c[0]=this.n11;c[1]= +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,t=b.n31,u=b.n32,w=b.n33,p=b.n34,z=b.n41,G=b.n42,F=b.n43,B=b.n44,T=d.n11,C=d.n12,V=d.n13,P=d.n14,Q=d.n21,ka=d.n22, +ea=d.n23,pa=d.n24,aa=d.n31,oa=d.n32,e=d.n33,xa=d.n34;this.n11=c*T+f*Q+g*aa;this.n12=c*C+f*ka+g*oa;this.n13=c*V+f*ea+g*e;this.n14=c*P+f*pa+g*xa+h;this.n21=j*T+k*Q+m*aa;this.n22=j*C+k*ka+m*oa;this.n23=j*V+k*ea+m*e;this.n24=j*P+k*pa+m*xa+o;this.n31=t*T+u*Q+w*aa;this.n32=t*C+u*ka+w*oa;this.n33=t*V+u*ea+w*e;this.n34=t*P+u*pa+w*xa+p;this.n41=z*T+G*Q+F*aa;this.n42=z*C+G*ka+F*oa;this.n43=z*V+G*ea+F*e;this.n44=z*P+G*pa+F*xa+B;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,t=this.n33,p=this.n34,y=this.n41,u=this.n42,z=this.n43,H=this.n44;return f*j*o*y-c*k*o*y-f*h*t*y+d*k*t*y+c*h*p*y-d*j*p*y-f*j*m*u+c*k*m*u+f*g*t*u-b*k*t*u-c*g*p*u+b*j*p*u+f*h*m*z-d*k*m*z-f*g*o*z+b*k*o*z+d*g*p*z-b*h*p*z-c*h*m*H+d*j*m*H+c*g*o*H-b*j*o*H-d*g*t*H+b*h*t*H},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31= +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,t=this.n33,u=this.n34,w=this.n41,p=this.n42,z=this.n43,G=this.n44;return f*j*o*w-c*k*o*w-f*h*t*w+d*k*t*w+c*h*u*w-d*j*u*w-f*j*m*p+c*k*m*p+f*g*t*p-b*k*t*p-c*g*u*p+b*j*u*p+f*h*m*z-d*k*m*z-f*g*o*z+b*k*o*z+d*g*u*z-b*h*u*z-c*h*m*G+d*j*m*G+c*g*o*G-b*j*o*G-d*g*t*G+b*h*t*G},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, @@ -35,9 +34,9 @@ b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=t 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,t=b.n31,p=b.n32,y=b.n33,u=b.n34,z=b.n41,H=b.n42,G=b.n43,B=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=m*u*H-o*y*H+o*p*G-k*u*G-m*p*B+k*y*B;d.n12=h*y*H-g*u*H-h*p*G+f*u*G+g*p*B-f*y*B;d.n13=g*o*H-h*m*H+h*k*G-f*o*G-g*k*B+f*m*B;d.n14=h*m*p-g*o*p-h*k*y+f*o*y+g*k*u-f*m*u;d.n21=o*y*z-m*u*z-o*t*G+j*u*G+m*t*B-j*y*B;d.n22=g*u*z-h*y*z+h*t*G-c*u*G-g*t*B+c*y*B;d.n23=h*m*z-g*o*z-h*j*G+c*o*G+g*j*B-c*m*B; -d.n24=g*o*t-h*m*t+h*j*y-c*o*y-g*j*u+c*m*u;d.n31=k*u*z-o*p*z+o*t*H-j*u*H-k*t*B+j*p*B;d.n32=h*p*z-f*u*z-h*t*H+c*u*H+f*t*B-c*p*B;d.n33=g*o*z-h*k*z+h*j*H-c*o*H-f*j*B+c*k*B;d.n34=h*k*t-f*o*t-h*j*p+c*o*p+f*j*u-c*k*u;d.n41=m*p*z-k*y*z-m*t*H+j*y*H+k*t*G-j*p*G;d.n42=f*y*z-g*p*z+g*t*H-c*y*H-f*t*G+c*p*G;d.n43=g*k*z-f*m*z-g*j*H+c*m*H+f*j*G-c*k*G;d.n44=f*m*t-g*k*t+g*j*p-c*m*p-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,t=-b.n23*b.n11+b.n21*b.n13,p=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*t;c[8]=b*p;return d}; +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,t=b.n31,u=b.n32,w=b.n33,p=b.n34,z=b.n41,G=b.n42,F=b.n43,B=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=m*p*G-o*w*G+o*u*F-k*p*F-m*u*B+k*w*B;d.n12=h*w*G-g*p*G-h*u*F+f*p*F+g*u*B-f*w*B;d.n13=g*o*G-h*m*G+h*k*F-f*o*F-g*k*B+f*m*B;d.n14=h*m*u-g*o*u-h*k*w+f*o*w+g*k*p-f*m*p;d.n21=o*w*z-m*p*z-o*t*F+j*p*F+m*t*B-j*w*B;d.n22=g*p*z-h*w*z+h*t*F-c*p*F-g*t*B+c*w*B;d.n23=h*m*z-g*o*z-h*j*F+c*o*F+g*j*B-c*m*B; +d.n24=g*o*t-h*m*t+h*j*w-c*o*w-g*j*p+c*m*p;d.n31=k*p*z-o*u*z+o*t*G-j*p*G-k*t*B+j*u*B;d.n32=h*u*z-f*p*z-h*t*G+c*p*G+f*t*B-c*u*B;d.n33=g*o*z-h*k*z+h*j*G-c*o*G-f*j*B+c*k*B;d.n34=h*k*t-f*o*t-h*j*u+c*o*u+f*j*p-c*k*p;d.n41=m*u*z-k*w*z-m*t*G+j*w*G+k*t*F-j*u*F;d.n42=f*w*z-g*u*z+g*t*G-c*w*G-f*t*F+c*u*F;d.n43=g*k*z-f*m*z-g*j*G+c*m*G+f*j*F-c*k*F;d.n44=f*m*t-g*k*t+g*j*u-c*m*u-f*j*w+c*k*w;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,t=-b.n23*b.n11+b.n21*b.n13,u=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*t;c[8]=b*u;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.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= @@ -49,8 +48,8 @@ this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matri THREE.Quaternion.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.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var d=0.5*Math.PI/360,c=b.x*d,f=b.y*d,g=b.z*d;b=Math.cos(f);f=Math.sin(f);d=Math.cos(-g);g=Math.sin(-g);var h=Math.cos(c);c=Math.sin(c);var j=b*d,k=f*g;this.w=j*h-k*c;this.x=j*c+k*h;this.y=f*d*h+b*g*c;this.z=b*g*h-f*d*c;return this},setFromAxisAngle:function(b,d){var c=d/2,f=Math.sin(c);this.x=b.x*f;this.y= b.y*f;this.z=b.z*f;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(b==0)this.w=this.z=this.y=this.x=0;else{b=1/b;this.x*=b;this.y*=b;this.z*=b;this.w*=b}return this}, multiplySelf:function(b){var d=this.x,c=this.y,f=this.z,g=this.w,h=b.x,j=b.y,k=b.z;b=b.w;this.x=d*b+g*h+c*k-f*j;this.y=c*b+g*j+f*h-d*k;this.z=f*b+g*k+d*j-c*h;this.w=g*b-d*h-c*j-f*k;return this},multiply:function(b,d){this.x=b.x*d.w+b.y*d.z-b.z*d.y+b.w*d.x;this.y=-b.x*d.z+b.y*d.w+b.z*d.x+b.w*d.y;this.z=b.x*d.y-b.y*d.x+b.z*d.w+b.w*d.z;this.w=-b.x*d.x-b.y*d.y-b.z*d.z+b.w*d.w;return this},multiplyVector3:function(b,d){d||(d=b);var c=b.x,f=b.y,g=b.z,h=this.x,j=this.y,k=this.z,m=this.w,o=m*c+j*g-k*f,t= -m*f+k*c-h*g,p=m*g+h*f-j*c;c=-h*c-j*f-k*g;d.x=o*m+c*-h+t*-k-p*-j;d.y=t*m+c*-j+p*-h-o*-k;d.z=p*m+c*-k+o*-j-t*-h;return d}}; -THREE.Quaternion.slerp=function(b,d,c,f){var g=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(g)>=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.0010){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}; +m*f+k*c-h*g,u=m*g+h*f-j*c;c=-h*c-j*f-k*g;d.x=o*m+c*-h+t*-k-u*-j;d.y=t*m+c*-j+u*-h-o*-k;d.z=u*m+c*-k+o*-j-t*-h;return d}}; +THREE.Quaternion.slerp=function(b,d,c,f){var g=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(g)>=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}; @@ -58,17 +57,17 @@ THREE.Geometry.prototype={computeCentroids:function(){var b,d,c;b=0;for(d=this.f c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(b){var d,c,f,g,h,j,k=new THREE.Vector3,m=new THREE.Vector3;f=0;for(g=this.faces.length;f0){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; +c.vertexNormals[1].copy(f[c.b]);c.vertexNormals[2].copy(f[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(f[c.a]);c.vertexNormals[1].copy(f[c.b]);c.vertexNormals[2].copy(f[c.c]);c.vertexNormals[3].copy(f[c.d])}}},computeTangents:function(){function b(ra,fa,za,na,ua,qa,ja){k=ra.vertices[fa].position;m=ra.vertices[za].position;o=ra.vertices[na].position;t=j[ua];u=j[qa];w=j[ja];p=m.x-k.x;z=o.x-k.x;G=m.y-k.y;F=o.y-k.y;B=m.z-k.z;T=o.z-k.z;C=u.u-t.u;V=w.u-t.u;P=u.v-t.v;Q=w.v-t.v;ka=1/(C* +Q-V*P);oa.set((Q*p-P*z)*ka,(Q*G-P*F)*ka,(Q*B-P*T)*ka);e.set((C*z-V*p)*ka,(C*F-V*G)*ka,(C*T-V*B)*ka);pa[fa].addSelf(oa);pa[za].addSelf(oa);pa[na].addSelf(oa);aa[fa].addSelf(e);aa[za].addSelf(e);aa[na].addSelf(e)}var d,c,f,g,h,j,k,m,o,t,u,w,p,z,G,F,B,T,C,V,P,Q,ka,ea,pa=[],aa=[],oa=new THREE.Vector3,e=new THREE.Vector3,xa=new THREE.Vector3,sa=new THREE.Vector3,Ba=new THREE.Vector3;d=0;for(c=this.vertices.length;d0){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]];t=this.points[c[1]]; -p=this.points[c[2]];y=this.points[c[3]];k=j*j;m=j*k;f.x=d(o.x,t.x,p.x,y.x,j,k,m);f.y=d(o.y,t.y,p.y,y.y,j,k,m);f.z=d(o.z,t.z,p.z,y.z,j,k,m);return f};this.getControlPointsArray=function(){var u,z,H=this.points.length,G=[];for(u=0;uthis.points.length-2?h:h+1;c[3]=h>this.points.length-3?h:h+2;o=this.points[c[0]];t=this.points[c[1]]; +u=this.points[c[2]];w=this.points[c[3]];k=j*j;m=j*k;f.x=d(o.x,t.x,u.x,w.x,j,k,m);f.y=d(o.y,t.y,u.y,w.y,j,k,m);f.z=d(o.z,t.z,u.z,w.z,j,k,m);return f};this.getControlPointsArray=function(){var p,z,G=this.points.length,F=[];for(p=0;p1){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(;fp){c=t;t=p;p=c}}else if(tu){c=y;y=u;u=c}}else if(yu){c=t;t=u;u=c}}else if(tp){c=w;w=p;p=c}}else if(w=0&&ea>=0&&ga>=0&&xa>=0)return!0;else if(Da<0&&ea<0||ga<0&&xa<0)return!1;else{if(Da<0)qa=Math.max(qa,Da/(Da-ea));else ea<0&&(Ea=Math.min(Ea,Da/(Da-ea)));if(ga<0)qa=Math.max(qa,ga/(ga-xa));else xa<0&&(Ea=Math.min(Ea,ga/(ga-xa)));if(EaDa&&j.positionScreen.z0&&L.z<1){Ia=E[R]=E[R]||new THREE.RenderableParticle;R++;B=Ia;B.x=L.x/L.w;B.y=L.y/L.w;B.z=L.z;B.rotation=ia.rotation.z;B.scale.x=ia.scale.x*Math.abs(B.x-(L.x+e.projectionMatrix.n11)/(L.w+e.projectionMatrix.n14));B.scale.y=ia.scale.y*Math.abs(B.y-(L.y+e.projectionMatrix.n22)/(L.w+e.projectionMatrix.n24));B.materials=ia.materials;Ea.push(B)}}}}qa&&Ea.sort(d);return Ea}}; -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,t,p,y,u,z,H;b=d.projectScene(j,k);m=0;for(o=b.length;m>1;Ja=la.height>>1;na=ma.scale.x*o;ua=ma.scale.y*t;$=na*Y;wa=ua*Ja;v.set(X.x-$,X.y-wa,X.x+$,X.y+ -wa);if(C.instersects(v)){p.save();p.translate(X.x,X.y);p.rotate(-ma.rotation);p.scale(na,-ua);p.translate(-Y,-Ja);p.drawImage(la,0,0);p.restore()}}}else if(na instanceof THREE.ParticleCanvasMaterial){$=ma.scale.x*o;wa=ma.scale.y*t;v.set(X.x-$,X.y-wa,X.x+$,X.y+wa);if(C.instersects(v)){c(na.color.__styleString);ua=na.color.__styleString;if(B!=ua)p.fillStyle=B=ua;p.save();p.translate(X.x,X.y);p.rotate(-ma.rotation);p.scale($,wa);na.program(p);p.restore()}}}function Ua(X,ma,na,$){b($.opacity);d($.blending); -p.beginPath();p.moveTo(X.positionScreen.x,X.positionScreen.y);p.lineTo(ma.positionScreen.x,ma.positionScreen.y);p.closePath();if($ instanceof THREE.LineBasicMaterial){pa.__styleString=$.color.__styleString;X=$.linewidth;if(R!=X)p.lineWidth=R=X;X=$.linecap;if(E!=X)p.lineCap=E=X;X=$.linejoin;if(P!=X)p.lineJoin=P=X;c(pa.__styleString);p.stroke();v.inflate($.linewidth*2)}}function F(X,ma,na,$,wa,ua,la,Y,Ja){f.data.vertices+=3;f.data.faces++;b(Y.opacity);d(Y.blending);fa=X.positionScreen.x;e=X.positionScreen.y; -qa=ma.positionScreen.x;Ea=ma.positionScreen.y;Da=na.positionScreen.x;ea=na.positionScreen.y;x(fa,e,qa,Ea,Da,ea);if(Y instanceof THREE.MeshBasicMaterial)if(Y.map){if(Y.map.mapping instanceof THREE.UVMapping){Q=la.uvs[0];Pa(fa,e,qa,Ea,Da,ea,Y.map.image,Q[$].u,Q[$].v,Q[wa].u,Q[wa].v,Q[ua].u,Q[ua].v)}}else if(Y.envMap){if(Y.envMap.mapping instanceof THREE.SphericalReflectionMapping){X=Oa.matrixWorldInverse;D.copy(la.vertexNormalsWorld[0]);aa=(D.x*X.n11+D.y*X.n12+D.z*X.n13)*0.5+0.5;W=-(D.x*X.n21+D.y*X.n22+ -D.z*X.n23)*0.5+0.5;D.copy(la.vertexNormalsWorld[1]);T=(D.x*X.n11+D.y*X.n12+D.z*X.n13)*0.5+0.5;La=-(D.x*X.n21+D.y*X.n22+D.z*X.n23)*0.5+0.5;D.copy(la.vertexNormalsWorld[2]);db=(D.x*X.n11+D.y*X.n12+D.z*X.n13)*0.5+0.5;n=-(D.x*X.n21+D.y*X.n22+D.z*X.n23)*0.5+0.5;Pa(fa,e,qa,Ea,Da,ea,Y.envMap.image,aa,W,T,La,db,n)}}else Y.wireframe?eb(Y.color.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Na(Y.color.__styleString);else if(Y instanceof THREE.MeshLambertMaterial){if(Y.map&&!Y.wireframe){if(Y.map.mapping instanceof -THREE.UVMapping){Q=la.uvs[0];Pa(fa,e,qa,Ea,Da,ea,Y.map.image,Q[$].u,Q[$].v,Q[wa].u,Q[wa].v,Q[ua].u,Q[ua].v)}d(THREE.SubtractiveBlending)}if(A)if(!Y.wireframe&&Y.shading==THREE.SmoothShading&&la.vertexNormalsWorld.length==3){Fa.r=ja.r=ia.r=J.r;Fa.g=ja.g=ia.g=J.g;Fa.b=ja.b=ia.b=J.b;za(Ja,la.v1.positionWorld,la.vertexNormalsWorld[0],Fa);za(Ja,la.v2.positionWorld,la.vertexNormalsWorld[1],ja);za(Ja,la.v3.positionWorld,la.vertexNormalsWorld[2],ia);Ia.r=(ja.r+ia.r)*0.5;Ia.g=(ja.g+ia.g)*0.5;Ia.b=(ja.b+ia.b)* -0.5;Ra=ib(Fa,ja,ia,Ia);Pa(fa,e,qa,Ea,Da,ea,Ra,0,0,1,0,0,1)}else{K.r=J.r;K.g=J.g;K.b=J.b;za(Ja,la.centroidWorld,la.normalWorld,K);pa.r=Y.color.r*K.r;pa.g=Y.color.g*K.g;pa.b=Y.color.b*K.b;pa.updateStyleString();Y.wireframe?eb(pa.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Na(pa.__styleString)}else Y.wireframe?eb(Y.color.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Na(Y.color.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){Ya= -Oa.near;ab=Oa.far;Fa.r=Fa.g=Fa.b=1-fb(X.positionScreen.z,Ya,ab);ja.r=ja.g=ja.b=1-fb(ma.positionScreen.z,Ya,ab);ia.r=ia.g=ia.b=1-fb(na.positionScreen.z,Ya,ab);Ia.r=(ja.r+ia.r)*0.5;Ia.g=(ja.g+ia.g)*0.5;Ia.b=(ja.b+ia.b)*0.5;Ra=ib(Fa,ja,ia,Ia);Pa(fa,e,qa,Ea,Da,ea,Ra,0,0,1,0,0,1)}else if(Y instanceof THREE.MeshNormalMaterial){pa.r=Za(la.normalWorld.x);pa.g=Za(la.normalWorld.y);pa.b=Za(la.normalWorld.z);pa.updateStyleString();Y.wireframe?eb(pa.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin): -Na(pa.__styleString)}}function da(X,ma,na,$,wa,ua,la,Y,Ja){f.data.vertices+=4;f.data.faces++;b(Y.opacity);d(Y.blending);if(Y.map||Y.envMap){F(X,ma,$,0,1,3,la,Y,Ja);F(wa,na,ua,1,2,3,la,Y,Ja)}else{fa=X.positionScreen.x;e=X.positionScreen.y;qa=ma.positionScreen.x;Ea=ma.positionScreen.y;Da=na.positionScreen.x;ea=na.positionScreen.y;ga=$.positionScreen.x;xa=$.positionScreen.y;va=wa.positionScreen.x;ra=wa.positionScreen.y;ca=ua.positionScreen.x;ka=ua.positionScreen.y;if(Y instanceof THREE.MeshBasicMaterial){bb(fa, -e,qa,Ea,Da,ea,ga,xa);Y.wireframe?eb(Y.color.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Na(Y.color.__styleString)}else if(Y instanceof THREE.MeshLambertMaterial)if(A)if(!Y.wireframe&&Y.shading==THREE.SmoothShading&&la.vertexNormalsWorld.length==4){Fa.r=ja.r=ia.r=Ia.r=J.r;Fa.g=ja.g=ia.g=Ia.g=J.g;Fa.b=ja.b=ia.b=Ia.b=J.b;za(Ja,la.v1.positionWorld,la.vertexNormalsWorld[0],Fa);za(Ja,la.v2.positionWorld,la.vertexNormalsWorld[1],ja);za(Ja,la.v4.positionWorld,la.vertexNormalsWorld[3], -ia);za(Ja,la.v3.positionWorld,la.vertexNormalsWorld[2],Ia);Ra=ib(Fa,ja,ia,Ia);x(fa,e,qa,Ea,ga,xa);Pa(fa,e,qa,Ea,ga,xa,Ra,0,0,1,0,0,1);x(va,ra,Da,ea,ca,ka);Pa(va,ra,Da,ea,ca,ka,Ra,1,0,1,1,0,1)}else{K.r=J.r;K.g=J.g;K.b=J.b;za(Ja,la.centroidWorld,la.normalWorld,K);pa.r=Y.color.r*K.r;pa.g=Y.color.g*K.g;pa.b=Y.color.b*K.b;pa.updateStyleString();bb(fa,e,qa,Ea,Da,ea,ga,xa);Y.wireframe?eb(pa.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Na(pa.__styleString)}else{bb(fa,e,qa,Ea, -Da,ea,ga,xa);Y.wireframe?eb(Y.color.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Na(Y.color.__styleString)}else if(Y instanceof THREE.MeshNormalMaterial){pa.r=Za(la.normalWorld.x);pa.g=Za(la.normalWorld.y);pa.b=Za(la.normalWorld.z);pa.updateStyleString();bb(fa,e,qa,Ea,Da,ea,ga,xa);Y.wireframe?eb(pa.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Na(pa.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){Ya=Oa.near;ab=Oa.far;Fa.r=Fa.g= -Fa.b=1-fb(X.positionScreen.z,Ya,ab);ja.r=ja.g=ja.b=1-fb(ma.positionScreen.z,Ya,ab);ia.r=ia.g=ia.b=1-fb($.positionScreen.z,Ya,ab);Ia.r=Ia.g=Ia.b=1-fb(na.positionScreen.z,Ya,ab);Ra=ib(Fa,ja,ia,Ia);x(fa,e,qa,Ea,ga,xa);Pa(fa,e,qa,Ea,ga,xa,Ra,0,0,1,0,0,1);x(va,ra,Da,ea,ca,ka);Pa(va,ra,Da,ea,ca,ka,Ra,1,0,1,1,0,1)}}}function x(X,ma,na,$,wa,ua){p.beginPath();p.moveTo(X,ma);p.lineTo(na,$);p.lineTo(wa,ua);p.lineTo(X,ma);p.closePath()}function bb(X,ma,na,$,wa,ua,la,Y){p.beginPath();p.moveTo(X,ma);p.lineTo(na, -$);p.lineTo(wa,ua);p.lineTo(la,Y);p.lineTo(X,ma);p.closePath()}function eb(X,ma,na,$){if(R!=ma)p.lineWidth=R=ma;if(E!=na)p.lineCap=E=na;if(P!=$)p.lineJoin=P=$;c(X);p.stroke();v.inflate(ma*2)}function Na(X){if(B!=X)p.fillStyle=B=X;p.fill()}function Pa(X,ma,na,$,wa,ua,la,Y,Ja,Va,Ta,jb,Wa){var gb,hb;gb=la.width-1;hb=la.height-1;Y*=gb;Ja*=hb;Va*=gb;Ta*=hb;jb*=gb;Wa*=hb;na-=X;$-=ma;wa-=X;ua-=ma;Va-=Y;Ta-=Ja;jb-=Y;Wa-=Ja;gb=Va*Wa-jb*Ta;if(gb!=0){hb=1/gb;gb=(Wa*na-Ta*wa)*hb;Ta=(Wa*$-Ta*ua)*hb;na=(Va*wa- -jb*na)*hb;$=(Va*ua-jb*$)*hb;X=X-gb*Y-na*Ja;ma=ma-Ta*Y-$*Ja;p.save();p.transform(gb,Ta,na,$,X,ma);p.clip();p.drawImage(la,0,0);p.restore()}}function ib(X,ma,na,$){var wa=~~(X.r*255),ua=~~(X.g*255);X=~~(X.b*255);var la=~~(ma.r*255),Y=~~(ma.g*255);ma=~~(ma.b*255);var Ja=~~(na.r*255),Va=~~(na.g*255);na=~~(na.b*255);var Ta=~~($.r*255),jb=~~($.g*255);$=~~($.b*255);V[0]=wa<0?0:wa>255?255:wa;V[1]=ua<0?0:ua>255?255:ua;V[2]=X<0?0:X>255?255:X;V[4]=la<0?0:la>255?255:la;V[5]=Y<0?0:Y>255?255:Y;V[6]=ma<0?0:ma>255? -255:ma;V[8]=Ja<0?0:Ja>255?255:Ja;V[9]=Va<0?0:Va>255?255:Va;V[10]=na<0?0:na>255?255:na;V[12]=Ta<0?0:Ta>255?255:Ta;V[13]=jb<0?0:jb>255?255:jb;V[14]=$<0?0:$>255?255:$;N.putImageData(Z,0,0);Ka.drawImage(M,0,0);return Aa}function fb(X,ma,na){X=(X-ma)/(na-ma);return X*X*(3-2*X)}function Za(X){X=(X+1)*0.5;return X<0?0:X>1?1:X}function $a(X,ma){var na=ma.x-X.x,$=ma.y-X.y,wa=1/Math.sqrt(na*na+$*$);na*=wa;$*=wa;ma.x+=na;ma.y+=$;X.x-=na;X.y-=$}var Ma,cb,Ca,U,Qa,Sa,kb,Xa;this.autoClear?this.clear():p.setTransform(1, -0,0,-1,o,t);f.data.vertices=0;f.data.faces=0;g=h.projectScene(ya,Oa,this.sortElements);(A=ya.lights.length>0)&&Ga(ya);Ma=0;for(cb=g.length;Ma0){va.r+=ka.color.r*pa;va.g+=ka.color.g*pa;va.b+=ka.color.b*pa}}else if(ka instanceof THREE.PointLight){ha.sub(ka.position,xa.centroidWorld);ha.normalize();pa=xa.normalWorld.dot(ha)*ka.intensity;if(pa>0){va.r+=ka.color.r*pa;va.g+=ka.color.g*pa;va.b+=ka.color.b*pa}}}}function d(ga,xa, -va,ra,ca,ka){h.data.vertices+=3;h.data.faces++;qa=f(Ea++);qa.setAttribute("d","M "+ga.positionScreen.x+" "+ga.positionScreen.y+" L "+xa.positionScreen.x+" "+xa.positionScreen.y+" L "+va.positionScreen.x+","+va.positionScreen.y+"z");if(ca instanceof THREE.MeshBasicMaterial)P.__styleString=ca.color.__styleString;else if(ca instanceof THREE.MeshLambertMaterial)if(E){L.r=O.r;L.g=O.g;L.b=O.b;b(ka,ra,L);P.r=ca.color.r*L.r;P.g=ca.color.g*L.g;P.b=ca.color.b*L.b;P.updateStyleString()}else P.__styleString= -ca.color.__styleString;else if(ca instanceof THREE.MeshDepthMaterial){ta=1-ca.__2near/(ca.__farPlusNear-ra.z*ca.__farMinusNear);P.setRGB(ta,ta,ta)}else ca instanceof THREE.MeshNormalMaterial&&P.setRGB(g(ra.normalWorld.x),g(ra.normalWorld.y),g(ra.normalWorld.z));ca.wireframe?qa.setAttribute("style","fill: none; stroke: "+P.__styleString+"; stroke-width: "+ca.wireframeLinewidth+"; stroke-opacity: "+ca.opacity+"; stroke-linecap: "+ca.wireframeLinecap+"; stroke-linejoin: "+ca.wireframeLinejoin):qa.setAttribute("style", -"fill: "+P.__styleString+"; fill-opacity: "+ca.opacity);m.appendChild(qa)}function c(ga,xa,va,ra,ca,ka,pa){h.data.vertices+=4;h.data.faces++;qa=f(Ea++);qa.setAttribute("d","M "+ga.positionScreen.x+" "+ga.positionScreen.y+" L "+xa.positionScreen.x+" "+xa.positionScreen.y+" L "+va.positionScreen.x+","+va.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+"z");if(ka instanceof THREE.MeshBasicMaterial)P.__styleString=ka.color.__styleString;else if(ka instanceof THREE.MeshLambertMaterial)if(E){L.r= -O.r;L.g=O.g;L.b=O.b;b(pa,ca,L);P.r=ka.color.r*L.r;P.g=ka.color.g*L.g;P.b=ka.color.b*L.b;P.updateStyleString()}else P.__styleString=ka.color.__styleString;else if(ka instanceof THREE.MeshDepthMaterial){ta=1-ka.__2near/(ka.__farPlusNear-ca.z*ka.__farMinusNear);P.setRGB(ta,ta,ta)}else ka instanceof THREE.MeshNormalMaterial&&P.setRGB(g(ca.normalWorld.x),g(ca.normalWorld.y),g(ca.normalWorld.z));ka.wireframe?qa.setAttribute("style","fill: none; stroke: "+P.__styleString+"; stroke-width: "+ka.wireframeLinewidth+ -"; stroke-opacity: "+ka.opacity+"; stroke-linecap: "+ka.wireframeLinecap+"; stroke-linejoin: "+ka.wireframeLinejoin):qa.setAttribute("style","fill: "+P.__styleString+"; fill-opacity: "+ka.opacity);m.appendChild(qa)}function f(ga){if(fa[ga]==null){fa[ga]=document.createElementNS("http://www.w3.org/2000/svg","path");ea==0&&fa[ga].setAttribute("shape-rendering","crispEdges")}return fa[ga]}function g(ga){return ga<0?Math.min((1+ga)*0.5,0.5):0.5+Math.min(ga*0.5,0.5)}var h=this,j=null,k=new THREE.Projector, -m=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,t,p,y,u,z,H,G,B=new THREE.Rectangle,R=new THREE.Rectangle,E=!1,P=new THREE.Color(16777215),L=new THREE.Color(16777215),O=new THREE.Color(0),sa=new THREE.Color(0),oa=new THREE.Color(0),ta,ha=new THREE.Vector3,fa=[],e=[],qa,Ea,Da,ea=1;this.domElement=m;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data={vertices:0,faces:0};this.setQuality=function(ga){switch(ga){case "high":ea=1;break;case "low":ea=0}};this.setSize=function(ga, -xa){o=ga;t=xa;p=o/2;y=t/2;m.setAttribute("viewBox",-p+" "+-y+" "+o+" "+t);m.setAttribute("width",o);m.setAttribute("height",t);B.set(-p,-y,p,y)};this.clear=function(){for(;m.childNodes.length>0;)m.removeChild(m.childNodes[0])};this.render=function(ga,xa){var va,ra,ca,ka,pa,Fa,ja,ia;this.autoClear&&this.clear();h.data.vertices=0;h.data.faces=0;j=k.projectScene(ga,xa,this.sortElements);Da=Ea=0;if(E=ga.lights.length>0){ja=ga.lights;O.setRGB(0,0,0);sa.setRGB(0,0,0);oa.setRGB(0,0,0);va=0;for(ra=ja.length;va< -ra;va++){ca=ja[va];ka=ca.color;if(ca instanceof THREE.AmbientLight){O.r+=ka.r;O.g+=ka.g;O.b+=ka.b}else if(ca instanceof THREE.DirectionalLight){sa.r+=ka.r;sa.g+=ka.g;sa.b+=ka.b}else if(ca instanceof THREE.PointLight){oa.r+=ka.r;oa.g+=ka.g;oa.b+=ka.b}}}va=0;for(ra=j.length;va 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", +THREE.Projector=function(){function b(){var oa=m[k]=m[k]||new THREE.RenderableVertex;k++;return oa}function d(oa,e){return e.z-oa.z}function c(oa,e){var xa=0,sa=1,Ba=oa.z+oa.w,ga=e.z+e.w,ra=-oa.z+oa.w,fa=-e.z+e.w;if(Ba>=0&&ga>=0&&ra>=0&&fa>=0)return!0;else if(Ba<0&&ga<0||ra<0&&fa<0)return!1;else{if(Ba<0)xa=Math.max(xa,Ba/(Ba-ga));else ga<0&&(sa=Math.min(sa,Ba/(Ba-ga)));if(ra<0)xa=Math.max(xa,ra/(ra-fa));else fa<0&&(sa=Math.min(sa,ra/(ra-fa)));if(saBa&&j.positionScreen.z0&&P.z<1){va=C[T]=C[T]||new THREE.RenderableParticle;T++;B=va;B.x=P.x/P.w;B.y=P.y/P.w;B.z=P.z;B.rotation=ha.rotation.z;B.scale.x=ha.scale.x*Math.abs(B.x-(P.x+e.projectionMatrix.n11)/(P.w+e.projectionMatrix.n14));B.scale.y=ha.scale.y*Math.abs(B.y-(P.y+e.projectionMatrix.n22)/(P.w+e.projectionMatrix.n24));B.materials=ha.materials;sa.push(B)}}}}xa&&sa.sort(d);return sa}}; +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,t,u,w,p,z,G;b=d.projectScene(j,k);m=0;for(o=b.length;m>1;Ka=ta.height>>1;ia=la.scale.x*u;Na=la.scale.y*w;ca=ia*W;wa=Na*Ka;K.set(U.x-ca,U.y-wa,U.x+ca,U.y+wa);if(x.instersects(K)){p.save();p.translate(U.x,U.y);p.rotate(-la.rotation);p.scale(ia,-Na);p.translate(-W,-Ka);p.drawImage(ta,0,0);p.restore()}}}else if(ia instanceof THREE.ParticleCanvasMaterial){ca=la.scale.x*u;wa=la.scale.y*w;K.set(U.x-ca,U.y-wa,U.x+ca,U.y+wa);if(x.instersects(K)){c(ia.color);f(ia.color);p.save(); +p.translate(U.x,U.y);p.rotate(-la.rotation);p.scale(ca,wa);ia.program(p);p.restore()}}}function da(U,la,ia,ca){b(ca.opacity);d(ca.blending);p.beginPath();p.moveTo(U.positionScreen.x,U.positionScreen.y);p.lineTo(la.positionScreen.x,la.positionScreen.y);p.closePath();if(ca instanceof THREE.LineBasicMaterial){U=ca.linewidth;if(V!=U)p.lineWidth=V=U;U=ca.linecap;if(P!=U)p.lineCap=P=U;U=ca.linejoin;if(Q!=U)p.lineJoin=Q=U;c(ca.color);p.stroke();K.inflate(ca.linewidth*2)}}function v(U,la,ia,ca,wa,Na,ta,W, +Ka){h.data.vertices+=3;h.data.faces++;b(W.opacity);d(W.blending);xa=U.positionScreen.x;sa=U.positionScreen.y;Ba=la.positionScreen.x;ga=la.positionScreen.y;ra=ia.positionScreen.x;fa=ia.positionScreen.y;gb(xa,sa,Ba,ga,ra,fa);if(W instanceof THREE.MeshBasicMaterial)if(W.map){if(W.map.mapping instanceof THREE.UVMapping){R=ta.uvs[0];db(xa,sa,Ba,ga,ra,fa,W.map.image,R[ca].u,R[ca].v,R[wa].u,R[wa].v,R[Na].u,R[Na].v)}}else if(W.envMap){if(W.envMap.mapping instanceof THREE.SphericalReflectionMapping){U=ya.matrixWorldInverse; +J.copy(ta.vertexNormalsWorld[0]);S=(J.x*U.n11+J.y*U.n12+J.z*U.n13)*0.5+0.5;Ma=-(J.x*U.n21+J.y*U.n22+J.z*U.n23)*0.5+0.5;J.copy(ta.vertexNormalsWorld[1]);bb=(J.x*U.n11+J.y*U.n12+J.z*U.n13)*0.5+0.5;n=-(J.x*U.n21+J.y*U.n22+J.z*U.n23)*0.5+0.5;J.copy(ta.vertexNormalsWorld[2]);D=(J.x*U.n11+J.y*U.n12+J.z*U.n13)*0.5+0.5;y=-(J.x*U.n21+J.y*U.n22+J.z*U.n23)*0.5+0.5;db(xa,sa,Ba,ga,ra,fa,W.envMap.image,S,Ma,bb,n,D,y)}}else W.wireframe?Ta(W.color,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):fb(W.color); +else if(W instanceof THREE.MeshLambertMaterial){if(W.map&&!W.wireframe){if(W.map.mapping instanceof THREE.UVMapping){R=ta.uvs[0];db(xa,sa,Ba,ga,ra,fa,W.map.image,R[ca].u,R[ca].v,R[wa].u,R[wa].v,R[Na].u,R[Na].v)}d(THREE.SubtractiveBlending)}if(M)if(!W.wireframe&&W.shading==THREE.SmoothShading&&ta.vertexNormalsWorld.length==3){ha.r=va.r=Ja.r=N.r;ha.g=va.g=Ja.g=N.g;ha.b=va.b=Ja.b=N.b;Pa(Ka,ta.v1.positionWorld,ta.vertexNormalsWorld[0],ha);Pa(Ka,ta.v2.positionWorld,ta.vertexNormalsWorld[1],va);Pa(Ka,ta.v3.positionWorld, +ta.vertexNormalsWorld[2],Ja);Sa.r=(va.r+Ja.r)*0.5;Sa.g=(va.g+Ja.g)*0.5;Sa.b=(va.b+Ja.b)*0.5;Z=$a(ha,va,Ja,Sa);db(xa,sa,Ba,ga,ra,fa,Z,0,0,1,0,0,1)}else{I.r=N.r;I.g=N.g;I.b=N.b;Pa(Ka,ta.centroidWorld,ta.normalWorld,I);Aa.r=Math.max(0,Math.min(W.color.r*I.r,1));Aa.g=Math.max(0,Math.min(W.color.g*I.g,1));Aa.b=Math.max(0,Math.min(W.color.b*I.b,1));Aa.updateHex();W.wireframe?Ta(Aa,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):fb(Aa)}else W.wireframe?Ta(W.color,W.wireframeLinewidth,W.wireframeLinecap, +W.wireframeLinejoin):fb(W.color)}else if(W instanceof THREE.MeshDepthMaterial){Wa=ya.near;O=ya.far;ha.r=ha.g=ha.b=1-Za(U.positionScreen.z,Wa,O);va.r=va.g=va.b=1-Za(la.positionScreen.z,Wa,O);Ja.r=Ja.g=Ja.b=1-Za(ia.positionScreen.z,Wa,O);Sa.r=(va.r+Ja.r)*0.5;Sa.g=(va.g+Ja.g)*0.5;Sa.b=(va.b+Ja.b)*0.5;Z=$a(ha,va,Ja,Sa);db(xa,sa,Ba,ga,ra,fa,Z,0,0,1,0,0,1)}else if(W instanceof THREE.MeshNormalMaterial){Aa.r=Oa(ta.normalWorld.x);Aa.g=Oa(ta.normalWorld.y);Aa.b=Oa(ta.normalWorld.z);Aa.updateHex();W.wireframe? +Ta(Aa,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):fb(Aa)}}function ab(U,la,ia,ca,wa,Na,ta,W,Ka){h.data.vertices+=4;h.data.faces++;b(W.opacity);d(W.blending);if(W.map||W.envMap){v(U,la,ca,0,1,3,ta,W,Ka);v(wa,ia,Na,1,2,3,ta,W,Ka)}else{xa=U.positionScreen.x;sa=U.positionScreen.y;Ba=la.positionScreen.x;ga=la.positionScreen.y;ra=ia.positionScreen.x;fa=ia.positionScreen.y;za=ca.positionScreen.x;na=ca.positionScreen.y;ua=wa.positionScreen.x;qa=wa.positionScreen.y;ja=Na.positionScreen.x; +Fa=Na.positionScreen.y;if(W instanceof THREE.MeshBasicMaterial){Ua(xa,sa,Ba,ga,ra,fa,za,na);W.wireframe?Ta(W.color,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):fb(W.color)}else if(W instanceof THREE.MeshLambertMaterial)if(M)if(!W.wireframe&&W.shading==THREE.SmoothShading&&ta.vertexNormalsWorld.length==4){ha.r=va.r=Ja.r=Sa.r=N.r;ha.g=va.g=Ja.g=Sa.g=N.g;ha.b=va.b=Ja.b=Sa.b=N.b;Pa(Ka,ta.v1.positionWorld,ta.vertexNormalsWorld[0],ha);Pa(Ka,ta.v2.positionWorld,ta.vertexNormalsWorld[1],va); +Pa(Ka,ta.v4.positionWorld,ta.vertexNormalsWorld[3],Ja);Pa(Ka,ta.v3.positionWorld,ta.vertexNormalsWorld[2],Sa);Z=$a(ha,va,Ja,Sa);gb(xa,sa,Ba,ga,za,na);db(xa,sa,Ba,ga,za,na,Z,0,0,1,0,0,1);gb(ua,qa,ra,fa,ja,Fa);db(ua,qa,ra,fa,ja,Fa,Z,1,0,1,1,0,1)}else{I.r=N.r;I.g=N.g;I.b=N.b;Pa(Ka,ta.centroidWorld,ta.normalWorld,I);Aa.r=Math.max(0,Math.min(W.color.r*I.r,1));Aa.g=Math.max(0,Math.min(W.color.g*I.g,1));Aa.b=Math.max(0,Math.min(W.color.b*I.b,1));Aa.updateHex();Ua(xa,sa,Ba,ga,ra,fa,za,na);W.wireframe?Ta(Aa, +W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):fb(Aa)}else{Ua(xa,sa,Ba,ga,ra,fa,za,na);W.wireframe?Ta(W.color,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):fb(W.color)}else if(W instanceof THREE.MeshNormalMaterial){Aa.r=Oa(ta.normalWorld.x);Aa.g=Oa(ta.normalWorld.y);Aa.b=Oa(ta.normalWorld.z);Aa.updateHex();Ua(xa,sa,Ba,ga,ra,fa,za,na);W.wireframe?Ta(Aa,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):fb(Aa)}else if(W instanceof THREE.MeshDepthMaterial){Wa=ya.near; +O=ya.far;ha.r=ha.g=ha.b=1-Za(U.positionScreen.z,Wa,O);va.r=va.g=va.b=1-Za(la.positionScreen.z,Wa,O);Ja.r=Ja.g=Ja.b=1-Za(ca.positionScreen.z,Wa,O);Sa.r=Sa.g=Sa.b=1-Za(ia.positionScreen.z,Wa,O);Z=$a(ha,va,Ja,Sa);gb(xa,sa,Ba,ga,za,na);db(xa,sa,Ba,ga,za,na,Z,0,0,1,0,0,1);gb(ua,qa,ra,fa,ja,Fa);db(ua,qa,ra,fa,ja,Fa,Z,1,0,1,1,0,1)}}}function gb(U,la,ia,ca,wa,Na){p.beginPath();p.moveTo(U,la);p.lineTo(ia,ca);p.lineTo(wa,Na);p.lineTo(U,la);p.closePath()}function Ua(U,la,ia,ca,wa,Na,ta,W){p.beginPath();p.moveTo(U, +la);p.lineTo(ia,ca);p.lineTo(wa,Na);p.lineTo(ta,W);p.lineTo(U,la);p.closePath()}function Ta(U,la,ia,ca){if(V!=la)p.lineWidth=V=la;if(P!=ia)p.lineCap=P=ia;if(Q!=ca)p.lineJoin=Q=ca;c(U);p.stroke();K.inflate(la*2)}function fb(U){f(U);p.fill()}function db(U,la,ia,ca,wa,Na,ta,W,Ka,kb,Ra,ib,mb){var eb,jb;eb=ta.width-1;jb=ta.height-1;W*=eb;Ka*=jb;kb*=eb;Ra*=jb;ib*=eb;mb*=jb;ia-=U;ca-=la;wa-=U;Na-=la;kb-=W;Ra-=Ka;ib-=W;mb-=Ka;eb=kb*mb-ib*Ra;if(eb!=0){jb=1/eb;eb=(mb*ia-Ra*wa)*jb;Ra=(mb*ca-Ra*Na)*jb;ia=(kb* +wa-ib*ia)*jb;ca=(kb*Na-ib*ca)*jb;U=U-eb*W-ia*Ka;la=la-Ra*W-ca*Ka;p.save();p.transform(eb,Ra,ia,ca,U,la);p.clip();p.drawImage(ta,0,0);p.restore()}}function $a(U,la,ia,ca){var wa=~~(U.r*255),Na=~~(U.g*255);U=~~(U.b*255);var ta=~~(la.r*255),W=~~(la.g*255);la=~~(la.b*255);var Ka=~~(ia.r*255),kb=~~(ia.g*255);ia=~~(ia.b*255);var Ra=~~(ca.r*255),ib=~~(ca.g*255);ca=~~(ca.b*255);Ha[0]=wa<0?0:wa>255?255:wa;Ha[1]=Na<0?0:Na>255?255:Na;Ha[2]=U<0?0:U>255?255:U;Ha[4]=ta<0?0:ta>255?255:ta;Ha[5]=W<0?0:W>255?255:W; +Ha[6]=la<0?0:la>255?255:la;Ha[8]=Ka<0?0:Ka>255?255:Ka;Ha[9]=kb<0?0:kb>255?255:kb;Ha[10]=ia<0?0:ia>255?255:ia;Ha[12]=Ra<0?0:Ra>255?255:Ra;Ha[13]=ib<0?0:ib>255?255:ib;Ha[14]=ca<0?0:ca>255?255:ca;X.putImageData(Ca,0,0);La.drawImage($,0,0);return Da}function Za(U,la,ia){U=(U-la)/(ia-la);return U*U*(3-2*U)}function Oa(U){U=(U+1)*0.5;return U<0?0:U>1?1:U}function Ya(U,la){var ia=la.x-U.x,ca=la.y-U.y,wa=1/Math.sqrt(ia*ia+ca*ca);ia*=wa;ca*=wa;la.x+=ia;la.y+=ca;U.x-=ia;U.y-=ca}var Va,Y,Ea,Qa,hb,lb,cb,Ia;this.autoClear? +this.clear():p.setTransform(1,0,0,-1,u,w);h.data.vertices=0;h.data.faces=0;j=k.projectScene(ma,ya,this.sortElements);(M=ma.lights.length>0)&&Ga(ma);Va=0;for(Y=j.length;Va0){na.r+=ja.color.r*Fa;na.g+=ja.color.g*Fa;na.b+=ja.color.b*Fa}}else if(ja instanceof THREE.PointLight){oa.sub(ja.position,za.centroidWorld);oa.normalize();Fa=za.normalWorld.dot(oa)*ja.intensity;if(Fa>0){na.r+=ja.color.r*Fa;na.g+=ja.color.g*Fa;na.b+=ja.color.b*Fa}}}}function d(fa,za, +na,ua,qa,ja){j.data.vertices+=3;j.data.faces++;sa=f(Ba++);sa.setAttribute("d","M "+fa.positionScreen.x+" "+fa.positionScreen.y+" L "+za.positionScreen.x+" "+za.positionScreen.y+" L "+na.positionScreen.x+","+na.positionScreen.y+"z");if(qa instanceof THREE.MeshBasicMaterial)P.hex=qa.color.hex;else if(qa instanceof THREE.MeshLambertMaterial)if(V){Q.r=ka.r;Q.g=ka.g;Q.b=ka.b;b(ja,ua,Q);P.r=Math.max(0,Math.min(qa.color.r*Q.r,1));P.g=Math.max(0,Math.min(qa.color.g*Q.g,1));P.b=Math.max(0,Math.min(qa.color.b* +Q.b,1));P.updateHex()}else P.hex=qa.color.hex;else if(qa instanceof THREE.MeshDepthMaterial){aa=1-qa.__2near/(qa.__farPlusNear-ua.z*qa.__farMinusNear);P.setRGB(aa,aa,aa)}else qa instanceof THREE.MeshNormalMaterial&&P.setRGB(g(ua.normalWorld.x),g(ua.normalWorld.y),g(ua.normalWorld.z));qa.wireframe?sa.setAttribute("style","fill: none; stroke: #"+h(P.hex.toString(16))+"; stroke-width: "+qa.wireframeLinewidth+"; stroke-opacity: "+qa.opacity+"; stroke-linecap: "+qa.wireframeLinecap+"; stroke-linejoin: "+ +qa.wireframeLinejoin):sa.setAttribute("style","fill: #"+h(P.hex.toString(16))+"; fill-opacity: "+qa.opacity);o.appendChild(sa)}function c(fa,za,na,ua,qa,ja,Fa){j.data.vertices+=4;j.data.faces++;sa=f(Ba++);sa.setAttribute("d","M "+fa.positionScreen.x+" "+fa.positionScreen.y+" L "+za.positionScreen.x+" "+za.positionScreen.y+" L "+na.positionScreen.x+","+na.positionScreen.y+" L "+ua.positionScreen.x+","+ua.positionScreen.y+"z");if(ja instanceof THREE.MeshBasicMaterial)P.hex=ja.color.hex;else if(ja instanceof +THREE.MeshLambertMaterial)if(V){Q.r=ka.r;Q.g=ka.g;Q.b=ka.b;b(Fa,qa,Q);P.r=Math.max(0,Math.min(ja.color.r*Q.r,1));P.g=Math.max(0,Math.min(ja.color.g*Q.g,1));P.b=Math.max(0,Math.min(ja.color.b*Q.b,1));P.updateHex()}else P.hex=ja.color.hex;else if(ja instanceof THREE.MeshDepthMaterial){aa=1-ja.__2near/(ja.__farPlusNear-qa.z*ja.__farMinusNear);P.setRGB(aa,aa,aa)}else ja instanceof THREE.MeshNormalMaterial&&P.setRGB(g(qa.normalWorld.x),g(qa.normalWorld.y),g(qa.normalWorld.z));ja.wireframe?sa.setAttribute("style", +"fill: none; stroke: #"+h(P.hex.toString(16))+"; stroke-width: "+ja.wireframeLinewidth+"; stroke-opacity: "+ja.opacity+"; stroke-linecap: "+ja.wireframeLinecap+"; stroke-linejoin: "+ja.wireframeLinejoin):sa.setAttribute("style","fill: #"+h(P.hex.toString(16))+"; fill-opacity: "+ja.opacity);o.appendChild(sa)}function f(fa){if(e[fa]==null){e[fa]=document.createElementNS("http://www.w3.org/2000/svg","path");ra==0&&e[fa].setAttribute("shape-rendering","crispEdges")}return e[fa]}function g(fa){fa=(fa+ +1)*0.5;return fa<0?0:fa>1?1:fa}function h(fa){for(;fa.length<6;)fa="0"+fa;return fa}var j=this,k=null,m=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),t,u,w,p,z,G,F,B,T=new THREE.Rectangle,C=new THREE.Rectangle,V=!1,P=new THREE.Color(16777215),Q=new THREE.Color(16777215),ka=new THREE.Color(0),ea=new THREE.Color(0),pa=new THREE.Color(0),aa,oa=new THREE.Vector3,e=[],xa=[],sa,Ba,ga,ra=1;this.domElement=o;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data= +{vertices:0,faces:0};this.setQuality=function(fa){switch(fa){case "high":ra=1;break;case "low":ra=0}};this.setSize=function(fa,za){t=fa;u=za;w=t/2;p=u/2;o.setAttribute("viewBox",-w+" "+-p+" "+t+" "+u);o.setAttribute("width",t);o.setAttribute("height",u);T.set(-w,-p,w,p)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=function(fa,za){var na,ua,qa,ja,Fa,Aa,ha,va;this.autoClear&&this.clear();j.data.vertices=0;j.data.faces=0;k=m.projectScene(fa,za,this.sortElements); +ga=Ba=0;if(V=fa.lights.length>0){ha=fa.lights;ka.setRGB(0,0,0);ea.setRGB(0,0,0);pa.setRGB(0,0,0);na=0;for(ua=ha.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", @@ -219,121 +220,122 @@ THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.Shade "void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex, THREE.ShaderChunk.default_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;", THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}}; -THREE.WebGLRenderer=function(b){function d(n,C,w){var v,A,K,J=n.vertices,I=J.length,S=n.colors,D=S.length,M=n.__vertexArray,N=n.__colorArray,Z=n.__sortArray,V=n.__dirtyVertices,Aa=n.__dirtyColors;if(w.sortParticles){Ia.multiplySelf(w.matrixWorld);for(v=0;v=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglVertexBuffer);e.vertexAttribPointer(n.position,3,e.FLOAT,!1,0,0)}else{C=v.program.attributes;if(K.morphTargetBase!==-1){e.bindBuffer(e.ARRAY_BUFFER,A.__webglMorphTargetsBuffers[K.morphTargetBase]); -e.vertexAttribPointer(C.position,3,e.FLOAT,!1,0,0)}else if(C.position>=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglVertexBuffer);e.vertexAttribPointer(C.position,3,e.FLOAT,!1,0,0)}if(K.morphTargetForcedOrder.length){w=0;for(var I=K.morphTargetForcedOrder,S=K.morphTargetInfluences;wD){M=N;D=S[M]}e.bindBuffer(e.ARRAY_BUFFER,A.__webglMorphTargetsBuffers[M]);e.vertexAttribPointer(C["morphTarget"+w],3,e.FLOAT,!1,0,0);K.__webglMorphTargetInfluences[w]=D;I[M]=1;D=-1;w++}}v.program.uniforms.morphTargetInfluences!==null&&e.uniform1fv(v.program.uniforms.morphTargetInfluences,K.__webglMorphTargetInfluences)}if(v.attributes)for(J in v.attributes)if(n[J]>= -0){C=v.attributes[J];e.bindBuffer(e.ARRAY_BUFFER,C.buffer);e.vertexAttribPointer(n[J],C.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(K 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)}fa.data.vertices+=A.__webglFaceCount;fa.data.faces+=A.__webglFaceCount/3;fa.data.drawCalls++}else if(K instanceof THREE.Line){K=K.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(v.linewidth);e.drawArrays(K,0,A.__webglLineCount);fa.data.drawCalls++}else if(K instanceof THREE.ParticleSystem){e.drawArrays(e.POINTS,0,A.__webglParticleCount); -fa.data.drawCalls++}else if(K instanceof THREE.Ribbon){e.drawArrays(e.TRIANGLE_STRIP,0,A.__webglVertexCount);fa.data.drawCalls++}}}function g(n,C,w){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(C.attributes.position);e.vertexAttribPointer(C.attributes.position,3,e.FLOAT, -!1,0,0)}if(n.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,n.__webglNormalBuffer);if(w==THREE.FlatShading){var v,A,K,J,I,S,D,M,N,Z,V=n.count*3;for(Z=0;Z0&&Ka[0]0&&Ka[1]0.0010&&I.scale>0.0010){Aa[0]=I.x;Aa[1]=I.y;Aa[2]=I.z;Z=I.size*I.scale/ja;V[0]=Z*D;V[1]=Z;e.uniform3fv(Ba.screenPosition,Aa);e.uniform2fv(Ba.scale,V);e.uniform1f(Ba.rotation,I.rotation);e.uniform1f(Ba.opacity,I.opacity);P(I.blending);O(I.texture,1);e.drawElements(e.TRIANGLES, -6,e.UNSIGNED_SHORT,0)}}}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(ga)}function G(n,C){n._modelViewMatrix.multiplyToArray(C.matrixWorldInverse,n.matrixWorld,n._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(n._modelViewMatrix).transposeIntoArray(n._normalMatrixArray)}function B(n){var C,w,v,A,K;if(n instanceof THREE.Mesh){w=n.geometry;for(C in w.geometryGroups){v=w.geometryGroups[C];K=!1;for(A in v.__webglCustomAttributes)if(v.__webglCustomAttributes[A].needsUpdate){K=!0;break}if(w.__dirtyVertices|| -w.__dirtyMorphTargets||w.__dirtyElements||w.__dirtyUvs||w.__dirtyNormals||w.__dirtyColors||w.__dirtyTangents||K){K=e.DYNAMIC_DRAW;var J=void 0,I=void 0,S=void 0,D=void 0;S=void 0;var M=void 0,N=void 0,Z=void 0,V=void 0,Aa=void 0,Ka=void 0,Ba=void 0,ya=void 0,Oa=void 0,Ga=void 0,za=void 0,Ha=void 0,Ua=void 0;N=void 0;Z=void 0;D=void 0;V=void 0;D=void 0;var F=void 0,da=void 0;N=void 0;F=void 0;da=void 0;var x=void 0,bb=void 0;F=void 0;da=void 0;x=void 0;bb=void 0;F=void 0;da=void 0;x=void 0;bb=void 0; -F=void 0;da=void 0;x=void 0;D=void 0;V=void 0;M=void 0;S=void 0;S=void 0;F=void 0;da=void 0;x=void 0;var eb=void 0,Na=0,Pa=0,ib=0,fb=0,Za=0,$a=0,Ma=0,cb=0,Ca=0,U=0,Qa=0;da=F=0;var Sa=v.__vertexArray,kb=v.__uvArray,Xa=v.__uv2Array,X=v.__normalArray,ma=v.__tangentArray,na=v.__colorArray,$=v.__skinVertexAArray,wa=v.__skinVertexBArray,ua=v.__skinIndexArray,la=v.__skinWeightArray,Y=v.__morphTargetsArrays,Ja=v.__webglCustomAttributes;x=void 0;var Va=v.__faceArray,Ta=v.__lineArray,jb=v.__needsSmoothNormals; -Ka=v.__vertexColorType;Aa=v.__uvType;Ba=v.__normalType;var Wa=n.geometry,gb=Wa.__dirtyVertices,hb=Wa.__dirtyElements,rb=Wa.__dirtyUvs,sb=Wa.__dirtyNormals,tb=Wa.__dirtyTangents,ub=Wa.__dirtyColors,vb=Wa.__dirtyMorphTargets,nb=Wa.vertices,wb=v.faces,zb=Wa.faces,xb=Wa.faceVertexUvs[0],yb=Wa.faceVertexUvs[1],ob=Wa.skinVerticesA,pb=Wa.skinVerticesB,qb=Wa.skinIndices,lb=Wa.skinWeights,mb=n instanceof THREE.ShadowVolume?Wa.edgeFaces:undefined;morphTargets=Wa.morphTargets;if(Ja)for(eb in Ja){Ja[eb].offset= -0;Ja[eb].offsetSrc=0}J=0;for(I=wb.length;J0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,na,K)}if(sb){e.bindBuffer(e.ARRAY_BUFFER,v.__webglNormalBuffer);e.bufferData(e.ARRAY_BUFFER,X,K)}if(tb&&Wa.hasTangents){e.bindBuffer(e.ARRAY_BUFFER, -v.__webglTangentBuffer);e.bufferData(e.ARRAY_BUFFER,ma,K)}if(rb&&ib>0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglUVBuffer);e.bufferData(e.ARRAY_BUFFER,kb,K)}if(rb&&fb>0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Xa,K)}if(hb){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,v.__webglFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Va,K);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,v.__webglLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ta,K)}if(U>0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinVertexABuffer); -e.bufferData(e.ARRAY_BUFFER,$,K);e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,wa,K);e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,ua,K);e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,la,K)}}}w.__dirtyVertices=!1;w.__dirtyMorphTargets=!1;w.__dirtyElements=!1;w.__dirtyUvs=!1;w.__dirtyNormals=!1;w.__dirtyTangents=!1;w.__dirtyColors=!1}else if(n instanceof THREE.Ribbon){w=n.geometry;if(w.__dirtyVertices|| -w.__dirtyColors){n=w;C=e.DYNAMIC_DRAW;Ka=n.vertices;v=n.colors;Ba=Ka.length;K=v.length;ya=n.__vertexArray;J=n.__colorArray;Oa=n.__dirtyColors;if(n.__dirtyVertices){for(I=0;I65535){M[S].counter+=1;D=M[S].hash+"_"+M[S].counter;n.geometryGroups[D]==undefined&&(n.geometryGroups[D]={faces:[],materials:I,vertices:0,numMorphTargets:N})}n.geometryGroups[D].faces.push(A); -n.geometryGroups[D].vertices+=J}}function E(n,C,w){n.push({buffer:C,object:w,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function P(n){if(n!=ra){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)}ra=n}}function L(n,C,w){if((w.width&w.width-1)==0&&(w.height&w.height-1)==0){e.texParameteri(n,e.TEXTURE_WRAP_S,ha(C.wrapS));e.texParameteri(n,e.TEXTURE_WRAP_T,ha(C.wrapT));e.texParameteri(n,e.TEXTURE_MAG_FILTER,ha(C.magFilter));e.texParameteri(n,e.TEXTURE_MIN_FILTER,ha(C.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,ta(C.magFilter));e.texParameteri(n,e.TEXTURE_MIN_FILTER,ta(C.minFilter))}}function O(n,C){if(n.needsUpdate){if(n.__webglInit){e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n.image)}else{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);n.__webglInit=!0}L(e.TEXTURE_2D,n,n.image);e.bindTexture(e.TEXTURE_2D,null); -n.needsUpdate=!1}e.activeTexture(e.TEXTURE0+C);e.bindTexture(e.TEXTURE_2D,n.__webglTexture)}function sa(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,ha(n.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T, -ha(n.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,ha(n.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,ha(n.minFilter));e.texImage2D(e.TEXTURE_2D,0,ha(n.format),n.width,n.height,0,ha(n.format),ha(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 C,w;if(n){C=n.__webglFramebuffer;w=n.width;n=n.height}else{C=null;w=Fa;n=ja}if(C!=ea){e.bindFramebuffer(e.FRAMEBUFFER,C);e.viewport(ka,pa,w,n);ea=C}}function oa(n,C){var w;if(n=="fragment")w=e.createShader(e.FRAGMENT_SHADER);else n=="vertex"&&(w=e.createShader(e.VERTEX_SHADER));e.shaderSource(w,C);e.compileShader(w);if(!e.getShaderParameter(w,e.COMPILE_STATUS)){console.error(e.getShaderInfoLog(w));console.error(C);return null}return w}function ta(n){switch(n){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST; -default:return e.LINEAR}}function ha(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 fa=this,e,qa=document.createElement("canvas"),Ea=[],Da=null,ea=null,ga=!0,xa=null,va=null,ra=null,ca=null,ka=0,pa=0,Fa=0,ja=0,ia=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ia=new THREE.Matrix4,Ya=new Float32Array(16),ab=new Float32Array(16),Ra=new THREE.Vector4,Q={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};b=b||{};stencil=b.stencil!==undefined?b.stencil:!0; -antialias=b.antialias!==undefined?b.antialias:!1;clearColor=b.clearColor!==undefined?new THREE.Color(b.clearColor):new THREE.Color(0);clearAlpha=b.clearAlpha!==undefined?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=qa;this.autoClear=!0;this.sortObjects=!0;(function(n,C,w,v){try{if(!(e=qa.getContext("experimental-webgl",{antialias:n,stencil:v})))throw"Error creating WebGL context.";}catch(A){console.error(A)}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(C.r,C.g,C.b,w)})(antialias,clearColor,clearAlpha,stencil);this.context=e;var aa=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)> -0;if(stencil){var W={};W.vertices=new Float32Array(12);W.faces=new Uint16Array(6);W.darkness=0.5;W.vertices[0]=-20;W.vertices[1]=-20;W.vertices[2]=-1;W.vertices[3]=20;W.vertices[4]=-20;W.vertices[5]=-1;W.vertices[6]=20;W.vertices[7]=20;W.vertices[8]=-1;W.vertices[9]=-20;W.vertices[10]=20;W.vertices[11]=-1;W.faces[0]=0;W.faces[1]=1;W.faces[2]=2;W.faces[3]=0;W.faces[4]=2;W.faces[5]=3;W.vertexBuffer=e.createBuffer();W.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,W.vertexBuffer);e.bufferData(e.ARRAY_BUFFER, -W.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,W.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,W.faces,e.STATIC_DRAW);W.program=e.createProgram();e.attachShader(W.program,oa("fragment",THREE.ShaderLib.shadowPost.fragmentShader));e.attachShader(W.program,oa("vertex",THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(W.program);W.vertexLocation=e.getAttribLocation(W.program,"position");W.projectionLocation=e.getUniformLocation(W.program,"projectionMatrix");W.darknessLocation= -e.getUniformLocation(W.program,"darkness")}var T={};T.vertices=new Float32Array(16);T.faces=new Uint16Array(6);b=0;T.vertices[b++]=-1;T.vertices[b++]=-1;T.vertices[b++]=0;T.vertices[b++]=0;T.vertices[b++]=1;T.vertices[b++]=-1;T.vertices[b++]=1;T.vertices[b++]=0;T.vertices[b++]=1;T.vertices[b++]=1;T.vertices[b++]=1;T.vertices[b++]=1;T.vertices[b++]=-1;T.vertices[b++]=1;T.vertices[b++]=0;T.vertices[b++]=1;b=0;T.faces[b++]=0;T.faces[b++]=1;T.faces[b++]=2;T.faces[b++]=0;T.faces[b++]=2;T.faces[b++]=3; -T.vertexBuffer=e.createBuffer();T.elementBuffer=e.createBuffer();T.tempTexture=e.createTexture();T.occlusionTexture=e.createTexture();e.bindBuffer(e.ARRAY_BUFFER,T.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,T.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,T.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,T.faces,e.STATIC_DRAW);e.bindTexture(e.TEXTURE_2D,T.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,T.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){T.hasVertexTexture=!1;T.program=e.createProgram();e.attachShader(T.program,oa("fragment",THREE.ShaderLib.lensFlare.fragmentShader));e.attachShader(T.program,oa("vertex",THREE.ShaderLib.lensFlare.vertexShader))}else{T.hasVertexTexture=!0;T.program=e.createProgram();e.attachShader(T.program,oa("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader));e.attachShader(T.program, -oa("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader))}e.linkProgram(T.program);T.attributes={};T.uniforms={};T.attributes.vertex=e.getAttribLocation(T.program,"position");T.attributes.uv=e.getAttribLocation(T.program,"UV");T.uniforms.renderType=e.getUniformLocation(T.program,"renderType");T.uniforms.map=e.getUniformLocation(T.program,"map");T.uniforms.occlusionMap=e.getUniformLocation(T.program,"occlusionMap");T.uniforms.opacity=e.getUniformLocation(T.program,"opacity");T.uniforms.scale= -e.getUniformLocation(T.program,"scale");T.uniforms.rotation=e.getUniformLocation(T.program,"rotation");T.uniforms.screenPosition=e.getUniformLocation(T.program,"screenPosition");var La=!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,oa("fragment",THREE.ShaderLib.sprite.fragmentShader));e.attachShader(_sprite.program,oa("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 db=!1;this.setSize=function(n,C){qa.width=n;qa.height=C;this.setViewport(0, -0,qa.width,qa.height)};this.setViewport=function(n,C,w,v){ka=n;pa=C;Fa=w;ja=v;e.viewport(ka,pa,Fa,ja)};this.setScissor=function(n,C,w,v){e.scissor(n,C,w,v)};this.enableScissorTest=function(n){n?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(n){ga=n;e.depthMask(n)};this.setClearColorHex=function(n,C){var w=new THREE.Color(n);e.clearColor(w.r,w.g,w.b,C)};this.setClearColor=function(n,C){e.clearColor(n.r,n.g,n.b,C)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT| -e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(n){W.darkness=n};this.getContext=function(){return e};this.initMaterial=function(n,C,w,v){var A,K,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 I=THREE.ShaderLib[J];n.uniforms=THREE.UniformsUtils.clone(I.uniforms);n.vertexShader=I.vertexShader;n.fragmentShader=I.fragmentShader}var S,D,M;S=M=I=0;for(D=C.length;S=0&&e.enableVertexAttribArray(N.color);N.normal>= -0&&e.enableVertexAttribArray(N.normal);N.tangent>=0&&e.enableVertexAttribArray(N.tangent);if(n.skinning&&N.skinVertexA>=0&&N.skinVertexB>=0&&N.skinIndex>=0&&N.skinWeight>=0){e.enableVertexAttribArray(N.skinVertexA);e.enableVertexAttribArray(N.skinVertexB);e.enableVertexAttribArray(N.skinIndex);e.enableVertexAttribArray(N.skinWeight)}for(A in n.attributes)N[A]>=0&&e.enableVertexAttribArray(N[A]);if(n.morphTargets){n.numSupportedMorphTargets=0;if(N.morphTarget0>=0){e.enableVertexAttribArray(N.morphTarget0); -n.numSupportedMorphTargets++}if(N.morphTarget1>=0){e.enableVertexAttribArray(N.morphTarget1);n.numSupportedMorphTargets++}if(N.morphTarget2>=0){e.enableVertexAttribArray(N.morphTarget2);n.numSupportedMorphTargets++}if(N.morphTarget3>=0){e.enableVertexAttribArray(N.morphTarget3);n.numSupportedMorphTargets++}if(N.morphTarget4>=0){e.enableVertexAttribArray(N.morphTarget4);n.numSupportedMorphTargets++}if(N.morphTarget5>=0){e.enableVertexAttribArray(N.morphTarget5);n.numSupportedMorphTargets++}if(N.morphTarget6>= -0){e.enableVertexAttribArray(N.morphTarget6);n.numSupportedMorphTargets++}if(N.morphTarget7>=0){e.enableVertexAttribArray(N.morphTarget7);n.numSupportedMorphTargets++}v.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);n=0;for(A=this.maxMorphTargets;n0||Z.faceVertexUvs.length>0)J.__uvArray=new Float32Array(S*2);if(Z.faceUvs.length>1||Z.faceVertexUvs.length>1)J.__uv2Array=new Float32Array(S* -2)}if(I.geometry.skinWeights.length&&I.geometry.skinIndices.length){J.__skinVertexAArray=new Float32Array(S*4);J.__skinVertexBArray=new Float32Array(S*4);J.__skinIndexArray=new Float32Array(S*4);J.__skinWeightArray=new Float32Array(S*4)}J.__faceArray=new Uint16Array(Aa*3+(I.geometry.edgeFaces?I.geometry.edgeFaces.length*6:0));J.__lineArray=new Uint16Array(Ka*2);if(J.numMorphTargets){J.__morphTargetsArrays=[];Z=0;for(V=J.numMorphTargets;Z=0;A--){v=w.__webglObjects[A].object;if(C==v){w.__webglObjects.splice(A,1);break}}else if(C instanceof THREE.Sprite)for(A=w.__webglSprites.length-1;A>=0;A--){v= -w.__webglSprites[A];if(C==v){w.__webglSprites.splice(A,1);break}}n.__objectsRemoved.splice(0,1)}C=0;for(w=n.__webglObjects.length;C=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglVertexBuffer);e.vertexAttribPointer(n.position,3,e.FLOAT,!1,0,0)}else{D=x.program.attributes;if(K.morphTargetBase!==-1){e.bindBuffer(e.ARRAY_BUFFER,A.__webglMorphTargetsBuffers[K.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(K.morphTargetForcedOrder.length){y=0;for(var I=K.morphTargetForcedOrder,N=K.morphTargetInfluences;yH){L=J;H=N[L]}e.bindBuffer(e.ARRAY_BUFFER,A.__webglMorphTargetsBuffers[L]);e.vertexAttribPointer(D["morphTarget"+y],3,e.FLOAT,!1,0,0);K.__webglMorphTargetInfluences[y]=H;I[L]=1;H=-1;y++}}x.program.uniforms.morphTargetInfluences!==null&&e.uniform1fv(x.program.uniforms.morphTargetInfluences,K.__webglMorphTargetInfluences)}if(x.attributes)for(M in x.attributes)if(n[M]>= +0){D=x.attributes[M];e.bindBuffer(e.ARRAY_BUFFER,D.buffer);e.vertexAttribPointer(n[M],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(x.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(K instanceof THREE.Mesh){if(x.wireframe){e.lineWidth(x.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)}oa.data.vertices+=A.__webglFaceCount;oa.data.faces+=A.__webglFaceCount/3;oa.data.drawCalls++}else if(K instanceof THREE.Line){K=K.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(x.linewidth);e.drawArrays(K,0,A.__webglLineCount);oa.data.drawCalls++}else if(K instanceof THREE.ParticleSystem){e.drawArrays(e.POINTS,0,A.__webglParticleCount); +oa.data.drawCalls++}else if(K instanceof THREE.Ribbon){e.drawArrays(e.TRIANGLE_STRIP,0,A.__webglVertexCount);oa.data.drawCalls++}}}function g(n,D,y){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(y==THREE.FlatShading){var x,A,K,M,I,N,H,L,J,$,X=n.count*3;for($=0;$0&&Ha[0]0&&Ha[1]0.001&&I.scale>0.001){Ca[0]=I.x;Ca[1]=I.y;Ca[2]=I.z;$=I.size*I.scale/Aa;X[0]=$*H;X[1]=$;e.uniform3fv(Da.screenPosition,Ca);e.uniform2fv(Da.scale,X);e.uniform1f(Da.rotation,I.rotation);e.uniform1f(Da.opacity,I.opacity);V(I.blending);Q(I.texture,1);e.drawElements(e.TRIANGLES, +6,e.UNSIGNED_SHORT,0)}}}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(ra)}function F(n,D){n._modelViewMatrix.multiplyToArray(D.matrixWorldInverse,n.matrixWorld,n._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(n._modelViewMatrix).transposeIntoArray(n._normalMatrixArray)}function B(n){var D,y,x,A,K;if(n instanceof THREE.Mesh){y=n.geometry;for(D in y.geometryGroups){x=y.geometryGroups[D];K=!1;for(A in x.__webglCustomAttributes)if(x.__webglCustomAttributes[A].needsUpdate){K=!0;break}if(y.__dirtyVertices|| +y.__dirtyMorphTargets||y.__dirtyElements||y.__dirtyUvs||y.__dirtyNormals||y.__dirtyColors||y.__dirtyTangents||K){K=e.DYNAMIC_DRAW;var M=void 0,I=void 0,N=void 0,H=void 0;N=void 0;var L=void 0,J=void 0,$=void 0,X=void 0,Ca=void 0,Ha=void 0,Da=void 0,La=void 0,Xa=void 0,ma=void 0,ya=void 0,Ga=void 0,Pa=void 0;J=void 0;$=void 0;H=void 0;X=void 0;H=void 0;var E=void 0,da=void 0;J=void 0;E=void 0;da=void 0;var v=void 0,ab=void 0;E=void 0;da=void 0;v=void 0;ab=void 0;E=void 0;da=void 0;v=void 0;ab=void 0; +E=void 0;da=void 0;v=void 0;H=void 0;X=void 0;L=void 0;N=void 0;N=void 0;E=void 0;da=void 0;v=void 0;var gb=void 0,Ua=0,Ta=0,fb=0,db=0,$a=0,Za=0,Oa=0,Ya=0,Va=0,Y=0,Ea=0;da=E=0;var Qa=x.__vertexArray,hb=x.__uvArray,lb=x.__uv2Array,cb=x.__normalArray,Ia=x.__tangentArray,U=x.__colorArray,la=x.__skinVertexAArray,ia=x.__skinVertexBArray,ca=x.__skinIndexArray,wa=x.__skinWeightArray,Na=x.__morphTargetsArrays,ta=x.__webglCustomAttributes;v=void 0;var W=x.__faceArray,Ka=x.__lineArray,kb=x.__needsSmoothNormals; +Ha=x.__vertexColorType;Ca=x.__uvType;Da=x.__normalType;var Ra=n.geometry,ib=Ra.__dirtyVertices,mb=Ra.__dirtyElements,eb=Ra.__dirtyUvs,jb=Ra.__dirtyNormals,tb=Ra.__dirtyTangents,ub=Ra.__dirtyColors,vb=Ra.__dirtyMorphTargets,pb=Ra.vertices,wb=x.faces,zb=Ra.faces,xb=Ra.faceVertexUvs[0],yb=Ra.faceVertexUvs[1],qb=Ra.skinVerticesA,rb=Ra.skinVerticesB,sb=Ra.skinIndices,nb=Ra.skinWeights,ob=n instanceof THREE.ShadowVolume?Ra.edgeFaces:undefined;morphTargets=Ra.morphTargets;if(ta)for(gb in ta){ta[gb].offset= +0;ta[gb].offsetSrc=0}M=0;for(I=wb.length;M0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,U,K)}if(jb){e.bindBuffer(e.ARRAY_BUFFER,x.__webglNormalBuffer);e.bufferData(e.ARRAY_BUFFER, +cb,K)}if(tb&&Ra.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,x.__webglTangentBuffer);e.bufferData(e.ARRAY_BUFFER,Ia,K)}if(eb&&fb>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglUVBuffer);e.bufferData(e.ARRAY_BUFFER,hb,K)}if(eb&&db>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglUV2Buffer);e.bufferData(e.ARRAY_BUFFER,lb,K)}if(mb){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,x.__webglFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,W,K);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,x.__webglLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER, +Ka,K)}if(Y>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,la,K);e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,ia,K);e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,ca,K);e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,wa,K)}}}y.__dirtyVertices=!1;y.__dirtyMorphTargets=!1;y.__dirtyElements=!1;y.__dirtyUvs=!1;y.__dirtyNormals=!1;y.__dirtyTangents=!1;y.__dirtyColors= +!1}else if(n instanceof THREE.Ribbon){y=n.geometry;if(y.__dirtyVertices||y.__dirtyColors){n=y;D=e.DYNAMIC_DRAW;Ha=n.vertices;x=n.colors;Da=Ha.length;K=x.length;La=n.__vertexArray;M=n.__colorArray;Xa=n.__dirtyColors;if(n.__dirtyVertices){for(I=0;I65535){L[N].counter+=1;H=L[N].hash+"_"+L[N].counter;n.geometryGroups[H]==undefined&&(n.geometryGroups[H]= +{faces:[],materials:I,vertices:0,numMorphTargets:J})}n.geometryGroups[H].faces.push(A);n.geometryGroups[H].vertices+=M}}function C(n,D,y){n.push({buffer:D,object:y,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function V(n){if(n!=na){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)}na=n}}function P(n,D,y){if((y.width&y.width-1)==0&&(y.height&y.height-1)==0){e.texParameteri(n,e.TEXTURE_WRAP_S,aa(D.wrapS));e.texParameteri(n,e.TEXTURE_WRAP_T,aa(D.wrapT));e.texParameteri(n,e.TEXTURE_MAG_FILTER,aa(D.magFilter));e.texParameteri(n,e.TEXTURE_MIN_FILTER,aa(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,pa(D.magFilter));e.texParameteri(n,e.TEXTURE_MIN_FILTER,pa(D.minFilter))}}function Q(n,D){if(n.needsUpdate){if(n.__webglInit){e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n.image)}else{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);n.__webglInit=!0}P(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 ka(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,aa(n.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,aa(n.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,aa(n.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,aa(n.minFilter));e.texImage2D(e.TEXTURE_2D,0,aa(n.format),n.width,n.height,0,aa(n.format),aa(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,y;if(n){D=n.__webglFramebuffer;y=n.width;n=n.height}else{D=null;y=Fa;n=Aa}if(D!=ga){e.bindFramebuffer(e.FRAMEBUFFER,D);e.viewport(qa,ja,y,n);ga=D}}function ea(n,D){var y;if(n=="fragment")y=e.createShader(e.FRAGMENT_SHADER);else n=="vertex"&&(y=e.createShader(e.VERTEX_SHADER));e.shaderSource(y,D);e.compileShader(y);if(!e.getShaderParameter(y,e.COMPILE_STATUS)){console.error(e.getShaderInfoLog(y));console.error(D); +return null}return y}function pa(n){switch(n){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;default:return e.LINEAR}}function aa(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 oa=this,e,xa=document.createElement("canvas"),sa=[],Ba=null,ga=null,ra=!0,fa=null,za=null,na=null,ua=null,qa=0,ja=0,Fa=0,Aa=0,ha=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],va=new THREE.Matrix4,Ja=new Float32Array(16),Sa=new Float32Array(16),Wa=new THREE.Vector4, +O={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};b=b||{};stencil=b.stencil!==undefined?b.stencil:!0;antialias=b.antialias!==undefined?b.antialias:!1;clearColor=b.clearColor!==undefined?new THREE.Color(b.clearColor):new THREE.Color(0);clearAlpha=b.clearAlpha!==undefined?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=xa;this.autoClear=!0;this.sortObjects=!0;(function(n,D,y,x){try{if(!(e= +xa.getContext("experimental-webgl",{antialias:n,stencil:x})))throw"Error creating WebGL context.";}catch(A){console.error(A)}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(D.r,D.g,D.b,y)})(antialias,clearColor,clearAlpha,stencil);this.context=e;var Z=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(stencil){var R={};R.vertices=new Float32Array(12);R.faces=new Uint16Array(6);R.darkness=0.5;R.vertices[0]=-20;R.vertices[1]=-20;R.vertices[2]=-1;R.vertices[3]=20;R.vertices[4]=-20;R.vertices[5]=-1;R.vertices[6]=20;R.vertices[7]=20;R.vertices[8]=-1;R.vertices[9]=-20;R.vertices[10]=20;R.vertices[11]=-1;R.faces[0]=0;R.faces[1]=1;R.faces[2]= +2;R.faces[3]=0;R.faces[4]=2;R.faces[5]=3;R.vertexBuffer=e.createBuffer();R.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,R.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,R.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,R.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,R.faces,e.STATIC_DRAW);R.program=e.createProgram();e.attachShader(R.program,ea("fragment",THREE.ShaderLib.shadowPost.fragmentShader));e.attachShader(R.program,ea("vertex",THREE.ShaderLib.shadowPost.vertexShader)); +e.linkProgram(R.program);R.vertexLocation=e.getAttribLocation(R.program,"position");R.projectionLocation=e.getUniformLocation(R.program,"projectionMatrix");R.darknessLocation=e.getUniformLocation(R.program,"darkness")}var S={};S.vertices=new Float32Array(16);S.faces=new Uint16Array(6);b=0;S.vertices[b++]=-1;S.vertices[b++]=-1;S.vertices[b++]=0;S.vertices[b++]=0;S.vertices[b++]=1;S.vertices[b++]=-1;S.vertices[b++]=1;S.vertices[b++]=0;S.vertices[b++]=1;S.vertices[b++]=1;S.vertices[b++]=1;S.vertices[b++]= +1;S.vertices[b++]=-1;S.vertices[b++]=1;S.vertices[b++]=0;S.vertices[b++]=1;b=0;S.faces[b++]=0;S.faces[b++]=1;S.faces[b++]=2;S.faces[b++]=0;S.faces[b++]=2;S.faces[b++]=3;S.vertexBuffer=e.createBuffer();S.elementBuffer=e.createBuffer();S.tempTexture=e.createTexture();S.occlusionTexture=e.createTexture();e.bindBuffer(e.ARRAY_BUFFER,S.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,S.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,S.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,S.faces,e.STATIC_DRAW); +e.bindTexture(e.TEXTURE_2D,S.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,S.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){S.hasVertexTexture=!1;S.program=e.createProgram();e.attachShader(S.program,ea("fragment",THREE.ShaderLib.lensFlare.fragmentShader));e.attachShader(S.program,ea("vertex",THREE.ShaderLib.lensFlare.vertexShader))}else{S.hasVertexTexture= +!0;S.program=e.createProgram();e.attachShader(S.program,ea("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader));e.attachShader(S.program,ea("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader))}e.linkProgram(S.program);S.attributes={};S.uniforms={};S.attributes.vertex=e.getAttribLocation(S.program,"position");S.attributes.uv=e.getAttribLocation(S.program,"UV");S.uniforms.renderType=e.getUniformLocation(S.program,"renderType");S.uniforms.map=e.getUniformLocation(S.program,"map"); +S.uniforms.occlusionMap=e.getUniformLocation(S.program,"occlusionMap");S.uniforms.opacity=e.getUniformLocation(S.program,"opacity");S.uniforms.scale=e.getUniformLocation(S.program,"scale");S.uniforms.rotation=e.getUniformLocation(S.program,"rotation");S.uniforms.screenPosition=e.getUniformLocation(S.program,"screenPosition");var Ma=!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,ea("fragment",THREE.ShaderLib.sprite.fragmentShader));e.attachShader(_sprite.program,ea("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 bb=!1;this.setSize=function(n,D){xa.width=n;xa.height=D;this.setViewport(0,0,xa.width,xa.height)};this.setViewport=function(n,D,y,x){qa=n;ja=D;Fa=y;Aa=x;e.viewport(qa,ja,Fa,Aa)};this.setScissor=function(n,D,y,x){e.scissor(n,D,y,x)};this.enableScissorTest=function(n){n?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(n){ra=n;e.depthMask(n)};this.setClearColorHex=function(n,D){var y=new THREE.Color(n); +e.clearColor(y.r,y.g,y.b,D)};this.setClearColor=function(n,D){e.clearColor(n.r,n.g,n.b,D)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(n){R.darkness=n};this.getContext=function(){return e};this.initMaterial=function(n,D,y,x){var A,K,M;if(n instanceof THREE.MeshDepthMaterial)M="depth";else if(n instanceof THREE.ShadowVolumeDynamicMaterial)M="shadowVolumeDynamic";else if(n instanceof THREE.MeshNormalMaterial)M="normal"; +else if(n instanceof THREE.MeshBasicMaterial)M="basic";else if(n instanceof THREE.MeshLambertMaterial)M="lambert";else if(n instanceof THREE.MeshPhongMaterial)M="phong";else if(n instanceof THREE.LineBasicMaterial)M="basic";else n instanceof THREE.ParticleBasicMaterial&&(M="particle_basic");if(M){var I=THREE.ShaderLib[M];n.uniforms=THREE.UniformsUtils.clone(I.uniforms);n.vertexShader=I.vertexShader;n.fragmentShader=I.fragmentShader}var N,H,L;N=L=I=0;for(H=D.length;N=0&&e.enableVertexAttribArray(J.color);J.normal>= +0&&e.enableVertexAttribArray(J.normal);J.tangent>=0&&e.enableVertexAttribArray(J.tangent);if(n.skinning&&J.skinVertexA>=0&&J.skinVertexB>=0&&J.skinIndex>=0&&J.skinWeight>=0){e.enableVertexAttribArray(J.skinVertexA);e.enableVertexAttribArray(J.skinVertexB);e.enableVertexAttribArray(J.skinIndex);e.enableVertexAttribArray(J.skinWeight)}for(A in n.attributes)J[A]>=0&&e.enableVertexAttribArray(J[A]);if(n.morphTargets){n.numSupportedMorphTargets=0;if(J.morphTarget0>=0){e.enableVertexAttribArray(J.morphTarget0); +n.numSupportedMorphTargets++}if(J.morphTarget1>=0){e.enableVertexAttribArray(J.morphTarget1);n.numSupportedMorphTargets++}if(J.morphTarget2>=0){e.enableVertexAttribArray(J.morphTarget2);n.numSupportedMorphTargets++}if(J.morphTarget3>=0){e.enableVertexAttribArray(J.morphTarget3);n.numSupportedMorphTargets++}if(J.morphTarget4>=0){e.enableVertexAttribArray(J.morphTarget4);n.numSupportedMorphTargets++}if(J.morphTarget5>=0){e.enableVertexAttribArray(J.morphTarget5);n.numSupportedMorphTargets++}if(J.morphTarget6>= +0){e.enableVertexAttribArray(J.morphTarget6);n.numSupportedMorphTargets++}if(J.morphTarget7>=0){e.enableVertexAttribArray(J.morphTarget7);n.numSupportedMorphTargets++}x.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);n=0;for(A=this.maxMorphTargets;n0||$.faceVertexUvs.length>0)M.__uvArray=new Float32Array(N*2);if($.faceUvs.length>1||$.faceVertexUvs.length>1)M.__uv2Array=new Float32Array(N* +2)}if(I.geometry.skinWeights.length&&I.geometry.skinIndices.length){M.__skinVertexAArray=new Float32Array(N*4);M.__skinVertexBArray=new Float32Array(N*4);M.__skinIndexArray=new Float32Array(N*4);M.__skinWeightArray=new Float32Array(N*4)}M.__faceArray=new Uint16Array(Ca*3+(I.geometry.edgeFaces?I.geometry.edgeFaces.length*6:0));M.__lineArray=new Uint16Array(Ha*2);if(M.numMorphTargets){M.__morphTargetsArrays=[];$=0;for(X=M.numMorphTargets;$=0;A--){x=y.__webglObjects[A].object;if(D==x){y.__webglObjects.splice(A,1);break}}else if(D instanceof THREE.Sprite)for(A=y.__webglSprites.length-1;A>=0;A--){x= +y.__webglSprites[A];if(D==x){y.__webglSprites.splice(A,1);break}}n.__objectsRemoved.splice(0,1)}D=0;for(y=n.__webglObjects.length;D1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+u);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",u,j.index-1).pos;this.points[1]=g;this.points[2]=h;this.points[3]=this.getNextKeyWith("pos",u,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&&t[0][o]===undefined){this.hierarchy[0].update(undefined,!0);for(u=0;u1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+p);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",p,j.index-1).pos;this.points[1]=g;this.points[2]=h;this.points[3]=this.getNextKeyWith("pos",p,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&&t[0][o]===undefined){this.hierarchy[0].update(undefined,!0);for(p=0;pb.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.ColorUtils={adjustHSV:function(b,d,c,f){var g=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(b,g);g.h=THREE.ColorUtils.clamp(g.h+d,0,1);g.s=THREE.ColorUtils.clamp(g.s+c,0,1);g.v=THREE.ColorUtils.clamp(g.v+f,0,1);b.setHSV(g.h,g.s,g.v)},rgbToHsv:function(b,d){var c=b.r,f=b.g,g=b.b,h=Math.max(Math.max(c,f),g),j=Math.min(Math.min(c,f),g);if(j==h)j=c=0;else{var k=h-j;j=k/h;c=c==h?(f-g)/k:f==h?2+(g-c)/k:4+(c-f)/k;c/=6;c<0&&(c+=1);c>1&&(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 t=0,p=j.length;t25&&(h=25);g=(h-1)*0.5;c=Array(h);for(d=f=0;d=0?y:y+g;y=this.verticalAngleMap.srcRange;u=this.verticalAngleMap.dstRange; -this.phi=(this.phi-y[0])*(u[1]-u[0])/(y[1]-y[0])+u[0];y=this.horizontalAngleMap.srcRange;u=this.horizontalAngleMap.dstRange;this.theta=(this.theta-y[0])*(u[1]-u[0])/(y[1]-y[0])+u[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,t,p)};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.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,h=Math.PI/180;this.update=function(o,t,u){var w,p;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;w=this.phi%g;this.phi=w>=0?w:w+g;w=this.verticalAngleMap.srcRange;p=this.verticalAngleMap.dstRange; +this.phi=(this.phi-w[0])*(p[1]-p[0])/(w[1]-w[0])+p[0];w=this.horizontalAngleMap.srcRange;p=this.horizontalAngleMap.dstRange;this.theta=(this.theta-w[0])*(p[1]-p[0])/(w[1]-w[0])+p[0];w=this.target.position;w.x=100*Math.sin(this.phi)*Math.cos(this.theta);w.y=100*Math.cos(this.phi);w.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,o,t,u)};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,t){return function(){t.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.0050;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= +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; @@ -406,91 +408,91 @@ this.rollSpeed;this.translateX(this.moveVector.x*c);this.translateY(this.moveVec 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,t=0,p=0,y=0,u=0,z=0,H=window.innerWidth/2,G=window.innerHeight/2;this.update= -function(){var B=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=B;this.delta=(B-this.lastUpdate)/1E3;this.lastUpdate=B;if(this.mouseLook){B=this.delta*this.lookSpeed;this.rotateHorizontally(B*u);this.rotateVertically(B*z)}B=this.delta*this.movementSpeed;this.translateZ(B*(t>0||this.autoForward&&!(t<0)?1:t));this.translateX(B*p);this.translateY(B*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< +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,t=0,u=0,w=0,p=0,z=0,G=window.innerWidth/2,F=window.innerHeight/2;this.update= +function(){var B=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=B;this.delta=(B-this.lastUpdate)/1E3;this.lastUpdate=B;if(this.mouseLook){B=this.delta*this.lookSpeed;this.rotateHorizontally(B*p);this.rotateVertically(B*z)}B=this.delta*this.movementSpeed;this.translateZ(B*(t>0||this.autoForward&&!(t<0)?1:t));this.translateX(B*u);this.translateY(B*w);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(B){this.position.x+=this.matrix.n11*B;this.position.y+=this.matrix.n21*B;this.position.z+=this.matrix.n31*B};this.translateY=function(B){this.position.x+=this.matrix.n12*B;this.position.y+=this.matrix.n22*B;this.position.z+=this.matrix.n32*B};this.translateZ=function(B){this.position.x-=this.matrix.n13*B;this.position.y-= this.matrix.n23*B;this.position.z-=this.matrix.n33*B};this.rotateHorizontally=function(B){g.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);g.multiplyScalar(B);this.forward.subSelf(g);this.forward.normalize()};this.rotateVertically=function(B){h.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);h.multiplyScalar(B);this.forward.addSelf(h);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(B){B.preventDefault()},!1);this.domElement.addEventListener("mousemove", -function(B){u=(B.clientX-H)/window.innerWidth;z=(B.clientY-G)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(B){B.preventDefault();B.stopPropagation();switch(B.button){case 0:t=1;break;case 2:t=-1}},!1);this.domElement.addEventListener("mouseup",function(B){B.preventDefault();B.stopPropagation();switch(B.button){case 0:t=0;break;case 2:t=0}},!1);this.domElement.addEventListener("keydown",function(B){switch(B.keyCode){case 38:case 87:t=1;break;case 37:case 65:p=-1;break; -case 40:case 83:t=-1;break;case 39:case 68:p=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(B){switch(B.keyCode){case 38:case 87:t=0;break;case 37:case 65:p=0;break;case 40:case 83:t=0;break;case 39:case 68:p=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; +function(B){p=(B.clientX-G)/window.innerWidth;z=(B.clientY-F)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(B){B.preventDefault();B.stopPropagation();switch(B.button){case 0:t=1;break;case 2:t=-1}},!1);this.domElement.addEventListener("mouseup",function(B){B.preventDefault();B.stopPropagation();switch(B.button){case 0:t=0;break;case 2:t=0}},!1);this.domElement.addEventListener("keydown",function(B){switch(B.keyCode){case 38:case 87:t=1;break;case 37:case 65:u=-1;break; +case 40:case 83:t=-1;break;case 39:case 68:u=1;break;case 81:m=!0;o=1;break;case 69:m=!0;o=-1;break;case 82:w=1;break;case 70:w=-1}},!1);this.domElement.addEventListener("keyup",function(B){switch(B.keyCode){case 38:case 87:t=0;break;case 37:case 65:u=0;break;case 40:case 83:t=0;break;case 39:case 68:u=0;break;case 81:m=!1;break;case 69:m=!1;break;case 82:w=0;break;case 70:w=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(G,B,R,E,P,L,O,sa){var oa,ta,ha=f||1,fa=g||1,e=P/2,qa=L/2,Ea=t.vertices.length;if(G=="x"&&B=="y"||G=="y"&&B=="x")oa="z";else if(G=="x"&&B=="z"||G=="z"&&B=="x"){oa="y";fa=h||1}else if(G=="z"&&B=="y"||G=="y"&&B=="z"){oa="x";ha=h||1}var Da=ha+1,ea=fa+1;P/=ha;var ga=L/fa;for(ta=0;ta0){j(0,0,-t-(h||0));for(m=b;m0){j(0,0,t+(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){j(0,0,-t-(h||0));for(m=b;m0){j(0,0,t+(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||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(p,k,y)))-1);o.push(t)}d.push(o)}var u,z,H;g=d.length;for(c=0;c0)for(f=0;f1){u=this.vertices[j].position.clone(); -z=this.vertices[m].position.clone();H=this.vertices[o].position.clone();u.normalize();z.normalize();H.normalize();this.faces.push(new THREE.Face3(j,m,o,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(H.x,H.y,H.z)]));this.faceVertexUvs[0].push([t,p,G])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere; +THREE.Sphere=function(b,d,c){THREE.Geometry.call(this);var f,g=Math.PI,h=Math.max(3,d||8),j=Math.max(2,c||6);d=[];for(c=0;c0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(u,k,w)))-1);o.push(t)}d.push(o)}var p,z,G;g=d.length;for(c=0;c0)for(f=0;f1){p=this.vertices[j].position.clone(); +z=this.vertices[m].position.clone();G=this.vertices[o].position.clone();p.normalize();z.normalize();G.normalize();this.faces.push(new THREE.Face3(j,m,o,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([t,u,F])}}}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(p,y,u,z,H,G){y=u/z*p;u=Math.cos(y);return new THREE.Vector3(H*(2+u)*0.5*Math.cos(p),H*(2+u)*Math.sin(p)*0.5,G*H*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;W|=(La&127)<<16|T<<8;if(W==0&&n==-127)return 0;return(1-2*(db>>7))*(1+W*Math.pow(2,-23))*Math.pow(2,n)}function k(Q,aa){var W=t(Q,aa),T=t(Q,aa+1),La=t(Q,aa+2);return(t(Q,aa+3)<<24)+(La<<16)+(T<<8)+W}function m(Q,aa){var W=t(Q,aa);return(t(Q,aa+1)<<8)+W}function o(Q,aa){var W=t(Q,aa);return W>127? -W-256:W}function t(Q,aa){return Q.charCodeAt(aa)&255}function p(Q){var aa,W,T;aa=k(b,Q);W=k(b,Q+O);T=k(b,Q+sa);Q=m(b,Q+oa);THREE.BinaryLoader.prototype.f3(B,aa,W,T,Q)}function y(Q){var aa,W,T,La,db,n;aa=k(b,Q);W=k(b,Q+O);T=k(b,Q+sa);La=m(b,Q+oa);db=k(b,Q+ta);n=k(b,Q+ha);Q=k(b,Q+fa);THREE.BinaryLoader.prototype.f3n(B,P,aa,W,T,La,db,n,Q)}function u(Q){var aa,W,T,La;aa=k(b,Q);W=k(b,Q+e);T=k(b,Q+qa);La=k(b,Q+Ea);Q=m(b,Q+Da);THREE.BinaryLoader.prototype.f4(B,aa,W,T,La,Q)}function z(Q){var aa,W,T,La,db, -n,C,w;aa=k(b,Q);W=k(b,Q+e);T=k(b,Q+qa);La=k(b,Q+Ea);db=m(b,Q+Da);n=k(b,Q+ea);C=k(b,Q+ga);w=k(b,Q+xa);Q=k(b,Q+va);THREE.BinaryLoader.prototype.f4n(B,P,aa,W,T,La,db,n,C,w,Q)}function H(Q){var aa,W;aa=k(b,Q);W=k(b,Q+ra);Q=k(b,Q+ca);THREE.BinaryLoader.prototype.uv3(B.faceVertexUvs[0],L[aa*2],L[aa*2+1],L[W*2],L[W*2+1],L[Q*2],L[Q*2+1])}function G(Q){var aa,W,T;aa=k(b,Q);W=k(b,Q+ka);T=k(b,Q+pa);Q=k(b,Q+Fa);THREE.BinaryLoader.prototype.uv4(B.faceVertexUvs[0],L[aa*2],L[aa*2+1],L[W*2],L[W*2+1],L[T*2],L[T*2+ -1],L[Q*2],L[Q*2+1])}var B=this,R=0,E,P=[],L=[],O,sa,oa,ta,ha,fa,e,qa,Ea,Da,ea,ga,xa,va,ra,ca,ka,pa,Fa,ja,ia,Ia,Ya,ab,Ra;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(B,f,h);E={signature:b.substr(R,8),header_bytes:t(b,R+8),vertex_coordinate_bytes:t(b,R+9),normal_coordinate_bytes:t(b,R+10),uv_coordinate_bytes:t(b,R+11),vertex_index_bytes:t(b,R+12),normal_index_bytes:t(b,R+13),uv_index_bytes:t(b,R+14),material_index_bytes:t(b,R+15),nvertices:k(b,R+16),nnormals:k(b,R+16+4),nuvs:k(b, -R+16+8),ntri_flat:k(b,R+16+12),ntri_smooth:k(b,R+16+16),ntri_flat_uv:k(b,R+16+20),ntri_smooth_uv:k(b,R+16+24),nquad_flat:k(b,R+16+28),nquad_smooth:k(b,R+16+32),nquad_flat_uv:k(b,R+16+36),nquad_smooth_uv:k(b,R+16+40)};R+=E.header_bytes;O=E.vertex_index_bytes;sa=E.vertex_index_bytes*2;oa=E.vertex_index_bytes*3;ta=E.vertex_index_bytes*3+E.material_index_bytes;ha=E.vertex_index_bytes*3+E.material_index_bytes+E.normal_index_bytes;fa=E.vertex_index_bytes*3+E.material_index_bytes+E.normal_index_bytes*2; -e=E.vertex_index_bytes;qa=E.vertex_index_bytes*2;Ea=E.vertex_index_bytes*3;Da=E.vertex_index_bytes*4;ea=E.vertex_index_bytes*4+E.material_index_bytes;ga=E.vertex_index_bytes*4+E.material_index_bytes+E.normal_index_bytes;xa=E.vertex_index_bytes*4+E.material_index_bytes+E.normal_index_bytes*2;va=E.vertex_index_bytes*4+E.material_index_bytes+E.normal_index_bytes*3;ra=E.uv_index_bytes;ca=E.uv_index_bytes*2;ka=E.uv_index_bytes;pa=E.uv_index_bytes*2;Fa=E.uv_index_bytes*3;h=E.vertex_index_bytes*3+E.material_index_bytes; -Ra=E.vertex_index_bytes*4+E.material_index_bytes;ja=E.ntri_flat*h;ia=E.ntri_smooth*(h+E.normal_index_bytes*3);Ia=E.ntri_flat_uv*(h+E.uv_index_bytes*3);Ya=E.ntri_smooth_uv*(h+E.normal_index_bytes*3+E.uv_index_bytes*3);ab=E.nquad_flat*Ra;h=E.nquad_smooth*(Ra+E.normal_index_bytes*4);Ra=E.nquad_flat_uv*(Ra+E.uv_index_bytes*4);R+=function(Q){for(var aa,W,T,La=E.vertex_coordinate_bytes*3,db=Q+E.nvertices*La;Q>7)-127;R|=(Ma&127)<<16|S<<8;if(R==0&&n==-127)return 0;return(1-2*(bb>>7))*(1+R*Math.pow(2,-23))*Math.pow(2,n)}function k(O,Z){var R=t(O,Z),S=t(O,Z+1),Ma=t(O,Z+2);return(t(O,Z+3)<<24)+(Ma<<16)+(S<<8)+R}function m(O,Z){var R=t(O,Z);return(t(O,Z+1)<<8)+R}function o(O,Z){var R=t(O,Z);return R>127?R-256:R}function t(O, +Z){return O.charCodeAt(Z)&255}function u(O){var Z,R,S;Z=k(b,O);R=k(b,O+Q);S=k(b,O+ka);O=m(b,O+ea);THREE.BinaryLoader.prototype.f3(B,Z,R,S,O)}function w(O){var Z,R,S,Ma,bb,n;Z=k(b,O);R=k(b,O+Q);S=k(b,O+ka);Ma=m(b,O+ea);bb=k(b,O+pa);n=k(b,O+aa);O=k(b,O+oa);THREE.BinaryLoader.prototype.f3n(B,V,Z,R,S,Ma,bb,n,O)}function p(O){var Z,R,S,Ma;Z=k(b,O);R=k(b,O+e);S=k(b,O+xa);Ma=k(b,O+sa);O=m(b,O+Ba);THREE.BinaryLoader.prototype.f4(B,Z,R,S,Ma,O)}function z(O){var Z,R,S,Ma,bb,n,D,y;Z=k(b,O);R=k(b,O+e);S=k(b, +O+xa);Ma=k(b,O+sa);bb=m(b,O+Ba);n=k(b,O+ga);D=k(b,O+ra);y=k(b,O+fa);O=k(b,O+za);THREE.BinaryLoader.prototype.f4n(B,V,Z,R,S,Ma,bb,n,D,y,O)}function G(O){var Z,R;Z=k(b,O);R=k(b,O+na);O=k(b,O+ua);THREE.BinaryLoader.prototype.uv3(B.faceVertexUvs[0],P[Z*2],P[Z*2+1],P[R*2],P[R*2+1],P[O*2],P[O*2+1])}function F(O){var Z,R,S;Z=k(b,O);R=k(b,O+qa);S=k(b,O+ja);O=k(b,O+Fa);THREE.BinaryLoader.prototype.uv4(B.faceVertexUvs[0],P[Z*2],P[Z*2+1],P[R*2],P[R*2+1],P[S*2],P[S*2+1],P[O*2],P[O*2+1])}var B=this,T=0,C,V=[], +P=[],Q,ka,ea,pa,aa,oa,e,xa,sa,Ba,ga,ra,fa,za,na,ua,qa,ja,Fa,Aa,ha,va,Ja,Sa,Wa;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(B,f,h);C={signature:b.substr(T,8),header_bytes:t(b,T+8),vertex_coordinate_bytes:t(b,T+9),normal_coordinate_bytes:t(b,T+10),uv_coordinate_bytes:t(b,T+11),vertex_index_bytes:t(b,T+12),normal_index_bytes:t(b,T+13),uv_index_bytes:t(b,T+14),material_index_bytes:t(b,T+15),nvertices:k(b,T+16),nnormals:k(b,T+16+4),nuvs:k(b,T+16+8),ntri_flat:k(b,T+16+12),ntri_smooth:k(b, +T+16+16),ntri_flat_uv:k(b,T+16+20),ntri_smooth_uv:k(b,T+16+24),nquad_flat:k(b,T+16+28),nquad_smooth:k(b,T+16+32),nquad_flat_uv:k(b,T+16+36),nquad_smooth_uv:k(b,T+16+40)};T+=C.header_bytes;Q=C.vertex_index_bytes;ka=C.vertex_index_bytes*2;ea=C.vertex_index_bytes*3;pa=C.vertex_index_bytes*3+C.material_index_bytes;aa=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes;oa=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes*2;e=C.vertex_index_bytes;xa=C.vertex_index_bytes* +2;sa=C.vertex_index_bytes*3;Ba=C.vertex_index_bytes*4;ga=C.vertex_index_bytes*4+C.material_index_bytes;ra=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes;fa=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*2;za=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*3;na=C.uv_index_bytes;ua=C.uv_index_bytes*2;qa=C.uv_index_bytes;ja=C.uv_index_bytes*2;Fa=C.uv_index_bytes*3;h=C.vertex_index_bytes*3+C.material_index_bytes;Wa=C.vertex_index_bytes*4+C.material_index_bytes; +Aa=C.ntri_flat*h;ha=C.ntri_smooth*(h+C.normal_index_bytes*3);va=C.ntri_flat_uv*(h+C.uv_index_bytes*3);Ja=C.ntri_smooth_uv*(h+C.normal_index_bytes*3+C.uv_index_bytes*3);Sa=C.nquad_flat*Wa;h=C.nquad_smooth*(Wa+C.normal_index_bytes*4);Wa=C.nquad_flat_uv*(Wa+C.uv_index_bytes*4);T+=function(O){for(var Z,R,S,Ma=C.vertex_coordinate_bytes*3,bb=O+C.nvertices*Ma;O1&&(ta=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(O,ta);object.name=u;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=R.visible;ea.scene.addObject(object);ea.objects[u]=object;if(R.meshCollider){var ra=THREE.CollisionUtils.MeshColliderWBox(object);ea.scene.collisions.colliders.push(ra)}if(R.castsShadow){ra= -new THREE.ShadowVolume(O);ea.scene.addChild(ra);ra.position=object.position;ra.rotation=object.rotation;ra.scale=object.scale}if(R.trigger&&R.trigger.toLowerCase()!="none"){ra={type:R.trigger,object:R};ea.triggers[object.name]=ra}}}else{E=R.position;r=R.rotation;q=R.quaternion;s=R.scale;q=0;object=new THREE.Object3D;object.name=u;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=R.visible!==undefined?R.visible:!1;ea.scene.addObject(object);ea.objects[u]=object;ea.empties[u]=object;if(R.trigger&&R.trigger.toLowerCase()!="none"){ra={type:R.trigger,object:R};ea.triggers[object.name]=ra}}}}function m(ra){return function(ca){ea.geometries[ra]=ca;k();e-=1;c.onLoadComplete();t()}}function o(ra){return function(ca){ea.geometries[ra]=ca}}function t(){c.callbackProgress({totalModels:Ea,totalTextures:Da,loadedModels:Ea-e,loadedTextures:Da-qa},ea);c.onLoadProgress(); -e==0&&qa==0&&d(ea)}var p,y,u,z,H,G,B,R,E,P,L,O,sa,oa,ta,ha,fa,e,qa,Ea,Da,ea;ha=h.data;h=new THREE.BinaryLoader;fa=new THREE.JSONLoader;qa=e=0;ea={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};var ga=!1;for(u in ha.objects){R=ha.objects[u];if(R.meshCollider){ga=!0;break}}if(ga)ea.scene.collisions=new THREE.CollisionSystem;if(ha.transform){ga=ha.transform.position;P=ha.transform.rotation;var xa=ha.transform.scale;ga&&ea.scene.position.set(ga[0], -ga[1],ga[2]);P&&ea.scene.rotation.set(P[0],P[1],P[2]);xa&&ea.scene.scale.set(xa[0],xa[1],xa[2]);(ga||P||xa)&&ea.scene.updateMatrix()}ga=function(){qa-=1;t();c.onLoadComplete()};for(H in ha.cameras){P=ha.cameras[H];if(P.type=="perspective")sa=new THREE.Camera(P.fov,P.aspect,P.near,P.far);else if(P.type=="ortho"){sa=new THREE.Camera;sa.projectionMatrix=THREE.Matrix4.makeOrtho(P.left,P.right,P.top,P.bottom,P.near,P.far)}E=P.position;P=P.target;sa.position.set(E[0],E[1],E[2]);sa.target.position.set(P[0], -P[1],P[2]);ea.cameras[H]=sa}for(z in ha.lights){H=ha.lights[z];sa=H.color!==undefined?H.color:16777215;P=H.intensity!==undefined?H.intensity:1;if(H.type=="directional"){E=H.direction;light=new THREE.DirectionalLight(sa,P);light.position.set(E[0],E[1],E[2]);light.position.normalize()}else if(H.type=="point"){E=H.position;light=new THREE.PointLight(sa,P);light.position.set(E[0],E[1],E[2])}ea.scene.addLight(light);ea.lights[z]=light}for(G in ha.fogs){z=ha.fogs[G];if(z.type=="linear")oa=new THREE.Fog(0, -z.near,z.far);else z.type=="exp2"&&(oa=new THREE.FogExp2(0,z.density));P=z.color;oa.color.setRGB(P[0],P[1],P[2]);ea.fogs[G]=oa}if(ea.cameras&&ha.defaults.camera)ea.currentCamera=ea.cameras[ha.defaults.camera];if(ea.fogs&&ha.defaults.fog)ea.scene.fog=ea.fogs[ha.defaults.fog];P=ha.defaults.bgcolor;ea.bgColor=new THREE.Color;ea.bgColor.setRGB(P[0],P[1],P[2]);ea.bgColorAlpha=ha.defaults.bgalpha;for(p in ha.geometries){G=ha.geometries[p];if(G.type=="bin_mesh"||G.type=="ascii_mesh"){e+=1;c.onLoadStart()}}Ea= -e;for(p in ha.geometries){G=ha.geometries[p];if(G.type=="cube"){O=new THREE.Cube(G.width,G.height,G.depth,G.segmentsWidth,G.segmentsHeight,G.segmentsDepth,null,G.flipped,G.sides);ea.geometries[p]=O}else if(G.type=="plane"){O=new THREE.Plane(G.width,G.height,G.segmentsWidth,G.segmentsHeight);ea.geometries[p]=O}else if(G.type=="sphere"){O=new THREE.Sphere(G.radius,G.segmentsWidth,G.segmentsHeight);ea.geometries[p]=O}else if(G.type=="cylinder"){O=new THREE.Cylinder(G.numSegs,G.topRad,G.botRad,G.height, -G.topOffset,G.botOffset);ea.geometries[p]=O}else if(G.type=="torus"){O=new THREE.Torus(G.radius,G.tube,G.segmentsR,G.segmentsT);ea.geometries[p]=O}else if(G.type=="icosahedron"){O=new THREE.Icosahedron(G.subdivisions);ea.geometries[p]=O}else if(G.type=="bin_mesh")h.load({model:j(G.url,ha.urlBaseType),callback:m(p)});else if(G.type=="ascii_mesh")fa.load({model:j(G.url,ha.urlBaseType),callback:m(p)});else if(G.type=="embedded_mesh")(G=ha.embeds[G.id])&&fa.createModel(G,o(p),"")}for(B in ha.textures){p= -ha.textures[B];if(p.url instanceof Array){qa+=p.url.length;for(h=0;h1&&(pa=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(Q,pa);object.name=p;object.position.set(C[0],C[1],C[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=T.visible;ga.scene.addObject(object);ga.objects[p]=object;if(T.meshCollider){var na=THREE.CollisionUtils.MeshColliderWBox(object);ga.scene.collisions.colliders.push(na)}if(T.castsShadow){na= +new THREE.ShadowVolume(Q);ga.scene.addChild(na);na.position=object.position;na.rotation=object.rotation;na.scale=object.scale}if(T.trigger&&T.trigger.toLowerCase()!="none"){na={type:T.trigger,object:T};ga.triggers[object.name]=na}}}else{C=T.position;r=T.rotation;q=T.quaternion;s=T.scale;q=0;object=new THREE.Object3D;object.name=p;object.position.set(C[0],C[1],C[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=T.visible!==undefined?T.visible:!1;ga.scene.addObject(object);ga.objects[p]=object;ga.empties[p]=object;if(T.trigger&&T.trigger.toLowerCase()!="none"){na={type:T.trigger,object:T};ga.triggers[object.name]=na}}}}function m(na){return function(ua){ga.geometries[na]=ua;k();e-=1;c.onLoadComplete();t()}}function o(na){return function(ua){ga.geometries[na]=ua}}function t(){c.callbackProgress({totalModels:sa,totalTextures:Ba,loadedModels:sa-e,loadedTextures:Ba-xa},ga);c.onLoadProgress(); +e==0&&xa==0&&d(ga)}var u,w,p,z,G,F,B,T,C,V,P,Q,ka,ea,pa,aa,oa,e,xa,sa,Ba,ga;aa=h.data;h=new THREE.BinaryLoader;oa=new THREE.JSONLoader;xa=e=0;ga={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};var ra=!1;for(p in aa.objects){T=aa.objects[p];if(T.meshCollider){ra=!0;break}}if(ra)ga.scene.collisions=new THREE.CollisionSystem;if(aa.transform){ra=aa.transform.position;V=aa.transform.rotation;var fa=aa.transform.scale;ra&&ga.scene.position.set(ra[0], +ra[1],ra[2]);V&&ga.scene.rotation.set(V[0],V[1],V[2]);fa&&ga.scene.scale.set(fa[0],fa[1],fa[2]);(ra||V||fa)&&ga.scene.updateMatrix()}ra=function(){xa-=1;t();c.onLoadComplete()};for(G in aa.cameras){V=aa.cameras[G];if(V.type=="perspective")ka=new THREE.Camera(V.fov,V.aspect,V.near,V.far);else if(V.type=="ortho"){ka=new THREE.Camera;ka.projectionMatrix=THREE.Matrix4.makeOrtho(V.left,V.right,V.top,V.bottom,V.near,V.far)}C=V.position;V=V.target;ka.position.set(C[0],C[1],C[2]);ka.target.position.set(V[0], +V[1],V[2]);ga.cameras[G]=ka}for(z in aa.lights){G=aa.lights[z];ka=G.color!==undefined?G.color:16777215;V=G.intensity!==undefined?G.intensity:1;if(G.type=="directional"){C=G.direction;light=new THREE.DirectionalLight(ka,V);light.position.set(C[0],C[1],C[2]);light.position.normalize()}else if(G.type=="point"){C=G.position;light=new THREE.PointLight(ka,V);light.position.set(C[0],C[1],C[2])}ga.scene.addLight(light);ga.lights[z]=light}for(F in aa.fogs){z=aa.fogs[F];if(z.type=="linear")ea=new THREE.Fog(0, +z.near,z.far);else z.type=="exp2"&&(ea=new THREE.FogExp2(0,z.density));V=z.color;ea.color.setRGB(V[0],V[1],V[2]);ga.fogs[F]=ea}if(ga.cameras&&aa.defaults.camera)ga.currentCamera=ga.cameras[aa.defaults.camera];if(ga.fogs&&aa.defaults.fog)ga.scene.fog=ga.fogs[aa.defaults.fog];V=aa.defaults.bgcolor;ga.bgColor=new THREE.Color;ga.bgColor.setRGB(V[0],V[1],V[2]);ga.bgColorAlpha=aa.defaults.bgalpha;for(u in aa.geometries){F=aa.geometries[u];if(F.type=="bin_mesh"||F.type=="ascii_mesh"){e+=1;c.onLoadStart()}}sa= +e;for(u in aa.geometries){F=aa.geometries[u];if(F.type=="cube"){Q=new THREE.Cube(F.width,F.height,F.depth,F.segmentsWidth,F.segmentsHeight,F.segmentsDepth,null,F.flipped,F.sides);ga.geometries[u]=Q}else if(F.type=="plane"){Q=new THREE.Plane(F.width,F.height,F.segmentsWidth,F.segmentsHeight);ga.geometries[u]=Q}else if(F.type=="sphere"){Q=new THREE.Sphere(F.radius,F.segmentsWidth,F.segmentsHeight);ga.geometries[u]=Q}else if(F.type=="cylinder"){Q=new THREE.Cylinder(F.numSegs,F.topRad,F.botRad,F.height, +F.topOffset,F.botOffset);ga.geometries[u]=Q}else if(F.type=="torus"){Q=new THREE.Torus(F.radius,F.tube,F.segmentsR,F.segmentsT);ga.geometries[u]=Q}else if(F.type=="icosahedron"){Q=new THREE.Icosahedron(F.subdivisions);ga.geometries[u]=Q}else if(F.type=="bin_mesh")h.load({model:j(F.url,aa.urlBaseType),callback:m(u)});else if(F.type=="ascii_mesh")oa.load({model:j(F.url,aa.urlBaseType),callback:m(u)});else if(F.type=="embedded_mesh")(F=aa.embeds[F.id])&&oa.createModel(F,o(u),"")}for(B in aa.textures){u= +aa.textures[B];if(u.url instanceof Array){xa+=u.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 u=Math.floor(t-k);u<1&&(u=1);k=Math.floor(t+k);k>this.size-1&&(k=this.size-1);for(var z,H,G,B,R,E;p0&&(this.field[G+z]+=B)}}}};this.addPlaneX=function(c,f){var g,h,j,k,m,o=this.size,t=this.yd,p=this.zd,y=this.field,u=o*Math.sqrt(c/f);u>o&&(u=o);for(g=0;g0)for(h=0;ht&&(z=t);for(h=0;h0){m=h*p;for(g=0;gsize&&(dist=size);for(j=0;j0){m=zd*j;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 w=Math.floor(o-k);w<1&&(w=1);o=Math.floor(o+k);o>this.size-1&& +(o=this.size-1);var p=Math.floor(t-k);p<1&&(p=1);k=Math.floor(t+k);k>this.size-1&&(k=this.size-1);for(var z,G,F,B,T,C;u0&&(this.field[F+z]+=B)}}}};this.addPlaneX=function(c,f){var g,h,j,k,m,o=this.size,t=this.yd,u=this.zd,w=this.field,p=o*Math.sqrt(c/f);p>o&&(p=o);for(g=0;g0)for(h=0;ht&&(z=t);for(h=0;h0){m=h*u;for(g=0;gsize&&(dist=size);for(j=0;j0){m=zd*j;for(h=0;h>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* -255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)}; +THREE.Color.prototype={copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex},setHex:function(a){this.hex=~~a&16777215;this.updateRGB()},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;this.updateHex()},setHSV:function(a,b,c){var d,e,g,f,i,h;if(c==0)d=e=g=0;else{f=Math.floor(a*6);i=a*6-f;a=c*(1-b);h=c*(1-b*i);b=c*(1-b*(1-i));switch(f){case 1:d=h;e=c;g=a;break;case 2:d=a;e=c;g=b;break;case 3:d=a;e=h;g=c;break;case 4:d=b;e=a;g=c;break;case 5:d=c;e=a;g=h;break;case 6:case 0:d=c;e=b;g=a}}this.setRGB(d, +e,g)},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(a,b){this.set(a||0,b||0)}; THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/ this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)}; THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a, @@ -12,59 +11,59 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPosit 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)}; THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(this.x+(a.x-this.x)*b,this.y+(a.y-this.y)*b,this.z+(a.z-this.z)*b,this.w+(a.w-this.w)*b)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a0&&D>0&&s+D<1}var c,d,e,h,f,k,g,i,n,j, -p,r=a.geometry,y=r.vertices,A=[];c=0;for(d=r.faces.length;c0:n<0)){i=i.dot((new THREE.Vector3).sub(h,j))/ -n;j=j.addSelf(p.multiplyScalar(i));if(e instanceof THREE.Face3){if(b(j,h,f,k)){e={distance:this.origin.distanceTo(j),point:j,face:e,object:a};A.push(e)}}else if(e instanceof THREE.Face4&&(b(j,h,f,g)||b(j,f,k,g))){e={distance:this.origin.distanceTo(j),point:j,face:e,object:a};A.push(e)}}}return A}}; -THREE.Rectangle=function(){function a(){h=d-b;f=e-c}var b,c,d,e,h,f,k=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,i,n,j){k=!1;b=g;c=i;d=n;e=j;a()};this.addPoint=function(g,i){if(k){k=!1;b=g;c=i;d=g;e=i}else{b=bg?d:g;e=e>i?e:i}a()}; -this.add3Points=function(g,i,n,j,p,r){if(k){k=!1;b=gn?g>p?g:p:n>p?n:p;e=i>j?i>r?i:r:j>r?j:r}else{b=gn?g>p?g>d?g:d:p>d?p:d:n>p?n>d?n:d:p>d?p:d;e=i>j?i>r?i>e?i:e:r>e?r:e:j>r?j>e?j:e:r>e?r:e}a()};this.addRectangle=function(g){if(k){k=!1;b=g.getLeft();c=g.getTop();d=g.getRight();e=g.getBottom()}else{b=bg.getRight()? -d:g.getRight();e=e>g.getBottom()?e:g.getBottom()}a()};this.inflate=function(g){b-=g;c-=g;d+=g;e+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d=0&&Math.min(e,g.getBottom())-Math.max(c,g.getTop())>=0};this.empty=function(){k=!0;e=d=c=b=0;a()};this.isEmpty=function(){return k}}; +THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a0&&D>0&&H+D<1}var c,d,e,g,f,i,h, +j,p,n,o,k=a.geometry,t=k.vertices,w=[];c=0;for(d=k.faces.length;c0:p<0)){j=j.dot((new THREE.Vector3).sub(g, +n))/p;n=n.addSelf(o.multiplyScalar(j));if(e instanceof THREE.Face3){if(b(n,g,f,i)){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};w.push(e)}}else if(e instanceof THREE.Face4&&(b(n,g,f,h)||b(n,f,i,h))){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};w.push(e)}}}return w}}; +THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(h,j,p,n){i=!1;b=h;c=j;d=p;e=n;a()};this.addPoint=function(h,j){if(i){i=!1;b=h;c=j;d=h;e=j}else{b=bh?d:h;e=e>j?e:j}a()}; +this.add3Points=function(h,j,p,n,o,k){if(i){i=!1;b=hp?h>o?h:o:p>o?p:o;e=j>n?j>k?j:k:n>k?n:k}else{b=hp?h>o?h>d?h:d:o>d?o:d:p>o?p>d?p:d:o>d?o:d;e=j>n?j>k?j>e?j:e:k>e?k:e:n>k?n>e?n:e:k>e?k:e}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=bh.getRight()? +d:h.getRight();e=e>h.getBottom()?e:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;d+=h;e+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();d=d=0&&Math.min(e,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){i=!0;e=d=c=b=0;a()};this.isEmpty=function(){return i}}; THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}}; -THREE.Matrix4=function(a,b,c,d,e,h,f,k,g,i,n,j,p,r,y,A){this.set(a||1,b||0,c||0,d||0,e||0,h||1,f||0,k||0,g||0,i||0,n||1,j||0,p||0,r||0,y||0,A||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(a,b,c,d,e,h,f,k,g,i,n,j,p,r,y,A){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=h;this.n23=f;this.n24=k;this.n31=g;this.n32=i;this.n33=n;this.n34=j;this.n41=p;this.n42=r;this.n43=y;this.n44=A;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__v1, -e=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,b).normalize();if(h.length()===0)h.z=1;d.cross(c,h).normalize();if(d.length()===0){h.x+=1.0E-4;d.cross(c,h).normalize()}e.cross(h,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=h.x;this.n21=d.y;this.n22=e.y;this.n23=h.y;this.n31=d.z;this.n32=e.z;this.n33=h.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23* +THREE.Matrix4=function(a,b,c,d,e,g,f,i,h,j,p,n,o,k,t,w){this.set(a||1,b||0,c||0,d||0,e||0,g||1,f||0,i||0,h||0,j||0,p||1,n||0,o||0,k||0,t||0,w||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(a,b,c,d,e,g,f,i,h,j,p,n,o,k,t,w){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=f;this.n24=i;this.n31=h;this.n32=j;this.n33=p;this.n34=n;this.n41=o;this.n42=k;this.n43=t;this.n44=w;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__v1, +e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;d.cross(c,g).normalize();if(d.length()===0){g.x+=1.0E-4;d.cross(c,g).normalize()}e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23* d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize(); -return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,h=a.n14,f=a.n21,k=a.n22,g=a.n23,i=a.n24,n=a.n31,j=a.n32,p=a.n33,r=a.n34,y=a.n41,A=a.n42,D=a.n43,z=a.n44,T=b.n11,U=b.n12,X=b.n13,s=b.n14,o=b.n21,L=b.n22, -R=b.n23,aa=b.n24,ba=b.n31,w=b.n32,u=b.n33,H=b.n34;this.n11=c*T+d*o+e*ba;this.n12=c*U+d*L+e*w;this.n13=c*X+d*R+e*u;this.n14=c*s+d*aa+e*H+h;this.n21=f*T+k*o+g*ba;this.n22=f*U+k*L+g*w;this.n23=f*X+k*R+g*u;this.n24=f*s+k*aa+g*H+i;this.n31=n*T+j*o+p*ba;this.n32=n*U+j*L+p*w;this.n33=n*X+j*R+p*u;this.n34=n*s+j*aa+p*H+r;this.n41=y*T+A*o+D*ba;this.n42=y*U+A*L+D*w;this.n43=y*X+A*R+D*u;this.n44=y*s+A*aa+D*H+z;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31; +return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,i=a.n22,h=a.n23,j=a.n24,p=a.n31,n=a.n32,o=a.n33,k=a.n34,t=a.n41,w=a.n42,D=a.n43,x=a.n44,W=b.n11,X=b.n12,aa=b.n13,H=b.n14,q=b.n21,B=b.n22, +z=b.n23,L=b.n24,Y=b.n31,C=b.n32,A=b.n33,I=b.n34;this.n11=c*W+d*q+e*Y;this.n12=c*X+d*B+e*C;this.n13=c*aa+d*z+e*A;this.n14=c*H+d*L+e*I+g;this.n21=f*W+i*q+h*Y;this.n22=f*X+i*B+h*C;this.n23=f*aa+i*z+h*A;this.n24=f*H+i*L+h*I+j;this.n31=p*W+n*q+o*Y;this.n32=p*X+n*B+o*C;this.n33=p*aa+n*z+o*A;this.n34=p*H+n*L+o*I+k;this.n41=t*W+w*q+D*Y;this.n42=t*X+w*B+D*C;this.n43=t*aa+w*z+D*A;this.n44=t*H+w*L+D*I+x;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31; c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a= -this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,h=this.n22,f=this.n23,k=this.n24,g=this.n31,i=this.n32,n=this.n33,j=this.n34,p=this.n41,r=this.n42,y=this.n43,A=this.n44;return d*f*i*p-c*k*i*p-d*h*n*p+b*k*n*p+c*h*j*p-b*f*j*p-d*f*g*r+c*k*g*r+d*e*n*r-a*k*n*r-c*e*j*r+a*f*j*r+d*h*g*y-b*k*g*y-d*e*i*y+a*k*i*y+b*e*j*y-a*h*j*y-c*h*g*A+b*f*g*A+c*e*i*A-a*f*i*A-b*e*n*A+a*h*n*A},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32= +this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,g=this.n22,f=this.n23,i=this.n24,h=this.n31,j=this.n32,p=this.n33,n=this.n34,o=this.n41,k=this.n42,t=this.n43,w=this.n44;return d*f*j*o-c*i*j*o-d*g*p*o+b*i*p*o+c*g*n*o-b*f*n*o-d*f*h*k+c*i*h*k+d*e*p*k-a*i*p*k-c*e*n*k+a*f*n*k+d*g*h*t-b*i*h*t-d*e*j*t+a*i*j*t+b*e*n*t-a*g*n*t-c*g*h*w+b*f*h*w+c*e*j*w-a*f*j*w-b*e*p*w+a*g*p*w},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32= this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21; this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]= this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a, -b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,h=a.x,f=a.y,k=a.z,g=e*h,i=e*f;this.set(g* -h+c,g*f-d*k,g*k+d*f,0,g*f+d*k,i*f+c,i*k-d*h,0,g*k-d*f,i*k+d*h,e*k*k+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},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(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var h=Math.cos(d);d=Math.sin(d);var f=a*c,k=b*c;this.n11=e*h;this.n12=-e*d;this.n13=c;this.n21=k*h+a*d;this.n22=-k*d+a*h;this.n23=-b*e;this.n31=-f*h+b*d;this.n32=f*d+b*h;this.n33=a*e;return this}, -setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,h=b+b,f=c+c,k=d+d;a=b*h;var g=b*f;b*=k;var i=c*f;c*=k;d*=k;h*=e;f*=e;e*=k;this.n11=1-(i+d);this.n12=g-e;this.n13=b+f;this.n21=g+e;this.n22=1-(a+d);this.n23=c-h;this.n31=b-f;this.n32=c+h;this.n33=1-(a+i);return this},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14= +b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,g=a.x,f=a.y,i=a.z,h=e*g,j=e*f;this.set(h* +g+c,h*f-d*i,h*i+d*f,0,h*f+d*i,j*f+c,j*i-d*g,0,h*i-d*f,j*i+d*g,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){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(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var f=a*c,i=b*c;this.n11=e*g;this.n12=-e*d;this.n13=c;this.n21=i*g+a*d;this.n22=-i*d+a*g;this.n23=-b*e;this.n31=-f*g+b*d;this.n32=f*d+b*g;this.n33=a*e;return this}, +setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,g=b+b,f=c+c,i=d+d;a=b*g;var h=b*f;b*=i;var j=c*f;c*=i;d*=i;g*=e;f*=e;e*=i;this.n11=1-(j+d);this.n12=h-e;this.n13=b+f;this.n21=h+e;this.n22=1-(a+d);this.n23=c-g;this.n31=b-f;this.n32=c+g;this.n33=1-(a+j);return this},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14= a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/b.y,e=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}}; -THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,h=a.n14,f=a.n21,k=a.n22,g=a.n23,i=a.n24,n=a.n31,j=a.n32,p=a.n33,r=a.n34,y=a.n41,A=a.n42,D=a.n43,z=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=g*r*A-i*p*A+i*j*D-k*r*D-g*j*z+k*p*z;b.n12=h*p*A-e*r*A-h*j*D+d*r*D+e*j*z-d*p*z;b.n13=e*i*A-h*g*A+h*k*D-d*i*D-e*k*z+d*g*z;b.n14=h*g*j-e*i*j-h*k*p+d*i*p+e*k*r-d*g*r;b.n21=i*p*y-g*r*y-i*n*D+f*r*D+g*n*z-f*p*z;b.n22=e*r*y-h*p*y+h*n*D-c*r*D-e*n*z+c*p*z;b.n23=h*g*y-e*i*y-h*f*D+c*i*D+e*f*z-c*g*z; -b.n24=e*i*n-h*g*n+h*f*p-c*i*p-e*f*r+c*g*r;b.n31=k*r*y-i*j*y+i*n*A-f*r*A-k*n*z+f*j*z;b.n32=h*j*y-d*r*y-h*n*A+c*r*A+d*n*z-c*j*z;b.n33=e*i*y-h*k*y+h*f*A-c*i*A-d*f*z+c*k*z;b.n34=h*k*n-d*i*n-h*f*j+c*i*j+d*f*r-c*k*r;b.n41=g*j*y-k*p*y-g*n*A+f*p*A+k*n*D-f*j*D;b.n42=d*p*y-e*j*y+e*n*A-c*p*A-d*n*D+c*j*D;b.n43=e*k*y-d*g*y-e*f*A+c*g*A+d*f*D-c*k*D;b.n44=d*g*n-e*k*n+e*f*j-c*g*j-d*f*p+c*k*p;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,h=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,g=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,j=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*f+a.n31*i;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*h;c[3]=a*f;c[4]=a*k;c[5]=a*g;c[6]=a*i;c[7]=a*n;c[8]=a*j;return b}; -THREE.Matrix4.makeFrustum=function(a,b,c,d,e,h){var f;f=new THREE.Matrix4;f.n11=2*e/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*e/(d-c);f.n23=(d+c)/(d-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(h+e)/(h-e);f.n34=-2*h*e/(h-e);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)}; -THREE.Matrix4.makeOrtho=function(a,b,c,d,e,h){var f,k,g,i;f=new THREE.Matrix4;k=b-a;g=c-d;i=h-e;f.n11=2/k;f.n12=0;f.n13=0;f.n14=-((b+a)/k);f.n21=0;f.n22=2/g;f.n23=0;f.n24=-((c+d)/g);f.n31=0;f.n32=0;f.n33=-2/i;f.n34=-((h+e)/i);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; +THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,i=a.n22,h=a.n23,j=a.n24,p=a.n31,n=a.n32,o=a.n33,k=a.n34,t=a.n41,w=a.n42,D=a.n43,x=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*k*w-j*o*w+j*n*D-i*k*D-h*n*x+i*o*x;b.n12=g*o*w-e*k*w-g*n*D+d*k*D+e*n*x-d*o*x;b.n13=e*j*w-g*h*w+g*i*D-d*j*D-e*i*x+d*h*x;b.n14=g*h*n-e*j*n-g*i*o+d*j*o+e*i*k-d*h*k;b.n21=j*o*t-h*k*t-j*p*D+f*k*D+h*p*x-f*o*x;b.n22=e*k*t-g*o*t+g*p*D-c*k*D-e*p*x+c*o*x;b.n23=g*h*t-e*j*t-g*f*D+c*j*D+e*f*x-c*h*x; +b.n24=e*j*p-g*h*p+g*f*o-c*j*o-e*f*k+c*h*k;b.n31=i*k*t-j*n*t+j*p*w-f*k*w-i*p*x+f*n*x;b.n32=g*n*t-d*k*t-g*p*w+c*k*w+d*p*x-c*n*x;b.n33=e*j*t-g*i*t+g*f*w-c*j*w-d*f*x+c*i*x;b.n34=g*i*p-d*j*p-g*f*n+c*j*n+d*f*k-c*i*k;b.n41=h*n*t-i*o*t-h*p*w+f*o*w+i*p*D-f*n*D;b.n42=d*o*t-e*n*t+e*p*w-c*o*w-d*p*D+c*n*D;b.n43=e*i*t-d*h*t-e*f*w+c*h*w+d*f*D-c*i*D;b.n44=d*h*p-e*i*p+e*f*n-c*h*n-d*f*o+c*i*o;b.multiplyScalar(1/a.determinant());return b}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,j=a.n23*a.n12-a.n22*a.n13,p=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*f+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*f;c[4]=a*i;c[5]=a*h;c[6]=a*j;c[7]=a*p;c[8]=a*n;return b}; +THREE.Matrix4.makeFrustum=function(a,b,c,d,e,g){var f;f=new THREE.Matrix4;f.n11=2*e/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*e/(d-c);f.n23=(d+c)/(d-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(g+e)/(g-e);f.n34=-2*g*e/(g-e);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)}; +THREE.Matrix4.makeOrtho=function(a,b,c,d,e,g){var f,i,h,j;f=new THREE.Matrix4;i=b-a;h=c-d;j=g-e;f.n11=2/i;f.n12=0;f.n13=0;f.n14=-((b+a)/i);f.n21=0;f.n22=2/h;f.n23=0;f.n24=-((c+d)/h);f.n31=0;f.n32=0;f.n33=-2/j;f.n34=-((g+e)/j);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible= !0;this._vector=new THREE.Vector3;this.name=""}; THREE.Object3D.prototype={translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)=== -1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==undefined;)b=b.parent;b!==undefined&&b instanceof THREE.Scene&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},getChildByName:function(a,b){var c,d,e;c=0;for(d=this.children.length;c=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*h)/f;d=Math.sin(d*h)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; -THREE.Face3=function(a,b,c,d,e,h){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3}; -THREE.Face4=function(a,b,c,d,e,h,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)}; +multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,i=a.z;a=a.w;this.x=b*a+e*g+c*i-d*f;this.y=c*a+e*f+d*g-b*i;this.z=d*a+e*i+b*f-c*g;this.w=e*a-b*g-c*f-d*i;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,i=this.z,h=this.w,j=h*c+f*e-i*d,p= +h*d+i*c-g*e,n=h*e+g*d-f*c;c=-g*c-f*d-i*e;b.x=j*h+c*-g+p*-i-n*-f;b.y=p*h+c*-f+n*-g-j*-i;b.z=n*h+c*-i+j*-f-p*-g;return b}}; +THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; +THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3}; +THREE.Face4=function(a,b,c,d,e,g,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)}; THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.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 a,b,c;a=0;for(b=this.faces.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;bthis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b=0&&I>=0&&E>=0&&O>=0)return!0;else if(P<0&&I<0||E<0&&O<0)return!1;else{if(P<0)H=Math.max(H,P/(P-I));else I<0&&(M=Math.min(M,P/(P-I)));if(E<0)H=Math.max(H,E/(E-O));else O<0&&(M=Math.min(M,E/(E-O)));if(MP&&f.positionScreen.z0&&s.z<1){Z=U[T]=U[T]||new THREE.RenderableParticle;T++;z=Z;z.x=s.x/s.w;z.y=s.y/s.w;z.z=s.z;z.rotation=C.rotation.z;z.scale.x=C.scale.x* -Math.abs(z.x-(s.x+u.projectionMatrix.n11)/(s.w+u.projectionMatrix.n14));z.scale.y=C.scale.y*Math.abs(z.y-(s.y+u.projectionMatrix.n22)/(s.w+u.projectionMatrix.n24));z.materials=C.materials;M.push(z)}}}}H&&M.sort(b);return M}}; -THREE.CanvasRenderer=function(){function a($){if(y!=$)j.globalAlpha=y=$}function b($){if(A!=$){switch($){case THREE.NormalBlending:j.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:j.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:j.globalCompositeOperation="darker"}A=$}}function c($){if(D!=$)j.strokeStyle=D=$}var d=this,e=null,h=new THREE.Projector,f=document.createElement("canvas"),k,g,i,n,j=f.getContext("2d"),p=new THREE.Color(0),r=0,y=1,A=0,D=null, -z=null,T=null,U=null,X=null,s,o,L,R,aa=new THREE.RenderableVertex,ba=new THREE.RenderableVertex,w,u,H,M,P,I,E,O,S,V,F,Y,B=new THREE.Color,Q=new THREE.Color,K=new THREE.Color,C=new THREE.Color,Z=new THREE.Color,ia,ma,ja,ca,Da,wa,Wa,Xa,Ya,Za,Ba=new THREE.Rectangle,ka=new THREE.Rectangle,fa=new THREE.Rectangle,Ua=!1,ha=new THREE.Color,ga=new THREE.Color,Ma=new THREE.Color,Na=new THREE.Color,da=new THREE.Vector3,Ha,Ia,Va,la,Ja,Oa,Ea=16;Ha=document.createElement("canvas");Ha.width=Ha.height=2;Ia=Ha.getContext("2d"); -Ia.fillStyle="rgba(0,0,0,1)";Ia.fillRect(0,0,2,2);Va=Ia.getImageData(0,0,2,2);la=Va.data;Ja=document.createElement("canvas");Ja.width=Ja.height=Ea;Oa=Ja.getContext("2d");Oa.translate(-Ea/2,-Ea/2);Oa.scale(Ea,Ea);Ea--;this.domElement=f;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data={vertices:0,faces:0};this.setSize=function($,na){k=$;g=na;i=k/2;n=g/2;f.width=k;f.height=g;Ba.set(-i,-n,i,n);y=1;A=0;X=U=T=z=D=null};this.setClearColor=function($,na){p=$;r=na};this.setClearColorHex= -function($,na){p.setHex($);r=na};this.clear=function(){j.setTransform(1,0,0,-1,i,n);if(!ka.isEmpty()){ka.inflate(1);ka.minSelf(Ba);if(p.hex==0&&r==0)j.clearRect(ka.getX(),ka.getY(),ka.getWidth(),ka.getHeight());else{b(THREE.NormalBlending);a(1);j.fillStyle="rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*255)+","+r+")";j.fillRect(ka.getX(),ka.getY(),ka.getWidth(),ka.getHeight())}ka.empty()}};this.render=function($,na){function bb(m){var x,t,q,J=m.lights;ga.setRGB(0,0,0);Ma.setRGB(0, -0,0);Na.setRGB(0,0,0);m=0;for(x=J.length;m>1;W=v.height>>1;t=x.scale.x*i;G=x.scale.y*n;q=t*l;J=G*W;fa.set(m.x-q,m.y-J,m.x+q,m.y+J);if(Ba.instersects(fa)){j.save();j.translate(m.x,m.y);j.rotate(-x.rotation); -j.scale(t,-G);j.translate(-l,-W);j.drawImage(v,0,0);j.restore()}}}else if(t instanceof THREE.ParticleCanvasMaterial){q=x.scale.x*i;J=x.scale.y*n;fa.set(m.x-q,m.y-J,m.x+q,m.y+J);if(Ba.instersects(fa)){c(t.color.__styleString);G=t.color.__styleString;if(z!=G)j.fillStyle=z=G;j.save();j.translate(m.x,m.y);j.rotate(-x.rotation);j.scale(q,J);t.program(j);j.restore()}}}function db(m,x,t,q){a(q.opacity);b(q.blending);j.beginPath();j.moveTo(m.positionScreen.x,m.positionScreen.y);j.lineTo(x.positionScreen.x, -x.positionScreen.y);j.closePath();if(q instanceof THREE.LineBasicMaterial){B.__styleString=q.color.__styleString;m=q.linewidth;if(T!=m)j.lineWidth=T=m;m=q.linecap;if(U!=m)j.lineCap=U=m;m=q.linejoin;if(X!=m)j.lineJoin=X=m;c(B.__styleString);j.stroke();fa.inflate(q.linewidth*2)}}function Pa(m,x,t,q,J,G,v,l,W){d.data.vertices+=3;d.data.faces++;a(l.opacity);b(l.blending);w=m.positionScreen.x;u=m.positionScreen.y;H=x.positionScreen.x;M=x.positionScreen.y;P=t.positionScreen.x;I=t.positionScreen.y;Ka(w, -u,H,M,P,I);if(l instanceof THREE.MeshBasicMaterial)if(l.map){if(l.map.mapping instanceof THREE.UVMapping){ca=v.uvs[0];sa(w,u,H,M,P,I,l.map.image,ca[q].u,ca[q].v,ca[J].u,ca[J].v,ca[G].u,ca[G].v)}}else if(l.envMap){if(l.envMap.mapping instanceof THREE.SphericalReflectionMapping){m=na.matrixWorldInverse;da.copy(v.vertexNormalsWorld[0]);Da=(da.x*m.n11+da.y*m.n12+da.z*m.n13)*0.5+0.5;wa=-(da.x*m.n21+da.y*m.n22+da.z*m.n23)*0.5+0.5;da.copy(v.vertexNormalsWorld[1]);Wa=(da.x*m.n11+da.y*m.n12+da.z*m.n13)*0.5+ -0.5;Xa=-(da.x*m.n21+da.y*m.n22+da.z*m.n23)*0.5+0.5;da.copy(v.vertexNormalsWorld[2]);Ya=(da.x*m.n11+da.y*m.n12+da.z*m.n13)*0.5+0.5;Za=-(da.x*m.n21+da.y*m.n22+da.z*m.n23)*0.5+0.5;sa(w,u,H,M,P,I,l.envMap.image,Da,wa,Wa,Xa,Ya,Za)}}else l.wireframe?xa(l.color.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(l.color.__styleString);else if(l instanceof THREE.MeshLambertMaterial){if(l.map&&!l.wireframe){if(l.map.mapping instanceof THREE.UVMapping){ca=v.uvs[0];sa(w,u,H,M,P,I,l.map.image, -ca[q].u,ca[q].v,ca[J].u,ca[J].v,ca[G].u,ca[G].v)}b(THREE.SubtractiveBlending)}if(Ua)if(!l.wireframe&&l.shading==THREE.SmoothShading&&v.vertexNormalsWorld.length==3){Q.r=K.r=C.r=ga.r;Q.g=K.g=C.g=ga.g;Q.b=K.b=C.b=ga.b;ra(W,v.v1.positionWorld,v.vertexNormalsWorld[0],Q);ra(W,v.v2.positionWorld,v.vertexNormalsWorld[1],K);ra(W,v.v3.positionWorld,v.vertexNormalsWorld[2],C);Z.r=(K.r+C.r)*0.5;Z.g=(K.g+C.g)*0.5;Z.b=(K.b+C.b)*0.5;ja=Qa(Q,K,C,Z);sa(w,u,H,M,P,I,ja,0,0,1,0,0,1)}else{ha.r=ga.r;ha.g=ga.g;ha.b=ga.b; -ra(W,v.centroidWorld,v.normalWorld,ha);B.r=l.color.r*ha.r;B.g=l.color.g*ha.g;B.b=l.color.b*ha.b;B.updateStyleString();l.wireframe?xa(B.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(B.__styleString)}else l.wireframe?xa(l.color.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(l.color.__styleString)}else if(l instanceof THREE.MeshDepthMaterial){ia=na.near;ma=na.far;Q.r=Q.g=Q.b=1-Ca(m.positionScreen.z,ia,ma);K.r=K.g=K.b=1-Ca(x.positionScreen.z, -ia,ma);C.r=C.g=C.b=1-Ca(t.positionScreen.z,ia,ma);Z.r=(K.r+C.r)*0.5;Z.g=(K.g+C.g)*0.5;Z.b=(K.b+C.b)*0.5;ja=Qa(Q,K,C,Z);sa(w,u,H,M,P,I,ja,0,0,1,0,0,1)}else if(l instanceof THREE.MeshNormalMaterial){B.r=Fa(v.normalWorld.x);B.g=Fa(v.normalWorld.y);B.b=Fa(v.normalWorld.z);B.updateStyleString();l.wireframe?xa(B.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(B.__styleString)}}function $a(m,x,t,q,J,G,v,l,W){d.data.vertices+=4;d.data.faces++;a(l.opacity);b(l.blending);if(l.map|| -l.envMap){Pa(m,x,q,0,1,3,v,l,W);Pa(J,t,G,1,2,3,v,l,W)}else{w=m.positionScreen.x;u=m.positionScreen.y;H=x.positionScreen.x;M=x.positionScreen.y;P=t.positionScreen.x;I=t.positionScreen.y;E=q.positionScreen.x;O=q.positionScreen.y;S=J.positionScreen.x;V=J.positionScreen.y;F=G.positionScreen.x;Y=G.positionScreen.y;if(l instanceof THREE.MeshBasicMaterial){Ra(w,u,H,M,P,I,E,O);l.wireframe?xa(l.color.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(l.color.__styleString)}else if(l instanceof -THREE.MeshLambertMaterial)if(Ua)if(!l.wireframe&&l.shading==THREE.SmoothShading&&v.vertexNormalsWorld.length==4){Q.r=K.r=C.r=Z.r=ga.r;Q.g=K.g=C.g=Z.g=ga.g;Q.b=K.b=C.b=Z.b=ga.b;ra(W,v.v1.positionWorld,v.vertexNormalsWorld[0],Q);ra(W,v.v2.positionWorld,v.vertexNormalsWorld[1],K);ra(W,v.v4.positionWorld,v.vertexNormalsWorld[3],C);ra(W,v.v3.positionWorld,v.vertexNormalsWorld[2],Z);ja=Qa(Q,K,C,Z);Ka(w,u,H,M,E,O);sa(w,u,H,M,E,O,ja,0,0,1,0,0,1);Ka(S,V,P,I,F,Y);sa(S,V,P,I,F,Y,ja,1,0,1,1,0,1)}else{ha.r=ga.r; -ha.g=ga.g;ha.b=ga.b;ra(W,v.centroidWorld,v.normalWorld,ha);B.r=l.color.r*ha.r;B.g=l.color.g*ha.g;B.b=l.color.b*ha.b;B.updateStyleString();Ra(w,u,H,M,P,I,E,O);l.wireframe?xa(B.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(B.__styleString)}else{Ra(w,u,H,M,P,I,E,O);l.wireframe?xa(l.color.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(l.color.__styleString)}else if(l instanceof THREE.MeshNormalMaterial){B.r=Fa(v.normalWorld.x);B.g=Fa(v.normalWorld.y); -B.b=Fa(v.normalWorld.z);B.updateStyleString();Ra(w,u,H,M,P,I,E,O);l.wireframe?xa(B.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(B.__styleString)}else if(l instanceof THREE.MeshDepthMaterial){ia=na.near;ma=na.far;Q.r=Q.g=Q.b=1-Ca(m.positionScreen.z,ia,ma);K.r=K.g=K.b=1-Ca(x.positionScreen.z,ia,ma);C.r=C.g=C.b=1-Ca(q.positionScreen.z,ia,ma);Z.r=Z.g=Z.b=1-Ca(t.positionScreen.z,ia,ma);ja=Qa(Q,K,C,Z);Ka(w,u,H,M,E,O);sa(w,u,H,M,E,O,ja,0,0,1,0,0,1);Ka(S,V,P,I,F,Y);sa(S,V, -P,I,F,Y,ja,1,0,1,1,0,1)}}}function Ka(m,x,t,q,J,G){j.beginPath();j.moveTo(m,x);j.lineTo(t,q);j.lineTo(J,G);j.lineTo(m,x);j.closePath()}function Ra(m,x,t,q,J,G,v,l){j.beginPath();j.moveTo(m,x);j.lineTo(t,q);j.lineTo(J,G);j.lineTo(v,l);j.lineTo(m,x);j.closePath()}function xa(m,x,t,q){if(T!=x)j.lineWidth=T=x;if(U!=t)j.lineCap=U=t;if(X!=q)j.lineJoin=X=q;c(m);j.stroke();fa.inflate(x*2)}function ya(m){if(z!=m)j.fillStyle=z=m;j.fill()}function sa(m,x,t,q,J,G,v,l,W,ta,oa,ua,La){var qa,va;qa=v.width-1;va= -v.height-1;l*=qa;W*=va;ta*=qa;oa*=va;ua*=qa;La*=va;t-=m;q-=x;J-=m;G-=x;ta-=l;oa-=W;ua-=l;La-=W;qa=ta*La-ua*oa;if(qa!=0){va=1/qa;qa=(La*t-oa*J)*va;oa=(La*q-oa*G)*va;t=(ta*J-ua*t)*va;q=(ta*G-ua*q)*va;m=m-qa*l-t*W;x=x-oa*l-q*W;j.save();j.transform(qa,oa,t,q,m,x);j.clip();j.drawImage(v,0,0);j.restore()}}function Qa(m,x,t,q){var J=~~(m.r*255),G=~~(m.g*255);m=~~(m.b*255);var v=~~(x.r*255),l=~~(x.g*255);x=~~(x.b*255);var W=~~(t.r*255),ta=~~(t.g*255);t=~~(t.b*255);var oa=~~(q.r*255),ua=~~(q.g*255);q=~~(q.b* -255);la[0]=J<0?0:J>255?255:J;la[1]=G<0?0:G>255?255:G;la[2]=m<0?0:m>255?255:m;la[4]=v<0?0:v>255?255:v;la[5]=l<0?0:l>255?255:l;la[6]=x<0?0:x>255?255:x;la[8]=W<0?0:W>255?255:W;la[9]=ta<0?0:ta>255?255:ta;la[10]=t<0?0:t>255?255:t;la[12]=oa<0?0:oa>255?255:oa;la[13]=ua<0?0:ua>255?255:ua;la[14]=q<0?0:q>255?255:q;Ia.putImageData(Va,0,0);Oa.drawImage(Ha,0,0);return Ja}function Ca(m,x,t){m=(m-x)/(t-x);return m*m*(3-2*m)}function Fa(m){m=(m+1)*0.5;return m<0?0:m>1?1:m}function za(m,x){var t=x.x-m.x,q=x.y-m.y, -J=1/Math.sqrt(t*t+q*q);t*=J;q*=J;x.x+=t;x.y+=q;m.x-=t;m.y-=q}var Sa,ab,N,pa,Aa,Ga,Ta,ea;this.autoClear?this.clear():j.setTransform(1,0,0,-1,i,n);d.data.vertices=0;d.data.faces=0;e=h.projectScene($,na,this.sortElements);(Ua=$.lights.length>0)&&bb($);Sa=0;for(ab=e.length;Sa=0&&J>=0&&y>=0&&F>=0)return!0;else if(R<0&&J<0||y<0&&F<0)return!1;else{if(R<0)I=Math.max(I,R/(R-J));else J<0&&(O=Math.min(O,R/(R-J)));if(y<0)I=Math.max(I,y/(y-F));else F<0&&(O=Math.min(O,y/(y-F)));if(OR&&f.positionScreen.z0&&H.z<1){T=X[W]=X[W]||new THREE.RenderableParticle;W++;x=T;x.x=H.x/H.w;x.y=H.y/H.w;x.z=H.z;x.rotation=E.rotation.z;x.scale.x= +E.scale.x*Math.abs(x.x-(H.x+A.projectionMatrix.n11)/(H.w+A.projectionMatrix.n14));x.scale.y=E.scale.y*Math.abs(x.y-(H.y+A.projectionMatrix.n22)/(H.w+A.projectionMatrix.n24));x.materials=E.materials;O.push(x)}}}}I&&O.sort(b);return O}}; +THREE.CanvasRenderer=function(){function a(U){if(D!=U)k.globalAlpha=D=U}function b(U){if(x!=U){switch(U){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}x=U}}function c(U){if(W!=U.hex){W=U.hex;k.strokeStyle="#"+e(W.toString(16))}}function d(U){if(X!=U.hex){X=U.hex;k.fillStyle="#"+e(X.toString(16))}}function e(U){for(;U.length<6;)U="0"+U; +return U}var g=this,f=null,i=new THREE.Projector,h=document.createElement("canvas"),j,p,n,o,k=h.getContext("2d"),t=new THREE.Color(0),w=0,D=1,x=0,W=null,X=null,aa=null,H=null,q=null,B,z,L,Y,C=new THREE.RenderableVertex,A=new THREE.RenderableVertex,I,O,R,J,y,F,Q,S,G,ba,Z,da,M=new THREE.Color(0),E=new THREE.Color(0),T=new THREE.Color(0),$=new THREE.Color(0),ea=new THREE.Color(0),oa,ia,ka,fa,Wa,Xa,Ya,Za,$a,ab,Ca=new THREE.Rectangle,ma=new THREE.Rectangle,ha=new THREE.Rectangle,Ua=!1,la=new THREE.Color, +ja=new THREE.Color,Ma=new THREE.Color,Na=new THREE.Color,ca=new THREE.Vector3,Ha,Ia,Va,na,Ja,Oa,Ea=16;Ha=document.createElement("canvas");Ha.width=Ha.height=2;Ia=Ha.getContext("2d");Ia.fillStyle="rgba(0,0,0,1)";Ia.fillRect(0,0,2,2);Va=Ia.getImageData(0,0,2,2);na=Va.data;Ja=document.createElement("canvas");Ja.width=Ja.height=Ea;Oa=Ja.getContext("2d");Oa.translate(-Ea/2,-Ea/2);Oa.scale(Ea,Ea);Ea--;this.domElement=h;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data={vertices:0,faces:0}; +this.setSize=function(U,pa){j=U;p=pa;n=j/2;o=p/2;h.width=j;h.height=p;Ca.set(-n,-o,n,o);D=1;x=0;q=H=aa=X=W=null};this.setClearColor=function(U,pa){t=U;w=pa};this.setClearColorHex=function(U,pa){t.setHex(U);w=pa};this.clear=function(){k.setTransform(1,0,0,-1,n,o);if(!ma.isEmpty()){ma.inflate(1);ma.minSelf(Ca);if(t.hex==0&&w==0)k.clearRect(ma.getX(),ma.getY(),ma.getWidth(),ma.getHeight());else{b(THREE.NormalBlending);a(1);k.fillStyle="rgba("+Math.floor(t.r*255)+","+Math.floor(t.g*255)+","+Math.floor(t.b* +255)+","+w+")";k.fillRect(ma.getX(),ma.getY(),ma.getWidth(),ma.getHeight())}ma.empty()}};this.render=function(U,pa){function db(m){var v,s,r,K=m.lights;ja.setRGB(0,0,0);Ma.setRGB(0,0,0);Na.setRGB(0,0,0);m=0;for(v=K.length;m>1;V=u.height>>1;s=v.scale.x*n;N=v.scale.y*o;r=s*l;K=N*V;ha.set(m.x-r,m.y-K,m.x+r,m.y+K);if(Ca.instersects(ha)){k.save();k.translate(m.x,m.y);k.rotate(-v.rotation);k.scale(s,-N);k.translate(-l,-V);k.drawImage(u,0,0);k.restore()}}}else if(s instanceof THREE.ParticleCanvasMaterial){r=v.scale.x*n;K=v.scale.y*o;ha.set(m.x-r,m.y-K,m.x+r,m.y+K);if(Ca.instersects(ha)){c(s.color);d(s.color);k.save();k.translate(m.x,m.y);k.rotate(-v.rotation);k.scale(r,K);s.program(k);k.restore()}}}function fb(m, +v,s,r){a(r.opacity);b(r.blending);k.beginPath();k.moveTo(m.positionScreen.x,m.positionScreen.y);k.lineTo(v.positionScreen.x,v.positionScreen.y);k.closePath();if(r instanceof THREE.LineBasicMaterial){m=r.linewidth;if(aa!=m)k.lineWidth=aa=m;m=r.linecap;if(H!=m)k.lineCap=H=m;m=r.linejoin;if(q!=m)k.lineJoin=q=m;c(r.color);k.stroke();ha.inflate(r.linewidth*2)}}function Pa(m,v,s,r,K,N,u,l,V){g.data.vertices+=3;g.data.faces++;a(l.opacity);b(l.blending);I=m.positionScreen.x;O=m.positionScreen.y;R=v.positionScreen.x; +J=v.positionScreen.y;y=s.positionScreen.x;F=s.positionScreen.y;Ka(I,O,R,J,y,F);if(l instanceof THREE.MeshBasicMaterial)if(l.map){if(l.map.mapping instanceof THREE.UVMapping){fa=u.uvs[0];ua(I,O,R,J,y,F,l.map.image,fa[r].u,fa[r].v,fa[K].u,fa[K].v,fa[N].u,fa[N].v)}}else if(l.envMap){if(l.envMap.mapping instanceof THREE.SphericalReflectionMapping){m=pa.matrixWorldInverse;ca.copy(u.vertexNormalsWorld[0]);Wa=(ca.x*m.n11+ca.y*m.n12+ca.z*m.n13)*0.5+0.5;Xa=-(ca.x*m.n21+ca.y*m.n22+ca.z*m.n23)*0.5+0.5;ca.copy(u.vertexNormalsWorld[1]); +Ya=(ca.x*m.n11+ca.y*m.n12+ca.z*m.n13)*0.5+0.5;Za=-(ca.x*m.n21+ca.y*m.n22+ca.z*m.n23)*0.5+0.5;ca.copy(u.vertexNormalsWorld[2]);$a=(ca.x*m.n11+ca.y*m.n12+ca.z*m.n13)*0.5+0.5;ab=-(ca.x*m.n21+ca.y*m.n22+ca.z*m.n23)*0.5+0.5;ua(I,O,R,J,y,F,l.envMap.image,Wa,Xa,Ya,Za,$a,ab)}}else l.wireframe?ya(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(l.color);else if(l instanceof THREE.MeshLambertMaterial){if(l.map&&!l.wireframe){if(l.map.mapping instanceof THREE.UVMapping){fa=u.uvs[0];ua(I, +O,R,J,y,F,l.map.image,fa[r].u,fa[r].v,fa[K].u,fa[K].v,fa[N].u,fa[N].v)}b(THREE.SubtractiveBlending)}if(Ua)if(!l.wireframe&&l.shading==THREE.SmoothShading&&u.vertexNormalsWorld.length==3){E.r=T.r=$.r=ja.r;E.g=T.g=$.g=ja.g;E.b=T.b=$.b=ja.b;ta(V,u.v1.positionWorld,u.vertexNormalsWorld[0],E);ta(V,u.v2.positionWorld,u.vertexNormalsWorld[1],T);ta(V,u.v3.positionWorld,u.vertexNormalsWorld[2],$);ea.r=(T.r+$.r)*0.5;ea.g=(T.g+$.g)*0.5;ea.b=(T.b+$.b)*0.5;ka=Qa(E,T,$,ea);ua(I,O,R,J,y,F,ka,0,0,1,0,0,1)}else{la.r= +ja.r;la.g=ja.g;la.b=ja.b;ta(V,u.centroidWorld,u.normalWorld,la);M.r=Math.max(0,Math.min(l.color.r*la.r,1));M.g=Math.max(0,Math.min(l.color.g*la.g,1));M.b=Math.max(0,Math.min(l.color.b*la.b,1));M.updateHex();l.wireframe?ya(M,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(M)}else l.wireframe?ya(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(l.color)}else if(l instanceof THREE.MeshDepthMaterial){oa=pa.near;ia=pa.far;E.r=E.g=E.b=1-Da(m.positionScreen.z,oa,ia); +T.r=T.g=T.b=1-Da(v.positionScreen.z,oa,ia);$.r=$.g=$.b=1-Da(s.positionScreen.z,oa,ia);ea.r=(T.r+$.r)*0.5;ea.g=(T.g+$.g)*0.5;ea.b=(T.b+$.b)*0.5;ka=Qa(E,T,$,ea);ua(I,O,R,J,y,F,ka,0,0,1,0,0,1)}else if(l instanceof THREE.MeshNormalMaterial){M.r=Fa(u.normalWorld.x);M.g=Fa(u.normalWorld.y);M.b=Fa(u.normalWorld.z);M.updateHex();l.wireframe?ya(M,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(M)}}function bb(m,v,s,r,K,N,u,l,V){g.data.vertices+=4;g.data.faces++;a(l.opacity);b(l.blending);if(l.map|| +l.envMap){Pa(m,v,r,0,1,3,u,l,V);Pa(K,s,N,1,2,3,u,l,V)}else{I=m.positionScreen.x;O=m.positionScreen.y;R=v.positionScreen.x;J=v.positionScreen.y;y=s.positionScreen.x;F=s.positionScreen.y;Q=r.positionScreen.x;S=r.positionScreen.y;G=K.positionScreen.x;ba=K.positionScreen.y;Z=N.positionScreen.x;da=N.positionScreen.y;if(l instanceof THREE.MeshBasicMaterial){Ra(I,O,R,J,y,F,Q,S);l.wireframe?ya(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(l.color)}else if(l instanceof THREE.MeshLambertMaterial)if(Ua)if(!l.wireframe&& +l.shading==THREE.SmoothShading&&u.vertexNormalsWorld.length==4){E.r=T.r=$.r=ea.r=ja.r;E.g=T.g=$.g=ea.g=ja.g;E.b=T.b=$.b=ea.b=ja.b;ta(V,u.v1.positionWorld,u.vertexNormalsWorld[0],E);ta(V,u.v2.positionWorld,u.vertexNormalsWorld[1],T);ta(V,u.v4.positionWorld,u.vertexNormalsWorld[3],$);ta(V,u.v3.positionWorld,u.vertexNormalsWorld[2],ea);ka=Qa(E,T,$,ea);Ka(I,O,R,J,Q,S);ua(I,O,R,J,Q,S,ka,0,0,1,0,0,1);Ka(G,ba,y,F,Z,da);ua(G,ba,y,F,Z,da,ka,1,0,1,1,0,1)}else{la.r=ja.r;la.g=ja.g;la.b=ja.b;ta(V,u.centroidWorld, +u.normalWorld,la);M.r=Math.max(0,Math.min(l.color.r*la.r,1));M.g=Math.max(0,Math.min(l.color.g*la.g,1));M.b=Math.max(0,Math.min(l.color.b*la.b,1));M.updateHex();Ra(I,O,R,J,y,F,Q,S);l.wireframe?ya(M,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(M)}else{Ra(I,O,R,J,y,F,Q,S);l.wireframe?ya(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(l.color)}else if(l instanceof THREE.MeshNormalMaterial){M.r=Fa(u.normalWorld.x);M.g=Fa(u.normalWorld.y);M.b=Fa(u.normalWorld.z); +M.updateHex();Ra(I,O,R,J,y,F,Q,S);l.wireframe?ya(M,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(M)}else if(l instanceof THREE.MeshDepthMaterial){oa=pa.near;ia=pa.far;E.r=E.g=E.b=1-Da(m.positionScreen.z,oa,ia);T.r=T.g=T.b=1-Da(v.positionScreen.z,oa,ia);$.r=$.g=$.b=1-Da(r.positionScreen.z,oa,ia);ea.r=ea.g=ea.b=1-Da(s.positionScreen.z,oa,ia);ka=Qa(E,T,$,ea);Ka(I,O,R,J,Q,S);ua(I,O,R,J,Q,S,ka,0,0,1,0,0,1);Ka(G,ba,y,F,Z,da);ua(G,ba,y,F,Z,da,ka,1,0,1,1,0,1)}}}function Ka(m,v,s,r,K,N){k.beginPath(); +k.moveTo(m,v);k.lineTo(s,r);k.lineTo(K,N);k.lineTo(m,v);k.closePath()}function Ra(m,v,s,r,K,N,u,l){k.beginPath();k.moveTo(m,v);k.lineTo(s,r);k.lineTo(K,N);k.lineTo(u,l);k.lineTo(m,v);k.closePath()}function ya(m,v,s,r){if(aa!=v)k.lineWidth=aa=v;if(H!=s)k.lineCap=H=s;if(q!=r)k.lineJoin=q=r;c(m);k.stroke();ha.inflate(v*2)}function za(m){d(m);k.fill()}function ua(m,v,s,r,K,N,u,l,V,va,qa,wa,La){var sa,xa;sa=u.width-1;xa=u.height-1;l*=sa;V*=xa;va*=sa;qa*=xa;wa*=sa;La*=xa;s-=m;r-=v;K-=m;N-=v;va-=l;qa-=V; +wa-=l;La-=V;sa=va*La-wa*qa;if(sa!=0){xa=1/sa;sa=(La*s-qa*K)*xa;qa=(La*r-qa*N)*xa;s=(va*K-wa*s)*xa;r=(va*N-wa*r)*xa;m=m-sa*l-s*V;v=v-qa*l-r*V;k.save();k.transform(sa,qa,s,r,m,v);k.clip();k.drawImage(u,0,0);k.restore()}}function Qa(m,v,s,r){var K=~~(m.r*255),N=~~(m.g*255);m=~~(m.b*255);var u=~~(v.r*255),l=~~(v.g*255);v=~~(v.b*255);var V=~~(s.r*255),va=~~(s.g*255);s=~~(s.b*255);var qa=~~(r.r*255),wa=~~(r.g*255);r=~~(r.b*255);na[0]=K<0?0:K>255?255:K;na[1]=N<0?0:N>255?255:N;na[2]=m<0?0:m>255?255:m;na[4]= +u<0?0:u>255?255:u;na[5]=l<0?0:l>255?255:l;na[6]=v<0?0:v>255?255:v;na[8]=V<0?0:V>255?255:V;na[9]=va<0?0:va>255?255:va;na[10]=s<0?0:s>255?255:s;na[12]=qa<0?0:qa>255?255:qa;na[13]=wa<0?0:wa>255?255:wa;na[14]=r<0?0:r>255?255:r;Ia.putImageData(Va,0,0);Oa.drawImage(Ha,0,0);return Ja}function Da(m,v,s){m=(m-v)/(s-v);return m*m*(3-2*m)}function Fa(m){m=(m+1)*0.5;return m<0?0:m>1?1:m}function Aa(m,v){var s=v.x-m.x,r=v.y-m.y,K=1/Math.sqrt(s*s+r*r);s*=K;r*=K;v.x+=s;v.y+=r;m.x-=s;m.y-=r}var Sa,cb,P,ra,Ba,Ga, +Ta,ga;this.autoClear?this.clear():k.setTransform(1,0,0,-1,n,o);g.data.vertices=0;g.data.faces=0;f=i.projectScene(U,pa,this.sortElements);(Ua=U.lights.length>0)&&db(U);Sa=0;for(cb=f.length;Sa>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* -255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)}; +THREE.Color.prototype={copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex},setHex:function(a){this.hex=~~a&16777215;this.updateRGB()},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;this.updateHex()},setHSV:function(a,b,c){var d,e,h,f,j,g;if(c==0)d=e=h=0;else{f=Math.floor(a*6);j=a*6-f;a=c*(1-b);g=c*(1-b*j);b=c*(1-b*(1-j));switch(f){case 1:d=g;e=c;h=a;break;case 2:d=a;e=c;h=b;break;case 3:d=a;e=g;h=c;break;case 4:d=b;e=a;h=c;break;case 5:d=c;e=a;h=g;break;case 6:case 0:d=c;e=b;h=a}}this.setRGB(d, +e,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(a,b){this.set(a||0,b||0)}; THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/ this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)}; THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a, @@ -50,7 +49,7 @@ THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;thi a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this}, multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,h=a.x,f=a.y,j=a.z;a=a.w;this.x=b*a+e*h+c*j-d*f;this.y=c*a+e*f+d*h-b*j;this.z=d*a+e*j+b*f-c*h;this.w=e*a-b*h-c*f-d*j;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,h=this.x,f=this.y,j=this.z,g=this.w,i=g*c+f*e-j*d,l= g*d+j*c-h*e,k=g*e+h*d-f*c;c=-h*c-f*d-j*e;b.x=i*g+c*-h+l*-j-k*-f;b.y=l*g+c*-f+k*-h-i*-j;b.z=k*g+c*-j+i*-f-l*-h;return b}}; -THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*h)/f;d=Math.sin(d*h)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; +THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*h)/f;d=Math.sin(d*h)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,b,c,d,e,h){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3}; THREE.Face4=function(a,b,c,d,e,h,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)}; THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera; diff --git a/build/custom/ThreeExtras.js b/build/custom/ThreeExtras.js index 4c7bfd14..9ee8060d 100644 --- a/build/custom/ThreeExtras.js +++ b/build/custom/ThreeExtras.js @@ -35,7 +35,7 @@ value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.00195 film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time * 1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor = vec4( cResult, cTextureScreen.a );\n}"}, screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}", fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,b,e,f,d=2*Math.ceil(a*3)+1;d>25&&(d=25);f=(d-1)*0.5;b=Array(d);for(c=e=0;c=0?p:p+f;p=this.verticalAngleMap.srcRange;n=this.verticalAngleMap.dstRange; this.phi=(this.phi-p[0])*(n[1]-n[0])/(p[1]-p[0])+n[0];p=this.horizontalAngleMap.srcRange;n=this.horizontalAngleMap.dstRange;this.theta=(this.theta-p[0])*(n[1]-n[0])/(p[1]-p[0])+n[0];p=this.target.position;p.x=100*Math.sin(this.phi)*Math.cos(this.theta);p.y=100*Math.cos(this.phi);p.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,l,k,m)};this.onMouseMove=function(l){this.mouseX=l.clientX-this.windowHalfX;this.mouseY=l.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints); this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var g=new THREE.MeshLambertMaterial({color:65280}),h=new THREE.Cube(10,10,20),j=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(h,a);a=new THREE.Mesh(j,g);a.position.set(0,10,0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation= c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&e(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(l,k){return function(){k.apply(l,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(a){function c(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.dragToLook=!1;this.autoForward=!1;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==undefined)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.autoForward!==undefined)this.autoForward= +THREE.FlyCamera=function(a){function c(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.005;this.dragToLook=!1;this.autoForward=!1;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==undefined)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.autoForward!==undefined)this.autoForward= a.autoForward;if(a.domElement!==undefined)this.domElement=a.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(b){if(typeof this[b.type]=="function")this[b.type](b)};this.keydown=function(b){if(!b.altKey){switch(b.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(b){switch(b.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; @@ -82,7 +82,7 @@ e));b instanceof THREE.Face4&&c.push(new THREE.UV(0.5+Math.atan2(m.position.x,m. THREE.Icosahedron=function(a){function c(m,p,n){var v=Math.sqrt(m*m+p*p+n*n);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(m/v,p/v,n/v)))-1}function b(m,p,n,v){v.faces.push(new THREE.Face3(m,p,n))}function e(m,p){var n=f.vertices[m].position,v=f.vertices[p].position;return c((n.x+v.x)/2,(n.y+v.y)/2,(n.z+v.z)/2)}var f=this,d=new THREE.Geometry,g;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0, 1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,d);b(0,5,1,d);b(0,1,7,d);b(0,7,10,d);b(0,10,11,d);b(1,5,9,d);b(5,11,4,d);b(11,10,2,d);b(10,7,6,d);b(7,1,8,d);b(3,9,4,d);b(3,4,2,d);b(3,2,6,d);b(3,6,8,d);b(3,8,9,d);b(4,9,5,d);b(2,4,11,d);b(6,2,10,d);b(8,6,7,d);b(9,8,1,d);for(a=0;a>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* -255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)}; +THREE.Color.prototype={copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex},setHex:function(a){this.hex=~~a&16777215;this.updateRGB()},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;this.updateHex()},setHSV:function(a,b,c){var d,e,g,f,j,h;if(c==0)d=e=g=0;else{f=Math.floor(a*6);j=a*6-f;a=c*(1-b);h=c*(1-b*j);b=c*(1-b*(1-j));switch(f){case 1:d=h;e=c;g=a;break;case 2:d=a;e=c;g=b;break;case 3:d=a;e=h;g=c;break;case 4:d=b;e=a;g=c;break;case 5:d=c;e=a;g=h;break;case 6:case 0:d=c;e=b;g=a}}this.setRGB(d, +e,g)},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(a,b){this.set(a||0,b||0)}; THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/ this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)}; THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a, @@ -12,59 +11,59 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPosit 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)}; THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(this.x+(a.x-this.x)*b,this.y+(a.y-this.y)*b,this.z+(a.z-this.z)*b,this.w+(a.w-this.w)*b)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a0&&y>0&&w+y<1}var c,d,e,h,f,i,g,j,m,k, -n,l=a.geometry,r=l.vertices,s=[];c=0;for(d=l.faces.length;c0:m<0)){j=j.dot((new THREE.Vector3).sub(h,k))/ -m;k=k.addSelf(n.multiplyScalar(j));if(e instanceof THREE.Face3){if(b(k,h,f,i)){e={distance:this.origin.distanceTo(k),point:k,face:e,object:a};s.push(e)}}else if(e instanceof THREE.Face4&&(b(k,h,f,g)||b(k,f,i,g))){e={distance:this.origin.distanceTo(k),point:k,face:e,object:a};s.push(e)}}}return s}}; -THREE.Rectangle=function(){function a(){h=d-b;f=e-c}var b,c,d,e,h,f,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,j,m,k){i=!1;b=g;c=j;d=m;e=k;a()};this.addPoint=function(g,j){if(i){i=!1;b=g;c=j;d=g;e=j}else{b=bg?d:g;e=e>j?e:j}a()}; -this.add3Points=function(g,j,m,k,n,l){if(i){i=!1;b=gm?g>n?g:n:m>n?m:n;e=j>k?j>l?j:l:k>l?k:l}else{b=gm?g>n?g>d?g:d:n>d?n:d:m>n?m>d?m:d:n>d?n:d;e=j>k?j>l?j>e?j:e:l>e?l:e:k>l?k>e?k:e:l>e?l:e}a()};this.addRectangle=function(g){if(i){i=!1;b=g.getLeft();c=g.getTop();d=g.getRight();e=g.getBottom()}else{b=bg.getRight()? -d:g.getRight();e=e>g.getBottom()?e:g.getBottom()}a()};this.inflate=function(g){b-=g;c-=g;d+=g;e+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d=0&&Math.min(e,g.getBottom())-Math.max(c,g.getTop())>=0};this.empty=function(){i=!0;e=d=c=b=0;a()};this.isEmpty=function(){return i}}; +THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a0&&v>0&&x+v<1}var c,d,e,g,f,j,h,i,k,n, +m,o=a.geometry,q=o.vertices,r=[];c=0;for(d=o.faces.length;c0:k<0)){i=i.dot((new THREE.Vector3).sub(g,n))/ +k;n=n.addSelf(m.multiplyScalar(i));if(e instanceof THREE.Face3){if(b(n,g,f,j)){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};r.push(e)}}else if(e instanceof THREE.Face4&&(b(n,g,f,h)||b(n,f,j,h))){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};r.push(e)}}}return r}}; +THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,j=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(h,i,k,n){j=!1;b=h;c=i;d=k;e=n;a()};this.addPoint=function(h,i){if(j){j=!1;b=h;c=i;d=h;e=i}else{b=bh?d:h;e=e>i?e:i}a()}; +this.add3Points=function(h,i,k,n,m,o){if(j){j=!1;b=hk?h>m?h:m:k>m?k:m;e=i>n?i>o?i:o:n>o?n:o}else{b=hk?h>m?h>d?h:d:m>d?m:d:k>m?k>d?k:d:m>d?m:d;e=i>n?i>o?i>e?i:e:o>e?o:e:n>o?n>e?n:e:o>e?o:e}a()};this.addRectangle=function(h){if(j){j=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=bh.getRight()? +d:h.getRight();e=e>h.getBottom()?e:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;d+=h;e+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();d=d=0&&Math.min(e,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){j=!0;e=d=c=b=0;a()};this.isEmpty=function(){return j}}; THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}}; -THREE.Matrix4=function(a,b,c,d,e,h,f,i,g,j,m,k,n,l,r,s){this.set(a||1,b||0,c||0,d||0,e||0,h||1,f||0,i||0,g||0,j||0,m||1,k||0,n||0,l||0,r||0,s||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(a,b,c,d,e,h,f,i,g,j,m,k,n,l,r,s){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=h;this.n23=f;this.n24=i;this.n31=g;this.n32=j;this.n33=m;this.n34=k;this.n41=n;this.n42=l;this.n43=r;this.n44=s;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__v1, -e=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,b).normalize();if(h.length()===0)h.z=1;d.cross(c,h).normalize();if(d.length()===0){h.x+=1.0E-4;d.cross(c,h).normalize()}e.cross(h,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=h.x;this.n21=d.y;this.n22=e.y;this.n23=h.y;this.n31=d.z;this.n32=e.z;this.n33=h.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23* +THREE.Matrix4=function(a,b,c,d,e,g,f,j,h,i,k,n,m,o,q,r){this.set(a||1,b||0,c||0,d||0,e||0,g||1,f||0,j||0,h||0,i||0,k||1,n||0,m||0,o||0,q||0,r||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(a,b,c,d,e,g,f,j,h,i,k,n,m,o,q,r){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=f;this.n24=j;this.n31=h;this.n32=i;this.n33=k;this.n34=n;this.n41=m;this.n42=o;this.n43=q;this.n44=r;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__v1, +e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;d.cross(c,g).normalize();if(d.length()===0){g.x+=1.0E-4;d.cross(c,g).normalize()}e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23* d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize(); -return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,h=a.n14,f=a.n21,i=a.n22,g=a.n23,j=a.n24,m=a.n31,k=a.n32,n=a.n33,l=a.n34,r=a.n41,s=a.n42,y=a.n43,u=a.n44,H=b.n11,I=b.n12,D=b.n13,w=b.n14,o=b.n21,O=b.n22, -J=b.n23,K=b.n24,P=b.n31,C=b.n32,x=b.n33,F=b.n34;this.n11=c*H+d*o+e*P;this.n12=c*I+d*O+e*C;this.n13=c*D+d*J+e*x;this.n14=c*w+d*K+e*F+h;this.n21=f*H+i*o+g*P;this.n22=f*I+i*O+g*C;this.n23=f*D+i*J+g*x;this.n24=f*w+i*K+g*F+j;this.n31=m*H+k*o+n*P;this.n32=m*I+k*O+n*C;this.n33=m*D+k*J+n*x;this.n34=m*w+k*K+n*F+l;this.n41=r*H+s*o+y*P;this.n42=r*I+s*O+y*C;this.n43=r*D+s*J+y*x;this.n44=r*w+s*K+y*F+u;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]= +return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,j=a.n22,h=a.n23,i=a.n24,k=a.n31,n=a.n32,m=a.n33,o=a.n34,q=a.n41,r=a.n42,v=a.n43,w=a.n44,I=b.n11,D=b.n12,N=b.n13,x=b.n14,l=b.n21,J=b.n22, +K=b.n23,P=b.n24,L=b.n31,B=b.n32,z=b.n33,M=b.n34;this.n11=c*I+d*l+e*L;this.n12=c*D+d*J+e*B;this.n13=c*N+d*K+e*z;this.n14=c*x+d*P+e*M+g;this.n21=f*I+j*l+h*L;this.n22=f*D+j*J+h*B;this.n23=f*N+j*K+h*z;this.n24=f*x+j*P+h*M+i;this.n31=k*I+n*l+m*L;this.n32=k*D+n*J+m*B;this.n33=k*N+n*K+m*z;this.n34=k*x+n*P+m*M+o;this.n41=q*I+r*l+v*L;this.n42=q*D+r*J+v*B;this.n43=q*N+r*K+v*z;this.n44=q*x+r*P+v*M+w;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]= this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a= -this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,h=this.n22,f=this.n23,i=this.n24,g=this.n31,j=this.n32,m=this.n33,k=this.n34,n=this.n41,l=this.n42,r=this.n43,s=this.n44;return d*f*j*n-c*i*j*n-d*h*m*n+b*i*m*n+c*h*k*n-b*f*k*n-d*f*g*l+c*i*g*l+d*e*m*l-a*i*m*l-c*e*k*l+a*f*k*l+d*h*g*r-b*i*g*r-d*e*j*r+a*i*j*r+b*e*k*r-a*h*k*r-c*h*g*s+b*f*g*s+c*e*j*s-a*f*j*s-b*e*m*s+a*h*m*s},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32= +this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,g=this.n22,f=this.n23,j=this.n24,h=this.n31,i=this.n32,k=this.n33,n=this.n34,m=this.n41,o=this.n42,q=this.n43,r=this.n44;return d*f*i*m-c*j*i*m-d*g*k*m+b*j*k*m+c*g*n*m-b*f*n*m-d*f*h*o+c*j*h*o+d*e*k*o-a*j*k*o-c*e*n*o+a*f*n*o+d*g*h*q-b*j*h*q-d*e*i*q+a*j*i*q+b*e*n*q-a*g*n*q-c*g*h*r+b*f*h*r+c*e*i*r-a*f*i*r-b*e*k*r+a*g*k*r},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32= this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21; this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]= this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a, -b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,h=a.x,f=a.y,i=a.z,g=e*h,j=e*f;this.set(g* -h+c,g*f-d*i,g*i+d*f,0,g*f+d*i,j*f+c,j*i-d*h,0,g*i-d*f,j*i+d*h,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){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(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var h=Math.cos(d);d=Math.sin(d);var f=a*c,i=b*c;this.n11=e*h;this.n12=-e*d;this.n13=c;this.n21=i*h+a*d;this.n22=-i*d+a*h;this.n23=-b*e;this.n31=-f*h+b*d;this.n32=f*d+b*h;this.n33=a*e;return this}, -setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,h=b+b,f=c+c,i=d+d;a=b*h;var g=b*f;b*=i;var j=c*f;c*=i;d*=i;h*=e;f*=e;e*=i;this.n11=1-(j+d);this.n12=g-e;this.n13=b+f;this.n21=g+e;this.n22=1-(a+d);this.n23=c-h;this.n31=b-f;this.n32=c+h;this.n33=1-(a+j);return this},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14= +b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,g=a.x,f=a.y,j=a.z,h=e*g,i=e*f;this.set(h* +g+c,h*f-d*j,h*j+d*f,0,h*f+d*j,i*f+c,i*j-d*g,0,h*j-d*f,i*j+d*g,e*j*j+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){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(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var f=a*c,j=b*c;this.n11=e*g;this.n12=-e*d;this.n13=c;this.n21=j*g+a*d;this.n22=-j*d+a*g;this.n23=-b*e;this.n31=-f*g+b*d;this.n32=f*d+b*g;this.n33=a*e;return this}, +setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,g=b+b,f=c+c,j=d+d;a=b*g;var h=b*f;b*=j;var i=c*f;c*=j;d*=j;g*=e;f*=e;e*=j;this.n11=1-(i+d);this.n12=h-e;this.n13=b+f;this.n21=h+e;this.n22=1-(a+d);this.n23=c-g;this.n31=b-f;this.n32=c+g;this.n33=1-(a+i);return this},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14= a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/b.y,e=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}}; -THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,h=a.n14,f=a.n21,i=a.n22,g=a.n23,j=a.n24,m=a.n31,k=a.n32,n=a.n33,l=a.n34,r=a.n41,s=a.n42,y=a.n43,u=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=g*l*s-j*n*s+j*k*y-i*l*y-g*k*u+i*n*u;b.n12=h*n*s-e*l*s-h*k*y+d*l*y+e*k*u-d*n*u;b.n13=e*j*s-h*g*s+h*i*y-d*j*y-e*i*u+d*g*u;b.n14=h*g*k-e*j*k-h*i*n+d*j*n+e*i*l-d*g*l;b.n21=j*n*r-g*l*r-j*m*y+f*l*y+g*m*u-f*n*u;b.n22=e*l*r-h*n*r+h*m*y-c*l*y-e*m*u+c*n*u;b.n23=h*g*r-e*j*r-h*f*y+c*j*y+e*f*u-c*g*u; -b.n24=e*j*m-h*g*m+h*f*n-c*j*n-e*f*l+c*g*l;b.n31=i*l*r-j*k*r+j*m*s-f*l*s-i*m*u+f*k*u;b.n32=h*k*r-d*l*r-h*m*s+c*l*s+d*m*u-c*k*u;b.n33=e*j*r-h*i*r+h*f*s-c*j*s-d*f*u+c*i*u;b.n34=h*i*m-d*j*m-h*f*k+c*j*k+d*f*l-c*i*l;b.n41=g*k*r-i*n*r-g*m*s+f*n*s+i*m*y-f*k*y;b.n42=d*n*r-e*k*r+e*m*s-c*n*s-d*m*y+c*k*y;b.n43=e*i*r-d*g*r-e*f*s+c*g*s+d*f*y-c*i*y;b.n44=d*g*m-e*i*m+e*f*k-c*g*k-d*f*n+c*i*n;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,h=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,g=-a.n32*a.n11+a.n31*a.n12,j=a.n23*a.n12-a.n22*a.n13,m=-a.n23*a.n11+a.n21*a.n13,k=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*f+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*h;c[3]=a*f;c[4]=a*i;c[5]=a*g;c[6]=a*j;c[7]=a*m;c[8]=a*k;return b}; -THREE.Matrix4.makeFrustum=function(a,b,c,d,e,h){var f;f=new THREE.Matrix4;f.n11=2*e/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*e/(d-c);f.n23=(d+c)/(d-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(h+e)/(h-e);f.n34=-2*h*e/(h-e);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)}; -THREE.Matrix4.makeOrtho=function(a,b,c,d,e,h){var f,i,g,j;f=new THREE.Matrix4;i=b-a;g=c-d;j=h-e;f.n11=2/i;f.n12=0;f.n13=0;f.n14=-((b+a)/i);f.n21=0;f.n22=2/g;f.n23=0;f.n24=-((c+d)/g);f.n31=0;f.n32=0;f.n33=-2/j;f.n34=-((h+e)/j);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; +THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,j=a.n22,h=a.n23,i=a.n24,k=a.n31,n=a.n32,m=a.n33,o=a.n34,q=a.n41,r=a.n42,v=a.n43,w=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*r-i*m*r+i*n*v-j*o*v-h*n*w+j*m*w;b.n12=g*m*r-e*o*r-g*n*v+d*o*v+e*n*w-d*m*w;b.n13=e*i*r-g*h*r+g*j*v-d*i*v-e*j*w+d*h*w;b.n14=g*h*n-e*i*n-g*j*m+d*i*m+e*j*o-d*h*o;b.n21=i*m*q-h*o*q-i*k*v+f*o*v+h*k*w-f*m*w;b.n22=e*o*q-g*m*q+g*k*v-c*o*v-e*k*w+c*m*w;b.n23=g*h*q-e*i*q-g*f*v+c*i*v+e*f*w-c*h*w; +b.n24=e*i*k-g*h*k+g*f*m-c*i*m-e*f*o+c*h*o;b.n31=j*o*q-i*n*q+i*k*r-f*o*r-j*k*w+f*n*w;b.n32=g*n*q-d*o*q-g*k*r+c*o*r+d*k*w-c*n*w;b.n33=e*i*q-g*j*q+g*f*r-c*i*r-d*f*w+c*j*w;b.n34=g*j*k-d*i*k-g*f*n+c*i*n+d*f*o-c*j*o;b.n41=h*n*q-j*m*q-h*k*r+f*m*r+j*k*v-f*n*v;b.n42=d*m*q-e*n*q+e*k*r-c*m*r-d*k*v+c*n*v;b.n43=e*j*q-d*h*q-e*f*r+c*h*r+d*f*v-c*j*v;b.n44=d*h*k-e*j*k+e*f*n-c*h*n-d*f*m+c*j*m;b.multiplyScalar(1/a.determinant());return b}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,k=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*f+a.n31*i;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*f;c[4]=a*j;c[5]=a*h;c[6]=a*i;c[7]=a*k;c[8]=a*n;return b}; +THREE.Matrix4.makeFrustum=function(a,b,c,d,e,g){var f;f=new THREE.Matrix4;f.n11=2*e/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*e/(d-c);f.n23=(d+c)/(d-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(g+e)/(g-e);f.n34=-2*g*e/(g-e);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)}; +THREE.Matrix4.makeOrtho=function(a,b,c,d,e,g){var f,j,h,i;f=new THREE.Matrix4;j=b-a;h=c-d;i=g-e;f.n11=2/j;f.n12=0;f.n13=0;f.n14=-((b+a)/j);f.n21=0;f.n22=2/h;f.n23=0;f.n24=-((c+d)/h);f.n31=0;f.n32=0;f.n33=-2/i;f.n34=-((g+e)/i);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible= !0;this._vector=new THREE.Vector3;this.name=""}; THREE.Object3D.prototype={translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)=== -1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==undefined;)b=b.parent;b!==undefined&&b instanceof THREE.Scene&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},getChildByName:function(a,b){var c,d,e;c=0;for(d=this.children.length;c=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*h)/f;d=Math.sin(d*h)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; -THREE.Face3=function(a,b,c,d,e,h){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3}; -THREE.Face4=function(a,b,c,d,e,h,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)}; +multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,j=a.z;a=a.w;this.x=b*a+e*g+c*j-d*f;this.y=c*a+e*f+d*g-b*j;this.z=d*a+e*j+b*f-c*g;this.w=e*a-b*g-c*f-d*j;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,j=this.z,h=this.w,i=h*c+f*e-j*d,k= +h*d+j*c-g*e,n=h*e+g*d-f*c;c=-g*c-f*d-j*e;b.x=i*h+c*-g+k*-j-n*-f;b.y=k*h+c*-f+n*-g-i*-j;b.z=n*h+c*-j+i*-f-k*-g;return b}}; +THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; +THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3}; +THREE.Face4=function(a,b,c,d,e,g,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)}; THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.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 a,b,c;a=0;for(b=this.faces.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;bthis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b=0&&L>=0&&t>=0&&G>=0)return!0;else if(Q<0&&L<0||t<0&&G<0)return!1;else{if(Q<0)F=Math.max(F,Q/(Q-L));else L<0&&(M=Math.min(M,Q/(Q-L)));if(t<0)F=Math.max(F,t/(t-G));else G<0&&(M=Math.min(M,t/(t-G)));if(MQ&&f.positionScreen.z0&&w.z<1){R=I[H]=I[H]||new THREE.RenderableParticle;H++;u=R;u.x=w.x/w.w;u.y=w.y/w.w;u.z=w.z;u.rotation=v.rotation.z;u.scale.x=v.scale.x*Math.abs(u.x-(w.x+x.projectionMatrix.n11)/ -(w.w+x.projectionMatrix.n14));u.scale.y=v.scale.y*Math.abs(u.y-(w.y+x.projectionMatrix.n22)/(w.w+x.projectionMatrix.n24));u.materials=v.materials;M.push(u)}}}}F&&M.sort(b);return M}}; -THREE.SVGRenderer=function(){function a(t,G,z){var E,p,q,A;E=0;for(p=t.lights.length;E0){z.r+=q.color.r*A;z.g+=q.color.g*A;z.b+=q.color.b*A}}else if(q instanceof THREE.PointLight){P.sub(q.position,G.centroidWorld);P.normalize();A=G.normalWorld.dot(P)*q.intensity;if(A>0){z.r+=q.color.r*A;z.g+=q.color.g*A;z.b+=q.color.b*A}}}}function b(t,G,z,E,p,q){h.data.vertices+=3;h.data.faces++;F=d(M++); -F.setAttribute("d","M "+t.positionScreen.x+" "+t.positionScreen.y+" L "+G.positionScreen.x+" "+G.positionScreen.y+" L "+z.positionScreen.x+","+z.positionScreen.y+"z");if(p instanceof THREE.MeshBasicMaterial)D.__styleString=p.color.__styleString;else if(p instanceof THREE.MeshLambertMaterial)if(I){w.r=o.r;w.g=o.g;w.b=o.b;a(q,E,w);D.r=p.color.r*w.r;D.g=p.color.g*w.g;D.b=p.color.b*w.b;D.updateStyleString()}else D.__styleString=p.color.__styleString;else if(p instanceof THREE.MeshDepthMaterial){K=1-p.__2near/ -(p.__farPlusNear-E.z*p.__farMinusNear);D.setRGB(K,K,K)}else p instanceof THREE.MeshNormalMaterial&&D.setRGB(e(E.normalWorld.x),e(E.normalWorld.y),e(E.normalWorld.z));p.wireframe?F.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+p.wireframeLinewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.wireframeLinecap+"; stroke-linejoin: "+p.wireframeLinejoin):F.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+p.opacity);g.appendChild(F)}function c(t, -G,z,E,p,q,A){h.data.vertices+=4;h.data.faces++;F=d(M++);F.setAttribute("d","M "+t.positionScreen.x+" "+t.positionScreen.y+" L "+G.positionScreen.x+" "+G.positionScreen.y+" L "+z.positionScreen.x+","+z.positionScreen.y+" L "+E.positionScreen.x+","+E.positionScreen.y+"z");if(q instanceof THREE.MeshBasicMaterial)D.__styleString=q.color.__styleString;else if(q instanceof THREE.MeshLambertMaterial)if(I){w.r=o.r;w.g=o.g;w.b=o.b;a(A,p,w);D.r=q.color.r*w.r;D.g=q.color.g*w.g;D.b=q.color.b*w.b;D.updateStyleString()}else D.__styleString= -q.color.__styleString;else if(q instanceof THREE.MeshDepthMaterial){K=1-q.__2near/(q.__farPlusNear-p.z*q.__farMinusNear);D.setRGB(K,K,K)}else q instanceof THREE.MeshNormalMaterial&&D.setRGB(e(p.normalWorld.x),e(p.normalWorld.y),e(p.normalWorld.z));q.wireframe?F.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+q.wireframeLinewidth+"; stroke-opacity: "+q.opacity+"; stroke-linecap: "+q.wireframeLinecap+"; stroke-linejoin: "+q.wireframeLinejoin):F.setAttribute("style","fill: "+ -D.__styleString+"; fill-opacity: "+q.opacity);g.appendChild(F)}function d(t){if(C[t]==null){C[t]=document.createElementNS("http://www.w3.org/2000/svg","path");L==0&&C[t].setAttribute("shape-rendering","crispEdges")}return C[t]}function e(t){return t<0?Math.min((1+t)*0.5,0.5):0.5+Math.min(t*0.5,0.5)}var h=this,f=null,i=new THREE.Projector,g=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,k,n,l,r,s,y,u=new THREE.Rectangle,H=new THREE.Rectangle,I=!1,D=new THREE.Color(16777215),w=new THREE.Color(16777215), -o=new THREE.Color(0),O=new THREE.Color(0),J=new THREE.Color(0),K,P=new THREE.Vector3,C=[],x=[],F,M,Q,L=1;this.domElement=g;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data={vertices:0,faces:0};this.setQuality=function(t){switch(t){case "high":L=1;break;case "low":L=0}};this.setSize=function(t,G){j=t;m=G;k=j/2;n=m/2;g.setAttribute("viewBox",-k+" "+-n+" "+j+" "+m);g.setAttribute("width",j);g.setAttribute("height",m);u.set(-k,-n,k,n)};this.clear=function(){for(;g.childNodes.length> -0;)g.removeChild(g.childNodes[0])};this.render=function(t,G){var z,E,p,q,A,N,B,v;this.autoClear&&this.clear();h.data.vertices=0;h.data.faces=0;f=i.projectScene(t,G,this.sortElements);Q=M=0;if(I=t.lights.length>0){B=t.lights;o.setRGB(0,0,0);O.setRGB(0,0,0);J.setRGB(0,0,0);z=0;for(E=B.length;z=0&&O>=0&&F>=0&&t>=0)return!0;else if(Q<0&&O<0||F<0&&t<0)return!1;else{if(Q<0)M=Math.max(M,Q/(Q-O));else O<0&&(G=Math.min(G,Q/(Q-O)));if(F<0)M=Math.max(M,F/(F-t));else t<0&&(G=Math.min(G,F/(F-t)));if(GQ&&f.positionScreen.z0&&x.z<1){H=D[I]=D[I]||new THREE.RenderableParticle;I++;w=H;w.x=x.x/x.w;w.y=x.y/x.w;w.z=x.z;w.rotation=u.rotation.z;w.scale.x=u.scale.x*Math.abs(w.x-(x.x+z.projectionMatrix.n11)/ +(x.w+z.projectionMatrix.n14));w.scale.y=u.scale.y*Math.abs(w.y-(x.y+z.projectionMatrix.n22)/(x.w+z.projectionMatrix.n24));w.materials=u.materials;G.push(w)}}}}M&&G.sort(b);return G}}; +THREE.SVGRenderer=function(){function a(t,C,A){var y,s,p,E;y=0;for(s=t.lights.length;y0){A.r+=p.color.r*E;A.g+=p.color.g*E;A.b+=p.color.b*E}}else if(p instanceof THREE.PointLight){B.sub(p.position,C.centroidWorld);B.normalize();E=C.normalWorld.dot(B)*p.intensity;if(E>0){A.r+=p.color.r*E;A.g+=p.color.g*E;A.b+=p.color.b*E}}}}function b(t,C,A,y,s,p){f.data.vertices+=3;f.data.faces++;G=d(Q++); +G.setAttribute("d","M "+t.positionScreen.x+" "+t.positionScreen.y+" L "+C.positionScreen.x+" "+C.positionScreen.y+" L "+A.positionScreen.x+","+A.positionScreen.y+"z");if(s instanceof THREE.MeshBasicMaterial)x.hex=s.color.hex;else if(s instanceof THREE.MeshLambertMaterial)if(N){l.r=J.r;l.g=J.g;l.b=J.b;a(p,y,l);x.r=Math.max(0,Math.min(s.color.r*l.r,1));x.g=Math.max(0,Math.min(s.color.g*l.g,1));x.b=Math.max(0,Math.min(s.color.b*l.b,1));x.updateHex()}else x.hex=s.color.hex;else if(s instanceof THREE.MeshDepthMaterial){L= +1-s.__2near/(s.__farPlusNear-y.z*s.__farMinusNear);x.setRGB(L,L,L)}else s instanceof THREE.MeshNormalMaterial&&x.setRGB(e(y.normalWorld.x),e(y.normalWorld.y),e(y.normalWorld.z));s.wireframe?G.setAttribute("style","fill: none; stroke: #"+g(x.hex.toString(16))+"; stroke-width: "+s.wireframeLinewidth+"; stroke-opacity: "+s.opacity+"; stroke-linecap: "+s.wireframeLinecap+"; stroke-linejoin: "+s.wireframeLinejoin):G.setAttribute("style","fill: #"+g(x.hex.toString(16))+"; fill-opacity: "+s.opacity);i.appendChild(G)} +function c(t,C,A,y,s,p,E){f.data.vertices+=4;f.data.faces++;G=d(Q++);G.setAttribute("d","M "+t.positionScreen.x+" "+t.positionScreen.y+" L "+C.positionScreen.x+" "+C.positionScreen.y+" L "+A.positionScreen.x+","+A.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+"z");if(p instanceof THREE.MeshBasicMaterial)x.hex=p.color.hex;else if(p instanceof THREE.MeshLambertMaterial)if(N){l.r=J.r;l.g=J.g;l.b=J.b;a(E,s,l);x.r=Math.max(0,Math.min(p.color.r*l.r,1));x.g=Math.max(0,Math.min(p.color.g* +l.g,1));x.b=Math.max(0,Math.min(p.color.b*l.b,1));x.updateHex()}else x.hex=p.color.hex;else if(p instanceof THREE.MeshDepthMaterial){L=1-p.__2near/(p.__farPlusNear-s.z*p.__farMinusNear);x.setRGB(L,L,L)}else p instanceof THREE.MeshNormalMaterial&&x.setRGB(e(s.normalWorld.x),e(s.normalWorld.y),e(s.normalWorld.z));p.wireframe?G.setAttribute("style","fill: none; stroke: #"+g(x.hex.toString(16))+"; stroke-width: "+p.wireframeLinewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.wireframeLinecap+ +"; stroke-linejoin: "+p.wireframeLinejoin):G.setAttribute("style","fill: #"+g(x.hex.toString(16))+"; fill-opacity: "+p.opacity);i.appendChild(G)}function d(t){if(z[t]==null){z[t]=document.createElementNS("http://www.w3.org/2000/svg","path");F==0&&z[t].setAttribute("shape-rendering","crispEdges")}return z[t]}function e(t){t=(t+1)*0.5;return t<0?0:t>1?1:t}function g(t){for(;t.length<6;)t="0"+t;return t}var f=this,j=null,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"), +k,n,m,o,q,r,v,w,I=new THREE.Rectangle,D=new THREE.Rectangle,N=!1,x=new THREE.Color(16777215),l=new THREE.Color(16777215),J=new THREE.Color(0),K=new THREE.Color(0),P=new THREE.Color(0),L,B=new THREE.Vector3,z=[],M=[],G,Q,O,F=1;this.domElement=i;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data={vertices:0,faces:0};this.setQuality=function(t){switch(t){case "high":F=1;break;case "low":F=0}};this.setSize=function(t,C){k=t;n=C;m=k/2;o=n/2;i.setAttribute("viewBox",-m+" "+-o+" "+k+" "+ +n);i.setAttribute("width",k);i.setAttribute("height",n);I.set(-m,-o,m,o)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(t,C){var A,y,s,p,E,R,u,H;this.autoClear&&this.clear();f.data.vertices=0;f.data.faces=0;j=h.projectScene(t,C,this.sortElements);O=Q=0;if(N=t.lights.length>0){u=t.lights;J.setRGB(0,0,0);K.setRGB(0,0,0);P.setRGB(0,0,0);A=0;for(y=u.length;A>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* -255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(b,d){this.set(b||0,d||0)}; +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,e){this.r=b;this.g=d;this.b=e;this.updateHex()},setHSV:function(b,d,e){var g,h,o,n,q,r;if(e==0)g=h=o=0;else{n=Math.floor(b*6);q=b*6-n;b=e*(1-d);r=e*(1-d*q);d=e*(1-d*(1-q));switch(n){case 1:g=r;h=e;o=b;break;case 2:g=b;h=e;o=d;break;case 3:g=b;h=r;o=e;break;case 4:g=d;h=b;o=e;break;case 5:g=e;h=b;o=r;break;case 6:case 0:g=e;h=d;o=b}}this.setRGB(g, +h,o)},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,e){this.set(b||0,d||0,e||0)}; THREE.Vector3.prototype={set:function(b,d,e){this.x=b;this.y=d;this.z=e;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, @@ -50,7 +49,7 @@ THREE.Quaternion.prototype={set:function(b,d,e,g){this.x=b;this.y=d;this.z=e;thi b.y*g;this.z=b.z*g;this.w=Math.cos(e);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(b==0)this.w=this.z=this.y=this.x=0;else{b=1/b;this.x*=b;this.y*=b;this.z*=b;this.w*=b}return this}, multiplySelf:function(b){var d=this.x,e=this.y,g=this.z,h=this.w,o=b.x,n=b.y,q=b.z;b=b.w;this.x=d*b+h*o+e*q-g*n;this.y=e*b+h*n+g*o-d*q;this.z=g*b+h*q+d*n-e*o;this.w=h*b-d*o-e*n-g*q;return this},multiply:function(b,d){this.x=b.x*d.w+b.y*d.z-b.z*d.y+b.w*d.x;this.y=-b.x*d.z+b.y*d.w+b.z*d.x+b.w*d.y;this.z=b.x*d.y-b.y*d.x+b.z*d.w+b.w*d.z;this.w=-b.x*d.x-b.y*d.y-b.z*d.z+b.w*d.w;return this},multiplyVector3:function(b,d){d||(d=b);var e=b.x,g=b.y,h=b.z,o=this.x,n=this.y,q=this.z,r=this.w,v=r*e+n*h-q*g,E= r*g+q*e-o*h,F=r*h+o*g-n*e;e=-o*e-n*g-q*h;d.x=v*r+e*-o+E*-q-F*-n;d.y=E*r+e*-n+F*-o-v*-q;d.z=F*r+e*-q+v*-n-E*-o;return d}}; -THREE.Quaternion.slerp=function(b,d,e,g){var h=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(h)>=1){e.w=b.w;e.x=b.x;e.y=b.y;e.z=b.z;return e}var o=Math.acos(h),n=Math.sqrt(1-h*h);if(Math.abs(n)<0.0010){e.w=0.5*(b.w+d.w);e.x=0.5*(b.x+d.x);e.y=0.5*(b.y+d.y);e.z=0.5*(b.z+d.z);return e}h=Math.sin((1-g)*o)/n;g=Math.sin(g*o)/n;e.w=b.w*h+d.w*g;e.x=b.x*h+d.x*g;e.y=b.y*h+d.y*g;e.z=b.z*h+d.z*g;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; +THREE.Quaternion.slerp=function(b,d,e,g){var h=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(h)>=1){e.w=b.w;e.x=b.x;e.y=b.y;e.z=b.z;return e}var o=Math.acos(h),n=Math.sqrt(1-h*h);if(Math.abs(n)<0.001){e.w=0.5*(b.w+d.w);e.x=0.5*(b.x+d.x);e.y=0.5*(b.y+d.y);e.z=0.5*(b.z+d.z);return e}h=Math.sin((1-g)*o)/n;g=Math.sin(g*o)/n;e.w=b.w*h+d.w*g;e.x=b.x*h+d.x*g;e.y=b.y*h+d.y*g;e.z=b.z*h+d.z*g;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; THREE.Face3=function(b,d,e,g,h,o){this.a=b;this.b=d;this.c=e;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=o instanceof Array?o:[o];this.centroid=new THREE.Vector3}; THREE.Face4=function(b,d,e,g,h,o,n){this.a=b;this.b=d;this.c=e;this.d=g;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=o instanceof THREE.Color?o:new THREE.Color;this.vertexColors=o instanceof Array?o:[];this.vertexTangents=[];this.materials=n instanceof Array?n:[n];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}; @@ -205,7 +204,7 @@ m.rotation);c.uniform2fv(x.scale,A);if(m.mergeWith3D&&!z){c.enable(c.DEPTH_TEST) c.enableVertexAttribArray(J.attributes.uv);qb=!0}c.uniform1i(P.occlusionMap,0);c.uniform1i(P.map,1);c.bindBuffer(c.ARRAY_BUFFER,J.vertexBuffer);c.vertexAttribPointer(j.vertex,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(j.uv,2,c.FLOAT,!1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,J.elementBuffer);c.disable(c.CULL_FACE);c.depthMask(!1);c.activeTexture(c.TEXTURE0);c.bindTexture(c.TEXTURE_2D,J.occlusionTexture);c.activeTexture(c.TEXTURE1);for(k=0;k0&&W[0]0&&W[1] -0.0010&&u.scale>0.0010){O[0]=u.x;O[1]=u.y;O[2]=u.z;D=u.size*u.scale/Aa;B[0]=D*t;B[1]=D;c.uniform3fv(P.screenPosition,O);c.uniform2fv(P.scale,B);c.uniform1f(P.rotation,u.rotation);c.uniform1f(P.opacity,u.opacity);pa(u.blending);K(u.texture,1);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}}}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(Y)}function V(f,p){f._modelViewMatrix.multiplyToArray(p.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)} +0.001&&u.scale>0.001){O[0]=u.x;O[1]=u.y;O[2]=u.z;D=u.size*u.scale/Aa;B[0]=D*t;B[1]=D;c.uniform3fv(P.screenPosition,O);c.uniform2fv(P.scale,B);c.uniform1f(P.rotation,u.rotation);c.uniform1f(P.opacity,u.opacity);pa(u.blending);K(u.texture,1);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}}}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(Y)}function V(f,p){f._modelViewMatrix.multiplyToArray(p.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)} function L(f){var p,j,k,m,x;if(f instanceof THREE.Mesh){j=f.geometry;for(p in j.geometryGroups){k=j.geometryGroups[p];x=!1;for(m in k.__webglCustomAttributes)if(k.__webglCustomAttributes[m].needsUpdate){x=!0;break}if(j.__dirtyVertices||j.__dirtyMorphTargets||j.__dirtyElements||j.__dirtyUvs||j.__dirtyNormals||j.__dirtyColors||j.__dirtyTangents||x){x=c.DYNAMIC_DRAW;var y=void 0,u=void 0,A=void 0,t=void 0;A=void 0;var w=void 0,z=void 0,D=void 0,B=void 0,O=void 0,W=void 0,P=void 0,X=void 0,Ga=void 0, T=void 0,R=void 0,U=void 0,ta=void 0;z=void 0;D=void 0;t=void 0;B=void 0;t=void 0;var s=void 0,G=void 0;z=void 0;s=void 0;G=void 0;var i=void 0,Ka=void 0;s=void 0;G=void 0;i=void 0;Ka=void 0;s=void 0;G=void 0;i=void 0;Ka=void 0;s=void 0;G=void 0;i=void 0;t=void 0;B=void 0;w=void 0;A=void 0;A=void 0;s=void 0;G=void 0;i=void 0;var Va=void 0,ua=0,Ba=0,Za=0,$a=0,Ja=0,La=0,ea=0,Ma=0,wa=0,C=0,Ca=0;G=s=0;var Da=k.__vertexArray,gb=k.__uvArray,hb=k.__uv2Array,Qa=k.__normalArray,ia=k.__tangentArray,Ea=k.__colorArray, ja=k.__skinVertexAArray,ka=k.__skinVertexBArray,la=k.__skinIndexArray,ma=k.__skinWeightArray,ib=k.__morphTargetsArrays,Ra=k.__webglCustomAttributes;i=void 0;var Na=k.__faceArray,Oa=k.__lineArray,rb=k.__needsSmoothNormals;W=k.__vertexColorType;O=k.__uvType;P=k.__normalType;var Ha=f.geometry,jb=Ha.__dirtyVertices,kb=Ha.__dirtyElements,fb=Ha.__dirtyUvs,lb=Ha.__dirtyNormals,mb=Ha.__dirtyTangents,nb=Ha.__dirtyColors,ob=Ha.__dirtyMorphTargets,ab=Ha.vertices,sb=k.faces,vb=Ha.faces,tb=Ha.faceVertexUvs[0], diff --git a/examples/canvas_geometry_birds.html b/examples/canvas_geometry_birds.html index 792b6edf..3893b8a3 100644 --- a/examples/canvas_geometry_birds.html +++ b/examples/canvas_geometry_birds.html @@ -420,7 +420,7 @@ color = bird.materials[ 0 ].color; color.r = color.g = color.b = ( 500 - bird.position.z ) / 1000; - color.updateStyleString(); + color.updateHex(); bird.rotation.y = Math.atan2( - boid.velocity.z, boid.velocity.x ); bird.rotation.z = Math.asin( boid.velocity.y / boid.velocity.length() ); diff --git a/src/core/Color.js b/src/core/Color.js index 22f055d0..8968935b 100644 --- a/src/core/Color.js +++ b/src/core/Color.js @@ -10,15 +10,19 @@ THREE.Color = function ( hex ) { THREE.Color.prototype = { - autoUpdate : true, - copy : function ( color ) { this.r = color.r; this.g = color.g; this.b = color.b; this.hex = color.hex; - this.__styleString = color.__styleString; + + }, + + setHex : function ( hex ) { + + this.hex = ( ~~ hex ) & 0xffffff; + this.updateRGB(); }, @@ -28,12 +32,7 @@ THREE.Color.prototype = { this.g = g; this.b = b; - if ( this.autoUpdate ) { - - this.updateHex(); - this.updateStyleString(); - - } + this.updateHex(); }, @@ -42,11 +41,11 @@ THREE.Color.prototype = { // based on MochiKit implementation by Bob Ippolito // h,s,v ranges are < 0.0 - 1.0 > - var red, green, blue, i, f, p, q, t; + var r, g, b, i, f, p, q, t; if ( v == 0.0 ) { - red = green = blue = 0; + r = g = b = 0; } else { @@ -58,41 +57,19 @@ THREE.Color.prototype = { switch ( i ) { - case 1: red = q; green = v; blue = p; break; - case 2: red = p; green = v; blue = t; break; - case 3: red = p; green = q; blue = v; break; - case 4: red = t; green = p; blue = v; break; - case 5: red = v; green = p; blue = q; break; + case 1: r = q; g = v; b = p; break; + case 2: r = p; g = v; b = t; break; + case 3: r = p; g = q; b = v; break; + case 4: r = t; g = p; b = v; break; + case 5: r = v; g = p; b = q; break; case 6: // fall through - case 0: red = v; green = t; blue = p; break; + case 0: r = v; g = t; b = p; break; } } - this.r = red; - this.g = green; - this.b = blue; - - if ( this.autoUpdate ) { - - this.updateHex(); - this.updateStyleString(); - - } - - }, - - setHex : function ( hex ) { - - this.hex = ( ~~ hex ) & 0xffffff; - - if ( this.autoUpdate ) { - - this.updateRGB(); - this.updateStyleString(); - - } + this.setRGB( r, g, b ); }, @@ -110,12 +87,6 @@ THREE.Color.prototype = { }, - updateStyleString : function () { - - this.__styleString = 'rgb(' + ~~ ( this.r * 255 ) + ',' + ~~ ( this.g * 255 ) + ',' + ~~ ( this.b * 255 ) + ')'; - - }, - clone : function () { return new THREE.Color( this.hex ); diff --git a/src/extras/io/JSONLoader.js b/src/extras/io/JSONLoader.js index 8852a858..83fdb83a 100644 --- a/src/extras/io/JSONLoader.js +++ b/src/extras/io/JSONLoader.js @@ -46,7 +46,7 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path var scope = this, geometry = new THREE.Geometry(), - scale = ( json.scale !== undefined ) ? json.scale : 1.0; + scale = ( json.scale !== undefined ) ? 1.0 / json.scale : 1.0; this.init_materials( geometry, json.materials, texture_path ); @@ -121,9 +121,9 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path vertex = new THREE.Vertex(); - vertex.position.x = vertices[ offset ++ ] / scale; - vertex.position.y = vertices[ offset ++ ] / scale; - vertex.position.z = vertices[ offset ++ ] / scale; + vertex.position.x = vertices[ offset ++ ] * scale; + vertex.position.y = vertices[ offset ++ ] * scale; + vertex.position.z = vertices[ offset ++ ] * scale; geometry.vertices.push( vertex ); @@ -342,9 +342,9 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path for( v = 0, vl = srcVertices.length; v < vl; v += 3 ) { - x = srcVertices[ v ] / scale; - y = srcVertices[ v + 1 ] / scale; - z = srcVertices[ v + 2 ] / scale; + x = srcVertices[ v ] * scale; + y = srcVertices[ v + 1 ] * scale; + z = srcVertices[ v + 2 ] * scale; dstVertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) ); diff --git a/src/renderers/CanvasRenderer.js b/src/renderers/CanvasRenderer.js index 8528d110..c0605b89 100644 --- a/src/renderers/CanvasRenderer.js +++ b/src/renderers/CanvasRenderer.js @@ -30,11 +30,11 @@ THREE.CanvasRenderer = function () { _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y, _v5x, _v5y, _v6x, _v6y, - _color = new THREE.Color(), - _color1 = new THREE.Color(), - _color2 = new THREE.Color(), - _color3 = new THREE.Color(), - _color4 = new THREE.Color(), + _color = new THREE.Color( 0x000000 ), + _color1 = new THREE.Color( 0x000000 ), + _color2 = new THREE.Color( 0x000000 ), + _color3 = new THREE.Color( 0x000000 ), + _color4 = new THREE.Color( 0x000000 ), _near, _far, @@ -505,8 +505,8 @@ THREE.CanvasRenderer = function () { } - setStrokeStyle( material.color.__styleString ); - setFillStyle( material.color.__styleString ); + setStrokeStyle( material.color ); + setFillStyle( material.color ); _context.save(); _context.translate( v1.x, v1.y ); @@ -533,12 +533,10 @@ THREE.CanvasRenderer = function () { if ( material instanceof THREE.LineBasicMaterial ) { - _color.__styleString = material.color.__styleString; - setLineWidth( material.linewidth ); setLineCap( material.linecap ); setLineJoin( material.linejoin ); - setStrokeStyle( _color.__styleString ); + setStrokeStyle( material.color ); _context.stroke(); _bboxRect.inflate( material.linewidth * 2 ); @@ -602,7 +600,7 @@ THREE.CanvasRenderer = function () { } else { - material.wireframe ? strokePath( material.color.__styleString, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color.__styleString ); + material.wireframe ? strokePath( material.color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color ); } @@ -633,7 +631,7 @@ THREE.CanvasRenderer = function () { calculateLight( scene, element.v2.positionWorld, element.vertexNormalsWorld[ 1 ], _color2 ); calculateLight( scene, element.v3.positionWorld, element.vertexNormalsWorld[ 2 ], _color3 ); - _color4.r = ( _color2.r + _color3.r ) * 0.5; + _color4.r = ( _color2.r + _color3.r ) * 0.5; _color4.g = ( _color2.g + _color3.g ) * 0.5; _color4.b = ( _color2.b + _color3.b ) * 0.5; @@ -649,19 +647,18 @@ THREE.CanvasRenderer = function () { calculateLight( scene, element.centroidWorld, element.normalWorld, _light ); - _color.r = material.color.r * _light.r; - _color.g = material.color.g * _light.g; - _color.b = material.color.b * _light.b; + _color.r = Math.max( 0, Math.min( material.color.r * _light.r, 1 ) ); + _color.g = Math.max( 0, Math.min( material.color.g * _light.g, 1 ) ); + _color.b = Math.max( 0, Math.min( material.color.b * _light.b, 1 ) ); + _color.updateHex(); - _color.updateStyleString(); - - material.wireframe ? strokePath( _color.__styleString, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color.__styleString ); + material.wireframe ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color ); } } else { - material.wireframe ? strokePath( material.color.__styleString, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color.__styleString ); + material.wireframe ? strokePath( material.color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color ); } @@ -687,9 +684,9 @@ THREE.CanvasRenderer = function () { _color.r = normalToComponent( element.normalWorld.x ); _color.g = normalToComponent( element.normalWorld.y ); _color.b = normalToComponent( element.normalWorld.z ); - _color.updateStyleString(); + _color.updateHex(); - material.wireframe ? strokePath( _color.__styleString, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color.__styleString ); + material.wireframe ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color ); } @@ -725,7 +722,7 @@ THREE.CanvasRenderer = function () { drawQuad( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y ); - material.wireframe ? strokePath( material.color.__styleString, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color.__styleString ); + material.wireframe ? strokePath( material.color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color ); } else if ( material instanceof THREE.MeshLambertMaterial ) { @@ -760,15 +757,14 @@ THREE.CanvasRenderer = function () { calculateLight( scene, element.centroidWorld, element.normalWorld, _light ); - _color.r = material.color.r * _light.r; - _color.g = material.color.g * _light.g; - _color.b = material.color.b * _light.b; - - _color.updateStyleString(); + _color.r = Math.max( 0, Math.min( material.color.r * _light.r, 1 ) ); + _color.g = Math.max( 0, Math.min( material.color.g * _light.g, 1 ) ); + _color.b = Math.max( 0, Math.min( material.color.b * _light.b, 1 ) ); + _color.updateHex(); drawQuad( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y ); - material.wireframe ? strokePath( _color.__styleString, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color.__styleString ); + material.wireframe ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color ); } @@ -776,7 +772,7 @@ THREE.CanvasRenderer = function () { drawQuad( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y ); - material.wireframe ? strokePath( material.color.__styleString, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color.__styleString ); + material.wireframe ? strokePath( material.color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color ); } @@ -785,11 +781,11 @@ THREE.CanvasRenderer = function () { _color.r = normalToComponent( element.normalWorld.x ); _color.g = normalToComponent( element.normalWorld.y ); _color.b = normalToComponent( element.normalWorld.z ); - _color.updateStyleString(); + _color.updateHex(); drawQuad( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y ); - material.wireframe ? strokePath( _color.__styleString, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color.__styleString ); + material.wireframe ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color ); } else if ( material instanceof THREE.MeshDepthMaterial ) { @@ -1076,24 +1072,33 @@ THREE.CanvasRenderer = function () { } - function setStrokeStyle( value ) { + function setStrokeStyle( color ) { - if ( _contextStrokeStyle != value ) { + if ( _contextStrokeStyle != color.hex ) { - _context.strokeStyle = _contextStrokeStyle = value; + _contextStrokeStyle = color.hex; + _context.strokeStyle = '#' + pad( _contextStrokeStyle.toString( 16 ) ); } } - function setFillStyle( value ) { + function setFillStyle( color ) { - if ( _contextFillStyle != value ) { + if ( _contextFillStyle != color.hex ) { - _context.fillStyle = _contextFillStyle = value; + _contextFillStyle = color.hex; + _context.fillStyle = '#' + pad( _contextFillStyle.toString( 16 ) ); } } + function pad( str ) { + + while ( str.length < 6 ) str = '0' + str; + return str; + + } + }; diff --git a/src/renderers/SVGRenderer.js b/src/renderers/SVGRenderer.js index 6013c27a..4e92f973 100644 --- a/src/renderers/SVGRenderer.js +++ b/src/renderers/SVGRenderer.js @@ -363,9 +363,7 @@ THREE.SVGRenderer = function () { if ( material instanceof THREE.LineBasicMaterial ) { - _color.__styleString = material.color.__styleString; - - _svgNode.setAttribute( 'style', 'fill: none; stroke: ' + _color.__styleString + '; stroke-width: ' + material.linewidth + '; stroke-opacity: ' + material.opacity + '; stroke-linecap: ' + material.linecap + '; stroke-linejoin: ' + material.linejoin ); + _svgNode.setAttribute( 'style', 'fill: none; stroke: #' + '#' + pad( material.color.hex.toString( 16 ) ) + '; stroke-width: ' + material.linewidth + '; stroke-opacity: ' + material.opacity + '; stroke-linecap: ' + material.linecap + '; stroke-linejoin: ' + material.linejoin ); _svg.appendChild( _svgNode ); @@ -383,7 +381,7 @@ THREE.SVGRenderer = function () { if ( material instanceof THREE.MeshBasicMaterial ) { - _color.__styleString = material.color.__styleString; + _color.hex = material.color.hex; } else if ( material instanceof THREE.MeshLambertMaterial ) { @@ -395,15 +393,15 @@ THREE.SVGRenderer = function () { calculateFaceLight( scene, element, _light ); - _color.r = material.color.r * _light.r; - _color.g = material.color.g * _light.g; - _color.b = material.color.b * _light.b; + _color.r = Math.max( 0, Math.min( material.color.r * _light.r, 1 ) ); + _color.g = Math.max( 0, Math.min( material.color.g * _light.g, 1 ) ); + _color.b = Math.max( 0, Math.min( material.color.b * _light.b, 1 ) ); - _color.updateStyleString(); + _color.updateHex(); } else { - _color.__styleString = material.color.__styleString; + _color.hex = material.color.hex; } @@ -420,11 +418,11 @@ THREE.SVGRenderer = function () { if ( material.wireframe ) { - _svgNode.setAttribute( 'style', 'fill: none; stroke: ' + _color.__styleString + '; stroke-width: ' + material.wireframeLinewidth + '; stroke-opacity: ' + material.opacity + '; stroke-linecap: ' + material.wireframeLinecap + '; stroke-linejoin: ' + material.wireframeLinejoin ); + _svgNode.setAttribute( 'style', 'fill: none; stroke: #' + pad( _color.hex.toString( 16 ) ) + '; stroke-width: ' + material.wireframeLinewidth + '; stroke-opacity: ' + material.opacity + '; stroke-linecap: ' + material.wireframeLinecap + '; stroke-linejoin: ' + material.wireframeLinejoin ); } else { - _svgNode.setAttribute( 'style', 'fill: ' + _color.__styleString + '; fill-opacity: ' + material.opacity ); + _svgNode.setAttribute( 'style', 'fill: #' + pad( _color.hex.toString( 16 ) ) + '; fill-opacity: ' + material.opacity ); } @@ -442,7 +440,7 @@ THREE.SVGRenderer = function () { if ( material instanceof THREE.MeshBasicMaterial ) { - _color.__styleString = material.color.__styleString; + _color.hex = material.color.hex; } else if ( material instanceof THREE.MeshLambertMaterial ) { @@ -454,15 +452,15 @@ THREE.SVGRenderer = function () { calculateFaceLight( scene, element, _light ); - _color.r = material.color.r * _light.r; - _color.g = material.color.g * _light.g; - _color.b = material.color.b * _light.b; + _color.r = Math.max( 0, Math.min( material.color.r * _light.r, 1 ) ); + _color.g = Math.max( 0, Math.min( material.color.g * _light.g, 1 ) ); + _color.b = Math.max( 0, Math.min( material.color.b * _light.b, 1 ) ); - _color.updateStyleString(); + _color.updateHex(); } else { - _color.__styleString = material.color.__styleString; + _color.hex = material.color.hex; } @@ -479,11 +477,11 @@ THREE.SVGRenderer = function () { if ( material.wireframe ) { - _svgNode.setAttribute( 'style', 'fill: none; stroke: ' + _color.__styleString + '; stroke-width: ' + material.wireframeLinewidth + '; stroke-opacity: ' + material.opacity + '; stroke-linecap: ' + material.wireframeLinecap + '; stroke-linejoin: ' + material.wireframeLinejoin ); + _svgNode.setAttribute( 'style', 'fill: none; stroke: #' + pad( _color.hex.toString( 16 ) ) + '; stroke-width: ' + material.wireframeLinewidth + '; stroke-opacity: ' + material.opacity + '; stroke-linecap: ' + material.wireframeLinecap + '; stroke-linejoin: ' + material.wireframeLinejoin ); } else { - _svgNode.setAttribute( 'style', 'fill: ' + _color.__styleString + '; fill-opacity: ' + material.opacity ); + _svgNode.setAttribute( 'style', 'fill: #' + pad( _color.hex.toString( 16 ) ) + '; fill-opacity: ' + material.opacity ); } @@ -553,9 +551,15 @@ THREE.SVGRenderer = function () { function normalToComponent( normal ) { - // https://gist.github.com/665829 + var component = ( normal + 1 ) * 0.5; + return component < 0 ? 0 : ( component > 1 ? 1 : component ); - return normal < 0 ? Math.min( ( 1 + normal ) * 0.5, 0.5 ) : 0.5 + Math.min( normal * 0.5, 0.5 ); + } + + function pad( str ) { + + while ( str.length < 6 ) str = '0' + str; + return str; }