From dedf6a203515ececad83ab5d4cd84f340112e576 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Thu, 24 Mar 2011 07:07:47 +0000 Subject: [PATCH 01/10] convert_obj_three.py: sorting morph filenames (again :P) --- utils/exporters/convert_obj_three.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 + From 95e92d902659062931b2e975f809dc06ecd7494e Mon Sep 17 00:00:00 2001 From: Mikael Emtinger Date: Thu, 24 Mar 2011 09:09:25 +0100 Subject: [PATCH 02/10] Stencil shadows added --- build/Three.js | 586 ++++++++++--------- examples/webgl_stencil.html | 190 ++++++ src/materials/ShadowVolumeDynamicMaterial.js | 59 ++ src/objects/ShadowVolume.js | 200 +++++++ src/renderers/WebGLRenderer.js | 226 ++++++- src/renderers/WebGLShaders.js | 63 ++ utils/build.py | 2 + 7 files changed, 1029 insertions(+), 297 deletions(-) create mode 100644 examples/webgl_stencil.html create mode 100644 src/materials/ShadowVolumeDynamicMaterial.js create mode 100644 src/objects/ShadowVolume.js diff --git a/build/Three.js b/build/Three.js index 0879518a..dfeccfd5 100755 --- a/build/Three.js +++ b/build/Three.js @@ -1,7 +1,7 @@ // 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,k,j;if(b==0)d=e=g=0;else{h=Math.floor(a*6);k=a*6-h;a=b*(1-c);j=b*(1-c*k);c=b*(1-c*(1-k));switch(h){case 1:d=j;e=b;g=a;break;case 2:d=a;e=b;g=c;break;case 3:d=a;e=j;g=b;break;case 4:d=c;e=a;g=b;break;case 5:d=b;e=a; -g=j;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 d,f,g,h,k,m;if(b==0)d=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:d=m;f=b;g=a;break;case 2:d=a;f=b;g=c;break;case 3:d=a;f=m;g=b;break;case 4:d=c;f=a;g=b;break;case 5:d=b;f=a; +g=m;break;case 6:case 0:d=b;f=c;g=a}}this.r=d;this.g=f;this.b=g;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* 255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,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)}; @@ -12,78 +12,77 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPosit 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,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* 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&&H>0&&Q+H<1}var b,d,e,g,h,k,j,m,t,x, -y,q=a.geometry,z=q.vertices,G=[];b=0;for(d=q.faces.length;bj?d:j;e=e>m?e:m}a()}; -this.add3Points=function(j,m,t,x,y,q){if(k){k=!1;c=jt?j>y?j:y:t>y?t:y;e=m>x?m>q?m:q:x>q?x:q}else{c=jt?j>y?j>d?j:d:y>d?y:d:t>y?t>d?t:d:y>d?y:d;e=m>x?m>q?m>e?m:e:q>e?q:e:x>q?x>e?x:e:q>e?q:e}a()};this.addRectangle=function(j){if(k){k=!1;c=j.getLeft();b=j.getTop();d=j.getRight();e=j.getBottom()}else{c=cj.getRight()? -d:j.getRight();e=e>j.getBottom()?e:j.getBottom()}a()};this.inflate=function(j){c-=j;b-=j;d+=j;e+=j;a()};this.minSelf=function(j){c=c>j.getLeft()?c:j.getLeft();b=b>j.getTop()?b:j.getTop();d=d=0&&Math.min(e,j.getBottom())-Math.max(b,j.getTop())>=0};this.empty=function(){k=!0;e=d=b=c=0;a()};this.isEmpty=function(){return k}}; +THREE.Ray.prototype={intersectScene:function(a){var c,b,d=a.objects,f=[];a=0;for(c=d.length;a0&&I>0&&P+I<1}var b,d,f,g,h,k,m,n,q,x, +z,p=a.geometry,A=p.vertices,G=[];b=0;for(d=p.faces.length;bm?d:m;f=f>n?f:n}a()}; +this.add3Points=function(m,n,q,x,z,p){if(k){k=!1;c=mq?m>z?m:z:q>z?q:z;f=n>x?n>p?n:p:x>p?x:p}else{c=mq?m>z?m>d?m:d:z>d?z:d:q>z?q>d?q:d:z>d?z:d;f=n>x?n>p?n>f?n:f:p>f?p:f:x>p?x>f?x:f:p>f?p:f}a()};this.addRectangle=function(m){if(k){k=!1;c=m.getLeft();b=m.getTop();d=m.getRight();f=m.getBottom()}else{c=cm.getRight()? +d:m.getRight();f=f>m.getBottom()?f:m.getBottom()}a()};this.inflate=function(m){c-=m;b-=m;d+=m;f+=m;a()};this.minSelf=function(m){c=c>m.getLeft()?c:m.getLeft();b=b>m.getTop()?b:m.getTop();d=d=0&&Math.min(f,m.getBottom())-Math.max(b,m.getTop())>=0};this.empty=function(){k=!0;f=d=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,k,j,m,t,x,y,q,z,G){this.set(a||1,c||0,b||0,d||0,e||0,g||1,h||0,k||0,j||0,m||0,t||1,x||0,y||0,q||0,z||0,G||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(a,c,b,d,e,g,h,k,j,m,t,x,y,q,z,G){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=k;this.n31=j;this.n32=m;this.n33=t;this.n34=x;this.n41=y;this.n42=q;this.n43=z;this.n44=G;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(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,k=a.n22,j=a.n23,m=a.n24,t=a.n31,x=a.n32,y=a.n33,q=a.n34,z=a.n41,G=a.n42,H=a.n43,E=a.n44,I=c.n11,A=c.n12,S=c.n13,Q=c.n14,O=c.n21,X=c.n22, -f=c.n23,ea=c.n24,ka=c.n31,W=c.n32,T=c.n33,xa=c.n34;this.n11=b*I+d*O+e*ka;this.n12=b*A+d*X+e*W;this.n13=b*S+d*f+e*T;this.n14=b*Q+d*ea+e*xa+g;this.n21=h*I+k*O+j*ka;this.n22=h*A+k*X+j*W;this.n23=h*S+k*f+j*T;this.n24=h*Q+k*ea+j*xa+m;this.n31=t*I+x*O+y*ka;this.n32=t*A+x*X+y*W;this.n33=t*S+x*f+y*T;this.n34=t*Q+x*ea+y*xa+q;this.n41=z*I+G*O+H*ka;this.n42=z*A+G*X+H*W;this.n43=z*S+G*f+H*T;this.n44=z*Q+G*ea+H*xa+E;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,k=this.n24,j=this.n31,m=this.n32,t=this.n33,x=this.n34,y=this.n41,q=this.n42,z=this.n43,G=this.n44;return d*h*m*y-b*k*m*y-d*g*t*y+c*k*t*y+b*g*x*y-c*h*x*y-d*h*j*q+b*k*j*q+d*e*t*q-a*k*t*q-b*e*x*q+a*h*x*q+d*g*j*z-c*k*j*z-d*e*m*z+a*k*m*z+c*e*x*z-a*g*x*z-b*g*j*G+c*h*j*G+b*e*m*G-a*h*m*G-c*e*t*G+a*g*t*G},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,k= -a.z,j=e*g,m=e*h;this.set(j*g+b,j*h-d*k,j*k+d*h,0,j*h+d*k,m*h+b,m*k-d*g,0,j*k-d*h,m*k+d*g,e*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,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,k=c*b;this.n11=e*g;this.n12=-e*d;this.n13=b;this.n21=k*g+a*d;this.n22=-k*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,k=d+d;a=c*g;var j=c*h;c*=k;var m=b*h;b*=k;d*=k;g*=e;h*=e;e*=k;this.n11=1-(m+d);this.n12=j-e;this.n13=c+h;this.n21=j+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,k=a.n22,j=a.n23,m=a.n24,t=a.n31,x=a.n32,y=a.n33,q=a.n34,z=a.n41,G=a.n42,H=a.n43,E=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=j*q*G-m*y*G+m*x*H-k*q*H-j*x*E+k*y*E;c.n12=g*y*G-e*q*G-g*x*H+d*q*H+e*x*E-d*y*E;c.n13=e*m*G-g*j*G+g*k*H-d*m*H-e*k*E+d*j*E;c.n14=g*j*x-e*m*x-g*k*y+d*m*y+e*k*q-d*j*q;c.n21=m*y*z-j*q*z-m*t*H+h*q*H+j*t*E-h*y*E;c.n22=e*q*z-g*y*z+g*t*H-b*q*H-e*t*E+b*y*E;c.n23=g*j*z-e*m*z-g*h*H+b*m*H+e*h*E-b*j*E; -c.n24=e*m*t-g*j*t+g*h*y-b*m*y-e*h*q+b*j*q;c.n31=k*q*z-m*x*z+m*t*G-h*q*G-k*t*E+h*x*E;c.n32=g*x*z-d*q*z-g*t*G+b*q*G+d*t*E-b*x*E;c.n33=e*m*z-g*k*z+g*h*G-b*m*G-d*h*E+b*k*E;c.n34=g*k*t-d*m*t-g*h*x+b*m*x+d*h*q-b*k*q;c.n41=j*x*z-k*y*z-j*t*G+h*y*G+k*t*H-h*x*H;c.n42=d*y*z-e*x*z+e*t*G-b*y*G-d*t*H+b*x*H;c.n43=e*k*z-d*j*z-e*h*G+b*j*G+d*h*H-b*k*H;c.n44=d*j*t-e*k*t+e*h*x-b*j*x-d*h*y+b*k*y;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,k=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,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*k;b[5]=a*j;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,k,j,m;h=new THREE.Matrix4;k=c-a;j=b-d;m=g-e;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-((c+a)/k);h.n21=0;h.n22=2/j;h.n23=0;h.n24=-((b+d)/j);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; +THREE.Matrix4=function(a,c,b,d,f,g,h,k,m,n,q,x,z,p,A,G){this.set(a||1,c||0,b||0,d||0,f||0,g||1,h||0,k||0,m||0,n||0,q||1,x||0,z||0,p||0,A||0,G||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(a,c,b,d,f,g,h,k,m,n,q,x,z,p,A,G){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=f;this.n22=g;this.n23=h;this.n24=k;this.n31=m;this.n32=n;this.n33=q;this.n34=x;this.n41=z;this.n42=p;this.n43=A;this.n44=G;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(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, +f=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()}f.cross(g,d).normalize();this.n11=d.x;this.n12=f.x;this.n13=g.x;this.n21=d.y;this.n22=f.y;this.n23=g.y;this.n31=d.z;this.n32=f.z;this.n33=g.z;return this},multiplyVector3:function(a){var c=a.x,b=a.y,d=a.z,f=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)*f;a.y=(this.n21*c+this.n22*b+this.n23* +d+this.n24)*f;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*f;return a},multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,f=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*f;a.y=this.n21*c+this.n22*b+this.n23*d+this.n24*f;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*f;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*f;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,f=a.n13,g=a.n14,h=a.n21,k=a.n22,m=a.n23,n=a.n24,q=a.n31,x=a.n32,z=a.n33,p=a.n34,A=a.n41,G=a.n42,I=a.n43,C=a.n44,J=c.n11,B=c.n12,U=c.n13,P=c.n14,O=c.n21,V=c.n22, +Y=c.n23,e=c.n24,ja=c.n31,X=c.n32,W=c.n33,wa=c.n34;this.n11=b*J+d*O+f*ja;this.n12=b*B+d*V+f*X;this.n13=b*U+d*Y+f*W;this.n14=b*P+d*e+f*wa+g;this.n21=h*J+k*O+m*ja;this.n22=h*B+k*V+m*X;this.n23=h*U+k*Y+m*W;this.n24=h*P+k*e+m*wa+n;this.n31=q*J+x*O+z*ja;this.n32=q*B+x*V+z*X;this.n33=q*U+x*Y+z*W;this.n34=q*P+x*e+z*wa+p;this.n41=A*J+G*O+I*ja;this.n42=A*B+G*V+I*X;this.n43=A*U+G*Y+I*W;this.n44=A*P+G*e+I*wa+C;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,f=this.n21,g=this.n22,h=this.n23,k=this.n24,m=this.n31,n=this.n32,q=this.n33,x=this.n34,z=this.n41,p=this.n42,A=this.n43,G=this.n44;return d*h*n*z-b*k*n*z-d*g*q*z+c*k*q*z+b*g*x*z-c*h*x*z-d*h*m*p+b*k*m*p+d*f*q*p-a*k*q*p-b*f*x*p+a*h*x*p+d*g*m*A-c*k*m*A-d*f*n*A+a*k*n*A+c*f*x*A-a*g*x*A-b*g*m*G+c*h*m*G+b*f*n*G-a*h*n*G-c*f*q*G+a*g*q*G},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),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-d*k,m*k+d*h,0,m*h+d*k,n*h+b,n*k-d*g,0,m*k-d*h,n*k+d*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,d=a.z;a=Math.cos(c);c=Math.sin(c);var f=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var h=a*b,k=c*b;this.n11=f*g;this.n12=-f*d;this.n13=b;this.n21=k*g+a*d;this.n22=-k*d+a*g;this.n23=-c*f;this.n31=-h*g+c*d;this.n32=h*d+c*g;this.n33=a*f;return this},setRotationFromQuaternion:function(a){var c= +a.x,b=a.y,d=a.z,f=a.w,g=c+c,h=b+b,k=d+d;a=c*g;var m=c*h;c*=k;var n=b*h;b*=k;d*=k;g*=f;h*=f;f*=k;this.n11=1-(n+d);this.n12=m-f;this.n13=c+h;this.n21=m+f;this.n22=1-(a+d);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,d=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*d;this.n22=a.n22*d;this.n32=a.n32*d;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,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,m=a.n23,n=a.n24,q=a.n31,x=a.n32,z=a.n33,p=a.n34,A=a.n41,G=a.n42,I=a.n43,C=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=m*p*G-n*z*G+n*x*I-k*p*I-m*x*C+k*z*C;c.n12=g*z*G-f*p*G-g*x*I+d*p*I+f*x*C-d*z*C;c.n13=f*n*G-g*m*G+g*k*I-d*n*I-f*k*C+d*m*C;c.n14=g*m*x-f*n*x-g*k*z+d*n*z+f*k*p-d*m*p;c.n21=n*z*A-m*p*A-n*q*I+h*p*I+m*q*C-h*z*C;c.n22=f*p*A-g*z*A+g*q*I-b*p*I-f*q*C+b*z*C;c.n23=g*m*A-f*n*A-g*h*I+b*n*I+f*h*C-b*m*C; +c.n24=f*n*q-g*m*q+g*h*z-b*n*z-f*h*p+b*m*p;c.n31=k*p*A-n*x*A+n*q*G-h*p*G-k*q*C+h*x*C;c.n32=g*x*A-d*p*A-g*q*G+b*p*G+d*q*C-b*x*C;c.n33=f*n*A-g*k*A+g*h*G-b*n*G-d*h*C+b*k*C;c.n34=g*k*q-d*n*q-g*h*x+b*n*x+d*h*p-b*k*p;c.n41=m*x*A-k*z*A-m*q*G+h*z*G+k*q*I-h*x*I;c.n42=d*z*A-f*x*A+f*q*G-b*z*G-d*q*I+b*x*I;c.n43=f*k*A-d*m*A-f*h*G+b*m*G+d*h*I-b*k*I;c.n44=d*m*q-f*k*q+f*h*x-b*m*x-d*h*z+b*k*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,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,q=-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*n;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*d;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*q;b[8]=a*x;return c}; +THREE.Matrix4.makeFrustum=function(a,c,b,d,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/(d-b);h.n23=(d+b)/(d-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,d){var f;a=b*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,b,d)}; +THREE.Matrix4.makeOrtho=function(a,c,b,d,f,g){var h,k,m,n;h=new THREE.Matrix4;k=c-a;m=b-d;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+d)/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.001){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)}; +THREE.Quaternion.prototype={set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},setFromEuler:function(a){var c=0.5*Math.PI/360,b=a.x*c,d=a.y*c,f=a.z*c;a=Math.cos(d);d=Math.sin(d);c=Math.cos(-f);f=Math.sin(-f);var g=Math.cos(b);b=Math.sin(b);var h=a*c,k=d*f;this.w=h*g-k*b;this.x=h*b+k*g;this.y=d*c*g+a*f*b;this.z=a*f*g-d*c*b;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*= +-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var c=this.x,b=this.y,d=this.z,f=this.w,g=a.x,h=a.y,k=a.z;a=a.w;this.x=c*a+f*g+b*k-d*h;this.y=b*a+f*h+d*g-c*k;this.z=d*a+f*k+c*h-b*g;this.w=f*a-c*g-b*h-d*k;return this}, +multiplyVector3:function(a,c){c||(c=a);var b=a.x,d=a.y,f=a.z,g=this.x,h=this.y,k=this.z,m=this.w,n=m*b+h*f-k*d,q=m*d+k*b-g*f,x=m*f+g*d-h*b;b=-g*b-h*d-k*f;c.x=n*m+b*-g+q*-k-x*-h;c.y=q*m+b*-h+x*-g-n*-k;c.z=x*m+b*-k+n*-h-q*-g;return c}}; +THREE.Quaternion.slerp=function(a,c,b,d){var f=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;if(Math.abs(f)>=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-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*f+c.w*d;b.x=a.x*f+c.x*d;b.y=a.y*f+c.y*d;b.z=a.z*f+c.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; +THREE.Face3=function(a,c,b,d,f,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=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,d,f,g,h){this.a=a;this.b=c;this.c=b;this.d=d;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]];y=this.points[b[3]];k=h*h;j=h*k;d.x=c(m.x,t.x,x.x,y.x,h,k,j);d.y=c(m.y,t.y,x.y,y.y,h,k,j);d.z=c(m.z,t.z,x.z,y.z,h,k,j);return d};this.getControlPointsArray=function(){var q,z,G=this.points.length,H=[];for(q=0;q0){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;n=this.points[b[0]];q=this.points[b[1]]; +x=this.points[b[2]];z=this.points[b[3]];k=h*h;m=h*k;d.x=c(n.x,q.x,x.x,z.x,h,k,m);d.y=c(n.y,q.y,x.y,z.y,h,k,m);d.z=c(n.z,q.z,x.z,z.z,h,k,m);return d};this.getControlPointsArray=function(){var p,A,G=this.points.length,I=[];for(p=0;p1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+q);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",q,h.index-1).pos;this.points[1]=e;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",q,k.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(q=0;qa.length-2?g:g+1;b[3]=g>a.length-3?g:g+2;g=a[b[0]];k=a[b[1]];j=a[b[2]];m=a[b[3]];b=e*e;h=e*b;d[0]=this.interpolate(g[0],k[0],j[0],m[0],e,b,h);d[1]=this.interpolate(g[1],k[1],j[1],m[1],e,b,h);d[2]=this.interpolate(g[2],k[2],j[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=b1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+p);d=d<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=f[0]+(g[0]-f[0])*d;b.y=f[1]+(g[1]-f[1])*d;b.z=f[2]+(g[2]-f[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= +this.getPrevKeyWith("pos",p,h.index-1).pos;this.points[1]=f;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",p,k.index+1).pos;d=d*0.33+0.33;f=this.interpolateCatmullRom(this.points,d);b.x=f[0];b.y=f[1];b.z=f[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(f,g,a.quaternion,d);else if(b==="scl"){b=a.scale;b.x=f[0]+(g[0]-f[0])*d;b.y=f[1]+(g[1]-f[1])*d;b.z=f[2]+(g[2]-f[2])*d}}}}if(this.JITCompile&&q[0][n]===undefined){this.hierarchy[0].update(undefined,!0);for(p=0;pa.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;d[0]=this.interpolate(g[0],k[0],m[0],n[0],f,b,h);d[1]=this.interpolate(g[1],k[1],m[1],n[1],f,b,h);d[2]=this.interpolate(g[2],k[2],m[2],n[2],f,b,h);return d}; +THREE.Animation.prototype.interpolate=function(a,c,b,d,f,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*f+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.Camera=function(a,c,b,d,f){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=b||0.1;this.far=d||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(;d=0&&ja>=0&&oa>=0&&la>=0)return!0;else if(Da<0&&ja<0||oa<0&&la<0)return!1;else{if(Da<0)xa=Math.max(xa,Da/(Da-ja));else ja<0&&(ca=Math.min(ca,Da/(Da-ja)));if(oa<0)xa=Math.max(xa,oa/(oa-la));else la<0&&(ca=Math.min(ca,oa/(oa-la)));if(caDa&&h.positionScreen.z0&&Q.z<1){La=A[I]=A[I]||new THREE.RenderableParticle;I++;E=La;E.x=Q.x/Q.w;E.y=Q.y/Q.w;E.z=Q.z;E.rotation=ya.rotation.z;E.scale.x=ya.scale.x*Math.abs(E.x-(Q.x+T.projectionMatrix.n11)/(Q.w+T.projectionMatrix.n14));E.scale.y=ya.scale.y*Math.abs(E.y-(Q.y+T.projectionMatrix.n22)/(Q.w+T.projectionMatrix.n24));E.materials=ya.materials;ca.push(E)}}}}xa&&ca.sort(c);return ca}}; -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,k){b=h;d=k;e=b/2;g=d/2};this.render=function(h,k){var j,m,t,x,y,q,z,G;a=c.projectScene(h,k);j=0;for(m=a.length;j0){fa.r+=pa.r*qa;fa.g+=pa.g*qa;fa.b+=pa.b*qa}}else if(qa instanceof THREE.PointLight){$.sub(qa.position,Y);$.normalize();qa=U.dot($)*R;if(qa>0){fa.r+= -pa.r*qa;fa.g+=pa.g*qa;fa.b+=pa.b*qa}}}}function ga(J,Y,U){a(U.opacity);c(U.blending);var fa,za,qa,pa,R,Ka;if(U instanceof THREE.ParticleBasicMaterial){if(U.map){pa=U.map.image;R=pa.width>>1;Ka=pa.height>>1;U=Y.scale.x*k;qa=Y.scale.y*j;fa=U*R;za=qa*Ka;F.set(J.x-fa,J.y-za,J.x+fa,J.y+za);if(D.instersects(F)){m.save();m.translate(J.x,J.y);m.rotate(-Y.rotation);m.scale(U,-qa);m.translate(-R,-Ka);m.drawImage(pa,0,0);m.restore()}}}else if(U instanceof THREE.ParticleCanvasMaterial){if(Z){N.r=K.r+ra.r+Ea.r; -N.g=K.g+ra.g+Ea.g;N.b=K.b+ra.b+Ea.b;aa.r=U.color.r*N.r;aa.g=U.color.g*N.g;aa.b=U.color.b*N.b;aa.updateStyleString()}else aa.__styleString=U.color.__styleString;fa=Y.scale.x*k;za=Y.scale.y*j;F.set(J.x-fa,J.y-za,J.x+fa,J.y+za);if(D.instersects(F)){m.save();m.translate(J.x,J.y);m.rotate(-Y.rotation);m.scale(fa,za);U.program(m,aa);m.restore()}}}function ha(J,Y,U,fa){a(fa.opacity);c(fa.blending);m.beginPath();m.moveTo(J.positionScreen.x,J.positionScreen.y);m.lineTo(Y.positionScreen.x,Y.positionScreen.y); -m.closePath();if(fa instanceof THREE.LineBasicMaterial){aa.__styleString=fa.color.__styleString;J=fa.linewidth;if(H!=J)m.lineWidth=H=J;J=aa.__styleString;if(z!=J)m.strokeStyle=z=J;m.stroke();F.inflate(fa.linewidth*2)}}function na(J,Y,U,fa,za,qa,pa,R,Ka){a(R.opacity);c(R.blending);X=J.positionScreen.x;f=J.positionScreen.y;ea=Y.positionScreen.x;ka=Y.positionScreen.y;W=U.positionScreen.x;T=U.positionScreen.y;Sa(X,f,ea,ka,W,T);if(R instanceof THREE.MeshBasicMaterial)if(R.map){if(R.map.mapping instanceof -THREE.UVMapping){La=pa.uvs[0];Ta(X,f,ea,ka,W,T,R.map.image,La[fa].u,La[fa].v,La[za].u,La[za].v,La[qa].u,La[qa].v)}}else if(R.envMap){if(R.envMap.mapping instanceof THREE.SphericalReflectionMapping){J=Ba.matrixWorldInverse;$.copy(pa.vertexNormalsWorld[0]);ab=($.x*J.n11+$.y*J.n12+$.z*J.n13)*0.5+0.5;n=-($.x*J.n21+$.y*J.n22+$.z*J.n23)*0.5+0.5;$.copy(pa.vertexNormalsWorld[1]);C=($.x*J.n11+$.y*J.n12+$.z*J.n13)*0.5+0.5;p=-($.x*J.n21+$.y*J.n22+$.z*J.n23)*0.5+0.5;$.copy(pa.vertexNormalsWorld[2]);o=($.x*J.n11+ -$.y*J.n12+$.z*J.n13)*0.5+0.5;w=-($.x*J.n21+$.y*J.n22+$.z*J.n23)*0.5+0.5;Ta(X,f,ea,ka,W,T,R.envMap.image,ab,n,C,p,o,w)}}else R.wireframe?Na(R.color.__styleString,R.wireframeLinewidth):Xa(R.color.__styleString);else if(R instanceof THREE.MeshLambertMaterial){if(R.map&&!R.wireframe){if(R.map.mapping instanceof THREE.UVMapping){La=pa.uvs[0];Ta(X,f,ea,ka,W,T,R.map.image,La[fa].u,La[fa].v,La[za].u,La[za].v,La[qa].u,La[qa].v)}c(THREE.SubtractiveBlending)}if(Z)if(!R.wireframe&&R.shading==THREE.SmoothShading&& -pa.vertexNormalsWorld.length==3){P.r=M.r=da.r=K.r;P.g=M.g=da.g=K.g;P.b=M.b=da.b=K.b;ua(Ka,pa.v1.positionWorld,pa.vertexNormalsWorld[0],P);ua(Ka,pa.v2.positionWorld,pa.vertexNormalsWorld[1],M);ua(Ka,pa.v3.positionWorld,pa.vertexNormalsWorld[2],da);sa.r=(M.r+da.r)*0.5;sa.g=(M.g+da.g)*0.5;sa.b=(M.b+da.b)*0.5;ya=Ja(P,M,da,sa);Ta(X,f,ea,ka,W,T,ya,0,0,1,0,0,1)}else{N.r=K.r;N.g=K.g;N.b=K.b;ua(Ka,pa.centroidWorld,pa.normalWorld,N);aa.r=R.color.r*N.r;aa.g=R.color.g*N.g;aa.b=R.color.b*N.b;aa.updateStyleString(); -R.wireframe?Na(aa.__styleString,R.wireframeLinewidth):Xa(aa.__styleString)}else R.wireframe?Na(R.color.__styleString,R.wireframeLinewidth):Xa(R.color.__styleString)}else if(R instanceof THREE.MeshDepthMaterial){ia=Ba.near;ta=Ba.far;P.r=P.g=P.b=1-Va(J.positionScreen.z,ia,ta);M.r=M.g=M.b=1-Va(Y.positionScreen.z,ia,ta);da.r=da.g=da.b=1-Va(U.positionScreen.z,ia,ta);sa.r=(M.r+da.r)*0.5;sa.g=(M.g+da.g)*0.5;sa.b=(M.b+da.b)*0.5;ya=Ja(P,M,da,sa);Ta(X,f,ea,ka,W,T,ya,0,0,1,0,0,1)}else if(R instanceof THREE.MeshNormalMaterial){aa.r= -Oa(pa.normalWorld.x);aa.g=Oa(pa.normalWorld.y);aa.b=Oa(pa.normalWorld.z);aa.updateStyleString();R.wireframe?Na(aa.__styleString,R.wireframeLinewidth):Xa(aa.__styleString)}}function Pa(J,Y,U,fa,za,qa,pa,R,Ka){a(R.opacity);c(R.blending);if(R.map||R.envMap){na(J,Y,fa,0,1,3,pa,R,Ka);na(za,U,qa,1,2,3,pa,R,Ka)}else{X=J.positionScreen.x;f=J.positionScreen.y;ea=Y.positionScreen.x;ka=Y.positionScreen.y;W=U.positionScreen.x;T=U.positionScreen.y;xa=fa.positionScreen.x;ca=fa.positionScreen.y;Da=za.positionScreen.x; -ja=za.positionScreen.y;oa=qa.positionScreen.x;la=qa.positionScreen.y;if(R instanceof THREE.MeshBasicMaterial){fb(X,f,ea,ka,W,T,xa,ca);R.wireframe?Na(R.color.__styleString,R.wireframeLinewidth):Xa(R.color.__styleString)}else if(R instanceof THREE.MeshLambertMaterial)if(Z)if(!R.wireframe&&R.shading==THREE.SmoothShading&&pa.vertexNormalsWorld.length==4){P.r=M.r=da.r=sa.r=K.r;P.g=M.g=da.g=sa.g=K.g;P.b=M.b=da.b=sa.b=K.b;ua(Ka,pa.v1.positionWorld,pa.vertexNormalsWorld[0],P);ua(Ka,pa.v2.positionWorld,pa.vertexNormalsWorld[1], -M);ua(Ka,pa.v4.positionWorld,pa.vertexNormalsWorld[3],da);ua(Ka,pa.v3.positionWorld,pa.vertexNormalsWorld[2],sa);ya=Ja(P,M,da,sa);Sa(X,f,ea,ka,xa,ca);Ta(X,f,ea,ka,xa,ca,ya,0,0,1,0,0,1);Sa(Da,ja,W,T,oa,la);Ta(Da,ja,W,T,oa,la,ya,1,0,1,1,0,1)}else{N.r=K.r;N.g=K.g;N.b=K.b;ua(Ka,pa.centroidWorld,pa.normalWorld,N);aa.r=R.color.r*N.r;aa.g=R.color.g*N.g;aa.b=R.color.b*N.b;aa.updateStyleString();fb(X,f,ea,ka,W,T,xa,ca);R.wireframe?Na(aa.__styleString,R.wireframeLinewidth):Xa(aa.__styleString)}else{fb(X,f, -ea,ka,W,T,xa,ca);R.wireframe?Na(R.color.__styleString,R.wireframeLinewidth):Xa(R.color.__styleString)}else if(R instanceof THREE.MeshNormalMaterial){aa.r=Oa(pa.normalWorld.x);aa.g=Oa(pa.normalWorld.y);aa.b=Oa(pa.normalWorld.z);aa.updateStyleString();fb(X,f,ea,ka,W,T,xa,ca);R.wireframe?Na(aa.__styleString,R.wireframeLinewidth):Xa(aa.__styleString)}else if(R instanceof THREE.MeshDepthMaterial){ia=Ba.near;ta=Ba.far;P.r=P.g=P.b=1-Va(J.positionScreen.z,ia,ta);M.r=M.g=M.b=1-Va(Y.positionScreen.z,ia,ta); -da.r=da.g=da.b=1-Va(fa.positionScreen.z,ia,ta);sa.r=sa.g=sa.b=1-Va(U.positionScreen.z,ia,ta);ya=Ja(P,M,da,sa);Sa(X,f,ea,ka,xa,ca);Ta(X,f,ea,ka,xa,ca,ya,0,0,1,0,0,1);Sa(Da,ja,W,T,oa,la);Ta(Da,ja,W,T,oa,la,ya,1,0,1,1,0,1)}}}function Sa(J,Y,U,fa,za,qa){m.beginPath();m.moveTo(J,Y);m.lineTo(U,fa);m.lineTo(za,qa);m.lineTo(J,Y);m.closePath()}function fb(J,Y,U,fa,za,qa,pa,R){m.beginPath();m.moveTo(J,Y);m.lineTo(U,fa);m.lineTo(za,qa);m.lineTo(pa,R);m.lineTo(J,Y);m.closePath()}function Na(J,Y){if(z!=J)m.strokeStyle= -z=J;if(H!=Y)m.lineWidth=H=Y;m.stroke();F.inflate(Y*2)}function Xa(J){if(G!=J)m.fillStyle=G=J;m.fill()}function Ta(J,Y,U,fa,za,qa,pa,R,Ka,cb,Za,db,hb){var bb,eb;bb=pa.width-1;eb=pa.height-1;R*=bb;Ka*=eb;cb*=bb;Za*=eb;db*=bb;hb*=eb;U-=J;fa-=Y;za-=J;qa-=Y;cb-=R;Za-=Ka;db-=R;hb-=Ka;bb=cb*hb-db*Za;if(bb!=0){eb=1/bb;bb=(hb*U-Za*za)*eb;Za=(hb*fa-Za*qa)*eb;U=(cb*za-db*U)*eb;fa=(cb*qa-db*fa)*eb;J=J-bb*R-U*Ka;Y=Y-Za*R-fa*Ka;m.save();m.transform(bb,Za,U,fa,J,Y);m.clip();m.drawImage(pa,0,0);m.restore()}}function Ja(J, -Y,U,fa){var za=~~(J.r*255),qa=~~(J.g*255);J=~~(J.b*255);var pa=~~(Y.r*255),R=~~(Y.g*255);Y=~~(Y.b*255);var Ka=~~(U.r*255),cb=~~(U.g*255);U=~~(U.b*255);var Za=~~(fa.r*255),db=~~(fa.g*255);fa=~~(fa.b*255);Ma[0]=za<0?0:za>255?255:za;Ma[1]=qa<0?0:qa>255?255:qa;Ma[2]=J<0?0:J>255?255:J;Ma[4]=pa<0?0:pa>255?255:pa;Ma[5]=R<0?0:R>255?255:R;Ma[6]=Y<0?0:Y>255?255:Y;Ma[8]=Ka<0?0:Ka>255?255:Ka;Ma[9]=cb<0?0:cb>255?255:cb;Ma[10]=U<0?0:U>255?255:U;Ma[12]=Za<0?0:Za>255?255:Za;Ma[13]=db<0?0:db>255?255:db;Ma[14]=fa< -0?0:fa>255?255:fa;ma.putImageData(Ga,0,0);Ia.drawImage(Aa,0,0);return wa}function Va(J,Y,U){J=(J-Y)/(U-Y);return J*J*(3-2*J)}function Oa(J){J=(J+1)*0.5;return J<0?0:J>1?1:J}function L(J,Y){var U=Y.x-J.x,fa=Y.y-J.y,za=1/Math.sqrt(U*U+fa*fa);U*=za;fa*=za;Y.x+=U;Y.y+=fa;J.x-=U;J.y-=fa}var Qa,Ua,Fa,$a,Wa,Ha,Ra,va;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,j);b=d.projectScene(Ca,Ba,this.sortElements);(Z=Ca.lights.length>0)&&Ya(Ca);Qa=0;for(Ua=b.length;Qa0){la.r+=M.color.r*da;la.g+=M.color.g*da;la.b+=M.color.b*da}}else if(M instanceof THREE.PointLight){ea.sub(M.position,oa.centroidWorld);ea.normalize();da=oa.normalWorld.dot(ea)*M.intensity;if(da>0){la.r+=M.color.r*da;la.g+=M.color.g*da;la.b+=M.color.b*da}}}}function c(ja,oa,la,aa,P,M){T=d(xa++); -T.setAttribute("d","M "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+la.positionScreen.x+","+la.positionScreen.y+"z");if(P instanceof THREE.MeshBasicMaterial)A.__styleString=P.color.__styleString;else if(P instanceof THREE.MeshLambertMaterial)if(I){S.r=Q.r;S.g=Q.g;S.b=Q.b;a(M,aa,S);A.r=P.color.r*S.r;A.g=P.color.g*S.g;A.b=P.color.b*S.b;A.updateStyleString()}else A.__styleString=P.color.__styleString;else if(P instanceof THREE.MeshDepthMaterial){f= -1-P.__2near/(P.__farPlusNear-aa.z*P.__farMinusNear);A.setRGB(f,f,f)}else P instanceof THREE.MeshNormalMaterial&&A.setRGB(e(aa.normalWorld.x),e(aa.normalWorld.y),e(aa.normalWorld.z));P.wireframe?T.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+P.wireframeLinewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.wireframeLinecap+"; stroke-linejoin: "+P.wireframeLinejoin):T.setAttribute("style","fill: "+A.__styleString+"; fill-opacity: "+P.opacity);k.appendChild(T)} -function b(ja,oa,la,aa,P,M,da){T=d(xa++);T.setAttribute("d","M "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+la.positionScreen.x+","+la.positionScreen.y+" L "+aa.positionScreen.x+","+aa.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)A.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(I){S.r=Q.r;S.g=Q.g;S.b=Q.b;a(da,P,S);A.r=M.color.r*S.r;A.g=M.color.g*S.g;A.b=M.color.b*S.b;A.updateStyleString()}else A.__styleString= -M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){f=1-M.__2near/(M.__farPlusNear-P.z*M.__farMinusNear);A.setRGB(f,f,f)}else M instanceof THREE.MeshNormalMaterial&&A.setRGB(e(P.normalWorld.x),e(P.normalWorld.y),e(P.normalWorld.z));M.wireframe?T.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+M.wireframeLinewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframeLinecap+"; stroke-linejoin: "+M.wireframeLinejoin):T.setAttribute("style","fill: "+ -A.__styleString+"; fill-opacity: "+M.opacity);k.appendChild(T)}function d(ja){if(ka[ja]==null){ka[ja]=document.createElementNS("http://www.w3.org/2000/svg","path");Da==0&&ka[ja].setAttribute("shape-rendering","crispEdges")}return ka[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,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,t,x,y,q,z,G,H=new THREE.Rectangle,E=new THREE.Rectangle,I=!1,A=new THREE.Color(16777215), -S=new THREE.Color(16777215),Q=new THREE.Color(0),O=new THREE.Color(0),X=new THREE.Color(0),f,ea=new THREE.Vector3,ka=[],W=[],T,xa,ca,Da=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ja){switch(ja){case "high":Da=1;break;case "low":Da=0}};this.setSize=function(ja,oa){j=ja;m=oa;t=j/2;x=m/2;k.setAttribute("viewBox",-t+" "+-x+" "+j+" "+m);k.setAttribute("width",j);k.setAttribute("height",m);H.set(-t,-x,t,x)};this.clear=function(){for(;k.childNodes.length> -0;)k.removeChild(k.childNodes[0])};this.render=function(ja,oa){var la,aa,P,M,da,sa,ia,ta;this.autoClear&&this.clear();g=h.projectScene(ja,oa,this.sortElements);ca=xa=0;if(I=ja.lights.length>0){ia=ja.lights;Q.setRGB(0,0,0);O.setRGB(0,0,0);X.setRGB(0,0,0);la=0;for(aa=ia.length;la=0&&ka>=0&&oa>=0&&ma>=0)return!0;else if(Aa<0&&ka<0||oa<0&&ma<0)return!1;else{if(Aa<0)wa=Math.max(wa,Aa/(Aa-ka));else ka<0&&(ha=Math.min(ha,Aa/(Aa-ka)));if(oa<0)wa=Math.max(wa,oa/(oa-ma));else ma<0&&(ha=Math.min(ha,oa/(oa-ma)));if(haAa&&h.positionScreen.z0&&P.z<1){Ca=B[J]=B[J]||new THREE.RenderableParticle;J++;C=Ca;C.x=P.x/P.w;C.y=P.y/P.w;C.z=P.z;C.rotation=xa.rotation.z;C.scale.x=xa.scale.x*Math.abs(C.x-(P.x+W.projectionMatrix.n11)/(P.w+W.projectionMatrix.n14));C.scale.y=xa.scale.y*Math.abs(C.y-(P.y+W.projectionMatrix.n22)/(P.w+W.projectionMatrix.n24));C.materials=xa.materials;ha.push(C)}}}}wa&&ha.sort(c);return ha}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,f,g;this.domElement=document.createElement("div");this.setSize=function(h,k){b=h;d=k;f=b/2;g=d/2};this.render=function(h,k){var m,n,q,x,z,p,A,G;a=c.projectScene(h,k);m=0;for(n=a.length;m0){aa.r+=ea.r*za;aa.g+=ea.g*za;aa.b+=ea.b*za}}else if(za instanceof THREE.PointLight){T.sub(za.position,Z);T.normalize();za=na.dot(T)*$;if(za>0){aa.r+= +ea.r*za;aa.g+=ea.g*za;aa.b+=ea.b*za}}}}function eb(L,Z,na){a(na.opacity);c(na.blending);var aa,ta,za,ea,$,Ka;if(na instanceof THREE.ParticleBasicMaterial){if(na.map){ea=na.map.image;$=ea.width>>1;Ka=ea.height>>1;na=Z.scale.x*k;za=Z.scale.y*m;aa=na*$;ta=za*Ka;E.set(L.x-aa,L.y-ta,L.x+aa,L.y+ta);if(o.instersects(E)){n.save();n.translate(L.x,L.y);n.rotate(-Z.rotation);n.scale(na,-za);n.translate(-$,-Ka);n.drawImage(ea,0,0);n.restore()}}}else if(na instanceof THREE.ParticleCanvasMaterial){if(K){F.r=D.r+ +Q.r+H.r;F.g=D.g+Q.g+H.g;F.b=D.b+Q.b+H.b;ca.r=na.color.r*F.r;ca.g=na.color.g*F.g;ca.b=na.color.b*F.b;ca.updateStyleString()}else ca.__styleString=na.color.__styleString;aa=Z.scale.x*k;ta=Z.scale.y*m;E.set(L.x-aa,L.y-ta,L.x+aa,L.y+ta);if(o.instersects(E)){n.save();n.translate(L.x,L.y);n.rotate(-Z.rotation);n.scale(aa,ta);na.program(n,ca);n.restore()}}}function Ta(L,Z,na,aa){a(aa.opacity);c(aa.blending);n.beginPath();n.moveTo(L.positionScreen.x,L.positionScreen.y);n.lineTo(Z.positionScreen.x,Z.positionScreen.y); +n.closePath();if(aa instanceof THREE.LineBasicMaterial){ca.__styleString=aa.color.__styleString;L=aa.linewidth;if(I!=L)n.lineWidth=I=L;L=ca.__styleString;if(A!=L)n.strokeStyle=A=L;n.stroke();E.inflate(aa.linewidth*2)}}function Ia(L,Z,na,aa,ta,za,ea,$,Ka){a($.opacity);c($.blending);V=L.positionScreen.x;Y=L.positionScreen.y;e=Z.positionScreen.x;ja=Z.positionScreen.y;X=na.positionScreen.x;W=na.positionScreen.y;bb(V,Y,e,ja,X,W);if($ instanceof THREE.MeshBasicMaterial)if($.map){if($.map.mapping instanceof +THREE.UVMapping){Ca=ea.uvs[0];Da(V,Y,e,ja,X,W,$.map.image,Ca[aa].u,Ca[aa].v,Ca[ta].u,Ca[ta].v,Ca[za].u,Ca[za].v)}}else if($.envMap){if($.envMap.mapping instanceof THREE.SphericalReflectionMapping){L=ia.matrixWorldInverse;T.copy(ea.vertexNormalsWorld[0]);Za=(T.x*L.n11+T.y*L.n12+T.z*L.n13)*0.5+0.5;$a=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;T.copy(ea.vertexNormalsWorld[1]);Ha=(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(ea.vertexNormalsWorld[2]);w=(T.x*L.n11+ +T.y*L.n12+T.z*L.n13)*0.5+0.5;t=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;Da(V,Y,e,ja,X,W,$.envMap.image,Za,$a,Ha,j,w,t)}}else $.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&!$.wireframe){if($.map.mapping instanceof THREE.UVMapping){Ca=ea.uvs[0];Da(V,Y,e,ja,X,W,$.map.image,Ca[aa].u,Ca[aa].v,Ca[ta].u,Ca[ta].v,Ca[za].u,Ca[za].v)}c(THREE.SubtractiveBlending)}if(K)if(!$.wireframe&&$.shading==THREE.SmoothShading&& +ea.vertexNormalsWorld.length==3){S.r=M.r=fa.r=D.r;S.g=M.g=fa.g=D.g;S.b=M.b=fa.b=D.b;Ga(Ka,ea.v1.positionWorld,ea.vertexNormalsWorld[0],S);Ga(Ka,ea.v2.positionWorld,ea.vertexNormalsWorld[1],M);Ga(Ka,ea.v3.positionWorld,ea.vertexNormalsWorld[2],fa);ra.r=(M.r+fa.r)*0.5;ra.g=(M.g+fa.g)*0.5;ra.b=(M.b+fa.b)*0.5;xa=Va(S,M,fa,ra);Da(V,Y,e,ja,X,W,xa,0,0,1,0,0,1)}else{F.r=D.r;F.g=D.g;F.b=D.b;Ga(Ka,ea.centroidWorld,ea.normalWorld,F);ca.r=$.color.r*F.r;ca.g=$.color.g*F.g;ca.b=$.color.b*F.b;ca.updateStyleString(); +$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else $.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){la=ia.near;qa=ia.far;S.r=S.g=S.b=1-Ma(L.positionScreen.z,la,qa);M.r=M.g=M.b=1-Ma(Z.positionScreen.z,la,qa);fa.r=fa.g=fa.b=1-Ma(na.positionScreen.z,la,qa);ra.r=(M.r+fa.r)*0.5;ra.g=(M.g+fa.g)*0.5;ra.b=(M.b+fa.b)*0.5;xa=Va(S,M,fa,ra);Da(V,Y,e,ja,X,W,xa,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){ca.r= +N(ea.normalWorld.x);ca.g=N(ea.normalWorld.y);ca.b=N(ea.normalWorld.z);ca.updateStyleString();$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}}function Ra(L,Z,na,aa,ta,za,ea,$,Ka){a($.opacity);c($.blending);if($.map||$.envMap){Ia(L,Z,aa,0,1,3,ea,$,Ka);Ia(ta,na,za,1,2,3,ea,$,Ka)}else{V=L.positionScreen.x;Y=L.positionScreen.y;e=Z.positionScreen.x;ja=Z.positionScreen.y;X=na.positionScreen.x;W=na.positionScreen.y;wa=aa.positionScreen.x;ha=aa.positionScreen.y;Aa=ta.positionScreen.x; +ka=ta.positionScreen.y;oa=za.positionScreen.x;ma=za.positionScreen.y;if($ instanceof THREE.MeshBasicMaterial){db(V,Y,e,ja,X,W,wa,ha);$.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshLambertMaterial)if(K)if(!$.wireframe&&$.shading==THREE.SmoothShading&&ea.vertexNormalsWorld.length==4){S.r=M.r=fa.r=ra.r=D.r;S.g=M.g=fa.g=ra.g=D.g;S.b=M.b=fa.b=ra.b=D.b;Ga(Ka,ea.v1.positionWorld,ea.vertexNormalsWorld[0],S);Ga(Ka,ea.v2.positionWorld,ea.vertexNormalsWorld[1], +M);Ga(Ka,ea.v4.positionWorld,ea.vertexNormalsWorld[3],fa);Ga(Ka,ea.v3.positionWorld,ea.vertexNormalsWorld[2],ra);xa=Va(S,M,fa,ra);bb(V,Y,e,ja,wa,ha);Da(V,Y,e,ja,wa,ha,xa,0,0,1,0,0,1);bb(Aa,ka,X,W,oa,ma);Da(Aa,ka,X,W,oa,ma,xa,1,0,1,1,0,1)}else{F.r=D.r;F.g=D.g;F.b=D.b;Ga(Ka,ea.centroidWorld,ea.normalWorld,F);ca.r=$.color.r*F.r;ca.g=$.color.g*F.g;ca.b=$.color.b*F.b;ca.updateStyleString();db(V,Y,e,ja,X,W,wa,ha);$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else{db(V,Y,e,ja, +X,W,wa,ha);$.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshNormalMaterial){ca.r=N(ea.normalWorld.x);ca.g=N(ea.normalWorld.y);ca.b=N(ea.normalWorld.z);ca.updateStyleString();db(V,Y,e,ja,X,W,wa,ha);$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){la=ia.near;qa=ia.far;S.r=S.g=S.b=1-Ma(L.positionScreen.z,la,qa);M.r=M.g=M.b=1-Ma(Z.positionScreen.z,la,qa);fa.r=fa.g= +fa.b=1-Ma(aa.positionScreen.z,la,qa);ra.r=ra.g=ra.b=1-Ma(na.positionScreen.z,la,qa);xa=Va(S,M,fa,ra);bb(V,Y,e,ja,wa,ha);Da(V,Y,e,ja,wa,ha,xa,0,0,1,0,0,1);bb(Aa,ka,X,W,oa,ma);Da(Aa,ka,X,W,oa,ma,xa,1,0,1,1,0,1)}}}function bb(L,Z,na,aa,ta,za){n.beginPath();n.moveTo(L,Z);n.lineTo(na,aa);n.lineTo(ta,za);n.lineTo(L,Z);n.closePath()}function db(L,Z,na,aa,ta,za,ea,$){n.beginPath();n.moveTo(L,Z);n.lineTo(na,aa);n.lineTo(ta,za);n.lineTo(ea,$);n.lineTo(L,Z);n.closePath()}function Pa(L,Z){if(A!=L)n.strokeStyle= +A=L;if(I!=Z)n.lineWidth=I=Z;n.stroke();E.inflate(Z*2)}function Ua(L){if(G!=L)n.fillStyle=G=L;n.fill()}function Da(L,Z,na,aa,ta,za,ea,$,Ka,Xa,Ya,cb,gb){var ab,Wa;ab=ea.width-1;Wa=ea.height-1;$*=ab;Ka*=Wa;Xa*=ab;Ya*=Wa;cb*=ab;gb*=Wa;na-=L;aa-=Z;ta-=L;za-=Z;Xa-=$;Ya-=Ka;cb-=$;gb-=Ka;ab=Xa*gb-cb*Ya;if(ab!=0){Wa=1/ab;ab=(gb*na-Ya*ta)*Wa;Ya=(gb*aa-Ya*za)*Wa;na=(Xa*ta-cb*na)*Wa;aa=(Xa*za-cb*aa)*Wa;L=L-ab*$-na*Ka;Z=Z-Ya*$-aa*Ka;n.save();n.transform(ab,Ya,na,aa,L,Z);n.clip();n.drawImage(ea,0,0);n.restore()}} +function Va(L,Z,na,aa){var ta=~~(L.r*255),za=~~(L.g*255);L=~~(L.b*255);var ea=~~(Z.r*255),$=~~(Z.g*255);Z=~~(Z.b*255);var Ka=~~(na.r*255),Xa=~~(na.g*255);na=~~(na.b*255);var Ya=~~(aa.r*255),cb=~~(aa.g*255);aa=~~(aa.b*255);ya[0]=ta<0?0:ta>255?255:ta;ya[1]=za<0?0:za>255?255:za;ya[2]=L<0?0:L>255?255:L;ya[4]=ea<0?0:ea>255?255:ea;ya[5]=$<0?0:$>255?255:$;ya[6]=Z<0?0:Z>255?255:Z;ya[8]=Ka<0?0:Ka>255?255:Ka;ya[9]=Xa<0?0:Xa>255?255:Xa;ya[10]=na<0?0:na>255?255:na;ya[12]=Ya<0?0:Ya>255?255:Ya;ya[13]=cb<0?0:cb> +255?255:cb;ya[14]=aa<0?0:aa>255?255:aa;pa.putImageData(sa,0,0);Ea.drawImage(ga,0,0);return ua}function Ma(L,Z,na){L=(L-Z)/(na-Z);return L*L*(3-2*L)}function N(L){L=(L+1)*0.5;return L<0?0:L>1?1:L}function Na(L,Z){var na=Z.x-L.x,aa=Z.y-L.y,ta=1/Math.sqrt(na*na+aa*aa);na*=ta;aa*=ta;Z.x+=na;Z.y+=aa;L.x-=na;L.y-=aa}var Qa,ib,Ba,Sa,Fa,Oa,Ja,va;this.autoClear?this.clear():n.setTransform(1,0,0,-1,k,m);b=d.projectScene(R,ia,this.sortElements);(K=R.lights.length>0)&&La(R);Qa=0;for(ib=b.length;Qa0){ma.r+=M.color.r*fa;ma.g+=M.color.g*fa;ma.b+=M.color.b*fa}}else if(M instanceof THREE.PointLight){e.sub(M.position,oa.centroidWorld);e.normalize();fa=oa.normalWorld.dot(e)*M.intensity;if(fa>0){ma.r+=M.color.r*fa;ma.g+=M.color.g*fa;ma.b+=M.color.b*fa}}}}function c(ka,oa,ma,ca,S,M){W=d(wa++); +W.setAttribute("d","M "+ka.positionScreen.x+" "+ka.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+ma.positionScreen.x+","+ma.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)B.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(J){U.r=P.r;U.g=P.g;U.b=P.b;a(M,ca,U);B.r=S.color.r*U.r;B.g=S.color.g*U.g;B.b=S.color.b*U.b;B.updateStyleString()}else B.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){Y= +1-S.__2near/(S.__farPlusNear-ca.z*S.__farMinusNear);B.setRGB(Y,Y,Y)}else S instanceof THREE.MeshNormalMaterial&&B.setRGB(f(ca.normalWorld.x),f(ca.normalWorld.y),f(ca.normalWorld.z));S.wireframe?W.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+S.wireframeLinewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframeLinecap+"; stroke-linejoin: "+S.wireframeLinejoin):W.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+S.opacity);k.appendChild(W)} +function b(ka,oa,ma,ca,S,M,fa){W=d(wa++);W.setAttribute("d","M "+ka.positionScreen.x+" "+ka.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+ma.positionScreen.x+","+ma.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)B.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(J){U.r=P.r;U.g=P.g;U.b=P.b;a(fa,S,U);B.r=M.color.r*U.r;B.g=M.color.g*U.g;B.b=M.color.b*U.b;B.updateStyleString()}else B.__styleString= +M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){Y=1-M.__2near/(M.__farPlusNear-S.z*M.__farMinusNear);B.setRGB(Y,Y,Y)}else M instanceof THREE.MeshNormalMaterial&&B.setRGB(f(S.normalWorld.x),f(S.normalWorld.y),f(S.normalWorld.z));M.wireframe?W.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+M.wireframeLinewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframeLinecap+"; stroke-linejoin: "+M.wireframeLinejoin):W.setAttribute("style","fill: "+ +B.__styleString+"; fill-opacity: "+M.opacity);k.appendChild(W)}function d(ka){if(ja[ka]==null){ja[ka]=document.createElementNS("http://www.w3.org/2000/svg","path");Aa==0&&ja[ka].setAttribute("shape-rendering","crispEdges")}return ja[ka]}function f(ka){return ka<0?Math.min((1+ka)*0.5,0.5):0.5+Math.min(ka*0.5,0.5)}var g=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,n,q,x,z,p,A,G,I=new THREE.Rectangle,C=new THREE.Rectangle,J=!1,B=new THREE.Color(16777215), +U=new THREE.Color(16777215),P=new THREE.Color(0),O=new THREE.Color(0),V=new THREE.Color(0),Y,e=new THREE.Vector3,ja=[],X=[],W,wa,ha,Aa=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ka){switch(ka){case "high":Aa=1;break;case "low":Aa=0}};this.setSize=function(ka,oa){m=ka;n=oa;q=m/2;x=n/2;k.setAttribute("viewBox",-q+" "+-x+" "+m+" "+n);k.setAttribute("width",m);k.setAttribute("height",n);I.set(-q,-x,q,x)};this.clear=function(){for(;k.childNodes.length> +0;)k.removeChild(k.childNodes[0])};this.render=function(ka,oa){var ma,ca,S,M,fa,ra,la,qa;this.autoClear&&this.clear();g=h.projectScene(ka,oa,this.sortElements);ha=wa=0;if(J=ka.lights.length>0){la=ka.lights;P.setRGB(0,0,0);O.setRGB(0,0,0);V.setRGB(0,0,0);ma=0;for(ca=la.length;maZ){N=K;Z=F[N]}f.bindBuffer(f.ARRAY_BUFFER,w.__webGLMorphTargetsBuffers[N]);f.vertexAttribPointer(C["morphTarget"+p],3,f.FLOAT,!1,0,0);D.__webGLMorphTargetInfluences[p]=Z;B[N]= -1;Z=-1;p++}}f.uniform1fv(o.program.uniforms.morphTargetInfluences,D.__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(D 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(D instanceof THREE.Line){D=D.type==THREE.LineStrip?f.LINE_STRIP:f.LINES;f.lineWidth(o.linewidth);f.drawArrays(D,0,w.__webGLLineCount)}else if(D instanceof THREE.ParticleSystem)f.drawArrays(f.POINTS,0,w.__webGLParticleCount);else D instanceof THREE.Ribbon&& -f.drawArrays(f.TRIANGLE_STRIP,0,w.__webGLVertexCount)}}function g(n,C){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(C.attributes.position);f.vertexAttribPointer(C.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(C.attributes.normal);f.vertexAttribPointer(C.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,n.count);n.count=0}function h(n){if(T!=n.doubleSided){n.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE);T=n.doubleSided}if(xa!=n.flipSided){n.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW);xa=n.flipSided}}function k(n){if(Da!=n){n?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST);Da=n}}function j(n){P[0].set(n.n41- -n.n11,n.n42-n.n12,n.n43-n.n13,n.n44-n.n14);P[1].set(n.n41+n.n11,n.n42+n.n12,n.n43+n.n13,n.n44+n.n14);P[2].set(n.n41+n.n21,n.n42+n.n22,n.n43+n.n23,n.n44+n.n24);P[3].set(n.n41-n.n21,n.n42-n.n22,n.n43-n.n23,n.n44-n.n24);P[4].set(n.n41-n.n31,n.n42-n.n32,n.n43-n.n33,n.n44-n.n34);P[5].set(n.n41+n.n31,n.n42+n.n32,n.n43+n.n33,n.n44+n.n34);var C;for(n=0;n<6;n++){C=P[n];C.divideScalar(Math.sqrt(C.x*C.x+C.y*C.y+C.z*C.z))}}function m(n){for(var C=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=P[o].x*C.n14+P[o].y*C.n24+P[o].z*C.n34+P[o].w;if(n<=p)return!1}return!0}function t(n,C){n.list[n.count]=C;n.count+=1}function x(n){var C,p,o=n.object,w=n.opaque,D=n.transparent;D.count=0;n=w.count=0;for(C=o.materials.length;n65535){K[Z].counter+=1;N=K[Z].hash+"_"+K[Z].counter;n.geometryGroups[N]==undefined&&(n.geometryGroups[N]={faces:[],materials:F,vertices:0,numMorphTargets:ra})}n.geometryGroups[N].faces.push(w);n.geometryGroups[N].vertices+=B}}function H(n,C,p){n.push({buffer:C,object:p,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function E(n){if(n!=ca){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)}ca=n}}function I(n,C,p){if((p.width&p.width-1)==0&&(p.height&p.height-1)==0){f.texParameteri(n,f.TEXTURE_WRAP_S,O(C.wrapS));f.texParameteri(n,f.TEXTURE_WRAP_T,O(C.wrapT));f.texParameteri(n,f.TEXTURE_MAG_FILTER, -O(C.magFilter));f.texParameteri(n,f.TEXTURE_MIN_FILTER,O(C.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,Q(C.magFilter));f.texParameteri(n,f.TEXTURE_MIN_FILTER,Q(C.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,O(n.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,O(n.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,O(n.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,O(n.minFilter));f.texImage2D(f.TEXTURE_2D,0,O(n.format),n.width,n.height,0,O(n.format),O(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 C,p;if(n){C=n.__webGLFramebuffer;p=n.width;n=n.height}else{C=null;p=la;n=aa}if(C!=ka){f.bindFramebuffer(f.FRAMEBUFFER,C);f.viewport(ja,oa,p,n);ka=C}}function S(n,C){var p;if(n== -"fragment")p=f.createShader(f.FRAGMENT_SHADER);else n=="vertex"&&(p=f.createShader(f.VERTEX_SHADER));f.shaderSource(p,C);f.compileShader(p);if(!f.getShaderParameter(p,f.COMPILE_STATUS)){console.error(f.getShaderInfoLog(p));console.error(C);return null}return p}function Q(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 O(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 X=document.createElement("canvas"),f,ea=null,ka=null,W=this,T=null,xa=null,ca=null,Da=null,ja=0,oa=0,la=0,aa=0,P=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],M=new THREE.Matrix4,da=new Float32Array(16),sa=new Float32Array(16),ia=new THREE.Vector4,ta={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},ya=!0,La=new THREE.Color(0),ab=0;if(a){if(a.antialias!==undefined)ya=a.antialias; -a.clearColor!==undefined&&La.setHex(a.clearColor);if(a.clearAlpha!==undefined)ab=a.clearAlpha}this.maxMorphTargets=8;this.domElement=X;this.autoClear=!0;this.sortObjects=!0;(function(n,C,p){try{if(!(f=X.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(C.r,C.g,C.b,p);_cullEnabled=!0})(ya,La,ab);this.context=f;this.setSize=function(n,C){X.width=n;X.height=C;this.setViewport(0,0,X.width,X.height)};this.setViewport=function(n,C,p,o){ja=n;oa=C;la=p;aa=o;f.viewport(ja,oa,la,aa)};this.setScissor=function(n,C,p,o){f.scissor(n,C,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,C){var p=new THREE.Color(n);f.clearColor(p.r, -p.g,p.b,C)};this.setClearColor=function(n,C){f.clearColor(n.r,n.g,n.b,C)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT)};this.initMaterial=function(n,C,p,o){var w,D,B;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 F,Z,N,K;B=N=K=0;for(F=C.length;B0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+F.maxDirLights,"#define MAX_POINT_LIGHTS "+F.maxPointLights,"#define MAX_BONES "+F.maxBones,F.map?"#define USE_MAP":"",F.envMap?"#define USE_ENVMAP":"",F.lightMap?"#define USE_LIGHTMAP":"",F.vertexColors?"#define USE_COLOR":"",F.skinning?"#define USE_SKINNING": -"",F.morphTargets?"#define USE_MORPHTARGETS":"",F.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,S("fragment",B+K));f.attachShader(p,S("vertex",F+C));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(C=p.length;K=0&&f.enableVertexAttribArray(D.color);D.normal>=0&&f.enableVertexAttribArray(D.normal); -D.tangent>=0&&f.enableVertexAttribArray(D.tangent);if(n.skinning&&D.skinVertexA>=0&&D.skinVertexB>=0&&D.skinIndex>=0&&D.skinWeight>=0){f.enableVertexAttribArray(D.skinVertexA);f.enableVertexAttribArray(D.skinVertexB);f.enableVertexAttribArray(D.skinIndex);f.enableVertexAttribArray(D.skinWeight)}if(n.morphTargets){n.numSupportedMorphTargets=0;if(D.morphTarget0>=0){f.enableVertexAttribArray(D.morphTarget0);n.numSupportedMorphTargets++}if(D.morphTarget1>=0){f.enableVertexAttribArray(D.morphTarget1); -n.numSupportedMorphTargets++}if(D.morphTarget2>=0){f.enableVertexAttribArray(D.morphTarget2);n.numSupportedMorphTargets++}if(D.morphTarget3>=0){f.enableVertexAttribArray(D.morphTarget3);n.numSupportedMorphTargets++}if(D.morphTarget4>=0){f.enableVertexAttribArray(D.morphTarget4);n.numSupportedMorphTargets++}if(D.morphTarget5>=0){f.enableVertexAttribArray(D.morphTarget5);n.numSupportedMorphTargets++}if(D.morphTarget6>=0){f.enableVertexAttribArray(D.morphTarget6);n.numSupportedMorphTargets++}if(D.morphTarget7>= -0){f.enableVertexAttribArray(D.morphTarget7);n.numSupportedMorphTargets++}o.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(w=0;w0||Aa.faceVertexUvs.length>0)B.__uvArray=new Float32Array(F*2);if(Aa.faceUvs.length>1||Aa.faceVertexUvs.length>1)B.__uv2Array=new Float32Array(F*2)}if(N.geometry.skinWeights.length&&N.geometry.skinIndices.length){B.__skinVertexAArray=new Float32Array(F*4);B.__skinVertexBArray=new Float32Array(F*4);B.__skinIndexArray=new Float32Array(F*4);B.__skinWeightArray=new Float32Array(F*4)}B.__faceArray=new Uint16Array(Z*3);B.__lineArray=new Uint16Array(Ea*2);if(B.numMorphTargets){N= -void 0;Aa=void 0;B.__morphTargetsArrays=[];N=0;for(Aa=B.numMorphTargets;N=0;w--){o=p.__webglObjects[w].object;C==o&&p.__webglObjects.splice(w,1)}n.__objectsRemoved.splice(0,1)}C=0;for(p=n.__webglObjects.length;C0){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,Ra,F)}if(db){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLNormalBuffer);f.bufferData(f.ARRAY_BUFFER,Wa,F)}if(hb&&R.hasTangents){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLTangentBuffer);f.bufferData(f.ARRAY_BUFFER,Ha,F)}if(Za&&Ga>0){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLUVBuffer); -f.bufferData(f.ARRAY_BUFFER,Fa,F)}if(Za&&Ma>0){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLUV2Buffer);f.bufferData(f.ARRAY_BUFFER,$a,F)}if(cb){f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,B.__webGLFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,za,F);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,B.__webGLLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,qa,F)}if(L>0){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinVertexABuffer);f.bufferData(f.ARRAY_BUFFER,va,F);f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinVertexBBuffer);f.bufferData(f.ARRAY_BUFFER, -J,F);f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinIndicesBuffer);f.bufferData(f.ARRAY_BUFFER,Y,F);f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinWeightsBuffer);f.bufferData(f.ARRAY_BUFFER,U,F)}}}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;D=f.DYNAMIC_DRAW;N=void 0;N=void 0;Aa=void 0;B=void 0;K=o.vertices;F=o.colors;ra=K.length; -Z=F.length;$=o.__vertexArray;Ea=o.__colorArray;ma=o.__dirtyColors;if(o.__dirtyVertices){for(N=0;N0}}; -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;dD){Q=H;D=F[Q]}e.bindBuffer(e.ARRAY_BUFFER,y.__webGLMorphTargetsBuffers[Q]);e.vertexAttribPointer(w["morphTarget"+t],3,e.FLOAT,!1,0,0);E.__webGLMorphTargetInfluences[t]=D;K[Q]=1;D=-1;t++}}e.uniform1fv(o.program.uniforms.morphTargetInfluences,E.__webGLMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,y.__webGLVertexBuffer);e.vertexAttribPointer(j.position,3, +e.FLOAT,!1,0,0)}if(j.color>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLColorBuffer);e.vertexAttribPointer(j.color,3,e.FLOAT,!1,0,0)}if(j.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLNormalBuffer);e.vertexAttribPointer(j.normal,3,e.FLOAT,!1,0,0)}if(j.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLTangentBuffer);e.vertexAttribPointer(j.tangent,4,e.FLOAT,!1,0,0)}if(j.uv>=0)if(y.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLUVBuffer);e.vertexAttribPointer(j.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(j.uv)}else e.disableVertexAttribArray(j.uv); +if(j.uv2>=0)if(y.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLUV2Buffer);e.vertexAttribPointer(j.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(j.uv2)}else e.disableVertexAttribArray(j.uv2);if(o.skinning&&j.skinVertexA>=0&&j.skinVertexB>=0&&j.skinIndex>=0&&j.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinVertexABuffer);e.vertexAttribPointer(j.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinVertexBBuffer);e.vertexAttribPointer(j.skinVertexB,4,e.FLOAT,!1,0, +0);e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinIndicesBuffer);e.vertexAttribPointer(j.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinWeightsBuffer);e.vertexAttribPointer(j.skinWeight,4,e.FLOAT,!1,0,0)}if(E instanceof THREE.Mesh)if(o.wireframe){e.lineWidth(o.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,y.__webGLLineBuffer);e.drawElements(e.LINES,y.__webGLLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,y.__webGLFaceBuffer);e.drawElements(e.TRIANGLES, +y.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else if(E instanceof THREE.Line){E=E.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(o.linewidth);e.drawArrays(E,0,y.__webGLLineCount)}else if(E instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,0,y.__webGLParticleCount);else E instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,y.__webGLVertexCount)}}function g(j,w){if(!j.__webGLVertexBuffer)j.__webGLVertexBuffer=e.createBuffer();if(!j.__webGLNormalBuffer)j.__webGLNormalBuffer=e.createBuffer(); +if(j.hasPos){e.bindBuffer(e.ARRAY_BUFFER,j.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,j.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(w.attributes.position);e.vertexAttribPointer(w.attributes.position,3,e.FLOAT,!1,0,0)}if(j.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,j.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,j.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(w.attributes.normal);e.vertexAttribPointer(w.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,j.count); +j.count=0}function h(j){if(wa!=j.doubleSided){j.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);wa=j.doubleSided}if(ha!=j.flipSided){j.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);ha=j.flipSided}}function k(j){if(ka!=j){j?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);ka=j}}function m(j){M[0].set(j.n41-j.n11,j.n42-j.n12,j.n43-j.n13,j.n44-j.n14);M[1].set(j.n41+j.n11,j.n42+j.n12,j.n43+j.n13,j.n44+j.n14);M[2].set(j.n41+j.n21,j.n42+j.n22,j.n43+j.n23,j.n44+j.n24);M[3].set(j.n41-j.n21,j.n42- +j.n22,j.n43-j.n23,j.n44-j.n24);M[4].set(j.n41-j.n31,j.n42-j.n32,j.n43-j.n33,j.n44-j.n34);M[5].set(j.n41+j.n31,j.n42+j.n32,j.n43+j.n33,j.n44+j.n34);var w;for(j=0;j<6;j++){w=M[j];w.divideScalar(Math.sqrt(w.x*w.x+w.y*w.y+w.z*w.z))}}function n(j){for(var w=j.matrixWorld,t=-j.geometry.boundingSphere.radius*Math.max(j.scale.x,Math.max(j.scale.y,j.scale.z)),o=0;o<6;o++){j=M[o].x*w.n14+M[o].y*w.n24+M[o].z*w.n34+M[o].w;if(j<=t)return!1}return!0}function q(j,w){j.list[j.count]=w;j.count+=1}function x(j){var w, +t,o=j.object,y=j.opaque,E=j.transparent;E.count=0;j=y.count=0;for(w=o.materials.length;j0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,Oa,y)}if(Ya){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,Sa,y)}if(cb&&ea.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLTangentBuffer);e.bufferData(e.ARRAY_BUFFER,Fa,y)}if(Xa&&bb>0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,ib,y)}if(Xa&&db>0){e.bindBuffer(e.ARRAY_BUFFER, +o.__webGLUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Ba,y)}if(Ka){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,aa,y);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ta,y)}if(N>0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,Ja,y);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,va,y);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer); +e.bufferData(e.ARRAY_BUFFER,L,y);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,Z,y)}}}t.__dirtyVertices=!1;t.__dirtyMorphTargets=!1;t.__dirtyElements=!1;t.__dirtyUvs=!1;t.__dirtyNormals=!1;t.__dirtyTangents=!1;t.__dirtyColors=!1}else if(j instanceof THREE.Ribbon){t=j.geometry;if(t.__dirtyVertices||t.__dirtyColors){j=t;w=e.DYNAMIC_DRAW;ya=j.vertices;y=j.colors;ua=ya.length;E=y.length;Ea=j.__vertexArray;K=j.__colorArray;Ia=j.__dirtyColors;if(j.__dirtyVertices){for(pa= +0;pa65535){H[D].counter+=1;Q=H[D].hash+"_"+H[D].counter;j.geometryGroups[Q]==undefined&&(j.geometryGroups[Q]={faces:[],materials:F,vertices:0,numMorphTargets:T})}j.geometryGroups[Q].faces.push(y);j.geometryGroups[Q].vertices+=K}}function C(j,w,t){j.push({buffer:w,object:t,opaque:{list:[],count:0},transparent:{list:[], +count:0}})}function J(j){if(j!=Aa){switch(j){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE);break;case THREE.SubtractiveBlending:e.blendFunc(e.DST_COLOR,e.ZERO);break;case THREE.BillboardBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:e.blendEquation(e.FUNC_REVERSE_SUBTRACT);e.blendFunc(e.ONE,e.ONE);break;default:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}Aa= +j}}function B(j,w,t){if((t.width&t.width-1)==0&&(t.height&t.height-1)==0){e.texParameteri(j,e.TEXTURE_WRAP_S,V(w.wrapS));e.texParameteri(j,e.TEXTURE_WRAP_T,V(w.wrapT));e.texParameteri(j,e.TEXTURE_MAG_FILTER,V(w.magFilter));e.texParameteri(j,e.TEXTURE_MIN_FILTER,V(w.minFilter));e.generateMipmap(j)}else{e.texParameteri(j,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(j,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(j,e.TEXTURE_MAG_FILTER,O(w.magFilter));e.texParameteri(j,e.TEXTURE_MIN_FILTER, +O(w.minFilter))}}function U(j){if(j&&!j.__webGLFramebuffer){j.__webGLFramebuffer=e.createFramebuffer();j.__webGLRenderbuffer=e.createRenderbuffer();j.__webGLTexture=e.createTexture();e.bindRenderbuffer(e.RENDERBUFFER,j.__webGLRenderbuffer);e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,j.width,j.height);e.bindTexture(e.TEXTURE_2D,j.__webGLTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,V(j.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,V(j.wrapT));e.texParameteri(e.TEXTURE_2D, +e.TEXTURE_MAG_FILTER,V(j.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,V(j.minFilter));e.texImage2D(e.TEXTURE_2D,0,V(j.format),j.width,j.height,0,V(j.format),V(j.type),null);e.bindFramebuffer(e.FRAMEBUFFER,j.__webGLFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,j.__webGLTexture,0);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,j.__webGLRenderbuffer);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null); +e.bindFramebuffer(e.FRAMEBUFFER,null)}var w,t;if(j){w=j.__webGLFramebuffer;t=j.width;j=j.height}else{w=null;t=ca;j=S}if(w!=X){e.bindFramebuffer(e.FRAMEBUFFER,w);e.viewport(oa,ma,t,j);X=w}}function P(j,w){var t;if(j=="fragment")t=e.createShader(e.FRAGMENT_SHADER);else j=="vertex"&&(t=e.createShader(e.VERTEX_SHADER));e.shaderSource(t,w);e.compileShader(t);if(!e.getShaderParameter(t,e.COMPILE_STATUS)){console.error(e.getShaderInfoLog(t));console.error(w);return null}return t}function O(j){switch(j){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST; +default:return e.LINEAR}}function V(j){switch(j){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR; +case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0} +var Y=document.createElement("canvas"),e,ja=null,X=null,W=this,wa=null,ha=null,Aa=null,ka=null,oa=0,ma=0,ca=0,S=0,M=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],fa=new THREE.Matrix4,ra=new Float32Array(16),la=new Float32Array(16),qa=new THREE.Vector4,xa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},Ca=!0,Za=new THREE.Color(0),$a=0;if(a){if(a.antialias!==undefined)Ca=a.antialias; +a.clearColor!==undefined&&Za.setHex(a.clearColor);if(a.clearAlpha!==undefined)$a=a.clearAlpha}this.maxMorphTargets=8;this.domElement=Y;this.autoClear=!0;this.sortObjects=!0;(function(j,w,t){try{if(!(e=Y.getContext("experimental-webgl",{antialias:j,stencil:!0})))throw"Error creating WebGL context.";}catch(o){console.error(o)}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendFunc(e.ONE, +e.ONE_MINUS_SRC_ALPHA);e.clearColor(w.r,w.g,w.b,t)})(Ca,Za,$a);this.context=e;var Ha={};a=[];Ca=[];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;Ca[0]=0;Ca[1]=1;Ca[2]=2;Ca[3]=0;Ca[4]=2;Ca[5]=3;Ha.vertexBuffer=e.createBuffer();Ha.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,Ha.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,new Float32Array(a),e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,Ha.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER, +new Uint16Array(Ca),e.STATIC_DRAW);Ha.program=e.createProgram();e.attachShader(Ha.program,P("fragment",THREE.ShaderLib.shadowPost.fragmentShader));e.attachShader(Ha.program,P("vertex",THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(Ha.program);Ha.vertexLocation=e.getAttribLocation(Ha.program,"position");Ha.projectionLocation=e.getUniformLocation(Ha.program,"projectionMatrix");this.setSize=function(j,w){Y.width=j;Y.height=w;this.setViewport(0,0,Y.width,Y.height)};this.setViewport=function(j, +w,t,o){oa=j;ma=w;ca=t;S=o;e.viewport(oa,ma,ca,S)};this.setScissor=function(j,w,t,o){e.scissor(j,w,t,o)};this.enableScissorTest=function(j){j?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(j){e.depthMask(j)};this.setClearColorHex=function(j,w){var t=new THREE.Color(j);e.clearColor(t.r,t.g,t.b,w)};this.setClearColor=function(j,w){e.clearColor(j.r,j.g,j.b,w)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.initMaterial= +function(j,w,t,o){var y,E,K;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);var F,D,Q,H;K=Q=H=0;for(F=w.length;K0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+F.maxDirLights,"#define MAX_POINT_LIGHTS "+F.maxPointLights,"#define MAX_BONES "+F.maxBones,F.map?"#define USE_MAP":"",F.envMap?"#define USE_ENVMAP":"",F.lightMap?"#define USE_LIGHTMAP":"",F.vertexColors?"#define USE_COLOR":"",F.skinning?"#define USE_SKINNING":"",F.morphTargets?"#define USE_MORPHTARGETS":"",F.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"); +e.attachShader(t,P("fragment",K+H));e.attachShader(t,P("vertex",F+w));e.linkProgram(t);e.getProgramParameter(t,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(t,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");t.uniforms={};t.attributes={};j.program=t;t=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(y in j.uniforms)t.push(y); +y=j.program;H=0;for(w=t.length;H=0&&e.enableVertexAttribArray(E.color);E.normal>=0&&e.enableVertexAttribArray(E.normal); +E.tangent>=0&&e.enableVertexAttribArray(E.tangent);if(j.skinning&&E.skinVertexA>=0&&E.skinVertexB>=0&&E.skinIndex>=0&&E.skinWeight>=0){e.enableVertexAttribArray(E.skinVertexA);e.enableVertexAttribArray(E.skinVertexB);e.enableVertexAttribArray(E.skinIndex);e.enableVertexAttribArray(E.skinWeight)}if(j.morphTargets){j.numSupportedMorphTargets=0;if(E.morphTarget0>=0){e.enableVertexAttribArray(E.morphTarget0);j.numSupportedMorphTargets++}if(E.morphTarget1>=0){e.enableVertexAttribArray(E.morphTarget1); +j.numSupportedMorphTargets++}if(E.morphTarget2>=0){e.enableVertexAttribArray(E.morphTarget2);j.numSupportedMorphTargets++}if(E.morphTarget3>=0){e.enableVertexAttribArray(E.morphTarget3);j.numSupportedMorphTargets++}if(E.morphTarget4>=0){e.enableVertexAttribArray(E.morphTarget4);j.numSupportedMorphTargets++}if(E.morphTarget5>=0){e.enableVertexAttribArray(E.morphTarget5);j.numSupportedMorphTargets++}if(E.morphTarget6>=0){e.enableVertexAttribArray(E.morphTarget6);j.numSupportedMorphTargets++}if(E.morphTarget7>= +0){e.enableVertexAttribArray(E.morphTarget7);j.numSupportedMorphTargets++}o.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(y=0;y0||ya.faceVertexUvs.length>0)K.__uvArray=new Float32Array(D*2);if(ya.faceUvs.length>1||ya.faceVertexUvs.length>1)K.__uv2Array=new Float32Array(D*2)}if(F.geometry.skinWeights.length&&F.geometry.skinIndices.length){K.__skinVertexAArray= +new Float32Array(D*4);K.__skinVertexBArray=new Float32Array(D*4);K.__skinIndexArray=new Float32Array(D*4);K.__skinWeightArray=new Float32Array(D*4)}K.__faceArray=new Uint16Array(ga*3+(F.geometry.edgeFaces?F.geometry.edgeFaces.length*6:0));K.__lineArray=new Uint16Array(pa*2);if(K.numMorphTargets){ya=void 0;ua=void 0;K.__morphTargetsArrays=[];ya=0;for(ua=K.numMorphTargets;ya=0;y--){o=t.__webglObjects[y].object;w==o&&t.__webglObjects.splice(y,1)}j.__objectsRemoved.splice(0,1)}w=0;for(t=j.__webglObjects.length;w0}}; +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,f=b.length;for(d=0;d= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}", @@ -324,8 +336,8 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i25&&(g=25);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=d=0;c=0?y:y+e;y=this.verticalAngleMap.srcRange;q=this.verticalAngleMap.dstRange; -this.phi=(this.phi-y[0])*(q[1]-q[0])/(y[1]-y[0])+q[0];y=this.horizontalAngleMap.srcRange;q=this.horizontalAngleMap.dstRange;this.theta=(this.theta-y[0])*(q[1]-q[0])/(y[1]-y[0])+q[0];y=this.target.position;y.x=100*Math.sin(this.phi)*Math.cos(this.theta);y.y=100*Math.cos(this.phi);y.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,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}),k=new Cube(10,10,20),j=new Cube(2,2,10);this.animationParent=new THREE.Mesh(k,a);a=new THREE.Mesh(j,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,k,j){function m(H,E,I,A,S,Q,O,X){var f,ea,ka=d||1,W=e||1,T=S/2,xa=Q/2,ca=t.vertices.length;if(H=="x"&&E=="y"||H=="y"&&E=="x")f="z";else if(H=="x"&&E=="z"||H=="z"&&E=="x"){f="y";W=g||1}else if(H=="z"&&E=="y"||H=="y"&&E=="z"){f="x";ka=g||1}var Da=ka+1,ja=W+1;S/=ka;var oa=Q/W;for(ea=0;ea0){h(0,0,-m-(g||0));for(d=a;d0){h(0,0,m+(e||0)); +this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var f=Math.PI*2,g=Math.PI/180;this.update=function(n,q,x){var z,p;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*g;this.theta=this.lon*g;z=this.phi%f;this.phi=z>=0?z:z+f;z=this.verticalAngleMap.srcRange;p=this.verticalAngleMap.dstRange; +this.phi=(this.phi-z[0])*(p[1]-p[0])/(z[1]-z[0])+p[0];z=this.horizontalAngleMap.srcRange;p=this.horizontalAngleMap.dstRange;this.theta=(this.theta-z[0])*(p[1]-p[0])/(z[1]-z[0])+p[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,q,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&&d(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(n,q){return function(){q.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,d,f,g,h,k,m){function n(I,C,J,B,U,P,O,V){var Y,e,ja=d||1,X=f||1,W=U/2,wa=P/2,ha=q.vertices.length;if(I=="x"&&C=="y"||I=="y"&&C=="x")Y="z";else if(I=="x"&&C=="z"||I=="z"&&C=="x"){Y="y";X=g||1}else if(I=="z"&&C=="y"||I=="y"&&C=="z"){Y="x";ja=g||1}var Aa=ja+1,ka=X+1;U/=ja;var oa=P/X;for(e=0;e0){h(0,0,-n-(g||0));for(d=a;d0){h(0,0,n+(f||0)); for(d=a+a/2;d<2*a;d++)k.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,y,q){var z=Math.sqrt(x*x+y*y+q*q);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(x/z,y/z,q/z)))-1}function b(x,y,q,z){z.faces.push(new THREE.Face3(x,y,q))}function d(x,y){var q=e.vertices[x].position,z=e.vertices[y].position;return c((q.x+z.x)/2,(q.y+z.y)/2,(q.z+z.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;a0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,y)))-1);m.push(t)}c.push(m)}var q,z,G;e=c.length;for(b=0;b0)for(d=0;d1){q=this.vertices[h].position.clone(); -z=this.vertices[j].position.clone();G=this.vertices[m].position.clone();q.normalize();z.normalize();G.normalize();this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([t,x,H])}}}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 k(x,y,q,z,G,H){y=q/z*x;q=Math.cos(y);return new THREE.Vector3(G*(2+q)*0.5*Math.cos(x),G*(2+q)*Math.sin(x)*0.5,H*G*Math.sin(y)*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;a0||(q=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,z)))-1);n.push(q)}c.push(n)}var p,A,G;f=c.length;for(b=0;b0)for(d=0;d1){p=this.vertices[h].position.clone(); +A=this.vertices[m].position.clone();G=this.vertices[n].position.clone();p.normalize();A.normalize();G.normalize();this.faces.push(new THREE.Face3(h,m,n,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([q,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,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 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(d),(this.radius+this.tube*Math.cos(f))*Math.sin(d),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){d=(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(d,f,g,h));this.faceVertexUvs[0].push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; +var TorusKnot=function(a,c,b,d,f,g,h){function k(x,z,p,A,G,I){z=p/A*x;p=Math.cos(z);return new THREE.Vector3(G*(2+p)*0.5*Math.cos(x),G*(2+p)*Math.sin(x)*0.5,I*G*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=f||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|=(B&127)<<16|D<<8;if(w==0&&Z==-127)return 0;return(1-2*(F>>7))*(1+w*Math.pow(2,-23))*Math.pow(2,Z)}function k(p,o){var w=t(p,o),D=t(p,o+1),B=t(p,o+2);return(t(p,o+3)<<24)+(B<<16)+(D<<8)+w}function j(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,D;o=k(a,p);w=k(a,p+O);D=k(a,p+X);p=j(a,p+f);THREE.BinaryLoader.prototype.f3(E,o,w,D,p)}function y(p){var o,w,D,B,F,Z;o=k(a,p);w=k(a,p+O);D=k(a,p+X);B=j(a,p+f);F=k(a,p+ea);Z=k(a,p+ka);p=k(a,p+W);THREE.BinaryLoader.prototype.f3n(E,S,o,w,D,B,F,Z,p)}function q(p){var o,w,D,B;o=k(a,p);w=k(a,p+T);D=k(a,p+xa);B=k(a,p+ca);p=j(a,p+Da);THREE.BinaryLoader.prototype.f4(E,o,w,D,B,p)}function z(p){var o,w,D,B,F,Z,N,K;o=k(a,p);w=k(a,p+T);D=k(a,p+xa);B=k(a,p+ca); -F=j(a,p+Da);Z=k(a,p+ja);N=k(a,p+oa);K=k(a,p+la);p=k(a,p+aa);THREE.BinaryLoader.prototype.f4n(E,S,o,w,D,B,F,Z,N,K,p)}function G(p){var o,w;o=k(a,p);w=k(a,p+P);p=k(a,p+M);THREE.BinaryLoader.prototype.uv3(E.faceVertexUvs[0],Q[o*2],Q[o*2+1],Q[w*2],Q[w*2+1],Q[p*2],Q[p*2+1])}function H(p){var o,w,D;o=k(a,p);w=k(a,p+da);D=k(a,p+sa);p=k(a,p+ia);THREE.BinaryLoader.prototype.uv4(E.faceVertexUvs[0],Q[o*2],Q[o*2+1],Q[w*2],Q[w*2+1],Q[D*2],Q[D*2+1],Q[p*2],Q[p*2+1])}var E=this,I=0,A,S=[],Q=[],O,X,f,ea,ka,W,T,xa, -ca,Da,ja,oa,la,aa,P,M,da,sa,ia,ta,ya,La,ab,n,C;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(E,d,g);A={signature:a.substr(I,8),header_bytes:t(a,I+8),vertex_coordinate_bytes:t(a,I+9),normal_coordinate_bytes:t(a,I+10),uv_coordinate_bytes:t(a,I+11),vertex_index_bytes:t(a,I+12),normal_index_bytes:t(a,I+13),uv_index_bytes:t(a,I+14),material_index_bytes:t(a,I+15),nvertices:k(a,I+16),nnormals:k(a,I+16+4),nuvs:k(a,I+16+8),ntri_flat:k(a,I+16+12),ntri_smooth:k(a,I+16+16),ntri_flat_uv:k(a, -I+16+20),ntri_smooth_uv:k(a,I+16+24),nquad_flat:k(a,I+16+28),nquad_smooth:k(a,I+16+32),nquad_flat_uv:k(a,I+16+36),nquad_smooth_uv:k(a,I+16+40)};I+=A.header_bytes;O=A.vertex_index_bytes;X=A.vertex_index_bytes*2;f=A.vertex_index_bytes*3;ea=A.vertex_index_bytes*3+A.material_index_bytes;ka=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes;W=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*2;T=A.vertex_index_bytes;xa=A.vertex_index_bytes*2;ca=A.vertex_index_bytes*3;Da= -A.vertex_index_bytes*4;ja=A.vertex_index_bytes*4+A.material_index_bytes;oa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes;la=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*2;aa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*3;P=A.uv_index_bytes;M=A.uv_index_bytes*2;da=A.uv_index_bytes;sa=A.uv_index_bytes*2;ia=A.uv_index_bytes*3;g=A.vertex_index_bytes*3+A.material_index_bytes;C=A.vertex_index_bytes*4+A.material_index_bytes;ta=A.ntri_flat* -g;ya=A.ntri_smooth*(g+A.normal_index_bytes*3);La=A.ntri_flat_uv*(g+A.uv_index_bytes*3);ab=A.ntri_smooth_uv*(g+A.normal_index_bytes*3+A.uv_index_bytes*3);n=A.nquad_flat*C;g=A.nquad_smooth*(C+A.normal_index_bytes*4);C=A.nquad_flat_uv*(C+A.uv_index_bytes*4);I+=function(p){for(var o,w,D,B=A.vertex_coordinate_bytes*3,F=p+A.nvertices*B;p>7)-127;t|=(y&127)<<16|o<<8;if(t==0&&K==-127)return 0;return(1-2*(E>>7))*(1+t*Math.pow(2,-23))*Math.pow(2,K)}function k(j,w){var t=q(j,w),o=q(j,w+1),y=q(j,w+2);return(q(j,w+3)<<24)+(y<<16)+(o<<8)+t}function m(j,w){var t=q(j,w);return(q(j,w+1)<<8)+t}function n(j,w){var t=q(j,w);return t>127?t-256:t}function q(j, +w){return j.charCodeAt(w)&255}function x(j){var w,t,o;w=k(a,j);t=k(a,j+O);o=k(a,j+V);j=m(a,j+Y);THREE.BinaryLoader.prototype.f3(C,w,t,o,j)}function z(j){var w,t,o,y,E,K;w=k(a,j);t=k(a,j+O);o=k(a,j+V);y=m(a,j+Y);E=k(a,j+e);K=k(a,j+ja);j=k(a,j+X);THREE.BinaryLoader.prototype.f3n(C,U,w,t,o,y,E,K,j)}function p(j){var w,t,o,y;w=k(a,j);t=k(a,j+W);o=k(a,j+wa);y=k(a,j+ha);j=m(a,j+Aa);THREE.BinaryLoader.prototype.f4(C,w,t,o,y,j)}function A(j){var w,t,o,y,E,K,F,D;w=k(a,j);t=k(a,j+W);o=k(a,j+wa);y=k(a,j+ha); +E=m(a,j+Aa);K=k(a,j+ka);F=k(a,j+oa);D=k(a,j+ma);j=k(a,j+ca);THREE.BinaryLoader.prototype.f4n(C,U,w,t,o,y,E,K,F,D,j)}function G(j){var w,t;w=k(a,j);t=k(a,j+S);j=k(a,j+M);THREE.BinaryLoader.prototype.uv3(C.faceVertexUvs[0],P[w*2],P[w*2+1],P[t*2],P[t*2+1],P[j*2],P[j*2+1])}function I(j){var w,t,o;w=k(a,j);t=k(a,j+fa);o=k(a,j+ra);j=k(a,j+la);THREE.BinaryLoader.prototype.uv4(C.faceVertexUvs[0],P[w*2],P[w*2+1],P[t*2],P[t*2+1],P[o*2],P[o*2+1],P[j*2],P[j*2+1])}var C=this,J=0,B,U=[],P=[],O,V,Y,e,ja,X,W,wa, +ha,Aa,ka,oa,ma,ca,S,M,fa,ra,la,qa,xa,Ca,Za,$a,Ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(C,d,g);B={signature:a.substr(J,8),header_bytes:q(a,J+8),vertex_coordinate_bytes:q(a,J+9),normal_coordinate_bytes:q(a,J+10),uv_coordinate_bytes:q(a,J+11),vertex_index_bytes:q(a,J+12),normal_index_bytes:q(a,J+13),uv_index_bytes:q(a,J+14),material_index_bytes:q(a,J+15),nvertices:k(a,J+16),nnormals:k(a,J+16+4),nuvs:k(a,J+16+8),ntri_flat:k(a,J+16+12),ntri_smooth:k(a,J+16+16),ntri_flat_uv:k(a, +J+16+20),ntri_smooth_uv:k(a,J+16+24),nquad_flat:k(a,J+16+28),nquad_smooth:k(a,J+16+32),nquad_flat_uv:k(a,J+16+36),nquad_smooth_uv:k(a,J+16+40)};J+=B.header_bytes;O=B.vertex_index_bytes;V=B.vertex_index_bytes*2;Y=B.vertex_index_bytes*3;e=B.vertex_index_bytes*3+B.material_index_bytes;ja=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes;X=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*2;W=B.vertex_index_bytes;wa=B.vertex_index_bytes*2;ha=B.vertex_index_bytes*3;Aa= +B.vertex_index_bytes*4;ka=B.vertex_index_bytes*4+B.material_index_bytes;oa=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes;ma=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*2;ca=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*3;S=B.uv_index_bytes;M=B.uv_index_bytes*2;fa=B.uv_index_bytes;ra=B.uv_index_bytes*2;la=B.uv_index_bytes*3;g=B.vertex_index_bytes*3+B.material_index_bytes;Ha=B.vertex_index_bytes*4+B.material_index_bytes;qa=B.ntri_flat* +g;xa=B.ntri_smooth*(g+B.normal_index_bytes*3);Ca=B.ntri_flat_uv*(g+B.uv_index_bytes*3);Za=B.ntri_smooth_uv*(g+B.normal_index_bytes*3+B.uv_index_bytes*3);$a=B.nquad_flat*Ha;g=B.nquad_smooth*(Ha+B.normal_index_bytes*4);Ha=B.nquad_flat_uv*(Ha+B.uv_index_bytes*4);J+=function(j){for(var w,t,o,y=B.vertex_coordinate_bytes*3,E=j+B.nvertices*y;j= -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 d=this.count*3;dthis.size-1&&(j=this.size-1);var y=Math.floor(m-k);y<1&&(y=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var q=Math.floor(t- -k);q<1&&(q=1);k=Math.floor(t+k);k>this.size-1&&(k=this.size-1);for(var z,G,H,E,I,A;x0&&(this.field[H+z]+=E)}}}};this.addPlaneX=function(b,d){var e,g,h,k,j,m=this.size,t=this.yd,x=this.zd,y=this.field,q=m*Math.sqrt(b/d);q>m&&(q=m);for(e=0;e0)for(g=0;gt&&(z=t);for(g=0;g0){j=g*x;for(e=0;esize&&(dist=size);for(h=0;h0){j=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 d=this.count*3;dthis.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 p=Math.floor(q-k);p<1&&(p=1);k=Math.floor(q+k); +k>this.size-1&&(k=this.size-1);for(var A,G,I,C,J,B;x0&&(this.field[I+A]+=C)}}}};this.addPlaneX=function(b,d){var f,g,h,k,m,n=this.size,q=this.yd,x=this.zd,z=this.field,p=n*Math.sqrt(b/d);p>n&&(p=n);for(f=0;f0)for(g=0;gq&&(A=q);for(g=0;g0){m=g*x;for(f=0;fsize&&(dist=size);for(h=0;h0){m=zd*h;for(g=0;g + + + three.js - webgl + + + + + + + + + + + + + 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..71aa0975 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 ); @@ -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' ] ); @@ -1782,6 +1841,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 +2334,7 @@ THREE.WebGLRenderer = function ( parameters ) { this.clear(); } + // set matrices @@ -2450,6 +2524,121 @@ 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; + + ol = scene.__webglShadowVolumes.length; + + for( l = 0; l < ll; l++ ) { + + light = scene.lights[ l ]; + + if( light instanceof THREE.DirectionalLight ) { + + // render all volumes + + for ( o = 0; o < ol; o++ ) { + + webglObject = scene.__webglShadowVolumes[ o ]; + + object = webglObject.object; + buffer = webglObject.buffer; + opaque = webglObject.opaque; + + object.matrixWorld.flattenToArray( object._objectMatrixArray ); + setupMatrices( object, camera ); + unrollBufferMaterials( webglObject ); + + + // render first back, then front + + _gl.cullFace( _gl.FRONT ); + + for( p = 0; p < 2; p++ ) { + + for( i = 0; i < opaque.count; i++ ) { + + material = opaque.list[ i ]; + renderBuffer( camera, light, fog, material, buffer, object ); + + } + + _gl.cullFace( _gl.BACK ); + } + + } + + } + + } + + + // 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.SRC_ALPHA, _gl.ONE ); + _gl.blendEquation( _gl.FUNC_REVERSE_SUBTRACT ); + + + _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 +2662,7 @@ THREE.WebGLRenderer = function ( parameters ) { scene.__webglObjects = []; scene.__webglObjectsImmediate = []; - + scene.__webglShadowVolumes = []; } while ( scene.__objectsAdded.length ) { @@ -2497,6 +2686,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 +2747,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 +3064,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 +3557,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..641510f3 100644 --- a/src/renderers/WebGLShaders.js +++ b/src/renderers/WebGLShaders.js @@ -6,6 +6,7 @@ THREE.ShaderChunk = { + // FOG fog_pars_fragment: [ @@ -555,6 +556,68 @@ 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( 1, 1, 1, 0.5 );", + "}" + + ].join( "\n" ) + + }, + + + 'shadowVolumeDynamic': { + + uniforms: { "directionalLightDirection": { type: "fv", value: [] }}, + + vertexShader: [ + + "uniform vec3 directionalLightDirection;", + + "void main() {", + +// todo: optimize + + "vec3 pos = ( objectMatrix * vec4( position, 1.0 )).xyz;", + "vec3 norm = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz) * normal;// normalMatrix * normal;", + "vec4 final = vec4( pos + directionalLightDirection * 5000.0 * step( 0.0, dot( directionalLightDirection, norm )), 1.0 );", + "gl_Position = projectionMatrix * viewMatrix * final;", + "}" + + ].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..6d242c53 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', From a25155bde61b364f2755028c1a724b13bd3e0d91 Mon Sep 17 00:00:00 2001 From: Mikael Emtinger Date: Thu, 24 Mar 2011 11:35:38 +0100 Subject: [PATCH 03/10] Change blending method on shadow polygons. Updated example to use Lambert material and only one shadow casting directional light. --- build/Three.js | 4 +-- examples/webgl_stencil.html | 56 ++++++++++++---------------------- src/renderers/WebGLRenderer.js | 5 +-- src/renderers/WebGLShaders.js | 2 +- 4 files changed, 26 insertions(+), 41 deletions(-) diff --git a/build/Three.js b/build/Three.js index dfeccfd5..98d664f9 100755 --- a/build/Three.js +++ b/build/Three.js @@ -213,7 +213,7 @@ default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = pr THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)},morphTargetInfluences:{type:"f", value:0}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f", value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}}; -THREE.ShaderLib={shadowPost:{vertexShader:"uniform \tmat4 \tprojectionMatrix;\nattribute \tvec3 \tposition;\nvoid main(void)\n{\ngl_Position = projectionMatrix * vec4( position, 1.0 );\n}",fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nvoid main( void )\n{\ngl_FragColor = vec4( 1, 1, 1, 0.5 );\n}"},shadowVolumeDynamic:{uniforms:{directionalLightDirection:{type:"fv",value:[]}},vertexShader:"uniform \tvec3 \tdirectionalLightDirection;\nvoid main() {\nvec3 pos = ( objectMatrix * vec4( position, 1.0 )).xyz;\nvec3 norm = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz) * normal;// normalMatrix * normal;\nvec4 final = vec4( pos + directionalLightDirection * 5000.0 * step( 0.0, dot( directionalLightDirection, norm )), 1.0 );\ngl_Position = projectionMatrix * viewMatrix * final;\n}",fragmentShader:"void main() {\ngl_FragColor = vec4( 1, 1, 1, 1 );\n}"}, +THREE.ShaderLib={shadowPost:{vertexShader:"uniform \tmat4 \tprojectionMatrix;\nattribute \tvec3 \tposition;\nvoid main(void)\n{\ngl_Position = projectionMatrix * vec4( position, 1.0 );\n}",fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nvoid main( void )\n{\ngl_FragColor = vec4( 0, 0, 0, 0.5 );\n}"},shadowVolumeDynamic:{uniforms:{directionalLightDirection:{type:"fv",value:[]}},vertexShader:"uniform \tvec3 \tdirectionalLightDirection;\nvoid main() {\nvec3 pos = ( objectMatrix * vec4( position, 1.0 )).xyz;\nvec3 norm = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz) * normal;// normalMatrix * normal;\nvec4 final = vec4( pos + directionalLightDirection * 5000.0 * step( 0.0, dot( directionalLightDirection, norm )), 1.0 );\ngl_Position = projectionMatrix * viewMatrix * final;\n}",fragmentShader:"void main() {\ngl_FragColor = vec4( 1, 1, 1, 1 );\n}"}, depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},fragmentShader:"uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}",vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f",value:1}}, fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment, THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:[THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex, @@ -295,7 +295,7 @@ U(t);(this.autoClear||o)&&this.clear();D=j.__webglObjects.length;for(o=0;o Date: Thu, 24 Mar 2011 11:36:37 +0100 Subject: [PATCH 04/10] Updated example --- examples/webgl_stencil.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/webgl_stencil.html b/examples/webgl_stencil.html index 574371e8..6b698400 100644 --- a/examples/webgl_stencil.html +++ b/examples/webgl_stencil.html @@ -144,7 +144,7 @@ boxMesh.rotation.x = Math.sin( t ) * 180 * Math.PI / 180; light.position.x = Math.sin( t ); - light.position.y = 1; + light.position.y = 1.5; light.position.z = Math.cos( t ); lightCube.position.copy( light.position ); From 66f657d84a43a1be6a6bfe194a5c271a4b1eeadd Mon Sep 17 00:00:00 2001 From: Mikael Emtinger Date: Thu, 24 Mar 2011 16:01:56 +0100 Subject: [PATCH 05/10] Optimized rendering of shadow volumes and the shader. --- src/renderers/WebGLRenderer.js | 78 +++++++++++++++++++++++----------- src/renderers/WebGLShaders.js | 10 ++--- 2 files changed, 57 insertions(+), 31 deletions(-) diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index a1b0dc10..e1887573 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -2553,7 +2553,12 @@ THREE.WebGLRenderer = function ( parameters ) { var l, ll = scene.lights.length; var p; - var light; + var light, geometryGroup; + var dirLight = []; + var program; + var p_uniforms; + var m_uniforms; + var attributes; ol = scene.__webglShadowVolumes.length; @@ -2562,38 +2567,61 @@ THREE.WebGLRenderer = function ( parameters ) { 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++ ) { - webglObject = scene.__webglShadowVolumes[ o ]; - - object = webglObject.object; - buffer = webglObject.buffer; - opaque = webglObject.opaque; - - object.matrixWorld.flattenToArray( object._objectMatrixArray ); - setupMatrices( object, camera ); - unrollBufferMaterials( webglObject ); + object = scene.__webglShadowVolumes[ o ].object; + geometryGroup = scene.__webglShadowVolumes[ o ].buffer; + material = object.materials[ 0 ]; + + + if ( !material.program ) _this.initMaterial( material, lights, fog, object ); - - // render first back, then front - - _gl.cullFace( _gl.FRONT ); - - for( p = 0; p < 2; p++ ) { - - for( i = 0; i < opaque.count; i++ ) { - - material = opaque.list[ i ]; - renderBuffer( camera, light, fog, material, buffer, object ); - - } - - _gl.cullFace( _gl.BACK ); + 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 ); + } } diff --git a/src/renderers/WebGLShaders.js b/src/renderers/WebGLShaders.js index 75415d6e..7778595f 100644 --- a/src/renderers/WebGLShaders.js +++ b/src/renderers/WebGLShaders.js @@ -596,12 +596,10 @@ THREE.ShaderLib = { "void main() {", -// todo: optimize - - "vec3 pos = ( objectMatrix * vec4( position, 1.0 )).xyz;", - "vec3 norm = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz) * normal;// normalMatrix * normal;", - "vec4 final = vec4( pos + directionalLightDirection * 5000.0 * step( 0.0, dot( directionalLightDirection, norm )), 1.0 );", - "gl_Position = projectionMatrix * viewMatrix * final;", + "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" ), From a81a02ba3004eb1de6bc687b385ab7a45b0131e2 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Thu, 24 Mar 2011 20:13:32 +0000 Subject: [PATCH 06/10] WebGLRenderer: Made material program sharing a bit simpler/efficient. API still not good for this, but works. --- src/renderers/WebGLRenderer.js | 185 +++++++++++++++++---------------- 1 file changed, 97 insertions(+), 88 deletions(-) diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 1d3a1217..f7068c82 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -1463,15 +1463,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 ); @@ -1582,103 +1582,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, From 5abbcec4492207976ffeeb3eb6b16dbbf487dde6 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Thu, 24 Mar 2011 20:40:08 +0000 Subject: [PATCH 07/10] That trickery isn't needed anymore. --- examples/webgl_materials_video.html | 1 - examples/webgl_postprocessing_dof.html | 1 - examples/webgl_ribbons.html | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) 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_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 ); From bd2d39ac6bcb850fb9d2009c4ae901ecfa5fabab Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Thu, 24 Mar 2011 21:04:34 +0000 Subject: [PATCH 08/10] Fixed broken examples. Updated build script. --- build/Three.js | 573 +++++++++++++------------ build/custom/ThreeWebGL.js | 406 +++++++++--------- examples/misc_ubiquity_test.html | 4 + examples/webgl_geometry_minecraft.html | 87 +--- examples/webgl_performance.html | 3 +- examples/webgl_sandbox.html | 12 +- utils/build.py | 2 + 7 files changed, 515 insertions(+), 572 deletions(-) diff --git a/build/Three.js b/build/Three.js index 98d664f9..c6528f26 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,f,g,h,k,m;if(b==0)d=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:d=m;f=b;g=a;break;case 2:d=a;f=b;g=c;break;case 3:d=a;f=m;g=b;break;case 4:d=c;f=a;g=b;break;case 5:d=b;f=a; -g=m;break;case 6:case 0:d=b;f=c;g=a}}this.r=d;this.g=f;this.b=g;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* +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,f=[];a=0;for(c=d.length;a0&&I>0&&P+I<1}var b,d,f,g,h,k,m,n,q,x, -z,p=a.geometry,A=p.vertices,G=[];b=0;for(d=p.faces.length;b0&&J>0&&P+J<1}var b,e,f,g,h,k,m,n,p,x, +y,o=a.geometry,A=o.vertices,G=[];b=0;for(e=o.faces.length;bm?d:m;f=f>n?f:n}a()}; -this.add3Points=function(m,n,q,x,z,p){if(k){k=!1;c=mq?m>z?m:z:q>z?q:z;f=n>x?n>p?n:p:x>p?x:p}else{c=mq?m>z?m>d?m:d:z>d?z:d:q>z?q>d?q:d:z>d?z:d;f=n>x?n>p?n>f?n:f:p>f?p:f:x>p?x>f?x:f:p>f?p:f}a()};this.addRectangle=function(m){if(k){k=!1;c=m.getLeft();b=m.getTop();d=m.getRight();f=m.getBottom()}else{c=cm.getRight()? -d:m.getRight();f=f>m.getBottom()?f:m.getBottom()}a()};this.inflate=function(m){c-=m;b-=m;d+=m;f+=m;a()};this.minSelf=function(m){c=c>m.getLeft()?c:m.getLeft();b=b>m.getTop()?b:m.getTop();d=d=0&&Math.min(f,m.getBottom())-Math.max(b,m.getTop())>=0};this.empty=function(){k=!0;f=d=b=c=0;a()};this.isEmpty=function(){return k}}; +THREE.Rectangle=function(){function a(){g=e-c;h=f-b}var c,b,e,f,g,h,k=!0;this.getX=function(){return c};this.getY=function(){return b};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return c};this.getTop=function(){return b};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(m,n,p,x){k=!1;c=m;b=n;e=p;f=x;a()};this.addPoint=function(m,n){if(k){k=!1;c=m;b=n;e=m;f=n}else{c=cm?e:m;f=f>n?f:n}a()}; +this.add3Points=function(m,n,p,x,y,o){if(k){k=!1;c=mp?m>y?m:y:p>y?p:y;f=n>x?n>o?n:o:x>o?x:o}else{c=mp?m>y?m>e?m:e:y>e?y:e:p>y?p>e?p:e:y>e?y:e;f=n>x?n>o?n>f?n:f:o>f?o:f:x>o?x>f?x:f:o>f?o: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,f,g,h,k,m,n,q,x,z,p,A,G){this.set(a||1,c||0,b||0,d||0,f||0,g||1,h||0,k||0,m||0,n||0,q||1,x||0,z||0,p||0,A||0,G||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(a,c,b,d,f,g,h,k,m,n,q,x,z,p,A,G){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=f;this.n22=g;this.n23=h;this.n24=k;this.n31=m;this.n32=n;this.n33=q;this.n34=x;this.n41=z;this.n42=p;this.n43=A;this.n44=G;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(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, -f=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()}f.cross(g,d).normalize();this.n11=d.x;this.n12=f.x;this.n13=g.x;this.n21=d.y;this.n22=f.y;this.n23=g.y;this.n31=d.z;this.n32=f.z;this.n33=g.z;return this},multiplyVector3:function(a){var c=a.x,b=a.y,d=a.z,f=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)*f;a.y=(this.n21*c+this.n22*b+this.n23* -d+this.n24)*f;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*f;return a},multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,f=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*f;a.y=this.n21*c+this.n22*b+this.n23*d+this.n24*f;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*f;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*f;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,f=a.n13,g=a.n14,h=a.n21,k=a.n22,m=a.n23,n=a.n24,q=a.n31,x=a.n32,z=a.n33,p=a.n34,A=a.n41,G=a.n42,I=a.n43,C=a.n44,J=c.n11,B=c.n12,U=c.n13,P=c.n14,O=c.n21,V=c.n22, -Y=c.n23,e=c.n24,ja=c.n31,X=c.n32,W=c.n33,wa=c.n34;this.n11=b*J+d*O+f*ja;this.n12=b*B+d*V+f*X;this.n13=b*U+d*Y+f*W;this.n14=b*P+d*e+f*wa+g;this.n21=h*J+k*O+m*ja;this.n22=h*B+k*V+m*X;this.n23=h*U+k*Y+m*W;this.n24=h*P+k*e+m*wa+n;this.n31=q*J+x*O+z*ja;this.n32=q*B+x*V+z*X;this.n33=q*U+x*Y+z*W;this.n34=q*P+x*e+z*wa+p;this.n41=A*J+G*O+I*ja;this.n42=A*B+G*V+I*X;this.n43=A*U+G*Y+I*W;this.n44=A*P+G*e+I*wa+C;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]=this.n31; +THREE.Matrix4=function(a,c,b,e,f,g,h,k,m,n,p,x,y,o,A,G){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,y||0,o||0,A||0,G||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,y,o,A,G){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=y;this.n42=o;this.n43=A;this.n44=G;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(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,y=a.n33,o=a.n34,A=a.n41,G=a.n42,J=a.n43,D=a.n44,K=c.n11,C=c.n12,U=c.n13,P=c.n14,O=c.n21,W=c.n22, +Y=c.n23,d=c.n24,ja=c.n31,X=c.n32,V=c.n33,va=c.n34;this.n11=b*K+e*O+f*ja;this.n12=b*C+e*W+f*X;this.n13=b*U+e*Y+f*V;this.n14=b*P+e*d+f*va+g;this.n21=h*K+k*O+m*ja;this.n22=h*C+k*W+m*X;this.n23=h*U+k*Y+m*V;this.n24=h*P+k*d+m*va+n;this.n31=p*K+x*O+y*ja;this.n32=p*C+x*W+y*X;this.n33=p*U+x*Y+y*V;this.n34=p*P+x*d+y*va+o;this.n41=A*K+G*O+J*ja;this.n42=A*C+G*W+J*X;this.n43=A*U+G*Y+J*V;this.n44=A*P+G*d+J*va+D;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,f=this.n21,g=this.n22,h=this.n23,k=this.n24,m=this.n31,n=this.n32,q=this.n33,x=this.n34,z=this.n41,p=this.n42,A=this.n43,G=this.n44;return d*h*n*z-b*k*n*z-d*g*q*z+c*k*q*z+b*g*x*z-c*h*x*z-d*h*m*p+b*k*m*p+d*f*q*p-a*k*q*p-b*f*x*p+a*h*x*p+d*g*m*A-c*k*m*A-d*f*n*A+a*k*n*A+c*f*x*A-a*g*x*A-b*g*m*G+c*h*m*G+b*f*n*G-a*h*n*G-c*f*q*G+a*g*q*G},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32= +this.n11,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,y=this.n41,o=this.n42,A=this.n43,G=this.n44;return e*h*n*y-b*k*n*y-e*g*p*y+c*k*p*y+b*g*x*y-c*h*x*y-e*h*m*o+b*k*m*o+e*f*p*o-a*k*p*o-b*f*x*o+a*h*x*o+e*g*m*A-c*k*m*A-e*f*n*A+a*k*n*A+c*f*x*A-a*g*x*A-b*g*m*G+c*h*m*G+b*f*n*G-a*h*n*G-c*f*p*G+a*g*p*G},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),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-d*k,m*k+d*h,0,m*h+d*k,n*h+b,n*k-d*g,0,m*k-d*h,n*k+d*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,d=a.z;a=Math.cos(c);c=Math.sin(c);var f=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var h=a*b,k=c*b;this.n11=f*g;this.n12=-f*d;this.n13=b;this.n21=k*g+a*d;this.n22=-k*d+a*g;this.n23=-c*f;this.n31=-h*g+c*d;this.n32=h*d+c*g;this.n33=a*f;return this},setRotationFromQuaternion:function(a){var c= -a.x,b=a.y,d=a.z,f=a.w,g=c+c,h=b+b,k=d+d;a=c*g;var m=c*h;c*=k;var n=b*h;b*=k;d*=k;g*=f;h*=f;f*=k;this.n11=1-(n+d);this.n12=m-f;this.n13=c+h;this.n21=m+f;this.n22=1-(a+d);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,d=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*d;this.n22=a.n22*d;this.n32=a.n32*d;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,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,m=a.n23,n=a.n24,q=a.n31,x=a.n32,z=a.n33,p=a.n34,A=a.n41,G=a.n42,I=a.n43,C=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=m*p*G-n*z*G+n*x*I-k*p*I-m*x*C+k*z*C;c.n12=g*z*G-f*p*G-g*x*I+d*p*I+f*x*C-d*z*C;c.n13=f*n*G-g*m*G+g*k*I-d*n*I-f*k*C+d*m*C;c.n14=g*m*x-f*n*x-g*k*z+d*n*z+f*k*p-d*m*p;c.n21=n*z*A-m*p*A-n*q*I+h*p*I+m*q*C-h*z*C;c.n22=f*p*A-g*z*A+g*q*I-b*p*I-f*q*C+b*z*C;c.n23=g*m*A-f*n*A-g*h*I+b*n*I+f*h*C-b*m*C; -c.n24=f*n*q-g*m*q+g*h*z-b*n*z-f*h*p+b*m*p;c.n31=k*p*A-n*x*A+n*q*G-h*p*G-k*q*C+h*x*C;c.n32=g*x*A-d*p*A-g*q*G+b*p*G+d*q*C-b*x*C;c.n33=f*n*A-g*k*A+g*h*G-b*n*G-d*h*C+b*k*C;c.n34=g*k*q-d*n*q-g*h*x+b*n*x+d*h*p-b*k*p;c.n41=m*x*A-k*z*A-m*q*G+h*z*G+k*q*I-h*x*I;c.n42=d*z*A-f*x*A+f*q*G-b*z*G-d*q*I+b*x*I;c.n43=f*k*A-d*m*A-f*h*G+b*m*G+d*h*I-b*k*I;c.n44=d*m*q-f*k*q+f*h*x-b*m*x-d*h*z+b*k*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,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,q=-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*n;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*d;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*q;b[8]=a*x;return c}; -THREE.Matrix4.makeFrustum=function(a,c,b,d,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/(d-b);h.n23=(d+b)/(d-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,d){var f;a=b*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,b,d)}; -THREE.Matrix4.makeOrtho=function(a,c,b,d,f,g){var h,k,m,n;h=new THREE.Matrix4;k=c-a;m=b-d;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+d)/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; +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,y=a.n33,o=a.n34,A=a.n41,G=a.n42,J=a.n43,D=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=m*o*G-n*y*G+n*x*J-k*o*J-m*x*D+k*y*D;c.n12=g*y*G-f*o*G-g*x*J+e*o*J+f*x*D-e*y*D;c.n13=f*n*G-g*m*G+g*k*J-e*n*J-f*k*D+e*m*D;c.n14=g*m*x-f*n*x-g*k*y+e*n*y+f*k*o-e*m*o;c.n21=n*y*A-m*o*A-n*p*J+h*o*J+m*p*D-h*y*D;c.n22=f*o*A-g*y*A+g*p*J-b*o*J-f*p*D+b*y*D;c.n23=g*m*A-f*n*A-g*h*J+b*n*J+f*h*D-b*m*D; +c.n24=f*n*p-g*m*p+g*h*y-b*n*y-f*h*o+b*m*o;c.n31=k*o*A-n*x*A+n*p*G-h*o*G-k*p*D+h*x*D;c.n32=g*x*A-e*o*A-g*p*G+b*o*G+e*p*D-b*x*D;c.n33=f*n*A-g*k*A+g*h*G-b*n*G-e*h*D+b*k*D;c.n34=g*k*p-e*n*p-g*h*x+b*n*x+e*h*o-b*k*o;c.n41=m*x*A-k*y*A-m*p*G+h*y*G+k*p*J-h*x*J;c.n42=e*y*A-f*x*A+f*p*G-b*y*G-e*p*J+b*x*J;c.n43=f*k*A-e*m*A-f*h*G+b*m*G+e*h*J-b*k*J;c.n44=e*m*p-f*k*p+f*h*x-b*m*x-e*h*y+b*k*y;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(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-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*f+c.w*d;b.x=a.x*f+c.x*d;b.y=a.y*f+c.y*d;b.z=a.z*f+c.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; -THREE.Face3=function(a,c,b,d,f,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=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,d,f,g,h){this.a=a;this.b=c;this.c=b;this.d=d;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)}; +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.001){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;n=this.points[b[0]];q=this.points[b[1]]; -x=this.points[b[2]];z=this.points[b[3]];k=h*h;m=h*k;d.x=c(n.x,q.x,x.x,z.x,h,k,m);d.y=c(n.y,q.y,x.y,z.y,h,k,m);d.z=c(n.z,q.z,x.z,z.z,h,k,m);return d};this.getControlPointsArray=function(){var p,A,G=this.points.length,I=[];for(p=0;pthis.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]];y=this.points[b[3]];k=h*h;m=h*k;e.x=c(n.x,p.x,x.x,y.x,h,k,m);e.y=c(n.y,p.y,x.y,y.y,h,k,m);e.z=c(n.z,p.z,x.z,y.z,h,k,m);return e};this.getControlPointsArray=function(){var o,A,G=this.points.length,J=[];for(o=0;o1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+p);d=d<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=f[0]+(g[0]-f[0])*d;b.y=f[1]+(g[1]-f[1])*d;b.z=f[2]+(g[2]-f[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= -this.getPrevKeyWith("pos",p,h.index-1).pos;this.points[1]=f;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",p,k.index+1).pos;d=d*0.33+0.33;f=this.interpolateCatmullRom(this.points,d);b.x=f[0];b.y=f[1];b.z=f[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(f,g,a.quaternion,d);else if(b==="scl"){b=a.scale;b.x=f[0]+(g[0]-f[0])*d;b.y=f[1]+(g[1]-f[1])*d;b.z=f[2]+(g[2]-f[2])*d}}}}if(this.JITCompile&&q[0][n]===undefined){this.hierarchy[0].update(undefined,!0);for(p=0;pa.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;d[0]=this.interpolate(g[0],k[0],m[0],n[0],f,b,h);d[1]=this.interpolate(g[1],k[1],m[1],n[1],f,b,h);d[2]=this.interpolate(g[2],k[2],m[2],n[2],f,b,h);return d}; -THREE.Animation.prototype.interpolate=function(a,c,b,d,f,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*f+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,f){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=b||0.1;this.far=d||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.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,y;this.currentTime+=a*this.timeScale;y=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 o=0,A=this.hierarchy.length;o1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+o);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",o,h.index-1).pos;this.points[1]=f;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",o,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(o=0;oa.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&&ka>=0&&oa>=0&&ma>=0)return!0;else if(Aa<0&&ka<0||oa<0&&ma<0)return!1;else{if(Aa<0)wa=Math.max(wa,Aa/(Aa-ka));else ka<0&&(ha=Math.min(ha,Aa/(Aa-ka)));if(oa<0)wa=Math.max(wa,oa/(oa-ma));else ma<0&&(ha=Math.min(ha,oa/(oa-ma)));if(haAa&&h.positionScreen.z0&&P.z<1){Ca=B[J]=B[J]||new THREE.RenderableParticle;J++;C=Ca;C.x=P.x/P.w;C.y=P.y/P.w;C.z=P.z;C.rotation=xa.rotation.z;C.scale.x=xa.scale.x*Math.abs(C.x-(P.x+W.projectionMatrix.n11)/(P.w+W.projectionMatrix.n14));C.scale.y=xa.scale.y*Math.abs(C.y-(P.y+W.projectionMatrix.n22)/(P.w+W.projectionMatrix.n24));C.materials=xa.materials;ha.push(C)}}}}wa&&ha.sort(c);return ha}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,f,g;this.domElement=document.createElement("div");this.setSize=function(h,k){b=h;d=k;f=b/2;g=d/2};this.render=function(h,k){var m,n,q,x,z,p,A,G;a=c.projectScene(h,k);m=0;for(n=a.length;m0){aa.r+=ea.r*za;aa.g+=ea.g*za;aa.b+=ea.b*za}}else if(za instanceof THREE.PointLight){T.sub(za.position,Z);T.normalize();za=na.dot(T)*$;if(za>0){aa.r+= -ea.r*za;aa.g+=ea.g*za;aa.b+=ea.b*za}}}}function eb(L,Z,na){a(na.opacity);c(na.blending);var aa,ta,za,ea,$,Ka;if(na instanceof THREE.ParticleBasicMaterial){if(na.map){ea=na.map.image;$=ea.width>>1;Ka=ea.height>>1;na=Z.scale.x*k;za=Z.scale.y*m;aa=na*$;ta=za*Ka;E.set(L.x-aa,L.y-ta,L.x+aa,L.y+ta);if(o.instersects(E)){n.save();n.translate(L.x,L.y);n.rotate(-Z.rotation);n.scale(na,-za);n.translate(-$,-Ka);n.drawImage(ea,0,0);n.restore()}}}else if(na instanceof THREE.ParticleCanvasMaterial){if(K){F.r=D.r+ -Q.r+H.r;F.g=D.g+Q.g+H.g;F.b=D.b+Q.b+H.b;ca.r=na.color.r*F.r;ca.g=na.color.g*F.g;ca.b=na.color.b*F.b;ca.updateStyleString()}else ca.__styleString=na.color.__styleString;aa=Z.scale.x*k;ta=Z.scale.y*m;E.set(L.x-aa,L.y-ta,L.x+aa,L.y+ta);if(o.instersects(E)){n.save();n.translate(L.x,L.y);n.rotate(-Z.rotation);n.scale(aa,ta);na.program(n,ca);n.restore()}}}function Ta(L,Z,na,aa){a(aa.opacity);c(aa.blending);n.beginPath();n.moveTo(L.positionScreen.x,L.positionScreen.y);n.lineTo(Z.positionScreen.x,Z.positionScreen.y); -n.closePath();if(aa instanceof THREE.LineBasicMaterial){ca.__styleString=aa.color.__styleString;L=aa.linewidth;if(I!=L)n.lineWidth=I=L;L=ca.__styleString;if(A!=L)n.strokeStyle=A=L;n.stroke();E.inflate(aa.linewidth*2)}}function Ia(L,Z,na,aa,ta,za,ea,$,Ka){a($.opacity);c($.blending);V=L.positionScreen.x;Y=L.positionScreen.y;e=Z.positionScreen.x;ja=Z.positionScreen.y;X=na.positionScreen.x;W=na.positionScreen.y;bb(V,Y,e,ja,X,W);if($ instanceof THREE.MeshBasicMaterial)if($.map){if($.map.mapping instanceof -THREE.UVMapping){Ca=ea.uvs[0];Da(V,Y,e,ja,X,W,$.map.image,Ca[aa].u,Ca[aa].v,Ca[ta].u,Ca[ta].v,Ca[za].u,Ca[za].v)}}else if($.envMap){if($.envMap.mapping instanceof THREE.SphericalReflectionMapping){L=ia.matrixWorldInverse;T.copy(ea.vertexNormalsWorld[0]);Za=(T.x*L.n11+T.y*L.n12+T.z*L.n13)*0.5+0.5;$a=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;T.copy(ea.vertexNormalsWorld[1]);Ha=(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(ea.vertexNormalsWorld[2]);w=(T.x*L.n11+ -T.y*L.n12+T.z*L.n13)*0.5+0.5;t=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;Da(V,Y,e,ja,X,W,$.envMap.image,Za,$a,Ha,j,w,t)}}else $.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&!$.wireframe){if($.map.mapping instanceof THREE.UVMapping){Ca=ea.uvs[0];Da(V,Y,e,ja,X,W,$.map.image,Ca[aa].u,Ca[aa].v,Ca[ta].u,Ca[ta].v,Ca[za].u,Ca[za].v)}c(THREE.SubtractiveBlending)}if(K)if(!$.wireframe&&$.shading==THREE.SmoothShading&& -ea.vertexNormalsWorld.length==3){S.r=M.r=fa.r=D.r;S.g=M.g=fa.g=D.g;S.b=M.b=fa.b=D.b;Ga(Ka,ea.v1.positionWorld,ea.vertexNormalsWorld[0],S);Ga(Ka,ea.v2.positionWorld,ea.vertexNormalsWorld[1],M);Ga(Ka,ea.v3.positionWorld,ea.vertexNormalsWorld[2],fa);ra.r=(M.r+fa.r)*0.5;ra.g=(M.g+fa.g)*0.5;ra.b=(M.b+fa.b)*0.5;xa=Va(S,M,fa,ra);Da(V,Y,e,ja,X,W,xa,0,0,1,0,0,1)}else{F.r=D.r;F.g=D.g;F.b=D.b;Ga(Ka,ea.centroidWorld,ea.normalWorld,F);ca.r=$.color.r*F.r;ca.g=$.color.g*F.g;ca.b=$.color.b*F.b;ca.updateStyleString(); -$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else $.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){la=ia.near;qa=ia.far;S.r=S.g=S.b=1-Ma(L.positionScreen.z,la,qa);M.r=M.g=M.b=1-Ma(Z.positionScreen.z,la,qa);fa.r=fa.g=fa.b=1-Ma(na.positionScreen.z,la,qa);ra.r=(M.r+fa.r)*0.5;ra.g=(M.g+fa.g)*0.5;ra.b=(M.b+fa.b)*0.5;xa=Va(S,M,fa,ra);Da(V,Y,e,ja,X,W,xa,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){ca.r= -N(ea.normalWorld.x);ca.g=N(ea.normalWorld.y);ca.b=N(ea.normalWorld.z);ca.updateStyleString();$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}}function Ra(L,Z,na,aa,ta,za,ea,$,Ka){a($.opacity);c($.blending);if($.map||$.envMap){Ia(L,Z,aa,0,1,3,ea,$,Ka);Ia(ta,na,za,1,2,3,ea,$,Ka)}else{V=L.positionScreen.x;Y=L.positionScreen.y;e=Z.positionScreen.x;ja=Z.positionScreen.y;X=na.positionScreen.x;W=na.positionScreen.y;wa=aa.positionScreen.x;ha=aa.positionScreen.y;Aa=ta.positionScreen.x; -ka=ta.positionScreen.y;oa=za.positionScreen.x;ma=za.positionScreen.y;if($ instanceof THREE.MeshBasicMaterial){db(V,Y,e,ja,X,W,wa,ha);$.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshLambertMaterial)if(K)if(!$.wireframe&&$.shading==THREE.SmoothShading&&ea.vertexNormalsWorld.length==4){S.r=M.r=fa.r=ra.r=D.r;S.g=M.g=fa.g=ra.g=D.g;S.b=M.b=fa.b=ra.b=D.b;Ga(Ka,ea.v1.positionWorld,ea.vertexNormalsWorld[0],S);Ga(Ka,ea.v2.positionWorld,ea.vertexNormalsWorld[1], -M);Ga(Ka,ea.v4.positionWorld,ea.vertexNormalsWorld[3],fa);Ga(Ka,ea.v3.positionWorld,ea.vertexNormalsWorld[2],ra);xa=Va(S,M,fa,ra);bb(V,Y,e,ja,wa,ha);Da(V,Y,e,ja,wa,ha,xa,0,0,1,0,0,1);bb(Aa,ka,X,W,oa,ma);Da(Aa,ka,X,W,oa,ma,xa,1,0,1,1,0,1)}else{F.r=D.r;F.g=D.g;F.b=D.b;Ga(Ka,ea.centroidWorld,ea.normalWorld,F);ca.r=$.color.r*F.r;ca.g=$.color.g*F.g;ca.b=$.color.b*F.b;ca.updateStyleString();db(V,Y,e,ja,X,W,wa,ha);$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else{db(V,Y,e,ja, -X,W,wa,ha);$.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshNormalMaterial){ca.r=N(ea.normalWorld.x);ca.g=N(ea.normalWorld.y);ca.b=N(ea.normalWorld.z);ca.updateStyleString();db(V,Y,e,ja,X,W,wa,ha);$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){la=ia.near;qa=ia.far;S.r=S.g=S.b=1-Ma(L.positionScreen.z,la,qa);M.r=M.g=M.b=1-Ma(Z.positionScreen.z,la,qa);fa.r=fa.g= -fa.b=1-Ma(aa.positionScreen.z,la,qa);ra.r=ra.g=ra.b=1-Ma(na.positionScreen.z,la,qa);xa=Va(S,M,fa,ra);bb(V,Y,e,ja,wa,ha);Da(V,Y,e,ja,wa,ha,xa,0,0,1,0,0,1);bb(Aa,ka,X,W,oa,ma);Da(Aa,ka,X,W,oa,ma,xa,1,0,1,1,0,1)}}}function bb(L,Z,na,aa,ta,za){n.beginPath();n.moveTo(L,Z);n.lineTo(na,aa);n.lineTo(ta,za);n.lineTo(L,Z);n.closePath()}function db(L,Z,na,aa,ta,za,ea,$){n.beginPath();n.moveTo(L,Z);n.lineTo(na,aa);n.lineTo(ta,za);n.lineTo(ea,$);n.lineTo(L,Z);n.closePath()}function Pa(L,Z){if(A!=L)n.strokeStyle= -A=L;if(I!=Z)n.lineWidth=I=Z;n.stroke();E.inflate(Z*2)}function Ua(L){if(G!=L)n.fillStyle=G=L;n.fill()}function Da(L,Z,na,aa,ta,za,ea,$,Ka,Xa,Ya,cb,gb){var ab,Wa;ab=ea.width-1;Wa=ea.height-1;$*=ab;Ka*=Wa;Xa*=ab;Ya*=Wa;cb*=ab;gb*=Wa;na-=L;aa-=Z;ta-=L;za-=Z;Xa-=$;Ya-=Ka;cb-=$;gb-=Ka;ab=Xa*gb-cb*Ya;if(ab!=0){Wa=1/ab;ab=(gb*na-Ya*ta)*Wa;Ya=(gb*aa-Ya*za)*Wa;na=(Xa*ta-cb*na)*Wa;aa=(Xa*za-cb*aa)*Wa;L=L-ab*$-na*Ka;Z=Z-Ya*$-aa*Ka;n.save();n.transform(ab,Ya,na,aa,L,Z);n.clip();n.drawImage(ea,0,0);n.restore()}} -function Va(L,Z,na,aa){var ta=~~(L.r*255),za=~~(L.g*255);L=~~(L.b*255);var ea=~~(Z.r*255),$=~~(Z.g*255);Z=~~(Z.b*255);var Ka=~~(na.r*255),Xa=~~(na.g*255);na=~~(na.b*255);var Ya=~~(aa.r*255),cb=~~(aa.g*255);aa=~~(aa.b*255);ya[0]=ta<0?0:ta>255?255:ta;ya[1]=za<0?0:za>255?255:za;ya[2]=L<0?0:L>255?255:L;ya[4]=ea<0?0:ea>255?255:ea;ya[5]=$<0?0:$>255?255:$;ya[6]=Z<0?0:Z>255?255:Z;ya[8]=Ka<0?0:Ka>255?255:Ka;ya[9]=Xa<0?0:Xa>255?255:Xa;ya[10]=na<0?0:na>255?255:na;ya[12]=Ya<0?0:Ya>255?255:Ya;ya[13]=cb<0?0:cb> -255?255:cb;ya[14]=aa<0?0:aa>255?255:aa;pa.putImageData(sa,0,0);Ea.drawImage(ga,0,0);return ua}function Ma(L,Z,na){L=(L-Z)/(na-Z);return L*L*(3-2*L)}function N(L){L=(L+1)*0.5;return L<0?0:L>1?1:L}function Na(L,Z){var na=Z.x-L.x,aa=Z.y-L.y,ta=1/Math.sqrt(na*na+aa*aa);na*=ta;aa*=ta;Z.x+=na;Z.y+=aa;L.x-=na;L.y-=aa}var Qa,ib,Ba,Sa,Fa,Oa,Ja,va;this.autoClear?this.clear():n.setTransform(1,0,0,-1,k,m);b=d.projectScene(R,ia,this.sortElements);(K=R.lights.length>0)&&La(R);Qa=0;for(ib=b.length;Qa0){ma.r+=M.color.r*fa;ma.g+=M.color.g*fa;ma.b+=M.color.b*fa}}else if(M instanceof THREE.PointLight){e.sub(M.position,oa.centroidWorld);e.normalize();fa=oa.normalWorld.dot(e)*M.intensity;if(fa>0){ma.r+=M.color.r*fa;ma.g+=M.color.g*fa;ma.b+=M.color.b*fa}}}}function c(ka,oa,ma,ca,S,M){W=d(wa++); -W.setAttribute("d","M "+ka.positionScreen.x+" "+ka.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+ma.positionScreen.x+","+ma.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)B.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(J){U.r=P.r;U.g=P.g;U.b=P.b;a(M,ca,U);B.r=S.color.r*U.r;B.g=S.color.g*U.g;B.b=S.color.b*U.b;B.updateStyleString()}else B.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){Y= -1-S.__2near/(S.__farPlusNear-ca.z*S.__farMinusNear);B.setRGB(Y,Y,Y)}else S instanceof THREE.MeshNormalMaterial&&B.setRGB(f(ca.normalWorld.x),f(ca.normalWorld.y),f(ca.normalWorld.z));S.wireframe?W.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+S.wireframeLinewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframeLinecap+"; stroke-linejoin: "+S.wireframeLinejoin):W.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+S.opacity);k.appendChild(W)} -function b(ka,oa,ma,ca,S,M,fa){W=d(wa++);W.setAttribute("d","M "+ka.positionScreen.x+" "+ka.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+ma.positionScreen.x+","+ma.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)B.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(J){U.r=P.r;U.g=P.g;U.b=P.b;a(fa,S,U);B.r=M.color.r*U.r;B.g=M.color.g*U.g;B.b=M.color.b*U.b;B.updateStyleString()}else B.__styleString= -M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){Y=1-M.__2near/(M.__farPlusNear-S.z*M.__farMinusNear);B.setRGB(Y,Y,Y)}else M instanceof THREE.MeshNormalMaterial&&B.setRGB(f(S.normalWorld.x),f(S.normalWorld.y),f(S.normalWorld.z));M.wireframe?W.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+M.wireframeLinewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframeLinecap+"; stroke-linejoin: "+M.wireframeLinejoin):W.setAttribute("style","fill: "+ -B.__styleString+"; fill-opacity: "+M.opacity);k.appendChild(W)}function d(ka){if(ja[ka]==null){ja[ka]=document.createElementNS("http://www.w3.org/2000/svg","path");Aa==0&&ja[ka].setAttribute("shape-rendering","crispEdges")}return ja[ka]}function f(ka){return ka<0?Math.min((1+ka)*0.5,0.5):0.5+Math.min(ka*0.5,0.5)}var g=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,n,q,x,z,p,A,G,I=new THREE.Rectangle,C=new THREE.Rectangle,J=!1,B=new THREE.Color(16777215), -U=new THREE.Color(16777215),P=new THREE.Color(0),O=new THREE.Color(0),V=new THREE.Color(0),Y,e=new THREE.Vector3,ja=[],X=[],W,wa,ha,Aa=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ka){switch(ka){case "high":Aa=1;break;case "low":Aa=0}};this.setSize=function(ka,oa){m=ka;n=oa;q=m/2;x=n/2;k.setAttribute("viewBox",-q+" "+-x+" "+m+" "+n);k.setAttribute("width",m);k.setAttribute("height",n);I.set(-q,-x,q,x)};this.clear=function(){for(;k.childNodes.length> -0;)k.removeChild(k.childNodes[0])};this.render=function(ka,oa){var ma,ca,S,M,fa,ra,la,qa;this.autoClear&&this.clear();g=h.projectScene(ka,oa,this.sortElements);ha=wa=0;if(J=ka.lights.length>0){la=ka.lights;P.setRGB(0,0,0);O.setRGB(0,0,0);V.setRGB(0,0,0);ma=0;for(ca=la.length;ma=0&&la>=0&&oa>=0&&ma>=0)return!0;else if(za<0&&la<0||oa<0&&ma<0)return!1;else{if(za<0)va=Math.max(va,za/(za-la));else la<0&&(ga=Math.min(ga,za/(za-la)));if(oa<0)va=Math.max(va,oa/(oa-ma));else ma<0&&(ga=Math.min(ga,oa/(oa-ma)));if(gaza&&h.positionScreen.z0&&P.z<1){Ca=C[K]=C[K]||new THREE.RenderableParticle;K++;D=Ca;D.x=P.x/P.w;D.y=P.y/P.w;D.z=P.z;D.rotation=wa.rotation.z;D.scale.x=wa.scale.x*Math.abs(D.x-(P.x+V.projectionMatrix.n11)/(P.w+V.projectionMatrix.n14));D.scale.y=wa.scale.y*Math.abs(D.y-(P.y+V.projectionMatrix.n22)/(P.w+V.projectionMatrix.n24));D.materials=wa.materials;ga.push(D)}}}}va&&ga.sort(c);return ga}}; +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,y,o,A,G;a=c.projectScene(h,k);m=0;for(n=a.length;m0){aa.r+=ea.r*ya;aa.g+=ea.g*ya;aa.b+=ea.b*ya}}else if(ya instanceof THREE.PointLight){Q.sub(ya.position,Z);Q.normalize();ya=na.dot(Q)*$;if(ya>0){aa.r+= +ea.r*ya;aa.g+=ea.g*ya;aa.b+=ea.b*ya}}}}function eb(L,Z,na){a(na.opacity);c(na.blending);var aa,ta,ya,ea,$,Ka;if(na instanceof THREE.ParticleBasicMaterial){if(na.map){ea=na.map.image;$=ea.width>>1;Ka=ea.height>>1;na=Z.scale.x*k;ya=Z.scale.y*m;aa=na*$;ta=ya*Ka;F.set(L.x-aa,L.y-ta,L.x+aa,L.y+ta);if(q.instersects(F)){n.save();n.translate(L.x,L.y);n.rotate(-Z.rotation);n.scale(na,-ya);n.translate(-$,-Ka);n.drawImage(ea,0,0);n.restore()}}}else if(na instanceof THREE.ParticleCanvasMaterial){if(H){E.r=z.r+ +T.r+I.r;E.g=z.g+T.g+I.g;E.b=z.b+T.b+I.b;ca.r=na.color.r*E.r;ca.g=na.color.g*E.g;ca.b=na.color.b*E.b;ca.updateStyleString()}else ca.__styleString=na.color.__styleString;aa=Z.scale.x*k;ta=Z.scale.y*m;F.set(L.x-aa,L.y-ta,L.x+aa,L.y+ta);if(q.instersects(F)){n.save();n.translate(L.x,L.y);n.rotate(-Z.rotation);n.scale(aa,ta);na.program(n,ca);n.restore()}}}function Ta(L,Z,na,aa){a(aa.opacity);c(aa.blending);n.beginPath();n.moveTo(L.positionScreen.x,L.positionScreen.y);n.lineTo(Z.positionScreen.x,Z.positionScreen.y); +n.closePath();if(aa instanceof THREE.LineBasicMaterial){ca.__styleString=aa.color.__styleString;L=aa.linewidth;if(J!=L)n.lineWidth=J=L;L=ca.__styleString;if(A!=L)n.strokeStyle=A=L;n.stroke();F.inflate(aa.linewidth*2)}}function Ia(L,Z,na,aa,ta,ya,ea,$,Ka){a($.opacity);c($.blending);W=L.positionScreen.x;Y=L.positionScreen.y;d=Z.positionScreen.x;ja=Z.positionScreen.y;X=na.positionScreen.x;V=na.positionScreen.y;bb(W,Y,d,ja,X,V);if($ instanceof THREE.MeshBasicMaterial)if($.map){if($.map.mapping instanceof +THREE.UVMapping){Ca=ea.uvs[0];Da(W,Y,d,ja,X,V,$.map.image,Ca[aa].u,Ca[aa].v,Ca[ta].u,Ca[ta].v,Ca[ya].u,Ca[ya].v)}}else if($.envMap){if($.envMap.mapping instanceof THREE.SphericalReflectionMapping){L=ia.matrixWorldInverse;Q.copy(ea.vertexNormalsWorld[0]);Za=(Q.x*L.n11+Q.y*L.n12+Q.z*L.n13)*0.5+0.5;$a=-(Q.x*L.n21+Q.y*L.n22+Q.z*L.n23)*0.5+0.5;Q.copy(ea.vertexNormalsWorld[1]);Ha=(Q.x*L.n11+Q.y*L.n12+Q.z*L.n13)*0.5+0.5;j=-(Q.x*L.n21+Q.y*L.n22+Q.z*L.n23)*0.5+0.5;Q.copy(ea.vertexNormalsWorld[2]);t=(Q.x*L.n11+ +Q.y*L.n12+Q.z*L.n13)*0.5+0.5;w=-(Q.x*L.n21+Q.y*L.n22+Q.z*L.n23)*0.5+0.5;Da(W,Y,d,ja,X,V,$.envMap.image,Za,$a,Ha,j,t,w)}}else $.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&!$.wireframe){if($.map.mapping instanceof THREE.UVMapping){Ca=ea.uvs[0];Da(W,Y,d,ja,X,V,$.map.image,Ca[aa].u,Ca[aa].v,Ca[ta].u,Ca[ta].v,Ca[ya].u,Ca[ya].v)}c(THREE.SubtractiveBlending)}if(H)if(!$.wireframe&&$.shading==THREE.SmoothShading&& +ea.vertexNormalsWorld.length==3){S.r=M.r=fa.r=z.r;S.g=M.g=fa.g=z.g;S.b=M.b=fa.b=z.b;Ga(Ka,ea.v1.positionWorld,ea.vertexNormalsWorld[0],S);Ga(Ka,ea.v2.positionWorld,ea.vertexNormalsWorld[1],M);Ga(Ka,ea.v3.positionWorld,ea.vertexNormalsWorld[2],fa);ra.r=(M.r+fa.r)*0.5;ra.g=(M.g+fa.g)*0.5;ra.b=(M.b+fa.b)*0.5;wa=Va(S,M,fa,ra);Da(W,Y,d,ja,X,V,wa,0,0,1,0,0,1)}else{E.r=z.r;E.g=z.g;E.b=z.b;Ga(Ka,ea.centroidWorld,ea.normalWorld,E);ca.r=$.color.r*E.r;ca.g=$.color.g*E.g;ca.b=$.color.b*E.b;ca.updateStyleString(); +$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else $.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){ka=ia.near;qa=ia.far;S.r=S.g=S.b=1-Ma(L.positionScreen.z,ka,qa);M.r=M.g=M.b=1-Ma(Z.positionScreen.z,ka,qa);fa.r=fa.g=fa.b=1-Ma(na.positionScreen.z,ka,qa);ra.r=(M.r+fa.r)*0.5;ra.g=(M.g+fa.g)*0.5;ra.b=(M.b+fa.b)*0.5;wa=Va(S,M,fa,ra);Da(W,Y,d,ja,X,V,wa,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){ca.r= +N(ea.normalWorld.x);ca.g=N(ea.normalWorld.y);ca.b=N(ea.normalWorld.z);ca.updateStyleString();$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}}function Ra(L,Z,na,aa,ta,ya,ea,$,Ka){a($.opacity);c($.blending);if($.map||$.envMap){Ia(L,Z,aa,0,1,3,ea,$,Ka);Ia(ta,na,ya,1,2,3,ea,$,Ka)}else{W=L.positionScreen.x;Y=L.positionScreen.y;d=Z.positionScreen.x;ja=Z.positionScreen.y;X=na.positionScreen.x;V=na.positionScreen.y;va=aa.positionScreen.x;ga=aa.positionScreen.y;za=ta.positionScreen.x; +la=ta.positionScreen.y;oa=ya.positionScreen.x;ma=ya.positionScreen.y;if($ instanceof THREE.MeshBasicMaterial){db(W,Y,d,ja,X,V,va,ga);$.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshLambertMaterial)if(H)if(!$.wireframe&&$.shading==THREE.SmoothShading&&ea.vertexNormalsWorld.length==4){S.r=M.r=fa.r=ra.r=z.r;S.g=M.g=fa.g=ra.g=z.g;S.b=M.b=fa.b=ra.b=z.b;Ga(Ka,ea.v1.positionWorld,ea.vertexNormalsWorld[0],S);Ga(Ka,ea.v2.positionWorld,ea.vertexNormalsWorld[1], +M);Ga(Ka,ea.v4.positionWorld,ea.vertexNormalsWorld[3],fa);Ga(Ka,ea.v3.positionWorld,ea.vertexNormalsWorld[2],ra);wa=Va(S,M,fa,ra);bb(W,Y,d,ja,va,ga);Da(W,Y,d,ja,va,ga,wa,0,0,1,0,0,1);bb(za,la,X,V,oa,ma);Da(za,la,X,V,oa,ma,wa,1,0,1,1,0,1)}else{E.r=z.r;E.g=z.g;E.b=z.b;Ga(Ka,ea.centroidWorld,ea.normalWorld,E);ca.r=$.color.r*E.r;ca.g=$.color.g*E.g;ca.b=$.color.b*E.b;ca.updateStyleString();db(W,Y,d,ja,X,V,va,ga);$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else{db(W,Y,d,ja, +X,V,va,ga);$.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshNormalMaterial){ca.r=N(ea.normalWorld.x);ca.g=N(ea.normalWorld.y);ca.b=N(ea.normalWorld.z);ca.updateStyleString();db(W,Y,d,ja,X,V,va,ga);$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){ka=ia.near;qa=ia.far;S.r=S.g=S.b=1-Ma(L.positionScreen.z,ka,qa);M.r=M.g=M.b=1-Ma(Z.positionScreen.z,ka,qa);fa.r=fa.g= +fa.b=1-Ma(aa.positionScreen.z,ka,qa);ra.r=ra.g=ra.b=1-Ma(na.positionScreen.z,ka,qa);wa=Va(S,M,fa,ra);bb(W,Y,d,ja,va,ga);Da(W,Y,d,ja,va,ga,wa,0,0,1,0,0,1);bb(za,la,X,V,oa,ma);Da(za,la,X,V,oa,ma,wa,1,0,1,1,0,1)}}}function bb(L,Z,na,aa,ta,ya){n.beginPath();n.moveTo(L,Z);n.lineTo(na,aa);n.lineTo(ta,ya);n.lineTo(L,Z);n.closePath()}function db(L,Z,na,aa,ta,ya,ea,$){n.beginPath();n.moveTo(L,Z);n.lineTo(na,aa);n.lineTo(ta,ya);n.lineTo(ea,$);n.lineTo(L,Z);n.closePath()}function Pa(L,Z){if(A!=L)n.strokeStyle= +A=L;if(J!=Z)n.lineWidth=J=Z;n.stroke();F.inflate(Z*2)}function Ua(L){if(G!=L)n.fillStyle=G=L;n.fill()}function Da(L,Z,na,aa,ta,ya,ea,$,Ka,Xa,Ya,cb,gb){var ab,Wa;ab=ea.width-1;Wa=ea.height-1;$*=ab;Ka*=Wa;Xa*=ab;Ya*=Wa;cb*=ab;gb*=Wa;na-=L;aa-=Z;ta-=L;ya-=Z;Xa-=$;Ya-=Ka;cb-=$;gb-=Ka;ab=Xa*gb-cb*Ya;if(ab!=0){Wa=1/ab;ab=(gb*na-Ya*ta)*Wa;Ya=(gb*aa-Ya*ya)*Wa;na=(Xa*ta-cb*na)*Wa;aa=(Xa*ya-cb*aa)*Wa;L=L-ab*$-na*Ka;Z=Z-Ya*$-aa*Ka;n.save();n.transform(ab,Ya,na,aa,L,Z);n.clip();n.drawImage(ea,0,0);n.restore()}} +function Va(L,Z,na,aa){var ta=~~(L.r*255),ya=~~(L.g*255);L=~~(L.b*255);var ea=~~(Z.r*255),$=~~(Z.g*255);Z=~~(Z.b*255);var Ka=~~(na.r*255),Xa=~~(na.g*255);na=~~(na.b*255);var Ya=~~(aa.r*255),cb=~~(aa.g*255);aa=~~(aa.b*255);Aa[0]=ta<0?0:ta>255?255:ta;Aa[1]=ya<0?0:ya>255?255:ya;Aa[2]=L<0?0:L>255?255:L;Aa[4]=ea<0?0:ea>255?255:ea;Aa[5]=$<0?0:$>255?255:$;Aa[6]=Z<0?0:Z>255?255:Z;Aa[8]=Ka<0?0:Ka>255?255:Ka;Aa[9]=Xa<0?0:Xa>255?255:Xa;Aa[10]=na<0?0:na>255?255:na;Aa[12]=Ya<0?0:Ya>255?255:Ya;Aa[13]=cb<0?0:cb> +255?255:cb;Aa[14]=aa<0?0:aa>255?255:aa;pa.putImageData(sa,0,0);Ea.drawImage(ha,0,0);return xa}function Ma(L,Z,na){L=(L-Z)/(na-Z);return L*L*(3-2*L)}function N(L){L=(L+1)*0.5;return L<0?0:L>1?1:L}function Na(L,Z){var na=Z.x-L.x,aa=Z.y-L.y,ta=1/Math.sqrt(na*na+aa*aa);na*=ta;aa*=ta;Z.x+=na;Z.y+=aa;L.x-=na;L.y-=aa}var Qa,ib,Ba,Sa,Fa,Oa,Ja,ua;this.autoClear?this.clear():n.setTransform(1,0,0,-1,k,m);b=e.projectScene(R,ia,this.sortElements);(H=R.lights.length>0)&&La(R);Qa=0;for(ib=b.length;Qa0){ma.r+=M.color.r*fa;ma.g+=M.color.g*fa;ma.b+=M.color.b*fa}}else if(M instanceof THREE.PointLight){d.sub(M.position,oa.centroidWorld);d.normalize();fa=oa.normalWorld.dot(d)*M.intensity;if(fa>0){ma.r+=M.color.r*fa;ma.g+=M.color.g*fa;ma.b+=M.color.b*fa}}}}function c(la,oa,ma,ca,S,M){V=e(va++); +V.setAttribute("d","M "+la.positionScreen.x+" "+la.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+ma.positionScreen.x+","+ma.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)C.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(K){U.r=P.r;U.g=P.g;U.b=P.b;a(M,ca,U);C.r=S.color.r*U.r;C.g=S.color.g*U.g;C.b=S.color.b*U.b;C.updateStyleString()}else C.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){Y= +1-S.__2near/(S.__farPlusNear-ca.z*S.__farMinusNear);C.setRGB(Y,Y,Y)}else S instanceof THREE.MeshNormalMaterial&&C.setRGB(f(ca.normalWorld.x),f(ca.normalWorld.y),f(ca.normalWorld.z));S.wireframe?V.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+S.wireframeLinewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframeLinecap+"; stroke-linejoin: "+S.wireframeLinejoin):V.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+S.opacity);k.appendChild(V)} +function b(la,oa,ma,ca,S,M,fa){V=e(va++);V.setAttribute("d","M "+la.positionScreen.x+" "+la.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+ma.positionScreen.x+","+ma.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)C.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(K){U.r=P.r;U.g=P.g;U.b=P.b;a(fa,S,U);C.r=M.color.r*U.r;C.g=M.color.g*U.g;C.b=M.color.b*U.b;C.updateStyleString()}else C.__styleString= +M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){Y=1-M.__2near/(M.__farPlusNear-S.z*M.__farMinusNear);C.setRGB(Y,Y,Y)}else M instanceof THREE.MeshNormalMaterial&&C.setRGB(f(S.normalWorld.x),f(S.normalWorld.y),f(S.normalWorld.z));M.wireframe?V.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+M.wireframeLinewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframeLinecap+"; stroke-linejoin: "+M.wireframeLinejoin):V.setAttribute("style","fill: "+ +C.__styleString+"; fill-opacity: "+M.opacity);k.appendChild(V)}function e(la){if(ja[la]==null){ja[la]=document.createElementNS("http://www.w3.org/2000/svg","path");za==0&&ja[la].setAttribute("shape-rendering","crispEdges")}return ja[la]}function f(la){return la<0?Math.min((1+la)*0.5,0.5):0.5+Math.min(la*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,y,o,A,G,J=new THREE.Rectangle,D=new THREE.Rectangle,K=!1,C=new THREE.Color(16777215), +U=new THREE.Color(16777215),P=new THREE.Color(0),O=new THREE.Color(0),W=new THREE.Color(0),Y,d=new THREE.Vector3,ja=[],X=[],V,va,ga,za=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(la){switch(la){case "high":za=1;break;case "low":za=0}};this.setSize=function(la,oa){m=la;n=oa;p=m/2;x=n/2;k.setAttribute("viewBox",-p+" "+-x+" "+m+" "+n);k.setAttribute("width",m);k.setAttribute("height",n);J.set(-p,-x,p,x)};this.clear=function(){for(;k.childNodes.length> +0;)k.removeChild(k.childNodes[0])};this.render=function(la,oa){var ma,ca,S,M,fa,ra,ka,qa;this.autoClear&&this.clear();g=h.projectScene(la,oa,this.sortElements);ga=va=0;if(K=la.lights.length>0){ka=la.lights;P.setRGB(0,0,0);O.setRGB(0,0,0);W.setRGB(0,0,0);ma=0;for(ca=ka.length;maD){Q=H;D=F[Q]}e.bindBuffer(e.ARRAY_BUFFER,y.__webGLMorphTargetsBuffers[Q]);e.vertexAttribPointer(w["morphTarget"+t],3,e.FLOAT,!1,0,0);E.__webGLMorphTargetInfluences[t]=D;K[Q]=1;D=-1;t++}}e.uniform1fv(o.program.uniforms.morphTargetInfluences,E.__webGLMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,y.__webGLVertexBuffer);e.vertexAttribPointer(j.position,3, -e.FLOAT,!1,0,0)}if(j.color>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLColorBuffer);e.vertexAttribPointer(j.color,3,e.FLOAT,!1,0,0)}if(j.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLNormalBuffer);e.vertexAttribPointer(j.normal,3,e.FLOAT,!1,0,0)}if(j.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLTangentBuffer);e.vertexAttribPointer(j.tangent,4,e.FLOAT,!1,0,0)}if(j.uv>=0)if(y.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLUVBuffer);e.vertexAttribPointer(j.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(j.uv)}else e.disableVertexAttribArray(j.uv); -if(j.uv2>=0)if(y.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLUV2Buffer);e.vertexAttribPointer(j.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(j.uv2)}else e.disableVertexAttribArray(j.uv2);if(o.skinning&&j.skinVertexA>=0&&j.skinVertexB>=0&&j.skinIndex>=0&&j.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinVertexABuffer);e.vertexAttribPointer(j.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinVertexBBuffer);e.vertexAttribPointer(j.skinVertexB,4,e.FLOAT,!1,0, -0);e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinIndicesBuffer);e.vertexAttribPointer(j.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinWeightsBuffer);e.vertexAttribPointer(j.skinWeight,4,e.FLOAT,!1,0,0)}if(E instanceof THREE.Mesh)if(o.wireframe){e.lineWidth(o.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,y.__webGLLineBuffer);e.drawElements(e.LINES,y.__webGLLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,y.__webGLFaceBuffer);e.drawElements(e.TRIANGLES, -y.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else if(E instanceof THREE.Line){E=E.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(o.linewidth);e.drawArrays(E,0,y.__webGLLineCount)}else if(E instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,0,y.__webGLParticleCount);else E instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,y.__webGLVertexCount)}}function g(j,w){if(!j.__webGLVertexBuffer)j.__webGLVertexBuffer=e.createBuffer();if(!j.__webGLNormalBuffer)j.__webGLNormalBuffer=e.createBuffer(); -if(j.hasPos){e.bindBuffer(e.ARRAY_BUFFER,j.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,j.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(w.attributes.position);e.vertexAttribPointer(w.attributes.position,3,e.FLOAT,!1,0,0)}if(j.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,j.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,j.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(w.attributes.normal);e.vertexAttribPointer(w.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,j.count); -j.count=0}function h(j){if(wa!=j.doubleSided){j.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);wa=j.doubleSided}if(ha!=j.flipSided){j.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);ha=j.flipSided}}function k(j){if(ka!=j){j?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);ka=j}}function m(j){M[0].set(j.n41-j.n11,j.n42-j.n12,j.n43-j.n13,j.n44-j.n14);M[1].set(j.n41+j.n11,j.n42+j.n12,j.n43+j.n13,j.n44+j.n14);M[2].set(j.n41+j.n21,j.n42+j.n22,j.n43+j.n23,j.n44+j.n24);M[3].set(j.n41-j.n21,j.n42- -j.n22,j.n43-j.n23,j.n44-j.n24);M[4].set(j.n41-j.n31,j.n42-j.n32,j.n43-j.n33,j.n44-j.n34);M[5].set(j.n41+j.n31,j.n42+j.n32,j.n43+j.n33,j.n44+j.n34);var w;for(j=0;j<6;j++){w=M[j];w.divideScalar(Math.sqrt(w.x*w.x+w.y*w.y+w.z*w.z))}}function n(j){for(var w=j.matrixWorld,t=-j.geometry.boundingSphere.radius*Math.max(j.scale.x,Math.max(j.scale.y,j.scale.z)),o=0;o<6;o++){j=M[o].x*w.n14+M[o].y*w.n24+M[o].z*w.n34+M[o].w;if(j<=t)return!1}return!0}function q(j,w){j.list[j.count]=w;j.count+=1}function x(j){var w, -t,o=j.object,y=j.opaque,E=j.transparent;E.count=0;j=y.count=0;for(w=o.materials.length;j0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,Oa,y)}if(Ya){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,Sa,y)}if(cb&&ea.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLTangentBuffer);e.bufferData(e.ARRAY_BUFFER,Fa,y)}if(Xa&&bb>0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,ib,y)}if(Xa&&db>0){e.bindBuffer(e.ARRAY_BUFFER, -o.__webGLUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Ba,y)}if(Ka){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,aa,y);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ta,y)}if(N>0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,Ja,y);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,va,y);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer); -e.bufferData(e.ARRAY_BUFFER,L,y);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,Z,y)}}}t.__dirtyVertices=!1;t.__dirtyMorphTargets=!1;t.__dirtyElements=!1;t.__dirtyUvs=!1;t.__dirtyNormals=!1;t.__dirtyTangents=!1;t.__dirtyColors=!1}else if(j instanceof THREE.Ribbon){t=j.geometry;if(t.__dirtyVertices||t.__dirtyColors){j=t;w=e.DYNAMIC_DRAW;ya=j.vertices;y=j.colors;ua=ya.length;E=y.length;Ea=j.__vertexArray;K=j.__colorArray;Ia=j.__dirtyColors;if(j.__dirtyVertices){for(pa= -0;pa65535){H[D].counter+=1;Q=H[D].hash+"_"+H[D].counter;j.geometryGroups[Q]==undefined&&(j.geometryGroups[Q]={faces:[],materials:F,vertices:0,numMorphTargets:T})}j.geometryGroups[Q].faces.push(y);j.geometryGroups[Q].vertices+=K}}function C(j,w,t){j.push({buffer:w,object:t,opaque:{list:[],count:0},transparent:{list:[], -count:0}})}function J(j){if(j!=Aa){switch(j){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE);break;case THREE.SubtractiveBlending:e.blendFunc(e.DST_COLOR,e.ZERO);break;case THREE.BillboardBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:e.blendEquation(e.FUNC_REVERSE_SUBTRACT);e.blendFunc(e.ONE,e.ONE);break;default:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}Aa= -j}}function B(j,w,t){if((t.width&t.width-1)==0&&(t.height&t.height-1)==0){e.texParameteri(j,e.TEXTURE_WRAP_S,V(w.wrapS));e.texParameteri(j,e.TEXTURE_WRAP_T,V(w.wrapT));e.texParameteri(j,e.TEXTURE_MAG_FILTER,V(w.magFilter));e.texParameteri(j,e.TEXTURE_MIN_FILTER,V(w.minFilter));e.generateMipmap(j)}else{e.texParameteri(j,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(j,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(j,e.TEXTURE_MAG_FILTER,O(w.magFilter));e.texParameteri(j,e.TEXTURE_MIN_FILTER, -O(w.minFilter))}}function U(j){if(j&&!j.__webGLFramebuffer){j.__webGLFramebuffer=e.createFramebuffer();j.__webGLRenderbuffer=e.createRenderbuffer();j.__webGLTexture=e.createTexture();e.bindRenderbuffer(e.RENDERBUFFER,j.__webGLRenderbuffer);e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,j.width,j.height);e.bindTexture(e.TEXTURE_2D,j.__webGLTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,V(j.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,V(j.wrapT));e.texParameteri(e.TEXTURE_2D, -e.TEXTURE_MAG_FILTER,V(j.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,V(j.minFilter));e.texImage2D(e.TEXTURE_2D,0,V(j.format),j.width,j.height,0,V(j.format),V(j.type),null);e.bindFramebuffer(e.FRAMEBUFFER,j.__webGLFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,j.__webGLTexture,0);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,j.__webGLRenderbuffer);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null); -e.bindFramebuffer(e.FRAMEBUFFER,null)}var w,t;if(j){w=j.__webGLFramebuffer;t=j.width;j=j.height}else{w=null;t=ca;j=S}if(w!=X){e.bindFramebuffer(e.FRAMEBUFFER,w);e.viewport(oa,ma,t,j);X=w}}function P(j,w){var t;if(j=="fragment")t=e.createShader(e.FRAGMENT_SHADER);else j=="vertex"&&(t=e.createShader(e.VERTEX_SHADER));e.shaderSource(t,w);e.compileShader(t);if(!e.getShaderParameter(t,e.COMPILE_STATUS)){console.error(e.getShaderInfoLog(t));console.error(w);return null}return t}function O(j){switch(j){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST; -default:return e.LINEAR}}function V(j){switch(j){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR; -case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0} -var Y=document.createElement("canvas"),e,ja=null,X=null,W=this,wa=null,ha=null,Aa=null,ka=null,oa=0,ma=0,ca=0,S=0,M=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],fa=new THREE.Matrix4,ra=new Float32Array(16),la=new Float32Array(16),qa=new THREE.Vector4,xa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},Ca=!0,Za=new THREE.Color(0),$a=0;if(a){if(a.antialias!==undefined)Ca=a.antialias; -a.clearColor!==undefined&&Za.setHex(a.clearColor);if(a.clearAlpha!==undefined)$a=a.clearAlpha}this.maxMorphTargets=8;this.domElement=Y;this.autoClear=!0;this.sortObjects=!0;(function(j,w,t){try{if(!(e=Y.getContext("experimental-webgl",{antialias:j,stencil:!0})))throw"Error creating WebGL context.";}catch(o){console.error(o)}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendFunc(e.ONE, -e.ONE_MINUS_SRC_ALPHA);e.clearColor(w.r,w.g,w.b,t)})(Ca,Za,$a);this.context=e;var Ha={};a=[];Ca=[];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;Ca[0]=0;Ca[1]=1;Ca[2]=2;Ca[3]=0;Ca[4]=2;Ca[5]=3;Ha.vertexBuffer=e.createBuffer();Ha.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,Ha.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,new Float32Array(a),e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,Ha.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER, -new Uint16Array(Ca),e.STATIC_DRAW);Ha.program=e.createProgram();e.attachShader(Ha.program,P("fragment",THREE.ShaderLib.shadowPost.fragmentShader));e.attachShader(Ha.program,P("vertex",THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(Ha.program);Ha.vertexLocation=e.getAttribLocation(Ha.program,"position");Ha.projectionLocation=e.getUniformLocation(Ha.program,"projectionMatrix");this.setSize=function(j,w){Y.width=j;Y.height=w;this.setViewport(0,0,Y.width,Y.height)};this.setViewport=function(j, -w,t,o){oa=j;ma=w;ca=t;S=o;e.viewport(oa,ma,ca,S)};this.setScissor=function(j,w,t,o){e.scissor(j,w,t,o)};this.enableScissorTest=function(j){j?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(j){e.depthMask(j)};this.setClearColorHex=function(j,w){var t=new THREE.Color(j);e.clearColor(t.r,t.g,t.b,w)};this.setClearColor=function(j,w){e.clearColor(j.r,j.g,j.b,w)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.initMaterial= -function(j,w,t,o){var y,E,K;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);var F,D,Q,H;K=Q=H=0;for(F=w.length;K0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+F.maxDirLights,"#define MAX_POINT_LIGHTS "+F.maxPointLights,"#define MAX_BONES "+F.maxBones,F.map?"#define USE_MAP":"",F.envMap?"#define USE_ENVMAP":"",F.lightMap?"#define USE_LIGHTMAP":"",F.vertexColors?"#define USE_COLOR":"",F.skinning?"#define USE_SKINNING":"",F.morphTargets?"#define USE_MORPHTARGETS":"",F.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"); -e.attachShader(t,P("fragment",K+H));e.attachShader(t,P("vertex",F+w));e.linkProgram(t);e.getProgramParameter(t,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(t,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");t.uniforms={};t.attributes={};j.program=t;t=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(y in j.uniforms)t.push(y); -y=j.program;H=0;for(w=t.length;H=0&&e.enableVertexAttribArray(E.color);E.normal>=0&&e.enableVertexAttribArray(E.normal); -E.tangent>=0&&e.enableVertexAttribArray(E.tangent);if(j.skinning&&E.skinVertexA>=0&&E.skinVertexB>=0&&E.skinIndex>=0&&E.skinWeight>=0){e.enableVertexAttribArray(E.skinVertexA);e.enableVertexAttribArray(E.skinVertexB);e.enableVertexAttribArray(E.skinIndex);e.enableVertexAttribArray(E.skinWeight)}if(j.morphTargets){j.numSupportedMorphTargets=0;if(E.morphTarget0>=0){e.enableVertexAttribArray(E.morphTarget0);j.numSupportedMorphTargets++}if(E.morphTarget1>=0){e.enableVertexAttribArray(E.morphTarget1); -j.numSupportedMorphTargets++}if(E.morphTarget2>=0){e.enableVertexAttribArray(E.morphTarget2);j.numSupportedMorphTargets++}if(E.morphTarget3>=0){e.enableVertexAttribArray(E.morphTarget3);j.numSupportedMorphTargets++}if(E.morphTarget4>=0){e.enableVertexAttribArray(E.morphTarget4);j.numSupportedMorphTargets++}if(E.morphTarget5>=0){e.enableVertexAttribArray(E.morphTarget5);j.numSupportedMorphTargets++}if(E.morphTarget6>=0){e.enableVertexAttribArray(E.morphTarget6);j.numSupportedMorphTargets++}if(E.morphTarget7>= -0){e.enableVertexAttribArray(E.morphTarget7);j.numSupportedMorphTargets++}o.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(y=0;y0||ya.faceVertexUvs.length>0)K.__uvArray=new Float32Array(D*2);if(ya.faceUvs.length>1||ya.faceVertexUvs.length>1)K.__uv2Array=new Float32Array(D*2)}if(F.geometry.skinWeights.length&&F.geometry.skinIndices.length){K.__skinVertexAArray= -new Float32Array(D*4);K.__skinVertexBArray=new Float32Array(D*4);K.__skinIndexArray=new Float32Array(D*4);K.__skinWeightArray=new Float32Array(D*4)}K.__faceArray=new Uint16Array(ga*3+(F.geometry.edgeFaces?F.geometry.edgeFaces.length*6:0));K.__lineArray=new Uint16Array(pa*2);if(K.numMorphTargets){ya=void 0;ua=void 0;K.__morphTargetsArrays=[];ya=0;for(ua=K.numMorphTargets;ya=0;y--){o=t.__webglObjects[y].object;w==o&&t.__webglObjects.splice(y,1)}j.__objectsRemoved.splice(0,1)}w=0;for(t=j.__webglObjects.length;w0}}; -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,f=b.length;for(d=0;dz){T=I;z=E[T]}d.bindBuffer(d.ARRAY_BUFFER,B.__webGLMorphTargetsBuffers[T]);d.vertexAttribPointer(t["morphTarget"+w],3,d.FLOAT,!1,0,0);F.__webGLMorphTargetInfluences[w]=z;H[T]=1;z=-1;w++}}d.uniform1fv(q.program.uniforms.morphTargetInfluences,F.__webGLMorphTargetInfluences)}else{d.bindBuffer(d.ARRAY_BUFFER,B.__webGLVertexBuffer);d.vertexAttribPointer(j.position,3, +d.FLOAT,!1,0,0)}if(j.color>=0){d.bindBuffer(d.ARRAY_BUFFER,B.__webGLColorBuffer);d.vertexAttribPointer(j.color,3,d.FLOAT,!1,0,0)}if(j.normal>=0){d.bindBuffer(d.ARRAY_BUFFER,B.__webGLNormalBuffer);d.vertexAttribPointer(j.normal,3,d.FLOAT,!1,0,0)}if(j.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,B.__webGLTangentBuffer);d.vertexAttribPointer(j.tangent,4,d.FLOAT,!1,0,0)}if(j.uv>=0)if(B.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,B.__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(B.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,B.__webGLUV2Buffer);d.vertexAttribPointer(j.uv2,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(j.uv2)}else d.disableVertexAttribArray(j.uv2);if(q.skinning&&j.skinVertexA>=0&&j.skinVertexB>=0&&j.skinIndex>=0&&j.skinWeight>=0){d.bindBuffer(d.ARRAY_BUFFER,B.__webGLSkinVertexABuffer);d.vertexAttribPointer(j.skinVertexA,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,B.__webGLSkinVertexBBuffer);d.vertexAttribPointer(j.skinVertexB,4,d.FLOAT,!1,0, +0);d.bindBuffer(d.ARRAY_BUFFER,B.__webGLSkinIndicesBuffer);d.vertexAttribPointer(j.skinIndex,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,B.__webGLSkinWeightsBuffer);d.vertexAttribPointer(j.skinWeight,4,d.FLOAT,!1,0,0)}if(F instanceof THREE.Mesh)if(q.wireframe){d.lineWidth(q.wireframeLinewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,B.__webGLLineBuffer);d.drawElements(d.LINES,B.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,B.__webGLFaceBuffer);d.drawElements(d.TRIANGLES, +B.__webGLFaceCount,d.UNSIGNED_SHORT,0)}else if(F instanceof THREE.Line){F=F.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(q.linewidth);d.drawArrays(F,0,B.__webGLLineCount)}else if(F instanceof THREE.ParticleSystem)d.drawArrays(d.POINTS,0,B.__webGLParticleCount);else F instanceof THREE.Ribbon&&d.drawArrays(d.TRIANGLE_STRIP,0,B.__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(va!=j.doubleSided){j.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE);va=j.doubleSided}if(ga!=j.flipSided){j.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW);ga=j.flipSided}}function k(j){if(la!=j){j?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST);la=j}}function m(j){M[0].set(j.n41-j.n11,j.n42-j.n12,j.n43-j.n13,j.n44-j.n14);M[1].set(j.n41+j.n11,j.n42+j.n12,j.n43+j.n13,j.n44+j.n14);M[2].set(j.n41+j.n21,j.n42+j.n22,j.n43+j.n23,j.n44+j.n24);M[3].set(j.n41-j.n21,j.n42- +j.n22,j.n43-j.n23,j.n44-j.n24);M[4].set(j.n41-j.n31,j.n42-j.n32,j.n43-j.n33,j.n44-j.n34);M[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=M[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)),q=0;q<6;q++){j=M[q].x*t.n14+M[q].y*t.n24+M[q].z*t.n34+M[q].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,q=j.object,B=j.opaque,F=j.transparent;F.count=0;j=B.count=0;for(t=q.materials.length;j0){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,Oa,B)}if(Ya){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,Sa,B)}if(cb&&ea.hasTangents){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLTangentBuffer);d.bufferData(d.ARRAY_BUFFER,Fa,B)}if(Xa&&bb>0){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLUVBuffer);d.bufferData(d.ARRAY_BUFFER,ib,B)}if(Xa&&db>0){d.bindBuffer(d.ARRAY_BUFFER, +q.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Ba,B)}if(Ka){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,aa,B);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,ta,B)}if(N>0){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLSkinVertexABuffer);d.bufferData(d.ARRAY_BUFFER,Ja,B);d.bindBuffer(d.ARRAY_BUFFER,q.__webGLSkinVertexBBuffer);d.bufferData(d.ARRAY_BUFFER,ua,B);d.bindBuffer(d.ARRAY_BUFFER,q.__webGLSkinIndicesBuffer); +d.bufferData(d.ARRAY_BUFFER,L,B);d.bindBuffer(d.ARRAY_BUFFER,q.__webGLSkinWeightsBuffer);d.bufferData(d.ARRAY_BUFFER,Z,B)}}}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;Aa=j.vertices;B=j.colors;xa=Aa.length;F=B.length;Ea=j.__vertexArray;H=j.__colorArray;Ia=j.__dirtyColors;if(j.__dirtyVertices){for(pa= +0;pa65535){I[z].counter+=1;T=I[z].hash+"_"+I[z].counter;j.geometryGroups[T]==undefined&&(j.geometryGroups[T]={faces:[],materials:E,vertices:0,numMorphTargets:Q})}j.geometryGroups[T].faces.push(B);j.geometryGroups[T].vertices+=H}}function D(j,t,w){j.push({buffer:t,object:w,opaque:{list:[],count:0},transparent:{list:[], +count:0}})}function K(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 C(j,t,w){if((w.width&w.width-1)==0&&(w.height&w.height-1)==0){d.texParameteri(j,d.TEXTURE_WRAP_S,W(t.wrapS));d.texParameteri(j,d.TEXTURE_WRAP_T,W(t.wrapT));d.texParameteri(j,d.TEXTURE_MAG_FILTER,W(t.magFilter));d.texParameteri(j,d.TEXTURE_MIN_FILTER,W(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,O(t.magFilter));d.texParameteri(j,d.TEXTURE_MIN_FILTER, +O(t.minFilter))}}function U(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,W(j.wrapS));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,W(j.wrapT));d.texParameteri(d.TEXTURE_2D, +d.TEXTURE_MAG_FILTER,W(j.magFilter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,W(j.minFilter));d.texImage2D(d.TEXTURE_2D,0,W(j.format),j.width,j.height,0,W(j.format),W(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=ca;j=S}if(t!=X){d.bindFramebuffer(d.FRAMEBUFFER,t);d.viewport(oa,ma,w,j);X=t}}function P(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 O(j){switch(j){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return d.NEAREST; +default:return d.LINEAR}}function W(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 Y=document.createElement("canvas"),d,ja=null,X=null,V=this,va=null,ga=null,za=null,la=null,oa=0,ma=0,ca=0,S=0,M=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],fa=new THREE.Matrix4,ra=new Float32Array(16),ka=new Float32Array(16),qa=new THREE.Vector4,wa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},Ca=!0,Za=new THREE.Color(0),$a=0;if(a){if(a.antialias!==undefined)Ca=a.antialias; +a.clearColor!==undefined&&Za.setHex(a.clearColor);if(a.clearAlpha!==undefined)$a=a.clearAlpha}this.maxMorphTargets=8;this.domElement=Y;this.autoClear=!0;this.sortObjects=!0;(function(j,t,w){try{if(!(d=Y.getContext("experimental-webgl",{antialias:j,stencil:!0})))throw"Error creating WebGL context.";}catch(q){console.error(q)}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)})(Ca,Za,$a);this.context=d;var Ha={};a=[];Ca=[];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;Ca[0]=0;Ca[1]=1;Ca[2]=2;Ca[3]=0;Ca[4]=2;Ca[5]=3;Ha.vertexBuffer=d.createBuffer();Ha.elementBuffer=d.createBuffer();d.bindBuffer(d.ARRAY_BUFFER,Ha.vertexBuffer);d.bufferData(d.ARRAY_BUFFER,new Float32Array(a),d.STATIC_DRAW);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,Ha.elementBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER, +new Uint16Array(Ca),d.STATIC_DRAW);Ha.program=d.createProgram();d.attachShader(Ha.program,P("fragment",THREE.ShaderLib.shadowPost.fragmentShader));d.attachShader(Ha.program,P("vertex",THREE.ShaderLib.shadowPost.vertexShader));d.linkProgram(Ha.program);Ha.vertexLocation=d.getAttribLocation(Ha.program,"position");Ha.projectionLocation=d.getUniformLocation(Ha.program,"projectionMatrix");this.setSize=function(j,t){Y.width=j;Y.height=t;this.setViewport(0,0,Y.width,Y.height)};this.setViewport=function(j, +t,w,q){oa=j;ma=t;ca=w;S=q;d.viewport(oa,ma,ca,S)};this.setScissor=function(j,t,w,q){d.scissor(j,t,w,q)};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,q){var B,F,H,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 z,T,I;z=I=E=0;for(H=t.length;z0?"#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"); +d.attachShader(t,P("fragment",z+w));d.attachShader(t,P("vertex",H+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(B in j.uniforms)w.push(B); +B=j.program;E=0;for(t=w.length;E=0&&d.enableVertexAttribArray(F.color);F.normal>=0&&d.enableVertexAttribArray(F.normal); +F.tangent>=0&&d.enableVertexAttribArray(F.tangent);if(j.skinning&&F.skinVertexA>=0&&F.skinVertexB>=0&&F.skinIndex>=0&&F.skinWeight>=0){d.enableVertexAttribArray(F.skinVertexA);d.enableVertexAttribArray(F.skinVertexB);d.enableVertexAttribArray(F.skinIndex);d.enableVertexAttribArray(F.skinWeight)}if(j.morphTargets){j.numSupportedMorphTargets=0;if(F.morphTarget0>=0){d.enableVertexAttribArray(F.morphTarget0);j.numSupportedMorphTargets++}if(F.morphTarget1>=0){d.enableVertexAttribArray(F.morphTarget1); +j.numSupportedMorphTargets++}if(F.morphTarget2>=0){d.enableVertexAttribArray(F.morphTarget2);j.numSupportedMorphTargets++}if(F.morphTarget3>=0){d.enableVertexAttribArray(F.morphTarget3);j.numSupportedMorphTargets++}if(F.morphTarget4>=0){d.enableVertexAttribArray(F.morphTarget4);j.numSupportedMorphTargets++}if(F.morphTarget5>=0){d.enableVertexAttribArray(F.morphTarget5);j.numSupportedMorphTargets++}if(F.morphTarget6>=0){d.enableVertexAttribArray(F.morphTarget6);j.numSupportedMorphTargets++}if(F.morphTarget7>= +0){d.enableVertexAttribArray(F.morphTarget7);j.numSupportedMorphTargets++}q.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(B=0;B0||Aa.faceVertexUvs.length>0)H.__uvArray=new Float32Array(z*2);if(Aa.faceUvs.length>1||Aa.faceVertexUvs.length>1)H.__uv2Array=new Float32Array(z*2)}if(E.geometry.skinWeights.length&&E.geometry.skinIndices.length){H.__skinVertexAArray=new Float32Array(z*4);H.__skinVertexBArray=new Float32Array(z*4);H.__skinIndexArray=new Float32Array(z*4);H.__skinWeightArray=new Float32Array(z*4)}H.__faceArray=new Uint16Array(ha*3+(E.geometry.edgeFaces?E.geometry.edgeFaces.length*6:0)); +H.__lineArray=new Uint16Array(pa*2);if(H.numMorphTargets){Aa=void 0;xa=void 0;H.__morphTargetsArrays=[];Aa=0;for(xa=H.numMorphTargets;Aa=0;B--){q=w.__webglObjects[B].object; +t==q&&w.__webglObjects.splice(B,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;e= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}", @@ -336,86 +337,86 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i25&&(g=25);f=(g-1)*0.5;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(n,q,x,z){var p={name:x,fps:0.6,length:z,hierarchy:[]},A,G=q.getControlPointsArray(),I=q.getLength(),C=G.length,J=0;A=C-1;q={parent:-1,keys:[]};q.keys[0]={time:0,pos:G[0],rot:[0,0,0,1],scl:[1,1,1]};q.keys[A]={time:z,pos:G[A],rot:[0,0,0,1],scl:[1,1,1]};for(A=1;A=0?z:z+f;z=this.verticalAngleMap.srcRange;p=this.verticalAngleMap.dstRange; -this.phi=(this.phi-z[0])*(p[1]-p[0])/(z[1]-z[0])+p[0];z=this.horizontalAngleMap.srcRange;p=this.horizontalAngleMap.dstRange;this.theta=(this.theta-z[0])*(p[1]-p[0])/(z[1]-z[0])+p[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,q,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.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var f=Math.PI*2,g=Math.PI/180;this.update=function(n,p,x){var y,o;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*g;this.theta=this.lon*g;y=this.phi%f;this.phi=y>=0?y:y+f;y=this.verticalAngleMap.srcRange;o=this.verticalAngleMap.dstRange; +this.phi=(this.phi-y[0])*(o[1]-o[0])/(y[1]-y[0])+o[0];y=this.horizontalAngleMap.srcRange;o=this.horizontalAngleMap.dstRange;this.theta=(this.theta-y[0])*(o[1]-o[0])/(y[1]-y[0])+o[0];y=this.target.position;y.x=100*Math.sin(this.phi)*Math.cos(this.theta);y.y=100*Math.cos(this.phi);y.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,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&&d(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(n,q){return function(){q.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,d,f,g,h,k,m){function n(I,C,J,B,U,P,O,V){var Y,e,ja=d||1,X=f||1,W=U/2,wa=P/2,ha=q.vertices.length;if(I=="x"&&C=="y"||I=="y"&&C=="x")Y="z";else if(I=="x"&&C=="z"||I=="z"&&C=="x"){Y="y";X=g||1}else if(I=="z"&&C=="y"||I=="y"&&C=="z"){Y="x";ja=g||1}var Aa=ja+1,ka=X+1;U/=ja;var oa=P/X;for(e=0;e0){h(0,0,-n-(g||0));for(d=a;d0){h(0,0,n+(f||0)); -for(d=a+a/2;d<2*a;d++)k.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,p){var A=Math.sqrt(x*x+z*z+p*p);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(x/A,z/A,p/A)))-1}function b(x,z,p,A){A.faces.push(new THREE.Face3(x,z,p))}function d(x,z){var p=f.vertices[x].position,A=f.vertices[z].position;return c((p.x+A.x)/2,(p.y+A.y)/2,(p.z+A.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){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,y,o){var A=Math.sqrt(x*x+y*y+o*o);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(x/A,y/A,o/A)))-1}function b(x,y,o,A){A.faces.push(new THREE.Face3(x,y,o))}function e(x,y){var o=f.vertices[x].position,A=f.vertices[y].position;return c((o.x+A.x)/2,(o.y+A.y)/2,(o.z+A.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||(q=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,z)))-1);n.push(q)}c.push(n)}var p,A,G;f=c.length;for(b=0;b0)for(d=0;d1){p=this.vertices[h].position.clone(); -A=this.vertices[m].position.clone();G=this.vertices[n].position.clone();p.normalize();A.normalize();G.normalize();this.faces.push(new THREE.Face3(h,m,n,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([q,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,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 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(d),(this.radius+this.tube*Math.cos(f))*Math.sin(d),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){d=(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(d,f,g,h));this.faceVertexUvs[0].push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; -var TorusKnot=function(a,c,b,d,f,g,h){function k(x,z,p,A,G,I){z=p/A*x;p=Math.cos(z);return new THREE.Vector3(G*(2+p)*0.5*Math.cos(x),G*(2+p)*Math.sin(x)*0.5,I*G*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=f||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;a0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,y)))-1);n.push(p)}c.push(n)}var o,A,G;f=c.length;for(b=0;b0)for(e=0;e1){o=this.vertices[h].position.clone(); +A=this.vertices[m].position.clone();G=this.vertices[n].position.clone();o.normalize();A.normalize();G.normalize();this.faces.push(new THREE.Face3(h,m,n,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([p,x,J])}}}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,y,o,A,G,J){y=o/A*x;o=Math.cos(y);return new THREE.Vector3(G*(2+o)*0.5*Math.cos(x),G*(2+o)*Math.sin(x)*0.5,J*G*Math.sin(y)*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;t|=(y&127)<<16|o<<8;if(t==0&&K==-127)return 0;return(1-2*(E>>7))*(1+t*Math.pow(2,-23))*Math.pow(2,K)}function k(j,w){var t=q(j,w),o=q(j,w+1),y=q(j,w+2);return(q(j,w+3)<<24)+(y<<16)+(o<<8)+t}function m(j,w){var t=q(j,w);return(q(j,w+1)<<8)+t}function n(j,w){var t=q(j,w);return t>127?t-256:t}function q(j, -w){return j.charCodeAt(w)&255}function x(j){var w,t,o;w=k(a,j);t=k(a,j+O);o=k(a,j+V);j=m(a,j+Y);THREE.BinaryLoader.prototype.f3(C,w,t,o,j)}function z(j){var w,t,o,y,E,K;w=k(a,j);t=k(a,j+O);o=k(a,j+V);y=m(a,j+Y);E=k(a,j+e);K=k(a,j+ja);j=k(a,j+X);THREE.BinaryLoader.prototype.f3n(C,U,w,t,o,y,E,K,j)}function p(j){var w,t,o,y;w=k(a,j);t=k(a,j+W);o=k(a,j+wa);y=k(a,j+ha);j=m(a,j+Aa);THREE.BinaryLoader.prototype.f4(C,w,t,o,y,j)}function A(j){var w,t,o,y,E,K,F,D;w=k(a,j);t=k(a,j+W);o=k(a,j+wa);y=k(a,j+ha); -E=m(a,j+Aa);K=k(a,j+ka);F=k(a,j+oa);D=k(a,j+ma);j=k(a,j+ca);THREE.BinaryLoader.prototype.f4n(C,U,w,t,o,y,E,K,F,D,j)}function G(j){var w,t;w=k(a,j);t=k(a,j+S);j=k(a,j+M);THREE.BinaryLoader.prototype.uv3(C.faceVertexUvs[0],P[w*2],P[w*2+1],P[t*2],P[t*2+1],P[j*2],P[j*2+1])}function I(j){var w,t,o;w=k(a,j);t=k(a,j+fa);o=k(a,j+ra);j=k(a,j+la);THREE.BinaryLoader.prototype.uv4(C.faceVertexUvs[0],P[w*2],P[w*2+1],P[t*2],P[t*2+1],P[o*2],P[o*2+1],P[j*2],P[j*2+1])}var C=this,J=0,B,U=[],P=[],O,V,Y,e,ja,X,W,wa, -ha,Aa,ka,oa,ma,ca,S,M,fa,ra,la,qa,xa,Ca,Za,$a,Ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(C,d,g);B={signature:a.substr(J,8),header_bytes:q(a,J+8),vertex_coordinate_bytes:q(a,J+9),normal_coordinate_bytes:q(a,J+10),uv_coordinate_bytes:q(a,J+11),vertex_index_bytes:q(a,J+12),normal_index_bytes:q(a,J+13),uv_index_bytes:q(a,J+14),material_index_bytes:q(a,J+15),nvertices:k(a,J+16),nnormals:k(a,J+16+4),nuvs:k(a,J+16+8),ntri_flat:k(a,J+16+12),ntri_smooth:k(a,J+16+16),ntri_flat_uv:k(a, -J+16+20),ntri_smooth_uv:k(a,J+16+24),nquad_flat:k(a,J+16+28),nquad_smooth:k(a,J+16+32),nquad_flat_uv:k(a,J+16+36),nquad_smooth_uv:k(a,J+16+40)};J+=B.header_bytes;O=B.vertex_index_bytes;V=B.vertex_index_bytes*2;Y=B.vertex_index_bytes*3;e=B.vertex_index_bytes*3+B.material_index_bytes;ja=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes;X=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*2;W=B.vertex_index_bytes;wa=B.vertex_index_bytes*2;ha=B.vertex_index_bytes*3;Aa= -B.vertex_index_bytes*4;ka=B.vertex_index_bytes*4+B.material_index_bytes;oa=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes;ma=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*2;ca=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*3;S=B.uv_index_bytes;M=B.uv_index_bytes*2;fa=B.uv_index_bytes;ra=B.uv_index_bytes*2;la=B.uv_index_bytes*3;g=B.vertex_index_bytes*3+B.material_index_bytes;Ha=B.vertex_index_bytes*4+B.material_index_bytes;qa=B.ntri_flat* -g;xa=B.ntri_smooth*(g+B.normal_index_bytes*3);Ca=B.ntri_flat_uv*(g+B.uv_index_bytes*3);Za=B.ntri_smooth_uv*(g+B.normal_index_bytes*3+B.uv_index_bytes*3);$a=B.nquad_flat*Ha;g=B.nquad_smooth*(Ha+B.normal_index_bytes*4);Ha=B.nquad_flat_uv*(Ha+B.uv_index_bytes*4);J+=function(j){for(var w,t,o,y=B.vertex_coordinate_bytes*3,E=j+B.nvertices*y;j>7)-127;w|=(B&127)<<16|q<<8;if(w==0&&H==-127)return 0;return(1-2*(F>>7))*(1+w*Math.pow(2,-23))*Math.pow(2,H)}function k(j,t){var w=p(j,t),q=p(j,t+1),B=p(j,t+2);return(p(j,t+3)<<24)+(B<<16)+(q<<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,q;t=k(a,j);w=k(a,j+O);q=k(a,j+W);j=m(a,j+Y);THREE.BinaryLoader.prototype.f3(D,t,w,q,j)}function y(j){var t,w,q,B,F,H;t=k(a,j);w=k(a,j+O);q=k(a,j+W);B=m(a,j+Y);F=k(a,j+d);H=k(a,j+ja);j=k(a,j+X);THREE.BinaryLoader.prototype.f3n(D,U,t,w,q,B,F,H,j)}function o(j){var t,w,q,B;t=k(a,j);w=k(a,j+V);q=k(a,j+va);B=k(a,j+ga);j=m(a,j+za);THREE.BinaryLoader.prototype.f4(D,t,w,q,B,j)}function A(j){var t,w,q,B,F,H,E,z;t=k(a,j);w=k(a,j+V);q=k(a,j+va);B=k(a,j+ga); +F=m(a,j+za);H=k(a,j+la);E=k(a,j+oa);z=k(a,j+ma);j=k(a,j+ca);THREE.BinaryLoader.prototype.f4n(D,U,t,w,q,B,F,H,E,z,j)}function G(j){var t,w;t=k(a,j);w=k(a,j+S);j=k(a,j+M);THREE.BinaryLoader.prototype.uv3(D.faceVertexUvs[0],P[t*2],P[t*2+1],P[w*2],P[w*2+1],P[j*2],P[j*2+1])}function J(j){var t,w,q;t=k(a,j);w=k(a,j+fa);q=k(a,j+ra);j=k(a,j+ka);THREE.BinaryLoader.prototype.uv4(D.faceVertexUvs[0],P[t*2],P[t*2+1],P[w*2],P[w*2+1],P[q*2],P[q*2+1],P[j*2],P[j*2+1])}var D=this,K=0,C,U=[],P=[],O,W,Y,d,ja,X,V,va, +ga,za,la,oa,ma,ca,S,M,fa,ra,ka,qa,wa,Ca,Za,$a,Ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(D,e,g);C={signature:a.substr(K,8),header_bytes:p(a,K+8),vertex_coordinate_bytes:p(a,K+9),normal_coordinate_bytes:p(a,K+10),uv_coordinate_bytes:p(a,K+11),vertex_index_bytes:p(a,K+12),normal_index_bytes:p(a,K+13),uv_index_bytes:p(a,K+14),material_index_bytes:p(a,K+15),nvertices:k(a,K+16),nnormals:k(a,K+16+4),nuvs:k(a,K+16+8),ntri_flat:k(a,K+16+12),ntri_smooth:k(a,K+16+16),ntri_flat_uv:k(a, +K+16+20),ntri_smooth_uv:k(a,K+16+24),nquad_flat:k(a,K+16+28),nquad_smooth:k(a,K+16+32),nquad_flat_uv:k(a,K+16+36),nquad_smooth_uv:k(a,K+16+40)};K+=C.header_bytes;O=C.vertex_index_bytes;W=C.vertex_index_bytes*2;Y=C.vertex_index_bytes*3;d=C.vertex_index_bytes*3+C.material_index_bytes;ja=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes;X=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes*2;V=C.vertex_index_bytes;va=C.vertex_index_bytes*2;ga=C.vertex_index_bytes*3;za= +C.vertex_index_bytes*4;la=C.vertex_index_bytes*4+C.material_index_bytes;oa=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes;ma=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*2;ca=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*3;S=C.uv_index_bytes;M=C.uv_index_bytes*2;fa=C.uv_index_bytes;ra=C.uv_index_bytes*2;ka=C.uv_index_bytes*3;g=C.vertex_index_bytes*3+C.material_index_bytes;Ha=C.vertex_index_bytes*4+C.material_index_bytes;qa=C.ntri_flat* +g;wa=C.ntri_smooth*(g+C.normal_index_bytes*3);Ca=C.ntri_flat_uv*(g+C.uv_index_bytes*3);Za=C.ntri_smooth_uv*(g+C.normal_index_bytes*3+C.uv_index_bytes*3);$a=C.nquad_flat*Ha;g=C.nquad_smooth*(Ha+C.normal_index_bytes*4);Ha=C.nquad_flat_uv*(Ha+C.uv_index_bytes*4);K+=function(j){for(var t,w,q,B=C.vertex_coordinate_bytes*3,F=j+C.nvertices*B;j=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 d=this.count*3;dthis.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 p=Math.floor(q-k);p<1&&(p=1);k=Math.floor(q+k); -k>this.size-1&&(k=this.size-1);for(var A,G,I,C,J,B;x0&&(this.field[I+A]+=C)}}}};this.addPlaneX=function(b,d){var f,g,h,k,m,n=this.size,q=this.yd,x=this.zd,z=this.field,p=n*Math.sqrt(b/d);p>n&&(p=n);for(f=0;f0)for(g=0;gq&&(A=q);for(g=0;g0){m=g*x;for(f=0;fsize&&(dist=size);for(h=0;h0){m=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 y=Math.floor(n-k);y<1&&(y=1);n=Math.floor(n+k);n>this.size-1&&(n=this.size-1);var o=Math.floor(p-k);o<1&&(o=1);k=Math.floor(p+k); +k>this.size-1&&(k=this.size-1);for(var A,G,J,D,K,C;x0&&(this.field[J+A]+=D)}}}};this.addPlaneX=function(b,e){var f,g,h,k,m,n=this.size,p=this.yd,x=this.zd,y=this.field,o=n*Math.sqrt(b/e);o>n&&(o=n);for(f=0;f0)for(g=0;gp&&(A=p);for(g=0;g0){m=g*x;for(f=0;fsize&&(dist=size);for(h=0;h0){m=zd*h;for(g=0;g>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.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-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.001){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_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_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/utils/build.py b/utils/build.py index 6d242c53..3e024f6f 100644 --- a/utils/build.py +++ b/utils/build.py @@ -270,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', @@ -282,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', From af993ea3796fd350208ca8f0a526368475f34093 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Thu, 24 Mar 2011 23:29:10 +0000 Subject: [PATCH 09/10] Added onLoadStart, onLoadProgress and onLoadComplete methods to Loader. Simplified JSONLoader. --- build/Three.js | 569 ++++++++++++++++++------------------ build/custom/ThreeExtras.js | 169 ++++++----- src/extras/io/JSONLoader.js | 562 ++++++++++++++++++----------------- src/extras/io/Loader.js | 70 ++--- 4 files changed, 681 insertions(+), 689 deletions(-) diff --git a/build/Three.js b/build/Three.js index c6528f26..d8735e3c 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 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* +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,f,g,h,k,m;if(b==0)d=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:d=m;f=b;g=a;break;case 2:d=a;f=b;g=c;break;case 3:d=a;f=m;g=b;break;case 4:d=c;f=a;g=b;break;case 5:d=b;f=a; +g=m;break;case 6:case 0:d=b;f=c;g=a}}this.r=d;this.g=f;this.b=g;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* 255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,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,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/ +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/ 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,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* +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* 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,e=a.objects,f=[];a=0;for(c=e.length;a0&&J>0&&P+J<1}var b,e,f,g,h,k,m,n,p,x, -y,o=a.geometry,A=o.vertices,G=[];b=0;for(e=o.faces.length;b0&&M>0&&P+M<1}var b,d,f,g,h,k,m,n,q,x, +y,p=a.geometry,z=p.vertices,G=[];b=0;for(d=p.faces.length;bm?e:m;f=f>n?f:n}a()}; -this.add3Points=function(m,n,p,x,y,o){if(k){k=!1;c=mp?m>y?m:y:p>y?p:y;f=n>x?n>o?n:o:x>o?x:o}else{c=mp?m>y?m>e?m:e:y>e?y:e:p>y?p>e?p:e:y>e?y:e;f=n>x?n>o?n>f?n:f:o>f?o:f:x>o?x>f?x:f:o>f?o: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.Rectangle=function(){function a(){g=d-c;h=f-b}var c,b,d,f,g,h,k=!0;this.getX=function(){return c};this.getY=function(){return b};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return c};this.getTop=function(){return b};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(m,n,q,x){k=!1;c=m;b=n;d=q;f=x;a()};this.addPoint=function(m,n){if(k){k=!1;c=m;b=n;d=m;f=n}else{c=cm?d:m;f=f>n?f:n}a()}; +this.add3Points=function(m,n,q,x,y,p){if(k){k=!1;c=mq?m>y?m:y:q>y?q:y;f=n>x?n>p?n:p:x>p?x:p}else{c=mq?m>y?m>d?m:d:y>d?y:d:q>y?q>d?q:d:y>d?y:d;f=n>x?n>p?n>f?n:f:p>f?p:f:x>p?x>f?x:f:p>f?p:f}a()};this.addRectangle=function(m){if(k){k=!1;c=m.getLeft();b=m.getTop();d=m.getRight();f=m.getBottom()}else{c=cm.getRight()? +d:m.getRight();f=f>m.getBottom()?f:m.getBottom()}a()};this.inflate=function(m){c-=m;b-=m;d+=m;f+=m;a()};this.minSelf=function(m){c=c>m.getLeft()?c:m.getLeft();b=b>m.getTop()?b:m.getTop();d=d=0&&Math.min(f,m.getBottom())-Math.max(b,m.getTop())>=0};this.empty=function(){k=!0;f=d=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,e,f,g,h,k,m,n,p,x,y,o,A,G){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,y||0,o||0,A||0,G||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,y,o,A,G){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=y;this.n42=o;this.n43=A;this.n44=G;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(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,y=a.n33,o=a.n34,A=a.n41,G=a.n42,J=a.n43,D=a.n44,K=c.n11,C=c.n12,U=c.n13,P=c.n14,O=c.n21,W=c.n22, -Y=c.n23,d=c.n24,ja=c.n31,X=c.n32,V=c.n33,va=c.n34;this.n11=b*K+e*O+f*ja;this.n12=b*C+e*W+f*X;this.n13=b*U+e*Y+f*V;this.n14=b*P+e*d+f*va+g;this.n21=h*K+k*O+m*ja;this.n22=h*C+k*W+m*X;this.n23=h*U+k*Y+m*V;this.n24=h*P+k*d+m*va+n;this.n31=p*K+x*O+y*ja;this.n32=p*C+x*W+y*X;this.n33=p*U+x*Y+y*V;this.n34=p*P+x*d+y*va+o;this.n41=A*K+G*O+J*ja;this.n42=A*C+G*W+J*X;this.n43=A*U+G*Y+J*V;this.n44=A*P+G*d+J*va+D;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]=this.n31; +THREE.Matrix4=function(a,c,b,d,f,g,h,k,m,n,q,x,y,p,z,G){this.set(a||1,c||0,b||0,d||0,f||0,g||1,h||0,k||0,m||0,n||0,q||1,x||0,y||0,p||0,z||0,G||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(a,c,b,d,f,g,h,k,m,n,q,x,y,p,z,G){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=f;this.n22=g;this.n23=h;this.n24=k;this.n31=m;this.n32=n;this.n33=q;this.n34=x;this.n41=y;this.n42=p;this.n43=z;this.n44=G;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(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, +f=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()}f.cross(g,d).normalize();this.n11=d.x;this.n12=f.x;this.n13=g.x;this.n21=d.y;this.n22=f.y;this.n23=g.y;this.n31=d.z;this.n32=f.z;this.n33=g.z;return this},multiplyVector3:function(a){var c=a.x,b=a.y,d=a.z,f=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)*f;a.y=(this.n21*c+this.n22*b+this.n23* +d+this.n24)*f;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*f;return a},multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,f=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*f;a.y=this.n21*c+this.n22*b+this.n23*d+this.n24*f;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*f;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*f;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,f=a.n13,g=a.n14,h=a.n21,k=a.n22,m=a.n23,n=a.n24,q=a.n31,x=a.n32,y=a.n33,p=a.n34,z=a.n41,G=a.n42,M=a.n43,D=a.n44,J=c.n11,C=c.n12,U=c.n13,P=c.n14,O=c.n21,W=c.n22, +Y=c.n23,e=c.n24,ja=c.n31,X=c.n32,V=c.n33,va=c.n34;this.n11=b*J+d*O+f*ja;this.n12=b*C+d*W+f*X;this.n13=b*U+d*Y+f*V;this.n14=b*P+d*e+f*va+g;this.n21=h*J+k*O+m*ja;this.n22=h*C+k*W+m*X;this.n23=h*U+k*Y+m*V;this.n24=h*P+k*e+m*va+n;this.n31=q*J+x*O+y*ja;this.n32=q*C+x*W+y*X;this.n33=q*U+x*Y+y*V;this.n34=q*P+x*e+y*va+p;this.n41=z*J+G*O+M*ja;this.n42=z*C+G*W+M*X;this.n43=z*U+G*Y+M*V;this.n44=z*P+G*e+M*va+D;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,y=this.n41,o=this.n42,A=this.n43,G=this.n44;return e*h*n*y-b*k*n*y-e*g*p*y+c*k*p*y+b*g*x*y-c*h*x*y-e*h*m*o+b*k*m*o+e*f*p*o-a*k*p*o-b*f*x*o+a*h*x*o+e*g*m*A-c*k*m*A-e*f*n*A+a*k*n*A+c*f*x*A-a*g*x*A-b*g*m*G+c*h*m*G+b*f*n*G-a*h*n*G-c*f*p*G+a*g*p*G},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32= +this.n11,c=this.n12,b=this.n13,d=this.n14,f=this.n21,g=this.n22,h=this.n23,k=this.n24,m=this.n31,n=this.n32,q=this.n33,x=this.n34,y=this.n41,p=this.n42,z=this.n43,G=this.n44;return d*h*n*y-b*k*n*y-d*g*q*y+c*k*q*y+b*g*x*y-c*h*x*y-d*h*m*p+b*k*m*p+d*f*q*p-a*k*q*p-b*f*x*p+a*h*x*p+d*g*m*z-c*k*m*z-d*f*n*z+a*k*n*z+c*f*x*z-a*g*x*z-b*g*m*G+c*h*m*G+b*f*n*G-a*h*n*G-c*f*q*G+a*g*q*G},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),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,y=a.n33,o=a.n34,A=a.n41,G=a.n42,J=a.n43,D=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=m*o*G-n*y*G+n*x*J-k*o*J-m*x*D+k*y*D;c.n12=g*y*G-f*o*G-g*x*J+e*o*J+f*x*D-e*y*D;c.n13=f*n*G-g*m*G+g*k*J-e*n*J-f*k*D+e*m*D;c.n14=g*m*x-f*n*x-g*k*y+e*n*y+f*k*o-e*m*o;c.n21=n*y*A-m*o*A-n*p*J+h*o*J+m*p*D-h*y*D;c.n22=f*o*A-g*y*A+g*p*J-b*o*J-f*p*D+b*y*D;c.n23=g*m*A-f*n*A-g*h*J+b*n*J+f*h*D-b*m*D; -c.n24=f*n*p-g*m*p+g*h*y-b*n*y-f*h*o+b*m*o;c.n31=k*o*A-n*x*A+n*p*G-h*o*G-k*p*D+h*x*D;c.n32=g*x*A-e*o*A-g*p*G+b*o*G+e*p*D-b*x*D;c.n33=f*n*A-g*k*A+g*h*G-b*n*G-e*h*D+b*k*D;c.n34=g*k*p-e*n*p-g*h*x+b*n*x+e*h*o-b*k*o;c.n41=m*x*A-k*y*A-m*p*G+h*y*G+k*p*J-h*x*J;c.n42=e*y*A-f*x*A+f*p*G-b*y*G-e*p*J+b*x*J;c.n43=f*k*A-e*m*A-f*h*G+b*m*G+e*h*J-b*k*J;c.n44=e*m*p-f*k*p+f*h*x-b*m*x-e*h*y+b*k*y;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; +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),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-d*k,m*k+d*h,0,m*h+d*k,n*h+b,n*k-d*g,0,m*k-d*h,n*k+d*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,d=a.z;a=Math.cos(c);c=Math.sin(c);var f=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var h=a*b,k=c*b;this.n11=f*g;this.n12=-f*d;this.n13=b;this.n21=k*g+a*d;this.n22=-k*d+a*g;this.n23=-c*f;this.n31=-h*g+c*d;this.n32=h*d+c*g;this.n33=a*f;return this},setRotationFromQuaternion:function(a){var c= +a.x,b=a.y,d=a.z,f=a.w,g=c+c,h=b+b,k=d+d;a=c*g;var m=c*h;c*=k;var n=b*h;b*=k;d*=k;g*=f;h*=f;f*=k;this.n11=1-(n+d);this.n12=m-f;this.n13=c+h;this.n21=m+f;this.n22=1-(a+d);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,d=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*d;this.n22=a.n22*d;this.n32=a.n32*d;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,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,m=a.n23,n=a.n24,q=a.n31,x=a.n32,y=a.n33,p=a.n34,z=a.n41,G=a.n42,M=a.n43,D=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=m*p*G-n*y*G+n*x*M-k*p*M-m*x*D+k*y*D;c.n12=g*y*G-f*p*G-g*x*M+d*p*M+f*x*D-d*y*D;c.n13=f*n*G-g*m*G+g*k*M-d*n*M-f*k*D+d*m*D;c.n14=g*m*x-f*n*x-g*k*y+d*n*y+f*k*p-d*m*p;c.n21=n*y*z-m*p*z-n*q*M+h*p*M+m*q*D-h*y*D;c.n22=f*p*z-g*y*z+g*q*M-b*p*M-f*q*D+b*y*D;c.n23=g*m*z-f*n*z-g*h*M+b*n*M+f*h*D-b*m*D; +c.n24=f*n*q-g*m*q+g*h*y-b*n*y-f*h*p+b*m*p;c.n31=k*p*z-n*x*z+n*q*G-h*p*G-k*q*D+h*x*D;c.n32=g*x*z-d*p*z-g*q*G+b*p*G+d*q*D-b*x*D;c.n33=f*n*z-g*k*z+g*h*G-b*n*G-d*h*D+b*k*D;c.n34=g*k*q-d*n*q-g*h*x+b*n*x+d*h*p-b*k*p;c.n41=m*x*z-k*y*z-m*q*G+h*y*G+k*q*M-h*x*M;c.n42=d*y*z-f*x*z+f*q*G-b*y*G-d*q*M+b*x*M;c.n43=f*k*z-d*m*z-f*h*G+b*m*G+d*h*M-b*k*M;c.n44=d*m*q-f*k*q+f*h*x-b*m*x-d*h*y+b*k*y;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,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,q=-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*n;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*d;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*q;b[8]=a*x;return c}; +THREE.Matrix4.makeFrustum=function(a,c,b,d,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/(d-b);h.n23=(d+b)/(d-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,d){var f;a=b*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,b,d)}; +THREE.Matrix4.makeOrtho=function(a,c,b,d,f,g){var h,k,m,n;h=new THREE.Matrix4;k=c-a;m=b-d;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+d)/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 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.001){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)}; +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(f),h=Math.sqrt(1-f*f);if(Math.abs(h)<0.001){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-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*f+c.w*d;b.x=a.x*f+c.x*d;b.y=a.y*f+c.y*d;b.z=a.z*f+c.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; +THREE.Face3=function(a,c,b,d,f,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=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,d,f,g,h){this.a=a;this.b=c;this.c=b;this.d=d;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;n=this.points[b[0]];p=this.points[b[1]]; -x=this.points[b[2]];y=this.points[b[3]];k=h*h;m=h*k;e.x=c(n.x,p.x,x.x,y.x,h,k,m);e.y=c(n.y,p.y,x.y,y.y,h,k,m);e.z=c(n.z,p.z,x.z,y.z,h,k,m);return e};this.getControlPointsArray=function(){var o,A,G=this.points.length,J=[];for(o=0;othis.points.length-2?g:g+1;b[3]=g>this.points.length-3?g:g+2;n=this.points[b[0]];q=this.points[b[1]]; +x=this.points[b[2]];y=this.points[b[3]];k=h*h;m=h*k;d.x=c(n.x,q.x,x.x,y.x,h,k,m);d.y=c(n.y,q.y,x.y,y.y,h,k,m);d.z=c(n.z,q.z,x.z,y.z,h,k,m);return d};this.getControlPointsArray=function(){var p,z,G=this.points.length,M=[];for(p=0;p1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+o);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",o,h.index-1).pos;this.points[1]=f;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",o,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(o=0;oa.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.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,d,f,g,h,k,m,n,q=this.data.JIT.hierarchy,x,y;this.currentTime+=a*this.timeScale;y=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 p=0,z=this.hierarchy.length;p1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+p);d=d<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=f[0]+(g[0]-f[0])*d;b.y=f[1]+(g[1]-f[1])*d;b.z=f[2]+(g[2]-f[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= +this.getPrevKeyWith("pos",p,h.index-1).pos;this.points[1]=f;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",p,k.index+1).pos;d=d*0.33+0.33;f=this.interpolateCatmullRom(this.points,d);b.x=f[0];b.y=f[1];b.z=f[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(f,g,a.quaternion,d);else if(b==="scl"){b=a.scale;b.x=f[0]+(g[0]-f[0])*d;b.y=f[1]+(g[1]-f[1])*d;b.z=f[2]+(g[2]-f[2])*d}}}}if(this.JITCompile&&q[0][n]===undefined){this.hierarchy[0].update(undefined,!0);for(p=0;pa.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;d[0]=this.interpolate(g[0],k[0],m[0],n[0],f,b,h);d[1]=this.interpolate(g[1],k[1],m[1],n[1],f,b,h);d[2]=this.interpolate(g[2],k[2],m[2],n[2],f,b,h);return d}; +THREE.Animation.prototype.interpolate=function(a,c,b,d,f,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*f+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,f){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=b||0.1;this.far=d||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 e=1;e=this.LODs[e].visibleAtDistance){this.LODs[e-1].object3D.visible= -!1;this.LODs[e].object3D.visible=!0}else break;for(;e1){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(;d=0&&la>=0&&oa>=0&&ma>=0)return!0;else if(za<0&&la<0||oa<0&&ma<0)return!1;else{if(za<0)va=Math.max(va,za/(za-la));else la<0&&(ga=Math.min(ga,za/(za-la)));if(oa<0)va=Math.max(va,oa/(oa-ma));else ma<0&&(ga=Math.min(ga,oa/(oa-ma)));if(gaza&&h.positionScreen.z0&&P.z<1){Ca=C[K]=C[K]||new THREE.RenderableParticle;K++;D=Ca;D.x=P.x/P.w;D.y=P.y/P.w;D.z=P.z;D.rotation=wa.rotation.z;D.scale.x=wa.scale.x*Math.abs(D.x-(P.x+V.projectionMatrix.n11)/(P.w+V.projectionMatrix.n14));D.scale.y=wa.scale.y*Math.abs(D.y-(P.y+V.projectionMatrix.n22)/(P.w+V.projectionMatrix.n24));D.materials=wa.materials;ga.push(D)}}}}va&&ga.sort(c);return ga}}; -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,y,o,A,G;a=c.projectScene(h,k);m=0;for(n=a.length;m0){aa.r+=ea.r*ya;aa.g+=ea.g*ya;aa.b+=ea.b*ya}}else if(ya instanceof THREE.PointLight){Q.sub(ya.position,Z);Q.normalize();ya=na.dot(Q)*$;if(ya>0){aa.r+= -ea.r*ya;aa.g+=ea.g*ya;aa.b+=ea.b*ya}}}}function eb(L,Z,na){a(na.opacity);c(na.blending);var aa,ta,ya,ea,$,Ka;if(na instanceof THREE.ParticleBasicMaterial){if(na.map){ea=na.map.image;$=ea.width>>1;Ka=ea.height>>1;na=Z.scale.x*k;ya=Z.scale.y*m;aa=na*$;ta=ya*Ka;F.set(L.x-aa,L.y-ta,L.x+aa,L.y+ta);if(q.instersects(F)){n.save();n.translate(L.x,L.y);n.rotate(-Z.rotation);n.scale(na,-ya);n.translate(-$,-Ka);n.drawImage(ea,0,0);n.restore()}}}else if(na instanceof THREE.ParticleCanvasMaterial){if(H){E.r=z.r+ -T.r+I.r;E.g=z.g+T.g+I.g;E.b=z.b+T.b+I.b;ca.r=na.color.r*E.r;ca.g=na.color.g*E.g;ca.b=na.color.b*E.b;ca.updateStyleString()}else ca.__styleString=na.color.__styleString;aa=Z.scale.x*k;ta=Z.scale.y*m;F.set(L.x-aa,L.y-ta,L.x+aa,L.y+ta);if(q.instersects(F)){n.save();n.translate(L.x,L.y);n.rotate(-Z.rotation);n.scale(aa,ta);na.program(n,ca);n.restore()}}}function Ta(L,Z,na,aa){a(aa.opacity);c(aa.blending);n.beginPath();n.moveTo(L.positionScreen.x,L.positionScreen.y);n.lineTo(Z.positionScreen.x,Z.positionScreen.y); -n.closePath();if(aa instanceof THREE.LineBasicMaterial){ca.__styleString=aa.color.__styleString;L=aa.linewidth;if(J!=L)n.lineWidth=J=L;L=ca.__styleString;if(A!=L)n.strokeStyle=A=L;n.stroke();F.inflate(aa.linewidth*2)}}function Ia(L,Z,na,aa,ta,ya,ea,$,Ka){a($.opacity);c($.blending);W=L.positionScreen.x;Y=L.positionScreen.y;d=Z.positionScreen.x;ja=Z.positionScreen.y;X=na.positionScreen.x;V=na.positionScreen.y;bb(W,Y,d,ja,X,V);if($ instanceof THREE.MeshBasicMaterial)if($.map){if($.map.mapping instanceof -THREE.UVMapping){Ca=ea.uvs[0];Da(W,Y,d,ja,X,V,$.map.image,Ca[aa].u,Ca[aa].v,Ca[ta].u,Ca[ta].v,Ca[ya].u,Ca[ya].v)}}else if($.envMap){if($.envMap.mapping instanceof THREE.SphericalReflectionMapping){L=ia.matrixWorldInverse;Q.copy(ea.vertexNormalsWorld[0]);Za=(Q.x*L.n11+Q.y*L.n12+Q.z*L.n13)*0.5+0.5;$a=-(Q.x*L.n21+Q.y*L.n22+Q.z*L.n23)*0.5+0.5;Q.copy(ea.vertexNormalsWorld[1]);Ha=(Q.x*L.n11+Q.y*L.n12+Q.z*L.n13)*0.5+0.5;j=-(Q.x*L.n21+Q.y*L.n22+Q.z*L.n23)*0.5+0.5;Q.copy(ea.vertexNormalsWorld[2]);t=(Q.x*L.n11+ -Q.y*L.n12+Q.z*L.n13)*0.5+0.5;w=-(Q.x*L.n21+Q.y*L.n22+Q.z*L.n23)*0.5+0.5;Da(W,Y,d,ja,X,V,$.envMap.image,Za,$a,Ha,j,t,w)}}else $.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&!$.wireframe){if($.map.mapping instanceof THREE.UVMapping){Ca=ea.uvs[0];Da(W,Y,d,ja,X,V,$.map.image,Ca[aa].u,Ca[aa].v,Ca[ta].u,Ca[ta].v,Ca[ya].u,Ca[ya].v)}c(THREE.SubtractiveBlending)}if(H)if(!$.wireframe&&$.shading==THREE.SmoothShading&& -ea.vertexNormalsWorld.length==3){S.r=M.r=fa.r=z.r;S.g=M.g=fa.g=z.g;S.b=M.b=fa.b=z.b;Ga(Ka,ea.v1.positionWorld,ea.vertexNormalsWorld[0],S);Ga(Ka,ea.v2.positionWorld,ea.vertexNormalsWorld[1],M);Ga(Ka,ea.v3.positionWorld,ea.vertexNormalsWorld[2],fa);ra.r=(M.r+fa.r)*0.5;ra.g=(M.g+fa.g)*0.5;ra.b=(M.b+fa.b)*0.5;wa=Va(S,M,fa,ra);Da(W,Y,d,ja,X,V,wa,0,0,1,0,0,1)}else{E.r=z.r;E.g=z.g;E.b=z.b;Ga(Ka,ea.centroidWorld,ea.normalWorld,E);ca.r=$.color.r*E.r;ca.g=$.color.g*E.g;ca.b=$.color.b*E.b;ca.updateStyleString(); -$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else $.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){ka=ia.near;qa=ia.far;S.r=S.g=S.b=1-Ma(L.positionScreen.z,ka,qa);M.r=M.g=M.b=1-Ma(Z.positionScreen.z,ka,qa);fa.r=fa.g=fa.b=1-Ma(na.positionScreen.z,ka,qa);ra.r=(M.r+fa.r)*0.5;ra.g=(M.g+fa.g)*0.5;ra.b=(M.b+fa.b)*0.5;wa=Va(S,M,fa,ra);Da(W,Y,d,ja,X,V,wa,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){ca.r= -N(ea.normalWorld.x);ca.g=N(ea.normalWorld.y);ca.b=N(ea.normalWorld.z);ca.updateStyleString();$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}}function Ra(L,Z,na,aa,ta,ya,ea,$,Ka){a($.opacity);c($.blending);if($.map||$.envMap){Ia(L,Z,aa,0,1,3,ea,$,Ka);Ia(ta,na,ya,1,2,3,ea,$,Ka)}else{W=L.positionScreen.x;Y=L.positionScreen.y;d=Z.positionScreen.x;ja=Z.positionScreen.y;X=na.positionScreen.x;V=na.positionScreen.y;va=aa.positionScreen.x;ga=aa.positionScreen.y;za=ta.positionScreen.x; -la=ta.positionScreen.y;oa=ya.positionScreen.x;ma=ya.positionScreen.y;if($ instanceof THREE.MeshBasicMaterial){db(W,Y,d,ja,X,V,va,ga);$.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshLambertMaterial)if(H)if(!$.wireframe&&$.shading==THREE.SmoothShading&&ea.vertexNormalsWorld.length==4){S.r=M.r=fa.r=ra.r=z.r;S.g=M.g=fa.g=ra.g=z.g;S.b=M.b=fa.b=ra.b=z.b;Ga(Ka,ea.v1.positionWorld,ea.vertexNormalsWorld[0],S);Ga(Ka,ea.v2.positionWorld,ea.vertexNormalsWorld[1], -M);Ga(Ka,ea.v4.positionWorld,ea.vertexNormalsWorld[3],fa);Ga(Ka,ea.v3.positionWorld,ea.vertexNormalsWorld[2],ra);wa=Va(S,M,fa,ra);bb(W,Y,d,ja,va,ga);Da(W,Y,d,ja,va,ga,wa,0,0,1,0,0,1);bb(za,la,X,V,oa,ma);Da(za,la,X,V,oa,ma,wa,1,0,1,1,0,1)}else{E.r=z.r;E.g=z.g;E.b=z.b;Ga(Ka,ea.centroidWorld,ea.normalWorld,E);ca.r=$.color.r*E.r;ca.g=$.color.g*E.g;ca.b=$.color.b*E.b;ca.updateStyleString();db(W,Y,d,ja,X,V,va,ga);$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else{db(W,Y,d,ja, -X,V,va,ga);$.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshNormalMaterial){ca.r=N(ea.normalWorld.x);ca.g=N(ea.normalWorld.y);ca.b=N(ea.normalWorld.z);ca.updateStyleString();db(W,Y,d,ja,X,V,va,ga);$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){ka=ia.near;qa=ia.far;S.r=S.g=S.b=1-Ma(L.positionScreen.z,ka,qa);M.r=M.g=M.b=1-Ma(Z.positionScreen.z,ka,qa);fa.r=fa.g= -fa.b=1-Ma(aa.positionScreen.z,ka,qa);ra.r=ra.g=ra.b=1-Ma(na.positionScreen.z,ka,qa);wa=Va(S,M,fa,ra);bb(W,Y,d,ja,va,ga);Da(W,Y,d,ja,va,ga,wa,0,0,1,0,0,1);bb(za,la,X,V,oa,ma);Da(za,la,X,V,oa,ma,wa,1,0,1,1,0,1)}}}function bb(L,Z,na,aa,ta,ya){n.beginPath();n.moveTo(L,Z);n.lineTo(na,aa);n.lineTo(ta,ya);n.lineTo(L,Z);n.closePath()}function db(L,Z,na,aa,ta,ya,ea,$){n.beginPath();n.moveTo(L,Z);n.lineTo(na,aa);n.lineTo(ta,ya);n.lineTo(ea,$);n.lineTo(L,Z);n.closePath()}function Pa(L,Z){if(A!=L)n.strokeStyle= -A=L;if(J!=Z)n.lineWidth=J=Z;n.stroke();F.inflate(Z*2)}function Ua(L){if(G!=L)n.fillStyle=G=L;n.fill()}function Da(L,Z,na,aa,ta,ya,ea,$,Ka,Xa,Ya,cb,gb){var ab,Wa;ab=ea.width-1;Wa=ea.height-1;$*=ab;Ka*=Wa;Xa*=ab;Ya*=Wa;cb*=ab;gb*=Wa;na-=L;aa-=Z;ta-=L;ya-=Z;Xa-=$;Ya-=Ka;cb-=$;gb-=Ka;ab=Xa*gb-cb*Ya;if(ab!=0){Wa=1/ab;ab=(gb*na-Ya*ta)*Wa;Ya=(gb*aa-Ya*ya)*Wa;na=(Xa*ta-cb*na)*Wa;aa=(Xa*ya-cb*aa)*Wa;L=L-ab*$-na*Ka;Z=Z-Ya*$-aa*Ka;n.save();n.transform(ab,Ya,na,aa,L,Z);n.clip();n.drawImage(ea,0,0);n.restore()}} -function Va(L,Z,na,aa){var ta=~~(L.r*255),ya=~~(L.g*255);L=~~(L.b*255);var ea=~~(Z.r*255),$=~~(Z.g*255);Z=~~(Z.b*255);var Ka=~~(na.r*255),Xa=~~(na.g*255);na=~~(na.b*255);var Ya=~~(aa.r*255),cb=~~(aa.g*255);aa=~~(aa.b*255);Aa[0]=ta<0?0:ta>255?255:ta;Aa[1]=ya<0?0:ya>255?255:ya;Aa[2]=L<0?0:L>255?255:L;Aa[4]=ea<0?0:ea>255?255:ea;Aa[5]=$<0?0:$>255?255:$;Aa[6]=Z<0?0:Z>255?255:Z;Aa[8]=Ka<0?0:Ka>255?255:Ka;Aa[9]=Xa<0?0:Xa>255?255:Xa;Aa[10]=na<0?0:na>255?255:na;Aa[12]=Ya<0?0:Ya>255?255:Ya;Aa[13]=cb<0?0:cb> -255?255:cb;Aa[14]=aa<0?0:aa>255?255:aa;pa.putImageData(sa,0,0);Ea.drawImage(ha,0,0);return xa}function Ma(L,Z,na){L=(L-Z)/(na-Z);return L*L*(3-2*L)}function N(L){L=(L+1)*0.5;return L<0?0:L>1?1:L}function Na(L,Z){var na=Z.x-L.x,aa=Z.y-L.y,ta=1/Math.sqrt(na*na+aa*aa);na*=ta;aa*=ta;Z.x+=na;Z.y+=aa;L.x-=na;L.y-=aa}var Qa,ib,Ba,Sa,Fa,Oa,Ja,ua;this.autoClear?this.clear():n.setTransform(1,0,0,-1,k,m);b=e.projectScene(R,ia,this.sortElements);(H=R.lights.length>0)&&La(R);Qa=0;for(ib=b.length;Qa0){ma.r+=M.color.r*fa;ma.g+=M.color.g*fa;ma.b+=M.color.b*fa}}else if(M instanceof THREE.PointLight){d.sub(M.position,oa.centroidWorld);d.normalize();fa=oa.normalWorld.dot(d)*M.intensity;if(fa>0){ma.r+=M.color.r*fa;ma.g+=M.color.g*fa;ma.b+=M.color.b*fa}}}}function c(la,oa,ma,ca,S,M){V=e(va++); -V.setAttribute("d","M "+la.positionScreen.x+" "+la.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+ma.positionScreen.x+","+ma.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)C.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(K){U.r=P.r;U.g=P.g;U.b=P.b;a(M,ca,U);C.r=S.color.r*U.r;C.g=S.color.g*U.g;C.b=S.color.b*U.b;C.updateStyleString()}else C.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){Y= +for(ca=S.length;maza&&h.positionScreen.z0&&P.z<1){Ca=C[J]=C[J]||new THREE.RenderableParticle;J++;D=Ca;D.x=P.x/P.w;D.y=P.y/P.w;D.z=P.z;D.rotation=wa.rotation.z;D.scale.x=wa.scale.x*Math.abs(D.x-(P.x+V.projectionMatrix.n11)/(P.w+V.projectionMatrix.n14));D.scale.y=wa.scale.y*Math.abs(D.y-(P.y+V.projectionMatrix.n22)/(P.w+V.projectionMatrix.n24));D.materials=wa.materials;ga.push(D)}}}}va&&ga.sort(c);return ga}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,f,g;this.domElement=document.createElement("div");this.setSize=function(h,k){b=h;d=k;f=b/2;g=d/2};this.render=function(h,k){var m,n,q,x,y,p,z,G;a=c.projectScene(h,k);m=0;for(n=a.length;m0){aa.r+=ea.r*ya;aa.g+=ea.g*ya;aa.b+=ea.b*ya}}else if(ya instanceof THREE.PointLight){Q.sub(ya.position,Z);Q.normalize();ya=na.dot(Q)*$;if(ya>0){aa.r+= +ea.r*ya;aa.g+=ea.g*ya;aa.b+=ea.b*ya}}}}function eb(K,Z,na){a(na.opacity);c(na.blending);var aa,ta,ya,ea,$,Ka;if(na instanceof THREE.ParticleBasicMaterial){if(na.map){ea=na.map.image;$=ea.width>>1;Ka=ea.height>>1;na=Z.scale.x*k;ya=Z.scale.y*m;aa=na*$;ta=ya*Ka;F.set(K.x-aa,K.y-ta,K.x+aa,K.y+ta);if(o.instersects(F)){n.save();n.translate(K.x,K.y);n.rotate(-Z.rotation);n.scale(na,-ya);n.translate(-$,-Ka);n.drawImage(ea,0,0);n.restore()}}}else if(na instanceof THREE.ParticleCanvasMaterial){if(H){E.r=A.r+ +T.r+I.r;E.g=A.g+T.g+I.g;E.b=A.b+T.b+I.b;ca.r=na.color.r*E.r;ca.g=na.color.g*E.g;ca.b=na.color.b*E.b;ca.updateStyleString()}else ca.__styleString=na.color.__styleString;aa=Z.scale.x*k;ta=Z.scale.y*m;F.set(K.x-aa,K.y-ta,K.x+aa,K.y+ta);if(o.instersects(F)){n.save();n.translate(K.x,K.y);n.rotate(-Z.rotation);n.scale(aa,ta);na.program(n,ca);n.restore()}}}function Ta(K,Z,na,aa){a(aa.opacity);c(aa.blending);n.beginPath();n.moveTo(K.positionScreen.x,K.positionScreen.y);n.lineTo(Z.positionScreen.x,Z.positionScreen.y); +n.closePath();if(aa instanceof THREE.LineBasicMaterial){ca.__styleString=aa.color.__styleString;K=aa.linewidth;if(M!=K)n.lineWidth=M=K;K=ca.__styleString;if(z!=K)n.strokeStyle=z=K;n.stroke();F.inflate(aa.linewidth*2)}}function Ia(K,Z,na,aa,ta,ya,ea,$,Ka){a($.opacity);c($.blending);W=K.positionScreen.x;Y=K.positionScreen.y;e=Z.positionScreen.x;ja=Z.positionScreen.y;X=na.positionScreen.x;V=na.positionScreen.y;bb(W,Y,e,ja,X,V);if($ instanceof THREE.MeshBasicMaterial)if($.map){if($.map.mapping instanceof +THREE.UVMapping){Ca=ea.uvs[0];Da(W,Y,e,ja,X,V,$.map.image,Ca[aa].u,Ca[aa].v,Ca[ta].u,Ca[ta].v,Ca[ya].u,Ca[ya].v)}}else if($.envMap){if($.envMap.mapping instanceof THREE.SphericalReflectionMapping){K=ia.matrixWorldInverse;Q.copy(ea.vertexNormalsWorld[0]);Za=(Q.x*K.n11+Q.y*K.n12+Q.z*K.n13)*0.5+0.5;$a=-(Q.x*K.n21+Q.y*K.n22+Q.z*K.n23)*0.5+0.5;Q.copy(ea.vertexNormalsWorld[1]);Ha=(Q.x*K.n11+Q.y*K.n12+Q.z*K.n13)*0.5+0.5;j=-(Q.x*K.n21+Q.y*K.n22+Q.z*K.n23)*0.5+0.5;Q.copy(ea.vertexNormalsWorld[2]);t=(Q.x*K.n11+ +Q.y*K.n12+Q.z*K.n13)*0.5+0.5;w=-(Q.x*K.n21+Q.y*K.n22+Q.z*K.n23)*0.5+0.5;Da(W,Y,e,ja,X,V,$.envMap.image,Za,$a,Ha,j,t,w)}}else $.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&!$.wireframe){if($.map.mapping instanceof THREE.UVMapping){Ca=ea.uvs[0];Da(W,Y,e,ja,X,V,$.map.image,Ca[aa].u,Ca[aa].v,Ca[ta].u,Ca[ta].v,Ca[ya].u,Ca[ya].v)}c(THREE.SubtractiveBlending)}if(H)if(!$.wireframe&&$.shading==THREE.SmoothShading&& +ea.vertexNormalsWorld.length==3){S.r=L.r=fa.r=A.r;S.g=L.g=fa.g=A.g;S.b=L.b=fa.b=A.b;Ga(Ka,ea.v1.positionWorld,ea.vertexNormalsWorld[0],S);Ga(Ka,ea.v2.positionWorld,ea.vertexNormalsWorld[1],L);Ga(Ka,ea.v3.positionWorld,ea.vertexNormalsWorld[2],fa);ra.r=(L.r+fa.r)*0.5;ra.g=(L.g+fa.g)*0.5;ra.b=(L.b+fa.b)*0.5;wa=Va(S,L,fa,ra);Da(W,Y,e,ja,X,V,wa,0,0,1,0,0,1)}else{E.r=A.r;E.g=A.g;E.b=A.b;Ga(Ka,ea.centroidWorld,ea.normalWorld,E);ca.r=$.color.r*E.r;ca.g=$.color.g*E.g;ca.b=$.color.b*E.b;ca.updateStyleString(); +$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else $.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){ka=ia.near;qa=ia.far;S.r=S.g=S.b=1-Ma(K.positionScreen.z,ka,qa);L.r=L.g=L.b=1-Ma(Z.positionScreen.z,ka,qa);fa.r=fa.g=fa.b=1-Ma(na.positionScreen.z,ka,qa);ra.r=(L.r+fa.r)*0.5;ra.g=(L.g+fa.g)*0.5;ra.b=(L.b+fa.b)*0.5;wa=Va(S,L,fa,ra);Da(W,Y,e,ja,X,V,wa,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){ca.r= +N(ea.normalWorld.x);ca.g=N(ea.normalWorld.y);ca.b=N(ea.normalWorld.z);ca.updateStyleString();$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}}function Ra(K,Z,na,aa,ta,ya,ea,$,Ka){a($.opacity);c($.blending);if($.map||$.envMap){Ia(K,Z,aa,0,1,3,ea,$,Ka);Ia(ta,na,ya,1,2,3,ea,$,Ka)}else{W=K.positionScreen.x;Y=K.positionScreen.y;e=Z.positionScreen.x;ja=Z.positionScreen.y;X=na.positionScreen.x;V=na.positionScreen.y;va=aa.positionScreen.x;ga=aa.positionScreen.y;za=ta.positionScreen.x; +la=ta.positionScreen.y;oa=ya.positionScreen.x;ma=ya.positionScreen.y;if($ instanceof THREE.MeshBasicMaterial){db(W,Y,e,ja,X,V,va,ga);$.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshLambertMaterial)if(H)if(!$.wireframe&&$.shading==THREE.SmoothShading&&ea.vertexNormalsWorld.length==4){S.r=L.r=fa.r=ra.r=A.r;S.g=L.g=fa.g=ra.g=A.g;S.b=L.b=fa.b=ra.b=A.b;Ga(Ka,ea.v1.positionWorld,ea.vertexNormalsWorld[0],S);Ga(Ka,ea.v2.positionWorld,ea.vertexNormalsWorld[1], +L);Ga(Ka,ea.v4.positionWorld,ea.vertexNormalsWorld[3],fa);Ga(Ka,ea.v3.positionWorld,ea.vertexNormalsWorld[2],ra);wa=Va(S,L,fa,ra);bb(W,Y,e,ja,va,ga);Da(W,Y,e,ja,va,ga,wa,0,0,1,0,0,1);bb(za,la,X,V,oa,ma);Da(za,la,X,V,oa,ma,wa,1,0,1,1,0,1)}else{E.r=A.r;E.g=A.g;E.b=A.b;Ga(Ka,ea.centroidWorld,ea.normalWorld,E);ca.r=$.color.r*E.r;ca.g=$.color.g*E.g;ca.b=$.color.b*E.b;ca.updateStyleString();db(W,Y,e,ja,X,V,va,ga);$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else{db(W,Y,e,ja, +X,V,va,ga);$.wireframe?Pa($.color.__styleString,$.wireframeLinewidth):Ua($.color.__styleString)}else if($ instanceof THREE.MeshNormalMaterial){ca.r=N(ea.normalWorld.x);ca.g=N(ea.normalWorld.y);ca.b=N(ea.normalWorld.z);ca.updateStyleString();db(W,Y,e,ja,X,V,va,ga);$.wireframe?Pa(ca.__styleString,$.wireframeLinewidth):Ua(ca.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){ka=ia.near;qa=ia.far;S.r=S.g=S.b=1-Ma(K.positionScreen.z,ka,qa);L.r=L.g=L.b=1-Ma(Z.positionScreen.z,ka,qa);fa.r=fa.g= +fa.b=1-Ma(aa.positionScreen.z,ka,qa);ra.r=ra.g=ra.b=1-Ma(na.positionScreen.z,ka,qa);wa=Va(S,L,fa,ra);bb(W,Y,e,ja,va,ga);Da(W,Y,e,ja,va,ga,wa,0,0,1,0,0,1);bb(za,la,X,V,oa,ma);Da(za,la,X,V,oa,ma,wa,1,0,1,1,0,1)}}}function bb(K,Z,na,aa,ta,ya){n.beginPath();n.moveTo(K,Z);n.lineTo(na,aa);n.lineTo(ta,ya);n.lineTo(K,Z);n.closePath()}function db(K,Z,na,aa,ta,ya,ea,$){n.beginPath();n.moveTo(K,Z);n.lineTo(na,aa);n.lineTo(ta,ya);n.lineTo(ea,$);n.lineTo(K,Z);n.closePath()}function Pa(K,Z){if(z!=K)n.strokeStyle= +z=K;if(M!=Z)n.lineWidth=M=Z;n.stroke();F.inflate(Z*2)}function Ua(K){if(G!=K)n.fillStyle=G=K;n.fill()}function Da(K,Z,na,aa,ta,ya,ea,$,Ka,Xa,Ya,cb,gb){var ab,Wa;ab=ea.width-1;Wa=ea.height-1;$*=ab;Ka*=Wa;Xa*=ab;Ya*=Wa;cb*=ab;gb*=Wa;na-=K;aa-=Z;ta-=K;ya-=Z;Xa-=$;Ya-=Ka;cb-=$;gb-=Ka;ab=Xa*gb-cb*Ya;if(ab!=0){Wa=1/ab;ab=(gb*na-Ya*ta)*Wa;Ya=(gb*aa-Ya*ya)*Wa;na=(Xa*ta-cb*na)*Wa;aa=(Xa*ya-cb*aa)*Wa;K=K-ab*$-na*Ka;Z=Z-Ya*$-aa*Ka;n.save();n.transform(ab,Ya,na,aa,K,Z);n.clip();n.drawImage(ea,0,0);n.restore()}} +function Va(K,Z,na,aa){var ta=~~(K.r*255),ya=~~(K.g*255);K=~~(K.b*255);var ea=~~(Z.r*255),$=~~(Z.g*255);Z=~~(Z.b*255);var Ka=~~(na.r*255),Xa=~~(na.g*255);na=~~(na.b*255);var Ya=~~(aa.r*255),cb=~~(aa.g*255);aa=~~(aa.b*255);Aa[0]=ta<0?0:ta>255?255:ta;Aa[1]=ya<0?0:ya>255?255:ya;Aa[2]=K<0?0:K>255?255:K;Aa[4]=ea<0?0:ea>255?255:ea;Aa[5]=$<0?0:$>255?255:$;Aa[6]=Z<0?0:Z>255?255:Z;Aa[8]=Ka<0?0:Ka>255?255:Ka;Aa[9]=Xa<0?0:Xa>255?255:Xa;Aa[10]=na<0?0:na>255?255:na;Aa[12]=Ya<0?0:Ya>255?255:Ya;Aa[13]=cb<0?0:cb> +255?255:cb;Aa[14]=aa<0?0:aa>255?255:aa;pa.putImageData(sa,0,0);Ea.drawImage(ha,0,0);return xa}function Ma(K,Z,na){K=(K-Z)/(na-Z);return K*K*(3-2*K)}function N(K){K=(K+1)*0.5;return K<0?0:K>1?1:K}function Na(K,Z){var na=Z.x-K.x,aa=Z.y-K.y,ta=1/Math.sqrt(na*na+aa*aa);na*=ta;aa*=ta;Z.x+=na;Z.y+=aa;K.x-=na;K.y-=aa}var Qa,ib,Ba,Sa,Fa,Oa,Ja,ua;this.autoClear?this.clear():n.setTransform(1,0,0,-1,k,m);b=d.projectScene(R,ia,this.sortElements);(H=R.lights.length>0)&&La(R);Qa=0;for(ib=b.length;Qa0){ma.r+=L.color.r*fa;ma.g+=L.color.g*fa;ma.b+=L.color.b*fa}}else if(L instanceof THREE.PointLight){e.sub(L.position,oa.centroidWorld);e.normalize();fa=oa.normalWorld.dot(e)*L.intensity;if(fa>0){ma.r+=L.color.r*fa;ma.g+=L.color.g*fa;ma.b+=L.color.b*fa}}}}function c(la,oa,ma,ca,S,L){V=d(va++); +V.setAttribute("d","M "+la.positionScreen.x+" "+la.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+ma.positionScreen.x+","+ma.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)C.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(J){U.r=P.r;U.g=P.g;U.b=P.b;a(L,ca,U);C.r=S.color.r*U.r;C.g=S.color.g*U.g;C.b=S.color.b*U.b;C.updateStyleString()}else C.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){Y= 1-S.__2near/(S.__farPlusNear-ca.z*S.__farMinusNear);C.setRGB(Y,Y,Y)}else S instanceof THREE.MeshNormalMaterial&&C.setRGB(f(ca.normalWorld.x),f(ca.normalWorld.y),f(ca.normalWorld.z));S.wireframe?V.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+S.wireframeLinewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframeLinecap+"; stroke-linejoin: "+S.wireframeLinejoin):V.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+S.opacity);k.appendChild(V)} -function b(la,oa,ma,ca,S,M,fa){V=e(va++);V.setAttribute("d","M "+la.positionScreen.x+" "+la.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+ma.positionScreen.x+","+ma.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)C.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(K){U.r=P.r;U.g=P.g;U.b=P.b;a(fa,S,U);C.r=M.color.r*U.r;C.g=M.color.g*U.g;C.b=M.color.b*U.b;C.updateStyleString()}else C.__styleString= -M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){Y=1-M.__2near/(M.__farPlusNear-S.z*M.__farMinusNear);C.setRGB(Y,Y,Y)}else M instanceof THREE.MeshNormalMaterial&&C.setRGB(f(S.normalWorld.x),f(S.normalWorld.y),f(S.normalWorld.z));M.wireframe?V.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+M.wireframeLinewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframeLinecap+"; stroke-linejoin: "+M.wireframeLinejoin):V.setAttribute("style","fill: "+ -C.__styleString+"; fill-opacity: "+M.opacity);k.appendChild(V)}function e(la){if(ja[la]==null){ja[la]=document.createElementNS("http://www.w3.org/2000/svg","path");za==0&&ja[la].setAttribute("shape-rendering","crispEdges")}return ja[la]}function f(la){return la<0?Math.min((1+la)*0.5,0.5):0.5+Math.min(la*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,y,o,A,G,J=new THREE.Rectangle,D=new THREE.Rectangle,K=!1,C=new THREE.Color(16777215), -U=new THREE.Color(16777215),P=new THREE.Color(0),O=new THREE.Color(0),W=new THREE.Color(0),Y,d=new THREE.Vector3,ja=[],X=[],V,va,ga,za=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(la){switch(la){case "high":za=1;break;case "low":za=0}};this.setSize=function(la,oa){m=la;n=oa;p=m/2;x=n/2;k.setAttribute("viewBox",-p+" "+-x+" "+m+" "+n);k.setAttribute("width",m);k.setAttribute("height",n);J.set(-p,-x,p,x)};this.clear=function(){for(;k.childNodes.length> -0;)k.removeChild(k.childNodes[0])};this.render=function(la,oa){var ma,ca,S,M,fa,ra,ka,qa;this.autoClear&&this.clear();g=h.projectScene(la,oa,this.sortElements);ga=va=0;if(K=la.lights.length>0){ka=la.lights;P.setRGB(0,0,0);O.setRGB(0,0,0);W.setRGB(0,0,0);ma=0;for(ca=ka.length;ma +0;)k.removeChild(k.childNodes[0])};this.render=function(la,oa){var ma,ca,S,L,fa,ra,ka,qa;this.autoClear&&this.clear();g=h.projectScene(la,oa,this.sortElements);ga=va=0;if(J=la.lights.length>0){ka=la.lights;P.setRGB(0,0,0);O.setRGB(0,0,0);W.setRGB(0,0,0);ma=0;for(ca=ka.length;maz){T=I;z=E[T]}d.bindBuffer(d.ARRAY_BUFFER,B.__webGLMorphTargetsBuffers[T]);d.vertexAttribPointer(t["morphTarget"+w],3,d.FLOAT,!1,0,0);F.__webGLMorphTargetInfluences[w]=z;H[T]=1;z=-1;w++}}d.uniform1fv(q.program.uniforms.morphTargetInfluences,F.__webGLMorphTargetInfluences)}else{d.bindBuffer(d.ARRAY_BUFFER,B.__webGLVertexBuffer);d.vertexAttribPointer(j.position,3, -d.FLOAT,!1,0,0)}if(j.color>=0){d.bindBuffer(d.ARRAY_BUFFER,B.__webGLColorBuffer);d.vertexAttribPointer(j.color,3,d.FLOAT,!1,0,0)}if(j.normal>=0){d.bindBuffer(d.ARRAY_BUFFER,B.__webGLNormalBuffer);d.vertexAttribPointer(j.normal,3,d.FLOAT,!1,0,0)}if(j.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,B.__webGLTangentBuffer);d.vertexAttribPointer(j.tangent,4,d.FLOAT,!1,0,0)}if(j.uv>=0)if(B.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,B.__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(B.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,B.__webGLUV2Buffer);d.vertexAttribPointer(j.uv2,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(j.uv2)}else d.disableVertexAttribArray(j.uv2);if(q.skinning&&j.skinVertexA>=0&&j.skinVertexB>=0&&j.skinIndex>=0&&j.skinWeight>=0){d.bindBuffer(d.ARRAY_BUFFER,B.__webGLSkinVertexABuffer);d.vertexAttribPointer(j.skinVertexA,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,B.__webGLSkinVertexBBuffer);d.vertexAttribPointer(j.skinVertexB,4,d.FLOAT,!1,0, -0);d.bindBuffer(d.ARRAY_BUFFER,B.__webGLSkinIndicesBuffer);d.vertexAttribPointer(j.skinIndex,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,B.__webGLSkinWeightsBuffer);d.vertexAttribPointer(j.skinWeight,4,d.FLOAT,!1,0,0)}if(F instanceof THREE.Mesh)if(q.wireframe){d.lineWidth(q.wireframeLinewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,B.__webGLLineBuffer);d.drawElements(d.LINES,B.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,B.__webGLFaceBuffer);d.drawElements(d.TRIANGLES, -B.__webGLFaceCount,d.UNSIGNED_SHORT,0)}else if(F instanceof THREE.Line){F=F.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(q.linewidth);d.drawArrays(F,0,B.__webGLLineCount)}else if(F instanceof THREE.ParticleSystem)d.drawArrays(d.POINTS,0,B.__webGLParticleCount);else F instanceof THREE.Ribbon&&d.drawArrays(d.TRIANGLE_STRIP,0,B.__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(va!=j.doubleSided){j.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE);va=j.doubleSided}if(ga!=j.flipSided){j.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW);ga=j.flipSided}}function k(j){if(la!=j){j?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST);la=j}}function m(j){M[0].set(j.n41-j.n11,j.n42-j.n12,j.n43-j.n13,j.n44-j.n14);M[1].set(j.n41+j.n11,j.n42+j.n12,j.n43+j.n13,j.n44+j.n14);M[2].set(j.n41+j.n21,j.n42+j.n22,j.n43+j.n23,j.n44+j.n24);M[3].set(j.n41-j.n21,j.n42- -j.n22,j.n43-j.n23,j.n44-j.n24);M[4].set(j.n41-j.n31,j.n42-j.n32,j.n43-j.n33,j.n44-j.n34);M[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=M[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)),q=0;q<6;q++){j=M[q].x*t.n14+M[q].y*t.n24+M[q].z*t.n34+M[q].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,q=j.object,B=j.opaque,F=j.transparent;F.count=0;j=B.count=0;for(t=q.materials.length;j0){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,Oa,B)}if(Ya){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,Sa,B)}if(cb&&ea.hasTangents){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLTangentBuffer);d.bufferData(d.ARRAY_BUFFER,Fa,B)}if(Xa&&bb>0){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLUVBuffer);d.bufferData(d.ARRAY_BUFFER,ib,B)}if(Xa&&db>0){d.bindBuffer(d.ARRAY_BUFFER, -q.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Ba,B)}if(Ka){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,aa,B);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,ta,B)}if(N>0){d.bindBuffer(d.ARRAY_BUFFER,q.__webGLSkinVertexABuffer);d.bufferData(d.ARRAY_BUFFER,Ja,B);d.bindBuffer(d.ARRAY_BUFFER,q.__webGLSkinVertexBBuffer);d.bufferData(d.ARRAY_BUFFER,ua,B);d.bindBuffer(d.ARRAY_BUFFER,q.__webGLSkinIndicesBuffer); -d.bufferData(d.ARRAY_BUFFER,L,B);d.bindBuffer(d.ARRAY_BUFFER,q.__webGLSkinWeightsBuffer);d.bufferData(d.ARRAY_BUFFER,Z,B)}}}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;Aa=j.vertices;B=j.colors;xa=Aa.length;F=B.length;Ea=j.__vertexArray;H=j.__colorArray;Ia=j.__dirtyColors;if(j.__dirtyVertices){for(pa= -0;pa65535){I[z].counter+=1;T=I[z].hash+"_"+I[z].counter;j.geometryGroups[T]==undefined&&(j.geometryGroups[T]={faces:[],materials:E,vertices:0,numMorphTargets:Q})}j.geometryGroups[T].faces.push(B);j.geometryGroups[T].vertices+=H}}function D(j,t,w){j.push({buffer:t,object:w,opaque:{list:[],count:0},transparent:{list:[], -count:0}})}function K(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 C(j,t,w){if((w.width&w.width-1)==0&&(w.height&w.height-1)==0){d.texParameteri(j,d.TEXTURE_WRAP_S,W(t.wrapS));d.texParameteri(j,d.TEXTURE_WRAP_T,W(t.wrapT));d.texParameteri(j,d.TEXTURE_MAG_FILTER,W(t.magFilter));d.texParameteri(j,d.TEXTURE_MIN_FILTER,W(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,O(t.magFilter));d.texParameteri(j,d.TEXTURE_MIN_FILTER, -O(t.minFilter))}}function U(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,W(j.wrapS));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,W(j.wrapT));d.texParameteri(d.TEXTURE_2D, -d.TEXTURE_MAG_FILTER,W(j.magFilter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,W(j.minFilter));d.texImage2D(d.TEXTURE_2D,0,W(j.format),j.width,j.height,0,W(j.format),W(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=ca;j=S}if(t!=X){d.bindFramebuffer(d.FRAMEBUFFER,t);d.viewport(oa,ma,w,j);X=t}}function P(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 O(j){switch(j){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return d.NEAREST; -default:return d.LINEAR}}function W(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 Y=document.createElement("canvas"),d,ja=null,X=null,V=this,va=null,ga=null,za=null,la=null,oa=0,ma=0,ca=0,S=0,M=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],fa=new THREE.Matrix4,ra=new Float32Array(16),ka=new Float32Array(16),qa=new THREE.Vector4,wa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},Ca=!0,Za=new THREE.Color(0),$a=0;if(a){if(a.antialias!==undefined)Ca=a.antialias; -a.clearColor!==undefined&&Za.setHex(a.clearColor);if(a.clearAlpha!==undefined)$a=a.clearAlpha}this.maxMorphTargets=8;this.domElement=Y;this.autoClear=!0;this.sortObjects=!0;(function(j,t,w){try{if(!(d=Y.getContext("experimental-webgl",{antialias:j,stencil:!0})))throw"Error creating WebGL context.";}catch(q){console.error(q)}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)})(Ca,Za,$a);this.context=d;var Ha={};a=[];Ca=[];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;Ca[0]=0;Ca[1]=1;Ca[2]=2;Ca[3]=0;Ca[4]=2;Ca[5]=3;Ha.vertexBuffer=d.createBuffer();Ha.elementBuffer=d.createBuffer();d.bindBuffer(d.ARRAY_BUFFER,Ha.vertexBuffer);d.bufferData(d.ARRAY_BUFFER,new Float32Array(a),d.STATIC_DRAW);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,Ha.elementBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER, -new Uint16Array(Ca),d.STATIC_DRAW);Ha.program=d.createProgram();d.attachShader(Ha.program,P("fragment",THREE.ShaderLib.shadowPost.fragmentShader));d.attachShader(Ha.program,P("vertex",THREE.ShaderLib.shadowPost.vertexShader));d.linkProgram(Ha.program);Ha.vertexLocation=d.getAttribLocation(Ha.program,"position");Ha.projectionLocation=d.getUniformLocation(Ha.program,"projectionMatrix");this.setSize=function(j,t){Y.width=j;Y.height=t;this.setViewport(0,0,Y.width,Y.height)};this.setViewport=function(j, -t,w,q){oa=j;ma=t;ca=w;S=q;d.viewport(oa,ma,ca,S)};this.setScissor=function(j,t,w,q){d.scissor(j,t,w,q)};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,q){var B,F,H,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 z,T,I;z=I=E=0;for(H=t.length;z0?"#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": +w.directional.colors;E.directionalLightDirection.value=w.directional.positions;E.pointLightColor.value=w.point.colors;E.pointLightPosition.value=w.point.positions}if(o instanceof THREE.MeshBasicMaterial||o instanceof THREE.MeshLambertMaterial||o instanceof THREE.MeshPhongMaterial){E.diffuse.value.setRGB(o.color.r*o.opacity,o.color.g*o.opacity,o.color.b*o.opacity);E.opacity.value=o.opacity;E.map.texture=o.map;E.lightMap.texture=o.lightMap;E.envMap.texture=o.envMap;E.reflectivity.value=o.reflectivity; +E.refractionRatio.value=o.refractionRatio;E.combine.value=o.combine;E.useRefract.value=o.envMap&&o.envMap.mapping instanceof THREE.CubeRefractionMapping}if(o instanceof THREE.LineBasicMaterial){E.diffuse.value.setRGB(o.color.r*o.opacity,o.color.g*o.opacity,o.color.b*o.opacity);E.opacity.value=o.opacity}else if(o instanceof THREE.ParticleBasicMaterial){E.psColor.value.setRGB(o.color.r*o.opacity,o.color.g*o.opacity,o.color.b*o.opacity);E.opacity.value=o.opacity;E.size.value=o.size;E.scale.value=Y.height/ +2;E.map.texture=o.map}else if(o instanceof THREE.MeshPhongMaterial){E.ambient.value.setRGB(o.ambient.r,o.ambient.g,o.ambient.b);E.specular.value.setRGB(o.specular.r,o.specular.g,o.specular.b);E.shininess.value=o.shininess}else if(o instanceof THREE.MeshDepthMaterial){E.mNear.value=j.near;E.mFar.value=j.far;E.opacity.value=o.opacity}else if(o instanceof THREE.MeshNormalMaterial)E.opacity.value=o.opacity;for(var eb in E)if(Q=F.uniforms[eb]){A=E[eb];I=A.type;w=A.value;if(I=="i")e.uniform1i(Q,w);else if(I== +"f")e.uniform1f(Q,w);else if(I=="fv1")e.uniform1fv(Q,w);else if(I=="fv")e.uniform3fv(Q,w);else if(I=="v2")e.uniform2f(Q,w.x,w.y);else if(I=="v3")e.uniform3f(Q,w.x,w.y,w.z);else if(I=="c")e.uniform3f(Q,w.r,w.g,w.b);else if(I=="t"){e.uniform1i(Q,w);if(A=A.texture)if(A.image instanceof Array&&A.image.length==6){if(A.image.length==6){if(A.needsUpdate){if(A.__wasSetOnce){e.bindTexture(e.TEXTURE_CUBE_MAP,A.image.__webGLTextureCube);for(I=0;I<6;++I)e.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+I,0,0,0,e.RGBA, +e.UNSIGNED_BYTE,A.image[I])}else{A.image.__webGLTextureCube=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,A.image.__webGLTextureCube);for(I=0;I<6;++I)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+I,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,A.image[I]);A.__wasSetOnce=!0}C(e.TEXTURE_CUBE_MAP,A,A.image[0]);e.bindTexture(e.TEXTURE_CUBE_MAP,null);A.needsUpdate=!1}e.activeTexture(e.TEXTURE0+w);e.bindTexture(e.TEXTURE_CUBE_MAP,A.image.__webGLTextureCube)}}else{if(A.needsUpdate){if(A.__wasSetOnce){e.bindTexture(e.TEXTURE_2D, +A.__webGLTexture);e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,A.image)}else{A.__webGLTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,A.__webGLTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,A.image);A.__wasSetOnce=!0}C(e.TEXTURE_2D,A,A.image);e.bindTexture(e.TEXTURE_2D,null);A.needsUpdate=!1}e.activeTexture(e.TEXTURE0+w);e.bindTexture(e.TEXTURE_2D,A.__webGLTexture)}}}e.uniformMatrix4fv(H.modelViewMatrix,!1,B._modelViewMatrixArray);e.uniformMatrix3fv(H.normalMatrix, +!1,B._normalMatrixArray);(o instanceof THREE.MeshShaderMaterial||o instanceof THREE.MeshPhongMaterial||o.envMap)&&e.uniform3f(H.cameraPosition,j.position.x,j.position.y,j.position.z);(o instanceof THREE.MeshShaderMaterial||o.envMap||o.skinning)&&e.uniformMatrix4fv(H.objectMatrix,!1,B._objectMatrixArray);(o instanceof THREE.MeshPhongMaterial||o instanceof THREE.MeshLambertMaterial||o instanceof THREE.MeshShaderMaterial||o.skinning)&&e.uniformMatrix4fv(H.viewMatrix,!1,ka);if(o instanceof THREE.ShadowVolumeDynamicMaterial){j= +E.directionalLightDirection.value;j[0]=-t.position.x;j[1]=-t.position.y;j[2]=-t.position.z;e.uniform3fv(H.directionalLightDirection,j);e.uniformMatrix4fv(H.objectMatrix,!1,B._objectMatrixArray);e.uniformMatrix4fv(H.viewMatrix,!1,ka)}if(o.skinning){e.uniformMatrix4fv(H.cameraInverseMatrix,!1,ka);e.uniformMatrix4fv(H.boneGlobalMatrices,!1,B.boneMatrices)}return F}function f(j,t,w,o,B,F){if(o.opacity!=0){j=d(j,t,w,o,F).attributes;if(o.morphTargets){t=o.program.attributes;F.morphTargetBase!==-1?e.bindBuffer(e.ARRAY_BUFFER, +B.__webGLMorphTargetsBuffers[F.morphTargetBase]):e.bindBuffer(e.ARRAY_BUFFER,B.__webGLVertexBuffer);e.vertexAttribPointer(t.position,3,e.FLOAT,!1,0,0);if(F.morphTargetForcedOrder.length){w=0;for(var H=F.morphTargetForcedOrder,E=F.morphTargetInfluences;wA){T=I;A=E[T]}e.bindBuffer(e.ARRAY_BUFFER,B.__webGLMorphTargetsBuffers[T]);e.vertexAttribPointer(t["morphTarget"+w],3,e.FLOAT,!1,0,0);F.__webGLMorphTargetInfluences[w]=A;H[T]=1;A=-1;w++}}e.uniform1fv(o.program.uniforms.morphTargetInfluences,F.__webGLMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,B.__webGLVertexBuffer);e.vertexAttribPointer(j.position,3, +e.FLOAT,!1,0,0)}if(j.color>=0){e.bindBuffer(e.ARRAY_BUFFER,B.__webGLColorBuffer);e.vertexAttribPointer(j.color,3,e.FLOAT,!1,0,0)}if(j.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,B.__webGLNormalBuffer);e.vertexAttribPointer(j.normal,3,e.FLOAT,!1,0,0)}if(j.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,B.__webGLTangentBuffer);e.vertexAttribPointer(j.tangent,4,e.FLOAT,!1,0,0)}if(j.uv>=0)if(B.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,B.__webGLUVBuffer);e.vertexAttribPointer(j.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(j.uv)}else e.disableVertexAttribArray(j.uv); +if(j.uv2>=0)if(B.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,B.__webGLUV2Buffer);e.vertexAttribPointer(j.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(j.uv2)}else e.disableVertexAttribArray(j.uv2);if(o.skinning&&j.skinVertexA>=0&&j.skinVertexB>=0&&j.skinIndex>=0&&j.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,B.__webGLSkinVertexABuffer);e.vertexAttribPointer(j.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,B.__webGLSkinVertexBBuffer);e.vertexAttribPointer(j.skinVertexB,4,e.FLOAT,!1,0, +0);e.bindBuffer(e.ARRAY_BUFFER,B.__webGLSkinIndicesBuffer);e.vertexAttribPointer(j.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,B.__webGLSkinWeightsBuffer);e.vertexAttribPointer(j.skinWeight,4,e.FLOAT,!1,0,0)}if(F instanceof THREE.Mesh)if(o.wireframe){e.lineWidth(o.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,B.__webGLLineBuffer);e.drawElements(e.LINES,B.__webGLLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,B.__webGLFaceBuffer);e.drawElements(e.TRIANGLES, +B.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else if(F instanceof THREE.Line){F=F.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(o.linewidth);e.drawArrays(F,0,B.__webGLLineCount)}else if(F instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,0,B.__webGLParticleCount);else F instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,B.__webGLVertexCount)}}function g(j,t){if(!j.__webGLVertexBuffer)j.__webGLVertexBuffer=e.createBuffer();if(!j.__webGLNormalBuffer)j.__webGLNormalBuffer=e.createBuffer(); +if(j.hasPos){e.bindBuffer(e.ARRAY_BUFFER,j.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,j.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(t.attributes.position);e.vertexAttribPointer(t.attributes.position,3,e.FLOAT,!1,0,0)}if(j.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,j.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,j.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(t.attributes.normal);e.vertexAttribPointer(t.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,j.count); +j.count=0}function h(j){if(va!=j.doubleSided){j.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);va=j.doubleSided}if(ga!=j.flipSided){j.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);ga=j.flipSided}}function k(j){if(la!=j){j?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);la=j}}function m(j){L[0].set(j.n41-j.n11,j.n42-j.n12,j.n43-j.n13,j.n44-j.n14);L[1].set(j.n41+j.n11,j.n42+j.n12,j.n43+j.n13,j.n44+j.n14);L[2].set(j.n41+j.n21,j.n42+j.n22,j.n43+j.n23,j.n44+j.n24);L[3].set(j.n41-j.n21,j.n42- +j.n22,j.n43-j.n23,j.n44-j.n24);L[4].set(j.n41-j.n31,j.n42-j.n32,j.n43-j.n33,j.n44-j.n34);L[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=L[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=L[o].x*t.n14+L[o].y*t.n24+L[o].z*t.n34+L[o].w;if(j<=w)return!1}return!0}function q(j,t){j.list[j.count]=t;j.count+=1}function x(j){var t, +w,o=j.object,B=j.opaque,F=j.transparent;F.count=0;j=B.count=0;for(t=o.materials.length;j0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,Oa,B)}if(Ya){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,Sa,B)}if(cb&&ea.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLTangentBuffer);e.bufferData(e.ARRAY_BUFFER,Fa,B)}if(Xa&&bb>0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,ib,B)}if(Xa&&db>0){e.bindBuffer(e.ARRAY_BUFFER, +o.__webGLUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Ba,B)}if(Ka){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,aa,B);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ta,B)}if(N>0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,Ja,B);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,ua,B);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer); +e.bufferData(e.ARRAY_BUFFER,K,B);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,Z,B)}}}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=e.DYNAMIC_DRAW;Aa=j.vertices;B=j.colors;xa=Aa.length;F=B.length;Ea=j.__vertexArray;H=j.__colorArray;Ia=j.__dirtyColors;if(j.__dirtyVertices){for(pa= +0;pa65535){I[A].counter+=1;T=I[A].hash+"_"+I[A].counter;j.geometryGroups[T]==undefined&&(j.geometryGroups[T]={faces:[],materials:E,vertices:0,numMorphTargets:Q})}j.geometryGroups[T].faces.push(B);j.geometryGroups[T].vertices+=H}}function D(j,t,w){j.push({buffer:t,object:w,opaque:{list:[],count:0},transparent:{list:[], +count:0}})}function J(j){if(j!=za){switch(j){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE);break;case THREE.SubtractiveBlending:e.blendFunc(e.DST_COLOR,e.ZERO);break;case THREE.BillboardBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:e.blendEquation(e.FUNC_REVERSE_SUBTRACT);e.blendFunc(e.ONE,e.ONE);break;default:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}za= +j}}function C(j,t,w){if((w.width&w.width-1)==0&&(w.height&w.height-1)==0){e.texParameteri(j,e.TEXTURE_WRAP_S,W(t.wrapS));e.texParameteri(j,e.TEXTURE_WRAP_T,W(t.wrapT));e.texParameteri(j,e.TEXTURE_MAG_FILTER,W(t.magFilter));e.texParameteri(j,e.TEXTURE_MIN_FILTER,W(t.minFilter));e.generateMipmap(j)}else{e.texParameteri(j,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(j,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(j,e.TEXTURE_MAG_FILTER,O(t.magFilter));e.texParameteri(j,e.TEXTURE_MIN_FILTER, +O(t.minFilter))}}function U(j){if(j&&!j.__webGLFramebuffer){j.__webGLFramebuffer=e.createFramebuffer();j.__webGLRenderbuffer=e.createRenderbuffer();j.__webGLTexture=e.createTexture();e.bindRenderbuffer(e.RENDERBUFFER,j.__webGLRenderbuffer);e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,j.width,j.height);e.bindTexture(e.TEXTURE_2D,j.__webGLTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,W(j.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,W(j.wrapT));e.texParameteri(e.TEXTURE_2D, +e.TEXTURE_MAG_FILTER,W(j.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,W(j.minFilter));e.texImage2D(e.TEXTURE_2D,0,W(j.format),j.width,j.height,0,W(j.format),W(j.type),null);e.bindFramebuffer(e.FRAMEBUFFER,j.__webGLFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,j.__webGLTexture,0);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,j.__webGLRenderbuffer);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null); +e.bindFramebuffer(e.FRAMEBUFFER,null)}var t,w;if(j){t=j.__webGLFramebuffer;w=j.width;j=j.height}else{t=null;w=ca;j=S}if(t!=X){e.bindFramebuffer(e.FRAMEBUFFER,t);e.viewport(oa,ma,w,j);X=t}}function P(j,t){var w;if(j=="fragment")w=e.createShader(e.FRAGMENT_SHADER);else j=="vertex"&&(w=e.createShader(e.VERTEX_SHADER));e.shaderSource(w,t);e.compileShader(w);if(!e.getShaderParameter(w,e.COMPILE_STATUS)){console.error(e.getShaderInfoLog(w));console.error(t);return null}return w}function O(j){switch(j){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST; +default:return e.LINEAR}}function W(j){switch(j){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR; +case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0} +var Y=document.createElement("canvas"),e,ja=null,X=null,V=this,va=null,ga=null,za=null,la=null,oa=0,ma=0,ca=0,S=0,L=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],fa=new THREE.Matrix4,ra=new Float32Array(16),ka=new Float32Array(16),qa=new THREE.Vector4,wa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},Ca=!0,Za=new THREE.Color(0),$a=0;if(a){if(a.antialias!==undefined)Ca=a.antialias; +a.clearColor!==undefined&&Za.setHex(a.clearColor);if(a.clearAlpha!==undefined)$a=a.clearAlpha}this.maxMorphTargets=8;this.domElement=Y;this.autoClear=!0;this.sortObjects=!0;(function(j,t,w){try{if(!(e=Y.getContext("experimental-webgl",{antialias:j,stencil:!0})))throw"Error creating WebGL context.";}catch(o){console.error(o)}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendFunc(e.ONE, +e.ONE_MINUS_SRC_ALPHA);e.clearColor(t.r,t.g,t.b,w)})(Ca,Za,$a);this.context=e;var Ha={};a=[];Ca=[];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;Ca[0]=0;Ca[1]=1;Ca[2]=2;Ca[3]=0;Ca[4]=2;Ca[5]=3;Ha.vertexBuffer=e.createBuffer();Ha.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,Ha.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,new Float32Array(a),e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,Ha.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER, +new Uint16Array(Ca),e.STATIC_DRAW);Ha.program=e.createProgram();e.attachShader(Ha.program,P("fragment",THREE.ShaderLib.shadowPost.fragmentShader));e.attachShader(Ha.program,P("vertex",THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(Ha.program);Ha.vertexLocation=e.getAttribLocation(Ha.program,"position");Ha.projectionLocation=e.getUniformLocation(Ha.program,"projectionMatrix");this.setSize=function(j,t){Y.width=j;Y.height=t;this.setViewport(0,0,Y.width,Y.height)};this.setViewport=function(j, +t,w,o){oa=j;ma=t;ca=w;S=o;e.viewport(oa,ma,ca,S)};this.setScissor=function(j,t,w,o){e.scissor(j,t,w,o)};this.enableScissorTest=function(j){j?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(j){e.depthMask(j)};this.setClearColorHex=function(j,t){var w=new THREE.Color(j);e.clearColor(w.r,w.g,w.b,t)};this.setClearColor=function(j,t){e.clearColor(j.r,j.g,j.b,t)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.initMaterial= +function(j,t,w,o){var B,F,H,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,T,I;A=I=E=0;for(H=t.length;A0?"#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"); -d.attachShader(t,P("fragment",z+w));d.attachShader(t,P("vertex",H+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(B in j.uniforms)w.push(B); -B=j.program;E=0;for(t=w.length;E=0&&d.enableVertexAttribArray(F.color);F.normal>=0&&d.enableVertexAttribArray(F.normal); -F.tangent>=0&&d.enableVertexAttribArray(F.tangent);if(j.skinning&&F.skinVertexA>=0&&F.skinVertexB>=0&&F.skinIndex>=0&&F.skinWeight>=0){d.enableVertexAttribArray(F.skinVertexA);d.enableVertexAttribArray(F.skinVertexB);d.enableVertexAttribArray(F.skinIndex);d.enableVertexAttribArray(F.skinWeight)}if(j.morphTargets){j.numSupportedMorphTargets=0;if(F.morphTarget0>=0){d.enableVertexAttribArray(F.morphTarget0);j.numSupportedMorphTargets++}if(F.morphTarget1>=0){d.enableVertexAttribArray(F.morphTarget1); -j.numSupportedMorphTargets++}if(F.morphTarget2>=0){d.enableVertexAttribArray(F.morphTarget2);j.numSupportedMorphTargets++}if(F.morphTarget3>=0){d.enableVertexAttribArray(F.morphTarget3);j.numSupportedMorphTargets++}if(F.morphTarget4>=0){d.enableVertexAttribArray(F.morphTarget4);j.numSupportedMorphTargets++}if(F.morphTarget5>=0){d.enableVertexAttribArray(F.morphTarget5);j.numSupportedMorphTargets++}if(F.morphTarget6>=0){d.enableVertexAttribArray(F.morphTarget6);j.numSupportedMorphTargets++}if(F.morphTarget7>= -0){d.enableVertexAttribArray(F.morphTarget7);j.numSupportedMorphTargets++}q.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(B=0;B0||Aa.faceVertexUvs.length>0)H.__uvArray=new Float32Array(z*2);if(Aa.faceUvs.length>1||Aa.faceVertexUvs.length>1)H.__uv2Array=new Float32Array(z*2)}if(E.geometry.skinWeights.length&&E.geometry.skinIndices.length){H.__skinVertexAArray=new Float32Array(z*4);H.__skinVertexBArray=new Float32Array(z*4);H.__skinIndexArray=new Float32Array(z*4);H.__skinWeightArray=new Float32Array(z*4)}H.__faceArray=new Uint16Array(ha*3+(E.geometry.edgeFaces?E.geometry.edgeFaces.length*6:0)); -H.__lineArray=new Uint16Array(pa*2);if(H.numMorphTargets){Aa=void 0;xa=void 0;H.__morphTargetsArrays=[];Aa=0;for(xa=H.numMorphTargets;Aa=0;B--){q=w.__webglObjects[B].object; -t==q&&w.__webglObjects.splice(B,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;e=0&&e.enableVertexAttribArray(F.color);F.normal>=0&&e.enableVertexAttribArray(F.normal); +F.tangent>=0&&e.enableVertexAttribArray(F.tangent);if(j.skinning&&F.skinVertexA>=0&&F.skinVertexB>=0&&F.skinIndex>=0&&F.skinWeight>=0){e.enableVertexAttribArray(F.skinVertexA);e.enableVertexAttribArray(F.skinVertexB);e.enableVertexAttribArray(F.skinIndex);e.enableVertexAttribArray(F.skinWeight)}if(j.morphTargets){j.numSupportedMorphTargets=0;if(F.morphTarget0>=0){e.enableVertexAttribArray(F.morphTarget0);j.numSupportedMorphTargets++}if(F.morphTarget1>=0){e.enableVertexAttribArray(F.morphTarget1); +j.numSupportedMorphTargets++}if(F.morphTarget2>=0){e.enableVertexAttribArray(F.morphTarget2);j.numSupportedMorphTargets++}if(F.morphTarget3>=0){e.enableVertexAttribArray(F.morphTarget3);j.numSupportedMorphTargets++}if(F.morphTarget4>=0){e.enableVertexAttribArray(F.morphTarget4);j.numSupportedMorphTargets++}if(F.morphTarget5>=0){e.enableVertexAttribArray(F.morphTarget5);j.numSupportedMorphTargets++}if(F.morphTarget6>=0){e.enableVertexAttribArray(F.morphTarget6);j.numSupportedMorphTargets++}if(F.morphTarget7>= +0){e.enableVertexAttribArray(F.morphTarget7);j.numSupportedMorphTargets++}o.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(B=0;B0||Aa.faceVertexUvs.length>0)H.__uvArray=new Float32Array(A*2);if(Aa.faceUvs.length>1||Aa.faceVertexUvs.length>1)H.__uv2Array=new Float32Array(A*2)}if(E.geometry.skinWeights.length&&E.geometry.skinIndices.length){H.__skinVertexAArray=new Float32Array(A*4);H.__skinVertexBArray=new Float32Array(A*4);H.__skinIndexArray=new Float32Array(A*4);H.__skinWeightArray=new Float32Array(A*4)}H.__faceArray=new Uint16Array(ha*3+(E.geometry.edgeFaces?E.geometry.edgeFaces.length*6:0)); +H.__lineArray=new Uint16Array(pa*2);if(H.numMorphTargets){Aa=void 0;xa=void 0;H.__morphTargetsArrays=[];Aa=0;for(xa=H.numMorphTargets;Aa=0;B--){o=w.__webglObjects[B].object; +t==o&&w.__webglObjects.splice(B,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 d,f=b.length;for(d=0;d= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}", @@ -337,86 +337,85 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i25&&(g=25);f=(g-1)*0.5;b=Array(g);for(c=e=0;c25&&(g=25);f=(g-1)*0.5;b=Array(g);for(c=d=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 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()}, +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()}, !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(n,p,x,y){var o={name:x,fps:0.6,length:y,hierarchy:[]},A,G=p.getControlPointsArray(),J=p.getLength(),D=G.length,K=0;A=D-1;p={parent:-1,keys:[]};p.keys[0]={time:0,pos:G[0],rot:[0,0,0,1],scl:[1,1,1]};p.keys[A]={time:y,pos:G[A],rot:[0,0,0,1],scl:[1,1,1]};for(A=1;A=0?y:y+f;y=this.verticalAngleMap.srcRange;o=this.verticalAngleMap.dstRange; -this.phi=(this.phi-y[0])*(o[1]-o[0])/(y[1]-y[0])+o[0];y=this.horizontalAngleMap.srcRange;o=this.horizontalAngleMap.dstRange;this.theta=(this.theta-y[0])*(o[1]-o[0])/(y[1]-y[0])+o[0];y=this.target.position;y.x=100*Math.sin(this.phi)*Math.cos(this.theta);y.y=100*Math.cos(this.phi);y.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,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.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var f=Math.PI*2,g=Math.PI/180;this.update=function(n,q,x){var y,p;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*g;this.theta=this.lon*g;y=this.phi%f;this.phi=y>=0?y:y+f;y=this.verticalAngleMap.srcRange;p=this.verticalAngleMap.dstRange; +this.phi=(this.phi-y[0])*(p[1]-p[0])/(y[1]-y[0])+p[0];y=this.horizontalAngleMap.srcRange;p=this.horizontalAngleMap.dstRange;this.theta=(this.theta-y[0])*(p[1]-p[0])/(y[1]-y[0])+p[0];y=this.target.position;y.x=100*Math.sin(this.phi)*Math.cos(this.theta);y.y=100*Math.cos(this.phi);y.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,n,q,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(J,D,K,C,U,P,O,W){var Y,d,ja=e||1,X=f||1,V=U/2,va=P/2,ga=p.vertices.length;if(J=="x"&&D=="y"||J=="y"&&D=="x")Y="z";else if(J=="x"&&D=="z"||J=="z"&&D=="x"){Y="y";X=g||1}else if(J=="z"&&D=="y"||J=="y"&&D=="z"){Y="x";ja=g||1}var za=ja+1,la=X+1;U/=ja;var oa=P/X;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,y,o){var A=Math.sqrt(x*x+y*y+o*o);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(x/A,y/A,o/A)))-1}function b(x,y,o,A){A.faces.push(new THREE.Face3(x,y,o))}function e(x,y){var o=f.vertices[x].position,A=f.vertices[y].position;return c((o.x+A.x)/2,(o.y+A.y)/2,(o.z+A.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){h(0,0,-n-(g||0));for(d=a;d0){h(0,0,n+(f||0)); +for(d=a+a/2;d<2*a;d++)k.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,y,p){var z=Math.sqrt(x*x+y*y+p*p);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(x/z,y/z,p/z)))-1}function b(x,y,p,z){z.faces.push(new THREE.Face3(x,y,p))}function d(x,y){var p=f.vertices[x].position,z=f.vertices[y].position;return c((p.x+z.x)/2,(p.y+z.y)/2,(p.z+z.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||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,y)))-1);n.push(p)}c.push(n)}var o,A,G;f=c.length;for(b=0;b0)for(e=0;e1){o=this.vertices[h].position.clone(); -A=this.vertices[m].position.clone();G=this.vertices[n].position.clone();o.normalize();A.normalize();G.normalize();this.faces.push(new THREE.Face3(h,m,n,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([p,x,J])}}}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,y,o,A,G,J){y=o/A*x;o=Math.cos(y);return new THREE.Vector3(G*(2+o)*0.5*Math.cos(x),G*(2+o)*Math.sin(x)*0.5,J*G*Math.sin(y)*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;a0||(q=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,y)))-1);n.push(q)}c.push(n)}var p,z,G;f=c.length;for(b=0;b0)for(d=0;d1){p=this.vertices[h].position.clone(); +z=this.vertices[m].position.clone();G=this.vertices[n].position.clone();p.normalize();z.normalize();G.normalize();this.faces.push(new THREE.Face3(h,m,n,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([q,x,M])}}}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 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(d),(this.radius+this.tube*Math.cos(f))*Math.sin(d),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){d=(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(d,f,g,h));this.faceVertexUvs[0].push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; +var TorusKnot=function(a,c,b,d,f,g,h){function k(x,y,p,z,G,M){y=p/z*x;p=Math.cos(y);return new THREE.Vector3(G*(2+p)*0.5*Math.cos(x),G*(2+p)*Math.sin(x)*0.5,M*G*Math.sin(y)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=d||8;this.p=f||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|=(B&127)<<16|q<<8;if(w==0&&H==-127)return 0;return(1-2*(F>>7))*(1+w*Math.pow(2,-23))*Math.pow(2,H)}function k(j,t){var w=p(j,t),q=p(j,t+1),B=p(j,t+2);return(p(j,t+3)<<24)+(B<<16)+(q<<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,q;t=k(a,j);w=k(a,j+O);q=k(a,j+W);j=m(a,j+Y);THREE.BinaryLoader.prototype.f3(D,t,w,q,j)}function y(j){var t,w,q,B,F,H;t=k(a,j);w=k(a,j+O);q=k(a,j+W);B=m(a,j+Y);F=k(a,j+d);H=k(a,j+ja);j=k(a,j+X);THREE.BinaryLoader.prototype.f3n(D,U,t,w,q,B,F,H,j)}function o(j){var t,w,q,B;t=k(a,j);w=k(a,j+V);q=k(a,j+va);B=k(a,j+ga);j=m(a,j+za);THREE.BinaryLoader.prototype.f4(D,t,w,q,B,j)}function A(j){var t,w,q,B,F,H,E,z;t=k(a,j);w=k(a,j+V);q=k(a,j+va);B=k(a,j+ga); -F=m(a,j+za);H=k(a,j+la);E=k(a,j+oa);z=k(a,j+ma);j=k(a,j+ca);THREE.BinaryLoader.prototype.f4n(D,U,t,w,q,B,F,H,E,z,j)}function G(j){var t,w;t=k(a,j);w=k(a,j+S);j=k(a,j+M);THREE.BinaryLoader.prototype.uv3(D.faceVertexUvs[0],P[t*2],P[t*2+1],P[w*2],P[w*2+1],P[j*2],P[j*2+1])}function J(j){var t,w,q;t=k(a,j);w=k(a,j+fa);q=k(a,j+ra);j=k(a,j+ka);THREE.BinaryLoader.prototype.uv4(D.faceVertexUvs[0],P[t*2],P[t*2+1],P[w*2],P[w*2+1],P[q*2],P[q*2+1],P[j*2],P[j*2+1])}var D=this,K=0,C,U=[],P=[],O,W,Y,d,ja,X,V,va, -ga,za,la,oa,ma,ca,S,M,fa,ra,ka,qa,wa,Ca,Za,$a,Ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(D,e,g);C={signature:a.substr(K,8),header_bytes:p(a,K+8),vertex_coordinate_bytes:p(a,K+9),normal_coordinate_bytes:p(a,K+10),uv_coordinate_bytes:p(a,K+11),vertex_index_bytes:p(a,K+12),normal_index_bytes:p(a,K+13),uv_index_bytes:p(a,K+14),material_index_bytes:p(a,K+15),nvertices:k(a,K+16),nnormals:k(a,K+16+4),nuvs:k(a,K+16+8),ntri_flat:k(a,K+16+12),ntri_smooth:k(a,K+16+16),ntri_flat_uv:k(a, -K+16+20),ntri_smooth_uv:k(a,K+16+24),nquad_flat:k(a,K+16+28),nquad_smooth:k(a,K+16+32),nquad_flat_uv:k(a,K+16+36),nquad_smooth_uv:k(a,K+16+40)};K+=C.header_bytes;O=C.vertex_index_bytes;W=C.vertex_index_bytes*2;Y=C.vertex_index_bytes*3;d=C.vertex_index_bytes*3+C.material_index_bytes;ja=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes;X=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes*2;V=C.vertex_index_bytes;va=C.vertex_index_bytes*2;ga=C.vertex_index_bytes*3;za= -C.vertex_index_bytes*4;la=C.vertex_index_bytes*4+C.material_index_bytes;oa=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes;ma=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*2;ca=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*3;S=C.uv_index_bytes;M=C.uv_index_bytes*2;fa=C.uv_index_bytes;ra=C.uv_index_bytes*2;ka=C.uv_index_bytes*3;g=C.vertex_index_bytes*3+C.material_index_bytes;Ha=C.vertex_index_bytes*4+C.material_index_bytes;qa=C.ntri_flat* -g;wa=C.ntri_smooth*(g+C.normal_index_bytes*3);Ca=C.ntri_flat_uv*(g+C.uv_index_bytes*3);Za=C.ntri_smooth_uv*(g+C.normal_index_bytes*3+C.uv_index_bytes*3);$a=C.nquad_flat*Ha;g=C.nquad_smooth*(Ha+C.normal_index_bytes*4);Ha=C.nquad_flat_uv*(Ha+C.uv_index_bytes*4);K+=function(j){for(var t,w,q,B=C.vertex_coordinate_bytes*3,F=j+C.nvertices*B;j>7)-127;w|=(B&127)<<16|o<<8;if(w==0&&H==-127)return 0;return(1-2*(F>>7))*(1+w*Math.pow(2,-23))*Math.pow(2,H)}function k(j,t){var w=q(j,t),o=q(j,t+1),B=q(j,t+2);return(q(j,t+3)<<24)+(B<<16)+(o<<8)+w}function m(j,t){var w=q(j,t);return(q(j,t+1)<<8)+w}function n(j,t){var w=q(j,t);return w>127?w-256:w}function q(j, +t){return j.charCodeAt(t)&255}function x(j){var t,w,o;t=k(a,j);w=k(a,j+O);o=k(a,j+W);j=m(a,j+Y);THREE.BinaryLoader.prototype.f3(D,t,w,o,j)}function y(j){var t,w,o,B,F,H;t=k(a,j);w=k(a,j+O);o=k(a,j+W);B=m(a,j+Y);F=k(a,j+e);H=k(a,j+ja);j=k(a,j+X);THREE.BinaryLoader.prototype.f3n(D,U,t,w,o,B,F,H,j)}function p(j){var t,w,o,B;t=k(a,j);w=k(a,j+V);o=k(a,j+va);B=k(a,j+ga);j=m(a,j+za);THREE.BinaryLoader.prototype.f4(D,t,w,o,B,j)}function z(j){var t,w,o,B,F,H,E,A;t=k(a,j);w=k(a,j+V);o=k(a,j+va);B=k(a,j+ga); +F=m(a,j+za);H=k(a,j+la);E=k(a,j+oa);A=k(a,j+ma);j=k(a,j+ca);THREE.BinaryLoader.prototype.f4n(D,U,t,w,o,B,F,H,E,A,j)}function G(j){var t,w;t=k(a,j);w=k(a,j+S);j=k(a,j+L);THREE.BinaryLoader.prototype.uv3(D.faceVertexUvs[0],P[t*2],P[t*2+1],P[w*2],P[w*2+1],P[j*2],P[j*2+1])}function M(j){var t,w,o;t=k(a,j);w=k(a,j+fa);o=k(a,j+ra);j=k(a,j+ka);THREE.BinaryLoader.prototype.uv4(D.faceVertexUvs[0],P[t*2],P[t*2+1],P[w*2],P[w*2+1],P[o*2],P[o*2+1],P[j*2],P[j*2+1])}var D=this,J=0,C,U=[],P=[],O,W,Y,e,ja,X,V,va, +ga,za,la,oa,ma,ca,S,L,fa,ra,ka,qa,wa,Ca,Za,$a,Ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(D,d,g);C={signature:a.substr(J,8),header_bytes:q(a,J+8),vertex_coordinate_bytes:q(a,J+9),normal_coordinate_bytes:q(a,J+10),uv_coordinate_bytes:q(a,J+11),vertex_index_bytes:q(a,J+12),normal_index_bytes:q(a,J+13),uv_index_bytes:q(a,J+14),material_index_bytes:q(a,J+15),nvertices:k(a,J+16),nnormals:k(a,J+16+4),nuvs:k(a,J+16+8),ntri_flat:k(a,J+16+12),ntri_smooth:k(a,J+16+16),ntri_flat_uv:k(a, +J+16+20),ntri_smooth_uv:k(a,J+16+24),nquad_flat:k(a,J+16+28),nquad_smooth:k(a,J+16+32),nquad_flat_uv:k(a,J+16+36),nquad_smooth_uv:k(a,J+16+40)};J+=C.header_bytes;O=C.vertex_index_bytes;W=C.vertex_index_bytes*2;Y=C.vertex_index_bytes*3;e=C.vertex_index_bytes*3+C.material_index_bytes;ja=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes;X=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes*2;V=C.vertex_index_bytes;va=C.vertex_index_bytes*2;ga=C.vertex_index_bytes*3;za= +C.vertex_index_bytes*4;la=C.vertex_index_bytes*4+C.material_index_bytes;oa=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes;ma=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*2;ca=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*3;S=C.uv_index_bytes;L=C.uv_index_bytes*2;fa=C.uv_index_bytes;ra=C.uv_index_bytes*2;ka=C.uv_index_bytes*3;g=C.vertex_index_bytes*3+C.material_index_bytes;Ha=C.vertex_index_bytes*4+C.material_index_bytes;qa=C.ntri_flat* +g;wa=C.ntri_smooth*(g+C.normal_index_bytes*3);Ca=C.ntri_flat_uv*(g+C.uv_index_bytes*3);Za=C.ntri_smooth_uv*(g+C.normal_index_bytes*3+C.uv_index_bytes*3);$a=C.nquad_flat*Ha;g=C.nquad_smooth*(Ha+C.normal_index_bytes*4);Ha=C.nquad_flat_uv*(Ha+C.uv_index_bytes*4);J+=function(j){for(var t,w,o,B=C.vertex_coordinate_bytes*3,F=j+C.nvertices*B;j=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 y=Math.floor(n-k);y<1&&(y=1);n=Math.floor(n+k);n>this.size-1&&(n=this.size-1);var o=Math.floor(p-k);o<1&&(o=1);k=Math.floor(p+k); -k>this.size-1&&(k=this.size-1);for(var A,G,J,D,K,C;x0&&(this.field[J+A]+=D)}}}};this.addPlaneX=function(b,e){var f,g,h,k,m,n=this.size,p=this.yd,x=this.zd,y=this.field,o=n*Math.sqrt(b/e);o>n&&(o=n);for(f=0;f0)for(g=0;gp&&(A=p);for(g=0;g0){m=g*x;for(f=0;fsize&&(dist=size);for(h=0;h0){m=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 d=this.count*3;dthis.size-1&&(m=this.size-1);var y=Math.floor(n-k);y<1&&(y=1);n=Math.floor(n+k);n>this.size-1&&(n=this.size-1);var p=Math.floor(q-k);p<1&&(p=1);k=Math.floor(q+k); +k>this.size-1&&(k=this.size-1);for(var z,G,M,D,J,C;x0&&(this.field[M+z]+=D)}}}};this.addPlaneX=function(b,d){var f,g,h,k,m,n=this.size,q=this.yd,x=this.zd,y=this.field,p=n*Math.sqrt(b/d);p>n&&(p=n);for(f=0;f0)for(g=0;gq&&(z=q);for(g=0;g0){m=g*x;for(f=0;fsize&&(dist=size);for(h=0;h0){m=zd*h;for(g=0;g= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}", @@ -22,86 +22,85 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i25&&(f=25);g=(f-1)*0.5;b=Array(f);for(e=c=0;e25&&(e=25);d=(e-1)*0.5;b=Array(e);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,o,q){var m={name:o,fps:0.6,length:q,hierarchy:[]},t,A=k.getControlPointsArray(),z=k.getLength(),x=A.length,y=0;t=x-1;k={parent:-1,keys:[]};k.keys[0]={time:0,pos:A[0],rot:[0,0,0,1],scl:[1,1,1]};k.keys[t]={time:q,pos:A[t],rot:[0,0,0,1],scl:[1,1,1]};for(t=1;t=0?q:q+g;q=this.verticalAngleMap.srcRange;m=this.verticalAngleMap.dstRange; -this.phi=(this.phi-q[0])*(m[1]-m[0])/(q[1]-q[0])+m[0];q=this.horizontalAngleMap.srcRange;m=this.horizontalAngleMap.dstRange;this.theta=(this.theta-q[0])*(m[1]-m[0])/(q[1]-q[0])+m[0];q=this.target.position;q.x=100*Math.sin(this.phi)*Math.cos(this.theta);q.y=100*Math.cos(this.phi);q.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,l,k,o)};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}),h=new Cube(10,10,20),j=new Cube(2,2,10);this.animationParent=new THREE.Mesh(h,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,g,f,d,h,j){function l(z,x,y,n,H,D,M,F){var J,I,K=c||1,L=g||1,P=H/2,Q=D/2,E=k.vertices.length;if(z=="x"&&x=="y"||z=="y"&&x=="x")J="z";else if(z=="x"&&x=="z"||z=="z"&&x=="x"){J="y";L=f||1}else if(z=="z"&&x=="y"||z=="y"&&x=="z"){J="x";K=f||1}var O=K+1,U=L+1;H/=K;var $=D/L;for(I=0;I0){d(0,0,-l-(f||0));for(c=a;c0){d(0,0,l+(g||0)); +this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var d=Math.PI*2,e=Math.PI/180;this.update=function(k,l,p){var q,m;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*e;this.theta=this.lon*e;q=this.phi%d;this.phi=q>=0?q:q+d;q=this.verticalAngleMap.srcRange;m=this.verticalAngleMap.dstRange; +this.phi=(this.phi-q[0])*(m[1]-m[0])/(q[1]-q[0])+m[0];q=this.horizontalAngleMap.srcRange;m=this.horizontalAngleMap.dstRange;this.theta=(this.theta-q[0])*(m[1]-m[0])/(q[1]-q[0])+m[0];q=this.target.position;q.x=100*Math.sin(this.phi)*Math.cos(this.theta);q.y=100*Math.cos(this.phi);q.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,k,l,p)};this.onMouseMove=function(k){this.mouseX=k.clientX-this.windowHalfX;this.mouseY=k.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 f=new THREE.MeshLambertMaterial({color:65280}),h=new Cube(10,10,20),j=new Cube(2,2,10);this.animationParent=new THREE.Mesh(h,a);a=new THREE.Mesh(j,f);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(k,l){return function(){l.apply(k,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,e,f,h,j){function k(C,x,z,n,H,D,M,F){var J,I,K=c||1,L=d||1,P=H/2,Q=D/2,E=l.vertices.length;if(C=="x"&&x=="y"||C=="y"&&x=="x")J="z";else if(C=="x"&&x=="z"||C=="z"&&x=="x"){J="y";L=e||1}else if(C=="z"&&x=="y"||C=="y"&&x=="z"){J="x";K=e||1}var O=K+1,U=L+1;H/=K;var $=D/L;for(I=0;I0){f(0,0,-k-(e||0));for(c=a;c0){f(0,0,k+(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 e(o,q,m){var t=Math.sqrt(o*o+q*q+m*m);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(o/t,q/t,m/t)))-1}function b(o,q,m,t){t.faces.push(new THREE.Face3(o,q,m))}function c(o,q){var m=g.vertices[o].position,t=g.vertices[q].position;return e((m.x+t.x)/2,(m.y+t.y)/2,(m.z+t.z)/2)}var g=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;a0||(k=this.vertices.push(new THREE.Vertex(new THREE.Vector3(o,h,q)))-1);l.push(k)}e.push(l)}var m,t,A;g=e.length;for(b=0;b0)for(c=0;c1){m=this.vertices[d].position.clone(); -t=this.vertices[j].position.clone();A=this.vertices[l].position.clone();m.normalize();t.normalize();A.normalize();this.faces.push(new THREE.Face3(d,j,l,[new THREE.Vector3(m.x,m.y,m.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(A.x,A.y,A.z)]));this.faceVertexUvs[0].push([k,o,z])}}}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 g=e/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(c),(this.radius+this.tube*Math.cos(g))*Math.sin(c),this.tube*Math.sin(g))));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;g=(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,g,f,d));this.faceVertexUvs[0].push([new THREE.UV(a[c][0],a[c][1]),new THREE.UV(a[g][0],a[g][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,g,f,d){function h(o,q,m,t,A,z){q=m/t*o;m=Math.cos(q);return new THREE.Vector3(A*(2+m)*0.5*Math.cos(o),A*(2+m)*Math.sin(o)*0.5,z*A*Math.sin(q)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=e||40;this.segmentsR=b||64;this.segmentsT=c||8;this.p=g||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;B|=(G&127)<<16|C<<8;if(B==0&&R==-127)return 0;return(1-2*(N>>7))*(1+B*Math.pow(2,-23))*Math.pow(2,R)}function h(p,w){var B=k(p,w),C=k(p,w+1),G=k(p,w+2);return(k(p,w+3)<<24)+(G<<16)+(C<<8)+B}function j(p,w){var B=k(p,w);return(k(p,w+1)<<8)+B}function l(p,w){var B=k(p,w);return B>127?B-256:B}function k(p, -w){return p.charCodeAt(w)&255}function o(p){var w,B,C;w=h(a,p);B=h(a,p+M);C=h(a,p+F);p=j(a,p+J);THREE.BinaryLoader.prototype.f3(x,w,B,C,p)}function q(p){var w,B,C,G,N,R;w=h(a,p);B=h(a,p+M);C=h(a,p+F);G=j(a,p+J);N=h(a,p+I);R=h(a,p+K);p=h(a,p+L);THREE.BinaryLoader.prototype.f3n(x,H,w,B,C,G,N,R,p)}function m(p){var w,B,C,G;w=h(a,p);B=h(a,p+P);C=h(a,p+Q);G=h(a,p+E);p=j(a,p+O);THREE.BinaryLoader.prototype.f4(x,w,B,C,G,p)}function t(p){var w,B,C,G,N,R,aa,ba;w=h(a,p);B=h(a,p+P);C=h(a,p+Q);G=h(a,p+E);N=j(a, -p+O);R=h(a,p+U);aa=h(a,p+$);ba=h(a,p+T);p=h(a,p+ca);THREE.BinaryLoader.prototype.f4n(x,H,w,B,C,G,N,R,aa,ba,p)}function A(p){var w,B;w=h(a,p);B=h(a,p+da);p=h(a,p+ea);THREE.BinaryLoader.prototype.uv3(x.faceVertexUvs[0],D[w*2],D[w*2+1],D[B*2],D[B*2+1],D[p*2],D[p*2+1])}function z(p){var w,B,C;w=h(a,p);B=h(a,p+fa);C=h(a,p+ga);p=h(a,p+ha);THREE.BinaryLoader.prototype.uv4(x.faceVertexUvs[0],D[w*2],D[w*2+1],D[B*2],D[B*2+1],D[C*2],D[C*2+1],D[p*2],D[p*2+1])}var x=this,y=0,n,H=[],D=[],M,F,J,I,K,L,P,Q,E,O,U, -$,T,ca,da,ea,fa,ga,ha,V,W,X,Y,Z,S;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(x,c,f);n={signature:a.substr(y,8),header_bytes:k(a,y+8),vertex_coordinate_bytes:k(a,y+9),normal_coordinate_bytes:k(a,y+10),uv_coordinate_bytes:k(a,y+11),vertex_index_bytes:k(a,y+12),normal_index_bytes:k(a,y+13),uv_index_bytes:k(a,y+14),material_index_bytes:k(a,y+15),nvertices:h(a,y+16),nnormals:h(a,y+16+4),nuvs:h(a,y+16+8),ntri_flat:h(a,y+16+12),ntri_smooth:h(a,y+16+16),ntri_flat_uv:h(a,y+16+20),ntri_smooth_uv:h(a, -y+16+24),nquad_flat:h(a,y+16+28),nquad_smooth:h(a,y+16+32),nquad_flat_uv:h(a,y+16+36),nquad_smooth_uv:h(a,y+16+40)};y+=n.header_bytes;M=n.vertex_index_bytes;F=n.vertex_index_bytes*2;J=n.vertex_index_bytes*3;I=n.vertex_index_bytes*3+n.material_index_bytes;K=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;L=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;P=n.vertex_index_bytes;Q=n.vertex_index_bytes*2;E=n.vertex_index_bytes*3;O=n.vertex_index_bytes*4;U=n.vertex_index_bytes* -4+n.material_index_bytes;$=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;T=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;ca=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;da=n.uv_index_bytes;ea=n.uv_index_bytes*2;fa=n.uv_index_bytes;ga=n.uv_index_bytes*2;ha=n.uv_index_bytes*3;f=n.vertex_index_bytes*3+n.material_index_bytes;S=n.vertex_index_bytes*4+n.material_index_bytes;V=n.ntri_flat*f;W=n.ntri_smooth*(f+n.normal_index_bytes*3);X=n.ntri_flat_uv* -(f+n.uv_index_bytes*3);Y=n.ntri_smooth_uv*(f+n.normal_index_bytes*3+n.uv_index_bytes*3);Z=n.nquad_flat*S;f=n.nquad_smooth*(S+n.normal_index_bytes*4);S=n.nquad_flat_uv*(S+n.uv_index_bytes*4);y+=function(p){for(var w,B,C,G=n.vertex_coordinate_bytes*3,N=p+n.nvertices*G;p=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&&(j=this.size-1);var q=Math.floor(l-h);q<1&&(q=1);l=Math.floor(l+h);l>this.size-1&&(l=this.size-1);var m=Math.floor(k-h);m<1&&(m=1);h=Math.floor(k+h); -h>this.size-1&&(h=this.size-1);for(var t,A,z,x,y,n;o0&&(this.field[z+t]+=x)}}}};this.addPlaneX=function(b,c){var g,f,d,h,j,l=this.size,k=this.yd,o=this.zd,q=this.field,m=l*Math.sqrt(b/c);m>l&&(m=l);for(g=0;g0)for(f=0;fk&&(t=k);for(f=0;f0){j=f*o;for(g=0;gsize&&(dist=size);for(d=0;d0){j=zd*d;for(f=0;f0||(l=this.vertices.push(new THREE.Vertex(new THREE.Vector3(p,h,q)))-1);k.push(l)}g.push(k)}var m,t,y;d=g.length;for(b=0;b0)for(c=0;c1){m=this.vertices[f].position.clone(); +t=this.vertices[j].position.clone();y=this.vertices[k].position.clone();m.normalize();t.normalize();y.normalize();this.faces.push(new THREE.Face3(f,j,k,[new THREE.Vector3(m.x,m.y,m.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(y.x,y.y,y.z)]));this.faceVertexUvs[0].push([l,p,C])}}}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 e=(this.segmentsT+1)*(g-1)+b-1,f=(this.segmentsT+1)*(g-1)+b;this.faces.push(new THREE.Face4(c,d,e,f));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[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][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,e,f){function h(p,q,m,t,y,C){q=m/t*p;m=Math.cos(q);return new THREE.Vector3(y*(2+m)*0.5*Math.cos(p),y*(2+m)*Math.sin(p)*0.5,C*y*Math.sin(q)*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=e||3;this.heightScale=f||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;c=new THREE.Vector3;e=new THREE.Vector3;for(a=0;a>7)-127;A|=(G&127)<<16|B<<8;if(A==0&&R==-127)return 0;return(1-2*(N>>7))*(1+A*Math.pow(2,-23))*Math.pow(2,R)}function h(o,w){var A=l(o,w),B=l(o,w+1),G=l(o,w+2);return(l(o,w+3)<<24)+(G<<16)+(B<<8)+A}function j(o,w){var A=l(o,w);return(l(o,w+1)<<8)+A}function k(o,w){var A=l(o,w);return A>127?A-256:A}function l(o, +w){return o.charCodeAt(w)&255}function p(o){var w,A,B;w=h(a,o);A=h(a,o+M);B=h(a,o+F);o=j(a,o+J);THREE.BinaryLoader.prototype.f3(x,w,A,B,o)}function q(o){var w,A,B,G,N,R;w=h(a,o);A=h(a,o+M);B=h(a,o+F);G=j(a,o+J);N=h(a,o+I);R=h(a,o+K);o=h(a,o+L);THREE.BinaryLoader.prototype.f3n(x,H,w,A,B,G,N,R,o)}function m(o){var w,A,B,G;w=h(a,o);A=h(a,o+P);B=h(a,o+Q);G=h(a,o+E);o=j(a,o+O);THREE.BinaryLoader.prototype.f4(x,w,A,B,G,o)}function t(o){var w,A,B,G,N,R,aa,ba;w=h(a,o);A=h(a,o+P);B=h(a,o+Q);G=h(a,o+E);N=j(a, +o+O);R=h(a,o+U);aa=h(a,o+$);ba=h(a,o+T);o=h(a,o+ca);THREE.BinaryLoader.prototype.f4n(x,H,w,A,B,G,N,R,aa,ba,o)}function y(o){var w,A;w=h(a,o);A=h(a,o+da);o=h(a,o+ea);THREE.BinaryLoader.prototype.uv3(x.faceVertexUvs[0],D[w*2],D[w*2+1],D[A*2],D[A*2+1],D[o*2],D[o*2+1])}function C(o){var w,A,B;w=h(a,o);A=h(a,o+fa);B=h(a,o+ga);o=h(a,o+ha);THREE.BinaryLoader.prototype.uv4(x.faceVertexUvs[0],D[w*2],D[w*2+1],D[A*2],D[A*2+1],D[B*2],D[B*2+1],D[o*2],D[o*2+1])}var x=this,z=0,n,H=[],D=[],M,F,J,I,K,L,P,Q,E,O,U, +$,T,ca,da,ea,fa,ga,ha,V,W,X,Y,Z,S;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(x,c,e);n={signature:a.substr(z,8),header_bytes:l(a,z+8),vertex_coordinate_bytes:l(a,z+9),normal_coordinate_bytes:l(a,z+10),uv_coordinate_bytes:l(a,z+11),vertex_index_bytes:l(a,z+12),normal_index_bytes:l(a,z+13),uv_index_bytes:l(a,z+14),material_index_bytes:l(a,z+15),nvertices:h(a,z+16),nnormals:h(a,z+16+4),nuvs:h(a,z+16+8),ntri_flat:h(a,z+16+12),ntri_smooth:h(a,z+16+16),ntri_flat_uv:h(a,z+16+20),ntri_smooth_uv:h(a, +z+16+24),nquad_flat:h(a,z+16+28),nquad_smooth:h(a,z+16+32),nquad_flat_uv:h(a,z+16+36),nquad_smooth_uv:h(a,z+16+40)};z+=n.header_bytes;M=n.vertex_index_bytes;F=n.vertex_index_bytes*2;J=n.vertex_index_bytes*3;I=n.vertex_index_bytes*3+n.material_index_bytes;K=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;L=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;P=n.vertex_index_bytes;Q=n.vertex_index_bytes*2;E=n.vertex_index_bytes*3;O=n.vertex_index_bytes*4;U=n.vertex_index_bytes* +4+n.material_index_bytes;$=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;T=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;ca=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;da=n.uv_index_bytes;ea=n.uv_index_bytes*2;fa=n.uv_index_bytes;ga=n.uv_index_bytes*2;ha=n.uv_index_bytes*3;e=n.vertex_index_bytes*3+n.material_index_bytes;S=n.vertex_index_bytes*4+n.material_index_bytes;V=n.ntri_flat*e;W=n.ntri_smooth*(e+n.normal_index_bytes*3);X=n.ntri_flat_uv* +(e+n.uv_index_bytes*3);Y=n.ntri_smooth_uv*(e+n.normal_index_bytes*3+n.uv_index_bytes*3);Z=n.nquad_flat*S;e=n.nquad_smooth*(S+n.normal_index_bytes*4);S=n.nquad_flat_uv*(S+n.uv_index_bytes*4);z+=function(o){for(var w,A,B,G=n.vertex_coordinate_bytes*3,N=o+n.nvertices*G;o=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&&(j=this.size-1);var q=Math.floor(k-h);q<1&&(q=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var m=Math.floor(l-h);m<1&&(m=1);h=Math.floor(l+h); +h>this.size-1&&(h=this.size-1);for(var t,y,C,x,z,n;p0&&(this.field[C+t]+=x)}}}};this.addPlaneX=function(b,c){var d,e,f,h,j,k=this.size,l=this.yd,p=this.zd,q=this.field,m=k*Math.sqrt(b/c);m>k&&(m=k);for(d=0;d0)for(e=0;el&&(t=l);for(e=0;e0){j=e*p;for(d=0;dsize&&(dist=size);for(f=0;f0){j=zd*f;for(e=0;e 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 555cb3d4..e8d80cf2 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; }; THREE.Loader.prototype = { - addStatusElement: function ( ) { - + onLoadStart: function () {}, + onLoadProgress: function() {}, + onLoadComplete: 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,20 @@ 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 }; - + // parameters from model file - + if ( m.shading ) { - + if ( m.shading == "Phong" ) mtype = "MeshPhongMaterial"; else if ( m.shading == "Basic" ) mtype = "MeshBasicMaterial"; @@ -135,10 +139,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 +160,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; - } - -}; - + } +}; From 0f3093373d20f42b2ee2bf9c266fbea309f3f351 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Thu, 24 Mar 2011 23:58:46 +0000 Subject: [PATCH 10/10] If I'm not mistaken that would have affected other Loaders. --- build/Three.js | 12 ++++++------ build/custom/ThreeExtras.js | 12 ++++++------ src/extras/io/Loader.js | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/build/Three.js b/build/Three.js index d8735e3c..113032c6 100755 --- a/build/Three.js +++ b/build/Three.js @@ -376,12 +376,12 @@ var Torus=function(a,c,b,d){this.radius=a||100;this.tube=c||40;this.segmentsR=b| var TorusKnot=function(a,c,b,d,f,g,h){function k(x,y,p,z,G,M){y=p/z*x;p=Math.cos(y);return new THREE.Vector3(G*(2+p)*0.5*Math.cos(x),G*(2+p)*Math.sin(x)*0.5,M*G*Math.sin(y)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=d||8;this.p=f||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