diff --git a/build/Three.js b/build/Three.js index 1cb150fb..1ab5be74 100755 --- a/build/Three.js +++ b/build/Three.js @@ -1,88 +1,88 @@ // Three.js r37 - http://github.com/mrdoob/three.js var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)}; -THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,b){var d,e,g,h,j,k;if(b==0)d=e=g=0;else{h=Math.floor(a*6);j=a*6-h;a=b*(1-c);k=b*(1-c*j);c=b*(1-c*(1-j));switch(h){case 1:d=k;e=b;g=a;break;case 2:d=a;e=b;g=c;break;case 3:d=a;e=k;g=b;break;case 4:d=c;e=a;g=b;break;case 5:d=b;e=a; -g=k;break;case 6:case 0:d=b;e=c;g=a}}this.r=d;this.g=e;this.b=g;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* +THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,b){var e,f,g,h,k,m;if(b==0)e=f=g=0;else{h=Math.floor(a*6);k=a*6-h;a=b*(1-c);m=b*(1-c*k);c=b*(1-c*(1-k));switch(h){case 1:e=m;f=b;g=a;break;case 2:e=a;f=b;g=c;break;case 3:e=a;f=m;g=b;break;case 4:e=c;f=a;g=b;break;case 5:e=b;f=a; +g=m;break;case 6:case 0:e=b;f=c;g=a}}this.r=e;this.g=f;this.b=g;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* 255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,c){this.set(a||0,c||0)}; THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/ this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,c,b){this.set(a||0,c||0,b||0)}; THREE.Vector3.prototype={set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a, -c){this.set(a.y*c.z-a.z*c.y,a.z*c.x-a.x*c.z,a.x*c.y-a.y*c.x);return this},crossSelf:function(a){var c=this.x,b=this.y,d=this.z;this.set(b*a.z-d*a.y,d*a.x-c*a.z,c*a.y-b*a.x);return this},multiply:function(a,c){this.set(a.x*c.x,a.y*c.y,a.z*c.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/ +c){this.set(a.y*c.z-a.z*c.y,a.z*c.x-a.x*c.z,a.x*c.y-a.y*c.x);return this},crossSelf:function(a){var c=this.x,b=this.y,e=this.z;this.set(b*a.z-e*a.y,e*a.x-c*a.z,c*a.y-b*a.x);return this},multiply:function(a,c){this.set(a.x*c.x,a.y*c.y,a.z*c.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/ a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var c=this.x-a.x,b=this.y-a.y;a=this.z-a.z;return c*c+b*b+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a= this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){this.y=Math.asin(a.n13);var c=Math.cos(this.y);if(Math.abs(c)>1.0E-5){this.x=Math.atan2(-a.n23/c,a.n33/c);this.z=Math.atan2(-a.n13/c,a.n11/c)}else{this.x=0;this.z=Math.atan2(a.n21,a.n22)}},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)< -1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,c,b,d){this.set(a||0,c||0,b||0,d||1)}; -THREE.Vector4.prototype={set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z,a.w+c.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z,a.w-c.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* +1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,c,b,e){this.set(a||0,c||0,b||0,e||1)}; +THREE.Vector4.prototype={set:function(a,c,b,e){this.x=a;this.y=c;this.z=b;this.w=e;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z,a.w+c.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z,a.w-c.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,c){this.set(this.x+(a.x-this.x)*c,this.y+(a.y-this.y)*c,this.z+(a.z-this.z)*c,this.w+(a.w-this.w)*c)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var c,b,d=a.objects,e=[];a=0;for(c=d.length;a0&&F>0&&R+F<1}var b,d,e,g,h,j,k,m,t,x, -z,y=a.geometry,B=y.vertices,I=[];b=0;for(d=y.faces.length;bk?d:k;e=e>m?e:m}a()}; -this.add3Points=function(k,m,t,x,z,y){if(j){j=!1;c=kt?k>z?k:z:t>z?t:z;e=m>x?m>y?m:y:x>y?x:y}else{c=kt?k>z?k>d?k:d:z>d?z:d:t>z?t>d?t:d:z>d?z:d;e=m>x?m>y?m>e?m:e:y>e?y:e:x>y?x>e?x:e:y>e?y:e}a()};this.addRectangle=function(k){if(j){j=!1;c=k.getLeft();b=k.getTop();d=k.getRight();e=k.getBottom()}else{c=ck.getRight()? -d:k.getRight();e=e>k.getBottom()?e:k.getBottom()}a()};this.inflate=function(k){c-=k;b-=k;d+=k;e+=k;a()};this.minSelf=function(k){c=c>k.getLeft()?c:k.getLeft();b=b>k.getTop()?b:k.getTop();d=d=0&&Math.min(e,k.getBottom())-Math.max(b,k.getTop())>=0};this.empty=function(){j=!0;e=d=b=c=0;a()};this.isEmpty=function(){return j}}; +THREE.Ray.prototype={intersectScene:function(a){var c,b,e=a.objects,f=[];a=0;for(c=e.length;a0&&I>0&&R+I<1}var b,e,f,g,h,k,m,n,p,x, +z,y=a.geometry,B=y.vertices,H=[];b=0;for(e=y.faces.length;bm?e:m;f=f>n?f:n}a()}; +this.add3Points=function(m,n,p,x,z,y){if(k){k=!1;c=mp?m>z?m:z:p>z?p:z;f=n>x?n>y?n:y:x>y?x:y}else{c=mp?m>z?m>e?m:e:z>e?z:e:p>z?p>e?p:e:z>e?z:e;f=n>x?n>y?n>f?n:f:y>f?y:f:x>y?x>f?x:f:y>f?y:f}a()};this.addRectangle=function(m){if(k){k=!1;c=m.getLeft();b=m.getTop();e=m.getRight();f=m.getBottom()}else{c=cm.getRight()? +e:m.getRight();f=f>m.getBottom()?f:m.getBottom()}a()};this.inflate=function(m){c-=m;b-=m;e+=m;f+=m;a()};this.minSelf=function(m){c=c>m.getLeft()?c:m.getLeft();b=b>m.getTop()?b:m.getTop();e=e=0&&Math.min(f,m.getBottom())-Math.max(b,m.getTop())>=0};this.empty=function(){k=!0;f=e=b=c=0;a()};this.isEmpty=function(){return k}}; THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}}; -THREE.Matrix4=function(a,c,b,d,e,g,h,j,k,m,t,x,z,y,B,I){this.set(a||1,c||0,b||0,d||0,e||0,g||1,h||0,j||0,k||0,m||0,t||1,x||0,z||0,y||0,B||0,I||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(a,c,b,d,e,g,h,j,k,m,t,x,z,y,B,I){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=j;this.n31=k;this.n32=m;this.n33=t;this.n34=x;this.n41=z;this.n42=y;this.n43=B;this.n44=I;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,c,b){var d=THREE.Matrix4.__v1, -e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,c).normalize();if(g.length()===0)g.z=1;d.cross(b,g).normalize();if(d.length()===0){g.x+=1.0E-4;d.cross(b,g).normalize()}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 c=a.x,b=a.y,d=a.z,e=1/(this.n41*c+this.n42*b+this.n43*d+this.n44);a.x=(this.n11*c+this.n12*b+this.n13*d+this.n14)*e;a.y=(this.n21*c+this.n22*b+this.n23* -d+this.n24)*e;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,e=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*e;a.y=this.n21*c+this.n22*b+this.n23*d+this.n24*e;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*e;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var c=a.x,b=a.y,d=a.z;a.x=c*this.n11+b*this.n12+d*this.n13;a.y=c*this.n21+b*this.n22+d*this.n23;a.z=c*this.n31+b*this.n32+d*this.n33;a.normalize(); -return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,j=a.n22,k=a.n23,m=a.n24,t=a.n31,x=a.n32,z=a.n33,y=a.n34,B=a.n41,I=a.n42,F=a.n43,G=a.n44,L=c.n11,A=c.n12,P=c.n13,R=c.n14,M=c.n21,ia=c.n22, -f=c.n23,ea=c.n24,W=c.n31,da=c.n32,X=c.n33,va=c.n34;this.n11=b*L+d*M+e*W;this.n12=b*A+d*ia+e*da;this.n13=b*P+d*f+e*X;this.n14=b*R+d*ea+e*va+g;this.n21=h*L+j*M+k*W;this.n22=h*A+j*ia+k*da;this.n23=h*P+j*f+k*X;this.n24=h*R+j*ea+k*va+m;this.n31=t*L+x*M+z*W;this.n32=t*A+x*ia+z*da;this.n33=t*P+x*f+z*X;this.n34=t*R+x*ea+z*va+y;this.n41=B*L+I*M+F*W;this.n42=B*A+I*ia+F*da;this.n43=B*P+I*f+F*X;this.n44=B*R+I*ea+F*va+G;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21; -b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this}, -determinant:function(){var a=this.n11,c=this.n12,b=this.n13,d=this.n14,e=this.n21,g=this.n22,h=this.n23,j=this.n24,k=this.n31,m=this.n32,t=this.n33,x=this.n34,z=this.n41,y=this.n42,B=this.n43,I=this.n44;return d*h*m*z-b*j*m*z-d*g*t*z+c*j*t*z+b*g*x*z-c*h*x*z-d*h*k*y+b*j*k*y+d*e*t*y-a*j*t*y-b*e*x*y+a*h*x*y+d*g*k*B-c*j*k*B-d*e*m*B+a*j*m*B+c*e*x*B-a*g*x*B-b*g*k*I+c*h*k*I+b*e*m*I-a*h*m*I-c*e*t*I+a*g*t*I},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13= +THREE.Matrix4=function(a,c,b,e,f,g,h,k,m,n,p,x,z,y,B,H){this.set(a||1,c||0,b||0,e||0,f||0,g||1,h||0,k||0,m||0,n||0,p||1,x||0,z||0,y||0,B||0,H||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(a,c,b,e,f,g,h,k,m,n,p,x,z,y,B,H){this.n11=a;this.n12=c;this.n13=b;this.n14=e;this.n21=f;this.n22=g;this.n23=h;this.n24=k;this.n31=m;this.n32=n;this.n33=p;this.n34=x;this.n41=z;this.n42=y;this.n43=B;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(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,c,b){var e=THREE.Matrix4.__v1, +f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,c).normalize();if(g.length()===0)g.z=1;e.cross(b,g).normalize();if(e.length()===0){g.x+=1.0E-4;e.cross(b,g).normalize()}f.cross(g,e).normalize();this.n11=e.x;this.n12=f.x;this.n13=g.x;this.n21=e.y;this.n22=f.y;this.n23=g.y;this.n31=e.z;this.n32=f.z;this.n33=g.z;return this},multiplyVector3:function(a){var c=a.x,b=a.y,e=a.z,f=1/(this.n41*c+this.n42*b+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*b+this.n13*e+this.n14)*f;a.y=(this.n21*c+this.n22*b+this.n23* +e+this.n24)*f;a.z=(this.n31*c+this.n32*b+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var c=a.x,b=a.y,e=a.z,f=a.w;a.x=this.n11*c+this.n12*b+this.n13*e+this.n14*f;a.y=this.n21*c+this.n22*b+this.n23*e+this.n24*f;a.z=this.n31*c+this.n32*b+this.n33*e+this.n34*f;a.w=this.n41*c+this.n42*b+this.n43*e+this.n44*f;return a},rotateAxis:function(a){var c=a.x,b=a.y,e=a.z;a.x=c*this.n11+b*this.n12+e*this.n13;a.y=c*this.n21+b*this.n22+e*this.n23;a.z=c*this.n31+b*this.n32+e*this.n33;a.normalize(); +return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var b=a.n11,e=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,m=a.n23,n=a.n24,p=a.n31,x=a.n32,z=a.n33,y=a.n34,B=a.n41,H=a.n42,I=a.n43,F=a.n44,M=c.n11,D=c.n12,Q=c.n13,R=c.n14,P=c.n21,ka=c.n22, +$=c.n23,d=c.n24,X=c.n31,da=c.n32,Y=c.n33,ua=c.n34;this.n11=b*M+e*P+f*X;this.n12=b*D+e*ka+f*da;this.n13=b*Q+e*$+f*Y;this.n14=b*R+e*d+f*ua+g;this.n21=h*M+k*P+m*X;this.n22=h*D+k*ka+m*da;this.n23=h*Q+k*$+m*Y;this.n24=h*R+k*d+m*ua+n;this.n31=p*M+x*P+z*X;this.n32=p*D+x*ka+z*da;this.n33=p*Q+x*$+z*Y;this.n34=p*R+x*d+z*ua+y;this.n41=B*M+H*P+I*X;this.n42=B*D+H*ka+I*da;this.n43=B*Q+H*$+I*Y;this.n44=B*R+H*d+I*ua+F;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]= +this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this}, +determinant:function(){var a=this.n11,c=this.n12,b=this.n13,e=this.n14,f=this.n21,g=this.n22,h=this.n23,k=this.n24,m=this.n31,n=this.n32,p=this.n33,x=this.n34,z=this.n41,y=this.n42,B=this.n43,H=this.n44;return e*h*n*z-b*k*n*z-e*g*p*z+c*k*p*z+b*g*x*z-c*h*x*z-e*h*m*y+b*k*m*y+e*f*p*y-a*k*p*y-b*f*x*y+a*h*x*y+e*g*m*B-c*k*m*B-e*f*n*B+a*k*n*B+c*f*x*B-a*g*x*B-b*g*m*H+c*h*m*H+b*f*n*H-a*h*n*H-c*f*p*H+a*g*p*H},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13= a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11; this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13; a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,c){a[c]=this.n11;a[c+1]=this.n21;a[c+2]=this.n31;a[c+3]=this.n41;a[c+4]=this.n12;a[c+5]=this.n22;a[c+6]=this.n32;a[c+7]=this.n42;a[c+8]=this.n13;a[c+9]=this.n23;a[c+10]=this.n33;a[c+11]=this.n43;a[c+12]=this.n14;a[c+13]=this.n24;a[c+14]=this.n34;a[c+15]=this.n44;return a},setTranslation:function(a,c,b){this.set(1,0,0,a,0,1,0,c,0,0,1,b,0,0,0,1);return this}, -setScale:function(a,c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0,0,1);return this},setRotationX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotationY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotationZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,c){var b=Math.cos(c),d=Math.sin(c),e=1-b,g=a.x,h=a.y,j= -a.z,k=e*g,m=e*h;this.set(k*g+b,k*h-d*j,k*j+d*h,0,k*h+d*j,m*h+b,m*j-d*g,0,k*j-d*h,m*j+d*g,e*j*j+b,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var c=a.x,b=a.y,d=a.z;a=Math.cos(c);c=Math.sin(c);var e=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var h=a*b,j=c*b;this.n11=e*g;this.n12=-e*d;this.n13=b;this.n21=j*g+a*d;this.n22=-j*d+a*g;this.n23=-c*e;this.n31=-h*g+c*d;this.n32=h*d+c*g;this.n33=a*e;return this}, -setRotationFromQuaternion:function(a){var c=a.x,b=a.y,d=a.z,e=a.w,g=c+c,h=b+b,j=d+d;a=c*g;var k=c*h;c*=j;var m=b*h;b*=j;d*=j;g*=e;h*=e;e*=j;this.n11=1-(m+d);this.n12=k-e;this.n13=c+h;this.n21=k+e;this.n22=1-(a+d);this.n23=b-g;this.n31=c-h;this.n32=b+g;this.n33=1-(a+m);return this},scale:function(a){var c=a.x,b=a.y;a=a.z;this.n11*=c;this.n12*=b;this.n13*=a;this.n21*=c;this.n22*=b;this.n23*=a;this.n31*=c;this.n32*=b;this.n33*=a;this.n41*=c;this.n42*=b;this.n43*=a;return this},extractPosition:function(a){this.n14= -a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,c){var b=1/c.x,d=1/c.y,e=1/c.z;this.n11=a.n11*b;this.n21=a.n21*b;this.n31=a.n31*b;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}}; -THREE.Matrix4.makeInvert=function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,j=a.n22,k=a.n23,m=a.n24,t=a.n31,x=a.n32,z=a.n33,y=a.n34,B=a.n41,I=a.n42,F=a.n43,G=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=k*y*I-m*z*I+m*x*F-j*y*F-k*x*G+j*z*G;c.n12=g*z*I-e*y*I-g*x*F+d*y*F+e*x*G-d*z*G;c.n13=e*m*I-g*k*I+g*j*F-d*m*F-e*j*G+d*k*G;c.n14=g*k*x-e*m*x-g*j*z+d*m*z+e*j*y-d*k*y;c.n21=m*z*B-k*y*B-m*t*F+h*y*F+k*t*G-h*z*G;c.n22=e*y*B-g*z*B+g*t*F-b*y*F-e*t*G+b*z*G;c.n23=g*k*B-e*m*B-g*h*F+b*m*F+e*h*G-b*k*G; -c.n24=e*m*t-g*k*t+g*h*z-b*m*z-e*h*y+b*k*y;c.n31=j*y*B-m*x*B+m*t*I-h*y*I-j*t*G+h*x*G;c.n32=g*x*B-d*y*B-g*t*I+b*y*I+d*t*G-b*x*G;c.n33=e*m*B-g*j*B+g*h*I-b*m*I-d*h*G+b*j*G;c.n34=g*j*t-d*m*t-g*h*x+b*m*x+d*h*y-b*j*y;c.n41=k*x*B-j*z*B-k*t*I+h*z*I+j*t*F-h*x*F;c.n42=d*z*B-e*x*B+e*t*I-b*z*I-d*t*F+b*x*F;c.n43=e*j*B-d*k*B-e*h*I+b*k*I+d*h*F-b*j*F;c.n44=d*k*t-e*j*t+e*h*x-b*k*x-d*h*z+b*j*z;c.multiplyScalar(1/a.determinant());return c}; -THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,b=c.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,t=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*d;b[1]=a*e;b[2]=a*g;b[3]=a*h;b[4]=a*j;b[5]=a*k;b[6]=a*m;b[7]=a*t;b[8]=a*x;return c}; -THREE.Matrix4.makeFrustum=function(a,c,b,d,e,g){var h;h=new THREE.Matrix4;h.n11=2*e/(c-a);h.n12=0;h.n13=(c+a)/(c-a);h.n14=0;h.n21=0;h.n22=2*e/(d-b);h.n23=(d+b)/(d-b);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+e)/(g-e);h.n34=-2*g*e/(g-e);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,b,d){var e;a=b*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*c,a*c,e,a,b,d)}; -THREE.Matrix4.makeOrtho=function(a,c,b,d,e,g){var h,j,k,m;h=new THREE.Matrix4;j=c-a;k=b-d;m=g-e;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-((c+a)/j);h.n21=0;h.n22=2/k;h.n23=0;h.n24=-((b+d)/k);h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-((g+e)/m);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; +setScale:function(a,c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0,0,1);return this},setRotationX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotationY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotationZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,c){var b=Math.cos(c),e=Math.sin(c),f=1-b,g=a.x,h=a.y,k= +a.z,m=f*g,n=f*h;this.set(m*g+b,m*h-e*k,m*k+e*h,0,m*h+e*k,n*h+b,n*k-e*g,0,m*k-e*h,n*k+e*g,f*k*k+b,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var c=a.x,b=a.y,e=a.z;a=Math.cos(c);c=Math.sin(c);var f=Math.cos(b);b=Math.sin(b);var g=Math.cos(e);e=Math.sin(e);var h=a*b,k=c*b;this.n11=f*g;this.n12=-f*e;this.n13=b;this.n21=k*g+a*e;this.n22=-k*e+a*g;this.n23=-c*f;this.n31=-h*g+c*e;this.n32=h*e+c*g;this.n33=a*f;return this}, +setRotationFromQuaternion:function(a){var c=a.x,b=a.y,e=a.z,f=a.w,g=c+c,h=b+b,k=e+e;a=c*g;var m=c*h;c*=k;var n=b*h;b*=k;e*=k;g*=f;h*=f;f*=k;this.n11=1-(n+e);this.n12=m-f;this.n13=c+h;this.n21=m+f;this.n22=1-(a+e);this.n23=b-g;this.n31=c-h;this.n32=b+g;this.n33=1-(a+n);return this},scale:function(a){var c=a.x,b=a.y;a=a.z;this.n11*=c;this.n12*=b;this.n13*=a;this.n21*=c;this.n22*=b;this.n23*=a;this.n31*=c;this.n32*=b;this.n33*=a;this.n41*=c;this.n42*=b;this.n43*=a;return this},extractPosition:function(a){this.n14= +a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,c){var b=1/c.x,e=1/c.y,f=1/c.z;this.n11=a.n11*b;this.n21=a.n21*b;this.n31=a.n31*b;this.n12=a.n12*e;this.n22=a.n22*e;this.n32=a.n32*e;this.n13=a.n13*f;this.n23=a.n23*f;this.n33=a.n33*f}}; +THREE.Matrix4.makeInvert=function(a,c){var b=a.n11,e=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,m=a.n23,n=a.n24,p=a.n31,x=a.n32,z=a.n33,y=a.n34,B=a.n41,H=a.n42,I=a.n43,F=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=m*y*H-n*z*H+n*x*I-k*y*I-m*x*F+k*z*F;c.n12=g*z*H-f*y*H-g*x*I+e*y*I+f*x*F-e*z*F;c.n13=f*n*H-g*m*H+g*k*I-e*n*I-f*k*F+e*m*F;c.n14=g*m*x-f*n*x-g*k*z+e*n*z+f*k*y-e*m*y;c.n21=n*z*B-m*y*B-n*p*I+h*y*I+m*p*F-h*z*F;c.n22=f*y*B-g*z*B+g*p*I-b*y*I-f*p*F+b*z*F;c.n23=g*m*B-f*n*B-g*h*I+b*n*I+f*h*F-b*m*F; +c.n24=f*n*p-g*m*p+g*h*z-b*n*z-f*h*y+b*m*y;c.n31=k*y*B-n*x*B+n*p*H-h*y*H-k*p*F+h*x*F;c.n32=g*x*B-e*y*B-g*p*H+b*y*H+e*p*F-b*x*F;c.n33=f*n*B-g*k*B+g*h*H-b*n*H-e*h*F+b*k*F;c.n34=g*k*p-e*n*p-g*h*x+b*n*x+e*h*y-b*k*y;c.n41=m*x*B-k*z*B-m*p*H+h*z*H+k*p*I-h*x*I;c.n42=e*z*B-f*x*B+f*p*H-b*z*H-e*p*I+b*x*I;c.n43=f*k*B-e*m*B-f*h*H+b*m*H+e*h*I-b*k*I;c.n44=e*m*p-f*k*p+f*h*x-b*m*x-e*h*z+b*k*z;c.multiplyScalar(1/a.determinant());return c}; +THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,b=c.m,e=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,m=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,p=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*h+a.n31*n;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*e;b[1]=a*f;b[2]=a*g;b[3]=a*h;b[4]=a*k;b[5]=a*m;b[6]=a*n;b[7]=a*p;b[8]=a*x;return c}; +THREE.Matrix4.makeFrustum=function(a,c,b,e,f,g){var h;h=new THREE.Matrix4;h.n11=2*f/(c-a);h.n12=0;h.n13=(c+a)/(c-a);h.n14=0;h.n21=0;h.n22=2*f/(e-b);h.n23=(e+b)/(e-b);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+f)/(g-f);h.n34=-2*g*f/(g-f);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,b,e){var f;a=b*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,b,e)}; +THREE.Matrix4.makeOrtho=function(a,c,b,e,f,g){var h,k,m,n;h=new THREE.Matrix4;k=c-a;m=b-e;n=g-f;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-((c+a)/k);h.n21=0;h.n22=2/m;h.n23=0;h.n24=-((b+e)/m);h.n31=0;h.n32=0;h.n33=-2/n;h.n34=-((g+f)/n);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible= !0;this._vector=new THREE.Vector3}; THREE.Object3D.prototype={translate:function(a,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!== undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var c=this;c instanceof THREE.Scene===!1&&c!==undefined;)c=c.parent;c!==undefined&&c.addChildRecurse(a)}},removeChild:function(a){var c=this.children.indexOf(a);if(c!==-1){a.parent=undefined;this.children.splice(c,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!== -1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}this.matrixWorldNeedsUpdate=!0},update:function(a,c,b){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||c){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;c=!0}a=0;for(var d=this.children.length;a=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(e),h=Math.sqrt(1-e*e);if(Math.abs(h)<0.0010){b.w=0.5*(a.w+c.w);b.x=0.5*(a.x+c.x);b.y=0.5*(a.y+c.y);b.z=0.5*(a.z+c.z);return b}e=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*e+c.w*d;b.x=a.x*e+c.x*d;b.y=a.y*e+c.y*d;b.z=a.z*e+c.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; -THREE.Face3=function(a,c,b,d,e,g){this.a=a;this.b=c;this.c=b;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=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,c,b,d,e,g,h){this.a=a;this.b=c;this.c=b;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=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.set(a||0,c||0)}; +1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}this.matrixWorldNeedsUpdate=!0},update:function(a,c,b){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||c){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;c=!0}a=0;for(var e=this.children.length;a=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(f),h=Math.sqrt(1-f*f);if(Math.abs(h)<0.0010){b.w=0.5*(a.w+c.w);b.x=0.5*(a.x+c.x);b.y=0.5*(a.y+c.y);b.z=0.5*(a.z+c.z);return b}f=Math.sin((1-e)*g)/h;e=Math.sin(e*g)/h;b.w=a.w*f+c.w*e;b.x=a.x*f+c.x*e;b.y=a.y*f+c.y*e;b.z=a.z*f+c.z*e;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; +THREE.Face3=function(a,c,b,e,f,g){this.a=a;this.b=c;this.c=b;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3}; +THREE.Face4=function(a,c,b,e,f,g,h){this.a=a;this.b=c;this.c=b;this.d=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.set(a||0,c||0)}; THREE.UV.prototype={set:function(a,c){this.u=a;this.v=c;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1}; THREE.Geometry.prototype={computeCentroids:function(){var a,c,b;a=0;for(c=this.faces.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,b=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,b=this.vertices.length;cthis.points.length-2?g:g+1;b[3]=g>this.points.length-3?g:g+2;m=this.points[b[0]];t=this.points[b[1]]; -x=this.points[b[2]];z=this.points[b[3]];j=h*h;k=h*j;d.x=c(m.x,t.x,x.x,z.x,h,j,k);d.y=c(m.y,t.y,x.y,z.y,h,j,k);d.z=c(m.z,t.z,x.z,z.z,h,j,k);return d};this.getControlPointsArray=function(){var y,B,I=this.points.length,F=[];for(y=0;ythis.points.length-2?g:g+1;b[3]=g>this.points.length-3?g:g+2;n=this.points[b[0]];p=this.points[b[1]]; +x=this.points[b[2]];z=this.points[b[3]];k=h*h;m=h*k;e.x=c(n.x,p.x,x.x,z.x,h,k,m);e.y=c(n.y,p.y,x.y,z.y,h,k,m);e.z=c(n.z,p.z,x.z,z.z,h,k,m);return e};this.getControlPointsArray=function(){var y,B,H=this.points.length,I=[];for(y=0;y1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+y);d=d<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=e[0]+(g[0]-e[0])*d;b.y=e[1]+(g[1]-e[1])*d;b.z=e[2]+(g[2]-e[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= -this.getPrevKeyWith("pos",y,h.index-1).pos;this.points[1]=e;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",y,j.index+1).pos;d=d*0.33+0.33;e=this.interpolateCatmullRom(this.points,d);b.x=e[0];b.y=e[1];b.z=e[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){d=this.interpolateCatmullRom(this.points,d*1.01);this.target.set(d[0],d[1],d[2]);this.target.subSelf(b);this.target.y=0;this.target.normalize();d=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,d,0)}}}else if(b=== -"rot")THREE.Quaternion.slerp(e,g,a.quaternion,d);else if(b==="scl"){b=a.scale;b.x=e[0]+(g[0]-e[0])*d;b.y=e[1]+(g[1]-e[1])*d;b.z=e[2]+(g[2]-e[2])*d}}}}if(this.JITCompile&&t[0][m]===undefined){this.hierarchy[0].update(undefined,!0);for(y=0;ya.length-2?g:g+1;b[3]=g>a.length-3?g:g+2;g=a[b[0]];j=a[b[1]];k=a[b[2]];m=a[b[3]];b=e*e;h=e*b;d[0]=this.interpolate(g[0],j[0],k[0],m[0],e,b,h);d[1]=this.interpolate(g[1],j[1],k[1],m[1],e,b,h);d[2]=this.interpolate(g[2],j[2],k[2],m[2],e,b,h);return d}; -THREE.Animation.prototype.interpolate=function(a,c,b,d,e,g,h){a=(b-a)*0.5;d=(d-c)*0.5;return(2*(c-b)+a+d)*h+(-3*(c-b)-2*a-d)*g+a*e+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)b=b0?b:0:b>=0?b:b+d.length;b>=0;b--)if(d[b][a]!==undefined)return d[b];return this.data.hierarchy[c].keys[d.length-1]}; -THREE.Camera=function(a,c,b,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=b||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;THREE.Camera.prototype.supr=THREE.Object3D.prototype; +THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,e,f,g,h,k,m,n,p=this.data.JIT.hierarchy,x,z;this.currentTime+=a*this.timeScale;z=this.currentTime;x=this.currentTime%=this.data.length;n=parseInt(Math.min(x*this.data.fps,this.data.length*this.data.fps),10);for(var y=0,B=this.hierarchy.length;y1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+y);e=e<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=f[0]+(g[0]-f[0])*e;b.y=f[1]+(g[1]-f[1])*e;b.z=f[2]+(g[2]-f[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= +this.getPrevKeyWith("pos",y,h.index-1).pos;this.points[1]=f;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",y,k.index+1).pos;e=e*0.33+0.33;f=this.interpolateCatmullRom(this.points,e);b.x=f[0];b.y=f[1];b.z=f[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){e=this.interpolateCatmullRom(this.points,e*1.01);this.target.set(e[0],e[1],e[2]);this.target.subSelf(b);this.target.y=0;this.target.normalize();e=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,e,0)}}}else if(b=== +"rot")THREE.Quaternion.slerp(f,g,a.quaternion,e);else if(b==="scl"){b=a.scale;b.x=f[0]+(g[0]-f[0])*e;b.y=f[1]+(g[1]-f[1])*e;b.z=f[2]+(g[2]-f[2])*e}}}}if(this.JITCompile&&p[0][n]===undefined){this.hierarchy[0].update(undefined,!0);for(y=0;ya.length-2?g:g+1;b[3]=g>a.length-3?g:g+2;g=a[b[0]];k=a[b[1]];m=a[b[2]];n=a[b[3]];b=f*f;h=f*b;e[0]=this.interpolate(g[0],k[0],m[0],n[0],f,b,h);e[1]=this.interpolate(g[1],k[1],m[1],n[1],f,b,h);e[2]=this.interpolate(g[2],k[2],m[2],n[2],f,b,h);return e}; +THREE.Animation.prototype.interpolate=function(a,c,b,e,f,g,h){a=(b-a)*0.5;e=(e-c)*0.5;return(2*(c-b)+a+e)*h+(-3*(c-b)-2*a-e)*g+a*f+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var e=this.data.hierarchy[c].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)b=b0?b:0:b>=0?b:b+e.length;b>=0;b--)if(e[b][a]!==undefined)return e[b];return this.data.hierarchy[c].keys[e.length-1]}; +THREE.Camera=function(a,c,b,e,f){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=b||0.1;this.far=e||2E3;this.target=f||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype; THREE.Camera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)}; THREE.Camera.prototype.update=function(a,c,b){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);c=!0}else{this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate= !1;c=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a1){a=b.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var d=1;d=this.LODs[d].visibleAtDistance){this.LODs[d-1].object3D.visible= -!1;this.LODs[d].object3D.visible=!0}else break;for(;d1){a=b.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var e=1;e=this.LODs[e].visibleAtDistance){this.LODs[e-1].object3D.visible= +!1;this.LODs[e].object3D.visible=!0}else break;for(;e=0&&ja>=0&&U>=0&&fa>=0)return!0;else if(Ca<0&&ja<0||U<0&&fa<0)return!1;else{if(Ca<0)va=Math.max(va,Ca/(Ca-ja));else ja<0&&(wa=Math.min(wa,Ca/(Ca-ja)));if(U<0)va=Math.max(va,U/(U-fa));else fa<0&&(wa=Math.min(wa,U/(U-fa)));if(waCa&&h.positionScreen.z0&&R.z<1){Ma=A[L]=A[L]||new THREE.RenderableParticle;L++;G=Ma;G.x=R.x/R.w;G.y=R.y/R.w;G.z=R.z;G.rotation=za.rotation.z;G.scale.x=za.scale.x*Math.abs(G.x-(R.x+X.projectionMatrix.n11)/(R.w+X.projectionMatrix.n14));G.scale.y=za.scale.y*Math.abs(G.y-(R.y+X.projectionMatrix.n22)/(R.w+X.projectionMatrix.n24));G.materials=za.materials;wa.push(G)}}}}va&&wa.sort(c);return wa}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,e,g;this.domElement=document.createElement("div");this.setSize=function(h,j){b=h;d=j;e=b/2;g=d/2};this.render=function(h,j){var k,m,t,x,z,y,B,I;a=c.projectScene(h,j);k=0;for(m=a.length;k0){ha.r+=pa.r*qa;ha.g+=pa.g*qa;ha.b+=pa.b*qa}}else if(qa instanceof THREE.PointLight){ca.sub(qa.position,$);ca.normalize();qa=V.dot(ca)*T;if(qa>0){ha.r+= -pa.r*qa;ha.g+=pa.g*qa;ha.b+=pa.b*qa}}}}function ka(J,$,V){a(V.opacity);c(V.blending);var ha,Aa,qa,pa,T,La;if(V instanceof THREE.ParticleBasicMaterial){if(V.map){pa=V.map.image;T=pa.width>>1;La=pa.height>>1;V=$.scale.x*j;qa=$.scale.y*k;ha=V*T;Aa=qa*La;H.set(J.x-ha,J.y-Aa,J.x+ha,J.y+Aa);if(E.instersects(H)){m.save();m.translate(J.x,J.y);m.rotate(-$.rotation);m.scale(V,-qa);m.translate(-T,-La);m.drawImage(pa,0,0);m.restore()}}}else if(V instanceof THREE.ParticleCanvasMaterial){if(aa){Q.r=K.r+ra.r+Fa.r; -Q.g=K.g+ra.g+Fa.g;Q.b=K.b+ra.b+Fa.b;Y.r=V.color.r*Q.r;Y.g=V.color.g*Q.g;Y.b=V.color.b*Q.b;Y.updateStyleString()}else Y.__styleString=V.color.__styleString;ha=$.scale.x*j;Aa=$.scale.y*k;H.set(J.x-ha,J.y-Aa,J.x+ha,J.y+Aa);if(E.instersects(H)){m.save();m.translate(J.x,J.y);m.rotate(-$.rotation);m.scale(ha,Aa);V.program(m,Y);m.restore()}}}function la(J,$,V,ha){a(ha.opacity);c(ha.blending);m.beginPath();m.moveTo(J.positionScreen.x,J.positionScreen.y);m.lineTo($.positionScreen.x,$.positionScreen.y);m.closePath(); -if(ha instanceof THREE.LineBasicMaterial){Y.__styleString=ha.color.__styleString;J=ha.linewidth;if(F!=J)m.lineWidth=F=J;J=Y.__styleString;if(B!=J)m.strokeStyle=B=J;m.stroke();H.inflate(ha.linewidth*2)}}function oa(J,$,V,ha,Aa,qa,pa,T,La){a(T.opacity);c(T.blending);ia=J.positionScreen.x;f=J.positionScreen.y;ea=$.positionScreen.x;W=$.positionScreen.y;da=V.positionScreen.x;X=V.positionScreen.y;Ta(ia,f,ea,W,da,X);if(T instanceof THREE.MeshBasicMaterial)if(T.map){if(T.map.mapping instanceof THREE.UVMapping){Ma= -pa.uvs[0];Ua(ia,f,ea,W,da,X,T.map.image,Ma[ha].u,Ma[ha].v,Ma[Aa].u,Ma[Aa].v,Ma[qa].u,Ma[qa].v)}}else if(T.envMap){if(T.envMap.mapping instanceof THREE.SphericalReflectionMapping){J=Da.matrixWorldInverse;ca.copy(pa.vertexNormalsWorld[0]);bb=(ca.x*J.n11+ca.y*J.n12+ca.z*J.n13)*0.5+0.5;n=-(ca.x*J.n21+ca.y*J.n22+ca.z*J.n23)*0.5+0.5;ca.copy(pa.vertexNormalsWorld[1]);D=(ca.x*J.n11+ca.y*J.n12+ca.z*J.n13)*0.5+0.5;p=-(ca.x*J.n21+ca.y*J.n22+ca.z*J.n23)*0.5+0.5;ca.copy(pa.vertexNormalsWorld[2]);o=(ca.x*J.n11+ -ca.y*J.n12+ca.z*J.n13)*0.5+0.5;w=-(ca.x*J.n21+ca.y*J.n22+ca.z*J.n23)*0.5+0.5;Ua(ia,f,ea,W,da,X,T.envMap.image,bb,n,D,p,o,w)}}else T.wireframe?Oa(T.color.__styleString,T.wireframeLinewidth):Ya(T.color.__styleString);else if(T instanceof THREE.MeshLambertMaterial){if(T.map&&!T.wireframe){if(T.map.mapping instanceof THREE.UVMapping){Ma=pa.uvs[0];Ua(ia,f,ea,W,da,X,T.map.image,Ma[ha].u,Ma[ha].v,Ma[Aa].u,Ma[Aa].v,Ma[qa].u,Ma[qa].v)}c(THREE.SubtractiveBlending)}if(aa)if(!T.wireframe&&T.shading==THREE.SmoothShading&& -pa.vertexNormalsWorld.length==3){S.r=O.r=ga.r=K.r;S.g=O.g=ga.g=K.g;S.b=O.b=ga.b=K.b;ua(La,pa.v1.positionWorld,pa.vertexNormalsWorld[0],S);ua(La,pa.v2.positionWorld,pa.vertexNormalsWorld[1],O);ua(La,pa.v3.positionWorld,pa.vertexNormalsWorld[2],ga);sa.r=(O.r+ga.r)*0.5;sa.g=(O.g+ga.g)*0.5;sa.b=(O.b+ga.b)*0.5;za=Ka(S,O,ga,sa);Ua(ia,f,ea,W,da,X,za,0,0,1,0,0,1)}else{Q.r=K.r;Q.g=K.g;Q.b=K.b;ua(La,pa.centroidWorld,pa.normalWorld,Q);Y.r=T.color.r*Q.r;Y.g=T.color.g*Q.g;Y.b=T.color.b*Q.b;Y.updateStyleString(); -T.wireframe?Oa(Y.__styleString,T.wireframeLinewidth):Ya(Y.__styleString)}else T.wireframe?Oa(T.color.__styleString,T.wireframeLinewidth):Ya(T.color.__styleString)}else if(T instanceof THREE.MeshDepthMaterial){ma=Da.near;ta=Da.far;S.r=S.g=S.b=1-Wa(J.positionScreen.z,ma,ta);O.r=O.g=O.b=1-Wa($.positionScreen.z,ma,ta);ga.r=ga.g=ga.b=1-Wa(V.positionScreen.z,ma,ta);sa.r=(O.r+ga.r)*0.5;sa.g=(O.g+ga.g)*0.5;sa.b=(O.b+ga.b)*0.5;za=Ka(S,O,ga,sa);Ua(ia,f,ea,W,da,X,za,0,0,1,0,0,1)}else if(T instanceof THREE.MeshNormalMaterial){Y.r= -Pa(pa.normalWorld.x);Y.g=Pa(pa.normalWorld.y);Y.b=Pa(pa.normalWorld.z);Y.updateStyleString();T.wireframe?Oa(Y.__styleString,T.wireframeLinewidth):Ya(Y.__styleString)}}function Qa(J,$,V,ha,Aa,qa,pa,T,La){a(T.opacity);c(T.blending);if(T.map||T.envMap){oa(J,$,ha,0,1,3,pa,T,La);oa(Aa,V,qa,1,2,3,pa,T,La)}else{ia=J.positionScreen.x;f=J.positionScreen.y;ea=$.positionScreen.x;W=$.positionScreen.y;da=V.positionScreen.x;X=V.positionScreen.y;va=ha.positionScreen.x;wa=ha.positionScreen.y;Ca=Aa.positionScreen.x; -ja=Aa.positionScreen.y;U=qa.positionScreen.x;fa=qa.positionScreen.y;if(T instanceof THREE.MeshBasicMaterial){gb(ia,f,ea,W,da,X,va,wa);T.wireframe?Oa(T.color.__styleString,T.wireframeLinewidth):Ya(T.color.__styleString)}else if(T instanceof THREE.MeshLambertMaterial)if(aa)if(!T.wireframe&&T.shading==THREE.SmoothShading&&pa.vertexNormalsWorld.length==4){S.r=O.r=ga.r=sa.r=K.r;S.g=O.g=ga.g=sa.g=K.g;S.b=O.b=ga.b=sa.b=K.b;ua(La,pa.v1.positionWorld,pa.vertexNormalsWorld[0],S);ua(La,pa.v2.positionWorld,pa.vertexNormalsWorld[1], -O);ua(La,pa.v4.positionWorld,pa.vertexNormalsWorld[3],ga);ua(La,pa.v3.positionWorld,pa.vertexNormalsWorld[2],sa);za=Ka(S,O,ga,sa);Ta(ia,f,ea,W,va,wa);Ua(ia,f,ea,W,va,wa,za,0,0,1,0,0,1);Ta(Ca,ja,da,X,U,fa);Ua(Ca,ja,da,X,U,fa,za,1,0,1,1,0,1)}else{Q.r=K.r;Q.g=K.g;Q.b=K.b;ua(La,pa.centroidWorld,pa.normalWorld,Q);Y.r=T.color.r*Q.r;Y.g=T.color.g*Q.g;Y.b=T.color.b*Q.b;Y.updateStyleString();gb(ia,f,ea,W,da,X,va,wa);T.wireframe?Oa(Y.__styleString,T.wireframeLinewidth):Ya(Y.__styleString)}else{gb(ia,f,ea,W, -da,X,va,wa);T.wireframe?Oa(T.color.__styleString,T.wireframeLinewidth):Ya(T.color.__styleString)}else if(T instanceof THREE.MeshNormalMaterial){Y.r=Pa(pa.normalWorld.x);Y.g=Pa(pa.normalWorld.y);Y.b=Pa(pa.normalWorld.z);Y.updateStyleString();gb(ia,f,ea,W,da,X,va,wa);T.wireframe?Oa(Y.__styleString,T.wireframeLinewidth):Ya(Y.__styleString)}else if(T instanceof THREE.MeshDepthMaterial){ma=Da.near;ta=Da.far;S.r=S.g=S.b=1-Wa(J.positionScreen.z,ma,ta);O.r=O.g=O.b=1-Wa($.positionScreen.z,ma,ta);ga.r=ga.g= -ga.b=1-Wa(ha.positionScreen.z,ma,ta);sa.r=sa.g=sa.b=1-Wa(V.positionScreen.z,ma,ta);za=Ka(S,O,ga,sa);Ta(ia,f,ea,W,va,wa);Ua(ia,f,ea,W,va,wa,za,0,0,1,0,0,1);Ta(Ca,ja,da,X,U,fa);Ua(Ca,ja,da,X,U,fa,za,1,0,1,1,0,1)}}}function Ta(J,$,V,ha,Aa,qa){m.beginPath();m.moveTo(J,$);m.lineTo(V,ha);m.lineTo(Aa,qa);m.lineTo(J,$);m.closePath()}function gb(J,$,V,ha,Aa,qa,pa,T){m.beginPath();m.moveTo(J,$);m.lineTo(V,ha);m.lineTo(Aa,qa);m.lineTo(pa,T);m.lineTo(J,$);m.closePath()}function Oa(J,$){if(B!=J)m.strokeStyle= -B=J;if(F!=$)m.lineWidth=F=$;m.stroke();H.inflate($*2)}function Ya(J){if(I!=J)m.fillStyle=I=J;m.fill()}function Ua(J,$,V,ha,Aa,qa,pa,T,La,db,$a,eb,ib){var cb,fb;cb=pa.width-1;fb=pa.height-1;T*=cb;La*=fb;db*=cb;$a*=fb;eb*=cb;ib*=fb;V-=J;ha-=$;Aa-=J;qa-=$;db-=T;$a-=La;eb-=T;ib-=La;cb=db*ib-eb*$a;if(cb!=0){fb=1/cb;cb=(ib*V-$a*Aa)*fb;$a=(ib*ha-$a*qa)*fb;V=(db*Aa-eb*V)*fb;ha=(db*qa-eb*ha)*fb;J=J-cb*T-V*La;$=$-$a*T-ha*La;m.save();m.transform(cb,$a,V,ha,J,$);m.clip();m.drawImage(pa,0,0);m.restore()}}function Ka(J, -$,V,ha){var Aa=~~(J.r*255),qa=~~(J.g*255);J=~~(J.b*255);var pa=~~($.r*255),T=~~($.g*255);$=~~($.b*255);var La=~~(V.r*255),db=~~(V.g*255);V=~~(V.b*255);var $a=~~(ha.r*255),eb=~~(ha.g*255);ha=~~(ha.b*255);Na[0]=Aa<0?0:Aa>255?255:Aa;Na[1]=qa<0?0:qa>255?255:qa;Na[2]=J<0?0:J>255?255:J;Na[4]=pa<0?0:pa>255?255:pa;Na[5]=T<0?0:T>255?255:T;Na[6]=$<0?0:$>255?255:$;Na[8]=La<0?0:La>255?255:La;Na[9]=db<0?0:db>255?255:db;Na[10]=V<0?0:V>255?255:V;Na[12]=$a<0?0:$a>255?255:$a;Na[13]=eb<0?0:eb>255?255:eb;Na[14]=ha< -0?0:ha>255?255:ha;na.putImageData(Ha,0,0);Ja.drawImage(Ba,0,0);return ya}function Wa(J,$,V){J=(J-$)/(V-$);return J*J*(3-2*J)}function Pa(J){J=(J+1)*0.5;return J<0?0:J>1?1:J}function N(J,$){var V=$.x-J.x,ha=$.y-J.y,Aa=1/Math.sqrt(V*V+ha*ha);V*=Aa;ha*=Aa;$.x+=V;$.y+=ha;J.x-=V;J.y-=ha}var Ra,Va,Ga,ab,Xa,Ia,Sa,xa;this.autoClear?this.clear():m.setTransform(1,0,0,-1,j,k);b=d.projectScene(Ea,Da,this.sortElements);(aa=Ea.lights.length>0)&&Za(Ea);Ra=0;for(Va=b.length;Ra0){fa.r+=O.color.r*ga;fa.g+=O.color.g*ga;fa.b+=O.color.b*ga}}else if(O instanceof THREE.PointLight){ea.sub(O.position,U.centroidWorld);ea.normalize();ga=U.normalWorld.dot(ea)*O.intensity;if(ga>0){fa.r+=O.color.r*ga;fa.g+=O.color.g*ga;fa.b+=O.color.b*ga}}}}function c(ja,U,fa,Y,S,O){X=d(va++);X.setAttribute("d", -"M "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+fa.positionScreen.x+","+fa.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)A.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(L){P.r=R.r;P.g=R.g;P.b=R.b;a(O,Y,P);A.r=S.color.r*P.r;A.g=S.color.g*P.g;A.b=S.color.b*P.b;A.updateStyleString()}else A.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){f=1-S.__2near/(S.__farPlusNear- -Y.z*S.__farMinusNear);A.setRGB(f,f,f)}else S instanceof THREE.MeshNormalMaterial&&A.setRGB(e(Y.normalWorld.x),e(Y.normalWorld.y),e(Y.normalWorld.z));S.wireframe?X.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+S.wireframeLinewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframeLinecap+"; stroke-linejoin: "+S.wireframeLinejoin):X.setAttribute("style","fill: "+A.__styleString+"; fill-opacity: "+S.opacity);j.appendChild(X)}function b(ja,U,fa,Y,S,O,ga){X= -d(va++);X.setAttribute("d","M "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+fa.positionScreen.x+","+fa.positionScreen.y+" L "+Y.positionScreen.x+","+Y.positionScreen.y+"z");if(O instanceof THREE.MeshBasicMaterial)A.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshLambertMaterial)if(L){P.r=R.r;P.g=R.g;P.b=R.b;a(ga,S,P);A.r=O.color.r*P.r;A.g=O.color.g*P.g;A.b=O.color.b*P.b;A.updateStyleString()}else A.__styleString=O.color.__styleString; -else if(O instanceof THREE.MeshDepthMaterial){f=1-O.__2near/(O.__farPlusNear-S.z*O.__farMinusNear);A.setRGB(f,f,f)}else O instanceof THREE.MeshNormalMaterial&&A.setRGB(e(S.normalWorld.x),e(S.normalWorld.y),e(S.normalWorld.z));O.wireframe?X.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+O.wireframeLinewidth+"; stroke-opacity: "+O.opacity+"; stroke-linecap: "+O.wireframeLinecap+"; stroke-linejoin: "+O.wireframeLinejoin):X.setAttribute("style","fill: "+A.__styleString+ -"; fill-opacity: "+O.opacity);j.appendChild(X)}function d(ja){if(W[ja]==null){W[ja]=document.createElementNS("http://www.w3.org/2000/svg","path");Ca==0&&W[ja].setAttribute("shape-rendering","crispEdges")}return W[ja]}function e(ja){return ja<0?Math.min((1+ja)*0.5,0.5):0.5+Math.min(ja*0.5,0.5)}var g=null,h=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,m,t,x,z,y,B,I,F=new THREE.Rectangle,G=new THREE.Rectangle,L=!1,A=new THREE.Color(16777215),P=new THREE.Color(16777215), -R=new THREE.Color(0),M=new THREE.Color(0),ia=new THREE.Color(0),f,ea=new THREE.Vector3,W=[],da=[],X,va,wa,Ca=1;this.domElement=j;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ja){switch(ja){case "high":Ca=1;break;case "low":Ca=0}};this.setSize=function(ja,U){k=ja;m=U;t=k/2;x=m/2;j.setAttribute("viewBox",-t+" "+-x+" "+k+" "+m);j.setAttribute("width",k);j.setAttribute("height",m);F.set(-t,-x,t,x)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])}; -this.render=function(ja,U){var fa,Y,S,O,ga,sa,ma,ta;this.autoClear&&this.clear();g=h.projectScene(ja,U,this.sortElements);wa=va=0;if(L=ja.lights.length>0){ma=ja.lights;R.setRGB(0,0,0);M.setRGB(0,0,0);ia.setRGB(0,0,0);fa=0;for(Y=ma.length;fa=0&&ma>=0&&W>=0&&ia>=0)return!0;else if(za<0&&ma<0||W<0&&ia<0)return!1;else{if(za<0)ua=Math.max(ua,za/(za-ma));else ma<0&&(va=Math.min(va,za/(za-ma)));if(W<0)ua=Math.max(ua,W/(W-ia));else ia<0&&(va=Math.min(va,W/(W-ia)));if(vaza&&h.positionScreen.z0&&R.z<1){Da=D[M]=D[M]||new THREE.RenderableParticle;M++;F=Da;F.x=R.x/R.w;F.y=R.y/R.w;F.z=R.z;F.rotation=xa.rotation.z;F.scale.x=xa.scale.x*Math.abs(F.x-(R.x+Y.projectionMatrix.n11)/(R.w+Y.projectionMatrix.n14));F.scale.y=xa.scale.y*Math.abs(F.y-(R.y+Y.projectionMatrix.n22)/(R.w+Y.projectionMatrix.n24));F.materials=xa.materials;va.push(F)}}}}ua&&va.sort(c);return va}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,e,f,g;this.domElement=document.createElement("div");this.setSize=function(h,k){b=h;e=k;f=b/2;g=e/2};this.render=function(h,k){var m,n,p,x,z,y,B,H;a=c.projectScene(h,k);m=0;for(n=a.length;m0){ea.r+=ga.r*Aa;ea.g+=ga.g*Aa;ea.b+=ga.b*Aa}}else if(Aa instanceof THREE.PointLight){T.sub(Aa.position,aa);T.normalize();Aa=oa.dot(T)*ca;if(Aa> +0){ea.r+=ga.r*Aa;ea.g+=ga.g*Aa;ea.b+=ga.b*Aa}}}}function fb(L,aa,oa){a(oa.opacity);c(oa.blending);var ea,ta,Aa,ga,ca,La;if(oa instanceof THREE.ParticleBasicMaterial){if(oa.map){ga=oa.map.image;ca=ga.width>>1;La=ga.height>>1;oa=aa.scale.x*k;Aa=aa.scale.y*m;ea=oa*ca;ta=Aa*La;G.set(L.x-ea,L.y-ta,L.x+ea,L.y+ta);if(o.instersects(G)){n.save();n.translate(L.x,L.y);n.rotate(-aa.rotation);n.scale(oa,-Aa);n.translate(-ca,-La);n.drawImage(ga,0,0);n.restore()}}}else if(oa instanceof THREE.ParticleCanvasMaterial){if(J){E.r= +A.r+V.r+K.r;E.g=A.g+V.g+K.g;E.b=A.b+V.b+K.b;Z.r=oa.color.r*E.r;Z.g=oa.color.g*E.g;Z.b=oa.color.b*E.b;Z.updateStyleString()}else Z.__styleString=oa.color.__styleString;ea=aa.scale.x*k;ta=aa.scale.y*m;G.set(L.x-ea,L.y-ta,L.x+ea,L.y+ta);if(o.instersects(G)){n.save();n.translate(L.x,L.y);n.rotate(-aa.rotation);n.scale(ea,ta);oa.program(n,Z);n.restore()}}}function Ua(L,aa,oa,ea){a(ea.opacity);c(ea.blending);n.beginPath();n.moveTo(L.positionScreen.x,L.positionScreen.y);n.lineTo(aa.positionScreen.x,aa.positionScreen.y); +n.closePath();if(ea instanceof THREE.LineBasicMaterial){Z.__styleString=ea.color.__styleString;L=ea.linewidth;if(I!=L)n.lineWidth=I=L;L=Z.__styleString;if(B!=L)n.strokeStyle=B=L;n.stroke();G.inflate(ea.linewidth*2)}}function Ja(L,aa,oa,ea,ta,Aa,ga,ca,La){a(ca.opacity);c(ca.blending);ka=L.positionScreen.x;$=L.positionScreen.y;d=aa.positionScreen.x;X=aa.positionScreen.y;da=oa.positionScreen.x;Y=oa.positionScreen.y;cb(ka,$,d,X,da,Y);if(ca instanceof THREE.MeshBasicMaterial)if(ca.map){if(ca.map.mapping instanceof +THREE.UVMapping){Da=ga.uvs[0];Ea(ka,$,d,X,da,Y,ca.map.image,Da[ea].u,Da[ea].v,Da[ta].u,Da[ta].v,Da[Aa].u,Da[Aa].v)}}else if(ca.envMap){if(ca.envMap.mapping instanceof THREE.SphericalReflectionMapping){L=la.matrixWorldInverse;T.copy(ga.vertexNormalsWorld[0]);$a=(T.x*L.n11+T.y*L.n12+T.z*L.n13)*0.5+0.5;ab=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;T.copy(ga.vertexNormalsWorld[1]);Ia=(T.x*L.n11+T.y*L.n12+T.z*L.n13)*0.5+0.5;j=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;T.copy(ga.vertexNormalsWorld[2]);t=(T.x* +L.n11+T.y*L.n12+T.z*L.n13)*0.5+0.5;w=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;Ea(ka,$,d,X,da,Y,ca.envMap.image,$a,ab,Ia,j,t,w)}}else ca.wireframe?Qa(ca.color.__styleString,ca.wireframeLinewidth):Va(ca.color.__styleString);else if(ca instanceof THREE.MeshLambertMaterial){if(ca.map&&!ca.wireframe){if(ca.map.mapping instanceof THREE.UVMapping){Da=ga.uvs[0];Ea(ka,$,d,X,da,Y,ca.map.image,Da[ea].u,Da[ea].v,Da[ta].u,Da[ta].v,Da[Aa].u,Da[Aa].v)}c(THREE.SubtractiveBlending)}if(J)if(!ca.wireframe&&ca.shading== +THREE.SmoothShading&&ga.vertexNormalsWorld.length==3){S.r=N.r=ha.r=A.r;S.g=N.g=ha.g=A.g;S.b=N.b=ha.b=A.b;Ha(La,ga.v1.positionWorld,ga.vertexNormalsWorld[0],S);Ha(La,ga.v2.positionWorld,ga.vertexNormalsWorld[1],N);Ha(La,ga.v3.positionWorld,ga.vertexNormalsWorld[2],ha);ra.r=(N.r+ha.r)*0.5;ra.g=(N.g+ha.g)*0.5;ra.b=(N.b+ha.b)*0.5;xa=Wa(S,N,ha,ra);Ea(ka,$,d,X,da,Y,xa,0,0,1,0,0,1)}else{E.r=A.r;E.g=A.g;E.b=A.b;Ha(La,ga.centroidWorld,ga.normalWorld,E);Z.r=ca.color.r*E.r;Z.g=ca.color.g*E.g;Z.b=ca.color.b* +E.b;Z.updateStyleString();ca.wireframe?Qa(Z.__styleString,ca.wireframeLinewidth):Va(Z.__styleString)}else ca.wireframe?Qa(ca.color.__styleString,ca.wireframeLinewidth):Va(ca.color.__styleString)}else if(ca instanceof THREE.MeshDepthMaterial){na=la.near;qa=la.far;S.r=S.g=S.b=1-Na(L.positionScreen.z,na,qa);N.r=N.g=N.b=1-Na(aa.positionScreen.z,na,qa);ha.r=ha.g=ha.b=1-Na(oa.positionScreen.z,na,qa);ra.r=(N.r+ha.r)*0.5;ra.g=(N.g+ha.g)*0.5;ra.b=(N.b+ha.b)*0.5;xa=Wa(S,N,ha,ra);Ea(ka,$,d,X,da,Y,xa,0,0,1,0, +0,1)}else if(ca instanceof THREE.MeshNormalMaterial){Z.r=O(ga.normalWorld.x);Z.g=O(ga.normalWorld.y);Z.b=O(ga.normalWorld.z);Z.updateStyleString();ca.wireframe?Qa(Z.__styleString,ca.wireframeLinewidth):Va(Z.__styleString)}}function Sa(L,aa,oa,ea,ta,Aa,ga,ca,La){a(ca.opacity);c(ca.blending);if(ca.map||ca.envMap){Ja(L,aa,ea,0,1,3,ga,ca,La);Ja(ta,oa,Aa,1,2,3,ga,ca,La)}else{ka=L.positionScreen.x;$=L.positionScreen.y;d=aa.positionScreen.x;X=aa.positionScreen.y;da=oa.positionScreen.x;Y=oa.positionScreen.y; +ua=ea.positionScreen.x;va=ea.positionScreen.y;za=ta.positionScreen.x;ma=ta.positionScreen.y;W=Aa.positionScreen.x;ia=Aa.positionScreen.y;if(ca instanceof THREE.MeshBasicMaterial){eb(ka,$,d,X,da,Y,ua,va);ca.wireframe?Qa(ca.color.__styleString,ca.wireframeLinewidth):Va(ca.color.__styleString)}else if(ca instanceof THREE.MeshLambertMaterial)if(J)if(!ca.wireframe&&ca.shading==THREE.SmoothShading&&ga.vertexNormalsWorld.length==4){S.r=N.r=ha.r=ra.r=A.r;S.g=N.g=ha.g=ra.g=A.g;S.b=N.b=ha.b=ra.b=A.b;Ha(La, +ga.v1.positionWorld,ga.vertexNormalsWorld[0],S);Ha(La,ga.v2.positionWorld,ga.vertexNormalsWorld[1],N);Ha(La,ga.v4.positionWorld,ga.vertexNormalsWorld[3],ha);Ha(La,ga.v3.positionWorld,ga.vertexNormalsWorld[2],ra);xa=Wa(S,N,ha,ra);cb(ka,$,d,X,ua,va);Ea(ka,$,d,X,ua,va,xa,0,0,1,0,0,1);cb(za,ma,da,Y,W,ia);Ea(za,ma,da,Y,W,ia,xa,1,0,1,1,0,1)}else{E.r=A.r;E.g=A.g;E.b=A.b;Ha(La,ga.centroidWorld,ga.normalWorld,E);Z.r=ca.color.r*E.r;Z.g=ca.color.g*E.g;Z.b=ca.color.b*E.b;Z.updateStyleString();eb(ka,$,d,X,da, +Y,ua,va);ca.wireframe?Qa(Z.__styleString,ca.wireframeLinewidth):Va(Z.__styleString)}else{eb(ka,$,d,X,da,Y,ua,va);ca.wireframe?Qa(ca.color.__styleString,ca.wireframeLinewidth):Va(ca.color.__styleString)}else if(ca instanceof THREE.MeshNormalMaterial){Z.r=O(ga.normalWorld.x);Z.g=O(ga.normalWorld.y);Z.b=O(ga.normalWorld.z);Z.updateStyleString();eb(ka,$,d,X,da,Y,ua,va);ca.wireframe?Qa(Z.__styleString,ca.wireframeLinewidth):Va(Z.__styleString)}else if(ca instanceof THREE.MeshDepthMaterial){na=la.near; +qa=la.far;S.r=S.g=S.b=1-Na(L.positionScreen.z,na,qa);N.r=N.g=N.b=1-Na(aa.positionScreen.z,na,qa);ha.r=ha.g=ha.b=1-Na(ea.positionScreen.z,na,qa);ra.r=ra.g=ra.b=1-Na(oa.positionScreen.z,na,qa);xa=Wa(S,N,ha,ra);cb(ka,$,d,X,ua,va);Ea(ka,$,d,X,ua,va,xa,0,0,1,0,0,1);cb(za,ma,da,Y,W,ia);Ea(za,ma,da,Y,W,ia,xa,1,0,1,1,0,1)}}}function cb(L,aa,oa,ea,ta,Aa){n.beginPath();n.moveTo(L,aa);n.lineTo(oa,ea);n.lineTo(ta,Aa);n.lineTo(L,aa);n.closePath()}function eb(L,aa,oa,ea,ta,Aa,ga,ca){n.beginPath();n.moveTo(L,aa); +n.lineTo(oa,ea);n.lineTo(ta,Aa);n.lineTo(ga,ca);n.lineTo(L,aa);n.closePath()}function Qa(L,aa){if(B!=L)n.strokeStyle=B=L;if(I!=aa)n.lineWidth=I=aa;n.stroke();G.inflate(aa*2)}function Va(L){if(H!=L)n.fillStyle=H=L;n.fill()}function Ea(L,aa,oa,ea,ta,Aa,ga,ca,La,Ya,Za,db,hb){var bb,Xa;bb=ga.width-1;Xa=ga.height-1;ca*=bb;La*=Xa;Ya*=bb;Za*=Xa;db*=bb;hb*=Xa;oa-=L;ea-=aa;ta-=L;Aa-=aa;Ya-=ca;Za-=La;db-=ca;hb-=La;bb=Ya*hb-db*Za;if(bb!=0){Xa=1/bb;bb=(hb*oa-Za*ta)*Xa;Za=(hb*ea-Za*Aa)*Xa;oa=(Ya*ta-db*oa)*Xa; +ea=(Ya*Aa-db*ea)*Xa;L=L-bb*ca-oa*La;aa=aa-Za*ca-ea*La;n.save();n.transform(bb,Za,oa,ea,L,aa);n.clip();n.drawImage(ga,0,0);n.restore()}}function Wa(L,aa,oa,ea){var ta=~~(L.r*255),Aa=~~(L.g*255);L=~~(L.b*255);var ga=~~(aa.r*255),ca=~~(aa.g*255);aa=~~(aa.b*255);var La=~~(oa.r*255),Ya=~~(oa.g*255);oa=~~(oa.b*255);var Za=~~(ea.r*255),db=~~(ea.g*255);ea=~~(ea.b*255);Ba[0]=ta<0?0:ta>255?255:ta;Ba[1]=Aa<0?0:Aa>255?255:Aa;Ba[2]=L<0?0:L>255?255:L;Ba[4]=ga<0?0:ga>255?255:ga;Ba[5]=ca<0?0:ca>255?255:ca;Ba[6]= +aa<0?0:aa>255?255:aa;Ba[8]=La<0?0:La>255?255:La;Ba[9]=Ya<0?0:Ya>255?255:Ya;Ba[10]=oa<0?0:oa>255?255:oa;Ba[12]=Za<0?0:Za>255?255:Za;Ba[13]=db<0?0:db>255?255:db;Ba[14]=ea<0?0:ea>255?255:ea;pa.putImageData(sa,0,0);Fa.drawImage(ja,0,0);return ya}function Na(L,aa,oa){L=(L-aa)/(oa-aa);return L*L*(3-2*L)}function O(L){L=(L+1)*0.5;return L<0?0:L>1?1:L}function Oa(L,aa){var oa=aa.x-L.x,ea=aa.y-L.y,ta=1/Math.sqrt(oa*oa+ea*ea);oa*=ta;ea*=ta;aa.x+=oa;aa.y+=ea;L.x-=oa;L.y-=ea}var Ra,jb,Ca,Ta,Ga,Pa,Ka,wa;this.autoClear? +this.clear():n.setTransform(1,0,0,-1,k,m);b=e.projectScene(U,la,this.sortElements);(J=U.lights.length>0)&&Ma(U);Ra=0;for(jb=b.length;Ra0){ia.r+=N.color.r*ha;ia.g+=N.color.g*ha;ia.b+=N.color.b*ha}}else if(N instanceof THREE.PointLight){d.sub(N.position,W.centroidWorld);d.normalize();ha=W.normalWorld.dot(d)*N.intensity;if(ha>0){ia.r+=N.color.r*ha;ia.g+=N.color.g*ha;ia.b+=N.color.b*ha}}}}function c(ma,W,ia,Z,S,N){Y=e(ua++);Y.setAttribute("d", +"M "+ma.positionScreen.x+" "+ma.positionScreen.y+" L "+W.positionScreen.x+" "+W.positionScreen.y+" L "+ia.positionScreen.x+","+ia.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)D.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(M){Q.r=R.r;Q.g=R.g;Q.b=R.b;a(N,Z,Q);D.r=S.color.r*Q.r;D.g=S.color.g*Q.g;D.b=S.color.b*Q.b;D.updateStyleString()}else D.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){$=1-S.__2near/(S.__farPlusNear- +Z.z*S.__farMinusNear);D.setRGB($,$,$)}else S instanceof THREE.MeshNormalMaterial&&D.setRGB(f(Z.normalWorld.x),f(Z.normalWorld.y),f(Z.normalWorld.z));S.wireframe?Y.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+S.wireframeLinewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframeLinecap+"; stroke-linejoin: "+S.wireframeLinejoin):Y.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+S.opacity);k.appendChild(Y)}function b(ma,W,ia,Z,S,N,ha){Y= +e(ua++);Y.setAttribute("d","M "+ma.positionScreen.x+" "+ma.positionScreen.y+" L "+W.positionScreen.x+" "+W.positionScreen.y+" L "+ia.positionScreen.x+","+ia.positionScreen.y+" L "+Z.positionScreen.x+","+Z.positionScreen.y+"z");if(N instanceof THREE.MeshBasicMaterial)D.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshLambertMaterial)if(M){Q.r=R.r;Q.g=R.g;Q.b=R.b;a(ha,S,Q);D.r=N.color.r*Q.r;D.g=N.color.g*Q.g;D.b=N.color.b*Q.b;D.updateStyleString()}else D.__styleString=N.color.__styleString; +else if(N instanceof THREE.MeshDepthMaterial){$=1-N.__2near/(N.__farPlusNear-S.z*N.__farMinusNear);D.setRGB($,$,$)}else N instanceof THREE.MeshNormalMaterial&&D.setRGB(f(S.normalWorld.x),f(S.normalWorld.y),f(S.normalWorld.z));N.wireframe?Y.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+N.wireframeLinewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.wireframeLinecap+"; stroke-linejoin: "+N.wireframeLinejoin):Y.setAttribute("style","fill: "+D.__styleString+ +"; fill-opacity: "+N.opacity);k.appendChild(Y)}function e(ma){if(X[ma]==null){X[ma]=document.createElementNS("http://www.w3.org/2000/svg","path");za==0&&X[ma].setAttribute("shape-rendering","crispEdges")}return X[ma]}function f(ma){return ma<0?Math.min((1+ma)*0.5,0.5):0.5+Math.min(ma*0.5,0.5)}var g=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,n,p,x,z,y,B,H,I=new THREE.Rectangle,F=new THREE.Rectangle,M=!1,D=new THREE.Color(16777215),Q=new THREE.Color(16777215), +R=new THREE.Color(0),P=new THREE.Color(0),ka=new THREE.Color(0),$,d=new THREE.Vector3,X=[],da=[],Y,ua,va,za=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ma){switch(ma){case "high":za=1;break;case "low":za=0}};this.setSize=function(ma,W){m=ma;n=W;p=m/2;x=n/2;k.setAttribute("viewBox",-p+" "+-x+" "+m+" "+n);k.setAttribute("width",m);k.setAttribute("height",n);I.set(-p,-x,p,x)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])}; +this.render=function(ma,W){var ia,Z,S,N,ha,ra,na,qa;this.autoClear&&this.clear();g=h.projectScene(ma,W,this.sortElements);va=ua=0;if(M=ma.lights.length>0){na=ma.lights;R.setRGB(0,0,0);P.setRGB(0,0,0);ka.setRGB(0,0,0);ia=0;for(Z=na.length;iaaa){Q=K;aa=H[Q]}f.bindBuffer(f.ARRAY_BUFFER,w.__webGLMorphTargetsBuffers[Q]);f.vertexAttribPointer(D["morphTarget"+p],3,f.FLOAT,!1, -0,0);E.__webGLMorphTargetInfluences[p]=aa;C[Q]=1;aa=-1;p++}}f.uniform1fv(o.program.uniforms.morphTargetInfluences,E.__webGLMorphTargetInfluences)}else{f.bindBuffer(f.ARRAY_BUFFER,w.__webGLVertexBuffer);f.vertexAttribPointer(n.position,3,f.FLOAT,!1,0,0)}if(n.color>=0){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLColorBuffer);f.vertexAttribPointer(n.color,3,f.FLOAT,!1,0,0)}if(n.normal>=0){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLNormalBuffer);f.vertexAttribPointer(n.normal,3,f.FLOAT,!1,0,0)}if(n.tangent>=0){f.bindBuffer(f.ARRAY_BUFFER, -w.__webGLTangentBuffer);f.vertexAttribPointer(n.tangent,4,f.FLOAT,!1,0,0)}if(n.uv>=0)if(w.__webGLUVBuffer){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLUVBuffer);f.vertexAttribPointer(n.uv,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(n.uv)}else f.disableVertexAttribArray(n.uv);if(n.uv2>=0)if(w.__webGLUV2Buffer){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLUV2Buffer);f.vertexAttribPointer(n.uv2,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(n.uv2)}else f.disableVertexAttribArray(n.uv2);if(o.skinning&&n.skinVertexA>=0&& -n.skinVertexB>=0&&n.skinIndex>=0&&n.skinWeight>=0){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLSkinVertexABuffer);f.vertexAttribPointer(n.skinVertexA,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,w.__webGLSkinVertexBBuffer);f.vertexAttribPointer(n.skinVertexB,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,w.__webGLSkinIndicesBuffer);f.vertexAttribPointer(n.skinIndex,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,w.__webGLSkinWeightsBuffer);f.vertexAttribPointer(n.skinWeight,4,f.FLOAT,!1,0,0)}if(E instanceof -THREE.Mesh)if(o.wireframe){f.lineWidth(o.wireframeLinewidth);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,w.__webGLLineBuffer);f.drawElements(f.LINES,w.__webGLLineCount,f.UNSIGNED_SHORT,0)}else{f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);f.drawElements(f.TRIANGLES,w.__webGLFaceCount,f.UNSIGNED_SHORT,0)}else if(E instanceof THREE.Line){E=E.type==THREE.LineStrip?f.LINE_STRIP:f.LINES;f.lineWidth(o.linewidth);f.drawArrays(E,0,w.__webGLLineCount)}else if(E instanceof THREE.ParticleSystem)f.drawArrays(f.POINTS, -0,w.__webGLParticleCount);else E instanceof THREE.Ribbon&&f.drawArrays(f.TRIANGLE_STRIP,0,w.__webGLVertexCount)}}function g(n,D){if(!n.__webGLVertexBuffer)n.__webGLVertexBuffer=f.createBuffer();if(!n.__webGLNormalBuffer)n.__webGLNormalBuffer=f.createBuffer();if(n.hasPos){f.bindBuffer(f.ARRAY_BUFFER,n.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,n.positionArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(D.attributes.position);f.vertexAttribPointer(D.attributes.position,3,f.FLOAT,!1,0,0)}if(n.hasNormal){f.bindBuffer(f.ARRAY_BUFFER, -n.__webGLNormalBuffer);f.bufferData(f.ARRAY_BUFFER,n.normalArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(D.attributes.normal);f.vertexAttribPointer(D.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,n.count);n.count=0}function h(n){if(X!=n.doubleSided){n.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE);X=n.doubleSided}if(va!=n.flipSided){n.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW);va=n.flipSided}}function j(n){if(Ca!=n){n?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST); -Ca=n}}function k(n){S[0].set(n.n41-n.n11,n.n42-n.n12,n.n43-n.n13,n.n44-n.n14);S[1].set(n.n41+n.n11,n.n42+n.n12,n.n43+n.n13,n.n44+n.n14);S[2].set(n.n41+n.n21,n.n42+n.n22,n.n43+n.n23,n.n44+n.n24);S[3].set(n.n41-n.n21,n.n42-n.n22,n.n43-n.n23,n.n44-n.n24);S[4].set(n.n41-n.n31,n.n42-n.n32,n.n43-n.n33,n.n44-n.n34);S[5].set(n.n41+n.n31,n.n42+n.n32,n.n43+n.n33,n.n44+n.n34);var D;for(n=0;n<6;n++){D=S[n];D.divideScalar(Math.sqrt(D.x*D.x+D.y*D.y+D.z*D.z))}}function m(n){for(var D=n.matrixWorld,p=-n.geometry.boundingSphere.radius* -Math.max(n.scale.x,Math.max(n.scale.y,n.scale.z)),o=0;o<6;o++){n=S[o].x*D.n14+S[o].y*D.n24+S[o].z*D.n34+S[o].w;if(n<=p)return!1}return!0}function t(n,D){n.list[n.count]=D;n.count+=1}function x(n){var D,p,o=n.object,w=n.opaque,E=n.transparent;E.count=0;n=w.count=0;for(D=o.materials.length;n65535){K[aa].counter+=1;Q=K[aa].hash+"_"+K[aa].counter;n.geometryGroups[Q]==undefined&&(n.geometryGroups[Q]={faces:[],materials:H,vertices:0,numMorphTargets:ra})}n.geometryGroups[Q].faces.push(w);n.geometryGroups[Q].vertices+=C}}function F(n,D,p){n.push({buffer:D,object:p,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function G(n){if(n!=wa){switch(n){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE);break; -case THREE.SubtractiveBlending:f.blendFunc(f.DST_COLOR,f.ZERO);break;case THREE.BillboardBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:f.blendEquation(f.FUNC_REVERSE_SUBTRACT);f.blendFunc(f.ONE,f.ONE);break;default:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA)}wa=n}}function L(n,D,p){if((p.width&p.width-1)==0&&(p.height&p.height-1)==0){f.texParameteri(n,f.TEXTURE_WRAP_S,M(D.wrapS));f.texParameteri(n, -f.TEXTURE_WRAP_T,M(D.wrapT));f.texParameteri(n,f.TEXTURE_MAG_FILTER,M(D.magFilter));f.texParameteri(n,f.TEXTURE_MIN_FILTER,M(D.minFilter));f.generateMipmap(n)}else{f.texParameteri(n,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(n,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(n,f.TEXTURE_MAG_FILTER,R(D.magFilter));f.texParameteri(n,f.TEXTURE_MIN_FILTER,R(D.minFilter))}}function A(n){if(n&&!n.__webGLFramebuffer){n.__webGLFramebuffer=f.createFramebuffer();n.__webGLRenderbuffer=f.createRenderbuffer(); -n.__webGLTexture=f.createTexture();f.bindRenderbuffer(f.RENDERBUFFER,n.__webGLRenderbuffer);f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,n.width,n.height);f.bindTexture(f.TEXTURE_2D,n.__webGLTexture);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,M(n.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,M(n.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,M(n.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,M(n.minFilter));f.texImage2D(f.TEXTURE_2D,0,M(n.format),n.width, -n.height,0,M(n.format),M(n.type),null);f.bindFramebuffer(f.FRAMEBUFFER,n.__webGLFramebuffer);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,n.__webGLTexture,0);f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,n.__webGLRenderbuffer);f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}var D,p;if(n){D=n.__webGLFramebuffer;p=n.width;n=n.height}else{D=null;p=fa;n=Y}if(D!=W){f.bindFramebuffer(f.FRAMEBUFFER, -D);f.viewport(ja,U,p,n);W=D}}function P(n,D){var p;if(n=="fragment")p=f.createShader(f.FRAGMENT_SHADER);else n=="vertex"&&(p=f.createShader(f.VERTEX_SHADER));f.shaderSource(p,D);f.compileShader(p);if(!f.getShaderParameter(p,f.COMPILE_STATUS)){console.error(f.getShaderInfoLog(p));console.error(D);return null}return p}function R(n){switch(n){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return f.LINEAR}} -function M(n){switch(n){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT;case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR; -case THREE.ByteType:return f.BYTE;case THREE.UnsignedByteType:return f.UNSIGNED_BYTE;case THREE.ShortType:return f.SHORT;case THREE.UnsignedShortType:return f.UNSIGNED_SHORT;case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0} -var ia=document.createElement("canvas"),f,ea=null,W=null,da=this,X=null,va=null,wa=null,Ca=null,ja=0,U=0,fa=0,Y=0,S=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],O=new THREE.Matrix4,ga=new Float32Array(16),sa=new Float32Array(16),ma=new THREE.Vector4,ta={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},za=!0,Ma=new THREE.Color(0),bb=0;if(a){if(a.antialias!==undefined)za=a.antialias; -a.clearColor!==undefined&&Ma.setHex(a.clearColor);if(a.clearAlpha!==undefined)bb=a.clearAlpha}this.maxMorphTargets=8;this.domElement=ia;this.autoClear=!0;this.sortObjects=!0;(function(n,D,p){try{if(!(f=ia.getContext("experimental-webgl",{antialias:n})))throw"Error creating WebGL context.";}catch(o){console.error(o)}f.clearColor(0,0,0,1);f.clearDepth(1);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);f.enable(f.BLEND);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA); -f.clearColor(D.r,D.g,D.b,p);_cullEnabled=!0})(za,Ma,bb);this.context=f;this.setSize=function(n,D){ia.width=n;ia.height=D;this.setViewport(0,0,ia.width,ia.height)};this.setViewport=function(n,D,p,o){ja=n;U=D;fa=p;Y=o;f.viewport(ja,U,fa,Y)};this.setScissor=function(n,D,p,o){f.scissor(n,D,p,o)};this.enableScissorTest=function(n){n?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.enableDepthBufferWrite=function(n){f.depthMask(n)};this.setClearColorHex=function(n,D){var p=new THREE.Color(n);f.clearColor(p.r, -p.g,p.b,D)};this.setClearColor=function(n,D){f.clearColor(n.r,n.g,n.b,D)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT)};this.initMaterial=function(n,D,p,o){var w,E,C;if(n instanceof THREE.MeshDepthMaterial)b(n,THREE.ShaderLib.depth);else if(n instanceof THREE.MeshNormalMaterial)b(n,THREE.ShaderLib.normal);else if(n instanceof THREE.MeshBasicMaterial)b(n,THREE.ShaderLib.basic);else if(n instanceof THREE.MeshLambertMaterial)b(n,THREE.ShaderLib.lambert);else if(n instanceof THREE.MeshPhongMaterial)b(n, -THREE.ShaderLib.phong);else if(n instanceof THREE.LineBasicMaterial)b(n,THREE.ShaderLib.basic);else n instanceof THREE.ParticleBasicMaterial&&b(n,THREE.ShaderLib.particle_basic);var H,aa,Q,K;C=Q=K=0;for(H=D.length;C0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+H.maxDirLights,"#define MAX_POINT_LIGHTS "+H.maxPointLights,"#define MAX_BONES "+H.maxBones,H.map?"#define USE_MAP":"",H.envMap?"#define USE_ENVMAP":"",H.lightMap?"#define USE_LIGHTMAP":"",H.vertexColors?"#define USE_COLOR":"",H.skinning?"#define USE_SKINNING": -"",H.morphTargets?"#define USE_MORPHTARGETS":"",H.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); -f.attachShader(p,P("fragment",C+K));f.attachShader(p,P("vertex",H+D));f.linkProgram(p);f.getProgramParameter(p,f.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+f.getProgramParameter(p,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");p.uniforms={};p.attributes={};n.program=p;p=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(w in n.uniforms)p.push(w); -w=n.program;K=0;for(D=p.length;K=0&&f.enableVertexAttribArray(E.color);E.normal>=0&&f.enableVertexAttribArray(E.normal); -E.tangent>=0&&f.enableVertexAttribArray(E.tangent);if(n.skinning&&E.skinVertexA>=0&&E.skinVertexB>=0&&E.skinIndex>=0&&E.skinWeight>=0){f.enableVertexAttribArray(E.skinVertexA);f.enableVertexAttribArray(E.skinVertexB);f.enableVertexAttribArray(E.skinIndex);f.enableVertexAttribArray(E.skinWeight)}if(n.morphTargets){n.numSupportedMorphTargets=0;if(E.morphTarget0>=0){f.enableVertexAttribArray(E.morphTarget0);n.numSupportedMorphTargets++}if(E.morphTarget1>=0){f.enableVertexAttribArray(E.morphTarget1); -n.numSupportedMorphTargets++}if(E.morphTarget2>=0){f.enableVertexAttribArray(E.morphTarget2);n.numSupportedMorphTargets++}if(E.morphTarget3>=0){f.enableVertexAttribArray(E.morphTarget3);n.numSupportedMorphTargets++}if(E.morphTarget4>=0){f.enableVertexAttribArray(E.morphTarget4);n.numSupportedMorphTargets++}if(E.morphTarget5>=0){f.enableVertexAttribArray(E.morphTarget5);n.numSupportedMorphTargets++}if(E.morphTarget6>=0){f.enableVertexAttribArray(E.morphTarget6);n.numSupportedMorphTargets++}if(E.morphTarget7>= -0){f.enableVertexAttribArray(E.morphTarget7);n.numSupportedMorphTargets++}o.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(w=0;w0||Ba.faceVertexUvs.length>0)C.__uvArray=new Float32Array(H*2);if(Ba.faceUvs.length>1||Ba.faceVertexUvs.length>1)C.__uv2Array=new Float32Array(H*2)}if(Q.geometry.skinWeights.length&&Q.geometry.skinIndices.length){C.__skinVertexAArray=new Float32Array(H*4);C.__skinVertexBArray=new Float32Array(H*4);C.__skinIndexArray=new Float32Array(H*4);C.__skinWeightArray=new Float32Array(H*4)}C.__faceArray=new Uint16Array(aa*3);C.__lineArray=new Uint16Array(Fa*2);if(C.numMorphTargets){Q= -void 0;Ba=void 0;C.__morphTargetsArrays=[];Q=0;for(Ba=C.numMorphTargets;Q=0;w--){o=p.__webglObjects[w].object;D==o&&p.__webglObjects.splice(w,1)}n.__objectsRemoved.splice(0,1)}D=0;for(p=n.__webglObjects.length;D0){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,Sa,H)}if(eb){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLNormalBuffer);f.bufferData(f.ARRAY_BUFFER,Xa,H)}if(ib&&T.hasTangents){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLTangentBuffer);f.bufferData(f.ARRAY_BUFFER,Ia,H)}if($a&&Ha>0){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLUVBuffer); -f.bufferData(f.ARRAY_BUFFER,Ga,H)}if($a&&Na>0){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLUV2Buffer);f.bufferData(f.ARRAY_BUFFER,ab,H)}if(db){f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,C.__webGLFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,Aa,H);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,C.__webGLLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,qa,H)}if(N>0){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLSkinVertexABuffer);f.bufferData(f.ARRAY_BUFFER,xa,H);f.bindBuffer(f.ARRAY_BUFFER,C.__webGLSkinVertexBBuffer);f.bufferData(f.ARRAY_BUFFER, -J,H);f.bindBuffer(f.ARRAY_BUFFER,C.__webGLSkinIndicesBuffer);f.bufferData(f.ARRAY_BUFFER,$,H);f.bindBuffer(f.ARRAY_BUFFER,C.__webGLSkinWeightsBuffer);f.bufferData(f.ARRAY_BUFFER,V,H)}}}w.__dirtyVertices=!1;w.__dirtyMorphTargets=!1;w.__dirtyElements=!1;w.__dirtyUvs=!1;w.__dirtyNormals=!1;w.__dirtyTangents=!1;w.__dirtyColors=!1}else if(o instanceof THREE.Ribbon){w=o.geometry;if(w.__dirtyVertices||w.__dirtyColors){o=w;E=f.DYNAMIC_DRAW;Q=void 0;Q=void 0;Ba=void 0;C=void 0;K=o.vertices;H=o.colors;ra=K.length; -aa=H.length;ca=o.__vertexArray;Fa=o.__colorArray;na=o.__dirtyColors;if(o.__dirtyVertices){for(Q=0;Q0}}; -THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,c,b){b&&a.update(undefined,!1,c);b=a.sounds;var d,e=b.length;for(d=0;dA){V=K;A=E[V]}d.bindBuffer(d.ARRAY_BUFFER,C.__webGLMorphTargetsBuffers[V]);d.vertexAttribPointer(t["morphTarget"+w],3,d.FLOAT,!1,0,0);G.__webGLMorphTargetInfluences[w]=A;J[V]=1;A=-1;w++}}d.uniform1fv(o.program.uniforms.morphTargetInfluences,G.__webGLMorphTargetInfluences)}else{d.bindBuffer(d.ARRAY_BUFFER,C.__webGLVertexBuffer);d.vertexAttribPointer(j.position,3, +d.FLOAT,!1,0,0)}if(j.color>=0){d.bindBuffer(d.ARRAY_BUFFER,C.__webGLColorBuffer);d.vertexAttribPointer(j.color,3,d.FLOAT,!1,0,0)}if(j.normal>=0){d.bindBuffer(d.ARRAY_BUFFER,C.__webGLNormalBuffer);d.vertexAttribPointer(j.normal,3,d.FLOAT,!1,0,0)}if(j.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,C.__webGLTangentBuffer);d.vertexAttribPointer(j.tangent,4,d.FLOAT,!1,0,0)}if(j.uv>=0)if(C.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,C.__webGLUVBuffer);d.vertexAttribPointer(j.uv,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(j.uv)}else d.disableVertexAttribArray(j.uv); +if(j.uv2>=0)if(C.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,C.__webGLUV2Buffer);d.vertexAttribPointer(j.uv2,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(j.uv2)}else d.disableVertexAttribArray(j.uv2);if(o.skinning&&j.skinVertexA>=0&&j.skinVertexB>=0&&j.skinIndex>=0&&j.skinWeight>=0){d.bindBuffer(d.ARRAY_BUFFER,C.__webGLSkinVertexABuffer);d.vertexAttribPointer(j.skinVertexA,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,C.__webGLSkinVertexBBuffer);d.vertexAttribPointer(j.skinVertexB,4,d.FLOAT,!1,0, +0);d.bindBuffer(d.ARRAY_BUFFER,C.__webGLSkinIndicesBuffer);d.vertexAttribPointer(j.skinIndex,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,C.__webGLSkinWeightsBuffer);d.vertexAttribPointer(j.skinWeight,4,d.FLOAT,!1,0,0)}if(G instanceof THREE.Mesh)if(o.wireframe){d.lineWidth(o.wireframeLinewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,C.__webGLLineBuffer);d.drawElements(d.LINES,C.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,C.__webGLFaceBuffer);d.drawElements(d.TRIANGLES, +C.__webGLFaceCount,d.UNSIGNED_SHORT,0)}else if(G instanceof THREE.Line){G=G.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(o.linewidth);d.drawArrays(G,0,C.__webGLLineCount)}else if(G instanceof THREE.ParticleSystem)d.drawArrays(d.POINTS,0,C.__webGLParticleCount);else G instanceof THREE.Ribbon&&d.drawArrays(d.TRIANGLE_STRIP,0,C.__webGLVertexCount)}}function g(j,t){if(!j.__webGLVertexBuffer)j.__webGLVertexBuffer=d.createBuffer();if(!j.__webGLNormalBuffer)j.__webGLNormalBuffer=d.createBuffer(); +if(j.hasPos){d.bindBuffer(d.ARRAY_BUFFER,j.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,j.positionArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(t.attributes.position);d.vertexAttribPointer(t.attributes.position,3,d.FLOAT,!1,0,0)}if(j.hasNormal){d.bindBuffer(d.ARRAY_BUFFER,j.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,j.normalArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(t.attributes.normal);d.vertexAttribPointer(t.attributes.normal,3,d.FLOAT,!1,0,0)}d.drawArrays(d.TRIANGLES,0,j.count); +j.count=0}function h(j){if(ua!=j.doubleSided){j.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE);ua=j.doubleSided}if(va!=j.flipSided){j.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW);va=j.flipSided}}function k(j){if(ma!=j){j?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST);ma=j}}function m(j){N[0].set(j.n41-j.n11,j.n42-j.n12,j.n43-j.n13,j.n44-j.n14);N[1].set(j.n41+j.n11,j.n42+j.n12,j.n43+j.n13,j.n44+j.n14);N[2].set(j.n41+j.n21,j.n42+j.n22,j.n43+j.n23,j.n44+j.n24);N[3].set(j.n41-j.n21,j.n42- +j.n22,j.n43-j.n23,j.n44-j.n24);N[4].set(j.n41-j.n31,j.n42-j.n32,j.n43-j.n33,j.n44-j.n34);N[5].set(j.n41+j.n31,j.n42+j.n32,j.n43+j.n33,j.n44+j.n34);var t;for(j=0;j<6;j++){t=N[j];t.divideScalar(Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z))}}function n(j){for(var t=j.matrixWorld,w=-j.geometry.boundingSphere.radius*Math.max(j.scale.x,Math.max(j.scale.y,j.scale.z)),o=0;o<6;o++){j=N[o].x*t.n14+N[o].y*t.n24+N[o].z*t.n34+N[o].w;if(j<=w)return!1}return!0}function p(j,t){j.list[j.count]=t;j.count+=1}function x(j){var t, +w,o=j.object,C=j.opaque,G=j.transparent;G.count=0;j=C.count=0;for(t=o.materials.length;j0){d.bindBuffer(d.ARRAY_BUFFER,o.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,Pa,C)}if(Za){d.bindBuffer(d.ARRAY_BUFFER,o.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,Ta,C)}if(db&&ga.hasTangents){d.bindBuffer(d.ARRAY_BUFFER,o.__webGLTangentBuffer);d.bufferData(d.ARRAY_BUFFER,Ga,C)}if(Ya&&cb>0){d.bindBuffer(d.ARRAY_BUFFER,o.__webGLUVBuffer);d.bufferData(d.ARRAY_BUFFER,jb,C)}if(Ya&& +eb>0){d.bindBuffer(d.ARRAY_BUFFER,o.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Ca,C)}if(La){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,ea,C);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,ta,C)}if(O>0){d.bindBuffer(d.ARRAY_BUFFER,o.__webGLSkinVertexABuffer);d.bufferData(d.ARRAY_BUFFER,Ka,C);d.bindBuffer(d.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);d.bufferData(d.ARRAY_BUFFER,wa,C);d.bindBuffer(d.ARRAY_BUFFER, +o.__webGLSkinIndicesBuffer);d.bufferData(d.ARRAY_BUFFER,L,C);d.bindBuffer(d.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);d.bufferData(d.ARRAY_BUFFER,aa,C)}}}w.__dirtyVertices=!1;w.__dirtyMorphTargets=!1;w.__dirtyElements=!1;w.__dirtyUvs=!1;w.__dirtyNormals=!1;w.__dirtyTangents=!1;w.__dirtyColors=!1}else if(j instanceof THREE.Ribbon){w=j.geometry;if(w.__dirtyVertices||w.__dirtyColors){j=w;t=d.DYNAMIC_DRAW;Ba=j.vertices;C=j.colors;ya=Ba.length;G=C.length;Fa=j.__vertexArray;J=j.__colorArray;Ja=j.__dirtyColors; +if(j.__dirtyVertices){for(pa=0;pa65535){K[A].counter+=1;V=K[A].hash+"_"+K[A].counter;j.geometryGroups[V]==undefined&&(j.geometryGroups[V]={faces:[],materials:E,vertices:0,numMorphTargets:T})}j.geometryGroups[V].faces.push(C);j.geometryGroups[V].vertices+=J}}function F(j,t,w){j.push({buffer:t,object:w,opaque:{list:[], +count:0},transparent:{list:[],count:0}})}function M(j){if(j!=za){switch(j){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE);break;case THREE.SubtractiveBlending:d.blendFunc(d.DST_COLOR,d.ZERO);break;case THREE.BillboardBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:d.blendEquation(d.FUNC_REVERSE_SUBTRACT);d.blendFunc(d.ONE,d.ONE);break;default:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE, +d.ONE_MINUS_SRC_ALPHA)}za=j}}function D(j,t,w){if((w.width&w.width-1)==0&&(w.height&w.height-1)==0){d.texParameteri(j,d.TEXTURE_WRAP_S,ka(t.wrapS));d.texParameteri(j,d.TEXTURE_WRAP_T,ka(t.wrapT));d.texParameteri(j,d.TEXTURE_MAG_FILTER,ka(t.magFilter));d.texParameteri(j,d.TEXTURE_MIN_FILTER,ka(t.minFilter));d.generateMipmap(j)}else{d.texParameteri(j,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE);d.texParameteri(j,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE);d.texParameteri(j,d.TEXTURE_MAG_FILTER,P(t.magFilter));d.texParameteri(j, +d.TEXTURE_MIN_FILTER,P(t.minFilter))}}function Q(j){if(j&&!j.__webGLFramebuffer){j.__webGLFramebuffer=d.createFramebuffer();j.__webGLRenderbuffer=d.createRenderbuffer();j.__webGLTexture=d.createTexture();d.bindRenderbuffer(d.RENDERBUFFER,j.__webGLRenderbuffer);d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,j.width,j.height);d.bindTexture(d.TEXTURE_2D,j.__webGLTexture);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,ka(j.wrapS));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,ka(j.wrapT));d.texParameteri(d.TEXTURE_2D, +d.TEXTURE_MAG_FILTER,ka(j.magFilter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,ka(j.minFilter));d.texImage2D(d.TEXTURE_2D,0,ka(j.format),j.width,j.height,0,ka(j.format),ka(j.type),null);d.bindFramebuffer(d.FRAMEBUFFER,j.__webGLFramebuffer);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,j.__webGLTexture,0);d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.RENDERBUFFER,j.__webGLRenderbuffer);d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER, +null);d.bindFramebuffer(d.FRAMEBUFFER,null)}var t,w;if(j){t=j.__webGLFramebuffer;w=j.width;j=j.height}else{t=null;w=Z;j=S}if(t!=da){d.bindFramebuffer(d.FRAMEBUFFER,t);d.viewport(W,ia,w,j);da=t}}function R(j,t){var w;if(j=="fragment")w=d.createShader(d.FRAGMENT_SHADER);else j=="vertex"&&(w=d.createShader(d.VERTEX_SHADER));d.shaderSource(w,t);d.compileShader(w);if(!d.getShaderParameter(w,d.COMPILE_STATUS)){console.error(d.getShaderInfoLog(w));console.error(t);return null}return w}function P(j){switch(j){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return d.NEAREST; +default:return d.LINEAR}}function ka(j){switch(j){case THREE.RepeatWrapping:return d.REPEAT;case THREE.ClampToEdgeWrapping:return d.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return d.MIRRORED_REPEAT;case THREE.NearestFilter:return d.NEAREST;case THREE.NearestMipMapNearestFilter:return d.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return d.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return d.LINEAR;case THREE.LinearMipMapNearestFilter:return d.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return d.LINEAR_MIPMAP_LINEAR; +case THREE.ByteType:return d.BYTE;case THREE.UnsignedByteType:return d.UNSIGNED_BYTE;case THREE.ShortType:return d.SHORT;case THREE.UnsignedShortType:return d.UNSIGNED_SHORT;case THREE.IntType:return d.INT;case THREE.UnsignedShortType:return d.UNSIGNED_INT;case THREE.FloatType:return d.FLOAT;case THREE.AlphaFormat:return d.ALPHA;case THREE.RGBFormat:return d.RGB;case THREE.RGBAFormat:return d.RGBA;case THREE.LuminanceFormat:return d.LUMINANCE;case THREE.LuminanceAlphaFormat:return d.LUMINANCE_ALPHA}return 0} +var $=document.createElement("canvas"),d,X=null,da=null,Y=this,ua=null,va=null,za=null,ma=null,W=0,ia=0,Z=0,S=0,N=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ha=new THREE.Matrix4,ra=new Float32Array(16),na=new Float32Array(16),qa=new THREE.Vector4,xa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},Da=!0,$a=new THREE.Color(0),ab=0;if(a){if(a.antialias!==undefined)Da=a.antialias; +a.clearColor!==undefined&&$a.setHex(a.clearColor);if(a.clearAlpha!==undefined)ab=a.clearAlpha}this.maxMorphTargets=8;this.domElement=$;this.autoClear=!0;this.sortObjects=!0;(function(j,t,w){try{if(!(d=$.getContext("experimental-webgl",{antialias:j,stencil:!0})))throw"Error creating WebGL context.";}catch(o){console.error(o)}d.clearColor(0,0,0,1);d.clearDepth(1);d.enable(d.DEPTH_TEST);d.depthFunc(d.LEQUAL);d.frontFace(d.CCW);d.cullFace(d.BACK);d.enable(d.CULL_FACE);d.enable(d.BLEND);d.blendFunc(d.ONE, +d.ONE_MINUS_SRC_ALPHA);d.clearColor(t.r,t.g,t.b,w)})(Da,$a,ab);this.context=d;var Ia={};a=[];Da=[];a[0]=-2;a[1]=-1;a[2]=-1;a[3]=2;a[4]=-1;a[5]=-1;a[6]=2;a[7]=1;a[8]=-1;a[9]=-2;a[10]=1;a[11]=-1;Da[0]=0;Da[1]=1;Da[2]=2;Da[3]=0;Da[4]=2;Da[5]=3;Ia.vertexBuffer=d.createBuffer();Ia.elementBuffer=d.createBuffer();d.bindBuffer(d.ARRAY_BUFFER,Ia.vertexBuffer);d.bufferData(d.ARRAY_BUFFER,new Float32Array(a),d.STATIC_DRAW);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,Ia.elementBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER, +new Uint16Array(Da),d.STATIC_DRAW);Ia.program=d.createProgram();d.attachShader(Ia.program,R("fragment",THREE.ShaderLib.shadowPost.fragmentShader));d.attachShader(Ia.program,R("vertex",THREE.ShaderLib.shadowPost.vertexShader));d.linkProgram(Ia.program);Ia.vertexLocation=d.getAttribLocation(Ia.program,"position");Ia.projectionLocation=d.getUniformLocation(Ia.program,"projectionMatrix");this.setSize=function(j,t){$.width=j;$.height=t;this.setViewport(0,0,$.width,$.height)};this.setViewport=function(j, +t,w,o){W=j;ia=t;Z=w;S=o;d.viewport(W,ia,Z,S)};this.setScissor=function(j,t,w,o){d.scissor(j,t,w,o)};this.enableScissorTest=function(j){j?d.enable(d.SCISSOR_TEST):d.disable(d.SCISSOR_TEST)};this.enableDepthBufferWrite=function(j){d.depthMask(j)};this.setClearColorHex=function(j,t){var w=new THREE.Color(j);d.clearColor(w.r,w.g,w.b,t)};this.setClearColor=function(j,t){d.clearColor(j.r,j.g,j.b,t)};this.clear=function(){d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT|d.STENCIL_BUFFER_BIT)};this.initMaterial= +function(j,t,w,o){var C,G,J,E;if(j instanceof THREE.MeshDepthMaterial)b(j,THREE.ShaderLib.depth);else if(j instanceof THREE.ShadowVolumeDynamicMaterial)b(j,THREE.ShaderLib.shadowVolumeDynamic);else if(j instanceof THREE.MeshNormalMaterial)b(j,THREE.ShaderLib.normal);else if(j instanceof THREE.MeshBasicMaterial)b(j,THREE.ShaderLib.basic);else if(j instanceof THREE.MeshLambertMaterial)b(j,THREE.ShaderLib.lambert);else if(j instanceof THREE.MeshPhongMaterial)b(j,THREE.ShaderLib.phong);else if(j instanceof +THREE.LineBasicMaterial)b(j,THREE.ShaderLib.basic);else j instanceof THREE.ParticleBasicMaterial&&b(j,THREE.ShaderLib.particle_basic);if(!j.program){var A,V,K;A=K=E=0;for(J=t.length;A0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+J.maxDirLights,"#define MAX_POINT_LIGHTS "+J.maxPointLights,"#define MAX_BONES "+J.maxBones,J.map?"#define USE_MAP":"",J.envMap?"#define USE_ENVMAP":"",J.lightMap?"#define USE_LIGHTMAP":"",J.vertexColors?"#define USE_COLOR":"",J.skinning?"#define USE_SKINNING":"",J.morphTargets?"#define USE_MORPHTARGETS": +"",J.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); +d.attachShader(t,R("fragment",A+w));d.attachShader(t,R("vertex",J+E));d.linkProgram(t);d.getProgramParameter(t,d.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+d.getProgramParameter(t,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");t.uniforms={};t.attributes={};j.program=t;w=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(C in j.uniforms)w.push(C); +C=j.program;E=0;for(t=w.length;E=0&&d.enableVertexAttribArray(G.color);G.normal>=0&&d.enableVertexAttribArray(G.normal); +G.tangent>=0&&d.enableVertexAttribArray(G.tangent);if(j.skinning&&G.skinVertexA>=0&&G.skinVertexB>=0&&G.skinIndex>=0&&G.skinWeight>=0){d.enableVertexAttribArray(G.skinVertexA);d.enableVertexAttribArray(G.skinVertexB);d.enableVertexAttribArray(G.skinIndex);d.enableVertexAttribArray(G.skinWeight)}if(j.morphTargets){j.numSupportedMorphTargets=0;if(G.morphTarget0>=0){d.enableVertexAttribArray(G.morphTarget0);j.numSupportedMorphTargets++}if(G.morphTarget1>=0){d.enableVertexAttribArray(G.morphTarget1); +j.numSupportedMorphTargets++}if(G.morphTarget2>=0){d.enableVertexAttribArray(G.morphTarget2);j.numSupportedMorphTargets++}if(G.morphTarget3>=0){d.enableVertexAttribArray(G.morphTarget3);j.numSupportedMorphTargets++}if(G.morphTarget4>=0){d.enableVertexAttribArray(G.morphTarget4);j.numSupportedMorphTargets++}if(G.morphTarget5>=0){d.enableVertexAttribArray(G.morphTarget5);j.numSupportedMorphTargets++}if(G.morphTarget6>=0){d.enableVertexAttribArray(G.morphTarget6);j.numSupportedMorphTargets++}if(G.morphTarget7>= +0){d.enableVertexAttribArray(G.morphTarget7);j.numSupportedMorphTargets++}o.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(C=0;C0||Ba.faceVertexUvs.length>0)J.__uvArray=new Float32Array(A*2);if(Ba.faceUvs.length>1||Ba.faceVertexUvs.length>1)J.__uv2Array=new Float32Array(A*2)}if(E.geometry.skinWeights.length&&E.geometry.skinIndices.length){J.__skinVertexAArray=new Float32Array(A*4);J.__skinVertexBArray=new Float32Array(A*4);J.__skinIndexArray=new Float32Array(A*4);J.__skinWeightArray=new Float32Array(A*4)}J.__faceArray=new Uint16Array(ja*3+(E.geometry.edgeFaces?E.geometry.edgeFaces.length*6:0)); +J.__lineArray=new Uint16Array(pa*2);if(J.numMorphTargets){Ba=void 0;ya=void 0;J.__morphTargetsArrays=[];Ba=0;for(ya=J.numMorphTargets;Ba=0;C--){o=w.__webglObjects[C].object; +t==o&&w.__webglObjects.splice(C,1)}j.__objectsRemoved.splice(0,1)}t=0;for(w=j.__webglObjects.length;t +0}};THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,c,b){b&&a.update(undefined,!1,c);b=a.sounds;var e,f=b.length;for(e=0;e25&&(g=25);e=(g-1)*0.5;b=Array(g);for(c=d=0;c25&&(g=25);f=(g-1)*0.5;b=Array(g);for(c=e=0;cthis.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&&this.translateZ(-(this.movementSpeed+this.autoSpeedFactor));this.moveBackward&&this.translateZ(this.movementSpeed);this.moveLeft&&this.translateX(-this.movementSpeed);this.moveRight&&this.translateX(this.movementSpeed); -var b=this.lookSpeed;this.dragToLook&&!this.mouseDragOn&&(b=0);this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;b=this.target.position;var d=this.position;b.x=d.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=d.y+100*Math.cos(this.phi);b.z=d.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()}, +var b=this.lookSpeed;this.dragToLook&&!this.mouseDragOn&&(b=0);this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;b=this.target.position;var e=this.position;b.x=e.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=e.y+100*Math.cos(this.phi);b.z=e.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()}, !1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype; THREE.QuakeCamera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))}; -THREE.PathCamera=function(a){function c(m,t,x,z){var y={name:x,fps:0.6,length:z,hierarchy:[]},B,I=t.getControlPointsArray(),F=t.getLength(),G=I.length,L=0;B=G-1;t={parent:-1,keys:[]};t.keys[0]={time:0,pos:I[0],rot:[0,0,0,1],scl:[1,1,1]};t.keys[B]={time:z,pos:I[B],rot:[0,0,0,1],scl:[1,1,1]};for(B=1;B=0?z:z+e;z=this.verticalAngleMap.srcRange;y=this.verticalAngleMap.dstRange; -this.phi=(this.phi-z[0])*(y[1]-y[0])/(z[1]-z[0])+y[0];z=this.horizontalAngleMap.srcRange;y=this.horizontalAngleMap.dstRange;this.theta=(this.theta-z[0])*(y[1]-y[0])/(z[1]-z[0])+y[0];z=this.target.position;z.x=100*Math.sin(this.phi)*Math.cos(this.theta);z.y=100*Math.cos(this.phi);z.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,m,t,x)};this.onMouseMove=function(m){this.mouseX=m.clientX-this.windowHalfX;this.mouseY=m.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints); -this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var h=new THREE.MeshLambertMaterial({color:65280}),j=new Cube(10,10,20),k=new Cube(2,2,10);this.animationParent=new THREE.Mesh(j,a);a=new THREE.Mesh(k,h);a.position.set(0,10,0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation= -c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&d(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(m,t){return function(){t.apply(m,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; -var Cube=function(a,c,b,d,e,g,h,j,k){function m(F,G,L,A,P,R,M,ia){var f,ea,W=d||1,da=e||1,X=P/2,va=R/2,wa=t.vertices.length;if(F=="x"&&G=="y"||F=="y"&&G=="x")f="z";else if(F=="x"&&G=="z"||F=="z"&&G=="x"){f="y";da=g||1}else if(F=="z"&&G=="y"||F=="y"&&G=="z"){f="x";W=g||1}var Ca=W+1,ja=da+1;P/=W;var U=R/da;for(ea=0;ea0){h(0,0,-m-(g||0));for(d=a;d0){h(0,0,m+(e||0)); -for(d=a+a/2;d<2*a;d++)j.faces.push(new THREE.Face4(2*a+1,(2*d-2*a+2)%a+a,(2*d-2*a+1)%a+a,(2*d-2*a)%a+a))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder; -var Icosahedron=function(a){function c(x,z,y){var B=Math.sqrt(x*x+z*z+y*y);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(x/B,z/B,y/B)))-1}function b(x,z,y,B){B.faces.push(new THREE.Face3(x,z,y))}function d(x,z){var y=e.vertices[x].position,B=e.vertices[z].position;return c((y.x+B.x)/2,(y.y+B.y)/2,(y.z+B.z)/2)}var e=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0, -1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,g);b(0,5,1,g);b(0,1,7,g);b(0,7,10,g);b(0,10,11,g);b(1,5,9,g);b(5,11,4,g);b(11,10,2,g);b(10,7,6,g);b(7,1,8,g);b(3,9,4,g);b(3,4,2,g);b(3,2,6,g);b(3,6,8,g);b(3,8,9,g);b(4,9,5,g);b(2,4,11,g);b(6,2,10,g);b(8,6,7,g);b(9,8,1,g);for(a=0;a=0?z:z+f;z=this.verticalAngleMap.srcRange;y=this.verticalAngleMap.dstRange; +this.phi=(this.phi-z[0])*(y[1]-y[0])/(z[1]-z[0])+y[0];z=this.horizontalAngleMap.srcRange;y=this.horizontalAngleMap.dstRange;this.theta=(this.theta-z[0])*(y[1]-y[0])/(z[1]-z[0])+y[0];z=this.target.position;z.x=100*Math.sin(this.phi)*Math.cos(this.theta);z.y=100*Math.cos(this.phi);z.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,n,p,x)};this.onMouseMove=function(n){this.mouseX=n.clientX-this.windowHalfX;this.mouseY=n.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints); +this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var h=new THREE.MeshLambertMaterial({color:65280}),k=new Cube(10,10,20),m=new Cube(2,2,10);this.animationParent=new THREE.Mesh(k,a);a=new THREE.Mesh(m,h);a.position.set(0,10,0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation= +c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&e(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(n,p){return function(){p.apply(n,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; +var Cube=function(a,c,b,e,f,g,h,k,m){function n(I,F,M,D,Q,R,P,ka){var $,d,X=e||1,da=f||1,Y=Q/2,ua=R/2,va=p.vertices.length;if(I=="x"&&F=="y"||I=="y"&&F=="x")$="z";else if(I=="x"&&F=="z"||I=="z"&&F=="x"){$="y";da=g||1}else if(I=="z"&&F=="y"||I=="y"&&F=="z"){$="x";X=g||1}var za=X+1,ma=da+1;Q/=X;var W=R/da;for(d=0;d0){h(0,0,-n-(g||0));for(e=a;e0){h(0,0,n+(f||0)); +for(e=a+a/2;e<2*a;e++)k.faces.push(new THREE.Face4(2*a+1,(2*e-2*a+2)%a+a,(2*e-2*a+1)%a+a,(2*e-2*a)%a+a))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder; +var Icosahedron=function(a){function c(x,z,y){var B=Math.sqrt(x*x+z*z+y*y);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(x/B,z/B,y/B)))-1}function b(x,z,y,B){B.faces.push(new THREE.Face3(x,z,y))}function e(x,z){var y=f.vertices[x].position,B=f.vertices[z].position;return c((y.x+B.x)/2,(y.y+B.y)/2,(y.z+B.z)/2)}var f=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0, +1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,g);b(0,5,1,g);b(0,1,7,g);b(0,7,10,g);b(0,10,11,g);b(1,5,9,g);b(5,11,4,g);b(11,10,2,g);b(10,7,6,g);b(7,1,8,g);b(3,9,4,g);b(3,4,2,g);b(3,2,6,g);b(3,6,8,g);b(3,8,9,g);b(4,9,5,g);b(2,4,11,g);b(6,2,10,g);b(8,6,7,g);b(9,8,1,g);for(a=0;a0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,j,z)))-1);m.push(t)}c.push(m)}var y,B,I;e=c.length;for(b=0;b0)for(d=0;d1){y=this.vertices[h].position.clone(); -B=this.vertices[k].position.clone();I=this.vertices[m].position.clone();y.normalize();B.normalize();I.normalize();this.faces.push(new THREE.Face3(h,k,m,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(B.x,B.y,B.z),new THREE.Vector3(I.x,I.y,I.z)]));this.faceVertexUvs[0].push([t,x,F])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; -var Torus=function(a,c,b,d){this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){d=b/this.segmentsT*2*Math.PI;var e=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(e))*Math.cos(d),(this.radius+this.tube*Math.cos(e))*Math.sin(d),this.tube*Math.sin(e))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b= -1;b<=this.segmentsT;++b){d=(this.segmentsT+1)*c+b;e=(this.segmentsT+1)*c+b-1;var g=(this.segmentsT+1)*(c-1)+b-1,h=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(d,e,g,h));this.faceVertexUvs[0].push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; -var TorusKnot=function(a,c,b,d,e,g,h){function j(x,z,y,B,I,F){z=y/B*x;y=Math.cos(z);return new THREE.Vector3(I*(2+y)*0.5*Math.cos(x),I*(2+y)*Math.sin(x)*0.5,F*I*Math.sin(z)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=d||8;this.p=e||2;this.q=g||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;d=new THREE.Vector3;g=new THREE.Vector3;for(a=0;a>7)-127;w|=(C&127)<<16|E<<8;if(w==0&&aa==-127)return 0;return(1-2*(H>>7))*(1+w*Math.pow(2,-23))*Math.pow(2,aa)}function j(p,o){var w=t(p,o),E=t(p,o+1),C=t(p,o+2);return(t(p,o+3)<<24)+(C<<16)+(E<<8)+w}function k(p,o){var w=t(p,o);return(t(p,o+1)<<8)+w}function m(p,o){var w=t(p,o);return w>127?w-256:w}function t(p, -o){return p.charCodeAt(o)&255}function x(p){var o,w,E;o=j(a,p);w=j(a,p+M);E=j(a,p+ia);p=k(a,p+f);THREE.BinaryLoader.prototype.f3(G,o,w,E,p)}function z(p){var o,w,E,C,H,aa;o=j(a,p);w=j(a,p+M);E=j(a,p+ia);C=k(a,p+f);H=j(a,p+ea);aa=j(a,p+W);p=j(a,p+da);THREE.BinaryLoader.prototype.f3n(G,P,o,w,E,C,H,aa,p)}function y(p){var o,w,E,C;o=j(a,p);w=j(a,p+X);E=j(a,p+va);C=j(a,p+wa);p=k(a,p+Ca);THREE.BinaryLoader.prototype.f4(G,o,w,E,C,p)}function B(p){var o,w,E,C,H,aa,Q,K;o=j(a,p);w=j(a,p+X);E=j(a,p+va);C=j(a, -p+wa);H=k(a,p+Ca);aa=j(a,p+ja);Q=j(a,p+U);K=j(a,p+fa);p=j(a,p+Y);THREE.BinaryLoader.prototype.f4n(G,P,o,w,E,C,H,aa,Q,K,p)}function I(p){var o,w;o=j(a,p);w=j(a,p+S);p=j(a,p+O);THREE.BinaryLoader.prototype.uv3(G.faceVertexUvs[0],R[o*2],R[o*2+1],R[w*2],R[w*2+1],R[p*2],R[p*2+1])}function F(p){var o,w,E;o=j(a,p);w=j(a,p+ga);E=j(a,p+sa);p=j(a,p+ma);THREE.BinaryLoader.prototype.uv4(G.faceVertexUvs[0],R[o*2],R[o*2+1],R[w*2],R[w*2+1],R[E*2],R[E*2+1],R[p*2],R[p*2+1])}var G=this,L=0,A,P=[],R=[],M,ia,f,ea,W, -da,X,va,wa,Ca,ja,U,fa,Y,S,O,ga,sa,ma,ta,za,Ma,bb,n,D;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(G,d,g);A={signature:a.substr(L,8),header_bytes:t(a,L+8),vertex_coordinate_bytes:t(a,L+9),normal_coordinate_bytes:t(a,L+10),uv_coordinate_bytes:t(a,L+11),vertex_index_bytes:t(a,L+12),normal_index_bytes:t(a,L+13),uv_index_bytes:t(a,L+14),material_index_bytes:t(a,L+15),nvertices:j(a,L+16),nnormals:j(a,L+16+4),nuvs:j(a,L+16+8),ntri_flat:j(a,L+16+12),ntri_smooth:j(a,L+16+16),ntri_flat_uv:j(a, -L+16+20),ntri_smooth_uv:j(a,L+16+24),nquad_flat:j(a,L+16+28),nquad_smooth:j(a,L+16+32),nquad_flat_uv:j(a,L+16+36),nquad_smooth_uv:j(a,L+16+40)};L+=A.header_bytes;M=A.vertex_index_bytes;ia=A.vertex_index_bytes*2;f=A.vertex_index_bytes*3;ea=A.vertex_index_bytes*3+A.material_index_bytes;W=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes;da=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*2;X=A.vertex_index_bytes;va=A.vertex_index_bytes*2;wa=A.vertex_index_bytes*3; -Ca=A.vertex_index_bytes*4;ja=A.vertex_index_bytes*4+A.material_index_bytes;U=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes;fa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*2;Y=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*3;S=A.uv_index_bytes;O=A.uv_index_bytes*2;ga=A.uv_index_bytes;sa=A.uv_index_bytes*2;ma=A.uv_index_bytes*3;g=A.vertex_index_bytes*3+A.material_index_bytes;D=A.vertex_index_bytes*4+A.material_index_bytes;ta=A.ntri_flat* -g;za=A.ntri_smooth*(g+A.normal_index_bytes*3);Ma=A.ntri_flat_uv*(g+A.uv_index_bytes*3);bb=A.ntri_smooth_uv*(g+A.normal_index_bytes*3+A.uv_index_bytes*3);n=A.nquad_flat*D;g=A.nquad_smooth*(D+A.normal_index_bytes*4);D=A.nquad_flat_uv*(D+A.uv_index_bytes*4);L+=function(p){for(var o,w,E,C=A.vertex_coordinate_bytes*3,H=p+A.nvertices*C;p0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,z)))-1);n.push(p)}c.push(n)}var y,B,H;f=c.length;for(b=0;b0)for(e=0;e1){y=this.vertices[h].position.clone(); +B=this.vertices[m].position.clone();H=this.vertices[n].position.clone();y.normalize();B.normalize();H.normalize();this.faces.push(new THREE.Face3(h,m,n,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(B.x,B.y,B.z),new THREE.Vector3(H.x,H.y,H.z)]));this.faceVertexUvs[0].push([p,x,I])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; +var Torus=function(a,c,b,e){this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){e=b/this.segmentsT*2*Math.PI;var f=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(e),(this.radius+this.tube*Math.cos(f))*Math.sin(e),this.tube*Math.sin(f))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b= +1;b<=this.segmentsT;++b){e=(this.segmentsT+1)*c+b;f=(this.segmentsT+1)*c+b-1;var g=(this.segmentsT+1)*(c-1)+b-1,h=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(e,f,g,h));this.faceVertexUvs[0].push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; +var TorusKnot=function(a,c,b,e,f,g,h){function k(x,z,y,B,H,I){z=y/B*x;y=Math.cos(z);return new THREE.Vector3(H*(2+y)*0.5*Math.cos(x),H*(2+y)*Math.sin(x)*0.5,I*H*Math.sin(z)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=e||8;this.p=f||2;this.q=g||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;e=new THREE.Vector3;g=new THREE.Vector3;for(a=0;a>7)-127;w|=(C&127)<<16|o<<8;if(w==0&&J==-127)return 0;return(1-2*(G>>7))*(1+w*Math.pow(2,-23))*Math.pow(2,J)}function k(j,t){var w=p(j,t),o=p(j,t+1),C=p(j,t+2);return(p(j,t+3)<<24)+(C<<16)+(o<<8)+w}function m(j,t){var w=p(j,t);return(p(j,t+1)<<8)+w}function n(j,t){var w=p(j,t);return w>127?w-256:w}function p(j, +t){return j.charCodeAt(t)&255}function x(j){var t,w,o;t=k(a,j);w=k(a,j+P);o=k(a,j+ka);j=m(a,j+$);THREE.BinaryLoader.prototype.f3(F,t,w,o,j)}function z(j){var t,w,o,C,G,J;t=k(a,j);w=k(a,j+P);o=k(a,j+ka);C=m(a,j+$);G=k(a,j+d);J=k(a,j+X);j=k(a,j+da);THREE.BinaryLoader.prototype.f3n(F,Q,t,w,o,C,G,J,j)}function y(j){var t,w,o,C;t=k(a,j);w=k(a,j+Y);o=k(a,j+ua);C=k(a,j+va);j=m(a,j+za);THREE.BinaryLoader.prototype.f4(F,t,w,o,C,j)}function B(j){var t,w,o,C,G,J,E,A;t=k(a,j);w=k(a,j+Y);o=k(a,j+ua);C=k(a,j+va); +G=m(a,j+za);J=k(a,j+ma);E=k(a,j+W);A=k(a,j+ia);j=k(a,j+Z);THREE.BinaryLoader.prototype.f4n(F,Q,t,w,o,C,G,J,E,A,j)}function H(j){var t,w;t=k(a,j);w=k(a,j+S);j=k(a,j+N);THREE.BinaryLoader.prototype.uv3(F.faceVertexUvs[0],R[t*2],R[t*2+1],R[w*2],R[w*2+1],R[j*2],R[j*2+1])}function I(j){var t,w,o;t=k(a,j);w=k(a,j+ha);o=k(a,j+ra);j=k(a,j+na);THREE.BinaryLoader.prototype.uv4(F.faceVertexUvs[0],R[t*2],R[t*2+1],R[w*2],R[w*2+1],R[o*2],R[o*2+1],R[j*2],R[j*2+1])}var F=this,M=0,D,Q=[],R=[],P,ka,$,d,X,da,Y,ua,va, +za,ma,W,ia,Z,S,N,ha,ra,na,qa,xa,Da,$a,ab,Ia;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(F,e,g);D={signature:a.substr(M,8),header_bytes:p(a,M+8),vertex_coordinate_bytes:p(a,M+9),normal_coordinate_bytes:p(a,M+10),uv_coordinate_bytes:p(a,M+11),vertex_index_bytes:p(a,M+12),normal_index_bytes:p(a,M+13),uv_index_bytes:p(a,M+14),material_index_bytes:p(a,M+15),nvertices:k(a,M+16),nnormals:k(a,M+16+4),nuvs:k(a,M+16+8),ntri_flat:k(a,M+16+12),ntri_smooth:k(a,M+16+16),ntri_flat_uv:k(a,M+16+ +20),ntri_smooth_uv:k(a,M+16+24),nquad_flat:k(a,M+16+28),nquad_smooth:k(a,M+16+32),nquad_flat_uv:k(a,M+16+36),nquad_smooth_uv:k(a,M+16+40)};M+=D.header_bytes;P=D.vertex_index_bytes;ka=D.vertex_index_bytes*2;$=D.vertex_index_bytes*3;d=D.vertex_index_bytes*3+D.material_index_bytes;X=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes;da=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes*2;Y=D.vertex_index_bytes;ua=D.vertex_index_bytes*2;va=D.vertex_index_bytes*3;za=D.vertex_index_bytes* +4;ma=D.vertex_index_bytes*4+D.material_index_bytes;W=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes;ia=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*2;Z=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*3;S=D.uv_index_bytes;N=D.uv_index_bytes*2;ha=D.uv_index_bytes;ra=D.uv_index_bytes*2;na=D.uv_index_bytes*3;g=D.vertex_index_bytes*3+D.material_index_bytes;Ia=D.vertex_index_bytes*4+D.material_index_bytes;qa=D.ntri_flat*g;xa=D.ntri_smooth*(g+ +D.normal_index_bytes*3);Da=D.ntri_flat_uv*(g+D.uv_index_bytes*3);$a=D.ntri_smooth_uv*(g+D.normal_index_bytes*3+D.uv_index_bytes*3);ab=D.nquad_flat*Ia;g=D.nquad_smooth*(Ia+D.normal_index_bytes*4);Ia=D.nquad_flat_uv*(Ia+D.uv_index_bytes*4);M+=function(j){for(var t,w,o,C=D.vertex_coordinate_bytes*3,G=j+D.nvertices*C;j= -this.maxCount-3&&j(this)};this.begin=function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var d=this.count*3;dthis.size-1&&(k=this.size-1);var z=Math.floor(m-j);z<1&&(z=1);m=Math.floor(m+j);m>this.size-1&&(m=this.size-1);var y=Math.floor(t- -j);y<1&&(y=1);j=Math.floor(t+j);j>this.size-1&&(j=this.size-1);for(var B,I,F,G,L,A;x0&&(this.field[F+B]+=G)}}}};this.addPlaneX=function(b,d){var e,g,h,j,k,m=this.size,t=this.yd,x=this.zd,z=this.field,y=m*Math.sqrt(b/d);y>m&&(y=m);for(e=0;e0)for(g=0;gt&&(B=t);for(g=0;g0){k=g*x;for(e=0;esize&&(dist=size);for(h=0;h0){k=zd*h;for(g=0;g=this.maxCount-3&&k(this)};this.begin= +function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var e=this.count*3;ethis.size-1&&(m=this.size-1);var z=Math.floor(n-k);z<1&&(z=1);n=Math.floor(n+k);n>this.size-1&&(n=this.size-1);var y=Math.floor(p-k);y<1&&(y=1);k=Math.floor(p+k); +k>this.size-1&&(k=this.size-1);for(var B,H,I,F,M,D;x0&&(this.field[I+B]+=F)}}}};this.addPlaneX=function(b,e){var f,g,h,k,m,n=this.size,p=this.yd,x=this.zd,z=this.field,y=n*Math.sqrt(b/e);y>n&&(y=n);for(f=0;f0)for(g=0;gp&&(B=p);for(g=0;g0){m=g*x;for(f=0;fsize&&(dist=size);for(h=0;h0){m=zd*h;for(g=0;g25&&(f=25);h=(f-1)*0.5;b=Array(f);for(e=c=0;e25&&(f=25);d=(f-1)*0.5;b=Array(f);for(g=c=0;gthis.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&&this.translateZ(-(this.movementSpeed+this.autoSpeedFactor));this.moveBackward&&this.translateZ(this.movementSpeed);this.moveLeft&&this.translateX(-this.movementSpeed);this.moveRight&&this.translateX(this.movementSpeed); var b=this.lookSpeed;this.dragToLook&&!this.mouseDragOn&&(b=0);this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;b=this.target.position;var c=this.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()}, -!1);this.domElement.addEventListener("mousemove",e(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",e(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",e(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",e(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",e(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype; -THREE.QuakeCamera.prototype.translate=function(a,e){this.matrix.rotateAxis(e);if(this.noFly)e.y=0;this.position.addSelf(e.multiplyScalar(a));this.target.position.addSelf(e.multiplyScalar(a))}; -THREE.PathCamera=function(a){function e(l,k,m,t){var w={name:m,fps:0.6,length:t,hierarchy:[]},y,z=k.getControlPointsArray(),p=k.getLength(),A=z.length,B=0;y=A-1;k={parent:-1,keys:[]};k.keys[0]={time:0,pos:z[0],rot:[0,0,0,1],scl:[1,1,1]};k.keys[y]={time:t,pos:z[y],rot:[0,0,0,1],scl:[1,1,1]};for(y=1;y=0?t:t+h;t=this.verticalAngleMap.srcRange;w=this.verticalAngleMap.dstRange; -this.phi=(this.phi-t[0])*(w[1]-w[0])/(t[1]-t[0])+w[0];t=this.horizontalAngleMap.srcRange;w=this.horizontalAngleMap.dstRange;this.theta=(this.theta-t[0])*(w[1]-w[0])/(t[1]-t[0])+w[0];t=this.target.position;t.x=100*Math.sin(this.phi)*Math.cos(this.theta);t.y=100*Math.cos(this.phi);t.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 d=new THREE.MeshLambertMaterial({color:65280}),g=new Cube(10,10,20),j=new Cube(2,2,10);this.animationParent=new THREE.Mesh(g,a);a=new THREE.Mesh(j,d);a.position.set(0,10,0);this.animation=e(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation= -e(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&c(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; -var Cube=function(a,e,b,c,h,f,d,g,j){function l(p,A,B,n,E,D,L,M){var K,J,G=c||1,N=h||1,U=E/2,R=D/2,P=k.vertices.length;if(p=="x"&&A=="y"||p=="y"&&A=="x")K="z";else if(p=="x"&&A=="z"||p=="z"&&A=="x"){K="y";N=f||1}else if(p=="z"&&A=="y"||p=="y"&&A=="z"){K="x";G=f||1}var Q=G+1,T=N+1;E/=G;var H=D/N;for(J=0;J0){d(0,0,-l-(f||0));for(c=a;c0){d(0,0,l+(h||0)); -for(c=a+a/2;c<2*a;c++)g.faces.push(new THREE.Face4(2*a+1,(2*c-2*a+2)%a+a,(2*c-2*a+1)%a+a,(2*c-2*a)%a+a))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder; -var Icosahedron=function(a){function e(m,t,w){var y=Math.sqrt(m*m+t*t+w*w);return h.vertices.push(new THREE.Vertex(new THREE.Vector3(m/y,t/y,w/y)))-1}function b(m,t,w,y){y.faces.push(new THREE.Face3(m,t,w))}function c(m,t){var w=h.vertices[m].position,y=h.vertices[t].position;return e((w.x+y.x)/2,(w.y+y.y)/2,(w.z+y.z)/2)}var h=this,f=new THREE.Geometry,d;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;e(-1,a,0);e(1,a,0);e(-1,-a,0);e(1,-a,0);e(0,-1,a);e(0,1,a);e(0,-1,-a);e(0, -1,-a);e(a,0,-1);e(a,0,1);e(-a,0,-1);e(-a,0,1);b(0,11,5,f);b(0,5,1,f);b(0,1,7,f);b(0,7,10,f);b(0,10,11,f);b(1,5,9,f);b(5,11,4,f);b(11,10,2,f);b(10,7,6,f);b(7,1,8,f);b(3,9,4,f);b(3,4,2,f);b(3,2,6,f);b(3,6,8,f);b(3,8,9,f);b(4,9,5,f);b(2,4,11,f);b(6,2,10,f);b(8,6,7,f);b(9,8,1,f);for(a=0;a=0?p:p+d;p=this.verticalAngleMap.srcRange;w=this.verticalAngleMap.dstRange; +this.phi=(this.phi-p[0])*(w[1]-w[0])/(p[1]-p[0])+w[0];p=this.horizontalAngleMap.srcRange;w=this.horizontalAngleMap.dstRange;this.theta=(this.theta-p[0])*(w[1]-w[0])/(p[1]-p[0])+w[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,j,k,m)};this.onMouseMove=function(j){this.mouseX=j.clientX-this.windowHalfX;this.mouseY=j.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 e=new THREE.MeshLambertMaterial({color:65280}),h=new Cube(10,10,20),l=new Cube(2,2,10);this.animationParent=new THREE.Mesh(h,a);a=new THREE.Mesh(l,e);a.position.set(0,10,0);this.animation=g(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation= +g(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&c(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(j,k){return function(){k.apply(j,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; +var Cube=function(a,g,b,c,d,f,e,h,l){function j(y,A,C,n,E,D,L,M){var K,J,G=c||1,N=d||1,U=E/2,R=D/2,P=k.vertices.length;if(y=="x"&&A=="y"||y=="y"&&A=="x")K="z";else if(y=="x"&&A=="z"||y=="z"&&A=="x"){K="y";N=f||1}else if(y=="z"&&A=="y"||y=="y"&&A=="z"){K="x";G=f||1}var Q=G+1,T=N+1;E/=G;var H=D/N;for(J=0;J0){e(0,0,-j-(f||0));for(c=a;c0){e(0,0,j+(d||0)); +for(c=a+a/2;c<2*a;c++)h.faces.push(new THREE.Face4(2*a+1,(2*c-2*a+2)%a+a,(2*c-2*a+1)%a+a,(2*c-2*a)%a+a))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder; +var Icosahedron=function(a){function g(m,p,w){var t=Math.sqrt(m*m+p*p+w*w);return d.vertices.push(new THREE.Vertex(new THREE.Vector3(m/t,p/t,w/t)))-1}function b(m,p,w,t){t.faces.push(new THREE.Face3(m,p,w))}function c(m,p){var w=d.vertices[m].position,t=d.vertices[p].position;return g((w.x+t.x)/2,(w.y+t.y)/2,(w.z+t.z)/2)}var d=this,f=new THREE.Geometry,e;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;g(-1,a,0);g(1,a,0);g(-1,-a,0);g(1,-a,0);g(0,-1,a);g(0,1,a);g(0,-1,-a);g(0, +1,-a);g(a,0,-1);g(a,0,1);g(-a,0,-1);g(-a,0,1);b(0,11,5,f);b(0,5,1,f);b(0,1,7,f);b(0,7,10,f);b(0,10,11,f);b(1,5,9,f);b(5,11,4,f);b(11,10,2,f);b(10,7,6,f);b(7,1,8,f);b(3,9,4,f);b(3,4,2,f);b(3,2,6,f);b(3,6,8,f);b(3,8,9,f);b(4,9,5,f);b(2,4,11,f);b(6,2,10,f);b(8,6,7,f);b(9,8,1,f);for(a=0;a0||(k=this.vertices.push(new THREE.Vertex(new THREE.Vector3(m,g,t)))-1);l.push(k)}e.push(l)}var w,y,z;h=e.length;for(b=0;b0)for(c=0;c1){w=this.vertices[d].position.clone(); -y=this.vertices[j].position.clone();z=this.vertices[l].position.clone();w.normalize();y.normalize();z.normalize();this.faces.push(new THREE.Face3(d,j,l,[new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(z.x,z.y,z.z)]));this.faceVertexUvs[0].push([k,m,p])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; -var Torus=function(a,e,b,c){this.radius=a||100;this.tube=e||40;this.segmentsR=b||8;this.segmentsT=c||6;a=[];THREE.Geometry.call(this);for(e=0;e<=this.segmentsR;++e)for(b=0;b<=this.segmentsT;++b){c=b/this.segmentsT*2*Math.PI;var h=e/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(h))*Math.cos(c),(this.radius+this.tube*Math.cos(h))*Math.sin(c),this.tube*Math.sin(h))));a.push([b/this.segmentsT,1-e/this.segmentsR])}for(e=1;e<=this.segmentsR;++e)for(b= -1;b<=this.segmentsT;++b){c=(this.segmentsT+1)*e+b;h=(this.segmentsT+1)*e+b-1;var f=(this.segmentsT+1)*(e-1)+b-1,d=(this.segmentsT+1)*(e-1)+b;this.faces.push(new THREE.Face4(c,h,f,d));this.faceVertexUvs[0].push([new THREE.UV(a[c][0],a[c][1]),new THREE.UV(a[h][0],a[h][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[d][0],a[d][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; -var TorusKnot=function(a,e,b,c,h,f,d){function g(m,t,w,y,z,p){t=w/y*m;w=Math.cos(t);return new THREE.Vector3(z*(2+w)*0.5*Math.cos(m),z*(2+w)*Math.sin(m)*0.5,p*z*Math.sin(t)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=e||40;this.segmentsR=b||64;this.segmentsT=c||8;this.p=h||2;this.q=f||3;this.heightScale=d||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;c=new THREE.Vector3;f=new THREE.Vector3;for(a=0;a>7)-127;C|=(I&127)<<16|F<<8;if(C==0&&V==-127)return 0;return(1-2*(S>>7))*(1+C*Math.pow(2,-23))*Math.pow(2,V)}function g(o,x){var C=k(o,x),F=k(o,x+1),I=k(o,x+2);return(k(o,x+3)<<24)+(I<<16)+(F<<8)+C}function j(o,x){var C=k(o,x);return(k(o,x+1)<<8)+C}function l(o,x){var C=k(o,x);return C>127?C-256:C}function k(o, -x){return o.charCodeAt(x)&255}function m(o){var x,C,F;x=g(a,o);C=g(a,o+L);F=g(a,o+M);o=j(a,o+K);THREE.BinaryLoader.prototype.f3(A,x,C,F,o)}function t(o){var x,C,F,I,S,V;x=g(a,o);C=g(a,o+L);F=g(a,o+M);I=j(a,o+K);S=g(a,o+J);V=g(a,o+G);o=g(a,o+N);THREE.BinaryLoader.prototype.f3n(A,E,x,C,F,I,S,V,o)}function w(o){var x,C,F,I;x=g(a,o);C=g(a,o+U);F=g(a,o+R);I=g(a,o+P);o=j(a,o+Q);THREE.BinaryLoader.prototype.f4(A,x,C,F,I,o)}function y(o){var x,C,F,I,S,V,da,ea;x=g(a,o);C=g(a,o+U);F=g(a,o+R);I=g(a,o+P);S=j(a, -o+Q);V=g(a,o+T);da=g(a,o+H);ea=g(a,o+O);o=g(a,o+X);THREE.BinaryLoader.prototype.f4n(A,E,x,C,F,I,S,V,da,ea,o)}function z(o){var x,C;x=g(a,o);C=g(a,o+Y);o=g(a,o+fa);THREE.BinaryLoader.prototype.uv3(A.faceVertexUvs[0],D[x*2],D[x*2+1],D[C*2],D[C*2+1],D[o*2],D[o*2+1])}function p(o){var x,C,F;x=g(a,o);C=g(a,o+ga);F=g(a,o+ha);o=g(a,o+ia);THREE.BinaryLoader.prototype.uv4(A.faceVertexUvs[0],D[x*2],D[x*2+1],D[C*2],D[C*2+1],D[F*2],D[F*2+1],D[o*2],D[o*2+1])}var A=this,B=0,n,E=[],D=[],L,M,K,J,G,N,U,R,P,Q,T,H, -O,X,Y,fa,ga,ha,ia,Z,$,aa,ba,ca,W;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(A,c,f);n={signature:a.substr(B,8),header_bytes:k(a,B+8),vertex_coordinate_bytes:k(a,B+9),normal_coordinate_bytes:k(a,B+10),uv_coordinate_bytes:k(a,B+11),vertex_index_bytes:k(a,B+12),normal_index_bytes:k(a,B+13),uv_index_bytes:k(a,B+14),material_index_bytes:k(a,B+15),nvertices:g(a,B+16),nnormals:g(a,B+16+4),nuvs:g(a,B+16+8),ntri_flat:g(a,B+16+12),ntri_smooth:g(a,B+16+16),ntri_flat_uv:g(a,B+16+20),ntri_smooth_uv:g(a, -B+16+24),nquad_flat:g(a,B+16+28),nquad_smooth:g(a,B+16+32),nquad_flat_uv:g(a,B+16+36),nquad_smooth_uv:g(a,B+16+40)};B+=n.header_bytes;L=n.vertex_index_bytes;M=n.vertex_index_bytes*2;K=n.vertex_index_bytes*3;J=n.vertex_index_bytes*3+n.material_index_bytes;G=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;N=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;U=n.vertex_index_bytes;R=n.vertex_index_bytes*2;P=n.vertex_index_bytes*3;Q=n.vertex_index_bytes*4;T=n.vertex_index_bytes* +var Sphere=function(a,g,b){THREE.Geometry.call(this);var c,d=Math.PI,f=Math.max(3,g||8),e=Math.max(2,b||6);g=[];for(b=0;b0||(k=this.vertices.push(new THREE.Vertex(new THREE.Vector3(m,h,p)))-1);j.push(k)}g.push(j)}var w,t,z;d=g.length;for(b=0;b0)for(c=0;c1){w=this.vertices[e].position.clone(); +t=this.vertices[l].position.clone();z=this.vertices[j].position.clone();w.normalize();t.normalize();z.normalize();this.faces.push(new THREE.Face3(e,l,j,[new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(z.x,z.y,z.z)]));this.faceVertexUvs[0].push([k,m,y])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; +var Torus=function(a,g,b,c){this.radius=a||100;this.tube=g||40;this.segmentsR=b||8;this.segmentsT=c||6;a=[];THREE.Geometry.call(this);for(g=0;g<=this.segmentsR;++g)for(b=0;b<=this.segmentsT;++b){c=b/this.segmentsT*2*Math.PI;var d=g/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(d))*Math.cos(c),(this.radius+this.tube*Math.cos(d))*Math.sin(c),this.tube*Math.sin(d))));a.push([b/this.segmentsT,1-g/this.segmentsR])}for(g=1;g<=this.segmentsR;++g)for(b= +1;b<=this.segmentsT;++b){c=(this.segmentsT+1)*g+b;d=(this.segmentsT+1)*g+b-1;var f=(this.segmentsT+1)*(g-1)+b-1,e=(this.segmentsT+1)*(g-1)+b;this.faces.push(new THREE.Face4(c,d,f,e));this.faceVertexUvs[0].push([new THREE.UV(a[c][0],a[c][1]),new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[e][0],a[e][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; +var TorusKnot=function(a,g,b,c,d,f,e){function h(m,p,w,t,z,y){p=w/t*m;w=Math.cos(p);return new THREE.Vector3(z*(2+w)*0.5*Math.cos(m),z*(2+w)*Math.sin(m)*0.5,y*z*Math.sin(p)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=g||40;this.segmentsR=b||64;this.segmentsT=c||8;this.p=d||2;this.q=f||3;this.heightScale=e||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;c=new THREE.Vector3;f=new THREE.Vector3;for(a=0;a>7)-127;B|=(I&127)<<16|F<<8;if(B==0&&V==-127)return 0;return(1-2*(S>>7))*(1+B*Math.pow(2,-23))*Math.pow(2,V)}function h(o,x){var B=k(o,x),F=k(o,x+1),I=k(o,x+2);return(k(o,x+3)<<24)+(I<<16)+(F<<8)+B}function l(o,x){var B=k(o,x);return(k(o,x+1)<<8)+B}function j(o,x){var B=k(o,x);return B>127?B-256:B}function k(o, +x){return o.charCodeAt(x)&255}function m(o){var x,B,F;x=h(a,o);B=h(a,o+L);F=h(a,o+M);o=l(a,o+K);THREE.BinaryLoader.prototype.f3(A,x,B,F,o)}function p(o){var x,B,F,I,S,V;x=h(a,o);B=h(a,o+L);F=h(a,o+M);I=l(a,o+K);S=h(a,o+J);V=h(a,o+G);o=h(a,o+N);THREE.BinaryLoader.prototype.f3n(A,E,x,B,F,I,S,V,o)}function w(o){var x,B,F,I;x=h(a,o);B=h(a,o+U);F=h(a,o+R);I=h(a,o+P);o=l(a,o+Q);THREE.BinaryLoader.prototype.f4(A,x,B,F,I,o)}function t(o){var x,B,F,I,S,V,da,ea;x=h(a,o);B=h(a,o+U);F=h(a,o+R);I=h(a,o+P);S=l(a, +o+Q);V=h(a,o+T);da=h(a,o+H);ea=h(a,o+O);o=h(a,o+X);THREE.BinaryLoader.prototype.f4n(A,E,x,B,F,I,S,V,da,ea,o)}function z(o){var x,B;x=h(a,o);B=h(a,o+Y);o=h(a,o+fa);THREE.BinaryLoader.prototype.uv3(A.faceVertexUvs[0],D[x*2],D[x*2+1],D[B*2],D[B*2+1],D[o*2],D[o*2+1])}function y(o){var x,B,F;x=h(a,o);B=h(a,o+ga);F=h(a,o+ha);o=h(a,o+ia);THREE.BinaryLoader.prototype.uv4(A.faceVertexUvs[0],D[x*2],D[x*2+1],D[B*2],D[B*2+1],D[F*2],D[F*2+1],D[o*2],D[o*2+1])}var A=this,C=0,n,E=[],D=[],L,M,K,J,G,N,U,R,P,Q,T,H, +O,X,Y,fa,ga,ha,ia,Z,$,aa,ba,ca,W;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(A,c,f);n={signature:a.substr(C,8),header_bytes:k(a,C+8),vertex_coordinate_bytes:k(a,C+9),normal_coordinate_bytes:k(a,C+10),uv_coordinate_bytes:k(a,C+11),vertex_index_bytes:k(a,C+12),normal_index_bytes:k(a,C+13),uv_index_bytes:k(a,C+14),material_index_bytes:k(a,C+15),nvertices:h(a,C+16),nnormals:h(a,C+16+4),nuvs:h(a,C+16+8),ntri_flat:h(a,C+16+12),ntri_smooth:h(a,C+16+16),ntri_flat_uv:h(a,C+16+20),ntri_smooth_uv:h(a, +C+16+24),nquad_flat:h(a,C+16+28),nquad_smooth:h(a,C+16+32),nquad_flat_uv:h(a,C+16+36),nquad_smooth_uv:h(a,C+16+40)};C+=n.header_bytes;L=n.vertex_index_bytes;M=n.vertex_index_bytes*2;K=n.vertex_index_bytes*3;J=n.vertex_index_bytes*3+n.material_index_bytes;G=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;N=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;U=n.vertex_index_bytes;R=n.vertex_index_bytes*2;P=n.vertex_index_bytes*3;Q=n.vertex_index_bytes*4;T=n.vertex_index_bytes* 4+n.material_index_bytes;H=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;O=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;X=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;Y=n.uv_index_bytes;fa=n.uv_index_bytes*2;ga=n.uv_index_bytes;ha=n.uv_index_bytes*2;ia=n.uv_index_bytes*3;f=n.vertex_index_bytes*3+n.material_index_bytes;W=n.vertex_index_bytes*4+n.material_index_bytes;Z=n.ntri_flat*f;$=n.ntri_smooth*(f+n.normal_index_bytes*3);aa=n.ntri_flat_uv* -(f+n.uv_index_bytes*3);ba=n.ntri_smooth_uv*(f+n.normal_index_bytes*3+n.uv_index_bytes*3);ca=n.nquad_flat*W;f=n.nquad_smooth*(W+n.normal_index_bytes*4);W=n.nquad_flat_uv*(W+n.uv_index_bytes*4);B+=function(o){for(var x,C,F,I=n.vertex_coordinate_bytes*3,S=o+n.nvertices*I;o=this.maxCount-3&&g(this)};this.begin= -function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;cthis.size-1&&(j=this.size-1);var t=Math.floor(l-g);t<1&&(t=1);l=Math.floor(l+g);l>this.size-1&&(l=this.size-1);var w=Math.floor(k-g);w<1&&(w=1);g=Math.floor(k+g); -g>this.size-1&&(g=this.size-1);for(var y,z,p,A,B,n;m0&&(this.field[p+y]+=A)}}}};this.addPlaneX=function(b,c){var h,f,d,g,j,l=this.size,k=this.yd,m=this.zd,t=this.field,w=l*Math.sqrt(b/c);w>l&&(w=l);for(h=0;h0)for(f=0;fk&&(y=k);for(f=0;f0){j=f*m;for(h=0;hsize&&(dist=size);for(d=0;d0){j=zd*d;for(f=0;f=this.maxCount-3&&h(this)};this.begin= +function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;cthis.size-1&&(l=this.size-1);var p=Math.floor(j-h);p<1&&(p=1);j=Math.floor(j+h);j>this.size-1&&(j=this.size-1);var w=Math.floor(k-h);w<1&&(w=1);h=Math.floor(k+h); +h>this.size-1&&(h=this.size-1);for(var t,z,y,A,C,n;m0&&(this.field[y+t]+=A)}}}};this.addPlaneX=function(b,c){var d,f,e,h,l,j=this.size,k=this.yd,m=this.zd,p=this.field,w=j*Math.sqrt(b/c);w>j&&(w=j);for(d=0;d0)for(f=0;fk&&(t=k);for(f=0;f0){l=f*m;for(d=0;dsize&&(dist=size);for(e=0;e0){l=zd*e;for(f=0;f>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* -255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)}; -THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/ -this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)}; -THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a, -b){this.set(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);return this},crossSelf:function(a){var b=this.x,c=this.y,f=this.z;this.set(c*a.z-f*a.y,f*a.x-b*a.z,b*a.y-c*a.x);return this},multiply:function(a,b){this.set(a.x*b.x,a.y*b.y,a.z*b.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/ -a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a= -this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){this.y=Math.asin(a.n13);var b=Math.cos(this.y);if(Math.abs(b)>1.0E-5){this.x=Math.atan2(-a.n23/b,a.n33/b);this.z=Math.atan2(-a.n13/b,a.n11/b)}else{this.x=0;this.z=Math.atan2(a.n21,a.n22)}},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)< -1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,f){this.set(a||0,b||0,c||0,f||1)}; -THREE.Vector4.prototype={set:function(a,b,c,f){this.x=a;this.y=b;this.z=c;this.w=f;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,f=a.objects,e=[];a=0;for(b=f.length;a0&&P>0&&U+P< -1}var c,f,e,h,j,p,n,s,x,z,C,y=a.geometry,J=y.vertices,K=[];c=0;for(f=y.faces.length;cn?f:n;e=e>s?e:s}a()}; -this.add3Points=function(n,s,x,z,C,y){if(p){p=!1;b=nx?n>C?n:C:x>C?x:C;e=s>z?s>y?s:y:z>y?z:y}else{b=nx?n>C?n>f?n:f:C>f?C:f:x>C?x>f?x:f:C>f?C:f;e=s>z?s>y?s>e?s:e:y>e?y:e:z>y?z>e?z:e:y>e?y:e}a()};this.addRectangle=function(n){if(p){p=!1;b=n.getLeft();c=n.getTop();f=n.getRight();e=n.getBottom()}else{b=bn.getRight()? -f:n.getRight();e=e>n.getBottom()?e:n.getBottom()}a()};this.inflate=function(n){b-=n;c-=n;f+=n;e+=n;a()};this.minSelf=function(n){b=b>n.getLeft()?b:n.getLeft();c=c>n.getTop()?c:n.getTop();f=f=0&&Math.min(e,n.getBottom())-Math.max(c,n.getTop())>=0};this.empty=function(){p=!0;e=f=c=b=0;a()};this.isEmpty=function(){return p}}; -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,f,e,h,j,p,n,s,x,z,C,y,J,K){this.set(a||1,b||0,c||0,f||0,e||0,h||1,j||0,p||0,n||0,s||0,x||1,z||0,C||0,y||0,J||0,K||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(a,b,c,f,e,h,j,p,n,s,x,z,C,y,J,K){this.n11=a;this.n12=b;this.n13=c;this.n14=f;this.n21=e;this.n22=h;this.n23=j;this.n24=p;this.n31=n;this.n32=s;this.n33=x;this.n34=z;this.n41=C;this.n42=y;this.n43=J;this.n44=K;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 f=THREE.Matrix4.__v1, -e=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,b).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()}e.cross(h,f).normalize();this.n11=f.x;this.n12=e.x;this.n13=h.x;this.n21=f.y;this.n22=e.y;this.n23=h.y;this.n31=f.z;this.n32=e.z;this.n33=h.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,f=a.z,e=1/(this.n41*b+this.n42*c+this.n43*f+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*f+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23* -f+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*f+this.n34)*e;return a},multiplyVector4:function(a){var b=a.x,c=a.y,f=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*f+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*f+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*f+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*f+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,f=a.z;a.x=b*this.n11+c*this.n12+f*this.n13;a.y=b*this.n21+c*this.n22+f*this.n23;a.z=b*this.n31+c*this.n32+f*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,f=a.n12,e=a.n13,h=a.n14,j=a.n21,p=a.n22,n=a.n23,s=a.n24,x=a.n31,z=a.n32,C=a.n33,y=a.n34,J=a.n41,K=a.n42,P=a.n43,L=a.n44,ja=b.n11,ma=b.n12,sa=b.n13,U=b.n14,A=b.n21,oa=b.n22, -d=b.n23,Ba=b.n24,Ca=b.n31,Q=b.n32,N=b.n33,pa=b.n34;this.n11=c*ja+f*A+e*Ca;this.n12=c*ma+f*oa+e*Q;this.n13=c*sa+f*d+e*N;this.n14=c*U+f*Ba+e*pa+h;this.n21=j*ja+p*A+n*Ca;this.n22=j*ma+p*oa+n*Q;this.n23=j*sa+p*d+n*N;this.n24=j*U+p*Ba+n*pa+s;this.n31=x*ja+z*A+C*Ca;this.n32=x*ma+z*oa+C*Q;this.n33=x*sa+z*d+C*N;this.n34=x*U+z*Ba+C*pa+y;this.n41=J*ja+K*A+P*Ca;this.n42=J*ma+K*oa+P*Q;this.n43=J*sa+K*d+P*N;this.n44=J*U+K*Ba+P*pa+L;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,f=this.n14,e=this.n21,h=this.n22,j=this.n23,p=this.n24,n=this.n31,s=this.n32,x=this.n33,z=this.n34,C=this.n41,y=this.n42,J=this.n43,K=this.n44;return f*j*s*C-c*p*s*C-f*h*x*C+b*p*x*C+c*h*z*C-b*j*z*C-f*j*n*y+c*p*n*y+f*e*x*y-a*p*x*y-c*e*z*y+a*j*z*y+f*h*n*J-b*p*n*J-f*e*s*J+a*p*s*J+b*e*z*J-a*h*z*J-c*h*n*K+b*j*n*K+c*e*s*K-a*j*s*K-b*e*x*K+a*h*x*K},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31= +THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var g,f,h,i,m,o;if(d==0)g=f=h=0;else{i=Math.floor(a*6);m=a*6-i;a=d*(1-c);o=d*(1-c*m);c=d*(1-c*(1-m));switch(i){case 1:g=o;f=d;h=a;break;case 2:g=a;f=d;h=c;break;case 3:g=a;f=o;h=d;break;case 4:g=c;f=a;h=d;break;case 5:g=d;f=a; +h=o;break;case 6:case 0:g=d;f=c;h=a}}this.r=g;this.g=f;this.b=h;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* +255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,c){this.set(a||0,c||0)}; +THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/ +this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,c,d){this.set(a||0,c||0,d||0)}; +THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;this.z=d;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a, +c){this.set(a.y*c.z-a.z*c.y,a.z*c.x-a.x*c.z,a.x*c.y-a.y*c.x);return this},crossSelf:function(a){var c=this.x,d=this.y,g=this.z;this.set(d*a.z-g*a.y,g*a.x-c*a.z,c*a.y-d*a.x);return this},multiply:function(a,c){this.set(a.x*c.x,a.y*c.y,a.z*c.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/ +a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+d*d+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a= +this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){this.y=Math.asin(a.n13);var c=Math.cos(this.y);if(Math.abs(c)>1.0E-5){this.x=Math.atan2(-a.n23/c,a.n33/c);this.z=Math.atan2(-a.n13/c,a.n11/c)}else{this.x=0;this.z=Math.atan2(a.n21,a.n22)}},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)< +1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,c,d,g){this.set(a||0,c||0,d||0,g||1)}; +THREE.Vector4.prototype={set:function(a,c,d,g){this.x=a;this.y=c;this.z=d;this.w=g;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z,a.w+c.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z,a.w-c.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* +a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,c){this.set(this.x+(a.x-this.x)*c,this.y+(a.y-this.y)*c,this.z+(a.z-this.z)*c,this.w+(a.w-this.w)*c)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3}; +THREE.Ray.prototype={intersectScene:function(a){var c,d,g=a.objects,f=[];a=0;for(c=g.length;a0&&Q>0&&S+Q< +1}var d,g,f,h,i,m,o,t,x,y,B,z=a.geometry,H=z.vertices,J=[];d=0;for(g=z.faces.length;do?g:o;f=f>t?f:t}a()}; +this.add3Points=function(o,t,x,y,B,z){if(m){m=!1;c=ox?o>B?o:B:x>B?x:B;f=t>y?t>z?t:z:y>z?y:z}else{c=ox?o>B?o>g?o:g:B>g?B:g:x>B?x>g?x:g:B>g?B:g;f=t>y?t>z?t>f?t:f:z>f?z:f:y>z?y>f?y:f:z>f?z:f}a()};this.addRectangle=function(o){if(m){m=!1;c=o.getLeft();d=o.getTop();g=o.getRight();f=o.getBottom()}else{c=co.getRight()? +g:o.getRight();f=f>o.getBottom()?f:o.getBottom()}a()};this.inflate=function(o){c-=o;d-=o;g+=o;f+=o;a()};this.minSelf=function(o){c=c>o.getLeft()?c:o.getLeft();d=d>o.getTop()?d:o.getTop();g=g=0&&Math.min(f,o.getBottom())-Math.max(d,o.getTop())>=0};this.empty=function(){m=!0;f=g=d=c=0;a()};this.isEmpty=function(){return m}}; +THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}}; +THREE.Matrix4=function(a,c,d,g,f,h,i,m,o,t,x,y,B,z,H,J){this.set(a||1,c||0,d||0,g||0,f||0,h||1,i||0,m||0,o||0,t||0,x||1,y||0,B||0,z||0,H||0,J||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(a,c,d,g,f,h,i,m,o,t,x,y,B,z,H,J){this.n11=a;this.n12=c;this.n13=d;this.n14=g;this.n21=f;this.n22=h;this.n23=i;this.n24=m;this.n31=o;this.n32=t;this.n33=x;this.n34=y;this.n41=B;this.n42=z;this.n43=H;this.n44=J;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,c,d){var g=THREE.Matrix4.__v1, +f=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,c).normalize();if(h.length()===0)h.z=1;g.cross(d,h).normalize();if(g.length()===0){h.x+=1.0E-4;g.cross(d,h).normalize()}f.cross(h,g).normalize();this.n11=g.x;this.n12=f.x;this.n13=h.x;this.n21=g.y;this.n22=f.y;this.n23=h.y;this.n31=g.z;this.n32=f.z;this.n33=h.z;return this},multiplyVector3:function(a){var c=a.x,d=a.y,g=a.z,f=1/(this.n41*c+this.n42*d+this.n43*g+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*g+this.n14)*f;a.y=(this.n21*c+this.n22*d+this.n23* +g+this.n24)*f;a.z=(this.n31*c+this.n32*d+this.n33*g+this.n34)*f;return a},multiplyVector4:function(a){var c=a.x,d=a.y,g=a.z,f=a.w;a.x=this.n11*c+this.n12*d+this.n13*g+this.n14*f;a.y=this.n21*c+this.n22*d+this.n23*g+this.n24*f;a.z=this.n31*c+this.n32*d+this.n33*g+this.n34*f;a.w=this.n41*c+this.n42*d+this.n43*g+this.n44*f;return a},rotateAxis:function(a){var c=a.x,d=a.y,g=a.z;a.x=c*this.n11+d*this.n12+g*this.n13;a.y=c*this.n21+d*this.n22+g*this.n23;a.z=c*this.n31+d*this.n32+g*this.n33;a.normalize(); +return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,g=a.n12,f=a.n13,h=a.n14,i=a.n21,m=a.n22,o=a.n23,t=a.n24,x=a.n31,y=a.n32,B=a.n33,z=a.n34,H=a.n41,J=a.n42,Q=a.n43,K=a.n44,ia=c.n11,la=c.n12,wa=c.n13,S=c.n14,E=c.n21,fa=c.n22, +Y=c.n23,b=c.n24,ra=c.n31,R=c.n32,N=c.n33,pa=c.n34;this.n11=d*ia+g*E+f*ra;this.n12=d*la+g*fa+f*R;this.n13=d*wa+g*Y+f*N;this.n14=d*S+g*b+f*pa+h;this.n21=i*ia+m*E+o*ra;this.n22=i*la+m*fa+o*R;this.n23=i*wa+m*Y+o*N;this.n24=i*S+m*b+o*pa+t;this.n31=x*ia+y*E+B*ra;this.n32=x*la+y*fa+B*R;this.n33=x*wa+y*Y+B*N;this.n34=x*S+y*b+B*pa+z;this.n41=H*ia+J*E+Q*ra;this.n42=H*la+J*fa+Q*R;this.n43=H*wa+J*Y+Q*N;this.n44=H*S+J*b+Q*pa+K;return this},multiplyToArray:function(a,c,d){this.multiply(a,c);d[0]=this.n11;d[1]= +this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*= +a;return this},determinant:function(){var a=this.n11,c=this.n12,d=this.n13,g=this.n14,f=this.n21,h=this.n22,i=this.n23,m=this.n24,o=this.n31,t=this.n32,x=this.n33,y=this.n34,B=this.n41,z=this.n42,H=this.n43,J=this.n44;return g*i*t*B-d*m*t*B-g*h*x*B+c*m*x*B+d*h*y*B-c*i*y*B-g*i*o*z+d*m*o*z+g*f*x*z-a*m*x*z-d*f*y*z+a*i*y*z+g*h*o*H-c*m*o*H-g*f*t*H+a*m*t*H+c*f*y*H-a*h*y*H-d*h*o*J+c*i*o*J+d*f*t*J-a*i*t*J-c*f*x*J+a*h*x*J},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),f=Math.sin(b),e= -1-c,h=a.x,j=a.y,p=a.z,n=e*h,s=e*j;this.set(n*h+c,n*j-f*p,n*p+f*j,0,n*j+f*p,s*j+c,s*p-f*h,0,n*p-f*j,s*p+f*h,e*p*p+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,f=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var h=Math.cos(f);f=Math.sin(f);var j=a*c,p=b*c;this.n11=e*h;this.n12=-e*f;this.n13=c;this.n21=p*h+a*f;this.n22=-p*f+a*h;this.n23=-b*e;this.n31=-j*h+b*f;this.n32=j*f+b*h;this.n33= -a*e;return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,f=a.z,e=a.w,h=b+b,j=c+c,p=f+f;a=b*h;var n=b*j;b*=p;var s=c*j;c*=p;f*=p;h*=e;j*=e;e*=p;this.n11=1-(s+f);this.n12=n-e;this.n13=b+j;this.n21=n+e;this.n22=1-(a+f);this.n23=c-h;this.n31=b-j;this.n32=c+h;this.n33=1-(a+s);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,f=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*f;this.n22=a.n22*f;this.n32=a.n32*f;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,f=a.n12,e=a.n13,h=a.n14,j=a.n21,p=a.n22,n=a.n23,s=a.n24,x=a.n31,z=a.n32,C=a.n33,y=a.n34,J=a.n41,K=a.n42,P=a.n43,L=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=n*y*K-s*C*K+s*z*P-p*y*P-n*z*L+p*C*L;b.n12=h*C*K-e*y*K-h*z*P+f*y*P+e*z*L-f*C*L;b.n13=e*s*K-h*n*K+h*p*P-f*s*P-e*p*L+f*n*L;b.n14=h*n*z-e*s*z-h*p*C+f*s*C+e*p*y-f*n*y;b.n21=s*C*J-n*y*J-s*x*P+j*y*P+n*x*L-j*C*L;b.n22=e*y*J-h*C*J+h*x*P-c*y*P-e*x*L+c*C*L;b.n23=h*n*J-e*s*J-h*j*P+c*s*P+e*j*L-c*n*L; -b.n24=e*s*x-h*n*x+h*j*C-c*s*C-e*j*y+c*n*y;b.n31=p*y*J-s*z*J+s*x*K-j*y*K-p*x*L+j*z*L;b.n32=h*z*J-f*y*J-h*x*K+c*y*K+f*x*L-c*z*L;b.n33=e*s*J-h*p*J+h*j*K-c*s*K-f*j*L+c*p*L;b.n34=h*p*x-f*s*x-h*j*z+c*s*z+f*j*y-c*p*y;b.n41=n*z*J-p*C*J-n*x*K+j*C*K+p*x*P-j*z*P;b.n42=f*C*J-e*z*J+e*x*K-c*C*K-f*x*P+c*z*P;b.n43=e*p*J-f*n*J-e*j*K+c*n*K+f*j*P-c*p*P;b.n44=f*n*x-e*p*x+e*j*z-c*n*z-f*j*C+c*p*C;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,f=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,j=-a.n33*a.n12+a.n32*a.n13,p=a.n33*a.n11-a.n31*a.n13,n=-a.n32*a.n11+a.n31*a.n12,s=a.n23*a.n12-a.n22*a.n13,x=-a.n23*a.n11+a.n21*a.n13,z=a.n22*a.n11-a.n21*a.n12;a=a.n11*f+a.n21*j+a.n31*s;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*f;c[1]=a*e;c[2]=a*h;c[3]=a*j;c[4]=a*p;c[5]=a*n;c[6]=a*s;c[7]=a*x;c[8]=a*z;return b}; -THREE.Matrix4.makeFrustum=function(a,b,c,f,e,h){var j;j=new THREE.Matrix4;j.n11=2*e/(b-a);j.n12=0;j.n13=(b+a)/(b-a);j.n14=0;j.n21=0;j.n22=2*e/(f-c);j.n23=(f+c)/(f-c);j.n24=0;j.n31=0;j.n32=0;j.n33=-(h+e)/(h-e);j.n34=-2*h*e/(h-e);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(a,b,c,f){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,f)}; -THREE.Matrix4.makeOrtho=function(a,b,c,f,e,h){var j,p,n,s;j=new THREE.Matrix4;p=b-a;n=c-f;s=h-e;j.n11=2/p;j.n12=0;j.n13=0;j.n14=-((b+a)/p);j.n21=0;j.n22=2/n;j.n23=0;j.n24=-((c+f)/n);j.n31=0;j.n32=0;j.n33=-2/s;j.n34=-((h+e)/s);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; +a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,c){a[c]=this.n11;a[c+1]=this.n21;a[c+2]=this.n31;a[c+3]=this.n41;a[c+4]=this.n12;a[c+5]=this.n22;a[c+6]=this.n32;a[c+7]=this.n42;a[c+8]=this.n13;a[c+9]=this.n23;a[c+10]=this.n33;a[c+11]=this.n43;a[c+12]=this.n14;a[c+13]=this.n24;a[c+14]=this.n34;a[c+15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0, +0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotationX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotationY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotationZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,c){var d=Math.cos(c),g=Math.sin(c),f= +1-d,h=a.x,i=a.y,m=a.z,o=f*h,t=f*i;this.set(o*h+d,o*i-g*m,o*m+g*i,0,o*i+g*m,t*i+d,t*m-g*h,0,o*m-g*i,t*m+g*h,f*m*m+d,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var c=a.x,d=a.y,g=a.z;a=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var h=Math.cos(g);g=Math.sin(g);var i=a*d,m=c*d;this.n11=f*h;this.n12=-f*g;this.n13=d;this.n21=m*h+a*g;this.n22=-m*g+a*h;this.n23=-c*f;this.n31=-i*h+c*g;this.n32=i*g+c*h;this.n33= +a*f;return this},setRotationFromQuaternion:function(a){var c=a.x,d=a.y,g=a.z,f=a.w,h=c+c,i=d+d,m=g+g;a=c*h;var o=c*i;c*=m;var t=d*i;d*=m;g*=m;h*=f;i*=f;f*=m;this.n11=1-(t+g);this.n12=o-f;this.n13=c+i;this.n21=o+f;this.n22=1-(a+g);this.n23=d-h;this.n31=c-i;this.n32=d+h;this.n33=1-(a+t);return this},scale:function(a){var c=a.x,d=a.y;a=a.z;this.n11*=c;this.n12*=d;this.n13*=a;this.n21*=c;this.n22*=d;this.n23*=a;this.n31*=c;this.n32*=d;this.n33*=a;this.n41*=c;this.n42*=d;this.n43*=a;return this},extractPosition:function(a){this.n14= +a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,c){var d=1/c.x,g=1/c.y,f=1/c.z;this.n11=a.n11*d;this.n21=a.n21*d;this.n31=a.n31*d;this.n12=a.n12*g;this.n22=a.n22*g;this.n32=a.n32*g;this.n13=a.n13*f;this.n23=a.n23*f;this.n33=a.n33*f}}; +THREE.Matrix4.makeInvert=function(a,c){var d=a.n11,g=a.n12,f=a.n13,h=a.n14,i=a.n21,m=a.n22,o=a.n23,t=a.n24,x=a.n31,y=a.n32,B=a.n33,z=a.n34,H=a.n41,J=a.n42,Q=a.n43,K=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=o*z*J-t*B*J+t*y*Q-m*z*Q-o*y*K+m*B*K;c.n12=h*B*J-f*z*J-h*y*Q+g*z*Q+f*y*K-g*B*K;c.n13=f*t*J-h*o*J+h*m*Q-g*t*Q-f*m*K+g*o*K;c.n14=h*o*y-f*t*y-h*m*B+g*t*B+f*m*z-g*o*z;c.n21=t*B*H-o*z*H-t*x*Q+i*z*Q+o*x*K-i*B*K;c.n22=f*z*H-h*B*H+h*x*Q-d*z*Q-f*x*K+d*B*K;c.n23=h*o*H-f*t*H-h*i*Q+d*t*Q+f*i*K-d*o*K; +c.n24=f*t*x-h*o*x+h*i*B-d*t*B-f*i*z+d*o*z;c.n31=m*z*H-t*y*H+t*x*J-i*z*J-m*x*K+i*y*K;c.n32=h*y*H-g*z*H-h*x*J+d*z*J+g*x*K-d*y*K;c.n33=f*t*H-h*m*H+h*i*J-d*t*J-g*i*K+d*m*K;c.n34=h*m*x-g*t*x-h*i*y+d*t*y+g*i*z-d*m*z;c.n41=o*y*H-m*B*H-o*x*J+i*B*J+m*x*Q-i*y*Q;c.n42=g*B*H-f*y*H+f*x*J-d*B*J-g*x*Q+d*y*Q;c.n43=f*m*H-g*o*H-f*i*J+d*o*J+g*i*Q-d*m*Q;c.n44=g*o*x-f*m*x+f*i*y-d*o*y-g*i*B+d*m*B;c.multiplyScalar(1/a.determinant());return c}; +THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,d=c.m,g=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,h=a.n32*a.n21-a.n31*a.n22,i=-a.n33*a.n12+a.n32*a.n13,m=a.n33*a.n11-a.n31*a.n13,o=-a.n32*a.n11+a.n31*a.n12,t=a.n23*a.n12-a.n22*a.n13,x=-a.n23*a.n11+a.n21*a.n13,y=a.n22*a.n11-a.n21*a.n12;a=a.n11*g+a.n21*i+a.n31*t;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*g;d[1]=a*f;d[2]=a*h;d[3]=a*i;d[4]=a*m;d[5]=a*o;d[6]=a*t;d[7]=a*x;d[8]=a*y;return c}; +THREE.Matrix4.makeFrustum=function(a,c,d,g,f,h){var i;i=new THREE.Matrix4;i.n11=2*f/(c-a);i.n12=0;i.n13=(c+a)/(c-a);i.n14=0;i.n21=0;i.n22=2*f/(g-d);i.n23=(g+d)/(g-d);i.n24=0;i.n31=0;i.n32=0;i.n33=-(h+f)/(h-f);i.n34=-2*h*f/(h-f);i.n41=0;i.n42=0;i.n43=-1;i.n44=0;return i};THREE.Matrix4.makePerspective=function(a,c,d,g){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,d,g)}; +THREE.Matrix4.makeOrtho=function(a,c,d,g,f,h){var i,m,o,t;i=new THREE.Matrix4;m=c-a;o=d-g;t=h-f;i.n11=2/m;i.n12=0;i.n13=0;i.n14=-((c+a)/m);i.n21=0;i.n22=2/o;i.n23=0;i.n24=-((d+g)/o);i.n31=0;i.n32=0;i.n33=-2/t;i.n34=-((h+f)/t);i.n41=0;i.n42=0;i.n43=0;i.n44=1;return i};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible= !0;this._vector=new THREE.Vector3}; -THREE.Object3D.prototype={translate:function(a,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(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!== -undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!== -1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||b){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;b=!0}a=0;for(var f=this.children.length;a=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),j=Math.sqrt(1-e*e);if(Math.abs(j)<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-f)*h)/j;f=Math.sin(f*h)/j;c.w=a.w*e+b.w*f;c.x=a.x*e+b.x*f;c.y=a.y*e+b.y*f;c.z=a.z*e+b.z*f;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; -THREE.Face3=function(a,b,c,f,e,h){this.a=a;this.b=b;this.c=c;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];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,f,e,h,j){this.a=a;this.b=b;this.c=c;this.d=f;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=j instanceof Array?j:[j];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.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];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;b=1){d.w=a.w;d.x=a.x;d.y=a.y;d.z=a.z;return d}var h=Math.acos(f),i=Math.sqrt(1-f*f);if(Math.abs(i)<0.0010){d.w=0.5*(a.w+c.w);d.x=0.5*(a.x+c.x);d.y=0.5*(a.y+c.y);d.z=0.5*(a.z+c.z);return d}f=Math.sin((1-g)*h)/i;g=Math.sin(g*h)/i;d.w=a.w*f+c.w*g;d.x=a.x*f+c.x*g;d.y=a.y*f+c.y*g;d.z=a.z*f+c.z*g;return d};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; +THREE.Face3=function(a,c,d,g,f,h){this.a=a;this.b=c;this.c=d;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3}; +THREE.Face4=function(a,c,d,g,f,h,i){this.a=a;this.b=c;this.c=d;this.d=g;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=i instanceof Array?i:[i];this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.set(a||0,c||0)}; +THREE.UV.prototype={set:function(a,c){this.u=a;this.v=c;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1}; +THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x; +if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+y);f=f<0?0:1}if(c==="pos"){c=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=e[0]+(h[0]-e[0])*f;c.y=e[1]+(h[1]-e[1])*f;c.z=e[2]+(h[2]-e[2])*f}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= -this.getPrevKeyWith("pos",y,j.index-1).pos;this.points[1]=e;this.points[2]=h;this.points[3]=this.getNextKeyWith("pos",y,p.index+1).pos;f=f*0.33+0.33;e=this.interpolateCatmullRom(this.points,f);c.x=e[0];c.y=e[1];c.z=e[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);a.rotation.set(0,f,0)}}}else if(c=== -"rot")THREE.Quaternion.slerp(e,h,a.quaternion,f);else if(c==="scl"){c=a.scale;c.x=e[0]+(h[0]-e[0])*f;c.y=e[1]+(h[1]-e[1])*f;c.z=e[2]+(h[2]-e[2])*f}}}}if(this.JITCompile&&x[0][s]===undefined){this.hierarchy[0].update(undefined,!0);for(y=0;ya.length-2?h:h+1;c[3]=h>a.length-3?h:h+2;h=a[c[0]];p=a[c[1]];n=a[c[2]];s=a[c[3]];c=e*e;j=e*c;f[0]=this.interpolate(h[0],p[0],n[0],s[0],e,c,j);f[1]=this.interpolate(h[1],p[1],n[1],s[1],e,c,j);f[2]=this.interpolate(h[2],p[2],n[2],s[2],e,c,j);return f}; -THREE.Animation.prototype.interpolate=function(a,b,c,f,e,h,j){a=(c-a)*0.5;f=(f-b)*0.5;return(2*(b-c)+a+f)*j+(-3*(b-c)-2*a-f)*h+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var f=this.data.hierarchy[b].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][a]!==undefined)return f[c];return this.data.hierarchy[b].keys[f.length-1]}; -THREE.Camera=function(a,b,c,f,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=f||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;THREE.Camera.prototype.supr=THREE.Object3D.prototype; -THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)}; -THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate= -!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+g+" on bone "+z);g=g<0?0:1}if(d==="pos"){d=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){d.x=f[0]+(h[0]-f[0])*g;d.y=f[1]+(h[1]-f[1])*g;d.z=f[2]+(h[2]-f[2])*g}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= +this.getPrevKeyWith("pos",z,i.index-1).pos;this.points[1]=f;this.points[2]=h;this.points[3]=this.getNextKeyWith("pos",z,m.index+1).pos;g=g*0.33+0.33;f=this.interpolateCatmullRom(this.points,g);d.x=f[0];d.y=f[1];d.z=f[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){g=this.interpolateCatmullRom(this.points,g*1.01);this.target.set(g[0],g[1],g[2]);this.target.subSelf(d);this.target.y=0;this.target.normalize();g=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,g,0)}}}else if(d=== +"rot")THREE.Quaternion.slerp(f,h,a.quaternion,g);else if(d==="scl"){d=a.scale;d.x=f[0]+(h[0]-f[0])*g;d.y=f[1]+(h[1]-f[1])*g;d.z=f[2]+(h[2]-f[2])*g}}}}if(this.JITCompile&&x[0][t]===undefined){this.hierarchy[0].update(undefined,!0);for(z=0;za.length-2?h:h+1;d[3]=h>a.length-3?h:h+2;h=a[d[0]];m=a[d[1]];o=a[d[2]];t=a[d[3]];d=f*f;i=f*d;g[0]=this.interpolate(h[0],m[0],o[0],t[0],f,d,i);g[1]=this.interpolate(h[1],m[1],o[1],t[1],f,d,i);g[2]=this.interpolate(h[2],m[2],o[2],t[2],f,d,i);return g}; +THREE.Animation.prototype.interpolate=function(a,c,d,g,f,h,i){a=(d-a)*0.5;g=(g-c)*0.5;return(2*(c-d)+a+g)*i+(-3*(c-d)-2*a-g)*h+a*f+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,d){var g=this.data.hierarchy[c].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=d0?d:0:d>=0?d:d+g.length;d>=0;d--)if(g[d][a]!==undefined)return g[d];return this.data.hierarchy[c].keys[g.length-1]}; +THREE.Camera=function(a,c,d,g,f){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=d||0.1;this.far=g||2E3;this.target=f||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype; +THREE.Camera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)}; +THREE.Camera.prototype.update=function(a,c,d){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);c=!0}else{this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate= +!1;c=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a1){a=c.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var f=1;f=this.LODs[f].visibleAtDistance){this.LODs[f-1].object3D.visible= -!1;this.LODs[f].object3D.visible=!0}else break;for(;f=0&&qa>=0&&V>=0&&ha>=0)return!0;else if(Da<0&&qa<0||V<0&&ha<0)return!1;else{if(Da<0)pa=Math.max(pa,Da/(Da-qa));else qa<0&&(ya=Math.min(ya,Da/(Da-qa)));if(V<0)pa=Math.max(pa,V/(V-ha));else ha<0&&(ya=Math.min(ya,V/(V-ha)));if(yaDa&&j.positionScreen.z0&&U.z<1){Na=ma[ja]=ma[ja]||new THREE.RenderableParticle;ja++;L=Na;L.x=U.x/U.w;L.y=U.y/U.w;L.z=U.z;L.rotation=la.rotation.z;L.scale.x=la.scale.x*Math.abs(L.x-(U.x+N.projectionMatrix.n11)/(U.w+N.projectionMatrix.n14));L.scale.y=la.scale.y*Math.abs(L.y-(U.y+N.projectionMatrix.n22)/(U.w+N.projectionMatrix.n24));L.materials=la.materials;ya.push(L)}}}}pa&&ya.sort(b);return ya}}; -THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,c){c&&a.update(undefined,!1,b);c=a.sounds;var f,e=c.length;for(f=0;f1){a=d.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var g=1;g=this.LODs[g].visibleAtDistance){this.LODs[g-1].object3D.visible= +!1;this.LODs[g].object3D.visible=!0}else break;for(;g=0&&sa>=0&&T>=0&&ga>=0)return!0;else if(Ba<0&&sa<0||T<0&&ga<0)return!1;else{if(Ba<0)pa=Math.max(pa,Ba/(Ba-sa));else sa<0&&(Aa=Math.min(Aa,Ba/(Ba-sa)));if(T<0)pa=Math.max(pa,T/(T-ga));else ga<0&&(Aa=Math.min(Aa,T/(T-ga)));if(AaBa&&i.positionScreen.z0&&S.z<1){Ea=la[ia]=la[ia]||new THREE.RenderableParticle;ia++;K=Ea;K.x=S.x/S.w;K.y=S.y/S.w;K.z=S.z;K.rotation=na.rotation.z;K.scale.x=na.scale.x*Math.abs(K.x-(S.x+N.projectionMatrix.n11)/(S.w+N.projectionMatrix.n14));K.scale.y=na.scale.y*Math.abs(K.y-(S.y+N.projectionMatrix.n22)/(S.w+N.projectionMatrix.n24));K.materials=na.materials;Aa.push(K)}}}}pa&&Aa.sort(c);return Aa}}; +THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,c,d){d&&a.update(undefined,!1,c);d=a.sounds;var g,f=d.length;for(g=0;gD){w=v;D=r[w]}d.bindBuffer(d.ARRAY_BUFFER,k.__webGLMorphTargetsBuffers[w]);d.vertexAttribPointer(m["morphTarget"+o],3,d.FLOAT,!1,0,0);t.__webGLMorphTargetInfluences[o]=D;q[w]=1;D=-1;o++}}d.uniform1fv(i.program.uniforms.morphTargetInfluences, -t.__webGLMorphTargetInfluences)}else{d.bindBuffer(d.ARRAY_BUFFER,k.__webGLVertexBuffer);d.vertexAttribPointer(g.position,3,d.FLOAT,!1,0,0)}if(g.color>=0){d.bindBuffer(d.ARRAY_BUFFER,k.__webGLColorBuffer);d.vertexAttribPointer(g.color,3,d.FLOAT,!1,0,0)}if(g.normal>=0){d.bindBuffer(d.ARRAY_BUFFER,k.__webGLNormalBuffer);d.vertexAttribPointer(g.normal,3,d.FLOAT,!1,0,0)}if(g.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,k.__webGLTangentBuffer);d.vertexAttribPointer(g.tangent,4,d.FLOAT,!1,0,0)}if(g.uv>=0)if(k.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER, -k.__webGLUVBuffer);d.vertexAttribPointer(g.uv,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(g.uv)}else d.disableVertexAttribArray(g.uv);if(g.uv2>=0)if(k.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,k.__webGLUV2Buffer);d.vertexAttribPointer(g.uv2,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(g.uv2)}else d.disableVertexAttribArray(g.uv2);if(i.skinning&&g.skinVertexA>=0&&g.skinVertexB>=0&&g.skinIndex>=0&&g.skinWeight>=0){d.bindBuffer(d.ARRAY_BUFFER,k.__webGLSkinVertexABuffer);d.vertexAttribPointer(g.skinVertexA, -4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,k.__webGLSkinVertexBBuffer);d.vertexAttribPointer(g.skinVertexB,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,k.__webGLSkinIndicesBuffer);d.vertexAttribPointer(g.skinIndex,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,k.__webGLSkinWeightsBuffer);d.vertexAttribPointer(g.skinWeight,4,d.FLOAT,!1,0,0)}if(t instanceof THREE.Mesh)if(i.wireframe){d.lineWidth(i.wireframeLinewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,k.__webGLLineBuffer);d.drawElements(d.LINES, -k.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,k.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,k.__webGLFaceCount,d.UNSIGNED_SHORT,0)}else if(t instanceof THREE.Line){t=t.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(i.linewidth);d.drawArrays(t,0,k.__webGLLineCount)}else if(t instanceof THREE.ParticleSystem)d.drawArrays(d.POINTS,0,k.__webGLParticleCount);else t instanceof THREE.Ribbon&&d.drawArrays(d.TRIANGLE_STRIP,0,k.__webGLVertexCount)}}function h(g,m){if(!g.__webGLVertexBuffer)g.__webGLVertexBuffer= -d.createBuffer();if(!g.__webGLNormalBuffer)g.__webGLNormalBuffer=d.createBuffer();if(g.hasPos){d.bindBuffer(d.ARRAY_BUFFER,g.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,g.positionArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(m.attributes.position);d.vertexAttribPointer(m.attributes.position,3,d.FLOAT,!1,0,0)}if(g.hasNormal){d.bindBuffer(d.ARRAY_BUFFER,g.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,g.normalArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(m.attributes.normal);d.vertexAttribPointer(m.attributes.normal, -3,d.FLOAT,!1,0,0)}d.drawArrays(d.TRIANGLES,0,g.count);g.count=0}function j(g){if(N!=g.doubleSided){g.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE);N=g.doubleSided}if(pa!=g.flipSided){g.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW);pa=g.flipSided}}function p(g){if(Da!=g){g?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST);Da=g}}function n(g){W[0].set(g.n41-g.n11,g.n42-g.n12,g.n43-g.n13,g.n44-g.n14);W[1].set(g.n41+g.n11,g.n42+g.n12,g.n43+g.n13,g.n44+g.n14);W[2].set(g.n41+g.n21,g.n42+g.n22, -g.n43+g.n23,g.n44+g.n24);W[3].set(g.n41-g.n21,g.n42-g.n22,g.n43-g.n23,g.n44-g.n24);W[4].set(g.n41-g.n31,g.n42-g.n32,g.n43-g.n33,g.n44-g.n34);W[5].set(g.n41+g.n31,g.n42+g.n32,g.n43+g.n33,g.n44+g.n34);var m;for(g=0;g<6;g++){m=W[g];m.divideScalar(Math.sqrt(m.x*m.x+m.y*m.y+m.z*m.z))}}function s(g){for(var m=g.matrixWorld,o=-g.geometry.boundingSphere.radius*Math.max(g.scale.x,Math.max(g.scale.y,g.scale.z)),i=0;i<6;i++){g=W[i].x*m.n14+W[i].y*m.n24+W[i].z*m.n34+W[i].w;if(g<=o)return!1}return!0}function x(g, -m){g.list[g.count]=m;g.count+=1}function z(g){var m,o,i=g.object,k=g.opaque,t=g.transparent;t.count=0;g=k.count=0;for(m=i.materials.length;g65535){v[D].counter+=1;w=v[D].hash+"_"+v[D].counter;g.geometryGroups[w]==undefined&&(g.geometryGroups[w]= -{faces:[],materials:r,vertices:0,numMorphTargets:M})}g.geometryGroups[w].faces.push(k);g.geometryGroups[w].vertices+=q}}function P(g,m,o){g.push({buffer:m,object:o,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function L(g){if(g!=ya){switch(g){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE);break;case THREE.SubtractiveBlending:d.blendFunc(d.DST_COLOR,d.ZERO);break;case THREE.BillboardBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA); -break;case THREE.ReverseSubtractiveBlending:d.blendEquation(d.FUNC_REVERSE_SUBTRACT);d.blendFunc(d.ONE,d.ONE);break;default:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA)}ya=g}}function ja(g,m,o){if((o.width&o.width-1)==0&&(o.height&o.height-1)==0){d.texParameteri(g,d.TEXTURE_WRAP_S,A(m.wrapS));d.texParameteri(g,d.TEXTURE_WRAP_T,A(m.wrapT));d.texParameteri(g,d.TEXTURE_MAG_FILTER,A(m.magFilter));d.texParameteri(g,d.TEXTURE_MIN_FILTER,A(m.minFilter));d.generateMipmap(g)}else{d.texParameteri(g, -d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE);d.texParameteri(g,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE);d.texParameteri(g,d.TEXTURE_MAG_FILTER,U(m.magFilter));d.texParameteri(g,d.TEXTURE_MIN_FILTER,U(m.minFilter))}}function ma(g){if(g&&!g.__webGLFramebuffer){g.__webGLFramebuffer=d.createFramebuffer();g.__webGLRenderbuffer=d.createRenderbuffer();g.__webGLTexture=d.createTexture();d.bindRenderbuffer(d.RENDERBUFFER,g.__webGLRenderbuffer);d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,g.width,g.height);d.bindTexture(d.TEXTURE_2D, -g.__webGLTexture);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,A(g.wrapS));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,A(g.wrapT));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,A(g.magFilter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,A(g.minFilter));d.texImage2D(d.TEXTURE_2D,0,A(g.format),g.width,g.height,0,A(g.format),A(g.type),null);d.bindFramebuffer(d.FRAMEBUFFER,g.__webGLFramebuffer);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,g.__webGLTexture,0);d.framebufferRenderbuffer(d.FRAMEBUFFER, -d.DEPTH_ATTACHMENT,d.RENDERBUFFER,g.__webGLRenderbuffer);d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,null)}var m,o;if(g){m=g.__webGLFramebuffer;o=g.width;g=g.height}else{m=null;o=ha;g=ia}if(m!=Ca){d.bindFramebuffer(d.FRAMEBUFFER,m);d.viewport(qa,V,o,g);Ca=m}}function sa(g,m){var o;if(g=="fragment")o=d.createShader(d.FRAGMENT_SHADER);else g=="vertex"&&(o=d.createShader(d.VERTEX_SHADER));d.shaderSource(o,m);d.compileShader(o);if(!d.getShaderParameter(o, -d.COMPILE_STATUS)){console.error(d.getShaderInfoLog(o));console.error(m);return null}return o}function U(g){switch(g){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return d.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return d.LINEAR}}function A(g){switch(g){case THREE.RepeatWrapping:return d.REPEAT;case THREE.ClampToEdgeWrapping:return d.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return d.MIRRORED_REPEAT; -case THREE.NearestFilter:return d.NEAREST;case THREE.NearestMipMapNearestFilter:return d.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return d.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return d.LINEAR;case THREE.LinearMipMapNearestFilter:return d.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return d.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return d.BYTE;case THREE.UnsignedByteType:return d.UNSIGNED_BYTE;case THREE.ShortType:return d.SHORT;case THREE.UnsignedShortType:return d.UNSIGNED_SHORT; -case THREE.IntType:return d.INT;case THREE.UnsignedShortType:return d.UNSIGNED_INT;case THREE.FloatType:return d.FLOAT;case THREE.AlphaFormat:return d.ALPHA;case THREE.RGBFormat:return d.RGB;case THREE.RGBAFormat:return d.RGBA;case THREE.LuminanceFormat:return d.LUMINANCE;case THREE.LuminanceAlphaFormat:return d.LUMINANCE_ALPHA}return 0}var oa=document.createElement("canvas"),d,Ba=null,Ca=null,Q=this,N=null,pa=null,ya=null,Da=null,qa=0,V=0,ha=0,ia=0,W=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4, -new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],S=new THREE.Matrix4,ta=new Float32Array(16),ka=new Float32Array(16),za=new THREE.Vector4,La={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},la=!0,Na=new THREE.Color(0),Wa=0;if(a){if(a.antialias!==undefined)la=a.antialias;a.clearColor!==undefined&&Na.setHex(a.clearColor);if(a.clearAlpha!==undefined)Wa=a.clearAlpha}this.maxMorphTargets=8;this.domElement=oa;this.autoClear=!0;this.sortObjects= -!0;(function(g,m,o){try{if(!(d=oa.getContext("experimental-webgl",{antialias:g})))throw"Error creating WebGL context.";}catch(i){console.error(i)}d.clearColor(0,0,0,1);d.clearDepth(1);d.enable(d.DEPTH_TEST);d.depthFunc(d.LEQUAL);d.frontFace(d.CCW);d.cullFace(d.BACK);d.enable(d.CULL_FACE);d.enable(d.BLEND);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA);d.clearColor(m.r,m.g,m.b,o);_cullEnabled=!0})(la,Na,Wa);this.context=d;this.setSize=function(g,m){oa.width=g;oa.height=m;this.setViewport(0,0,oa.width,oa.height)}; -this.setViewport=function(g,m,o,i){qa=g;V=m;ha=o;ia=i;d.viewport(qa,V,ha,ia)};this.setScissor=function(g,m,o,i){d.scissor(g,m,o,i)};this.enableScissorTest=function(g){g?d.enable(d.SCISSOR_TEST):d.disable(d.SCISSOR_TEST)};this.enableDepthBufferWrite=function(g){d.depthMask(g)};this.setClearColorHex=function(g,m){var o=new THREE.Color(g);d.clearColor(o.r,o.g,o.b,m)};this.setClearColor=function(g,m){d.clearColor(g.r,g.g,g.b,m)};this.clear=function(){d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT)};this.initMaterial= -function(g,m,o,i){var k,t,q;if(g instanceof THREE.MeshDepthMaterial)c(g,THREE.ShaderLib.depth);else if(g instanceof THREE.MeshNormalMaterial)c(g,THREE.ShaderLib.normal);else if(g instanceof THREE.MeshBasicMaterial)c(g,THREE.ShaderLib.basic);else if(g instanceof THREE.MeshLambertMaterial)c(g,THREE.ShaderLib.lambert);else if(g instanceof THREE.MeshPhongMaterial)c(g,THREE.ShaderLib.phong);else if(g instanceof THREE.LineBasicMaterial)c(g,THREE.ShaderLib.basic);else g instanceof THREE.ParticleBasicMaterial&& -c(g,THREE.ShaderLib.particle_basic);var r,D,w,v;q=w=v=0;for(r=m.length;q0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+r.maxDirLights,"#define MAX_POINT_LIGHTS "+r.maxPointLights,"#define MAX_BONES "+r.maxBones,r.map?"#define USE_MAP":"",r.envMap?"#define USE_ENVMAP":"",r.lightMap?"#define USE_LIGHTMAP":"",r.vertexColors?"#define USE_COLOR":"",r.skinning?"#define USE_SKINNING":"",r.morphTargets?"#define USE_MORPHTARGETS":"",r.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); -d.attachShader(o,sa("fragment",q+v));d.attachShader(o,sa("vertex",r+m));d.linkProgram(o);d.getProgramParameter(o,d.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+d.getProgramParameter(o,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");o.uniforms={};o.attributes={};g.program=o;o=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(k in g.uniforms)o.push(k); -k=g.program;v=0;for(m=o.length;v=0&&d.enableVertexAttribArray(t.color);t.normal>=0&&d.enableVertexAttribArray(t.normal); -t.tangent>=0&&d.enableVertexAttribArray(t.tangent);if(g.skinning&&t.skinVertexA>=0&&t.skinVertexB>=0&&t.skinIndex>=0&&t.skinWeight>=0){d.enableVertexAttribArray(t.skinVertexA);d.enableVertexAttribArray(t.skinVertexB);d.enableVertexAttribArray(t.skinIndex);d.enableVertexAttribArray(t.skinWeight)}if(g.morphTargets){g.numSupportedMorphTargets=0;if(t.morphTarget0>=0){d.enableVertexAttribArray(t.morphTarget0);g.numSupportedMorphTargets++}if(t.morphTarget1>=0){d.enableVertexAttribArray(t.morphTarget1); -g.numSupportedMorphTargets++}if(t.morphTarget2>=0){d.enableVertexAttribArray(t.morphTarget2);g.numSupportedMorphTargets++}if(t.morphTarget3>=0){d.enableVertexAttribArray(t.morphTarget3);g.numSupportedMorphTargets++}if(t.morphTarget4>=0){d.enableVertexAttribArray(t.morphTarget4);g.numSupportedMorphTargets++}if(t.morphTarget5>=0){d.enableVertexAttribArray(t.morphTarget5);g.numSupportedMorphTargets++}if(t.morphTarget6>=0){d.enableVertexAttribArray(t.morphTarget6);g.numSupportedMorphTargets++}if(t.morphTarget7>= -0){d.enableVertexAttribArray(t.morphTarget7);g.numSupportedMorphTargets++}i.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(k=0;k0||R.faceVertexUvs.length>0)q.__uvArray=new Float32Array(r*2);if(R.faceUvs.length>1||R.faceVertexUvs.length> -1)q.__uv2Array=new Float32Array(r*2)}if(w.geometry.skinWeights.length&&w.geometry.skinIndices.length){q.__skinVertexAArray=new Float32Array(r*4);q.__skinVertexBArray=new Float32Array(r*4);q.__skinIndexArray=new Float32Array(r*4);q.__skinWeightArray=new Float32Array(r*4)}q.__faceArray=new Uint16Array(D*3);q.__lineArray=new Uint16Array(X*2);if(q.numMorphTargets){w=void 0;R=void 0;q.__morphTargetsArrays=[];w=0;for(R=q.numMorphTargets;w=0;k--){i=o.__webglObjects[k].object;m==i&&o.__webglObjects.splice(k,1)}g.__objectsRemoved.splice(0,1)}m=0;for(o=g.__webglObjects.length;m0){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,xa,r)}if(db){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,Ma,r)}if(eb&&Fa.hasTangents){d.bindBuffer(d.ARRAY_BUFFER, -q.__webGLTangentBuffer);d.bufferData(d.ARRAY_BUFFER,ca,r)}if(Ya&&Z>0){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLUVBuffer);d.bufferData(d.ARRAY_BUFFER,Za,r)}if(Ya&&Ga>0){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,$a,r)}if(cb){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,Pa,r);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,Ka,r)}if(u>0){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLSkinVertexABuffer); -d.bufferData(d.ARRAY_BUFFER,da,r);d.bindBuffer(d.ARRAY_BUFFER,q.__webGLSkinVertexBBuffer);d.bufferData(d.ARRAY_BUFFER,ea,r);d.bindBuffer(d.ARRAY_BUFFER,q.__webGLSkinIndicesBuffer);d.bufferData(d.ARRAY_BUFFER,fa,r);d.bindBuffer(d.ARRAY_BUFFER,q.__webGLSkinWeightsBuffer);d.bufferData(d.ARRAY_BUFFER,ga,r)}}}k.__dirtyVertices=!1;k.__dirtyMorphTargets=!1;k.__dirtyElements=!1;k.__dirtyUvs=!1;k.__dirtyNormals=!1;k.__dirtyTangents=!1;k.__dirtyColors=!1}else if(i instanceof THREE.Ribbon){k=i.geometry;if(k.__dirtyVertices|| -k.__dirtyColors){i=k;t=d.DYNAMIC_DRAW;w=void 0;w=void 0;R=void 0;q=void 0;v=i.vertices;r=i.colors;M=v.length;D=r.length;G=i.__vertexArray;X=i.__colorArray;H=i.__dirtyColors;if(i.__dirtyVertices){for(w=0;w0}}; +THREE.WebGLRenderer=function(a){function c(e,p,n){var j,q,s,v=e.vertices,r=v.length,k=e.colors,A=k.length,u=e.__vertexArray,G=e.__colorArray,F=e.__sortArray,L=e.__dirtyVertices,M=e.__dirtyColors;if(n.sortParticles){ma.multiplySelf(n.matrixWorld);for(j=0;jk){A=u;k=r[A]}b.bindBuffer(b.ARRAY_BUFFER,q.__webGLMorphTargetsBuffers[A]);b.vertexAttribPointer(p["morphTarget"+n],3,b.FLOAT,!1,0,0);s.__webGLMorphTargetInfluences[n]=k;v[A]=1;k=-1;n++}}b.uniform1fv(j.program.uniforms.morphTargetInfluences,s.__webGLMorphTargetInfluences)}else{b.bindBuffer(b.ARRAY_BUFFER,q.__webGLVertexBuffer);b.vertexAttribPointer(e.position,3,b.FLOAT,!1,0,0)}if(e.color>=0){b.bindBuffer(b.ARRAY_BUFFER,q.__webGLColorBuffer); +b.vertexAttribPointer(e.color,3,b.FLOAT,!1,0,0)}if(e.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,q.__webGLNormalBuffer);b.vertexAttribPointer(e.normal,3,b.FLOAT,!1,0,0)}if(e.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,q.__webGLTangentBuffer);b.vertexAttribPointer(e.tangent,4,b.FLOAT,!1,0,0)}if(e.uv>=0)if(q.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,q.__webGLUVBuffer);b.vertexAttribPointer(e.uv,2,b.FLOAT,!1,0,0);b.enableVertexAttribArray(e.uv)}else b.disableVertexAttribArray(e.uv);if(e.uv2>=0)if(q.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER, +q.__webGLUV2Buffer);b.vertexAttribPointer(e.uv2,2,b.FLOAT,!1,0,0);b.enableVertexAttribArray(e.uv2)}else b.disableVertexAttribArray(e.uv2);if(j.skinning&&e.skinVertexA>=0&&e.skinVertexB>=0&&e.skinIndex>=0&&e.skinWeight>=0){b.bindBuffer(b.ARRAY_BUFFER,q.__webGLSkinVertexABuffer);b.vertexAttribPointer(e.skinVertexA,4,b.FLOAT,!1,0,0);b.bindBuffer(b.ARRAY_BUFFER,q.__webGLSkinVertexBBuffer);b.vertexAttribPointer(e.skinVertexB,4,b.FLOAT,!1,0,0);b.bindBuffer(b.ARRAY_BUFFER,q.__webGLSkinIndicesBuffer);b.vertexAttribPointer(e.skinIndex, +4,b.FLOAT,!1,0,0);b.bindBuffer(b.ARRAY_BUFFER,q.__webGLSkinWeightsBuffer);b.vertexAttribPointer(e.skinWeight,4,b.FLOAT,!1,0,0)}if(s instanceof THREE.Mesh)if(j.wireframe){b.lineWidth(j.wireframeLinewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);b.drawElements(b.LINES,q.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,q.__webGLFaceCount,b.UNSIGNED_SHORT,0)}else if(s instanceof THREE.Line){s=s.type==THREE.LineStrip? +b.LINE_STRIP:b.LINES;b.lineWidth(j.linewidth);b.drawArrays(s,0,q.__webGLLineCount)}else if(s instanceof THREE.ParticleSystem)b.drawArrays(b.POINTS,0,q.__webGLParticleCount);else s instanceof THREE.Ribbon&&b.drawArrays(b.TRIANGLE_STRIP,0,q.__webGLVertexCount)}}function h(e,p){if(!e.__webGLVertexBuffer)e.__webGLVertexBuffer=b.createBuffer();if(!e.__webGLNormalBuffer)e.__webGLNormalBuffer=b.createBuffer();if(e.hasPos){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,e.positionArray, +b.DYNAMIC_DRAW);b.enableVertexAttribArray(p.attributes.position);b.vertexAttribPointer(p.attributes.position,3,b.FLOAT,!1,0,0)}if(e.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,e.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(p.attributes.normal);b.vertexAttribPointer(p.attributes.normal,3,b.FLOAT,!1,0,0)}b.drawArrays(b.TRIANGLES,0,e.count);e.count=0}function i(e){if(pa!=e.doubleSided){e.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);pa= +e.doubleSided}if(Aa!=e.flipSided){e.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);Aa=e.flipSided}}function m(e){if(sa!=e){e?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST);sa=e}}function o(e){O[0].set(e.n41-e.n11,e.n42-e.n12,e.n43-e.n13,e.n44-e.n14);O[1].set(e.n41+e.n11,e.n42+e.n12,e.n43+e.n13,e.n44+e.n14);O[2].set(e.n41+e.n21,e.n42+e.n22,e.n43+e.n23,e.n44+e.n24);O[3].set(e.n41-e.n21,e.n42-e.n22,e.n43-e.n23,e.n44-e.n24);O[4].set(e.n41-e.n31,e.n42-e.n32,e.n43-e.n33,e.n44-e.n34);O[5].set(e.n41+e.n31, +e.n42+e.n32,e.n43+e.n33,e.n44+e.n34);var p;for(e=0;e<6;e++){p=O[e];p.divideScalar(Math.sqrt(p.x*p.x+p.y*p.y+p.z*p.z))}}function t(e){for(var p=e.matrixWorld,n=-e.geometry.boundingSphere.radius*Math.max(e.scale.x,Math.max(e.scale.y,e.scale.z)),j=0;j<6;j++){e=O[j].x*p.n14+O[j].y*p.n24+O[j].z*p.n34+O[j].w;if(e<=n)return!1}return!0}function x(e,p){e.list[e.count]=p;e.count+=1}function y(e){var p,n,j=e.object,q=e.opaque,s=e.transparent;s.count=0;e=q.count=0;for(p=j.materials.length;e0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,za,q)}if(db){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,La,q)}if(eb&&Da.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLTangentBuffer); +b.bufferData(b.ARRAY_BUFFER,$,q)}if(Xa&&Qa>0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,Za,q)}if(Xa&&Ra>0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,$a,q)}if(cb){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Ja,q);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Ka,q)}if(w>0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLSkinVertexABuffer);b.bufferData(b.ARRAY_BUFFER, +aa,q);b.bindBuffer(b.ARRAY_BUFFER,j.__webGLSkinVertexBBuffer);b.bufferData(b.ARRAY_BUFFER,ca,q);b.bindBuffer(b.ARRAY_BUFFER,j.__webGLSkinIndicesBuffer);b.bufferData(b.ARRAY_BUFFER,da,q);b.bindBuffer(b.ARRAY_BUFFER,j.__webGLSkinWeightsBuffer);b.bufferData(b.ARRAY_BUFFER,ea,q)}}}n.__dirtyVertices=!1;n.__dirtyMorphTargets=!1;n.__dirtyElements=!1;n.__dirtyUvs=!1;n.__dirtyNormals=!1;n.__dirtyTangents=!1;n.__dirtyColors=!1}else if(e instanceof THREE.Ribbon){n=e.geometry;if(n.__dirtyVertices||n.__dirtyColors){e= +n;p=b.DYNAMIC_DRAW;V=e.vertices;q=e.colors;P=V.length;s=q.length;U=e.__vertexArray;v=e.__colorArray;Z=e.__dirtyColors;if(e.__dirtyVertices){for(L=0;L65535){u[k].counter+=1;A=u[k].hash+"_"+u[k].counter;e.geometryGroups[A]==undefined&&(e.geometryGroups[A]={faces:[],materials:r,vertices:0,numMorphTargets:G})}e.geometryGroups[A].faces.push(q);e.geometryGroups[A].vertices+=v}}function K(e,p, +n){e.push({buffer:p,object:n,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function ia(e){if(e!=Ba){switch(e){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:b.blendEquation(b.FUNC_REVERSE_SUBTRACT);b.blendFunc(b.ONE,b.ONE);break;default:b.blendEquation(b.FUNC_ADD); +b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}Ba=e}}function la(e,p,n){if((n.width&n.width-1)==0&&(n.height&n.height-1)==0){b.texParameteri(e,b.TEXTURE_WRAP_S,fa(p.wrapS));b.texParameteri(e,b.TEXTURE_WRAP_T,fa(p.wrapT));b.texParameteri(e,b.TEXTURE_MAG_FILTER,fa(p.magFilter));b.texParameteri(e,b.TEXTURE_MIN_FILTER,fa(p.minFilter));b.generateMipmap(e)}else{b.texParameteri(e,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(e,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(e,b.TEXTURE_MAG_FILTER,E(p.magFilter)); +b.texParameteri(e,b.TEXTURE_MIN_FILTER,E(p.minFilter))}}function wa(e){if(e&&!e.__webGLFramebuffer){e.__webGLFramebuffer=b.createFramebuffer();e.__webGLRenderbuffer=b.createRenderbuffer();e.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,e.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,e.width,e.height);b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,fa(e.wrapS));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T, +fa(e.wrapT));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,fa(e.magFilter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,fa(e.minFilter));b.texImage2D(b.TEXTURE_2D,0,fa(e.format),e.width,e.height,0,fa(e.format),fa(e.type),null);b.bindFramebuffer(b.FRAMEBUFFER,e.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,e.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,e.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D, +null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}var p,n;if(e){p=e.__webGLFramebuffer;n=e.width;e=e.height}else{p=null;n=ha;e=ja}if(p!=R){b.bindFramebuffer(b.FRAMEBUFFER,p);b.viewport(T,ga,n,e);R=p}}function S(e,p){var n;if(e=="fragment")n=b.createShader(b.FRAGMENT_SHADER);else e=="vertex"&&(n=b.createShader(b.VERTEX_SHADER));b.shaderSource(n,p);b.compileShader(n);if(!b.getShaderParameter(n,b.COMPILE_STATUS)){console.error(b.getShaderInfoLog(n));console.error(p); +return null}return n}function E(e){switch(e){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return b.NEAREST;default:return b.LINEAR}}function fa(e){switch(e){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR; +case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA; +case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var Y=document.createElement("canvas"),b,ra=null,R=null,N=this,pa=null,Aa=null,Ba=null,sa=null,T=0,ga=0,ha=0,ja=0,O=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ma=new THREE.Matrix4,ka=new Float32Array(16),Ca=new Float32Array(16),Fa=new THREE.Vector4,na= +{ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},Ea=!0,Wa=new THREE.Color(0),Ya=0;if(a){if(a.antialias!==undefined)Ea=a.antialias;a.clearColor!==undefined&&Wa.setHex(a.clearColor);if(a.clearAlpha!==undefined)Ya=a.clearAlpha}this.maxMorphTargets=8;this.domElement=Y;this.autoClear=!0;this.sortObjects=!0;(function(e,p,n){try{if(!(b=Y.getContext("experimental-webgl",{antialias:e,stencil:!0})))throw"Error creating WebGL context.";}catch(j){console.error(j)}b.clearColor(0, +0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(p.r,p.g,p.b,n)})(Ea,Wa,Ya);this.context=b;var xa={};a=[];Ea=[];a[0]=-2;a[1]=-1;a[2]=-1;a[3]=2;a[4]=-1;a[5]=-1;a[6]=2;a[7]=1;a[8]=-1;a[9]=-2;a[10]=1;a[11]=-1;Ea[0]=0;Ea[1]=1;Ea[2]=2;Ea[3]=0;Ea[4]=2;Ea[5]=3;xa.vertexBuffer=b.createBuffer();xa.elementBuffer=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,xa.vertexBuffer); +b.bufferData(b.ARRAY_BUFFER,new Float32Array(a),b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,xa.elementBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,new Uint16Array(Ea),b.STATIC_DRAW);xa.program=b.createProgram();b.attachShader(xa.program,S("fragment",THREE.ShaderLib.shadowPost.fragmentShader));b.attachShader(xa.program,S("vertex",THREE.ShaderLib.shadowPost.vertexShader));b.linkProgram(xa.program);xa.vertexLocation=b.getAttribLocation(xa.program,"position");xa.projectionLocation=b.getUniformLocation(xa.program, +"projectionMatrix");this.setSize=function(e,p){Y.width=e;Y.height=p;this.setViewport(0,0,Y.width,Y.height)};this.setViewport=function(e,p,n,j){T=e;ga=p;ha=n;ja=j;b.viewport(T,ga,ha,ja)};this.setScissor=function(e,p,n,j){b.scissor(e,p,n,j)};this.enableScissorTest=function(e){e?b.enable(b.SCISSOR_TEST):b.disable(b.SCISSOR_TEST)};this.enableDepthBufferWrite=function(e){b.depthMask(e)};this.setClearColorHex=function(e,p){var n=new THREE.Color(e);b.clearColor(n.r,n.g,n.b,p)};this.setClearColor=function(e, +p){b.clearColor(e.r,e.g,e.b,p)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT|b.STENCIL_BUFFER_BIT)};this.initMaterial=function(e,p,n,j){var q,s,v,r;if(e instanceof THREE.MeshDepthMaterial)d(e,THREE.ShaderLib.depth);else if(e instanceof THREE.ShadowVolumeDynamicMaterial)d(e,THREE.ShaderLib.shadowVolumeDynamic);else if(e instanceof THREE.MeshNormalMaterial)d(e,THREE.ShaderLib.normal);else if(e instanceof THREE.MeshBasicMaterial)d(e,THREE.ShaderLib.basic);else if(e instanceof THREE.MeshLambertMaterial)d(e, +THREE.ShaderLib.lambert);else if(e instanceof THREE.MeshPhongMaterial)d(e,THREE.ShaderLib.phong);else if(e instanceof THREE.LineBasicMaterial)d(e,THREE.ShaderLib.basic);else e instanceof THREE.ParticleBasicMaterial&&d(e,THREE.ShaderLib.particle_basic);if(!e.program){var k,A,u;k=u=r=0;for(v=p.length;k0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+v.maxDirLights,"#define MAX_POINT_LIGHTS "+v.maxPointLights,"#define MAX_BONES "+v.maxBones,v.map?"#define USE_MAP":"",v.envMap?"#define USE_ENVMAP":"",v.lightMap?"#define USE_LIGHTMAP": +"",v.vertexColors?"#define USE_COLOR":"",v.skinning?"#define USE_SKINNING":"",v.morphTargets?"#define USE_MORPHTARGETS":"",v.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); +b.attachShader(p,S("fragment",k+n));b.attachShader(p,S("vertex",v+r));b.linkProgram(p);b.getProgramParameter(p,b.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+b.getProgramParameter(p,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");p.uniforms={};p.attributes={};e.program=p;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(q in e.uniforms)n.push(q); +q=e.program;r=0;for(p=n.length;r=0&&b.enableVertexAttribArray(s.color);s.normal>=0&&b.enableVertexAttribArray(s.normal); +s.tangent>=0&&b.enableVertexAttribArray(s.tangent);if(e.skinning&&s.skinVertexA>=0&&s.skinVertexB>=0&&s.skinIndex>=0&&s.skinWeight>=0){b.enableVertexAttribArray(s.skinVertexA);b.enableVertexAttribArray(s.skinVertexB);b.enableVertexAttribArray(s.skinIndex);b.enableVertexAttribArray(s.skinWeight)}if(e.morphTargets){e.numSupportedMorphTargets=0;if(s.morphTarget0>=0){b.enableVertexAttribArray(s.morphTarget0);e.numSupportedMorphTargets++}if(s.morphTarget1>=0){b.enableVertexAttribArray(s.morphTarget1); +e.numSupportedMorphTargets++}if(s.morphTarget2>=0){b.enableVertexAttribArray(s.morphTarget2);e.numSupportedMorphTargets++}if(s.morphTarget3>=0){b.enableVertexAttribArray(s.morphTarget3);e.numSupportedMorphTargets++}if(s.morphTarget4>=0){b.enableVertexAttribArray(s.morphTarget4);e.numSupportedMorphTargets++}if(s.morphTarget5>=0){b.enableVertexAttribArray(s.morphTarget5);e.numSupportedMorphTargets++}if(s.morphTarget6>=0){b.enableVertexAttribArray(s.morphTarget6);e.numSupportedMorphTargets++}if(s.morphTarget7>= +0){b.enableVertexAttribArray(s.morphTarget7);e.numSupportedMorphTargets++}j.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(q=0;q0||V.faceVertexUvs.length>0)v.__uvArray= +new Float32Array(k*2);if(V.faceUvs.length>1||V.faceVertexUvs.length>1)v.__uv2Array=new Float32Array(k*2)}if(r.geometry.skinWeights.length&&r.geometry.skinIndices.length){v.__skinVertexAArray=new Float32Array(k*4);v.__skinVertexBArray=new Float32Array(k*4);v.__skinIndexArray=new Float32Array(k*4);v.__skinWeightArray=new Float32Array(k*4)}v.__faceArray=new Uint16Array(F*3+(r.geometry.edgeFaces?r.geometry.edgeFaces.length*6:0));v.__lineArray=new Uint16Array(L*2);if(v.numMorphTargets){V=void 0;P=void 0; +v.__morphTargetsArrays=[];V=0;for(P=v.numMorphTargets;V=0;q--){j=n.__webglObjects[q].object;p==j&&n.__webglObjects.splice(q,1)}e.__objectsRemoved.splice(0,1)}p=0;for(n=e.__webglObjects.length;p< +n;p++)J(e.__webglObjects[p].object,e);p=0;for(n=e.__webglShadowVolumes.length;p0}}; diff --git a/examples/misc_ubiquity_test.html b/examples/misc_ubiquity_test.html index 7e958f14..b5fbac13 100644 --- a/examples/misc_ubiquity_test.html +++ b/examples/misc_ubiquity_test.html @@ -51,6 +51,7 @@ + @@ -66,6 +67,7 @@ + @@ -97,6 +99,8 @@ + + diff --git a/examples/webgl_geometry_minecraft.html b/examples/webgl_geometry_minecraft.html index 505a2786..e5f4e57a 100644 --- a/examples/webgl_geometry_minecraft.html +++ b/examples/webgl_geometry_minecraft.html @@ -39,92 +39,9 @@





