From e46346c9ba424d0a277cd346a4e24c3814b1e416 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Sat, 25 Dec 2010 18:14:10 +0000 Subject: [PATCH] Cleaned up CanvasRenderer/MeshDepthMaterial code. Moved near/far values from MeshDepthMaterial to Camera (CanvasRenderer/WebGLRenderer/WebGLRenderer2). --- build/Three.js | 248 +++++++++++++-------------- build/ThreeDebug.js | 250 +++++++++++++-------------- build/ThreeExtras.js | 260 ++++++++++++++--------------- examples/camera_orthographic.html | 2 +- examples/materials.html | 26 +-- examples/materials_depth.html | 2 +- examples/materials_gl.html | 4 +- src/cameras/Camera.js | 15 +- src/core/Vertex.js | 2 +- src/materials/MeshDepthMaterial.js | 11 -- src/renderers/CanvasRenderer.js | 26 ++- src/renderers/Projector.js | 12 +- src/renderers/WebGLRenderer.js | 4 +- src/renderers/WebGLRenderer2.js | 4 +- 14 files changed, 440 insertions(+), 426 deletions(-) diff --git a/build/Three.js b/build/Three.js index 48c7eae7..1ac63f6a 100755 --- a/build/Three.js +++ b/build/Three.js @@ -12,52 +12,53 @@ THREE.Vector4=function(a,b,f,d){this.x=a||0;this.y=b||0;this.z=f||0;this.w=d||1} THREE.Vector4.prototype={set:function(a,b,f,d){this.x=a;this.y=b;this.z=f;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}}; THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,f,d=a.objects,j=[];a=0;for(b=d.length;a0&&N>0&&O+N<1}var f,d,j,k,q,l,p,y,c,C, -u,t=a.geometry,J=t.vertices,R=[];f=0;for(d=t.faces.length;fp?d:p;j=j>y? -j:y}a()};this.add3Points=function(p,y,c,C,u,t){if(l){l=false;b=pc?p>u?p:u:c>u?c:u;j=y>C?y>t?y:t:C>t?C:t}else{b=pc?p>u?p>d?p:d:u>d?u:d:c>u?c>d?c:d:u>d?u:d;j=y>C?y>t?y>j?y:j:t>j?t:j:C>t?C>j?C:j:t>j?t:j}a()};this.addRectangle=function(p){if(l){l=false;b=p.getLeft();f=p.getTop();d=p.getRight();j=p.getBottom()}else{b=bp.getRight()?d:p.getRight();j=j>p.getBottom()?j:p.getBottom()}a()};this.inflate=function(p){b-=p;f-=p;d+=p;j+=p;a()};this.minSelf=function(p){b=b>p.getLeft()?b:p.getLeft();f=f>p.getTop()?f:p.getTop();d=d=0&&Math.min(j,p.getBottom())-Math.max(f,p.getTop())>=0};this.empty=function(){l=true;j=d=f=b=0;a()};this.isEmpty=function(){return l};this.toString= -function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+f+", bottom: "+j+", width: "+k+", height: "+q+" )"}};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,f,d,j,k,q,l,p,y,c,C,u,t,J,R){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=j||0;this.n22=k||1;this.n23=q||0;this.n24=l||0;this.n31=p||0;this.n32=y||0;this.n33=c||1;this.n34=C||0;this.n41=u||0;this.n42=t||0;this.n43=J||0;this.n44=R||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,f,d,j,k,q,l,p,y,c,C,u,t,J,R){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=j;this.n22=k;this.n23=q;this.n24=l;this.n31=p;this.n32=y;this.n33=c;this.n34=C;this.n41=u;this.n42=t;this.n43=J;this.n44=R;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,f){var d=new THREE.Vector3,j=new THREE.Vector3,k=new THREE.Vector3;k.sub(a,b).normalize();d.cross(f,k).normalize();j.cross(k,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.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,f=a.y,d=a.z,j=1/(this.n41*b+this.n42*f+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*d+this.n14)*j;a.y=(this.n21*b+this.n22*f+this.n23*d+this.n24)*j;a.z=(this.n31*b+this.n32*f+this.n33*d+this.n34)*j;return a},multiplyVector4:function(a){var b=a.x,f=a.y,d=a.z,j=a.w;a.x=this.n11*b+this.n12*f+this.n13*d+this.n14*j;a.y=this.n21*b+this.n22*f+this.n23*d+this.n24* -j;a.z=this.n31*b+this.n32*f+this.n33*d+this.n34*j;a.w=this.n41*b+this.n42*f+this.n43*d+this.n44*j;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 f=a.n11,d=a.n12,j=a.n13,k=a.n14,q=a.n21,l=a.n22,p=a.n23,y=a.n24,c=a.n31,C=a.n32, -u=a.n33,t=a.n34,J=a.n41,R=a.n42,N=a.n43,s=a.n44,T=b.n11,B=b.n12,L=b.n13,O=b.n14,Q=b.n21,e=b.n22,h=b.n23,m=b.n24,i=b.n31,n=b.n32,g=b.n33,o=b.n34,r=b.n41,D=b.n42,M=b.n43,H=b.n44;this.n11=f*T+d*Q+j*i+k*r;this.n12=f*B+d*e+j*n+k*D;this.n13=f*L+d*h+j*g+k*M;this.n14=f*O+d*m+j*o+k*H;this.n21=q*T+l*Q+p*i+y*r;this.n22=q*B+l*e+p*n+y*D;this.n23=q*L+l*h+p*g+y*M;this.n24=q*O+l*m+p*o+y*H;this.n31=c*T+C*Q+u*i+t*r;this.n32=c*B+C*e+u*n+t*D;this.n33=c*L+C*h+u*g+t*M;this.n34=c*O+C*m+u*o+t*H;this.n41=J*T+R*Q+N*i+s*r; -this.n42=J*B+R*e+N*n+s*D;this.n43=J*L+R*h+N*g+s*M;this.n44=J*O+R*m+N*o+s*H;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,j=this.n14,k=this.n21,q=this.n22,l=this.n23,p=this.n24,y=this.n31,c=this.n32,C=this.n33,u=this.n34,t=this.n41,J=this.n42,R=this.n43,N=this.n44,s=a.n11,T=a.n21,B=a.n31,L=a.n41,O=a.n12,Q=a.n22,e=a.n32,h=a.n42,m=a.n13,i=a.n23,n=a.n33,g=a.n43,o=a.n14,r=a.n24,D=a.n34;a=a.n44;this.n11=b*s+f*T+d*B+j*L;this.n12=b*O+f*Q+d*e+j*h;this.n13=b*m+f*i+d*n+j*g;this.n14= -b*o+f*r+d*D+j*a;this.n21=k*s+q*T+l*B+p*L;this.n22=k*O+q*Q+l*e+p*h;this.n23=k*m+q*i+l*n+p*g;this.n24=k*o+q*r+l*D+p*a;this.n31=y*s+c*T+C*B+u*L;this.n32=y*O+c*Q+C*e+u*h;this.n33=y*m+c*i+C*n+u*g;this.n34=y*o+c*r+C*D+u*a;this.n41=t*s+J*T+R*B+N*L;this.n42=t*O+J*Q+R*e+N*h;this.n43=t*m+J*i+R*n+N*g;this.n44=t*o+J*r+R*D+N*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*= +THREE.Ray.prototype={intersectScene:function(a){var b,f,d=a.objects,i=[];a=0;for(b=d.length;a0&&P>0&&Q+P<1}var f,d,i,j,p,l,o,x,c,E, +v,u=a.geometry,I=u.vertices,S=[];f=0;for(d=u.faces.length;fo?d:o;i=i>x? +i:x}a()};this.add3Points=function(o,x,c,E,v,u){if(l){l=false;b=oc?o>v?o:v:c>v?c:v;i=x>E?x>u?x:u:E>u?E:u}else{b=oc?o>v?o>d?o:d:v>d?v:d:c>v?c>d?c:d:v>d?v:d;i=x>E?x>u?x>i?x:i:u>i?u:i:E>u?E>i?E:i:u>i?u:i}a()};this.addRectangle=function(o){if(l){l=false;b=o.getLeft();f=o.getTop();d=o.getRight();i=o.getBottom()}else{b=bo.getRight()?d:o.getRight();i=i>o.getBottom()?i:o.getBottom()}a()};this.inflate=function(o){b-=o;f-=o;d+=o;i+=o;a()};this.minSelf=function(o){b=b>o.getLeft()?b:o.getLeft();f=f>o.getTop()?f:o.getTop();d=d=0&&Math.min(i,o.getBottom())-Math.max(f,o.getTop())>=0};this.empty=function(){l=true;i=d=f=b=0;a()};this.isEmpty=function(){return l};this.toString= +function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+f+", bottom: "+i+", width: "+j+", height: "+p+" )"}};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,f,d,i,j,p,l,o,x,c,E,v,u,I,S){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=i||0;this.n22=j||1;this.n23=p||0;this.n24=l||0;this.n31=o||0;this.n32=x||0;this.n33=c||1;this.n34=E||0;this.n41=v||0;this.n42=u||0;this.n43=I||0;this.n44=S||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,f,d,i,j,p,l,o,x,c,E,v,u,I,S){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=i;this.n22=j;this.n23=p;this.n24=l;this.n31=o;this.n32=x;this.n33=c;this.n34=E;this.n41=v;this.n42=u;this.n43=I;this.n44=S;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,f){var d=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();d.cross(f,j).normalize();i.cross(j,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=i.x;this.n22=i.y;this.n23=i.z;this.n24=-i.dot(a);this.n31=j.x; +this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,d=a.z,i=1/(this.n41*b+this.n42*f+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*d+this.n14)*i;a.y=(this.n21*b+this.n22*f+this.n23*d+this.n24)*i;a.z=(this.n31*b+this.n32*f+this.n33*d+this.n34)*i;return a},multiplyVector4:function(a){var b=a.x,f=a.y,d=a.z,i=a.w;a.x=this.n11*b+this.n12*f+this.n13*d+this.n14*i;a.y=this.n21*b+this.n22*f+this.n23*d+this.n24* +i;a.z=this.n31*b+this.n32*f+this.n33*d+this.n34*i;a.w=this.n41*b+this.n42*f+this.n43*d+this.n44*i;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var f=a.n11,d=a.n12,i=a.n13,j=a.n14,p=a.n21,l=a.n22,o=a.n23,x=a.n24,c=a.n31,E=a.n32, +v=a.n33,u=a.n34,I=a.n41,S=a.n42,P=a.n43,r=a.n44,V=b.n11,C=b.n12,J=b.n13,Q=b.n14,R=b.n21,e=b.n22,g=b.n23,m=b.n24,h=b.n31,n=b.n32,k=b.n33,q=b.n34,s=b.n41,K=b.n42,w=b.n43,T=b.n44;this.n11=f*V+d*R+i*h+j*s;this.n12=f*C+d*e+i*n+j*K;this.n13=f*J+d*g+i*k+j*w;this.n14=f*Q+d*m+i*q+j*T;this.n21=p*V+l*R+o*h+x*s;this.n22=p*C+l*e+o*n+x*K;this.n23=p*J+l*g+o*k+x*w;this.n24=p*Q+l*m+o*q+x*T;this.n31=c*V+E*R+v*h+u*s;this.n32=c*C+E*e+v*n+u*K;this.n33=c*J+E*g+v*k+u*w;this.n34=c*Q+E*m+v*q+u*T;this.n41=I*V+S*R+P*h+r*s; +this.n42=I*C+S*e+P*n+r*K;this.n43=I*J+S*g+P*k+r*w;this.n44=I*Q+S*m+P*q+r*T;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,i=this.n14,j=this.n21,p=this.n22,l=this.n23,o=this.n24,x=this.n31,c=this.n32,E=this.n33,v=this.n34,u=this.n41,I=this.n42,S=this.n43,P=this.n44,r=a.n11,V=a.n21,C=a.n31,J=a.n41,Q=a.n12,R=a.n22,e=a.n32,g=a.n42,m=a.n13,h=a.n23,n=a.n33,k=a.n43,q=a.n14,s=a.n24,K=a.n34;a=a.n44;this.n11=b*r+f*V+d*C+i*J;this.n12=b*Q+f*R+d*e+i*g;this.n13=b*m+f*h+d*n+i*k;this.n14= +b*q+f*s+d*K+i*a;this.n21=j*r+p*V+l*C+o*J;this.n22=j*Q+p*R+l*e+o*g;this.n23=j*m+p*h+l*n+o*k;this.n24=j*q+p*s+l*K+o*a;this.n31=x*r+c*V+E*C+v*J;this.n32=x*Q+c*R+E*e+v*g;this.n33=x*m+c*h+E*n+v*k;this.n34=x*q+c*s+E*K+v*a;this.n41=u*r+I*V+S*C+P*J;this.n42=u*Q+I*R+S*e+P*g;this.n43=u*m+I*h+S*n+P*k;this.n44=u*q+I*s+S*K+P*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,f,d){var j=b[f];b[f]=b[d]; -b[d]=j}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.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,f,d){var i=b[f];b[f]=b[d]; +b[d]=i}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12, this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,f){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=f;return d}; THREE.Matrix4.scaleMatrix=function(a,b,f){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=f;return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; -THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var f=new THREE.Matrix4,d=Math.cos(b),j=Math.sin(b),k=1-d,q=a.x,l=a.y,p=a.z;f.n11=k*q*q+d;f.n12=k*q*l-j*p;f.n13=k*q*p+j*l;f.n21=k*q*l+j*p;f.n22=k*l*l+d;f.n23=k*l*p-j*q;f.n31=k*q*p-j*l;f.n32=k*l*p+j*q;f.n33=k*p*p+d;return f}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var f=new THREE.Matrix4,d=Math.cos(b),i=Math.sin(b),j=1-d,p=a.x,l=a.y,o=a.z;f.n11=j*p*p+d;f.n12=j*p*l-i*o;f.n13=j*p*o+i*l;f.n21=j*p*l+i*o;f.n22=j*l*l+d;f.n23=j*l*o-i*p;f.n31=j*p*o-i*l;f.n32=j*l*o+i*p;f.n33=j*o*o+d;return f}; 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 f=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],j=b[6]*b[1]-b[2]*b[5],k=-b[10]*b[4]+b[6]*b[8],q=b[10]*b[0]-b[2]*b[8],l=-b[6]*b[0]+b[2]*b[4],p=b[9]*b[4]-b[5]*b[8],y=-b[9]*b[0]+b[1]*b[8],c=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*k+b[2]*p;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*d;a.m[2]=b*j;a.m[3]=b*k;a.m[4]=b*q;a.m[5]=b*l;a.m[6]=b*p;a.m[7]=b*y;a.m[8]=b*c;return a}; -THREE.Matrix4.makeFrustum=function(a,b,f,d,j,k){var q,l,p;q=new THREE.Matrix4;l=2*j/(b-a);p=2*j/(d-f);a=(b+a)/(b-a);f=(d+f)/(d-f);d=-(k+j)/(k-j);j=-2*k*j/(k-j);q.n11=l;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=p;q.n23=f;q.n24=0;q.n31=0;q.n32=0;q.n33=d;q.n34=j;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,b,f,d){var j;a=f*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*b,a*b,j,a,f,d)}; -THREE.Matrix4.makeOrtho=function(a,b,f,d,j,k){var q,l,p,y;q=new THREE.Matrix4;l=b-a;p=f-d;y=k-j;a=(b+a)/l;f=(f+d)/p;j=(k+j)/y;q.n11=2/l;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/p;q.n23=0;q.n24=-f;q.n31=0;q.n32=0;q.n33=-2/y;q.n34=-j;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var f=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],i=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],p=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],x=-b[9]*b[0]+b[1]*b[8],c=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*j+b[2]*o;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*d;a.m[2]=b*i;a.m[3]=b*j;a.m[4]=b*p;a.m[5]=b*l;a.m[6]=b*o;a.m[7]=b*x;a.m[8]=b*c;return a}; +THREE.Matrix4.makeFrustum=function(a,b,f,d,i,j){var p,l,o;p=new THREE.Matrix4;l=2*i/(b-a);o=2*i/(d-f);a=(b+a)/(b-a);f=(d+f)/(d-f);d=-(j+i)/(j-i);i=-2*j*i/(j-i);p.n11=l;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=o;p.n23=f;p.n24=0;p.n31=0;p.n32=0;p.n33=d;p.n34=i;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,b,f,d){var i;a=f*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*b,a*b,i,a,f,d)}; +THREE.Matrix4.makeOrtho=function(a,b,f,d,i,j){var p,l,o,x;p=new THREE.Matrix4;l=b-a;o=f-d;x=j-i;a=(b+a)/l;f=(f+d)/o;i=(j+i)/x;p.n11=2/l;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/o;p.n23=0;p.n24=-f;p.n31=0;p.n32=0;p.n33=-2/x;p.n34=-i;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p}; 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,f,d,j){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,b,f,d,j,k){this.a=a;this.b=b;this.c=f;this.d=d;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.materials=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.Face3=function(a,b,f,d,i){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=i instanceof Array?i:[i]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; +THREE.Face4=function(a,b,f,d,i,j){this.a=a;this.b=b;this.c=f;this.d=d;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];this.materials=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; THREE.Geometry.prototype={computeCentroids:function(){var a,b,f;a=0;for(b=this.faces.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x], +f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,f,d,i,j,p,l=new THREE.Vector3,o=new THREE.Vector3;d=0;for(i=this.vertices.length;d0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x], y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,f=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z< -this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,f=this.vertices.length;b65535){p[q].counter+=1;l=p[q].hash+"_"+p[q].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:materials,vertices:0}}this.geometryChunks[l].faces.push(d); -this.geometryChunks[l].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; -THREE.Camera=function(a,b,f,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,f,d);this.autoUpdateMatrix=true;this.translateX=function(j){j=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(j);j.cross(j.clone(),this.up);this.position.addSelf(j);this.target.position.addSelf(j)};this.translateZ=function(j){j=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(j); -this.position.subSelf(j);this.target.position.subSelf(j)};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; +this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,f=this.vertices.length;b65535){o[p].counter+=1;l=o[p].hash+"_"+o[p].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:materials,vertices:0}}this.geometryChunks[l].faces.push(d); +this.geometryChunks[l].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +THREE.Camera=function(a,b,f,d){this.fov=a;this.aspect=b;this.near=f;this.far=d;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=null;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.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix();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.visible=this.autoUpdateMatrix=true}; THREE.Object3D.prototype={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.materials=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.materials=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D; @@ -80,107 +81,106 @@ a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refract undefined)this.wireframe_linejoin=a.wireframe_linejoin}}; THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (
id: "+this.id+"
color: "+this.color+"
ambient: "+this.ambient+"
specular: "+this.specular+"
shininess: "+this.shininess+"
map: "+this.map+"
specular_map: "+this.specular_map+"
env_map: "+this.env_map+"
combine: "+this.combine+"
reflectivity: "+this.reflectivity+"
refraction_ratio: "+this.refraction_ratio+"
opacity: "+this.opacity+"
shading: "+this.shading+"
wireframe: "+ this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
)"}};THREE.MeshPhongMaterialCounter={value:0}; -THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1E3;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){if(a.near!==undefined)this.near=a.near;if(a.far!==undefined)this.far=a.far;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear= -this.far-this.near};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial"}};THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){}; -THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}}; +THREE.MeshDepthMaterial=function(a){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){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial"}}; +THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}}; THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};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){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!== undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}}; THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (
id: "+this.id+"
blending: "+this.blending+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
)"}};THREE.MeshShaderMaterialCounter={value:0}; THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}}; THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}}; THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}}; -THREE.Texture=function(a,b,f,d,j,k){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=j!==undefined?j:THREE.LinearFilter;this.min_filter=k!==undefined?k:THREE.LinearMipMapLinearFilter}; +THREE.Texture=function(a,b,f,d,i,j){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=j!==undefined?j:THREE.LinearMipMapLinearFilter}; THREE.Texture.prototype={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.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}}; THREE.Fog=function(a,b,f){this.color=new THREE.Color(a);this.near=b||1;this.far=f||1E3}; -THREE.Projector=function(){function a(e,h){return h.z-e.z}function b(e,h){var m=0,i=1,n=e.z+e.w,g=h.z+h.w,o=-e.z+e.w,r=-h.z+h.w;if(n>=0&&g>=0&&o>=0&&r>=0)return true;else if(n<0&&g<0||o<0&&r<0)return false;else{if(n<0)m=Math.max(m,n/(n-g));else if(g<0)i=Math.min(i,n/(n-g));if(o<0)m=Math.max(m,o/(o-r));else if(r<0)i=Math.min(i,o/(o-r));if(i0&&r.z<1}F=F.faces;g=0;for(o=F.length;g0&&N.z<1){u=J[t]=J[t]||new THREE.RenderableParticle;u.x=N.x/N.w;u.y=N.y/N.w;u.z=N.z;u.rotation=H.rotation.z;u.scale.x=H.scale.x*Math.abs(u.x-(N.x+h.projectionMatrix.n11)/(N.w+h.projectionMatrix.n14));u.scale.y=H.scale.y* -Math.abs(u.y-(N.y+h.projectionMatrix.n22)/(N.w+h.projectionMatrix.n24));u.materials=H.materials;i.push(u);t++}}}}m&&i.sort(a);return i};this.unprojectVector=function(e,h){var m=new THREE.Matrix4;m.multiply(THREE.Matrix4.makeInvert(h.matrix),THREE.Matrix4.makeInvert(h.projectionMatrix));m.multiplyVector3(e);return e}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,j,k;this.domElement=document.createElement("div");this.setSize=function(q,l){f=q;d=l;j=f/2;k=d/2};this.render=function(q,l){var p,y,c,C,u,t,J,R;a=b.projectScene(q,l);p=0;for(y=a.length;p0){A.r+=$.r*X;A.g+=$.g*X;A.b+=$.b*X}}else if(X instanceof THREE.PointLight){Y.sub(X.position,V);Y.normalize();X=P.dot(Y)*ca;if(X>0){A.r+=$.r*X;A.g+=$.g*X;A.b+=$.b*X}}}}function Ma(v,V,P){if(P.opacity!=0){Ca(P.opacity);xa(P.blending);var A,I,X,$,ca,da;if(P instanceof THREE.ParticleBasicMaterial){if(P.map){$=P.map;ca=$.width>>1;da=$.height>>1;I=V.scale.x*k;X=V.scale.y*q;P=I*ca;A=X*da;w.set(v.x-P,v.y-A,v.x+P,v.y+A);if(U.instersects(w)){l.save(); -l.translate(v.x,v.y);l.rotate(-V.rotation);l.scale(I,-X);l.translate(-ca,-da);l.drawImage($,0,0);l.restore()}}}else if(P instanceof THREE.ParticleCircleMaterial){if(x){K.r=G.r+W.r+ba.r;K.g=G.g+W.g+ba.g;K.b=G.b+W.b+ba.b;Q.r=P.color.r*K.r;Q.g=P.color.g*K.g;Q.b=P.color.b*K.b;Q.updateStyleString()}else Q.__styleString=P.color.__styleString;P=V.scale.x*k;A=V.scale.y*q;w.set(v.x-P,v.y-A,v.x+P,v.y+A);if(U.instersects(w)){I=Q.__styleString;if(C!=I)l.fillStyle=C=I;l.save();l.translate(v.x,v.y);l.rotate(-V.rotation); -l.scale(P,A);l.beginPath();l.arc(0,0,1,0,Ka,true);l.closePath();l.fill();l.restore()}}}}function Na(v,V,P,A){if(A.opacity!=0){Ca(A.opacity);xa(A.blending);l.beginPath();l.moveTo(v.positionScreen.x,v.positionScreen.y);l.lineTo(V.positionScreen.x,V.positionScreen.y);l.closePath();if(A instanceof THREE.LineBasicMaterial){Q.__styleString=A.color.__styleString;v=A.linewidth;if(u!=v)l.lineWidth=u=v;v=Q.__styleString;if(c!=v)l.strokeStyle=c=v;l.stroke();w.inflate(A.linewidth*2)}}}function Ga(v,V,P,A,I,X){if(I.opacity!= -0){Ca(I.opacity);xa(I.blending);N=v.positionScreen.x;s=v.positionScreen.y;T=V.positionScreen.x;B=V.positionScreen.y;L=P.positionScreen.x;O=P.positionScreen.y;l.beginPath();l.moveTo(N,s);l.lineTo(T,B);l.lineTo(L,O);l.lineTo(N,s);l.closePath();if(I instanceof THREE.MeshBasicMaterial)if(I.map)I.map.image.loaded&&I.map.mapping instanceof THREE.UVMapping&&ra(N,s,T,B,L,O,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){v=va.matrix;Y.copy(A.vertexNormalsWorld[0]);D=(Y.x*v.n11+Y.y*v.n12+Y.z*v.n13)*0.5+0.5;M=-(Y.x*v.n21+Y.y*v.n22+Y.z*v.n23)*0.5+0.5;Y.copy(A.vertexNormalsWorld[1]);H=(Y.x*v.n11+Y.y*v.n12+Y.z*v.n13)*0.5+0.5;z=-(Y.x*v.n21+Y.y*v.n22+Y.z*v.n23)*0.5+0.5;Y.copy(A.vertexNormalsWorld[2]);S=(Y.x*v.n11+Y.y*v.n12+Y.z*v.n13)*0.5+0.5;E=-(Y.x*v.n21+Y.y*v.n22+Y.z*v.n23)*0.5+0.5;ra(N,s,T,B,L,O,I.env_map.image,D,M,H,z,S,E)}}else I.wireframe?ya(I.color.__styleString,I.wireframe_linewidth): -za(I.color.__styleString);else if(I instanceof THREE.MeshLambertMaterial){if(I.map&&!I.wireframe){I.map.mapping instanceof THREE.UVMapping&&ra(N,s,T,B,L,O,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);xa(THREE.SubtractiveBlending)}if(x)if(!I.wireframe&&I.shading==THREE.SmoothShading&&A.vertexNormalsWorld.length==3){e.r=h.r=m.r=G.r;e.g=h.g=m.g=G.g;e.b=h.b=m.b=G.b;wa(X,A.v1.positionWorld,A.vertexNormalsWorld[0],e);wa(X,A.v2.positionWorld,A.vertexNormalsWorld[1],h);wa(X, -A.v3.positionWorld,A.vertexNormalsWorld[2],m);i.r=(h.r+m.r)*0.5;i.g=(h.g+m.g)*0.5;i.b=(h.b+m.b)*0.5;r=Ha(e,h,m,i);ra(N,s,T,B,L,O,r,0,0,1,0,0,1)}else{K.r=G.r;K.g=G.g;K.b=G.b;wa(X,A.centroidWorld,A.normalWorld,K);Q.r=I.color.r*K.r;Q.g=I.color.g*K.g;Q.b=I.color.b*K.b;Q.updateStyleString();I.wireframe?ya(Q.__styleString,I.wireframe_linewidth):za(Q.__styleString)}else I.wireframe?ya(I.color.__styleString,I.wireframe_linewidth):za(I.color.__styleString)}else if(I instanceof THREE.MeshDepthMaterial){n=I.__2near; -g=I.__farPlusNear;o=I.__farMinusNear;e.r=e.g=e.b=1-n/(g-v.positionScreen.z*o);h.r=h.g=h.b=1-n/(g-V.positionScreen.z*o);m.r=m.g=m.b=1-n/(g-P.positionScreen.z*o);i.r=(h.r+m.r)*0.5;i.g=(h.g+m.g)*0.5;i.b=(h.b+m.b)*0.5;r=Ha(e,h,m,i);ra(N,s,T,B,L,O,r,0,0,1,0,0,1)}else if(I instanceof THREE.MeshNormalMaterial){Q.r=Da(A.normalWorld.x);Q.g=Da(A.normalWorld.y);Q.b=Da(A.normalWorld.z);Q.updateStyleString();I.wireframe?ya(Q.__styleString,I.wireframe_linewidth):za(Q.__styleString)}}}function ya(v,V){if(c!=v)l.strokeStyle= -c=v;if(u!=V)l.lineWidth=u=V;l.stroke();w.inflate(V*2)}function za(v){if(C!=v)l.fillStyle=C=v;l.fill()}function ra(v,V,P,A,I,X,$,ca,da,ia,fa,ja,sa){var la,ka;la=$.width-1;ka=$.height-1;ca*=la;da*=ka;ia*=la;fa*=ka;ja*=la;sa*=ka;P-=v;A-=V;I-=v;X-=V;ia-=ca;fa-=da;ja-=ca;sa-=da;ka=1/(ia*sa-ja*fa);la=(sa*P-fa*I)*ka;fa=(sa*A-fa*X)*ka;P=(ia*I-ja*P)*ka;A=(ia*X-ja*A)*ka;v=v-la*ca-P*da;V=V-fa*ca-A*da;l.save();l.transform(la,fa,P,A,v,V);l.clip();l.drawImage($,0,0);l.restore()}function Ca(v){if(p!=v)l.globalAlpha= -p=v}function xa(v){if(y!=v){switch(v){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}y=v}}function Ha(v,V,P,A){var I=~~(v.r*255),X=~~(v.g*255);v=~~(v.b*255);var $=~~(V.r*255),ca=~~(V.g*255);V=~~(V.b*255);var da=~~(P.r*255),ia=~~(P.g*255);P=~~(P.b*255);var fa=~~(A.r*255),ja=~~(A.g*255);A=~~(A.b*255);ea[0]=I<0?0:I>255?255:I;ea[1]=X<0?0:X> -255?255:X;ea[2]=v<0?0:v>255?255:v;ea[4]=$<0?0:$>255?255:$;ea[5]=ca<0?0:ca>255?255:ca;ea[6]=V<0?0:V>255?255:V;ea[8]=da<0?0:da>255?255:da;ea[9]=ia<0?0:ia>255?255:ia;ea[10]=P<0?0:P>255?255:P;ea[12]=fa<0?0:fa>255?255:fa;ea[13]=ja<0?0:ja>255?255:ja;ea[14]=A<0?0:A>255?255:A;pa.putImageData(Ba,0,0);ua.drawImage(oa,0,0);return qa}function Da(v){v=(v+1)*0.5;return v<0?0:v>1?1:v}function Ea(v,V){var P=V.x-v.x,A=V.y-v.y,I=1/Math.sqrt(P*P+A*A);P*=I;A*=I;V.x+=P;V.y+=A;v.x-=P;v.y-=A}var Aa,Ia,Z,ga,na,Fa,Ja,ta; -l.setTransform(1,0,0,-1,k,q);this.autoClear&&this.clear();a=b.projectScene(ha,va,this.sortElements);(x=ha.lights.length>0)&&La(ha);Aa=0;for(Ia=a.length;Aa0){E.r+=w.color.r*x;E.g+=w.color.g*x;E.b+=w.color.b*x}}else if(w instanceof THREE.PointLight){m.sub(w.position,S.centroidWorld);m.normalize();x=S.normalWorld.dot(m)*w.intensity;if(x>0){E.r+=w.color.r*x;E.g+=w.color.g*x;E.b+=w.color.b*x}}}}function b(z,S,E,U,F,w){o=d(r++);o.setAttribute("d","M "+z.positionScreen.x+ -" "+z.positionScreen.y+" L "+S.positionScreen.x+" "+S.positionScreen.y+" L "+E.positionScreen.x+","+E.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)B.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(T){L.r=O.r;L.g=O.g;L.b=O.b;a(w,U,L);B.r=F.color.r*L.r;B.g=F.color.g*L.g;B.b=F.color.b*L.b;B.updateStyleString()}else B.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){h=1-F.__2near/(F.__farPlusNear-U.z*F.__farMinusNear); -B.setRGB(h,h,h)}else F instanceof THREE.MeshNormalMaterial&&B.setRGB(j(U.normalWorld.x),j(U.normalWorld.y),j(U.normalWorld.z));F.wireframe?o.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):o.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+F.opacity);l.appendChild(o)}function f(z,S,E,U,F,w,x){o=d(r++);o.setAttribute("d", -"M "+z.positionScreen.x+" "+z.positionScreen.y+" L "+S.positionScreen.x+" "+S.positionScreen.y+" L "+E.positionScreen.x+","+E.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)B.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(T){L.r=O.r;L.g=O.g;L.b=O.b;a(x,F,L);B.r=w.color.r*L.r;B.g=w.color.g*L.g;B.b=w.color.b*L.b;B.updateStyleString()}else B.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){h= -1-w.__2near/(w.__farPlusNear-F.z*w.__farMinusNear);B.setRGB(h,h,h)}else w instanceof THREE.MeshNormalMaterial&&B.setRGB(j(F.normalWorld.x),j(F.normalWorld.y),j(F.normalWorld.z));w.wireframe?o.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):o.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+w.opacity);l.appendChild(o)} -function d(z){if(i[z]==null){i[z]=document.createElementNS("http://www.w3.org/2000/svg","path");H==0&&i[z].setAttribute("shape-rendering","crispEdges");return i[z]}return i[z]}function j(z){return z<0?Math.min((1+z)*0.5,0.5):0.5+Math.min(z*0.5,0.5)}var k=null,q=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,y,c,C,u,t,J,R,N=new THREE.Rectangle,s=new THREE.Rectangle,T=false,B=new THREE.Color(16777215),L=new THREE.Color(16777215),O=new THREE.Color(0),Q=new THREE.Color(0), -e=new THREE.Color(0),h,m=new THREE.Vector3,i=[],n=[],g=[],o,r,D,M,H=1;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(z){switch(z){case "high":H=1;break;case "low":H=0}};this.setSize=function(z,S){p=z;y=S;c=p/2;C=y/2;l.setAttribute("viewBox",-c+" "+-C+" "+p+" "+y);l.setAttribute("width",p);l.setAttribute("height",y);N.set(-c,-C,c,C)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(z,S){var E,U, -F,w,x,K,G,W;this.autoClear&&this.clear();k=q.projectScene(z,S,this.sortElements);M=D=r=0;if(T=z.lights.length>0){G=z.lights;O.setRGB(0,0,0);Q.setRGB(0,0,0);e.setRGB(0,0,0);E=0;for(U=G.length;E0?"#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,l("fragment",m+e));c.attachShader(i,l("vertex",n+h));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(e,h){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube); +THREE.Projector=function(){function a(e,g){return g.z-e.z}function b(e,g){var m=0,h=1,n=e.z+e.w,k=g.z+g.w,q=-e.z+e.w,s=-g.z+g.w;if(n>=0&&k>=0&&q>=0&&s>=0)return true;else if(n<0&&k<0||q<0&&s<0)return false;else{if(n<0)m=Math.max(m,n/(n-k));else if(k<0)h=Math.min(h,n/(n-k));if(q<0)m=Math.max(m,q/(q-s));else if(s<0)h=Math.min(h,q/(q-s));if(hn&&w.z0&&P.z<1){v=I[u]=I[u]||new THREE.RenderableParticle;v.x=P.x/P.w;v.y=P.y/P.w;v.z=P.z;v.rotation=A.rotation.z;v.scale.x=A.scale.x*Math.abs(v.x-(P.x+g.projectionMatrix.n11)/(P.w+g.projectionMatrix.n14)); +v.scale.y=A.scale.y*Math.abs(v.y-(P.y+g.projectionMatrix.n22)/(P.w+g.projectionMatrix.n24));v.materials=A.materials;h.push(v);u++}}}}m&&h.sort(a);return h};this.unprojectVector=function(e,g){var m=new THREE.Matrix4;m.multiply(THREE.Matrix4.makeInvert(g.matrix),THREE.Matrix4.makeInvert(g.projectionMatrix));m.multiplyVector3(e);return e}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,i,j;this.domElement=document.createElement("div");this.setSize=function(p,l){f=p;d=l;i=f/2;j=d/2};this.render=function(p,l){var o,x,c,E,v,u,I,S;a=b.projectScene(p,l);o=0;for(x=a.length;o0){y.r+=ba.r*X;y.g+=ba.g*X;y.b+=ba.b*X}}else if(X instanceof THREE.PointLight){Z.sub(X.position,W);Z.normalize();X=O.dot(Z)*ca;if(X>0){y.r+=ba.r*X;y.g+=ba.g*X;y.b+=ba.b*X}}}}function Ma(t,W,O){if(O.opacity!=0){Ca(O.opacity);xa(O.blending);var y,M,X,ba,ca,da;if(O instanceof THREE.ParticleBasicMaterial){if(O.map){ba=O.map;ca=ba.width>>1;da=ba.height>>1;M=W.scale.x*j;X=W.scale.y*p;O=M*ca;y=X*da;F.set(t.x-O,t.y-y,t.x+O, +t.y+y);if(D.instersects(F)){l.save();l.translate(t.x,t.y);l.rotate(-W.rotation);l.scale(M,-X);l.translate(-ca,-da);l.drawImage(ba,0,0);l.restore()}}}else if(O instanceof THREE.ParticleCircleMaterial){if(H){G.r=L.r+B.r+N.r;G.g=L.g+B.g+N.g;G.b=L.b+B.b+N.b;R.r=O.color.r*G.r;R.g=O.color.g*G.g;R.b=O.color.b*G.b;R.updateStyleString()}else R.__styleString=O.color.__styleString;O=W.scale.x*j;y=W.scale.y*p;F.set(t.x-O,t.y-y,t.x+O,t.y+y);if(D.instersects(F)){M=R.__styleString;if(E!=M)l.fillStyle=E=M;l.save(); +l.translate(t.x,t.y);l.rotate(-W.rotation);l.scale(O,y);l.beginPath();l.arc(0,0,1,0,Y,true);l.closePath();l.fill();l.restore()}}}}function Na(t,W,O,y){if(y.opacity!=0){Ca(y.opacity);xa(y.blending);l.beginPath();l.moveTo(t.positionScreen.x,t.positionScreen.y);l.lineTo(W.positionScreen.x,W.positionScreen.y);l.closePath();if(y instanceof THREE.LineBasicMaterial){R.__styleString=y.color.__styleString;t=y.linewidth;if(v!=t)l.lineWidth=v=t;t=R.__styleString;if(c!=t)l.strokeStyle=c=t;l.stroke();F.inflate(y.linewidth* +2)}}}function Ha(t,W,O,y,M,X){if(M.opacity!=0){Ca(M.opacity);xa(M.blending);P=t.positionScreen.x;r=t.positionScreen.y;V=W.positionScreen.x;C=W.positionScreen.y;J=O.positionScreen.x;Q=O.positionScreen.y;l.beginPath();l.moveTo(P,r);l.lineTo(V,C);l.lineTo(J,Q);l.lineTo(P,r);l.closePath();if(M instanceof THREE.MeshBasicMaterial)if(M.map)M.map.image.loaded&&M.map.mapping instanceof THREE.UVMapping&&sa(P,r,V,C,J,Q,M.map.image,y.uvs[0].u,y.uvs[0].v,y.uvs[1].u,y.uvs[1].v,y.uvs[2].u,y.uvs[2].v);else if(M.env_map){if(M.env_map.image.loaded)if(M.env_map.mapping instanceof +THREE.SphericalReflectionMapping){t=na.matrix;Z.copy(y.vertexNormalsWorld[0]);s=(Z.x*t.n11+Z.y*t.n12+Z.z*t.n13)*0.5+0.5;K=-(Z.x*t.n21+Z.y*t.n22+Z.z*t.n23)*0.5+0.5;Z.copy(y.vertexNormalsWorld[1]);w=(Z.x*t.n11+Z.y*t.n12+Z.z*t.n13)*0.5+0.5;T=-(Z.x*t.n21+Z.y*t.n22+Z.z*t.n23)*0.5+0.5;Z.copy(y.vertexNormalsWorld[2]);z=(Z.x*t.n11+Z.y*t.n12+Z.z*t.n13)*0.5+0.5;A=-(Z.x*t.n21+Z.y*t.n22+Z.z*t.n23)*0.5+0.5;sa(P,r,V,C,J,Q,M.env_map.image,s,K,w,T,z,A)}}else M.wireframe?ya(M.color.__styleString,M.wireframe_linewidth): +za(M.color.__styleString);else if(M instanceof THREE.MeshLambertMaterial){if(M.map&&!M.wireframe){M.map.mapping instanceof THREE.UVMapping&&sa(P,r,V,C,J,Q,M.map.image,y.uvs[0].u,y.uvs[0].v,y.uvs[1].u,y.uvs[1].v,y.uvs[2].u,y.uvs[2].v);xa(THREE.SubtractiveBlending)}if(H)if(!M.wireframe&&M.shading==THREE.SmoothShading&&y.vertexNormalsWorld.length==3){e.r=g.r=m.r=L.r;e.g=g.g=m.g=L.g;e.b=g.b=m.b=L.b;wa(X,y.v1.positionWorld,y.vertexNormalsWorld[0],e);wa(X,y.v2.positionWorld,y.vertexNormalsWorld[1],g);wa(X, +y.v3.positionWorld,y.vertexNormalsWorld[2],m);h.r=(g.r+m.r)*0.5;h.g=(g.g+m.g)*0.5;h.b=(g.b+m.b)*0.5;q=Ia(e,g,m,h);sa(P,r,V,C,J,Q,q,0,0,1,0,0,1)}else{G.r=L.r;G.g=L.g;G.b=L.b;wa(X,y.centroidWorld,y.normalWorld,G);R.r=M.color.r*G.r;R.g=M.color.g*G.g;R.b=M.color.b*G.b;R.updateStyleString();M.wireframe?ya(R.__styleString,M.wireframe_linewidth):za(R.__styleString)}else M.wireframe?ya(M.color.__styleString,M.wireframe_linewidth):za(M.color.__styleString)}else if(M instanceof THREE.MeshDepthMaterial){n=na.near; +k=na.far;e.r=e.g=e.b=1-Da(t.positionScreen.z,n,k);g.r=g.g=g.b=1-Da(W.positionScreen.z,n,k);m.r=m.g=m.b=1-Da(O.positionScreen.z,n,k);h.r=(g.r+m.r)*0.5;h.g=(g.g+m.g)*0.5;h.b=(g.b+m.b)*0.5;q=Ia(e,g,m,h);sa(P,r,V,C,J,Q,q,0,0,1,0,0,1)}else if(M instanceof THREE.MeshNormalMaterial){R.r=Ea(y.normalWorld.x);R.g=Ea(y.normalWorld.y);R.b=Ea(y.normalWorld.z);R.updateStyleString();M.wireframe?ya(R.__styleString,M.wireframe_linewidth):za(R.__styleString)}}}function ya(t,W){if(c!=t)l.strokeStyle=c=t;if(v!=W)l.lineWidth= +v=W;l.stroke();F.inflate(W*2)}function za(t){if(E!=t)l.fillStyle=E=t;l.fill()}function sa(t,W,O,y,M,X,ba,ca,da,ia,fa,ja,ta){var la,ka;la=ba.width-1;ka=ba.height-1;ca*=la;da*=ka;ia*=la;fa*=ka;ja*=la;ta*=ka;O-=t;y-=W;M-=t;X-=W;ia-=ca;fa-=da;ja-=ca;ta-=da;ka=1/(ia*ta-ja*fa);la=(ta*O-fa*M)*ka;fa=(ta*y-fa*X)*ka;O=(ia*M-ja*O)*ka;y=(ia*X-ja*y)*ka;t=t-la*ca-O*da;W=W-fa*ca-y*da;l.save();l.transform(la,fa,O,y,t,W);l.clip();l.drawImage(ba,0,0);l.restore()}function Ca(t){if(o!=t)l.globalAlpha=o=t}function xa(t){if(x!= +t){switch(t){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}x=t}}function Ia(t,W,O,y){var M=~~(t.r*255),X=~~(t.g*255);t=~~(t.b*255);var ba=~~(W.r*255),ca=~~(W.g*255);W=~~(W.b*255);var da=~~(O.r*255),ia=~~(O.g*255);O=~~(O.b*255);var fa=~~(y.r*255),ja=~~(y.g*255);y=~~(y.b*255);ea[0]=M<0?0:M>255?255:M;ea[1]=X<0?0:X>255?255:X;ea[2]=t<0?0:t> +255?255:t;ea[4]=ba<0?0:ba>255?255:ba;ea[5]=ca<0?0:ca>255?255:ca;ea[6]=W<0?0:W>255?255:W;ea[8]=da<0?0:da>255?255:da;ea[9]=ia<0?0:ia>255?255:ia;ea[10]=O<0?0:O>255?255:O;ea[12]=fa<0?0:fa>255?255:fa;ea[13]=ja<0?0:ja>255?255:ja;ea[14]=y<0?0:y>255?255:y;qa.putImageData(Ba,0,0);va.drawImage(pa,0,0);return ra}function Da(t,W,O){t=(t-W)/(O-W);return t*t*(3-2*t)}function Ea(t){t=(t+1)*0.5;return t<0?0:t>1?1:t}function Fa(t,W){var O=W.x-t.x,y=W.y-t.y,M=1/Math.sqrt(O*O+y*y);O*=M;y*=M;W.x+=O;W.y+=y;t.x-=O;t.y-= +y}var Aa,Ja,$,ga,oa,Ga,Ka,ua;l.setTransform(1,0,0,-1,j,p);this.autoClear&&this.clear();a=b.projectScene(ha,na,this.sortElements);(H=ha.lights.length>0)&&La(ha);Aa=0;for(Ja=a.length;Aa0){D.r+=H.color.r*G;D.g+=H.color.g*G;D.b+=H.color.b*G}}else if(H instanceof THREE.PointLight){m.sub(H.position,A.centroidWorld);m.normalize();G=A.normalWorld.dot(m)*H.intensity;if(G>0){D.r+=H.color.r*G;D.g+=H.color.g*G;D.b+=H.color.b*G}}}}function b(z,A,D,U,F,H){q=d(s++);q.setAttribute("d","M "+z.positionScreen.x+ +" "+z.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+D.positionScreen.x+","+D.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)C.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(V){J.r=Q.r;J.g=Q.g;J.b=Q.b;a(H,U,J);C.r=F.color.r*J.r;C.g=F.color.g*J.g;C.b=F.color.b*J.b;C.updateStyleString()}else C.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){g=1-F.__2near/(F.__farPlusNear-U.z*F.__farMinusNear); +C.setRGB(g,g,g)}else F instanceof THREE.MeshNormalMaterial&&C.setRGB(i(U.normalWorld.x),i(U.normalWorld.y),i(U.normalWorld.z));F.wireframe?q.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):q.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+F.opacity);l.appendChild(q)}function f(z,A,D,U,F,H,G){q=d(s++);q.setAttribute("d", +"M "+z.positionScreen.x+" "+z.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+D.positionScreen.x+","+D.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(H instanceof THREE.MeshBasicMaterial)C.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshLambertMaterial)if(V){J.r=Q.r;J.g=Q.g;J.b=Q.b;a(G,F,J);C.r=H.color.r*J.r;C.g=H.color.g*J.g;C.b=H.color.b*J.b;C.updateStyleString()}else C.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshDepthMaterial){g= +1-H.__2near/(H.__farPlusNear-F.z*H.__farMinusNear);C.setRGB(g,g,g)}else H instanceof THREE.MeshNormalMaterial&&C.setRGB(i(F.normalWorld.x),i(F.normalWorld.y),i(F.normalWorld.z));H.wireframe?q.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+H.wireframe_linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: "+H.wireframe_linecap+"; stroke-linejoin: "+H.wireframe_linejoin):q.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+H.opacity);l.appendChild(q)} +function d(z){if(h[z]==null){h[z]=document.createElementNS("http://www.w3.org/2000/svg","path");T==0&&h[z].setAttribute("shape-rendering","crispEdges");return h[z]}return h[z]}function i(z){return z<0?Math.min((1+z)*0.5,0.5):0.5+Math.min(z*0.5,0.5)}var j=null,p=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,x,c,E,v,u,I,S,P=new THREE.Rectangle,r=new THREE.Rectangle,V=false,C=new THREE.Color(16777215),J=new THREE.Color(16777215),Q=new THREE.Color(0),R=new THREE.Color(0), +e=new THREE.Color(0),g,m=new THREE.Vector3,h=[],n=[],k=[],q,s,K,w,T=1;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(z){switch(z){case "high":T=1;break;case "low":T=0}};this.setSize=function(z,A){o=z;x=A;c=o/2;E=x/2;l.setAttribute("viewBox",-c+" "+-E+" "+o+" "+x);l.setAttribute("width",o);l.setAttribute("height",x);P.set(-c,-E,c,E)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(z,A){var D,U, +F,H,G,L,B,N;this.autoClear&&this.clear();j=p.projectScene(z,A,this.sortElements);w=K=s=0;if(V=z.lights.length>0){B=z.lights;Q.setRGB(0,0,0);R.setRGB(0,0,0);e.setRGB(0,0,0);D=0;for(U=B.length;D0?"#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(h,l("fragment",m+e));c.attachShader(h,l("vertex",n+g));c.linkProgram(h);c.getProgramParameter(h,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(h,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");h.uniforms={};h.attributes={};return h}function d(e,g){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube); c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var m=0;m<6;++m)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+m,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[m]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+ -h);c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}function j(e,h){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,p(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,p(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,p(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER, -p(e.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+h);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function k(e,h){var m,i,n;m=0;for(i=h.length;m= 0.0 )": -"",h?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",h?"pointDiffuse += mColor * pointDiffuseWeight;":"",h?"pointSpecular += mSpecular * pointSpecularWeight;":"",h?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": -"",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",h?"totalLight += pointDiffuse + pointSpecular;": +g);c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}function i(e,g){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,o(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,o(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,o(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER, +o(e.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+g);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function j(e,g){var m,h,n;m=0;for(h=g.length;m= 0.0 )": +"",g?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",g?"pointDiffuse += mColor * pointDiffuseWeight;":"",g?"pointSpecular += mSpecular * pointSpecularWeight;":"",g?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": +"",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",g?"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#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif\n}"].join("\n"); -i=f(n,i,m);c.useProgram(i);k(i,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);m&&k(i,["fogColor","fogNear","fogFar"]);e&&k(i,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);h&&k(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);q(i,["position","normal","uv"]);return i}(L.directional,L.point,fog);this.setSize=function(e,h){y.width=e;y.height=h;c.viewport(0,0,y.width,y.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,h){var m,i,n,g,o, -r=[],D=[],M=[];g=[];o=[];c.uniform1i(e.uniforms.enableLighting,h.length);m=0;for(i=h.length;m0){K.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,K.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(w),c.STATIC_DRAW)}K.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,K.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(z),c.STATIC_DRAW);K.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, -K.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(S),c.STATIC_DRAW);K.__webGLFaceCount=z.length;K.__webGLLineCount=S.length}};this.renderBuffer=function(e,h,m,i,n){var g,o,r,D,M,H,z,S,E;if(i instanceof THREE.MeshShaderMaterial||i instanceof THREE.MeshDepthMaterial||i instanceof THREE.MeshNormalMaterial){if(!i.program){if(i instanceof THREE.MeshDepthMaterial){z=Q.depth;i.fragment_shader=z.fragment_shader;i.vertex_shader=z.vertex_shader;i.uniforms=z.uniforms;i.uniforms.mNear.value= -i.near;i.uniforms.mFar.value=i.far}else if(i instanceof THREE.MeshNormalMaterial){z=Q.normal;i.fragment_shader=z.fragment_shader;i.vertex_shader=z.vertex_shader;i.uniforms=z.uniforms}i.program=f(i.fragment_shader,i.vertex_shader,null);z=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(E in i.uniforms)z.push(E);k(i.program,z);q(i.program,["position","normal","uv","tangent"])}E=i.program}else E=u;if(E!=C){c.useProgram(E);C=E}E==u&&this.setupLights(E, -h);this.loadCamera(E,e);this.loadMatrices(E);if(i instanceof THREE.MeshShaderMaterial||i instanceof THREE.MeshDepthMaterial||i instanceof THREE.MeshNormalMaterial){r=i.wireframe;D=i.wireframe_linewidth;e=E;h=i.uniforms;var U;for(g in h){S=h[g].type;z=h[g].value;U=e.uniforms[g];if(S=="i")c.uniform1i(U,z);else if(S=="f")c.uniform1f(U,z);else if(S=="v3")c.uniform3f(U,z.x,z.y,z.z);else if(S=="c")c.uniform3f(U,z.r,z.g,z.b);else if(S=="t"){c.uniform1i(U,z);if(S=h[g].texture)S.image instanceof Array&&S.image.length== -6?d(S,z):j(S,z)}}}if(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshBasicMaterial){g=i.color;o=i.opacity;r=i.wireframe;D=i.wireframe_linewidth;M=i.map;H=i.env_map;h=i.combine==THREE.MixOperation;e=i.reflectivity;S=i.env_map&&i.env_map.mapping instanceof THREE.CubeRefractionMapping;z=i.refraction_ratio;c.uniform4f(E.uniforms.mColor,g.r*o,g.g*o,g.b*o,o);c.uniform1i(E.uniforms.mixEnvMap,h);c.uniform1f(E.uniforms.mReflectivity,e);c.uniform1i(E.uniforms.useRefract, -S);c.uniform1f(E.uniforms.mRefractionRatio,z);if(m){c.uniform1f(E.uniforms.fogNear,m.near);c.uniform1f(E.uniforms.fogFar,m.far);c.uniform3f(E.uniforms.fogColor,m.color.r,m.color.g,m.color.b)}}if(i instanceof THREE.MeshPhongMaterial){m=i.ambient;g=i.specular;i=i.shininess;c.uniform4f(E.uniforms.mAmbient,m.r,m.g,m.b,o);c.uniform4f(E.uniforms.mSpecular,g.r,g.g,g.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 i instanceof THREE.MeshBasicMaterial&&c.uniform1i(E.uniforms.material,0);if(M){j(M,0);c.uniform1i(E.uniforms.tMap,0);c.uniform1i(E.uniforms.enableMap,1)}else c.uniform1i(E.uniforms.enableMap,0);if(H){d(H,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,n.__webGLVertexBuffer);c.vertexAttribPointer(o.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.position);if(o.normal>= -0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer);c.vertexAttribPointer(o.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.normal)}if(o.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLTangentBuffer);c.vertexAttribPointer(o.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.tangent)}if(o.uv>=0)if(n.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.vertexAttribPointer(o.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.uv)}else c.disableVertexAttribArray(o.uv);if(r){c.lineWidth(D); -c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);c.drawElements(c.LINES,n.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(e,h,m,i,n,g,o){var r,D,M,H,z;M=0;for(H=i.materials.length;M=0;m--){i=e.__webGLObjects[m].object; -h==i&&e.__webGLObjects.splice(m,1)}};this.setupMatrices=function(e,h){e.autoUpdateMatrix&&e.updateMatrix();t.multiply(h.matrix,e.matrix);N.set(t.flatten());J=THREE.Matrix4.makeInvert3x3(t).transpose();T.set(J.m);B.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,R);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,N);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,s);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,T);c.uniformMatrix4fv(e.uniforms.objectMatrix, -false,B)};this.loadCamera=function(e,h){c.uniform3f(e.uniforms.cameraPosition,h.position.x,h.position.y,h.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,h){if(e){!h||h=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK); -else e=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0};var Q={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}", +h=f(n,h,m);c.useProgram(h);j(h,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);m&&j(h,["fogColor","fogNear","fogFar"]);e&&j(h,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);g&&j(h,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(h.uniforms.enableMap,0);c.uniform1i(h.uniforms.tMap,0);c.uniform1i(h.uniforms.enableCubeMap,0);c.uniform1i(h.uniforms.tCube,1);c.uniform1i(h.uniforms.mixEnvMap,0);c.uniform1i(h.uniforms.useRefract,0);p(h,["position","normal","uv"]);return h}(J.directional,J.point,fog);this.setSize=function(e,g){x.width=e;x.height=g;c.viewport(0,0,x.width,x.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,g){var m,h,n,k,q, +s=[],K=[],w=[];k=[];q=[];c.uniform1i(e.uniforms.enableLighting,g.length);m=0;for(h=g.length;m0){L.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,L.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(H),c.STATIC_DRAW)}L.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,L.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(z),c.STATIC_DRAW);L.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +L.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(A),c.STATIC_DRAW);L.__webGLFaceCount=z.length;L.__webGLLineCount=A.length}};this.renderBuffer=function(e,g,m,h,n){var k,q,s,K,w,T,z,A,D;if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshDepthMaterial||h instanceof THREE.MeshNormalMaterial){if(!h.program){if(h instanceof THREE.MeshDepthMaterial){z=R.depth;h.fragment_shader=z.fragment_shader;h.vertex_shader=z.vertex_shader;h.uniforms=z.uniforms;h.uniforms.mNear.value= +e.near;h.uniforms.mFar.value=e.far}else if(h instanceof THREE.MeshNormalMaterial){z=R.normal;h.fragment_shader=z.fragment_shader;h.vertex_shader=z.vertex_shader;h.uniforms=z.uniforms}h.program=f(h.fragment_shader,h.vertex_shader,null);z=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(D in h.uniforms)z.push(D);j(h.program,z);p(h.program,["position","normal","uv","tangent"])}D=h.program}else D=v;if(D!=E){c.useProgram(D);E=D}D==v&&this.setupLights(D, +g);this.loadCamera(D,e);this.loadMatrices(D);if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshDepthMaterial||h instanceof THREE.MeshNormalMaterial){s=h.wireframe;K=h.wireframe_linewidth;e=D;g=h.uniforms;var U;for(k in g){A=g[k].type;z=g[k].value;U=e.uniforms[k];if(A=="i")c.uniform1i(U,z);else if(A=="f")c.uniform1f(U,z);else if(A=="v3")c.uniform3f(U,z.x,z.y,z.z);else if(A=="c")c.uniform3f(U,z.r,z.g,z.b);else if(A=="t"){c.uniform1i(U,z);if(A=g[k].texture)A.image instanceof Array&&A.image.length== +6?d(A,z):i(A,z)}}}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshBasicMaterial){k=h.color;q=h.opacity;s=h.wireframe;K=h.wireframe_linewidth;w=h.map;T=h.env_map;g=h.combine==THREE.MixOperation;e=h.reflectivity;A=h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping;z=h.refraction_ratio;c.uniform4f(D.uniforms.mColor,k.r*q,k.g*q,k.b*q,q);c.uniform1i(D.uniforms.mixEnvMap,g);c.uniform1f(D.uniforms.mReflectivity,e);c.uniform1i(D.uniforms.useRefract, +A);c.uniform1f(D.uniforms.mRefractionRatio,z);if(m){c.uniform1f(D.uniforms.fogNear,m.near);c.uniform1f(D.uniforms.fogFar,m.far);c.uniform3f(D.uniforms.fogColor,m.color.r,m.color.g,m.color.b)}}if(h instanceof THREE.MeshPhongMaterial){m=h.ambient;k=h.specular;h=h.shininess;c.uniform4f(D.uniforms.mAmbient,m.r,m.g,m.b,q);c.uniform4f(D.uniforms.mSpecular,k.r,k.g,k.b,q);c.uniform1f(D.uniforms.mShininess,h);c.uniform1i(D.uniforms.material,2)}else if(h instanceof THREE.MeshLambertMaterial)c.uniform1i(D.uniforms.material, +1);else h instanceof THREE.MeshBasicMaterial&&c.uniform1i(D.uniforms.material,0);if(w){i(w,0);c.uniform1i(D.uniforms.tMap,0);c.uniform1i(D.uniforms.enableMap,1)}else c.uniform1i(D.uniforms.enableMap,0);if(T){d(T,1);c.uniform1i(D.uniforms.tCube,1);c.uniform1i(D.uniforms.enableCubeMap,1)}else c.uniform1i(D.uniforms.enableCubeMap,0);q=D.attributes;c.bindBuffer(c.ARRAY_BUFFER,n.__webGLVertexBuffer);c.vertexAttribPointer(q.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.position);if(q.normal>= +0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer);c.vertexAttribPointer(q.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.normal)}if(q.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLTangentBuffer);c.vertexAttribPointer(q.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.tangent)}if(q.uv>=0)if(n.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.vertexAttribPointer(q.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.uv)}else c.disableVertexAttribArray(q.uv);if(s){c.lineWidth(K); +c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);c.drawElements(c.LINES,n.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(e,g,m,h,n,k,q){var s,K,w,T,z;w=0;for(T=h.materials.length;w=0;m--){h=e.__webGLObjects[m].object; +g==h&&e.__webGLObjects.splice(m,1)}};this.setupMatrices=function(e,g){e.autoUpdateMatrix&&e.updateMatrix();u.multiply(g.matrix,e.matrix);P.set(u.flatten());I=THREE.Matrix4.makeInvert3x3(u).transpose();V.set(I.m);C.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,S);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,P);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,r);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,V);c.uniformMatrix4fv(e.uniforms.objectMatrix, +false,C)};this.loadCamera=function(e,g){c.uniform3f(e.uniforms.cameraPosition,g.position.x,g.position.y,g.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,g){if(e){!g||g=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK); +else e=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0};var R={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}", vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{},fragment_shader:"varying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );\n}",vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"}}}; THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=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.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null}; diff --git a/build/ThreeDebug.js b/build/ThreeDebug.js index ba454395..97242956 100644 --- a/build/ThreeDebug.js +++ b/build/ThreeDebug.js @@ -12,52 +12,53 @@ THREE.Vector4=function(a,b,f,d){this.x=a||0;this.y=b||0;this.z=f||0;this.w=d||1} THREE.Vector4.prototype={set:function(a,b,f,d){this.x=a;this.y=b;this.z=f;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}}; THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,f,d=a.objects,j=[];a=0;for(b=d.length;a0&&N>0&&O+N<1}var f,d,j,k,q,l,p,y,c,C, -v,u=a.geometry,J=u.vertices,R=[];f=0;for(d=u.faces.length;fp?d:p;j=j>y? -j:y}a()};this.add3Points=function(p,y,c,C,v,u){if(l){l=false;b=pc?p>v?p:v:c>v?c:v;j=y>C?y>u?y:u:C>u?C:u}else{b=pc?p>v?p>d?p:d:v>d?v:d:c>v?c>d?c:d:v>d?v:d;j=y>C?y>u?y>j?y:j:u>j?u:j:C>u?C>j?C:j:u>j?u:j}a()};this.addRectangle=function(p){if(l){l=false;b=p.getLeft();f=p.getTop();d=p.getRight();j=p.getBottom()}else{b=bp.getRight()?d:p.getRight();j=j>p.getBottom()?j:p.getBottom()}a()};this.inflate=function(p){b-=p;f-=p;d+=p;j+=p;a()};this.minSelf=function(p){b=b>p.getLeft()?b:p.getLeft();f=f>p.getTop()?f:p.getTop();d=d=0&&Math.min(j,p.getBottom())-Math.max(f,p.getTop())>=0};this.empty=function(){l=true;j=d=f=b=0;a()};this.isEmpty=function(){return l};this.toString= -function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+f+", bottom: "+j+", width: "+k+", height: "+q+" )"}};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,f,d,j,k,q,l,p,y,c,C,v,u,J,R){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=j||0;this.n22=k||1;this.n23=q||0;this.n24=l||0;this.n31=p||0;this.n32=y||0;this.n33=c||1;this.n34=C||0;this.n41=v||0;this.n42=u||0;this.n43=J||0;this.n44=R||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,f,d,j,k,q,l,p,y,c,C,v,u,J,R){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=j;this.n22=k;this.n23=q;this.n24=l;this.n31=p;this.n32=y;this.n33=c;this.n34=C;this.n41=v;this.n42=u;this.n43=J;this.n44=R;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,f){var d=new THREE.Vector3,j=new THREE.Vector3,k=new THREE.Vector3;k.sub(a,b).normalize();d.cross(f,k).normalize();j.cross(k,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.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,f=a.y,d=a.z,j=1/(this.n41*b+this.n42*f+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*d+this.n14)*j;a.y=(this.n21*b+this.n22*f+this.n23*d+this.n24)*j;a.z=(this.n31*b+this.n32*f+this.n33*d+this.n34)*j;return a},multiplyVector4:function(a){var b=a.x,f=a.y,d=a.z,j=a.w;a.x=this.n11*b+this.n12*f+this.n13*d+this.n14*j;a.y=this.n21*b+this.n22*f+this.n23*d+this.n24* -j;a.z=this.n31*b+this.n32*f+this.n33*d+this.n34*j;a.w=this.n41*b+this.n42*f+this.n43*d+this.n44*j;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 f=a.n11,d=a.n12,j=a.n13,k=a.n14,q=a.n21,l=a.n22,p=a.n23,y=a.n24,c=a.n31,C=a.n32, -v=a.n33,u=a.n34,J=a.n41,R=a.n42,N=a.n43,s=a.n44,U=b.n11,B=b.n12,L=b.n13,O=b.n14,Q=b.n21,e=b.n22,h=b.n23,m=b.n24,i=b.n31,n=b.n32,g=b.n33,o=b.n34,r=b.n41,E=b.n42,M=b.n43,H=b.n44;this.n11=f*U+d*Q+j*i+k*r;this.n12=f*B+d*e+j*n+k*E;this.n13=f*L+d*h+j*g+k*M;this.n14=f*O+d*m+j*o+k*H;this.n21=q*U+l*Q+p*i+y*r;this.n22=q*B+l*e+p*n+y*E;this.n23=q*L+l*h+p*g+y*M;this.n24=q*O+l*m+p*o+y*H;this.n31=c*U+C*Q+v*i+u*r;this.n32=c*B+C*e+v*n+u*E;this.n33=c*L+C*h+v*g+u*M;this.n34=c*O+C*m+v*o+u*H;this.n41=J*U+R*Q+N*i+s*r; -this.n42=J*B+R*e+N*n+s*E;this.n43=J*L+R*h+N*g+s*M;this.n44=J*O+R*m+N*o+s*H;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,j=this.n14,k=this.n21,q=this.n22,l=this.n23,p=this.n24,y=this.n31,c=this.n32,C=this.n33,v=this.n34,u=this.n41,J=this.n42,R=this.n43,N=this.n44,s=a.n11,U=a.n21,B=a.n31,L=a.n41,O=a.n12,Q=a.n22,e=a.n32,h=a.n42,m=a.n13,i=a.n23,n=a.n33,g=a.n43,o=a.n14,r=a.n24,E=a.n34;a=a.n44;this.n11=b*s+f*U+d*B+j*L;this.n12=b*O+f*Q+d*e+j*h;this.n13=b*m+f*i+d*n+j*g;this.n14= -b*o+f*r+d*E+j*a;this.n21=k*s+q*U+l*B+p*L;this.n22=k*O+q*Q+l*e+p*h;this.n23=k*m+q*i+l*n+p*g;this.n24=k*o+q*r+l*E+p*a;this.n31=y*s+c*U+C*B+v*L;this.n32=y*O+c*Q+C*e+v*h;this.n33=y*m+c*i+C*n+v*g;this.n34=y*o+c*r+C*E+v*a;this.n41=u*s+J*U+R*B+N*L;this.n42=u*O+J*Q+R*e+N*h;this.n43=u*m+J*i+R*n+N*g;this.n44=u*o+J*r+R*E+N*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*= +THREE.Ray.prototype={intersectScene:function(a){var b,f,d=a.objects,i=[];a=0;for(b=d.length;a0&&P>0&&Q+P<1}var f,d,i,j,p,k,o,x,c,E, +v,u=a.geometry,I=u.vertices,T=[];f=0;for(d=u.faces.length;fo?d:o;i=i>x? +i:x}a()};this.add3Points=function(o,x,c,E,v,u){if(k){k=false;b=oc?o>v?o:v:c>v?c:v;i=x>E?x>u?x:u:E>u?E:u}else{b=oc?o>v?o>d?o:d:v>d?v:d:c>v?c>d?c:d:v>d?v:d;i=x>E?x>u?x>i?x:i:u>i?u:i:E>u?E>i?E:i:u>i?u:i}a()};this.addRectangle=function(o){if(k){k=false;b=o.getLeft();f=o.getTop();d=o.getRight();i=o.getBottom()}else{b=bo.getRight()?d:o.getRight();i=i>o.getBottom()?i:o.getBottom()}a()};this.inflate=function(o){b-=o;f-=o;d+=o;i+=o;a()};this.minSelf=function(o){b=b>o.getLeft()?b:o.getLeft();f=f>o.getTop()?f:o.getTop();d=d=0&&Math.min(i,o.getBottom())-Math.max(f,o.getTop())>=0};this.empty=function(){k=true;i=d=f=b=0;a()};this.isEmpty=function(){return k};this.toString= +function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+f+", bottom: "+i+", width: "+j+", height: "+p+" )"}};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,f,d,i,j,p,k,o,x,c,E,v,u,I,T){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=i||0;this.n22=j||1;this.n23=p||0;this.n24=k||0;this.n31=o||0;this.n32=x||0;this.n33=c||1;this.n34=E||0;this.n41=v||0;this.n42=u||0;this.n43=I||0;this.n44=T||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,f,d,i,j,p,k,o,x,c,E,v,u,I,T){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=i;this.n22=j;this.n23=p;this.n24=k;this.n31=o;this.n32=x;this.n33=c;this.n34=E;this.n41=v;this.n42=u;this.n43=I;this.n44=T;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,f){var d=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();d.cross(f,j).normalize();i.cross(j,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=i.x;this.n22=i.y;this.n23=i.z;this.n24=-i.dot(a);this.n31=j.x; +this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,d=a.z,i=1/(this.n41*b+this.n42*f+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*d+this.n14)*i;a.y=(this.n21*b+this.n22*f+this.n23*d+this.n24)*i;a.z=(this.n31*b+this.n32*f+this.n33*d+this.n34)*i;return a},multiplyVector4:function(a){var b=a.x,f=a.y,d=a.z,i=a.w;a.x=this.n11*b+this.n12*f+this.n13*d+this.n14*i;a.y=this.n21*b+this.n22*f+this.n23*d+this.n24* +i;a.z=this.n31*b+this.n32*f+this.n33*d+this.n34*i;a.w=this.n41*b+this.n42*f+this.n43*d+this.n44*i;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var f=a.n11,d=a.n12,i=a.n13,j=a.n14,p=a.n21,k=a.n22,o=a.n23,x=a.n24,c=a.n31,E=a.n32, +v=a.n33,u=a.n34,I=a.n41,T=a.n42,P=a.n43,s=a.n44,V=b.n11,D=b.n12,J=b.n13,Q=b.n14,R=b.n21,e=b.n22,g=b.n23,m=b.n24,h=b.n31,n=b.n32,l=b.n33,q=b.n34,t=b.n41,K=b.n42,w=b.n43,U=b.n44;this.n11=f*V+d*R+i*h+j*t;this.n12=f*D+d*e+i*n+j*K;this.n13=f*J+d*g+i*l+j*w;this.n14=f*Q+d*m+i*q+j*U;this.n21=p*V+k*R+o*h+x*t;this.n22=p*D+k*e+o*n+x*K;this.n23=p*J+k*g+o*l+x*w;this.n24=p*Q+k*m+o*q+x*U;this.n31=c*V+E*R+v*h+u*t;this.n32=c*D+E*e+v*n+u*K;this.n33=c*J+E*g+v*l+u*w;this.n34=c*Q+E*m+v*q+u*U;this.n41=I*V+T*R+P*h+s*t; +this.n42=I*D+T*e+P*n+s*K;this.n43=I*J+T*g+P*l+s*w;this.n44=I*Q+T*m+P*q+s*U;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,i=this.n14,j=this.n21,p=this.n22,k=this.n23,o=this.n24,x=this.n31,c=this.n32,E=this.n33,v=this.n34,u=this.n41,I=this.n42,T=this.n43,P=this.n44,s=a.n11,V=a.n21,D=a.n31,J=a.n41,Q=a.n12,R=a.n22,e=a.n32,g=a.n42,m=a.n13,h=a.n23,n=a.n33,l=a.n43,q=a.n14,t=a.n24,K=a.n34;a=a.n44;this.n11=b*s+f*V+d*D+i*J;this.n12=b*Q+f*R+d*e+i*g;this.n13=b*m+f*h+d*n+i*l;this.n14= +b*q+f*t+d*K+i*a;this.n21=j*s+p*V+k*D+o*J;this.n22=j*Q+p*R+k*e+o*g;this.n23=j*m+p*h+k*n+o*l;this.n24=j*q+p*t+k*K+o*a;this.n31=x*s+c*V+E*D+v*J;this.n32=x*Q+c*R+E*e+v*g;this.n33=x*m+c*h+E*n+v*l;this.n34=x*q+c*t+E*K+v*a;this.n41=u*s+I*V+T*D+P*J;this.n42=u*Q+I*R+T*e+P*g;this.n43=u*m+I*h+T*n+P*l;this.n44=u*q+I*t+T*K+P*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,f,d){var j=b[f];b[f]=b[d]; -b[d]=j}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.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,f,d){var i=b[f];b[f]=b[d]; +b[d]=i}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12, this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,f){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=f;return d}; THREE.Matrix4.scaleMatrix=function(a,b,f){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=f;return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; -THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var f=new THREE.Matrix4,d=Math.cos(b),j=Math.sin(b),k=1-d,q=a.x,l=a.y,p=a.z;f.n11=k*q*q+d;f.n12=k*q*l-j*p;f.n13=k*q*p+j*l;f.n21=k*q*l+j*p;f.n22=k*l*l+d;f.n23=k*l*p-j*q;f.n31=k*q*p-j*l;f.n32=k*l*p+j*q;f.n33=k*p*p+d;return f}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var f=new THREE.Matrix4,d=Math.cos(b),i=Math.sin(b),j=1-d,p=a.x,k=a.y,o=a.z;f.n11=j*p*p+d;f.n12=j*p*k-i*o;f.n13=j*p*o+i*k;f.n21=j*p*k+i*o;f.n22=j*k*k+d;f.n23=j*k*o-i*p;f.n31=j*p*o-i*k;f.n32=j*k*o+i*p;f.n33=j*o*o+d;return f}; 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 f=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],j=b[6]*b[1]-b[2]*b[5],k=-b[10]*b[4]+b[6]*b[8],q=b[10]*b[0]-b[2]*b[8],l=-b[6]*b[0]+b[2]*b[4],p=b[9]*b[4]-b[5]*b[8],y=-b[9]*b[0]+b[1]*b[8],c=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*k+b[2]*p;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*d;a.m[2]=b*j;a.m[3]=b*k;a.m[4]=b*q;a.m[5]=b*l;a.m[6]=b*p;a.m[7]=b*y;a.m[8]=b*c;return a}; -THREE.Matrix4.makeFrustum=function(a,b,f,d,j,k){var q,l,p;q=new THREE.Matrix4;l=2*j/(b-a);p=2*j/(d-f);a=(b+a)/(b-a);f=(d+f)/(d-f);d=-(k+j)/(k-j);j=-2*k*j/(k-j);q.n11=l;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=p;q.n23=f;q.n24=0;q.n31=0;q.n32=0;q.n33=d;q.n34=j;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,b,f,d){var j;a=f*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*b,a*b,j,a,f,d)}; -THREE.Matrix4.makeOrtho=function(a,b,f,d,j,k){var q,l,p,y;q=new THREE.Matrix4;l=b-a;p=f-d;y=k-j;a=(b+a)/l;f=(f+d)/p;j=(k+j)/y;q.n11=2/l;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/p;q.n23=0;q.n24=-f;q.n31=0;q.n32=0;q.n33=-2/y;q.n34=-j;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var f=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],i=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],p=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],x=-b[9]*b[0]+b[1]*b[8],c=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*j+b[2]*o;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*d;a.m[2]=b*i;a.m[3]=b*j;a.m[4]=b*p;a.m[5]=b*k;a.m[6]=b*o;a.m[7]=b*x;a.m[8]=b*c;return a}; +THREE.Matrix4.makeFrustum=function(a,b,f,d,i,j){var p,k,o;p=new THREE.Matrix4;k=2*i/(b-a);o=2*i/(d-f);a=(b+a)/(b-a);f=(d+f)/(d-f);d=-(j+i)/(j-i);i=-2*j*i/(j-i);p.n11=k;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=o;p.n23=f;p.n24=0;p.n31=0;p.n32=0;p.n33=d;p.n34=i;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,b,f,d){var i;a=f*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*b,a*b,i,a,f,d)}; +THREE.Matrix4.makeOrtho=function(a,b,f,d,i,j){var p,k,o,x;p=new THREE.Matrix4;k=b-a;o=f-d;x=j-i;a=(b+a)/k;f=(f+d)/o;i=(j+i)/x;p.n11=2/k;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/o;p.n23=0;p.n24=-f;p.n31=0;p.n32=0;p.n33=-2/x;p.n34=-i;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p}; 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,f,d,j){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,b,f,d,j,k){this.a=a;this.b=b;this.c=f;this.d=d;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.materials=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.Face3=function(a,b,f,d,i){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=i instanceof Array?i:[i]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; +THREE.Face4=function(a,b,f,d,i,j){this.a=a;this.b=b;this.c=f;this.d=d;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];this.materials=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; THREE.Geometry.prototype={computeCentroids:function(){var a,b,f;a=0;for(b=this.faces.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x], +f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,f,d,i,j,p,k=new THREE.Vector3,o=new THREE.Vector3;d=0;for(i=this.vertices.length;d0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x], y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,f=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z< -this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,f=this.vertices.length;b65535){p[q].counter+=1;l=p[q].hash+"_"+p[q].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:materials,vertices:0}}this.geometryChunks[l].faces.push(d); -this.geometryChunks[l].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; -THREE.Camera=function(a,b,f,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,f,d);this.autoUpdateMatrix=true;this.translateX=function(j){j=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(j);j.cross(j.clone(),this.up);this.position.addSelf(j);this.target.position.addSelf(j)};this.translateZ=function(j){j=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(j); -this.position.subSelf(j);this.target.position.subSelf(j)};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; +this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,f=this.vertices.length;b65535){o[p].counter+=1;k=o[p].hash+"_"+o[p].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:materials,vertices:0}}this.geometryChunks[k].faces.push(d); +this.geometryChunks[k].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +THREE.Camera=function(a,b,f,d){this.fov=a;this.aspect=b;this.near=f;this.far=d;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=null;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.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix();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.visible=this.autoUpdateMatrix=true}; THREE.Object3D.prototype={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.materials=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.materials=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D; @@ -80,108 +81,107 @@ a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refract undefined)this.wireframe_linejoin=a.wireframe_linejoin}}; THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (
id: "+this.id+"
color: "+this.color+"
ambient: "+this.ambient+"
specular: "+this.specular+"
shininess: "+this.shininess+"
map: "+this.map+"
specular_map: "+this.specular_map+"
env_map: "+this.env_map+"
combine: "+this.combine+"
reflectivity: "+this.reflectivity+"
refraction_ratio: "+this.refraction_ratio+"
opacity: "+this.opacity+"
shading: "+this.shading+"
wireframe: "+ this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
)"}};THREE.MeshPhongMaterialCounter={value:0}; -THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1E3;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){if(a.near!==undefined)this.near=a.near;if(a.far!==undefined)this.far=a.far;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear= -this.far-this.near};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial"}};THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){}; -THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}}; +THREE.MeshDepthMaterial=function(a){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){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial"}}; +THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}}; THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};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){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!== undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}}; THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (
id: "+this.id+"
blending: "+this.blending+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
)"}};THREE.MeshShaderMaterialCounter={value:0}; THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}}; THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}}; THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}}; -THREE.Texture=function(a,b,f,d,j,k){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=j!==undefined?j:THREE.LinearFilter;this.min_filter=k!==undefined?k:THREE.LinearMipMapLinearFilter}; +THREE.Texture=function(a,b,f,d,i,j){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=j!==undefined?j:THREE.LinearMipMapLinearFilter}; THREE.Texture.prototype={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.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}}; THREE.Fog=function(a,b,f){this.color=new THREE.Color(a);this.near=b||1;this.far=f||1E3}; -THREE.Projector=function(){function a(e,h){return h.z-e.z}function b(e,h){var m=0,i=1,n=e.z+e.w,g=h.z+h.w,o=-e.z+e.w,r=-h.z+h.w;if(n>=0&&g>=0&&o>=0&&r>=0)return true;else if(n<0&&g<0||o<0&&r<0)return false;else{if(n<0)m=Math.max(m,n/(n-g));else if(g<0)i=Math.min(i,n/(n-g));if(o<0)m=Math.max(m,o/(o-r));else if(r<0)i=Math.min(i,o/(o-r));if(i0&&r.z<1}D=D.faces;g=0;for(o=D.length;g0&&N.z<1){v=J[u]=J[u]||new THREE.RenderableParticle;v.x=N.x/N.w;v.y=N.y/N.w;v.z=N.z;v.rotation=H.rotation.z;v.scale.x=H.scale.x*Math.abs(v.x-(N.x+h.projectionMatrix.n11)/(N.w+h.projectionMatrix.n14));v.scale.y=H.scale.y* -Math.abs(v.y-(N.y+h.projectionMatrix.n22)/(N.w+h.projectionMatrix.n24));v.materials=H.materials;i.push(v);u++}}}}m&&i.sort(a);return i};this.unprojectVector=function(e,h){var m=new THREE.Matrix4;m.multiply(THREE.Matrix4.makeInvert(h.matrix),THREE.Matrix4.makeInvert(h.projectionMatrix));m.multiplyVector3(e);return e}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,j,k;this.domElement=document.createElement("div");this.setSize=function(q,l){f=q;d=l;j=f/2;k=d/2};this.render=function(q,l){var p,y,c,C,v,u,J,R;a=b.projectScene(q,l);p=0;for(y=a.length;p0){A.r+=$.r*X;A.g+=$.g*X;A.b+=$.b*X}}else if(X instanceof THREE.PointLight){Y.sub(X.position,V);Y.normalize();X=P.dot(Y)*ca;if(X>0){A.r+=$.r*X;A.g+=$.g*X;A.b+=$.b*X}}}}function Ma(t,V,P){if(P.opacity!=0){Ca(P.opacity);xa(P.blending);var A,I,X,$,ca,da;if(P instanceof THREE.ParticleBasicMaterial){if(P.map){$=P.map;ca=$.width>>1;da=$.height>>1;I=V.scale.x*k;X=V.scale.y*q;P=I*ca;A=X*da;w.set(t.x-P,t.y-A,t.x+P,t.y+A);if(!S.instersects(w))return; -l.save();l.translate(t.x,t.y);l.rotate(-V.rotation);l.scale(I,-X);l.translate(-ca,-da);l.drawImage($,0,0);l.restore()}l.beginPath();l.moveTo(t.x-10,t.y);l.lineTo(t.x+10,t.y);l.moveTo(t.x,t.y-10);l.lineTo(t.x,t.y+10);l.closePath();l.strokeStyle="rgb(255,255,0)";l.stroke()}else if(P instanceof THREE.ParticleCircleMaterial){if(x){K.r=G.r+W.r+ba.r;K.g=G.g+W.g+ba.g;K.b=G.b+W.b+ba.b;Q.r=P.color.r*K.r;Q.g=P.color.g*K.g;Q.b=P.color.b*K.b;Q.updateStyleString()}else Q.__styleString=P.color.__styleString;P= -V.scale.x*k;A=V.scale.y*q;w.set(t.x-P,t.y-A,t.x+P,t.y+A);if(S.instersects(w)){I=Q.__styleString;if(C!=I)l.fillStyle=C=I;l.save();l.translate(t.x,t.y);l.rotate(-V.rotation);l.scale(P,A);l.beginPath();l.arc(0,0,1,0,Ka,true);l.closePath();l.fill();l.restore()}}}}function Na(t,V,P,A){if(A.opacity!=0){Ca(A.opacity);xa(A.blending);l.beginPath();l.moveTo(t.positionScreen.x,t.positionScreen.y);l.lineTo(V.positionScreen.x,V.positionScreen.y);l.closePath();if(A instanceof THREE.LineBasicMaterial){Q.__styleString= -A.color.__styleString;t=A.linewidth;if(v!=t)l.lineWidth=v=t;t=Q.__styleString;if(c!=t)l.strokeStyle=c=t;l.stroke();w.inflate(A.linewidth*2)}}}function Ga(t,V,P,A,I,X){if(I.opacity!=0){Ca(I.opacity);xa(I.blending);N=t.positionScreen.x;s=t.positionScreen.y;U=V.positionScreen.x;B=V.positionScreen.y;L=P.positionScreen.x;O=P.positionScreen.y;l.beginPath();l.moveTo(N,s);l.lineTo(U,B);l.lineTo(L,O);l.lineTo(N,s);l.closePath();if(I instanceof THREE.MeshBasicMaterial)if(I.map)I.map.image.loaded&&I.map.mapping instanceof -THREE.UVMapping&&ra(N,s,U,B,L,O,I.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);else if(I.env_map){if(I.env_map.image.loaded)if(I.env_map.mapping instanceof THREE.SphericalReflectionMapping){t=va.matrix;Y.copy(A.vertexNormalsWorld[0]);E=(Y.x*t.n11+Y.y*t.n12+Y.z*t.n13)*0.5+0.5;M=-(Y.x*t.n21+Y.y*t.n22+Y.z*t.n23)*0.5+0.5;Y.copy(A.vertexNormalsWorld[1]);H=(Y.x*t.n11+Y.y*t.n12+Y.z*t.n13)*0.5+0.5;z=-(Y.x*t.n21+Y.y*t.n22+Y.z*t.n23)*0.5+0.5;Y.copy(A.vertexNormalsWorld[2]);T= -(Y.x*t.n11+Y.y*t.n12+Y.z*t.n13)*0.5+0.5;F=-(Y.x*t.n21+Y.y*t.n22+Y.z*t.n23)*0.5+0.5;ra(N,s,U,B,L,O,I.env_map.image,E,M,H,z,T,F)}}else I.wireframe?ya(I.color.__styleString,I.wireframe_linewidth):za(I.color.__styleString);else if(I instanceof THREE.MeshLambertMaterial){if(I.map&&!I.wireframe){I.map.mapping instanceof THREE.UVMapping&&ra(N,s,U,B,L,O,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);xa(THREE.SubtractiveBlending)}if(x)if(!I.wireframe&&I.shading==THREE.SmoothShading&& -A.vertexNormalsWorld.length==3){e.r=h.r=m.r=G.r;e.g=h.g=m.g=G.g;e.b=h.b=m.b=G.b;wa(X,A.v1.positionWorld,A.vertexNormalsWorld[0],e);wa(X,A.v2.positionWorld,A.vertexNormalsWorld[1],h);wa(X,A.v3.positionWorld,A.vertexNormalsWorld[2],m);i.r=(h.r+m.r)*0.5;i.g=(h.g+m.g)*0.5;i.b=(h.b+m.b)*0.5;r=Ha(e,h,m,i);ra(N,s,U,B,L,O,r,0,0,1,0,0,1)}else{K.r=G.r;K.g=G.g;K.b=G.b;wa(X,A.centroidWorld,A.normalWorld,K);Q.r=I.color.r*K.r;Q.g=I.color.g*K.g;Q.b=I.color.b*K.b;Q.updateStyleString();I.wireframe?ya(Q.__styleString, -I.wireframe_linewidth):za(Q.__styleString)}else I.wireframe?ya(I.color.__styleString,I.wireframe_linewidth):za(I.color.__styleString)}else if(I instanceof THREE.MeshDepthMaterial){n=I.__2near;g=I.__farPlusNear;o=I.__farMinusNear;e.r=e.g=e.b=1-n/(g-t.positionScreen.z*o);h.r=h.g=h.b=1-n/(g-V.positionScreen.z*o);m.r=m.g=m.b=1-n/(g-P.positionScreen.z*o);i.r=(h.r+m.r)*0.5;i.g=(h.g+m.g)*0.5;i.b=(h.b+m.b)*0.5;r=Ha(e,h,m,i);ra(N,s,U,B,L,O,r,0,0,1,0,0,1)}else if(I instanceof THREE.MeshNormalMaterial){Q.r= -Da(A.normalWorld.x);Q.g=Da(A.normalWorld.y);Q.b=Da(A.normalWorld.z);Q.updateStyleString();I.wireframe?ya(Q.__styleString,I.wireframe_linewidth):za(Q.__styleString)}}}function ya(t,V){if(c!=t)l.strokeStyle=c=t;if(v!=V)l.lineWidth=v=V;l.stroke();w.inflate(V*2)}function za(t){if(C!=t)l.fillStyle=C=t;l.fill()}function ra(t,V,P,A,I,X,$,ca,da,ia,fa,ja,sa){var la,ka;la=$.width-1;ka=$.height-1;ca*=la;da*=ka;ia*=la;fa*=ka;ja*=la;sa*=ka;P-=t;A-=V;I-=t;X-=V;ia-=ca;fa-=da;ja-=ca;sa-=da;ka=1/(ia*sa-ja*fa);la= -(sa*P-fa*I)*ka;fa=(sa*A-fa*X)*ka;P=(ia*I-ja*P)*ka;A=(ia*X-ja*A)*ka;t=t-la*ca-P*da;V=V-fa*ca-A*da;l.save();l.transform(la,fa,P,A,t,V);l.clip();l.drawImage($,0,0);l.restore()}function Ca(t){if(p!=t)l.globalAlpha=p=t}function xa(t){if(y!=t){switch(t){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}y=t}}function Ha(t,V,P,A){var I=~~(t.r*255), -X=~~(t.g*255);t=~~(t.b*255);var $=~~(V.r*255),ca=~~(V.g*255);V=~~(V.b*255);var da=~~(P.r*255),ia=~~(P.g*255);P=~~(P.b*255);var fa=~~(A.r*255),ja=~~(A.g*255);A=~~(A.b*255);ea[0]=I<0?0:I>255?255:I;ea[1]=X<0?0:X>255?255:X;ea[2]=t<0?0:t>255?255:t;ea[4]=$<0?0:$>255?255:$;ea[5]=ca<0?0:ca>255?255:ca;ea[6]=V<0?0:V>255?255:V;ea[8]=da<0?0:da>255?255:da;ea[9]=ia<0?0:ia>255?255:ia;ea[10]=P<0?0:P>255?255:P;ea[12]=fa<0?0:fa>255?255:fa;ea[13]=ja<0?0:ja>255?255:ja;ea[14]=A<0?0:A>255?255:A;pa.putImageData(Ba,0,0); -ua.drawImage(oa,0,0);return qa}function Da(t){t=(t+1)*0.5;return t<0?0:t>1?1:t}function Ea(t,V){var P=V.x-t.x,A=V.y-t.y,I=1/Math.sqrt(P*P+A*A);P*=I;A*=I;V.x+=P;V.y+=A;t.x-=P;t.y-=A}var Aa,Ia,Z,ga,na,Fa,Ja,ta;l.setTransform(1,0,0,-1,k,q);this.autoClear&&this.clear();a=b.projectScene(ha,va,this.sortElements);l.fillStyle="rgba( 0, 255, 255, 0.5 )";l.fillRect(S.getX(),S.getY(),S.getWidth(),S.getHeight());(x=ha.lights.length>0)&&La(ha);Aa=0;for(Ia=a.length;Aa0){F.r+=w.color.r*x;F.g+=w.color.g*x;F.b+=w.color.b*x}}else if(w instanceof THREE.PointLight){m.sub(w.position,T.centroidWorld);m.normalize();x=T.normalWorld.dot(m)*w.intensity;if(x>0){F.r+=w.color.r*x;F.g+=w.color.g*x;F.b+=w.color.b*x}}}}function b(z,T,F,S,D,w){o=d(r++);o.setAttribute("d","M "+z.positionScreen.x+ -" "+z.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+F.positionScreen.x+","+F.positionScreen.y+"z");if(D instanceof THREE.MeshBasicMaterial)B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshLambertMaterial)if(U){L.r=O.r;L.g=O.g;L.b=O.b;a(w,S,L);B.r=D.color.r*L.r;B.g=D.color.g*L.g;B.b=D.color.b*L.b;B.updateStyleString()}else B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshDepthMaterial){h=1-D.__2near/(D.__farPlusNear-S.z*D.__farMinusNear); -B.setRGB(h,h,h)}else D instanceof THREE.MeshNormalMaterial&&B.setRGB(j(S.normalWorld.x),j(S.normalWorld.y),j(S.normalWorld.z));D.wireframe?o.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+D.wireframe_linewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.wireframe_linecap+"; stroke-linejoin: "+D.wireframe_linejoin):o.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+D.opacity);l.appendChild(o)}function f(z,T,F,S,D,w,x){o=d(r++);o.setAttribute("d", -"M "+z.positionScreen.x+" "+z.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+F.positionScreen.x+","+F.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)B.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(U){L.r=O.r;L.g=O.g;L.b=O.b;a(x,D,L);B.r=w.color.r*L.r;B.g=w.color.g*L.g;B.b=w.color.b*L.b;B.updateStyleString()}else B.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){h= -1-w.__2near/(w.__farPlusNear-D.z*w.__farMinusNear);B.setRGB(h,h,h)}else w instanceof THREE.MeshNormalMaterial&&B.setRGB(j(D.normalWorld.x),j(D.normalWorld.y),j(D.normalWorld.z));w.wireframe?o.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):o.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+w.opacity);l.appendChild(o)} -function d(z){if(i[z]==null){i[z]=document.createElementNS("http://www.w3.org/2000/svg","path");H==0&&i[z].setAttribute("shape-rendering","crispEdges");return i[z]}return i[z]}function j(z){return z<0?Math.min((1+z)*0.5,0.5):0.5+Math.min(z*0.5,0.5)}var k=null,q=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,y,c,C,v,u,J,R,N=new THREE.Rectangle,s=new THREE.Rectangle,U=false,B=new THREE.Color(16777215),L=new THREE.Color(16777215),O=new THREE.Color(0),Q=new THREE.Color(0), -e=new THREE.Color(0),h,m=new THREE.Vector3,i=[],n=[],g=[],o,r,E,M,H=1;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(z){switch(z){case "high":H=1;break;case "low":H=0}};this.setSize=function(z,T){p=z;y=T;c=p/2;C=y/2;l.setAttribute("viewBox",-c+" "+-C+" "+p+" "+y);l.setAttribute("width",p);l.setAttribute("height",y);N.set(-c,-C,c,C)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(z,T){var F,S, -D,w,x,K,G,W;this.autoClear&&this.clear();k=q.projectScene(z,T,this.sortElements);M=E=r=0;if(U=z.lights.length>0){G=z.lights;O.setRGB(0,0,0);Q.setRGB(0,0,0);e.setRGB(0,0,0);F=0;for(S=G.length;F0?"#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,l("fragment",m+e));c.attachShader(i,l("vertex",n+h));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(e,h){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube); +THREE.Projector=function(){function a(e,g){return g.z-e.z}function b(e,g){var m=0,h=1,n=e.z+e.w,l=g.z+g.w,q=-e.z+e.w,t=-g.z+g.w;if(n>=0&&l>=0&&q>=0&&t>=0)return true;else if(n<0&&l<0||q<0&&t<0)return false;else{if(n<0)m=Math.max(m,n/(n-l));else if(l<0)h=Math.min(h,n/(n-l));if(q<0)m=Math.max(m,q/(q-t));else if(t<0)h=Math.min(h,q/(q-t));if(hn&&w.z0&&P.z<1){v=I[u]=I[u]||new THREE.RenderableParticle;v.x=P.x/P.w;v.y=P.y/P.w;v.z=P.z;v.rotation=B.rotation.z;v.scale.x=B.scale.x*Math.abs(v.x-(P.x+g.projectionMatrix.n11)/(P.w+g.projectionMatrix.n14)); +v.scale.y=B.scale.y*Math.abs(v.y-(P.y+g.projectionMatrix.n22)/(P.w+g.projectionMatrix.n24));v.materials=B.materials;h.push(v);u++}}}}m&&h.sort(a);return h};this.unprojectVector=function(e,g){var m=new THREE.Matrix4;m.multiply(THREE.Matrix4.makeInvert(g.matrix),THREE.Matrix4.makeInvert(g.projectionMatrix));m.multiplyVector3(e);return e}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,i,j;this.domElement=document.createElement("div");this.setSize=function(p,k){f=p;d=k;i=f/2;j=d/2};this.render=function(p,k){var o,x,c,E,v,u,I,T;a=b.projectScene(p,k);o=0;for(x=a.length;o0){z.r+=ba.r*X;z.g+=ba.g*X;z.b+=ba.b*X}}else if(X instanceof THREE.PointLight){Z.sub(X.position,W);Z.normalize();X=O.dot(Z)*ca;if(X>0){z.r+=ba.r*X;z.g+=ba.g*X;z.b+=ba.b*X}}}}function Ma(r,W,O){if(O.opacity!=0){Ca(O.opacity);xa(O.blending);var z,M,X,ba,ca,da;if(O instanceof THREE.ParticleBasicMaterial){if(O.map){ba=O.map;ca=ba.width>>1;da=ba.height>>1;M=W.scale.x*j;X=W.scale.y*p;O=M*ca;z=X*da;F.set(r.x-O,r.y-z,r.x+O, +r.y+z);if(!y.instersects(F))return;k.save();k.translate(r.x,r.y);k.rotate(-W.rotation);k.scale(M,-X);k.translate(-ca,-da);k.drawImage(ba,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(O instanceof THREE.ParticleCircleMaterial){if(H){G.r=L.r+C.r+N.r;G.g=L.g+C.g+N.g;G.b=L.b+C.b+N.b;R.r=O.color.r*G.r;R.g=O.color.g*G.g;R.b=O.color.b*G.b;R.updateStyleString()}else R.__styleString= +O.color.__styleString;O=W.scale.x*j;z=W.scale.y*p;F.set(r.x-O,r.y-z,r.x+O,r.y+z);if(y.instersects(F)){M=R.__styleString;if(E!=M)k.fillStyle=E=M;k.save();k.translate(r.x,r.y);k.rotate(-W.rotation);k.scale(O,z);k.beginPath();k.arc(0,0,1,0,Y,true);k.closePath();k.fill();k.restore()}}}}function Na(r,W,O,z){if(z.opacity!=0){Ca(z.opacity);xa(z.blending);k.beginPath();k.moveTo(r.positionScreen.x,r.positionScreen.y);k.lineTo(W.positionScreen.x,W.positionScreen.y);k.closePath();if(z instanceof THREE.LineBasicMaterial){R.__styleString= +z.color.__styleString;r=z.linewidth;if(v!=r)k.lineWidth=v=r;r=R.__styleString;if(c!=r)k.strokeStyle=c=r;k.stroke();F.inflate(z.linewidth*2)}}}function Ha(r,W,O,z,M,X){if(M.opacity!=0){Ca(M.opacity);xa(M.blending);P=r.positionScreen.x;s=r.positionScreen.y;V=W.positionScreen.x;D=W.positionScreen.y;J=O.positionScreen.x;Q=O.positionScreen.y;k.beginPath();k.moveTo(P,s);k.lineTo(V,D);k.lineTo(J,Q);k.lineTo(P,s);k.closePath();if(M instanceof THREE.MeshBasicMaterial)if(M.map)M.map.image.loaded&&M.map.mapping instanceof +THREE.UVMapping&&sa(P,s,V,D,J,Q,M.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);else if(M.env_map){if(M.env_map.image.loaded)if(M.env_map.mapping instanceof THREE.SphericalReflectionMapping){r=na.matrix;Z.copy(z.vertexNormalsWorld[0]);t=(Z.x*r.n11+Z.y*r.n12+Z.z*r.n13)*0.5+0.5;K=-(Z.x*r.n21+Z.y*r.n22+Z.z*r.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[1]);w=(Z.x*r.n11+Z.y*r.n12+Z.z*r.n13)*0.5+0.5;U=-(Z.x*r.n21+Z.y*r.n22+Z.z*r.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[2]);A= +(Z.x*r.n11+Z.y*r.n12+Z.z*r.n13)*0.5+0.5;B=-(Z.x*r.n21+Z.y*r.n22+Z.z*r.n23)*0.5+0.5;sa(P,s,V,D,J,Q,M.env_map.image,t,K,w,U,A,B)}}else M.wireframe?ya(M.color.__styleString,M.wireframe_linewidth):za(M.color.__styleString);else if(M instanceof THREE.MeshLambertMaterial){if(M.map&&!M.wireframe){M.map.mapping instanceof THREE.UVMapping&&sa(P,s,V,D,J,Q,M.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);xa(THREE.SubtractiveBlending)}if(H)if(!M.wireframe&&M.shading==THREE.SmoothShading&& +z.vertexNormalsWorld.length==3){e.r=g.r=m.r=L.r;e.g=g.g=m.g=L.g;e.b=g.b=m.b=L.b;wa(X,z.v1.positionWorld,z.vertexNormalsWorld[0],e);wa(X,z.v2.positionWorld,z.vertexNormalsWorld[1],g);wa(X,z.v3.positionWorld,z.vertexNormalsWorld[2],m);h.r=(g.r+m.r)*0.5;h.g=(g.g+m.g)*0.5;h.b=(g.b+m.b)*0.5;q=Ia(e,g,m,h);sa(P,s,V,D,J,Q,q,0,0,1,0,0,1)}else{G.r=L.r;G.g=L.g;G.b=L.b;wa(X,z.centroidWorld,z.normalWorld,G);R.r=M.color.r*G.r;R.g=M.color.g*G.g;R.b=M.color.b*G.b;R.updateStyleString();M.wireframe?ya(R.__styleString, +M.wireframe_linewidth):za(R.__styleString)}else M.wireframe?ya(M.color.__styleString,M.wireframe_linewidth):za(M.color.__styleString)}else if(M instanceof THREE.MeshDepthMaterial){n=na.near;l=na.far;e.r=e.g=e.b=1-Da(r.positionScreen.z,n,l);g.r=g.g=g.b=1-Da(W.positionScreen.z,n,l);m.r=m.g=m.b=1-Da(O.positionScreen.z,n,l);h.r=(g.r+m.r)*0.5;h.g=(g.g+m.g)*0.5;h.b=(g.b+m.b)*0.5;q=Ia(e,g,m,h);sa(P,s,V,D,J,Q,q,0,0,1,0,0,1)}else if(M instanceof THREE.MeshNormalMaterial){R.r=Ea(z.normalWorld.x);R.g=Ea(z.normalWorld.y); +R.b=Ea(z.normalWorld.z);R.updateStyleString();M.wireframe?ya(R.__styleString,M.wireframe_linewidth):za(R.__styleString)}}}function ya(r,W){if(c!=r)k.strokeStyle=c=r;if(v!=W)k.lineWidth=v=W;k.stroke();F.inflate(W*2)}function za(r){if(E!=r)k.fillStyle=E=r;k.fill()}function sa(r,W,O,z,M,X,ba,ca,da,ia,fa,ja,ta){var la,ka;la=ba.width-1;ka=ba.height-1;ca*=la;da*=ka;ia*=la;fa*=ka;ja*=la;ta*=ka;O-=r;z-=W;M-=r;X-=W;ia-=ca;fa-=da;ja-=ca;ta-=da;ka=1/(ia*ta-ja*fa);la=(ta*O-fa*M)*ka;fa=(ta*z-fa*X)*ka;O=(ia*M- +ja*O)*ka;z=(ia*X-ja*z)*ka;r=r-la*ca-O*da;W=W-fa*ca-z*da;k.save();k.transform(la,fa,O,z,r,W);k.clip();k.drawImage(ba,0,0);k.restore()}function Ca(r){if(o!=r)k.globalAlpha=o=r}function xa(r){if(x!=r){switch(r){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}x=r}}function Ia(r,W,O,z){var M=~~(r.r*255),X=~~(r.g*255);r=~~(r.b*255);var ba=~~(W.r* +255),ca=~~(W.g*255);W=~~(W.b*255);var da=~~(O.r*255),ia=~~(O.g*255);O=~~(O.b*255);var fa=~~(z.r*255),ja=~~(z.g*255);z=~~(z.b*255);ea[0]=M<0?0:M>255?255:M;ea[1]=X<0?0:X>255?255:X;ea[2]=r<0?0:r>255?255:r;ea[4]=ba<0?0:ba>255?255:ba;ea[5]=ca<0?0:ca>255?255:ca;ea[6]=W<0?0:W>255?255:W;ea[8]=da<0?0:da>255?255:da;ea[9]=ia<0?0:ia>255?255:ia;ea[10]=O<0?0:O>255?255:O;ea[12]=fa<0?0:fa>255?255:fa;ea[13]=ja<0?0:ja>255?255:ja;ea[14]=z<0?0:z>255?255:z;qa.putImageData(Ba,0,0);va.drawImage(pa,0,0);return ra}function Da(r, +W,O){r=(r-W)/(O-W);return r*r*(3-2*r)}function Ea(r){r=(r+1)*0.5;return r<0?0:r>1?1:r}function Fa(r,W){var O=W.x-r.x,z=W.y-r.y,M=1/Math.sqrt(O*O+z*z);O*=M;z*=M;W.x+=O;W.y+=z;r.x-=O;r.y-=z}var Aa,Ja,$,ga,oa,Ga,Ka,ua;k.setTransform(1,0,0,-1,j,p);this.autoClear&&this.clear();a=b.projectScene(ha,na,this.sortElements);k.fillStyle="rgba( 0, 255, 255, 0.5 )";k.fillRect(y.getX(),y.getY(),y.getWidth(),y.getHeight());(H=ha.lights.length>0)&&La(ha);Aa=0;for(Ja=a.length;Aa0){y.r+=H.color.r*G;y.g+=H.color.g*G;y.b+=H.color.b*G}}else if(H instanceof THREE.PointLight){m.sub(H.position,B.centroidWorld);m.normalize();G=B.normalWorld.dot(m)*H.intensity;if(G>0){y.r+=H.color.r*G;y.g+=H.color.g*G;y.b+=H.color.b*G}}}}function b(A,B,y,S,F,H){q=d(t++);q.setAttribute("d","M "+A.positionScreen.x+ +" "+A.positionScreen.y+" L "+B.positionScreen.x+" "+B.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)D.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(V){J.r=Q.r;J.g=Q.g;J.b=Q.b;a(H,S,J);D.r=F.color.r*J.r;D.g=F.color.g*J.g;D.b=F.color.b*J.b;D.updateStyleString()}else D.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){g=1-F.__2near/(F.__farPlusNear-S.z*F.__farMinusNear); +D.setRGB(g,g,g)}else F instanceof THREE.MeshNormalMaterial&&D.setRGB(i(S.normalWorld.x),i(S.normalWorld.y),i(S.normalWorld.z));F.wireframe?q.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):q.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+F.opacity);k.appendChild(q)}function f(A,B,y,S,F,H,G){q=d(t++);q.setAttribute("d", +"M "+A.positionScreen.x+" "+A.positionScreen.y+" L "+B.positionScreen.x+" "+B.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+"z");if(H instanceof THREE.MeshBasicMaterial)D.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshLambertMaterial)if(V){J.r=Q.r;J.g=Q.g;J.b=Q.b;a(G,F,J);D.r=H.color.r*J.r;D.g=H.color.g*J.g;D.b=H.color.b*J.b;D.updateStyleString()}else D.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshDepthMaterial){g= +1-H.__2near/(H.__farPlusNear-F.z*H.__farMinusNear);D.setRGB(g,g,g)}else H instanceof THREE.MeshNormalMaterial&&D.setRGB(i(F.normalWorld.x),i(F.normalWorld.y),i(F.normalWorld.z));H.wireframe?q.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+H.wireframe_linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: "+H.wireframe_linecap+"; stroke-linejoin: "+H.wireframe_linejoin):q.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+H.opacity);k.appendChild(q)} +function d(A){if(h[A]==null){h[A]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&h[A].setAttribute("shape-rendering","crispEdges");return h[A]}return h[A]}function i(A){return A<0?Math.min((1+A)*0.5,0.5):0.5+Math.min(A*0.5,0.5)}var j=null,p=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,x,c,E,v,u,I,T,P=new THREE.Rectangle,s=new THREE.Rectangle,V=false,D=new THREE.Color(16777215),J=new THREE.Color(16777215),Q=new THREE.Color(0),R=new THREE.Color(0), +e=new THREE.Color(0),g,m=new THREE.Vector3,h=[],n=[],l=[],q,t,K,w,U=1;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(A){switch(A){case "high":U=1;break;case "low":U=0}};this.setSize=function(A,B){o=A;x=B;c=o/2;E=x/2;k.setAttribute("viewBox",-c+" "+-E+" "+o+" "+x);k.setAttribute("width",o);k.setAttribute("height",x);P.set(-c,-E,c,E)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(A,B){var y,S, +F,H,G,L,C,N;this.autoClear&&this.clear();j=p.projectScene(A,B,this.sortElements);w=K=t=0;if(V=A.lights.length>0){C=A.lights;Q.setRGB(0,0,0);R.setRGB(0,0,0);e.setRGB(0,0,0);y=0;for(S=C.length;y0?"#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(h,k("fragment",m+e));c.attachShader(h,k("vertex",n+g));c.linkProgram(h);c.getProgramParameter(h,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(h,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");h.uniforms={};h.attributes={};return h}function d(e,g){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube); c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var m=0;m<6;++m)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+m,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[m]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+ -h);c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}function j(e,h){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,p(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,p(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,p(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER, -p(e.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+h);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function k(e,h){var m,i,n;m=0;for(i=h.length;m= 0.0 )": -"",h?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",h?"pointDiffuse += mColor * pointDiffuseWeight;":"",h?"pointSpecular += mSpecular * pointSpecularWeight;":"",h?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": -"",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",h?"totalLight += pointDiffuse + pointSpecular;": +g);c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}function i(e,g){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,o(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,o(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,o(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER, +o(e.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+g);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function j(e,g){var m,h,n;m=0;for(h=g.length;m= 0.0 )": +"",g?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",g?"pointDiffuse += mColor * pointDiffuseWeight;":"",g?"pointSpecular += mSpecular * pointSpecularWeight;":"",g?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": +"",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",g?"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#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif\n}"].join("\n"); -i=f(n,i,m);c.useProgram(i);k(i,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);m&&k(i,["fogColor","fogNear","fogFar"]);e&&k(i,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);h&&k(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);q(i,["position","normal","uv"]);return i}(L.directional,L.point,fog);this.setSize=function(e,h){y.width=e;y.height=h;c.viewport(0,0,y.width,y.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,h){var m,i,n,g,o, -r=[],E=[],M=[];g=[];o=[];c.uniform1i(e.uniforms.enableLighting,h.length);m=0;for(i=h.length;m0){K.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,K.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(w),c.STATIC_DRAW)}K.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,K.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(z),c.STATIC_DRAW);K.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, -K.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(T),c.STATIC_DRAW);K.__webGLFaceCount=z.length;K.__webGLLineCount=T.length}};this.renderBuffer=function(e,h,m,i,n){var g,o,r,E,M,H,z,T,F;if(i instanceof THREE.MeshShaderMaterial||i instanceof THREE.MeshDepthMaterial||i instanceof THREE.MeshNormalMaterial){if(!i.program){if(i instanceof THREE.MeshDepthMaterial){z=Q.depth;i.fragment_shader=z.fragment_shader;i.vertex_shader=z.vertex_shader;i.uniforms=z.uniforms;i.uniforms.mNear.value= -i.near;i.uniforms.mFar.value=i.far}else if(i instanceof THREE.MeshNormalMaterial){z=Q.normal;i.fragment_shader=z.fragment_shader;i.vertex_shader=z.vertex_shader;i.uniforms=z.uniforms}i.program=f(i.fragment_shader,i.vertex_shader,null);z=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(F in i.uniforms)z.push(F);k(i.program,z);q(i.program,["position","normal","uv","tangent"])}F=i.program}else F=v;if(F!=C){c.useProgram(F);C=F}F==v&&this.setupLights(F, -h);this.loadCamera(F,e);this.loadMatrices(F);if(i instanceof THREE.MeshShaderMaterial||i instanceof THREE.MeshDepthMaterial||i instanceof THREE.MeshNormalMaterial){r=i.wireframe;E=i.wireframe_linewidth;e=F;h=i.uniforms;var S;for(g in h){T=h[g].type;z=h[g].value;S=e.uniforms[g];if(T=="i")c.uniform1i(S,z);else if(T=="f")c.uniform1f(S,z);else if(T=="v3")c.uniform3f(S,z.x,z.y,z.z);else if(T=="c")c.uniform3f(S,z.r,z.g,z.b);else if(T=="t"){c.uniform1i(S,z);if(T=h[g].texture)T.image instanceof Array&&T.image.length== -6?d(T,z):j(T,z)}}}if(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshBasicMaterial){g=i.color;o=i.opacity;r=i.wireframe;E=i.wireframe_linewidth;M=i.map;H=i.env_map;h=i.combine==THREE.MixOperation;e=i.reflectivity;T=i.env_map&&i.env_map.mapping instanceof THREE.CubeRefractionMapping;z=i.refraction_ratio;c.uniform4f(F.uniforms.mColor,g.r*o,g.g*o,g.b*o,o);c.uniform1i(F.uniforms.mixEnvMap,h);c.uniform1f(F.uniforms.mReflectivity,e);c.uniform1i(F.uniforms.useRefract, -T);c.uniform1f(F.uniforms.mRefractionRatio,z);if(m){c.uniform1f(F.uniforms.fogNear,m.near);c.uniform1f(F.uniforms.fogFar,m.far);c.uniform3f(F.uniforms.fogColor,m.color.r,m.color.g,m.color.b)}}if(i instanceof THREE.MeshPhongMaterial){m=i.ambient;g=i.specular;i=i.shininess;c.uniform4f(F.uniforms.mAmbient,m.r,m.g,m.b,o);c.uniform4f(F.uniforms.mSpecular,g.r,g.g,g.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 i instanceof THREE.MeshBasicMaterial&&c.uniform1i(F.uniforms.material,0);if(M){j(M,0);c.uniform1i(F.uniforms.tMap,0);c.uniform1i(F.uniforms.enableMap,1)}else c.uniform1i(F.uniforms.enableMap,0);if(H){d(H,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,n.__webGLVertexBuffer);c.vertexAttribPointer(o.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.position);if(o.normal>= -0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer);c.vertexAttribPointer(o.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.normal)}if(o.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLTangentBuffer);c.vertexAttribPointer(o.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.tangent)}if(o.uv>=0)if(n.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.vertexAttribPointer(o.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.uv)}else c.disableVertexAttribArray(o.uv);if(r){c.lineWidth(E); -c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);c.drawElements(c.LINES,n.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(e,h,m,i,n,g,o){var r,E,M,H,z;M=0;for(H=i.materials.length;M=0;m--){i=e.__webGLObjects[m].object; -h==i&&e.__webGLObjects.splice(m,1)}};this.setupMatrices=function(e,h){e.autoUpdateMatrix&&e.updateMatrix();u.multiply(h.matrix,e.matrix);N.set(u.flatten());J=THREE.Matrix4.makeInvert3x3(u).transpose();U.set(J.m);B.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,R);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,N);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,s);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,U);c.uniformMatrix4fv(e.uniforms.objectMatrix, -false,B)};this.loadCamera=function(e,h){c.uniform3f(e.uniforms.cameraPosition,h.position.x,h.position.y,h.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,h){if(e){!h||h=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK); -else e=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0};var Q={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}", +h=f(n,h,m);c.useProgram(h);j(h,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);m&&j(h,["fogColor","fogNear","fogFar"]);e&&j(h,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);g&&j(h,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(h.uniforms.enableMap,0);c.uniform1i(h.uniforms.tMap,0);c.uniform1i(h.uniforms.enableCubeMap,0);c.uniform1i(h.uniforms.tCube,1);c.uniform1i(h.uniforms.mixEnvMap,0);c.uniform1i(h.uniforms.useRefract,0);p(h,["position","normal","uv"]);return h}(J.directional,J.point,fog);this.setSize=function(e,g){x.width=e;x.height=g;c.viewport(0,0,x.width,x.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,g){var m,h,n,l,q, +t=[],K=[],w=[];l=[];q=[];c.uniform1i(e.uniforms.enableLighting,g.length);m=0;for(h=g.length;m0){L.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,L.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(H),c.STATIC_DRAW)}L.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,L.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(A),c.STATIC_DRAW);L.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +L.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(B),c.STATIC_DRAW);L.__webGLFaceCount=A.length;L.__webGLLineCount=B.length}};this.renderBuffer=function(e,g,m,h,n){var l,q,t,K,w,U,A,B,y;if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshDepthMaterial||h instanceof THREE.MeshNormalMaterial){if(!h.program){if(h instanceof THREE.MeshDepthMaterial){A=R.depth;h.fragment_shader=A.fragment_shader;h.vertex_shader=A.vertex_shader;h.uniforms=A.uniforms;h.uniforms.mNear.value= +e.near;h.uniforms.mFar.value=e.far}else if(h instanceof THREE.MeshNormalMaterial){A=R.normal;h.fragment_shader=A.fragment_shader;h.vertex_shader=A.vertex_shader;h.uniforms=A.uniforms}h.program=f(h.fragment_shader,h.vertex_shader,null);A=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(y in h.uniforms)A.push(y);j(h.program,A);p(h.program,["position","normal","uv","tangent"])}y=h.program}else y=v;if(y!=E){c.useProgram(y);E=y}y==v&&this.setupLights(y, +g);this.loadCamera(y,e);this.loadMatrices(y);if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshDepthMaterial||h instanceof THREE.MeshNormalMaterial){t=h.wireframe;K=h.wireframe_linewidth;e=y;g=h.uniforms;var S;for(l in g){B=g[l].type;A=g[l].value;S=e.uniforms[l];if(B=="i")c.uniform1i(S,A);else if(B=="f")c.uniform1f(S,A);else if(B=="v3")c.uniform3f(S,A.x,A.y,A.z);else if(B=="c")c.uniform3f(S,A.r,A.g,A.b);else if(B=="t"){c.uniform1i(S,A);if(B=g[l].texture)B.image instanceof Array&&B.image.length== +6?d(B,A):i(B,A)}}}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshBasicMaterial){l=h.color;q=h.opacity;t=h.wireframe;K=h.wireframe_linewidth;w=h.map;U=h.env_map;g=h.combine==THREE.MixOperation;e=h.reflectivity;B=h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping;A=h.refraction_ratio;c.uniform4f(y.uniforms.mColor,l.r*q,l.g*q,l.b*q,q);c.uniform1i(y.uniforms.mixEnvMap,g);c.uniform1f(y.uniforms.mReflectivity,e);c.uniform1i(y.uniforms.useRefract, +B);c.uniform1f(y.uniforms.mRefractionRatio,A);if(m){c.uniform1f(y.uniforms.fogNear,m.near);c.uniform1f(y.uniforms.fogFar,m.far);c.uniform3f(y.uniforms.fogColor,m.color.r,m.color.g,m.color.b)}}if(h instanceof THREE.MeshPhongMaterial){m=h.ambient;l=h.specular;h=h.shininess;c.uniform4f(y.uniforms.mAmbient,m.r,m.g,m.b,q);c.uniform4f(y.uniforms.mSpecular,l.r,l.g,l.b,q);c.uniform1f(y.uniforms.mShininess,h);c.uniform1i(y.uniforms.material,2)}else if(h instanceof THREE.MeshLambertMaterial)c.uniform1i(y.uniforms.material, +1);else h instanceof THREE.MeshBasicMaterial&&c.uniform1i(y.uniforms.material,0);if(w){i(w,0);c.uniform1i(y.uniforms.tMap,0);c.uniform1i(y.uniforms.enableMap,1)}else c.uniform1i(y.uniforms.enableMap,0);if(U){d(U,1);c.uniform1i(y.uniforms.tCube,1);c.uniform1i(y.uniforms.enableCubeMap,1)}else c.uniform1i(y.uniforms.enableCubeMap,0);q=y.attributes;c.bindBuffer(c.ARRAY_BUFFER,n.__webGLVertexBuffer);c.vertexAttribPointer(q.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.position);if(q.normal>= +0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer);c.vertexAttribPointer(q.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.normal)}if(q.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLTangentBuffer);c.vertexAttribPointer(q.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.tangent)}if(q.uv>=0)if(n.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.vertexAttribPointer(q.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.uv)}else c.disableVertexAttribArray(q.uv);if(t){c.lineWidth(K); +c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);c.drawElements(c.LINES,n.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(e,g,m,h,n,l,q){var t,K,w,U,A;w=0;for(U=h.materials.length;w=0;m--){h=e.__webGLObjects[m].object; +g==h&&e.__webGLObjects.splice(m,1)}};this.setupMatrices=function(e,g){e.autoUpdateMatrix&&e.updateMatrix();u.multiply(g.matrix,e.matrix);P.set(u.flatten());I=THREE.Matrix4.makeInvert3x3(u).transpose();V.set(I.m);D.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,T);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,P);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,s);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,V);c.uniformMatrix4fv(e.uniforms.objectMatrix, +false,D)};this.loadCamera=function(e,g){c.uniform3f(e.uniforms.cameraPosition,g.position.x,g.position.y,g.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,g){if(e){!g||g=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK); +else e=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0};var R={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}", vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{},fragment_shader:"varying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );\n}",vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"}}}; THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=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.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null}; diff --git a/build/ThreeExtras.js b/build/ThreeExtras.js index 43cc3e0b..5e8d00e3 100644 --- a/build/ThreeExtras.js +++ b/build/ThreeExtras.js @@ -12,21 +12,21 @@ THREE.Vector4=function(a,b,e,d){this.x=a||0;this.y=b||0;this.z=e||0;this.w=d||1} THREE.Vector4.prototype={set:function(a,b,e,d){this.x=a;this.y=b;this.z=e;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}}; THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,e,d=a.objects,g=[];a=0;for(b=d.length;a0&&I>0&&L+I<1}var e,d,g,f,j,h,k,x,c,B, -r,t=a.geometry,y=t.vertices,A=[];e=0;for(d=t.faces.length;ek?d:k;g=g>x? -g:x}a()};this.add3Points=function(k,x,c,B,r,t){if(h){h=false;b=kc?k>r?k:r:c>r?c:r;g=x>B?x>t?x:t:B>t?B:t}else{b=kc?k>r?k>d?k:d:r>d?r:d:c>r?c>d?c:d:r>d?r:d;g=x>B?x>t?x>g?x:g:t>g?t:g:B>t?B>g?B:g:t>g?t:g}a()};this.addRectangle=function(k){if(h){h=false;b=k.getLeft();e=k.getTop();d=k.getRight();g=k.getBottom()}else{b=b0&&G>0&&O+G<1}var e,d,g,f,j,h,k,x,c,C, +r,t=a.geometry,y=t.vertices,A=[];e=0;for(d=t.faces.length;ek?d:k;g=g>x? +g:x}a()};this.add3Points=function(k,x,c,C,r,t){if(h){h=false;b=kc?k>r?k:r:c>r?c:r;g=x>C?x>t?x:t:C>t?C:t}else{b=kc?k>r?k>d?k:d:r>d?r:d:c>r?c>d?c:d:r>d?r:d;g=x>C?x>t?x>g?x:g:t>g?t:g:C>t?C>g?C:g:t>g?t:g}a()};this.addRectangle=function(k){if(h){h=false;b=k.getLeft();e=k.getTop();d=k.getRight();g=k.getBottom()}else{b=bk.getRight()?d:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;e-=k;d+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();e=e>k.getTop()?e:k.getTop();d=d=0&&Math.min(g,k.getBottom())-Math.max(e,k.getTop())>=0};this.empty=function(){h=true;g=d=e=b=0;a()};this.isEmpty=function(){return h};this.toString= function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+e+", bottom: "+g+", width: "+f+", height: "+j+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; -THREE.Matrix4=function(a,b,e,d,g,f,j,h,k,x,c,B,r,t,y,A){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=d||0;this.n21=g||0;this.n22=f||1;this.n23=j||0;this.n24=h||0;this.n31=k||0;this.n32=x||0;this.n33=c||1;this.n34=B||0;this.n41=r||0;this.n42=t||0;this.n43=y||0;this.n44=A||1}; -THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,e,d,g,f,j,h,k,x,c,B,r,t,y,A){this.n11=a;this.n12=b;this.n13=e;this.n14=d;this.n21=g;this.n22=f;this.n23=j;this.n24=h;this.n31=k;this.n32=x;this.n33=c;this.n34=B;this.n41=r;this.n42=t;this.n43=y;this.n44=A;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= +THREE.Matrix4=function(a,b,e,d,g,f,j,h,k,x,c,C,r,t,y,A){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=d||0;this.n21=g||0;this.n22=f||1;this.n23=j||0;this.n24=h||0;this.n31=k||0;this.n32=x||0;this.n33=c||1;this.n34=C||0;this.n41=r||0;this.n42=t||0;this.n43=y||0;this.n44=A||1}; +THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,e,d,g,f,j,h,k,x,c,C,r,t,y,A){this.n11=a;this.n12=b;this.n13=e;this.n14=d;this.n21=g;this.n22=f;this.n23=j;this.n24=h;this.n31=k;this.n32=x;this.n33=c;this.n34=C;this.n41=r;this.n42=t;this.n43=y;this.n44=A;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,e){var d=new THREE.Vector3,g=new THREE.Vector3,f=new THREE.Vector3;f.sub(a,b).normalize();d.cross(e,f).normalize();g.cross(f,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=f.x; this.n32=f.y;this.n33=f.z;this.n34=-f.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,e=a.y,d=a.z,g=1/(this.n41*b+this.n42*e+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*e+this.n13*d+this.n14)*g;a.y=(this.n21*b+this.n22*e+this.n23*d+this.n24)*g;a.z=(this.n31*b+this.n32*e+this.n33*d+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,e=a.y,d=a.z,g=a.w;a.x=this.n11*b+this.n12*e+this.n13*d+this.n14*g;a.y=this.n21*b+this.n22*e+this.n23*d+this.n24* -g;a.z=this.n31*b+this.n32*e+this.n33*d+this.n34*g;a.w=this.n41*b+this.n42*e+this.n43*d+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var e=a.n11,d=a.n12,g=a.n13,f=a.n14,j=a.n21,h=a.n22,k=a.n23,x=a.n24,c=a.n31,B=a.n32, -r=a.n33,t=a.n34,y=a.n41,A=a.n42,I=a.n43,w=a.n44,C=b.n11,n=b.n12,O=b.n13,L=b.n14,T=b.n21,i=b.n22,o=b.n23,s=b.n24,p=b.n31,u=b.n32,l=b.n33,v=b.n34,z=b.n41,J=b.n42,S=b.n43,Q=b.n44;this.n11=e*C+d*T+g*p+f*z;this.n12=e*n+d*i+g*u+f*J;this.n13=e*O+d*o+g*l+f*S;this.n14=e*L+d*s+g*v+f*Q;this.n21=j*C+h*T+k*p+x*z;this.n22=j*n+h*i+k*u+x*J;this.n23=j*O+h*o+k*l+x*S;this.n24=j*L+h*s+k*v+x*Q;this.n31=c*C+B*T+r*p+t*z;this.n32=c*n+B*i+r*u+t*J;this.n33=c*O+B*o+r*l+t*S;this.n34=c*L+B*s+r*v+t*Q;this.n41=y*C+A*T+I*p+w*z; -this.n42=y*n+A*i+I*u+w*J;this.n43=y*O+A*o+I*l+w*S;this.n44=y*L+A*s+I*v+w*Q;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,d=this.n13,g=this.n14,f=this.n21,j=this.n22,h=this.n23,k=this.n24,x=this.n31,c=this.n32,B=this.n33,r=this.n34,t=this.n41,y=this.n42,A=this.n43,I=this.n44,w=a.n11,C=a.n21,n=a.n31,O=a.n41,L=a.n12,T=a.n22,i=a.n32,o=a.n42,s=a.n13,p=a.n23,u=a.n33,l=a.n43,v=a.n14,z=a.n24,J=a.n34;a=a.n44;this.n11=b*w+e*C+d*n+g*O;this.n12=b*L+e*T+d*i+g*o;this.n13=b*s+e*p+d*u+g*l;this.n14= -b*v+e*z+d*J+g*a;this.n21=f*w+j*C+h*n+k*O;this.n22=f*L+j*T+h*i+k*o;this.n23=f*s+j*p+h*u+k*l;this.n24=f*v+j*z+h*J+k*a;this.n31=x*w+c*C+B*n+r*O;this.n32=x*L+c*T+B*i+r*o;this.n33=x*s+c*p+B*u+r*l;this.n34=x*v+c*z+B*J+r*a;this.n41=t*w+y*C+A*n+I*O;this.n42=t*L+y*T+A*i+I*o;this.n43=t*s+y*p+A*u+I*l;this.n44=t*v+y*z+A*J+I*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*= +g;a.z=this.n31*b+this.n32*e+this.n33*d+this.n34*g;a.w=this.n41*b+this.n42*e+this.n43*d+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var e=a.n11,d=a.n12,g=a.n13,f=a.n14,j=a.n21,h=a.n22,k=a.n23,x=a.n24,c=a.n31,C=a.n32, +r=a.n33,t=a.n34,y=a.n41,A=a.n42,G=a.n43,w=a.n44,D=b.n11,n=b.n12,P=b.n13,O=b.n14,U=b.n21,i=b.n22,m=b.n23,s=b.n24,o=b.n31,u=b.n32,q=b.n33,v=b.n34,B=b.n41,R=b.n42,F=b.n43,W=b.n44;this.n11=e*D+d*U+g*o+f*B;this.n12=e*n+d*i+g*u+f*R;this.n13=e*P+d*m+g*q+f*F;this.n14=e*O+d*s+g*v+f*W;this.n21=j*D+h*U+k*o+x*B;this.n22=j*n+h*i+k*u+x*R;this.n23=j*P+h*m+k*q+x*F;this.n24=j*O+h*s+k*v+x*W;this.n31=c*D+C*U+r*o+t*B;this.n32=c*n+C*i+r*u+t*R;this.n33=c*P+C*m+r*q+t*F;this.n34=c*O+C*s+r*v+t*W;this.n41=y*D+A*U+G*o+w*B; +this.n42=y*n+A*i+G*u+w*R;this.n43=y*P+A*m+G*q+w*F;this.n44=y*O+A*s+G*v+w*W;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,d=this.n13,g=this.n14,f=this.n21,j=this.n22,h=this.n23,k=this.n24,x=this.n31,c=this.n32,C=this.n33,r=this.n34,t=this.n41,y=this.n42,A=this.n43,G=this.n44,w=a.n11,D=a.n21,n=a.n31,P=a.n41,O=a.n12,U=a.n22,i=a.n32,m=a.n42,s=a.n13,o=a.n23,u=a.n33,q=a.n43,v=a.n14,B=a.n24,R=a.n34;a=a.n44;this.n11=b*w+e*D+d*n+g*P;this.n12=b*O+e*U+d*i+g*m;this.n13=b*s+e*o+d*u+g*q;this.n14= +b*v+e*B+d*R+g*a;this.n21=f*w+j*D+h*n+k*P;this.n22=f*O+j*U+h*i+k*m;this.n23=f*s+j*o+h*u+k*q;this.n24=f*v+j*B+h*R+k*a;this.n31=x*w+c*D+C*n+r*P;this.n32=x*O+c*U+C*i+r*m;this.n33=x*s+c*o+C*u+r*q;this.n34=x*v+c*B+C*R+r*a;this.n41=t*w+y*D+A*n+G*P;this.n42=t*O+y*U+A*i+G*m;this.n43=t*s+y*o+A*u+G*q;this.n44=t*v+y*B+A*R+G*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*= a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34* this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,e,d){var g=b[e];b[e]=b[d]; b[d]=g}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, @@ -47,17 +47,18 @@ THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){ THREE.Geometry.prototype={computeCentroids:function(){var a,b,e;a=0;for(b=this.faces.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x], +0;for(vl=this.vertices.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x], y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,e=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z< this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,e=this.vertices.length;b65535){k[j].counter+=1;h=k[j].hash+"_"+k[j].counter;if(this.geometryChunks[h]==undefined)this.geometryChunks[h]={faces:[],materials:materials,vertices:0}}this.geometryChunks[h].faces.push(d); this.geometryChunks[h].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; -THREE.Camera=function(a,b,e,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,e,d);this.autoUpdateMatrix=true;this.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g); -this.position.subSelf(g);this.target.position.subSelf(g)};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.Camera=function(a,b,e,d){this.fov=a;this.aspect=b;this.near=e;this.far=d;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=null;this.autoUpdateMatrix=true;this.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g); +this.position.subSelf(g);this.target.position.subSelf(g)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix();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.visible=this.autoUpdateMatrix=true}; THREE.Object3D.prototype={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.materials=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.materials=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D; @@ -80,9 +81,8 @@ a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refract undefined)this.wireframe_linejoin=a.wireframe_linejoin}}; THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (
id: "+this.id+"
color: "+this.color+"
ambient: "+this.ambient+"
specular: "+this.specular+"
shininess: "+this.shininess+"
map: "+this.map+"
specular_map: "+this.specular_map+"
env_map: "+this.env_map+"
combine: "+this.combine+"
reflectivity: "+this.reflectivity+"
refraction_ratio: "+this.refraction_ratio+"
opacity: "+this.opacity+"
shading: "+this.shading+"
wireframe: "+ this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
)"}};THREE.MeshPhongMaterialCounter={value:0}; -THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1E3;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){if(a.near!==undefined)this.near=a.near;if(a.far!==undefined)this.far=a.far;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear= -this.far-this.near};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial"}};THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){}; -THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}}; +THREE.MeshDepthMaterial=function(a){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){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial"}}; +THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}}; THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};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){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!== undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}}; THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (
id: "+this.id+"
blending: "+this.blending+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
)"}};THREE.MeshShaderMaterialCounter={value:0}; @@ -94,98 +94,98 @@ THREE.Texture.prototype={toString:function(){return"THREE.Texture (
image: " 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.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}}; THREE.Fog=function(a,b,e){this.color=new THREE.Color(a);this.near=b||1;this.far=e||1E3}; -THREE.Projector=function(){function a(i,o){return o.z-i.z}function b(i,o){var s=0,p=1,u=i.z+i.w,l=o.z+o.w,v=-i.z+i.w,z=-o.z+o.w;if(u>=0&&l>=0&&v>=0&&z>=0)return true;else if(u<0&&l<0||v<0&&z<0)return false;else{if(u<0)s=Math.max(s,u/(u-l));else if(l<0)p=Math.min(p,u/(u-l));if(v<0)s=Math.max(s,v/(v-z));else if(z<0)p=Math.min(p,v/(v-z));if(p0&&z.z<1}N=N.faces;l=0;for(v=N.length;l0&&I.z<1){r=y[t]=y[t]||new THREE.RenderableParticle;r.x=I.x/I.w;r.y=I.y/I.w;r.z=I.z;r.rotation=Q.rotation.z;r.scale.x=Q.scale.x*Math.abs(r.x-(I.x+o.projectionMatrix.n11)/(I.w+o.projectionMatrix.n14));r.scale.y=Q.scale.y* -Math.abs(r.y-(I.y+o.projectionMatrix.n22)/(I.w+o.projectionMatrix.n24));r.materials=Q.materials;p.push(r);t++}}}}s&&p.sort(a);return p};this.unprojectVector=function(i,o){var s=new THREE.Matrix4;s.multiply(THREE.Matrix4.makeInvert(o.matrix),THREE.Matrix4.makeInvert(o.projectionMatrix));s.multiplyVector3(i);return i}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,d,g,f;this.domElement=document.createElement("div");this.setSize=function(j,h){e=j;d=h;g=e/2;f=d/2};this.render=function(j,h){var k,x,c,B,r,t,y,A;a=b.projectScene(j,h);k=0;for(x=a.length;k0){K.r+=ca.r*$;K.g+=ca.g*$;K.b+=ca.b*$}}else if($ instanceof THREE.PointLight){Z.sub($.position,X);Z.normalize();$=U.dot(Z)*da;if($>0){K.r+=ca.r*$;K.g+=ca.g*$;K.b+=ca.b*$}}}}function Ma(E,X,U){if(U.opacity!=0){Da(U.opacity);za(U.blending);var K,R,$,ca,da,ea;if(U instanceof THREE.ParticleBasicMaterial){if(U.map){ca=U.map;da=ca.width>>1;ea=ca.height>>1;R=X.scale.x*f;$=X.scale.y*j;U=R*da;K=$*ea;F.set(E.x-U,E.y-K,E.x+U, -E.y+K);if(W.instersects(F)){h.save();h.translate(E.x,E.y);h.rotate(-X.rotation);h.scale(R,-$);h.translate(-da,-ea);h.drawImage(ca,0,0);h.restore()}}}else if(U instanceof THREE.ParticleCircleMaterial){if(G){m.r=q.r+D.r+P.r;m.g=q.g+D.g+P.g;m.b=q.b+D.b+P.b;T.r=U.color.r*m.r;T.g=U.color.g*m.g;T.b=U.color.b*m.b;T.updateStyleString()}else T.__styleString=U.color.__styleString;U=X.scale.x*f;K=X.scale.y*j;F.set(E.x-U,E.y-K,E.x+U,E.y+K);if(W.instersects(F)){R=T.__styleString;if(B!=R)h.fillStyle=B=R;h.save(); -h.translate(E.x,E.y);h.rotate(-X.rotation);h.scale(U,K);h.beginPath();h.arc(0,0,1,0,Y,true);h.closePath();h.fill();h.restore()}}}}function Na(E,X,U,K){if(K.opacity!=0){Da(K.opacity);za(K.blending);h.beginPath();h.moveTo(E.positionScreen.x,E.positionScreen.y);h.lineTo(X.positionScreen.x,X.positionScreen.y);h.closePath();if(K instanceof THREE.LineBasicMaterial){T.__styleString=K.color.__styleString;E=K.linewidth;if(r!=E)h.lineWidth=r=E;E=T.__styleString;if(c!=E)h.strokeStyle=c=E;h.stroke();F.inflate(K.linewidth* -2)}}}function Ha(E,X,U,K,R,$){if(R.opacity!=0){Da(R.opacity);za(R.blending);I=E.positionScreen.x;w=E.positionScreen.y;C=X.positionScreen.x;n=X.positionScreen.y;O=U.positionScreen.x;L=U.positionScreen.y;h.beginPath();h.moveTo(I,w);h.lineTo(C,n);h.lineTo(O,L);h.lineTo(I,w);h.closePath();if(R instanceof THREE.MeshBasicMaterial)if(R.map)R.map.image.loaded&&R.map.mapping instanceof THREE.UVMapping&&ta(I,w,C,n,O,L,R.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);else if(R.env_map){if(R.env_map.image.loaded)if(R.env_map.mapping instanceof -THREE.SphericalReflectionMapping){E=xa.matrix;Z.copy(K.vertexNormalsWorld[0]);J=(Z.x*E.n11+Z.y*E.n12+Z.z*E.n13)*0.5+0.5;S=-(Z.x*E.n21+Z.y*E.n22+Z.z*E.n23)*0.5+0.5;Z.copy(K.vertexNormalsWorld[1]);Q=(Z.x*E.n11+Z.y*E.n12+Z.z*E.n13)*0.5+0.5;H=-(Z.x*E.n21+Z.y*E.n22+Z.z*E.n23)*0.5+0.5;Z.copy(K.vertexNormalsWorld[2]);V=(Z.x*E.n11+Z.y*E.n12+Z.z*E.n13)*0.5+0.5;M=-(Z.x*E.n21+Z.y*E.n22+Z.z*E.n23)*0.5+0.5;ta(I,w,C,n,O,L,R.env_map.image,J,S,Q,H,V,M)}}else R.wireframe?Aa(R.color.__styleString,R.wireframe_linewidth): -Ba(R.color.__styleString);else if(R instanceof THREE.MeshLambertMaterial){if(R.map&&!R.wireframe){R.map.mapping instanceof THREE.UVMapping&&ta(I,w,C,n,O,L,R.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);za(THREE.SubtractiveBlending)}if(G)if(!R.wireframe&&R.shading==THREE.SmoothShading&&K.vertexNormalsWorld.length==3){i.r=o.r=s.r=q.r;i.g=o.g=s.g=q.g;i.b=o.b=s.b=q.b;ya($,K.v1.positionWorld,K.vertexNormalsWorld[0],i);ya($,K.v2.positionWorld,K.vertexNormalsWorld[1],o);ya($, -K.v3.positionWorld,K.vertexNormalsWorld[2],s);p.r=(o.r+s.r)*0.5;p.g=(o.g+s.g)*0.5;p.b=(o.b+s.b)*0.5;z=Ia(i,o,s,p);ta(I,w,C,n,O,L,z,0,0,1,0,0,1)}else{m.r=q.r;m.g=q.g;m.b=q.b;ya($,K.centroidWorld,K.normalWorld,m);T.r=R.color.r*m.r;T.g=R.color.g*m.g;T.b=R.color.b*m.b;T.updateStyleString();R.wireframe?Aa(T.__styleString,R.wireframe_linewidth):Ba(T.__styleString)}else R.wireframe?Aa(R.color.__styleString,R.wireframe_linewidth):Ba(R.color.__styleString)}else if(R instanceof THREE.MeshDepthMaterial){u=R.__2near; -l=R.__farPlusNear;v=R.__farMinusNear;i.r=i.g=i.b=1-u/(l-E.positionScreen.z*v);o.r=o.g=o.b=1-u/(l-X.positionScreen.z*v);s.r=s.g=s.b=1-u/(l-U.positionScreen.z*v);p.r=(o.r+s.r)*0.5;p.g=(o.g+s.g)*0.5;p.b=(o.b+s.b)*0.5;z=Ia(i,o,s,p);ta(I,w,C,n,O,L,z,0,0,1,0,0,1)}else if(R instanceof THREE.MeshNormalMaterial){T.r=Ea(K.normalWorld.x);T.g=Ea(K.normalWorld.y);T.b=Ea(K.normalWorld.z);T.updateStyleString();R.wireframe?Aa(T.__styleString,R.wireframe_linewidth):Ba(T.__styleString)}}}function Aa(E,X){if(c!=E)h.strokeStyle= -c=E;if(r!=X)h.lineWidth=r=X;h.stroke();F.inflate(X*2)}function Ba(E){if(B!=E)h.fillStyle=B=E;h.fill()}function ta(E,X,U,K,R,$,ca,da,ea,ka,ha,la,ua){var oa,ma;oa=ca.width-1;ma=ca.height-1;da*=oa;ea*=ma;ka*=oa;ha*=ma;la*=oa;ua*=ma;U-=E;K-=X;R-=E;$-=X;ka-=da;ha-=ea;la-=da;ua-=ea;ma=1/(ka*ua-la*ha);oa=(ua*U-ha*R)*ma;ha=(ua*K-ha*$)*ma;U=(ka*R-la*U)*ma;K=(ka*$-la*K)*ma;E=E-oa*da-U*ea;X=X-ha*da-K*ea;h.save();h.transform(oa,ha,U,K,E,X);h.clip();h.drawImage(ca,0,0);h.restore()}function Da(E){if(k!=E)h.globalAlpha= -k=E}function za(E){if(x!=E){switch(E){case THREE.NormalBlending:h.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:h.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:h.globalCompositeOperation="darker"}x=E}}function Ia(E,X,U,K){var R=~~(E.r*255),$=~~(E.g*255);E=~~(E.b*255);var ca=~~(X.r*255),da=~~(X.g*255);X=~~(X.b*255);var ea=~~(U.r*255),ka=~~(U.g*255);U=~~(U.b*255);var ha=~~(K.r*255),la=~~(K.g*255);K=~~(K.b*255);ga[0]=R<0?0:R>255?255:R;ga[1]=$<0?0: -$>255?255:$;ga[2]=E<0?0:E>255?255:E;ga[4]=ca<0?0:ca>255?255:ca;ga[5]=da<0?0:da>255?255:da;ga[6]=X<0?0:X>255?255:X;ga[8]=ea<0?0:ea>255?255:ea;ga[9]=ka<0?0:ka>255?255:ka;ga[10]=U<0?0:U>255?255:U;ga[12]=ha<0?0:ha>255?255:ha;ga[13]=la<0?0:la>255?255:la;ga[14]=K<0?0:K>255?255:K;na.putImageData(pa,0,0);wa.drawImage(fa,0,0);return sa}function Ea(E){E=(E+1)*0.5;return E<0?0:E>1?1:E}function Fa(E,X){var U=X.x-E.x,K=X.y-E.y,R=1/Math.sqrt(U*U+K*K);U*=R;K*=R;X.x+=U;X.y+=K;E.x-=U;E.y-=K}var Ca,Ja,ba,ia,ra,Ga, -Ka,va;h.setTransform(1,0,0,-1,f,j);this.autoClear&&this.clear();a=b.projectScene(ja,xa,this.sortElements);(G=ja.lights.length>0)&&La(ja);Ca=0;for(Ja=a.length;Ca0){M.r+=F.color.r*G;M.g+=F.color.g*G;M.b+=F.color.b*G}}else if(F instanceof THREE.PointLight){s.sub(F.position,V.centroidWorld);s.normalize();G=V.normalWorld.dot(s)*F.intensity;if(G>0){M.r+=F.color.r*G;M.g+=F.color.g*G;M.b+=F.color.b*G}}}}function b(H,V,M,W,N,F){v=d(z++);v.setAttribute("d","M "+H.positionScreen.x+ -" "+H.positionScreen.y+" L "+V.positionScreen.x+" "+V.positionScreen.y+" L "+M.positionScreen.x+","+M.positionScreen.y+"z");if(N instanceof THREE.MeshBasicMaterial)n.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshLambertMaterial)if(C){O.r=L.r;O.g=L.g;O.b=L.b;a(F,W,O);n.r=N.color.r*O.r;n.g=N.color.g*O.g;n.b=N.color.b*O.b;n.updateStyleString()}else n.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshDepthMaterial){o=1-N.__2near/(N.__farPlusNear-W.z*N.__farMinusNear); -n.setRGB(o,o,o)}else N instanceof THREE.MeshNormalMaterial&&n.setRGB(g(W.normalWorld.x),g(W.normalWorld.y),g(W.normalWorld.z));N.wireframe?v.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+N.wireframe_linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.wireframe_linecap+"; stroke-linejoin: "+N.wireframe_linejoin):v.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+N.opacity);h.appendChild(v)}function e(H,V,M,W,N,F,G){v=d(z++);v.setAttribute("d", -"M "+H.positionScreen.x+" "+H.positionScreen.y+" L "+V.positionScreen.x+" "+V.positionScreen.y+" L "+M.positionScreen.x+","+M.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)n.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(C){O.r=L.r;O.g=L.g;O.b=L.b;a(G,N,O);n.r=F.color.r*O.r;n.g=F.color.g*O.g;n.b=F.color.b*O.b;n.updateStyleString()}else n.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){o= -1-F.__2near/(F.__farPlusNear-N.z*F.__farMinusNear);n.setRGB(o,o,o)}else F instanceof THREE.MeshNormalMaterial&&n.setRGB(g(N.normalWorld.x),g(N.normalWorld.y),g(N.normalWorld.z));F.wireframe?v.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):v.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+F.opacity);h.appendChild(v)} -function d(H){if(p[H]==null){p[H]=document.createElementNS("http://www.w3.org/2000/svg","path");Q==0&&p[H].setAttribute("shape-rendering","crispEdges");return p[H]}return p[H]}function g(H){return H<0?Math.min((1+H)*0.5,0.5):0.5+Math.min(H*0.5,0.5)}var f=null,j=new THREE.Projector,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,x,c,B,r,t,y,A,I=new THREE.Rectangle,w=new THREE.Rectangle,C=false,n=new THREE.Color(16777215),O=new THREE.Color(16777215),L=new THREE.Color(0),T=new THREE.Color(0), -i=new THREE.Color(0),o,s=new THREE.Vector3,p=[],u=[],l=[],v,z,J,S,Q=1;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(H){switch(H){case "high":Q=1;break;case "low":Q=0}};this.setSize=function(H,V){k=H;x=V;c=k/2;B=x/2;h.setAttribute("viewBox",-c+" "+-B+" "+k+" "+x);h.setAttribute("width",k);h.setAttribute("height",x);I.set(-c,-B,c,B)};this.clear=function(){for(;h.childNodes.length>0;)h.removeChild(h.childNodes[0])};this.render=function(H,V){var M,W, -N,F,G,m,q,D;this.autoClear&&this.clear();f=j.projectScene(H,V,this.sortElements);S=J=z=0;if(C=H.lights.length>0){q=H.lights;L.setRGB(0,0,0);T.setRGB(0,0,0);i.setRGB(0,0,0);M=0;for(W=q.length;M0?"#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(p,h("fragment",s+i));c.attachShader(p,h("vertex",u+o));c.linkProgram(p);c.getProgramParameter(p,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(p,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");p.uniforms={};p.attributes={};return p}function d(i,o){if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube); +THREE.Projector=function(){function a(i,m){return m.z-i.z}function b(i,m){var s=0,o=1,u=i.z+i.w,q=m.z+m.w,v=-i.z+i.w,B=-m.z+m.w;if(u>=0&&q>=0&&v>=0&&B>=0)return true;else if(u<0&&q<0||v<0&&B<0)return false;else{if(u<0)s=Math.max(s,u/(u-q));else if(q<0)o=Math.min(o,u/(u-q));if(v<0)s=Math.max(s,v/(v-B));else if(B<0)o=Math.min(o,v/(v-B));if(ou&&F.z0&&G.z<1){r=y[t]=y[t]||new THREE.RenderableParticle;r.x=G.x/G.w;r.y=G.y/G.w;r.z=G.z;r.rotation=I.rotation.z;r.scale.x=I.scale.x*Math.abs(r.x-(G.x+m.projectionMatrix.n11)/(G.w+m.projectionMatrix.n14)); +r.scale.y=I.scale.y*Math.abs(r.y-(G.y+m.projectionMatrix.n22)/(G.w+m.projectionMatrix.n24));r.materials=I.materials;o.push(r);t++}}}}s&&o.sort(a);return o};this.unprojectVector=function(i,m){var s=new THREE.Matrix4;s.multiply(THREE.Matrix4.makeInvert(m.matrix),THREE.Matrix4.makeInvert(m.projectionMatrix));s.multiplyVector3(i);return i}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,d,g,f;this.domElement=document.createElement("div");this.setSize=function(j,h){e=j;d=h;g=e/2;f=d/2};this.render=function(j,h){var k,x,c,C,r,t,y,A;a=b.projectScene(j,h);k=0;for(x=a.length;k0){J.r+=ba.r*Z;J.g+=ba.g*Z;J.b+=ba.b*Z}}else if(Z instanceof THREE.PointLight){S.sub(Z.position,Y);S.normalize();Z=V.dot(S)*da;if(Z>0){J.r+=ba.r*Z;J.g+=ba.g*Z;J.b+=ba.b*Z}}}}function Ma(E,Y,V){if(V.opacity!=0){Ca(V.opacity);ya(V.blending);var J,T,Z,ba,da,fa;if(V instanceof THREE.ParticleBasicMaterial){if(V.map){ba=V.map;da=ba.width>>1;fa=ba.height>>1;T=Y.scale.x*f;Z=Y.scale.y*j;V=T*da;J=Z*fa;M.set(E.x-V,E.y-J,E.x+V, +E.y+J);if(K.instersects(M)){h.save();h.translate(E.x,E.y);h.rotate(-Y.rotation);h.scale(T,-Z);h.translate(-da,-fa);h.drawImage(ba,0,0);h.restore()}}}else if(V instanceof THREE.ParticleCircleMaterial){if(Q){N.r=l.r+p.r+z.r;N.g=l.g+p.g+z.g;N.b=l.b+p.b+z.b;U.r=V.color.r*N.r;U.g=V.color.g*N.g;U.b=V.color.b*N.b;U.updateStyleString()}else U.__styleString=V.color.__styleString;V=Y.scale.x*f;J=Y.scale.y*j;M.set(E.x-V,E.y-J,E.x+V,E.y+J);if(K.instersects(M)){T=U.__styleString;if(C!=T)h.fillStyle=C=T;h.save(); +h.translate(E.x,E.y);h.rotate(-Y.rotation);h.scale(V,J);h.beginPath();h.arc(0,0,1,0,L,true);h.closePath();h.fill();h.restore()}}}}function Na(E,Y,V,J){if(J.opacity!=0){Ca(J.opacity);ya(J.blending);h.beginPath();h.moveTo(E.positionScreen.x,E.positionScreen.y);h.lineTo(Y.positionScreen.x,Y.positionScreen.y);h.closePath();if(J instanceof THREE.LineBasicMaterial){U.__styleString=J.color.__styleString;E=J.linewidth;if(r!=E)h.lineWidth=r=E;E=U.__styleString;if(c!=E)h.strokeStyle=c=E;h.stroke();M.inflate(J.linewidth* +2)}}}function Ha(E,Y,V,J,T,Z){if(T.opacity!=0){Ca(T.opacity);ya(T.blending);G=E.positionScreen.x;w=E.positionScreen.y;D=Y.positionScreen.x;n=Y.positionScreen.y;P=V.positionScreen.x;O=V.positionScreen.y;h.beginPath();h.moveTo(G,w);h.lineTo(D,n);h.lineTo(P,O);h.lineTo(G,w);h.closePath();if(T instanceof THREE.MeshBasicMaterial)if(T.map)T.map.image.loaded&&T.map.mapping instanceof THREE.UVMapping&&ta(G,w,D,n,P,O,T.map.image,J.uvs[0].u,J.uvs[0].v,J.uvs[1].u,J.uvs[1].v,J.uvs[2].u,J.uvs[2].v);else if(T.env_map){if(T.env_map.image.loaded)if(T.env_map.mapping instanceof +THREE.SphericalReflectionMapping){E=qa.matrix;S.copy(J.vertexNormalsWorld[0]);B=(S.x*E.n11+S.y*E.n12+S.z*E.n13)*0.5+0.5;R=-(S.x*E.n21+S.y*E.n22+S.z*E.n23)*0.5+0.5;S.copy(J.vertexNormalsWorld[1]);F=(S.x*E.n11+S.y*E.n12+S.z*E.n13)*0.5+0.5;W=-(S.x*E.n21+S.y*E.n22+S.z*E.n23)*0.5+0.5;S.copy(J.vertexNormalsWorld[2]);H=(S.x*E.n11+S.y*E.n12+S.z*E.n13)*0.5+0.5;I=-(S.x*E.n21+S.y*E.n22+S.z*E.n23)*0.5+0.5;ta(G,w,D,n,P,O,T.env_map.image,B,R,F,W,H,I)}}else T.wireframe?za(T.color.__styleString,T.wireframe_linewidth): +Aa(T.color.__styleString);else if(T instanceof THREE.MeshLambertMaterial){if(T.map&&!T.wireframe){T.map.mapping instanceof THREE.UVMapping&&ta(G,w,D,n,P,O,T.map.image,J.uvs[0].u,J.uvs[0].v,J.uvs[1].u,J.uvs[1].v,J.uvs[2].u,J.uvs[2].v);ya(THREE.SubtractiveBlending)}if(Q)if(!T.wireframe&&T.shading==THREE.SmoothShading&&J.vertexNormalsWorld.length==3){i.r=m.r=s.r=l.r;i.g=m.g=s.g=l.g;i.b=m.b=s.b=l.b;xa(Z,J.v1.positionWorld,J.vertexNormalsWorld[0],i);xa(Z,J.v2.positionWorld,J.vertexNormalsWorld[1],m);xa(Z, +J.v3.positionWorld,J.vertexNormalsWorld[2],s);o.r=(m.r+s.r)*0.5;o.g=(m.g+s.g)*0.5;o.b=(m.b+s.b)*0.5;v=Ia(i,m,s,o);ta(G,w,D,n,P,O,v,0,0,1,0,0,1)}else{N.r=l.r;N.g=l.g;N.b=l.b;xa(Z,J.centroidWorld,J.normalWorld,N);U.r=T.color.r*N.r;U.g=T.color.g*N.g;U.b=T.color.b*N.b;U.updateStyleString();T.wireframe?za(U.__styleString,T.wireframe_linewidth):Aa(U.__styleString)}else T.wireframe?za(T.color.__styleString,T.wireframe_linewidth):Aa(T.color.__styleString)}else if(T instanceof THREE.MeshDepthMaterial){u=qa.near; +q=qa.far;i.r=i.g=i.b=1-Da(E.positionScreen.z,u,q);m.r=m.g=m.b=1-Da(Y.positionScreen.z,u,q);s.r=s.g=s.b=1-Da(V.positionScreen.z,u,q);o.r=(m.r+s.r)*0.5;o.g=(m.g+s.g)*0.5;o.b=(m.b+s.b)*0.5;v=Ia(i,m,s,o);ta(G,w,D,n,P,O,v,0,0,1,0,0,1)}else if(T instanceof THREE.MeshNormalMaterial){U.r=Ea(J.normalWorld.x);U.g=Ea(J.normalWorld.y);U.b=Ea(J.normalWorld.z);U.updateStyleString();T.wireframe?za(U.__styleString,T.wireframe_linewidth):Aa(U.__styleString)}}}function za(E,Y){if(c!=E)h.strokeStyle=c=E;if(r!=Y)h.lineWidth= +r=Y;h.stroke();M.inflate(Y*2)}function Aa(E){if(C!=E)h.fillStyle=C=E;h.fill()}function ta(E,Y,V,J,T,Z,ba,da,fa,ka,ha,la,ua){var na,ma;na=ba.width-1;ma=ba.height-1;da*=na;fa*=ma;ka*=na;ha*=ma;la*=na;ua*=ma;V-=E;J-=Y;T-=E;Z-=Y;ka-=da;ha-=fa;la-=da;ua-=fa;ma=1/(ka*ua-la*ha);na=(ua*V-ha*T)*ma;ha=(ua*J-ha*Z)*ma;V=(ka*T-la*V)*ma;J=(ka*Z-la*J)*ma;E=E-na*da-V*fa;Y=Y-ha*da-J*fa;h.save();h.transform(na,ha,V,J,E,Y);h.clip();h.drawImage(ba,0,0);h.restore()}function Ca(E){if(k!=E)h.globalAlpha=k=E}function ya(E){if(x!= +E){switch(E){case THREE.NormalBlending:h.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:h.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:h.globalCompositeOperation="darker"}x=E}}function Ia(E,Y,V,J){var T=~~(E.r*255),Z=~~(E.g*255);E=~~(E.b*255);var ba=~~(Y.r*255),da=~~(Y.g*255);Y=~~(Y.b*255);var fa=~~(V.r*255),ka=~~(V.g*255);V=~~(V.b*255);var ha=~~(J.r*255),la=~~(J.g*255);J=~~(J.b*255);ea[0]=T<0?0:T>255?255:T;ea[1]=Z<0?0:Z>255?255:Z;ea[2]=E<0?0:E> +255?255:E;ea[4]=ba<0?0:ba>255?255:ba;ea[5]=da<0?0:da>255?255:da;ea[6]=Y<0?0:Y>255?255:Y;ea[8]=fa<0?0:fa>255?255:fa;ea[9]=ka<0?0:ka>255?255:ka;ea[10]=V<0?0:V>255?255:V;ea[12]=ha<0?0:ha>255?255:ha;ea[13]=la<0?0:la>255?255:la;ea[14]=J<0?0:J>255?255:J;ga.putImageData(oa,0,0);wa.drawImage(ca,0,0);return sa}function Da(E,Y,V){E=(E-Y)/(V-Y);return E*E*(3-2*E)}function Ea(E){E=(E+1)*0.5;return E<0?0:E>1?1:E}function Fa(E,Y){var V=Y.x-E.x,J=Y.y-E.y,T=1/Math.sqrt(V*V+J*J);V*=T;J*=T;Y.x+=V;Y.y+=J;E.x-=V;E.y-= +J}var Ba,Ja,$,ia,ra,Ga,Ka,va;h.setTransform(1,0,0,-1,f,j);this.autoClear&&this.clear();a=b.projectScene(ja,qa,this.sortElements);(Q=ja.lights.length>0)&&La(ja);Ba=0;for(Ja=a.length;Ba0){K.r+=Q.color.r*N;K.g+=Q.color.g*N;K.b+=Q.color.b*N}}else if(Q instanceof THREE.PointLight){s.sub(Q.position,I.centroidWorld);s.normalize();N=I.normalWorld.dot(s)*Q.intensity;if(N>0){K.r+=Q.color.r*N;K.g+=Q.color.g*N;K.b+=Q.color.b*N}}}}function b(H,I,K,X,M,Q){v=d(B++);v.setAttribute("d","M "+H.positionScreen.x+ +" "+H.positionScreen.y+" L "+I.positionScreen.x+" "+I.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(D){P.r=O.r;P.g=O.g;P.b=O.b;a(Q,X,P);n.r=M.color.r*P.r;n.g=M.color.g*P.g;n.b=M.color.b*P.b;n.updateStyleString()}else n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){m=1-M.__2near/(M.__farPlusNear-X.z*M.__farMinusNear); +n.setRGB(m,m,m)}else M instanceof THREE.MeshNormalMaterial&&n.setRGB(g(X.normalWorld.x),g(X.normalWorld.y),g(X.normalWorld.z));M.wireframe?v.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):v.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+M.opacity);h.appendChild(v)}function e(H,I,K,X,M,Q,N){v=d(B++);v.setAttribute("d", +"M "+H.positionScreen.x+" "+H.positionScreen.y+" L "+I.positionScreen.x+" "+I.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(Q instanceof THREE.MeshBasicMaterial)n.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshLambertMaterial)if(D){P.r=O.r;P.g=O.g;P.b=O.b;a(N,M,P);n.r=Q.color.r*P.r;n.g=Q.color.g*P.g;n.b=Q.color.b*P.b;n.updateStyleString()}else n.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshDepthMaterial){m= +1-Q.__2near/(Q.__farPlusNear-M.z*Q.__farMinusNear);n.setRGB(m,m,m)}else Q instanceof THREE.MeshNormalMaterial&&n.setRGB(g(M.normalWorld.x),g(M.normalWorld.y),g(M.normalWorld.z));Q.wireframe?v.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+Q.wireframe_linewidth+"; stroke-opacity: "+Q.opacity+"; stroke-linecap: "+Q.wireframe_linecap+"; stroke-linejoin: "+Q.wireframe_linejoin):v.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+Q.opacity);h.appendChild(v)} +function d(H){if(o[H]==null){o[H]=document.createElementNS("http://www.w3.org/2000/svg","path");W==0&&o[H].setAttribute("shape-rendering","crispEdges");return o[H]}return o[H]}function g(H){return H<0?Math.min((1+H)*0.5,0.5):0.5+Math.min(H*0.5,0.5)}var f=null,j=new THREE.Projector,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,x,c,C,r,t,y,A,G=new THREE.Rectangle,w=new THREE.Rectangle,D=false,n=new THREE.Color(16777215),P=new THREE.Color(16777215),O=new THREE.Color(0),U=new THREE.Color(0), +i=new THREE.Color(0),m,s=new THREE.Vector3,o=[],u=[],q=[],v,B,R,F,W=1;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(H){switch(H){case "high":W=1;break;case "low":W=0}};this.setSize=function(H,I){k=H;x=I;c=k/2;C=x/2;h.setAttribute("viewBox",-c+" "+-C+" "+k+" "+x);h.setAttribute("width",k);h.setAttribute("height",x);G.set(-c,-C,c,C)};this.clear=function(){for(;h.childNodes.length>0;)h.removeChild(h.childNodes[0])};this.render=function(H,I){var K,X, +M,Q,N,l,p,z;this.autoClear&&this.clear();f=j.projectScene(H,I,this.sortElements);F=R=B=0;if(D=H.lights.length>0){p=H.lights;O.setRGB(0,0,0);U.setRGB(0,0,0);i.setRGB(0,0,0);K=0;for(X=p.length;K0?"#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(o,h("fragment",s+i));c.attachShader(o,h("vertex",u+m));c.linkProgram(o);c.getProgramParameter(o,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(o,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");o.uniforms={};o.attributes={};return o}function d(i,m){if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube); c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var s=0;s<6;++s)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image[s]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);i.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+ -o);c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube)}}function g(i,o){if(!i.__webGLTexture&&i.image.loaded){i.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,i.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,k(i.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,k(i.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,k(i.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER, -k(i.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+o);c.bindTexture(c.TEXTURE_2D,i.__webGLTexture)}function f(i,o){var s,p,u;s=0;for(p=o.length;s= 0.0 )": -"",o?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",o?"pointDiffuse += mColor * pointDiffuseWeight;":"",o?"pointSpecular += mSpecular * pointSpecularWeight;":"",o?"}":"",i?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"vec3 dirVector = normalize( lDirection.xyz );":"",i?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": -"",i?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",i?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",i?"float dirSpecularWeight = 0.0;":"",i?"if ( dirDotNormalHalf >= 0.0 )":"",i?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",i?"dirDiffuse += mColor * dirDiffuseWeight;":"",i?"dirSpecular += mSpecular * dirSpecularWeight;":"",i?"}":"","vec4 totalLight = mAmbient;",i?"totalLight += dirDiffuse + dirSpecular;":"",o?"totalLight += pointDiffuse + pointSpecular;": +m);c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube)}}function g(i,m){if(!i.__webGLTexture&&i.image.loaded){i.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,i.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,k(i.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,k(i.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,k(i.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER, +k(i.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_2D,i.__webGLTexture)}function f(i,m){var s,o,u;s=0;for(o=m.length;s= 0.0 )": +"",m?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",m?"pointDiffuse += mColor * pointDiffuseWeight;":"",m?"pointSpecular += mSpecular * pointSpecularWeight;":"",m?"}":"",i?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"vec3 dirVector = normalize( lDirection.xyz );":"",i?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": +"",i?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",i?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",i?"float dirSpecularWeight = 0.0;":"",i?"if ( dirDotNormalHalf >= 0.0 )":"",i?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",i?"dirDiffuse += mColor * dirDiffuseWeight;":"",i?"dirSpecular += mSpecular * dirSpecularWeight;":"",i?"}":"","vec4 totalLight = mAmbient;",i?"totalLight += dirDiffuse + dirSpecular;":"",m?"totalLight += pointDiffuse + pointSpecular;": "","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif\n}"].join("\n"); -p=e(u,p,s);c.useProgram(p);f(p,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);s&&f(p,["fogColor","fogNear","fogFar"]);i&&f(p,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);o&&f(p,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(p.uniforms.enableMap,0);c.uniform1i(p.uniforms.tMap,0);c.uniform1i(p.uniforms.enableCubeMap,0);c.uniform1i(p.uniforms.tCube,1);c.uniform1i(p.uniforms.mixEnvMap,0);c.uniform1i(p.uniforms.useRefract,0);j(p,["position","normal","uv"]);return p}(O.directional,O.point,fog);this.setSize=function(i,o){x.width=i;x.height=o;c.viewport(0,0,x.width,x.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(i,o){var s,p,u,l,v, -z=[],J=[],S=[];l=[];v=[];c.uniform1i(i.uniforms.enableLighting,o.length);s=0;for(p=o.length;s0){m.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,m.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(F),c.STATIC_DRAW)}m.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(H),c.STATIC_DRAW);m.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, -m.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(V),c.STATIC_DRAW);m.__webGLFaceCount=H.length;m.__webGLLineCount=V.length}};this.renderBuffer=function(i,o,s,p,u){var l,v,z,J,S,Q,H,V,M;if(p instanceof THREE.MeshShaderMaterial||p instanceof THREE.MeshDepthMaterial||p instanceof THREE.MeshNormalMaterial){if(!p.program){if(p instanceof THREE.MeshDepthMaterial){H=T.depth;p.fragment_shader=H.fragment_shader;p.vertex_shader=H.vertex_shader;p.uniforms=H.uniforms;p.uniforms.mNear.value= -p.near;p.uniforms.mFar.value=p.far}else if(p instanceof THREE.MeshNormalMaterial){H=T.normal;p.fragment_shader=H.fragment_shader;p.vertex_shader=H.vertex_shader;p.uniforms=H.uniforms}p.program=e(p.fragment_shader,p.vertex_shader,null);H=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(M in p.uniforms)H.push(M);f(p.program,H);j(p.program,["position","normal","uv","tangent"])}M=p.program}else M=r;if(M!=B){c.useProgram(M);B=M}M==r&&this.setupLights(M, -o);this.loadCamera(M,i);this.loadMatrices(M);if(p instanceof THREE.MeshShaderMaterial||p instanceof THREE.MeshDepthMaterial||p instanceof THREE.MeshNormalMaterial){z=p.wireframe;J=p.wireframe_linewidth;i=M;o=p.uniforms;var W;for(l in o){V=o[l].type;H=o[l].value;W=i.uniforms[l];if(V=="i")c.uniform1i(W,H);else if(V=="f")c.uniform1f(W,H);else if(V=="v3")c.uniform3f(W,H.x,H.y,H.z);else if(V=="c")c.uniform3f(W,H.r,H.g,H.b);else if(V=="t"){c.uniform1i(W,H);if(V=o[l].texture)V.image instanceof Array&&V.image.length== -6?d(V,H):g(V,H)}}}if(p instanceof THREE.MeshPhongMaterial||p instanceof THREE.MeshLambertMaterial||p instanceof THREE.MeshBasicMaterial){l=p.color;v=p.opacity;z=p.wireframe;J=p.wireframe_linewidth;S=p.map;Q=p.env_map;o=p.combine==THREE.MixOperation;i=p.reflectivity;V=p.env_map&&p.env_map.mapping instanceof THREE.CubeRefractionMapping;H=p.refraction_ratio;c.uniform4f(M.uniforms.mColor,l.r*v,l.g*v,l.b*v,v);c.uniform1i(M.uniforms.mixEnvMap,o);c.uniform1f(M.uniforms.mReflectivity,i);c.uniform1i(M.uniforms.useRefract, -V);c.uniform1f(M.uniforms.mRefractionRatio,H);if(s){c.uniform1f(M.uniforms.fogNear,s.near);c.uniform1f(M.uniforms.fogFar,s.far);c.uniform3f(M.uniforms.fogColor,s.color.r,s.color.g,s.color.b)}}if(p instanceof THREE.MeshPhongMaterial){s=p.ambient;l=p.specular;p=p.shininess;c.uniform4f(M.uniforms.mAmbient,s.r,s.g,s.b,v);c.uniform4f(M.uniforms.mSpecular,l.r,l.g,l.b,v);c.uniform1f(M.uniforms.mShininess,p);c.uniform1i(M.uniforms.material,2)}else if(p instanceof THREE.MeshLambertMaterial)c.uniform1i(M.uniforms.material, -1);else p instanceof THREE.MeshBasicMaterial&&c.uniform1i(M.uniforms.material,0);if(S){g(S,0);c.uniform1i(M.uniforms.tMap,0);c.uniform1i(M.uniforms.enableMap,1)}else c.uniform1i(M.uniforms.enableMap,0);if(Q){d(Q,1);c.uniform1i(M.uniforms.tCube,1);c.uniform1i(M.uniforms.enableCubeMap,1)}else c.uniform1i(M.uniforms.enableCubeMap,0);v=M.attributes;c.bindBuffer(c.ARRAY_BUFFER,u.__webGLVertexBuffer);c.vertexAttribPointer(v.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(v.position);if(v.normal>= -0){c.bindBuffer(c.ARRAY_BUFFER,u.__webGLNormalBuffer);c.vertexAttribPointer(v.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(v.normal)}if(v.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,u.__webGLTangentBuffer);c.vertexAttribPointer(v.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(v.tangent)}if(v.uv>=0)if(u.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,u.__webGLUVBuffer);c.vertexAttribPointer(v.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(v.uv)}else c.disableVertexAttribArray(v.uv);if(z){c.lineWidth(J); -c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.__webGLLineBuffer);c.drawElements(c.LINES,u.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,u.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(i,o,s,p,u,l,v){var z,J,S,Q,H;S=0;for(Q=p.materials.length;S=0;s--){p=i.__webGLObjects[s].object; -o==p&&i.__webGLObjects.splice(s,1)}};this.setupMatrices=function(i,o){i.autoUpdateMatrix&&i.updateMatrix();t.multiply(o.matrix,i.matrix);I.set(t.flatten());y=THREE.Matrix4.makeInvert3x3(t).transpose();C.set(y.m);n.set(i.matrix.flatten())};this.loadMatrices=function(i){c.uniformMatrix4fv(i.uniforms.viewMatrix,false,A);c.uniformMatrix4fv(i.uniforms.modelViewMatrix,false,I);c.uniformMatrix4fv(i.uniforms.projectionMatrix,false,w);c.uniformMatrix3fv(i.uniforms.normalMatrix,false,C);c.uniformMatrix4fv(i.uniforms.objectMatrix, -false,n)};this.loadCamera=function(i,o){c.uniform3f(i.uniforms.cameraPosition,o.position.x,o.position.y,o.position.z)};this.setBlending=function(i){switch(i){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(i,o){if(i){!o||o=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(i=="back")c.cullFace(c.BACK); -else i=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0};var T={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}", +o=e(u,o,s);c.useProgram(o);f(o,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);s&&f(o,["fogColor","fogNear","fogFar"]);i&&f(o,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);m&&f(o,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(o.uniforms.enableMap,0);c.uniform1i(o.uniforms.tMap,0);c.uniform1i(o.uniforms.enableCubeMap,0);c.uniform1i(o.uniforms.tCube,1);c.uniform1i(o.uniforms.mixEnvMap,0);c.uniform1i(o.uniforms.useRefract,0);j(o,["position","normal","uv"]);return o}(P.directional,P.point,fog);this.setSize=function(i,m){x.width=i;x.height=m;c.viewport(0,0,x.width,x.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(i,m){var s,o,u,q,v, +B=[],R=[],F=[];q=[];v=[];c.uniform1i(i.uniforms.enableLighting,m.length);s=0;for(o=m.length;s0){l.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,l.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(Q),c.STATIC_DRAW)}l.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,l.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(H),c.STATIC_DRAW);l.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +l.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(I),c.STATIC_DRAW);l.__webGLFaceCount=H.length;l.__webGLLineCount=I.length}};this.renderBuffer=function(i,m,s,o,u){var q,v,B,R,F,W,H,I,K;if(o instanceof THREE.MeshShaderMaterial||o instanceof THREE.MeshDepthMaterial||o instanceof THREE.MeshNormalMaterial){if(!o.program){if(o instanceof THREE.MeshDepthMaterial){H=U.depth;o.fragment_shader=H.fragment_shader;o.vertex_shader=H.vertex_shader;o.uniforms=H.uniforms;o.uniforms.mNear.value= +i.near;o.uniforms.mFar.value=i.far}else if(o instanceof THREE.MeshNormalMaterial){H=U.normal;o.fragment_shader=H.fragment_shader;o.vertex_shader=H.vertex_shader;o.uniforms=H.uniforms}o.program=e(o.fragment_shader,o.vertex_shader,null);H=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(K in o.uniforms)H.push(K);f(o.program,H);j(o.program,["position","normal","uv","tangent"])}K=o.program}else K=r;if(K!=C){c.useProgram(K);C=K}K==r&&this.setupLights(K, +m);this.loadCamera(K,i);this.loadMatrices(K);if(o instanceof THREE.MeshShaderMaterial||o instanceof THREE.MeshDepthMaterial||o instanceof THREE.MeshNormalMaterial){B=o.wireframe;R=o.wireframe_linewidth;i=K;m=o.uniforms;var X;for(q in m){I=m[q].type;H=m[q].value;X=i.uniforms[q];if(I=="i")c.uniform1i(X,H);else if(I=="f")c.uniform1f(X,H);else if(I=="v3")c.uniform3f(X,H.x,H.y,H.z);else if(I=="c")c.uniform3f(X,H.r,H.g,H.b);else if(I=="t"){c.uniform1i(X,H);if(I=m[q].texture)I.image instanceof Array&&I.image.length== +6?d(I,H):g(I,H)}}}if(o instanceof THREE.MeshPhongMaterial||o instanceof THREE.MeshLambertMaterial||o instanceof THREE.MeshBasicMaterial){q=o.color;v=o.opacity;B=o.wireframe;R=o.wireframe_linewidth;F=o.map;W=o.env_map;m=o.combine==THREE.MixOperation;i=o.reflectivity;I=o.env_map&&o.env_map.mapping instanceof THREE.CubeRefractionMapping;H=o.refraction_ratio;c.uniform4f(K.uniforms.mColor,q.r*v,q.g*v,q.b*v,v);c.uniform1i(K.uniforms.mixEnvMap,m);c.uniform1f(K.uniforms.mReflectivity,i);c.uniform1i(K.uniforms.useRefract, +I);c.uniform1f(K.uniforms.mRefractionRatio,H);if(s){c.uniform1f(K.uniforms.fogNear,s.near);c.uniform1f(K.uniforms.fogFar,s.far);c.uniform3f(K.uniforms.fogColor,s.color.r,s.color.g,s.color.b)}}if(o instanceof THREE.MeshPhongMaterial){s=o.ambient;q=o.specular;o=o.shininess;c.uniform4f(K.uniforms.mAmbient,s.r,s.g,s.b,v);c.uniform4f(K.uniforms.mSpecular,q.r,q.g,q.b,v);c.uniform1f(K.uniforms.mShininess,o);c.uniform1i(K.uniforms.material,2)}else if(o instanceof THREE.MeshLambertMaterial)c.uniform1i(K.uniforms.material, +1);else o instanceof THREE.MeshBasicMaterial&&c.uniform1i(K.uniforms.material,0);if(F){g(F,0);c.uniform1i(K.uniforms.tMap,0);c.uniform1i(K.uniforms.enableMap,1)}else c.uniform1i(K.uniforms.enableMap,0);if(W){d(W,1);c.uniform1i(K.uniforms.tCube,1);c.uniform1i(K.uniforms.enableCubeMap,1)}else c.uniform1i(K.uniforms.enableCubeMap,0);v=K.attributes;c.bindBuffer(c.ARRAY_BUFFER,u.__webGLVertexBuffer);c.vertexAttribPointer(v.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(v.position);if(v.normal>= +0){c.bindBuffer(c.ARRAY_BUFFER,u.__webGLNormalBuffer);c.vertexAttribPointer(v.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(v.normal)}if(v.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,u.__webGLTangentBuffer);c.vertexAttribPointer(v.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(v.tangent)}if(v.uv>=0)if(u.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,u.__webGLUVBuffer);c.vertexAttribPointer(v.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(v.uv)}else c.disableVertexAttribArray(v.uv);if(B){c.lineWidth(R); +c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.__webGLLineBuffer);c.drawElements(c.LINES,u.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,u.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(i,m,s,o,u,q,v){var B,R,F,W,H;F=0;for(W=o.materials.length;F=0;s--){o=i.__webGLObjects[s].object; +m==o&&i.__webGLObjects.splice(s,1)}};this.setupMatrices=function(i,m){i.autoUpdateMatrix&&i.updateMatrix();t.multiply(m.matrix,i.matrix);G.set(t.flatten());y=THREE.Matrix4.makeInvert3x3(t).transpose();D.set(y.m);n.set(i.matrix.flatten())};this.loadMatrices=function(i){c.uniformMatrix4fv(i.uniforms.viewMatrix,false,A);c.uniformMatrix4fv(i.uniforms.modelViewMatrix,false,G);c.uniformMatrix4fv(i.uniforms.projectionMatrix,false,w);c.uniformMatrix3fv(i.uniforms.normalMatrix,false,D);c.uniformMatrix4fv(i.uniforms.objectMatrix, +false,n)};this.loadCamera=function(i,m){c.uniform3f(i.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(i){switch(i){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(i,m){if(i){!m||m=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(i=="back")c.cullFace(c.BACK); +else i=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0};var U={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}", vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{},fragment_shader:"varying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );\n}",vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"}}}; THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=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.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null}; -var GeometryUtils={merge:function(a,b){var e=b instanceof THREE.Mesh,d=a.vertices.length,g=e?b.geometry:b,f=a.vertices,j=g.vertices,h=a.faces,k=g.faces,x=a.uvs;g=g.uvs;e&&b.updateMatrix();for(var c=0,B=j.length;c= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientColor, 1.0 );\ntotalLight += dirDiffuse + dirSpecular;\ntotalLight += pointDiffuse + pointSpecular;\ngl_FragColor = vec4( totalLight.xyz * vLightWeighting * aoTex, 1.0 );\n}", vertex_shader:"attribute vec4 tangent;\nuniform vec3 uDirLightPos;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightPos;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientLightColor;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvLightWeighting = uAmbientLightColor;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( vNormal, vPointLightVector ), 0.0 );\nvLightWeighting += uPointLightColor * pointLightWeighting;\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nfloat directionalLightWeighting = max( dot( vNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += uDirLightColor * directionalLightWeighting;\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"}, basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"void main() {\ngl_FragColor = vec4(1.0, 0.0, 0.0, 0.5);\n}"},cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}", -fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( -wPos.x, wPos.yz ) );\n}"}}},Cube=function(a,b,e,d,g,f,j,h){function k(A,I,w,C,n,O,L,T){var i,o=d||1,s=g||1,p=o+1,u=s+1,l=n/2,v=O/2;n=n/o;O=O/s;var z=x.vertices.length;if(A=="x"&&I=="y"||A=="y"&&I=="x")i="z";else if(A=="x"&&I=="z"||A=="z"&&I=="x")i="y";else if(A=="z"&&I=="y"||A=="y"&&I=="z")i="x";for(iy=0;iy0||(c=this.vertices.push(new THREE.Vertex(new THREE.Vector3(B,h,r)))-1);x.push(c)}b.push(x)}var t,y,A;g=b.length;for(e=0;e0)for(d=0;d1){t=this.vertices[j].position.clone(); -y=this.vertices[k].position.clone();A=this.vertices[x].position.clone();t.normalize();y.normalize();A.normalize();this.faces.push(new THREE.Face3(j,k,x,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([c,B,I])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; +var Sphere=function(a,b,e){THREE.Geometry.call(this);var d,g=Math.PI,f=Math.max(3,b||8),j=Math.max(2,e||6);b=[];for(e=0;e0||(c=this.vertices.push(new THREE.Vertex(new THREE.Vector3(C,h,r)))-1);x.push(c)}b.push(x)}var t,y,A;g=b.length;for(e=0;e0)for(d=0;d1){t=this.vertices[j].position.clone(); +y=this.vertices[k].position.clone();A=this.vertices[x].position.clone();t.normalize();y.normalize();A.normalize();this.faces.push(new THREE.Face3(j,k,x,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([c,C,G])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null}; THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML= b},loadAsciiOld:function(a,b){var e=document.createElement("script");e.type="text/javascript";e.onload=b;e.src=a;document.getElementsByTagName("head")[0].appendChild(e)},loadAscii:function(a,b,e){var d=(new Date).getTime();a=new Worker(a);a.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,b,e)};a.postMessage(d)},loadBinary:function(a,b,e){var d=(new Date).getTime();a=new Worker(a);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(f){THREE.Loader.prototype.loadAjaxBuffers(f.data.buffers, f.data.materials,b,e,g)};a.onerror=function(f){alert("worker.onerror: "+f.message+"\n"+f.data);f.preventDefault()};a.postMessage(d)},loadAjaxBuffers:function(a,b,e,d,g){var f=new XMLHttpRequest,j=d+"/"+a,h=0;f.onreadystatechange=function(){if(f.readyState==4)f.status==200||f.status==0?THREE.Loader.prototype.createBinModel(f.responseText,e,d,b):alert("Couldn't load ["+j+"] ["+f.status+"]");else if(f.readyState==3){if(g){if(h==0)h=f.getResponseHeader("Content-Length");g({total:h,loaded:f.responseText.length})}}else if(f.readyState== -2)h=f.getResponseHeader("Content-Length")};f.open("GET",j,true);f.overrideMimeType("text/plain; charset=x-user-defined");f.setRequestHeader("Content-Type","text/plain");f.send(null)},createBinModel:function(a,b,e,d){var g=function(f){function j(m,q){var D=c(m,q),P=c(m,q+1),Y=c(m,q+2),Z=c(m,q+3),fa=(Z<<1&255|Y>>7)-127;D=(Y&127)<<16|P<<8|D;if(D==0&&fa==-127)return 0;return(1-2*(Z>>7))*(1+D*Math.pow(2,-23))*Math.pow(2,fa)}function h(m,q){var D=c(m,q),P=c(m,q+1),Y=c(m,q+2);return(c(m,q+3)<<24)+(Y<<16)+ -(P<<8)+D}function k(m,q){var D=c(m,q);return(c(m,q+1)<<8)+D}function x(m,q){var D=c(m,q);return D>127?D-256:D}function c(m,q){return m.charCodeAt(q)&255}function B(m){var q,D,P;q=h(a,m);D=h(a,m+T);P=h(a,m+i);m=k(a,m+o);THREE.Loader.prototype.f3(w,q,D,P,m)}function r(m){var q,D,P,Y,Z,fa;q=h(a,m);D=h(a,m+T);P=h(a,m+i);Y=k(a,m+o);Z=h(a,m+s);fa=h(a,m+p);m=h(a,m+u);THREE.Loader.prototype.f3n(w,O,q,D,P,Y,Z,fa,m)}function t(m){var q,D,P,Y;q=h(a,m);D=h(a,m+l);P=h(a,m+v);Y=h(a,m+z);m=k(a,m+J);THREE.Loader.prototype.f4(w, -q,D,P,Y,m)}function y(m){var q,D,P,Y,Z,fa,na,pa;q=h(a,m);D=h(a,m+l);P=h(a,m+v);Y=h(a,m+z);Z=k(a,m+J);fa=h(a,m+S);na=h(a,m+Q);pa=h(a,m+H);m=h(a,m+V);THREE.Loader.prototype.f4n(w,O,q,D,P,Y,Z,fa,na,pa,m)}function A(m){var q,D;q=h(a,m);D=h(a,m+M);m=h(a,m+W);THREE.Loader.prototype.uv3(w,L[q*2],L[q*2+1],L[D*2],L[D*2+1],L[m*2],L[m*2+1])}function I(m){var q,D,P;q=h(a,m);D=h(a,m+N);P=h(a,m+F);m=h(a,m+G);THREE.Loader.prototype.uv4(w,L[q*2],L[q*2+1],L[D*2],L[D*2+1],L[P*2],L[P*2+1],L[m*2],L[m*2+1])}var w=this, -C=0,n,O=[],L=[],T,i,o,s,p,u,l,v,z,J,S,Q,H,V,M,W,N,F,G;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,d,f);n={signature:a.substr(C,8),header_bytes:c(a,C+8),vertex_coordinate_bytes:c(a,C+9),normal_coordinate_bytes:c(a,C+10),uv_coordinate_bytes:c(a,C+11),vertex_index_bytes:c(a,C+12),normal_index_bytes:c(a,C+13),uv_index_bytes:c(a,C+14),material_index_bytes:c(a,C+15),nvertices:h(a,C+16),nnormals:h(a,C+16+4),nuvs:h(a,C+16+8),ntri_flat:h(a,C+16+12),ntri_smooth:h(a,C+16+16),ntri_flat_uv:h(a, -C+16+20),ntri_smooth_uv:h(a,C+16+24),nquad_flat:h(a,C+16+28),nquad_smooth:h(a,C+16+32),nquad_flat_uv:h(a,C+16+36),nquad_smooth_uv:h(a,C+16+40)};C+=n.header_bytes;T=n.vertex_index_bytes;i=n.vertex_index_bytes*2;o=n.vertex_index_bytes*3;s=n.vertex_index_bytes*3+n.material_index_bytes;p=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;u=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;l=n.vertex_index_bytes;v=n.vertex_index_bytes*2;z=n.vertex_index_bytes*3;J=n.vertex_index_bytes* -4;S=n.vertex_index_bytes*4+n.material_index_bytes;Q=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;H=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;V=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;M=n.uv_index_bytes;W=n.uv_index_bytes*2;N=n.uv_index_bytes;F=n.uv_index_bytes*2;G=n.uv_index_bytes*3;C+=function(m){var q,D,P,Y=n.vertex_coordinate_bytes*3,Z=m+n.nvertices*Y;for(m=m;m>7)-127;z=(S&127)<<16|L<<8|z;if(z==0&&ga==-127)return 0;return(1-2*(ca>>7))*(1+z*Math.pow(2,-23))*Math.pow(2,ga)}function h(l,p){var z=c(l,p),L=c(l,p+1),S=c(l,p+2);return(c(l,p+3)<<24)+(S<< +16)+(L<<8)+z}function k(l,p){var z=c(l,p);return(c(l,p+1)<<8)+z}function x(l,p){var z=c(l,p);return z>127?z-256:z}function c(l,p){return l.charCodeAt(p)&255}function C(l){var p,z,L;p=h(a,l);z=h(a,l+U);L=h(a,l+i);l=k(a,l+m);THREE.Loader.prototype.f3(w,p,z,L,l)}function r(l){var p,z,L,S,ca,ga;p=h(a,l);z=h(a,l+U);L=h(a,l+i);S=k(a,l+m);ca=h(a,l+s);ga=h(a,l+o);l=h(a,l+u);THREE.Loader.prototype.f3n(w,P,p,z,L,S,ca,ga,l)}function t(l){var p,z,L,S;p=h(a,l);z=h(a,l+q);L=h(a,l+v);S=h(a,l+B);l=k(a,l+R);THREE.Loader.prototype.f4(w, +p,z,L,S,l)}function y(l){var p,z,L,S,ca,ga,oa,ea;p=h(a,l);z=h(a,l+q);L=h(a,l+v);S=h(a,l+B);ca=k(a,l+R);ga=h(a,l+F);oa=h(a,l+W);ea=h(a,l+H);l=h(a,l+I);THREE.Loader.prototype.f4n(w,P,p,z,L,S,ca,ga,oa,ea,l)}function A(l){var p,z;p=h(a,l);z=h(a,l+K);l=h(a,l+X);THREE.Loader.prototype.uv3(w,O[p*2],O[p*2+1],O[z*2],O[z*2+1],O[l*2],O[l*2+1])}function G(l){var p,z,L;p=h(a,l);z=h(a,l+M);L=h(a,l+Q);l=h(a,l+N);THREE.Loader.prototype.uv4(w,O[p*2],O[p*2+1],O[z*2],O[z*2+1],O[L*2],O[L*2+1],O[l*2],O[l*2+1])}var w= +this,D=0,n,P=[],O=[],U,i,m,s,o,u,q,v,B,R,F,W,H,I,K,X,M,Q,N;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,d,f);n={signature:a.substr(D,8),header_bytes:c(a,D+8),vertex_coordinate_bytes:c(a,D+9),normal_coordinate_bytes:c(a,D+10),uv_coordinate_bytes:c(a,D+11),vertex_index_bytes:c(a,D+12),normal_index_bytes:c(a,D+13),uv_index_bytes:c(a,D+14),material_index_bytes:c(a,D+15),nvertices:h(a,D+16),nnormals:h(a,D+16+4),nuvs:h(a,D+16+8),ntri_flat:h(a,D+16+12),ntri_smooth:h(a,D+16+16),ntri_flat_uv:h(a, +D+16+20),ntri_smooth_uv:h(a,D+16+24),nquad_flat:h(a,D+16+28),nquad_smooth:h(a,D+16+32),nquad_flat_uv:h(a,D+16+36),nquad_smooth_uv:h(a,D+16+40)};D+=n.header_bytes;U=n.vertex_index_bytes;i=n.vertex_index_bytes*2;m=n.vertex_index_bytes*3;s=n.vertex_index_bytes*3+n.material_index_bytes;o=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;u=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;q=n.vertex_index_bytes;v=n.vertex_index_bytes*2;B=n.vertex_index_bytes*3;R=n.vertex_index_bytes* +4;F=n.vertex_index_bytes*4+n.material_index_bytes;W=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;H=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;I=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;K=n.uv_index_bytes;X=n.uv_index_bytes*2;M=n.uv_index_bytes;Q=n.uv_index_bytes*2;N=n.uv_index_bytes*3;D+=function(l){var p,z,L,S=n.vertex_coordinate_bytes*3,ca=l+n.nvertices*S;for(l=l;l

-		
+
 		
 
 		
@@ -78,7 +78,7 @@
 				materials.push( { material: new THREE.MeshNormalMaterial( { shading: THREE.SmoothShading } ), overdraw: true, doubleSided: false } );
 				materials.push( { material: new THREE.MeshBasicMaterial( { color: 0xffaa00, wireframe: true } ), overdraw: false, doubleSided: true } );
 
-				materials.push( { material: new THREE.MeshDepthMaterial( { near: 1, far: 2000 } ), overdraw: true, doubleSided: false } );
+				materials.push( { material: new THREE.MeshDepthMaterial(), overdraw: true, doubleSided: false } );
 				materials.push( { material: new THREE.MeshBasicMaterial( { map: generatedTexture } ), overdraw: true, doubleSided: false } );
 				materials.push( { material: new THREE.MeshLambertMaterial( { map: generatedTexture } ), overdraw: true, doubleSided: false } );
 
diff --git a/src/cameras/Camera.js b/src/cameras/Camera.js
index e6e4d99d..2e1381df 100644
--- a/src/cameras/Camera.js
+++ b/src/cameras/Camera.js
@@ -4,13 +4,18 @@
 
 THREE.Camera = function ( fov, aspect, near, far ) {
 
+	this.fov = fov;
+	this.aspect = aspect;
+	this.near = near;
+	this.far = far;
+
 	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( fov, aspect, near, far );
+	this.projectionMatrix = null;
 
 	this.autoUpdateMatrix = true;
 
@@ -45,6 +50,14 @@ THREE.Camera = function ( fov, aspect, near, far ) {
 
 	};
 
+	this.updateProjectionMatrix = function () {
+
+		this.projectionMatrix = THREE.Matrix4.makePerspective( this.fov, this.aspect, this.near, this.far );
+
+	};
+
+	this.updateProjectionMatrix();
+
 	this.toString = function () {
 
 		return 'THREE.Camera ( ' + this.position + ', ' + this.target.position + ' )';
diff --git a/src/core/Vertex.js b/src/core/Vertex.js
index af45869c..3590829b 100644
--- a/src/core/Vertex.js
+++ b/src/core/Vertex.js
@@ -13,7 +13,7 @@ THREE.Vertex = function ( position, normal ) {
 	this.normalScreen = new THREE.Vector3();
 
 	this.tangent = new THREE.Vector4();
-	
+
 	this.__visible = true;
 
 }
diff --git a/src/materials/MeshDepthMaterial.js b/src/materials/MeshDepthMaterial.js
index d1956904..67f71e22 100644
--- a/src/materials/MeshDepthMaterial.js
+++ b/src/materials/MeshDepthMaterial.js
@@ -2,8 +2,6 @@
  * @author mr.doob / http://mrdoob.com/
  *
  * parameters = {
- *  near: ,
- *  far: ,
  *  opacity: ,
  *  blending: THREE.NormalBlending
  * } 
@@ -11,9 +9,6 @@
 
 THREE.MeshDepthMaterial = function ( parameters ) {
 
-	this.near = 1;
-	this.far = 1000;
-
 	this.opacity = 1;
 	this.shading = THREE.SmoothShading;
 	this.blending = THREE.NormalBlending;
@@ -25,17 +20,11 @@ THREE.MeshDepthMaterial = function ( parameters ) {
 
 	if ( parameters ) {
 
-		if ( parameters.near !== undefined ) this.near = parameters.near;
-		if ( parameters.far !== undefined ) this.far = parameters.far;
 		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
 
 	}
 
-	this.__2near = 2 * this.near;
-	this.__farPlusNear = this.far + this.near;
-	this.__farMinusNear = this.far - this.near;
-
 };
 
 THREE.MeshDepthMaterial.prototype = {
diff --git a/src/renderers/CanvasRenderer.js b/src/renderers/CanvasRenderer.js
index 81eb3efa..47e90809 100644
--- a/src/renderers/CanvasRenderer.js
+++ b/src/renderers/CanvasRenderer.js
@@ -25,7 +25,8 @@ THREE.CanvasRenderer = function () {
 	_color2 = new THREE.Color(),
 	_color3 = new THREE.Color(),
 	_color4 = new THREE.Color(),
-	_2near, _farPlusNear, _farMinusNear,
+
+	_near, _far,
 
 	_bitmap,
 	_uv1x, _uv1y, _uv2x, _uv2y, _uv3x, _uv3y,
@@ -575,13 +576,12 @@ THREE.CanvasRenderer = function () {
 				_color.setRGB( _w, _w, _w );
 				*/
 
-				_2near = material.__2near;
-				_farPlusNear = material.__farPlusNear;
-				_farMinusNear = material.__farMinusNear;
+				_near = camera.near;
+				_far = camera.far;
 
-				_color1.r = _color1.g = _color1.b = 1 - ( _2near / ( _farPlusNear - v1.positionScreen.z * _farMinusNear ) );
-				_color2.r = _color2.g = _color2.b = 1 - ( _2near / ( _farPlusNear - v2.positionScreen.z * _farMinusNear ) );
-				_color3.r = _color3.g = _color3.b = 1 - ( _2near / ( _farPlusNear - v3.positionScreen.z * _farMinusNear ) );
+				_color1.r = _color1.g = _color1.b = 1 - smoothstep( v1.positionScreen.z, _near, _far );
+				_color2.r = _color2.g = _color2.b = 1 - smoothstep( v2.positionScreen.z, _near, _far );
+				_color3.r = _color3.g = _color3.b = 1 - smoothstep( v3.positionScreen.z, _near, _far );
 
 				_color4.r = ( _color2.r + _color3.r ) * 0.5;
 				_color4.g = ( _color2.g + _color3.g ) * 0.5;
@@ -789,6 +789,18 @@ THREE.CanvasRenderer = function () {
 
 		}
 
+		function smoothstep( value, min, max ) {
+
+			/*
+			if ( value <= min ) return 0;
+			if ( value >= max ) return 1;
+			*/
+
+			var x = ( value - min ) / ( max - min );
+			return x * x * ( 3 - 2 * x );
+
+		}
+
 		function normalToComponent( normal ) {
 
 			var component = ( normal + 1 ) * 0.5;
diff --git a/src/renderers/Projector.js b/src/renderers/Projector.js
index 5d87e1ce..540d2bb4 100644
--- a/src/renderers/Projector.js
+++ b/src/renderers/Projector.js
@@ -64,7 +64,7 @@ THREE.Projector = function() {
 
 	this.projectScene = function ( scene, camera, sort ) {
 
-		var renderList = [],
+		var renderList = [], near = camera.near, far = camera.far,
 		o, ol, v, vl, f, fl, n, nl, objects, object,
 		objectMatrix, objectRotationMatrix, objectMaterials, objectOverdraw,
 		geometry, vertices, vertex, vertexPositionScreen,
@@ -99,7 +99,7 @@ THREE.Projector = function() {
 
 				vertices = geometry.vertices;
 
-				for ( v = 0, vl = vertices.length; v < vl; v++ ) {
+				for ( v = 0, vl = vertices.length; v < vl; v ++ ) {
 
 					vertex = vertices[ v ];
 
@@ -110,12 +110,10 @@ THREE.Projector = function() {
 					vertexPositionScreen.copy( vertex.positionWorld );
 					_projScreenMatrix.multiplyVector4( vertexPositionScreen );
 
-					// Perform the perspective divide. TODO: This should be be performend 
-					// post clipping (imagine if the vertex lies at the same location as 
-					// the camera, causing a divide by w = 0).
-					vertexPositionScreen.multiplyScalar( 1 / vertexPositionScreen.w );
+					vertexPositionScreen.x /= vertexPositionScreen.w;
+					vertexPositionScreen.y /= vertexPositionScreen.w;
 
-					vertex.__visible = vertexPositionScreen.z > 0 && vertexPositionScreen.z < 1;
+					vertex.__visible = vertexPositionScreen.z > near && vertexPositionScreen.z < far;
 
 				}
 
diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js
index 1bb1ede8..57e121bf 100644
--- a/src/renderers/WebGLRenderer.js
+++ b/src/renderers/WebGLRenderer.js
@@ -390,8 +390,8 @@ THREE.WebGLRenderer = function ( scene, antialias ) {
 
 					setMaterialShaders( material, ShaderLib[ 'depth' ] );
 
-					material.uniforms.mNear.value = material.near;
-					material.uniforms.mFar.value = material.far;
+					material.uniforms.mNear.value = camera.near;
+					material.uniforms.mFar.value = camera.far;
 
 				} else if ( material instanceof THREE.MeshNormalMaterial ) {
 
diff --git a/src/renderers/WebGLRenderer2.js b/src/renderers/WebGLRenderer2.js
index 14f08242..1c2d68d1 100644
--- a/src/renderers/WebGLRenderer2.js
+++ b/src/renderers/WebGLRenderer2.js
@@ -189,8 +189,8 @@ THREE.WebGLRenderer2 = function ( antialias ) {
 
 						} else if ( material instanceof THREE.MeshDepthMaterial ) {
 
-							_gl.uniform1f( uniforms.mNear, material.near );
-							_gl.uniform1f( uniforms.mFar, material.far );
+							_gl.uniform1f( uniforms.mNear, camera.near );
+							_gl.uniform1f( uniforms.mFar, camera.far );
 							_gl.uniform1f( uniforms.mOpacity, material.opacity );
 
 						}