From e85a0605e88ece7303fc22787a3ddc6d09f081e7 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Fri, 10 Dec 2010 11:06:19 +0000 Subject: [PATCH] Updated build. --- build/Three.js | 217 ++++++++++++++++----------------- build/ThreeDebug.js | 219 +++++++++++++++++----------------- build/ThreeExtras.js | 277 ++++++++++++++++++++++--------------------- 3 files changed, 358 insertions(+), 355 deletions(-) diff --git a/build/Three.js b/build/Three.js index 0c4e37336b..af9d2c9663 100755 --- a/build/Three.js +++ b/build/Three.js @@ -12,55 +12,56 @@ THREE.Vector4=function(a,b,d,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1} THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;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,d,e=a.objects,i=[];a=0;for(b=e.length;a0&&J>0&&k+J<1}var d,e,i,m,n,l,o,c,D,B, -v,y=a.geometry,G=y.vertices,E=[];d=0;for(e=y.faces.length;d= -0&&Math.min(i,o.getBottom())-Math.max(d,o.getTop())>=0};this.empty=function(){l=true;i=e=d=b=0;a()};this.isEmpty=function(){return l};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+i+", width: "+m+", height: "+n+" )"}};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,d,e,i,m,n,l,o,c,D,B,v,y,G,E){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=i||0;this.n22=m||1;this.n23=n||0;this.n24=l||0;this.n31=o||0;this.n32=c||0;this.n33=D||1;this.n34=B||0;this.n41=v||0;this.n42=y||0;this.n43=G||0;this.n44=E||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,d,e,i,m,n,l,o,c,D,B,v,y,G,E){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=i;this.n22=m;this.n23=n;this.n24=l;this.n31=o;this.n32=c;this.n33=D;this.n34=B;this.n41=v;this.n42=y;this.n43=G;this.n44=E;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,d){var e=new THREE.Vector3,i=new THREE.Vector3,m=new THREE.Vector3;m.sub(a,b).normalize();e.cross(d,m).normalize();i.cross(m,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=i.x;this.n22=i.y;this.n23=i.z;this.n24=-i.dot(a);this.n31=m.x; -this.n32=m.y;this.n33=m.z;this.n34=-m.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,i=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*i;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*i;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*i;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,i=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*i;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24* -i;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*i;a.w=this.n41*b+this.n42*d+this.n43*e+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 d=a.n11,e=a.n12,i=a.n13,m=a.n14,n=a.n21,l=a.n22,o=a.n23,c=a.n24,D=a.n31,B=a.n32, -v=a.n33,y=a.n34,G=a.n41,E=a.n42,J=a.n43,L=a.n44,M=b.n11,u=b.n12,f=b.n13,k=b.n14,g=b.n21,q=b.n22,h=b.n23,j=b.n24,r=b.n31,p=b.n32,F=b.n33,x=b.n34,I=b.n41,S=b.n42,t=b.n43,O=b.n44;this.n11=d*M+e*g+i*r+m*I;this.n12=d*u+e*q+i*p+m*S;this.n13=d*f+e*h+i*F+m*t;this.n14=d*k+e*j+i*x+m*O;this.n21=n*M+l*g+o*r+c*I;this.n22=n*u+l*q+o*p+c*S;this.n23=n*f+l*h+o*F+c*t;this.n24=n*k+l*j+o*x+c*O;this.n31=D*M+B*g+v*r+y*I;this.n32=D*u+B*q+v*p+y*S;this.n33=D*f+B*h+v*F+y*t;this.n34=D*k+B*j+v*x+y*O;this.n41=G*M+E*g+J*r+L*I; -this.n42=G*u+E*q+J*p+L*S;this.n43=G*f+E*h+J*F+L*t;this.n44=G*k+E*j+J*x+L*O;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,i=this.n14,m=this.n21,n=this.n22,l=this.n23,o=this.n24,c=this.n31,D=this.n32,B=this.n33,v=this.n34,y=this.n41,G=this.n42,E=this.n43,J=this.n44;this.n11=b*a.n11+d*a.n21+e*a.n31+i*a.n41;this.n12=b*a.n12+d*a.n22+e*a.n32+i*a.n42;this.n13=b*a.n13+d*a.n23+e*a.n33+i*a.n43;this.n14=b*a.n14+d*a.n24+e*a.n34+i*a.n44;this.n21=m*a.n11+n*a.n21+l*a.n31+o*a.n41;this.n22= -m*a.n12+n*a.n22+l*a.n32+o*a.n42;this.n23=m*a.n13+n*a.n23+l*a.n33+o*a.n43;this.n24=m*a.n14+n*a.n24+l*a.n34+o*a.n44;this.n31=c*a.n11+D*a.n21+B*a.n31+v*a.n41;this.n32=c*a.n12+D*a.n22+B*a.n32+v*a.n42;this.n33=c*a.n13+D*a.n23+B*a.n33+v*a.n43;this.n34=c*a.n14+D*a.n24+B*a.n34+v*a.n44;this.n41=y*a.n11+G*a.n21+E*a.n31+J*a.n41;this.n42=y*a.n12+G*a.n22+E*a.n32+J*a.n42;this.n43=y*a.n13+G*a.n23+E*a.n33+J*a.n43;this.n44=y*a.n14+G*a.n24+E*a.n34+J*a.n44;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,d,e){var i=b[d];b[d]=b[e];b[e]=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,d){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=d;return e};THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=d;return e};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 d=new THREE.Matrix4,e=Math.cos(b),i=Math.sin(b),m=1-e,n=a.x,l=a.y,o=a.z;d.n11=m*n*n+e;d.n12=m*n*l-i*o;d.n13=m*n*o+i*l;d.n21=m*n*l+i*o;d.n22=m*l*l+e;d.n23=m*l*o-i*n;d.n31=m*n*o-i*l;d.n32=m*l*o+i*n;d.n33=m*o*o+e;return d}; +THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,h=[];a=0;for(b=e.length;a0&&L>0&&k+L<1}var d,e,h,n,o,l,m,c,z,x, +r,s=a.geometry,H=s.vertices,F=[];d=0;for(e=s.faces.length;dm?e:m;h=h>c? +h:c}a()};this.add3Points=function(m,c,z,x,r,s){if(l){l=false;b=mz?m>r?m:r:z>r?z:r;h=c>x?c>s?c:s:x>s?x:s}else{b=mz?m>r?m>e?m:e:r>e?r:e:z>r?z>e?z:e:r>e?r:e;h=c>x?c>s?c>h?c:h:s>h?s:h:x>s?x>h?x:h:s>h?s:h}a()};this.addRectangle=function(m){if(l){l=false;b=m.getLeft();d=m.getTop();e=m.getRight();h=m.getBottom()}else{b=bm.getRight()?e:m.getRight();h=h>m.getBottom()?h:m.getBottom()}a()};this.inflate=function(m){b-=m;d-=m;e+=m;h+=m;a()};this.minSelf=function(m){b=b>m.getLeft()?b:m.getLeft();d=d>m.getTop()?d:m.getTop();e=e=0&&Math.min(h,m.getBottom())-Math.max(d,m.getTop())>=0};this.empty=function(){l=true;h=e=d=b=0;a()};this.isEmpty=function(){return l};this.toString= +function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+h+", width: "+n+", 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,d,e,h,n,o,l,m,c,z,x,r,s,H,F){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=h||0;this.n22=n||1;this.n23=o||0;this.n24=l||0;this.n31=m||0;this.n32=c||0;this.n33=z||1;this.n34=x||0;this.n41=r||0;this.n42=s||0;this.n43=H||0;this.n44=F||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,d,e,h,n,o,l,m,c,z,x,r,s,H,F){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=h;this.n22=n;this.n23=o;this.n24=l;this.n31=m;this.n32=c;this.n33=z;this.n34=x;this.n41=r;this.n42=s;this.n43=H;this.n44=F;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,d){var e=new THREE.Vector3,h=new THREE.Vector3,n=new THREE.Vector3;n.sub(a,b).normalize();e.cross(d,n).normalize();h.cross(n,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);this.n31=n.x; +this.n32=n.y;this.n33=n.z;this.n34=-n.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,h=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*h;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*h;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,h=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*h;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24* +h;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*h;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*h;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,h=a.n13,n=a.n14,o=a.n21,l=a.n22,m=a.n23,c=a.n24,z=a.n31,x=a.n32, +r=a.n33,s=a.n34,H=a.n41,F=a.n42,L=a.n43,J=a.n44,K=b.n11,v=b.n12,f=b.n13,k=b.n14,g=b.n21,q=b.n22,i=b.n23,j=b.n24,t=b.n31,p=b.n32,C=b.n33,y=b.n34,G=b.n41,O=b.n42,w=b.n43,P=b.n44;this.n11=d*K+e*g+h*t+n*G;this.n12=d*v+e*q+h*p+n*O;this.n13=d*f+e*i+h*C+n*w;this.n14=d*k+e*j+h*y+n*P;this.n21=o*K+l*g+m*t+c*G;this.n22=o*v+l*q+m*p+c*O;this.n23=o*f+l*i+m*C+c*w;this.n24=o*k+l*j+m*y+c*P;this.n31=z*K+x*g+r*t+s*G;this.n32=z*v+x*q+r*p+s*O;this.n33=z*f+x*i+r*C+s*w;this.n34=z*k+x*j+r*y+s*P;this.n41=H*K+F*g+L*t+J*G; +this.n42=H*v+F*q+L*p+J*O;this.n43=H*f+F*i+L*C+J*w;this.n44=H*k+F*j+L*y+J*P;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,h=this.n14,n=this.n21,o=this.n22,l=this.n23,m=this.n24,c=this.n31,z=this.n32,x=this.n33,r=this.n34,s=this.n41,H=this.n42,F=this.n43,L=this.n44,J=a.n11,K=a.n21,v=a.n31,f=a.n41,k=a.n12,g=a.n22,q=a.n32,i=a.n42,j=a.n13,t=a.n23,p=a.n33,C=a.n43,y=a.n14,G=a.n24,O=a.n34;a=a.n44;this.n11=b*J+d*K+e*v+h*f;this.n12=b*k+d*g+e*q+h*i;this.n13=b*j+d*t+e*p+h*C;this.n14= +b*y+d*G+e*O+h*a;this.n21=n*J+o*K+l*v+m*f;this.n22=n*k+o*g+l*q+m*i;this.n23=n*j+o*t+l*p+m*C;this.n24=n*y+o*G+l*O+m*a;this.n31=c*J+z*K+x*v+r*f;this.n32=c*k+z*g+x*q+r*i;this.n33=c*j+z*t+x*p+r*C;this.n34=c*y+z*G+x*O+r*a;this.n41=s*J+H*K+F*v+L*f;this.n42=s*k+H*g+F*q+L*i;this.n43=s*j+H*t+F*p+L*C;this.n44=s*y+H*G+F*O+L*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,d,e){var h=b[d];b[d]=b[e]; +b[e]=h}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,d){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=d;return e}; +THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=d;return e};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 d=new THREE.Matrix4,e=Math.cos(b),h=Math.sin(b),n=1-e,o=a.x,l=a.y,m=a.z;d.n11=n*o*o+e;d.n12=n*o*l-h*m;d.n13=n*o*m+h*l;d.n21=n*o*l+h*m;d.n22=n*l*l+e;d.n23=n*l*m-h*o;d.n31=n*o*m-h*l;d.n32=n*l*m+h*o;d.n33=n*m*m+e;return d}; 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 d=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],i=b[6]*b[1]-b[2]*b[5],m=-b[10]*b[4]+b[6]*b[8],n=b[10]*b[0]-b[2]*b[8],l=-b[6]*b[0]+b[2]*b[4],o=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],D=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*m+b[2]*o;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*i;a.m[3]=b*m;a.m[4]=b*n;a.m[5]=b*l;a.m[6]=b*o;a.m[7]=b*c;a.m[8]=b*D;return a}; -THREE.Matrix4.makeFrustum=function(a,b,d,e,i,m){var n,l,o;n=new THREE.Matrix4;l=2*i/(b-a);o=2*i/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(m+i)/(m-i);i=-2*m*i/(m-i);n.n11=l;n.n12=0;n.n13=a;n.n14=0;n.n21=0;n.n22=o;n.n23=d;n.n24=0;n.n31=0;n.n32=0;n.n33=e;n.n34=i;n.n41=0;n.n42=0;n.n43=-1;n.n44=0;return n};THREE.Matrix4.makePerspective=function(a,b,d,e){var i;a=d*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*b,a*b,i,a,d,e)}; -THREE.Matrix4.makeOrtho=function(a,b,d,e,i,m){var n,l,o,c;n=new THREE.Matrix4;l=b-a;o=d-e;c=m-i;a=(b+a)/l;d=(d+e)/o;i=(m+i)/c;n.n11=2/l;n.n12=0;n.n13=0;n.n14=-a;n.n21=0;n.n22=2/o;n.n23=0;n.n24=-d;n.n31=0;n.n32=0;n.n33=-2/c;n.n34=-i;n.n41=0;n.n42=0;n.n43=0;n.n44=1;return n}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],h=b[6]*b[1]-b[2]*b[5],n=-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],m=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],z=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*n+b[2]*m;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*h;a.m[3]=b*n;a.m[4]=b*o;a.m[5]=b*l;a.m[6]=b*m;a.m[7]=b*c;a.m[8]=b*z;return a}; +THREE.Matrix4.makeFrustum=function(a,b,d,e,h,n){var o,l,m;o=new THREE.Matrix4;l=2*h/(b-a);m=2*h/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(n+h)/(n-h);h=-2*n*h/(n-h);o.n11=l;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=m;o.n23=d;o.n24=0;o.n31=0;o.n32=0;o.n33=e;o.n34=h;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,b,d,e){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,d,e)}; +THREE.Matrix4.makeOrtho=function(a,b,d,e,h,n){var o,l,m,c;o=new THREE.Matrix4;l=b-a;m=d-e;c=n-h;a=(b+a)/l;d=(d+e)/m;h=(n+h)/c;o.n11=2/l;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/m;o.n23=0;o.n24=-d;o.n31=0;o.n32=0;o.n33=-2/c;o.n34=-h;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,d,e,i){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];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,d,e,i,m){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];this.material=m instanceof Array?m:[m]};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.Face3=function(a,b,d,e,h){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.material=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; +THREE.Face4=function(a,b,d,e,h,n){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.material=n instanceof Array?n:[n]};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.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x], +d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,h,n,o,l=new THREE.Vector3,m=new THREE.Vector3;e=0;for(h=this.vertices.length;e0){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(D){var B=[];b=0;for(d=D.length;b65535){c[l].counter+=1;o=c[l].hash+"_"+c[l].counter;if(this.geometryChunks[o]==undefined)this.geometryChunks[o]={faces:[],material:n,vertices:0}}this.geometryChunks[o].faces.push(e);this.geometryChunks[o].vertices+=m}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; -THREE.Camera=function(a,b,d,e){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,d,e);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; +vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(z){var x=[];b=0;for(d=z.length;b65535){c[l].counter+=1;m=c[l].hash+"_"+c[l].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],material:o,vertices:0}}this.geometryChunks[m].faces.push(e);this.geometryChunks[m].vertices+=n}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +THREE.Camera=function(a,b,d,e){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,d,e);this.autoUpdateMatrix=true;this.translateX=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);h.cross(h.clone(),this.up);this.position.addSelf(h);this.target.position.addSelf(h)};this.translateZ=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h); +this.position.subSelf(h);this.target.position.subSelf(h)};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,d){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;d&&this.normalizeUVs();this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh; -THREE.Mesh.prototype.normalizeUVs=function(){var a,b,d,e,i;a=0;for(b=this.geometry.uvs.length;acolor: "+ 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(15658734);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= @@ -85,62 +86,62 @@ undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shadi THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16711680);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(16711680);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,d,e,i,m){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=m!==undefined?m: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,d,e,h,n){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=n!==undefined?n: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.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){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(M,u){var f=0,k=1,g=M.z+M.w,q=u.z+u.w,h=-M.z+M.w,j=-u.z+u.w;if(g>=0&&q>=0&&h>=0&&j>=0)return true;else if(g<0&&q<0||h<0&&j<0)return false;else{if(g<0)f=Math.max(f,g/(g-q));else if(q<0)k=Math.min(k,g/(g-q));if(h<0)f=Math.max(f,h/(h-j));else if(j<0)k=Math.min(k,h/(h-j));if(k0&&C.z<1}O=p.geometry.faces;g=0;for(q=O.length;g0&&v.z<1){c=B[D]=B[D]||new THREE.RenderableParticle;c.x=v.x/v.w;c.y=v.y/v.w;c.z=v.z;c.rotation=p.rotation.z;c.scale.x=p.scale.x*Math.abs(c.x-(v.x+u.projectionMatrix.n11)/(v.w+u.projectionMatrix.n14));c.scale.y=p.scale.y*Math.abs(c.y-(v.y+u.projectionMatrix.n22)/(v.w+u.projectionMatrix.n24));c.material=p.material;b.push(c);D++}}}b.sort(function(K,z){return z.z-K.z});return b};this.unprojectVector=function(M,u){var f=new THREE.Matrix4; -f.multiply(THREE.Matrix4.makeInvert(u.matrix),THREE.Matrix4.makeInvert(u.projectionMatrix));f.multiplyVector3(M);return M}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,i,m;this.domElement=document.createElement("div");this.setSize=function(n,l){d=n;e=l;i=d/2;m=e/2};this.render=function(n,l){var o,c,D,B,v,y,G,E;a=b.projectScene(n,l);o=0;for(c=a.length;o0){w.r+=aa.r*W;w.g+=aa.g*W;w.b+=aa.b*W}}else if(W instanceof THREE.PointLight){Y.sub(W.position,U);Y.normalize();W=N.dot(Y)*ca;if(W>0){w.r+=aa.r*W;w.g+=aa.g*W;w.b+=aa.b*W}}}}function Na(s,U,N){if(N.opacity!=0){Da(N.opacity);ya(N.blending);var w,H,W,aa,ca,da;if(N instanceof THREE.ParticleBasicMaterial){if(N.map){aa=N.map;ca=aa.width>>1;da=aa.height>>1;H=U.scale.x*m;W=U.scale.y*n;N=H*ca;w=W*da;X.set(s.x-N, -s.y-w,s.x+N,s.y+w);if(A.instersects(X)){l.save();l.translate(s.x,s.y);l.rotate(-U.rotation);l.scale(H,-W);l.translate(-ca,-da);l.drawImage(aa,0,0);l.restore()}}}else if(N instanceof THREE.ParticleCircleMaterial){if(T){R.r=Z.r+ia.r+ja.r;R.g=Z.g+ia.g+ja.g;R.b=Z.b+ia.b+ja.b;h.r=N.color.r*R.r;h.g=N.color.g*R.g;h.b=N.color.b*R.b;h.updateStyleString()}else h.__styleString=N.color.__styleString;N=U.scale.x*m;w=U.scale.y*n;X.set(s.x-N,s.y-w,s.x+N,s.y+w);if(A.instersects(X)){H=h.__styleString;if(B!=H)l.fillStyle= -B=H;l.save();l.translate(s.x,s.y);l.rotate(-U.rotation);l.scale(N,w);l.beginPath();l.arc(0,0,1,0,La,true);l.closePath();l.fill();l.restore()}}}}function Oa(s,U,N,w){if(w.opacity!=0){Da(w.opacity);ya(w.blending);l.beginPath();l.moveTo(s.positionScreen.x,s.positionScreen.y);l.lineTo(U.positionScreen.x,U.positionScreen.y);l.closePath();if(w instanceof THREE.LineBasicMaterial){h.__styleString=w.color.__styleString;s=w.linewidth;if(v!=s)l.lineWidth=v=s;s=h.__styleString;if(D!=s)l.strokeStyle=D=s;l.stroke(); -X.inflate(w.linewidth*2)}}}function Ha(s,U,N,w,H,W){if(H.opacity!=0){Da(H.opacity);ya(H.blending);M=s.positionScreen.x;u=s.positionScreen.y;f=U.positionScreen.x;k=U.positionScreen.y;g=N.positionScreen.x;q=N.positionScreen.y;l.beginPath();l.moveTo(M,u);l.lineTo(f,k);l.lineTo(g,q);l.lineTo(M,u);l.closePath();if(H instanceof THREE.MeshBasicMaterial)if(H.map)H.map.image.loaded&&H.map.mapping instanceof THREE.UVMapping&&qa(M,u,f,k,g,q,H.map.image,w.uvs[0].u,w.uvs[0].v,w.uvs[1].u,w.uvs[1].v,w.uvs[2].u, -w.uvs[2].v);else if(H.env_map){if(H.env_map.image.loaded)if(H.env_map.mapping instanceof THREE.SphericalReflectionMapping){s=wa.matrix;Y.copy(w.vertexNormalsWorld[0]);O=(Y.x*s.n11+Y.y*s.n12+Y.z*s.n13)*0.5+0.5;C=-(Y.x*s.n21+Y.y*s.n22+Y.z*s.n23)*0.5+0.5;Y.copy(w.vertexNormalsWorld[1]);P=(Y.x*s.n11+Y.y*s.n12+Y.z*s.n13)*0.5+0.5;Q=-(Y.x*s.n21+Y.y*s.n22+Y.z*s.n23)*0.5+0.5;Y.copy(w.vertexNormalsWorld[2]);K=(Y.x*s.n11+Y.y*s.n12+Y.z*s.n13)*0.5+0.5;z=-(Y.x*s.n21+Y.y*s.n22+Y.z*s.n23)*0.5+0.5;qa(M,u,f,k,g,q, -H.env_map.image,O,C,P,Q,K,z)}}else H.wireframe?za(H.color.__styleString,H.wireframe_linewidth):Aa(H.color.__styleString);else if(H instanceof THREE.MeshLambertMaterial){if(H.map&&!H.wireframe){H.map.mapping instanceof THREE.UVMapping&&qa(M,u,f,k,g,q,H.map.image,w.uvs[0].u,w.uvs[0].v,w.uvs[1].u,w.uvs[1].v,w.uvs[2].u,w.uvs[2].v);ya(THREE.SubtractiveBlending)}if(T)if(!H.wireframe&&H.shading==THREE.SmoothShading&&w.vertexNormalsWorld.length==3){j.r=r.r=p.r=Z.r;j.g=r.g=p.g=Z.g;j.b=r.b=p.b=Z.b;xa(W,w.v1.positionWorld, -w.vertexNormalsWorld[0],j);xa(W,w.v2.positionWorld,w.vertexNormalsWorld[1],r);xa(W,w.v3.positionWorld,w.vertexNormalsWorld[2],p);F.r=(r.r+p.r)*0.5;F.g=(r.g+p.g)*0.5;F.b=(r.b+p.b)*0.5;t=Ia(j,r,p,F);qa(M,u,f,k,g,q,t,0,0,1,0,0,1)}else{R.r=Z.r;R.g=Z.g;R.b=Z.b;xa(W,w.centroidWorld,w.normalWorld,R);h.r=H.color.r*R.r;h.g=H.color.g*R.g;h.b=H.color.b*R.b;h.updateStyleString();H.wireframe?za(h.__styleString,H.wireframe_linewidth):Aa(h.__styleString)}else H.wireframe?za(H.color.__styleString,H.wireframe_linewidth): -Aa(H.color.__styleString)}else if(H instanceof THREE.MeshDepthMaterial){x=H.__2near;I=H.__farPlusNear;S=H.__farMinusNear;j.r=j.g=j.b=1-x/(I-s.positionScreen.z*S);r.r=r.g=r.b=1-x/(I-U.positionScreen.z*S);p.r=p.g=p.b=1-x/(I-N.positionScreen.z*S);F.r=(r.r+p.r)*0.5;F.g=(r.g+p.g)*0.5;F.b=(r.b+p.b)*0.5;t=Ia(j,r,p,F);qa(M,u,f,k,g,q,t,0,0,1,0,0,1)}else if(H instanceof THREE.MeshNormalMaterial){h.r=Ea(w.normalWorld.x);h.g=Ea(w.normalWorld.y);h.b=Ea(w.normalWorld.z);h.updateStyleString();H.wireframe?za(h.__styleString, -H.wireframe_linewidth):Aa(h.__styleString)}}}function za(s,U){if(D!=s)l.strokeStyle=D=s;if(v!=U)l.lineWidth=v=U;l.stroke();X.inflate(U*2)}function Aa(s){if(B!=s)l.fillStyle=B=s;l.fill()}function qa(s,U,N,w,H,W,aa,ca,da,ra,ha,sa,ta){var ka,ga;ka=aa.width-1;ga=aa.height-1;ca*=ka;da*=ga;ra*=ka;ha*=ga;sa*=ka;ta*=ga;N-=s;w-=U;H-=s;W-=U;ra-=ca;ha-=da;sa-=ca;ta-=da;ga=1/(ra*ta-sa*ha);ka=(ta*N-ha*H)*ga;ha=(ta*w-ha*W)*ga;N=(ra*H-sa*N)*ga;w=(ra*W-sa*w)*ga;s=s-ka*ca-N*da;U=U-ha*ca-w*da;l.save();l.transform(ka, -ha,N,w,s,U);l.clip();l.drawImage(aa,0,0);l.restore()}function Da(s){if(o!=s)l.globalAlpha=o=s}function ya(s){if(c!=s){switch(s){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}c=s}}function Ia(s,U,N,w){ba[0]=G(0,y(255,~~(s.r*255)));ba[1]=G(0,y(255,~~(s.g*255)));ba[2]=G(0,y(255,~~(s.b*255)));ba[4]=G(0,y(255,~~(U.r*255)));ba[5]=G(0,y(255, -~~(U.g*255)));ba[6]=G(0,y(255,~~(U.b*255)));ba[8]=G(0,y(255,~~(N.r*255)));ba[9]=G(0,y(255,~~(N.g*255)));ba[10]=G(0,y(255,~~(N.b*255)));ba[12]=G(0,y(255,~~(w.r*255)));ba[13]=G(0,y(255,~~(w.g*255)));ba[14]=G(0,y(255,~~(w.b*255)));oa.putImageData(Ca,0,0);va.drawImage(na,0,0);return pa}function Ea(s){return s<0?y((1+s)*0.5,0.5):0.5+y(s*0.5,0.5)}function Fa(s,U){var N=U.x-s.x,w=U.y-s.y,H=1/Math.sqrt(N*N+w*w);N*=H;w*=H;U.x+=N;U.y+=w;s.x-=N;s.y-=w}var Ba,Ja,$,ea,ma,Ga,Ka,ua;l.setTransform(1,0,0,-1,m,n); -this.autoClear&&this.clear();a=b.projectScene(fa,wa);(T=fa.lights.length>0)&&Ma(fa);Ba=0;for(Ja=a.length;Ba0){Q.r+=A.color.r*V;Q.g+=A.color.g*V;Q.b+=A.color.b*V}}else if(A instanceof THREE.PointLight){j.sub(A.position,P.centroidWorld);j.normalize();V=P.normalWorld.dot(j)*A.intensity;if(V>0){Q.r+=A.color.r*V;Q.g+=A.color.g*V;Q.b+=A.color.b*V}}}}function b(C,P,Q,K,z,A){x=e(I++);x.setAttribute("d","M "+C.positionScreen.x+ -" "+C.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(z instanceof THREE.MeshBasicMaterial)u.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshLambertMaterial)if(M){f.r=k.r;f.g=k.g;f.b=k.b;a(A,K,f);u.r=z.color.r*f.r;u.g=z.color.g*f.g;u.b=z.color.b*f.b;u.updateStyleString()}else u.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshDepthMaterial){h=1-z.__2near/(z.__farPlusNear-K.z*z.__farMinusNear); -u.setRGB(h,h,h)}else z instanceof THREE.MeshNormalMaterial&&u.setRGB(i(K.normalWorld.x),i(K.normalWorld.y),i(K.normalWorld.z));z.wireframe?x.setAttribute("style","fill: none; stroke: "+u.__styleString+"; stroke-width: "+z.wireframe_linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.wireframe_linecap+"; stroke-linejoin: "+z.wireframe_linejoin):x.setAttribute("style","fill: "+u.__styleString+"; fill-opacity: "+z.opacity);l.appendChild(x)}function d(C,P,Q,K,z,A,V){x=e(I++);x.setAttribute("d", -"M "+C.positionScreen.x+" "+C.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(A instanceof THREE.MeshBasicMaterial)u.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshLambertMaterial)if(M){f.r=k.r;f.g=k.g;f.b=k.b;a(V,z,f);u.r=A.color.r*f.r;u.g=A.color.g*f.g;u.b=A.color.b*f.b;u.updateStyleString()}else u.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshDepthMaterial){h= -1-A.__2near/(A.__farPlusNear-z.z*A.__farMinusNear);u.setRGB(h,h,h)}else A instanceof THREE.MeshNormalMaterial&&u.setRGB(i(z.normalWorld.x),i(z.normalWorld.y),i(z.normalWorld.z));A.wireframe?x.setAttribute("style","fill: none; stroke: "+u.__styleString+"; stroke-width: "+A.wireframe_linewidth+"; stroke-opacity: "+A.opacity+"; stroke-linecap: "+A.wireframe_linecap+"; stroke-linejoin: "+A.wireframe_linejoin):x.setAttribute("style","fill: "+u.__styleString+"; fill-opacity: "+A.opacity);l.appendChild(x)} -function e(C){if(r[C]==null){r[C]=document.createElementNS("http://www.w3.org/2000/svg","path");O==0&&r[C].setAttribute("shape-rendering","crispEdges");return r[C]}return r[C]}function i(C){return C<0?Math.min((1+C)*0.5,0.5):0.5+Math.min(C*0.5,0.5)}var m=null,n=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,c,D,B,v,y,G,E,J=new THREE.Rectangle,L=new THREE.Rectangle,M=false,u=new THREE.Color(16777215),f=new THREE.Color(16777215),k=new THREE.Color(0),g=new THREE.Color(0), -q=new THREE.Color(0),h,j=new THREE.Vector3,r=[],p=[],F=[],x,I,S,t,O=1;this.domElement=l;this.autoClear=true;this.setQuality=function(C){switch(C){case "high":O=1;break;case "low":O=0}};this.setSize=function(C,P){o=C;c=P;D=o/2;B=c/2;l.setAttribute("viewBox",-D+" "+-B+" "+o+" "+c);l.setAttribute("width",o);l.setAttribute("height",c);J.set(-D,-B,D,B)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(C,P){var Q,K,z,A,V,X,T,R;this.autoClear&&this.clear(); -m=n.projectScene(C,P);t=S=I=0;if(M=C.lights.length>0){T=C.lights;k.setRGB(0,0,0);g.setRGB(0,0,0);q.setRGB(0,0,0);Q=0;for(K=T.length;Q0?"#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(g,n("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+ -f));c.attachShader(g,n("vertex",q+k));c.linkProgram(g);c.getProgramParameter(g,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(g,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");g.uniforms={};g.attributes={};return g}function d(f,k){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, +THREE.Projector=function(){function a(K,v){var f=0,k=1,g=K.z+K.w,q=v.z+v.w,i=-K.z+K.w,j=-v.z+v.w;if(g>=0&&q>=0&&i>=0&&j>=0)return true;else if(g<0&&q<0||i<0&&j<0)return false;else{if(g<0)f=Math.max(f,g/(g-q));else if(q<0)k=Math.min(k,g/(g-q));if(i<0)f=Math.max(f,i/(i-j));else if(j<0)k=Math.min(k,i/(i-j));if(k0&&E.z<1}P=p.geometry.faces;g=0;for(q=P.length;g0&&r.z<1){c=x[z]=x[z]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=p.rotation.z;c.scale.x=p.scale.x*Math.abs(c.x-(r.x+v.projectionMatrix.n11)/(r.w+v.projectionMatrix.n14));c.scale.y=p.scale.y*Math.abs(c.y-(r.y+v.projectionMatrix.n22)/(r.w+v.projectionMatrix.n24));c.material=p.material;b.push(c);z++}}}b.sort(function(M,B){return B.z-M.z});return b};this.unprojectVector=function(K,v){var f=new THREE.Matrix4; +f.multiply(THREE.Matrix4.makeInvert(v.matrix),THREE.Matrix4.makeInvert(v.projectionMatrix));f.multiplyVector3(K);return K}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,h,n;this.domElement=document.createElement("div");this.setSize=function(o,l){d=o;e=l;h=d/2;n=e/2};this.render=function(o,l){var m,c,z,x,r,s,H,F;a=b.projectScene(o,l);m=0;for(c=a.length;m0){A.r+=aa.r*W;A.g+=aa.g*W;A.b+=aa.b*W}}else if(W instanceof THREE.PointLight){X.sub(W.position,U);X.normalize();W=N.dot(X)*ca;if(W>0){A.r+=aa.r*W;A.g+=aa.g*W;A.b+=aa.b*W}}}}function Na(u,U,N){if(N.opacity!=0){Da(N.opacity);ya(N.blending);var A,I,W,aa,ca,da;if(N instanceof THREE.ParticleBasicMaterial){if(N.map){aa=N.map;ca=aa.width>>1;da=aa.height>>1;I=U.scale.x*n;W=U.scale.y*o;N=I*ca;A=W*da;Y.set(u.x-N, +u.y-A,u.x+N,u.y+A);if(D.instersects(Y)){l.save();l.translate(u.x,u.y);l.rotate(-U.rotation);l.scale(I,-W);l.translate(-ca,-da);l.drawImage(aa,0,0);l.restore()}}}else if(N instanceof THREE.ParticleCircleMaterial){if(T){S.r=Z.r+ia.r+ja.r;S.g=Z.g+ia.g+ja.g;S.b=Z.b+ia.b+ja.b;i.r=N.color.r*S.r;i.g=N.color.g*S.g;i.b=N.color.b*S.b;i.updateStyleString()}else i.__styleString=N.color.__styleString;N=U.scale.x*n;A=U.scale.y*o;Y.set(u.x-N,u.y-A,u.x+N,u.y+A);if(D.instersects(Y)){I=i.__styleString;if(x!=I)l.fillStyle= +x=I;l.save();l.translate(u.x,u.y);l.rotate(-U.rotation);l.scale(N,A);l.beginPath();l.arc(0,0,1,0,La,true);l.closePath();l.fill();l.restore()}}}}function Oa(u,U,N,A){if(A.opacity!=0){Da(A.opacity);ya(A.blending);l.beginPath();l.moveTo(u.positionScreen.x,u.positionScreen.y);l.lineTo(U.positionScreen.x,U.positionScreen.y);l.closePath();if(A instanceof THREE.LineBasicMaterial){i.__styleString=A.color.__styleString;u=A.linewidth;if(r!=u)l.lineWidth=r=u;u=i.__styleString;if(z!=u)l.strokeStyle=z=u;l.stroke(); +Y.inflate(A.linewidth*2)}}}function Ha(u,U,N,A,I,W){if(I.opacity!=0){Da(I.opacity);ya(I.blending);K=u.positionScreen.x;v=u.positionScreen.y;f=U.positionScreen.x;k=U.positionScreen.y;g=N.positionScreen.x;q=N.positionScreen.y;l.beginPath();l.moveTo(K,v);l.lineTo(f,k);l.lineTo(g,q);l.lineTo(K,v);l.closePath();if(I instanceof THREE.MeshBasicMaterial)if(I.map)I.map.image.loaded&&I.map.mapping instanceof THREE.UVMapping&&qa(K,v,f,k,g,q,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){u=wa.matrix;X.copy(A.vertexNormalsWorld[0]);P=(X.x*u.n11+X.y*u.n12+X.z*u.n13)*0.5+0.5;E=-(X.x*u.n21+X.y*u.n22+X.z*u.n23)*0.5+0.5;X.copy(A.vertexNormalsWorld[1]);Q=(X.x*u.n11+X.y*u.n12+X.z*u.n13)*0.5+0.5;R=-(X.x*u.n21+X.y*u.n22+X.z*u.n23)*0.5+0.5;X.copy(A.vertexNormalsWorld[2]);M=(X.x*u.n11+X.y*u.n12+X.z*u.n13)*0.5+0.5;B=-(X.x*u.n21+X.y*u.n22+X.z*u.n23)*0.5+0.5;qa(K,v,f,k,g,q, +I.env_map.image,P,E,Q,R,M,B)}}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString);else if(I instanceof THREE.MeshLambertMaterial){if(I.map&&!I.wireframe){I.map.mapping instanceof THREE.UVMapping&&qa(K,v,f,k,g,q,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);ya(THREE.SubtractiveBlending)}if(T)if(!I.wireframe&&I.shading==THREE.SmoothShading&&A.vertexNormalsWorld.length==3){j.r=t.r=p.r=Z.r;j.g=t.g=p.g=Z.g;j.b=t.b=p.b=Z.b;xa(W,A.v1.positionWorld, +A.vertexNormalsWorld[0],j);xa(W,A.v2.positionWorld,A.vertexNormalsWorld[1],t);xa(W,A.v3.positionWorld,A.vertexNormalsWorld[2],p);C.r=(t.r+p.r)*0.5;C.g=(t.g+p.g)*0.5;C.b=(t.b+p.b)*0.5;w=Ia(j,t,p,C);qa(K,v,f,k,g,q,w,0,0,1,0,0,1)}else{S.r=Z.r;S.g=Z.g;S.b=Z.b;xa(W,A.centroidWorld,A.normalWorld,S);i.r=I.color.r*S.r;i.g=I.color.g*S.g;i.b=I.color.b*S.b;i.updateStyleString();I.wireframe?za(i.__styleString,I.wireframe_linewidth):Aa(i.__styleString)}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth): +Aa(I.color.__styleString)}else if(I instanceof THREE.MeshDepthMaterial){y=I.__2near;G=I.__farPlusNear;O=I.__farMinusNear;j.r=j.g=j.b=1-y/(G-u.positionScreen.z*O);t.r=t.g=t.b=1-y/(G-U.positionScreen.z*O);p.r=p.g=p.b=1-y/(G-N.positionScreen.z*O);C.r=(t.r+p.r)*0.5;C.g=(t.g+p.g)*0.5;C.b=(t.b+p.b)*0.5;w=Ia(j,t,p,C);qa(K,v,f,k,g,q,w,0,0,1,0,0,1)}else if(I instanceof THREE.MeshNormalMaterial){i.r=Ea(A.normalWorld.x);i.g=Ea(A.normalWorld.y);i.b=Ea(A.normalWorld.z);i.updateStyleString();I.wireframe?za(i.__styleString, +I.wireframe_linewidth):Aa(i.__styleString)}}}function za(u,U){if(z!=u)l.strokeStyle=z=u;if(r!=U)l.lineWidth=r=U;l.stroke();Y.inflate(U*2)}function Aa(u){if(x!=u)l.fillStyle=x=u;l.fill()}function qa(u,U,N,A,I,W,aa,ca,da,ra,ha,sa,ta){var ka,ga;ka=aa.width-1;ga=aa.height-1;ca*=ka;da*=ga;ra*=ka;ha*=ga;sa*=ka;ta*=ga;N-=u;A-=U;I-=u;W-=U;ra-=ca;ha-=da;sa-=ca;ta-=da;ga=1/(ra*ta-sa*ha);ka=(ta*N-ha*I)*ga;ha=(ta*A-ha*W)*ga;N=(ra*I-sa*N)*ga;A=(ra*W-sa*A)*ga;u=u-ka*ca-N*da;U=U-ha*ca-A*da;l.save();l.transform(ka, +ha,N,A,u,U);l.clip();l.drawImage(aa,0,0);l.restore()}function Da(u){if(m!=u)l.globalAlpha=m=u}function ya(u){if(c!=u){switch(u){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}c=u}}function Ia(u,U,N,A){ba[0]=H(0,s(255,~~(u.r*255)));ba[1]=H(0,s(255,~~(u.g*255)));ba[2]=H(0,s(255,~~(u.b*255)));ba[4]=H(0,s(255,~~(U.r*255)));ba[5]=H(0,s(255, +~~(U.g*255)));ba[6]=H(0,s(255,~~(U.b*255)));ba[8]=H(0,s(255,~~(N.r*255)));ba[9]=H(0,s(255,~~(N.g*255)));ba[10]=H(0,s(255,~~(N.b*255)));ba[12]=H(0,s(255,~~(A.r*255)));ba[13]=H(0,s(255,~~(A.g*255)));ba[14]=H(0,s(255,~~(A.b*255)));oa.putImageData(Ca,0,0);va.drawImage(na,0,0);return pa}function Ea(u){return u<0?s((1+u)*0.5,0.5):0.5+s(u*0.5,0.5)}function Fa(u,U){var N=U.x-u.x,A=U.y-u.y,I=1/Math.sqrt(N*N+A*A);N*=I;A*=I;U.x+=N;U.y+=A;u.x-=N;u.y-=A}var Ba,Ja,$,ea,ma,Ga,Ka,ua;l.setTransform(1,0,0,-1,n,o); +this.autoClear&&this.clear();a=b.projectScene(fa,wa);(T=fa.lights.length>0)&&Ma(fa);Ba=0;for(Ja=a.length;Ba0){R.r+=D.color.r*V;R.g+=D.color.g*V;R.b+=D.color.b*V}}else if(D instanceof THREE.PointLight){j.sub(D.position,Q.centroidWorld);j.normalize();V=Q.normalWorld.dot(j)*D.intensity;if(V>0){R.r+=D.color.r*V;R.g+=D.color.g*V;R.b+=D.color.b*V}}}}function b(E,Q,R,M,B,D){y=e(G++);y.setAttribute("d","M "+E.positionScreen.x+ +" "+E.positionScreen.y+" L "+Q.positionScreen.x+" "+Q.positionScreen.y+" L "+R.positionScreen.x+","+R.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)v.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(K){f.r=k.r;f.g=k.g;f.b=k.b;a(D,M,f);v.r=B.color.r*f.r;v.g=B.color.g*f.g;v.b=B.color.b*f.b;v.updateStyleString()}else v.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){i=1-B.__2near/(B.__farPlusNear-M.z*B.__farMinusNear); +v.setRGB(i,i,i)}else B instanceof THREE.MeshNormalMaterial&&v.setRGB(h(M.normalWorld.x),h(M.normalWorld.y),h(M.normalWorld.z));B.wireframe?y.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):y.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+B.opacity);l.appendChild(y)}function d(E,Q,R,M,B,D,V){y=e(G++);y.setAttribute("d", +"M "+E.positionScreen.x+" "+E.positionScreen.y+" L "+Q.positionScreen.x+" "+Q.positionScreen.y+" L "+R.positionScreen.x+","+R.positionScreen.y+" L "+M.positionScreen.x+","+M.positionScreen.y+"z");if(D instanceof THREE.MeshBasicMaterial)v.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshLambertMaterial)if(K){f.r=k.r;f.g=k.g;f.b=k.b;a(V,B,f);v.r=D.color.r*f.r;v.g=D.color.g*f.g;v.b=D.color.b*f.b;v.updateStyleString()}else v.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshDepthMaterial){i= +1-D.__2near/(D.__farPlusNear-B.z*D.__farMinusNear);v.setRGB(i,i,i)}else D instanceof THREE.MeshNormalMaterial&&v.setRGB(h(B.normalWorld.x),h(B.normalWorld.y),h(B.normalWorld.z));D.wireframe?y.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+D.wireframe_linewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.wireframe_linecap+"; stroke-linejoin: "+D.wireframe_linejoin):y.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+D.opacity);l.appendChild(y)} +function e(E){if(t[E]==null){t[E]=document.createElementNS("http://www.w3.org/2000/svg","path");P==0&&t[E].setAttribute("shape-rendering","crispEdges");return t[E]}return t[E]}function h(E){return E<0?Math.min((1+E)*0.5,0.5):0.5+Math.min(E*0.5,0.5)}var n=null,o=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,c,z,x,r,s,H,F,L=new THREE.Rectangle,J=new THREE.Rectangle,K=false,v=new THREE.Color(16777215),f=new THREE.Color(16777215),k=new THREE.Color(0),g=new THREE.Color(0), +q=new THREE.Color(0),i,j=new THREE.Vector3,t=[],p=[],C=[],y,G,O,w,P=1;this.domElement=l;this.autoClear=true;this.setQuality=function(E){switch(E){case "high":P=1;break;case "low":P=0}};this.setSize=function(E,Q){m=E;c=Q;z=m/2;x=c/2;l.setAttribute("viewBox",-z+" "+-x+" "+m+" "+c);l.setAttribute("width",m);l.setAttribute("height",c);L.set(-z,-x,z,x)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(E,Q){var R,M,B,D,V,Y,T,S;this.autoClear&&this.clear(); +n=o.projectScene(E,Q);w=O=G=0;if(K=E.lights.length>0){T=E.lights;k.setRGB(0,0,0);g.setRGB(0,0,0);q.setRGB(0,0,0);R=0;for(M=T.length;R0?"#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(g,o("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+ +f));c.attachShader(g,o("vertex",q+k));c.linkProgram(g);c.getProgramParameter(g,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(g,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");g.uniforms={};g.attributes={};return g}function d(f,k){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 g=0;g<6;++g)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,f.image[g]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);f.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+k);c.bindTexture(c.TEXTURE_CUBE_MAP, f.image.__webGLTextureCube)}}function e(f,k){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+k);c.bindTexture(c.TEXTURE_2D,f.__webGLTexture)}function i(f,k){var g,q,h;g=0;for(q=k.length;g=0&&c.enableVertexAttribArray(f.attributes[h])}}function n(f,k){var g;if(f=="fragment")g=c.createShader(c.FRAGMENT_SHADER);else if(f=="vertex")g=c.createShader(c.VERTEX_SHADER); +c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+k);c.bindTexture(c.TEXTURE_2D,f.__webGLTexture)}function h(f,k){var g,q,i;g=0;for(q=k.length;g=0&&c.enableVertexAttribArray(f.attributes[i])}}function o(f,k){var g;if(f=="fragment")g=c.createShader(c.FRAGMENT_SHADER);else if(f=="vertex")g=c.createShader(c.VERTEX_SHADER); c.shaderSource(g,k);c.compileShader(g);if(!c.getShaderParameter(g,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(g));return null}return g}function l(f){switch(f){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR; -case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var o=document.createElement("canvas"),c,D,B,v=new THREE.Matrix4,y,G=new Float32Array(16),E=new Float32Array(16),J=new Float32Array(16),L=new Float32Array(9),M=new Float32Array(16);a=function(f,k){if(f){var g,q,h,j=pointLights=maxDirLights=maxPointLights=0;g=0;for(q=f.lights.length;g= 0.0 )":"",f?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",f?"dirDiffuse += mColor * dirDiffuseWeight;":"",f?"dirSpecular += mSpecular * dirSpecularWeight;":"",f?"}":"","vec4 totalLight = mAmbient;",f?"totalLight += dirDiffuse + dirSpecular;":"",k?"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"); -g=b(q,g);c.useProgram(g);i(g,["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(g,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);k&&i(g,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(g.uniforms.enableMap,0);c.uniform1i(g.uniforms.tMap,0);c.uniform1i(g.uniforms.enableCubeMap,0);c.uniform1i(g.uniforms.tCube,1);c.uniform1i(g.uniforms.mixEnvMap,0);c.uniform1i(g.uniforms.useRefract,0);m(g,["position","normal","uv"]);return g}(a.directional,a.point);this.setSize=function(f,k){o.width=f;o.height=k;c.viewport(0,0,o.width,o.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(f,k){var g,q,h,j,r,p=[], -F=[],x=[];j=[];r=[];c.uniform1i(f.uniforms.enableLighting,k.length);g=0;for(q=k.length;g0){z.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,z.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(Q),c.STATIC_DRAW)}z.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,z.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(S),c.STATIC_DRAW);z.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, -z.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(t),c.STATIC_DRAW);z.__webGLFaceCount=S.length;z.__webGLLineCount=t.length}};this.renderBuffer=function(f,k,g,q){var h,j,r,p,F,x,I,S,t;if(g instanceof THREE.MeshShaderMaterial){if(!g.program){g.program=b(g.fragment_shader,g.vertex_shader);I=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in g.uniforms)I.push(t);i(g.program,I);m(g.program,["position","normal","uv","tangent"])}t= -g.program}else t=B;if(t!=D){c.useProgram(t);D=t}t==B&&this.setupLights(t,k);this.loadCamera(t,f);this.loadMatrices(t);if(g instanceof THREE.MeshShaderMaterial){r=g.wireframe;p=g.wireframe_linewidth;f=t;k=g.uniforms;var O;for(h in k){S=k[h].type;I=k[h].value;O=f.uniforms[h];if(S=="i")c.uniform1i(O,I);else if(S=="f")c.uniform1f(O,I);else if(S=="v3")c.uniform3f(O,I.x,I.y,I.z);else if(S=="c")c.uniform3f(O,I.r,I.g,I.b);else if(S=="t"){c.uniform1i(O,I);if(S=k[h].texture)S.image instanceof Array&&S.image.length== -6?d(S,I):e(S,I)}}}if(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshBasicMaterial){h=g.color;j=g.opacity;r=g.wireframe;p=g.wireframe_linewidth;F=g.map;x=g.env_map;k=g.combine==THREE.MixOperation;f=g.reflectivity;S=g.env_map&&g.env_map.mapping instanceof THREE.CubeRefractionMapping;I=g.refraction_ratio;c.uniform4f(t.uniforms.mColor,h.r*j,h.g*j,h.b*j,j);c.uniform1i(t.uniforms.mixEnvMap,k);c.uniform1f(t.uniforms.mReflectivity,f);c.uniform1i(t.uniforms.useRefract, -S);c.uniform1f(t.uniforms.mRefractionRatio,I)}if(g instanceof THREE.MeshNormalMaterial){j=g.opacity;c.uniform1f(t.uniforms.mOpacity,j);c.uniform1i(t.uniforms.material,4)}else if(g instanceof THREE.MeshDepthMaterial){j=g.opacity;r=g.wireframe;p=g.wireframe_linewidth;c.uniform1f(t.uniforms.mOpacity,j);c.uniform1f(t.uniforms.m2Near,g.__2near);c.uniform1f(t.uniforms.mFarPlusNear,g.__farPlusNear);c.uniform1f(t.uniforms.mFarMinusNear,g.__farMinusNear);c.uniform1i(t.uniforms.material,3)}else if(g instanceof -THREE.MeshPhongMaterial){h=g.ambient;f=g.specular;g=g.shininess;c.uniform4f(t.uniforms.mAmbient,h.r,h.g,h.b,j);c.uniform4f(t.uniforms.mSpecular,f.r,f.g,f.b,j);c.uniform1f(t.uniforms.mShininess,g);c.uniform1i(t.uniforms.material,2)}else if(g instanceof THREE.MeshLambertMaterial)c.uniform1i(t.uniforms.material,1);else if(g instanceof THREE.MeshBasicMaterial)c.uniform1i(t.uniforms.material,0);else if(g instanceof THREE.MeshCubeMaterial){c.uniform1i(t.uniforms.material,5);x=g.env_map}if(F){e(F,0);c.uniform1i(t.uniforms.tMap, -0);c.uniform1i(t.uniforms.enableMap,1)}else c.uniform1i(t.uniforms.enableMap,0);if(x){d(x,1);c.uniform1i(t.uniforms.tCube,1);c.uniform1i(t.uniforms.enableCubeMap,1)}else c.uniform1i(t.uniforms.enableCubeMap,0);j=t.attributes;c.bindBuffer(c.ARRAY_BUFFER,q.__webGLVertexBuffer);c.vertexAttribPointer(j.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,q.__webGLNormalBuffer);c.vertexAttribPointer(j.normal,3,c.FLOAT,false,0,0);if(j.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLTangentBuffer); -c.vertexAttribPointer(j.tangent,4,c.FLOAT,false,0,0)}if(j.uv>=0)if(q.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLUVBuffer);c.enableVertexAttribArray(j.uv);c.vertexAttribPointer(j.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(j.uv);if(r){c.lineWidth(p);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);c.drawElements(c.LINES,q.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,q.__webGLFaceCount,c.UNSIGNED_SHORT, -0)}};this.renderPass=function(f,k,g,q,h,j){var r,p,F,x,I;F=0;for(x=g.material.length;F=0;g--){q=f.__webGLObjects[g].object;k==q&&f.__webGLObjects.splice(g,1)}};this.setupMatrices=function(f,k){f.autoUpdateMatrix&&f.updateMatrix();v.multiply(k.matrix,f.matrix);G.set(k.matrix.flatten());E.set(v.flatten());J.set(k.projectionMatrix.flatten());y=THREE.Matrix4.makeInvert3x3(v).transpose();L.set(y.m);M.set(f.matrix.flatten())};this.loadMatrices= -function(f){c.uniformMatrix4fv(f.uniforms.viewMatrix,false,G);c.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,E);c.uniformMatrix4fv(f.uniforms.projectionMatrix,false,J);c.uniformMatrix3fv(f.uniforms.normalMatrix,false,L);c.uniformMatrix4fv(f.uniforms.objectMatrix,false,M)};this.loadCamera=function(f,k){c.uniform3f(f.uniforms.cameraPosition,k.position.x,k.position.y,k.position.z)};this.setBlending=function(f){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE); +g=b(q,g);c.useProgram(g);h(g,["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&&h(g,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);k&&h(g,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(g.uniforms.enableMap,0);c.uniform1i(g.uniforms.tMap,0);c.uniform1i(g.uniforms.enableCubeMap,0);c.uniform1i(g.uniforms.tCube,1);c.uniform1i(g.uniforms.mixEnvMap,0);c.uniform1i(g.uniforms.useRefract,0);n(g,["position","normal","uv"]);return g}(a.directional,a.point);this.setSize=function(f,k){m.width=f;m.height=k;c.viewport(0,0,m.width,m.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(f,k){var g,q,i,j,t,p=[], +C=[],y=[];j=[];t=[];c.uniform1i(f.uniforms.enableLighting,k.length);g=0;for(q=k.length;g0){B.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,B.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(R),c.STATIC_DRAW)}B.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,B.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(O),c.STATIC_DRAW);B.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +B.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(w),c.STATIC_DRAW);B.__webGLFaceCount=O.length;B.__webGLLineCount=w.length}};this.renderBuffer=function(f,k,g,q){var i,j,t,p,C,y,G,O,w;if(g instanceof THREE.MeshShaderMaterial){if(!g.program){g.program=b(g.fragment_shader,g.vertex_shader);G=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(w in g.uniforms)G.push(w);h(g.program,G);n(g.program,["position","normal","uv","tangent"])}w= +g.program}else w=x;if(w!=z){c.useProgram(w);z=w}w==x&&this.setupLights(w,k);this.loadCamera(w,f);this.loadMatrices(w);if(g instanceof THREE.MeshShaderMaterial){t=g.wireframe;p=g.wireframe_linewidth;f=w;k=g.uniforms;var P;for(i in k){O=k[i].type;G=k[i].value;P=f.uniforms[i];if(O=="i")c.uniform1i(P,G);else if(O=="f")c.uniform1f(P,G);else if(O=="v3")c.uniform3f(P,G.x,G.y,G.z);else if(O=="c")c.uniform3f(P,G.r,G.g,G.b);else if(O=="t"){c.uniform1i(P,G);if(O=k[i].texture)O.image instanceof Array&&O.image.length== +6?d(O,G):e(O,G)}}}if(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshBasicMaterial){i=g.color;j=g.opacity;t=g.wireframe;p=g.wireframe_linewidth;C=g.map;y=g.env_map;k=g.combine==THREE.MixOperation;f=g.reflectivity;O=g.env_map&&g.env_map.mapping instanceof THREE.CubeRefractionMapping;G=g.refraction_ratio;c.uniform4f(w.uniforms.mColor,i.r*j,i.g*j,i.b*j,j);c.uniform1i(w.uniforms.mixEnvMap,k);c.uniform1f(w.uniforms.mReflectivity,f);c.uniform1i(w.uniforms.useRefract, +O);c.uniform1f(w.uniforms.mRefractionRatio,G)}if(g instanceof THREE.MeshNormalMaterial){j=g.opacity;c.uniform1f(w.uniforms.mOpacity,j);c.uniform1i(w.uniforms.material,4)}else if(g instanceof THREE.MeshDepthMaterial){j=g.opacity;t=g.wireframe;p=g.wireframe_linewidth;c.uniform1f(w.uniforms.mOpacity,j);c.uniform1f(w.uniforms.m2Near,g.__2near);c.uniform1f(w.uniforms.mFarPlusNear,g.__farPlusNear);c.uniform1f(w.uniforms.mFarMinusNear,g.__farMinusNear);c.uniform1i(w.uniforms.material,3)}else if(g instanceof +THREE.MeshPhongMaterial){i=g.ambient;f=g.specular;g=g.shininess;c.uniform4f(w.uniforms.mAmbient,i.r,i.g,i.b,j);c.uniform4f(w.uniforms.mSpecular,f.r,f.g,f.b,j);c.uniform1f(w.uniforms.mShininess,g);c.uniform1i(w.uniforms.material,2)}else if(g instanceof THREE.MeshLambertMaterial)c.uniform1i(w.uniforms.material,1);else if(g instanceof THREE.MeshBasicMaterial)c.uniform1i(w.uniforms.material,0);else if(g instanceof THREE.MeshCubeMaterial){c.uniform1i(w.uniforms.material,5);y=g.env_map}if(C){e(C,0);c.uniform1i(w.uniforms.tMap, +0);c.uniform1i(w.uniforms.enableMap,1)}else c.uniform1i(w.uniforms.enableMap,0);if(y){d(y,1);c.uniform1i(w.uniforms.tCube,1);c.uniform1i(w.uniforms.enableCubeMap,1)}else c.uniform1i(w.uniforms.enableCubeMap,0);j=w.attributes;c.bindBuffer(c.ARRAY_BUFFER,q.__webGLVertexBuffer);c.vertexAttribPointer(j.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,q.__webGLNormalBuffer);c.vertexAttribPointer(j.normal,3,c.FLOAT,false,0,0);if(j.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLTangentBuffer); +c.vertexAttribPointer(j.tangent,4,c.FLOAT,false,0,0)}if(j.uv>=0)if(q.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLUVBuffer);c.enableVertexAttribArray(j.uv);c.vertexAttribPointer(j.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(j.uv);if(t){c.lineWidth(p);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);c.drawElements(c.LINES,q.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,q.__webGLFaceCount,c.UNSIGNED_SHORT, +0)}};this.renderPass=function(f,k,g,q,i,j){var t,p,C,y,G;C=0;for(y=g.material.length;C=0;g--){q=f.__webGLObjects[g].object;k==q&&f.__webGLObjects.splice(g,1)}};this.setupMatrices=function(f,k){f.autoUpdateMatrix&&f.updateMatrix();r.multiply(k.matrix,f.matrix);H.set(k.matrix.flatten());F.set(r.flatten());L.set(k.projectionMatrix.flatten());s=THREE.Matrix4.makeInvert3x3(r).transpose();J.set(s.m);K.set(f.matrix.flatten())};this.loadMatrices= +function(f){c.uniformMatrix4fv(f.uniforms.viewMatrix,false,H);c.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,F);c.uniformMatrix4fv(f.uniforms.projectionMatrix,false,L);c.uniformMatrix3fv(f.uniforms.normalMatrix,false,J);c.uniformMatrix4fv(f.uniforms.objectMatrix,false,K)};this.loadCamera=function(f,k){c.uniform3f(f.uniforms.cameraPosition,k.position.x,k.position.y,k.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,k){if(f){!k||k=="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}}; 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 1b269cfec1..f6491df443 100644 --- a/build/ThreeDebug.js +++ b/build/ThreeDebug.js @@ -12,55 +12,56 @@ THREE.Vector4=function(a,b,d,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1} THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;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,d,e=a.objects,i=[];a=0;for(b=e.length;a0&&J>0&&l+J<1}var d,e,i,m,n,k,o,c,D,B, -v,y=a.geometry,G=y.vertices,E=[];d=0;for(e=y.faces.length;d= -0&&Math.min(i,o.getBottom())-Math.max(d,o.getTop())>=0};this.empty=function(){k=true;i=e=d=b=0;a()};this.isEmpty=function(){return k};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+i+", width: "+m+", height: "+n+" )"}};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,d,e,i,m,n,k,o,c,D,B,v,y,G,E){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=i||0;this.n22=m||1;this.n23=n||0;this.n24=k||0;this.n31=o||0;this.n32=c||0;this.n33=D||1;this.n34=B||0;this.n41=v||0;this.n42=y||0;this.n43=G||0;this.n44=E||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,d,e,i,m,n,k,o,c,D,B,v,y,G,E){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=i;this.n22=m;this.n23=n;this.n24=k;this.n31=o;this.n32=c;this.n33=D;this.n34=B;this.n41=v;this.n42=y;this.n43=G;this.n44=E;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,d){var e=new THREE.Vector3,i=new THREE.Vector3,m=new THREE.Vector3;m.sub(a,b).normalize();e.cross(d,m).normalize();i.cross(m,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=i.x;this.n22=i.y;this.n23=i.z;this.n24=-i.dot(a);this.n31=m.x; -this.n32=m.y;this.n33=m.z;this.n34=-m.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,i=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*i;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*i;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*i;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,i=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*i;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24* -i;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*i;a.w=this.n41*b+this.n42*d+this.n43*e+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 d=a.n11,e=a.n12,i=a.n13,m=a.n14,n=a.n21,k=a.n22,o=a.n23,c=a.n24,D=a.n31,B=a.n32, -v=a.n33,y=a.n34,G=a.n41,E=a.n42,J=a.n43,L=a.n44,M=b.n11,u=b.n12,f=b.n13,l=b.n14,g=b.n21,q=b.n22,h=b.n23,j=b.n24,s=b.n31,p=b.n32,F=b.n33,x=b.n34,I=b.n41,S=b.n42,t=b.n43,O=b.n44;this.n11=d*M+e*g+i*s+m*I;this.n12=d*u+e*q+i*p+m*S;this.n13=d*f+e*h+i*F+m*t;this.n14=d*l+e*j+i*x+m*O;this.n21=n*M+k*g+o*s+c*I;this.n22=n*u+k*q+o*p+c*S;this.n23=n*f+k*h+o*F+c*t;this.n24=n*l+k*j+o*x+c*O;this.n31=D*M+B*g+v*s+y*I;this.n32=D*u+B*q+v*p+y*S;this.n33=D*f+B*h+v*F+y*t;this.n34=D*l+B*j+v*x+y*O;this.n41=G*M+E*g+J*s+L*I; -this.n42=G*u+E*q+J*p+L*S;this.n43=G*f+E*h+J*F+L*t;this.n44=G*l+E*j+J*x+L*O;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,i=this.n14,m=this.n21,n=this.n22,k=this.n23,o=this.n24,c=this.n31,D=this.n32,B=this.n33,v=this.n34,y=this.n41,G=this.n42,E=this.n43,J=this.n44;this.n11=b*a.n11+d*a.n21+e*a.n31+i*a.n41;this.n12=b*a.n12+d*a.n22+e*a.n32+i*a.n42;this.n13=b*a.n13+d*a.n23+e*a.n33+i*a.n43;this.n14=b*a.n14+d*a.n24+e*a.n34+i*a.n44;this.n21=m*a.n11+n*a.n21+k*a.n31+o*a.n41;this.n22= -m*a.n12+n*a.n22+k*a.n32+o*a.n42;this.n23=m*a.n13+n*a.n23+k*a.n33+o*a.n43;this.n24=m*a.n14+n*a.n24+k*a.n34+o*a.n44;this.n31=c*a.n11+D*a.n21+B*a.n31+v*a.n41;this.n32=c*a.n12+D*a.n22+B*a.n32+v*a.n42;this.n33=c*a.n13+D*a.n23+B*a.n33+v*a.n43;this.n34=c*a.n14+D*a.n24+B*a.n34+v*a.n44;this.n41=y*a.n11+G*a.n21+E*a.n31+J*a.n41;this.n42=y*a.n12+G*a.n22+E*a.n32+J*a.n42;this.n43=y*a.n13+G*a.n23+E*a.n33+J*a.n43;this.n44=y*a.n14+G*a.n24+E*a.n34+J*a.n44;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,d,e){var i=b[d];b[d]=b[e];b[e]=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,d){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=d;return e};THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=d;return e};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 d=new THREE.Matrix4,e=Math.cos(b),i=Math.sin(b),m=1-e,n=a.x,k=a.y,o=a.z;d.n11=m*n*n+e;d.n12=m*n*k-i*o;d.n13=m*n*o+i*k;d.n21=m*n*k+i*o;d.n22=m*k*k+e;d.n23=m*k*o-i*n;d.n31=m*n*o-i*k;d.n32=m*k*o+i*n;d.n33=m*o*o+e;return d}; +THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,h=[];a=0;for(b=e.length;a0&&L>0&&l+L<1}var d,e,h,n,o,k,m,c,z,x, +r,t=a.geometry,H=t.vertices,F=[];d=0;for(e=t.faces.length;dm?e:m;h=h>c? +h:c}a()};this.add3Points=function(m,c,z,x,r,t){if(k){k=false;b=mz?m>r?m:r:z>r?z:r;h=c>x?c>t?c:t:x>t?x:t}else{b=mz?m>r?m>e?m:e:r>e?r:e:z>r?z>e?z:e:r>e?r:e;h=c>x?c>t?c>h?c:h:t>h?t:h:x>t?x>h?x:h:t>h?t:h}a()};this.addRectangle=function(m){if(k){k=false;b=m.getLeft();d=m.getTop();e=m.getRight();h=m.getBottom()}else{b=bm.getRight()?e:m.getRight();h=h>m.getBottom()?h:m.getBottom()}a()};this.inflate=function(m){b-=m;d-=m;e+=m;h+=m;a()};this.minSelf=function(m){b=b>m.getLeft()?b:m.getLeft();d=d>m.getTop()?d:m.getTop();e=e=0&&Math.min(h,m.getBottom())-Math.max(d,m.getTop())>=0};this.empty=function(){k=true;h=e=d=b=0;a()};this.isEmpty=function(){return k};this.toString= +function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+h+", width: "+n+", 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,d,e,h,n,o,k,m,c,z,x,r,t,H,F){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=h||0;this.n22=n||1;this.n23=o||0;this.n24=k||0;this.n31=m||0;this.n32=c||0;this.n33=z||1;this.n34=x||0;this.n41=r||0;this.n42=t||0;this.n43=H||0;this.n44=F||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,d,e,h,n,o,k,m,c,z,x,r,t,H,F){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=h;this.n22=n;this.n23=o;this.n24=k;this.n31=m;this.n32=c;this.n33=z;this.n34=x;this.n41=r;this.n42=t;this.n43=H;this.n44=F;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,d){var e=new THREE.Vector3,h=new THREE.Vector3,n=new THREE.Vector3;n.sub(a,b).normalize();e.cross(d,n).normalize();h.cross(n,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);this.n31=n.x; +this.n32=n.y;this.n33=n.z;this.n34=-n.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,h=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*h;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*h;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,h=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*h;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24* +h;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*h;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*h;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,h=a.n13,n=a.n14,o=a.n21,k=a.n22,m=a.n23,c=a.n24,z=a.n31,x=a.n32, +r=a.n33,t=a.n34,H=a.n41,F=a.n42,L=a.n43,J=a.n44,K=b.n11,v=b.n12,f=b.n13,l=b.n14,g=b.n21,q=b.n22,i=b.n23,j=b.n24,u=b.n31,p=b.n32,D=b.n33,y=b.n34,G=b.n41,O=b.n42,w=b.n43,P=b.n44;this.n11=d*K+e*g+h*u+n*G;this.n12=d*v+e*q+h*p+n*O;this.n13=d*f+e*i+h*D+n*w;this.n14=d*l+e*j+h*y+n*P;this.n21=o*K+k*g+m*u+c*G;this.n22=o*v+k*q+m*p+c*O;this.n23=o*f+k*i+m*D+c*w;this.n24=o*l+k*j+m*y+c*P;this.n31=z*K+x*g+r*u+t*G;this.n32=z*v+x*q+r*p+t*O;this.n33=z*f+x*i+r*D+t*w;this.n34=z*l+x*j+r*y+t*P;this.n41=H*K+F*g+L*u+J*G; +this.n42=H*v+F*q+L*p+J*O;this.n43=H*f+F*i+L*D+J*w;this.n44=H*l+F*j+L*y+J*P;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,h=this.n14,n=this.n21,o=this.n22,k=this.n23,m=this.n24,c=this.n31,z=this.n32,x=this.n33,r=this.n34,t=this.n41,H=this.n42,F=this.n43,L=this.n44,J=a.n11,K=a.n21,v=a.n31,f=a.n41,l=a.n12,g=a.n22,q=a.n32,i=a.n42,j=a.n13,u=a.n23,p=a.n33,D=a.n43,y=a.n14,G=a.n24,O=a.n34;a=a.n44;this.n11=b*J+d*K+e*v+h*f;this.n12=b*l+d*g+e*q+h*i;this.n13=b*j+d*u+e*p+h*D;this.n14= +b*y+d*G+e*O+h*a;this.n21=n*J+o*K+k*v+m*f;this.n22=n*l+o*g+k*q+m*i;this.n23=n*j+o*u+k*p+m*D;this.n24=n*y+o*G+k*O+m*a;this.n31=c*J+z*K+x*v+r*f;this.n32=c*l+z*g+x*q+r*i;this.n33=c*j+z*u+x*p+r*D;this.n34=c*y+z*G+x*O+r*a;this.n41=t*J+H*K+F*v+L*f;this.n42=t*l+H*g+F*q+L*i;this.n43=t*j+H*u+F*p+L*D;this.n44=t*y+H*G+F*O+L*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,d,e){var h=b[d];b[d]=b[e]; +b[e]=h}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,d){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=d;return e}; +THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=d;return e};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 d=new THREE.Matrix4,e=Math.cos(b),h=Math.sin(b),n=1-e,o=a.x,k=a.y,m=a.z;d.n11=n*o*o+e;d.n12=n*o*k-h*m;d.n13=n*o*m+h*k;d.n21=n*o*k+h*m;d.n22=n*k*k+e;d.n23=n*k*m-h*o;d.n31=n*o*m-h*k;d.n32=n*k*m+h*o;d.n33=n*m*m+e;return d}; 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 d=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],i=b[6]*b[1]-b[2]*b[5],m=-b[10]*b[4]+b[6]*b[8],n=b[10]*b[0]-b[2]*b[8],k=-b[6]*b[0]+b[2]*b[4],o=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],D=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*m+b[2]*o;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*i;a.m[3]=b*m;a.m[4]=b*n;a.m[5]=b*k;a.m[6]=b*o;a.m[7]=b*c;a.m[8]=b*D;return a}; -THREE.Matrix4.makeFrustum=function(a,b,d,e,i,m){var n,k,o;n=new THREE.Matrix4;k=2*i/(b-a);o=2*i/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(m+i)/(m-i);i=-2*m*i/(m-i);n.n11=k;n.n12=0;n.n13=a;n.n14=0;n.n21=0;n.n22=o;n.n23=d;n.n24=0;n.n31=0;n.n32=0;n.n33=e;n.n34=i;n.n41=0;n.n42=0;n.n43=-1;n.n44=0;return n};THREE.Matrix4.makePerspective=function(a,b,d,e){var i;a=d*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*b,a*b,i,a,d,e)}; -THREE.Matrix4.makeOrtho=function(a,b,d,e,i,m){var n,k,o,c;n=new THREE.Matrix4;k=b-a;o=d-e;c=m-i;a=(b+a)/k;d=(d+e)/o;i=(m+i)/c;n.n11=2/k;n.n12=0;n.n13=0;n.n14=-a;n.n21=0;n.n22=2/o;n.n23=0;n.n24=-d;n.n31=0;n.n32=0;n.n33=-2/c;n.n34=-i;n.n41=0;n.n42=0;n.n43=0;n.n44=1;return n}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],h=b[6]*b[1]-b[2]*b[5],n=-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],m=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],z=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*n+b[2]*m;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*h;a.m[3]=b*n;a.m[4]=b*o;a.m[5]=b*k;a.m[6]=b*m;a.m[7]=b*c;a.m[8]=b*z;return a}; +THREE.Matrix4.makeFrustum=function(a,b,d,e,h,n){var o,k,m;o=new THREE.Matrix4;k=2*h/(b-a);m=2*h/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(n+h)/(n-h);h=-2*n*h/(n-h);o.n11=k;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=m;o.n23=d;o.n24=0;o.n31=0;o.n32=0;o.n33=e;o.n34=h;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,b,d,e){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,d,e)}; +THREE.Matrix4.makeOrtho=function(a,b,d,e,h,n){var o,k,m,c;o=new THREE.Matrix4;k=b-a;m=d-e;c=n-h;a=(b+a)/k;d=(d+e)/m;h=(n+h)/c;o.n11=2/k;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/m;o.n23=0;o.n24=-d;o.n31=0;o.n32=0;o.n33=-2/c;o.n34=-h;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,d,e,i){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];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,d,e,i,m){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];this.material=m instanceof Array?m:[m]};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.Face3=function(a,b,d,e,h){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.material=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; +THREE.Face4=function(a,b,d,e,h,n){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.material=n instanceof Array?n:[n]};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.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x], +d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,h,n,o,k=new THREE.Vector3,m=new THREE.Vector3;e=0;for(h=this.vertices.length;e0){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(D){var B=[];b=0;for(d=D.length;b65535){c[k].counter+=1;o=c[k].hash+"_"+c[k].counter;if(this.geometryChunks[o]==undefined)this.geometryChunks[o]={faces:[],material:n,vertices:0}}this.geometryChunks[o].faces.push(e);this.geometryChunks[o].vertices+=m}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; -THREE.Camera=function(a,b,d,e){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,d,e);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; +vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(z){var x=[];b=0;for(d=z.length;b65535){c[k].counter+=1;m=c[k].hash+"_"+c[k].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],material:o,vertices:0}}this.geometryChunks[m].faces.push(e);this.geometryChunks[m].vertices+=n}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +THREE.Camera=function(a,b,d,e){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,d,e);this.autoUpdateMatrix=true;this.translateX=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);h.cross(h.clone(),this.up);this.position.addSelf(h);this.target.position.addSelf(h)};this.translateZ=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h); +this.position.subSelf(h);this.target.position.subSelf(h)};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,d){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;d&&this.normalizeUVs();this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh; -THREE.Mesh.prototype.normalizeUVs=function(){var a,b,d,e,i;a=0;for(b=this.geometry.uvs.length;acolor: "+ 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(15658734);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= @@ -85,63 +86,63 @@ undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shadi THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16711680);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(16711680);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,d,e,i,m){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=m!==undefined?m: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,d,e,h,n){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=n!==undefined?n: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.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){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(M,u){var f=0,l=1,g=M.z+M.w,q=u.z+u.w,h=-M.z+M.w,j=-u.z+u.w;if(g>=0&&q>=0&&h>=0&&j>=0)return true;else if(g<0&&q<0||h<0&&j<0)return false;else{if(g<0)f=Math.max(f,g/(g-q));else if(q<0)l=Math.min(l,g/(g-q));if(h<0)f=Math.max(f,h/(h-j));else if(j<0)l=Math.min(l,h/(h-j));if(l0&&C.z<1}O=p.geometry.faces;g=0;for(q=O.length;g0&&v.z<1){c=B[D]=B[D]||new THREE.RenderableParticle;c.x=v.x/v.w;c.y=v.y/v.w;c.z=v.z;c.rotation=p.rotation.z;c.scale.x=p.scale.x*Math.abs(c.x-(v.x+u.projectionMatrix.n11)/(v.w+u.projectionMatrix.n14));c.scale.y=p.scale.y*Math.abs(c.y-(v.y+u.projectionMatrix.n22)/(v.w+u.projectionMatrix.n24));c.material=p.material;b.push(c);D++}}}b.sort(function(K,z){return z.z-K.z});return b};this.unprojectVector=function(M,u){var f=new THREE.Matrix4; -f.multiply(THREE.Matrix4.makeInvert(u.matrix),THREE.Matrix4.makeInvert(u.projectionMatrix));f.multiplyVector3(M);return M}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,i,m;this.domElement=document.createElement("div");this.setSize=function(n,k){d=n;e=k;i=d/2;m=e/2};this.render=function(n,k){var o,c,D,B,v,y,G,E;a=b.projectScene(n,k);o=0;for(c=a.length;o0){w.r+=aa.r*W;w.g+=aa.g*W;w.b+=aa.b*W}}else if(W instanceof THREE.PointLight){Y.sub(W.position,V);Y.normalize();W=N.dot(Y)*ca;if(W>0){w.r+=aa.r*W;w.g+=aa.g*W;w.b+=aa.b*W}}}}function Na(r,V,N){if(N.opacity!=0){Da(N.opacity);ya(N.blending);var w,H,W,aa,ca,da;if(N instanceof THREE.ParticleBasicMaterial){if(N.map){aa=N.map;ca=aa.width>>1;da=aa.height>>1;H=V.scale.x*m;W=V.scale.y*n;N=H*ca;w=W*da;X.set(r.x-N, -r.y-w,r.x+N,r.y+w);if(!A.instersects(X))return;k.save();k.translate(r.x,r.y);k.rotate(-V.rotation);k.scale(H,-W);k.translate(-ca,-da);k.drawImage(aa,0,0);k.restore()}k.beginPath();k.moveTo(r.x-10,r.y);k.lineTo(r.x+10,r.y);k.moveTo(r.x,r.y-10);k.lineTo(r.x,r.y+10);k.closePath();k.strokeStyle="rgb(255,255,0)";k.stroke()}else if(N instanceof THREE.ParticleCircleMaterial){if(U){R.r=Z.r+ia.r+ja.r;R.g=Z.g+ia.g+ja.g;R.b=Z.b+ia.b+ja.b;h.r=N.color.r*R.r;h.g=N.color.g*R.g;h.b=N.color.b*R.b;h.updateStyleString()}else h.__styleString= -N.color.__styleString;N=V.scale.x*m;w=V.scale.y*n;X.set(r.x-N,r.y-w,r.x+N,r.y+w);if(A.instersects(X)){H=h.__styleString;if(B!=H)k.fillStyle=B=H;k.save();k.translate(r.x,r.y);k.rotate(-V.rotation);k.scale(N,w);k.beginPath();k.arc(0,0,1,0,La,true);k.closePath();k.fill();k.restore()}}}}function Oa(r,V,N,w){if(w.opacity!=0){Da(w.opacity);ya(w.blending);k.beginPath();k.moveTo(r.positionScreen.x,r.positionScreen.y);k.lineTo(V.positionScreen.x,V.positionScreen.y);k.closePath();if(w instanceof THREE.LineBasicMaterial){h.__styleString= -w.color.__styleString;r=w.linewidth;if(v!=r)k.lineWidth=v=r;r=h.__styleString;if(D!=r)k.strokeStyle=D=r;k.stroke();X.inflate(w.linewidth*2)}}}function Ha(r,V,N,w,H,W){if(H.opacity!=0){Da(H.opacity);ya(H.blending);M=r.positionScreen.x;u=r.positionScreen.y;f=V.positionScreen.x;l=V.positionScreen.y;g=N.positionScreen.x;q=N.positionScreen.y;k.beginPath();k.moveTo(M,u);k.lineTo(f,l);k.lineTo(g,q);k.lineTo(M,u);k.closePath();if(H instanceof THREE.MeshBasicMaterial)if(H.map)H.map.image.loaded&&H.map.mapping instanceof -THREE.UVMapping&&qa(M,u,f,l,g,q,H.map.image,w.uvs[0].u,w.uvs[0].v,w.uvs[1].u,w.uvs[1].v,w.uvs[2].u,w.uvs[2].v);else if(H.env_map){if(H.env_map.image.loaded)if(H.env_map.mapping instanceof THREE.SphericalReflectionMapping){r=wa.matrix;Y.copy(w.vertexNormalsWorld[0]);O=(Y.x*r.n11+Y.y*r.n12+Y.z*r.n13)*0.5+0.5;C=-(Y.x*r.n21+Y.y*r.n22+Y.z*r.n23)*0.5+0.5;Y.copy(w.vertexNormalsWorld[1]);P=(Y.x*r.n11+Y.y*r.n12+Y.z*r.n13)*0.5+0.5;Q=-(Y.x*r.n21+Y.y*r.n22+Y.z*r.n23)*0.5+0.5;Y.copy(w.vertexNormalsWorld[2]);K= -(Y.x*r.n11+Y.y*r.n12+Y.z*r.n13)*0.5+0.5;z=-(Y.x*r.n21+Y.y*r.n22+Y.z*r.n23)*0.5+0.5;qa(M,u,f,l,g,q,H.env_map.image,O,C,P,Q,K,z)}}else H.wireframe?za(H.color.__styleString,H.wireframe_linewidth):Aa(H.color.__styleString);else if(H instanceof THREE.MeshLambertMaterial){if(H.map&&!H.wireframe){H.map.mapping instanceof THREE.UVMapping&&qa(M,u,f,l,g,q,H.map.image,w.uvs[0].u,w.uvs[0].v,w.uvs[1].u,w.uvs[1].v,w.uvs[2].u,w.uvs[2].v);ya(THREE.SubtractiveBlending)}if(U)if(!H.wireframe&&H.shading==THREE.SmoothShading&& -w.vertexNormalsWorld.length==3){j.r=s.r=p.r=Z.r;j.g=s.g=p.g=Z.g;j.b=s.b=p.b=Z.b;xa(W,w.v1.positionWorld,w.vertexNormalsWorld[0],j);xa(W,w.v2.positionWorld,w.vertexNormalsWorld[1],s);xa(W,w.v3.positionWorld,w.vertexNormalsWorld[2],p);F.r=(s.r+p.r)*0.5;F.g=(s.g+p.g)*0.5;F.b=(s.b+p.b)*0.5;t=Ia(j,s,p,F);qa(M,u,f,l,g,q,t,0,0,1,0,0,1)}else{R.r=Z.r;R.g=Z.g;R.b=Z.b;xa(W,w.centroidWorld,w.normalWorld,R);h.r=H.color.r*R.r;h.g=H.color.g*R.g;h.b=H.color.b*R.b;h.updateStyleString();H.wireframe?za(h.__styleString, -H.wireframe_linewidth):Aa(h.__styleString)}else H.wireframe?za(H.color.__styleString,H.wireframe_linewidth):Aa(H.color.__styleString)}else if(H instanceof THREE.MeshDepthMaterial){x=H.__2near;I=H.__farPlusNear;S=H.__farMinusNear;j.r=j.g=j.b=1-x/(I-r.positionScreen.z*S);s.r=s.g=s.b=1-x/(I-V.positionScreen.z*S);p.r=p.g=p.b=1-x/(I-N.positionScreen.z*S);F.r=(s.r+p.r)*0.5;F.g=(s.g+p.g)*0.5;F.b=(s.b+p.b)*0.5;t=Ia(j,s,p,F);qa(M,u,f,l,g,q,t,0,0,1,0,0,1)}else if(H instanceof THREE.MeshNormalMaterial){h.r= -Ea(w.normalWorld.x);h.g=Ea(w.normalWorld.y);h.b=Ea(w.normalWorld.z);h.updateStyleString();H.wireframe?za(h.__styleString,H.wireframe_linewidth):Aa(h.__styleString)}}}function za(r,V){if(D!=r)k.strokeStyle=D=r;if(v!=V)k.lineWidth=v=V;k.stroke();X.inflate(V*2)}function Aa(r){if(B!=r)k.fillStyle=B=r;k.fill()}function qa(r,V,N,w,H,W,aa,ca,da,ra,ha,sa,ta){var ka,ga;ka=aa.width-1;ga=aa.height-1;ca*=ka;da*=ga;ra*=ka;ha*=ga;sa*=ka;ta*=ga;N-=r;w-=V;H-=r;W-=V;ra-=ca;ha-=da;sa-=ca;ta-=da;ga=1/(ra*ta-sa*ha); -ka=(ta*N-ha*H)*ga;ha=(ta*w-ha*W)*ga;N=(ra*H-sa*N)*ga;w=(ra*W-sa*w)*ga;r=r-ka*ca-N*da;V=V-ha*ca-w*da;k.save();k.transform(ka,ha,N,w,r,V);k.clip();k.drawImage(aa,0,0);k.restore()}function Da(r){if(o!=r)k.globalAlpha=o=r}function ya(r){if(c!=r){switch(r){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}c=r}}function Ia(r,V,N,w){ba[0]=G(0,y(255, -~~(r.r*255)));ba[1]=G(0,y(255,~~(r.g*255)));ba[2]=G(0,y(255,~~(r.b*255)));ba[4]=G(0,y(255,~~(V.r*255)));ba[5]=G(0,y(255,~~(V.g*255)));ba[6]=G(0,y(255,~~(V.b*255)));ba[8]=G(0,y(255,~~(N.r*255)));ba[9]=G(0,y(255,~~(N.g*255)));ba[10]=G(0,y(255,~~(N.b*255)));ba[12]=G(0,y(255,~~(w.r*255)));ba[13]=G(0,y(255,~~(w.g*255)));ba[14]=G(0,y(255,~~(w.b*255)));oa.putImageData(Ca,0,0);va.drawImage(na,0,0);return pa}function Ea(r){return r<0?y((1+r)*0.5,0.5):0.5+y(r*0.5,0.5)}function Fa(r,V){var N=V.x-r.x,w=V.y-r.y, -H=1/Math.sqrt(N*N+w*w);N*=H;w*=H;V.x+=N;V.y+=w;r.x-=N;r.y-=w}var Ba,Ja,$,ea,ma,Ga,Ka,ua;k.setTransform(1,0,0,-1,m,n);this.autoClear&&this.clear();a=b.projectScene(fa,wa);k.fillStyle="rgba(0, 255, 255, 0.5)";k.fillRect(A.getX(),A.getY(),A.getWidth(),A.getHeight());(U=fa.lights.length>0)&&Ma(fa);Ba=0;for(Ja=a.length;Ba0){Q.r+=A.color.r*T;Q.g+=A.color.g*T;Q.b+=A.color.b*T}}else if(A instanceof THREE.PointLight){j.sub(A.position,P.centroidWorld);j.normalize();T=P.normalWorld.dot(j)*A.intensity;if(T>0){Q.r+=A.color.r*T;Q.g+=A.color.g*T;Q.b+=A.color.b*T}}}}function b(C,P,Q,K,z,A){x=e(I++);x.setAttribute("d","M "+C.positionScreen.x+ -" "+C.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(z instanceof THREE.MeshBasicMaterial)u.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshLambertMaterial)if(M){f.r=l.r;f.g=l.g;f.b=l.b;a(A,K,f);u.r=z.color.r*f.r;u.g=z.color.g*f.g;u.b=z.color.b*f.b;u.updateStyleString()}else u.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshDepthMaterial){h=1-z.__2near/(z.__farPlusNear-K.z*z.__farMinusNear); -u.setRGB(h,h,h)}else z instanceof THREE.MeshNormalMaterial&&u.setRGB(i(K.normalWorld.x),i(K.normalWorld.y),i(K.normalWorld.z));z.wireframe?x.setAttribute("style","fill: none; stroke: "+u.__styleString+"; stroke-width: "+z.wireframe_linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.wireframe_linecap+"; stroke-linejoin: "+z.wireframe_linejoin):x.setAttribute("style","fill: "+u.__styleString+"; fill-opacity: "+z.opacity);k.appendChild(x)}function d(C,P,Q,K,z,A,T){x=e(I++);x.setAttribute("d", -"M "+C.positionScreen.x+" "+C.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(A instanceof THREE.MeshBasicMaterial)u.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshLambertMaterial)if(M){f.r=l.r;f.g=l.g;f.b=l.b;a(T,z,f);u.r=A.color.r*f.r;u.g=A.color.g*f.g;u.b=A.color.b*f.b;u.updateStyleString()}else u.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshDepthMaterial){h= -1-A.__2near/(A.__farPlusNear-z.z*A.__farMinusNear);u.setRGB(h,h,h)}else A instanceof THREE.MeshNormalMaterial&&u.setRGB(i(z.normalWorld.x),i(z.normalWorld.y),i(z.normalWorld.z));A.wireframe?x.setAttribute("style","fill: none; stroke: "+u.__styleString+"; stroke-width: "+A.wireframe_linewidth+"; stroke-opacity: "+A.opacity+"; stroke-linecap: "+A.wireframe_linecap+"; stroke-linejoin: "+A.wireframe_linejoin):x.setAttribute("style","fill: "+u.__styleString+"; fill-opacity: "+A.opacity);k.appendChild(x)} -function e(C){if(s[C]==null){s[C]=document.createElementNS("http://www.w3.org/2000/svg","path");O==0&&s[C].setAttribute("shape-rendering","crispEdges");return s[C]}return s[C]}function i(C){return C<0?Math.min((1+C)*0.5,0.5):0.5+Math.min(C*0.5,0.5)}var m=null,n=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,c,D,B,v,y,G,E,J=new THREE.Rectangle,L=new THREE.Rectangle,M=false,u=new THREE.Color(16777215),f=new THREE.Color(16777215),l=new THREE.Color(0),g=new THREE.Color(0), -q=new THREE.Color(0),h,j=new THREE.Vector3,s=[],p=[],F=[],x,I,S,t,O=1;this.domElement=k;this.autoClear=true;this.setQuality=function(C){switch(C){case "high":O=1;break;case "low":O=0}};this.setSize=function(C,P){o=C;c=P;D=o/2;B=c/2;k.setAttribute("viewBox",-D+" "+-B+" "+o+" "+c);k.setAttribute("width",o);k.setAttribute("height",c);J.set(-D,-B,D,B)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(C,P){var Q,K,z,A,T,X,U,R;this.autoClear&&this.clear(); -m=n.projectScene(C,P);t=S=I=0;if(M=C.lights.length>0){U=C.lights;l.setRGB(0,0,0);g.setRGB(0,0,0);q.setRGB(0,0,0);Q=0;for(K=U.length;Q0?"#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(g,n("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+ -f));c.attachShader(g,n("vertex",q+l));c.linkProgram(g);c.getProgramParameter(g,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(g,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");g.uniforms={};g.attributes={};return g}function d(f,l){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, +THREE.Projector=function(){function a(K,v){var f=0,l=1,g=K.z+K.w,q=v.z+v.w,i=-K.z+K.w,j=-v.z+v.w;if(g>=0&&q>=0&&i>=0&&j>=0)return true;else if(g<0&&q<0||i<0&&j<0)return false;else{if(g<0)f=Math.max(f,g/(g-q));else if(q<0)l=Math.min(l,g/(g-q));if(i<0)f=Math.max(f,i/(i-j));else if(j<0)l=Math.min(l,i/(i-j));if(l0&&E.z<1}P=p.geometry.faces;g=0;for(q=P.length;g0&&r.z<1){c=x[z]=x[z]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=p.rotation.z;c.scale.x=p.scale.x*Math.abs(c.x-(r.x+v.projectionMatrix.n11)/(r.w+v.projectionMatrix.n14));c.scale.y=p.scale.y*Math.abs(c.y-(r.y+v.projectionMatrix.n22)/(r.w+v.projectionMatrix.n24));c.material=p.material;b.push(c);z++}}}b.sort(function(M,B){return B.z-M.z});return b};this.unprojectVector=function(K,v){var f=new THREE.Matrix4; +f.multiply(THREE.Matrix4.makeInvert(v.matrix),THREE.Matrix4.makeInvert(v.projectionMatrix));f.multiplyVector3(K);return K}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,h,n;this.domElement=document.createElement("div");this.setSize=function(o,k){d=o;e=k;h=d/2;n=e/2};this.render=function(o,k){var m,c,z,x,r,t,H,F;a=b.projectScene(o,k);m=0;for(c=a.length;m0){A.r+=aa.r*W;A.g+=aa.g*W;A.b+=aa.b*W}}else if(W instanceof THREE.PointLight){X.sub(W.position,V);X.normalize();W=N.dot(X)*ca;if(W>0){A.r+=aa.r*W;A.g+=aa.g*W;A.b+=aa.b*W}}}}function Na(s,V,N){if(N.opacity!=0){Da(N.opacity);ya(N.blending);var A,I,W,aa,ca,da;if(N instanceof THREE.ParticleBasicMaterial){if(N.map){aa=N.map;ca=aa.width>>1;da=aa.height>>1;I=V.scale.x*n;W=V.scale.y*o;N=I*ca;A=W*da;Y.set(s.x-N, +s.y-A,s.x+N,s.y+A);if(!C.instersects(Y))return;k.save();k.translate(s.x,s.y);k.rotate(-V.rotation);k.scale(I,-W);k.translate(-ca,-da);k.drawImage(aa,0,0);k.restore()}k.beginPath();k.moveTo(s.x-10,s.y);k.lineTo(s.x+10,s.y);k.moveTo(s.x,s.y-10);k.lineTo(s.x,s.y+10);k.closePath();k.strokeStyle="rgb(255,255,0)";k.stroke()}else if(N instanceof THREE.ParticleCircleMaterial){if(U){S.r=Z.r+ia.r+ja.r;S.g=Z.g+ia.g+ja.g;S.b=Z.b+ia.b+ja.b;i.r=N.color.r*S.r;i.g=N.color.g*S.g;i.b=N.color.b*S.b;i.updateStyleString()}else i.__styleString= +N.color.__styleString;N=V.scale.x*n;A=V.scale.y*o;Y.set(s.x-N,s.y-A,s.x+N,s.y+A);if(C.instersects(Y)){I=i.__styleString;if(x!=I)k.fillStyle=x=I;k.save();k.translate(s.x,s.y);k.rotate(-V.rotation);k.scale(N,A);k.beginPath();k.arc(0,0,1,0,La,true);k.closePath();k.fill();k.restore()}}}}function Oa(s,V,N,A){if(A.opacity!=0){Da(A.opacity);ya(A.blending);k.beginPath();k.moveTo(s.positionScreen.x,s.positionScreen.y);k.lineTo(V.positionScreen.x,V.positionScreen.y);k.closePath();if(A instanceof THREE.LineBasicMaterial){i.__styleString= +A.color.__styleString;s=A.linewidth;if(r!=s)k.lineWidth=r=s;s=i.__styleString;if(z!=s)k.strokeStyle=z=s;k.stroke();Y.inflate(A.linewidth*2)}}}function Ha(s,V,N,A,I,W){if(I.opacity!=0){Da(I.opacity);ya(I.blending);K=s.positionScreen.x;v=s.positionScreen.y;f=V.positionScreen.x;l=V.positionScreen.y;g=N.positionScreen.x;q=N.positionScreen.y;k.beginPath();k.moveTo(K,v);k.lineTo(f,l);k.lineTo(g,q);k.lineTo(K,v);k.closePath();if(I instanceof THREE.MeshBasicMaterial)if(I.map)I.map.image.loaded&&I.map.mapping instanceof +THREE.UVMapping&&qa(K,v,f,l,g,q,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){s=wa.matrix;X.copy(A.vertexNormalsWorld[0]);P=(X.x*s.n11+X.y*s.n12+X.z*s.n13)*0.5+0.5;E=-(X.x*s.n21+X.y*s.n22+X.z*s.n23)*0.5+0.5;X.copy(A.vertexNormalsWorld[1]);Q=(X.x*s.n11+X.y*s.n12+X.z*s.n13)*0.5+0.5;R=-(X.x*s.n21+X.y*s.n22+X.z*s.n23)*0.5+0.5;X.copy(A.vertexNormalsWorld[2]);M= +(X.x*s.n11+X.y*s.n12+X.z*s.n13)*0.5+0.5;B=-(X.x*s.n21+X.y*s.n22+X.z*s.n23)*0.5+0.5;qa(K,v,f,l,g,q,I.env_map.image,P,E,Q,R,M,B)}}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString);else if(I instanceof THREE.MeshLambertMaterial){if(I.map&&!I.wireframe){I.map.mapping instanceof THREE.UVMapping&&qa(K,v,f,l,g,q,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);ya(THREE.SubtractiveBlending)}if(U)if(!I.wireframe&&I.shading==THREE.SmoothShading&& +A.vertexNormalsWorld.length==3){j.r=u.r=p.r=Z.r;j.g=u.g=p.g=Z.g;j.b=u.b=p.b=Z.b;xa(W,A.v1.positionWorld,A.vertexNormalsWorld[0],j);xa(W,A.v2.positionWorld,A.vertexNormalsWorld[1],u);xa(W,A.v3.positionWorld,A.vertexNormalsWorld[2],p);D.r=(u.r+p.r)*0.5;D.g=(u.g+p.g)*0.5;D.b=(u.b+p.b)*0.5;w=Ia(j,u,p,D);qa(K,v,f,l,g,q,w,0,0,1,0,0,1)}else{S.r=Z.r;S.g=Z.g;S.b=Z.b;xa(W,A.centroidWorld,A.normalWorld,S);i.r=I.color.r*S.r;i.g=I.color.g*S.g;i.b=I.color.b*S.b;i.updateStyleString();I.wireframe?za(i.__styleString, +I.wireframe_linewidth):Aa(i.__styleString)}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString)}else if(I instanceof THREE.MeshDepthMaterial){y=I.__2near;G=I.__farPlusNear;O=I.__farMinusNear;j.r=j.g=j.b=1-y/(G-s.positionScreen.z*O);u.r=u.g=u.b=1-y/(G-V.positionScreen.z*O);p.r=p.g=p.b=1-y/(G-N.positionScreen.z*O);D.r=(u.r+p.r)*0.5;D.g=(u.g+p.g)*0.5;D.b=(u.b+p.b)*0.5;w=Ia(j,u,p,D);qa(K,v,f,l,g,q,w,0,0,1,0,0,1)}else if(I instanceof THREE.MeshNormalMaterial){i.r= +Ea(A.normalWorld.x);i.g=Ea(A.normalWorld.y);i.b=Ea(A.normalWorld.z);i.updateStyleString();I.wireframe?za(i.__styleString,I.wireframe_linewidth):Aa(i.__styleString)}}}function za(s,V){if(z!=s)k.strokeStyle=z=s;if(r!=V)k.lineWidth=r=V;k.stroke();Y.inflate(V*2)}function Aa(s){if(x!=s)k.fillStyle=x=s;k.fill()}function qa(s,V,N,A,I,W,aa,ca,da,ra,ha,sa,ta){var ka,ga;ka=aa.width-1;ga=aa.height-1;ca*=ka;da*=ga;ra*=ka;ha*=ga;sa*=ka;ta*=ga;N-=s;A-=V;I-=s;W-=V;ra-=ca;ha-=da;sa-=ca;ta-=da;ga=1/(ra*ta-sa*ha); +ka=(ta*N-ha*I)*ga;ha=(ta*A-ha*W)*ga;N=(ra*I-sa*N)*ga;A=(ra*W-sa*A)*ga;s=s-ka*ca-N*da;V=V-ha*ca-A*da;k.save();k.transform(ka,ha,N,A,s,V);k.clip();k.drawImage(aa,0,0);k.restore()}function Da(s){if(m!=s)k.globalAlpha=m=s}function ya(s){if(c!=s){switch(s){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}c=s}}function Ia(s,V,N,A){ba[0]=H(0,t(255, +~~(s.r*255)));ba[1]=H(0,t(255,~~(s.g*255)));ba[2]=H(0,t(255,~~(s.b*255)));ba[4]=H(0,t(255,~~(V.r*255)));ba[5]=H(0,t(255,~~(V.g*255)));ba[6]=H(0,t(255,~~(V.b*255)));ba[8]=H(0,t(255,~~(N.r*255)));ba[9]=H(0,t(255,~~(N.g*255)));ba[10]=H(0,t(255,~~(N.b*255)));ba[12]=H(0,t(255,~~(A.r*255)));ba[13]=H(0,t(255,~~(A.g*255)));ba[14]=H(0,t(255,~~(A.b*255)));oa.putImageData(Ca,0,0);va.drawImage(na,0,0);return pa}function Ea(s){return s<0?t((1+s)*0.5,0.5):0.5+t(s*0.5,0.5)}function Fa(s,V){var N=V.x-s.x,A=V.y-s.y, +I=1/Math.sqrt(N*N+A*A);N*=I;A*=I;V.x+=N;V.y+=A;s.x-=N;s.y-=A}var Ba,Ja,$,ea,ma,Ga,Ka,ua;k.setTransform(1,0,0,-1,n,o);this.autoClear&&this.clear();a=b.projectScene(fa,wa);k.fillStyle="rgba(0, 255, 255, 0.5)";k.fillRect(C.getX(),C.getY(),C.getWidth(),C.getHeight());(U=fa.lights.length>0)&&Ma(fa);Ba=0;for(Ja=a.length;Ba0){R.r+=C.color.r*T;R.g+=C.color.g*T;R.b+=C.color.b*T}}else if(C instanceof THREE.PointLight){j.sub(C.position,Q.centroidWorld);j.normalize();T=Q.normalWorld.dot(j)*C.intensity;if(T>0){R.r+=C.color.r*T;R.g+=C.color.g*T;R.b+=C.color.b*T}}}}function b(E,Q,R,M,B,C){y=e(G++);y.setAttribute("d","M "+E.positionScreen.x+ +" "+E.positionScreen.y+" L "+Q.positionScreen.x+" "+Q.positionScreen.y+" L "+R.positionScreen.x+","+R.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)v.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(K){f.r=l.r;f.g=l.g;f.b=l.b;a(C,M,f);v.r=B.color.r*f.r;v.g=B.color.g*f.g;v.b=B.color.b*f.b;v.updateStyleString()}else v.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){i=1-B.__2near/(B.__farPlusNear-M.z*B.__farMinusNear); +v.setRGB(i,i,i)}else B instanceof THREE.MeshNormalMaterial&&v.setRGB(h(M.normalWorld.x),h(M.normalWorld.y),h(M.normalWorld.z));B.wireframe?y.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):y.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+B.opacity);k.appendChild(y)}function d(E,Q,R,M,B,C,T){y=e(G++);y.setAttribute("d", +"M "+E.positionScreen.x+" "+E.positionScreen.y+" L "+Q.positionScreen.x+" "+Q.positionScreen.y+" L "+R.positionScreen.x+","+R.positionScreen.y+" L "+M.positionScreen.x+","+M.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)v.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(K){f.r=l.r;f.g=l.g;f.b=l.b;a(T,B,f);v.r=C.color.r*f.r;v.g=C.color.g*f.g;v.b=C.color.b*f.b;v.updateStyleString()}else v.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){i= +1-C.__2near/(C.__farPlusNear-B.z*C.__farMinusNear);v.setRGB(i,i,i)}else C instanceof THREE.MeshNormalMaterial&&v.setRGB(h(B.normalWorld.x),h(B.normalWorld.y),h(B.normalWorld.z));C.wireframe?y.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.wireframe_linecap+"; stroke-linejoin: "+C.wireframe_linejoin):y.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+C.opacity);k.appendChild(y)} +function e(E){if(u[E]==null){u[E]=document.createElementNS("http://www.w3.org/2000/svg","path");P==0&&u[E].setAttribute("shape-rendering","crispEdges");return u[E]}return u[E]}function h(E){return E<0?Math.min((1+E)*0.5,0.5):0.5+Math.min(E*0.5,0.5)}var n=null,o=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,c,z,x,r,t,H,F,L=new THREE.Rectangle,J=new THREE.Rectangle,K=false,v=new THREE.Color(16777215),f=new THREE.Color(16777215),l=new THREE.Color(0),g=new THREE.Color(0), +q=new THREE.Color(0),i,j=new THREE.Vector3,u=[],p=[],D=[],y,G,O,w,P=1;this.domElement=k;this.autoClear=true;this.setQuality=function(E){switch(E){case "high":P=1;break;case "low":P=0}};this.setSize=function(E,Q){m=E;c=Q;z=m/2;x=c/2;k.setAttribute("viewBox",-z+" "+-x+" "+m+" "+c);k.setAttribute("width",m);k.setAttribute("height",c);L.set(-z,-x,z,x)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(E,Q){var R,M,B,C,T,Y,U,S;this.autoClear&&this.clear(); +n=o.projectScene(E,Q);w=O=G=0;if(K=E.lights.length>0){U=E.lights;l.setRGB(0,0,0);g.setRGB(0,0,0);q.setRGB(0,0,0);R=0;for(M=U.length;R0?"#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(g,o("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+ +f));c.attachShader(g,o("vertex",q+l));c.linkProgram(g);c.getProgramParameter(g,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(g,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");g.uniforms={};g.attributes={};return g}function d(f,l){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 g=0;g<6;++g)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,f.image[g]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);f.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+l);c.bindTexture(c.TEXTURE_CUBE_MAP, f.image.__webGLTextureCube)}}function e(f,l){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,k(f.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,k(f.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,k(f.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,k(f.min_filter));c.generateMipmap(c.TEXTURE_2D); -c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+l);c.bindTexture(c.TEXTURE_2D,f.__webGLTexture)}function i(f,l){var g,q,h;g=0;for(q=l.length;g=0&&c.enableVertexAttribArray(f.attributes[h])}}function n(f,l){var g;if(f=="fragment")g=c.createShader(c.FRAGMENT_SHADER);else if(f=="vertex")g=c.createShader(c.VERTEX_SHADER); +c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+l);c.bindTexture(c.TEXTURE_2D,f.__webGLTexture)}function h(f,l){var g,q,i;g=0;for(q=l.length;g=0&&c.enableVertexAttribArray(f.attributes[i])}}function o(f,l){var g;if(f=="fragment")g=c.createShader(c.FRAGMENT_SHADER);else if(f=="vertex")g=c.createShader(c.VERTEX_SHADER); c.shaderSource(g,l);c.compileShader(g);if(!c.getShaderParameter(g,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(g));return null}return g}function k(f){switch(f){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR; -case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var o=document.createElement("canvas"),c,D,B,v=new THREE.Matrix4,y,G=new Float32Array(16),E=new Float32Array(16),J=new Float32Array(16),L=new Float32Array(9),M=new Float32Array(16);a=function(f,l){if(f){var g,q,h,j=pointLights=maxDirLights=maxPointLights=0;g=0;for(q=f.lights.length;g= 0.0 )":"",f?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",f?"dirDiffuse += mColor * dirDiffuseWeight;":"",f?"dirSpecular += mSpecular * dirSpecularWeight;":"",f?"}":"","vec4 totalLight = mAmbient;",f?"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"); -g=b(q,g);c.useProgram(g);i(g,["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(g,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);l&&i(g,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(g.uniforms.enableMap,0);c.uniform1i(g.uniforms.tMap,0);c.uniform1i(g.uniforms.enableCubeMap,0);c.uniform1i(g.uniforms.tCube,1);c.uniform1i(g.uniforms.mixEnvMap,0);c.uniform1i(g.uniforms.useRefract,0);m(g,["position","normal","uv"]);return g}(a.directional,a.point);this.setSize=function(f,l){o.width=f;o.height=l;c.viewport(0,0,o.width,o.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(f,l){var g,q,h,j,s,p=[], -F=[],x=[];j=[];s=[];c.uniform1i(f.uniforms.enableLighting,l.length);g=0;for(q=l.length;g0){z.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,z.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(Q),c.STATIC_DRAW)}z.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,z.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(S),c.STATIC_DRAW);z.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, -z.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(t),c.STATIC_DRAW);z.__webGLFaceCount=S.length;z.__webGLLineCount=t.length}};this.renderBuffer=function(f,l,g,q){var h,j,s,p,F,x,I,S,t;if(g instanceof THREE.MeshShaderMaterial){if(!g.program){g.program=b(g.fragment_shader,g.vertex_shader);I=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in g.uniforms)I.push(t);i(g.program,I);m(g.program,["position","normal","uv","tangent"])}t= -g.program}else t=B;if(t!=D){c.useProgram(t);D=t}t==B&&this.setupLights(t,l);this.loadCamera(t,f);this.loadMatrices(t);if(g instanceof THREE.MeshShaderMaterial){s=g.wireframe;p=g.wireframe_linewidth;f=t;l=g.uniforms;var O;for(h in l){S=l[h].type;I=l[h].value;O=f.uniforms[h];if(S=="i")c.uniform1i(O,I);else if(S=="f")c.uniform1f(O,I);else if(S=="v3")c.uniform3f(O,I.x,I.y,I.z);else if(S=="c")c.uniform3f(O,I.r,I.g,I.b);else if(S=="t"){c.uniform1i(O,I);if(S=l[h].texture)S.image instanceof Array&&S.image.length== -6?d(S,I):e(S,I)}}}if(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshBasicMaterial){h=g.color;j=g.opacity;s=g.wireframe;p=g.wireframe_linewidth;F=g.map;x=g.env_map;l=g.combine==THREE.MixOperation;f=g.reflectivity;S=g.env_map&&g.env_map.mapping instanceof THREE.CubeRefractionMapping;I=g.refraction_ratio;c.uniform4f(t.uniforms.mColor,h.r*j,h.g*j,h.b*j,j);c.uniform1i(t.uniforms.mixEnvMap,l);c.uniform1f(t.uniforms.mReflectivity,f);c.uniform1i(t.uniforms.useRefract, -S);c.uniform1f(t.uniforms.mRefractionRatio,I)}if(g instanceof THREE.MeshNormalMaterial){j=g.opacity;c.uniform1f(t.uniforms.mOpacity,j);c.uniform1i(t.uniforms.material,4)}else if(g instanceof THREE.MeshDepthMaterial){j=g.opacity;s=g.wireframe;p=g.wireframe_linewidth;c.uniform1f(t.uniforms.mOpacity,j);c.uniform1f(t.uniforms.m2Near,g.__2near);c.uniform1f(t.uniforms.mFarPlusNear,g.__farPlusNear);c.uniform1f(t.uniforms.mFarMinusNear,g.__farMinusNear);c.uniform1i(t.uniforms.material,3)}else if(g instanceof -THREE.MeshPhongMaterial){h=g.ambient;f=g.specular;g=g.shininess;c.uniform4f(t.uniforms.mAmbient,h.r,h.g,h.b,j);c.uniform4f(t.uniforms.mSpecular,f.r,f.g,f.b,j);c.uniform1f(t.uniforms.mShininess,g);c.uniform1i(t.uniforms.material,2)}else if(g instanceof THREE.MeshLambertMaterial)c.uniform1i(t.uniforms.material,1);else if(g instanceof THREE.MeshBasicMaterial)c.uniform1i(t.uniforms.material,0);else if(g instanceof THREE.MeshCubeMaterial){c.uniform1i(t.uniforms.material,5);x=g.env_map}if(F){e(F,0);c.uniform1i(t.uniforms.tMap, -0);c.uniform1i(t.uniforms.enableMap,1)}else c.uniform1i(t.uniforms.enableMap,0);if(x){d(x,1);c.uniform1i(t.uniforms.tCube,1);c.uniform1i(t.uniforms.enableCubeMap,1)}else c.uniform1i(t.uniforms.enableCubeMap,0);j=t.attributes;c.bindBuffer(c.ARRAY_BUFFER,q.__webGLVertexBuffer);c.vertexAttribPointer(j.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,q.__webGLNormalBuffer);c.vertexAttribPointer(j.normal,3,c.FLOAT,false,0,0);if(j.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLTangentBuffer); -c.vertexAttribPointer(j.tangent,4,c.FLOAT,false,0,0)}if(j.uv>=0)if(q.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLUVBuffer);c.enableVertexAttribArray(j.uv);c.vertexAttribPointer(j.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(j.uv);if(s){c.lineWidth(p);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);c.drawElements(c.LINES,q.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,q.__webGLFaceCount,c.UNSIGNED_SHORT, -0)}};this.renderPass=function(f,l,g,q,h,j){var s,p,F,x,I;F=0;for(x=g.material.length;F=0;g--){q=f.__webGLObjects[g].object;l==q&&f.__webGLObjects.splice(g,1)}};this.setupMatrices=function(f,l){f.autoUpdateMatrix&&f.updateMatrix();v.multiply(l.matrix,f.matrix);G.set(l.matrix.flatten());E.set(v.flatten());J.set(l.projectionMatrix.flatten());y=THREE.Matrix4.makeInvert3x3(v).transpose();L.set(y.m);M.set(f.matrix.flatten())};this.loadMatrices= -function(f){c.uniformMatrix4fv(f.uniforms.viewMatrix,false,G);c.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,E);c.uniformMatrix4fv(f.uniforms.projectionMatrix,false,J);c.uniformMatrix3fv(f.uniforms.normalMatrix,false,L);c.uniformMatrix4fv(f.uniforms.objectMatrix,false,M)};this.loadCamera=function(f,l){c.uniform3f(f.uniforms.cameraPosition,l.position.x,l.position.y,l.position.z)};this.setBlending=function(f){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE); +g=b(q,g);c.useProgram(g);h(g,["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&&h(g,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);l&&h(g,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(g.uniforms.enableMap,0);c.uniform1i(g.uniforms.tMap,0);c.uniform1i(g.uniforms.enableCubeMap,0);c.uniform1i(g.uniforms.tCube,1);c.uniform1i(g.uniforms.mixEnvMap,0);c.uniform1i(g.uniforms.useRefract,0);n(g,["position","normal","uv"]);return g}(a.directional,a.point);this.setSize=function(f,l){m.width=f;m.height=l;c.viewport(0,0,m.width,m.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(f,l){var g,q,i,j,u,p=[], +D=[],y=[];j=[];u=[];c.uniform1i(f.uniforms.enableLighting,l.length);g=0;for(q=l.length;g0){B.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,B.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(R),c.STATIC_DRAW)}B.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,B.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(O),c.STATIC_DRAW);B.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +B.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(w),c.STATIC_DRAW);B.__webGLFaceCount=O.length;B.__webGLLineCount=w.length}};this.renderBuffer=function(f,l,g,q){var i,j,u,p,D,y,G,O,w;if(g instanceof THREE.MeshShaderMaterial){if(!g.program){g.program=b(g.fragment_shader,g.vertex_shader);G=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(w in g.uniforms)G.push(w);h(g.program,G);n(g.program,["position","normal","uv","tangent"])}w= +g.program}else w=x;if(w!=z){c.useProgram(w);z=w}w==x&&this.setupLights(w,l);this.loadCamera(w,f);this.loadMatrices(w);if(g instanceof THREE.MeshShaderMaterial){u=g.wireframe;p=g.wireframe_linewidth;f=w;l=g.uniforms;var P;for(i in l){O=l[i].type;G=l[i].value;P=f.uniforms[i];if(O=="i")c.uniform1i(P,G);else if(O=="f")c.uniform1f(P,G);else if(O=="v3")c.uniform3f(P,G.x,G.y,G.z);else if(O=="c")c.uniform3f(P,G.r,G.g,G.b);else if(O=="t"){c.uniform1i(P,G);if(O=l[i].texture)O.image instanceof Array&&O.image.length== +6?d(O,G):e(O,G)}}}if(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshBasicMaterial){i=g.color;j=g.opacity;u=g.wireframe;p=g.wireframe_linewidth;D=g.map;y=g.env_map;l=g.combine==THREE.MixOperation;f=g.reflectivity;O=g.env_map&&g.env_map.mapping instanceof THREE.CubeRefractionMapping;G=g.refraction_ratio;c.uniform4f(w.uniforms.mColor,i.r*j,i.g*j,i.b*j,j);c.uniform1i(w.uniforms.mixEnvMap,l);c.uniform1f(w.uniforms.mReflectivity,f);c.uniform1i(w.uniforms.useRefract, +O);c.uniform1f(w.uniforms.mRefractionRatio,G)}if(g instanceof THREE.MeshNormalMaterial){j=g.opacity;c.uniform1f(w.uniforms.mOpacity,j);c.uniform1i(w.uniforms.material,4)}else if(g instanceof THREE.MeshDepthMaterial){j=g.opacity;u=g.wireframe;p=g.wireframe_linewidth;c.uniform1f(w.uniforms.mOpacity,j);c.uniform1f(w.uniforms.m2Near,g.__2near);c.uniform1f(w.uniforms.mFarPlusNear,g.__farPlusNear);c.uniform1f(w.uniforms.mFarMinusNear,g.__farMinusNear);c.uniform1i(w.uniforms.material,3)}else if(g instanceof +THREE.MeshPhongMaterial){i=g.ambient;f=g.specular;g=g.shininess;c.uniform4f(w.uniforms.mAmbient,i.r,i.g,i.b,j);c.uniform4f(w.uniforms.mSpecular,f.r,f.g,f.b,j);c.uniform1f(w.uniforms.mShininess,g);c.uniform1i(w.uniforms.material,2)}else if(g instanceof THREE.MeshLambertMaterial)c.uniform1i(w.uniforms.material,1);else if(g instanceof THREE.MeshBasicMaterial)c.uniform1i(w.uniforms.material,0);else if(g instanceof THREE.MeshCubeMaterial){c.uniform1i(w.uniforms.material,5);y=g.env_map}if(D){e(D,0);c.uniform1i(w.uniforms.tMap, +0);c.uniform1i(w.uniforms.enableMap,1)}else c.uniform1i(w.uniforms.enableMap,0);if(y){d(y,1);c.uniform1i(w.uniforms.tCube,1);c.uniform1i(w.uniforms.enableCubeMap,1)}else c.uniform1i(w.uniforms.enableCubeMap,0);j=w.attributes;c.bindBuffer(c.ARRAY_BUFFER,q.__webGLVertexBuffer);c.vertexAttribPointer(j.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,q.__webGLNormalBuffer);c.vertexAttribPointer(j.normal,3,c.FLOAT,false,0,0);if(j.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLTangentBuffer); +c.vertexAttribPointer(j.tangent,4,c.FLOAT,false,0,0)}if(j.uv>=0)if(q.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLUVBuffer);c.enableVertexAttribArray(j.uv);c.vertexAttribPointer(j.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(j.uv);if(u){c.lineWidth(p);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);c.drawElements(c.LINES,q.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,q.__webGLFaceCount,c.UNSIGNED_SHORT, +0)}};this.renderPass=function(f,l,g,q,i,j){var u,p,D,y,G;D=0;for(y=g.material.length;D=0;g--){q=f.__webGLObjects[g].object;l==q&&f.__webGLObjects.splice(g,1)}};this.setupMatrices=function(f,l){f.autoUpdateMatrix&&f.updateMatrix();r.multiply(l.matrix,f.matrix);H.set(l.matrix.flatten());F.set(r.flatten());L.set(l.projectionMatrix.flatten());t=THREE.Matrix4.makeInvert3x3(r).transpose();J.set(t.m);K.set(f.matrix.flatten())};this.loadMatrices= +function(f){c.uniformMatrix4fv(f.uniforms.viewMatrix,false,H);c.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,F);c.uniformMatrix4fv(f.uniforms.projectionMatrix,false,L);c.uniformMatrix3fv(f.uniforms.normalMatrix,false,J);c.uniformMatrix4fv(f.uniforms.objectMatrix,false,K)};this.loadCamera=function(f,l){c.uniform3f(f.uniforms.cameraPosition,l.position.x,l.position.y,l.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,l){if(f){!l||l=="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}}; 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 0d73ddb927..8474f31094 100644 --- a/build/ThreeExtras.js +++ b/build/ThreeExtras.js @@ -12,47 +12,48 @@ THREE.Vector4=function(a,b,d,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1} THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;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,d,e=a.objects,f=[];a=0;for(b=e.length;a0&&G>0&&p+G<1}var d,e,f,j,k,g,l,c,t,B, -r,u=a.geometry,v=u.vertices,w=[];d=0;for(e=u.faces.length;d= -0&&Math.min(f,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){g=true;f=e=d=b=0;a()};this.isEmpty=function(){return g};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+f+", width: "+j+", 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,d,e,f,j,k,g,l,c,t,B,r,u,v,w){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=f||0;this.n22=j||1;this.n23=k||0;this.n24=g||0;this.n31=l||0;this.n32=c||0;this.n33=t||1;this.n34=B||0;this.n41=r||0;this.n42=u||0;this.n43=v||0;this.n44=w||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,d,e,f,j,k,g,l,c,t,B,r,u,v,w){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=f;this.n22=j;this.n23=k;this.n24=g;this.n31=l;this.n32=c;this.n33=t;this.n34=B;this.n41=r;this.n42=u;this.n43=v;this.n44=w;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,d){var e=new THREE.Vector3,f=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(d,j).normalize();f.cross(j,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.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,d=a.y,e=a.z,f=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*f;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24* -f;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*b+this.n42*d+this.n43*e+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 d=a.n11,e=a.n12,f=a.n13,j=a.n14,k=a.n21,g=a.n22,l=a.n23,c=a.n24,t=a.n31,B=a.n32, -r=a.n33,u=a.n34,v=a.n41,w=a.n42,G=a.n43,H=a.n44,A=b.n11,n=b.n12,h=b.n13,p=b.n14,i=b.n21,x=b.n22,m=b.n23,o=b.n24,C=b.n31,y=b.n32,L=b.n33,F=b.n34,O=b.n41,V=b.n42,E=b.n43,S=b.n44;this.n11=d*A+e*i+f*C+j*O;this.n12=d*n+e*x+f*y+j*V;this.n13=d*h+e*m+f*L+j*E;this.n14=d*p+e*o+f*F+j*S;this.n21=k*A+g*i+l*C+c*O;this.n22=k*n+g*x+l*y+c*V;this.n23=k*h+g*m+l*L+c*E;this.n24=k*p+g*o+l*F+c*S;this.n31=t*A+B*i+r*C+u*O;this.n32=t*n+B*x+r*y+u*V;this.n33=t*h+B*m+r*L+u*E;this.n34=t*p+B*o+r*F+u*S;this.n41=v*A+w*i+G*C+H*O; -this.n42=v*n+w*x+G*y+H*V;this.n43=v*h+w*m+G*L+H*E;this.n44=v*p+w*o+G*F+H*S;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,f=this.n14,j=this.n21,k=this.n22,g=this.n23,l=this.n24,c=this.n31,t=this.n32,B=this.n33,r=this.n34,u=this.n41,v=this.n42,w=this.n43,G=this.n44;this.n11=b*a.n11+d*a.n21+e*a.n31+f*a.n41;this.n12=b*a.n12+d*a.n22+e*a.n32+f*a.n42;this.n13=b*a.n13+d*a.n23+e*a.n33+f*a.n43;this.n14=b*a.n14+d*a.n24+e*a.n34+f*a.n44;this.n21=j*a.n11+k*a.n21+g*a.n31+l*a.n41;this.n22= -j*a.n12+k*a.n22+g*a.n32+l*a.n42;this.n23=j*a.n13+k*a.n23+g*a.n33+l*a.n43;this.n24=j*a.n14+k*a.n24+g*a.n34+l*a.n44;this.n31=c*a.n11+t*a.n21+B*a.n31+r*a.n41;this.n32=c*a.n12+t*a.n22+B*a.n32+r*a.n42;this.n33=c*a.n13+t*a.n23+B*a.n33+r*a.n43;this.n34=c*a.n14+t*a.n24+B*a.n34+r*a.n44;this.n41=u*a.n11+v*a.n21+w*a.n31+G*a.n41;this.n42=u*a.n12+v*a.n22+w*a.n32+G*a.n42;this.n43=u*a.n13+v*a.n23+w*a.n33+G*a.n43;this.n44=u*a.n14+v*a.n24+w*a.n34+G*a.n44;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,d,e){var f=b[d];b[d]=b[e];b[e]=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,d){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=d;return e};THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=d;return e};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 d=new THREE.Matrix4,e=Math.cos(b),f=Math.sin(b),j=1-e,k=a.x,g=a.y,l=a.z;d.n11=j*k*k+e;d.n12=j*k*g-f*l;d.n13=j*k*l+f*g;d.n21=j*k*g+f*l;d.n22=j*g*g+e;d.n23=j*g*l-f*k;d.n31=j*k*l-f*g;d.n32=j*g*l+f*k;d.n33=j*l*l+e;return d}; +THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,f=[];a=0;for(b=e.length;a0&&H>0&&p+H<1}var d,e,f,k,m,g,j,c,t,x, +q,s=a.geometry,v=s.vertices,w=[];d=0;for(e=s.faces.length;dj?e:j;f=f>c? +f:c}a()};this.add3Points=function(j,c,t,x,q,s){if(g){g=false;b=jt?j>q?j:q:t>q?t:q;f=c>x?c>s?c:s:x>s?x:s}else{b=jt?j>q?j>e?j:e:q>e?q:e:t>q?t>e?t:e:q>e?q:e;f=c>x?c>s?c>f?c:f:s>f?s:f:x>s?x>f?x:f:s>f?s:f}a()};this.addRectangle=function(j){if(g){g=false;b=j.getLeft();d=j.getTop();e=j.getRight();f=j.getBottom()}else{b=bj.getRight()?e:j.getRight();f=f>j.getBottom()?f:j.getBottom()}a()};this.inflate=function(j){b-=j;d-=j;e+=j;f+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();d=d>j.getTop()?d:j.getTop();e=e=0&&Math.min(f,j.getBottom())-Math.max(d,j.getTop())>=0};this.empty=function(){g=true;f=e=d=b=0;a()};this.isEmpty=function(){return g};this.toString= +function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+f+", width: "+k+", height: "+m+" )"}};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,d,e,f,k,m,g,j,c,t,x,q,s,v,w){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=f||0;this.n22=k||1;this.n23=m||0;this.n24=g||0;this.n31=j||0;this.n32=c||0;this.n33=t||1;this.n34=x||0;this.n41=q||0;this.n42=s||0;this.n43=v||0;this.n44=w||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,d,e,f,k,m,g,j,c,t,x,q,s,v,w){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=f;this.n22=k;this.n23=m;this.n24=g;this.n31=j;this.n32=c;this.n33=t;this.n34=x;this.n41=q;this.n42=s;this.n43=v;this.n44=w;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,d){var e=new THREE.Vector3,f=new THREE.Vector3,k=new THREE.Vector3;k.sub(a,b).normalize();e.cross(d,k).normalize();f.cross(k,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.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,d=a.y,e=a.z,f=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*f;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24* +f;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*b+this.n42*d+this.n43*e+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 d=a.n11,e=a.n12,f=a.n13,k=a.n14,m=a.n21,g=a.n22,j=a.n23,c=a.n24,t=a.n31,x=a.n32, +q=a.n33,s=a.n34,v=a.n41,w=a.n42,H=a.n43,G=a.n44,A=b.n11,n=b.n12,h=b.n13,p=b.n14,i=b.n21,y=b.n22,l=b.n23,o=b.n24,C=b.n31,z=b.n32,K=b.n33,D=b.n34,O=b.n41,R=b.n42,F=b.n43,T=b.n44;this.n11=d*A+e*i+f*C+k*O;this.n12=d*n+e*y+f*z+k*R;this.n13=d*h+e*l+f*K+k*F;this.n14=d*p+e*o+f*D+k*T;this.n21=m*A+g*i+j*C+c*O;this.n22=m*n+g*y+j*z+c*R;this.n23=m*h+g*l+j*K+c*F;this.n24=m*p+g*o+j*D+c*T;this.n31=t*A+x*i+q*C+s*O;this.n32=t*n+x*y+q*z+s*R;this.n33=t*h+x*l+q*K+s*F;this.n34=t*p+x*o+q*D+s*T;this.n41=v*A+w*i+H*C+G*O; +this.n42=v*n+w*y+H*z+G*R;this.n43=v*h+w*l+H*K+G*F;this.n44=v*p+w*o+H*D+G*T;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,f=this.n14,k=this.n21,m=this.n22,g=this.n23,j=this.n24,c=this.n31,t=this.n32,x=this.n33,q=this.n34,s=this.n41,v=this.n42,w=this.n43,H=this.n44,G=a.n11,A=a.n21,n=a.n31,h=a.n41,p=a.n12,i=a.n22,y=a.n32,l=a.n42,o=a.n13,C=a.n23,z=a.n33,K=a.n43,D=a.n14,O=a.n24,R=a.n34;a=a.n44;this.n11=b*G+d*A+e*n+f*h;this.n12=b*p+d*i+e*y+f*l;this.n13=b*o+d*C+e*z+f*K;this.n14= +b*D+d*O+e*R+f*a;this.n21=k*G+m*A+g*n+j*h;this.n22=k*p+m*i+g*y+j*l;this.n23=k*o+m*C+g*z+j*K;this.n24=k*D+m*O+g*R+j*a;this.n31=c*G+t*A+x*n+q*h;this.n32=c*p+t*i+x*y+q*l;this.n33=c*o+t*C+x*z+q*K;this.n34=c*D+t*O+x*R+q*a;this.n41=s*G+v*A+w*n+H*h;this.n42=s*p+v*i+w*y+H*l;this.n43=s*o+v*C+w*z+H*K;this.n44=s*D+v*O+w*R+H*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,d,e){var f=b[d];b[d]=b[e]; +b[e]=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,d){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=d;return e}; +THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=d;return e};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 d=new THREE.Matrix4,e=Math.cos(b),f=Math.sin(b),k=1-e,m=a.x,g=a.y,j=a.z;d.n11=k*m*m+e;d.n12=k*m*g-f*j;d.n13=k*m*j+f*g;d.n21=k*m*g+f*j;d.n22=k*g*g+e;d.n23=k*g*j-f*m;d.n31=k*m*j-f*g;d.n32=k*g*j+f*m;d.n33=k*j*j+e;return d}; 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 d=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],f=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],k=b[10]*b[0]-b[2]*b[8],g=-b[6]*b[0]+b[2]*b[4],l=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],t=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*j+b[2]*l;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*f;a.m[3]=b*j;a.m[4]=b*k;a.m[5]=b*g;a.m[6]=b*l;a.m[7]=b*c;a.m[8]=b*t;return a}; -THREE.Matrix4.makeFrustum=function(a,b,d,e,f,j){var k,g,l;k=new THREE.Matrix4;g=2*f/(b-a);l=2*f/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(j+f)/(j-f);f=-2*j*f/(j-f);k.n11=g;k.n12=0;k.n13=a;k.n14=0;k.n21=0;k.n22=l;k.n23=d;k.n24=0;k.n31=0;k.n32=0;k.n33=e;k.n34=f;k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,b,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,d,e)}; -THREE.Matrix4.makeOrtho=function(a,b,d,e,f,j){var k,g,l,c;k=new THREE.Matrix4;g=b-a;l=d-e;c=j-f;a=(b+a)/g;d=(d+e)/l;f=(j+f)/c;k.n11=2/g;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/l;k.n23=0;k.n24=-d;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.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],f=b[6]*b[1]-b[2]*b[5],k=-b[10]*b[4]+b[6]*b[8],m=b[10]*b[0]-b[2]*b[8],g=-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],t=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*k+b[2]*j;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*f;a.m[3]=b*k;a.m[4]=b*m;a.m[5]=b*g;a.m[6]=b*j;a.m[7]=b*c;a.m[8]=b*t;return a}; +THREE.Matrix4.makeFrustum=function(a,b,d,e,f,k){var m,g,j;m=new THREE.Matrix4;g=2*f/(b-a);j=2*f/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(k+f)/(k-f);f=-2*k*f/(k-f);m.n11=g;m.n12=0;m.n13=a;m.n14=0;m.n21=0;m.n22=j;m.n23=d;m.n24=0;m.n31=0;m.n32=0;m.n33=e;m.n34=f;m.n41=0;m.n42=0;m.n43=-1;m.n44=0;return m};THREE.Matrix4.makePerspective=function(a,b,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,d,e)}; +THREE.Matrix4.makeOrtho=function(a,b,d,e,f,k){var m,g,j,c;m=new THREE.Matrix4;g=b-a;j=d-e;c=k-f;a=(b+a)/g;d=(d+e)/j;f=(k+f)/c;m.n11=2/g;m.n12=0;m.n13=0;m.n14=-a;m.n21=0;m.n22=2/j;m.n23=0;m.n24=-d;m.n31=0;m.n32=0;m.n33=-2/c;m.n34=-f;m.n41=0;m.n42=0;m.n43=0;m.n44=1;return m}; 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,d,e,f){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];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,d,e,f,j){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];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.Face4=function(a,b,d,e,f,k){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];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.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x], +d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,f,k,m,g=new THREE.Vector3,j=new THREE.Vector3;e=0;for(f=this.vertices.length;e0){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(t){var B=[];b=0;for(d=t.length;b65535){c[g].counter+=1;l=c[g].hash+"_"+c[g].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],material:k,vertices:0}}this.geometryChunks[l].faces.push(e);this.geometryChunks[l].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(t){var x=[];b=0;for(d=t.length;b65535){c[g].counter+=1;j=c[g].hash+"_"+c[g].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],material:m,vertices:0}}this.geometryChunks[j].faces.push(e);this.geometryChunks[j].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; THREE.Camera=function(a,b,d,e){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,d,e);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; @@ -85,136 +86,136 @@ undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shadi THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16711680);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(16711680);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,d,e,f,j){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=f!==undefined?f: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,d,e,f,k){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=f!==undefined?f: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.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){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(A,n){var h=0,p=1,i=A.z+A.w,x=n.z+n.w,m=-A.z+A.w,o=-n.z+n.w;if(i>=0&&x>=0&&m>=0&&o>=0)return true;else if(i<0&&x<0||m<0&&o<0)return false;else{if(i<0)h=Math.max(h,i/(i-x));else if(x<0)p=Math.min(p,i/(i-x));if(m<0)h=Math.max(h,m/(m-o));else if(o<0)p=Math.min(p,m/(m-o));if(p0&&N.z<1}S=y.geometry.faces;i=0;for(x=S.length;i0&&r.z<1){c=B[t]=B[t]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=y.rotation.z;c.scale.x=y.scale.x*Math.abs(c.x-(r.x+n.projectionMatrix.n11)/(r.w+n.projectionMatrix.n14));c.scale.y=y.scale.y*Math.abs(c.y-(r.y+n.projectionMatrix.n22)/(r.w+n.projectionMatrix.n24));c.material=y.material;b.push(c);t++}}}b.sort(function(Q,K){return K.z-Q.z});return b};this.unprojectVector=function(A,n){var h=new THREE.Matrix4; +THREE.Projector=function(){function a(A,n){var h=0,p=1,i=A.z+A.w,y=n.z+n.w,l=-A.z+A.w,o=-n.z+n.w;if(i>=0&&y>=0&&l>=0&&o>=0)return true;else if(i<0&&y<0||l<0&&o<0)return false;else{if(i<0)h=Math.max(h,i/(i-y));else if(y<0)p=Math.min(p,i/(i-y));if(l<0)h=Math.max(h,l/(l-o));else if(o<0)p=Math.min(p,l/(l-o));if(p0&&N.z<1}T=z.geometry.faces;i=0;for(y=T.length;i0&&q.z<1){c=x[t]=x[t]||new THREE.RenderableParticle;c.x=q.x/q.w;c.y=q.y/q.w;c.z=q.z;c.rotation=z.rotation.z;c.scale.x=z.scale.x*Math.abs(c.x-(q.x+n.projectionMatrix.n11)/(q.w+n.projectionMatrix.n14));c.scale.y=z.scale.y*Math.abs(c.y-(q.y+n.projectionMatrix.n22)/(q.w+n.projectionMatrix.n24));c.material=z.material;b.push(c);t++}}}b.sort(function(Q,L){return L.z-Q.z});return b};this.unprojectVector=function(A,n){var h=new THREE.Matrix4; h.multiply(THREE.Matrix4.makeInvert(n.matrix),THREE.Matrix4.makeInvert(n.projectionMatrix));h.multiplyVector3(A);return A}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,f,j;this.domElement=document.createElement("div");this.setSize=function(k,g){d=k;e=g;f=d/2;j=e/2};this.render=function(k,g){var l,c,t,B,r,u,v,w;a=b.projectScene(k,g);l=0;for(c=a.length;l0){I.r+=ca.r*Z;I.g+=ca.g*Z;I.b+=ca.b*Z}}else if(Z instanceof THREE.PointLight){$.sub(Z.position,Y);$.normalize();Z=R.dot($)*ea;if(Z>0){I.r+=ca.r*Z;I.g+=ca.g*Z;I.b+=ca.b*Z}}}}function Na(D,Y,R){if(R.opacity!=0){Ea(R.opacity);za(R.blending);var I,P,Z,ca,ea,fa;if(R instanceof THREE.ParticleBasicMaterial){if(R.map){ca=R.map;ea=ca.width>>1;fa=ca.height>>1;P=Y.scale.x*j;Z=Y.scale.y*k;R=P*ea;I=Z*fa;q.set(D.x-R,D.y-I,D.x+R, -D.y+I);if(M.instersects(q)){g.save();g.translate(D.x,D.y);g.rotate(-Y.rotation);g.scale(P,-Z);g.translate(-ea,-fa);g.drawImage(ca,0,0);g.restore()}}}else if(R instanceof THREE.ParticleCircleMaterial){if(s){z.r=J.r+W.r+ba.r;z.g=J.g+W.g+ba.g;z.b=J.b+W.b+ba.b;m.r=R.color.r*z.r;m.g=R.color.g*z.g;m.b=R.color.b*z.b;m.updateStyleString()}else m.__styleString=R.color.__styleString;R=Y.scale.x*j;I=Y.scale.y*k;q.set(D.x-R,D.y-I,D.x+R,D.y+I);if(M.instersects(q)){P=m.__styleString;if(B!=P)g.fillStyle=B=P;g.save(); -g.translate(D.x,D.y);g.rotate(-Y.rotation);g.scale(R,I);g.beginPath();g.arc(0,0,1,0,ga,true);g.closePath();g.fill();g.restore()}}}}function Oa(D,Y,R,I){if(I.opacity!=0){Ea(I.opacity);za(I.blending);g.beginPath();g.moveTo(D.positionScreen.x,D.positionScreen.y);g.lineTo(Y.positionScreen.x,Y.positionScreen.y);g.closePath();if(I instanceof THREE.LineBasicMaterial){m.__styleString=I.color.__styleString;D=I.linewidth;if(r!=D)g.lineWidth=r=D;D=m.__styleString;if(t!=D)g.strokeStyle=t=D;g.stroke();q.inflate(I.linewidth* -2)}}}function Ia(D,Y,R,I,P,Z){if(P.opacity!=0){Ea(P.opacity);za(P.blending);A=D.positionScreen.x;n=D.positionScreen.y;h=Y.positionScreen.x;p=Y.positionScreen.y;i=R.positionScreen.x;x=R.positionScreen.y;g.beginPath();g.moveTo(A,n);g.lineTo(h,p);g.lineTo(i,x);g.lineTo(A,n);g.closePath();if(P instanceof THREE.MeshBasicMaterial)if(P.map)P.map.image.loaded&&P.map.mapping instanceof THREE.UVMapping&&ra(A,n,h,p,i,x,P.map.image,I.uvs[0].u,I.uvs[0].v,I.uvs[1].u,I.uvs[1].v,I.uvs[2].u,I.uvs[2].v);else if(P.env_map){if(P.env_map.image.loaded)if(P.env_map.mapping instanceof -THREE.SphericalReflectionMapping){D=xa.matrix;$.copy(I.vertexNormalsWorld[0]);S=($.x*D.n11+$.y*D.n12+$.z*D.n13)*0.5+0.5;N=-($.x*D.n21+$.y*D.n22+$.z*D.n23)*0.5+0.5;$.copy(I.vertexNormalsWorld[1]);T=($.x*D.n11+$.y*D.n12+$.z*D.n13)*0.5+0.5;U=-($.x*D.n21+$.y*D.n22+$.z*D.n23)*0.5+0.5;$.copy(I.vertexNormalsWorld[2]);Q=($.x*D.n11+$.y*D.n12+$.z*D.n13)*0.5+0.5;K=-($.x*D.n21+$.y*D.n22+$.z*D.n23)*0.5+0.5;ra(A,n,h,p,i,x,P.env_map.image,S,N,T,U,Q,K)}}else P.wireframe?Aa(P.color.__styleString,P.wireframe_linewidth): -Ba(P.color.__styleString);else if(P instanceof THREE.MeshLambertMaterial){if(P.map&&!P.wireframe){P.map.mapping instanceof THREE.UVMapping&&ra(A,n,h,p,i,x,P.map.image,I.uvs[0].u,I.uvs[0].v,I.uvs[1].u,I.uvs[1].v,I.uvs[2].u,I.uvs[2].v);za(THREE.SubtractiveBlending)}if(s)if(!P.wireframe&&P.shading==THREE.SmoothShading&&I.vertexNormalsWorld.length==3){o.r=C.r=y.r=J.r;o.g=C.g=y.g=J.g;o.b=C.b=y.b=J.b;ya(Z,I.v1.positionWorld,I.vertexNormalsWorld[0],o);ya(Z,I.v2.positionWorld,I.vertexNormalsWorld[1],C);ya(Z, -I.v3.positionWorld,I.vertexNormalsWorld[2],y);L.r=(C.r+y.r)*0.5;L.g=(C.g+y.g)*0.5;L.b=(C.b+y.b)*0.5;E=Ja(o,C,y,L);ra(A,n,h,p,i,x,E,0,0,1,0,0,1)}else{z.r=J.r;z.g=J.g;z.b=J.b;ya(Z,I.centroidWorld,I.normalWorld,z);m.r=P.color.r*z.r;m.g=P.color.g*z.g;m.b=P.color.b*z.b;m.updateStyleString();P.wireframe?Aa(m.__styleString,P.wireframe_linewidth):Ba(m.__styleString)}else P.wireframe?Aa(P.color.__styleString,P.wireframe_linewidth):Ba(P.color.__styleString)}else if(P instanceof THREE.MeshDepthMaterial){F=P.__2near; -O=P.__farPlusNear;V=P.__farMinusNear;o.r=o.g=o.b=1-F/(O-D.positionScreen.z*V);C.r=C.g=C.b=1-F/(O-Y.positionScreen.z*V);y.r=y.g=y.b=1-F/(O-R.positionScreen.z*V);L.r=(C.r+y.r)*0.5;L.g=(C.g+y.g)*0.5;L.b=(C.b+y.b)*0.5;E=Ja(o,C,y,L);ra(A,n,h,p,i,x,E,0,0,1,0,0,1)}else if(P instanceof THREE.MeshNormalMaterial){m.r=Fa(I.normalWorld.x);m.g=Fa(I.normalWorld.y);m.b=Fa(I.normalWorld.z);m.updateStyleString();P.wireframe?Aa(m.__styleString,P.wireframe_linewidth):Ba(m.__styleString)}}}function Aa(D,Y){if(t!=D)g.strokeStyle= -t=D;if(r!=Y)g.lineWidth=r=Y;g.stroke();q.inflate(Y*2)}function Ba(D){if(B!=D)g.fillStyle=B=D;g.fill()}function ra(D,Y,R,I,P,Z,ca,ea,fa,sa,la,ta,ua){var ma,ja;ma=ca.width-1;ja=ca.height-1;ea*=ma;fa*=ja;sa*=ma;la*=ja;ta*=ma;ua*=ja;R-=D;I-=Y;P-=D;Z-=Y;sa-=ea;la-=fa;ta-=ea;ua-=fa;ja=1/(sa*ua-ta*la);ma=(ua*R-la*P)*ja;la=(ua*I-la*Z)*ja;R=(sa*P-ta*R)*ja;I=(sa*Z-ta*I)*ja;D=D-ma*ea-R*fa;Y=Y-la*ea-I*fa;g.save();g.transform(ma,la,R,I,D,Y);g.clip();g.drawImage(ca,0,0);g.restore()}function Ea(D){if(l!=D)g.globalAlpha= -l=D}function za(D){if(c!=D){switch(D){case THREE.NormalBlending:g.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:g.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:g.globalCompositeOperation="darker"}c=D}}function Ja(D,Y,R,I){da[0]=v(0,u(255,~~(D.r*255)));da[1]=v(0,u(255,~~(D.g*255)));da[2]=v(0,u(255,~~(D.b*255)));da[4]=v(0,u(255,~~(Y.r*255)));da[5]=v(0,u(255,~~(Y.g*255)));da[6]=v(0,u(255,~~(Y.b*255)));da[8]=v(0,u(255,~~(R.r*255)));da[9]=v(0,u(255, -~~(R.g*255)));da[10]=v(0,u(255,~~(R.b*255)));da[12]=v(0,u(255,~~(I.r*255)));da[13]=v(0,u(255,~~(I.g*255)));da[14]=v(0,u(255,~~(I.b*255)));pa.putImageData(Da,0,0);wa.drawImage(ka,0,0);return qa}function Fa(D){return D<0?u((1+D)*0.5,0.5):0.5+u(D*0.5,0.5)}function Ga(D,Y){var R=Y.x-D.x,I=Y.y-D.y,P=1/Math.sqrt(R*R+I*I);R*=P;I*=P;Y.x+=R;Y.y+=I;D.x-=R;D.y-=I}var Ca,Ka,aa,ha,oa,Ha,La,va;g.setTransform(1,0,0,-1,j,k);this.autoClear&&this.clear();a=b.projectScene(ia,xa);(s=ia.lights.length>0)&&Ma(ia);Ca=0; -for(Ka=a.length;Ca0){U.r+=M.color.r*X;U.g+=M.color.g*X;U.b+=M.color.b*X}}else if(M instanceof THREE.PointLight){o.sub(M.position,T.centroidWorld);o.normalize();X=T.normalWorld.dot(o)*M.intensity;if(X>0){U.r+=M.color.r*X;U.g+=M.color.g*X;U.b+=M.color.b*X}}}}function b(N,T,U,Q,K,M){F=e(O++);F.setAttribute("d","M "+N.positionScreen.x+ -" "+N.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(K instanceof THREE.MeshBasicMaterial)n.__styleString=K.color.__styleString;else if(K instanceof THREE.MeshLambertMaterial)if(A){h.r=p.r;h.g=p.g;h.b=p.b;a(M,Q,h);n.r=K.color.r*h.r;n.g=K.color.g*h.g;n.b=K.color.b*h.b;n.updateStyleString()}else n.__styleString=K.color.__styleString;else if(K instanceof THREE.MeshDepthMaterial){m=1-K.__2near/(K.__farPlusNear-Q.z*K.__farMinusNear); -n.setRGB(m,m,m)}else K instanceof THREE.MeshNormalMaterial&&n.setRGB(f(Q.normalWorld.x),f(Q.normalWorld.y),f(Q.normalWorld.z));K.wireframe?F.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+K.wireframe_linewidth+"; stroke-opacity: "+K.opacity+"; stroke-linecap: "+K.wireframe_linecap+"; stroke-linejoin: "+K.wireframe_linejoin):F.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+K.opacity);g.appendChild(F)}function d(N,T,U,Q,K,M,X){F=e(O++);F.setAttribute("d", -"M "+N.positionScreen.x+" "+N.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(A){h.r=p.r;h.g=p.g;h.b=p.b;a(X,K,h);n.r=M.color.r*h.r;n.g=M.color.g*h.g;n.b=M.color.b*h.b;n.updateStyleString()}else n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){m= -1-M.__2near/(M.__farPlusNear-K.z*M.__farMinusNear);n.setRGB(m,m,m)}else M instanceof THREE.MeshNormalMaterial&&n.setRGB(f(K.normalWorld.x),f(K.normalWorld.y),f(K.normalWorld.z));M.wireframe?F.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+M.wireframe_linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframe_linecap+"; stroke-linejoin: "+M.wireframe_linejoin):F.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+M.opacity);g.appendChild(F)} -function e(N){if(C[N]==null){C[N]=document.createElementNS("http://www.w3.org/2000/svg","path");S==0&&C[N].setAttribute("shape-rendering","crispEdges");return C[N]}return C[N]}function f(N){return N<0?Math.min((1+N)*0.5,0.5):0.5+Math.min(N*0.5,0.5)}var j=null,k=new THREE.Projector,g=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,c,t,B,r,u,v,w,G=new THREE.Rectangle,H=new THREE.Rectangle,A=false,n=new THREE.Color(16777215),h=new THREE.Color(16777215),p=new THREE.Color(0),i=new THREE.Color(0), -x=new THREE.Color(0),m,o=new THREE.Vector3,C=[],y=[],L=[],F,O,V,E,S=1;this.domElement=g;this.autoClear=true;this.setQuality=function(N){switch(N){case "high":S=1;break;case "low":S=0}};this.setSize=function(N,T){l=N;c=T;t=l/2;B=c/2;g.setAttribute("viewBox",-t+" "+-B+" "+l+" "+c);g.setAttribute("width",l);g.setAttribute("height",c);G.set(-t,-B,t,B)};this.clear=function(){for(;g.childNodes.length>0;)g.removeChild(g.childNodes[0])};this.render=function(N,T){var U,Q,K,M,X,q,s,z;this.autoClear&&this.clear(); -j=k.projectScene(N,T);E=V=O=0;if(A=N.lights.length>0){s=N.lights;p.setRGB(0,0,0);i.setRGB(0,0,0);x.setRGB(0,0,0);U=0;for(Q=s.length;U0?"#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(i,k("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+ -h));c.attachShader(i,k("vertex",x+p));c.linkProgram(i);c.getProgramParameter(i,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(i,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");i.uniforms={};i.attributes={};return i}function d(h,p){if(h.image.length==6){if(!h.image.__webGLTextureCube&&!h.image.__cubeMapInitialized&&h.image.loadCount==6){h.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,h.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP, +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,f,k;this.domElement=document.createElement("div");this.setSize=function(m,g){d=m;e=g;f=d/2;k=e/2};this.render=function(m,g){var j,c,t,x,q,s,v,w;a=b.projectScene(m,g);j=0;for(c=a.length;j0){I.r+=ca.r*Z;I.g+=ca.g*Z;I.b+=ca.b*Z}}else if(Z instanceof THREE.PointLight){$.sub(Z.position,Y);$.normalize();Z=S.dot($)*ea;if(Z>0){I.r+=ca.r*Z;I.g+=ca.g*Z;I.b+=ca.b*Z}}}}function Na(E,Y,S){if(S.opacity!=0){Ea(S.opacity);za(S.blending);var I,P,Z,ca,ea,fa;if(S instanceof THREE.ParticleBasicMaterial){if(S.map){ca=S.map;ea=ca.width>>1;fa=ca.height>>1;P=Y.scale.x*k;Z=Y.scale.y*m;S=P*ea;I=Z*fa;r.set(E.x-S,E.y-I,E.x+S, +E.y+I);if(M.instersects(r)){g.save();g.translate(E.x,E.y);g.rotate(-Y.rotation);g.scale(P,-Z);g.translate(-ea,-fa);g.drawImage(ca,0,0);g.restore()}}}else if(S instanceof THREE.ParticleCircleMaterial){if(u){B.r=J.r+W.r+ba.r;B.g=J.g+W.g+ba.g;B.b=J.b+W.b+ba.b;l.r=S.color.r*B.r;l.g=S.color.g*B.g;l.b=S.color.b*B.b;l.updateStyleString()}else l.__styleString=S.color.__styleString;S=Y.scale.x*k;I=Y.scale.y*m;r.set(E.x-S,E.y-I,E.x+S,E.y+I);if(M.instersects(r)){P=l.__styleString;if(x!=P)g.fillStyle=x=P;g.save(); +g.translate(E.x,E.y);g.rotate(-Y.rotation);g.scale(S,I);g.beginPath();g.arc(0,0,1,0,ga,true);g.closePath();g.fill();g.restore()}}}}function Oa(E,Y,S,I){if(I.opacity!=0){Ea(I.opacity);za(I.blending);g.beginPath();g.moveTo(E.positionScreen.x,E.positionScreen.y);g.lineTo(Y.positionScreen.x,Y.positionScreen.y);g.closePath();if(I instanceof THREE.LineBasicMaterial){l.__styleString=I.color.__styleString;E=I.linewidth;if(q!=E)g.lineWidth=q=E;E=l.__styleString;if(t!=E)g.strokeStyle=t=E;g.stroke();r.inflate(I.linewidth* +2)}}}function Ia(E,Y,S,I,P,Z){if(P.opacity!=0){Ea(P.opacity);za(P.blending);A=E.positionScreen.x;n=E.positionScreen.y;h=Y.positionScreen.x;p=Y.positionScreen.y;i=S.positionScreen.x;y=S.positionScreen.y;g.beginPath();g.moveTo(A,n);g.lineTo(h,p);g.lineTo(i,y);g.lineTo(A,n);g.closePath();if(P instanceof THREE.MeshBasicMaterial)if(P.map)P.map.image.loaded&&P.map.mapping instanceof THREE.UVMapping&&ra(A,n,h,p,i,y,P.map.image,I.uvs[0].u,I.uvs[0].v,I.uvs[1].u,I.uvs[1].v,I.uvs[2].u,I.uvs[2].v);else if(P.env_map){if(P.env_map.image.loaded)if(P.env_map.mapping instanceof +THREE.SphericalReflectionMapping){E=xa.matrix;$.copy(I.vertexNormalsWorld[0]);T=($.x*E.n11+$.y*E.n12+$.z*E.n13)*0.5+0.5;N=-($.x*E.n21+$.y*E.n22+$.z*E.n23)*0.5+0.5;$.copy(I.vertexNormalsWorld[1]);U=($.x*E.n11+$.y*E.n12+$.z*E.n13)*0.5+0.5;V=-($.x*E.n21+$.y*E.n22+$.z*E.n23)*0.5+0.5;$.copy(I.vertexNormalsWorld[2]);Q=($.x*E.n11+$.y*E.n12+$.z*E.n13)*0.5+0.5;L=-($.x*E.n21+$.y*E.n22+$.z*E.n23)*0.5+0.5;ra(A,n,h,p,i,y,P.env_map.image,T,N,U,V,Q,L)}}else P.wireframe?Aa(P.color.__styleString,P.wireframe_linewidth): +Ba(P.color.__styleString);else if(P instanceof THREE.MeshLambertMaterial){if(P.map&&!P.wireframe){P.map.mapping instanceof THREE.UVMapping&&ra(A,n,h,p,i,y,P.map.image,I.uvs[0].u,I.uvs[0].v,I.uvs[1].u,I.uvs[1].v,I.uvs[2].u,I.uvs[2].v);za(THREE.SubtractiveBlending)}if(u)if(!P.wireframe&&P.shading==THREE.SmoothShading&&I.vertexNormalsWorld.length==3){o.r=C.r=z.r=J.r;o.g=C.g=z.g=J.g;o.b=C.b=z.b=J.b;ya(Z,I.v1.positionWorld,I.vertexNormalsWorld[0],o);ya(Z,I.v2.positionWorld,I.vertexNormalsWorld[1],C);ya(Z, +I.v3.positionWorld,I.vertexNormalsWorld[2],z);K.r=(C.r+z.r)*0.5;K.g=(C.g+z.g)*0.5;K.b=(C.b+z.b)*0.5;F=Ja(o,C,z,K);ra(A,n,h,p,i,y,F,0,0,1,0,0,1)}else{B.r=J.r;B.g=J.g;B.b=J.b;ya(Z,I.centroidWorld,I.normalWorld,B);l.r=P.color.r*B.r;l.g=P.color.g*B.g;l.b=P.color.b*B.b;l.updateStyleString();P.wireframe?Aa(l.__styleString,P.wireframe_linewidth):Ba(l.__styleString)}else P.wireframe?Aa(P.color.__styleString,P.wireframe_linewidth):Ba(P.color.__styleString)}else if(P instanceof THREE.MeshDepthMaterial){D=P.__2near; +O=P.__farPlusNear;R=P.__farMinusNear;o.r=o.g=o.b=1-D/(O-E.positionScreen.z*R);C.r=C.g=C.b=1-D/(O-Y.positionScreen.z*R);z.r=z.g=z.b=1-D/(O-S.positionScreen.z*R);K.r=(C.r+z.r)*0.5;K.g=(C.g+z.g)*0.5;K.b=(C.b+z.b)*0.5;F=Ja(o,C,z,K);ra(A,n,h,p,i,y,F,0,0,1,0,0,1)}else if(P instanceof THREE.MeshNormalMaterial){l.r=Fa(I.normalWorld.x);l.g=Fa(I.normalWorld.y);l.b=Fa(I.normalWorld.z);l.updateStyleString();P.wireframe?Aa(l.__styleString,P.wireframe_linewidth):Ba(l.__styleString)}}}function Aa(E,Y){if(t!=E)g.strokeStyle= +t=E;if(q!=Y)g.lineWidth=q=Y;g.stroke();r.inflate(Y*2)}function Ba(E){if(x!=E)g.fillStyle=x=E;g.fill()}function ra(E,Y,S,I,P,Z,ca,ea,fa,sa,la,ta,ua){var ma,ja;ma=ca.width-1;ja=ca.height-1;ea*=ma;fa*=ja;sa*=ma;la*=ja;ta*=ma;ua*=ja;S-=E;I-=Y;P-=E;Z-=Y;sa-=ea;la-=fa;ta-=ea;ua-=fa;ja=1/(sa*ua-ta*la);ma=(ua*S-la*P)*ja;la=(ua*I-la*Z)*ja;S=(sa*P-ta*S)*ja;I=(sa*Z-ta*I)*ja;E=E-ma*ea-S*fa;Y=Y-la*ea-I*fa;g.save();g.transform(ma,la,S,I,E,Y);g.clip();g.drawImage(ca,0,0);g.restore()}function Ea(E){if(j!=E)g.globalAlpha= +j=E}function za(E){if(c!=E){switch(E){case THREE.NormalBlending:g.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:g.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:g.globalCompositeOperation="darker"}c=E}}function Ja(E,Y,S,I){da[0]=v(0,s(255,~~(E.r*255)));da[1]=v(0,s(255,~~(E.g*255)));da[2]=v(0,s(255,~~(E.b*255)));da[4]=v(0,s(255,~~(Y.r*255)));da[5]=v(0,s(255,~~(Y.g*255)));da[6]=v(0,s(255,~~(Y.b*255)));da[8]=v(0,s(255,~~(S.r*255)));da[9]=v(0,s(255, +~~(S.g*255)));da[10]=v(0,s(255,~~(S.b*255)));da[12]=v(0,s(255,~~(I.r*255)));da[13]=v(0,s(255,~~(I.g*255)));da[14]=v(0,s(255,~~(I.b*255)));pa.putImageData(Da,0,0);wa.drawImage(ka,0,0);return qa}function Fa(E){return E<0?s((1+E)*0.5,0.5):0.5+s(E*0.5,0.5)}function Ga(E,Y){var S=Y.x-E.x,I=Y.y-E.y,P=1/Math.sqrt(S*S+I*I);S*=P;I*=P;Y.x+=S;Y.y+=I;E.x-=S;E.y-=I}var Ca,Ka,aa,ha,oa,Ha,La,va;g.setTransform(1,0,0,-1,k,m);this.autoClear&&this.clear();a=b.projectScene(ia,xa);(u=ia.lights.length>0)&&Ma(ia);Ca=0; +for(Ka=a.length;Ca0){V.r+=M.color.r*X;V.g+=M.color.g*X;V.b+=M.color.b*X}}else if(M instanceof THREE.PointLight){o.sub(M.position,U.centroidWorld);o.normalize();X=U.normalWorld.dot(o)*M.intensity;if(X>0){V.r+=M.color.r*X;V.g+=M.color.g*X;V.b+=M.color.b*X}}}}function b(N,U,V,Q,L,M){D=e(O++);D.setAttribute("d","M "+N.positionScreen.x+ +" "+N.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(L instanceof THREE.MeshBasicMaterial)n.__styleString=L.color.__styleString;else if(L instanceof THREE.MeshLambertMaterial)if(A){h.r=p.r;h.g=p.g;h.b=p.b;a(M,Q,h);n.r=L.color.r*h.r;n.g=L.color.g*h.g;n.b=L.color.b*h.b;n.updateStyleString()}else n.__styleString=L.color.__styleString;else if(L instanceof THREE.MeshDepthMaterial){l=1-L.__2near/(L.__farPlusNear-Q.z*L.__farMinusNear); +n.setRGB(l,l,l)}else L instanceof THREE.MeshNormalMaterial&&n.setRGB(f(Q.normalWorld.x),f(Q.normalWorld.y),f(Q.normalWorld.z));L.wireframe?D.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+L.wireframe_linewidth+"; stroke-opacity: "+L.opacity+"; stroke-linecap: "+L.wireframe_linecap+"; stroke-linejoin: "+L.wireframe_linejoin):D.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+L.opacity);g.appendChild(D)}function d(N,U,V,Q,L,M,X){D=e(O++);D.setAttribute("d", +"M "+N.positionScreen.x+" "+N.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(A){h.r=p.r;h.g=p.g;h.b=p.b;a(X,L,h);n.r=M.color.r*h.r;n.g=M.color.g*h.g;n.b=M.color.b*h.b;n.updateStyleString()}else n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){l= +1-M.__2near/(M.__farPlusNear-L.z*M.__farMinusNear);n.setRGB(l,l,l)}else M instanceof THREE.MeshNormalMaterial&&n.setRGB(f(L.normalWorld.x),f(L.normalWorld.y),f(L.normalWorld.z));M.wireframe?D.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+M.wireframe_linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframe_linecap+"; stroke-linejoin: "+M.wireframe_linejoin):D.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+M.opacity);g.appendChild(D)} +function e(N){if(C[N]==null){C[N]=document.createElementNS("http://www.w3.org/2000/svg","path");T==0&&C[N].setAttribute("shape-rendering","crispEdges");return C[N]}return C[N]}function f(N){return N<0?Math.min((1+N)*0.5,0.5):0.5+Math.min(N*0.5,0.5)}var k=null,m=new THREE.Projector,g=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,c,t,x,q,s,v,w,H=new THREE.Rectangle,G=new THREE.Rectangle,A=false,n=new THREE.Color(16777215),h=new THREE.Color(16777215),p=new THREE.Color(0),i=new THREE.Color(0), +y=new THREE.Color(0),l,o=new THREE.Vector3,C=[],z=[],K=[],D,O,R,F,T=1;this.domElement=g;this.autoClear=true;this.setQuality=function(N){switch(N){case "high":T=1;break;case "low":T=0}};this.setSize=function(N,U){j=N;c=U;t=j/2;x=c/2;g.setAttribute("viewBox",-t+" "+-x+" "+j+" "+c);g.setAttribute("width",j);g.setAttribute("height",c);H.set(-t,-x,t,x)};this.clear=function(){for(;g.childNodes.length>0;)g.removeChild(g.childNodes[0])};this.render=function(N,U){var V,Q,L,M,X,r,u,B;this.autoClear&&this.clear(); +k=m.projectScene(N,U);F=R=O=0;if(A=N.lights.length>0){u=N.lights;p.setRGB(0,0,0);i.setRGB(0,0,0);y.setRGB(0,0,0);V=0;for(Q=u.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(i,m("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+ +h));c.attachShader(i,m("vertex",y+p));c.linkProgram(i);c.getProgramParameter(i,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(i,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");i.uniforms={};i.attributes={};return i}function d(h,p){if(h.image.length==6){if(!h.image.__webGLTextureCube&&!h.image.__cubeMapInitialized&&h.image.loadCount==6){h.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,h.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 i=0;i<6;++i)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,h.image[i]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);h.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+p);c.bindTexture(c.TEXTURE_CUBE_MAP, h.image.__webGLTextureCube)}}function e(h,p){if(!h.__webGLTexture&&h.image.loaded){h.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,h.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,h.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,g(h.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,g(h.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,g(h.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,g(h.min_filter));c.generateMipmap(c.TEXTURE_2D); -c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+p);c.bindTexture(c.TEXTURE_2D,h.__webGLTexture)}function f(h,p){var i,x,m;i=0;for(x=p.length;i=0&&c.enableVertexAttribArray(h.attributes[m])}}function k(h,p){var i;if(h=="fragment")i=c.createShader(c.FRAGMENT_SHADER);else if(h=="vertex")i=c.createShader(c.VERTEX_SHADER); +c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+p);c.bindTexture(c.TEXTURE_2D,h.__webGLTexture)}function f(h,p){var i,y,l;i=0;for(y=p.length;i=0&&c.enableVertexAttribArray(h.attributes[l])}}function m(h,p){var i;if(h=="fragment")i=c.createShader(c.FRAGMENT_SHADER);else if(h=="vertex")i=c.createShader(c.VERTEX_SHADER); c.shaderSource(i,p);c.compileShader(i);if(!c.getShaderParameter(i,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(i));return null}return i}function g(h){switch(h){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR; -case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var l=document.createElement("canvas"),c,t,B,r=new THREE.Matrix4,u,v=new Float32Array(16),w=new Float32Array(16),G=new Float32Array(16),H=new Float32Array(9),A=new Float32Array(16);a=function(h,p){if(h){var i,x,m,o=pointLights=maxDirLights=maxPointLights=0;i=0;for(x=h.lights.length;i= 0.0 )": "",p?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",p?"pointDiffuse += mColor * pointDiffuseWeight;":"",p?"pointSpecular += mSpecular * pointSpecularWeight;":"",p?"}":"",h?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",h?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",h?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",h?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",h?"vec3 dirVector = normalize( lDirection.xyz );":"",h?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": "",h?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",h?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",h?"float dirSpecularWeight = 0.0;":"",h?"if ( dirDotNormalHalf >= 0.0 )":"",h?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",h?"dirDiffuse += mColor * dirDiffuseWeight;":"",h?"dirSpecular += mSpecular * dirSpecularWeight;":"",h?"}":"","vec4 totalLight = mAmbient;",h?"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"); -i=b(x,i);c.useProgram(i);f(i,["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"]);h&&f(i,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);p&&f(i,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(i.uniforms.enableMap,0);c.uniform1i(i.uniforms.tMap,0);c.uniform1i(i.uniforms.enableCubeMap,0);c.uniform1i(i.uniforms.tCube,1);c.uniform1i(i.uniforms.mixEnvMap,0);c.uniform1i(i.uniforms.useRefract,0);j(i,["position","normal","uv"]);return i}(a.directional,a.point);this.setSize=function(h,p){l.width=h;l.height=p;c.viewport(0,0,l.width,l.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(h,p){var i,x,m,o,C,y=[], -L=[],F=[];o=[];C=[];c.uniform1i(h.uniforms.enableLighting,p.length);i=0;for(x=p.length;i0){K.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,K.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(U),c.STATIC_DRAW)}K.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,K.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(V),c.STATIC_DRAW);K.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, -K.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(E),c.STATIC_DRAW);K.__webGLFaceCount=V.length;K.__webGLLineCount=E.length}};this.renderBuffer=function(h,p,i,x){var m,o,C,y,L,F,O,V,E;if(i instanceof THREE.MeshShaderMaterial){if(!i.program){i.program=b(i.fragment_shader,i.vertex_shader);O=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(E in i.uniforms)O.push(E);f(i.program,O);j(i.program,["position","normal","uv","tangent"])}E= -i.program}else E=B;if(E!=t){c.useProgram(E);t=E}E==B&&this.setupLights(E,p);this.loadCamera(E,h);this.loadMatrices(E);if(i instanceof THREE.MeshShaderMaterial){C=i.wireframe;y=i.wireframe_linewidth;h=E;p=i.uniforms;var S;for(m in p){V=p[m].type;O=p[m].value;S=h.uniforms[m];if(V=="i")c.uniform1i(S,O);else if(V=="f")c.uniform1f(S,O);else if(V=="v3")c.uniform3f(S,O.x,O.y,O.z);else if(V=="c")c.uniform3f(S,O.r,O.g,O.b);else if(V=="t"){c.uniform1i(S,O);if(V=p[m].texture)V.image instanceof Array&&V.image.length== -6?d(V,O):e(V,O)}}}if(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshBasicMaterial){m=i.color;o=i.opacity;C=i.wireframe;y=i.wireframe_linewidth;L=i.map;F=i.env_map;p=i.combine==THREE.MixOperation;h=i.reflectivity;V=i.env_map&&i.env_map.mapping instanceof THREE.CubeRefractionMapping;O=i.refraction_ratio;c.uniform4f(E.uniforms.mColor,m.r*o,m.g*o,m.b*o,o);c.uniform1i(E.uniforms.mixEnvMap,p);c.uniform1f(E.uniforms.mReflectivity,h);c.uniform1i(E.uniforms.useRefract, -V);c.uniform1f(E.uniforms.mRefractionRatio,O)}if(i instanceof THREE.MeshNormalMaterial){o=i.opacity;c.uniform1f(E.uniforms.mOpacity,o);c.uniform1i(E.uniforms.material,4)}else if(i instanceof THREE.MeshDepthMaterial){o=i.opacity;C=i.wireframe;y=i.wireframe_linewidth;c.uniform1f(E.uniforms.mOpacity,o);c.uniform1f(E.uniforms.m2Near,i.__2near);c.uniform1f(E.uniforms.mFarPlusNear,i.__farPlusNear);c.uniform1f(E.uniforms.mFarMinusNear,i.__farMinusNear);c.uniform1i(E.uniforms.material,3)}else if(i instanceof -THREE.MeshPhongMaterial){m=i.ambient;h=i.specular;i=i.shininess;c.uniform4f(E.uniforms.mAmbient,m.r,m.g,m.b,o);c.uniform4f(E.uniforms.mSpecular,h.r,h.g,h.b,o);c.uniform1f(E.uniforms.mShininess,i);c.uniform1i(E.uniforms.material,2)}else if(i instanceof THREE.MeshLambertMaterial)c.uniform1i(E.uniforms.material,1);else if(i instanceof THREE.MeshBasicMaterial)c.uniform1i(E.uniforms.material,0);else if(i instanceof THREE.MeshCubeMaterial){c.uniform1i(E.uniforms.material,5);F=i.env_map}if(L){e(L,0);c.uniform1i(E.uniforms.tMap, -0);c.uniform1i(E.uniforms.enableMap,1)}else c.uniform1i(E.uniforms.enableMap,0);if(F){d(F,1);c.uniform1i(E.uniforms.tCube,1);c.uniform1i(E.uniforms.enableCubeMap,1)}else c.uniform1i(E.uniforms.enableCubeMap,0);o=E.attributes;c.bindBuffer(c.ARRAY_BUFFER,x.__webGLVertexBuffer);c.vertexAttribPointer(o.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,x.__webGLNormalBuffer);c.vertexAttribPointer(o.normal,3,c.FLOAT,false,0,0);if(o.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,x.__webGLTangentBuffer); -c.vertexAttribPointer(o.tangent,4,c.FLOAT,false,0,0)}if(o.uv>=0)if(x.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,x.__webGLUVBuffer);c.enableVertexAttribArray(o.uv);c.vertexAttribPointer(o.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(o.uv);if(C){c.lineWidth(y);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webGLLineBuffer);c.drawElements(c.LINES,x.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,x.__webGLFaceCount,c.UNSIGNED_SHORT, -0)}};this.renderPass=function(h,p,i,x,m,o){var C,y,L,F,O;L=0;for(F=i.material.length;L=0;i--){x=h.__webGLObjects[i].object;p==x&&h.__webGLObjects.splice(i,1)}};this.setupMatrices=function(h,p){h.autoUpdateMatrix&&h.updateMatrix();r.multiply(p.matrix,h.matrix);v.set(p.matrix.flatten());w.set(r.flatten());G.set(p.projectionMatrix.flatten());u=THREE.Matrix4.makeInvert3x3(r).transpose();H.set(u.m);A.set(h.matrix.flatten())};this.loadMatrices= -function(h){c.uniformMatrix4fv(h.uniforms.viewMatrix,false,v);c.uniformMatrix4fv(h.uniforms.modelViewMatrix,false,w);c.uniformMatrix4fv(h.uniforms.projectionMatrix,false,G);c.uniformMatrix3fv(h.uniforms.normalMatrix,false,H);c.uniformMatrix4fv(h.uniforms.objectMatrix,false,A)};this.loadCamera=function(h,p){c.uniform3f(h.uniforms.cameraPosition,p.position.x,p.position.y,p.position.z)};this.setBlending=function(h){switch(h){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE); +i=b(y,i);c.useProgram(i);f(i,["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"]);h&&f(i,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);p&&f(i,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(i.uniforms.enableMap,0);c.uniform1i(i.uniforms.tMap,0);c.uniform1i(i.uniforms.enableCubeMap,0);c.uniform1i(i.uniforms.tCube,1);c.uniform1i(i.uniforms.mixEnvMap,0);c.uniform1i(i.uniforms.useRefract,0);k(i,["position","normal","uv"]);return i}(a.directional,a.point);this.setSize=function(h,p){j.width=h;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(h,p){var i,y,l,o,C,z=[], +K=[],D=[];o=[];C=[];c.uniform1i(h.uniforms.enableLighting,p.length);i=0;for(y=p.length;i0){L.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,L.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW)}L.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,L.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(R),c.STATIC_DRAW);L.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +L.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(F),c.STATIC_DRAW);L.__webGLFaceCount=R.length;L.__webGLLineCount=F.length}};this.renderBuffer=function(h,p,i,y){var l,o,C,z,K,D,O,R,F;if(i instanceof THREE.MeshShaderMaterial){if(!i.program){i.program=b(i.fragment_shader,i.vertex_shader);O=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(F in i.uniforms)O.push(F);f(i.program,O);k(i.program,["position","normal","uv","tangent"])}F= +i.program}else F=x;if(F!=t){c.useProgram(F);t=F}F==x&&this.setupLights(F,p);this.loadCamera(F,h);this.loadMatrices(F);if(i instanceof THREE.MeshShaderMaterial){C=i.wireframe;z=i.wireframe_linewidth;h=F;p=i.uniforms;var T;for(l in p){R=p[l].type;O=p[l].value;T=h.uniforms[l];if(R=="i")c.uniform1i(T,O);else if(R=="f")c.uniform1f(T,O);else if(R=="v3")c.uniform3f(T,O.x,O.y,O.z);else if(R=="c")c.uniform3f(T,O.r,O.g,O.b);else if(R=="t"){c.uniform1i(T,O);if(R=p[l].texture)R.image instanceof Array&&R.image.length== +6?d(R,O):e(R,O)}}}if(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshBasicMaterial){l=i.color;o=i.opacity;C=i.wireframe;z=i.wireframe_linewidth;K=i.map;D=i.env_map;p=i.combine==THREE.MixOperation;h=i.reflectivity;R=i.env_map&&i.env_map.mapping instanceof THREE.CubeRefractionMapping;O=i.refraction_ratio;c.uniform4f(F.uniforms.mColor,l.r*o,l.g*o,l.b*o,o);c.uniform1i(F.uniforms.mixEnvMap,p);c.uniform1f(F.uniforms.mReflectivity,h);c.uniform1i(F.uniforms.useRefract, +R);c.uniform1f(F.uniforms.mRefractionRatio,O)}if(i instanceof THREE.MeshNormalMaterial){o=i.opacity;c.uniform1f(F.uniforms.mOpacity,o);c.uniform1i(F.uniforms.material,4)}else if(i instanceof THREE.MeshDepthMaterial){o=i.opacity;C=i.wireframe;z=i.wireframe_linewidth;c.uniform1f(F.uniforms.mOpacity,o);c.uniform1f(F.uniforms.m2Near,i.__2near);c.uniform1f(F.uniforms.mFarPlusNear,i.__farPlusNear);c.uniform1f(F.uniforms.mFarMinusNear,i.__farMinusNear);c.uniform1i(F.uniforms.material,3)}else if(i instanceof +THREE.MeshPhongMaterial){l=i.ambient;h=i.specular;i=i.shininess;c.uniform4f(F.uniforms.mAmbient,l.r,l.g,l.b,o);c.uniform4f(F.uniforms.mSpecular,h.r,h.g,h.b,o);c.uniform1f(F.uniforms.mShininess,i);c.uniform1i(F.uniforms.material,2)}else if(i instanceof THREE.MeshLambertMaterial)c.uniform1i(F.uniforms.material,1);else if(i instanceof THREE.MeshBasicMaterial)c.uniform1i(F.uniforms.material,0);else if(i instanceof THREE.MeshCubeMaterial){c.uniform1i(F.uniforms.material,5);D=i.env_map}if(K){e(K,0);c.uniform1i(F.uniforms.tMap, +0);c.uniform1i(F.uniforms.enableMap,1)}else c.uniform1i(F.uniforms.enableMap,0);if(D){d(D,1);c.uniform1i(F.uniforms.tCube,1);c.uniform1i(F.uniforms.enableCubeMap,1)}else c.uniform1i(F.uniforms.enableCubeMap,0);o=F.attributes;c.bindBuffer(c.ARRAY_BUFFER,y.__webGLVertexBuffer);c.vertexAttribPointer(o.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,y.__webGLNormalBuffer);c.vertexAttribPointer(o.normal,3,c.FLOAT,false,0,0);if(o.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,y.__webGLTangentBuffer); +c.vertexAttribPointer(o.tangent,4,c.FLOAT,false,0,0)}if(o.uv>=0)if(y.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,y.__webGLUVBuffer);c.enableVertexAttribArray(o.uv);c.vertexAttribPointer(o.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(o.uv);if(C){c.lineWidth(z);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y.__webGLLineBuffer);c.drawElements(c.LINES,y.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,y.__webGLFaceCount,c.UNSIGNED_SHORT, +0)}};this.renderPass=function(h,p,i,y,l,o){var C,z,K,D,O;K=0;for(D=i.material.length;K=0;i--){y=h.__webGLObjects[i].object;p==y&&h.__webGLObjects.splice(i,1)}};this.setupMatrices=function(h,p){h.autoUpdateMatrix&&h.updateMatrix();q.multiply(p.matrix,h.matrix);v.set(p.matrix.flatten());w.set(q.flatten());H.set(p.projectionMatrix.flatten());s=THREE.Matrix4.makeInvert3x3(q).transpose();G.set(s.m);A.set(h.matrix.flatten())};this.loadMatrices= +function(h){c.uniformMatrix4fv(h.uniforms.viewMatrix,false,v);c.uniformMatrix4fv(h.uniforms.modelViewMatrix,false,w);c.uniformMatrix4fv(h.uniforms.projectionMatrix,false,H);c.uniformMatrix3fv(h.uniforms.normalMatrix,false,G);c.uniformMatrix4fv(h.uniforms.objectMatrix,false,A)};this.loadCamera=function(h,p){c.uniform3f(h.uniforms.cameraPosition,p.position.x,p.position.y,p.position.z)};this.setBlending=function(h){switch(h){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(h,p){if(h){!p||p=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(h=="back")c.cullFace(c.BACK);else h=="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.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 d=b instanceof THREE.Mesh,e=a.vertices.length,f=d?b.geometry:b,j=a.vertices,k=f.vertices,g=a.faces,l=f.faces,c=a.uvs;f=f.uvs;d&&b.updateMatrix();for(var t=0,B=k.length;t= 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}"}}}, -Cube=function(a,b,d,e,f,j,k,g){function l(w,G,H,A,n,h,p,i){var x=e||1,m=f||1,o=x+1,C=m+1;n=n/x;h=h/m;var y=c.vertices.length,L;if(w=="x"&&G=="y"||w=="y"&&G=="x")L="z";else if(w=="x"&&G=="z"||w=="z"&&G=="x")L="y";else if(w=="z"&&G=="y"||w=="y"&&G=="z")L="x";for(iy=0;iy0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(B,g,r)))-1);c.push(t)}b.push(c)}var u,v;a=b.length;for(d=0;d0)for(e=0;e1){B=this.vertices[j].position.clone(); -u=this.vertices[g].position.clone();v=this.vertices[l].position.clone();B.normalize();u.normalize();v.normalize();this.faces.push(new THREE.Face3(j,g,l,[new THREE.Vector3(B.x,B.y,B.z),new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z)]));this.uvs.push([c,r,w])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; +var Sphere=function(a,b,d){THREE.Geometry.call(this);var e,f=Math.PI,k=Math.max(3,b||8),m=Math.max(2,d||6);b=[];for(d=0;d0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,g,q)))-1);c.push(t)}b.push(c)}var s,v;a=b.length;for(d=0;d0)for(e=0;e1){x=this.vertices[k].position.clone(); +s=this.vertices[g].position.clone();v=this.vertices[j].position.clone();x.normalize();s.normalize();v.normalize();this.faces.push(new THREE.Face3(k,g,j,[new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(s.x,s.y,s.z),new THREE.Vector3(v.x,v.y,v.z)]));this.uvs.push([c,q,w])}}}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 d=document.createElement("script");d.type="text/javascript";d.onload=b;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);a.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,b,d)};a.postMessage(e)},loadBinary:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers, -j.data.materials,b,d,f)};a.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};a.postMessage(e)},loadAjaxBuffers:function(a,b,d,e,f){var j=new XMLHttpRequest,k=e+"/"+a,g=0;j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.Loader.prototype.createBinModel(j.responseText,d,e,b):alert("Couldn't load ["+k+"] ["+j.status+"]");else if(j.readyState==3){if(f){if(g==0)g=j.getResponseHeader("Content-Length");f({total:g,loaded:j.responseText.length})}}else if(j.readyState== -2)g=j.getResponseHeader("Content-Length")};j.open("GET",k,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)},createBinModel:function(a,b,d,e){var f=function(j){function k(q,s){var z=t(q,s),J=t(q,s+1),W=t(q,s+2),ba=t(q,s+3),ga=(ba<<1&255|W>>7)-127;z=(W&127)<<16|J<<8|z;if(z==0&&ga==-127)return 0;return(1-2*(ba>>7))*(1+z*Math.pow(2,-23))*Math.pow(2,ga)}function g(q,s){var z=t(q,s),J=t(q,s+1),W=t(q,s+2);return(t(q,s+3)<<24)+(W<< -16)+(J<<8)+z}function l(q,s){var z=t(q,s);return(t(q,s+1)<<8)+z}function c(q,s){var z=t(q,s);return z>127?z-256:z}function t(q,s){return q.charCodeAt(s)&255}function B(q){var s,z,J;s=g(a,q);z=g(a,q+i);J=g(a,q+x);q=l(a,q+m);THREE.Loader.prototype.f3(H,s,z,J,q)}function r(q){var s,z,J,W,ba,ga;s=g(a,q);z=g(a,q+i);J=g(a,q+x);W=l(a,q+m);ba=g(a,q+o);ga=g(a,q+C);q=g(a,q+y);THREE.Loader.prototype.f3n(H,h,s,z,J,W,ba,ga,q)}function u(q){var s,z,J,W;s=g(a,q);z=g(a,q+L);J=g(a,q+F);W=g(a,q+O);q=l(a,q+V);THREE.Loader.prototype.f4(H, -s,z,J,W,q)}function v(q){var s,z,J,W,ba,ga,$,ka;s=g(a,q);z=g(a,q+L);J=g(a,q+F);W=g(a,q+O);ba=l(a,q+V);ga=g(a,q+E);$=g(a,q+S);ka=g(a,q+N);q=g(a,q+T);THREE.Loader.prototype.f4n(H,h,s,z,J,W,ba,ga,$,ka,q)}function w(q){var s,z;s=g(a,q);z=g(a,q+U);q=g(a,q+Q);THREE.Loader.prototype.uv3(H,p[s*2],p[s*2+1],p[z*2],p[z*2+1],p[q*2],p[q*2+1])}function G(q){var s,z,J;s=g(a,q);z=g(a,q+K);J=g(a,q+M);q=g(a,q+X);THREE.Loader.prototype.uv4(H,p[s*2],p[s*2+1],p[z*2],p[z*2+1],p[J*2],p[J*2+1],p[q*2],p[q*2+1])}var H=this, -A=0,n,h=[],p=[],i,x,m,o,C,y,L,F,O,V,E,S,N,T,U,Q,K,M,X;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(H,e,j);n={signature:a.substr(A,8),header_bytes:t(a,A+8),vertex_coordinate_bytes:t(a,A+9),normal_coordinate_bytes:t(a,A+10),uv_coordinate_bytes:t(a,A+11),vertex_index_bytes:t(a,A+12),normal_index_bytes:t(a,A+13),uv_index_bytes:t(a,A+14),material_index_bytes:t(a,A+15),nvertices:g(a,A+16),nnormals:g(a,A+16+4),nuvs:g(a,A+16+8),ntri_flat:g(a,A+16+12),ntri_smooth:g(a,A+16+16),ntri_flat_uv:g(a, -A+16+20),ntri_smooth_uv:g(a,A+16+24),nquad_flat:g(a,A+16+28),nquad_smooth:g(a,A+16+32),nquad_flat_uv:g(a,A+16+36),nquad_smooth_uv:g(a,A+16+40)};A+=n.header_bytes;i=n.vertex_index_bytes;x=n.vertex_index_bytes*2;m=n.vertex_index_bytes*3;o=n.vertex_index_bytes*3+n.material_index_bytes;C=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;y=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;L=n.vertex_index_bytes;F=n.vertex_index_bytes*2;O=n.vertex_index_bytes*3;V=n.vertex_index_bytes* -4;E=n.vertex_index_bytes*4+n.material_index_bytes;S=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;N=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;T=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;U=n.uv_index_bytes;Q=n.uv_index_bytes*2;K=n.uv_index_bytes;M=n.uv_index_bytes*2;X=n.uv_index_bytes*3;A+=function(q){var s,z,J,W=n.vertex_coordinate_bytes*3,ba=q+n.nvertices*W;for(q=q;q>7)-127;B=(W&127)<<16|J<<8|B;if(B==0&&ga==-127)return 0;return(1-2*(ba>>7))*(1+B*Math.pow(2,-23))*Math.pow(2,ga)}function g(r,u){var B=t(r,u),J=t(r,u+1),W=t(r,u+2);return(t(r,u+3)<<24)+(W<< +16)+(J<<8)+B}function j(r,u){var B=t(r,u);return(t(r,u+1)<<8)+B}function c(r,u){var B=t(r,u);return B>127?B-256:B}function t(r,u){return r.charCodeAt(u)&255}function x(r){var u,B,J;u=g(a,r);B=g(a,r+i);J=g(a,r+y);r=j(a,r+l);THREE.Loader.prototype.f3(G,u,B,J,r)}function q(r){var u,B,J,W,ba,ga;u=g(a,r);B=g(a,r+i);J=g(a,r+y);W=j(a,r+l);ba=g(a,r+o);ga=g(a,r+C);r=g(a,r+z);THREE.Loader.prototype.f3n(G,h,u,B,J,W,ba,ga,r)}function s(r){var u,B,J,W;u=g(a,r);B=g(a,r+K);J=g(a,r+D);W=g(a,r+O);r=j(a,r+R);THREE.Loader.prototype.f4(G, +u,B,J,W,r)}function v(r){var u,B,J,W,ba,ga,$,ka;u=g(a,r);B=g(a,r+K);J=g(a,r+D);W=g(a,r+O);ba=j(a,r+R);ga=g(a,r+F);$=g(a,r+T);ka=g(a,r+N);r=g(a,r+U);THREE.Loader.prototype.f4n(G,h,u,B,J,W,ba,ga,$,ka,r)}function w(r){var u,B;u=g(a,r);B=g(a,r+V);r=g(a,r+Q);THREE.Loader.prototype.uv3(G,p[u*2],p[u*2+1],p[B*2],p[B*2+1],p[r*2],p[r*2+1])}function H(r){var u,B,J;u=g(a,r);B=g(a,r+L);J=g(a,r+M);r=g(a,r+X);THREE.Loader.prototype.uv4(G,p[u*2],p[u*2+1],p[B*2],p[B*2+1],p[J*2],p[J*2+1],p[r*2],p[r*2+1])}var G=this, +A=0,n,h=[],p=[],i,y,l,o,C,z,K,D,O,R,F,T,N,U,V,Q,L,M,X;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(G,e,k);n={signature:a.substr(A,8),header_bytes:t(a,A+8),vertex_coordinate_bytes:t(a,A+9),normal_coordinate_bytes:t(a,A+10),uv_coordinate_bytes:t(a,A+11),vertex_index_bytes:t(a,A+12),normal_index_bytes:t(a,A+13),uv_index_bytes:t(a,A+14),material_index_bytes:t(a,A+15),nvertices:g(a,A+16),nnormals:g(a,A+16+4),nuvs:g(a,A+16+8),ntri_flat:g(a,A+16+12),ntri_smooth:g(a,A+16+16),ntri_flat_uv:g(a, +A+16+20),ntri_smooth_uv:g(a,A+16+24),nquad_flat:g(a,A+16+28),nquad_smooth:g(a,A+16+32),nquad_flat_uv:g(a,A+16+36),nquad_smooth_uv:g(a,A+16+40)};A+=n.header_bytes;i=n.vertex_index_bytes;y=n.vertex_index_bytes*2;l=n.vertex_index_bytes*3;o=n.vertex_index_bytes*3+n.material_index_bytes;C=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;z=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;K=n.vertex_index_bytes;D=n.vertex_index_bytes*2;O=n.vertex_index_bytes*3;R=n.vertex_index_bytes* +4;F=n.vertex_index_bytes*4+n.material_index_bytes;T=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;N=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;U=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;V=n.uv_index_bytes;Q=n.uv_index_bytes*2;L=n.uv_index_bytes;M=n.uv_index_bytes*2;X=n.uv_index_bytes*3;A+=function(r){var u,B,J,W=n.vertex_coordinate_bytes*3,ba=r+n.nvertices*W;for(r=r;r