Generating world...
three.js - minecraft demo. featuring painterly pack
(left click: forward, right click: backward)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/examples/webgl_materials_video.html b/examples/webgl_materials_video.html index 462dd0cb..0c613b13 100644 --- a/examples/webgl_materials_video.html +++ b/examples/webgl_materials_video.html @@ -138,7 +138,6 @@ material = materials[ cube_count ]; material.program = material_base.program; - material.uniforms = Uniforms.clone( THREE.ShaderLib[ 'lambert' ].uniforms ); material.hue = i/xgrid; material.saturation = j/ygrid; diff --git a/examples/webgl_performance.html b/examples/webgl_performance.html index 01d2f4ab..6bfb9b50 100644 --- a/examples/webgl_performance.html +++ b/examples/webgl_performance.html @@ -16,8 +16,7 @@ - - + diff --git a/examples/webgl_postprocessing_dof.html b/examples/webgl_postprocessing_dof.html index 65ccd83b..b819777a 100644 --- a/examples/webgl_postprocessing_dof.html +++ b/examples/webgl_postprocessing_dof.html @@ -135,7 +135,6 @@ materials[c] = new THREE.MeshBasicMaterial( parameters ); materials[c].program = material_base.program; - materials[c].uniforms = Uniforms.clone( THREE.ShaderLib[ 'basic' ].uniforms ); if ( singleMaterial ) mesh = new THREE.Mesh( geo, zmaterial ); diff --git a/examples/webgl_ribbons.html b/examples/webgl_ribbons.html index a3dfbf38..6198ebc8 100644 --- a/examples/webgl_ribbons.html +++ b/examples/webgl_ribbons.html @@ -130,12 +130,11 @@ materials[c] = new THREE.MeshBasicMaterial( { color:0xffffff, vertexColors:true } ); materials[c].program = material_base.program; - materials[c].uniforms = Uniforms.clone( THREE.ShaderLib[ 'basic' ].uniforms ); ribbon = new THREE.Ribbon( i % 2 ? geometry : geometry2, materials[c] ); ribbon.rotation.x = 0; ribbon.rotation.y = 1.57; - ribbon.rotation.z = 3.14; + ribbon.rotation.z = 3.14; x = 40 * ( i - xgrid/2 ); y = 40 * ( j - ygrid/2 ); diff --git a/examples/webgl_sandbox.html b/examples/webgl_sandbox.html index 09732597..62ddd6d3 100644 --- a/examples/webgl_sandbox.html +++ b/examples/webgl_sandbox.html @@ -69,8 +69,9 @@ + - + @@ -84,6 +85,7 @@ + @@ -94,8 +96,10 @@ - + + + @@ -113,8 +117,10 @@ + + - + diff --git a/examples/webgl_stencil.html b/examples/webgl_stencil.html new file mode 100644 index 00000000..f7311977 --- /dev/null +++ b/examples/webgl_stencil.html @@ -0,0 +1,174 @@ + + + + three.js webgl - stencil shadow + + + + + + + + + + + + + diff --git a/src/extras/io/JSONLoader.js b/src/extras/io/JSONLoader.js index 9da16980..d323ad0c 100644 --- a/src/extras/io/JSONLoader.js +++ b/src/extras/io/JSONLoader.js @@ -6,7 +6,7 @@ THREE.JSONLoader = function ( showStatus ) { THREE.Loader.call( this, showStatus ); - + }; THREE.JSONLoader.prototype = new THREE.Loader(); @@ -14,342 +14,334 @@ THREE.JSONLoader.prototype.constructor = THREE.JSONLoader; THREE.JSONLoader.prototype.supr = THREE.Loader.prototype; -THREE.JSONLoader.prototype = { +/** + * Load models generated by slim OBJ converter with ASCII option (converter_obj_three_slim.py -t ascii) + * - parameters + * - model (required) + * - callback (required) + * - texture_path (optional: if not specified, textures will be assumed to be in the same folder as JS model file) + */ - // Load models generated by slim OBJ converter with ASCII option (converter_obj_three_slim.py -t ascii) - // - parameters - // - model (required) - // - callback (required) - // - texture_path (optional: if not specified, textures will be assumed to be in the same folder as JS model file) +THREE.JSONLoader.prototype.load = function ( parameters ) { - load: function ( parameters ) { - - var url = parameters.model, - callback = parameters.callback, - texture_path = parameters.texture_path ? parameters.texture_path : THREE.Loader.prototype.extractUrlbase( url ), - - s = (new Date).getTime(), - worker = new Worker( url ); - - worker.onmessage = function( event ) { - - THREE.JSONLoader.prototype.createModel( event.data, callback, texture_path ); + var scope = this, + url = parameters.model, + callback = parameters.callback, + texture_path = parameters.texture_path ? parameters.texture_path : this.extractUrlbase( url ), + worker = new Worker( url ); + + worker.onmessage = function ( event ) { + + scope.createModel( event.data, callback, texture_path ); + scope.onLoadComplete(); + + }; + + this.onLoadStart(); + worker.postMessage( new Date().getTime() ); + +}; + +THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path ) { + + var scope = this, + geometry = new THREE.Geometry(); + + this.init_materials( geometry, json.materials, texture_path ); + + parse(); + + init_skin(); + init_morphing(); + + geometry.computeCentroids(); + geometry.computeFaceNormals(); + + function parse() { + + if ( json.version === undefined || json.version != 2 ) { + + console.error( 'Deprecated file format.' ); + return; + + } + + function isBitSet( value, position ) { + + return value & ( 1 << position ); }; - worker.postMessage( s ); + var i, j, fi, - }, - - createModel: function ( json, callback, texture_path ) { + offset, zLength, - var Model = function ( texture_path ) { + type, + isQuad, + hasMaterial, + hasFaceUv, hasFaceVertexUv, + hasFaceNormal, hasFaceVertexNormal, + hasFaceColor, hasFaceVertexColor, - var scope = this; + vertex, face, - THREE.Geometry.call( this ); + faces = json.faces, + vertices = json.vertices, + normals = json.normals, + colors = json.colors, - THREE.Loader.prototype.init_materials( scope, json.materials, texture_path ); - - parse(); - init_skin(); - init_morphing(); + nUvLayers = 0; - this.computeCentroids(); - this.computeFaceNormals(); - - function parse() { + // disregard empty arrays - if ( json.version === undefined || json.version != 2 ) { + for ( i = 0; i < json.uvs.length; i++ ) { - console.error( 'Deprecated file format.' ); - return; + if ( json.uvs[ i ].length ) nUvLayers ++; - } - - function isBitSet( value, position ) { - - return value & ( 1 << position ); + } - }; - - var i, j, fi, - - offset, zLength, + for ( i = 0; i < nUvLayers; i++ ) { - type, - isQuad, - hasMaterial, - hasFaceUv, hasFaceVertexUv, - hasFaceNormal, hasFaceVertexNormal, - hasFaceColor, hasFaceVertexColor, + geometry.faceUvs[ i ] = []; + geometry.faceVertexUvs[ i ] = []; - vertex, face, - - faces = json.faces, - vertices = json.vertices, - normals = json.normals, - colors = json.colors, + } - nUvLayers = 0; - - // disregard empty arrays - - for ( i = 0; i < json.uvs.length; i++ ) { - - if ( json.uvs[ i ].length ) nUvLayers ++; + offset = 0; + zLength = vertices.length; + + while ( offset < zLength ) { + + vertex = new THREE.Vertex(); + + vertex.position.x = vertices[ offset ++ ]; + vertex.position.y = vertices[ offset ++ ]; + vertex.position.z = vertices[ offset ++ ]; + + geometry.vertices.push( vertex ); + + } + + offset = 0; + zLength = faces.length; + + while ( offset < zLength ) { + + type = faces[ offset ++ ]; + + + isQuad = isBitSet( type, 0 ); + hasMaterial = isBitSet( type, 1 ); + hasFaceUv = isBitSet( type, 2 ); + hasFaceVertexUv = isBitSet( type, 3 ); + hasFaceNormal = isBitSet( type, 4 ); + hasFaceVertexNormal = isBitSet( type, 5 ); + hasFaceColor = isBitSet( type, 6 ); + hasFaceVertexColor = isBitSet( type, 7 ); + + //console.log("type", type, "bits", isQuad, hasMaterial, hasFaceUv, hasFaceVertexUv, hasFaceNormal, hasFaceVertexNormal, hasFaceColor, hasFaceVertexColor); + + if ( isQuad ) { + + face = new THREE.Face4(); + + face.a = faces[ offset ++ ]; + face.b = faces[ offset ++ ]; + face.c = faces[ offset ++ ]; + face.d = faces[ offset ++ ]; + + nVertices = 4; + + } else { + + face = new THREE.Face3(); + + face.a = faces[ offset ++ ]; + face.b = faces[ offset ++ ]; + face.c = faces[ offset ++ ]; + + nVertices = 3; + + } + + if ( hasMaterial ) { + + materialIndex = faces[ offset ++ ]; + face.materials = geometry.materials[ materialIndex ]; + + } + + if ( hasFaceUv ) { - } - for ( i = 0; i < nUvLayers; i++ ) { - scope.faceUvs[ i ] = []; - scope.faceVertexUvs[ i ] = []; + uvLayer = json.uvs[ i ]; + + uvIndex = faces[ offset ++ ]; + + u = uvLayer[ uvIndex * 2 ]; + v = uvLayer[ uvIndex * 2 + 1 ]; + + geometry.faceUvs[ i ].push( new THREE.UV( u, v ) ); } - offset = 0; - zLength = vertices.length; - - while ( offset < zLength ) { + } - vertex = new THREE.Vertex(); - - vertex.position.x = vertices[ offset ++ ]; - vertex.position.y = vertices[ offset ++ ]; - vertex.position.z = vertices[ offset ++ ]; + if ( hasFaceVertexUv ) { - scope.vertices.push( vertex ); + for ( i = 0; i < nUvLayers; i++ ) { - } - - offset = 0; - zLength = faces.length; + uvLayer = json.uvs[ i ]; - while ( offset < zLength ) { + uvs = []; - type = faces[ offset ++ ]; + for ( j = 0; j < nVertices; j ++ ) { - - isQuad = isBitSet( type, 0 ); - hasMaterial = isBitSet( type, 1 ); - hasFaceUv = isBitSet( type, 2 ); - hasFaceVertexUv = isBitSet( type, 3 ); - hasFaceNormal = isBitSet( type, 4 ); - hasFaceVertexNormal = isBitSet( type, 5 ); - hasFaceColor = isBitSet( type, 6 ); - hasFaceVertexColor = isBitSet( type, 7 ); + uvIndex = faces[ offset ++ ]; - //console.log("type", type, "bits", isQuad, hasMaterial, hasFaceUv, hasFaceVertexUv, hasFaceNormal, hasFaceVertexNormal, hasFaceColor, hasFaceVertexColor); + u = uvLayer[ uvIndex * 2 ]; + v = uvLayer[ uvIndex * 2 + 1 ]; - if ( isQuad ) { - - face = new THREE.Face4(); - - face.a = faces[ offset ++ ]; - face.b = faces[ offset ++ ]; - face.c = faces[ offset ++ ]; - face.d = faces[ offset ++ ]; - - nVertices = 4; - - } else { - - face = new THREE.Face3(); - - face.a = faces[ offset ++ ]; - face.b = faces[ offset ++ ]; - face.c = faces[ offset ++ ]; - - nVertices = 3; - - } - - if ( hasMaterial ) { - - materialIndex = faces[ offset ++ ]; - face.materials = scope.materials[ materialIndex ]; + uvs[ j ] = new THREE.UV( u, v ); } - if ( hasFaceUv ) { + // to get face <=> uv index correspondence - for ( i = 0; i < nUvLayers; i++ ) { - - uvLayer = json.uvs[ i ]; - - uvIndex = faces[ offset ++ ]; - - u = uvLayer[ uvIndex * 2 ]; - v = uvLayer[ uvIndex * 2 + 1 ]; - - scope.faceUvs[ i ].push( new THREE.UV( u, v ) ); - - } - - } - - if ( hasFaceVertexUv ) { - - for ( i = 0; i < nUvLayers; i++ ) { - - uvLayer = json.uvs[ i ]; - - uvs = []; - - for ( j = 0; j < nVertices; j ++ ) { - - uvIndex = faces[ offset ++ ]; - - u = uvLayer[ uvIndex * 2 ]; - v = uvLayer[ uvIndex * 2 + 1 ]; - - uvs[ j ] = new THREE.UV( u, v ); - - } - - // to get face <=> uv index correspondence - - fi = scope.faces.length; - scope.faceVertexUvs[ i ][ fi ] = uvs; - - } - - } - - if ( hasFaceNormal ) { - - normalIndex = faces[ offset ++ ] * 3; - - normal = new THREE.Vector3(); - - normal.x = normals[ normalIndex ++ ]; - normal.y = normals[ normalIndex ++ ]; - normal.z = normals[ normalIndex ]; - - face.normal = normal; - - } - - if ( hasFaceVertexNormal ) { - - for ( i = 0; i < nVertices; i++ ) { - - normalIndex = faces[ offset ++ ] * 3; - - normal = new THREE.Vector3(); - - normal.x = normals[ normalIndex ++ ]; - normal.y = normals[ normalIndex ++ ]; - normal.z = normals[ normalIndex ]; - - face.vertexNormals.push( normal ); - - } - - } - - - if ( hasFaceColor ) { - - color = new THREE.Color( faces[ offset ++ ] ); - face.color = color; - - } - - - if ( hasFaceVertexColor ) { - - for ( i = 0; i < nVertices; i++ ) { - - colorIndex = faces[ offset ++ ]; - - color = new THREE.Color( colors[ colorIndex ] ); - face.vertexColors.push( color ); - - } - - } - - scope.faces.push( face ); + fi = geometry.faces.length; + geometry.faceVertexUvs[ i ][ fi ] = uvs; } - }; - - function init_skin() { - - var i, l, x, y, z, w, a, b, c, d; + } - if ( json.skinWeights ) { - - for( i = 0, l = json.skinWeights.length; i < l; i += 2 ) { + if ( hasFaceNormal ) { - x = json.skinWeights[ i ]; - y = json.skinWeights[ i + 1 ]; - z = 0; - w = 0; - - scope.skinWeights.push( new THREE.Vector4( x, y, z, w ) ); + normalIndex = faces[ offset ++ ] * 3; - } - - } - - if ( json.skinIndices ) { - - for( i = 0, l = json.skinIndices.length; i < l; i += 2 ) { + normal = new THREE.Vector3(); - a = json.skinIndices[ i ]; - b = json.skinIndices[ i + 1 ]; - c = 0; - d = 0; + normal.x = normals[ normalIndex ++ ]; + normal.y = normals[ normalIndex ++ ]; + normal.z = normals[ normalIndex ]; - scope.skinIndices.push( new THREE.Vector4( a, b, c, d ) ); + face.normal = normal; - } - - } - - scope.bones = json.bones; - scope.animation = json.animation; - - }; - - function init_morphing() { + } - if( json.morphTargets !== undefined ) { - - var i, l, v, vl; - - for( i = 0, l = json.morphTargets.length; i < l; i++ ) { - - scope.morphTargets[ i ] = {}; - scope.morphTargets[ i ].name = json.morphTargets[ i ].name; - scope.morphTargets[ i ].vertices = []; - - dstVertices = scope.morphTargets[ i ].vertices; - srcVertices = json.morphTargets [ i ].vertices; + if ( hasFaceVertexNormal ) { - for( v = 0, vl = srcVertices.length; v < vl; v += 3 ) { + for ( i = 0; i < nVertices; i++ ) { - dstVertices.push( new THREE.Vertex( new THREE.Vector3( srcVertices[ v ], srcVertices[ v + 1 ], srcVertices[ v + 2 ] ) ) ); + normalIndex = faces[ offset ++ ] * 3; + + normal = new THREE.Vector3(); + + normal.x = normals[ normalIndex ++ ]; + normal.y = normals[ normalIndex ++ ]; + normal.z = normals[ normalIndex ]; + + face.vertexNormals.push( normal ); - } - - } - } - }; - - }; + } - Model.prototype = new THREE.Geometry(); - Model.prototype.constructor = Model; - callback( new Model( texture_path ) ); + if ( hasFaceColor ) { - } + color = new THREE.Color( faces[ offset ++ ] ); + face.color = color; -}; \ No newline at end of file + } + + + if ( hasFaceVertexColor ) { + + for ( i = 0; i < nVertices; i++ ) { + + colorIndex = faces[ offset ++ ]; + + color = new THREE.Color( colors[ colorIndex ] ); + face.vertexColors.push( color ); + + } + + } + + geometry.faces.push( face ); + + } + + }; + + function init_skin() { + + var i, l, x, y, z, w, a, b, c, d; + + if ( json.skinWeights ) { + + for( i = 0, l = json.skinWeights.length; i < l; i += 2 ) { + + x = json.skinWeights[ i ]; + y = json.skinWeights[ i + 1 ]; + z = 0; + w = 0; + + geometry.skinWeights.push( new THREE.Vector4( x, y, z, w ) ); + + } + + } + + if ( json.skinIndices ) { + + for( i = 0, l = json.skinIndices.length; i < l; i += 2 ) { + + a = json.skinIndices[ i ]; + b = json.skinIndices[ i + 1 ]; + c = 0; + d = 0; + + geometry.skinIndices.push( new THREE.Vector4( a, b, c, d ) ); + + } + + } + + geometry.bones = json.bones; + geometry.animation = json.animation; + + }; + + function init_morphing() { + + if( json.morphTargets !== undefined ) { + + var i, l, v, vl; + + for( i = 0, l = json.morphTargets.length; i < l; i++ ) { + + geometry.morphTargets[ i ] = {}; + geometry.morphTargets[ i ].name = json.morphTargets[ i ].name; + geometry.morphTargets[ i ].vertices = []; + + dstVertices = geometry.morphTargets[ i ].vertices; + srcVertices = json.morphTargets [ i ].vertices; + + for( v = 0, vl = srcVertices.length; v < vl; v += 3 ) { + + dstVertices.push( new THREE.Vertex( new THREE.Vector3( srcVertices[ v ], srcVertices[ v + 1 ], srcVertices[ v + 2 ] ) ) ); + + } + + } + + } + + }; + + callback( geometry ); + +} diff --git a/src/extras/io/Loader.js b/src/extras/io/Loader.js index 89f4411b..26d1756c 100644 --- a/src/extras/io/Loader.js +++ b/src/extras/io/Loader.js @@ -4,34 +4,38 @@ THREE.Loader = function ( showStatus ) { - this.showStatus = showStatus; + this.showStatus = showStatus; this.statusDomElement = showStatus ? THREE.Loader.prototype.addStatusElement() : null; + this.onLoadStart = function () {}; + this.onLoadProgress = function() {}; + this.onLoadComplete = function () {}; + }; THREE.Loader.prototype = { - addStatusElement: function ( ) { - + addStatusElement: function () { + var e = document.createElement( "div" ); - - e.style.fontSize = "0.8em"; - e.style.textAlign = "left"; - e.style.background = "#b00"; - e.style.color = "#fff"; - e.style.width = "140px"; - e.style.padding = "0.25em 0.25em 0.25em 0.5em"; + e.style.position = "absolute"; e.style.right = "0px"; e.style.top = "0px"; + e.style.fontSize = "0.8em"; + e.style.textAlign = "left"; + e.style.background = "rgba(0,0,0,0.25)"; + e.style.color = "#fff"; + e.style.width = "120px"; + e.style.padding = "0.5em 0.5em 0.5em 0.5em"; e.style.zIndex = 1000; - + e.innerHTML = "Loading ..."; - + return e; - + }, - + updateProgress: function ( progress ) { var message = "Loaded "; @@ -50,13 +54,13 @@ THREE.Loader.prototype = { this.statusDomElement.innerHTML = message; }, - + extractUrlbase: function( url ) { - + var chunks = url.split( "/" ); chunks.pop(); return chunks.join( "/" ); - + }, init_materials: function( scope, materials, texture_path ) { @@ -88,9 +92,9 @@ THREE.Loader.prototype = { } function load_image( where, url ) { - + var image = new Image(); - + image.onload = function () { if ( !is_pow2( this.width ) || !is_pow2( this.height ) ) { @@ -113,20 +117,21 @@ THREE.Loader.prototype = { }; image.src = url; - + } - + var material, mtype, mpars, texture, color; // defaults - + mtype = "MeshLambertMaterial"; + mpars = { color: 0xeeeeee, opacity: 1.0, map: null, lightMap: null, vertexColors: m.vertexColors ? THREE.VertexColors : false, wireframe: m.wireframe }; // parameters from model file - + if ( m.shading ) { - + if ( m.shading == "Phong" ) mtype = "MeshPhongMaterial"; else if ( m.shading == "Basic" ) mtype = "MeshBasicMaterial"; @@ -135,10 +140,10 @@ THREE.Loader.prototype = { if ( m.mapDiffuse && texture_path ) { texture = document.createElement( 'canvas' ); - + mpars.map = new THREE.Texture( texture ); mpars.map.sourceFile = m.mapDiffuse; - + load_image( mpars.map, texture_path + "/" + m.mapDiffuse ); } else if ( m.colorDiffuse ) { @@ -156,20 +161,18 @@ THREE.Loader.prototype = { if ( m.mapLightmap && texture_path ) { texture = document.createElement( 'canvas' ); - + mpars.lightMap = new THREE.Texture( texture ); mpars.lightMap.sourceFile = m.mapLightmap; - + load_image( mpars.lightMap, texture_path + "/" + m.mapLightmap ); } - + material = new THREE[ mtype ]( mpars ); return material; - } - -}; - + } +}; diff --git a/src/materials/ShadowVolumeDynamicMaterial.js b/src/materials/ShadowVolumeDynamicMaterial.js new file mode 100644 index 00000000..3fdc2314 --- /dev/null +++ b/src/materials/ShadowVolumeDynamicMaterial.js @@ -0,0 +1,59 @@ +/** + * @author mr.doob / http://mrdoob.com/ + * @author alteredq / http://alteredqualia.com/ + * + * parameters = { + * color: , + * opacity: , + * map: new THREE.Texture( ), + + * lightMap: new THREE.Texture( ), + + * envMap: new THREE.TextureCube( [posx, negx, posy, negy, posz, negz] ), + * combine: THREE.Multiply, + * reflectivity: , + * refractionRatio: , + + * shading: THREE.SmoothShading, + * blending: THREE.NormalBlending, + * depthTest: , + + * wireframe: , + * wireframeLinewidth: , + + * vertexColors: , + * skinning: + * } + */ + +THREE.ShadowVolumeDynamicMaterial = function ( parameters ) { + + this.id = THREE.MaterialCounter.value ++; + + this.color = new THREE.Color( 0xffffff ); + this.opacity = 1.0; + this.map = null; + + this.lightMap = null; + + this.envMap = null; + this.combine = THREE.MultiplyOperation; + this.reflectivity = 1.0; + this.refractionRatio = 0.98; + + this.fog = true; // implemented just in WebGLRenderer2 + + this.shading = THREE.FlatShading; + this.blending = THREE.NormalBlending; + this.depthTest = true; + + this.wireframe = false; + this.wireframeLinewidth = 1.0; + this.wireframeLinecap = 'round'; // implemented just in CanvasRenderer + this.wireframeLinejoin = 'round'; // implemented just in CanvasRenderer + + this.vertexColors = false; + this.skinning = false; + this.morphTargets = false; + +}; diff --git a/src/objects/ShadowVolume.js b/src/objects/ShadowVolume.js new file mode 100644 index 00000000..66d99f01 --- /dev/null +++ b/src/objects/ShadowVolume.js @@ -0,0 +1,200 @@ +/* + * Shadow Volume + */ + +THREE.ShadowVolume = function( mesh, isStatic ) { + + THREE.Mesh.call( this, mesh.geometry, isStatic ? [ new THREE.ShadowVolumeDynamicMaterial() ] : [ new THREE.ShadowVolumeDynamicMaterial() ] ); + mesh.addChild( this ); + + this.calculateShadowVolumeGeometry( mesh.geometry ); +} + +THREE.ShadowVolume.prototype = new THREE.Mesh(); +THREE.ShadowVolume.prototype.constructor = THREE.ShadowVolume; +THREE.ShadowVolume.prototype.supr = THREE.Mesh.prototype; + + +/* + * Calculate Geometry + */ + +THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry = function( originalGeometry ) { + + // create geometry + + this.geometry = new THREE.Geometry(); + this.geometry.boundingSphere = originalGeometry.boundingSphere; + this.geometry.edgeFaces = []; + + // copy vertices / faces from original mesh + + var vertexTypes = this.geometry.vertexTypes; + var vertices = this.geometry.vertices; + var faces = this.geometry.faces; + var edgeFaces = this.geometry.edgeFaces; + + var originalFaces = originalGeometry.faces; + var originalVertices = originalGeometry.vertices; + var fl = originalFaces.length; + + var originalFace, face, i, f, n, vertex, numVertices; + var indices = [ "a", "b", "c", "d" ]; + + + for( f = 0; f < fl; f++ ) { + + numVertices = vertices.length; + originalFace = originalFaces[ f ]; + + if ( originalFace instanceof THREE.Face4 ) { + + n = 4; + face = new THREE.Face4( numVertices, numVertices + 1, numVertices + 2, numVertices + 3 ); + + } else { + + n = 3; + face = new THREE.Face3( numVertices, numVertices + 1, numVertices + 2 ); + } + + face.normal.copy( originalFace.normal ); + faces.push( face ); + + + for( i = 0; i < n; i++ ) { + + vertex = originalVertices[ originalFace[ indices[ i ]]]; + vertices.push( new THREE.Vertex( vertex.position.clone())); + + } + + } + + + // calculate edge faces + + var result, faceA, faceB, v, vl; + + for( var fa = 0; fa < originalFaces.length - 1; fa++ ) { + + faceA = faces[ fa ]; + + for( var fb = fa + 1; fb < originalFaces.length; fb++ ) { + + faceB = faces[ fb ]; + result = this.facesShareEdge( vertices, faceA, faceB ); + + if( result !== undefined ) { + + numVertices = vertices.length; + face = new THREE.Face4( result.indices[ 0 ], result.indices[ 3 ], result.indices[ 2 ], result.indices[ 1 ] ); + face.normal.set( 1, 0, 0 ); + edgeFaces.push( face ); + + } + + } + + } + +} + + + +/* + * Faces share edge? + */ + +THREE.ShadowVolume.prototype.facesShareEdge = function( vertices, faceA, faceB ) { + + var indicesA, + indicesB, + indexA, + indexB, + vertexA, + vertexB, + savedVertexA, + savedVertexB, + savedIndexA, + savedIndexB, + indexLetters, + a, b, + numMatches = 0, + indices = [ "a", "b", "c", "d" ]; + + if( faceA instanceof THREE.Face4 ) indicesA = 4; + else indicesA = 3; + + if( faceB instanceof THREE.Face4 ) indicesB = 4; + else indicesB = 3; + + + for( a = 0; a < indicesA; a++ ) { + + indexA = faceA[ indices[ a ] ]; + vertexA = vertices[ indexA ]; + + for( b = 0; b < indicesB; b++ ) { + + indexB = faceB[ indices[ b ] ]; + vertexB = vertices[ indexB ]; + + if( Math.abs( vertexA.position.x - vertexB.position.x ) < 0.0001 && + Math.abs( vertexA.position.y - vertexB.position.y ) < 0.0001 && + Math.abs( vertexA.position.z - vertexB.position.z ) < 0.0001 ) { + + numMatches++; + + if( numMatches === 1 ) { + + savedVertexA = vertexA; + savedVertexB = vertexB; + savedIndexA = indexA; + savedIndexB = indexB; + indexLetters = indices[ a ]; + + } + + if( numMatches === 2 ) { + + indexLetters += indices[ a ]; + + if( indexLetters === "ad" || indexLetters === "ac" ) { + + return { + + faces : [ faceA, faceB ], + vertices : [ savedVertexA, savedVertexB, vertexB, vertexA ], + indices : [ savedIndexA, savedIndexB, indexB, indexA ], + vertexTypes : [ 1, 2, 2, 1 ], + extrudable : true + + }; + + } else { + + return { + + faces : [ faceA, faceB ], + vertices : [ savedVertexA, vertexA, vertexB, savedVertexB ], + indices : [ savedIndexA, indexA, indexB, savedIndexB ], + vertexTypes : [ 1, 1, 2, 2 ], + extrudable : true + + }; + + } + + } + + } + + } + + } + + return undefined; + +} + diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 1d3a1217..69c383af 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -32,6 +32,7 @@ THREE.WebGLRenderer = function ( parameters ) { _oldFlipSided = null, _oldBlending = null, _oldDepth = null, + _cullEnabled = true, _viewportX = 0, _viewportY = 0, @@ -88,7 +89,42 @@ THREE.WebGLRenderer = function ( parameters ) { this.context = _gl; - // alert( dumpObject( getGLParams() ) ); + + // create shadow polygons + + var _shadow = {}; + var vertices = []; + var faces = []; + + vertices[ 0 * 3 + 0 ] = -2; vertices[ 0 * 3 + 1 ] = -1; vertices[ 0 * 3 + 2 ] = -1; + vertices[ 1 * 3 + 0 ] = 2; vertices[ 1 * 3 + 1 ] = -1; vertices[ 1 * 3 + 2 ] = -1; + vertices[ 2 * 3 + 0 ] = 2; vertices[ 2 * 3 + 1 ] = 1; vertices[ 2 * 3 + 2 ] = -1; + vertices[ 3 * 3 + 0 ] = -2; vertices[ 3 * 3 + 1 ] = 1; vertices[ 3 * 3 + 2 ] = -1; + + faces[ 0 ] = 0; faces[ 1 ] = 1; faces[ 2 ] = 2; + faces[ 3 ] = 0; faces[ 4 ] = 2; faces[ 5 ] = 3; + + + _shadow.vertexBuffer = _gl.createBuffer(); + _shadow.elementBuffer = _gl.createBuffer(); + + _gl.bindBuffer( _gl.ARRAY_BUFFER, _shadow.vertexBuffer ); + _gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( vertices ), _gl.STATIC_DRAW ); + + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, _shadow.elementBuffer ); + _gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, new Uint16Array( faces ), _gl.STATIC_DRAW ); + + + _shadow.program = _gl.createProgram(); + + _gl.attachShader( _shadow.program, getShader( "fragment", THREE.ShaderLib.shadowPost.fragmentShader )); + _gl.attachShader( _shadow.program, getShader( "vertex", THREE.ShaderLib.shadowPost.vertexShader )); + + _gl.linkProgram( _shadow.program ); + + _shadow.vertexLocation = _gl.getAttribLocation ( _shadow.program, "position" ); + _shadow.projectionLocation = _gl.getUniformLocation( _shadow.program, "projectionMatrix" ); + this.setSize = function ( width, height ) { @@ -147,7 +183,7 @@ THREE.WebGLRenderer = function ( parameters ) { this.clear = function () { - _gl.clear( _gl.COLOR_BUFFER_BIT | _gl.DEPTH_BUFFER_BIT ); + _gl.clear( _gl.COLOR_BUFFER_BIT | _gl.DEPTH_BUFFER_BIT | _gl.STENCIL_BUFFER_BIT ); }; @@ -321,7 +357,7 @@ THREE.WebGLRenderer = function ( parameters ) { function initMeshBuffers ( geometryGroup, object ) { - var f, fl, + var f, fl, fi, face, nvertices = 0, ntris = 0, nlines = 0, @@ -408,7 +444,7 @@ THREE.WebGLRenderer = function ( parameters ) { } - geometryGroup.__faceArray = new Uint16Array( ntris * 3 ); + geometryGroup.__faceArray = new Uint16Array( ntris * 3 + ( object.geometry.edgeFaces ? object.geometry.edgeFaces.length * 2 * 3 : 0 )); geometryGroup.__lineArray = new Uint16Array( nlines * 2 ); if( geometryGroup.numMorphTargets ) { @@ -429,7 +465,7 @@ THREE.WebGLRenderer = function ( parameters ) { geometryGroup.__vertexColorType = vertexColorType; geometryGroup.__normalType = normalType; - geometryGroup.__webGLFaceCount = ntris * 3; + geometryGroup.__webGLFaceCount = ntris * 3 + ( object.geometry.edgeFaces ? object.geometry.edgeFaces.length * 2 * 3 : 0 ); geometryGroup.__webGLLineCount = nlines * 2; }; @@ -510,6 +546,7 @@ THREE.WebGLRenderer = function ( parameters ) { obj_skinVerticesB = geometry.skinVerticesB, obj_skinIndices = geometry.skinIndices, obj_skinWeights = geometry.skinWeights, + obj_edgeFaces = geometry.edgeFaces, morphTargets = geometry.morphTargets; @@ -1163,6 +1200,24 @@ THREE.WebGLRenderer = function ( parameters ) { } + if( obj_edgeFaces ) { + + for( f = 0, fl = obj_edgeFaces.length; f < fl; f++ ) { + + faceArray[ offset_face ] = obj_edgeFaces[ f ].a; + faceArray[ offset_face + 1 ] = obj_edgeFaces[ f ].b; + faceArray[ offset_face + 2 ] = obj_edgeFaces[ f ].c; + + faceArray[ offset_face + 3 ] = obj_edgeFaces[ f ].a; + faceArray[ offset_face + 4 ] = obj_edgeFaces[ f ].c; + faceArray[ offset_face + 5 ] = obj_edgeFaces[ f ].d; + + offset_face += 6; + } + + } + + if ( dirtyVertices ) { _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLVertexBuffer ); @@ -1463,15 +1518,15 @@ THREE.WebGLRenderer = function ( parameters ) { }; - function setMaterialShaders ( material, shaders ) { + function setMaterialShaders( material, shaders ) { - material.fragmentShader = shaders.fragmentShader; - material.vertexShader = shaders.vertexShader; material.uniforms = Uniforms.clone( shaders.uniforms ); + material.vertexShader = shaders.vertexShader; + material.fragmentShader = shaders.fragmentShader; }; - function refreshUniformsCommon ( uniforms, material ) { + function refreshUniformsCommon( uniforms, material ) { // premultiply alpha uniforms.diffuse.value.setRGB( material.color.r * material.opacity, material.color.g * material.opacity, material.color.b * material.opacity ); @@ -1556,6 +1611,10 @@ THREE.WebGLRenderer = function ( parameters ) { setMaterialShaders( material, THREE.ShaderLib[ 'depth' ] ); + } else if ( material instanceof THREE.ShadowVolumeDynamicMaterial ) { + + setMaterialShaders( material, THREE.ShaderLib[ 'shadowVolumeDynamic' ] ); + } else if ( material instanceof THREE.MeshNormalMaterial ) { setMaterialShaders( material, THREE.ShaderLib[ 'normal' ] ); @@ -1582,103 +1641,112 @@ THREE.WebGLRenderer = function ( parameters ) { } - // heuristics to create shader parameters according to lights in the scene - // (not to blow over maxLights budget) + if ( ! material.program ) { - maxLightCount = allocateLights( lights, 4 ); + // heuristics to create shader parameters according to lights in the scene + // (not to blow over maxLights budget) - maxBones = allocateBones( object ); - - parameters = { fog: fog, map: material.map, envMap: material.envMap, lightMap: material.lightMap, vertexColors: material.vertexColors, - sizeAttenuation: material.sizeAttenuation, - skinning: material.skinning, - morphTargets: material.morphTargets, - maxDirLights: maxLightCount.directional, maxPointLights: maxLightCount.point, - maxBones: maxBones }; + maxLightCount = allocateLights( lights, 4 ); - material.program = buildProgram( material.fragmentShader, material.vertexShader, parameters ); + maxBones = allocateBones( object ); + + parameters = { fog: fog, map: material.map, envMap: material.envMap, lightMap: material.lightMap, vertexColors: material.vertexColors, + sizeAttenuation: material.sizeAttenuation, + skinning: material.skinning, + morphTargets: material.morphTargets, + maxDirLights: maxLightCount.directional, maxPointLights: maxLightCount.point, + maxBones: maxBones }; + + material.program = buildProgram( material.fragmentShader, material.vertexShader, parameters ); + + // load uniforms + + identifiers = [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition', + 'cameraInverseMatrix', 'boneGlobalMatrices', 'morphTargetInfluences' + ]; - // load uniforms + for( u in material.uniforms ) { - identifiers = [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition', - 'cameraInverseMatrix', 'boneGlobalMatrices', 'morphTargetInfluences' - ]; - - - for( u in material.uniforms ) { - - identifiers.push(u); - } - - cacheUniformLocations( material.program, identifiers ); - - - // load attributes - - identifiers = [ "position", "normal", "uv", "uv2", "tangent", "color", - "skinVertexA", "skinVertexB", "skinIndex", "skinWeight" ]; - - for( i = 0; i < this.maxMorphTargets; i++ ) { - - identifiers.push( "morphTarget" + i ); - } - - for( a in material.attributes ) { - - identifiers.push( a ); - } - - cacheAttributeLocations( material.program, identifiers ); - - - var attributes = material.program.attributes; - - _gl.enableVertexAttribArray( attributes.position ); - - if ( attributes.color >= 0 ) _gl.enableVertexAttribArray( attributes.color ); - if ( attributes.normal >= 0 ) _gl.enableVertexAttribArray( attributes.normal ); - if ( attributes.tangent >= 0 ) _gl.enableVertexAttribArray( attributes.tangent ); - - if ( material.skinning && - attributes.skinVertexA >=0 && attributes.skinVertexB >= 0 && - attributes.skinIndex >= 0 && attributes.skinWeight >= 0 ) { - - _gl.enableVertexAttribArray( attributes.skinVertexA ); - _gl.enableVertexAttribArray( attributes.skinVertexB ); - _gl.enableVertexAttribArray( attributes.skinIndex ); - _gl.enableVertexAttribArray( attributes.skinWeight ); - - } - - if ( material.morphTargets ) { - - material.numSupportedMorphTargets = 0; - - if( attributes.morphTarget0 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget0 ); material.numSupportedMorphTargets++ } - if( attributes.morphTarget1 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget1 ); material.numSupportedMorphTargets++ } - if( attributes.morphTarget2 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget2 ); material.numSupportedMorphTargets++ } - if( attributes.morphTarget3 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget3 ); material.numSupportedMorphTargets++ } - if( attributes.morphTarget4 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget4 ); material.numSupportedMorphTargets++ } - if( attributes.morphTarget5 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget5 ); material.numSupportedMorphTargets++ } - if( attributes.morphTarget6 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget6 ); material.numSupportedMorphTargets++ } - if( attributes.morphTarget7 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget7 ); material.numSupportedMorphTargets++ } - - object.__webGLMorphTargetInfluences = new Float32Array( this.maxMorphTargets ); - - for( var i = 0; i < this.maxMorphTargets; i++ ) { - - object.__webGLMorphTargetInfluences[ i ] = 0; - + identifiers.push(u); } - + + cacheUniformLocations( material.program, identifiers ); + + + // load attributes + + identifiers = [ "position", "normal", "uv", "uv2", "tangent", "color", + "skinVertexA", "skinVertexB", "skinIndex", "skinWeight" ]; + + for ( i = 0; i < this.maxMorphTargets; i++ ) { + + identifiers.push( "morphTarget" + i ); + } + + for ( a in material.attributes ) { + + identifiers.push( a ); + } + + cacheAttributeLocations( material.program, identifiers ); + + + var attributes = material.program.attributes; + + _gl.enableVertexAttribArray( attributes.position ); + + if ( attributes.color >= 0 ) _gl.enableVertexAttribArray( attributes.color ); + if ( attributes.normal >= 0 ) _gl.enableVertexAttribArray( attributes.normal ); + if ( attributes.tangent >= 0 ) _gl.enableVertexAttribArray( attributes.tangent ); + + if ( material.skinning && + attributes.skinVertexA >=0 && attributes.skinVertexB >= 0 && + attributes.skinIndex >= 0 && attributes.skinWeight >= 0 ) { + + _gl.enableVertexAttribArray( attributes.skinVertexA ); + _gl.enableVertexAttribArray( attributes.skinVertexB ); + _gl.enableVertexAttribArray( attributes.skinIndex ); + _gl.enableVertexAttribArray( attributes.skinWeight ); + + } + + if ( material.morphTargets ) { + + material.numSupportedMorphTargets = 0; + + if( attributes.morphTarget0 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget0 ); material.numSupportedMorphTargets++ } + if( attributes.morphTarget1 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget1 ); material.numSupportedMorphTargets++ } + if( attributes.morphTarget2 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget2 ); material.numSupportedMorphTargets++ } + if( attributes.morphTarget3 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget3 ); material.numSupportedMorphTargets++ } + if( attributes.morphTarget4 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget4 ); material.numSupportedMorphTargets++ } + if( attributes.morphTarget5 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget5 ); material.numSupportedMorphTargets++ } + if( attributes.morphTarget6 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget6 ); material.numSupportedMorphTargets++ } + if( attributes.morphTarget7 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget7 ); material.numSupportedMorphTargets++ } + + object.__webGLMorphTargetInfluences = new Float32Array( this.maxMorphTargets ); + + for( var i = 0; i < this.maxMorphTargets; i++ ) { + + object.__webGLMorphTargetInfluences[ i ] = 0; + + } + + } + } + material.__webglProgram = true; + }; function setProgram( camera, lights, fog, material, object ) { - if ( !material.program ) _this.initMaterial( material, lights, fog, object ); + if ( ! material.__webglProgram ) { + + _this.initMaterial( material, lights, fog, object ); + + } var program = material.program, p_uniforms = program.uniforms, @@ -1782,6 +1850,20 @@ THREE.WebGLRenderer = function ( parameters ) { } + if( material instanceof THREE.ShadowVolumeDynamicMaterial ) { + + var dirLight = m_uniforms.directionalLightDirection.value; + + dirLight[ 0 ] = -lights.position.x; + dirLight[ 1 ] = -lights.position.y; + dirLight[ 2 ] = -lights.position.z; + + _gl.uniform3fv( p_uniforms.directionalLightDirection, dirLight ); + _gl.uniformMatrix4fv( p_uniforms.objectMatrix, false, object._objectMatrixArray ); + _gl.uniformMatrix4fv( p_uniforms.viewMatrix, false, _viewMatrixArray ); + } + + if ( material.skinning ) { loadUniformsSkinning( p_uniforms, object ); @@ -2261,6 +2343,7 @@ THREE.WebGLRenderer = function ( parameters ) { this.clear(); } + // set matrices @@ -2450,6 +2533,150 @@ THREE.WebGLRenderer = function ( parameters ) { } + + + //////////////////////// stencil shadows begin ////////////////////// + // method: we're rendering the world in light, then the shadow + // volumes into the stencil and last a big darkening + // quad over the whole thing. This is NOT how you're + // supposed to do stencil shadows but is much faster + // + + if( scene.__webglShadowVolumes.length && scene.lights.length ) { + + // setup stencil + + _gl.enable( _gl.POLYGON_OFFSET_FILL ); + _gl.polygonOffset( 0.1, 1.0 ); + _gl.enable( _gl.STENCIL_TEST ); + _gl.depthMask( false ); + _gl.colorMask( false, false, false, false ); + + _gl.stencilFunc( _gl.ALWAYS, 1, 0xFF ); + _gl.stencilOpSeparate( _gl.BACK, _gl.KEEP, _gl.INCR, _gl.KEEP ); + _gl.stencilOpSeparate( _gl.FRONT, _gl.KEEP, _gl.DECR, _gl.KEEP ); + + + + // loop through all directional lights + + var l, ll = scene.lights.length; + var p; + var light, geometryGroup; + var dirLight = []; + var program; + var p_uniforms; + var m_uniforms; + var attributes; + + ol = scene.__webglShadowVolumes.length; + + for( l = 0; l < ll; l++ ) { + + light = scene.lights[ l ]; + + if( light instanceof THREE.DirectionalLight ) { + + dirLight[ 0 ] = -light.position.x; + dirLight[ 1 ] = -light.position.y; + dirLight[ 2 ] = -light.position.z; + + + // render all volumes + + for ( o = 0; o < ol; o++ ) { + + object = scene.__webglShadowVolumes[ o ].object; + geometryGroup = scene.__webglShadowVolumes[ o ].buffer; + material = object.materials[ 0 ]; + + + if ( !material.program ) _this.initMaterial( material, lights, fog, object ); + + program = material.program, + p_uniforms = program.uniforms, + m_uniforms = material.uniforms, + attributes = program.attributes; + + + if( _oldProgram !== program ) { + + _gl.useProgram( program ); + _oldProgram = program; + + _gl.uniformMatrix4fv( p_uniforms.projectionMatrix, false, _projectionMatrixArray ); + _gl.uniformMatrix4fv( p_uniforms.viewMatrix, false, _viewMatrixArray ); + _gl.uniform3fv( p_uniforms.directionalLightDirection, dirLight ); + } + + + object.matrixWorld.flattenToArray( object._objectMatrixArray ); + //object._modelViewMatrix.multiplyToArray( camera.matrixWorldInverse, object.matrixWorld, object._modelViewMatrixArray ); + + _gl.uniformMatrix4fv( p_uniforms.objectMatrix, false, object._objectMatrixArray ); + //_gl.uniformMatrix4fv( p_uniforms.modelViewMatrix, false, object._modelViewMatrixArray ); + + + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLVertexBuffer ); + _gl.vertexAttribPointer( attributes.position, 3, _gl.FLOAT, false, 0, 0 ); + + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLNormalBuffer ); + _gl.vertexAttribPointer( attributes.normal, 3, _gl.FLOAT, false, 0, 0 ); + + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webGLFaceBuffer ); + + _gl.cullFace( _gl.FRONT ); + _gl.drawElements( _gl.TRIANGLES, geometryGroup.__webGLFaceCount, _gl.UNSIGNED_SHORT, 0 ); + + _gl.cullFace( _gl.BACK ); + _gl.drawElements( _gl.TRIANGLES, geometryGroup.__webGLFaceCount, _gl.UNSIGNED_SHORT, 0 ); + + } + + } + + } + + + // draw darkening polygon + + _gl.disable( _gl.POLYGON_OFFSET_FILL ); + _gl.colorMask( true, true, true, true ); + _gl.stencilFunc( _gl.NOTEQUAL, 0, 0xFF ); + _gl.stencilOp( _gl.KEEP, _gl.KEEP, _gl.KEEP ); + _gl.disable( _gl.DEPTH_TEST ); + + _gl.enable( _gl.BLEND ); + _gl.blendFunc( _gl.ONE, _gl.ONE_MINUS_SRC_ALPHA ); + _gl.blendEquation( _gl.FUNC_ADD ); + + + _oldBlending = ""; + _oldProgram = _shadow.program; + + _gl.useProgram( _shadow.program ); + _gl.uniformMatrix4fv( _shadow.projectionLocation, false, _projectionMatrixArray ); + + _gl.bindBuffer( _gl.ARRAY_BUFFER, _shadow.vertexBuffer ); + _gl.vertexAttribPointer( _shadow.vertexLocation, 3, _gl.FLOAT, false, 0, 0 ); + _gl.enableVertexAttribArray( _shadow.vertexLocation ); + + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, _shadow.elementBuffer ); + _gl.drawElements( _gl.TRIANGLES, 6, _gl.UNSIGNED_SHORT, 0 ); + + + // disable stencil + + _gl.disable ( _gl.STENCIL_TEST ); + _gl.enable ( _gl.DEPTH_TEST ); + _gl.disable ( _gl.BLEND ); + _gl.depthMask( true ); + } + + + //////////////////////// stencil shadows end ////////////////////// + + // Generate mipmap if we're using any kind of mipmap filtering if ( renderTarget && renderTarget.minFilter !== THREE.NearestFilter && renderTarget.minFilter !== THREE.LinearFilter ) { @@ -2473,7 +2700,7 @@ THREE.WebGLRenderer = function ( parameters ) { scene.__webglObjects = []; scene.__webglObjectsImmediate = []; - + scene.__webglShadowVolumes = []; } while ( scene.__objectsAdded.length ) { @@ -2497,6 +2724,13 @@ THREE.WebGLRenderer = function ( parameters ) { updateObject( scene.__webglObjects[ o ].object, scene ); } + + for ( var o = 0, ol = scene.__webglShadowVolumes.length; o < ol; o ++ ) { + + updateObject( scene.__webglShadowVolumes[ o ].object, scene ); + + } + }; @@ -2551,8 +2785,15 @@ THREE.WebGLRenderer = function ( parameters ) { // create separate wrapper per each use of VBO - addBuffer( scene.__webglObjects, geometryGroup, object ); - + if( object instanceof THREE.ShadowVolume ) { + + addBuffer( scene.__webglShadowVolumes, geometryGroup, object ); + + } else { + + addBuffer( scene.__webglObjects, geometryGroup, object ); + + } } } else if ( object instanceof THREE.Ribbon ) { @@ -2861,7 +3102,7 @@ THREE.WebGLRenderer = function ( parameters ) { try { - if ( ! ( _gl = _canvas.getContext( 'experimental-webgl', { antialias: antialias } ) ) ) { + if ( ! ( _gl = _canvas.getContext( 'experimental-webgl', { antialias: antialias, stencil:true } ) ) ) { throw 'Error creating WebGL context.'; @@ -3354,7 +3595,10 @@ THREE.WebGLRenderer = function ( parameters ) { case THREE.LinearFilter: case THREE.LinearMipMapNearestFilter: - case THREE.LinearMipMapLinearFilter: return _gl.LINEAR; break; + case THREE.LinearMipMapLinearFilter: + default: + + return _gl.LINEAR; break; } diff --git a/src/renderers/WebGLShaders.js b/src/renderers/WebGLShaders.js index 42dcc3ed..7778595f 100644 --- a/src/renderers/WebGLShaders.js +++ b/src/renderers/WebGLShaders.js @@ -6,6 +6,7 @@ THREE.ShaderChunk = { + // FOG fog_pars_fragment: [ @@ -555,6 +556,66 @@ THREE.UniformsLib = { THREE.ShaderLib = { + 'shadowPost': { + + vertexShader: [ + + "uniform mat4 projectionMatrix;", + "attribute vec3 position;", + + "void main(void)", + "{", + "gl_Position = projectionMatrix * vec4( position, 1.0 );", + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "#ifdef GL_ES", + "precision highp float;", + "#endif", + + "void main( void )", + "{", + "gl_FragColor = vec4( 0, 0, 0, 0.5 );", + "}" + + ].join( "\n" ) + + }, + + + 'shadowVolumeDynamic': { + + uniforms: { "directionalLightDirection": { type: "fv", value: [] }}, + + vertexShader: [ + + "uniform vec3 directionalLightDirection;", + + "void main() {", + + "vec4 pos = objectMatrix * vec4( position, 1.0 );", + "vec3 norm = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;", + "vec4 extruded = vec4( directionalLightDirection * 5000.0 * step( 0.0, dot( directionalLightDirection, norm )), 0.0 );", + "gl_Position = projectionMatrix * viewMatrix * ( pos + extruded );", + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "void main() {", + + "gl_FragColor = vec4( 1, 1, 1, 1 );", + + "}" + + ].join( "\n" ) + }, + + 'depth': { uniforms: { "mNear": { type: "f", value: 1.0 }, diff --git a/utils/build.py b/utils/build.py index c5d96123..3e024f6f 100644 --- a/utils/build.py +++ b/utils/build.py @@ -46,6 +46,7 @@ COMMON_FILES = [ 'materials/MeshNormalMaterial.js', 'materials/MeshFaceMaterial.js', 'materials/MeshShaderMaterial.js', +'materials/ShadowVolumeDynamicMaterial.js', 'materials/ParticleBasicMaterial.js', 'materials/ParticleCanvasMaterial.js', 'materials/ParticleDOMMaterial.js', @@ -61,6 +62,7 @@ COMMON_FILES = [ 'objects/Ribbon.js', 'objects/Sound.js', 'objects/LOD.js', +'objects/ShadowVolume.js', 'scenes/Scene.js', 'scenes/Fog.js', 'scenes/FogExp2.js', @@ -268,6 +270,7 @@ WEBGL_FILES = [ 'materials/MeshFaceMaterial.js', 'materials/MeshShaderMaterial.js', 'materials/ParticleBasicMaterial.js', +'materials/ShadowVolumeDynamicMaterial.js', 'materials/Texture.js', 'materials/RenderTarget.js', 'materials/Uniforms.js', @@ -280,6 +283,7 @@ WEBGL_FILES = [ 'objects/Ribbon.js', 'objects/Sound.js', 'objects/LOD.js', +'objects/ShadowVolume.js', 'scenes/Scene.js', 'scenes/Fog.js', 'scenes/FogExp2.js', diff --git a/utils/exporters/convert_obj_three.py b/utils/exporters/convert_obj_three.py index 1e1baab9..d546d29a 100644 --- a/utils/exporters/convert_obj_three.py +++ b/utils/exporters/convert_obj_three.py @@ -846,7 +846,9 @@ def convert_ascii(infile, morphfiles, outfile): morphData = [] for mfilepattern in morphfiles.split(): - for path in glob.glob(mfilepattern): + matches = glob.glob(mfilepattern) + matches.sort() + for path in matches: normpath = os.path.normpath(path) if normpath != norminfile or not skipOriginalMorph: name = os.path.basename(normpath) @@ -1276,4 +1278,4 @@ if __name__ == "__main__": convert_ascii(infile, morphfiles, outfile) elif TYPE == "binary": convert_binary(infile, outfile) - \ No newline at end of file +