From cacdf0216612ede7fb3378f84732ede530821866 Mon Sep 17 00:00:00 2001 From: alteredq Date: Sun, 6 Mar 2011 08:48:13 +0100 Subject: [PATCH] Added API for setting viewport and scissor testing. Made texture filtering example more fancy. --- build/Three.js | 485 +++++++++--------- build/custom/ThreeWebGL.js | 163 +++--- examples/misc_sound.html | 2 +- examples/webgl_materials_texture_filters.html | 138 +++-- src/renderers/WebGLRenderer.js | 41 +- 5 files changed, 462 insertions(+), 367 deletions(-) diff --git a/build/Three.js b/build/Three.js index e6d79f8d..99648da2 100755 --- a/build/Three.js +++ b/build/Three.js @@ -1,6 +1,6 @@ // Three.js r34 - http://github.com/mrdoob/three.js var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)}; -THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,b){var d,e,g,h,j,k;if(b==0)d=e=g=0;else{h=Math.floor(a*6);j=a*6-h;a=b*(1-c);k=b*(1-c*j);c=b*(1-c*(1-j));switch(h){case 1:d=k;e=b;g=a;break;case 2:d=a;e=b;g=c;break;case 3:d=a;e=k;g=b;break;case 4:d=c;e=a;g=b;break;case 5:d=b;e=a;g=k;break;case 6:case 0:d=b;e=c;g=a}}this.r=d;this.g=e;this.b=g;if(this.autoUpdate){this.updateHex(); +THREE.Color.prototype={autoUpdate:!0,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,j,l;if(b==0)d=f=g=0;else{h=Math.floor(a*6);j=a*6-h;a=b*(1-c);l=b*(1-c*j);c=b*(1-c*(1-j));switch(h){case 1:d=l;f=b;g=a;break;case 2:d=a;f=b;g=c;break;case 3:d=a;f=l;g=b;break;case 4:d=c;f=a;g=b;break;case 5:d=b;f=a;g=l;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/ @@ -12,72 +12,72 @@ 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&&F>0&&M+F<1}var b,d,e,g,h,j,k,m,o,z, -u,p=a.geometry,A=p.vertices,D=[];b=0;for(d=p.faces.length;bk?d:k;e=e>m?e:m}a()}; -this.add3Points=function(k,m,o,z,u,p){if(j){j=!1;c=ko?k>u?k:u:o>u?o:u;e=m>z?m>p?m:p:z>p?z:p}else{c=ko?k>u?k>d?k:d:u>d?u:d:o>u?o>d?o:d:u>d?u:d;e=m>z?m>p?m>e?m:e:p>e?p:e:z>p?z>e?z:e:p>e?p:e}a()};this.addRectangle=function(k){if(j){j=!1;c=k.getLeft();b=k.getTop();d=k.getRight();e=k.getBottom()}else{c=ck.getRight()? -d:k.getRight();e=e>k.getBottom()?e:k.getBottom()}a()};this.inflate=function(k){c-=k;b-=k;d+=k;e+=k;a()};this.minSelf=function(k){c=c>k.getLeft()?c:k.getLeft();b=b>k.getTop()?b:k.getTop();d=d=0&&Math.min(e,k.getBottom())-Math.max(b,k.getTop())>=0};this.empty=function(){j=!0;e=d=b=c=0;a()};this.isEmpty=function(){return j}}; +THREE.Ray.prototype={intersectScene:function(a){var c,b,d=a.objects,f=[];a=0;for(c=d.length;a0&&E>0&&L+E<1}var b,d,f,g,h,j,l,n,p,w, +t,q=a.geometry,x=q.vertices,B=[];b=0;for(d=q.faces.length;bl?d:l;f=f>n?f:n}a()}; +this.add3Points=function(l,n,p,w,t,q){if(j){j=!1;c=lp?l>t?l:t:p>t?p:t;f=n>w?n>q?n:q:w>q?w:q}else{c=lp?l>t?l>d?l:d:t>d?t:d:p>t?p>d?p:d:t>d?t:d;f=n>w?n>q?n>f?n:f:q>f?q:f:w>q?w>f?w:f:q>f?q:f}a()};this.addRectangle=function(l){if(j){j=!1;c=l.getLeft();b=l.getTop();d=l.getRight();f=l.getBottom()}else{c=cl.getRight()? +d:l.getRight();f=f>l.getBottom()?f:l.getBottom()}a()};this.inflate=function(l){c-=l;b-=l;d+=l;f+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();b=b>l.getTop()?b:l.getTop();d=d=0&&Math.min(f,l.getBottom())-Math.max(b,l.getTop())>=0};this.empty=function(){j=!0;f=d=b=c=0;a()};this.isEmpty=function(){return j}}; THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}}; -THREE.Matrix4=function(a,c,b,d,e,g,h,j,k,m,o,z,u,p,A,D){this.set(a||1,c||0,b||0,d||0,e||0,g||1,h||0,j||0,k||0,m||0,o||1,z||0,u||0,p||0,A||0,D||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(a,c,b,d,e,g,h,j,k,m,o,z,u,p,A,D){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=j;this.n31=k;this.n32=m;this.n33=o;this.n34=z;this.n41=u;this.n42=p;this.n43=A;this.n44=D;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();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}, -multiplyVector3OnlyZ:function(a){var c=a.x,b=a.y;a=a.z;return(this.n31*c+this.n32*b+this.n33*a+this.n34)*(1/(this.n41*c+this.n42*b+this.n43*a+this.n44))},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},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+ -this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,j=a.n22,k=a.n23,m=a.n24,o=a.n31,z=a.n32,u=a.n33,p=a.n34,A=a.n41,D=a.n42,F=a.n43,w=a.n44,H=c.n11,x=c.n12,Q=c.n13,M=c.n14,X=c.n21,L=c.n22,f=c.n23,T=c.n24,R=c.n31,$=c.n32,ca=c.n33,J=c.n34;this.n11=b*H+d*X+e*R;this.n12=b*x+d*L+e*$;this.n13=b* -Q+d*f+e*ca;this.n14=b*M+d*T+e*J+g;this.n21=h*H+j*X+k*R;this.n22=h*x+j*L+k*$;this.n23=h*Q+j*f+k*ca;this.n24=h*M+j*T+k*J+m;this.n31=o*H+z*X+u*R;this.n32=o*x+z*L+u*$;this.n33=o*Q+z*f+u*ca;this.n34=o*M+z*T+u*J+p;this.n41=A*H+D*X+F*R;this.n42=A*x+D*L+F*$;this.n43=A*Q+D*f+F*ca;this.n44=A*M+D*T+F*J+w;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]= -this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,c=this.n12,b=this.n13,d=this.n14,e=this.n21,g=this.n22,h=this.n23,j=this.n24, -k=this.n31,m=this.n32,o=this.n33,z=this.n34,u=this.n41,p=this.n42,A=this.n43,D=this.n44;return d*h*m*u-b*j*m*u-d*g*o*u+c*j*o*u+b*g*z*u-c*h*z*u-d*h*k*p+b*j*k*p+d*e*o*p-a*j*o*p-b*e*z*p+a*h*z*p+d*g*k*A-c*j*k*A-d*e*m*A+a*j*m*A+c*e*z*A-a*g*z*A-b*g*k*D+c*h*k*D+b*e*m*D-a*h*m*D-c*e*o*D+a*g*o*D},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24; -this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22; -this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44; -return a},flattenToArrayOffset:function(a,c){a[c]=this.n11;a[c+1]=this.n21;a[c+2]=this.n31;a[c+3]=this.n41;a[c+4]=this.n12;a[c+5]=this.n22;a[c+6]=this.n32;a[c+7]=this.n42;a[c+8]=this.n13;a[c+9]=this.n23;a[c+10]=this.n33;a[c+11]=this.n43;a[c+12]=this.n14;a[c+13]=this.n24;a[c+14]=this.n34;a[c+15]=this.n44;return a},setTranslation:function(a,c,b){this.set(1,0,0,a,0,1,0,c,0,0,1,b,0,0,0,1);return this},setScale:function(a,c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0,0,1);return this},setRotationX:function(a){var c= -Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotationY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotationZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,c){var b=Math.cos(c),d=Math.sin(c),e=1-b,g=a.x,h=a.y,j=a.z,k=e*g,m=e*h;this.set(k*g+b,k*h-d*j,k*j+d*h,0,k*h+d*j,m*h+b,m*j-d*g,0,k*j-d*h,m*j+d*g,e*j*j+b,0,0,0,0,1);return this}, -setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var c=a.x,b=a.y,d=a.z;a=Math.cos(c);c=Math.sin(c);var e=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var h=a*b,j=c*b;this.n11=e*g;this.n12=-e*d;this.n13=b;this.n21=j*g+a*d;this.n22=-j*d+a*g;this.n23=-c*e;this.n31=-h*g+c*d;this.n32=h*d+c*g;this.n33=a*e;return this},setRotationFromQuaternion:function(a){var c=a.x,b=a.y,d=a.z,e=a.w,g=c+c,h=b+b,j=d+d;a=c*g;var k=c*h;c*=j;var m=b*h; -b*=j;d*=j;g*=e;h*=e;e*=j;this.n11=1-(m+d);this.n12=k-e;this.n13=c+h;this.n21=k+e;this.n22=1-(a+d);this.n23=b-g;this.n31=c-h;this.n32=b+g;this.n33=1-(a+m);return this},scale:function(a){var c=a.x,b=a.y;a=a.z;this.n11*=c;this.n12*=b;this.n13*=a;this.n21*=c;this.n22*=b;this.n23*=a;this.n31*=c;this.n32*=b;this.n33*=a;this.n41*=c;this.n42*=b;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,c){var b=1/c.x,d=1/c.y,e=1/c.z;this.n11= -a.n11*b;this.n21=a.n21*b;this.n31=a.n31*b;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}}; -THREE.Matrix4.makeInvert=function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,j=a.n22,k=a.n23,m=a.n24,o=a.n31,z=a.n32,u=a.n33,p=a.n34,A=a.n41,D=a.n42,F=a.n43,w=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=k*p*D-m*u*D+m*z*F-j*p*F-k*z*w+j*u*w;c.n12=g*u*D-e*p*D-g*z*F+d*p*F+e*z*w-d*u*w;c.n13=e*m*D-g*k*D+g*j*F-d*m*F-e*j*w+d*k*w;c.n14=g*k*z-e*m*z-g*j*u+d*m*u+e*j*p-d*k*p;c.n21=m*u*A-k*p*A-m*o*F+h*p*F+k*o*w-h*u*w;c.n22=e*p*A-g*u*A+g*o*F-b*p*F-e*o*w+b*u*w;c.n23=g*k*A-e*m*A-g*h*F+b*m*F+e*h*w-b*k*w; -c.n24=e*m*o-g*k*o+g*h*u-b*m*u-e*h*p+b*k*p;c.n31=j*p*A-m*z*A+m*o*D-h*p*D-j*o*w+h*z*w;c.n32=g*z*A-d*p*A-g*o*D+b*p*D+d*o*w-b*z*w;c.n33=e*m*A-g*j*A+g*h*D-b*m*D-d*h*w+b*j*w;c.n34=g*j*o-d*m*o-g*h*z+b*m*z+d*h*p-b*j*p;c.n41=k*z*A-j*u*A-k*o*D+h*u*D+j*o*F-h*z*F;c.n42=d*u*A-e*z*A+e*o*D-b*u*D-d*o*F+b*z*F;c.n43=e*j*A-d*k*A-e*h*D+b*k*D+d*h*F-b*j*F;c.n44=d*k*o-e*j*o+e*h*z-b*k*z-d*h*u+b*j*u;c.multiplyScalar(1/a.determinant());return c}; -THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,b=c.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,o=-a.n23*a.n11+a.n21*a.n13,z=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*d;b[1]=a*e;b[2]=a*g;b[3]=a*h;b[4]=a*j;b[5]=a*k;b[6]=a*m;b[7]=a*o;b[8]=a*z;return c}; -THREE.Matrix4.makeFrustum=function(a,c,b,d,e,g){var h;h=new THREE.Matrix4;h.n11=2*e/(c-a);h.n12=0;h.n13=(c+a)/(c-a);h.n14=0;h.n21=0;h.n22=2*e/(d-b);h.n23=(d+b)/(d-b);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+e)/(g-e);h.n34=-2*g*e/(g-e);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,b,d){var e;a=b*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*c,a*c,e,a,b,d)}; -THREE.Matrix4.makeOrtho=function(a,c,b,d,e,g){var h,j,k,m;h=new THREE.Matrix4;j=c-a;k=b-d;m=g-e;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-((c+a)/j);h.n21=0;h.n22=2/k;h.n23=0;h.n24=-((b+d)/k);h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-((g+e)/m);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; +THREE.Matrix4=function(a,c,b,d,f,g,h,j,l,n,p,w,t,q,x,B){this.set(a||1,c||0,b||0,d||0,f||0,g||1,h||0,j||0,l||0,n||0,p||1,w||0,t||0,q||0,x||0,B||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(a,c,b,d,f,g,h,j,l,n,p,w,t,q,x,B){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=f;this.n22=g;this.n23=h;this.n24=j;this.n31=l;this.n32=n;this.n33=p;this.n34=w;this.n41=t;this.n42=q;this.n43=x;this.n44=B;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();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}, +multiplyVector3OnlyZ:function(a){var c=a.x,b=a.y;a=a.z;return(this.n31*c+this.n32*b+this.n33*a+this.n34)*(1/(this.n41*c+this.n42*b+this.n43*a+this.n44))},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},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,j=a.n22,l=a.n23,n=a.n24,p=a.n31,w=a.n32,t=a.n33,q=a.n34,x=a.n41,B=a.n42,E=a.n43,u=a.n44,F=c.n11,v=c.n12,N=c.n13,L=c.n14,Y=c.n21,M=c.n22,e=c.n23,V=c.n24,S=c.n31,ba=c.n32,ea=c.n33,J=c.n34;this.n11=b*F+d*Y+f*S;this.n12=b*v+d*M+f*ba;this.n13= +b*N+d*e+f*ea;this.n14=b*L+d*V+f*J+g;this.n21=h*F+j*Y+l*S;this.n22=h*v+j*M+l*ba;this.n23=h*N+j*e+l*ea;this.n24=h*L+j*V+l*J+n;this.n31=p*F+w*Y+t*S;this.n32=p*v+w*M+t*ba;this.n33=p*N+w*e+t*ea;this.n34=p*L+w*V+t*J+q;this.n41=x*F+B*Y+E*S;this.n42=x*v+B*M+E*ba;this.n43=x*N+B*e+E*ea;this.n44=x*L+B*V+E*J+u;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,j= +this.n24,l=this.n31,n=this.n32,p=this.n33,w=this.n34,t=this.n41,q=this.n42,x=this.n43,B=this.n44;return d*h*n*t-b*j*n*t-d*g*p*t+c*j*p*t+b*g*w*t-c*h*w*t-d*h*l*q+b*j*l*q+d*f*p*q-a*j*p*q-b*f*w*q+a*h*w*q+d*g*l*x-c*j*l*x-d*f*n*x+a*j*n*x+c*f*w*x-a*g*w*x-b*g*l*B+c*h*l*B+b*f*n*B-a*h*n*B-c*f*p*B+a*g*p*B},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,j=a.z,l=f*g,n=f*h;this.set(l*g+b,l*h-d*j,l*j+d*h,0,l*h+d*j,n*h+b,n*j-d*g,0,l*j-d*h,n*j+d*g,f*j*j+b,0,0,0,0,1);return this}, +setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var c=a.x,b=a.y,d=a.z;a=Math.cos(c);c=Math.sin(c);var f=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var h=a*b,j=c*b;this.n11=f*g;this.n12=-f*d;this.n13=b;this.n21=j*g+a*d;this.n22=-j*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,j=d+d;a=c*g;var l=c*h;c*=j;var n=b*h; +b*=j;d*=j;g*=f;h*=f;f*=j;this.n11=1-(n+d);this.n12=l-f;this.n13=c+h;this.n21=l+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,j=a.n22,l=a.n23,n=a.n24,p=a.n31,w=a.n32,t=a.n33,q=a.n34,x=a.n41,B=a.n42,E=a.n43,u=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=l*q*B-n*t*B+n*w*E-j*q*E-l*w*u+j*t*u;c.n12=g*t*B-f*q*B-g*w*E+d*q*E+f*w*u-d*t*u;c.n13=f*n*B-g*l*B+g*j*E-d*n*E-f*j*u+d*l*u;c.n14=g*l*w-f*n*w-g*j*t+d*n*t+f*j*q-d*l*q;c.n21=n*t*x-l*q*x-n*p*E+h*q*E+l*p*u-h*t*u;c.n22=f*q*x-g*t*x+g*p*E-b*q*E-f*p*u+b*t*u;c.n23=g*l*x-f*n*x-g*h*E+b*n*E+f*h*u-b*l*u; +c.n24=f*n*p-g*l*p+g*h*t-b*n*t-f*h*q+b*l*q;c.n31=j*q*x-n*w*x+n*p*B-h*q*B-j*p*u+h*w*u;c.n32=g*w*x-d*q*x-g*p*B+b*q*B+d*p*u-b*w*u;c.n33=f*n*x-g*j*x+g*h*B-b*n*B-d*h*u+b*j*u;c.n34=g*j*p-d*n*p-g*h*w+b*n*w+d*h*q-b*j*q;c.n41=l*w*x-j*t*x-l*p*B+h*t*B+j*p*E-h*w*E;c.n42=d*t*x-f*w*x+f*p*B-b*t*B-d*p*E+b*w*E;c.n43=f*j*x-d*l*x-f*h*B+b*l*B+d*h*E-b*j*E;c.n44=d*l*p-f*j*p+f*h*w-b*l*w-d*h*t+b*j*t;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,j=a.n33*a.n11-a.n31*a.n13,l=-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,w=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*j;b[5]=a*l;b[6]=a*n;b[7]=a*p;b[8]=a*w;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,j,l,n;h=new THREE.Matrix4;j=c-a;l=b-d;n=g-f;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-((c+a)/j);h.n21=0;h.n22=2/l;h.n23=0;h.n24=-((b+d)/l);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}; THREE.Object3D.prototype={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))}return!0},update:function(a,c,b){if(this.visible){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a, this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;c=!0}a=0;for(var d=this.children.length;a=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(e),h=Math.sqrt(1-e*e);if(Math.abs(h)<0.0010){b.w=0.5*(a.w+c.w);b.x=0.5*(a.x+c.x);b.y=0.5*(a.y+c.y);b.z=0.5*(a.z+c.z);return b}e=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*e+c.w*d;b.x=a.x*e+c.x*d;b.y=a.y*e+c.y*d;b.z=a.z*e+c.z*d;return b}; +THREE.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,j=d*f;this.w=h*g-j*b;this.x=h*b+j*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,j=a.z;a=a.w;this.x=c*a+f*g+b*j-d*h;this.y=b*a+f*h+d*g-c*j;this.z=d*a+f*j+c*h-b*g;this.w=f*a-c*g-b*h-d*j;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,j=this.z,l=this.w,n=l*b+h*f-j*d,p=l*d+j*b-g*f,w=l*f+g*d-h*b;b=-g*b-h*d-j*f;c.x=n*l+b*-g+p*-j-w*-h;c.y=p*l+b*-h+w*-g-n*-j;c.z=w*l+b*-j+n*-h-p*-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,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0}; -THREE.Face3=function(a,c,b,d,e){this.a=a;this.b=c;this.c=b;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=e instanceof Array?e:[e]};THREE.Face4=function(a,c,b,d,e,g){this.a=a;this.b=c;this.c=b;this.d=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]}; +THREE.Face3=function(a,c,b,d,f){this.a=a;this.b=c;this.c=b;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=f instanceof Array?f:[f]};THREE.Face4=function(a,c,b,d,f,g){this.a=a;this.b=c;this.c=b;this.d=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=g instanceof Array?g:[g]}; THREE.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.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];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], +c;a++){b=this.faces[a];if(b instanceof THREE.Face3){b.vertexNormals[0].copy(d[b.a]);b.vertexNormals[1].copy(d[b.b]);b.vertexNormals[2].copy(d[b.c])}else if(b instanceof THREE.Face4){b.vertexNormals[0].copy(d[b.a]);b.vertexNormals[1].copy(d[b.b]);b.vertexNormals[2].copy(d[b.c]);b.vertexNormals[3].copy(d[b.d])}}},computeTangents:function(){function a(J,ca,wa,da,ta,ha,fa){g=J.vertices[ca].position;h=J.vertices[wa].position;j=J.vertices[da].position;l=f[ta];n=f[ha];p=f[fa];w=h.x-g.x;t=j.x-g.x;q=h.y-g.y; +x=j.y-g.y;B=h.z-g.z;E=j.z-g.z;u=n.u-l.u;F=p.u-l.u;v=n.v-l.v;N=p.v-l.v;L=1/(u*N-F*v);e.set((N*w-v*t)*L,(N*q-v*x)*L,(N*B-v*E)*L);V.set((u*t-F*w)*L,(u*x-F*q)*L,(u*E-F*B)*L);Y[ca].addSelf(e);Y[wa].addSelf(e);Y[da].addSelf(e);M[ca].addSelf(V);M[wa].addSelf(V);M[da].addSelf(V)}var c,b,d,f,g,h,j,l,n,p,w,t,q,x,B,E,u,F,v,N,L,Y=[],M=[],e=new THREE.Vector3,V=new THREE.Vector3,S=new THREE.Vector3,ba=new THREE.Vector3,ea=new THREE.Vector3;c=0;for(b=this.vertices.length;c0){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.z this.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;cu.length-2?e:e+1;c[3]=e>u.length-3?e:e+2;k=u[c[0]];m=u[c[1]];o=u[c[2]];z=u[c[3]];h=g*g;j=g*h;b.x=a(k.x,m.x,o.x,z.x,g,h,j);b.y=a(k.y,m.y,o.y,z.y,g,h,j);b.z=a(k.z,m.z,o.z,z.z,g,h,j);return b}}; -THREE.AnimationHandler=function(){var a=[],c={},b={};b.update=function(e){for(var g=0;gt.length-2?f:f+1;c[3]=f>t.length-3?f:f+2;l=t[c[0]];n=t[c[1]];p=t[c[2]];w=t[c[3]];h=g*g;j=g*h;b.x=a(l.x,n.x,p.x,w.x,g,h,j);b.y=a(l.y,n.y,p.y,w.y,g,h,j);b.z=a(l.z,n.z,p.z,w.z,g,h,j);return b}}; +THREE.AnimationHandler=function(){var a=[],c={},b={};b.update=function(f){for(var g=0;g1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d);d=d<0?0:1}if(b==="pos")if(this.interpolationType===THREE.AnimationHandler.LINEAR){b=a.position;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{var F=[];F[0]=this.getPrevKeyWith(b,p,h.index-1)[b];F[1]=e;F[2]=g;F[3]=this.getNextKeyWith(b,p,j.index+1)[b];d=d*0.33+0.33;d=this.interpolateCatmullRom(F, -d);a.position.x=d[0];a.position.y=d[1];a.position.z=d[2]}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&&o[0][m]===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]];j=a[b[1]];k=a[b[2]];m=a[b[3]];b=e*e;h=e*b;d[0]=this.interpolate(g[0],j[0],k[0],m[0],e,b,h);d[1]=this.interpolate(g[1],j[1],k[1],m[1],e,b,h);d[2]=this.interpolate(g[2],j[2],k[2],m[2],e,b,h);return d}; -THREE.Animation.prototype.interpolate=function(a,c,b,d,e,g,h){a=(b-a)*0.5;d=(d-c)*0.5;return(2*(c-b)+a+d)*h+(-3*(c-b)-2*a-d)*g+a*e+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;for(b%=d.length;b1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d);d=d<0?0:1}if(b==="pos")if(this.interpolationType===THREE.AnimationHandler.LINEAR){b=a.position;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{var E=[];E[0]=this.getPrevKeyWith(b,q,h.index-1)[b];E[1]=f;E[2]=g;E[3]=this.getNextKeyWith(b,q,j.index+1)[b];d=d*0.33+0.33;d=this.interpolateCatmullRom(E, +d);a.position.x=d[0];a.position.y=d[1];a.position.z=d[2]}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&&p[0][n]===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]];j=a[b[1]];l=a[b[2]];n=a[b[3]];b=f*f;h=f*b;d[0]=this.interpolate(g[0],j[0],l[0],n[0],f,b,h);d[1]=this.interpolate(g[1],j[1],l[1],n[1],f,b,h);d[2]=this.interpolate(g[2],j[2],l[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;for(b%=d.length;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();var g=new THREE.Vector3;this.translateX=function(h,j){g.sub(this.target.position,this.position).normalize().multiplyScalar(h);g.crossSelf(this.up);if(j)g.y=0;this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ= +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();var g=new THREE.Vector3;this.translateX=function(h,j){g.sub(this.target.position,this.position).normalize().multiplyScalar(h);g.crossSelf(this.up);if(j)g.y=0;this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ= function(h,j){g.sub(this.target.position,this.position).normalize().multiplyScalar(h);if(j)g.y=0;this.position.subSelf(g);this.target.position.subSelf(g)}};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)}; 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;a=0&&ca>=0&&J>=0&&aa>=0)return!0;else if($<0&&ca<0||J<0&&aa<0)return!1;else{if($<0)T=Math.max(T,$/($-ca));else ca<0&&(R=Math.min(R,$/($-ca)));if(J<0)T=Math.max(T,J/(J-aa));else aa<0&&(R=Math.min(R,J/(J-aa)));if(R$&&Y.z0&&F.z<1){u=A[p]=A[p]||new THREE.RenderableParticle;u.x=F.x/F.w;u.y=F.y/F.w;u.z=F.z;u.rotation=da.rotation.z;u.scale.x=da.scale.x*Math.abs(u.x-(F.x+f.projectionMatrix.n11)/ -(F.w+f.projectionMatrix.n14));u.scale.y=da.scale.y*Math.abs(u.y-(F.y+f.projectionMatrix.n22)/(F.w+f.projectionMatrix.n24));u.materials=da.materials;R.push(u);p++}}}}T&&R.sort(a);return R};this.unprojectVector=function(L,f){var T=f.matrixWorld.clone();T.multiplySelf(THREE.Matrix4.makeInvert(f.projectionMatrix));T.multiplyVector3(L);return L}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,e,g;this.domElement=document.createElement("div");this.setSize=function(h,j){b=h;d=j;e=b/2;g=d/2};this.render=function(h,j){var k,m,o,z,u,p,A,D;a=c.projectScene(h,j);k=0;for(m=a.length;k0){P.r+=Aa.r*qa;P.g+=Aa.g*qa;P.b+=Aa.b*qa}}else if(qa instanceof THREE.PointLight){B.sub(qa.position,fa);B.normalize();qa=ha.dot(B)*Ga;if(qa>0){P.r+=Aa.r*qa;P.g+=Aa.g*qa;P.b+=Aa.b*qa}}}}function Ja(O,fa,ha){if(ha.opacity!= -0){a(ha.opacity);c(ha.blending);var P,ba,qa,Aa,Ga,Ia;if(ha instanceof THREE.ParticleBasicMaterial){if(ha.map){Aa=ha.map.image;Ga=Aa.width>>1;Ia=Aa.height>>1;ba=fa.scale.x*j;qa=fa.scale.y*k;ha=ba*Ga;P=qa*Ia;v.set(O.x-ha,O.y-P,O.x+ha,O.y+P);if(l.instersects(v)){m.save();m.translate(O.x,O.y);m.rotate(-fa.rotation);m.scale(ba,-qa);m.translate(-Ga,-Ia);m.drawImage(Aa,0,0);m.restore()}}}else if(ha instanceof THREE.ParticleCircleMaterial){if(n){q.r=K.r+G.r+t.r;q.g=K.g+G.g+t.g;q.b=K.b+G.b+t.b;R.r=ha.color.r* -q.r;R.g=ha.color.g*q.g;R.b=ha.color.b*q.b;R.updateStyleString()}else R.__styleString=ha.color.__styleString;ha=fa.scale.x*j;P=fa.scale.y*k;v.set(O.x-ha,O.y-P,O.x+ha,O.y+P);if(l.instersects(v)){ba=R.__styleString;if(D!=ba)m.fillStyle=D=ba;m.save();m.translate(O.x,O.y);m.rotate(-fa.rotation);m.scale(ha,P);m.beginPath();m.arc(0,0,1,0,C,!0);m.closePath();m.fill();m.restore()}}}}function U(O,fa,ha,P){if(P.opacity!=0){a(P.opacity);c(P.blending);m.beginPath();m.moveTo(O.positionScreen.x,O.positionScreen.y); -m.lineTo(fa.positionScreen.x,fa.positionScreen.y);m.closePath();if(P instanceof THREE.LineBasicMaterial){R.__styleString=P.color.__styleString;O=P.linewidth;if(F!=O)m.lineWidth=F=O;O=R.__styleString;if(A!=O)m.strokeStyle=A=O;m.stroke();v.inflate(P.linewidth*2)}}}function V(O,fa,ha,P,ba,qa){if(ba.opacity!=0){a(ba.opacity);c(ba.blending);Q=O.positionScreen.x;M=O.positionScreen.y;X=fa.positionScreen.x;L=fa.positionScreen.y;f=ha.positionScreen.x;T=ha.positionScreen.y;m.beginPath();m.moveTo(Q,M);m.lineTo(X, -L);m.lineTo(f,T);m.lineTo(Q,M);m.closePath();if(ba instanceof THREE.MeshBasicMaterial)if(ba.map)ba.map.mapping instanceof THREE.UVMapping&&Fa(Q,M,X,L,f,T,ba.map.image,P.uvs[0].u,P.uvs[0].v,P.uvs[1].u,P.uvs[1].v,P.uvs[2].u,P.uvs[2].v);else if(ba.envMap){if(ba.envMap.mapping instanceof THREE.SphericalReflectionMapping){O=N.matrixWorldInverse;B.copy(P.vertexNormalsWorld[0]);ia=(B.x*O.n11+B.y*O.n12+B.z*O.n13)*0.5+0.5;da=-(B.x*O.n21+B.y*O.n22+B.z*O.n23)*0.5+0.5;B.copy(P.vertexNormalsWorld[1]);pa=(B.x* -O.n11+B.y*O.n12+B.z*O.n13)*0.5+0.5;ya=-(B.x*O.n21+B.y*O.n22+B.z*O.n23)*0.5+0.5;B.copy(P.vertexNormalsWorld[2]);ea=(B.x*O.n11+B.y*O.n12+B.z*O.n13)*0.5+0.5;Z=-(B.x*O.n21+B.y*O.n22+B.z*O.n23)*0.5+0.5;Fa(Q,M,X,L,f,T,ba.envMap.image,ia,da,pa,ya,ea,Z)}}else ba.wireframe?W(ba.color.__styleString,ba.wireframeLinewidth):sa(ba.color.__styleString);else if(ba instanceof THREE.MeshLambertMaterial){if(ba.map&&!ba.wireframe){ba.map.mapping instanceof THREE.UVMapping&&Fa(Q,M,X,L,f,T,ba.map.image,P.uvs[0].u,P.uvs[0].v, -P.uvs[1].u,P.uvs[1].v,P.uvs[2].u,P.uvs[2].v);c(THREE.SubtractiveBlending)}if(n)if(!ba.wireframe&&ba.shading==THREE.SmoothShading&&P.vertexNormalsWorld.length==3){$.r=ca.r=J.r=K.r;$.g=ca.g=J.g=K.g;$.b=ca.b=J.b=K.b;Ea(qa,P.v1.positionWorld,P.vertexNormalsWorld[0],$);Ea(qa,P.v2.positionWorld,P.vertexNormalsWorld[1],ca);Ea(qa,P.v3.positionWorld,P.vertexNormalsWorld[2],J);aa.r=(ca.r+J.r)*0.5;aa.g=(ca.g+J.g)*0.5;aa.b=(ca.b+J.b)*0.5;oa=Ca($,ca,J,aa);Fa(Q,M,X,L,f,T,oa,0,0,1,0,0,1)}else{q.r=K.r;q.g=K.g;q.b= -K.b;Ea(qa,P.centroidWorld,P.normalWorld,q);R.r=ba.color.r*q.r;R.g=ba.color.g*q.g;R.b=ba.color.b*q.b;R.updateStyleString();ba.wireframe?W(R.__styleString,ba.wireframeLinewidth):sa(R.__styleString)}else ba.wireframe?W(ba.color.__styleString,ba.wireframeLinewidth):sa(ba.color.__styleString)}else if(ba instanceof THREE.MeshDepthMaterial){ua=N.near;Y=N.far;$.r=$.g=$.b=1-I(O.positionScreen.z,ua,Y);ca.r=ca.g=ca.b=1-I(fa.positionScreen.z,ua,Y);J.r=J.g=J.b=1-I(ha.positionScreen.z,ua,Y);aa.r=(ca.r+J.r)*0.5; -aa.g=(ca.g+J.g)*0.5;aa.b=(ca.b+J.b)*0.5;oa=Ca($,ca,J,aa);Fa(Q,M,X,L,f,T,oa,0,0,1,0,0,1)}else if(ba instanceof THREE.MeshNormalMaterial){R.r=Da(P.normalWorld.x);R.g=Da(P.normalWorld.y);R.b=Da(P.normalWorld.z);R.updateStyleString();ba.wireframe?W(R.__styleString,ba.wireframeLinewidth):sa(R.__styleString)}}}function W(O,fa){if(A!=O)m.strokeStyle=A=O;if(F!=fa)m.lineWidth=F=fa;m.stroke();v.inflate(fa*2)}function sa(O){if(D!=O)m.fillStyle=D=O;m.fill()}function Fa(O,fa,ha,P,ba,qa,Aa,Ga,Ia,La,Ba,Ma,Ta){var Na, -Oa;Na=Aa.width-1;Oa=Aa.height-1;Ga*=Na;Ia*=Oa;La*=Na;Ba*=Oa;Ma*=Na;Ta*=Oa;ha-=O;P-=fa;ba-=O;qa-=fa;La-=Ga;Ba-=Ia;Ma-=Ga;Ta-=Ia;Na=La*Ta-Ma*Ba;if(Na!=0){Oa=1/Na;Na=(Ta*ha-Ba*ba)*Oa;Ba=(Ta*P-Ba*qa)*Oa;ha=(La*ba-Ma*ha)*Oa;P=(La*qa-Ma*P)*Oa;O=O-Na*Ga-ha*Ia;fa=fa-Ba*Ga-P*Ia;m.save();m.transform(Na,Ba,ha,P,O,fa);m.clip();m.drawImage(Aa,0,0);m.restore()}}function Ca(O,fa,ha,P){var ba=~~(O.r*255),qa=~~(O.g*255);O=~~(O.b*255);var Aa=~~(fa.r*255),Ga=~~(fa.g*255);fa=~~(fa.b*255);var Ia=~~(ha.r*255),La=~~(ha.g* -255);ha=~~(ha.b*255);var Ba=~~(P.r*255),Ma=~~(P.g*255);P=~~(P.b*255);ga[0]=ba<0?0:ba>255?255:ba;ga[1]=qa<0?0:qa>255?255:qa;ga[2]=O<0?0:O>255?255:O;ga[4]=Aa<0?0:Aa>255?255:Aa;ga[5]=Ga<0?0:Ga>255?255:Ga;ga[6]=fa<0?0:fa>255?255:fa;ga[8]=Ia<0?0:Ia>255?255:Ia;ga[9]=La<0?0:La>255?255:La;ga[10]=ha<0?0:ha>255?255:ha;ga[12]=Ba<0?0:Ba>255?255:Ba;ga[13]=Ma<0?0:Ma>255?255:Ma;ga[14]=P<0?0:P>255?255:P;S.putImageData(na,0,0);ma.drawImage(E,0,0);return ja}function I(O,fa,ha){O=(O-fa)/(ha-fa);return O*O*(3-2*O)}function Da(O){O= -(O+1)*0.5;return O<0?0:O>1?1:O}function Ra(O,fa){var ha=fa.x-O.x,P=fa.y-O.y,ba=1/Math.sqrt(ha*ha+P*P);ha*=ba;P*=ba;fa.x+=ha;fa.y+=P;O.x-=ha;O.y-=P}var Pa,Ka,ka,wa,ta,xa,za,va;this.autoClear?this.clear():m.setTransform(1,0,0,-1,j,k);b=d.projectScene(ra,N,this.sortElements);(n=ra.lights.length>0)&&Ha(ra);Pa=0;for(Ka=b.length;Pa0){pa.r+=Z.color.r*l;pa.g+=Z.color.g*l;pa.b+=Z.color.b*l}}else if(Z instanceof THREE.PointLight){T.sub(Z.position,da.centroidWorld);T.normalize();l=da.normalWorld.dot(T)*Z.intensity;if(l>0){pa.r+=Z.color.r*l;pa.g+=Z.color.g*l;pa.b+=Z.color.b*l}}}}function c(ia,da,pa,ya,ea,Z){J=d(aa++);J.setAttribute("d", -"M "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+da.positionScreen.x+" "+da.positionScreen.y+" L "+pa.positionScreen.x+","+pa.positionScreen.y+"z");if(ea instanceof THREE.MeshBasicMaterial)x.__styleString=ea.color.__styleString;else if(ea instanceof THREE.MeshLambertMaterial)if(H){Q.r=M.r;Q.g=M.g;Q.b=M.b;a(Z,ya,Q);x.r=ea.color.r*Q.r;x.g=ea.color.g*Q.g;x.b=ea.color.b*Q.b;x.updateStyleString()}else x.__styleString=ea.color.__styleString;else if(ea instanceof THREE.MeshDepthMaterial){f=1-ea.__2near/ -(ea.__farPlusNear-ya.z*ea.__farMinusNear);x.setRGB(f,f,f)}else ea instanceof THREE.MeshNormalMaterial&&x.setRGB(e(ya.normalWorld.x),e(ya.normalWorld.y),e(ya.normalWorld.z));ea.wireframe?J.setAttribute("style","fill: none; stroke: "+x.__styleString+"; stroke-width: "+ea.wireframeLinewidth+"; stroke-opacity: "+ea.opacity+"; stroke-linecap: "+ea.wireframeLinecap+"; stroke-linejoin: "+ea.wireframeLinejoin):J.setAttribute("style","fill: "+x.__styleString+"; fill-opacity: "+ea.opacity);j.appendChild(J)} -function b(ia,da,pa,ya,ea,Z,l){J=d(aa++);J.setAttribute("d","M "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+da.positionScreen.x+" "+da.positionScreen.y+" L "+pa.positionScreen.x+","+pa.positionScreen.y+" L "+ya.positionScreen.x+","+ya.positionScreen.y+"z");if(Z instanceof THREE.MeshBasicMaterial)x.__styleString=Z.color.__styleString;else if(Z instanceof THREE.MeshLambertMaterial)if(H){Q.r=M.r;Q.g=M.g;Q.b=M.b;a(l,ea,Q);x.r=Z.color.r*Q.r;x.g=Z.color.g*Q.g;x.b=Z.color.b*Q.b;x.updateStyleString()}else x.__styleString= -Z.color.__styleString;else if(Z instanceof THREE.MeshDepthMaterial){f=1-Z.__2near/(Z.__farPlusNear-ea.z*Z.__farMinusNear);x.setRGB(f,f,f)}else Z instanceof THREE.MeshNormalMaterial&&x.setRGB(e(ea.normalWorld.x),e(ea.normalWorld.y),e(ea.normalWorld.z));Z.wireframe?J.setAttribute("style","fill: none; stroke: "+x.__styleString+"; stroke-width: "+Z.wireframeLinewidth+"; stroke-opacity: "+Z.opacity+"; stroke-linecap: "+Z.wireframeLinecap+"; stroke-linejoin: "+Z.wireframeLinejoin):J.setAttribute("style", -"fill: "+x.__styleString+"; fill-opacity: "+Z.opacity);j.appendChild(J)}function d(ia){if(R[ia]==null){R[ia]=document.createElementNS("http://www.w3.org/2000/svg","path");oa==0&&R[ia].setAttribute("shape-rendering","crispEdges")}return R[ia]}function e(ia){return ia<0?Math.min((1+ia)*0.5,0.5):0.5+Math.min(ia*0.5,0.5)}var g=null,h=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,m,o,z,u,p,A,D,F=new THREE.Rectangle,w=new THREE.Rectangle,H=!1,x=new THREE.Color(16777215), -Q=new THREE.Color(16777215),M=new THREE.Color(0),X=new THREE.Color(0),L=new THREE.Color(0),f,T=new THREE.Vector3,R=[],$=[],ca=[],J,aa,ua,Y,oa=1;this.domElement=j;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ia){switch(ia){case "high":oa=1;break;case "low":oa=0}};this.setSize=function(ia,da){k=ia;m=da;o=k/2;z=m/2;j.setAttribute("viewBox",-o+" "+-z+" "+k+" "+m);j.setAttribute("width",k);j.setAttribute("height",m);F.set(-o,-z,o,z)};this.clear=function(){for(;j.childNodes.length> -0;)j.removeChild(j.childNodes[0])};this.render=function(ia,da){var pa,ya,ea,Z,l,y,v,n;this.autoClear&&this.clear();g=h.projectScene(ia,da,this.sortElements);Y=ua=aa=0;if(H=ia.lights.length>0){v=ia.lights;M.setRGB(0,0,0);X.setRGB(0,0,0);L.setRGB(0,0,0);pa=0;for(ya=v.length;pa=0){f.bindBuffer(f.ARRAY_BUFFER,q.__webGLColorBuffer);f.vertexAttribPointer(l.color,3,f.FLOAT,!1,0,0)}if(l.normal>=0){f.bindBuffer(f.ARRAY_BUFFER,q.__webGLNormalBuffer);f.vertexAttribPointer(l.normal,3,f.FLOAT,!1,0,0)}if(l.tangent>=0){f.bindBuffer(f.ARRAY_BUFFER,q.__webGLTangentBuffer);f.vertexAttribPointer(l.tangent, -4,f.FLOAT,!1,0,0)}if(l.uv>=0)if(q.__webGLUVBuffer){f.bindBuffer(f.ARRAY_BUFFER,q.__webGLUVBuffer);f.vertexAttribPointer(l.uv,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(l.uv)}else f.disableVertexAttribArray(l.uv);if(l.uv2>=0)if(q.__webGLUV2Buffer){f.bindBuffer(f.ARRAY_BUFFER,q.__webGLUV2Buffer);f.vertexAttribPointer(l.uv2,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(l.uv2)}else f.disableVertexAttribArray(l.uv2);if(n.skinning&&l.skinVertexA>=0&&l.skinVertexB>=0&&l.skinIndex>=0&&l.skinWeight>=0){f.bindBuffer(f.ARRAY_BUFFER, -q.__webGLSkinVertexABuffer);f.vertexAttribPointer(l.skinVertexA,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,q.__webGLSkinVertexBBuffer);f.vertexAttribPointer(l.skinVertexB,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,q.__webGLSkinIndicesBuffer);f.vertexAttribPointer(l.skinIndex,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,q.__webGLSkinWeightsBuffer);f.vertexAttribPointer(l.skinWeight,4,f.FLOAT,!1,0,0)}if(K instanceof THREE.Mesh)if(n.wireframe){f.lineWidth(n.wireframeLinewidth);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER, -q.__webGLLineBuffer);f.drawElements(f.LINES,q.__webGLLineCount,f.UNSIGNED_SHORT,0)}else{f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);f.drawElements(f.TRIANGLES,q.__webGLFaceCount,f.UNSIGNED_SHORT,0)}else if(K instanceof THREE.Line){K=K.type==THREE.LineStrip?f.LINE_STRIP:f.LINES;f.lineWidth(n.linewidth);f.drawArrays(K,0,q.__webGLLineCount)}else if(K instanceof THREE.ParticleSystem)f.drawArrays(f.POINTS,0,q.__webGLParticleCount);else K instanceof THREE.Ribbon&&f.drawArrays(f.TRIANGLE_STRIP, -0,q.__webGLVertexCount)}function g(l,y){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=f.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=f.createBuffer();if(l.hasPos){f.bindBuffer(f.ARRAY_BUFFER,l.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,l.positionArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(y.attributes.position);f.vertexAttribPointer(y.attributes.position,3,f.FLOAT,!1,0,0)}if(l.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,l.__webGLNormalBuffer);f.bufferData(f.ARRAY_BUFFER,l.normalArray, -f.DYNAMIC_DRAW);f.enableVertexAttribArray(y.attributes.normal);f.vertexAttribPointer(y.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,l.count);l.count=0}function h(l){if(ca!=l.doubleSided){l.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE);ca=l.doubleSided}if(J!=l.flipSided){l.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW);J=l.flipSided}}function j(l){if(ua!=l){l?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST);ua=l}}function k(l){Y[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13, -l.n44-l.n14);Y[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+l.n14);Y[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);Y[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);Y[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);Y[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var y;for(l=0;l<6;l++){y=Y[l];y.divideScalar(Math.sqrt(y.x*y.x+y.y*y.y+y.z*y.z))}}function m(l){for(var y=l.matrixWorld,v=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)), -n=0;n<6;n++){l=Y[n].x*y.n14+Y[n].y*y.n24+Y[n].z*y.n34+Y[n].w;if(l<=v)return!1}return!0}function o(l,y){l.list[l.count]=y;l.count+=1}function z(l){var y,v,n=l.object,q=l.opaque,K=l.transparent;K.count=0;l=q.count=0;for(y=n.materials.length;l65535){E[C].counter+=1;B=E[C].hash+"_"+E[C].counter;l.geometryGroups[B]==undefined&&(l.geometryGroups[B]= -{faces:[],materials:t,vertices:0})}l.geometryGroups[B].faces.push(q);l.geometryGroups[B].vertices+=G}}function F(l,y,v){l.push({buffer:y,object:v,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function w(l){if(l!=aa){switch(l){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)}aa=l}}function H(l,y,v){if((v.width&v.width-1)==0&&(v.height&v.height-1)==0){f.texParameteri(l,f.TEXTURE_WRAP_S,X(y.wrapS));f.texParameteri(l,f.TEXTURE_WRAP_T,X(y.wrapT));f.texParameteri(l,f.TEXTURE_MAG_FILTER,X(y.magFilter));f.texParameteri(l,f.TEXTURE_MIN_FILTER,X(y.minFilter));f.generateMipmap(l)}else{f.texParameteri(l, -f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(l,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(l,f.TEXTURE_MAG_FILTER,M(y.magFilter));f.texParameteri(l,f.TEXTURE_MIN_FILTER,M(y.minFilter))}}function x(l,y){if(l&&!l.__webGLFramebuffer){l.__webGLFramebuffer=f.createFramebuffer();l.__webGLRenderbuffer=f.createRenderbuffer();l.__webGLTexture=f.createTexture();f.bindRenderbuffer(f.RENDERBUFFER,l.__webGLRenderbuffer);f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,l.width,l.height);f.bindTexture(f.TEXTURE_2D, -l.__webGLTexture);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,X(l.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,X(l.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,X(l.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,X(l.minFilter));f.texImage2D(f.TEXTURE_2D,0,X(l.format),l.width,l.height,0,X(l.format),X(l.type),null);f.bindFramebuffer(f.FRAMEBUFFER,l.__webGLFramebuffer);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,l.__webGLTexture,0);f.framebufferRenderbuffer(f.FRAMEBUFFER, -f.DEPTH_ATTACHMENT,f.RENDERBUFFER,l.__webGLRenderbuffer);f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}var v,n,q;if(l){v=l.__webGLFramebuffer;n=l.width;q=l.height}else{v=null;n=L.width;q=L.height}if(v!=R){f.bindFramebuffer(f.FRAMEBUFFER,v);f.viewport(0,0,n,q);y&&f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT);R=v}}function Q(l,y){var v;if(l=="fragment")v=f.createShader(f.FRAGMENT_SHADER);else l=="vertex"&&(v=f.createShader(f.VERTEX_SHADER)); -f.shaderSource(v,y);f.compileShader(v);if(!f.getShaderParameter(v,f.COMPILE_STATUS)){alert(f.getShaderInfoLog(v));return null}return v}function M(l){switch(l){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 X(l){switch(l){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 L=document.createElement("canvas"),f,T=null,R=null,$=this,ca=null,J=null,aa=null,ua=null,Y=[new THREE.Vector4, -new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],oa=new THREE.Matrix4,ia=new Float32Array(16),da=new Float32Array(16),pa=new THREE.Vector4,ya=!0,ea=new THREE.Color(0),Z=0;if(a){if(a.antialias!==undefined)ya=a.antialias;a.clearColor!==undefined&&ea.setHex(a.clearColor);if(a.clearAlpha!==undefined)Z=a.clearAlpha}this.domElement=L;this.autoClear=!0;this.sortObjects=!0;(function(l,y,v){try{if(!(f=L.getContext("experimental-webgl",{antialias:l})))throw"Error creating WebGL context."; -}catch(n){console.error(n)}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(y.r,y.g,y.b,v);_cullEnabled=!0})(ya,ea,Z);this.context=f;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,y){L.width=l;L.height=y;f.viewport(0,0,L.width,L.height)};this.setClearColorHex= -function(l,y){var v=new THREE.Color(l);f.clearColor(v.r,v.g,v.b,y)};this.setClearColor=function(l,y){f.clearColor(l.r,l.g,l.b,y)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT)};this.initMaterial=function(l,y,v){var n,q;if(l instanceof THREE.MeshDepthMaterial)b(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)b(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)b(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)b(l, -THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)b(l,THREE.ShaderLib.phong);else if(l instanceof THREE.LineBasicMaterial)b(l,THREE.ShaderLib.basic);else l instanceof THREE.ParticleBasicMaterial&&b(l,THREE.ShaderLib.particle_basic);var K,G,t,C;q=t=C=0;for(K=y.length;q0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+K.maxDirLights,"#define MAX_POINT_LIGHTS "+K.maxPointLights,K.map?"#define USE_MAP":"",K.envMap?"#define USE_ENVMAP":"",K.lightMap?"#define USE_LIGHTMAP":"",K.vertexColors?"#define USE_COLOR":"",K.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); -f.attachShader(v,Q("fragment",q+C));f.attachShader(v,Q("vertex",K+y));f.linkProgram(v);f.getProgramParameter(v,f.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+f.getProgramParameter(v,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");v.uniforms={};v.attributes={};l.program=v;v=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(n in l.uniforms)v.push(n);n=l.program;C=0;for(y=v.length;C< -y;C++){q=v[C];n.uniforms[q]=f.getUniformLocation(n,q)}n=l.program;v=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];C=0;for(y=v.length;C=0&&f.enableVertexAttribArray(n.color);n.normal>=0&&f.enableVertexAttribArray(n.normal);n.tangent>=0&&f.enableVertexAttribArray(n.tangent);if(l.skinning&&n.skinVertexA>=0&&n.skinVertexB>= -0&&n.skinIndex>=0&&n.skinWeight>=0){f.enableVertexAttribArray(n.skinVertexA);f.enableVertexAttribArray(n.skinVertexB);f.enableVertexAttribArray(n.skinIndex);f.enableVertexAttribArray(n.skinWeight)}};this.render=function(l,y,v,n){var q,K,G,t,C,B,E,S,na=l.lights,ga=l.fog;y.matrixAutoUpdate&&y.update();y.matrixWorldInverse.flattenToArray(da);y.projectionMatrix.flattenToArray(ia);oa.multiply(y.projectionMatrix,y.matrixWorldInverse);k(oa);l.update(undefined,!1,y);this.initWebGLObjects(l,y);x(v,n!==undefined? -n:!0);this.autoClear&&this.clear();C=l.__webglObjects.length;for(n=0;n=0;q--){n=v.__webglObjects[q].object;y==n&&v.__webglObjects.splice(q,1)}l.__objectsRemoved.splice(0,1)}y=0;for(v=l.__webglObjects.length;y0){f.bindBuffer(f.ARRAY_BUFFER,G.__webGLUVBuffer);f.bufferData(f.ARRAY_BUFFER,Ra,S)}if(Aa&&ga>0){f.bindBuffer(f.ARRAY_BUFFER,G.__webGLUV2Buffer);f.bufferData(f.ARRAY_BUFFER,Pa,S)}if(qa){f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,G.__webGLFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,O,S);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,G.__webGLLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,fa,S)}if(I>0){f.bindBuffer(f.ARRAY_BUFFER,G.__webGLSkinVertexABuffer);f.bufferData(f.ARRAY_BUFFER,ta,S);f.bindBuffer(f.ARRAY_BUFFER, -G.__webGLSkinVertexBBuffer);f.bufferData(f.ARRAY_BUFFER,xa,S);f.bindBuffer(f.ARRAY_BUFFER,G.__webGLSkinIndicesBuffer);f.bufferData(f.ARRAY_BUFFER,za,S);f.bindBuffer(f.ARRAY_BUFFER,G.__webGLSkinWeightsBuffer);f.bufferData(f.ARRAY_BUFFER,va,S)}}}q.__dirtyVertices=!1;q.__dirtyElements=!1;q.__dirtyUvs=!1;q.__dirtyNormals=!1;q.__dirtyTangents=!1;q.__dirtyColors=!1}else if(n instanceof THREE.Ribbon){q=n.geometry;if(q.__dirtyVertices||q.__dirtyColors){n=q;K=f.DYNAMIC_DRAW;B=void 0;B=void 0;t=void 0;G=void 0; -E=n.vertices;S=n.colors;ga=E.length;na=S.length;ja=n.__vertexArray;C=n.__colorArray;ma=n.__dirtyColors;if(n.__dirtyVertices){for(B=0;B0}}; +THREE.Projector=function(){function a(M,e){return e.z-M.z}function c(M,e){var V=0,S=1,ba=M.z+M.w,ea=e.z+e.w,J=-M.z+M.w,ca=-e.z+e.w;if(ba>=0&&ea>=0&&J>=0&&ca>=0)return!0;else if(ba<0&&ea<0||J<0&&ca<0)return!1;else{if(ba<0)V=Math.max(V,ba/(ba-ea));else ea<0&&(S=Math.min(S,ba/(ba-ea)));if(J<0)V=Math.max(V,J/(J-ca));else ca<0&&(S=Math.min(S,J/(J-ca)));if(Sba&&da.z0&& +E.z<1){t=x[q]=x[q]||new THREE.RenderableParticle;t.x=E.x/E.w;t.y=E.y/E.w;t.z=E.z;t.rotation=fa.rotation.z;t.scale.x=fa.scale.x*Math.abs(t.x-(E.x+e.projectionMatrix.n11)/(E.w+e.projectionMatrix.n14));t.scale.y=fa.scale.y*Math.abs(t.y-(E.y+e.projectionMatrix.n22)/(E.w+e.projectionMatrix.n24));t.materials=fa.materials;S.push(t);q++}}}}V&&S.sort(a);return S};this.unprojectVector=function(M,e){var V=e.matrixWorld.clone();V.multiplySelf(THREE.Matrix4.makeInvert(e.projectionMatrix));V.multiplyVector3(M); +return M}}; +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,j){b=h;d=j;f=b/2;g=d/2};this.render=function(h,j){var l,n,p,w,t,q,x,B;a=c.projectScene(h,j);l=0;for(n=a.length;l0){K.r+=Ea.r*na;K.g+=Ea.g*na;K.b+=Ea.b*na}}else if(na instanceof THREE.PointLight){y.sub(na.position,W);y.normalize();na=T.dot(y)*va;if(na>0){K.r+=Ea.r*na;K.g+=Ea.g*na;K.b+=Ea.b*na}}}}function Ka(G,W,T){if(T.opacity!=0){a(T.opacity); +c(T.blending);var K,$,na,Ea,va,Ha;if(T instanceof THREE.ParticleBasicMaterial){if(T.map){Ea=T.map.image;va=Ea.width>>1;Ha=Ea.height>>1;$=W.scale.x*j;na=W.scale.y*l;T=$*va;K=na*Ha;R.set(G.x-T,G.y-K,G.x+T,G.y+K);if(oa.instersects(R)){n.save();n.translate(G.x,G.y);n.rotate(-W.rotation);n.scale($,-na);n.translate(-va,-Ha);n.drawImage(Ea,0,0);n.restore()}}}else if(T instanceof THREE.ParticleCircleMaterial){if(ia){m.r=z.r+C.r+k.r;m.g=z.g+C.g+k.g;m.b=z.b+C.b+k.b;S.r=T.color.r*m.r;S.g=T.color.g*m.g;S.b=T.color.b* +m.b;S.updateStyleString()}else S.__styleString=T.color.__styleString;T=W.scale.x*j;K=W.scale.y*l;R.set(G.x-T,G.y-K,G.x+T,G.y+K);if(oa.instersects(R)){$=S.__styleString;if(B!=$)n.fillStyle=B=$;n.save();n.translate(G.x,G.y);n.rotate(-W.rotation);n.scale(T,K);n.beginPath();n.arc(0,0,1,0,o,!0);n.closePath();n.fill();n.restore()}}}}function Q(G,W,T,K){if(K.opacity!=0){a(K.opacity);c(K.blending);n.beginPath();n.moveTo(G.positionScreen.x,G.positionScreen.y);n.lineTo(W.positionScreen.x,W.positionScreen.y); +n.closePath();if(K instanceof THREE.LineBasicMaterial){S.__styleString=K.color.__styleString;G=K.linewidth;if(E!=G)n.lineWidth=E=G;G=S.__styleString;if(x!=G)n.strokeStyle=x=G;n.stroke();R.inflate(K.linewidth*2)}}}function Ga(G,W,T,K,$,na){if($.opacity!=0){a($.opacity);c($.blending);N=G.positionScreen.x;L=G.positionScreen.y;Y=W.positionScreen.x;M=W.positionScreen.y;e=T.positionScreen.x;V=T.positionScreen.y;n.beginPath();n.moveTo(N,L);n.lineTo(Y,M);n.lineTo(e,V);n.lineTo(N,L);n.closePath();if($ instanceof +THREE.MeshBasicMaterial)if($.map)$.map.mapping instanceof THREE.UVMapping&&U(N,L,Y,M,e,V,$.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);else if($.envMap){if($.envMap.mapping instanceof THREE.SphericalReflectionMapping){G=ka.matrixWorldInverse;y.copy(K.vertexNormalsWorld[0]);ha=(y.x*G.n11+y.y*G.n12+y.z*G.n13)*0.5+0.5;fa=-(y.x*G.n21+y.y*G.n22+y.z*G.n23)*0.5+0.5;y.copy(K.vertexNormalsWorld[1]);ra=(y.x*G.n11+y.y*G.n12+y.z*G.n13)*0.5+0.5;xa=-(y.x*G.n21+y.y*G.n22+y.z*G.n23)* +0.5+0.5;y.copy(K.vertexNormalsWorld[2]);ga=(y.x*G.n11+y.y*G.n12+y.z*G.n13)*0.5+0.5;aa=-(y.x*G.n21+y.y*G.n22+y.z*G.n23)*0.5+0.5;U(N,L,Y,M,e,V,$.envMap.image,ha,fa,ra,xa,ga,aa)}}else $.wireframe?Ca($.color.__styleString,$.wireframeLinewidth):Fa($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&!$.wireframe){$.map.mapping instanceof THREE.UVMapping&&U(N,L,Y,M,e,V,$.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);c(THREE.SubtractiveBlending)}if(ia)if(!$.wireframe&& +$.shading==THREE.SmoothShading&&K.vertexNormalsWorld.length==3){ba.r=ea.r=J.r=z.r;ba.g=ea.g=J.g=z.g;ba.b=ea.b=J.b=z.b;ma(na,K.v1.positionWorld,K.vertexNormalsWorld[0],ba);ma(na,K.v2.positionWorld,K.vertexNormalsWorld[1],ea);ma(na,K.v3.positionWorld,K.vertexNormalsWorld[2],J);ca.r=(ea.r+J.r)*0.5;ca.g=(ea.g+J.g)*0.5;ca.b=(ea.b+J.b)*0.5;ta=X(ba,ea,J,ca);U(N,L,Y,M,e,V,ta,0,0,1,0,0,1)}else{m.r=z.r;m.g=z.g;m.b=z.b;ma(na,K.centroidWorld,K.normalWorld,m);S.r=$.color.r*m.r;S.g=$.color.g*m.g;S.b=$.color.b* +m.b;S.updateStyleString();$.wireframe?Ca(S.__styleString,$.wireframeLinewidth):Fa(S.__styleString)}else $.wireframe?Ca($.color.__styleString,$.wireframeLinewidth):Fa($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){wa=ka.near;da=ka.far;ba.r=ba.g=ba.b=1-Z(G.positionScreen.z,wa,da);ea.r=ea.g=ea.b=1-Z(W.positionScreen.z,wa,da);J.r=J.g=J.b=1-Z(T.positionScreen.z,wa,da);ca.r=(ea.r+J.r)*0.5;ca.g=(ea.g+J.g)*0.5;ca.b=(ea.b+J.b)*0.5;ta=X(ba,ea,J,ca);U(N,L,Y,M,e,V,ta,0,0,1,0,0,1)}else if($ instanceof +THREE.MeshNormalMaterial){S.r=ya(K.normalWorld.x);S.g=ya(K.normalWorld.y);S.b=ya(K.normalWorld.z);S.updateStyleString();$.wireframe?Ca(S.__styleString,$.wireframeLinewidth):Fa(S.__styleString)}}}function Ca(G,W){if(x!=G)n.strokeStyle=x=G;if(E!=W)n.lineWidth=E=W;n.stroke();R.inflate(W*2)}function Fa(G){if(B!=G)n.fillStyle=B=G;n.fill()}function U(G,W,T,K,$,na,Ea,va,Ha,Oa,Ja,Pa,Sa){var Na,Da;Na=Ea.width-1;Da=Ea.height-1;va*=Na;Ha*=Da;Oa*=Na;Ja*=Da;Pa*=Na;Sa*=Da;T-=G;K-=W;$-=G;na-=W;Oa-=va;Ja-=Ha;Pa-= +va;Sa-=Ha;Na=Oa*Sa-Pa*Ja;if(Na!=0){Da=1/Na;Na=(Sa*T-Ja*$)*Da;Ja=(Sa*K-Ja*na)*Da;T=(Oa*$-Pa*T)*Da;K=(Oa*na-Pa*K)*Da;G=G-Na*va-T*Ha;W=W-Ja*va-K*Ha;n.save();n.transform(Na,Ja,T,K,G,W);n.clip();n.drawImage(Ea,0,0);n.restore()}}function X(G,W,T,K){var $=~~(G.r*255),na=~~(G.g*255);G=~~(G.b*255);var Ea=~~(W.r*255),va=~~(W.g*255);W=~~(W.b*255);var Ha=~~(T.r*255),Oa=~~(T.g*255);T=~~(T.b*255);var Ja=~~(K.r*255),Pa=~~(K.g*255);K=~~(K.b*255);H[0]=$<0?0:$>255?255:$;H[1]=na<0?0:na>255?255:na;H[2]=G<0?0:G>255?255: +G;H[4]=Ea<0?0:Ea>255?255:Ea;H[5]=va<0?0:va>255?255:va;H[6]=W<0?0:W>255?255:W;H[8]=Ha<0?0:Ha>255?255:Ha;H[9]=Oa<0?0:Oa>255?255:Oa;H[10]=T<0?0:T>255?255:T;H[12]=Ja<0?0:Ja>255?255:Ja;H[13]=Pa<0?0:Pa>255?255:Pa;H[14]=K<0?0:K>255?255:K;D.putImageData(P,0,0);la.drawImage(A,0,0);return O}function Z(G,W,T){G=(G-W)/(T-W);return G*G*(3-2*G)}function ya(G){G=(G+1)*0.5;return G<0?0:G>1?1:G}function Ia(G,W){var T=W.x-G.x,K=W.y-G.y,$=1/Math.sqrt(T*T+K*K);T*=$;K*=$;W.x+=T;W.y+=K;G.x-=T;G.y-=K}var Aa,I,qa,Ma,Qa, +La,za,Ba;this.autoClear?this.clear():n.setTransform(1,0,0,-1,j,l);b=d.projectScene(ja,ka,this.sortElements);(ia=ja.lights.length>0)&&sa(ja);Aa=0;for(I=b.length;Aa0){ra.r+=aa.color.r*oa;ra.g+=aa.color.g*oa;ra.b+=aa.color.b*oa}}else if(aa instanceof THREE.PointLight){V.sub(aa.position,fa.centroidWorld);V.normalize();oa=fa.normalWorld.dot(V)*aa.intensity;if(oa>0){ra.r+=aa.color.r*oa;ra.g+=aa.color.g*oa;ra.b+=aa.color.b*oa}}}}function c(ha,fa,ra, +xa,ga,aa){J=d(ca++);J.setAttribute("d","M "+ha.positionScreen.x+" "+ha.positionScreen.y+" L "+fa.positionScreen.x+" "+fa.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+"z");if(ga instanceof THREE.MeshBasicMaterial)v.__styleString=ga.color.__styleString;else if(ga instanceof THREE.MeshLambertMaterial)if(F){N.r=L.r;N.g=L.g;N.b=L.b;a(aa,xa,N);v.r=ga.color.r*N.r;v.g=ga.color.g*N.g;v.b=ga.color.b*N.b;v.updateStyleString()}else v.__styleString=ga.color.__styleString;else if(ga instanceof +THREE.MeshDepthMaterial){e=1-ga.__2near/(ga.__farPlusNear-xa.z*ga.__farMinusNear);v.setRGB(e,e,e)}else ga instanceof THREE.MeshNormalMaterial&&v.setRGB(f(xa.normalWorld.x),f(xa.normalWorld.y),f(xa.normalWorld.z));ga.wireframe?J.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+ga.wireframeLinewidth+"; stroke-opacity: "+ga.opacity+"; stroke-linecap: "+ga.wireframeLinecap+"; stroke-linejoin: "+ga.wireframeLinejoin):J.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+ +ga.opacity);j.appendChild(J)}function b(ha,fa,ra,xa,ga,aa,oa){J=d(ca++);J.setAttribute("d","M "+ha.positionScreen.x+" "+ha.positionScreen.y+" L "+fa.positionScreen.x+" "+fa.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+" L "+xa.positionScreen.x+","+xa.positionScreen.y+"z");if(aa instanceof THREE.MeshBasicMaterial)v.__styleString=aa.color.__styleString;else if(aa instanceof THREE.MeshLambertMaterial)if(F){N.r=L.r;N.g=L.g;N.b=L.b;a(oa,ga,N);v.r=aa.color.r*N.r;v.g=aa.color.g*N.g; +v.b=aa.color.b*N.b;v.updateStyleString()}else v.__styleString=aa.color.__styleString;else if(aa instanceof THREE.MeshDepthMaterial){e=1-aa.__2near/(aa.__farPlusNear-ga.z*aa.__farMinusNear);v.setRGB(e,e,e)}else aa instanceof THREE.MeshNormalMaterial&&v.setRGB(f(ga.normalWorld.x),f(ga.normalWorld.y),f(ga.normalWorld.z));aa.wireframe?J.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+aa.wireframeLinewidth+"; stroke-opacity: "+aa.opacity+"; stroke-linecap: "+aa.wireframeLinecap+ +"; stroke-linejoin: "+aa.wireframeLinejoin):J.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+aa.opacity);j.appendChild(J)}function d(ha){if(S[ha]==null){S[ha]=document.createElementNS("http://www.w3.org/2000/svg","path");ta==0&&S[ha].setAttribute("shape-rendering","crispEdges")}return S[ha]}function f(ha){return ha<0?Math.min((1+ha)*0.5,0.5):0.5+Math.min(ha*0.5,0.5)}var g=null,h=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,n,p,w,t,q,x,B,E= +new THREE.Rectangle,u=new THREE.Rectangle,F=!1,v=new THREE.Color(16777215),N=new THREE.Color(16777215),L=new THREE.Color(0),Y=new THREE.Color(0),M=new THREE.Color(0),e,V=new THREE.Vector3,S=[],ba=[],ea=[],J,ca,wa,da,ta=1;this.domElement=j;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ha){switch(ha){case "high":ta=1;break;case "low":ta=0}};this.setSize=function(ha,fa){l=ha;n=fa;p=l/2;w=n/2;j.setAttribute("viewBox",-p+" "+-w+" "+l+" "+n);j.setAttribute("width", +l);j.setAttribute("height",n);E.set(-p,-w,p,w)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])};this.render=function(ha,fa){var ra,xa,ga,aa,oa,pa,R,ia;this.autoClear&&this.clear();g=h.projectScene(ha,fa,this.sortElements);da=wa=ca=0;if(F=ha.lights.length>0){R=ha.lights;L.setRGB(0,0,0);Y.setRGB(0,0,0);M.setRGB(0,0,0);ra=0;for(xa=R.length;ra=0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLColorBuffer);e.vertexAttribPointer(m.color,3,e.FLOAT,!1,0,0)}if(m.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLNormalBuffer);e.vertexAttribPointer(m.normal,3,e.FLOAT,!1,0,0)}if(m.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLTangentBuffer);e.vertexAttribPointer(m.tangent, +4,e.FLOAT,!1,0,0)}if(m.uv>=0)if(o.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLUVBuffer);e.vertexAttribPointer(m.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(m.uv)}else e.disableVertexAttribArray(m.uv);if(m.uv2>=0)if(o.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLUV2Buffer);e.vertexAttribPointer(m.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(m.uv2)}else e.disableVertexAttribArray(m.uv2);if(k.skinning&&m.skinVertexA>=0&&m.skinVertexB>=0&&m.skinIndex>=0&&m.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER, +o.__webGLSkinVertexABuffer);e.vertexAttribPointer(m.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);e.vertexAttribPointer(m.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer);e.vertexAttribPointer(m.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);e.vertexAttribPointer(m.skinWeight,4,e.FLOAT,!1,0,0)}if(y instanceof THREE.Mesh)if(k.wireframe){e.lineWidth(k.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, +o.__webGLLineBuffer);e.drawElements(e.LINES,o.__webGLLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);e.drawElements(e.TRIANGLES,o.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else if(y instanceof THREE.Line){y=y.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(k.linewidth);e.drawArrays(y,0,o.__webGLLineCount)}else if(y instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,0,o.__webGLParticleCount);else y instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP, +0,o.__webGLVertexCount)}function g(m,z){if(!m.__webGLVertexBuffer)m.__webGLVertexBuffer=e.createBuffer();if(!m.__webGLNormalBuffer)m.__webGLNormalBuffer=e.createBuffer();if(m.hasPos){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,m.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(z.attributes.position);e.vertexAttribPointer(z.attributes.position,3,e.FLOAT,!1,0,0)}if(m.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,m.normalArray, +e.DYNAMIC_DRAW);e.enableVertexAttribArray(z.attributes.normal);e.vertexAttribPointer(z.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,m.count);m.count=0}function h(m){if(ea!=m.doubleSided){m.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);ea=m.doubleSided}if(J!=m.flipSided){m.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);J=m.flipSided}}function j(m){if(wa!=m){m?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);wa=m}}function l(m){ra[0].set(m.n41-m.n11,m.n42-m.n12,m.n43-m.n13, +m.n44-m.n14);ra[1].set(m.n41+m.n11,m.n42+m.n12,m.n43+m.n13,m.n44+m.n14);ra[2].set(m.n41+m.n21,m.n42+m.n22,m.n43+m.n23,m.n44+m.n24);ra[3].set(m.n41-m.n21,m.n42-m.n22,m.n43-m.n23,m.n44-m.n24);ra[4].set(m.n41-m.n31,m.n42-m.n32,m.n43-m.n33,m.n44-m.n34);ra[5].set(m.n41+m.n31,m.n42+m.n32,m.n43+m.n33,m.n44+m.n34);var z;for(m=0;m<6;m++){z=ra[m];z.divideScalar(Math.sqrt(z.x*z.x+z.y*z.y+z.z*z.z))}}function n(m){for(var z=m.matrixWorld,C=-m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y, +m.scale.z)),k=0;k<6;k++){m=ra[k].x*z.n14+ra[k].y*z.n24+ra[k].z*z.n34+ra[k].w;if(m<=C)return!1}return!0}function p(m,z){m.list[m.count]=z;m.count+=1}function w(m){var z,C,k=m.object,o=m.opaque,y=m.transparent;y.count=0;m=o.count=0;for(z=k.materials.length;m65535){O[P].counter+=1;H=O[P].hash+"_"+O[P].counter;m.geometryGroups[H]== +undefined&&(m.geometryGroups[H]={faces:[],materials:D,vertices:0})}m.geometryGroups[H].faces.push(o);m.geometryGroups[H].vertices+=A}}function E(m,z,C){m.push({buffer:z,object:C,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function u(m){if(m!=ca){switch(m){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)}ca=m}}function F(m,z,C){if((C.width&C.width-1)==0&&(C.height&C.height-1)==0){e.texParameteri(m,e.TEXTURE_WRAP_S,Y(z.wrapS));e.texParameteri(m,e.TEXTURE_WRAP_T,Y(z.wrapT));e.texParameteri(m,e.TEXTURE_MAG_FILTER,Y(z.magFilter));e.texParameteri(m,e.TEXTURE_MIN_FILTER,Y(z.minFilter));e.generateMipmap(m)}else{e.texParameteri(m, +e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(m,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(m,e.TEXTURE_MAG_FILTER,L(z.magFilter));e.texParameteri(m,e.TEXTURE_MIN_FILTER,L(z.minFilter))}}function v(m,z){if(m&&!m.__webGLFramebuffer){m.__webGLFramebuffer=e.createFramebuffer();m.__webGLRenderbuffer=e.createRenderbuffer();m.__webGLTexture=e.createTexture();e.bindRenderbuffer(e.RENDERBUFFER,m.__webGLRenderbuffer);e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,m.width,m.height);e.bindTexture(e.TEXTURE_2D, +m.__webGLTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,Y(m.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,Y(m.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,Y(m.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,Y(m.minFilter));e.texImage2D(e.TEXTURE_2D,0,Y(m.format),m.width,m.height,0,Y(m.format),Y(m.type),null);e.bindFramebuffer(e.FRAMEBUFFER,m.__webGLFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,m.__webGLTexture,0);e.framebufferRenderbuffer(e.FRAMEBUFFER, +e.DEPTH_ATTACHMENT,e.RENDERBUFFER,m.__webGLRenderbuffer);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var C,k,o;if(m){C=m.__webGLFramebuffer;k=m.width;o=m.height}else{C=null;k=ha;o=fa}if(C!=S){e.bindFramebuffer(e.FRAMEBUFFER,C);e.viewport(da,ta,k,o);z&&e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT);S=C}}function N(m,z){var C;if(m=="fragment")C=e.createShader(e.FRAGMENT_SHADER);else m=="vertex"&&(C=e.createShader(e.VERTEX_SHADER));e.shaderSource(C, +z);e.compileShader(C);if(!e.getShaderParameter(C,e.COMPILE_STATUS)){alert(e.getShaderInfoLog(C));return null}return C}function L(m){switch(m){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return e.LINEAR}}function Y(m){switch(m){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 M=document.createElement("canvas"),e,V=null,S=null,ba=this,ea=null,J=null,ca=null,wa=null,da=0,ta=0,ha=0,fa=0,ra=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4, +new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],xa=new THREE.Matrix4,ga=new Float32Array(16),aa=new Float32Array(16),oa=new THREE.Vector4,pa=!0,R=new THREE.Color(0),ia=0;if(a){if(a.antialias!==undefined)pa=a.antialias;a.clearColor!==undefined&&R.setHex(a.clearColor);if(a.clearAlpha!==undefined)ia=a.clearAlpha}this.domElement=M;this.autoClear=!0;this.sortObjects=!0;(function(m,z,C){try{if(!(e=M.getContext("experimental-webgl",{antialias:m})))throw"Error creating WebGL context.";}catch(k){console.error(k)}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(z.r,z.g,z.b,C);_cullEnabled=!0})(pa,R,ia);this.context=e;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(m,z){M.width=m;M.height=z;this.setViewport(0,0,M.width,M.height)};this.setViewport=function(m,z,C,k){da=m; +ta=z;ha=C;fa=k;e.viewport(da,ta,ha,fa)};this.setScissor=function(m,z,C,k){e.scissor(m,z,C,k)};this.enableScissorTest=function(m){m?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.setClearColorHex=function(m,z){var C=new THREE.Color(m);e.clearColor(C.r,C.g,C.b,z)};this.setClearColor=function(m,z){e.clearColor(m.r,m.g,m.b,z)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)};this.initMaterial=function(m,z,C){var k,o;if(m instanceof THREE.MeshDepthMaterial)b(m,THREE.ShaderLib.depth); +else if(m instanceof THREE.MeshNormalMaterial)b(m,THREE.ShaderLib.normal);else if(m instanceof THREE.MeshBasicMaterial)b(m,THREE.ShaderLib.basic);else if(m instanceof THREE.MeshLambertMaterial)b(m,THREE.ShaderLib.lambert);else if(m instanceof THREE.MeshPhongMaterial)b(m,THREE.ShaderLib.phong);else if(m instanceof THREE.LineBasicMaterial)b(m,THREE.ShaderLib.basic);else m instanceof THREE.ParticleBasicMaterial&&b(m,THREE.ShaderLib.particle_basic);var y,A,D,P;o=D=P=0;for(y=z.length;o0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,y.map?"#define USE_MAP":"",y.envMap?"#define USE_ENVMAP":"",y.lightMap? +"#define USE_LIGHTMAP":"",y.vertexColors?"#define USE_COLOR":"",y.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); +e.attachShader(C,N("fragment",o+P));e.attachShader(C,N("vertex",y+z));e.linkProgram(C);e.getProgramParameter(C,e.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+e.getProgramParameter(C,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");C.uniforms={};C.attributes={};m.program=C;C=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(k in m.uniforms)C.push(k);k=m.program;P=0;for(z=C.length;P< +z;P++){o=C[P];k.uniforms[o]=e.getUniformLocation(k,o)}k=m.program;C=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];P=0;for(z=C.length;P=0&&e.enableVertexAttribArray(k.color);k.normal>=0&&e.enableVertexAttribArray(k.normal);k.tangent>=0&&e.enableVertexAttribArray(k.tangent);if(m.skinning&&k.skinVertexA>=0&&k.skinVertexB>= +0&&k.skinIndex>=0&&k.skinWeight>=0){e.enableVertexAttribArray(k.skinVertexA);e.enableVertexAttribArray(k.skinVertexB);e.enableVertexAttribArray(k.skinIndex);e.enableVertexAttribArray(k.skinWeight)}};this.render=function(m,z,C,k){var o,y,A,D,P,H,O,la,ua=m.lights,ja=m.fog;z.matrixAutoUpdate&&z.update();z.matrixWorldInverse.flattenToArray(aa);z.projectionMatrix.flattenToArray(ga);xa.multiply(z.projectionMatrix,z.matrixWorldInverse);l(xa);m.update(undefined,!1,z);this.initWebGLObjects(m,z);v(C,k!==undefined? +k:!0);this.autoClear&&this.clear();P=m.__webglObjects.length;for(k=0;k=0;o--){k=C.__webglObjects[o].object;z==k&&C.__webglObjects.splice(o,1)}m.__objectsRemoved.splice(0,1)}z=0;for(C=m.__webglObjects.length;z0){e.bindBuffer(e.ARRAY_BUFFER,A.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER, +Ma,la)}if(Ja&&ja>0){e.bindBuffer(e.ARRAY_BUFFER,A.__webGLUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Qa,la)}if(Oa){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,A.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,$,la);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,A.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,na,la)}if(I>0){e.bindBuffer(e.ARRAY_BUFFER,A.__webGLSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,G,la);e.bindBuffer(e.ARRAY_BUFFER,A.__webGLSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,W,la);e.bindBuffer(e.ARRAY_BUFFER, +A.__webGLSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,T,la);e.bindBuffer(e.ARRAY_BUFFER,A.__webGLSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,K,la)}}}o.__dirtyVertices=!1;o.__dirtyElements=!1;o.__dirtyUvs=!1;o.__dirtyNormals=!1;o.__dirtyTangents=!1;o.__dirtyColors=!1}else if(k instanceof THREE.Ribbon){o=k.geometry;if(o.__dirtyVertices||o.__dirtyColors){k=o;y=e.DYNAMIC_DRAW;H=void 0;H=void 0;D=void 0;A=void 0;O=k.vertices;la=k.colors;ja=O.length;ua=la.length;ka=k.__vertexArray;P=k.__colorArray; +sa=k.__dirtyColors;if(k.__dirtyVertices){for(H=0;H +0}}; THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif", envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif", map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif", @@ -274,23 +275,23 @@ THREE.Snippets.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightW THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;", THREE.Snippets.lights_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_particle_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.Snippets.map_particle_fragment,THREE.Snippets.color_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;", THREE.Snippets.color_pars_vertex,"void main() {",THREE.Snippets.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\ngl_PointSize = size;\n}"].join("\n")}}; -THREE.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;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}", @@ -299,39 +300,39 @@ 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;c0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(z,j,u)))-1);m.push(o)}c.push(m)}var p,A,D;e=c.length;for(b=0;b0)for(d=0;d1){p=this.vertices[h].position.clone(); -A=this.vertices[k].position.clone();D=this.vertices[m].position.clone();p.normalize();A.normalize();D.normalize();this.faces.push(new THREE.Face3(h,k,m,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(D.x,D.y,D.z)]));this.uvs.push([o,z,F])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; -var Torus=function(a,c,b,d){this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){d=b/this.segmentsT*2*Math.PI;var e=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(e))*Math.cos(d),(this.radius+this.tube*Math.cos(e))*Math.sin(d),this.tube*Math.sin(e))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b= -1;b<=this.segmentsT;++b){d=(this.segmentsT+1)*c+b;e=(this.segmentsT+1)*c+b-1;var g=(this.segmentsT+1)*(c-1)+b-1,h=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(d,e,g,h));this.uvs.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 Icosahedron=function(a){function c(z,u,p){var A=Math.sqrt(z*z+u*u+p*p);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(z/A,u/A,p/A)))-1}function b(z,u,p,A){A.faces.push(new THREE.Face3(z,u,p))}function d(z,u){var p=e.vertices[z].position,A=e.vertices[u].position;return c((p.x+A.x)/2,(p.y+A.y)/2,(p.z+A.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||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(w,j,t)))-1);n.push(p)}c.push(n)}var q,x,B;f=c.length;for(b=0;b0)for(d=0;d1){q=this.vertices[h].position.clone(); +x=this.vertices[l].position.clone();B=this.vertices[n].position.clone();q.normalize();x.normalize();B.normalize();this.faces.push(new THREE.Face3(h,l,n,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(B.x,B.y,B.z)]));this.uvs.push([p,w,E])}}}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.uvs.push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; +var Icosahedron=function(a){function c(w,t,q){var x=Math.sqrt(w*w+t*t+q*q);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(w/x,t/x,q/x)))-1}function b(w,t,q,x){x.faces.push(new THREE.Face3(w,t,q))}function d(w,t){var q=f.vertices[w].position,x=f.vertices[t].position;return c((q.x+x.x)/2,(q.y+x.y)/2,(q.z+x.z)/2)}var f=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0, +1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,g);b(0,5,1,g);b(0,1,7,g);b(0,7,10,g);b(0,10,11,g);b(1,5,9,g);b(5,11,4,g);b(11,10,2,g);b(10,7,6,g);b(7,1,8,g);b(3,9,4,g);b(3,4,2,g);b(3,2,6,g);b(3,6,8,g);b(3,8,9,g);b(4,9,5,g);b(2,4,11,g);b(6,2,10,g);b(8,6,7,g);b(9,8,1,g);for(a=0;a=this.maxCount-3&&j(this)};this.begin= -function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var d=this.count*3;dthis.size-1&&(k=this.size-1);var u=Math.floor(m-j);u<1&&(u=1);m=Math.floor(m+j);m>this.size-1&&(m=this.size-1);var p=Math.floor(o-j);p<1&&(p=1);j=Math.floor(o+j); -j>this.size-1&&(j=this.size-1);for(var A,D,F,w,H,x;z0&&(this.field[F+A]+=w)}}}};this.addPlaneX=function(b,d){var e,g,h,j,k,m=this.size,o=this.yd,z=this.zd,u=this.field,p=m*Math.sqrt(b/d);p>m&&(p=m);for(e=0;e0)for(g=0;go&&(A=o);for(g=0;g0){k=g*z;for(e=0;esize&&(dist=size);for(h=0;h0){k=zd*h;for(g=0;g=this.maxCount-3&&j(this)};this.begin= +function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var d=this.count*3;dthis.size-1&&(l=this.size-1);var t=Math.floor(n-j);t<1&&(t=1);n=Math.floor(n+j);n>this.size-1&&(n=this.size-1);var q=Math.floor(p-j);q<1&&(q=1);j=Math.floor(p+j); +j>this.size-1&&(j=this.size-1);for(var x,B,E,u,F,v;w0&&(this.field[E+x]+=u)}}}};this.addPlaneX=function(b,d){var f,g,h,j,l,n=this.size,p=this.yd,w=this.zd,t=this.field,q=n*Math.sqrt(b/d);q>n&&(q=n);for(f=0;f0)for(g=0;gp&&(x=p);for(g=0;g0){l=g*w;for(f=0;fsize&&(dist=size);for(h=0;h0){l=zd*h;for(g=0;g>7)-127;B|=(S&127)<<16|E<<8;if(B==0&&ga==-127)return 0;return(1-2*(na>>7))*(1+B*Math.pow(2,-23))*Math.pow(2,ga)}function j(t,C){var B=o(t,C),E=o(t,C+1),S=o(t,C+2);return(o(t,C+3)<<24)+(S<<16)+(E<<8)+B}function k(t,C){var B=o(t,C);return(o(t,C+1)<<8)+B}function m(t,C){var B=o(t,C);return B>127?B-256:B}function o(t,C){return t.charCodeAt(C)&255}function z(t){var C,B,E;C= -j(a,t);B=j(a,t+X);E=j(a,t+L);t=k(a,t+f);THREE.Loader.prototype.f3(w,C,B,E,t)}function u(t){var C,B,E,S,na,ga;C=j(a,t);B=j(a,t+X);E=j(a,t+L);S=k(a,t+f);na=j(a,t+T);ga=j(a,t+R);t=j(a,t+$);THREE.Loader.prototype.f3n(w,Q,C,B,E,S,na,ga,t)}function p(t){var C,B,E,S;C=j(a,t);B=j(a,t+ca);E=j(a,t+J);S=j(a,t+aa);t=k(a,t+ua);THREE.Loader.prototype.f4(w,C,B,E,S,t)}function A(t){var C,B,E,S,na,ga,ja,ma;C=j(a,t);B=j(a,t+ca);E=j(a,t+J);S=j(a,t+aa);na=k(a,t+ua);ga=j(a,t+Y);ja=j(a,t+oa);ma=j(a,t+ia);t=j(a,t+da);THREE.Loader.prototype.f4n(w, -Q,C,B,E,S,na,ga,ja,ma,t)}function D(t){var C,B;C=j(a,t);B=j(a,t+pa);t=j(a,t+ya);THREE.Loader.prototype.uv3(w.uvs,M[C*2],M[C*2+1],M[B*2],M[B*2+1],M[t*2],M[t*2+1])}function F(t){var C,B,E;C=j(a,t);B=j(a,t+ea);E=j(a,t+Z);t=j(a,t+l);THREE.Loader.prototype.uv4(w.uvs,M[C*2],M[C*2+1],M[B*2],M[B*2+1],M[E*2],M[E*2+1],M[t*2],M[t*2+1])}var w=this,H=0,x,Q=[],M=[],X,L,f,T,R,$,ca,J,aa,ua,Y,oa,ia,da,pa,ya,ea,Z,l,y,v,n,q,K,G;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,d,g);x={signature:a.substr(H, -8),header_bytes:o(a,H+8),vertex_coordinate_bytes:o(a,H+9),normal_coordinate_bytes:o(a,H+10),uv_coordinate_bytes:o(a,H+11),vertex_index_bytes:o(a,H+12),normal_index_bytes:o(a,H+13),uv_index_bytes:o(a,H+14),material_index_bytes:o(a,H+15),nvertices:j(a,H+16),nnormals:j(a,H+16+4),nuvs:j(a,H+16+8),ntri_flat:j(a,H+16+12),ntri_smooth:j(a,H+16+16),ntri_flat_uv:j(a,H+16+20),ntri_smooth_uv:j(a,H+16+24),nquad_flat:j(a,H+16+28),nquad_smooth:j(a,H+16+32),nquad_flat_uv:j(a,H+16+36),nquad_smooth_uv:j(a,H+16+40)}; -H+=x.header_bytes;X=x.vertex_index_bytes;L=x.vertex_index_bytes*2;f=x.vertex_index_bytes*3;T=x.vertex_index_bytes*3+x.material_index_bytes;R=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes;$=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*2;ca=x.vertex_index_bytes;J=x.vertex_index_bytes*2;aa=x.vertex_index_bytes*3;ua=x.vertex_index_bytes*4;Y=x.vertex_index_bytes*4+x.material_index_bytes;oa=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes;ia= -x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*2;da=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*3;pa=x.uv_index_bytes;ya=x.uv_index_bytes*2;ea=x.uv_index_bytes;Z=x.uv_index_bytes*2;l=x.uv_index_bytes*3;g=x.vertex_index_bytes*3+x.material_index_bytes;G=x.vertex_index_bytes*4+x.material_index_bytes;y=x.ntri_flat*g;v=x.ntri_smooth*(g+x.normal_index_bytes*3);n=x.ntri_flat_uv*(g+x.uv_index_bytes*3);q=x.ntri_smooth_uv*(g+x.normal_index_bytes*3+x.uv_index_bytes* -3);K=x.nquad_flat*G;g=x.nquad_smooth*(G+x.normal_index_bytes*4);G=x.nquad_flat_uv*(G+x.uv_index_bytes*4);H+=function(t){for(var C,B,E,S=x.vertex_coordinate_bytes*3,na=t+x.nvertices*S;t>7)-127;y|=(D&127)<<16|A<<8;if(y==0&&H==-127)return 0;return(1-2*(P>>7))*(1+y*Math.pow(2,-23))*Math.pow(2,H)}function j(k,o){var y=p(k,o),A=p(k,o+1),D=p(k,o+2);return(p(k,o+3)<<24)+(D<<16)+(A<<8)+y}function l(k,o){var y=p(k,o);return(p(k,o+1)<<8)+y}function n(k,o){var y=p(k,o);return y>127?y-256:y}function p(k,o){return k.charCodeAt(o)&255}function w(k){var o,y,A;o=j(a,k); +y=j(a,k+Y);A=j(a,k+M);k=l(a,k+e);THREE.Loader.prototype.f3(u,o,y,A,k)}function t(k){var o,y,A,D,P,H;o=j(a,k);y=j(a,k+Y);A=j(a,k+M);D=l(a,k+e);P=j(a,k+V);H=j(a,k+S);k=j(a,k+ba);THREE.Loader.prototype.f3n(u,N,o,y,A,D,P,H,k)}function q(k){var o,y,A,D;o=j(a,k);y=j(a,k+ea);A=j(a,k+J);D=j(a,k+ca);k=l(a,k+wa);THREE.Loader.prototype.f4(u,o,y,A,D,k)}function x(k){var o,y,A,D,P,H,O,la;o=j(a,k);y=j(a,k+ea);A=j(a,k+J);D=j(a,k+ca);P=l(a,k+wa);H=j(a,k+da);O=j(a,k+ta);la=j(a,k+ha);k=j(a,k+fa);THREE.Loader.prototype.f4n(u, +N,o,y,A,D,P,H,O,la,k)}function B(k){var o,y;o=j(a,k);y=j(a,k+ra);k=j(a,k+xa);THREE.Loader.prototype.uv3(u.uvs,L[o*2],L[o*2+1],L[y*2],L[y*2+1],L[k*2],L[k*2+1])}function E(k){var o,y,A;o=j(a,k);y=j(a,k+ga);A=j(a,k+aa);k=j(a,k+oa);THREE.Loader.prototype.uv4(u.uvs,L[o*2],L[o*2+1],L[y*2],L[y*2+1],L[A*2],L[A*2+1],L[k*2],L[k*2+1])}var u=this,F=0,v,N=[],L=[],Y,M,e,V,S,ba,ea,J,ca,wa,da,ta,ha,fa,ra,xa,ga,aa,oa,pa,R,ia,m,z,C;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(u,d,g);v={signature:a.substr(F, +8),header_bytes:p(a,F+8),vertex_coordinate_bytes:p(a,F+9),normal_coordinate_bytes:p(a,F+10),uv_coordinate_bytes:p(a,F+11),vertex_index_bytes:p(a,F+12),normal_index_bytes:p(a,F+13),uv_index_bytes:p(a,F+14),material_index_bytes:p(a,F+15),nvertices:j(a,F+16),nnormals:j(a,F+16+4),nuvs:j(a,F+16+8),ntri_flat:j(a,F+16+12),ntri_smooth:j(a,F+16+16),ntri_flat_uv:j(a,F+16+20),ntri_smooth_uv:j(a,F+16+24),nquad_flat:j(a,F+16+28),nquad_smooth:j(a,F+16+32),nquad_flat_uv:j(a,F+16+36),nquad_smooth_uv:j(a,F+16+40)}; +F+=v.header_bytes;Y=v.vertex_index_bytes;M=v.vertex_index_bytes*2;e=v.vertex_index_bytes*3;V=v.vertex_index_bytes*3+v.material_index_bytes;S=v.vertex_index_bytes*3+v.material_index_bytes+v.normal_index_bytes;ba=v.vertex_index_bytes*3+v.material_index_bytes+v.normal_index_bytes*2;ea=v.vertex_index_bytes;J=v.vertex_index_bytes*2;ca=v.vertex_index_bytes*3;wa=v.vertex_index_bytes*4;da=v.vertex_index_bytes*4+v.material_index_bytes;ta=v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes;ha= +v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes*2;fa=v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes*3;ra=v.uv_index_bytes;xa=v.uv_index_bytes*2;ga=v.uv_index_bytes;aa=v.uv_index_bytes*2;oa=v.uv_index_bytes*3;g=v.vertex_index_bytes*3+v.material_index_bytes;C=v.vertex_index_bytes*4+v.material_index_bytes;pa=v.ntri_flat*g;R=v.ntri_smooth*(g+v.normal_index_bytes*3);ia=v.ntri_flat_uv*(g+v.uv_index_bytes*3);m=v.ntri_smooth_uv*(g+v.normal_index_bytes*3+v.uv_index_bytes* +3);z=v.nquad_flat*C;g=v.nquad_smooth*(C+v.normal_index_bytes*4);C=v.nquad_flat_uv*(C+v.uv_index_bytes*4);F+=function(k){for(var o,y,A,D=v.vertex_coordinate_bytes*3,P=k+v.nvertices*D;k>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/ @@ -12,57 +12,57 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPosit 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,d,f){this.set(a||0,b||0,d||0,f||1)}; THREE.Vector4.prototype={set:function(a,b,d,f){this.x=a;this.y=b;this.z=d;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,d,f=a.objects,h=[];a=0;for(b=f.length;a0&&L>0&&aa+L<1}var d,f,h,k, -l,q,n,w,A,y,D,E=a.geometry,F=E.vertices,H=[];d=0;for(f=E.faces.length;dn?f:n;h=h>w?h:w}a()}; +THREE.Ray.prototype={intersectScene:function(a){var b,d,f=a.objects,h=[];a=0;for(b=f.length;a0&&L>0&&aa+L<1}var d,f,h,l, +m,q,n,w,A,y,D,E=a.geometry,F=E.vertices,H=[];d=0;for(f=E.faces.length;dn?f:n;h=h>w?h:w}a()}; this.add3Points=function(n,w,A,y,D,E){if(q){q=!1;b=nA?n>D?n:D:A>D?A:D;h=w>y?w>E?w:E:y>E?y:E}else{b=nA?n>D?n>f?n:f:D>f?D:f:A>D?A>f?A:f:D>f?D:f;h=w>y?w>E?w>h?w:h:E>h?E:h:y>E?y>h?y:h:E>h?E:h}a()};this.addRectangle=function(n){if(q){q=!1;b=n.getLeft();d=n.getTop();f=n.getRight();h=n.getBottom()}else{b=bn.getRight()? f:n.getRight();h=h>n.getBottom()?h:n.getBottom()}a()};this.inflate=function(n){b-=n;d-=n;f+=n;h+=n;a()};this.minSelf=function(n){b=b>n.getLeft()?b:n.getLeft();d=d>n.getTop()?d:n.getTop();f=f=0&&Math.min(h,n.getBottom())-Math.max(d,n.getTop())>=0};this.empty=function(){q=!0;h=f=d=b=0;a()};this.isEmpty=function(){return q}}; 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,d,f,h,k,l,q,n,w,A,y,D,E,F,H){this.set(a||1,b||0,d||0,f||0,h||0,k||1,l||0,q||0,n||0,w||0,A||1,y||0,D||0,E||0,F||0,H||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(a,b,d,f,h,k,l,q,n,w,A,y,D,E,F,H){this.n11=a;this.n12=b;this.n13=d;this.n14=f;this.n21=h;this.n22=k;this.n23=l;this.n24=q;this.n31=n;this.n32=w;this.n33=A;this.n34=y;this.n41=D;this.n42=E;this.n43=F;this.n44=H;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,d){var f=THREE.Matrix4.__v1, -h=THREE.Matrix4.__v2,k=THREE.Matrix4.__v3;k.sub(a,b).normalize();f.cross(d,k).normalize();h.cross(k,f).normalize();this.n11=f.x;this.n12=h.x;this.n13=k.x;this.n21=f.y;this.n22=h.y;this.n23=k.y;this.n31=f.z;this.n32=h.z;this.n33=k.z;return this},multiplyVector3:function(a){var b=a.x,d=a.y,f=a.z,h=1/(this.n41*b+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*f+this.n14)*h;a.y=(this.n21*b+this.n22*d+this.n23*f+this.n24)*h;a.z=(this.n31*b+this.n32*d+this.n33*f+this.n34)*h;return a}, +THREE.Matrix4=function(a,b,d,f,h,l,m,q,n,w,A,y,D,E,F,H){this.set(a||1,b||0,d||0,f||0,h||0,l||1,m||0,q||0,n||0,w||0,A||1,y||0,D||0,E||0,F||0,H||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(a,b,d,f,h,l,m,q,n,w,A,y,D,E,F,H){this.n11=a;this.n12=b;this.n13=d;this.n14=f;this.n21=h;this.n22=l;this.n23=m;this.n24=q;this.n31=n;this.n32=w;this.n33=A;this.n34=y;this.n41=D;this.n42=E;this.n43=F;this.n44=H;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,d){var f=THREE.Matrix4.__v1, +h=THREE.Matrix4.__v2,l=THREE.Matrix4.__v3;l.sub(a,b).normalize();f.cross(d,l).normalize();h.cross(l,f).normalize();this.n11=f.x;this.n12=h.x;this.n13=l.x;this.n21=f.y;this.n22=h.y;this.n23=l.y;this.n31=f.z;this.n32=h.z;this.n33=l.z;return this},multiplyVector3:function(a){var b=a.x,d=a.y,f=a.z,h=1/(this.n41*b+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*f+this.n14)*h;a.y=(this.n21*b+this.n22*d+this.n23*f+this.n24)*h;a.z=(this.n31*b+this.n32*d+this.n33*f+this.n34)*h;return a}, multiplyVector3OnlyZ:function(a){var b=a.x,d=a.y;a=a.z;return(this.n31*b+this.n32*d+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*d+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,d=a.y,f=a.z,h=a.w;a.x=this.n11*b+this.n12*d+this.n13*f+this.n14*h;a.y=this.n21*b+this.n22*d+this.n23*f+this.n24*h;a.z=this.n31*b+this.n32*d+this.n33*f+this.n34*h;a.w=this.n41*b+this.n42*d+this.n43*f+this.n44*h;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 d=a.n11,f=a.n12,h=a.n13,k=a.n14,l=a.n21,q=a.n22,n=a.n23,w=a.n24,A=a.n31,y=a.n32,D=a.n33,E=a.n34,F=a.n41,H=a.n42,L=a.n43,M=a.n44,V=b.n11,X=b.n12,ca=b.n13,aa=b.n14,Y=b.n21,da=b.n22,c=b.n23,oa=b.n24,ma=b.n31,pa=b.n32,qa=b.n33,ra=b.n34;this.n11=d*V+f*Y+h*ma;this.n12=d*X+f*da+h*pa; -this.n13=d*ca+f*c+h*qa;this.n14=d*aa+f*oa+h*ra+k;this.n21=l*V+q*Y+n*ma;this.n22=l*X+q*da+n*pa;this.n23=l*ca+q*c+n*qa;this.n24=l*aa+q*oa+n*ra+w;this.n31=A*V+y*Y+D*ma;this.n32=A*X+y*da+D*pa;this.n33=A*ca+y*c+D*qa;this.n34=A*aa+y*oa+D*ra+E;this.n41=F*V+H*Y+L*ma;this.n42=F*X+H*da+L*pa;this.n43=F*ca+H*c+L*qa;this.n44=F*aa+H*oa+L*ra+M;return this},multiplyToArray:function(a,b,d){this.multiply(a,b);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; +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 d=a.n11,f=a.n12,h=a.n13,l=a.n14,m=a.n21,q=a.n22,n=a.n23,w=a.n24,A=a.n31,y=a.n32,D=a.n33,E=a.n34,F=a.n41,H=a.n42,L=a.n43,M=a.n44,V=b.n11,X=b.n12,ca=b.n13,aa=b.n14,Y=b.n21,fa=b.n22,c=b.n23,na=b.n24,la=b.n31,oa=b.n32,pa=b.n33,qa=b.n34;this.n11=d*V+f*Y+h*la;this.n12=d*X+f*fa+h*oa; +this.n13=d*ca+f*c+h*pa;this.n14=d*aa+f*na+h*qa+l;this.n21=m*V+q*Y+n*la;this.n22=m*X+q*fa+n*oa;this.n23=m*ca+q*c+n*pa;this.n24=m*aa+q*na+n*qa+w;this.n31=A*V+y*Y+D*la;this.n32=A*X+y*fa+D*oa;this.n33=A*ca+y*c+D*pa;this.n34=A*aa+y*na+D*qa+E;this.n41=F*V+H*Y+L*la;this.n42=F*X+H*fa+L*oa;this.n43=F*ca+H*c+L*pa;this.n44=F*aa+H*na+L*qa+M;return this},multiplyToArray:function(a,b,d){this.multiply(a,b);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,b=this.n12,d=this.n13,f=this.n14,h=this.n21, -k=this.n22,l=this.n23,q=this.n24,n=this.n31,w=this.n32,A=this.n33,y=this.n34,D=this.n41,E=this.n42,F=this.n43,H=this.n44;return f*l*w*D-d*q*w*D-f*k*A*D+b*q*A*D+d*k*y*D-b*l*y*D-f*l*n*E+d*q*n*E+f*h*A*E-a*q*A*E-d*h*y*E+a*l*y*E+f*k*n*F-b*q*n*F-f*h*w*F+a*q*w*F+b*h*y*F-a*k*y*F-d*k*n*H+b*l*n*H+d*h*w*H-a*l*w*H-b*h*A*H+a*k*A*H},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14= +l=this.n22,m=this.n23,q=this.n24,n=this.n31,w=this.n32,A=this.n33,y=this.n34,D=this.n41,E=this.n42,F=this.n43,H=this.n44;return f*m*w*D-d*q*w*D-f*l*A*D+b*q*A*D+d*l*y*D-b*m*y*D-f*m*n*E+d*q*n*E+f*h*A*E-a*q*A*E-d*h*y*E+a*m*y*E+f*l*n*F-b*q*n*F-f*h*w*F+a*q*w*F+b*h*y*F-a*l*y*F-d*l*n*H+b*m*n*H+d*h*w*H-a*m*w*H-b*h*A*H+a*l*A*H},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14= a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]= this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24; a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,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,d){this.set(1,0,0,a,0,1,0,b,0,0,1,d,0,0,0,1);return this},setScale:function(a,b,d){this.set(a,0,0,0,0,b,0,0,0,0,d,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 d=Math.cos(b),f=Math.sin(b),h=1-d,k=a.x,l=a.y,q=a.z,n=h*k,w=h*l;this.set(n*k+d,n*l-f*q,n*q+f*l,0,n*l+f*q,w*l+d,w*q-f*k,0,n*q-f*l, -w*q+f*k,h*q*q+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 b=a.x,d=a.y,f=a.z;a=Math.cos(b);b=Math.sin(b);var h=Math.cos(d);d=Math.sin(d);var k=Math.cos(f);f=Math.sin(f);var l=a*d,q=b*d;this.n11=h*k;this.n12=-h*f;this.n13=d;this.n21=q*k+a*f;this.n22=-q*f+a*k;this.n23=-b*h;this.n31=-l*k+b*f;this.n32=l*f+b*k;this.n33=a*h;return this},setRotationFromQuaternion:function(a){var b=a.x,d=a.y,f=a.z,h=a.w,k=b+b,l= -d+d,q=f+f;a=b*k;var n=b*l;b*=q;var w=d*l;d*=q;f*=q;k*=h;l*=h;h*=q;this.n11=1-(w+f);this.n12=n-h;this.n13=b+l;this.n21=n+h;this.n22=1-(a+f);this.n23=d-k;this.n31=b-l;this.n32=d+k;this.n33=1-(a+w);return this},scale:function(a){var b=a.x,d=a.y;a=a.z;this.n11*=b;this.n12*=d;this.n13*=a;this.n21*=b;this.n22*=d;this.n23*=a;this.n31*=b;this.n32*=d;this.n33*=a;this.n41*=b;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, +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 d=Math.cos(b),f=Math.sin(b),h=1-d,l=a.x,m=a.y,q=a.z,n=h*l,w=h*m;this.set(n*l+d,n*m-f*q,n*q+f*m,0,n*m+f*q,w*m+d,w*q-f*l,0,n*q-f*m, +w*q+f*l,h*q*q+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 b=a.x,d=a.y,f=a.z;a=Math.cos(b);b=Math.sin(b);var h=Math.cos(d);d=Math.sin(d);var l=Math.cos(f);f=Math.sin(f);var m=a*d,q=b*d;this.n11=h*l;this.n12=-h*f;this.n13=d;this.n21=q*l+a*f;this.n22=-q*f+a*l;this.n23=-b*h;this.n31=-m*l+b*f;this.n32=m*f+b*l;this.n33=a*h;return this},setRotationFromQuaternion:function(a){var b=a.x,d=a.y,f=a.z,h=a.w,l=b+b,m= +d+d,q=f+f;a=b*l;var n=b*m;b*=q;var w=d*m;d*=q;f*=q;l*=h;m*=h;h*=q;this.n11=1-(w+f);this.n12=n-h;this.n13=b+m;this.n21=n+h;this.n22=1-(a+f);this.n23=d-l;this.n31=b-m;this.n32=d+l;this.n33=1-(a+w);return this},scale:function(a){var b=a.x,d=a.y;a=a.z;this.n11*=b;this.n12*=d;this.n13*=a;this.n21*=b;this.n22*=d;this.n23*=a;this.n31*=b;this.n32*=d;this.n33*=a;this.n41*=b;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, b){var d=1/b.x,f=1/b.y,h=1/b.z;this.n11=a.n11*d;this.n21=a.n21*d;this.n31=a.n31*d;this.n12=a.n12*f;this.n22=a.n22*f;this.n32=a.n32*f;this.n13=a.n13*h;this.n23=a.n23*h;this.n33=a.n33*h}}; -THREE.Matrix4.makeInvert=function(a,b){var d=a.n11,f=a.n12,h=a.n13,k=a.n14,l=a.n21,q=a.n22,n=a.n23,w=a.n24,A=a.n31,y=a.n32,D=a.n33,E=a.n34,F=a.n41,H=a.n42,L=a.n43,M=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=n*E*H-w*D*H+w*y*L-q*E*L-n*y*M+q*D*M;b.n12=k*D*H-h*E*H-k*y*L+f*E*L+h*y*M-f*D*M;b.n13=h*w*H-k*n*H+k*q*L-f*w*L-h*q*M+f*n*M;b.n14=k*n*y-h*w*y-k*q*D+f*w*D+h*q*E-f*n*E;b.n21=w*D*F-n*E*F-w*A*L+l*E*L+n*A*M-l*D*M;b.n22=h*E*F-k*D*F+k*A*L-d*E*L-h*A*M+d*D*M;b.n23=k*n*F-h*w*F-k*l*L+d*w*L+h*l*M-d*n*M; -b.n24=h*w*A-k*n*A+k*l*D-d*w*D-h*l*E+d*n*E;b.n31=q*E*F-w*y*F+w*A*H-l*E*H-q*A*M+l*y*M;b.n32=k*y*F-f*E*F-k*A*H+d*E*H+f*A*M-d*y*M;b.n33=h*w*F-k*q*F+k*l*H-d*w*H-f*l*M+d*q*M;b.n34=k*q*A-f*w*A-k*l*y+d*w*y+f*l*E-d*q*E;b.n41=n*y*F-q*D*F-n*A*H+l*D*H+q*A*L-l*y*L;b.n42=f*D*F-h*y*F+h*A*H-d*D*H-f*A*L+d*y*L;b.n43=h*q*F-f*n*F-h*l*H+d*n*H+f*l*L-d*q*L;b.n44=f*n*A-h*q*A+h*l*y-d*n*y-f*l*D+d*q*D;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,d=b.m,f=a.n33*a.n22-a.n32*a.n23,h=-a.n33*a.n21+a.n31*a.n23,k=a.n32*a.n21-a.n31*a.n22,l=-a.n33*a.n12+a.n32*a.n13,q=a.n33*a.n11-a.n31*a.n13,n=-a.n32*a.n11+a.n31*a.n12,w=a.n23*a.n12-a.n22*a.n13,A=-a.n23*a.n11+a.n21*a.n13,y=a.n22*a.n11-a.n21*a.n12;a=a.n11*f+a.n21*l+a.n31*w;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*f;d[1]=a*h;d[2]=a*k;d[3]=a*l;d[4]=a*q;d[5]=a*n;d[6]=a*w;d[7]=a*A;d[8]=a*y;return b}; -THREE.Matrix4.makeFrustum=function(a,b,d,f,h,k){var l;l=new THREE.Matrix4;l.n11=2*h/(b-a);l.n12=0;l.n13=(b+a)/(b-a);l.n14=0;l.n21=0;l.n22=2*h/(f-d);l.n23=(f+d)/(f-d);l.n24=0;l.n31=0;l.n32=0;l.n33=-(k+h)/(k-h);l.n34=-2*k*h/(k-h);l.n41=0;l.n42=0;l.n43=-1;l.n44=0;return l};THREE.Matrix4.makePerspective=function(a,b,d,f){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,d,f)}; -THREE.Matrix4.makeOrtho=function(a,b,d,f,h,k){var l,q,n,w;l=new THREE.Matrix4;q=b-a;n=d-f;w=k-h;l.n11=2/q;l.n12=0;l.n13=0;l.n14=-((b+a)/q);l.n21=0;l.n22=2/n;l.n23=0;l.n24=-((d+f)/n);l.n31=0;l.n32=0;l.n33=-2/w;l.n34=-((k+h)/w);l.n41=0;l.n42=0;l.n43=0;l.n44=1;return l};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; +THREE.Matrix4.makeInvert=function(a,b){var d=a.n11,f=a.n12,h=a.n13,l=a.n14,m=a.n21,q=a.n22,n=a.n23,w=a.n24,A=a.n31,y=a.n32,D=a.n33,E=a.n34,F=a.n41,H=a.n42,L=a.n43,M=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=n*E*H-w*D*H+w*y*L-q*E*L-n*y*M+q*D*M;b.n12=l*D*H-h*E*H-l*y*L+f*E*L+h*y*M-f*D*M;b.n13=h*w*H-l*n*H+l*q*L-f*w*L-h*q*M+f*n*M;b.n14=l*n*y-h*w*y-l*q*D+f*w*D+h*q*E-f*n*E;b.n21=w*D*F-n*E*F-w*A*L+m*E*L+n*A*M-m*D*M;b.n22=h*E*F-l*D*F+l*A*L-d*E*L-h*A*M+d*D*M;b.n23=l*n*F-h*w*F-l*m*L+d*w*L+h*m*M-d*n*M; +b.n24=h*w*A-l*n*A+l*m*D-d*w*D-h*m*E+d*n*E;b.n31=q*E*F-w*y*F+w*A*H-m*E*H-q*A*M+m*y*M;b.n32=l*y*F-f*E*F-l*A*H+d*E*H+f*A*M-d*y*M;b.n33=h*w*F-l*q*F+l*m*H-d*w*H-f*m*M+d*q*M;b.n34=l*q*A-f*w*A-l*m*y+d*w*y+f*m*E-d*q*E;b.n41=n*y*F-q*D*F-n*A*H+m*D*H+q*A*L-m*y*L;b.n42=f*D*F-h*y*F+h*A*H-d*D*H-f*A*L+d*y*L;b.n43=h*q*F-f*n*F-h*m*H+d*n*H+f*m*L-d*q*L;b.n44=f*n*A-h*q*A+h*m*y-d*n*y-f*m*D+d*q*D;b.multiplyScalar(1/a.determinant());return b}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,d=b.m,f=a.n33*a.n22-a.n32*a.n23,h=-a.n33*a.n21+a.n31*a.n23,l=a.n32*a.n21-a.n31*a.n22,m=-a.n33*a.n12+a.n32*a.n13,q=a.n33*a.n11-a.n31*a.n13,n=-a.n32*a.n11+a.n31*a.n12,w=a.n23*a.n12-a.n22*a.n13,A=-a.n23*a.n11+a.n21*a.n13,y=a.n22*a.n11-a.n21*a.n12;a=a.n11*f+a.n21*m+a.n31*w;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*f;d[1]=a*h;d[2]=a*l;d[3]=a*m;d[4]=a*q;d[5]=a*n;d[6]=a*w;d[7]=a*A;d[8]=a*y;return b}; +THREE.Matrix4.makeFrustum=function(a,b,d,f,h,l){var m;m=new THREE.Matrix4;m.n11=2*h/(b-a);m.n12=0;m.n13=(b+a)/(b-a);m.n14=0;m.n21=0;m.n22=2*h/(f-d);m.n23=(f+d)/(f-d);m.n24=0;m.n31=0;m.n32=0;m.n33=-(l+h)/(l-h);m.n34=-2*l*h/(l-h);m.n41=0;m.n42=0;m.n43=-1;m.n44=0;return m};THREE.Matrix4.makePerspective=function(a,b,d,f){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,d,f)}; +THREE.Matrix4.makeOrtho=function(a,b,d,f,h,l){var m,q,n,w;m=new THREE.Matrix4;q=b-a;n=d-f;w=l-h;m.n11=2/q;m.n12=0;m.n13=0;m.n14=-((b+a)/q);m.n21=0;m.n22=2/n;m.n23=0;m.n24=-((d+f)/n);m.n31=0;m.n32=0;m.n33=-2/w;m.n34=-((l+h)/w);m.n41=0;m.n42=0;m.n43=0;m.n44=1;return m};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}; THREE.Object3D.prototype={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))}return!0},update:function(a,b,d){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){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){d.w=a.w;d.x=a.x;d.y=a.y;d.z=a.z;return d}var k=Math.acos(h),l=Math.sqrt(1-h*h);if(Math.abs(l)<0.0010){d.w=0.5*(a.w+b.w);d.x=0.5*(a.x+b.x);d.y=0.5*(a.y+b.y);d.z=0.5*(a.z+b.z);return d}h=Math.sin((1-f)*k)/l;f=Math.sin(f*k)/l;d.w=a.w*h+b.w*f;d.x=a.x*h+b.x*f;d.y=a.y*h+b.y*f;d.z=a.z*h+b.z*f;return d}; +THREE.Quaternion.prototype={set:function(a,b,d,f){this.x=a;this.y=b;this.z=d;this.w=f;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,d=a.x*b,f=a.y*b,h=a.z*b;a=Math.cos(f);f=Math.sin(f);b=Math.cos(-h);h=Math.sin(-h);var l=Math.cos(d);d=Math.sin(d);var m=a*b,q=f*h;this.w=m*l-q*d;this.x=m*d+q*l;this.y=f*b*l+a*h*d;this.z=a*h*l-f*b*d;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*= +-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,d=this.y,f=this.z,h=this.w,l=a.x,m=a.y,q=a.z;a=a.w;this.x=b*a+h*l+d*q-f*m;this.y=d*a+h*m+f*l-b*q;this.z=f*a+h*q+b*m-d*l;this.w=h*a-b*l-d*m-f*q;return this}, +multiplyVector3:function(a,b){b||(b=a);var d=a.x,f=a.y,h=a.z,l=this.x,m=this.y,q=this.z,n=this.w,w=n*d+m*h-q*f,A=n*f+q*d-l*h,y=n*h+l*f-m*d;d=-l*d-m*f-q*h;b.x=w*n+d*-l+A*-q-y*-m;b.y=A*n+d*-m+y*-l-w*-q;b.z=y*n+d*-q+w*-m-A*-l;return b}}; +THREE.Quaternion.slerp=function(a,b,d,f){var h=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(h)>=1){d.w=a.w;d.x=a.x;d.y=a.y;d.z=a.z;return d}var l=Math.acos(h),m=Math.sqrt(1-h*h);if(Math.abs(m)<0.0010){d.w=0.5*(a.w+b.w);d.x=0.5*(a.x+b.x);d.y=0.5*(a.y+b.y);d.z=0.5*(a.z+b.z);return d}h=Math.sin((1-f)*l)/m;f=Math.sin(f*l)/m;d.w=a.w*h+b.w*f;d.x=a.x*h+b.x*f;d.y=a.y*h+b.y*f;d.z=a.z*h+b.z*f;return d}; THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0}; -THREE.Face3=function(a,b,d,f,h){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=h instanceof Array?h:[h]};THREE.Face4=function(a,b,d,f,h,k){this.a=a;this.b=b;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=k instanceof Array?k:[k]}; +THREE.Face3=function(a,b,d,f,h){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=h instanceof Array?h:[h]};THREE.Face4=function(a,b,d,f,h,l){this.a=a;this.b=b;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=l instanceof Array?l:[l]}; 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.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1}; THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x], +b;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c]);d.vertexNormals[3].copy(f[d.d])}}},computeTangents:function(){function a(qa,za,Aa,va,Da,Ea,Fa){l=qa.vertices[za].position;m=qa.vertices[Aa].position;q=qa.vertices[va].position;n=h[Da];w=h[Ea];A=h[Fa];y=m.x-l.x;D=q.x-l.x;E=m.y- +l.y;F=q.y-l.y;H=m.z-l.z;L=q.z-l.z;M=w.u-n.u;V=A.u-n.u;X=w.v-n.v;ca=A.v-n.v;aa=1/(M*ca-V*X);c.set((ca*y-X*D)*aa,(ca*E-X*F)*aa,(ca*H-X*L)*aa);na.set((M*D-V*y)*aa,(M*F-V*E)*aa,(M*L-V*H)*aa);Y[za].addSelf(c);Y[Aa].addSelf(c);Y[va].addSelf(c);fa[za].addSelf(na);fa[Aa].addSelf(na);fa[va].addSelf(na)}var b,d,f,h,l,m,q,n,w,A,y,D,E,F,H,L,M,V,X,ca,aa,Y=[],fa=[],c=new THREE.Vector3,na=new THREE.Vector3,la=new THREE.Vector3,oa=new THREE.Vector3,pa=new THREE.Vector3;b=0;for(d=this.vertices.length;b0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x], y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,d=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z< this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,d=this.vertices.length;b=0){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLColorBuffer);c.vertexAttribPointer(e.color,3,c.FLOAT,!1,0,0)}if(e.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLNormalBuffer);c.vertexAttribPointer(e.normal,3,c.FLOAT,!1,0,0)}if(e.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLTangentBuffer);c.vertexAttribPointer(e.tangent,4,c.FLOAT,!1,0,0)}if(e.uv>=0)if(i.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLUVBuffer); c.vertexAttribPointer(e.uv,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(e.uv)}else c.disableVertexAttribArray(e.uv);if(e.uv2>=0)if(i.__webGLUV2Buffer){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLUV2Buffer);c.vertexAttribPointer(e.uv2,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(e.uv2)}else c.disableVertexAttribArray(e.uv2);if(g.skinning&&e.skinVertexA>=0&&e.skinVertexB>=0&&e.skinIndex>=0&&e.skinWeight>=0){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLSkinVertexABuffer);c.vertexAttribPointer(e.skinVertexA,4,c.FLOAT, !1,0,0);c.bindBuffer(c.ARRAY_BUFFER,i.__webGLSkinVertexBBuffer);c.vertexAttribPointer(e.skinVertexB,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,i.__webGLSkinIndicesBuffer);c.vertexAttribPointer(e.skinIndex,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,i.__webGLSkinWeightsBuffer);c.vertexAttribPointer(e.skinWeight,4,c.FLOAT,!1,0,0)}if(u instanceof THREE.Mesh)if(g.wireframe){c.lineWidth(g.wireframeLinewidth);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webGLLineBuffer);c.drawElements(c.LINES,i.__webGLLineCount, -c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,i.__webGLFaceCount,c.UNSIGNED_SHORT,0)}else if(u instanceof THREE.Line){u=u.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(g.linewidth);c.drawArrays(u,0,i.__webGLLineCount)}else if(u instanceof THREE.ParticleSystem)c.drawArrays(c.POINTS,0,i.__webGLParticleCount);else u instanceof THREE.Ribbon&&c.drawArrays(c.TRIANGLE_STRIP,0,i.__webGLVertexCount)}function k(e,j){if(!e.__webGLVertexBuffer)e.__webGLVertexBuffer= +c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,i.__webGLFaceCount,c.UNSIGNED_SHORT,0)}else if(u instanceof THREE.Line){u=u.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(g.linewidth);c.drawArrays(u,0,i.__webGLLineCount)}else if(u instanceof THREE.ParticleSystem)c.drawArrays(c.POINTS,0,i.__webGLParticleCount);else u instanceof THREE.Ribbon&&c.drawArrays(c.TRIANGLE_STRIP,0,i.__webGLVertexCount)}function l(e,j){if(!e.__webGLVertexBuffer)e.__webGLVertexBuffer= c.createBuffer();if(!e.__webGLNormalBuffer)e.__webGLNormalBuffer=c.createBuffer();if(e.hasPos){c.bindBuffer(c.ARRAY_BUFFER,e.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,e.positionArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(j.attributes.position);c.vertexAttribPointer(j.attributes.position,3,c.FLOAT,!1,0,0)}if(e.hasNormal){c.bindBuffer(c.ARRAY_BUFFER,e.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,e.normalArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(j.attributes.normal);c.vertexAttribPointer(j.attributes.normal, -3,c.FLOAT,!1,0,0)}c.drawArrays(c.TRIANGLES,0,e.count);e.count=0}function l(e){if(qa!=e.doubleSided){e.doubleSided?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE);qa=e.doubleSided}if(ra!=e.flipSided){e.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW);ra=e.flipSided}}function q(e){if(Aa!=e){e?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST);Aa=e}}function n(e){ja[0].set(e.n41-e.n11,e.n42-e.n12,e.n43-e.n13,e.n44-e.n14);ja[1].set(e.n41+e.n11,e.n42+e.n12,e.n43+e.n13,e.n44+e.n14);ja[2].set(e.n41+e.n21,e.n42+e.n22, -e.n43+e.n23,e.n44+e.n24);ja[3].set(e.n41-e.n21,e.n42-e.n22,e.n43-e.n23,e.n44-e.n24);ja[4].set(e.n41-e.n31,e.n42-e.n32,e.n43-e.n33,e.n44-e.n34);ja[5].set(e.n41+e.n31,e.n42+e.n32,e.n43+e.n33,e.n44+e.n34);var j;for(e=0;e<6;e++){j=ja[e];j.divideScalar(Math.sqrt(j.x*j.x+j.y*j.y+j.z*j.z))}}function w(e){for(var j=e.matrixWorld,m=-e.geometry.boundingSphere.radius*Math.max(e.scale.x,Math.max(e.scale.y,e.scale.z)),g=0;g<6;g++){e=ja[g].x*j.n14+ja[g].y*j.n24+ja[g].z*j.n34+ja[g].w;if(e<=m)return!1}return!0}function A(e, -j){e.list[e.count]=j;e.count+=1}function y(e){var j,m,g=e.object,i=e.opaque,u=e.transparent;u.count=0;e=i.count=0;for(j=g.materials.length;e65535){v[x].counter+=1;s=v[x].hash+"_"+v[x].counter;e.geometryGroups[s]==undefined&&(e.geometryGroups[s]={faces:[],materials:r,vertices:0})}e.geometryGroups[s].faces.push(i); -e.geometryGroups[s].vertices+=o}}function L(e,j,m){e.push({buffer:j,object:m,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function M(e){if(e!=za){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;case THREE.BillboardBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:c.blendEquation(c.FUNC_REVERSE_SUBTRACT); -c.blendFunc(c.ONE,c.ONE);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}za=e}}function V(e,j,m){if((m.width&m.width-1)==0&&(m.height&m.height-1)==0){c.texParameteri(e,c.TEXTURE_WRAP_S,Y(j.wrapS));c.texParameteri(e,c.TEXTURE_WRAP_T,Y(j.wrapT));c.texParameteri(e,c.TEXTURE_MAG_FILTER,Y(j.magFilter));c.texParameteri(e,c.TEXTURE_MIN_FILTER,Y(j.minFilter));c.generateMipmap(e)}else{c.texParameteri(e,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(e,c.TEXTURE_WRAP_T, +e.geometryGroups[s].vertices+=o}}function L(e,j,k){e.push({buffer:j,object:k,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function M(e){if(e!=za){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;case THREE.BillboardBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:c.blendEquation(c.FUNC_REVERSE_SUBTRACT); +c.blendFunc(c.ONE,c.ONE);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}za=e}}function V(e,j,k){if((k.width&k.width-1)==0&&(k.height&k.height-1)==0){c.texParameteri(e,c.TEXTURE_WRAP_S,Y(j.wrapS));c.texParameteri(e,c.TEXTURE_WRAP_T,Y(j.wrapT));c.texParameteri(e,c.TEXTURE_MAG_FILTER,Y(j.magFilter));c.texParameteri(e,c.TEXTURE_MIN_FILTER,Y(j.minFilter));c.generateMipmap(e)}else{c.texParameteri(e,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(e,c.TEXTURE_WRAP_T, c.CLAMP_TO_EDGE);c.texParameteri(e,c.TEXTURE_MAG_FILTER,aa(j.magFilter));c.texParameteri(e,c.TEXTURE_MIN_FILTER,aa(j.minFilter))}}function X(e,j){if(e&&!e.__webGLFramebuffer){e.__webGLFramebuffer=c.createFramebuffer();e.__webGLRenderbuffer=c.createRenderbuffer();e.__webGLTexture=c.createTexture();c.bindRenderbuffer(c.RENDERBUFFER,e.__webGLRenderbuffer);c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,e.width,e.height);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texParameteri(c.TEXTURE_2D, c.TEXTURE_WRAP_S,Y(e.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,Y(e.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,Y(e.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,Y(e.minFilter));c.texImage2D(c.TEXTURE_2D,0,Y(e.format),e.width,e.height,0,Y(e.format),Y(e.type),null);c.bindFramebuffer(c.FRAMEBUFFER,e.__webGLFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,e.__webGLTexture,0);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT, -c.RENDERBUFFER,e.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var m,g,i;if(e){m=e.__webGLFramebuffer;g=e.width;i=e.height}else{m=null;g=da.width;i=da.height}if(m!=ma){c.bindFramebuffer(c.FRAMEBUFFER,m);c.viewport(0,0,g,i);j&&c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT);ma=m}}function ca(e,j){var m;if(e=="fragment")m=c.createShader(c.FRAGMENT_SHADER);else e=="vertex"&&(m=c.createShader(c.VERTEX_SHADER));c.shaderSource(m, -j);c.compileShader(m);if(!c.getShaderParameter(m,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(m));return null}return m}function aa(e){switch(e){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return c.LINEAR}}function Y(e){switch(e){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT; +c.RENDERBUFFER,e.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var k,g,i;if(e){k=e.__webGLFramebuffer;g=e.width;i=e.height}else{k=null;g=Ea;i=Fa}if(k!=la){c.bindFramebuffer(c.FRAMEBUFFER,k);c.viewport(va,Da,g,i);j&&c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT);la=k}}function ca(e,j){var k;if(e=="fragment")k=c.createShader(c.FRAGMENT_SHADER);else e=="vertex"&&(k=c.createShader(c.VERTEX_SHADER));c.shaderSource(k, +j);c.compileShader(k);if(!c.getShaderParameter(k,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(k));return null}return k}function aa(e){switch(e){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return c.LINEAR}}function Y(e){switch(e){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT; case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE;case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT; -case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var da=document.createElement("canvas"),c,oa=null,ma=null,pa=this,qa=null,ra=null,za=null,Aa=null,ja=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4, -new THREE.Vector4,new THREE.Vector4],va=new THREE.Matrix4,Ga=new Float32Array(16),Da=new Float32Array(16),Ba=new THREE.Vector4,Ma=!0,Na=new THREE.Color(0),Oa=0;if(a){if(a.antialias!==undefined)Ma=a.antialias;a.clearColor!==undefined&&Na.setHex(a.clearColor);if(a.clearAlpha!==undefined)Oa=a.clearAlpha}this.domElement=da;this.autoClear=!0;this.sortObjects=!0;(function(e,j,m){try{if(!(c=da.getContext("experimental-webgl",{antialias:e})))throw"Error creating WebGL context.";}catch(g){console.error(g)}c.clearColor(0, -0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(j.r,j.g,j.b,m);_cullEnabled=!0})(Ma,Na,Oa);this.context=c;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(e,j){da.width=e;da.height=j;c.viewport(0,0,da.width,da.height)};this.setClearColorHex=function(e,j){var m= -new THREE.Color(e);c.clearColor(m.r,m.g,m.b,j)};this.setClearColor=function(e,j){c.clearColor(e.r,e.g,e.b,j)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.initMaterial=function(e,j,m){var g,i;if(e instanceof THREE.MeshDepthMaterial)d(e,THREE.ShaderLib.depth);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);var u,o,r,x;i=r=x=0;for(u=j.length;i0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+u.maxDirLights,"#define MAX_POINT_LIGHTS "+u.maxPointLights,u.map?"#define USE_MAP":"",u.envMap?"#define USE_ENVMAP":"",u.lightMap?"#define USE_LIGHTMAP":"",u.vertexColors?"#define USE_COLOR":"",u.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); -c.attachShader(m,ca("fragment",i+x));c.attachShader(m,ca("vertex",u+j));c.linkProgram(m);c.getProgramParameter(m,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(m,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");m.uniforms={};m.attributes={};e.program=m;m=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(g in e.uniforms)m.push(g);g=e.program;x=0;for(j=m.length;x< -j;x++){i=m[x];g.uniforms[i]=c.getUniformLocation(g,i)}g=e.program;m=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];x=0;for(j=m.length;x=0&&c.enableVertexAttribArray(g.color);g.normal>=0&&c.enableVertexAttribArray(g.normal);g.tangent>=0&&c.enableVertexAttribArray(g.tangent);if(e.skinning&&g.skinVertexA>=0&&g.skinVertexB>= -0&&g.skinIndex>=0&&g.skinWeight>=0){c.enableVertexAttribArray(g.skinVertexA);c.enableVertexAttribArray(g.skinVertexB);c.enableVertexAttribArray(g.skinIndex);c.enableVertexAttribArray(g.skinWeight)}};this.render=function(e,j,m,g){var i,u,o,r,x,s,v,J,P=e.lights,N=e.fog;j.matrixAutoUpdate&&j.update();j.matrixWorldInverse.flattenToArray(Da);j.projectionMatrix.flattenToArray(Ga);va.multiply(j.projectionMatrix,j.matrixWorldInverse);n(va);e.update(undefined,!1,j);this.initWebGLObjects(e,j);X(m,g!==undefined? -g:!0);this.autoClear&&this.clear();x=e.__webglObjects.length;for(g=0;g0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+u.maxDirLights,"#define MAX_POINT_LIGHTS "+u.maxPointLights,u.map?"#define USE_MAP":"",u.envMap?"#define USE_ENVMAP":"",u.lightMap? +"#define USE_LIGHTMAP":"",u.vertexColors?"#define USE_COLOR":"",u.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); +c.attachShader(k,ca("fragment",i+x));c.attachShader(k,ca("vertex",u+j));c.linkProgram(k);c.getProgramParameter(k,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(k,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");k.uniforms={};k.attributes={};e.program=k;k=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(g in e.uniforms)k.push(g);g=e.program;x=0;for(j=k.length;x< +j;x++){i=k[x];g.uniforms[i]=c.getUniformLocation(g,i)}g=e.program;k=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];x=0;for(j=k.length;x=0&&c.enableVertexAttribArray(g.color);g.normal>=0&&c.enableVertexAttribArray(g.normal);g.tangent>=0&&c.enableVertexAttribArray(g.tangent);if(e.skinning&&g.skinVertexA>=0&&g.skinVertexB>= +0&&g.skinIndex>=0&&g.skinWeight>=0){c.enableVertexAttribArray(g.skinVertexA);c.enableVertexAttribArray(g.skinVertexB);c.enableVertexAttribArray(g.skinIndex);c.enableVertexAttribArray(g.skinWeight)}};this.render=function(e,j,k,g){var i,u,o,r,x,s,v,J,P=e.lights,N=e.fog;j.matrixAutoUpdate&&j.update();j.matrixWorldInverse.flattenToArray(Ja);j.projectionMatrix.flattenToArray(Pa);Ga.multiply(j.projectionMatrix,j.matrixWorldInverse);n(Ga);e.update(undefined,!1,j);this.initWebGLObjects(e,j);X(k,g!==undefined? +g:!0);this.autoClear&&this.clear();x=e.__webglObjects.length;for(g=0;g=0;i--){g=m.__webglObjects[i].object;j==g&&m.__webglObjects.splice(i,1)}e.__objectsRemoved.splice(0,1)}j=0;for(m=e.__webglObjects.length;j=0;i--){g=k.__webglObjects[i].object;j==g&&k.__webglObjects.splice(i,1)}e.__objectsRemoved.splice(0,1)}j=0;for(k=e.__webglObjects.length;j0){c.bindBuffer(c.ARRAY_BUFFER,o.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,Ea,J)}if(Ca&&N>0){c.bindBuffer(c.ARRAY_BUFFER,o.__webGLUV2Buffer);c.bufferData(c.ARRAY_BUFFER,Fa,J)}if(Ia){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,sa,J);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER, -ka,J)}if(p>0){c.bindBuffer(c.ARRAY_BUFFER,o.__webGLSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,R,J);c.bindBuffer(c.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,S,J);c.bindBuffer(c.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,T,J);c.bindBuffer(c.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,U,J)}}}i.__dirtyVertices=!1;i.__dirtyElements=!1;i.__dirtyUvs=!1;i.__dirtyNormals=!1;i.__dirtyTangents=!1;i.__dirtyColors=!1}else if(g instanceof +R[p+8]=C.x;R[p+9]=C.y;R[p+10]=C.z;R[p+11]=1;R[p+12]=O.x;R[p+13]=O.y;R[p+14]=O.z;R[p+15]=1;z=xa[t.a];B=xa[t.b];C=xa[t.c];O=xa[t.d];S[p]=z.x;S[p+1]=z.y;S[p+2]=z.z;S[p+3]=1;S[p+4]=B.x;S[p+5]=B.y;S[p+6]=B.z;S[p+7]=1;S[p+8]=C.x;S[p+9]=C.y;S[p+10]=C.z;S[p+11]=1;S[p+12]=O.x;S[p+13]=O.y;S[p+14]=O.z;S[p+15]=1;p+=16}if(Oa&&ta.length){z=ta[t.a];B=ta[t.b];C=ta[t.c];O=ta[t.d];$[W]=z.r;$[W+1]=z.g;$[W+2]=z.b;$[W+3]=B.r;$[W+4]=B.g;$[W+5]=B.b;$[W+6]=C.r;$[W+7]=C.g;$[W+8]=C.b;$[W+9]=O.r;$[W+10]=O.g;$[W+11]=O.b;W+= +12}if(Na&&ea.hasTangents){z=ka[t.a].tangent;B=ka[t.b].tangent;C=ka[t.c].tangent;t=ka[t.d].tangent;Q[G]=z.x;Q[G+1]=z.y;Q[G+2]=z.z;Q[G+3]=z.w;Q[G+4]=B.x;Q[G+5]=B.y;Q[G+6]=B.z;Q[G+7]=B.w;Q[G+8]=C.x;Q[G+9]=C.y;Q[G+10]=C.z;Q[G+11]=C.w;Q[G+12]=t.x;Q[G+13]=t.y;Q[G+14]=t.z;Q[G+15]=t.w;G+=16}if(Ma)if(da.length==4&&Ta)for(t=0;t<4;t++){ba=da[t];ma[K]=ba.x;ma[K+1]=ba.y;ma[K+2]=ba.z;K+=3}else for(t=0;t<4;t++){ma[K]=ba.x;ma[K+1]=ba.y;ma[K+2]=ba.z;K+=3}if(Ca&&ga)for(t=0;t<4;t++){da=ga[t];Ha[v]=da.u;Ha[v+1]=da.v; +v+=2}if(Ca&&ha)for(t=0;t<4;t++){ga=ha[t];Ia[N]=ga.u;Ia[N+1]=ga.v;N+=2}if(La){sa[I]=s;sa[I+1]=s+1;sa[I+2]=s+2;sa[I+3]=s;sa[I+4]=s+2;sa[I+5]=s+3;I+=6;ja[ia]=s;ja[ia+1]=s+1;ja[ia+2]=s;ja[ia+3]=s+3;ja[ia+4]=s+1;ja[ia+5]=s+2;ja[ia+6]=s+2;ja[ia+7]=s+3;ia+=8;s+=4}}}if(Ka){c.bindBuffer(c.ARRAY_BUFFER,o.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,Z,J)}if(Oa&&ta.length){c.bindBuffer(c.ARRAY_BUFFER,o.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,$,J)}if(Ma){c.bindBuffer(c.ARRAY_BUFFER,o.__webGLNormalBuffer); +c.bufferData(c.ARRAY_BUFFER,ma,J)}if(Na&&ea.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,o.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,Q,J)}if(Ca&&v>0){c.bindBuffer(c.ARRAY_BUFFER,o.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,Ha,J)}if(Ca&&N>0){c.bindBuffer(c.ARRAY_BUFFER,o.__webGLUV2Buffer);c.bufferData(c.ARRAY_BUFFER,Ia,J)}if(La){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,sa,J);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER, +ja,J)}if(p>0){c.bindBuffer(c.ARRAY_BUFFER,o.__webGLSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,R,J);c.bindBuffer(c.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,S,J);c.bindBuffer(c.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,T,J);c.bindBuffer(c.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,U,J)}}}i.__dirtyVertices=!1;i.__dirtyElements=!1;i.__dirtyUvs=!1;i.__dirtyNormals=!1;i.__dirtyTangents=!1;i.__dirtyColors=!1}else if(g instanceof THREE.Ribbon){i=g.geometry;if(i.__dirtyVertices||i.__dirtyColors){g=i;u=c.DYNAMIC_DRAW;s=void 0;s=void 0;r=void 0;o=void 0;v=g.vertices;J=g.colors;N=v.length;P=J.length;I=g.__vertexArray;x=g.__colorArray;K=g.__dirtyColors;if(g.__dirtyVertices){for(s=0;s - three.js - misc - sound + three.js misc - sound @@ -33,7 +40,27 @@ - painting by Caravaggio - +
+ Floor (128x128)
+ mag: Linear
+ min: LinearMipMapLinear
+
+ Painting (748x600)
+ mag: Linear
+ min: Linear +
+ +
+ Floor
+ mag: Nearest
+ min: Nearest
+
+ Painting
+ mag: Nearest
+ min: Nearest +
+ + @@ -48,7 +75,7 @@ var container,stats; - var camera, scene, renderer; + var camera, scene, scene2, renderer; var mouseX = 0, mouseY = 0; @@ -68,7 +95,10 @@ camera.position.z = 1500; scene = new THREE.Scene(); + scene2 = new THREE.Scene(); + scene.fog = new THREE.Fog( 0x000000, 1500, 4000 ); + scene2.fog = scene.fog; // GROUND @@ -87,7 +117,12 @@ materialCanvas = new THREE.MeshBasicMaterial( { map: textureCanvas } ); textureCanvas.needsUpdate = true; - + + var textureCanvas2 = new THREE.Texture( imageCanvas, THREE.UVMapping, THREE.RepeatWrapping, THREE.RepeatWrapping, THREE.NearestFilter, THREE.NearestFilter ); + materialCanvas2 = new THREE.MeshBasicMaterial( { color:0xffccaa, map: textureCanvas2 } ); + + textureCanvas2.needsUpdate = true; + var i, j, uvs, geometryRepeat = new Plane( 100, 100, 1, 1 ); @@ -106,75 +141,88 @@ var meshCanvas = new THREE.Mesh( geometryRepeat, materialCanvas ); - meshCanvas.position.x = 0; - meshCanvas.position.y = 0; - meshCanvas.position.z = 0; meshCanvas.rotation.x = Math.PI / 2; meshCanvas.scale.x = meshCanvas.scale.y = meshCanvas.scale.z = 1000; meshCanvas.doubleSided = true; - scene.addObject( meshCanvas ); + + var meshCanvas2 = new THREE.Mesh( geometryRepeat, materialCanvas2 ); + meshCanvas2.rotation.x = Math.PI / 2; + meshCanvas2.scale.x = meshCanvas2.scale.y = meshCanvas2.scale.z = 1000; + meshCanvas2.doubleSided = true; + // PAINTING var callbackPainting = function( image ) { + texturePainting2.image = image; + texturePainting2.needsUpdate = true; + + scene.addObject( meshCanvas ); + scene2.addObject( meshCanvas2 ); + var geometry = new Plane( 100, 100, 1, 1 ), - mesh = new THREE.Mesh( geometry, materialPainting ); + mesh = new THREE.Mesh( geometry, materialPainting ), + mesh2 = new THREE.Mesh( geometry, materialPainting2 ); - mesh.position.x = 0; - mesh.position.y = 0; - mesh.position.z = 0; - mesh.scale.x = image.width / 100; - mesh.scale.y = image.height / 100; - mesh.scale.z = 1; - scene.addObject( mesh ); + addPainting( scene, mesh ); + addPainting( scene2, mesh2 ); + + function addPainting( zscene, zmesh ) { + + zmesh.scale.x = image.width / 100; + zmesh.scale.y = image.height / 100; - mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { color: 0x000000 } ) ); + zscene.addObject( zmesh ); - mesh.position.x = 0; - mesh.position.y = 0; - mesh.position.z = -0.5; - mesh.scale.x = 1.1 * image.width / 100; - mesh.scale.y = 1.1 * image.height / 100; - mesh.scale.z = 1; - scene.addObject( mesh ); + var meshFrame = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { color: 0x000000 } ) ); - mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { color: 0x000000, opacity: 0.9 } ) ); + meshFrame.position.z = -0.5; + meshFrame.scale.x = 1.1 * image.width / 100; + meshFrame.scale.y = 1.1 * image.height / 100; + + zscene.addObject( meshFrame ); - mesh.position.x = 0; - mesh.position.y = 0; - mesh.position.z = - 1.1 * image.height/2; - mesh.scale.x = 1.1 * image.width / 100; - mesh.scale.y = 1.1 * image.height / 100; - mesh.scale.z = 1; - mesh.rotation.x = -Math.PI / 2; - scene.addObject( mesh ); + var meshShadow = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { color: 0x000000, opacity: 0.9 } ) ); + + meshShadow.position.z = - 1.1 * image.height/2; + meshShadow.scale.x = 1.1 * image.width / 100; + meshShadow.scale.y = 1.1 * image.height / 100; + meshShadow.rotation.x = -Math.PI / 2; + zscene.addObject( meshShadow ); + + meshShadow.position.y = - 1.1 * image.height/2; + + var floorHeight = - 1.117 * image.height/2; + meshCanvas.position.y = meshCanvas2.position.y = floorHeight; + + } - mesh.position.y = - 1.1 * image.height/2; - meshCanvas.position.y = - 1.1125 * image.height/2; }; var texturePainting = ImageUtils.loadTexture( "textures/758px-Canestra_di_frutta_(Caravaggio).jpg", THREE.UVMapping, callbackPainting ), - materialPainting = new THREE.MeshBasicMaterial( { color:0xffffff, map: texturePainting } ); + texturePainting2 = new THREE.Texture(), + materialPainting = new THREE.MeshBasicMaterial( { color:0xffffff, map: texturePainting } ), + materialPainting2 = new THREE.MeshBasicMaterial( { color:0xffccaa, map: texturePainting2 } ); - //texturePainting.minFilter = texturePainting.magFilter = THREE.NearestFilter; + texturePainting2.minFilter = texturePainting2.magFilter = THREE.NearestFilter; texturePainting.minFilter = texturePainting.magFilter = THREE.LinearFilter; - renderer = new THREE.WebGLRenderer(); renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT ); renderer.domElement.style.position = "relative"; container.appendChild( renderer.domElement ); renderer.setClearColor( scene.fog.color, 1 ); - + renderer.autoClear = false; + stats = new Stats(); stats.domElement.style.position = 'absolute'; stats.domElement.style.top = '0px'; stats.domElement.style.zIndex = 100; - container.appendChild( stats.domElement ); + //container.appendChild( stats.domElement ); document.addEventListener( 'mousemove', onDocumentMouseMove, false ); @@ -203,8 +251,20 @@ camera.position.x += ( mouseX - camera.position.x ) * .05; camera.position.y += ( - ( mouseY - 200) - camera.position.y ) * .05; + renderer.enableScissorTest( false ); + renderer.clear(); + renderer.enableScissorTest( true ); + + //renderer.setViewport( 0, 0, SCREEN_WIDTH/2, SCREEN_HEIGHT ); + renderer.setScissor( 0, 0, SCREEN_WIDTH/2 - 2, SCREEN_HEIGHT ); renderer.render( scene, camera ); + + //renderer.setViewport( SCREEN_WIDTH/2, 0, SCREEN_WIDTH/2, SCREEN_HEIGHT ); + renderer.setScissor( SCREEN_WIDTH/2, 0, SCREEN_WIDTH/2 - 2, SCREEN_HEIGHT ); + renderer.render( scene2, camera ); + + } diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 8db20a94..032df912 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -33,6 +33,11 @@ THREE.WebGLRenderer = function ( parameters ) { _oldBlending = null, _oldDepth = null, + _viewportX = 0, + _viewportY = 0, + _viewportWidth = 0, + _viewportHeight = 0, + // camera matrices caches _frustum = [ @@ -86,10 +91,38 @@ THREE.WebGLRenderer = function ( parameters ) { _canvas.width = width; _canvas.height = height; - _gl.viewport( 0, 0, _canvas.width, _canvas.height ); + + this.setViewport( 0, 0, _canvas.width, _canvas.height ); }; + this.setViewport = function( x, y, width, height ) { + + _viewportX = x; + _viewportY = y; + + _viewportWidth = width; + _viewportHeight = height; + + _gl.viewport( _viewportX, _viewportY, _viewportWidth, _viewportHeight ); + + }; + + this.setScissor = function( x, y, width, height ) { + + _gl.scissor( x, y, width, height ); + + }; + + this.enableScissorTest = function( enable ) { + + if ( enable ) + _gl.enable( _gl.SCISSOR_TEST ); + else + _gl.disable( _gl.SCISSOR_TEST ); + + }; + this.setClearColorHex = function ( hex, alpha ) { var color = new THREE.Color( hex ); @@ -2866,15 +2899,15 @@ THREE.WebGLRenderer = function ( parameters ) { } else { framebuffer = null; - width = _canvas.width; - height = _canvas.height; + width = _viewportWidth; + height = _viewportHeight; } if( framebuffer != _oldFramebuffer ) { _gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer ); - _gl.viewport( 0, 0, width, height ); + _gl.viewport( _viewportX, _viewportY, width, height ); if ( clear ) {