From 7bd3c4b7e09e1ef5d1226a7879fca2edcdc96c41 Mon Sep 17 00:00:00 2001 From: alteredq Date: Wed, 26 Jan 2011 00:08:49 +0100 Subject: [PATCH] Added to scene loader support for Icosahedron primitive and material shading parameter. --- build/ThreeExtras.js | 322 ++++++++++++++------------- examples/scenes/test_scene.js | 24 +- src/extras/SceneUtils.js | 9 + src/extras/primitives/Icosahedron.js | 2 +- utils/build.py | 1 + 5 files changed, 196 insertions(+), 162 deletions(-) diff --git a/build/ThreeExtras.js b/build/ThreeExtras.js index 3ad9e66e..bbffa10a 100644 --- a/build/ThreeExtras.js +++ b/build/ThreeExtras.js @@ -12,50 +12,50 @@ THREE.Vector4=function(a,b,d,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1} THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}}; THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,f=[];a=0;for(b=e.length;a0&&K>0&&o+K<1}var d,e,f,h,j,c,k,l,n,C, -p,x=a.geometry,z=x.vertices,u=[];d=0;for(e=x.faces.length;dk?e:k;f=f>l? -f:l}a()};this.add3Points=function(k,l,n,C,p,x){if(c){c=false;b=kn?k>p?k:p:n>p?n:p;f=l>C?l>x?l:x:C>x?C:x}else{b=kn?k>p?k>e?k:e:p>e?p:e:n>p?n>e?n:e:p>e?p:e;f=l>C?l>x?l>f?l:f:x>f?x:f:C>x?C>f?C:f:x>f?x:f}a()};this.addRectangle=function(k){if(c){c=false;b=k.getLeft();d=k.getTop();e=k.getRight();f=k.getBottom()}else{b=bk.getRight()?e:k.getRight();f=f>k.getBottom()?f:k.getBottom()}a()};this.inflate=function(k){b-=k;d-=k;e+=k;f+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();d=d>k.getTop()?d:k.getTop();e=e=0&&Math.min(f,k.getBottom())-Math.max(d,k.getTop())>=0};this.empty=function(){c=true;f=e=d=b=0;a()};this.isEmpty=function(){return c};this.toString= -function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+f+", width: "+h+", height: "+j+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this}}; -THREE.Matrix4=function(a,b,d,e,f,h,j,c,k,l,n,C,p,x,z,u){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=f||0;this.n22=h||1;this.n23=j||0;this.n24=c||0;this.n31=k||0;this.n32=l||0;this.n33=n||1;this.n34=C||0;this.n41=p||0;this.n42=x||0;this.n43=z||0;this.n44=u||1;this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,d,e,f,h,j,c,k,l,n,C,p,x,z,u){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=f;this.n22=h;this.n23=j;this.n24=c;this.n31=k;this.n32=l;this.n33=n;this.n34=C;this.n41=p;this.n42=x;this.n43=z;this.n44=u;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= -a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,d){var e=THREE.Matrix4.__tmpVec1,f=THREE.Matrix4.__tmpVec2,h=THREE.Matrix4.__tmpVec3;h.sub(a,b).normalize();e.cross(d,h).normalize();f.cross(h,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a); -this.n31=h.x;this.n32=h.y;this.n33=h.z;this.n34=-h.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,f=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*f;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*b+this.n22*d+this.n23* -e+this.n24*f;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*f;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,f=a.n13,h=a.n14,j=a.n21,c=a.n22,k=a.n23,l=a.n24,n=a.n31, -C=a.n32,p=a.n33,x=a.n34,z=a.n41,u=a.n42,K=a.n43,t=a.n44,L=b.n11,m=b.n12,g=b.n13,o=b.n14,B=b.n21,q=b.n22,A=b.n23,N=b.n24,v=b.n31,D=b.n32,G=b.n33,E=b.n34,y=b.n41,I=b.n42,F=b.n43,T=b.n44;this.n11=d*L+e*B+f*v+h*y;this.n12=d*m+e*q+f*D+h*I;this.n13=d*g+e*A+f*G+h*F;this.n14=d*o+e*N+f*E+h*T;this.n21=j*L+c*B+k*v+l*y;this.n22=j*m+c*q+k*D+l*I;this.n23=j*g+c*A+k*G+l*F;this.n24=j*o+c*N+k*E+l*T;this.n31=n*L+C*B+p*v+x*y;this.n32=n*m+C*q+p*D+x*I;this.n33=n*g+C*A+p*G+x*F;this.n34=n*o+C*N+p*E+x*T;this.n41=z*L+u*B+ -K*v+t*y;this.n42=z*m+u*q+K*D+t*I;this.n43=z*g+u*A+K*G+t*F;this.n44=z*o+u*N+K*E+t*T;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,f=this.n14,h=this.n21,j=this.n22,c=this.n23,k=this.n24,l=this.n31,n=this.n32,C=this.n33,p=this.n34,x=this.n41,z=this.n42,u=this.n43,K=this.n44,t=a.n11,L=a.n21,m=a.n31,g=a.n41,o=a.n12,B=a.n22,q=a.n32,A=a.n42,N=a.n13,v=a.n23,D=a.n33,G=a.n43,E=a.n14,y=a.n24,I=a.n34;a=a.n44;this.n11=b*t+d*L+e*m+f*g;this.n12=b*o+d*B+e*q+f*A;this.n13=b*N+d*v+e*D+f* -G;this.n14=b*E+d*y+e*I+f*a;this.n21=h*t+j*L+c*m+k*g;this.n22=h*o+j*B+c*q+k*A;this.n23=h*N+j*v+c*D+k*G;this.n24=h*E+j*y+c*I+k*a;this.n31=l*t+n*L+C*m+p*g;this.n32=l*o+n*B+C*q+p*A;this.n33=l*N+n*v+C*D+p*G;this.n34=l*E+n*y+C*I+p*a;this.n41=x*t+z*L+u*m+K*g;this.n42=x*o+z*B+u*q+K*A;this.n43=x*N+z*v+u*D+K*G;this.n44=x*E+z*y+u*I+K*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*= -a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,d=this.n13,e=this.n14,f=this.n21,h=this.n22,j=this.n23,c=this.n24,k=this.n31,l=this.n32,n=this.n33,C=this.n34,p=this.n41,x=this.n42,z=this.n43,u=this.n44;return e*j*l*p-d*c*l*p-e*h*n*p+b*c*n*p+d*h*C*p-b*j*C*p-e*j*k*x+d*c*k*x+e*f*n*x-a*c*n*x-d*f*C*x+a*j*C*x+e*h*k*z-b*c*k*z-e*f*l*z+a*c*l*z+b*f*C*z-a*h*C*z-d*h*k*u+b*j*k*u+d*f*l*u-a*j*l*u-b*f*n*u+a*h*n*u},transpose:function(){function a(b,d, -e){var f=b[d];b[d]=b[e];b[e]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11; +THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,g=[];a=0;for(b=e.length;a0&&K>0&&p+K<1}var d,e,g,f,j,c,k,l,n,B, +o,u=a.geometry,v=u.vertices,w=[];d=0;for(e=u.faces.length;dk?e:k;g=g>l? +g:l}a()};this.add3Points=function(k,l,n,B,o,u){if(c){c=false;b=kn?k>o?k:o:n>o?n:o;g=l>B?l>u?l:u:B>u?B:u}else{b=kn?k>o?k>e?k:e:o>e?o:e:n>o?n>e?n:e:o>e?o:e;g=l>B?l>u?l>g?l:g:u>g?u:g:B>u?B>g?B:g:u>g?u:g}a()};this.addRectangle=function(k){if(c){c=false;b=k.getLeft();d=k.getTop();e=k.getRight();g=k.getBottom()}else{b=bk.getRight()?e:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;d-=k;e+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();d=d>k.getTop()?d:k.getTop();e=e=0&&Math.min(g,k.getBottom())-Math.max(d,k.getTop())>=0};this.empty=function(){c=true;g=e=d=b=0;a()};this.isEmpty=function(){return c};this.toString= +function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+g+", width: "+f+", height: "+j+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this}}; +THREE.Matrix4=function(a,b,d,e,g,f,j,c,k,l,n,B,o,u,v,w){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=g||0;this.n22=f||1;this.n23=j||0;this.n24=c||0;this.n31=k||0;this.n32=l||0;this.n33=n||1;this.n34=B||0;this.n41=o||0;this.n42=u||0;this.n43=v||0;this.n44=w||1;this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,d,e,g,f,j,c,k,l,n,B,o,u,v,w){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=g;this.n22=f;this.n23=j;this.n24=c;this.n31=k;this.n32=l;this.n33=n;this.n34=B;this.n41=o;this.n42=u;this.n43=v;this.n44=w;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= +a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,d){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();e.cross(d,f).normalize();g.cross(f,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.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,d=a.y,e=a.z,g=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*d+this.n23* +e+this.n24*g;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*d+this.n43*e+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 d=a.n11,e=a.n12,g=a.n13,f=a.n14,j=a.n21,c=a.n22,k=a.n23,l=a.n24,n=a.n31, +B=a.n32,o=a.n33,u=a.n34,v=a.n41,w=a.n42,K=a.n43,t=a.n44,L=b.n11,m=b.n12,h=b.n13,p=b.n14,C=b.n21,q=b.n22,A=b.n23,N=b.n24,x=b.n31,D=b.n32,G=b.n33,E=b.n34,z=b.n41,I=b.n42,F=b.n43,T=b.n44;this.n11=d*L+e*C+g*x+f*z;this.n12=d*m+e*q+g*D+f*I;this.n13=d*h+e*A+g*G+f*F;this.n14=d*p+e*N+g*E+f*T;this.n21=j*L+c*C+k*x+l*z;this.n22=j*m+c*q+k*D+l*I;this.n23=j*h+c*A+k*G+l*F;this.n24=j*p+c*N+k*E+l*T;this.n31=n*L+B*C+o*x+u*z;this.n32=n*m+B*q+o*D+u*I;this.n33=n*h+B*A+o*G+u*F;this.n34=n*p+B*N+o*E+u*T;this.n41=v*L+w*C+ +K*x+t*z;this.n42=v*m+w*q+K*D+t*I;this.n43=v*h+w*A+K*G+t*F;this.n44=v*p+w*N+K*E+t*T;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,g=this.n14,f=this.n21,j=this.n22,c=this.n23,k=this.n24,l=this.n31,n=this.n32,B=this.n33,o=this.n34,u=this.n41,v=this.n42,w=this.n43,K=this.n44,t=a.n11,L=a.n21,m=a.n31,h=a.n41,p=a.n12,C=a.n22,q=a.n32,A=a.n42,N=a.n13,x=a.n23,D=a.n33,G=a.n43,E=a.n14,z=a.n24,I=a.n34;a=a.n44;this.n11=b*t+d*L+e*m+g*h;this.n12=b*p+d*C+e*q+g*A;this.n13=b*N+d*x+e*D+g* +G;this.n14=b*E+d*z+e*I+g*a;this.n21=f*t+j*L+c*m+k*h;this.n22=f*p+j*C+c*q+k*A;this.n23=f*N+j*x+c*D+k*G;this.n24=f*E+j*z+c*I+k*a;this.n31=l*t+n*L+B*m+o*h;this.n32=l*p+n*C+B*q+o*A;this.n33=l*N+n*x+B*D+o*G;this.n34=l*E+n*z+B*I+o*a;this.n41=u*t+v*L+w*m+K*h;this.n42=u*p+v*C+w*q+K*A;this.n43=u*N+v*x+w*D+K*G;this.n44=u*E+v*z+w*I+K*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*= +a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,d=this.n13,e=this.n14,g=this.n21,f=this.n22,j=this.n23,c=this.n24,k=this.n31,l=this.n32,n=this.n33,B=this.n34,o=this.n41,u=this.n42,v=this.n43,w=this.n44;return e*j*l*o-d*c*l*o-e*f*n*o+b*c*n*o+d*f*B*o-b*j*B*o-e*j*k*u+d*c*k*u+e*g*n*u-a*c*n*u-d*g*B*u+a*j*B*u+e*f*k*v-b*c*k*v-e*g*l*v+a*c*l*v+b*g*B*v-a*f*B*v-d*f*k*w+b*j*k*w+d*g*l*w-a*j*l*w-b*g*n*w+a*f*n*w},transpose:function(){function a(b,d, +e){var g=b[d];b[d]=b[e];b[e]=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(){var a=this.flat;a[0]=this.n11; a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,b,d){this.set(1,0,0,a,0,1,0,b,0,0,1,d,0,0,0,1);return this},setScale:function(a,b,d){this.set(a,0,0,0,0,b,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b= -Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var d=Math.cos(b),e=Math.sin(b),f=1-d,h=a.x,j=a.y,c=a.z,k=f*h,l=f*j;this.set(k*h+d,k*j-e*c,k*c+e*j,0,k*j+e*c,l*j+d,l*c-e*h,0,k*c-e*j,l*c+e*h,f*c*c+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+ +Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var d=Math.cos(b),e=Math.sin(b),g=1-d,f=a.x,j=a.y,c=a.z,k=g*f,l=g*j;this.set(k*f+d,k*j-e*c,k*c+e*j,0,k*j+e*c,l*j+d,l*c-e*f,0,k*c-e*j,l*c+e*f,g*c*c+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+ this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,d){var e=new THREE.Matrix4;e.setTranslation(a,b,d);return e};THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.setScale(a,b,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b}; THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4;d.setRotAxis(a,b);return d}; -THREE.Matrix4.makeInvert=function(a){var b=a.n11,d=a.n12,e=a.n13,f=a.n14,h=a.n21,j=a.n22,c=a.n23,k=a.n24,l=a.n31,n=a.n32,C=a.n33,p=a.n34,x=a.n41,z=a.n42,u=a.n43,K=a.n44,t=new THREE.Matrix4;t.n11=c*p*z-k*C*z+k*n*u-j*p*u-c*n*K+j*C*K;t.n12=f*C*z-e*p*z-f*n*u+d*p*u+e*n*K-d*C*K;t.n13=e*k*z-f*c*z+f*j*u-d*k*u-e*j*K+d*c*K;t.n14=f*c*n-e*k*n-f*j*C+d*k*C+e*j*p-d*c*p;t.n21=k*C*x-c*p*x-k*l*u+h*p*u+c*l*K-h*C*K;t.n22=e*p*x-f*C*x+f*l*u-b*p*u-e*l*K+b*C*K;t.n23=f*c*x-e*k*x-f*h*u+b*k*u+e*h*K-b*c*K;t.n24=e*k*l-f*c*l+ -f*h*C-b*k*C-e*h*p+b*c*p;t.n31=j*p*x-k*n*x+k*l*z-h*p*z-j*l*K+h*n*K;t.n32=f*n*x-d*p*x-f*l*z+b*p*z+d*l*K-b*n*K;t.n33=e*k*x-f*j*x+f*h*z-b*k*z-d*h*K+b*j*K;t.n34=f*j*l-d*k*l-f*h*n+b*k*n+d*h*p-b*j*p;t.n41=c*n*x-j*C*x-c*l*z+h*C*z+j*l*u-h*n*u;t.n42=d*C*x-e*n*x+e*l*z-b*C*z-d*l*u+b*n*u;t.n43=e*j*x-d*c*x-e*h*z+b*c*z+d*h*u-b*j*u;t.n44=d*c*l-e*j*l+e*h*n-b*c*n-d*h*C+b*j*C;t.multiplyScalar(1/a.determinant());return t}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=a.m33;var d=a.m,e=b[10]*b[5]-b[6]*b[9],f=-b[10]*b[1]+b[2]*b[9],h=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],c=b[10]*b[0]-b[2]*b[8],k=-b[6]*b[0]+b[2]*b[4],l=b[9]*b[4]-b[5]*b[8],n=-b[9]*b[0]+b[1]*b[8],C=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*j+b[2]*l;if(b==0)throw"matrix not invertible";b=1/b;d[0]=b*e;d[1]=b*f;d[2]=b*h;d[3]=b*j;d[4]=b*c;d[5]=b*k;d[6]=b*l;d[7]=b*n;d[8]=b*C;return a}; -THREE.Matrix4.makeFrustum=function(a,b,d,e,f,h){var j,c,k;j=new THREE.Matrix4;c=2*f/(b-a);k=2*f/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(h+f)/(h-f);f=-2*h*f/(h-f);j.n11=c;j.n12=0;j.n13=a;j.n14=0;j.n21=0;j.n22=k;j.n23=d;j.n24=0;j.n31=0;j.n32=0;j.n33=e;j.n34=f;j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(a,b,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,d,e)}; -THREE.Matrix4.makeOrtho=function(a,b,d,e,f,h){var j,c,k,l;j=new THREE.Matrix4;c=b-a;k=d-e;l=h-f;a=(b+a)/c;d=(d+e)/k;f=(h+f)/l;j.n11=2/c;j.n12=0;j.n13=0;j.n14=-a;j.n21=0;j.n22=2/k;j.n23=0;j.n24=-d;j.n31=0;j.n32=0;j.n33=-2/l;j.n34=-f;j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; +THREE.Matrix4.makeInvert=function(a){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,j=a.n22,c=a.n23,k=a.n24,l=a.n31,n=a.n32,B=a.n33,o=a.n34,u=a.n41,v=a.n42,w=a.n43,K=a.n44,t=new THREE.Matrix4;t.n11=c*o*v-k*B*v+k*n*w-j*o*w-c*n*K+j*B*K;t.n12=g*B*v-e*o*v-g*n*w+d*o*w+e*n*K-d*B*K;t.n13=e*k*v-g*c*v+g*j*w-d*k*w-e*j*K+d*c*K;t.n14=g*c*n-e*k*n-g*j*B+d*k*B+e*j*o-d*c*o;t.n21=k*B*u-c*o*u-k*l*w+f*o*w+c*l*K-f*B*K;t.n22=e*o*u-g*B*u+g*l*w-b*o*w-e*l*K+b*B*K;t.n23=g*c*u-e*k*u-g*f*w+b*k*w+e*f*K-b*c*K;t.n24=e*k*l-g*c*l+ +g*f*B-b*k*B-e*f*o+b*c*o;t.n31=j*o*u-k*n*u+k*l*v-f*o*v-j*l*K+f*n*K;t.n32=g*n*u-d*o*u-g*l*v+b*o*v+d*l*K-b*n*K;t.n33=e*k*u-g*j*u+g*f*v-b*k*v-d*f*K+b*j*K;t.n34=g*j*l-d*k*l-g*f*n+b*k*n+d*f*o-b*j*o;t.n41=c*n*u-j*B*u-c*l*v+f*B*v+j*l*w-f*n*w;t.n42=d*B*u-e*n*u+e*l*v-b*B*v-d*l*w+b*n*w;t.n43=e*j*u-d*c*u-e*f*v+b*c*v+d*f*w-b*j*w;t.n44=d*c*l-e*j*l+e*f*n-b*c*n-d*f*B+b*j*B;t.multiplyScalar(1/a.determinant());return t}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=a.m33;var d=a.m,e=b[10]*b[5]-b[6]*b[9],g=-b[10]*b[1]+b[2]*b[9],f=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],c=b[10]*b[0]-b[2]*b[8],k=-b[6]*b[0]+b[2]*b[4],l=b[9]*b[4]-b[5]*b[8],n=-b[9]*b[0]+b[1]*b[8],B=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*j+b[2]*l;if(b==0)throw"matrix not invertible";b=1/b;d[0]=b*e;d[1]=b*g;d[2]=b*f;d[3]=b*j;d[4]=b*c;d[5]=b*k;d[6]=b*l;d[7]=b*n;d[8]=b*B;return a}; +THREE.Matrix4.makeFrustum=function(a,b,d,e,g,f){var j,c,k;j=new THREE.Matrix4;c=2*g/(b-a);k=2*g/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(f+g)/(f-g);g=-2*f*g/(f-g);j.n11=c;j.n12=0;j.n13=a;j.n14=0;j.n21=0;j.n22=k;j.n23=d;j.n24=0;j.n31=0;j.n32=0;j.n33=e;j.n34=g;j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(a,b,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,d,e)}; +THREE.Matrix4.makeOrtho=function(a,b,d,e,g,f){var j,c,k,l;j=new THREE.Matrix4;c=b-a;k=d-e;l=f-g;a=(b+a)/c;d=(d+e)/k;g=(f+g)/l;j.n11=2/c;j.n12=0;j.n13=0;j.n14=-a;j.n21=0;j.n22=2/k;j.n23=0;j.n24=-d;j.n31=0;j.n32=0;j.n33=-2/l;j.n34=-g;j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; -THREE.Face3=function(a,b,d,e,f){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,b,d,e,f,h){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=h instanceof Array?h:[h]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; +THREE.Face3=function(a,b,d,e,g){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; +THREE.Face4=function(a,b,d,e,g,f){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=f instanceof Array?f:[f]};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,d;a=0;for(b=this.faces.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y], +b;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(E,z,I,F,T,V,P){f=E.vertices[z].position;j=E.vertices[I].position;c=E.vertices[F].position;k=g[T];l=g[V];n=g[P];B=j.x-f.x;o=c.x-f.x;u=j.y-f.y;v=c.y-f.y; +w=j.z-f.z;K=c.z-f.z;t=l.u-k.u;L=n.u-k.u;m=l.v-k.v;h=n.v-k.v;p=1/(t*h-L*m);A.set((h*B-m*o)*p,(h*u-m*v)*p,(h*w-m*K)*p);N.set((t*o-L*B)*p,(t*v-L*u)*p,(t*K-L*w)*p);C[z].addSelf(A);C[I].addSelf(A);C[F].addSelf(A);q[z].addSelf(N);q[I].addSelf(N);q[F].addSelf(N)}var b,d,e,g,f,j,c,k,l,n,B,o,u,v,w,K,t,L,m,h,p,C=[],q=[],A=new THREE.Vector3,N=new THREE.Vector3,x=new THREE.Vector3,D=new THREE.Vector3,G=new THREE.Vector3;b=0;for(d=this.vertices.length;b0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y], z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,d=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z -this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,d=this.vertices.length;b65535){l[c].counter+=1;k=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:j,vertices:0}}this.geometryChunks[k].faces.push(e);this.geometryChunks[k].vertices+=h}},toString:function(){return"THREE.Geometry ( vertices: "+ +this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,d=this.vertices.length;b65535){l[c].counter+=1;k=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:j,vertices:0}}this.geometryChunks[k].faces.push(e);this.geometryChunks[k].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+ this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; -THREE.Camera=function(a,b,d,e){this.fov=a;this.aspect=b;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(f){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)}; -this.translateZ=function(f){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};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()}; +THREE.Camera=function(a,b,d,e){this.fov=a;this.aspect=b;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)}; +this.translateZ=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};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()}; THREE.Camera.prototype={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.PointLight.prototype=new THREE.Light;THREE.PointLight.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.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true}; @@ -89,101 +89,101 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM 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,d,e,f,h){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=f!==undefined?f:THREE.LinearFilter;this.min_filter=h!==undefined?h:THREE.LinearMipMapLinearFilter}; +THREE.Texture=function(a,b,d,e,g,f){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=f!==undefined?f:THREE.LinearMipMapLinearFilter}; THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},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.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20; THREE.RenderTarget=function(a,b,d){this.width=a;this.height=b;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType}; -var Uniforms={clone:function(a){var b,d,e,f={};for(b in a){f[b]={};for(d in a[b]){e=a[b][d];f[b][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return f},merge:function(a){var b,d,e,f={};for(b=0;b=0&&G>=0&&E>=0&&y>=0)return true;else if(D<0&&G<0||E<0&&y<0)return false;else{if(D<0)N=Math.max(N,D/(D-G));else if(G<0)v=Math.min(v,D/(D-G));if(E<0)N=Math.max(N,E/(E-y));else if(y<0)v=Math.min(v,E/(E-y));if(vD&&F.z0&&K.z<1){p=z[x]=z[x]||new THREE.RenderableParticle;p.x=K.x/K.w;p.y=K.y/K.w;p.z=K.z;p.rotation=P.rotation.z;p.scale.x=P.scale.x*Math.abs(p.x-(K.x+A.projectionMatrix.n11)/(K.w+A.projectionMatrix.n14)); -p.scale.y=P.scale.y*Math.abs(p.y-(K.y+A.projectionMatrix.n22)/(K.w+A.projectionMatrix.n24));p.materials=P.materials;v.push(p);x++}}}}N&&v.sort(a);return v};this.unprojectVector=function(q,A){var N=THREE.Matrix4.makeInvert(A.matrix);N.multiplySelf(THREE.Matrix4.makeInvert(A.projectionMatrix));N.multiplyVector3(q);return q}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,f,h;this.domElement=document.createElement("div");this.setSize=function(j,c){d=j;e=c;f=d/2;h=e/2};this.render=function(j,c){var k,l,n,C,p,x,z,u;a=b.projectScene(j,c);k=0;for(l=a.length;k0){Q.r+=la.r*fa;Q.g+=la.g*fa;Q.b+=la.b*fa}}else if(fa instanceof THREE.PointLight){J.sub(fa.position,ea);J.normalize();fa=aa.dot(J)*na;if(fa>0){Q.r+=la.r*fa;Q.g+=la.g*fa;Q.b+=la.b*fa}}}}function Qa(O,ea,aa){if(aa.opacity!= -0){a(aa.opacity);b(aa.blending);var Q,$,fa,la,na,oa;if(aa instanceof THREE.ParticleBasicMaterial){if(aa.map){la=aa.map;na=la.width>>1;oa=la.height>>1;$=ea.scale.x*c;fa=ea.scale.y*k;aa=$*na;Q=fa*oa;H.set(O.x-aa,O.y-Q,O.x+aa,O.y+Q);if(ba.instersects(H)){l.save();l.translate(O.x,O.y);l.rotate(-ea.rotation);l.scale($,-fa);l.translate(-na,-oa);l.drawImage(la,0,0);l.restore()}}}else if(aa instanceof THREE.ParticleCircleMaterial){if(S){W.r=ia.r+ha.r+w.r;W.g=ia.g+ha.g+w.g;W.b=ia.b+ha.b+w.b;v.r=aa.color.r* -W.r;v.g=aa.color.g*W.g;v.b=aa.color.b*W.b;v.updateStyleString()}else v.__styleString=aa.color.__styleString;aa=ea.scale.x*c;Q=ea.scale.y*k;H.set(O.x-aa,O.y-Q,O.x+aa,O.y+Q);if(ba.instersects(H)){$=v.__styleString;if(u!=$)l.fillStyle=u=$;l.save();l.translate(O.x,O.y);l.rotate(-ea.rotation);l.scale(aa,Q);l.beginPath();l.arc(0,0,1,0,M,true);l.closePath();l.fill();l.restore()}}}}function Ra(O,ea,aa,Q){if(Q.opacity!=0){a(Q.opacity);b(Q.blending);l.beginPath();l.moveTo(O.positionScreen.x,O.positionScreen.y); -l.lineTo(ea.positionScreen.x,ea.positionScreen.y);l.closePath();if(Q instanceof THREE.LineBasicMaterial){v.__styleString=Q.color.__styleString;O=Q.linewidth;if(K!=O)l.lineWidth=K=O;O=v.__styleString;if(z!=O)l.strokeStyle=z=O;l.stroke();H.inflate(Q.linewidth*2)}}}function La(O,ea,aa,Q,$,fa){if($.opacity!=0){a($.opacity);b($.blending);g=O.positionScreen.x;o=O.positionScreen.y;B=ea.positionScreen.x;q=ea.positionScreen.y;A=aa.positionScreen.x;N=aa.positionScreen.y;l.beginPath();l.moveTo(g,o);l.lineTo(B, -q);l.lineTo(A,N);l.lineTo(g,o);l.closePath();if($ instanceof THREE.MeshBasicMaterial)if($.map)$.map.image.loaded&&$.map.mapping instanceof THREE.UVMapping&&Aa(g,o,B,q,A,N,$.map.image,Q.uvs[0].u,Q.uvs[0].v,Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);else if($.env_map){if($.env_map.image.loaded)if($.env_map.mapping instanceof THREE.SphericalReflectionMapping){O=wa.matrix;J.copy(Q.vertexNormalsWorld[0]);V=(J.x*O.n11+J.y*O.n12+J.z*O.n13)*0.5+0.5;P=-(J.x*O.n21+J.y*O.n22+J.z*O.n23)*0.5+0.5;J.copy(Q.vertexNormalsWorld[1]); -da=(J.x*O.n11+J.y*O.n12+J.z*O.n13)*0.5+0.5;X=-(J.x*O.n21+J.y*O.n22+J.z*O.n23)*0.5+0.5;J.copy(Q.vertexNormalsWorld[2]);R=(J.x*O.n11+J.y*O.n12+J.z*O.n13)*0.5+0.5;U=-(J.x*O.n21+J.y*O.n22+J.z*O.n23)*0.5+0.5;Aa(g,o,B,q,A,N,$.env_map.image,V,P,da,X,R,U)}}else $.wireframe?Ea($.color.__styleString,$.wireframe_linewidth):Fa($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&!$.wireframe){$.map.mapping instanceof THREE.UVMapping&&Aa(g,o,B,q,A,N,$.map.image,Q.uvs[0].u,Q.uvs[0].v, -Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);b(THREE.SubtractiveBlending)}if(S)if(!$.wireframe&&$.shading==THREE.SmoothShading&&Q.vertexNormalsWorld.length==3){D.r=G.r=E.r=ia.r;D.g=G.g=E.g=ia.g;D.b=G.b=E.b=ia.b;Da(fa,Q.v1.positionWorld,Q.vertexNormalsWorld[0],D);Da(fa,Q.v2.positionWorld,Q.vertexNormalsWorld[1],G);Da(fa,Q.v3.positionWorld,Q.vertexNormalsWorld[2],E);y.r=(G.r+E.r)*0.5;y.g=(G.g+E.g)*0.5;y.b=(G.b+E.b)*0.5;T=Ma(D,G,E,y);Aa(g,o,B,q,A,N,T,0,0,1,0,0,1)}else{W.r=ia.r;W.g=ia.g;W.b=ia.b;Da(fa, -Q.centroidWorld,Q.normalWorld,W);v.r=$.color.r*W.r;v.g=$.color.g*W.g;v.b=$.color.b*W.b;v.updateStyleString();$.wireframe?Ea(v.__styleString,$.wireframe_linewidth):Fa(v.__styleString)}else $.wireframe?Ea($.color.__styleString,$.wireframe_linewidth):Fa($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){I=wa.near;F=wa.far;D.r=D.g=D.b=1-Ha(O.positionScreen.z,I,F);G.r=G.g=G.b=1-Ha(ea.positionScreen.z,I,F);E.r=E.g=E.b=1-Ha(aa.positionScreen.z,I,F);y.r=(G.r+E.r)*0.5;y.g=(G.g+E.g)*0.5;y.b= -(G.b+E.b)*0.5;T=Ma(D,G,E,y);Aa(g,o,B,q,A,N,T,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){v.r=Ia(Q.normalWorld.x);v.g=Ia(Q.normalWorld.y);v.b=Ia(Q.normalWorld.z);v.updateStyleString();$.wireframe?Ea(v.__styleString,$.wireframe_linewidth):Fa(v.__styleString)}}}function Ea(O,ea){if(z!=O)l.strokeStyle=z=O;if(K!=ea)l.lineWidth=K=ea;l.stroke();H.inflate(ea*2)}function Fa(O){if(u!=O)l.fillStyle=u=O;l.fill()}function Aa(O,ea,aa,Q,$,fa,la,na,oa,ta,pa,ua,Ba){var xa,va;xa=la.width-1;va=la.height- +THREE.Projector=function(){function a(q,A){return A.z-q.z}function b(q,A){var N=0,x=1,D=q.z+q.w,G=A.z+A.w,E=-q.z+q.w,z=-A.z+A.w;if(D>=0&&G>=0&&E>=0&&z>=0)return true;else if(D<0&&G<0||E<0&&z<0)return false;else{if(D<0)N=Math.max(N,D/(D-G));else if(G<0)x=Math.min(x,D/(D-G));if(E<0)N=Math.max(N,E/(E-z));else if(z<0)x=Math.min(x,E/(E-z));if(xD&&F.z0&&K.z<1){o=v[u]=v[u]||new THREE.RenderableParticle;o.x=K.x/K.w;o.y=K.y/K.w;o.z=K.z;o.rotation=P.rotation.z;o.scale.x=P.scale.x*Math.abs(o.x-(K.x+A.projectionMatrix.n11)/(K.w+A.projectionMatrix.n14)); +o.scale.y=P.scale.y*Math.abs(o.y-(K.y+A.projectionMatrix.n22)/(K.w+A.projectionMatrix.n24));o.materials=P.materials;x.push(o);u++}}}}N&&x.sort(a);return x};this.unprojectVector=function(q,A){var N=THREE.Matrix4.makeInvert(A.matrix);N.multiplySelf(THREE.Matrix4.makeInvert(A.projectionMatrix));N.multiplyVector3(q);return q}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,g,f;this.domElement=document.createElement("div");this.setSize=function(j,c){d=j;e=c;g=d/2;f=e/2};this.render=function(j,c){var k,l,n,B,o,u,v,w;a=b.projectScene(j,c);k=0;for(l=a.length;k0){Q.r+=la.r*fa;Q.g+=la.g*fa;Q.b+=la.b*fa}}else if(fa instanceof THREE.PointLight){J.sub(fa.position,ea);J.normalize();fa=aa.dot(J)*na;if(fa>0){Q.r+=la.r*fa;Q.g+=la.g*fa;Q.b+=la.b*fa}}}}function Qa(O,ea,aa){if(aa.opacity!= +0){a(aa.opacity);b(aa.blending);var Q,$,fa,la,na,oa;if(aa instanceof THREE.ParticleBasicMaterial){if(aa.map){la=aa.map;na=la.width>>1;oa=la.height>>1;$=ea.scale.x*c;fa=ea.scale.y*k;aa=$*na;Q=fa*oa;H.set(O.x-aa,O.y-Q,O.x+aa,O.y+Q);if(ba.instersects(H)){l.save();l.translate(O.x,O.y);l.rotate(-ea.rotation);l.scale($,-fa);l.translate(-na,-oa);l.drawImage(la,0,0);l.restore()}}}else if(aa instanceof THREE.ParticleCircleMaterial){if(S){W.r=ia.r+ha.r+y.r;W.g=ia.g+ha.g+y.g;W.b=ia.b+ha.b+y.b;x.r=aa.color.r* +W.r;x.g=aa.color.g*W.g;x.b=aa.color.b*W.b;x.updateStyleString()}else x.__styleString=aa.color.__styleString;aa=ea.scale.x*c;Q=ea.scale.y*k;H.set(O.x-aa,O.y-Q,O.x+aa,O.y+Q);if(ba.instersects(H)){$=x.__styleString;if(w!=$)l.fillStyle=w=$;l.save();l.translate(O.x,O.y);l.rotate(-ea.rotation);l.scale(aa,Q);l.beginPath();l.arc(0,0,1,0,M,true);l.closePath();l.fill();l.restore()}}}}function Ra(O,ea,aa,Q){if(Q.opacity!=0){a(Q.opacity);b(Q.blending);l.beginPath();l.moveTo(O.positionScreen.x,O.positionScreen.y); +l.lineTo(ea.positionScreen.x,ea.positionScreen.y);l.closePath();if(Q instanceof THREE.LineBasicMaterial){x.__styleString=Q.color.__styleString;O=Q.linewidth;if(K!=O)l.lineWidth=K=O;O=x.__styleString;if(v!=O)l.strokeStyle=v=O;l.stroke();H.inflate(Q.linewidth*2)}}}function La(O,ea,aa,Q,$,fa){if($.opacity!=0){a($.opacity);b($.blending);h=O.positionScreen.x;p=O.positionScreen.y;C=ea.positionScreen.x;q=ea.positionScreen.y;A=aa.positionScreen.x;N=aa.positionScreen.y;l.beginPath();l.moveTo(h,p);l.lineTo(C, +q);l.lineTo(A,N);l.lineTo(h,p);l.closePath();if($ instanceof THREE.MeshBasicMaterial)if($.map)$.map.image.loaded&&$.map.mapping instanceof THREE.UVMapping&&Aa(h,p,C,q,A,N,$.map.image,Q.uvs[0].u,Q.uvs[0].v,Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);else if($.env_map){if($.env_map.image.loaded)if($.env_map.mapping instanceof THREE.SphericalReflectionMapping){O=wa.matrix;J.copy(Q.vertexNormalsWorld[0]);V=(J.x*O.n11+J.y*O.n12+J.z*O.n13)*0.5+0.5;P=-(J.x*O.n21+J.y*O.n22+J.z*O.n23)*0.5+0.5;J.copy(Q.vertexNormalsWorld[1]); +da=(J.x*O.n11+J.y*O.n12+J.z*O.n13)*0.5+0.5;X=-(J.x*O.n21+J.y*O.n22+J.z*O.n23)*0.5+0.5;J.copy(Q.vertexNormalsWorld[2]);R=(J.x*O.n11+J.y*O.n12+J.z*O.n13)*0.5+0.5;U=-(J.x*O.n21+J.y*O.n22+J.z*O.n23)*0.5+0.5;Aa(h,p,C,q,A,N,$.env_map.image,V,P,da,X,R,U)}}else $.wireframe?Ea($.color.__styleString,$.wireframe_linewidth):Fa($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&!$.wireframe){$.map.mapping instanceof THREE.UVMapping&&Aa(h,p,C,q,A,N,$.map.image,Q.uvs[0].u,Q.uvs[0].v, +Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);b(THREE.SubtractiveBlending)}if(S)if(!$.wireframe&&$.shading==THREE.SmoothShading&&Q.vertexNormalsWorld.length==3){D.r=G.r=E.r=ia.r;D.g=G.g=E.g=ia.g;D.b=G.b=E.b=ia.b;Da(fa,Q.v1.positionWorld,Q.vertexNormalsWorld[0],D);Da(fa,Q.v2.positionWorld,Q.vertexNormalsWorld[1],G);Da(fa,Q.v3.positionWorld,Q.vertexNormalsWorld[2],E);z.r=(G.r+E.r)*0.5;z.g=(G.g+E.g)*0.5;z.b=(G.b+E.b)*0.5;T=Ma(D,G,E,z);Aa(h,p,C,q,A,N,T,0,0,1,0,0,1)}else{W.r=ia.r;W.g=ia.g;W.b=ia.b;Da(fa, +Q.centroidWorld,Q.normalWorld,W);x.r=$.color.r*W.r;x.g=$.color.g*W.g;x.b=$.color.b*W.b;x.updateStyleString();$.wireframe?Ea(x.__styleString,$.wireframe_linewidth):Fa(x.__styleString)}else $.wireframe?Ea($.color.__styleString,$.wireframe_linewidth):Fa($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){I=wa.near;F=wa.far;D.r=D.g=D.b=1-Ha(O.positionScreen.z,I,F);G.r=G.g=G.b=1-Ha(ea.positionScreen.z,I,F);E.r=E.g=E.b=1-Ha(aa.positionScreen.z,I,F);z.r=(G.r+E.r)*0.5;z.g=(G.g+E.g)*0.5;z.b= +(G.b+E.b)*0.5;T=Ma(D,G,E,z);Aa(h,p,C,q,A,N,T,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){x.r=Ia(Q.normalWorld.x);x.g=Ia(Q.normalWorld.y);x.b=Ia(Q.normalWorld.z);x.updateStyleString();$.wireframe?Ea(x.__styleString,$.wireframe_linewidth):Fa(x.__styleString)}}}function Ea(O,ea){if(v!=O)l.strokeStyle=v=O;if(K!=ea)l.lineWidth=K=ea;l.stroke();H.inflate(ea*2)}function Fa(O){if(w!=O)l.fillStyle=w=O;l.fill()}function Aa(O,ea,aa,Q,$,fa,la,na,oa,ta,pa,ua,Ba){var xa,va;xa=la.width-1;va=la.height- 1;na*=xa;oa*=va;ta*=xa;pa*=va;ua*=xa;Ba*=va;aa-=O;Q-=ea;$-=O;fa-=ea;ta-=na;pa-=oa;ua-=na;Ba-=oa;va=1/(ta*Ba-ua*pa);xa=(Ba*aa-pa*$)*va;pa=(Ba*Q-pa*fa)*va;aa=(ta*$-ua*aa)*va;Q=(ta*fa-ua*Q)*va;O=O-xa*na-aa*oa;ea=ea-pa*na-Q*oa;l.save();l.transform(xa,pa,aa,Q,O,ea);l.clip();l.drawImage(la,0,0);l.restore()}function Ma(O,ea,aa,Q){var $=~~(O.r*255),fa=~~(O.g*255);O=~~(O.b*255);var la=~~(ea.r*255),na=~~(ea.g*255);ea=~~(ea.b*255);var oa=~~(aa.r*255),ta=~~(aa.g*255);aa=~~(aa.b*255);var pa=~~(Q.r*255),ua=~~(Q.g* 255);Q=~~(Q.b*255);ja[0]=$<0?0:$>255?255:$;ja[1]=fa<0?0:fa>255?255:fa;ja[2]=O<0?0:O>255?255:O;ja[4]=la<0?0:la>255?255:la;ja[5]=na<0?0:na>255?255:na;ja[6]=ea<0?0:ea>255?255:ea;ja[8]=oa<0?0:oa>255?255:oa;ja[9]=ta<0?0:ta>255?255:ta;ja[10]=aa<0?0:aa>255?255:aa;ja[12]=pa<0?0:pa>255?255:pa;ja[13]=ua<0?0:ua>255?255:ua;ja[14]=Q<0?0:Q>255?255:Q;ca.putImageData(ga,0,0);sa.drawImage(Z,0,0);return qa}function Ha(O,ea,aa){O=(O-ea)/(aa-ea);return O*O*(3-2*O)}function Ia(O){O=(O+1)*0.5;return O<0?0:O>1?1:O}function Ja(O, ea){var aa=ea.x-O.x,Q=ea.y-O.y,$=1/Math.sqrt(aa*aa+Q*Q);aa*=$;Q*=$;ea.x+=aa;ea.y+=Q;O.x-=aa;O.y-=Q}var Ga,Na,ka,ra,za,Ka,Oa,Ca;l.setTransform(1,0,0,-1,c,k);this.autoClear&&this.clear();d=e.projectScene(ma,wa,this.sortElements);(S=ma.lights.length>0)&&Pa(ma);Ga=0;for(Na=d.length;Ga0){da.r+=U.color.r*ba;da.g+=U.color.g*ba;da.b+=U.color.b*ba}}else if(U instanceof THREE.PointLight){N.sub(U.position,P.centroidWorld);N.normalize();ba=P.normalWorld.dot(N)*U.intensity;if(ba>0){da.r+=U.color.r*ba;da.g+=U.color.g*ba;da.b+=U.color.b*ba}}}}function b(V,P,da,X,R,U){E=e(y++);E.setAttribute("d", -"M "+V.positionScreen.x+" "+V.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+"z");if(R instanceof THREE.MeshBasicMaterial)m.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshLambertMaterial)if(L){g.r=o.r;g.g=o.g;g.b=o.b;a(U,X,g);m.r=R.color.r*g.r;m.g=R.color.g*g.g;m.b=R.color.b*g.b;m.updateStyleString()}else m.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshDepthMaterial){A=1-R.__2near/(R.__farPlusNear- -X.z*R.__farMinusNear);m.setRGB(A,A,A)}else R instanceof THREE.MeshNormalMaterial&&m.setRGB(f(X.normalWorld.x),f(X.normalWorld.y),f(X.normalWorld.z));R.wireframe?E.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+R.wireframe_linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.wireframe_linecap+"; stroke-linejoin: "+R.wireframe_linejoin):E.setAttribute("style","fill: "+m.__styleString+"; fill-opacity: "+R.opacity);c.appendChild(E)}function d(V,P,da,X,R,U,ba){E= -e(y++);E.setAttribute("d","M "+V.positionScreen.x+" "+V.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(U instanceof THREE.MeshBasicMaterial)m.__styleString=U.color.__styleString;else if(U instanceof THREE.MeshLambertMaterial)if(L){g.r=o.r;g.g=o.g;g.b=o.b;a(ba,R,g);m.r=U.color.r*g.r;m.g=U.color.g*g.g;m.b=U.color.b*g.b;m.updateStyleString()}else m.__styleString=U.color.__styleString; -else if(U instanceof THREE.MeshDepthMaterial){A=1-U.__2near/(U.__farPlusNear-R.z*U.__farMinusNear);m.setRGB(A,A,A)}else U instanceof THREE.MeshNormalMaterial&&m.setRGB(f(R.normalWorld.x),f(R.normalWorld.y),f(R.normalWorld.z));U.wireframe?E.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+U.wireframe_linewidth+"; stroke-opacity: "+U.opacity+"; stroke-linecap: "+U.wireframe_linecap+"; stroke-linejoin: "+U.wireframe_linejoin):E.setAttribute("style","fill: "+m.__styleString+ -"; fill-opacity: "+U.opacity);c.appendChild(E)}function e(V){if(v[V]==null){v[V]=document.createElementNS("http://www.w3.org/2000/svg","path");T==0&&v[V].setAttribute("shape-rendering","crispEdges");return v[V]}return v[V]}function f(V){return V<0?Math.min((1+V)*0.5,0.5):0.5+Math.min(V*0.5,0.5)}var h=null,j=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,l,n,C,p,x,z,u,K=new THREE.Rectangle,t=new THREE.Rectangle,L=false,m=new THREE.Color(16777215),g=new THREE.Color(16777215), -o=new THREE.Color(0),B=new THREE.Color(0),q=new THREE.Color(0),A,N=new THREE.Vector3,v=[],D=[],G=[],E,y,I,F,T=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(V){switch(V){case "high":T=1;break;case "low":T=0}};this.setSize=function(V,P){k=V;l=P;n=k/2;C=l/2;c.setAttribute("viewBox",-n+" "+-C+" "+k+" "+l);c.setAttribute("width",k);c.setAttribute("height",l);K.set(-n,-C,n,C)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])}; -this.render=function(V,P){var da,X,R,U,ba,Y,H,S;this.autoClear&&this.clear();h=j.projectScene(V,P,this.sortElements);F=I=y=0;if(L=V.lights.length>0){H=V.lights;o.setRGB(0,0,0);B.setRGB(0,0,0);q.setRGB(0,0,0);da=0;for(X=H.length;da0){da.r+=U.color.r*ba;da.g+=U.color.g*ba;da.b+=U.color.b*ba}}else if(U instanceof THREE.PointLight){N.sub(U.position,P.centroidWorld);N.normalize();ba=P.normalWorld.dot(N)*U.intensity;if(ba>0){da.r+=U.color.r*ba;da.g+=U.color.g*ba;da.b+=U.color.b*ba}}}}function b(V,P,da,X,R,U){E=e(z++);E.setAttribute("d", +"M "+V.positionScreen.x+" "+V.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+"z");if(R instanceof THREE.MeshBasicMaterial)m.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshLambertMaterial)if(L){h.r=p.r;h.g=p.g;h.b=p.b;a(U,X,h);m.r=R.color.r*h.r;m.g=R.color.g*h.g;m.b=R.color.b*h.b;m.updateStyleString()}else m.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshDepthMaterial){A=1-R.__2near/(R.__farPlusNear- +X.z*R.__farMinusNear);m.setRGB(A,A,A)}else R instanceof THREE.MeshNormalMaterial&&m.setRGB(g(X.normalWorld.x),g(X.normalWorld.y),g(X.normalWorld.z));R.wireframe?E.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+R.wireframe_linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.wireframe_linecap+"; stroke-linejoin: "+R.wireframe_linejoin):E.setAttribute("style","fill: "+m.__styleString+"; fill-opacity: "+R.opacity);c.appendChild(E)}function d(V,P,da,X,R,U,ba){E= +e(z++);E.setAttribute("d","M "+V.positionScreen.x+" "+V.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(U instanceof THREE.MeshBasicMaterial)m.__styleString=U.color.__styleString;else if(U instanceof THREE.MeshLambertMaterial)if(L){h.r=p.r;h.g=p.g;h.b=p.b;a(ba,R,h);m.r=U.color.r*h.r;m.g=U.color.g*h.g;m.b=U.color.b*h.b;m.updateStyleString()}else m.__styleString=U.color.__styleString; +else if(U instanceof THREE.MeshDepthMaterial){A=1-U.__2near/(U.__farPlusNear-R.z*U.__farMinusNear);m.setRGB(A,A,A)}else U instanceof THREE.MeshNormalMaterial&&m.setRGB(g(R.normalWorld.x),g(R.normalWorld.y),g(R.normalWorld.z));U.wireframe?E.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+U.wireframe_linewidth+"; stroke-opacity: "+U.opacity+"; stroke-linecap: "+U.wireframe_linecap+"; stroke-linejoin: "+U.wireframe_linejoin):E.setAttribute("style","fill: "+m.__styleString+ +"; fill-opacity: "+U.opacity);c.appendChild(E)}function e(V){if(x[V]==null){x[V]=document.createElementNS("http://www.w3.org/2000/svg","path");T==0&&x[V].setAttribute("shape-rendering","crispEdges");return x[V]}return x[V]}function g(V){return V<0?Math.min((1+V)*0.5,0.5):0.5+Math.min(V*0.5,0.5)}var f=null,j=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,l,n,B,o,u,v,w,K=new THREE.Rectangle,t=new THREE.Rectangle,L=false,m=new THREE.Color(16777215),h=new THREE.Color(16777215), +p=new THREE.Color(0),C=new THREE.Color(0),q=new THREE.Color(0),A,N=new THREE.Vector3,x=[],D=[],G=[],E,z,I,F,T=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(V){switch(V){case "high":T=1;break;case "low":T=0}};this.setSize=function(V,P){k=V;l=P;n=k/2;B=l/2;c.setAttribute("viewBox",-n+" "+-B+" "+k+" "+l);c.setAttribute("width",k);c.setAttribute("height",l);K.set(-n,-B,n,B)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])}; +this.render=function(V,P){var da,X,R,U,ba,Y,H,S;this.autoClear&&this.clear();f=j.projectScene(V,P,this.sortElements);F=I=z=0;if(L=V.lights.length>0){H=V.lights;p.setRGB(0,0,0);C.setRGB(0,0,0);q.setRGB(0,0,0);da=0;for(X=H.length;da0){c.bindBuffer(c.ARRAY_BUFFER,g.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,ia,B)}if(A){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, -g.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,M,B);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,J,B)}};this.setLineBuffers=function(g,o,B,q){var A,N,v=g.vertices,D=v.length,G=g.__vertexArray,E=g.__lineArray;if(B)for(B=0;B0){c.bindBuffer(c.ARRAY_BUFFER,h.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,ia,C)}if(A){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +h.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,M,C);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,J,C)}};this.setLineBuffers=function(h,p,C,q){var A,N,x=h.vertices,D=x.length,G=h.__vertexArray,E=h.__lineArray;if(C)for(C=0;C0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+E.maxDirLights,"#define MAX_POINT_LIGHTS "+E.maxPointLights, -E.map?"#define USE_MAP":"",E.env_map?"#define USE_ENVMAP":"","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,f("fragment",F+D));c.attachShader(I,f("vertex",E+y));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={};q.program=I;D=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(v in q.uniforms)D.push(v);v=q.program;y=0;for(I=D.length;y=0){c.bindBuffer(c.ARRAY_BUFFER,A.__webGLNormalBuffer);c.vertexAttribPointer(G.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(G.normal)}if(G.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,A.__webGLTangentBuffer); +E.map?"#define USE_MAP":"",E.env_map?"#define USE_ENVMAP":"","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,g("fragment",F+D));c.attachShader(I,g("vertex",E+z));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={};q.program=I;D=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(x in q.uniforms)D.push(x);x=q.program;z=0;for(I=D.length;z=0){c.bindBuffer(c.ARRAY_BUFFER,A.__webGLNormalBuffer);c.vertexAttribPointer(G.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(G.normal)}if(G.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,A.__webGLTangentBuffer); c.vertexAttribPointer(G.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(G.tangent)}if(G.uv>=0)if(A.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,A.__webGLUVBuffer);c.vertexAttribPointer(G.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(G.uv)}else c.disableVertexAttribArray(G.uv);if(q.wireframe||q instanceof THREE.LineBasicMaterial){G=q.wireframe_linewidth!==undefined?q.wireframe_linewidth:q.linewidth!==undefined?q.linewidth:1;q=q instanceof THREE.LineBasicMaterial&&N.type==THREE.LineStrip? -c.LINE_STRIP:c.LINES;c.lineWidth(G);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.__webGLLineBuffer);c.drawElements(q,A.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,A.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(g,o,B,q,A,N,v){var D,G,E,y,I;E=0;for(y=q.materials.length;E=0;B--){q=g.__webGLObjects[B].object;o==q&&g.__webGLObjects.splice(B,1)}};this.setupMatrices=function(g,o){g.autoUpdateMatrix&& -g.updateMatrix();n.multiply(o.matrix,g.matrix);x.set(n.flatten());C=THREE.Matrix4.makeInvert3x3(n).transpose();u.set(C.m);K.set(g.matrix.flatten())};this.loadMatrices=function(g){c.uniformMatrix4fv(g.uniforms.viewMatrix,false,p);c.uniformMatrix4fv(g.uniforms.modelViewMatrix,false,x);c.uniformMatrix4fv(g.uniforms.projectionMatrix,false,z);c.uniformMatrix3fv(g.uniforms.normalMatrix,false,u);c.uniformMatrix4fv(g.uniforms.objectMatrix,false,K)};this.loadCamera=function(g,o){c.uniform3f(g.uniforms.cameraPosition, -o.position.x,o.position.y,o.position.z)};this.setBlending=function(g){switch(g){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(g,o){if(g){!o||o=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(g=="back")c.cullFace(c.BACK);else g=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK); +c.LINE_STRIP:c.LINES;c.lineWidth(G);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.__webGLLineBuffer);c.drawElements(q,A.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,A.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(h,p,C,q,A,N,x){var D,G,E,z,I;E=0;for(z=q.materials.length;E=0;C--){q=h.__webGLObjects[C].object;p==q&&h.__webGLObjects.splice(C,1)}};this.setupMatrices=function(h,p){h.autoUpdateMatrix&& +h.updateMatrix();n.multiply(p.matrix,h.matrix);u.set(n.flatten());B=THREE.Matrix4.makeInvert3x3(n).transpose();w.set(B.m);K.set(h.matrix.flatten())};this.loadMatrices=function(h){c.uniformMatrix4fv(h.uniforms.viewMatrix,false,o);c.uniformMatrix4fv(h.uniforms.modelViewMatrix,false,u);c.uniformMatrix4fv(h.uniforms.projectionMatrix,false,v);c.uniformMatrix3fv(h.uniforms.normalMatrix,false,w);c.uniformMatrix4fv(h.uniforms.objectMatrix,false,K)};this.loadCamera=function(h,p){c.uniform3f(h.uniforms.cameraPosition, +p.position.x,p.position.y,p.position.z)};this.setBlending=function(h){switch(h){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(h,p){if(h){!p||p=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(h=="back")c.cullFace(c.BACK);else h=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK); c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif", envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif", @@ -201,58 +201,62 @@ shininess:{type:"f",value:30}}]),fragment_shader:["uniform vec3 color;\nuniform "gl_FragColor = mapColor * totalLight * vec4( vLightWeighting, 1.0 );",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.Snippets.map_pars_vertex,THREE.Snippets.envmap_pars_vertex,THREE.Snippets.lights_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.envmap_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;", THREE.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\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 d=b instanceof THREE.Mesh,e=a.vertices.length,f=d?b.geometry:b,h=a.vertices,j=f.vertices,c=a.faces,k=f.faces,l=a.uvs;f=f.uvs;d&&b.autoUpdateMatrix&&b.updateMatrix();for(var n=0,C=j.length;n= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}", vertex_shader:"attribute vec4 tangent;\nuniform vec3 uPointLightPos;\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 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;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"}, cube:{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}"},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=function(a,b,d,e,f,h,j,c){function k(u,K,t,L,m,g,o,B){var q,A,N=e||1,v=f||1,D=N+1,G=v+1,E=m/2,y=g/2;m=m/N;var I=g/v,F=l.vertices.length;if(u=="x"&&K=="y"||u=="y"&&K=="x")q="z";else if(u=="x"&&K=="z"||u=="z"&&K=="x")q="y";else if(u=="z"&&K=="y"||u=="y"&&K=="z")q="x";for(A=0;A0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(C,c,p)))-1);l.push(n)}b.push(l)}var x,z,u;f=b.length;for(d=0;d0)for(e=0;e1){x=this.vertices[j].position.clone(); -z=this.vertices[k].position.clone();u=this.vertices[l].position.clone();x.normalize();z.normalize();u.normalize();this.faces.push(new THREE.Face3(j,k,l,[new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(u.x,u.y,u.z)]));this.uvs.push([n,C,K])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; -var Torus=function(a,b,d,e){this.radius=a||100;this.tube=b||40;this.segmentsR=d||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(d=0;d<=this.segmentsT;++d){e=d/this.segmentsT*2*Math.PI;var f=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(e),(this.radius+this.tube*Math.cos(f))*Math.sin(e),this.tube*Math.sin(f))));a.push([d/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(d= -1;d<=this.segmentsT;++d){e=(this.segmentsT+1)*b+d;f=(this.segmentsT+1)*b+d-1;var h=(this.segmentsT+1)*(b-1)+d-1,j=(this.segmentsT+1)*(b-1)+d;this.faces.push(new THREE.Face4(e,f,h,j));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[h][0],a[h][1]),new THREE.UV(a[j][0],a[j][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; -function LathedObject(a,b,d){THREE.Geometry.call(this);b=b||12;d=d||2*Math.PI;b=d/b;for(var e=[],f=[],h=[],j=[],c=0;c0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(B,c,o)))-1);l.push(n)}b.push(l)}var u,v,w;g=b.length;for(d=0;d0)for(e=0;e1){u=this.vertices[j].position.clone(); +v=this.vertices[k].position.clone();w=this.vertices[l].position.clone();u.normalize();v.normalize();w.normalize();this.faces.push(new THREE.Face3(j,k,l,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(w.x,w.y,w.z)]));this.uvs.push([n,B,K])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; +var Torus=function(a,b,d,e){this.radius=a||100;this.tube=b||40;this.segmentsR=d||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(d=0;d<=this.segmentsT;++d){e=d/this.segmentsT*2*Math.PI;var g=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(e),(this.radius+this.tube*Math.cos(g))*Math.sin(e),this.tube*Math.sin(g))));a.push([d/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(d= +1;d<=this.segmentsT;++d){e=(this.segmentsT+1)*b+d;g=(this.segmentsT+1)*b+d-1;var f=(this.segmentsT+1)*(b-1)+d-1,j=(this.segmentsT+1)*(b-1)+d;this.faces.push(new THREE.Face4(e,g,f,j));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[j][0],a[j][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; +var Icosahedron=function(a){function b(B,o,u){var v=Math.sqrt(B*B+o*o+u*u);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(B/v,o/v,u/v)))-1}function d(B,o,u,v){v.faces.push(new THREE.Face3(B,o,u))}function e(B,o){var u=g.vertices[B].position,v=g.vertices[o].position;return b((u.x+v.x)/2,(u.y+v.y)/2,(u.z+v.z)/2)}var g=this,f=new THREE.Geometry,j;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0, +1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);d(0,11,5,f);d(0,5,1,f);d(0,1,7,f);d(0,7,10,f);d(0,10,11,f);d(1,5,9,f);d(5,11,4,f);d(11,10,2,f);d(10,7,6,f);d(7,1,8,f);d(3,9,4,f);d(3,4,2,f);d(3,2,6,f);d(3,6,8,f);d(3,8,9,f);d(4,9,5,f);d(2,4,11,f);d(6,2,10,f);d(8,6,7,f);d(9,8,1,f);for(a=0;a>7)-127;J=(ca&127)<<16|Z<<8|J;if(J==0&&ja==-127)return 0;return(1-2*(ga>>7))*(1+J*Math.pow(2,-23))*Math.pow(2,ja)}function c(w,M){var J=n(w,M),Z=n(w,M+1),ca=n(w,M+2);return(n(w,M+3)<<24)+(ca<<16)+(Z<<8)+J}function k(w,M){var J=n(w,M);return(n(w,M+1)<<8)+J}function l(w,M){var J=n(w,M);return J>127?J-256:J}function n(w,M){return w.charCodeAt(M)&255}function C(w){var M, -J,Z;M=c(a,w);J=c(a,w+B);Z=c(a,w+q);w=k(a,w+A);THREE.Loader.prototype.f3(t,M,J,Z,w)}function p(w){var M,J,Z,ca,ga,ja;M=c(a,w);J=c(a,w+B);Z=c(a,w+q);ca=k(a,w+A);ga=c(a,w+N);ja=c(a,w+v);w=c(a,w+D);THREE.Loader.prototype.f3n(t,g,M,J,Z,ca,ga,ja,w)}function x(w){var M,J,Z,ca;M=c(a,w);J=c(a,w+G);Z=c(a,w+E);ca=c(a,w+y);w=k(a,w+I);THREE.Loader.prototype.f4(t,M,J,Z,ca,w)}function z(w){var M,J,Z,ca,ga,ja,qa,sa;M=c(a,w);J=c(a,w+G);Z=c(a,w+E);ca=c(a,w+y);ga=k(a,w+I);ja=c(a,w+F);qa=c(a,w+T);sa=c(a,w+V);w=c(a,w+ -P);THREE.Loader.prototype.f4n(t,g,M,J,Z,ca,ga,ja,qa,sa,w)}function u(w){var M,J;M=c(a,w);J=c(a,w+da);w=c(a,w+X);THREE.Loader.prototype.uv3(t,o[M*2],o[M*2+1],o[J*2],o[J*2+1],o[w*2],o[w*2+1])}function K(w){var M,J,Z;M=c(a,w);J=c(a,w+R);Z=c(a,w+U);w=c(a,w+ba);THREE.Loader.prototype.uv4(t,o[M*2],o[M*2+1],o[J*2],o[J*2+1],o[Z*2],o[Z*2+1],o[w*2],o[w*2+1])}var t=this,L=0,m,g=[],o=[],B,q,A,N,v,D,G,E,y,I,F,T,V,P,da,X,R,U,ba,Y,H,S,W,ia,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(t,e,h); +b},loadAsciiOld:function(a,b){var d=document.createElement("script");d.type="text/javascript";d.onload=b;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a){var b=a.model,d=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);b.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,d,e)};b.postMessage(a)},loadBinary:function(a){var b=a.model,d=a.callback,e=a.texture_path?a.texture_path: +THREE.Loader.prototype.extractUrlbase(b),g=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers,j.data.materials,d,g,e,f)};b.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,d,e,g,f){var j=new XMLHttpRequest,c=e+"/"+a,k=0; +j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.Loader.prototype.createBinModel(j.responseText,d,g,b):alert("Couldn't load ["+c+"] ["+j.status+"]");else if(j.readyState==3){if(f){if(k==0)k=j.getResponseHeader("Content-Length");f({total:k,loaded:j.responseText.length})}}else if(j.readyState==2)k=j.getResponseHeader("Content-Length")};j.open("GET",c,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)}, +createBinModel:function(a,b,d,e){var g=function(f){function j(y,M){var J=n(y,M),Z=n(y,M+1),ca=n(y,M+2),ga=n(y,M+3),ja=(ga<<1&255|ca>>7)-127;J=(ca&127)<<16|Z<<8|J;if(J==0&&ja==-127)return 0;return(1-2*(ga>>7))*(1+J*Math.pow(2,-23))*Math.pow(2,ja)}function c(y,M){var J=n(y,M),Z=n(y,M+1),ca=n(y,M+2);return(n(y,M+3)<<24)+(ca<<16)+(Z<<8)+J}function k(y,M){var J=n(y,M);return(n(y,M+1)<<8)+J}function l(y,M){var J=n(y,M);return J>127?J-256:J}function n(y,M){return y.charCodeAt(M)&255}function B(y){var M, +J,Z;M=c(a,y);J=c(a,y+C);Z=c(a,y+q);y=k(a,y+A);THREE.Loader.prototype.f3(t,M,J,Z,y)}function o(y){var M,J,Z,ca,ga,ja;M=c(a,y);J=c(a,y+C);Z=c(a,y+q);ca=k(a,y+A);ga=c(a,y+N);ja=c(a,y+x);y=c(a,y+D);THREE.Loader.prototype.f3n(t,h,M,J,Z,ca,ga,ja,y)}function u(y){var M,J,Z,ca;M=c(a,y);J=c(a,y+G);Z=c(a,y+E);ca=c(a,y+z);y=k(a,y+I);THREE.Loader.prototype.f4(t,M,J,Z,ca,y)}function v(y){var M,J,Z,ca,ga,ja,qa,sa;M=c(a,y);J=c(a,y+G);Z=c(a,y+E);ca=c(a,y+z);ga=k(a,y+I);ja=c(a,y+F);qa=c(a,y+T);sa=c(a,y+V);y=c(a,y+ +P);THREE.Loader.prototype.f4n(t,h,M,J,Z,ca,ga,ja,qa,sa,y)}function w(y){var M,J;M=c(a,y);J=c(a,y+da);y=c(a,y+X);THREE.Loader.prototype.uv3(t,p[M*2],p[M*2+1],p[J*2],p[J*2+1],p[y*2],p[y*2+1])}function K(y){var M,J,Z;M=c(a,y);J=c(a,y+R);Z=c(a,y+U);y=c(a,y+ba);THREE.Loader.prototype.uv4(t,p[M*2],p[M*2+1],p[J*2],p[J*2+1],p[Z*2],p[Z*2+1],p[y*2],p[y*2+1])}var t=this,L=0,m,h=[],p=[],C,q,A,N,x,D,G,E,z,I,F,T,V,P,da,X,R,U,ba,Y,H,S,W,ia,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(t,e,f); m={signature:a.substr(L,8),header_bytes:n(a,L+8),vertex_coordinate_bytes:n(a,L+9),normal_coordinate_bytes:n(a,L+10),uv_coordinate_bytes:n(a,L+11),vertex_index_bytes:n(a,L+12),normal_index_bytes:n(a,L+13),uv_index_bytes:n(a,L+14),material_index_bytes:n(a,L+15),nvertices:c(a,L+16),nnormals:c(a,L+16+4),nuvs:c(a,L+16+8),ntri_flat:c(a,L+16+12),ntri_smooth:c(a,L+16+16),ntri_flat_uv:c(a,L+16+20),ntri_smooth_uv:c(a,L+16+24),nquad_flat:c(a,L+16+28),nquad_smooth:c(a,L+16+32),nquad_flat_uv:c(a,L+16+36),nquad_smooth_uv:c(a, -L+16+40)};L+=m.header_bytes;B=m.vertex_index_bytes;q=m.vertex_index_bytes*2;A=m.vertex_index_bytes*3;N=m.vertex_index_bytes*3+m.material_index_bytes;v=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes;D=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*2;G=m.vertex_index_bytes;E=m.vertex_index_bytes*2;y=m.vertex_index_bytes*3;I=m.vertex_index_bytes*4;F=m.vertex_index_bytes*4+m.material_index_bytes;T=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes; -V=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*2;P=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*3;da=m.uv_index_bytes;X=m.uv_index_bytes*2;R=m.uv_index_bytes;U=m.uv_index_bytes*2;ba=m.uv_index_bytes*3;h=m.vertex_index_bytes*3+m.material_index_bytes;ha=m.vertex_index_bytes*4+m.material_index_bytes;Y=m.ntri_flat*h;H=m.ntri_smooth*(h+m.normal_index_bytes*3);S=m.ntri_flat_uv*(h+m.uv_index_bytes*3);W=m.ntri_smooth_uv*(h+m.normal_index_bytes*3+m.uv_index_bytes* -3);ia=m.nquad_flat*ha;h=m.nquad_smooth*(ha+m.normal_index_bytes*4);ha=m.nquad_flat_uv*(ha+m.uv_index_bytes*4);L+=function(w){var M,J,Z,ca=m.vertex_coordinate_bytes*3,ga=w+m.nvertices*ca;for(w=w;w