diff --git a/build/Three.js b/build/Three.js index 39861cb58c30e24e201247fcf4a27c0a8d27411d..23ece349f27df79e0faf685e577d76a68edcb517 100755 --- a/build/Three.js +++ b/build/Three.js @@ -12,55 +12,56 @@ THREE.Vector4=function(a,b,g,d){this.x=a||0;this.y=b||0;this.z=g||0;this.w=d||1} THREE.Vector4.prototype={set:function(a,b,g,d){this.x=a;this.y=b;this.z=g;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){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)},toString:function(){return"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,g,d=a.objects,i=[];a=0;for(b=d.length;a0&&J>0&&m+J<1}var g,d,i,j,o,l,n,c,B,A, -v,u=a.geometry,G=u.vertices,L=[];g=0;for(d=u.faces.length;gn?d:n;i=i>c? -i:c}a()};this.add3Points=function(n,c,B,A,v,u){if(l){l=false;b=nB?n>v?n:v:B>v?B:v;i=c>A?c>u?c:u:A>u?A:u}else{b=nB?n>v?n>d?n:d:v>d?v:d:B>v?B>d?B:d:v>d?v:d;i=c>A?c>u?c>i?c:i:u>i?u:i:A>u?A>i?A:i:u>i?u:i}a()};this.addRectangle=function(n){if(l){l=false;b=n.getLeft();g=n.getTop();d=n.getRight();i=n.getBottom()}else{b=bn.getRight()?d:n.getRight();i=i>n.getBottom()?i:n.getBottom()}a()};this.inflate=function(n){b-=n;g-=n;d+=n;i+=n;a()};this.minSelf=function(n){b=b>n.getLeft()?b:n.getLeft();g=g>n.getTop()?g:n.getTop();d=d=0&&Math.min(i,n.getBottom())-Math.max(g,n.getTop())>=0};this.empty=function(){l=true;i=d=g=b=0;a()};this.isEmpty=function(){return l};this.toString= -function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+g+", bottom: "+i+", width: "+j+", height: "+o+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; -THREE.Matrix4=function(a,b,g,d,i,j,o,l,n,c,B,A,v,u,G,L){this.n11=a||1;this.n12=b||0;this.n13=g||0;this.n14=d||0;this.n21=i||0;this.n22=j||1;this.n23=o||0;this.n24=l||0;this.n31=n||0;this.n32=c||0;this.n33=B||1;this.n34=A||0;this.n41=v||0;this.n42=u||0;this.n43=G||0;this.n44=L||1}; -THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,g,d,i,j,o,l,n,c,B,A,v,u,G,L){this.n11=a;this.n12=b;this.n13=g;this.n14=d;this.n21=i;this.n22=j;this.n23=o;this.n24=l;this.n31=n;this.n32=c;this.n33=B;this.n34=A;this.n41=v;this.n42=u;this.n43=G;this.n44=L;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= -a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,g){var d=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();d.cross(g,j).normalize();i.cross(j,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=i.x;this.n22=i.y;this.n23=i.z;this.n24=-i.dot(a);this.n31=j.x; -this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,g=a.y,d=a.z,i=1/(this.n41*b+this.n42*g+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*g+this.n13*d+this.n14)*i;a.y=(this.n21*b+this.n22*g+this.n23*d+this.n24)*i;a.z=(this.n31*b+this.n32*g+this.n33*d+this.n34)*i;return a},multiplyVector4:function(a){var b=a.x,g=a.y,d=a.z,i=a.w;a.x=this.n11*b+this.n12*g+this.n13*d+this.n14*i;a.y=this.n21*b+this.n22*g+this.n23*d+this.n24* -i;a.z=this.n31*b+this.n32*g+this.n33*d+this.n34*i;a.w=this.n41*b+this.n42*g+this.n43*d+this.n44*i;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 g=a.n11,d=a.n12,i=a.n13,j=a.n14,o=a.n21,l=a.n22,n=a.n23,c=a.n24,B=a.n31,A=a.n32, -v=a.n33,u=a.n34,G=a.n41,L=a.n42,J=a.n43,I=a.n44,O=b.n11,E=b.n12,f=b.n13,m=b.n14,e=b.n21,p=b.n22,k=b.n23,h=b.n24,t=b.n31,w=b.n32,D=b.n33,q=b.n34,C=b.n41,Q=b.n42,s=b.n43,U=b.n44;this.n11=g*O+d*e+i*t+j*C;this.n12=g*E+d*p+i*w+j*Q;this.n13=g*f+d*k+i*D+j*s;this.n14=g*m+d*h+i*q+j*U;this.n21=o*O+l*e+n*t+c*C;this.n22=o*E+l*p+n*w+c*Q;this.n23=o*f+l*k+n*D+c*s;this.n24=o*m+l*h+n*q+c*U;this.n31=B*O+A*e+v*t+u*C;this.n32=B*E+A*p+v*w+u*Q;this.n33=B*f+A*k+v*D+u*s;this.n34=B*m+A*h+v*q+u*U;this.n41=G*O+L*e+J*t+I*C; -this.n42=G*E+L*p+J*w+I*Q;this.n43=G*f+L*k+J*D+I*s;this.n44=G*m+L*h+J*q+I*U;return this},multiplySelf:function(a){var b=this.n11,g=this.n12,d=this.n13,i=this.n14,j=this.n21,o=this.n22,l=this.n23,n=this.n24,c=this.n31,B=this.n32,A=this.n33,v=this.n34,u=this.n41,G=this.n42,L=this.n43,J=this.n44,I=a.n11,O=a.n21,E=a.n31,f=a.n41,m=a.n12,e=a.n22,p=a.n32,k=a.n42,h=a.n13,t=a.n23,w=a.n33,D=a.n43,q=a.n14,C=a.n24,Q=a.n34;a=a.n44;this.n11=b*I+g*O+d*E+i*f;this.n12=b*m+g*e+d*p+i*k;this.n13=b*h+g*t+d*w+i*D;this.n14= -b*q+g*C+d*Q+i*a;this.n21=j*I+o*O+l*E+n*f;this.n22=j*m+o*e+l*p+n*k;this.n23=j*h+o*t+l*w+n*D;this.n24=j*q+o*C+l*Q+n*a;this.n31=c*I+B*O+A*E+v*f;this.n32=c*m+B*e+A*p+v*k;this.n33=c*h+B*t+A*w+v*D;this.n34=c*q+B*C+A*Q+v*a;this.n41=u*I+G*O+L*E+J*f;this.n42=u*m+G*e+L*p+J*k;this.n43=u*h+G*t+L*w+J*D;this.n44=u*q+G*C+L*Q+J*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*= +THREE.Ray.prototype={intersectScene:function(a){var b,g,d=a.objects,i=[];a=0;for(b=d.length;a0&&N>0&&l+N<1}var g,d,i,k,o,m,n,c,C,B, +w,v=a.geometry,J=v.vertices,P=[];g=0;for(d=v.faces.length;gn?d:n;i=i>c? +i:c}a()};this.add3Points=function(n,c,C,B,w,v){if(m){m=false;b=nC?n>w?n:w:C>w?C:w;i=c>B?c>v?c:v:B>v?B:v}else{b=nC?n>w?n>d?n:d:w>d?w:d:C>w?C>d?C:d:w>d?w:d;i=c>B?c>v?c>i?c:i:v>i?v:i:B>v?B>i?B:i:v>i?v:i}a()};this.addRectangle=function(n){if(m){m=false;b=n.getLeft();g=n.getTop();d=n.getRight();i=n.getBottom()}else{b=bn.getRight()?d:n.getRight();i=i>n.getBottom()?i:n.getBottom()}a()};this.inflate=function(n){b-=n;g-=n;d+=n;i+=n;a()};this.minSelf=function(n){b=b>n.getLeft()?b:n.getLeft();g=g>n.getTop()?g:n.getTop();d=d=0&&Math.min(i,n.getBottom())-Math.max(g,n.getTop())>=0};this.empty=function(){m=true;i=d=g=b=0;a()};this.isEmpty=function(){return m};this.toString= +function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+g+", bottom: "+i+", width: "+k+", height: "+o+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; +THREE.Matrix4=function(a,b,g,d,i,k,o,m,n,c,C,B,w,v,J,P){this.n11=a||1;this.n12=b||0;this.n13=g||0;this.n14=d||0;this.n21=i||0;this.n22=k||1;this.n23=o||0;this.n24=m||0;this.n31=n||0;this.n32=c||0;this.n33=C||1;this.n34=B||0;this.n41=w||0;this.n42=v||0;this.n43=J||0;this.n44=P||1}; +THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,g,d,i,k,o,m,n,c,C,B,w,v,J,P){this.n11=a;this.n12=b;this.n13=g;this.n14=d;this.n21=i;this.n22=k;this.n23=o;this.n24=m;this.n31=n;this.n32=c;this.n33=C;this.n34=B;this.n41=w;this.n42=v;this.n43=J;this.n44=P;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= +a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,g){var d=new THREE.Vector3,i=new THREE.Vector3,k=new THREE.Vector3;k.sub(a,b).normalize();d.cross(g,k).normalize();i.cross(k,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=i.x;this.n22=i.y;this.n23=i.z;this.n24=-i.dot(a);this.n31=k.x; +this.n32=k.y;this.n33=k.z;this.n34=-k.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,g=a.y,d=a.z,i=1/(this.n41*b+this.n42*g+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*g+this.n13*d+this.n14)*i;a.y=(this.n21*b+this.n22*g+this.n23*d+this.n24)*i;a.z=(this.n31*b+this.n32*g+this.n33*d+this.n34)*i;return a},multiplyVector4:function(a){var b=a.x,g=a.y,d=a.z,i=a.w;a.x=this.n11*b+this.n12*g+this.n13*d+this.n14*i;a.y=this.n21*b+this.n22*g+this.n23*d+this.n24* +i;a.z=this.n31*b+this.n32*g+this.n33*d+this.n34*i;a.w=this.n41*b+this.n42*g+this.n43*d+this.n44*i;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 g=a.n11,d=a.n12,i=a.n13,k=a.n14,o=a.n21,m=a.n22,n=a.n23,c=a.n24,C=a.n31,B=a.n32, +w=a.n33,v=a.n34,J=a.n41,P=a.n42,N=a.n43,q=a.n44,Q=b.n11,D=b.n12,e=b.n13,l=b.n14,f=b.n21,p=b.n22,j=b.n23,h=b.n24,s=b.n31,E=b.n32,r=b.n33,u=b.n34,t=b.n41,K=b.n42,F=b.n43,G=b.n44;this.n11=g*Q+d*f+i*s+k*t;this.n12=g*D+d*p+i*E+k*K;this.n13=g*e+d*j+i*r+k*F;this.n14=g*l+d*h+i*u+k*G;this.n21=o*Q+m*f+n*s+c*t;this.n22=o*D+m*p+n*E+c*K;this.n23=o*e+m*j+n*r+c*F;this.n24=o*l+m*h+n*u+c*G;this.n31=C*Q+B*f+w*s+v*t;this.n32=C*D+B*p+w*E+v*K;this.n33=C*e+B*j+w*r+v*F;this.n34=C*l+B*h+w*u+v*G;this.n41=J*Q+P*f+N*s+q*t; +this.n42=J*D+P*p+N*E+q*K;this.n43=J*e+P*j+N*r+q*F;this.n44=J*l+P*h+N*u+q*G;return this},multiplySelf:function(a){var b=this.n11,g=this.n12,d=this.n13,i=this.n14,k=this.n21,o=this.n22,m=this.n23,n=this.n24,c=this.n31,C=this.n32,B=this.n33,w=this.n34,v=this.n41,J=this.n42,P=this.n43,N=this.n44,q=a.n11,Q=a.n21,D=a.n31,e=a.n41,l=a.n12,f=a.n22,p=a.n32,j=a.n42,h=a.n13,s=a.n23,E=a.n33,r=a.n43,u=a.n14,t=a.n24,K=a.n34;a=a.n44;this.n11=b*q+g*Q+d*D+i*e;this.n12=b*l+g*f+d*p+i*j;this.n13=b*h+g*s+d*E+i*r;this.n14= +b*u+g*t+d*K+i*a;this.n21=k*q+o*Q+m*D+n*e;this.n22=k*l+o*f+m*p+n*j;this.n23=k*h+o*s+m*E+n*r;this.n24=k*u+o*t+m*K+n*a;this.n31=c*q+C*Q+B*D+w*e;this.n32=c*l+C*f+B*p+w*j;this.n33=c*h+C*s+B*E+w*r;this.n34=c*u+C*t+B*K+w*a;this.n41=v*q+J*Q+P*D+N*e;this.n42=v*l+J*f+P*p+N*j;this.n43=v*h+J*s+P*E+N*r;this.n44=v*u+J*t+P*K+N*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(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34* this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,g,d){var i=b[g];b[g]=b[d]; b[d]=i}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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(){return[this.n11,this.n21,this.n31,this.n41,this.n12, this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,g){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=g;return d}; THREE.Matrix4.scaleMatrix=function(a,b,g){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=g;return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; -THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var g=new THREE.Matrix4,d=Math.cos(b),i=Math.sin(b),j=1-d,o=a.x,l=a.y,n=a.z;g.n11=j*o*o+d;g.n12=j*o*l-i*n;g.n13=j*o*n+i*l;g.n21=j*o*l+i*n;g.n22=j*l*l+d;g.n23=j*l*n-i*o;g.n31=j*o*n-i*l;g.n32=j*l*n+i*o;g.n33=j*n*n+d;return g}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var g=new THREE.Matrix4,d=Math.cos(b),i=Math.sin(b),k=1-d,o=a.x,m=a.y,n=a.z;g.n11=k*o*o+d;g.n12=k*o*m-i*n;g.n13=k*o*n+i*m;g.n21=k*o*m+i*n;g.n22=k*m*m+d;g.n23=k*m*n-i*o;g.n31=k*o*n-i*m;g.n32=k*m*n+i*o;g.n33=k*n*n+d;return g}; THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12* a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32* a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22* a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var g=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],i=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],o=b[10]*b[0]-b[2]*b[8],l=-b[6]*b[0]+b[2]*b[4],n=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],B=b[5]*b[0]-b[1]*b[4];b=b[0]*g+b[1]*j+b[2]*n;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*g;a.m[1]=b*d;a.m[2]=b*i;a.m[3]=b*j;a.m[4]=b*o;a.m[5]=b*l;a.m[6]=b*n;a.m[7]=b*c;a.m[8]=b*B;return a}; -THREE.Matrix4.makeFrustum=function(a,b,g,d,i,j){var o,l,n;o=new THREE.Matrix4;l=2*i/(b-a);n=2*i/(d-g);a=(b+a)/(b-a);g=(d+g)/(d-g);d=-(j+i)/(j-i);i=-2*j*i/(j-i);o.n11=l;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=n;o.n23=g;o.n24=0;o.n31=0;o.n32=0;o.n33=d;o.n34=i;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,b,g,d){var i;a=g*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*b,a*b,i,a,g,d)}; -THREE.Matrix4.makeOrtho=function(a,b,g,d,i,j){var o,l,n,c;o=new THREE.Matrix4;l=b-a;n=g-d;c=j-i;a=(b+a)/l;g=(g+d)/n;i=(j+i)/c;o.n11=2/l;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/n;o.n23=0;o.n24=-g;o.n31=0;o.n32=0;o.n33=-2/c;o.n34=-i;o.n41=0;o.n42=0;o.n43=0;o.n44=1;return o}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var g=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],i=b[6]*b[1]-b[2]*b[5],k=-b[10]*b[4]+b[6]*b[8],o=b[10]*b[0]-b[2]*b[8],m=-b[6]*b[0]+b[2]*b[4],n=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],C=b[5]*b[0]-b[1]*b[4];b=b[0]*g+b[1]*k+b[2]*n;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*g;a.m[1]=b*d;a.m[2]=b*i;a.m[3]=b*k;a.m[4]=b*o;a.m[5]=b*m;a.m[6]=b*n;a.m[7]=b*c;a.m[8]=b*C;return a}; +THREE.Matrix4.makeFrustum=function(a,b,g,d,i,k){var o,m,n;o=new THREE.Matrix4;m=2*i/(b-a);n=2*i/(d-g);a=(b+a)/(b-a);g=(d+g)/(d-g);d=-(k+i)/(k-i);i=-2*k*i/(k-i);o.n11=m;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=n;o.n23=g;o.n24=0;o.n31=0;o.n32=0;o.n33=d;o.n34=i;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,b,g,d){var i;a=g*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*b,a*b,i,a,g,d)}; +THREE.Matrix4.makeOrtho=function(a,b,g,d,i,k){var o,m,n,c;o=new THREE.Matrix4;m=b-a;n=g-d;c=k-i;a=(b+a)/m;g=(g+d)/n;i=(k+i)/c;o.n11=2/m;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/n;o.n23=0;o.n24=-g;o.n31=0;o.n32=0;o.n33=-2/c;o.n34=-i;o.n41=0;o.n42=0;o.n43=0;o.n44=1;return o}; 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=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; THREE.Face3=function(a,b,g,d,i){this.a=a;this.b=b;this.c=g;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.material=i instanceof Array?i:[i]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,b,g,d,i,j){this.a=a;this.b=b;this.c=g;this.d=d;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];this.material=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; -THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.geometryChunks={};this.hasTangents=false}; +THREE.Face4=function(a,b,g,d,i,k){this.a=a;this.b=b;this.c=g;this.d=d;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];this.material=k instanceof Array?k:[k]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; +THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; THREE.Geometry.prototype={computeCentroids:function(){var a,b,g;a=0;for(b=this.faces.length;a0){this.bbox={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 a=1,b=this.vertices.length;athis.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.ythis.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(B){var A=[];b=0;for(g=B.length;b65535){c[l].counter+=1;n=c[l].hash+"_"+c[l].counter;if(this.geometryChunks[n]==undefined)this.geometryChunks[n]={faces:[],material:o,vertices:0}}this.geometryChunks[n].faces.push(d);this.geometryChunks[n].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +g.centroid.addSelf(this.vertices[g.d].position);g.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,g,d,i,k,o,m=new THREE.Vector3,n=new THREE.Vector3;d=0;for(i=this.vertices.length;d0){this.bbox={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,g=this.vertices.length;bthis.bbox.x[1])this.bbox.x[1]=a.position.x;if(a.position.ythis.bbox.y[1])this.bbox.y[1]=a.position.y;if(a.position.z +this.bbox.z[1])this.bbox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,g=this.vertices.length;b65535){c[m].counter+=1;n=c[m].hash+"_"+c[m].counter;if(this.geometryChunks[n]==undefined)this.geometryChunks[n]={faces:[],material:o,vertices:0}}this.geometryChunks[n].faces.push(d);this.geometryChunks[n].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+ +this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; THREE.Camera=function(a,b,g,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,g,d);this.autoUpdateMatrix=true;this.translateX=function(i){i=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(i);i.cross(i.clone(),this.up);this.position.addSelf(i);this.target.position.addSelf(i)};this.translateZ=function(i){i=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(i); this.position.subSelf(i);this.target.position.subSelf(i)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight; THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z); this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0}; THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; -THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2; +THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2; THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}this.toString=function(){return"THREE.LineBasicMaterial (
color: "+ this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+this.linewidth+"
linecap: "+this.linecap+"
linejoin: "+this.linejoin+"
)"}}; THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map= @@ -84,93 +85,95 @@ undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shadi THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleBasicMaterial (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+ this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}}; THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}}; -THREE.Texture=function(a,b,g,d,i,j){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=g!==undefined?g:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=j!==undefined?j:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
mag_filter: "+this.mag_filter+"
min_filter: "+ +THREE.Texture=function(a,b,g,d,i,k){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=g!==undefined?g:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=k!==undefined?k:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
mag_filter: "+this.mag_filter+"
min_filter: "+ this.min_filter+"
)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){}; THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){}; THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}}; -THREE.Projector=function(){function a(e,p){var k=0,h=1,t=e.z+e.w,w=p.z+p.w,D=-e.z+e.w,q=-p.z+p.w;if(t>=0&&w>=0&&D>=0&&q>=0)return true;else if(t<0&&w<0||D<0&&q<0)return false;else{if(t<0)k=Math.max(k,t/(t-w));else if(w<0)h=Math.min(h,t/(t-w));if(D<0)k=Math.max(k,D/(D-q));else if(q<0)h=Math.min(h,D/(D-q));if(h0&&q.z<1}H=H.faces;w=0;for(D=H.length;w0&&J.z<1){v=G[u]=G[u]||new THREE.RenderableParticle; -v.x=J.x/J.w;v.y=J.y/J.w;v.z=J.z;v.rotation=s.rotation.z;v.scale.x=s.scale.x*Math.abs(v.x-(J.x+p.projectionMatrix.n11)/(J.w+p.projectionMatrix.n14));v.scale.y=s.scale.y*Math.abs(v.y-(J.y+p.projectionMatrix.n22)/(J.w+p.projectionMatrix.n24));v.material=s.material;h.push(v);u++}}}}k&&h.sort(b);return h};this.unprojectVector=function(e,p){var k=new THREE.Matrix4;k.multiply(THREE.Matrix4.makeInvert(p.matrix),THREE.Matrix4.makeInvert(p.projectionMatrix));k.multiplyVector3(e);return e}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,g,d,i,j;this.domElement=document.createElement("div");this.setSize=function(o,l){g=o;d=l;i=g/2;j=d/2};this.render=function(o,l){var n,c,B,A,v,u,G,L;a=b.projectScene(o,l);n=0;for(c=a.length;n0){z.r+=$.r*W;z.g+=$.g*W;z.b+=$.b*W}}else if(W instanceof THREE.PointLight){Y.sub(W.position,R);Y.normalize();W=K.dot(Y)*ba;if(W>0){z.r+=$.r*W;z.g+=$.g*W;z.b+=$.b*W}}}}function La(x,R,K){if(K.opacity!=0){Ba(K.opacity);wa(K.blending);var z,F,W,$,ba,ca;if(K instanceof THREE.ParticleBasicMaterial){if(K.map){$=K.map;ba=$.width>>1;ca=$.height>>1;F=R.scale.x*j;W=R.scale.y*o;K=F*ba;z=W*ca;r.set(x.x-K,x.y-z,x.x+K,x.y+z);if(H.instersects(r)){l.save(); -l.translate(x.x,x.y);l.rotate(-R.rotation);l.scale(F,-W);l.translate(-ba,-ca);l.drawImage($,0,0);l.restore()}}}else if(K instanceof THREE.ParticleCircleMaterial){if(N){S.r=M.r+T.r+aa.r;S.g=M.g+T.g+aa.g;S.b=M.b+T.b+aa.b;e.r=K.color.r*S.r;e.g=K.color.g*S.g;e.b=K.color.b*S.b;e.updateStyleString()}else e.__styleString=K.color.__styleString;K=R.scale.x*j;z=R.scale.y*o;r.set(x.x-K,x.y-z,x.x+K,x.y+z);if(H.instersects(r)){F=e.__styleString;if(A!=F)l.fillStyle=A=F;l.save();l.translate(x.x,x.y);l.rotate(-R.rotation); -l.scale(K,z);l.beginPath();l.arc(0,0,1,0,Ja,true);l.closePath();l.fill();l.restore()}}}}function Ma(x,R,K,z){if(z.opacity!=0){Ba(z.opacity);wa(z.blending);l.beginPath();l.moveTo(x.positionScreen.x,x.positionScreen.y);l.lineTo(R.positionScreen.x,R.positionScreen.y);l.closePath();if(z instanceof THREE.LineBasicMaterial){e.__styleString=z.color.__styleString;x=z.linewidth;if(v!=x)l.lineWidth=v=x;x=e.__styleString;if(B!=x)l.strokeStyle=B=x;l.stroke();r.inflate(z.linewidth*2)}}}function Fa(x,R,K,z,F,W){if(F.opacity!= -0){Ba(F.opacity);wa(F.blending);J=x.positionScreen.x;I=x.positionScreen.y;O=R.positionScreen.x;E=R.positionScreen.y;f=K.positionScreen.x;m=K.positionScreen.y;l.beginPath();l.moveTo(J,I);l.lineTo(O,E);l.lineTo(f,m);l.lineTo(J,I);l.closePath();if(F instanceof THREE.MeshBasicMaterial)if(F.map)F.map.image.loaded&&F.map.mapping instanceof THREE.UVMapping&&qa(J,I,O,E,f,m,F.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);else if(F.env_map){if(F.env_map.image.loaded)if(F.env_map.mapping instanceof -THREE.SphericalReflectionMapping){x=ua.matrix;Y.copy(z.vertexNormalsWorld[0]);Q=(Y.x*x.n11+Y.y*x.n12+Y.z*x.n13)*0.5+0.5;s=-(Y.x*x.n21+Y.y*x.n22+Y.z*x.n23)*0.5+0.5;Y.copy(z.vertexNormalsWorld[1]);U=(Y.x*x.n11+Y.y*x.n12+Y.z*x.n13)*0.5+0.5;P=-(Y.x*x.n21+Y.y*x.n22+Y.z*x.n23)*0.5+0.5;Y.copy(z.vertexNormalsWorld[2]);X=(Y.x*x.n11+Y.y*x.n12+Y.z*x.n13)*0.5+0.5;V=-(Y.x*x.n21+Y.y*x.n22+Y.z*x.n23)*0.5+0.5;qa(J,I,O,E,f,m,F.env_map.image,Q,s,U,P,X,V)}}else F.wireframe?xa(F.color.__styleString,F.wireframe_linewidth): -ya(F.color.__styleString);else if(F instanceof THREE.MeshLambertMaterial){if(F.map&&!F.wireframe){F.map.mapping instanceof THREE.UVMapping&&qa(J,I,O,E,f,m,F.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);wa(THREE.SubtractiveBlending)}if(N)if(!F.wireframe&&F.shading==THREE.SmoothShading&&z.vertexNormalsWorld.length==3){p.r=k.r=h.r=M.r;p.g=k.g=h.g=M.g;p.b=k.b=h.b=M.b;va(W,z.v1.positionWorld,z.vertexNormalsWorld[0],p);va(W,z.v2.positionWorld,z.vertexNormalsWorld[1],k);va(W, -z.v3.positionWorld,z.vertexNormalsWorld[2],h);t.r=(k.r+h.r)*0.5;t.g=(k.g+h.g)*0.5;t.b=(k.b+h.b)*0.5;C=Ga(p,k,h,t);qa(J,I,O,E,f,m,C,0,0,1,0,0,1)}else{S.r=M.r;S.g=M.g;S.b=M.b;va(W,z.centroidWorld,z.normalWorld,S);e.r=F.color.r*S.r;e.g=F.color.g*S.g;e.b=F.color.b*S.b;e.updateStyleString();F.wireframe?xa(e.__styleString,F.wireframe_linewidth):ya(e.__styleString)}else F.wireframe?xa(F.color.__styleString,F.wireframe_linewidth):ya(F.color.__styleString)}else if(F instanceof THREE.MeshDepthMaterial){w=F.__2near; -D=F.__farPlusNear;q=F.__farMinusNear;p.r=p.g=p.b=1-w/(D-x.positionScreen.z*q);k.r=k.g=k.b=1-w/(D-R.positionScreen.z*q);h.r=h.g=h.b=1-w/(D-K.positionScreen.z*q);t.r=(k.r+h.r)*0.5;t.g=(k.g+h.g)*0.5;t.b=(k.b+h.b)*0.5;C=Ga(p,k,h,t);qa(J,I,O,E,f,m,C,0,0,1,0,0,1)}else if(F instanceof THREE.MeshNormalMaterial){e.r=Ca(z.normalWorld.x);e.g=Ca(z.normalWorld.y);e.b=Ca(z.normalWorld.z);e.updateStyleString();F.wireframe?xa(e.__styleString,F.wireframe_linewidth):ya(e.__styleString)}}}function xa(x,R){if(B!=x)l.strokeStyle= -B=x;if(v!=R)l.lineWidth=v=R;l.stroke();r.inflate(R*2)}function ya(x){if(A!=x)l.fillStyle=A=x;l.fill()}function qa(x,R,K,z,F,W,$,ba,ca,ha,ea,ia,ra){var ka,ja;ka=$.width-1;ja=$.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;ra*=ja;K-=x;z-=R;F-=x;W-=R;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka=(ra*K-ea*F)*ja;ea=(ra*z-ea*W)*ja;K=(ha*F-ia*K)*ja;z=(ha*W-ia*z)*ja;x=x-ka*ba-K*ca;R=R-ea*ba-z*ca;l.save();l.transform(ka,ea,K,z,x,R);l.clip();l.drawImage($,0,0);l.restore()}function Ba(x){if(n!=x)l.globalAlpha= -n=x}function wa(x){if(c!=x){switch(x){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}c=x}}function Ga(x,R,K,z){var F=~~(x.r*255),W=~~(x.g*255);x=~~(x.b*255);var $=~~(R.r*255),ba=~~(R.g*255);R=~~(R.b*255);var ca=~~(K.r*255),ha=~~(K.g*255);K=~~(K.b*255);var ea=~~(z.r*255),ia=~~(z.g*255);z=~~(z.b*255);da[0]=F<0?0:F>255?255:F;da[1]=W<0?0:W> -255?255:W;da[2]=x<0?0:x>255?255:x;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=R<0?0:R>255?255:R;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=K<0?0:K>255?255:K;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=z<0?0:z>255?255:z;oa.putImageData(Aa,0,0);ta.drawImage(na,0,0);return pa}function Ca(x){x=(x+1)*0.5;return x<0?0:x>1?1:x}function Da(x,R){var K=R.x-x.x,z=R.y-x.y,F=1/Math.sqrt(K*K+z*z);K*=F;z*=F;R.x+=K;R.y+=z;x.x-=K;x.y-=z}var za,Ha,Z,fa,ma,Ea,Ia,sa; -l.setTransform(1,0,0,-1,j,o);this.autoClear&&this.clear();a=b.projectScene(ga,ua,this.sortElements);(N=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za0){V.r+=r.color.r*N;V.g+=r.color.g*N;V.b+=r.color.b*N}}else if(r instanceof THREE.PointLight){h.sub(r.position,X.centroidWorld);h.normalize();N=X.normalWorld.dot(h)*r.intensity;if(N>0){V.r+=r.color.r*N;V.g+=r.color.g*N;V.b+=r.color.b*N}}}}function b(P,X,V,H,y,r){q=d(C++);q.setAttribute("d","M "+P.positionScreen.x+ -" "+P.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(y instanceof THREE.MeshBasicMaterial)E.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshLambertMaterial)if(O){f.r=m.r;f.g=m.g;f.b=m.b;a(r,H,f);E.r=y.color.r*f.r;E.g=y.color.g*f.g;E.b=y.color.b*f.b;E.updateStyleString()}else E.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshDepthMaterial){k=1-y.__2near/(y.__farPlusNear-H.z*y.__farMinusNear); -E.setRGB(k,k,k)}else y instanceof THREE.MeshNormalMaterial&&E.setRGB(i(H.normalWorld.x),i(H.normalWorld.y),i(H.normalWorld.z));y.wireframe?q.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+y.wireframe_linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframe_linecap+"; stroke-linejoin: "+y.wireframe_linejoin):q.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+y.opacity);l.appendChild(q)}function g(P,X,V,H,y,r,N){q=d(C++);q.setAttribute("d", -"M "+P.positionScreen.x+" "+P.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+H.positionScreen.x+","+H.positionScreen.y+"z");if(r instanceof THREE.MeshBasicMaterial)E.__styleString=r.color.__styleString;else if(r instanceof THREE.MeshLambertMaterial)if(O){f.r=m.r;f.g=m.g;f.b=m.b;a(N,y,f);E.r=r.color.r*f.r;E.g=r.color.g*f.g;E.b=r.color.b*f.b;E.updateStyleString()}else E.__styleString=r.color.__styleString;else if(r instanceof THREE.MeshDepthMaterial){k= -1-r.__2near/(r.__farPlusNear-y.z*r.__farMinusNear);E.setRGB(k,k,k)}else r instanceof THREE.MeshNormalMaterial&&E.setRGB(i(y.normalWorld.x),i(y.normalWorld.y),i(y.normalWorld.z));r.wireframe?q.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+r.wireframe_linewidth+"; stroke-opacity: "+r.opacity+"; stroke-linecap: "+r.wireframe_linecap+"; stroke-linejoin: "+r.wireframe_linejoin):q.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+r.opacity);l.appendChild(q)} -function d(P){if(t[P]==null){t[P]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&t[P].setAttribute("shape-rendering","crispEdges");return t[P]}return t[P]}function i(P){return P<0?Math.min((1+P)*0.5,0.5):0.5+Math.min(P*0.5,0.5)}var j=null,o=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,c,B,A,v,u,G,L,J=new THREE.Rectangle,I=new THREE.Rectangle,O=false,E=new THREE.Color(16777215),f=new THREE.Color(16777215),m=new THREE.Color(0),e=new THREE.Color(0), -p=new THREE.Color(0),k,h=new THREE.Vector3,t=[],w=[],D=[],q,C,Q,s,U=1;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(P){switch(P){case "high":U=1;break;case "low":U=0}};this.setSize=function(P,X){n=P;c=X;B=n/2;A=c/2;l.setAttribute("viewBox",-B+" "+-A+" "+n+" "+c);l.setAttribute("width",n);l.setAttribute("height",c);J.set(-B,-A,B,A)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(P,X){var V,H, -y,r,N,S,M,T;this.autoClear&&this.clear();j=o.projectScene(P,X,this.sortElements);s=Q=C=0;if(O=P.lights.length>0){M=P.lights;m.setRGB(0,0,0);e.setRGB(0,0,0);p.setRGB(0,0,0);V=0;for(H=M.length;V0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(e,o("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"+ -f));c.attachShader(e,o("vertex",p+m));c.linkProgram(e);c.getProgramParameter(e,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(e,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");e.uniforms={};e.attributes={};return e}function g(f,m){if(f.image.length==6){if(!f.image.__webGLTextureCube&&!f.image.__cubeMapInitialized&&f.image.loadCount==6){f.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,f.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP, -c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var e=0;e<6;++e)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,f.image[e]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);f.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_CUBE_MAP, -f.image.__webGLTextureCube)}}function d(f,m){if(!f.__webGLTexture&&f.image.loaded){f.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,f.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,f.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,l(f.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,l(f.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,l(f.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,l(f.min_filter));c.generateMipmap(c.TEXTURE_2D); -c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_2D,f.__webGLTexture)}function i(f,m){var e,p,k;e=0;for(p=m.length;e= 0.0 )": -"",m?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",m?"pointDiffuse += mColor * pointDiffuseWeight;":"",m?"pointSpecular += mSpecular * pointSpecularWeight;":"",m?"}":"",f?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",f?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",f?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",f?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",f?"vec3 dirVector = normalize( lDirection.xyz );":"",f?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": -"",f?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",f?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",f?"float dirSpecularWeight = 0.0;":"",f?"if ( dirDotNormalHalf >= 0.0 )":"",f?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",f?"dirDiffuse += mColor * dirDiffuseWeight;":"",f?"dirSpecular += mSpecular * dirSpecularWeight;":"",f?"}":"","vec4 totalLight = mAmbient;",f?"totalLight += dirDiffuse + dirSpecular;":"",m?"totalLight += pointDiffuse + pointSpecular;": +THREE.Projector=function(){function a(p,j){return j.z-p.z}function b(p,j){var h=0,s=1,E=p.z+p.w,r=j.z+j.w,u=-p.z+p.w,t=-j.z+j.w;if(E>=0&&r>=0&&u>=0&&t>=0)return true;else if(E<0&&r<0||u<0&&t<0)return false;else{if(E<0)h=Math.max(h,E/(E-r));else if(r<0)s=Math.min(s,E/(E-r));if(u<0)h=Math.max(h,u/(u-t));else if(t<0)s=Math.min(s,u/(u-t));if(s0&&t.z<1}z=z.faces;r=0;for(u=z.length;r0&&N.z<1){w=J[v]=J[v]||new THREE.RenderableParticle;w.x=N.x/N.w;w.y=N.y/N.w;w.z=N.z;w.rotation=G.rotation.z;w.scale.x=G.scale.x*Math.abs(w.x-(N.x+j.projectionMatrix.n11)/(N.w+j.projectionMatrix.n14));w.scale.y=G.scale.y*Math.abs(w.y-(N.y+j.projectionMatrix.n22)/(N.w+ +j.projectionMatrix.n24));w.material=G.material;s.push(w);v++}}}}h&&s.sort(a);return s};this.unprojectVector=function(p,j){var h=new THREE.Matrix4;h.multiply(THREE.Matrix4.makeInvert(j.matrix),THREE.Matrix4.makeInvert(j.projectionMatrix));h.multiplyVector3(p);return p}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,g,d,i,k;this.domElement=document.createElement("div");this.setSize=function(o,m){g=o;d=m;i=g/2;k=d/2};this.render=function(o,m){var n,c,C,B,w,v,J,P;a=b.projectScene(o,m);n=0;for(c=a.length;n0){A.r+=$.r*W;A.g+=$.g*W;A.b+=$.b*W}}else if(W instanceof THREE.PointLight){Y.sub(W.position,T);Y.normalize();W=O.dot(Y)*ba;if(W>0){A.r+=$.r*W;A.g+=$.g*W;A.b+=$.b*W}}}}function La(x,T,O){if(O.opacity!=0){Ba(O.opacity);wa(O.blending);var A,I,W,$,ba,ca;if(O instanceof THREE.ParticleBasicMaterial){if(O.map){$=O.map;ba=$.width>>1;ca=$.height>>1;I=T.scale.x*k;W=T.scale.y*o;O=I*ba;A=W*ca;y.set(x.x-O,x.y-A,x.x+O,x.y+A);if(M.instersects(y)){m.save(); +m.translate(x.x,x.y);m.rotate(-T.rotation);m.scale(I,-W);m.translate(-ba,-ca);m.drawImage($,0,0);m.restore()}}}else if(O instanceof THREE.ParticleCircleMaterial){if(L){S.r=H.r+U.r+aa.r;S.g=H.g+U.g+aa.g;S.b=H.b+U.b+aa.b;f.r=O.color.r*S.r;f.g=O.color.g*S.g;f.b=O.color.b*S.b;f.updateStyleString()}else f.__styleString=O.color.__styleString;O=T.scale.x*k;A=T.scale.y*o;y.set(x.x-O,x.y-A,x.x+O,x.y+A);if(M.instersects(y)){I=f.__styleString;if(B!=I)m.fillStyle=B=I;m.save();m.translate(x.x,x.y);m.rotate(-T.rotation); +m.scale(O,A);m.beginPath();m.arc(0,0,1,0,Ja,true);m.closePath();m.fill();m.restore()}}}}function Ma(x,T,O,A){if(A.opacity!=0){Ba(A.opacity);wa(A.blending);m.beginPath();m.moveTo(x.positionScreen.x,x.positionScreen.y);m.lineTo(T.positionScreen.x,T.positionScreen.y);m.closePath();if(A instanceof THREE.LineBasicMaterial){f.__styleString=A.color.__styleString;x=A.linewidth;if(w!=x)m.lineWidth=w=x;x=f.__styleString;if(C!=x)m.strokeStyle=C=x;m.stroke();y.inflate(A.linewidth*2)}}}function Fa(x,T,O,A,I,W){if(I.opacity!= +0){Ba(I.opacity);wa(I.blending);N=x.positionScreen.x;q=x.positionScreen.y;Q=T.positionScreen.x;D=T.positionScreen.y;e=O.positionScreen.x;l=O.positionScreen.y;m.beginPath();m.moveTo(N,q);m.lineTo(Q,D);m.lineTo(e,l);m.lineTo(N,q);m.closePath();if(I instanceof THREE.MeshBasicMaterial)if(I.map)I.map.image.loaded&&I.map.mapping instanceof THREE.UVMapping&&qa(N,q,Q,D,e,l,I.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);else if(I.env_map){if(I.env_map.image.loaded)if(I.env_map.mapping instanceof +THREE.SphericalReflectionMapping){x=ua.matrix;Y.copy(A.vertexNormalsWorld[0]);K=(Y.x*x.n11+Y.y*x.n12+Y.z*x.n13)*0.5+0.5;F=-(Y.x*x.n21+Y.y*x.n22+Y.z*x.n23)*0.5+0.5;Y.copy(A.vertexNormalsWorld[1]);G=(Y.x*x.n11+Y.y*x.n12+Y.z*x.n13)*0.5+0.5;R=-(Y.x*x.n21+Y.y*x.n22+Y.z*x.n23)*0.5+0.5;Y.copy(A.vertexNormalsWorld[2]);X=(Y.x*x.n11+Y.y*x.n12+Y.z*x.n13)*0.5+0.5;V=-(Y.x*x.n21+Y.y*x.n22+Y.z*x.n23)*0.5+0.5;qa(N,q,Q,D,e,l,I.env_map.image,K,F,G,R,X,V)}}else I.wireframe?xa(I.color.__styleString,I.wireframe_linewidth): +ya(I.color.__styleString);else if(I instanceof THREE.MeshLambertMaterial){if(I.map&&!I.wireframe){I.map.mapping instanceof THREE.UVMapping&&qa(N,q,Q,D,e,l,I.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);wa(THREE.SubtractiveBlending)}if(L)if(!I.wireframe&&I.shading==THREE.SmoothShading&&A.vertexNormalsWorld.length==3){p.r=j.r=h.r=H.r;p.g=j.g=h.g=H.g;p.b=j.b=h.b=H.b;va(W,A.v1.positionWorld,A.vertexNormalsWorld[0],p);va(W,A.v2.positionWorld,A.vertexNormalsWorld[1],j);va(W, +A.v3.positionWorld,A.vertexNormalsWorld[2],h);s.r=(j.r+h.r)*0.5;s.g=(j.g+h.g)*0.5;s.b=(j.b+h.b)*0.5;t=Ga(p,j,h,s);qa(N,q,Q,D,e,l,t,0,0,1,0,0,1)}else{S.r=H.r;S.g=H.g;S.b=H.b;va(W,A.centroidWorld,A.normalWorld,S);f.r=I.color.r*S.r;f.g=I.color.g*S.g;f.b=I.color.b*S.b;f.updateStyleString();I.wireframe?xa(f.__styleString,I.wireframe_linewidth):ya(f.__styleString)}else I.wireframe?xa(I.color.__styleString,I.wireframe_linewidth):ya(I.color.__styleString)}else if(I instanceof THREE.MeshDepthMaterial){E=I.__2near; +r=I.__farPlusNear;u=I.__farMinusNear;p.r=p.g=p.b=1-E/(r-x.positionScreen.z*u);j.r=j.g=j.b=1-E/(r-T.positionScreen.z*u);h.r=h.g=h.b=1-E/(r-O.positionScreen.z*u);s.r=(j.r+h.r)*0.5;s.g=(j.g+h.g)*0.5;s.b=(j.b+h.b)*0.5;t=Ga(p,j,h,s);qa(N,q,Q,D,e,l,t,0,0,1,0,0,1)}else if(I instanceof THREE.MeshNormalMaterial){f.r=Ca(A.normalWorld.x);f.g=Ca(A.normalWorld.y);f.b=Ca(A.normalWorld.z);f.updateStyleString();I.wireframe?xa(f.__styleString,I.wireframe_linewidth):ya(f.__styleString)}}}function xa(x,T){if(C!=x)m.strokeStyle= +C=x;if(w!=T)m.lineWidth=w=T;m.stroke();y.inflate(T*2)}function ya(x){if(B!=x)m.fillStyle=B=x;m.fill()}function qa(x,T,O,A,I,W,$,ba,ca,ha,ea,ia,ra){var ka,ja;ka=$.width-1;ja=$.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;ra*=ja;O-=x;A-=T;I-=x;W-=T;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka=(ra*O-ea*I)*ja;ea=(ra*A-ea*W)*ja;O=(ha*I-ia*O)*ja;A=(ha*W-ia*A)*ja;x=x-ka*ba-O*ca;T=T-ea*ba-A*ca;m.save();m.transform(ka,ea,O,A,x,T);m.clip();m.drawImage($,0,0);m.restore()}function Ba(x){if(n!=x)m.globalAlpha= +n=x}function wa(x){if(c!=x){switch(x){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}c=x}}function Ga(x,T,O,A){var I=~~(x.r*255),W=~~(x.g*255);x=~~(x.b*255);var $=~~(T.r*255),ba=~~(T.g*255);T=~~(T.b*255);var ca=~~(O.r*255),ha=~~(O.g*255);O=~~(O.b*255);var ea=~~(A.r*255),ia=~~(A.g*255);A=~~(A.b*255);da[0]=I<0?0:I>255?255:I;da[1]=W<0?0:W> +255?255:W;da[2]=x<0?0:x>255?255:x;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=T<0?0:T>255?255:T;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=O<0?0:O>255?255:O;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=A<0?0:A>255?255:A;oa.putImageData(Aa,0,0);ta.drawImage(na,0,0);return pa}function Ca(x){x=(x+1)*0.5;return x<0?0:x>1?1:x}function Da(x,T){var O=T.x-x.x,A=T.y-x.y,I=1/Math.sqrt(O*O+A*A);O*=I;A*=I;T.x+=O;T.y+=A;x.x-=O;x.y-=A}var za,Ha,Z,fa,ma,Ea,Ia,sa; +m.setTransform(1,0,0,-1,k,o);this.autoClear&&this.clear();a=b.projectScene(ga,ua,this.sortElements);(L=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za0){V.r+=y.color.r*L;V.g+=y.color.g*L;V.b+=y.color.b*L}}else if(y instanceof THREE.PointLight){h.sub(y.position,X.centroidWorld);h.normalize();L=X.normalWorld.dot(h)*y.intensity;if(L>0){V.r+=y.color.r*L;V.g+=y.color.g*L;V.b+=y.color.b*L}}}}function b(R,X,V,M,z,y){u=d(t++);u.setAttribute("d","M "+R.positionScreen.x+ +" "+R.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(z instanceof THREE.MeshBasicMaterial)D.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshLambertMaterial)if(Q){e.r=l.r;e.g=l.g;e.b=l.b;a(y,M,e);D.r=z.color.r*e.r;D.g=z.color.g*e.g;D.b=z.color.b*e.b;D.updateStyleString()}else D.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshDepthMaterial){j=1-z.__2near/(z.__farPlusNear-M.z*z.__farMinusNear); +D.setRGB(j,j,j)}else z instanceof THREE.MeshNormalMaterial&&D.setRGB(i(M.normalWorld.x),i(M.normalWorld.y),i(M.normalWorld.z));z.wireframe?u.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+z.wireframe_linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.wireframe_linecap+"; stroke-linejoin: "+z.wireframe_linejoin):u.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+z.opacity);m.appendChild(u)}function g(R,X,V,M,z,y,L){u=d(t++);u.setAttribute("d", +"M "+R.positionScreen.x+" "+R.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+M.positionScreen.x+","+M.positionScreen.y+"z");if(y instanceof THREE.MeshBasicMaterial)D.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshLambertMaterial)if(Q){e.r=l.r;e.g=l.g;e.b=l.b;a(L,z,e);D.r=y.color.r*e.r;D.g=y.color.g*e.g;D.b=y.color.b*e.b;D.updateStyleString()}else D.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshDepthMaterial){j= +1-y.__2near/(y.__farPlusNear-z.z*y.__farMinusNear);D.setRGB(j,j,j)}else y instanceof THREE.MeshNormalMaterial&&D.setRGB(i(z.normalWorld.x),i(z.normalWorld.y),i(z.normalWorld.z));y.wireframe?u.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+y.wireframe_linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframe_linecap+"; stroke-linejoin: "+y.wireframe_linejoin):u.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+y.opacity);m.appendChild(u)} +function d(R){if(s[R]==null){s[R]=document.createElementNS("http://www.w3.org/2000/svg","path");G==0&&s[R].setAttribute("shape-rendering","crispEdges");return s[R]}return s[R]}function i(R){return R<0?Math.min((1+R)*0.5,0.5):0.5+Math.min(R*0.5,0.5)}var k=null,o=new THREE.Projector,m=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,c,C,B,w,v,J,P,N=new THREE.Rectangle,q=new THREE.Rectangle,Q=false,D=new THREE.Color(16777215),e=new THREE.Color(16777215),l=new THREE.Color(0),f=new THREE.Color(0), +p=new THREE.Color(0),j,h=new THREE.Vector3,s=[],E=[],r=[],u,t,K,F,G=1;this.domElement=m;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(R){switch(R){case "high":G=1;break;case "low":G=0}};this.setSize=function(R,X){n=R;c=X;C=n/2;B=c/2;m.setAttribute("viewBox",-C+" "+-B+" "+n+" "+c);m.setAttribute("width",n);m.setAttribute("height",c);N.set(-C,-B,C,B)};this.clear=function(){for(;m.childNodes.length>0;)m.removeChild(m.childNodes[0])};this.render=function(R,X){var V,M, +z,y,L,S,H,U;this.autoClear&&this.clear();k=o.projectScene(R,X,this.sortElements);F=K=t=0;if(Q=R.lights.length>0){H=R.lights;l.setRGB(0,0,0);f.setRGB(0,0,0);p.setRGB(0,0,0);V=0;for(M=H.length;V0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(f,o("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"+ +e));c.attachShader(f,o("vertex",p+l));c.linkProgram(f);c.getProgramParameter(f,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(f,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");f.uniforms={};f.attributes={};return f}function g(e,l){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP, +c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var f=0;f<6;++f)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[f]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+l);c.bindTexture(c.TEXTURE_CUBE_MAP, +e.image.__webGLTextureCube)}}function d(e,l){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,m(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,m(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,m(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,m(e.min_filter));c.generateMipmap(c.TEXTURE_2D); +c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+l);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function i(e,l){var f,p,j;f=0;for(p=l.length;f= 0.0 )": +"",l?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",l?"pointDiffuse += mColor * pointDiffuseWeight;":"",l?"pointSpecular += mSpecular * pointSpecularWeight;":"",l?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": +"",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",l?"totalLight += pointDiffuse + pointSpecular;": "","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n"); -e=b(p,e);c.useProgram(e);i(e,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);f&&i(e,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);m&&i(e,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(e.uniforms.enableMap,0);c.uniform1i(e.uniforms.tMap,0);c.uniform1i(e.uniforms.enableCubeMap,0);c.uniform1i(e.uniforms.tCube,1);c.uniform1i(e.uniforms.mixEnvMap,0);c.uniform1i(e.uniforms.useRefract,0);j(e,["position","normal","uv"]);return e}(a.directional,a.point);this.setSize=function(f,m){n.width=f;n.height=m;c.viewport(0,0,n.width,n.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(f,m){var e,p,k,h,t,w=[], -D=[],q=[];h=[];t=[];c.uniform1i(f.uniforms.enableLighting,m.length);e=0;for(p=m.length;e0){y.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,y.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW)}y.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(Q),c.STATIC_DRAW);y.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, -y.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(s),c.STATIC_DRAW);y.__webGLFaceCount=Q.length;y.__webGLLineCount=s.length}};this.renderBuffer=function(f,m,e,p){var k,h,t,w,D,q,C,Q,s;if(e instanceof THREE.MeshShaderMaterial){if(!e.program){e.program=b(e.fragment_shader,e.vertex_shader);C=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(s in e.uniforms)C.push(s);i(e.program,C);j(e.program,["position","normal","uv","tangent"])}s= -e.program}else s=A;if(s!=B){c.useProgram(s);B=s}s==A&&this.setupLights(s,m);this.loadCamera(s,f);this.loadMatrices(s);if(e instanceof THREE.MeshShaderMaterial){t=e.wireframe;w=e.wireframe_linewidth;f=s;m=e.uniforms;var U;for(k in m){Q=m[k].type;C=m[k].value;U=f.uniforms[k];if(Q=="i")c.uniform1i(U,C);else if(Q=="f")c.uniform1f(U,C);else if(Q=="v3")c.uniform3f(U,C.x,C.y,C.z);else if(Q=="c")c.uniform3f(U,C.r,C.g,C.b);else if(Q=="t"){c.uniform1i(U,C);if(Q=m[k].texture)Q.image instanceof Array&&Q.image.length== -6?g(Q,C):d(Q,C)}}}if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshBasicMaterial){k=e.color;h=e.opacity;t=e.wireframe;w=e.wireframe_linewidth;D=e.map;q=e.env_map;m=e.combine==THREE.MixOperation;f=e.reflectivity;Q=e.env_map&&e.env_map.mapping instanceof THREE.CubeRefractionMapping;C=e.refraction_ratio;c.uniform4f(s.uniforms.mColor,k.r*h,k.g*h,k.b*h,h);c.uniform1i(s.uniforms.mixEnvMap,m);c.uniform1f(s.uniforms.mReflectivity,f);c.uniform1i(s.uniforms.useRefract, -Q);c.uniform1f(s.uniforms.mRefractionRatio,C)}if(e instanceof THREE.MeshNormalMaterial){h=e.opacity;c.uniform1f(s.uniforms.mOpacity,h);c.uniform1i(s.uniforms.material,4)}else if(e instanceof THREE.MeshDepthMaterial){h=e.opacity;t=e.wireframe;w=e.wireframe_linewidth;c.uniform1f(s.uniforms.mOpacity,h);c.uniform1f(s.uniforms.m2Near,e.__2near);c.uniform1f(s.uniforms.mFarPlusNear,e.__farPlusNear);c.uniform1f(s.uniforms.mFarMinusNear,e.__farMinusNear);c.uniform1i(s.uniforms.material,3)}else if(e instanceof -THREE.MeshPhongMaterial){k=e.ambient;f=e.specular;e=e.shininess;c.uniform4f(s.uniforms.mAmbient,k.r,k.g,k.b,h);c.uniform4f(s.uniforms.mSpecular,f.r,f.g,f.b,h);c.uniform1f(s.uniforms.mShininess,e);c.uniform1i(s.uniforms.material,2)}else if(e instanceof THREE.MeshLambertMaterial)c.uniform1i(s.uniforms.material,1);else e instanceof THREE.MeshBasicMaterial&&c.uniform1i(s.uniforms.material,0);if(D){d(D,0);c.uniform1i(s.uniforms.tMap,0);c.uniform1i(s.uniforms.enableMap,1)}else c.uniform1i(s.uniforms.enableMap, -0);if(q){g(q,1);c.uniform1i(s.uniforms.tCube,1);c.uniform1i(s.uniforms.enableCubeMap,1)}else c.uniform1i(s.uniforms.enableCubeMap,0);h=s.attributes;c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(h.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(h.position);if(h.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(h.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(h.normal)}if(h.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer); -c.vertexAttribPointer(h.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(h.tangent)}if(h.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.vertexAttribPointer(h.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(h.uv)}else c.disableVertexAttribArray(h.uv);if(t){c.lineWidth(w);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(c.LINES,p.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES, -p.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(f,m,e,p,k,h){var t,w,D,q,C;D=0;for(q=e.material.length;D=0;e--){p=f.__webGLObjects[e].object;m==p&&f.__webGLObjects.splice(e,1)}};this.setupMatrices=function(f,m){f.autoUpdateMatrix&&f.updateMatrix();v.multiply(m.matrix,f.matrix);L.set(v.flatten());u=THREE.Matrix4.makeInvert3x3(v).transpose();I.set(u.m);O.set(f.matrix.flatten())}; -this.loadMatrices=function(f){c.uniformMatrix4fv(f.uniforms.viewMatrix,false,G);c.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,L);c.uniformMatrix4fv(f.uniforms.projectionMatrix,false,J);c.uniformMatrix3fv(f.uniforms.normalMatrix,false,I);c.uniformMatrix4fv(f.uniforms.objectMatrix,false,O)};this.loadCamera=function(f,m){c.uniform3f(f.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(f){switch(f){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;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(f,m){if(f){!m||m=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(f=="back")c.cullFace(c.BACK);else f=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; +f=b(p,f);c.useProgram(f);i(f,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);e&&i(f,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);l&&i(f,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(f.uniforms.enableMap,0);c.uniform1i(f.uniforms.tMap,0);c.uniform1i(f.uniforms.enableCubeMap,0);c.uniform1i(f.uniforms.tCube,1);c.uniform1i(f.uniforms.mixEnvMap,0);c.uniform1i(f.uniforms.useRefract,0);k(f,["position","normal","uv"]);return f}(a.directional,a.point);this.setSize=function(e,l){n.width=e;n.height=l;c.viewport(0,0,n.width,n.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,l){var f,p,j,h,s,E=[], +r=[],u=[];h=[];s=[];c.uniform1i(e.uniforms.enableLighting,l.length);f=0;for(p=l.length;f0){z.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,z.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW)}z.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,z.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(K),c.STATIC_DRAW);z.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +z.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(F),c.STATIC_DRAW);z.__webGLFaceCount=K.length;z.__webGLLineCount=F.length}};this.renderBuffer=function(e,l,f,p){var j,h,s,E,r,u,t,K,F;if(f instanceof THREE.MeshShaderMaterial){if(!f.program){f.program=b(f.fragment_shader,f.vertex_shader);t=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(F in f.uniforms)t.push(F);i(f.program,t);k(f.program,["position","normal","uv","tangent"])}F= +f.program}else F=B;if(F!=C){c.useProgram(F);C=F}F==B&&this.setupLights(F,l);this.loadCamera(F,e);this.loadMatrices(F);if(f instanceof THREE.MeshShaderMaterial){s=f.wireframe;E=f.wireframe_linewidth;e=F;l=f.uniforms;var G;for(j in l){K=l[j].type;t=l[j].value;G=e.uniforms[j];if(K=="i")c.uniform1i(G,t);else if(K=="f")c.uniform1f(G,t);else if(K=="v3")c.uniform3f(G,t.x,t.y,t.z);else if(K=="c")c.uniform3f(G,t.r,t.g,t.b);else if(K=="t"){c.uniform1i(G,t);if(K=l[j].texture)K.image instanceof Array&&K.image.length== +6?g(K,t):d(K,t)}}}if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){j=f.color;h=f.opacity;s=f.wireframe;E=f.wireframe_linewidth;r=f.map;u=f.env_map;l=f.combine==THREE.MixOperation;e=f.reflectivity;K=f.env_map&&f.env_map.mapping instanceof THREE.CubeRefractionMapping;t=f.refraction_ratio;c.uniform4f(F.uniforms.mColor,j.r*h,j.g*h,j.b*h,h);c.uniform1i(F.uniforms.mixEnvMap,l);c.uniform1f(F.uniforms.mReflectivity,e);c.uniform1i(F.uniforms.useRefract, +K);c.uniform1f(F.uniforms.mRefractionRatio,t)}if(f instanceof THREE.MeshNormalMaterial){h=f.opacity;c.uniform1f(F.uniforms.mOpacity,h);c.uniform1i(F.uniforms.material,4)}else if(f instanceof THREE.MeshDepthMaterial){h=f.opacity;s=f.wireframe;E=f.wireframe_linewidth;c.uniform1f(F.uniforms.mOpacity,h);c.uniform1f(F.uniforms.m2Near,f.__2near);c.uniform1f(F.uniforms.mFarPlusNear,f.__farPlusNear);c.uniform1f(F.uniforms.mFarMinusNear,f.__farMinusNear);c.uniform1i(F.uniforms.material,3)}else if(f instanceof +THREE.MeshPhongMaterial){j=f.ambient;e=f.specular;f=f.shininess;c.uniform4f(F.uniforms.mAmbient,j.r,j.g,j.b,h);c.uniform4f(F.uniforms.mSpecular,e.r,e.g,e.b,h);c.uniform1f(F.uniforms.mShininess,f);c.uniform1i(F.uniforms.material,2)}else if(f instanceof THREE.MeshLambertMaterial)c.uniform1i(F.uniforms.material,1);else f instanceof THREE.MeshBasicMaterial&&c.uniform1i(F.uniforms.material,0);if(r){d(r,0);c.uniform1i(F.uniforms.tMap,0);c.uniform1i(F.uniforms.enableMap,1)}else c.uniform1i(F.uniforms.enableMap, +0);if(u){g(u,1);c.uniform1i(F.uniforms.tCube,1);c.uniform1i(F.uniforms.enableCubeMap,1)}else c.uniform1i(F.uniforms.enableCubeMap,0);h=F.attributes;c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(h.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(h.position);if(h.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(h.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(h.normal)}if(h.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer); +c.vertexAttribPointer(h.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(h.tangent)}if(h.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.vertexAttribPointer(h.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(h.uv)}else c.disableVertexAttribArray(h.uv);if(s){c.lineWidth(E);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(c.LINES,p.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES, +p.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(e,l,f,p,j,h){var s,E,r,u,t;r=0;for(u=f.material.length;r=0;f--){p=e.__webGLObjects[f].object;l==p&&e.__webGLObjects.splice(f,1)}};this.setupMatrices=function(e,l){e.autoUpdateMatrix&&e.updateMatrix();w.multiply(l.matrix,e.matrix);P.set(w.flatten());v=THREE.Matrix4.makeInvert3x3(w).transpose();q.set(v.m);Q.set(e.matrix.flatten())}; +this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,J);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,P);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,N);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,q);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,Q)};this.loadCamera=function(e,l){c.uniform3f(e.uniforms.cameraPosition,l.position.x,l.position.y,l.position.z)};this.setBlending=function(e){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;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,l){if(e){!l||l=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);else e=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]}; THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null}; diff --git a/build/ThreeDebug.js b/build/ThreeDebug.js index 8bdaedc6362f9f4152c11b519c7e4e6b6b4a6148..bf1e1d462790359484a3593b3a7fec48b11d33cf 100644 --- a/build/ThreeDebug.js +++ b/build/ThreeDebug.js @@ -12,55 +12,56 @@ THREE.Vector4=function(a,b,g,d){this.x=a||0;this.y=b||0;this.z=g||0;this.w=d||1} THREE.Vector4.prototype={set:function(a,b,g,d){this.x=a;this.y=b;this.z=g;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){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)},toString:function(){return"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,g,d=a.objects,i=[];a=0;for(b=d.length;a0&&J>0&&m+J<1}var g,d,i,k,o,j,n,c,B,A, -x,v=a.geometry,H=v.vertices,L=[];g=0;for(d=v.faces.length;gn?d:n;i=i>c? -i:c}a()};this.add3Points=function(n,c,B,A,x,v){if(j){j=false;b=nB?n>x?n:x:B>x?B:x;i=c>A?c>v?c:v:A>v?A:v}else{b=nB?n>x?n>d?n:d:x>d?x:d:B>x?B>d?B:d:x>d?x:d;i=c>A?c>v?c>i?c:i:v>i?v:i:A>v?A>i?A:i:v>i?v:i}a()};this.addRectangle=function(n){if(j){j=false;b=n.getLeft();g=n.getTop();d=n.getRight();i=n.getBottom()}else{b=bn.getRight()?d:n.getRight();i=i>n.getBottom()?i:n.getBottom()}a()};this.inflate=function(n){b-=n;g-=n;d+=n;i+=n;a()};this.minSelf=function(n){b=b>n.getLeft()?b:n.getLeft();g=g>n.getTop()?g:n.getTop();d=d=0&&Math.min(i,n.getBottom())-Math.max(g,n.getTop())>=0};this.empty=function(){j=true;i=d=g=b=0;a()};this.isEmpty=function(){return j};this.toString= -function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+g+", bottom: "+i+", width: "+k+", height: "+o+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; -THREE.Matrix4=function(a,b,g,d,i,k,o,j,n,c,B,A,x,v,H,L){this.n11=a||1;this.n12=b||0;this.n13=g||0;this.n14=d||0;this.n21=i||0;this.n22=k||1;this.n23=o||0;this.n24=j||0;this.n31=n||0;this.n32=c||0;this.n33=B||1;this.n34=A||0;this.n41=x||0;this.n42=v||0;this.n43=H||0;this.n44=L||1}; -THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,g,d,i,k,o,j,n,c,B,A,x,v,H,L){this.n11=a;this.n12=b;this.n13=g;this.n14=d;this.n21=i;this.n22=k;this.n23=o;this.n24=j;this.n31=n;this.n32=c;this.n33=B;this.n34=A;this.n41=x;this.n42=v;this.n43=H;this.n44=L;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= -a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,g){var d=new THREE.Vector3,i=new THREE.Vector3,k=new THREE.Vector3;k.sub(a,b).normalize();d.cross(g,k).normalize();i.cross(k,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=i.x;this.n22=i.y;this.n23=i.z;this.n24=-i.dot(a);this.n31=k.x; -this.n32=k.y;this.n33=k.z;this.n34=-k.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,g=a.y,d=a.z,i=1/(this.n41*b+this.n42*g+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*g+this.n13*d+this.n14)*i;a.y=(this.n21*b+this.n22*g+this.n23*d+this.n24)*i;a.z=(this.n31*b+this.n32*g+this.n33*d+this.n34)*i;return a},multiplyVector4:function(a){var b=a.x,g=a.y,d=a.z,i=a.w;a.x=this.n11*b+this.n12*g+this.n13*d+this.n14*i;a.y=this.n21*b+this.n22*g+this.n23*d+this.n24* -i;a.z=this.n31*b+this.n32*g+this.n33*d+this.n34*i;a.w=this.n41*b+this.n42*g+this.n43*d+this.n44*i;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 g=a.n11,d=a.n12,i=a.n13,k=a.n14,o=a.n21,j=a.n22,n=a.n23,c=a.n24,B=a.n31,A=a.n32, -x=a.n33,v=a.n34,H=a.n41,L=a.n42,J=a.n43,I=a.n44,O=b.n11,E=b.n12,f=b.n13,m=b.n14,e=b.n21,p=b.n22,l=b.n23,h=b.n24,u=b.n31,y=b.n32,D=b.n33,q=b.n34,C=b.n41,Q=b.n42,t=b.n43,U=b.n44;this.n11=g*O+d*e+i*u+k*C;this.n12=g*E+d*p+i*y+k*Q;this.n13=g*f+d*l+i*D+k*t;this.n14=g*m+d*h+i*q+k*U;this.n21=o*O+j*e+n*u+c*C;this.n22=o*E+j*p+n*y+c*Q;this.n23=o*f+j*l+n*D+c*t;this.n24=o*m+j*h+n*q+c*U;this.n31=B*O+A*e+x*u+v*C;this.n32=B*E+A*p+x*y+v*Q;this.n33=B*f+A*l+x*D+v*t;this.n34=B*m+A*h+x*q+v*U;this.n41=H*O+L*e+J*u+I*C; -this.n42=H*E+L*p+J*y+I*Q;this.n43=H*f+L*l+J*D+I*t;this.n44=H*m+L*h+J*q+I*U;return this},multiplySelf:function(a){var b=this.n11,g=this.n12,d=this.n13,i=this.n14,k=this.n21,o=this.n22,j=this.n23,n=this.n24,c=this.n31,B=this.n32,A=this.n33,x=this.n34,v=this.n41,H=this.n42,L=this.n43,J=this.n44,I=a.n11,O=a.n21,E=a.n31,f=a.n41,m=a.n12,e=a.n22,p=a.n32,l=a.n42,h=a.n13,u=a.n23,y=a.n33,D=a.n43,q=a.n14,C=a.n24,Q=a.n34;a=a.n44;this.n11=b*I+g*O+d*E+i*f;this.n12=b*m+g*e+d*p+i*l;this.n13=b*h+g*u+d*y+i*D;this.n14= -b*q+g*C+d*Q+i*a;this.n21=k*I+o*O+j*E+n*f;this.n22=k*m+o*e+j*p+n*l;this.n23=k*h+o*u+j*y+n*D;this.n24=k*q+o*C+j*Q+n*a;this.n31=c*I+B*O+A*E+x*f;this.n32=c*m+B*e+A*p+x*l;this.n33=c*h+B*u+A*y+x*D;this.n34=c*q+B*C+A*Q+x*a;this.n41=v*I+H*O+L*E+J*f;this.n42=v*m+H*e+L*p+J*l;this.n43=v*h+H*u+L*y+J*D;this.n44=v*q+H*C+L*Q+J*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*= +THREE.Ray.prototype={intersectScene:function(a){var b,g,d=a.objects,i=[];a=0;for(b=d.length;a0&&N>0&&m+N<1}var g,d,i,l,o,k,n,c,C,B, +x,w=a.geometry,J=w.vertices,P=[];g=0;for(d=w.faces.length;gn?d:n;i=i>c? +i:c}a()};this.add3Points=function(n,c,C,B,x,w){if(k){k=false;b=nC?n>x?n:x:C>x?C:x;i=c>B?c>w?c:w:B>w?B:w}else{b=nC?n>x?n>d?n:d:x>d?x:d:C>x?C>d?C:d:x>d?x:d;i=c>B?c>w?c>i?c:i:w>i?w:i:B>w?B>i?B:i:w>i?w:i}a()};this.addRectangle=function(n){if(k){k=false;b=n.getLeft();g=n.getTop();d=n.getRight();i=n.getBottom()}else{b=bn.getRight()?d:n.getRight();i=i>n.getBottom()?i:n.getBottom()}a()};this.inflate=function(n){b-=n;g-=n;d+=n;i+=n;a()};this.minSelf=function(n){b=b>n.getLeft()?b:n.getLeft();g=g>n.getTop()?g:n.getTop();d=d=0&&Math.min(i,n.getBottom())-Math.max(g,n.getTop())>=0};this.empty=function(){k=true;i=d=g=b=0;a()};this.isEmpty=function(){return k};this.toString= +function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+g+", bottom: "+i+", width: "+l+", height: "+o+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; +THREE.Matrix4=function(a,b,g,d,i,l,o,k,n,c,C,B,x,w,J,P){this.n11=a||1;this.n12=b||0;this.n13=g||0;this.n14=d||0;this.n21=i||0;this.n22=l||1;this.n23=o||0;this.n24=k||0;this.n31=n||0;this.n32=c||0;this.n33=C||1;this.n34=B||0;this.n41=x||0;this.n42=w||0;this.n43=J||0;this.n44=P||1}; +THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,g,d,i,l,o,k,n,c,C,B,x,w,J,P){this.n11=a;this.n12=b;this.n13=g;this.n14=d;this.n21=i;this.n22=l;this.n23=o;this.n24=k;this.n31=n;this.n32=c;this.n33=C;this.n34=B;this.n41=x;this.n42=w;this.n43=J;this.n44=P;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= +a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,g){var d=new THREE.Vector3,i=new THREE.Vector3,l=new THREE.Vector3;l.sub(a,b).normalize();d.cross(g,l).normalize();i.cross(l,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=i.x;this.n22=i.y;this.n23=i.z;this.n24=-i.dot(a);this.n31=l.x; +this.n32=l.y;this.n33=l.z;this.n34=-l.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,g=a.y,d=a.z,i=1/(this.n41*b+this.n42*g+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*g+this.n13*d+this.n14)*i;a.y=(this.n21*b+this.n22*g+this.n23*d+this.n24)*i;a.z=(this.n31*b+this.n32*g+this.n33*d+this.n34)*i;return a},multiplyVector4:function(a){var b=a.x,g=a.y,d=a.z,i=a.w;a.x=this.n11*b+this.n12*g+this.n13*d+this.n14*i;a.y=this.n21*b+this.n22*g+this.n23*d+this.n24* +i;a.z=this.n31*b+this.n32*g+this.n33*d+this.n34*i;a.w=this.n41*b+this.n42*g+this.n43*d+this.n44*i;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 g=a.n11,d=a.n12,i=a.n13,l=a.n14,o=a.n21,k=a.n22,n=a.n23,c=a.n24,C=a.n31,B=a.n32, +x=a.n33,w=a.n34,J=a.n41,P=a.n42,N=a.n43,q=a.n44,Q=b.n11,D=b.n12,e=b.n13,m=b.n14,f=b.n21,p=b.n22,j=b.n23,h=b.n24,s=b.n31,E=b.n32,r=b.n33,v=b.n34,u=b.n41,K=b.n42,F=b.n43,G=b.n44;this.n11=g*Q+d*f+i*s+l*u;this.n12=g*D+d*p+i*E+l*K;this.n13=g*e+d*j+i*r+l*F;this.n14=g*m+d*h+i*v+l*G;this.n21=o*Q+k*f+n*s+c*u;this.n22=o*D+k*p+n*E+c*K;this.n23=o*e+k*j+n*r+c*F;this.n24=o*m+k*h+n*v+c*G;this.n31=C*Q+B*f+x*s+w*u;this.n32=C*D+B*p+x*E+w*K;this.n33=C*e+B*j+x*r+w*F;this.n34=C*m+B*h+x*v+w*G;this.n41=J*Q+P*f+N*s+q*u; +this.n42=J*D+P*p+N*E+q*K;this.n43=J*e+P*j+N*r+q*F;this.n44=J*m+P*h+N*v+q*G;return this},multiplySelf:function(a){var b=this.n11,g=this.n12,d=this.n13,i=this.n14,l=this.n21,o=this.n22,k=this.n23,n=this.n24,c=this.n31,C=this.n32,B=this.n33,x=this.n34,w=this.n41,J=this.n42,P=this.n43,N=this.n44,q=a.n11,Q=a.n21,D=a.n31,e=a.n41,m=a.n12,f=a.n22,p=a.n32,j=a.n42,h=a.n13,s=a.n23,E=a.n33,r=a.n43,v=a.n14,u=a.n24,K=a.n34;a=a.n44;this.n11=b*q+g*Q+d*D+i*e;this.n12=b*m+g*f+d*p+i*j;this.n13=b*h+g*s+d*E+i*r;this.n14= +b*v+g*u+d*K+i*a;this.n21=l*q+o*Q+k*D+n*e;this.n22=l*m+o*f+k*p+n*j;this.n23=l*h+o*s+k*E+n*r;this.n24=l*v+o*u+k*K+n*a;this.n31=c*q+C*Q+B*D+x*e;this.n32=c*m+C*f+B*p+x*j;this.n33=c*h+C*s+B*E+x*r;this.n34=c*v+C*u+B*K+x*a;this.n41=w*q+J*Q+P*D+N*e;this.n42=w*m+J*f+P*p+N*j;this.n43=w*h+J*s+P*E+N*r;this.n44=w*v+J*u+P*K+N*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(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34* this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,g,d){var i=b[g];b[g]=b[d]; b[d]=i}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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(){return[this.n11,this.n21,this.n31,this.n41,this.n12, this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,g){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=g;return d}; THREE.Matrix4.scaleMatrix=function(a,b,g){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=g;return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; -THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var g=new THREE.Matrix4,d=Math.cos(b),i=Math.sin(b),k=1-d,o=a.x,j=a.y,n=a.z;g.n11=k*o*o+d;g.n12=k*o*j-i*n;g.n13=k*o*n+i*j;g.n21=k*o*j+i*n;g.n22=k*j*j+d;g.n23=k*j*n-i*o;g.n31=k*o*n-i*j;g.n32=k*j*n+i*o;g.n33=k*n*n+d;return g}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var g=new THREE.Matrix4,d=Math.cos(b),i=Math.sin(b),l=1-d,o=a.x,k=a.y,n=a.z;g.n11=l*o*o+d;g.n12=l*o*k-i*n;g.n13=l*o*n+i*k;g.n21=l*o*k+i*n;g.n22=l*k*k+d;g.n23=l*k*n-i*o;g.n31=l*o*n-i*k;g.n32=l*k*n+i*o;g.n33=l*n*n+d;return g}; THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12* a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32* a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22* a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var g=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],i=b[6]*b[1]-b[2]*b[5],k=-b[10]*b[4]+b[6]*b[8],o=b[10]*b[0]-b[2]*b[8],j=-b[6]*b[0]+b[2]*b[4],n=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],B=b[5]*b[0]-b[1]*b[4];b=b[0]*g+b[1]*k+b[2]*n;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*g;a.m[1]=b*d;a.m[2]=b*i;a.m[3]=b*k;a.m[4]=b*o;a.m[5]=b*j;a.m[6]=b*n;a.m[7]=b*c;a.m[8]=b*B;return a}; -THREE.Matrix4.makeFrustum=function(a,b,g,d,i,k){var o,j,n;o=new THREE.Matrix4;j=2*i/(b-a);n=2*i/(d-g);a=(b+a)/(b-a);g=(d+g)/(d-g);d=-(k+i)/(k-i);i=-2*k*i/(k-i);o.n11=j;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=n;o.n23=g;o.n24=0;o.n31=0;o.n32=0;o.n33=d;o.n34=i;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,b,g,d){var i;a=g*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*b,a*b,i,a,g,d)}; -THREE.Matrix4.makeOrtho=function(a,b,g,d,i,k){var o,j,n,c;o=new THREE.Matrix4;j=b-a;n=g-d;c=k-i;a=(b+a)/j;g=(g+d)/n;i=(k+i)/c;o.n11=2/j;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/n;o.n23=0;o.n24=-g;o.n31=0;o.n32=0;o.n33=-2/c;o.n34=-i;o.n41=0;o.n42=0;o.n43=0;o.n44=1;return o}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var g=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],i=b[6]*b[1]-b[2]*b[5],l=-b[10]*b[4]+b[6]*b[8],o=b[10]*b[0]-b[2]*b[8],k=-b[6]*b[0]+b[2]*b[4],n=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],C=b[5]*b[0]-b[1]*b[4];b=b[0]*g+b[1]*l+b[2]*n;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*g;a.m[1]=b*d;a.m[2]=b*i;a.m[3]=b*l;a.m[4]=b*o;a.m[5]=b*k;a.m[6]=b*n;a.m[7]=b*c;a.m[8]=b*C;return a}; +THREE.Matrix4.makeFrustum=function(a,b,g,d,i,l){var o,k,n;o=new THREE.Matrix4;k=2*i/(b-a);n=2*i/(d-g);a=(b+a)/(b-a);g=(d+g)/(d-g);d=-(l+i)/(l-i);i=-2*l*i/(l-i);o.n11=k;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=n;o.n23=g;o.n24=0;o.n31=0;o.n32=0;o.n33=d;o.n34=i;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,b,g,d){var i;a=g*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*b,a*b,i,a,g,d)}; +THREE.Matrix4.makeOrtho=function(a,b,g,d,i,l){var o,k,n,c;o=new THREE.Matrix4;k=b-a;n=g-d;c=l-i;a=(b+a)/k;g=(g+d)/n;i=(l+i)/c;o.n11=2/k;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/n;o.n23=0;o.n24=-g;o.n31=0;o.n32=0;o.n33=-2/c;o.n34=-i;o.n41=0;o.n42=0;o.n43=0;o.n44=1;return o}; 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=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; THREE.Face3=function(a,b,g,d,i){this.a=a;this.b=b;this.c=g;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.material=i instanceof Array?i:[i]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,b,g,d,i,k){this.a=a;this.b=b;this.c=g;this.d=d;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];this.material=k instanceof Array?k:[k]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; -THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.geometryChunks={};this.hasTangents=false}; +THREE.Face4=function(a,b,g,d,i,l){this.a=a;this.b=b;this.c=g;this.d=d;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];this.material=l instanceof Array?l:[l]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; +THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; THREE.Geometry.prototype={computeCentroids:function(){var a,b,g;a=0;for(b=this.faces.length;a0){this.bbox={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 a=1,b=this.vertices.length;athis.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.ythis.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(B){var A=[];b=0;for(g=B.length;b65535){c[j].counter+=1;n=c[j].hash+"_"+c[j].counter;if(this.geometryChunks[n]==undefined)this.geometryChunks[n]={faces:[],material:o,vertices:0}}this.geometryChunks[n].faces.push(d);this.geometryChunks[n].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +g.centroid.addSelf(this.vertices[g.d].position);g.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,g,d,i,l,o,k=new THREE.Vector3,n=new THREE.Vector3;d=0;for(i=this.vertices.length;d0){this.bbox={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,g=this.vertices.length;bthis.bbox.x[1])this.bbox.x[1]=a.position.x;if(a.position.ythis.bbox.y[1])this.bbox.y[1]=a.position.y;if(a.position.z +this.bbox.z[1])this.bbox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,g=this.vertices.length;b65535){c[k].counter+=1;n=c[k].hash+"_"+c[k].counter;if(this.geometryChunks[n]==undefined)this.geometryChunks[n]={faces:[],material:o,vertices:0}}this.geometryChunks[n].faces.push(d);this.geometryChunks[n].vertices+=l}},toString:function(){return"THREE.Geometry ( vertices: "+ +this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; THREE.Camera=function(a,b,g,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,g,d);this.autoUpdateMatrix=true;this.translateX=function(i){i=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(i);i.cross(i.clone(),this.up);this.position.addSelf(i);this.target.position.addSelf(i)};this.translateZ=function(i){i=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(i); this.position.subSelf(i);this.target.position.subSelf(i)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight; THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z); this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0}; THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; -THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2; +THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2; THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}this.toString=function(){return"THREE.LineBasicMaterial (
color: "+ this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+this.linewidth+"
linecap: "+this.linecap+"
linejoin: "+this.linejoin+"
)"}}; THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map= @@ -84,94 +85,96 @@ undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shadi THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleBasicMaterial (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+ this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}}; THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}}; -THREE.Texture=function(a,b,g,d,i,k){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=g!==undefined?g:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=k!==undefined?k:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
mag_filter: "+this.mag_filter+"
min_filter: "+ +THREE.Texture=function(a,b,g,d,i,l){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=g!==undefined?g:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=l!==undefined?l:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
mag_filter: "+this.mag_filter+"
min_filter: "+ this.min_filter+"
)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){}; THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){}; THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}}; -THREE.Projector=function(){function a(e,p){var l=0,h=1,u=e.z+e.w,y=p.z+p.w,D=-e.z+e.w,q=-p.z+p.w;if(u>=0&&y>=0&&D>=0&&q>=0)return true;else if(u<0&&y<0||D<0&&q<0)return false;else{if(u<0)l=Math.max(l,u/(u-y));else if(y<0)h=Math.min(h,u/(u-y));if(D<0)l=Math.max(l,D/(D-q));else if(q<0)h=Math.min(h,D/(D-q));if(h0&&q.z<1}F=F.faces;y=0;for(D=F.length;y0&&J.z<1){x=H[v]=H[v]||new THREE.RenderableParticle; -x.x=J.x/J.w;x.y=J.y/J.w;x.z=J.z;x.rotation=t.rotation.z;x.scale.x=t.scale.x*Math.abs(x.x-(J.x+p.projectionMatrix.n11)/(J.w+p.projectionMatrix.n14));x.scale.y=t.scale.y*Math.abs(x.y-(J.y+p.projectionMatrix.n22)/(J.w+p.projectionMatrix.n24));x.material=t.material;h.push(x);v++}}}}l&&h.sort(b);return h};this.unprojectVector=function(e,p){var l=new THREE.Matrix4;l.multiply(THREE.Matrix4.makeInvert(p.matrix),THREE.Matrix4.makeInvert(p.projectionMatrix));l.multiplyVector3(e);return e}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,g,d,i,k;this.domElement=document.createElement("div");this.setSize=function(o,j){g=o;d=j;i=g/2;k=d/2};this.render=function(o,j){var n,c,B,A,x,v,H,L;a=b.projectScene(o,j);n=0;for(c=a.length;n0){z.r+=$.r*W;z.g+=$.g*W;z.b+=$.b*W}}else if(W instanceof THREE.PointLight){Y.sub(W.position,R);Y.normalize();W=K.dot(Y)*ba;if(W>0){z.r+=$.r*W;z.g+=$.g*W;z.b+=$.b*W}}}}function La(s,R,K){if(K.opacity!=0){Ba(K.opacity);wa(K.blending);var z,G,W,$,ba,ca;if(K instanceof THREE.ParticleBasicMaterial){if(K.map){$=K.map;ba=$.width>>1;ca=$.height>>1;G=R.scale.x*k;W=R.scale.y*o;K=G*ba;z=W*ca;r.set(s.x-K,s.y-z,s.x+K,s.y+z);if(!F.instersects(r))return; -j.save();j.translate(s.x,s.y);j.rotate(-R.rotation);j.scale(G,-W);j.translate(-ba,-ca);j.drawImage($,0,0);j.restore()}j.beginPath();j.moveTo(s.x-10,s.y);j.lineTo(s.x+10,s.y);j.moveTo(s.x,s.y-10);j.lineTo(s.x,s.y+10);j.closePath();j.strokeStyle="rgb(255,255,0)";j.stroke()}else if(K instanceof THREE.ParticleCircleMaterial){if(N){S.r=M.r+T.r+aa.r;S.g=M.g+T.g+aa.g;S.b=M.b+T.b+aa.b;e.r=K.color.r*S.r;e.g=K.color.g*S.g;e.b=K.color.b*S.b;e.updateStyleString()}else e.__styleString=K.color.__styleString;K= -R.scale.x*k;z=R.scale.y*o;r.set(s.x-K,s.y-z,s.x+K,s.y+z);if(F.instersects(r)){G=e.__styleString;if(A!=G)j.fillStyle=A=G;j.save();j.translate(s.x,s.y);j.rotate(-R.rotation);j.scale(K,z);j.beginPath();j.arc(0,0,1,0,Ja,true);j.closePath();j.fill();j.restore()}}}}function Ma(s,R,K,z){if(z.opacity!=0){Ba(z.opacity);wa(z.blending);j.beginPath();j.moveTo(s.positionScreen.x,s.positionScreen.y);j.lineTo(R.positionScreen.x,R.positionScreen.y);j.closePath();if(z instanceof THREE.LineBasicMaterial){e.__styleString= -z.color.__styleString;s=z.linewidth;if(x!=s)j.lineWidth=x=s;s=e.__styleString;if(B!=s)j.strokeStyle=B=s;j.stroke();r.inflate(z.linewidth*2)}}}function Fa(s,R,K,z,G,W){if(G.opacity!=0){Ba(G.opacity);wa(G.blending);J=s.positionScreen.x;I=s.positionScreen.y;O=R.positionScreen.x;E=R.positionScreen.y;f=K.positionScreen.x;m=K.positionScreen.y;j.beginPath();j.moveTo(J,I);j.lineTo(O,E);j.lineTo(f,m);j.lineTo(J,I);j.closePath();if(G instanceof THREE.MeshBasicMaterial)if(G.map)G.map.image.loaded&&G.map.mapping instanceof -THREE.UVMapping&&qa(J,I,O,E,f,m,G.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);else if(G.env_map){if(G.env_map.image.loaded)if(G.env_map.mapping instanceof THREE.SphericalReflectionMapping){s=ua.matrix;Y.copy(z.vertexNormalsWorld[0]);Q=(Y.x*s.n11+Y.y*s.n12+Y.z*s.n13)*0.5+0.5;t=-(Y.x*s.n21+Y.y*s.n22+Y.z*s.n23)*0.5+0.5;Y.copy(z.vertexNormalsWorld[1]);U=(Y.x*s.n11+Y.y*s.n12+Y.z*s.n13)*0.5+0.5;P=-(Y.x*s.n21+Y.y*s.n22+Y.z*s.n23)*0.5+0.5;Y.copy(z.vertexNormalsWorld[2]);X= -(Y.x*s.n11+Y.y*s.n12+Y.z*s.n13)*0.5+0.5;V=-(Y.x*s.n21+Y.y*s.n22+Y.z*s.n23)*0.5+0.5;qa(J,I,O,E,f,m,G.env_map.image,Q,t,U,P,X,V)}}else G.wireframe?xa(G.color.__styleString,G.wireframe_linewidth):ya(G.color.__styleString);else if(G instanceof THREE.MeshLambertMaterial){if(G.map&&!G.wireframe){G.map.mapping instanceof THREE.UVMapping&&qa(J,I,O,E,f,m,G.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);wa(THREE.SubtractiveBlending)}if(N)if(!G.wireframe&&G.shading==THREE.SmoothShading&& -z.vertexNormalsWorld.length==3){p.r=l.r=h.r=M.r;p.g=l.g=h.g=M.g;p.b=l.b=h.b=M.b;va(W,z.v1.positionWorld,z.vertexNormalsWorld[0],p);va(W,z.v2.positionWorld,z.vertexNormalsWorld[1],l);va(W,z.v3.positionWorld,z.vertexNormalsWorld[2],h);u.r=(l.r+h.r)*0.5;u.g=(l.g+h.g)*0.5;u.b=(l.b+h.b)*0.5;C=Ga(p,l,h,u);qa(J,I,O,E,f,m,C,0,0,1,0,0,1)}else{S.r=M.r;S.g=M.g;S.b=M.b;va(W,z.centroidWorld,z.normalWorld,S);e.r=G.color.r*S.r;e.g=G.color.g*S.g;e.b=G.color.b*S.b;e.updateStyleString();G.wireframe?xa(e.__styleString, -G.wireframe_linewidth):ya(e.__styleString)}else G.wireframe?xa(G.color.__styleString,G.wireframe_linewidth):ya(G.color.__styleString)}else if(G instanceof THREE.MeshDepthMaterial){y=G.__2near;D=G.__farPlusNear;q=G.__farMinusNear;p.r=p.g=p.b=1-y/(D-s.positionScreen.z*q);l.r=l.g=l.b=1-y/(D-R.positionScreen.z*q);h.r=h.g=h.b=1-y/(D-K.positionScreen.z*q);u.r=(l.r+h.r)*0.5;u.g=(l.g+h.g)*0.5;u.b=(l.b+h.b)*0.5;C=Ga(p,l,h,u);qa(J,I,O,E,f,m,C,0,0,1,0,0,1)}else if(G instanceof THREE.MeshNormalMaterial){e.r= -Ca(z.normalWorld.x);e.g=Ca(z.normalWorld.y);e.b=Ca(z.normalWorld.z);e.updateStyleString();G.wireframe?xa(e.__styleString,G.wireframe_linewidth):ya(e.__styleString)}}}function xa(s,R){if(B!=s)j.strokeStyle=B=s;if(x!=R)j.lineWidth=x=R;j.stroke();r.inflate(R*2)}function ya(s){if(A!=s)j.fillStyle=A=s;j.fill()}function qa(s,R,K,z,G,W,$,ba,ca,ha,ea,ia,ra){var ka,ja;ka=$.width-1;ja=$.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;ra*=ja;K-=s;z-=R;G-=s;W-=R;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka= -(ra*K-ea*G)*ja;ea=(ra*z-ea*W)*ja;K=(ha*G-ia*K)*ja;z=(ha*W-ia*z)*ja;s=s-ka*ba-K*ca;R=R-ea*ba-z*ca;j.save();j.transform(ka,ea,K,z,s,R);j.clip();j.drawImage($,0,0);j.restore()}function Ba(s){if(n!=s)j.globalAlpha=n=s}function wa(s){if(c!=s){switch(s){case THREE.NormalBlending:j.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:j.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:j.globalCompositeOperation="darker"}c=s}}function Ga(s,R,K,z){var G=~~(s.r*255), -W=~~(s.g*255);s=~~(s.b*255);var $=~~(R.r*255),ba=~~(R.g*255);R=~~(R.b*255);var ca=~~(K.r*255),ha=~~(K.g*255);K=~~(K.b*255);var ea=~~(z.r*255),ia=~~(z.g*255);z=~~(z.b*255);da[0]=G<0?0:G>255?255:G;da[1]=W<0?0:W>255?255:W;da[2]=s<0?0:s>255?255:s;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=R<0?0:R>255?255:R;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=K<0?0:K>255?255:K;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=z<0?0:z>255?255:z;oa.putImageData(Aa,0,0); -ta.drawImage(na,0,0);return pa}function Ca(s){s=(s+1)*0.5;return s<0?0:s>1?1:s}function Da(s,R){var K=R.x-s.x,z=R.y-s.y,G=1/Math.sqrt(K*K+z*z);K*=G;z*=G;R.x+=K;R.y+=z;s.x-=K;s.y-=z}var za,Ha,Z,fa,ma,Ea,Ia,sa;j.setTransform(1,0,0,-1,k,o);this.autoClear&&this.clear();a=b.projectScene(ga,ua,this.sortElements);j.fillStyle="rgba(0, 255, 255, 0.5)";j.fillRect(F.getX(),F.getY(),F.getWidth(),F.getHeight());(N=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za0){V.r+=r.color.r*N;V.g+=r.color.g*N;V.b+=r.color.b*N}}else if(r instanceof THREE.PointLight){h.sub(r.position,X.centroidWorld);h.normalize();N=X.normalWorld.dot(h)*r.intensity;if(N>0){V.r+=r.color.r*N;V.g+=r.color.g*N;V.b+=r.color.b*N}}}}function b(P,X,V,F,w,r){q=d(C++);q.setAttribute("d","M "+P.positionScreen.x+ -" "+P.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)E.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(O){f.r=m.r;f.g=m.g;f.b=m.b;a(r,F,f);E.r=w.color.r*f.r;E.g=w.color.g*f.g;E.b=w.color.b*f.b;E.updateStyleString()}else E.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){l=1-w.__2near/(w.__farPlusNear-F.z*w.__farMinusNear); -E.setRGB(l,l,l)}else w instanceof THREE.MeshNormalMaterial&&E.setRGB(i(F.normalWorld.x),i(F.normalWorld.y),i(F.normalWorld.z));w.wireframe?q.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):q.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+w.opacity);j.appendChild(q)}function g(P,X,V,F,w,r,N){q=d(C++);q.setAttribute("d", -"M "+P.positionScreen.x+" "+P.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+F.positionScreen.x+","+F.positionScreen.y+"z");if(r instanceof THREE.MeshBasicMaterial)E.__styleString=r.color.__styleString;else if(r instanceof THREE.MeshLambertMaterial)if(O){f.r=m.r;f.g=m.g;f.b=m.b;a(N,w,f);E.r=r.color.r*f.r;E.g=r.color.g*f.g;E.b=r.color.b*f.b;E.updateStyleString()}else E.__styleString=r.color.__styleString;else if(r instanceof THREE.MeshDepthMaterial){l= -1-r.__2near/(r.__farPlusNear-w.z*r.__farMinusNear);E.setRGB(l,l,l)}else r instanceof THREE.MeshNormalMaterial&&E.setRGB(i(w.normalWorld.x),i(w.normalWorld.y),i(w.normalWorld.z));r.wireframe?q.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+r.wireframe_linewidth+"; stroke-opacity: "+r.opacity+"; stroke-linecap: "+r.wireframe_linecap+"; stroke-linejoin: "+r.wireframe_linejoin):q.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+r.opacity);j.appendChild(q)} -function d(P){if(u[P]==null){u[P]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&u[P].setAttribute("shape-rendering","crispEdges");return u[P]}return u[P]}function i(P){return P<0?Math.min((1+P)*0.5,0.5):0.5+Math.min(P*0.5,0.5)}var k=null,o=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,c,B,A,x,v,H,L,J=new THREE.Rectangle,I=new THREE.Rectangle,O=false,E=new THREE.Color(16777215),f=new THREE.Color(16777215),m=new THREE.Color(0),e=new THREE.Color(0), -p=new THREE.Color(0),l,h=new THREE.Vector3,u=[],y=[],D=[],q,C,Q,t,U=1;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(P){switch(P){case "high":U=1;break;case "low":U=0}};this.setSize=function(P,X){n=P;c=X;B=n/2;A=c/2;j.setAttribute("viewBox",-B+" "+-A+" "+n+" "+c);j.setAttribute("width",n);j.setAttribute("height",c);J.set(-B,-A,B,A)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])};this.render=function(P,X){var V,F, -w,r,N,S,M,T;this.autoClear&&this.clear();k=o.projectScene(P,X,this.sortElements);t=Q=C=0;if(O=P.lights.length>0){M=P.lights;m.setRGB(0,0,0);e.setRGB(0,0,0);p.setRGB(0,0,0);V=0;for(F=M.length;V0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(e,o("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"+ -f));c.attachShader(e,o("vertex",p+m));c.linkProgram(e);c.getProgramParameter(e,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(e,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");e.uniforms={};e.attributes={};return e}function g(f,m){if(f.image.length==6){if(!f.image.__webGLTextureCube&&!f.image.__cubeMapInitialized&&f.image.loadCount==6){f.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,f.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP, -c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var e=0;e<6;++e)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,f.image[e]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);f.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_CUBE_MAP, -f.image.__webGLTextureCube)}}function d(f,m){if(!f.__webGLTexture&&f.image.loaded){f.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,f.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,f.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,j(f.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,j(f.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,j(f.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,j(f.min_filter));c.generateMipmap(c.TEXTURE_2D); -c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_2D,f.__webGLTexture)}function i(f,m){var e,p,l;e=0;for(p=m.length;e=0&&r>=0&&v>=0&&u>=0)return true;else if(E<0&&r<0||v<0&&u<0)return false;else{if(E<0)h=Math.max(h,E/(E-r));else if(r<0)s=Math.min(s,E/(E-r));if(v<0)h=Math.max(h,v/(v-u));else if(u<0)s=Math.min(s,v/(v-u));if(s0&&u.z<1}z=z.faces;r=0;for(v=z.length;r0&&N.z<1){x=J[w]=J[w]||new THREE.RenderableParticle;x.x=N.x/N.w;x.y=N.y/N.w;x.z=N.z;x.rotation=G.rotation.z;x.scale.x=G.scale.x*Math.abs(x.x-(N.x+j.projectionMatrix.n11)/(N.w+j.projectionMatrix.n14));x.scale.y=G.scale.y*Math.abs(x.y-(N.y+j.projectionMatrix.n22)/(N.w+ +j.projectionMatrix.n24));x.material=G.material;s.push(x);w++}}}}h&&s.sort(a);return s};this.unprojectVector=function(p,j){var h=new THREE.Matrix4;h.multiply(THREE.Matrix4.makeInvert(j.matrix),THREE.Matrix4.makeInvert(j.projectionMatrix));h.multiplyVector3(p);return p}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,g,d,i,l;this.domElement=document.createElement("div");this.setSize=function(o,k){g=o;d=k;i=g/2;l=d/2};this.render=function(o,k){var n,c,C,B,x,w,J,P;a=b.projectScene(o,k);n=0;for(c=a.length;n0){A.r+=$.r*W;A.g+=$.g*W;A.b+=$.b*W}}else if(W instanceof THREE.PointLight){Y.sub(W.position,T);Y.normalize();W=O.dot(Y)*ba;if(W>0){A.r+=$.r*W;A.g+=$.g*W;A.b+=$.b*W}}}}function La(t,T,O){if(O.opacity!=0){Ba(O.opacity);wa(O.blending);var A,I,W,$,ba,ca;if(O instanceof THREE.ParticleBasicMaterial){if(O.map){$=O.map;ba=$.width>>1;ca=$.height>>1;I=T.scale.x*l;W=T.scale.y*o;O=I*ba;A=W*ca;y.set(t.x-O,t.y-A,t.x+O,t.y+A);if(!L.instersects(y))return; +k.save();k.translate(t.x,t.y);k.rotate(-T.rotation);k.scale(I,-W);k.translate(-ba,-ca);k.drawImage($,0,0);k.restore()}k.beginPath();k.moveTo(t.x-10,t.y);k.lineTo(t.x+10,t.y);k.moveTo(t.x,t.y-10);k.lineTo(t.x,t.y+10);k.closePath();k.strokeStyle="rgb(255,255,0)";k.stroke()}else if(O instanceof THREE.ParticleCircleMaterial){if(M){S.r=H.r+U.r+aa.r;S.g=H.g+U.g+aa.g;S.b=H.b+U.b+aa.b;f.r=O.color.r*S.r;f.g=O.color.g*S.g;f.b=O.color.b*S.b;f.updateStyleString()}else f.__styleString=O.color.__styleString;O= +T.scale.x*l;A=T.scale.y*o;y.set(t.x-O,t.y-A,t.x+O,t.y+A);if(L.instersects(y)){I=f.__styleString;if(B!=I)k.fillStyle=B=I;k.save();k.translate(t.x,t.y);k.rotate(-T.rotation);k.scale(O,A);k.beginPath();k.arc(0,0,1,0,Ja,true);k.closePath();k.fill();k.restore()}}}}function Ma(t,T,O,A){if(A.opacity!=0){Ba(A.opacity);wa(A.blending);k.beginPath();k.moveTo(t.positionScreen.x,t.positionScreen.y);k.lineTo(T.positionScreen.x,T.positionScreen.y);k.closePath();if(A instanceof THREE.LineBasicMaterial){f.__styleString= +A.color.__styleString;t=A.linewidth;if(x!=t)k.lineWidth=x=t;t=f.__styleString;if(C!=t)k.strokeStyle=C=t;k.stroke();y.inflate(A.linewidth*2)}}}function Fa(t,T,O,A,I,W){if(I.opacity!=0){Ba(I.opacity);wa(I.blending);N=t.positionScreen.x;q=t.positionScreen.y;Q=T.positionScreen.x;D=T.positionScreen.y;e=O.positionScreen.x;m=O.positionScreen.y;k.beginPath();k.moveTo(N,q);k.lineTo(Q,D);k.lineTo(e,m);k.lineTo(N,q);k.closePath();if(I instanceof THREE.MeshBasicMaterial)if(I.map)I.map.image.loaded&&I.map.mapping instanceof +THREE.UVMapping&&qa(N,q,Q,D,e,m,I.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);else if(I.env_map){if(I.env_map.image.loaded)if(I.env_map.mapping instanceof THREE.SphericalReflectionMapping){t=ua.matrix;Y.copy(A.vertexNormalsWorld[0]);K=(Y.x*t.n11+Y.y*t.n12+Y.z*t.n13)*0.5+0.5;F=-(Y.x*t.n21+Y.y*t.n22+Y.z*t.n23)*0.5+0.5;Y.copy(A.vertexNormalsWorld[1]);G=(Y.x*t.n11+Y.y*t.n12+Y.z*t.n13)*0.5+0.5;R=-(Y.x*t.n21+Y.y*t.n22+Y.z*t.n23)*0.5+0.5;Y.copy(A.vertexNormalsWorld[2]);X= +(Y.x*t.n11+Y.y*t.n12+Y.z*t.n13)*0.5+0.5;V=-(Y.x*t.n21+Y.y*t.n22+Y.z*t.n23)*0.5+0.5;qa(N,q,Q,D,e,m,I.env_map.image,K,F,G,R,X,V)}}else I.wireframe?xa(I.color.__styleString,I.wireframe_linewidth):ya(I.color.__styleString);else if(I instanceof THREE.MeshLambertMaterial){if(I.map&&!I.wireframe){I.map.mapping instanceof THREE.UVMapping&&qa(N,q,Q,D,e,m,I.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);wa(THREE.SubtractiveBlending)}if(M)if(!I.wireframe&&I.shading==THREE.SmoothShading&& +A.vertexNormalsWorld.length==3){p.r=j.r=h.r=H.r;p.g=j.g=h.g=H.g;p.b=j.b=h.b=H.b;va(W,A.v1.positionWorld,A.vertexNormalsWorld[0],p);va(W,A.v2.positionWorld,A.vertexNormalsWorld[1],j);va(W,A.v3.positionWorld,A.vertexNormalsWorld[2],h);s.r=(j.r+h.r)*0.5;s.g=(j.g+h.g)*0.5;s.b=(j.b+h.b)*0.5;u=Ga(p,j,h,s);qa(N,q,Q,D,e,m,u,0,0,1,0,0,1)}else{S.r=H.r;S.g=H.g;S.b=H.b;va(W,A.centroidWorld,A.normalWorld,S);f.r=I.color.r*S.r;f.g=I.color.g*S.g;f.b=I.color.b*S.b;f.updateStyleString();I.wireframe?xa(f.__styleString, +I.wireframe_linewidth):ya(f.__styleString)}else I.wireframe?xa(I.color.__styleString,I.wireframe_linewidth):ya(I.color.__styleString)}else if(I instanceof THREE.MeshDepthMaterial){E=I.__2near;r=I.__farPlusNear;v=I.__farMinusNear;p.r=p.g=p.b=1-E/(r-t.positionScreen.z*v);j.r=j.g=j.b=1-E/(r-T.positionScreen.z*v);h.r=h.g=h.b=1-E/(r-O.positionScreen.z*v);s.r=(j.r+h.r)*0.5;s.g=(j.g+h.g)*0.5;s.b=(j.b+h.b)*0.5;u=Ga(p,j,h,s);qa(N,q,Q,D,e,m,u,0,0,1,0,0,1)}else if(I instanceof THREE.MeshNormalMaterial){f.r= +Ca(A.normalWorld.x);f.g=Ca(A.normalWorld.y);f.b=Ca(A.normalWorld.z);f.updateStyleString();I.wireframe?xa(f.__styleString,I.wireframe_linewidth):ya(f.__styleString)}}}function xa(t,T){if(C!=t)k.strokeStyle=C=t;if(x!=T)k.lineWidth=x=T;k.stroke();y.inflate(T*2)}function ya(t){if(B!=t)k.fillStyle=B=t;k.fill()}function qa(t,T,O,A,I,W,$,ba,ca,ha,ea,ia,ra){var ka,ja;ka=$.width-1;ja=$.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;ra*=ja;O-=t;A-=T;I-=t;W-=T;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka= +(ra*O-ea*I)*ja;ea=(ra*A-ea*W)*ja;O=(ha*I-ia*O)*ja;A=(ha*W-ia*A)*ja;t=t-ka*ba-O*ca;T=T-ea*ba-A*ca;k.save();k.transform(ka,ea,O,A,t,T);k.clip();k.drawImage($,0,0);k.restore()}function Ba(t){if(n!=t)k.globalAlpha=n=t}function wa(t){if(c!=t){switch(t){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}c=t}}function Ga(t,T,O,A){var I=~~(t.r*255), +W=~~(t.g*255);t=~~(t.b*255);var $=~~(T.r*255),ba=~~(T.g*255);T=~~(T.b*255);var ca=~~(O.r*255),ha=~~(O.g*255);O=~~(O.b*255);var ea=~~(A.r*255),ia=~~(A.g*255);A=~~(A.b*255);da[0]=I<0?0:I>255?255:I;da[1]=W<0?0:W>255?255:W;da[2]=t<0?0:t>255?255:t;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=T<0?0:T>255?255:T;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=O<0?0:O>255?255:O;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=A<0?0:A>255?255:A;oa.putImageData(Aa,0,0); +ta.drawImage(na,0,0);return pa}function Ca(t){t=(t+1)*0.5;return t<0?0:t>1?1:t}function Da(t,T){var O=T.x-t.x,A=T.y-t.y,I=1/Math.sqrt(O*O+A*A);O*=I;A*=I;T.x+=O;T.y+=A;t.x-=O;t.y-=A}var za,Ha,Z,fa,ma,Ea,Ia,sa;k.setTransform(1,0,0,-1,l,o);this.autoClear&&this.clear();a=b.projectScene(ga,ua,this.sortElements);k.fillStyle="rgba(0, 255, 255, 0.5)";k.fillRect(L.getX(),L.getY(),L.getWidth(),L.getHeight());(M=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za0){V.r+=y.color.r*M;V.g+=y.color.g*M;V.b+=y.color.b*M}}else if(y instanceof THREE.PointLight){h.sub(y.position,X.centroidWorld);h.normalize();M=X.normalWorld.dot(h)*y.intensity;if(M>0){V.r+=y.color.r*M;V.g+=y.color.g*M;V.b+=y.color.b*M}}}}function b(R,X,V,L,z,y){v=d(u++);v.setAttribute("d","M "+R.positionScreen.x+ +" "+R.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(z instanceof THREE.MeshBasicMaterial)D.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshLambertMaterial)if(Q){e.r=m.r;e.g=m.g;e.b=m.b;a(y,L,e);D.r=z.color.r*e.r;D.g=z.color.g*e.g;D.b=z.color.b*e.b;D.updateStyleString()}else D.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshDepthMaterial){j=1-z.__2near/(z.__farPlusNear-L.z*z.__farMinusNear); +D.setRGB(j,j,j)}else z instanceof THREE.MeshNormalMaterial&&D.setRGB(i(L.normalWorld.x),i(L.normalWorld.y),i(L.normalWorld.z));z.wireframe?v.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+z.wireframe_linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.wireframe_linecap+"; stroke-linejoin: "+z.wireframe_linejoin):v.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+z.opacity);k.appendChild(v)}function g(R,X,V,L,z,y,M){v=d(u++);v.setAttribute("d", +"M "+R.positionScreen.x+" "+R.positionScreen.y+" L "+X.positionScreen.x+" "+X.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+L.positionScreen.x+","+L.positionScreen.y+"z");if(y instanceof THREE.MeshBasicMaterial)D.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshLambertMaterial)if(Q){e.r=m.r;e.g=m.g;e.b=m.b;a(M,z,e);D.r=y.color.r*e.r;D.g=y.color.g*e.g;D.b=y.color.b*e.b;D.updateStyleString()}else D.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshDepthMaterial){j= +1-y.__2near/(y.__farPlusNear-z.z*y.__farMinusNear);D.setRGB(j,j,j)}else y instanceof THREE.MeshNormalMaterial&&D.setRGB(i(z.normalWorld.x),i(z.normalWorld.y),i(z.normalWorld.z));y.wireframe?v.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+y.wireframe_linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframe_linecap+"; stroke-linejoin: "+y.wireframe_linejoin):v.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+y.opacity);k.appendChild(v)} +function d(R){if(s[R]==null){s[R]=document.createElementNS("http://www.w3.org/2000/svg","path");G==0&&s[R].setAttribute("shape-rendering","crispEdges");return s[R]}return s[R]}function i(R){return R<0?Math.min((1+R)*0.5,0.5):0.5+Math.min(R*0.5,0.5)}var l=null,o=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,c,C,B,x,w,J,P,N=new THREE.Rectangle,q=new THREE.Rectangle,Q=false,D=new THREE.Color(16777215),e=new THREE.Color(16777215),m=new THREE.Color(0),f=new THREE.Color(0), +p=new THREE.Color(0),j,h=new THREE.Vector3,s=[],E=[],r=[],v,u,K,F,G=1;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(R){switch(R){case "high":G=1;break;case "low":G=0}};this.setSize=function(R,X){n=R;c=X;C=n/2;B=c/2;k.setAttribute("viewBox",-C+" "+-B+" "+n+" "+c);k.setAttribute("width",n);k.setAttribute("height",c);N.set(-C,-B,C,B)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(R,X){var V,L, +z,y,M,S,H,U;this.autoClear&&this.clear();l=o.projectScene(R,X,this.sortElements);F=K=u=0;if(Q=R.lights.length>0){H=R.lights;m.setRGB(0,0,0);f.setRGB(0,0,0);p.setRGB(0,0,0);V=0;for(L=H.length;V0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(f,o("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"+ +e));c.attachShader(f,o("vertex",p+m));c.linkProgram(f);c.getProgramParameter(f,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(f,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");f.uniforms={};f.attributes={};return f}function g(e,m){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP, +c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var f=0;f<6;++f)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[f]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_CUBE_MAP, +e.image.__webGLTextureCube)}}function d(e,m){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,k(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,k(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,k(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,k(e.min_filter));c.generateMipmap(c.TEXTURE_2D); +c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function i(e,m){var f,p,j;f=0;for(p=m.length;f= 0.0 )": -"",m?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",m?"pointDiffuse += mColor * pointDiffuseWeight;":"",m?"pointSpecular += mSpecular * pointSpecularWeight;":"",m?"}":"",f?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",f?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",f?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",f?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",f?"vec3 dirVector = normalize( lDirection.xyz );":"",f?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": -"",f?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",f?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",f?"float dirSpecularWeight = 0.0;":"",f?"if ( dirDotNormalHalf >= 0.0 )":"",f?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",f?"dirDiffuse += mColor * dirDiffuseWeight;":"",f?"dirSpecular += mSpecular * dirSpecularWeight;":"",f?"}":"","vec4 totalLight = mAmbient;",f?"totalLight += dirDiffuse + dirSpecular;":"",m?"totalLight += pointDiffuse + pointSpecular;": +"",m?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",m?"pointDiffuse += mColor * pointDiffuseWeight;":"",m?"pointSpecular += mSpecular * pointSpecularWeight;":"",m?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": +"",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",m?"totalLight += pointDiffuse + pointSpecular;": "","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n"); -e=b(p,e);c.useProgram(e);i(e,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);f&&i(e,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);m&&i(e,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(e.uniforms.enableMap,0);c.uniform1i(e.uniforms.tMap,0);c.uniform1i(e.uniforms.enableCubeMap,0);c.uniform1i(e.uniforms.tCube,1);c.uniform1i(e.uniforms.mixEnvMap,0);c.uniform1i(e.uniforms.useRefract,0);k(e,["position","normal","uv"]);return e}(a.directional,a.point);this.setSize=function(f,m){n.width=f;n.height=m;c.viewport(0,0,n.width,n.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(f,m){var e,p,l,h,u,y=[], -D=[],q=[];h=[];u=[];c.uniform1i(f.uniforms.enableLighting,m.length);e=0;for(p=m.length;e0){w.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,w.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW)}w.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(Q),c.STATIC_DRAW);w.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, -w.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(t),c.STATIC_DRAW);w.__webGLFaceCount=Q.length;w.__webGLLineCount=t.length}};this.renderBuffer=function(f,m,e,p){var l,h,u,y,D,q,C,Q,t;if(e instanceof THREE.MeshShaderMaterial){if(!e.program){e.program=b(e.fragment_shader,e.vertex_shader);C=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in e.uniforms)C.push(t);i(e.program,C);k(e.program,["position","normal","uv","tangent"])}t= -e.program}else t=A;if(t!=B){c.useProgram(t);B=t}t==A&&this.setupLights(t,m);this.loadCamera(t,f);this.loadMatrices(t);if(e instanceof THREE.MeshShaderMaterial){u=e.wireframe;y=e.wireframe_linewidth;f=t;m=e.uniforms;var U;for(l in m){Q=m[l].type;C=m[l].value;U=f.uniforms[l];if(Q=="i")c.uniform1i(U,C);else if(Q=="f")c.uniform1f(U,C);else if(Q=="v3")c.uniform3f(U,C.x,C.y,C.z);else if(Q=="c")c.uniform3f(U,C.r,C.g,C.b);else if(Q=="t"){c.uniform1i(U,C);if(Q=m[l].texture)Q.image instanceof Array&&Q.image.length== -6?g(Q,C):d(Q,C)}}}if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshBasicMaterial){l=e.color;h=e.opacity;u=e.wireframe;y=e.wireframe_linewidth;D=e.map;q=e.env_map;m=e.combine==THREE.MixOperation;f=e.reflectivity;Q=e.env_map&&e.env_map.mapping instanceof THREE.CubeRefractionMapping;C=e.refraction_ratio;c.uniform4f(t.uniforms.mColor,l.r*h,l.g*h,l.b*h,h);c.uniform1i(t.uniforms.mixEnvMap,m);c.uniform1f(t.uniforms.mReflectivity,f);c.uniform1i(t.uniforms.useRefract, -Q);c.uniform1f(t.uniforms.mRefractionRatio,C)}if(e instanceof THREE.MeshNormalMaterial){h=e.opacity;c.uniform1f(t.uniforms.mOpacity,h);c.uniform1i(t.uniforms.material,4)}else if(e instanceof THREE.MeshDepthMaterial){h=e.opacity;u=e.wireframe;y=e.wireframe_linewidth;c.uniform1f(t.uniforms.mOpacity,h);c.uniform1f(t.uniforms.m2Near,e.__2near);c.uniform1f(t.uniforms.mFarPlusNear,e.__farPlusNear);c.uniform1f(t.uniforms.mFarMinusNear,e.__farMinusNear);c.uniform1i(t.uniforms.material,3)}else if(e instanceof -THREE.MeshPhongMaterial){l=e.ambient;f=e.specular;e=e.shininess;c.uniform4f(t.uniforms.mAmbient,l.r,l.g,l.b,h);c.uniform4f(t.uniforms.mSpecular,f.r,f.g,f.b,h);c.uniform1f(t.uniforms.mShininess,e);c.uniform1i(t.uniforms.material,2)}else if(e instanceof THREE.MeshLambertMaterial)c.uniform1i(t.uniforms.material,1);else e instanceof THREE.MeshBasicMaterial&&c.uniform1i(t.uniforms.material,0);if(D){d(D,0);c.uniform1i(t.uniforms.tMap,0);c.uniform1i(t.uniforms.enableMap,1)}else c.uniform1i(t.uniforms.enableMap, -0);if(q){g(q,1);c.uniform1i(t.uniforms.tCube,1);c.uniform1i(t.uniforms.enableCubeMap,1)}else c.uniform1i(t.uniforms.enableCubeMap,0);h=t.attributes;c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(h.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(h.position);if(h.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(h.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(h.normal)}if(h.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer); -c.vertexAttribPointer(h.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(h.tangent)}if(h.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.vertexAttribPointer(h.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(h.uv)}else c.disableVertexAttribArray(h.uv);if(u){c.lineWidth(y);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(c.LINES,p.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES, -p.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(f,m,e,p,l,h){var u,y,D,q,C;D=0;for(q=e.material.length;D=0;e--){p=f.__webGLObjects[e].object;m==p&&f.__webGLObjects.splice(e,1)}};this.setupMatrices=function(f,m){f.autoUpdateMatrix&&f.updateMatrix();x.multiply(m.matrix,f.matrix);L.set(x.flatten());v=THREE.Matrix4.makeInvert3x3(x).transpose();I.set(v.m);O.set(f.matrix.flatten())}; -this.loadMatrices=function(f){c.uniformMatrix4fv(f.uniforms.viewMatrix,false,H);c.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,L);c.uniformMatrix4fv(f.uniforms.projectionMatrix,false,J);c.uniformMatrix3fv(f.uniforms.normalMatrix,false,I);c.uniformMatrix4fv(f.uniforms.objectMatrix,false,O)};this.loadCamera=function(f,m){c.uniform3f(f.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(f){switch(f){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;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(f,m){if(f){!m||m=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(f=="back")c.cullFace(c.BACK);else f=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; +f=b(p,f);c.useProgram(f);i(f,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);e&&i(f,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);m&&i(f,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(f.uniforms.enableMap,0);c.uniform1i(f.uniforms.tMap,0);c.uniform1i(f.uniforms.enableCubeMap,0);c.uniform1i(f.uniforms.tCube,1);c.uniform1i(f.uniforms.mixEnvMap,0);c.uniform1i(f.uniforms.useRefract,0);l(f,["position","normal","uv"]);return f}(a.directional,a.point);this.setSize=function(e,m){n.width=e;n.height=m;c.viewport(0,0,n.width,n.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,m){var f,p,j,h,s,E=[], +r=[],v=[];h=[];s=[];c.uniform1i(e.uniforms.enableLighting,m.length);f=0;for(p=m.length;f0){z.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,z.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW)}z.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,z.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(K),c.STATIC_DRAW);z.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +z.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(F),c.STATIC_DRAW);z.__webGLFaceCount=K.length;z.__webGLLineCount=F.length}};this.renderBuffer=function(e,m,f,p){var j,h,s,E,r,v,u,K,F;if(f instanceof THREE.MeshShaderMaterial){if(!f.program){f.program=b(f.fragment_shader,f.vertex_shader);u=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(F in f.uniforms)u.push(F);i(f.program,u);l(f.program,["position","normal","uv","tangent"])}F= +f.program}else F=B;if(F!=C){c.useProgram(F);C=F}F==B&&this.setupLights(F,m);this.loadCamera(F,e);this.loadMatrices(F);if(f instanceof THREE.MeshShaderMaterial){s=f.wireframe;E=f.wireframe_linewidth;e=F;m=f.uniforms;var G;for(j in m){K=m[j].type;u=m[j].value;G=e.uniforms[j];if(K=="i")c.uniform1i(G,u);else if(K=="f")c.uniform1f(G,u);else if(K=="v3")c.uniform3f(G,u.x,u.y,u.z);else if(K=="c")c.uniform3f(G,u.r,u.g,u.b);else if(K=="t"){c.uniform1i(G,u);if(K=m[j].texture)K.image instanceof Array&&K.image.length== +6?g(K,u):d(K,u)}}}if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){j=f.color;h=f.opacity;s=f.wireframe;E=f.wireframe_linewidth;r=f.map;v=f.env_map;m=f.combine==THREE.MixOperation;e=f.reflectivity;K=f.env_map&&f.env_map.mapping instanceof THREE.CubeRefractionMapping;u=f.refraction_ratio;c.uniform4f(F.uniforms.mColor,j.r*h,j.g*h,j.b*h,h);c.uniform1i(F.uniforms.mixEnvMap,m);c.uniform1f(F.uniforms.mReflectivity,e);c.uniform1i(F.uniforms.useRefract, +K);c.uniform1f(F.uniforms.mRefractionRatio,u)}if(f instanceof THREE.MeshNormalMaterial){h=f.opacity;c.uniform1f(F.uniforms.mOpacity,h);c.uniform1i(F.uniforms.material,4)}else if(f instanceof THREE.MeshDepthMaterial){h=f.opacity;s=f.wireframe;E=f.wireframe_linewidth;c.uniform1f(F.uniforms.mOpacity,h);c.uniform1f(F.uniforms.m2Near,f.__2near);c.uniform1f(F.uniforms.mFarPlusNear,f.__farPlusNear);c.uniform1f(F.uniforms.mFarMinusNear,f.__farMinusNear);c.uniform1i(F.uniforms.material,3)}else if(f instanceof +THREE.MeshPhongMaterial){j=f.ambient;e=f.specular;f=f.shininess;c.uniform4f(F.uniforms.mAmbient,j.r,j.g,j.b,h);c.uniform4f(F.uniforms.mSpecular,e.r,e.g,e.b,h);c.uniform1f(F.uniforms.mShininess,f);c.uniform1i(F.uniforms.material,2)}else if(f instanceof THREE.MeshLambertMaterial)c.uniform1i(F.uniforms.material,1);else f instanceof THREE.MeshBasicMaterial&&c.uniform1i(F.uniforms.material,0);if(r){d(r,0);c.uniform1i(F.uniforms.tMap,0);c.uniform1i(F.uniforms.enableMap,1)}else c.uniform1i(F.uniforms.enableMap, +0);if(v){g(v,1);c.uniform1i(F.uniforms.tCube,1);c.uniform1i(F.uniforms.enableCubeMap,1)}else c.uniform1i(F.uniforms.enableCubeMap,0);h=F.attributes;c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(h.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(h.position);if(h.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(h.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(h.normal)}if(h.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer); +c.vertexAttribPointer(h.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(h.tangent)}if(h.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.vertexAttribPointer(h.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(h.uv)}else c.disableVertexAttribArray(h.uv);if(s){c.lineWidth(E);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(c.LINES,p.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES, +p.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(e,m,f,p,j,h){var s,E,r,v,u;r=0;for(v=f.material.length;r=0;f--){p=e.__webGLObjects[f].object;m==p&&e.__webGLObjects.splice(f,1)}};this.setupMatrices=function(e,m){e.autoUpdateMatrix&&e.updateMatrix();x.multiply(m.matrix,e.matrix);P.set(x.flatten());w=THREE.Matrix4.makeInvert3x3(x).transpose();q.set(w.m);Q.set(e.matrix.flatten())}; +this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,J);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,P);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,N);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,q);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,Q)};this.loadCamera=function(e,m){c.uniform3f(e.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(e){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;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,m){if(e){!m||m=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);else e=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]}; THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null}; diff --git a/build/ThreeExtras.js b/build/ThreeExtras.js index 7a148932f730aef15961c4872c999d77d3cdec32..135602f727dd83807e9cf737d0f34f0b46464c92 100644 --- a/build/ThreeExtras.js +++ b/build/ThreeExtras.js @@ -12,55 +12,56 @@ THREE.Vector4=function(a,b,e,d){this.x=a||0;this.y=b||0;this.z=e||0;this.w=d||1} THREE.Vector4.prototype={set:function(a,b,e,d){this.x=a;this.y=b;this.z=e;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){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)},toString:function(){return"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,e,d=a.objects,f=[];a=0;for(b=d.length;a0&&K>0&&o+K<1}var e,d,f,g,l,h,k,c,u,y, -r,s=a.geometry,w=s.vertices,z=[];e=0;for(d=s.faces.length;ek?d:k;f=f>c? -f:c}a()};this.add3Points=function(k,c,u,y,r,s){if(h){h=false;b=ku?k>r?k:r:u>r?u:r;f=c>y?c>s?c:s:y>s?y:s}else{b=ku?k>r?k>d?k:d:r>d?r:d:u>r?u>d?u:d:r>d?r:d;f=c>y?c>s?c>f?c:f:s>f?s:f:y>s?y>f?y:f:s>f?s:f}a()};this.addRectangle=function(k){if(h){h=false;b=k.getLeft();e=k.getTop();d=k.getRight();f=k.getBottom()}else{b=bk.getRight()?d:k.getRight();f=f>k.getBottom()?f:k.getBottom()}a()};this.inflate=function(k){b-=k;e-=k;d+=k;f+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();e=e>k.getTop()?e:k.getTop();d=d=0&&Math.min(f,k.getBottom())-Math.max(e,k.getTop())>=0};this.empty=function(){h=true;f=d=e=b=0;a()};this.isEmpty=function(){return h};this.toString= -function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+e+", bottom: "+f+", width: "+g+", height: "+l+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; -THREE.Matrix4=function(a,b,e,d,f,g,l,h,k,c,u,y,r,s,w,z){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=d||0;this.n21=f||0;this.n22=g||1;this.n23=l||0;this.n24=h||0;this.n31=k||0;this.n32=c||0;this.n33=u||1;this.n34=y||0;this.n41=r||0;this.n42=s||0;this.n43=w||0;this.n44=z||1}; -THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,e,d,f,g,l,h,k,c,u,y,r,s,w,z){this.n11=a;this.n12=b;this.n13=e;this.n14=d;this.n21=f;this.n22=g;this.n23=l;this.n24=h;this.n31=k;this.n32=c;this.n33=u;this.n34=y;this.n41=r;this.n42=s;this.n43=w;this.n44=z;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= +THREE.Ray.prototype={intersectScene:function(a){var b,e,d=a.objects,f=[];a=0;for(b=d.length;a0&&J>0&&p+J<1}var e,d,f,g,k,h,j,c,u,y, +r,t=a.geometry,x=t.vertices,C=[];e=0;for(d=t.faces.length;ej?d:j;f=f>c? +f:c}a()};this.add3Points=function(j,c,u,y,r,t){if(h){h=false;b=ju?j>r?j:r:u>r?u:r;f=c>y?c>t?c:t:y>t?y:t}else{b=ju?j>r?j>d?j:d:r>d?r:d:u>r?u>d?u:d:r>d?r:d;f=c>y?c>t?c>f?c:f:t>f?t:f:y>t?y>f?y:f:t>f?t:f}a()};this.addRectangle=function(j){if(h){h=false;b=j.getLeft();e=j.getTop();d=j.getRight();f=j.getBottom()}else{b=bj.getRight()?d:j.getRight();f=f>j.getBottom()?f:j.getBottom()}a()};this.inflate=function(j){b-=j;e-=j;d+=j;f+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();e=e>j.getTop()?e:j.getTop();d=d=0&&Math.min(f,j.getBottom())-Math.max(e,j.getTop())>=0};this.empty=function(){h=true;f=d=e=b=0;a()};this.isEmpty=function(){return h};this.toString= +function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+e+", bottom: "+f+", width: "+g+", height: "+k+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; +THREE.Matrix4=function(a,b,e,d,f,g,k,h,j,c,u,y,r,t,x,C){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=d||0;this.n21=f||0;this.n22=g||1;this.n23=k||0;this.n24=h||0;this.n31=j||0;this.n32=c||0;this.n33=u||1;this.n34=y||0;this.n41=r||0;this.n42=t||0;this.n43=x||0;this.n44=C||1}; +THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,e,d,f,g,k,h,j,c,u,y,r,t,x,C){this.n11=a;this.n12=b;this.n13=e;this.n14=d;this.n21=f;this.n22=g;this.n23=k;this.n24=h;this.n31=j;this.n32=c;this.n33=u;this.n34=y;this.n41=r;this.n42=t;this.n43=x;this.n44=C;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,e){var d=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3;g.sub(a,b).normalize();d.cross(e,g).normalize();f.cross(g,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);this.n31=g.x; this.n32=g.y;this.n33=g.z;this.n34=-g.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,e=a.y,d=a.z,f=1/(this.n41*b+this.n42*e+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*e+this.n13*d+this.n14)*f;a.y=(this.n21*b+this.n22*e+this.n23*d+this.n24)*f;a.z=(this.n31*b+this.n32*e+this.n33*d+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,e=a.y,d=a.z,f=a.w;a.x=this.n11*b+this.n12*e+this.n13*d+this.n14*f;a.y=this.n21*b+this.n22*e+this.n23*d+this.n24* -f;a.z=this.n31*b+this.n32*e+this.n33*d+this.n34*f;a.w=this.n41*b+this.n42*e+this.n43*d+this.n44*f;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 e=a.n11,d=a.n12,f=a.n13,g=a.n14,l=a.n21,h=a.n22,k=a.n23,c=a.n24,u=a.n31,y=a.n32, -r=a.n33,s=a.n34,w=a.n41,z=a.n42,K=a.n43,I=a.n44,D=b.n11,n=b.n12,i=b.n13,o=b.n14,j=b.n21,v=b.n22,q=b.n23,m=b.n24,A=b.n31,F=b.n32,M=b.n33,x=b.n34,J=b.n41,R=b.n42,C=b.n43,V=b.n44;this.n11=e*D+d*j+f*A+g*J;this.n12=e*n+d*v+f*F+g*R;this.n13=e*i+d*q+f*M+g*C;this.n14=e*o+d*m+f*x+g*V;this.n21=l*D+h*j+k*A+c*J;this.n22=l*n+h*v+k*F+c*R;this.n23=l*i+h*q+k*M+c*C;this.n24=l*o+h*m+k*x+c*V;this.n31=u*D+y*j+r*A+s*J;this.n32=u*n+y*v+r*F+s*R;this.n33=u*i+y*q+r*M+s*C;this.n34=u*o+y*m+r*x+s*V;this.n41=w*D+z*j+K*A+I*J; -this.n42=w*n+z*v+K*F+I*R;this.n43=w*i+z*q+K*M+I*C;this.n44=w*o+z*m+K*x+I*V;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,d=this.n13,f=this.n14,g=this.n21,l=this.n22,h=this.n23,k=this.n24,c=this.n31,u=this.n32,y=this.n33,r=this.n34,s=this.n41,w=this.n42,z=this.n43,K=this.n44,I=a.n11,D=a.n21,n=a.n31,i=a.n41,o=a.n12,j=a.n22,v=a.n32,q=a.n42,m=a.n13,A=a.n23,F=a.n33,M=a.n43,x=a.n14,J=a.n24,R=a.n34;a=a.n44;this.n11=b*I+e*D+d*n+f*i;this.n12=b*o+e*j+d*v+f*q;this.n13=b*m+e*A+d*F+f*M;this.n14= -b*x+e*J+d*R+f*a;this.n21=g*I+l*D+h*n+k*i;this.n22=g*o+l*j+h*v+k*q;this.n23=g*m+l*A+h*F+k*M;this.n24=g*x+l*J+h*R+k*a;this.n31=c*I+u*D+y*n+r*i;this.n32=c*o+u*j+y*v+r*q;this.n33=c*m+u*A+y*F+r*M;this.n34=c*x+u*J+y*R+r*a;this.n41=s*I+w*D+z*n+K*i;this.n42=s*o+w*j+z*v+K*q;this.n43=s*m+w*A+z*F+K*M;this.n44=s*x+w*J+z*R+K*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*= +f;a.z=this.n31*b+this.n32*e+this.n33*d+this.n34*f;a.w=this.n41*b+this.n42*e+this.n43*d+this.n44*f;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 e=a.n11,d=a.n12,f=a.n13,g=a.n14,k=a.n21,h=a.n22,j=a.n23,c=a.n24,u=a.n31,y=a.n32, +r=a.n33,t=a.n34,x=a.n41,C=a.n42,J=a.n43,v=a.n44,E=b.n11,n=b.n12,i=b.n13,p=b.n14,l=b.n21,w=b.n22,o=b.n23,m=b.n24,z=b.n31,L=b.n32,A=b.n33,D=b.n34,B=b.n41,N=b.n42,M=b.n43,O=b.n44;this.n11=e*E+d*l+f*z+g*B;this.n12=e*n+d*w+f*L+g*N;this.n13=e*i+d*o+f*A+g*M;this.n14=e*p+d*m+f*D+g*O;this.n21=k*E+h*l+j*z+c*B;this.n22=k*n+h*w+j*L+c*N;this.n23=k*i+h*o+j*A+c*M;this.n24=k*p+h*m+j*D+c*O;this.n31=u*E+y*l+r*z+t*B;this.n32=u*n+y*w+r*L+t*N;this.n33=u*i+y*o+r*A+t*M;this.n34=u*p+y*m+r*D+t*O;this.n41=x*E+C*l+J*z+v*B; +this.n42=x*n+C*w+J*L+v*N;this.n43=x*i+C*o+J*A+v*M;this.n44=x*p+C*m+J*D+v*O;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,d=this.n13,f=this.n14,g=this.n21,k=this.n22,h=this.n23,j=this.n24,c=this.n31,u=this.n32,y=this.n33,r=this.n34,t=this.n41,x=this.n42,C=this.n43,J=this.n44,v=a.n11,E=a.n21,n=a.n31,i=a.n41,p=a.n12,l=a.n22,w=a.n32,o=a.n42,m=a.n13,z=a.n23,L=a.n33,A=a.n43,D=a.n14,B=a.n24,N=a.n34;a=a.n44;this.n11=b*v+e*E+d*n+f*i;this.n12=b*p+e*l+d*w+f*o;this.n13=b*m+e*z+d*L+f*A;this.n14= +b*D+e*B+d*N+f*a;this.n21=g*v+k*E+h*n+j*i;this.n22=g*p+k*l+h*w+j*o;this.n23=g*m+k*z+h*L+j*A;this.n24=g*D+k*B+h*N+j*a;this.n31=c*v+u*E+y*n+r*i;this.n32=c*p+u*l+y*w+r*o;this.n33=c*m+u*z+y*L+r*A;this.n34=c*D+u*B+y*N+r*a;this.n41=t*v+x*E+C*n+J*i;this.n42=t*p+x*l+C*w+J*o;this.n43=t*m+x*z+C*L+J*A;this.n44=t*D+x*B+C*N+J*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(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34* this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,e,d){var f=b[e];b[e]=b[d]; b[d]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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(){return[this.n11,this.n21,this.n31,this.n41,this.n12, this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,e){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=e;return d}; THREE.Matrix4.scaleMatrix=function(a,b,e){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=e;return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; -THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var e=new THREE.Matrix4,d=Math.cos(b),f=Math.sin(b),g=1-d,l=a.x,h=a.y,k=a.z;e.n11=g*l*l+d;e.n12=g*l*h-f*k;e.n13=g*l*k+f*h;e.n21=g*l*h+f*k;e.n22=g*h*h+d;e.n23=g*h*k-f*l;e.n31=g*l*k-f*h;e.n32=g*h*k+f*l;e.n33=g*k*k+d;return e}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var e=new THREE.Matrix4,d=Math.cos(b),f=Math.sin(b),g=1-d,k=a.x,h=a.y,j=a.z;e.n11=g*k*k+d;e.n12=g*k*h-f*j;e.n13=g*k*j+f*h;e.n21=g*k*h+f*j;e.n22=g*h*h+d;e.n23=g*h*j-f*k;e.n31=g*k*j-f*h;e.n32=g*h*j+f*k;e.n33=g*j*j+d;return e}; THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12* a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32* a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22* a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var e=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],f=b[6]*b[1]-b[2]*b[5],g=-b[10]*b[4]+b[6]*b[8],l=b[10]*b[0]-b[2]*b[8],h=-b[6]*b[0]+b[2]*b[4],k=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],u=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*g+b[2]*k;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*e;a.m[1]=b*d;a.m[2]=b*f;a.m[3]=b*g;a.m[4]=b*l;a.m[5]=b*h;a.m[6]=b*k;a.m[7]=b*c;a.m[8]=b*u;return a}; -THREE.Matrix4.makeFrustum=function(a,b,e,d,f,g){var l,h,k;l=new THREE.Matrix4;h=2*f/(b-a);k=2*f/(d-e);a=(b+a)/(b-a);e=(d+e)/(d-e);d=-(g+f)/(g-f);f=-2*g*f/(g-f);l.n11=h;l.n12=0;l.n13=a;l.n14=0;l.n21=0;l.n22=k;l.n23=e;l.n24=0;l.n31=0;l.n32=0;l.n33=d;l.n34=f;l.n41=0;l.n42=0;l.n43=-1;l.n44=0;return l};THREE.Matrix4.makePerspective=function(a,b,e,d){var f;a=e*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,e,d)}; -THREE.Matrix4.makeOrtho=function(a,b,e,d,f,g){var l,h,k,c;l=new THREE.Matrix4;h=b-a;k=e-d;c=g-f;a=(b+a)/h;e=(e+d)/k;f=(g+f)/c;l.n11=2/h;l.n12=0;l.n13=0;l.n14=-a;l.n21=0;l.n22=2/k;l.n23=0;l.n24=-e;l.n31=0;l.n32=0;l.n33=-2/c;l.n34=-f;l.n41=0;l.n42=0;l.n43=0;l.n44=1;return l}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var e=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],f=b[6]*b[1]-b[2]*b[5],g=-b[10]*b[4]+b[6]*b[8],k=b[10]*b[0]-b[2]*b[8],h=-b[6]*b[0]+b[2]*b[4],j=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],u=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*g+b[2]*j;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*e;a.m[1]=b*d;a.m[2]=b*f;a.m[3]=b*g;a.m[4]=b*k;a.m[5]=b*h;a.m[6]=b*j;a.m[7]=b*c;a.m[8]=b*u;return a}; +THREE.Matrix4.makeFrustum=function(a,b,e,d,f,g){var k,h,j;k=new THREE.Matrix4;h=2*f/(b-a);j=2*f/(d-e);a=(b+a)/(b-a);e=(d+e)/(d-e);d=-(g+f)/(g-f);f=-2*g*f/(g-f);k.n11=h;k.n12=0;k.n13=a;k.n14=0;k.n21=0;k.n22=j;k.n23=e;k.n24=0;k.n31=0;k.n32=0;k.n33=d;k.n34=f;k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,b,e,d){var f;a=e*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,e,d)}; +THREE.Matrix4.makeOrtho=function(a,b,e,d,f,g){var k,h,j,c;k=new THREE.Matrix4;h=b-a;j=e-d;c=g-f;a=(b+a)/h;e=(e+d)/j;f=(g+f)/c;k.n11=2/h;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/j;k.n23=0;k.n24=-e;k.n31=0;k.n32=0;k.n33=-2/c;k.n34=-f;k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k}; 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=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; THREE.Face3=function(a,b,e,d,f){this.a=a;this.b=b;this.c=e;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.material=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; THREE.Face4=function(a,b,e,d,f,g){this.a=a;this.b=b;this.c=e;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.material=g instanceof Array?g:[g]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; -THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.geometryChunks={};this.hasTangents=false}; +THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; THREE.Geometry.prototype={computeCentroids:function(){var a,b,e;a=0;for(b=this.faces.length;a0){this.bbox={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 a=1,b=this.vertices.length;athis.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.ythis.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(u){var y=[];b=0;for(e=u.length;b65535){c[h].counter+=1;k=c[h].hash+"_"+c[h].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],material:l,vertices:0}}this.geometryChunks[k].faces.push(d);this.geometryChunks[k].vertices+=g}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,e,d,f,g,k,h=new THREE.Vector3,j=new THREE.Vector3;d=0;for(f=this.vertices.length;d0){this.bbox={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,e=this.vertices.length;bthis.bbox.x[1])this.bbox.x[1]=a.position.x;if(a.position.ythis.bbox.y[1])this.bbox.y[1]=a.position.y;if(a.position.z +this.bbox.z[1])this.bbox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,e=this.vertices.length;b65535){c[h].counter+=1;j=c[h].hash+"_"+c[h].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],material:k,vertices:0}}this.geometryChunks[j].faces.push(d);this.geometryChunks[j].vertices+=g}},toString:function(){return"THREE.Geometry ( vertices: "+ +this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; THREE.Camera=function(a,b,e,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,e,d);this.autoUpdateMatrix=true;this.translateX=function(f){f=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(f);f.cross(f.clone(),this.up);this.position.addSelf(f);this.target.position.addSelf(f)};this.translateZ=function(f){f=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(f); this.position.subSelf(f);this.target.position.subSelf(f)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight; THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z); this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0}; THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; -THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2; +THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2; THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}this.toString=function(){return"THREE.LineBasicMaterial (
color: "+ this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+this.linewidth+"
linecap: "+this.linecap+"
linejoin: "+this.linejoin+"
)"}}; THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map= @@ -88,95 +89,97 @@ THREE.Texture=function(a,b,e,d,f,g){this.image=a;this.mapping=b!==undefined?b:ne this.min_filter+"
)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){}; THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){}; THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}}; -THREE.Projector=function(){function a(j,v){var q=0,m=1,A=j.z+j.w,F=v.z+v.w,M=-j.z+j.w,x=-v.z+v.w;if(A>=0&&F>=0&&M>=0&&x>=0)return true;else if(A<0&&F<0||M<0&&x<0)return false;else{if(A<0)q=Math.max(q,A/(A-F));else if(F<0)m=Math.min(m,A/(A-F));if(M<0)q=Math.max(q,M/(M-x));else if(x<0)m=Math.min(m,M/(M-x));if(m0&&x.z<1}O=O.faces;F=0;for(M=O.length;F0&&K.z<1){r=w[s]=w[s]||new THREE.RenderableParticle; -r.x=K.x/K.w;r.y=K.y/K.w;r.z=K.z;r.rotation=C.rotation.z;r.scale.x=C.scale.x*Math.abs(r.x-(K.x+v.projectionMatrix.n11)/(K.w+v.projectionMatrix.n14));r.scale.y=C.scale.y*Math.abs(r.y-(K.y+v.projectionMatrix.n22)/(K.w+v.projectionMatrix.n24));r.material=C.material;m.push(r);s++}}}}q&&m.sort(b);return m};this.unprojectVector=function(j,v){var q=new THREE.Matrix4;q.multiply(THREE.Matrix4.makeInvert(v.matrix),THREE.Matrix4.makeInvert(v.projectionMatrix));q.multiplyVector3(j);return j}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,d,f,g;this.domElement=document.createElement("div");this.setSize=function(l,h){e=l;d=h;f=e/2;g=d/2};this.render=function(l,h){var k,c,u,y,r,s,w,z;a=b.projectScene(l,h);k=0;for(c=a.length;k0){L.r+=ba.r*Z;L.g+=ba.g*Z;L.b+=ba.b*Z}}else if(Z instanceof THREE.PointLight){Y.sub(Z.position,U);Y.normalize();Z=Q.dot(Y)*ca;if(Z>0){L.r+=ba.r*Z;L.g+=ba.g*Z;L.b+=ba.b*Z}}}}function La(H,U,Q){if(Q.opacity!=0){Ca(Q.opacity);ya(Q.blending);var L,P,Z,ba,ca,da;if(Q instanceof THREE.ParticleBasicMaterial){if(Q.map){ba=Q.map;ca=ba.width>>1;da=ba.height>>1;P=U.scale.x*g;Z=U.scale.y*l;Q=P*ca;L=Z*da;B.set(H.x-Q,H.y-L,H.x+Q, -H.y+L);if(O.instersects(B)){h.save();h.translate(H.x,H.y);h.rotate(-U.rotation);h.scale(P,-Z);h.translate(-ca,-da);h.drawImage(ba,0,0);h.restore()}}}else if(Q instanceof THREE.ParticleCircleMaterial){if(S){p.r=t.r+E.r+N.r;p.g=t.g+E.g+N.g;p.b=t.b+E.b+N.b;j.r=Q.color.r*p.r;j.g=Q.color.g*p.g;j.b=Q.color.b*p.b;j.updateStyleString()}else j.__styleString=Q.color.__styleString;Q=U.scale.x*g;L=U.scale.y*l;B.set(H.x-Q,H.y-L,H.x+Q,H.y+L);if(O.instersects(B)){P=j.__styleString;if(y!=P)h.fillStyle=y=P;h.save(); -h.translate(H.x,H.y);h.rotate(-U.rotation);h.scale(Q,L);h.beginPath();h.arc(0,0,1,0,X,true);h.closePath();h.fill();h.restore()}}}}function Ma(H,U,Q,L){if(L.opacity!=0){Ca(L.opacity);ya(L.blending);h.beginPath();h.moveTo(H.positionScreen.x,H.positionScreen.y);h.lineTo(U.positionScreen.x,U.positionScreen.y);h.closePath();if(L instanceof THREE.LineBasicMaterial){j.__styleString=L.color.__styleString;H=L.linewidth;if(r!=H)h.lineWidth=r=H;H=j.__styleString;if(u!=H)h.strokeStyle=u=H;h.stroke();B.inflate(L.linewidth* -2)}}}function Ga(H,U,Q,L,P,Z){if(P.opacity!=0){Ca(P.opacity);ya(P.blending);K=H.positionScreen.x;I=H.positionScreen.y;D=U.positionScreen.x;n=U.positionScreen.y;i=Q.positionScreen.x;o=Q.positionScreen.y;h.beginPath();h.moveTo(K,I);h.lineTo(D,n);h.lineTo(i,o);h.lineTo(K,I);h.closePath();if(P instanceof THREE.MeshBasicMaterial)if(P.map)P.map.image.loaded&&P.map.mapping instanceof THREE.UVMapping&&sa(K,I,D,n,i,o,P.map.image,L.uvs[0].u,L.uvs[0].v,L.uvs[1].u,L.uvs[1].v,L.uvs[2].u,L.uvs[2].v);else if(P.env_map){if(P.env_map.image.loaded)if(P.env_map.mapping instanceof -THREE.SphericalReflectionMapping){H=wa.matrix;Y.copy(L.vertexNormalsWorld[0]);R=(Y.x*H.n11+Y.y*H.n12+Y.z*H.n13)*0.5+0.5;C=-(Y.x*H.n21+Y.y*H.n22+Y.z*H.n23)*0.5+0.5;Y.copy(L.vertexNormalsWorld[1]);V=(Y.x*H.n11+Y.y*H.n12+Y.z*H.n13)*0.5+0.5;T=-(Y.x*H.n21+Y.y*H.n22+Y.z*H.n23)*0.5+0.5;Y.copy(L.vertexNormalsWorld[2]);$=(Y.x*H.n11+Y.y*H.n12+Y.z*H.n13)*0.5+0.5;W=-(Y.x*H.n21+Y.y*H.n22+Y.z*H.n23)*0.5+0.5;sa(K,I,D,n,i,o,P.env_map.image,R,C,V,T,$,W)}}else P.wireframe?za(P.color.__styleString,P.wireframe_linewidth): -Aa(P.color.__styleString);else if(P instanceof THREE.MeshLambertMaterial){if(P.map&&!P.wireframe){P.map.mapping instanceof THREE.UVMapping&&sa(K,I,D,n,i,o,P.map.image,L.uvs[0].u,L.uvs[0].v,L.uvs[1].u,L.uvs[1].v,L.uvs[2].u,L.uvs[2].v);ya(THREE.SubtractiveBlending)}if(S)if(!P.wireframe&&P.shading==THREE.SmoothShading&&L.vertexNormalsWorld.length==3){v.r=q.r=m.r=t.r;v.g=q.g=m.g=t.g;v.b=q.b=m.b=t.b;xa(Z,L.v1.positionWorld,L.vertexNormalsWorld[0],v);xa(Z,L.v2.positionWorld,L.vertexNormalsWorld[1],q);xa(Z, -L.v3.positionWorld,L.vertexNormalsWorld[2],m);A.r=(q.r+m.r)*0.5;A.g=(q.g+m.g)*0.5;A.b=(q.b+m.b)*0.5;J=Ha(v,q,m,A);sa(K,I,D,n,i,o,J,0,0,1,0,0,1)}else{p.r=t.r;p.g=t.g;p.b=t.b;xa(Z,L.centroidWorld,L.normalWorld,p);j.r=P.color.r*p.r;j.g=P.color.g*p.g;j.b=P.color.b*p.b;j.updateStyleString();P.wireframe?za(j.__styleString,P.wireframe_linewidth):Aa(j.__styleString)}else P.wireframe?za(P.color.__styleString,P.wireframe_linewidth):Aa(P.color.__styleString)}else if(P instanceof THREE.MeshDepthMaterial){F=P.__2near; -M=P.__farPlusNear;x=P.__farMinusNear;v.r=v.g=v.b=1-F/(M-H.positionScreen.z*x);q.r=q.g=q.b=1-F/(M-U.positionScreen.z*x);m.r=m.g=m.b=1-F/(M-Q.positionScreen.z*x);A.r=(q.r+m.r)*0.5;A.g=(q.g+m.g)*0.5;A.b=(q.b+m.b)*0.5;J=Ha(v,q,m,A);sa(K,I,D,n,i,o,J,0,0,1,0,0,1)}else if(P instanceof THREE.MeshNormalMaterial){j.r=Da(L.normalWorld.x);j.g=Da(L.normalWorld.y);j.b=Da(L.normalWorld.z);j.updateStyleString();P.wireframe?za(j.__styleString,P.wireframe_linewidth):Aa(j.__styleString)}}}function za(H,U){if(u!=H)h.strokeStyle= -u=H;if(r!=U)h.lineWidth=r=U;h.stroke();B.inflate(U*2)}function Aa(H){if(y!=H)h.fillStyle=y=H;h.fill()}function sa(H,U,Q,L,P,Z,ba,ca,da,ja,ga,ka,ta){var na,la;na=ba.width-1;la=ba.height-1;ca*=na;da*=la;ja*=na;ga*=la;ka*=na;ta*=la;Q-=H;L-=U;P-=H;Z-=U;ja-=ca;ga-=da;ka-=ca;ta-=da;la=1/(ja*ta-ka*ga);na=(ta*Q-ga*P)*la;ga=(ta*L-ga*Z)*la;Q=(ja*P-ka*Q)*la;L=(ja*Z-ka*L)*la;H=H-na*ca-Q*da;U=U-ga*ca-L*da;h.save();h.transform(na,ga,Q,L,H,U);h.clip();h.drawImage(ba,0,0);h.restore()}function Ca(H){if(k!=H)h.globalAlpha= -k=H}function ya(H){if(c!=H){switch(H){case THREE.NormalBlending:h.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:h.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:h.globalCompositeOperation="darker"}c=H}}function Ha(H,U,Q,L){var P=~~(H.r*255),Z=~~(H.g*255);H=~~(H.b*255);var ba=~~(U.r*255),ca=~~(U.g*255);U=~~(U.b*255);var da=~~(Q.r*255),ja=~~(Q.g*255);Q=~~(Q.b*255);var ga=~~(L.r*255),ka=~~(L.g*255);L=~~(L.b*255);fa[0]=P<0?0:P>255?255:P;fa[1]=Z<0?0: -Z>255?255:Z;fa[2]=H<0?0:H>255?255:H;fa[4]=ba<0?0:ba>255?255:ba;fa[5]=ca<0?0:ca>255?255:ca;fa[6]=U<0?0:U>255?255:U;fa[8]=da<0?0:da>255?255:da;fa[9]=ja<0?0:ja>255?255:ja;fa[10]=Q<0?0:Q>255?255:Q;fa[12]=ga<0?0:ga>255?255:ga;fa[13]=ka<0?0:ka>255?255:ka;fa[14]=L<0?0:L>255?255:L;ma.putImageData(oa,0,0);va.drawImage(ea,0,0);return ra}function Da(H){H=(H+1)*0.5;return H<0?0:H>1?1:H}function Ea(H,U){var Q=U.x-H.x,L=U.y-H.y,P=1/Math.sqrt(Q*Q+L*L);Q*=P;L*=P;U.x+=Q;U.y+=L;H.x-=Q;H.y-=L}var Ba,Ia,aa,ha,qa,Fa, -Ja,ua;h.setTransform(1,0,0,-1,g,l);this.autoClear&&this.clear();a=b.projectScene(ia,wa,this.sortElements);(S=ia.lights.length>0)&&Ka(ia);Ba=0;for(Ia=a.length;Ba0){W.r+=B.color.r*S;W.g+=B.color.g*S;W.b+=B.color.b*S}}else if(B instanceof THREE.PointLight){m.sub(B.position,$.centroidWorld);m.normalize();S=$.normalWorld.dot(m)*B.intensity;if(S>0){W.r+=B.color.r*S;W.g+=B.color.g*S;W.b+=B.color.b*S}}}}function b(T,$,W,O,G,B){x=d(J++);x.setAttribute("d","M "+T.positionScreen.x+ -" "+T.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(G instanceof THREE.MeshBasicMaterial)n.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshLambertMaterial)if(D){i.r=o.r;i.g=o.g;i.b=o.b;a(B,O,i);n.r=G.color.r*i.r;n.g=G.color.g*i.g;n.b=G.color.b*i.b;n.updateStyleString()}else n.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshDepthMaterial){q=1-G.__2near/(G.__farPlusNear-O.z*G.__farMinusNear); -n.setRGB(q,q,q)}else G instanceof THREE.MeshNormalMaterial&&n.setRGB(f(O.normalWorld.x),f(O.normalWorld.y),f(O.normalWorld.z));G.wireframe?x.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+G.wireframe_linewidth+"; stroke-opacity: "+G.opacity+"; stroke-linecap: "+G.wireframe_linecap+"; stroke-linejoin: "+G.wireframe_linejoin):x.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+G.opacity);h.appendChild(x)}function e(T,$,W,O,G,B,S){x=d(J++);x.setAttribute("d", -"M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)n.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(D){i.r=o.r;i.g=o.g;i.b=o.b;a(S,G,i);n.r=B.color.r*i.r;n.g=B.color.g*i.g;n.b=B.color.b*i.b;n.updateStyleString()}else n.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){q= -1-B.__2near/(B.__farPlusNear-G.z*B.__farMinusNear);n.setRGB(q,q,q)}else B instanceof THREE.MeshNormalMaterial&&n.setRGB(f(G.normalWorld.x),f(G.normalWorld.y),f(G.normalWorld.z));B.wireframe?x.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):x.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+B.opacity);h.appendChild(x)} -function d(T){if(A[T]==null){A[T]=document.createElementNS("http://www.w3.org/2000/svg","path");V==0&&A[T].setAttribute("shape-rendering","crispEdges");return A[T]}return A[T]}function f(T){return T<0?Math.min((1+T)*0.5,0.5):0.5+Math.min(T*0.5,0.5)}var g=null,l=new THREE.Projector,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,c,u,y,r,s,w,z,K=new THREE.Rectangle,I=new THREE.Rectangle,D=false,n=new THREE.Color(16777215),i=new THREE.Color(16777215),o=new THREE.Color(0),j=new THREE.Color(0), -v=new THREE.Color(0),q,m=new THREE.Vector3,A=[],F=[],M=[],x,J,R,C,V=1;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(T){switch(T){case "high":V=1;break;case "low":V=0}};this.setSize=function(T,$){k=T;c=$;u=k/2;y=c/2;h.setAttribute("viewBox",-u+" "+-y+" "+k+" "+c);h.setAttribute("width",k);h.setAttribute("height",c);K.set(-u,-y,u,y)};this.clear=function(){for(;h.childNodes.length>0;)h.removeChild(h.childNodes[0])};this.render=function(T,$){var W,O, -G,B,S,p,t,E;this.autoClear&&this.clear();g=l.projectScene(T,$,this.sortElements);C=R=J=0;if(D=T.lights.length>0){t=T.lights;o.setRGB(0,0,0);j.setRGB(0,0,0);v.setRGB(0,0,0);W=0;for(O=t.length;W0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(j,l("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"+ -i));c.attachShader(j,l("vertex",v+o));c.linkProgram(j);c.getProgramParameter(j,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(j,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");j.uniforms={};j.attributes={};return j}function e(i,o){if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP, -c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var j=0;j<6;++j)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image[j]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);i.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+o);c.bindTexture(c.TEXTURE_CUBE_MAP, -i.image.__webGLTextureCube)}}function d(i,o){if(!i.__webGLTexture&&i.image.loaded){i.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,i.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,h(i.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,h(i.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(i.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,h(i.min_filter));c.generateMipmap(c.TEXTURE_2D); -c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+o);c.bindTexture(c.TEXTURE_2D,i.__webGLTexture)}function f(i,o){var j,v,q;j=0;for(v=o.length;j= 0.0 )": -"",o?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",o?"pointDiffuse += mColor * pointDiffuseWeight;":"",o?"pointSpecular += mSpecular * pointSpecularWeight;":"",o?"}":"",i?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"vec3 dirVector = normalize( lDirection.xyz );":"",i?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": -"",i?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",i?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",i?"float dirSpecularWeight = 0.0;":"",i?"if ( dirDotNormalHalf >= 0.0 )":"",i?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",i?"dirDiffuse += mColor * dirDiffuseWeight;":"",i?"dirSpecular += mSpecular * dirSpecularWeight;":"",i?"}":"","vec4 totalLight = mAmbient;",i?"totalLight += dirDiffuse + dirSpecular;":"",o?"totalLight += pointDiffuse + pointSpecular;": +THREE.Projector=function(){function a(w,o){return o.z-w.z}function b(w,o){var m=0,z=1,L=w.z+w.w,A=o.z+o.w,D=-w.z+w.w,B=-o.z+o.w;if(L>=0&&A>=0&&D>=0&&B>=0)return true;else if(L<0&&A<0||D<0&&B<0)return false;else{if(L<0)m=Math.max(m,L/(L-A));else if(A<0)z=Math.min(z,L/(L-A));if(D<0)m=Math.max(m,D/(D-B));else if(B<0)z=Math.min(z,D/(D-B));if(z0&&B.z<1}I=I.faces;A=0;for(D=I.length;A0&&J.z<1){r=x[t]=x[t]||new THREE.RenderableParticle;r.x=J.x/J.w;r.y=J.y/J.w;r.z=J.z;r.rotation=O.rotation.z;r.scale.x=O.scale.x*Math.abs(r.x-(J.x+o.projectionMatrix.n11)/(J.w+o.projectionMatrix.n14));r.scale.y=O.scale.y*Math.abs(r.y-(J.y+o.projectionMatrix.n22)/(J.w+ +o.projectionMatrix.n24));r.material=O.material;z.push(r);t++}}}}m&&z.sort(a);return z};this.unprojectVector=function(w,o){var m=new THREE.Matrix4;m.multiply(THREE.Matrix4.makeInvert(o.matrix),THREE.Matrix4.makeInvert(o.projectionMatrix));m.multiplyVector3(w);return w}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,d,f,g;this.domElement=document.createElement("div");this.setSize=function(k,h){e=k;d=h;f=e/2;g=d/2};this.render=function(k,h){var j,c,u,y,r,t,x,C;a=b.projectScene(k,h);j=0;for(c=a.length;j0){K.r+=ba.r*Z;K.g+=ba.g*Z;K.b+=ba.b*Z}}else if(Z instanceof THREE.PointLight){Y.sub(Z.position,V);Y.normalize();Z=T.dot(Y)*ca;if(Z>0){K.r+=ba.r*Z;K.g+=ba.g*Z;K.b+=ba.b*Z}}}}function La(G,V,T){if(T.opacity!=0){Ca(T.opacity);ya(T.blending);var K,Q,Z,ba,ca,da;if(T instanceof THREE.ParticleBasicMaterial){if(T.map){ba=T.map;ca=ba.width>>1;da=ba.height>>1;Q=V.scale.x*g;Z=V.scale.y*k;T=Q*ca;K=Z*da;H.set(G.x-T,G.y-K,G.x+T, +G.y+K);if(S.instersects(H)){h.save();h.translate(G.x,G.y);h.rotate(-V.rotation);h.scale(Q,-Z);h.translate(-ca,-da);h.drawImage(ba,0,0);h.restore()}}}else if(T instanceof THREE.ParticleCircleMaterial){if(R){q.r=s.r+F.r+P.r;q.g=s.g+F.g+P.g;q.b=s.b+F.b+P.b;l.r=T.color.r*q.r;l.g=T.color.g*q.g;l.b=T.color.b*q.b;l.updateStyleString()}else l.__styleString=T.color.__styleString;T=V.scale.x*g;K=V.scale.y*k;H.set(G.x-T,G.y-K,G.x+T,G.y+K);if(S.instersects(H)){Q=l.__styleString;if(y!=Q)h.fillStyle=y=Q;h.save(); +h.translate(G.x,G.y);h.rotate(-V.rotation);h.scale(T,K);h.beginPath();h.arc(0,0,1,0,X,true);h.closePath();h.fill();h.restore()}}}}function Ma(G,V,T,K){if(K.opacity!=0){Ca(K.opacity);ya(K.blending);h.beginPath();h.moveTo(G.positionScreen.x,G.positionScreen.y);h.lineTo(V.positionScreen.x,V.positionScreen.y);h.closePath();if(K instanceof THREE.LineBasicMaterial){l.__styleString=K.color.__styleString;G=K.linewidth;if(r!=G)h.lineWidth=r=G;G=l.__styleString;if(u!=G)h.strokeStyle=u=G;h.stroke();H.inflate(K.linewidth* +2)}}}function Ga(G,V,T,K,Q,Z){if(Q.opacity!=0){Ca(Q.opacity);ya(Q.blending);J=G.positionScreen.x;v=G.positionScreen.y;E=V.positionScreen.x;n=V.positionScreen.y;i=T.positionScreen.x;p=T.positionScreen.y;h.beginPath();h.moveTo(J,v);h.lineTo(E,n);h.lineTo(i,p);h.lineTo(J,v);h.closePath();if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&sa(J,v,E,n,i,p,Q.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(Q.env_map){if(Q.env_map.image.loaded)if(Q.env_map.mapping instanceof +THREE.SphericalReflectionMapping){G=wa.matrix;Y.copy(K.vertexNormalsWorld[0]);N=(Y.x*G.n11+Y.y*G.n12+Y.z*G.n13)*0.5+0.5;M=-(Y.x*G.n21+Y.y*G.n22+Y.z*G.n23)*0.5+0.5;Y.copy(K.vertexNormalsWorld[1]);O=(Y.x*G.n11+Y.y*G.n12+Y.z*G.n13)*0.5+0.5;U=-(Y.x*G.n21+Y.y*G.n22+Y.z*G.n23)*0.5+0.5;Y.copy(K.vertexNormalsWorld[2]);$=(Y.x*G.n11+Y.y*G.n12+Y.z*G.n13)*0.5+0.5;W=-(Y.x*G.n21+Y.y*G.n22+Y.z*G.n23)*0.5+0.5;sa(J,v,E,n,i,p,Q.env_map.image,N,M,O,U,$,W)}}else Q.wireframe?za(Q.color.__styleString,Q.wireframe_linewidth): +Aa(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&!Q.wireframe){Q.map.mapping instanceof THREE.UVMapping&&sa(J,v,E,n,i,p,Q.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);ya(THREE.SubtractiveBlending)}if(R)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&K.vertexNormalsWorld.length==3){w.r=o.r=m.r=s.r;w.g=o.g=m.g=s.g;w.b=o.b=m.b=s.b;xa(Z,K.v1.positionWorld,K.vertexNormalsWorld[0],w);xa(Z,K.v2.positionWorld,K.vertexNormalsWorld[1],o);xa(Z, +K.v3.positionWorld,K.vertexNormalsWorld[2],m);z.r=(o.r+m.r)*0.5;z.g=(o.g+m.g)*0.5;z.b=(o.b+m.b)*0.5;B=Ha(w,o,m,z);sa(J,v,E,n,i,p,B,0,0,1,0,0,1)}else{q.r=s.r;q.g=s.g;q.b=s.b;xa(Z,K.centroidWorld,K.normalWorld,q);l.r=Q.color.r*q.r;l.g=Q.color.g*q.g;l.b=Q.color.b*q.b;l.updateStyleString();Q.wireframe?za(l.__styleString,Q.wireframe_linewidth):Aa(l.__styleString)}else Q.wireframe?za(Q.color.__styleString,Q.wireframe_linewidth):Aa(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){L=Q.__2near; +A=Q.__farPlusNear;D=Q.__farMinusNear;w.r=w.g=w.b=1-L/(A-G.positionScreen.z*D);o.r=o.g=o.b=1-L/(A-V.positionScreen.z*D);m.r=m.g=m.b=1-L/(A-T.positionScreen.z*D);z.r=(o.r+m.r)*0.5;z.g=(o.g+m.g)*0.5;z.b=(o.b+m.b)*0.5;B=Ha(w,o,m,z);sa(J,v,E,n,i,p,B,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){l.r=Da(K.normalWorld.x);l.g=Da(K.normalWorld.y);l.b=Da(K.normalWorld.z);l.updateStyleString();Q.wireframe?za(l.__styleString,Q.wireframe_linewidth):Aa(l.__styleString)}}}function za(G,V){if(u!=G)h.strokeStyle= +u=G;if(r!=V)h.lineWidth=r=V;h.stroke();H.inflate(V*2)}function Aa(G){if(y!=G)h.fillStyle=y=G;h.fill()}function sa(G,V,T,K,Q,Z,ba,ca,da,ja,ga,ka,ta){var na,la;na=ba.width-1;la=ba.height-1;ca*=na;da*=la;ja*=na;ga*=la;ka*=na;ta*=la;T-=G;K-=V;Q-=G;Z-=V;ja-=ca;ga-=da;ka-=ca;ta-=da;la=1/(ja*ta-ka*ga);na=(ta*T-ga*Q)*la;ga=(ta*K-ga*Z)*la;T=(ja*Q-ka*T)*la;K=(ja*Z-ka*K)*la;G=G-na*ca-T*da;V=V-ga*ca-K*da;h.save();h.transform(na,ga,T,K,G,V);h.clip();h.drawImage(ba,0,0);h.restore()}function Ca(G){if(j!=G)h.globalAlpha= +j=G}function ya(G){if(c!=G){switch(G){case THREE.NormalBlending:h.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:h.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:h.globalCompositeOperation="darker"}c=G}}function Ha(G,V,T,K){var Q=~~(G.r*255),Z=~~(G.g*255);G=~~(G.b*255);var ba=~~(V.r*255),ca=~~(V.g*255);V=~~(V.b*255);var da=~~(T.r*255),ja=~~(T.g*255);T=~~(T.b*255);var ga=~~(K.r*255),ka=~~(K.g*255);K=~~(K.b*255);fa[0]=Q<0?0:Q>255?255:Q;fa[1]=Z<0?0: +Z>255?255:Z;fa[2]=G<0?0:G>255?255:G;fa[4]=ba<0?0:ba>255?255:ba;fa[5]=ca<0?0:ca>255?255:ca;fa[6]=V<0?0:V>255?255:V;fa[8]=da<0?0:da>255?255:da;fa[9]=ja<0?0:ja>255?255:ja;fa[10]=T<0?0:T>255?255:T;fa[12]=ga<0?0:ga>255?255:ga;fa[13]=ka<0?0:ka>255?255:ka;fa[14]=K<0?0:K>255?255:K;ma.putImageData(oa,0,0);va.drawImage(ea,0,0);return ra}function Da(G){G=(G+1)*0.5;return G<0?0:G>1?1:G}function Ea(G,V){var T=V.x-G.x,K=V.y-G.y,Q=1/Math.sqrt(T*T+K*K);T*=Q;K*=Q;V.x+=T;V.y+=K;G.x-=T;G.y-=K}var Ba,Ia,aa,ha,qa,Fa, +Ja,ua;h.setTransform(1,0,0,-1,g,k);this.autoClear&&this.clear();a=b.projectScene(ia,wa,this.sortElements);(R=ia.lights.length>0)&&Ka(ia);Ba=0;for(Ia=a.length;Ba0){W.r+=H.color.r*R;W.g+=H.color.g*R;W.b+=H.color.b*R}}else if(H instanceof THREE.PointLight){m.sub(H.position,$.centroidWorld);m.normalize();R=$.normalWorld.dot(m)*H.intensity;if(R>0){W.r+=H.color.r*R;W.g+=H.color.g*R;W.b+=H.color.b*R}}}}function b(U,$,W,S,I,H){D=d(B++);D.setAttribute("d","M "+U.positionScreen.x+ +" "+U.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(I instanceof THREE.MeshBasicMaterial)n.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshLambertMaterial)if(E){i.r=p.r;i.g=p.g;i.b=p.b;a(H,S,i);n.r=I.color.r*i.r;n.g=I.color.g*i.g;n.b=I.color.b*i.b;n.updateStyleString()}else n.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshDepthMaterial){o=1-I.__2near/(I.__farPlusNear-S.z*I.__farMinusNear); +n.setRGB(o,o,o)}else I instanceof THREE.MeshNormalMaterial&&n.setRGB(f(S.normalWorld.x),f(S.normalWorld.y),f(S.normalWorld.z));I.wireframe?D.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+I.wireframe_linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: "+I.wireframe_linecap+"; stroke-linejoin: "+I.wireframe_linejoin):D.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+I.opacity);h.appendChild(D)}function e(U,$,W,S,I,H,R){D=d(B++);D.setAttribute("d", +"M "+U.positionScreen.x+" "+U.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+"z");if(H instanceof THREE.MeshBasicMaterial)n.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshLambertMaterial)if(E){i.r=p.r;i.g=p.g;i.b=p.b;a(R,I,i);n.r=H.color.r*i.r;n.g=H.color.g*i.g;n.b=H.color.b*i.b;n.updateStyleString()}else n.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshDepthMaterial){o= +1-H.__2near/(H.__farPlusNear-I.z*H.__farMinusNear);n.setRGB(o,o,o)}else H instanceof THREE.MeshNormalMaterial&&n.setRGB(f(I.normalWorld.x),f(I.normalWorld.y),f(I.normalWorld.z));H.wireframe?D.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+H.wireframe_linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: "+H.wireframe_linecap+"; stroke-linejoin: "+H.wireframe_linejoin):D.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+H.opacity);h.appendChild(D)} +function d(U){if(z[U]==null){z[U]=document.createElementNS("http://www.w3.org/2000/svg","path");O==0&&z[U].setAttribute("shape-rendering","crispEdges");return z[U]}return z[U]}function f(U){return U<0?Math.min((1+U)*0.5,0.5):0.5+Math.min(U*0.5,0.5)}var g=null,k=new THREE.Projector,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,c,u,y,r,t,x,C,J=new THREE.Rectangle,v=new THREE.Rectangle,E=false,n=new THREE.Color(16777215),i=new THREE.Color(16777215),p=new THREE.Color(0),l=new THREE.Color(0), +w=new THREE.Color(0),o,m=new THREE.Vector3,z=[],L=[],A=[],D,B,N,M,O=1;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(U){switch(U){case "high":O=1;break;case "low":O=0}};this.setSize=function(U,$){j=U;c=$;u=j/2;y=c/2;h.setAttribute("viewBox",-u+" "+-y+" "+j+" "+c);h.setAttribute("width",j);h.setAttribute("height",c);J.set(-u,-y,u,y)};this.clear=function(){for(;h.childNodes.length>0;)h.removeChild(h.childNodes[0])};this.render=function(U,$){var W,S, +I,H,R,q,s,F;this.autoClear&&this.clear();g=k.projectScene(U,$,this.sortElements);M=N=B=0;if(E=U.lights.length>0){s=U.lights;p.setRGB(0,0,0);l.setRGB(0,0,0);w.setRGB(0,0,0);W=0;for(S=s.length;W0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(l,k("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"+ +i));c.attachShader(l,k("vertex",w+p));c.linkProgram(l);c.getProgramParameter(l,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(l,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");l.uniforms={};l.attributes={};return l}function e(i,p){if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP, +c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var l=0;l<6;++l)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+l,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image[l]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);i.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+p);c.bindTexture(c.TEXTURE_CUBE_MAP, +i.image.__webGLTextureCube)}}function d(i,p){if(!i.__webGLTexture&&i.image.loaded){i.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,i.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,h(i.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,h(i.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(i.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,h(i.min_filter));c.generateMipmap(c.TEXTURE_2D); +c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+p);c.bindTexture(c.TEXTURE_2D,i.__webGLTexture)}function f(i,p){var l,w,o;l=0;for(w=p.length;l= 0.0 )": +"",p?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",p?"pointDiffuse += mColor * pointDiffuseWeight;":"",p?"pointSpecular += mSpecular * pointSpecularWeight;":"",p?"}":"",i?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"vec3 dirVector = normalize( lDirection.xyz );":"",i?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": +"",i?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",i?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",i?"float dirSpecularWeight = 0.0;":"",i?"if ( dirDotNormalHalf >= 0.0 )":"",i?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",i?"dirDiffuse += mColor * dirDiffuseWeight;":"",i?"dirSpecular += mSpecular * dirSpecularWeight;":"",i?"}":"","vec4 totalLight = mAmbient;",i?"totalLight += dirDiffuse + dirSpecular;":"",p?"totalLight += pointDiffuse + pointSpecular;": "","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n"); -j=b(v,j);c.useProgram(j);f(j,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);i&&f(j,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);o&&f(j,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(j.uniforms.enableMap,0);c.uniform1i(j.uniforms.tMap,0);c.uniform1i(j.uniforms.enableCubeMap,0);c.uniform1i(j.uniforms.tCube,1);c.uniform1i(j.uniforms.mixEnvMap,0);c.uniform1i(j.uniforms.useRefract,0);g(j,["position","normal","uv"]);return j}(a.directional,a.point);this.setSize=function(i,o){k.width=i;k.height=o;c.viewport(0,0,k.width,k.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(i,o){var j,v,q,m,A,F=[], -M=[],x=[];m=[];A=[];c.uniform1i(i.uniforms.enableLighting,o.length);j=0;for(v=o.length;j0){G.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,G.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(W),c.STATIC_DRAW)}G.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,G.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(R),c.STATIC_DRAW);G.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, -G.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(C),c.STATIC_DRAW);G.__webGLFaceCount=R.length;G.__webGLLineCount=C.length}};this.renderBuffer=function(i,o,j,v){var q,m,A,F,M,x,J,R,C;if(j instanceof THREE.MeshShaderMaterial){if(!j.program){j.program=b(j.fragment_shader,j.vertex_shader);J=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(C in j.uniforms)J.push(C);f(j.program,J);g(j.program,["position","normal","uv","tangent"])}C= -j.program}else C=y;if(C!=u){c.useProgram(C);u=C}C==y&&this.setupLights(C,o);this.loadCamera(C,i);this.loadMatrices(C);if(j instanceof THREE.MeshShaderMaterial){A=j.wireframe;F=j.wireframe_linewidth;i=C;o=j.uniforms;var V;for(q in o){R=o[q].type;J=o[q].value;V=i.uniforms[q];if(R=="i")c.uniform1i(V,J);else if(R=="f")c.uniform1f(V,J);else if(R=="v3")c.uniform3f(V,J.x,J.y,J.z);else if(R=="c")c.uniform3f(V,J.r,J.g,J.b);else if(R=="t"){c.uniform1i(V,J);if(R=o[q].texture)R.image instanceof Array&&R.image.length== -6?e(R,J):d(R,J)}}}if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshBasicMaterial){q=j.color;m=j.opacity;A=j.wireframe;F=j.wireframe_linewidth;M=j.map;x=j.env_map;o=j.combine==THREE.MixOperation;i=j.reflectivity;R=j.env_map&&j.env_map.mapping instanceof THREE.CubeRefractionMapping;J=j.refraction_ratio;c.uniform4f(C.uniforms.mColor,q.r*m,q.g*m,q.b*m,m);c.uniform1i(C.uniforms.mixEnvMap,o);c.uniform1f(C.uniforms.mReflectivity,i);c.uniform1i(C.uniforms.useRefract, -R);c.uniform1f(C.uniforms.mRefractionRatio,J)}if(j instanceof THREE.MeshNormalMaterial){m=j.opacity;c.uniform1f(C.uniforms.mOpacity,m);c.uniform1i(C.uniforms.material,4)}else if(j instanceof THREE.MeshDepthMaterial){m=j.opacity;A=j.wireframe;F=j.wireframe_linewidth;c.uniform1f(C.uniforms.mOpacity,m);c.uniform1f(C.uniforms.m2Near,j.__2near);c.uniform1f(C.uniforms.mFarPlusNear,j.__farPlusNear);c.uniform1f(C.uniforms.mFarMinusNear,j.__farMinusNear);c.uniform1i(C.uniforms.material,3)}else if(j instanceof -THREE.MeshPhongMaterial){q=j.ambient;i=j.specular;j=j.shininess;c.uniform4f(C.uniforms.mAmbient,q.r,q.g,q.b,m);c.uniform4f(C.uniforms.mSpecular,i.r,i.g,i.b,m);c.uniform1f(C.uniforms.mShininess,j);c.uniform1i(C.uniforms.material,2)}else if(j instanceof THREE.MeshLambertMaterial)c.uniform1i(C.uniforms.material,1);else j instanceof THREE.MeshBasicMaterial&&c.uniform1i(C.uniforms.material,0);if(M){d(M,0);c.uniform1i(C.uniforms.tMap,0);c.uniform1i(C.uniforms.enableMap,1)}else c.uniform1i(C.uniforms.enableMap, -0);if(x){e(x,1);c.uniform1i(C.uniforms.tCube,1);c.uniform1i(C.uniforms.enableCubeMap,1)}else c.uniform1i(C.uniforms.enableCubeMap,0);m=C.attributes;c.bindBuffer(c.ARRAY_BUFFER,v.__webGLVertexBuffer);c.vertexAttribPointer(m.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(m.position);if(m.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,v.__webGLNormalBuffer);c.vertexAttribPointer(m.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(m.normal)}if(m.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,v.__webGLTangentBuffer); -c.vertexAttribPointer(m.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(m.tangent)}if(m.uv>=0)if(v.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,v.__webGLUVBuffer);c.vertexAttribPointer(m.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(m.uv)}else c.disableVertexAttribArray(m.uv);if(A){c.lineWidth(F);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.__webGLLineBuffer);c.drawElements(c.LINES,v.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.__webGLFaceBuffer);c.drawElements(c.TRIANGLES, -v.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(i,o,j,v,q,m){var A,F,M,x,J;M=0;for(x=j.material.length;M=0;j--){v=i.__webGLObjects[j].object;o==v&&i.__webGLObjects.splice(j,1)}};this.setupMatrices=function(i,o){i.autoUpdateMatrix&&i.updateMatrix();r.multiply(o.matrix,i.matrix);z.set(r.flatten());s=THREE.Matrix4.makeInvert3x3(r).transpose();I.set(s.m);D.set(i.matrix.flatten())}; -this.loadMatrices=function(i){c.uniformMatrix4fv(i.uniforms.viewMatrix,false,w);c.uniformMatrix4fv(i.uniforms.modelViewMatrix,false,z);c.uniformMatrix4fv(i.uniforms.projectionMatrix,false,K);c.uniformMatrix3fv(i.uniforms.normalMatrix,false,I);c.uniformMatrix4fv(i.uniforms.objectMatrix,false,D)};this.loadCamera=function(i,o){c.uniform3f(i.uniforms.cameraPosition,o.position.x,o.position.y,o.position.z)};this.setBlending=function(i){switch(i){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;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(i,o){if(i){!o||o=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(i=="back")c.cullFace(c.BACK);else i=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; +l=b(w,l);c.useProgram(l);f(l,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);i&&f(l,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);p&&f(l,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(l.uniforms.enableMap,0);c.uniform1i(l.uniforms.tMap,0);c.uniform1i(l.uniforms.enableCubeMap,0);c.uniform1i(l.uniforms.tCube,1);c.uniform1i(l.uniforms.mixEnvMap,0);c.uniform1i(l.uniforms.useRefract,0);g(l,["position","normal","uv"]);return l}(a.directional,a.point);this.setSize=function(i,p){j.width=i;j.height=p;c.viewport(0,0,j.width,j.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(i,p){var l,w,o,m,z,L=[], +A=[],D=[];m=[];z=[];c.uniform1i(i.uniforms.enableLighting,p.length);l=0;for(w=p.length;l0){I.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,I.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(W),c.STATIC_DRAW)}I.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,I.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(N),c.STATIC_DRAW);I.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +I.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(M),c.STATIC_DRAW);I.__webGLFaceCount=N.length;I.__webGLLineCount=M.length}};this.renderBuffer=function(i,p,l,w){var o,m,z,L,A,D,B,N,M;if(l instanceof THREE.MeshShaderMaterial){if(!l.program){l.program=b(l.fragment_shader,l.vertex_shader);B=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(M in l.uniforms)B.push(M);f(l.program,B);g(l.program,["position","normal","uv","tangent"])}M= +l.program}else M=y;if(M!=u){c.useProgram(M);u=M}M==y&&this.setupLights(M,p);this.loadCamera(M,i);this.loadMatrices(M);if(l instanceof THREE.MeshShaderMaterial){z=l.wireframe;L=l.wireframe_linewidth;i=M;p=l.uniforms;var O;for(o in p){N=p[o].type;B=p[o].value;O=i.uniforms[o];if(N=="i")c.uniform1i(O,B);else if(N=="f")c.uniform1f(O,B);else if(N=="v3")c.uniform3f(O,B.x,B.y,B.z);else if(N=="c")c.uniform3f(O,B.r,B.g,B.b);else if(N=="t"){c.uniform1i(O,B);if(N=p[o].texture)N.image instanceof Array&&N.image.length== +6?e(N,B):d(N,B)}}}if(l instanceof THREE.MeshPhongMaterial||l instanceof THREE.MeshLambertMaterial||l instanceof THREE.MeshBasicMaterial){o=l.color;m=l.opacity;z=l.wireframe;L=l.wireframe_linewidth;A=l.map;D=l.env_map;p=l.combine==THREE.MixOperation;i=l.reflectivity;N=l.env_map&&l.env_map.mapping instanceof THREE.CubeRefractionMapping;B=l.refraction_ratio;c.uniform4f(M.uniforms.mColor,o.r*m,o.g*m,o.b*m,m);c.uniform1i(M.uniforms.mixEnvMap,p);c.uniform1f(M.uniforms.mReflectivity,i);c.uniform1i(M.uniforms.useRefract, +N);c.uniform1f(M.uniforms.mRefractionRatio,B)}if(l instanceof THREE.MeshNormalMaterial){m=l.opacity;c.uniform1f(M.uniforms.mOpacity,m);c.uniform1i(M.uniforms.material,4)}else if(l instanceof THREE.MeshDepthMaterial){m=l.opacity;z=l.wireframe;L=l.wireframe_linewidth;c.uniform1f(M.uniforms.mOpacity,m);c.uniform1f(M.uniforms.m2Near,l.__2near);c.uniform1f(M.uniforms.mFarPlusNear,l.__farPlusNear);c.uniform1f(M.uniforms.mFarMinusNear,l.__farMinusNear);c.uniform1i(M.uniforms.material,3)}else if(l instanceof +THREE.MeshPhongMaterial){o=l.ambient;i=l.specular;l=l.shininess;c.uniform4f(M.uniforms.mAmbient,o.r,o.g,o.b,m);c.uniform4f(M.uniforms.mSpecular,i.r,i.g,i.b,m);c.uniform1f(M.uniforms.mShininess,l);c.uniform1i(M.uniforms.material,2)}else if(l instanceof THREE.MeshLambertMaterial)c.uniform1i(M.uniforms.material,1);else l instanceof THREE.MeshBasicMaterial&&c.uniform1i(M.uniforms.material,0);if(A){d(A,0);c.uniform1i(M.uniforms.tMap,0);c.uniform1i(M.uniforms.enableMap,1)}else c.uniform1i(M.uniforms.enableMap, +0);if(D){e(D,1);c.uniform1i(M.uniforms.tCube,1);c.uniform1i(M.uniforms.enableCubeMap,1)}else c.uniform1i(M.uniforms.enableCubeMap,0);m=M.attributes;c.bindBuffer(c.ARRAY_BUFFER,w.__webGLVertexBuffer);c.vertexAttribPointer(m.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(m.position);if(m.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,w.__webGLNormalBuffer);c.vertexAttribPointer(m.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(m.normal)}if(m.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,w.__webGLTangentBuffer); +c.vertexAttribPointer(m.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(m.tangent)}if(m.uv>=0)if(w.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,w.__webGLUVBuffer);c.vertexAttribPointer(m.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(m.uv)}else c.disableVertexAttribArray(m.uv);if(z){c.lineWidth(L);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.__webGLLineBuffer);c.drawElements(c.LINES,w.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);c.drawElements(c.TRIANGLES, +w.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(i,p,l,w,o,m){var z,L,A,D,B;A=0;for(D=l.material.length;A=0;l--){w=i.__webGLObjects[l].object;p==w&&i.__webGLObjects.splice(l,1)}};this.setupMatrices=function(i,p){i.autoUpdateMatrix&&i.updateMatrix();r.multiply(p.matrix,i.matrix);C.set(r.flatten());t=THREE.Matrix4.makeInvert3x3(r).transpose();v.set(t.m);E.set(i.matrix.flatten())}; +this.loadMatrices=function(i){c.uniformMatrix4fv(i.uniforms.viewMatrix,false,x);c.uniformMatrix4fv(i.uniforms.modelViewMatrix,false,C);c.uniformMatrix4fv(i.uniforms.projectionMatrix,false,J);c.uniformMatrix3fv(i.uniforms.normalMatrix,false,v);c.uniformMatrix4fv(i.uniforms.objectMatrix,false,E)};this.loadCamera=function(i,p){c.uniform3f(i.uniforms.cameraPosition,p.position.x,p.position.y,p.position.z)};this.setBlending=function(i){switch(i){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;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(i,p){if(i){!p||p=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(i=="back")c.cullFace(c.BACK);else i=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]}; THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null}; -var GeometryUtils={merge:function(a,b){var e=b instanceof THREE.Mesh,d=a.vertices.length,f=e?b.geometry:b,g=a.vertices,l=f.vertices,h=a.faces,k=f.faces,c=a.uvs;f=f.uvs;e&&b.updateMatrix();for(var u=0,y=l.length;u= 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( uAmbientColor, 1.0 );\ntotalLight += dirDiffuse + dirSpecular;\ntotalLight += pointDiffuse + pointSpecular;\ngl_FragColor = vec4( totalLight.xyz * vLightWeighting * aoTex, 1.0 );\n}", vertex_shader:"attribute vec4 tangent;\nuniform vec3 uDirLightPos;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightPos;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientLightColor;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvLightWeighting = uAmbientLightColor;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( vNormal, vPointLightVector ), 0.0 );\nvLightWeighting += uPointLightColor * pointLightWeighting;\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nfloat directionalLightWeighting = max( dot( vNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += uDirLightColor * directionalLightWeighting;\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"}, basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"void main() {\ngl_FragColor = vec4(1.0, 0.0, 0.0, 0.5);\n}"},cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}", -fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( -wPos.x, wPos.yz ) );\n}"}}},Cube=function(a,b,e,d,f,g,l,h){function k(z,K,I,D,n,i,o,j){var v,q=d||1,m=f||1,A=q+1,F=m+1,M=n/2,x=i/2;n=n/q;i=i/m;var J=c.vertices.length;if(z=="x"&&K=="y"||z=="y"&&K=="x")v="z";else if(z=="x"&&K=="z"||z=="z"&&K=="x")v="y";else if(z=="z"&&K=="y"||z=="y"&&K=="z")v="x";for(iy=0;iy0||(u=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,h,r)))-1);c.push(u)}b.push(c)}var s,w;a=b.length;for(e=0;e0)for(d=0;d1){y=this.vertices[g].position.clone(); -s=this.vertices[h].position.clone();w=this.vertices[k].position.clone();y.normalize();s.normalize();w.normalize();this.faces.push(new THREE.Face3(g,h,k,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(s.x,s.y,s.z),new THREE.Vector3(w.x,w.y,w.z)]));this.uvs.push([c,r,z])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; +var Sphere=function(a,b,e){THREE.Geometry.call(this);var d,f=Math.PI,g=Math.max(3,b||8),k=Math.max(2,e||6);b=[];for(e=0;e0||(u=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,h,r)))-1);c.push(u)}b.push(c)}var t,x;a=b.length;for(e=0;e0)for(d=0;d1){y=this.vertices[g].position.clone(); +t=this.vertices[h].position.clone();x=this.vertices[j].position.clone();y.normalize();t.normalize();x.normalize();this.faces.push(new THREE.Face3(g,h,j,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(x.x,x.y,x.z)]));this.uvs.push([c,r,C])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null}; THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML= b},loadAsciiOld:function(a,b){var e=document.createElement("script");e.type="text/javascript";e.onload=b;e.src=a;document.getElementsByTagName("head")[0].appendChild(e)},loadAscii:function(a,b,e){var d=(new Date).getTime();a=new Worker(a);a.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,b,e)};a.postMessage(d)},loadBinary:function(a,b,e){var d=(new Date).getTime();a=new Worker(a);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(g){THREE.Loader.prototype.loadAjaxBuffers(g.data.buffers, -g.data.materials,b,e,f)};a.onerror=function(g){alert("worker.onerror: "+g.message+"\n"+g.data);g.preventDefault()};a.postMessage(d)},loadAjaxBuffers:function(a,b,e,d,f){var g=new XMLHttpRequest,l=d+"/"+a,h=0;g.onreadystatechange=function(){if(g.readyState==4)g.status==200||g.status==0?THREE.Loader.prototype.createBinModel(g.responseText,e,d,b):alert("Couldn't load ["+l+"] ["+g.status+"]");else if(g.readyState==3){if(f){if(h==0)h=g.getResponseHeader("Content-Length");f({total:h,loaded:g.responseText.length})}}else if(g.readyState== -2)h=g.getResponseHeader("Content-Length")};g.open("GET",l,true);g.overrideMimeType("text/plain; charset=x-user-defined");g.setRequestHeader("Content-Type","text/plain");g.send(null)},createBinModel:function(a,b,e,d){var f=function(g){function l(p,t){var E=u(p,t),N=u(p,t+1),X=u(p,t+2),Y=u(p,t+3),ea=(Y<<1&255|X>>7)-127;E=(X&127)<<16|N<<8|E;if(E==0&&ea==-127)return 0;return(1-2*(Y>>7))*(1+E*Math.pow(2,-23))*Math.pow(2,ea)}function h(p,t){var E=u(p,t),N=u(p,t+1),X=u(p,t+2);return(u(p,t+3)<<24)+(X<<16)+ -(N<<8)+E}function k(p,t){var E=u(p,t);return(u(p,t+1)<<8)+E}function c(p,t){var E=u(p,t);return E>127?E-256:E}function u(p,t){return p.charCodeAt(t)&255}function y(p){var t,E,N;t=h(a,p);E=h(a,p+j);N=h(a,p+v);p=k(a,p+q);THREE.Loader.prototype.f3(I,t,E,N,p)}function r(p){var t,E,N,X,Y,ea;t=h(a,p);E=h(a,p+j);N=h(a,p+v);X=k(a,p+q);Y=h(a,p+m);ea=h(a,p+A);p=h(a,p+F);THREE.Loader.prototype.f3n(I,i,t,E,N,X,Y,ea,p)}function s(p){var t,E,N,X;t=h(a,p);E=h(a,p+M);N=h(a,p+x);X=h(a,p+J);p=k(a,p+R);THREE.Loader.prototype.f4(I, -t,E,N,X,p)}function w(p){var t,E,N,X,Y,ea,ma,oa;t=h(a,p);E=h(a,p+M);N=h(a,p+x);X=h(a,p+J);Y=k(a,p+R);ea=h(a,p+C);ma=h(a,p+V);oa=h(a,p+T);p=h(a,p+$);THREE.Loader.prototype.f4n(I,i,t,E,N,X,Y,ea,ma,oa,p)}function z(p){var t,E;t=h(a,p);E=h(a,p+W);p=h(a,p+O);THREE.Loader.prototype.uv3(I,o[t*2],o[t*2+1],o[E*2],o[E*2+1],o[p*2],o[p*2+1])}function K(p){var t,E,N;t=h(a,p);E=h(a,p+G);N=h(a,p+B);p=h(a,p+S);THREE.Loader.prototype.uv4(I,o[t*2],o[t*2+1],o[E*2],o[E*2+1],o[N*2],o[N*2+1],o[p*2],o[p*2+1])}var I=this, -D=0,n,i=[],o=[],j,v,q,m,A,F,M,x,J,R,C,V,T,$,W,O,G,B,S;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(I,d,g);n={signature:a.substr(D,8),header_bytes:u(a,D+8),vertex_coordinate_bytes:u(a,D+9),normal_coordinate_bytes:u(a,D+10),uv_coordinate_bytes:u(a,D+11),vertex_index_bytes:u(a,D+12),normal_index_bytes:u(a,D+13),uv_index_bytes:u(a,D+14),material_index_bytes:u(a,D+15),nvertices:h(a,D+16),nnormals:h(a,D+16+4),nuvs:h(a,D+16+8),ntri_flat:h(a,D+16+12),ntri_smooth:h(a,D+16+16),ntri_flat_uv:h(a, -D+16+20),ntri_smooth_uv:h(a,D+16+24),nquad_flat:h(a,D+16+28),nquad_smooth:h(a,D+16+32),nquad_flat_uv:h(a,D+16+36),nquad_smooth_uv:h(a,D+16+40)};D+=n.header_bytes;j=n.vertex_index_bytes;v=n.vertex_index_bytes*2;q=n.vertex_index_bytes*3;m=n.vertex_index_bytes*3+n.material_index_bytes;A=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;F=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;M=n.vertex_index_bytes;x=n.vertex_index_bytes*2;J=n.vertex_index_bytes*3;R=n.vertex_index_bytes* -4;C=n.vertex_index_bytes*4+n.material_index_bytes;V=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;T=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;$=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;W=n.uv_index_bytes;O=n.uv_index_bytes*2;G=n.uv_index_bytes;B=n.uv_index_bytes*2;S=n.uv_index_bytes*3;D+=function(p){var t,E,N,X=n.vertex_coordinate_bytes*3,Y=p+n.nvertices*X;for(p=p;p>7)-127;F=(X&127)<<16|P<<8|F;if(F==0&&ea==-127)return 0;return(1-2*(Y>>7))*(1+F*Math.pow(2,-23))*Math.pow(2,ea)}function h(q,s){var F=u(q,s),P=u(q,s+1),X=u(q,s+2);return(u(q,s+3)<<24)+(X<<16)+ +(P<<8)+F}function j(q,s){var F=u(q,s);return(u(q,s+1)<<8)+F}function c(q,s){var F=u(q,s);return F>127?F-256:F}function u(q,s){return q.charCodeAt(s)&255}function y(q){var s,F,P;s=h(a,q);F=h(a,q+l);P=h(a,q+w);q=j(a,q+o);THREE.Loader.prototype.f3(v,s,F,P,q)}function r(q){var s,F,P,X,Y,ea;s=h(a,q);F=h(a,q+l);P=h(a,q+w);X=j(a,q+o);Y=h(a,q+m);ea=h(a,q+z);q=h(a,q+L);THREE.Loader.prototype.f3n(v,i,s,F,P,X,Y,ea,q)}function t(q){var s,F,P,X;s=h(a,q);F=h(a,q+A);P=h(a,q+D);X=h(a,q+B);q=j(a,q+N);THREE.Loader.prototype.f4(v, +s,F,P,X,q)}function x(q){var s,F,P,X,Y,ea,ma,oa;s=h(a,q);F=h(a,q+A);P=h(a,q+D);X=h(a,q+B);Y=j(a,q+N);ea=h(a,q+M);ma=h(a,q+O);oa=h(a,q+U);q=h(a,q+$);THREE.Loader.prototype.f4n(v,i,s,F,P,X,Y,ea,ma,oa,q)}function C(q){var s,F;s=h(a,q);F=h(a,q+W);q=h(a,q+S);THREE.Loader.prototype.uv3(v,p[s*2],p[s*2+1],p[F*2],p[F*2+1],p[q*2],p[q*2+1])}function J(q){var s,F,P;s=h(a,q);F=h(a,q+I);P=h(a,q+H);q=h(a,q+R);THREE.Loader.prototype.uv4(v,p[s*2],p[s*2+1],p[F*2],p[F*2+1],p[P*2],p[P*2+1],p[q*2],p[q*2+1])}var v=this, +E=0,n,i=[],p=[],l,w,o,m,z,L,A,D,B,N,M,O,U,$,W,S,I,H,R;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,d,g);n={signature:a.substr(E,8),header_bytes:u(a,E+8),vertex_coordinate_bytes:u(a,E+9),normal_coordinate_bytes:u(a,E+10),uv_coordinate_bytes:u(a,E+11),vertex_index_bytes:u(a,E+12),normal_index_bytes:u(a,E+13),uv_index_bytes:u(a,E+14),material_index_bytes:u(a,E+15),nvertices:h(a,E+16),nnormals:h(a,E+16+4),nuvs:h(a,E+16+8),ntri_flat:h(a,E+16+12),ntri_smooth:h(a,E+16+16),ntri_flat_uv:h(a, +E+16+20),ntri_smooth_uv:h(a,E+16+24),nquad_flat:h(a,E+16+28),nquad_smooth:h(a,E+16+32),nquad_flat_uv:h(a,E+16+36),nquad_smooth_uv:h(a,E+16+40)};E+=n.header_bytes;l=n.vertex_index_bytes;w=n.vertex_index_bytes*2;o=n.vertex_index_bytes*3;m=n.vertex_index_bytes*3+n.material_index_bytes;z=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;L=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;A=n.vertex_index_bytes;D=n.vertex_index_bytes*2;B=n.vertex_index_bytes*3;N=n.vertex_index_bytes* +4;M=n.vertex_index_bytes*4+n.material_index_bytes;O=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;U=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;$=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;W=n.uv_index_bytes;S=n.uv_index_bytes*2;I=n.uv_index_bytes;H=n.uv_index_bytes*2;R=n.uv_index_bytes*3;E+=function(q){var s,F,P,X=n.vertex_coordinate_bytes*3,Y=q+n.nvertices*X;for(q=q;q diff --git a/examples/webglrenderer2_sandbox.html b/examples/webglrenderer2_sandbox.html index e0e3b6979952b5c49452aa7901ac1e781918ce16..c7aa214c4a6df5d9170cbb14a196889c4c3ab95c 100644 --- a/examples/webglrenderer2_sandbox.html +++ b/examples/webglrenderer2_sandbox.html @@ -105,7 +105,7 @@ var container, stats; - var camera, scene, webglRenderer; + var camera, scene, renderer; var mesh, zmesh, lightMesh, geometry; @@ -167,9 +167,10 @@ } - webglRenderer = new THREE.WebGLRenderer2(); - webglRenderer.setSize( window.innerWidth, window.innerHeight ); - container.appendChild( webglRenderer.domElement ); + renderer = new THREE.WebGLRenderer2(); + renderer.setSize( window.innerWidth, window.innerHeight ); + // renderer.sortObjects = false; + container.appendChild( renderer.domElement ); if ( statsEnabled ) { @@ -223,7 +224,7 @@ camera.position.x += ( mouseX - camera.position.x ) * .05; camera.position.y += ( - mouseY - camera.position.y ) * .05; - webglRenderer.render( scene, camera ); + renderer.render( scene, camera ); if ( statsEnabled ) stats.update(); diff --git a/src/cameras/Camera.js b/src/cameras/Camera.js index 16d9cfef25b1fc7716d0c49d4fe8781c027f93e4..e6e4d99dd50961ec4fe5792d80b4f3ce6ab37fba 100644 --- a/src/cameras/Camera.js +++ b/src/cameras/Camera.js @@ -8,6 +8,7 @@ THREE.Camera = function ( fov, aspect, near, far ) { this.target = { position: new THREE.Vector3() }; this.up = new THREE.Vector3( 0, 1, 0 ); + this.matrix = new THREE.Matrix4(); this.projectionMatrix = THREE.Matrix4.makePerspective( fov, aspect, near, far ); @@ -23,7 +24,7 @@ THREE.Camera = function ( fov, aspect, near, far ) { }; - /* + /* TODO this.translateY = function ( amount ) { }; diff --git a/src/core/Geometry.js b/src/core/Geometry.js index d773c6c242b61635a0b6c3bd6d6e38fd075b42af..e26c15bc8bd48a877368972ca99a701d7c10db16 100644 --- a/src/core/Geometry.js +++ b/src/core/Geometry.js @@ -10,6 +10,9 @@ THREE.Geometry = function () { this.faces = []; this.uvs = []; + this.boundingBox = null; + this.boundingSphere = null; + this.geometryChunks = {}; this.hasTangents = false; @@ -286,6 +289,8 @@ THREE.Geometry.prototype = { computeBoundingBox: function () { + var vertex; + if ( this.vertices.length > 0 ) { this.bbox = { 'x': [ this.vertices[ 0 ].position.x, this.vertices[ 0 ].position.x ], @@ -332,6 +337,20 @@ THREE.Geometry.prototype = { }, + computeBoundingSphere: function () { + + var radius = this.boundingSphere === null ? 0 : this.boundingSphere.radius; + + for ( var v = 0, vl = this.vertices.length; v < vl; v ++ ) { + + radius = Math.max( radius, this.vertices[ v ].position.length() ); + + } + + this.boundingSphere = { radius: radius }; + + }, + sortFacesByMaterial: function () { // TODO diff --git a/src/core/Matrix4.js b/src/core/Matrix4.js index 03aa4b4dbe7af28a98ec4575c14a00cdac1bc563..9ae2a3dfbd84af1f75bc90687c19dd5fe0af7b82 100644 --- a/src/core/Matrix4.js +++ b/src/core/Matrix4.js @@ -262,10 +262,10 @@ THREE.Matrix4.prototype = { flatten: function() { - return [this.n11, this.n21, this.n31, this.n41, - this.n12, this.n22, this.n32, this.n42, - this.n13, this.n23, this.n33, this.n43, - this.n14, this.n24, this.n34, this.n44]; + return [ this.n11, this.n21, this.n31, this.n41, + this.n12, this.n22, this.n32, this.n42, + this.n13, this.n23, this.n33, this.n43, + this.n14, this.n24, this.n34, this.n44 ]; }, diff --git a/src/objects/Mesh.js b/src/objects/Mesh.js index 5e11c64de1df58d727bf59b8b60fa859f97b1091..c32bfcf77ac2499ab94033ef7982a45890ddf20f 100644 --- a/src/objects/Mesh.js +++ b/src/objects/Mesh.js @@ -17,7 +17,8 @@ THREE.Mesh = function ( geometry, material/*, normUVs*/ ) { // if ( normUVs ) this.normalizeUVs(); - this.geometry.computeBoundingBox(); + // this.geometry.boundingBox ||this.geometry.computeBoundingBox(); + this.geometry.boundingSphere || this.geometry.computeBoundingSphere(); }; diff --git a/src/renderers/Projector.js b/src/renderers/Projector.js index 33b0cbb8243f2f5f3bc291e66c8daa5f7cb9e6d1..6859bd31ba4a59cbf70fa0b1e75d6ce42c744d7c 100644 --- a/src/renderers/Projector.js +++ b/src/renderers/Projector.js @@ -15,6 +15,7 @@ THREE.Projector = function() { _vector4 = new THREE.Vector4(), _projScreenMatrix = new THREE.Matrix4(), _projScreenObjectMatrix = new THREE.Matrix4(), + _frustum = [], _clippedVertex1PositionScreen = new THREE.Vector4(), _clippedVertex2PositionScreen = new THREE.Vector4(), @@ -29,13 +30,15 @@ THREE.Projector = function() { _objectCount = 0; _projScreenMatrix.multiply( camera.projectionMatrix, camera.matrix ); + computeFrustum( _projScreenMatrix ); + objects = scene.objects; for ( o = 0, ol = objects.length; o < ol; o++ ) { object = objects[ o ]; - if ( object.visible === false ) continue; + if ( object.visible === false || isInFrustum( object ) === false ) continue; _object = _objectPool[ _objectCount ] = _objectPool[ _objectCount ] || new THREE.RenderableObject(); @@ -372,6 +375,46 @@ THREE.Projector = function() { }; + function painterSort( a, b ) { + + return b.z - a.z; + + } + + function computeFrustum( m ) { + + _frustum[ 0 ] = new THREE.Vector4( m.n41 - m.n11, m.n42 - m.n12, m.n43 - m.n13, m.n44 - m.n14 ); + _frustum[ 1 ] = new THREE.Vector4( m.n41 + m.n11, m.n42 + m.n12, m.n43 + m.n13, m.n44 + m.n14 ); + _frustum[ 2 ] = new THREE.Vector4( m.n41 + m.n21, m.n42 + m.n22, m.n43 + m.n23, m.n44 + m.n24 ); + _frustum[ 3 ] = new THREE.Vector4( m.n41 - m.n21, m.n42 - m.n22, m.n43 - m.n23, m.n44 - m.n24 ); + _frustum[ 4 ] = new THREE.Vector4( m.n41 - m.n31, m.n42 - m.n32, m.n43 - m.n33, m.n44 - m.n34 ); + _frustum[ 5 ] = new THREE.Vector4( m.n41 + m.n31, m.n42 + m.n32, m.n43 + m.n33, m.n44 + m.n34 ); + + for ( var i = 0, l = _frustum.length; i < l; i ++ ) { + + var plane = _frustum[ i ]; + plane.divideScalar( Math.sqrt( plane.x * plane.x + plane.y * plane.y + plane.z * plane.z ) ); + + } + + } + + function isInFrustum( object ) { + + var d, position = object.position, + radius = - object.geometry.boundingSphere.radius * Math.max( object.scale.x, Math.max( object.scale.y, object.scale.z ) ); + + for ( var i = 0; i < 6; i ++ ) { + + d = _frustum[ i ].x * position.x + _frustum[ i ].y * position.y + _frustum[ i ].z * position.z + _frustum[ i ].w; + if ( d <= radius ) return false; + + } + + return true; + + } + function clipLine( s1, s2 ) { var alpha1 = 0, alpha2 = 1, @@ -442,10 +485,4 @@ THREE.Projector = function() { } - function painterSort( a, b ) { - - return b.z - a.z; - - } - }; diff --git a/src/renderers/WebGLRenderer2.js b/src/renderers/WebGLRenderer2.js index e4cd4fcc8ba65efb79ff7d280d3c2ad712b98659..c1d75524c5b3ea984a775a162dc15c3a7b955647 100644 --- a/src/renderers/WebGLRenderer2.js +++ b/src/renderers/WebGLRenderer2.js @@ -78,9 +78,7 @@ THREE.WebGLRenderer2 = function () { /* for ( o = 0, ol = scene.objects.length; o < ol; o++ ) { - object = scene.objects[ o ]; - - renderObject( object ); + renderObject( scene.objects[ o ] ); } */ @@ -89,13 +87,10 @@ THREE.WebGLRenderer2 = function () { for ( o = 0, ol = _renderList.length; o < ol; o++ ) { - object = _renderList[ o ]; - - renderObject( object.object ); + renderObject( _renderList[ o ].object ); } - function renderObject( object ) { var geometry, material, m, nl, @@ -242,8 +237,6 @@ THREE.WebGLRenderer2 = function () { function buildBuffers( geometry ) { - // TODO: Handle 65535 - var itemCount = 0, vertexIndex, group, f, fl, face, v1, v2, v3, vertexNormals, normal, uv, vertexGroups = [], faceGroups = [], lineGroups = [], normalGroups = [], uvGroups = [], @@ -470,8 +463,12 @@ THREE.WebGLRenderer2 = function () { pfs += 'uniform sampler2D tMap;\n'; pfs += 'varying vec2 vUv;\n'; - // fs += 'vec4 mapColor = texture2D( tMap, vUv );\n'; - // fs += 'mapColor.xyz *= mapColor.w;\n'; + + /* Premultiply alpha + fs += 'vec4 mapColor = texture2D( tMap, vUv );\n'; + fs += 'mapColor.xyz *= mapColor.w;\n'; + */ + fs += 'gl_FragColor *= texture2D( tMap, vUv );\n'; identifiers.push( 'tMap' );