From 3c1ca82d10255e985fbdd25dedac85b63a852b56 Mon Sep 17 00:00:00 2001 From: alteredq Date: Wed, 26 Jan 2011 18:49:25 +0100 Subject: [PATCH] Extended gating of scene start also to asynchronous loading of textures. --- build/ThreeExtras.js | 311 ++++++++++++++++++++------------------- src/extras/ImageUtils.js | 4 +- src/extras/SceneUtils.js | 43 +++++- 3 files changed, 194 insertions(+), 164 deletions(-) diff --git a/build/ThreeExtras.js b/build/ThreeExtras.js index a514bee8..1c08bc60 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,h=[];a=0;for(b=e.length;a0&&H>0&&m+H<1}var d,e,h,f,g,c,k,l,q,C, -p,u=a.geometry,w=u.vertices,t=[];d=0;for(e=u.faces.length;dk?e:k;h=h>l? -h:l}a()};this.add3Points=function(k,l,q,C,p,u){if(c){c=false;b=kq?k>p?k:p:q>p?q:p;h=l>C?l>u?l:u:C>u?C:u}else{b=kq?k>p?k>e?k:e:p>e?p:e:q>p?q>e?q:e:p>e?p:e;h=l>C?l>u?l>h?l:h:u>h?u:h:C>u?C>h?C:h:u>h?u:h}a()};this.addRectangle=function(k){if(c){c=false;b=k.getLeft();d=k.getTop();e=k.getRight();h=k.getBottom()}else{b=bk.getRight()?e:k.getRight();h=h>k.getBottom()?h:k.getBottom()}a()};this.inflate=function(k){b-=k;d-=k;e+=k;h+=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(h,k.getBottom())-Math.max(d,k.getTop())>=0};this.empty=function(){c=true;h=e=d=b=0;a()};this.isEmpty=function(){return c};this.toString= -function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+h+", width: "+f+", height: "+g+" )"}};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,h,f,g,c,k,l,q,C,p,u,w,t){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=h||0;this.n22=f||1;this.n23=g||0;this.n24=c||0;this.n31=k||0;this.n32=l||0;this.n33=q||1;this.n34=C||0;this.n41=p||0;this.n42=u||0;this.n43=w||0;this.n44=t||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,h,f,g,c,k,l,q,C,p,u,w,t){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=h;this.n22=f;this.n23=g;this.n24=c;this.n31=k;this.n32=l;this.n33=q;this.n34=C;this.n41=p;this.n42=u;this.n43=w;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,d){var e=THREE.Matrix4.__tmpVec1,h=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();e.cross(d,f).normalize();h.cross(f,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a); -this.n31=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,h=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*h;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*h;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,h=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*h;a.y=this.n21*b+this.n22*d+this.n23* -e+this.n24*h;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*h;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*h;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,h=a.n13,f=a.n14,g=a.n21,c=a.n22,k=a.n23,l=a.n24,q=a.n31, -C=a.n32,p=a.n33,u=a.n34,w=a.n41,t=a.n42,H=a.n43,v=a.n44,J=b.n11,n=b.n12,j=b.n13,m=b.n14,B=b.n21,o=b.n22,A=b.n23,M=b.n24,y=b.n31,D=b.n32,F=b.n33,E=b.n34,z=b.n41,O=b.n42,K=b.n43,U=b.n44;this.n11=d*J+e*B+h*y+f*z;this.n12=d*n+e*o+h*D+f*O;this.n13=d*j+e*A+h*F+f*K;this.n14=d*m+e*M+h*E+f*U;this.n21=g*J+c*B+k*y+l*z;this.n22=g*n+c*o+k*D+l*O;this.n23=g*j+c*A+k*F+l*K;this.n24=g*m+c*M+k*E+l*U;this.n31=q*J+C*B+p*y+u*z;this.n32=q*n+C*o+p*D+u*O;this.n33=q*j+C*A+p*F+u*K;this.n34=q*m+C*M+p*E+u*U;this.n41=w*J+t*B+ -H*y+v*z;this.n42=w*n+t*o+H*D+v*O;this.n43=w*j+t*A+H*F+v*K;this.n44=w*m+t*M+H*E+v*U;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,h=this.n14,f=this.n21,g=this.n22,c=this.n23,k=this.n24,l=this.n31,q=this.n32,C=this.n33,p=this.n34,u=this.n41,w=this.n42,t=this.n43,H=this.n44,v=a.n11,J=a.n21,n=a.n31,j=a.n41,m=a.n12,B=a.n22,o=a.n32,A=a.n42,M=a.n13,y=a.n23,D=a.n33,F=a.n43,E=a.n14,z=a.n24,O=a.n34;a=a.n44;this.n11=b*v+d*J+e*n+h*j;this.n12=b*m+d*B+e*o+h*A;this.n13=b*M+d*y+e*D+h* -F;this.n14=b*E+d*z+e*O+h*a;this.n21=f*v+g*J+c*n+k*j;this.n22=f*m+g*B+c*o+k*A;this.n23=f*M+g*y+c*D+k*F;this.n24=f*E+g*z+c*O+k*a;this.n31=l*v+q*J+C*n+p*j;this.n32=l*m+q*B+C*o+p*A;this.n33=l*M+q*y+C*D+p*F;this.n34=l*E+q*z+C*O+p*a;this.n41=u*v+w*J+t*n+H*j;this.n42=u*m+w*B+t*o+H*A;this.n43=u*M+w*y+t*D+H*F;this.n44=u*E+w*z+t*O+H*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*= -a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,d=this.n13,e=this.n14,h=this.n21,f=this.n22,g=this.n23,c=this.n24,k=this.n31,l=this.n32,q=this.n33,C=this.n34,p=this.n41,u=this.n42,w=this.n43,t=this.n44;return e*g*l*p-d*c*l*p-e*f*q*p+b*c*q*p+d*f*C*p-b*g*C*p-e*g*k*u+d*c*k*u+e*h*q*u-a*c*q*u-d*h*C*u+a*g*C*u+e*f*k*w-b*c*k*w-e*h*l*w+a*c*l*w+b*h*C*w-a*f*C*w-d*f*k*t+b*g*k*t+d*h*l*t-a*g*l*t-b*h*q*t+a*f*q*t},transpose:function(){function a(b,d, -e){var h=b[d];b[d]=b[e];b[e]=h}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){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&&H>0&&m+H<1}var d,e,g,f,h,c,k,l,q,C, +o,v=a.geometry,x=v.vertices,t=[];d=0;for(e=v.faces.length;dk?e:k;g=g>l? +g:l}a()};this.add3Points=function(k,l,q,C,o,v){if(c){c=false;b=kq?k>o?k:o:q>o?q:o;g=l>C?l>v?l:v:C>v?C:v}else{b=kq?k>o?k>e?k:e:o>e?o:e:q>o?q>e?q:e:o>e?o:e;g=l>C?l>v?l>g?l:g:v>g?v:g:C>v?C>g?C:g:v>g?v: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: "+h+" )"}};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,h,c,k,l,q,C,o,v,x,t){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=h||0;this.n24=c||0;this.n31=k||0;this.n32=l||0;this.n33=q||1;this.n34=C||0;this.n41=o||0;this.n42=v||0;this.n43=x||0;this.n44=t||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,h,c,k,l,q,C,o,v,x,t){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=g;this.n22=f;this.n23=h;this.n24=c;this.n31=k;this.n32=l;this.n33=q;this.n34=C;this.n41=o;this.n42=v;this.n43=x;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,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,h=a.n21,c=a.n22,k=a.n23,l=a.n24,q=a.n31, +C=a.n32,o=a.n33,v=a.n34,x=a.n41,t=a.n42,H=a.n43,w=a.n44,J=b.n11,n=b.n12,j=b.n13,m=b.n14,B=b.n21,u=b.n22,p=b.n23,M=b.n24,y=b.n31,D=b.n32,F=b.n33,E=b.n34,A=b.n41,O=b.n42,K=b.n43,U=b.n44;this.n11=d*J+e*B+g*y+f*A;this.n12=d*n+e*u+g*D+f*O;this.n13=d*j+e*p+g*F+f*K;this.n14=d*m+e*M+g*E+f*U;this.n21=h*J+c*B+k*y+l*A;this.n22=h*n+c*u+k*D+l*O;this.n23=h*j+c*p+k*F+l*K;this.n24=h*m+c*M+k*E+l*U;this.n31=q*J+C*B+o*y+v*A;this.n32=q*n+C*u+o*D+v*O;this.n33=q*j+C*p+o*F+v*K;this.n34=q*m+C*M+o*E+v*U;this.n41=x*J+t*B+ +H*y+w*A;this.n42=x*n+t*u+H*D+w*O;this.n43=x*j+t*p+H*F+w*K;this.n44=x*m+t*M+H*E+w*U;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,g=this.n14,f=this.n21,h=this.n22,c=this.n23,k=this.n24,l=this.n31,q=this.n32,C=this.n33,o=this.n34,v=this.n41,x=this.n42,t=this.n43,H=this.n44,w=a.n11,J=a.n21,n=a.n31,j=a.n41,m=a.n12,B=a.n22,u=a.n32,p=a.n42,M=a.n13,y=a.n23,D=a.n33,F=a.n43,E=a.n14,A=a.n24,O=a.n34;a=a.n44;this.n11=b*w+d*J+e*n+g*j;this.n12=b*m+d*B+e*u+g*p;this.n13=b*M+d*y+e*D+g* +F;this.n14=b*E+d*A+e*O+g*a;this.n21=f*w+h*J+c*n+k*j;this.n22=f*m+h*B+c*u+k*p;this.n23=f*M+h*y+c*D+k*F;this.n24=f*E+h*A+c*O+k*a;this.n31=l*w+q*J+C*n+o*j;this.n32=l*m+q*B+C*u+o*p;this.n33=l*M+q*y+C*D+o*F;this.n34=l*E+q*A+C*O+o*a;this.n41=v*w+x*J+t*n+H*j;this.n42=v*m+x*B+t*u+H*p;this.n43=v*M+x*y+t*D+H*F;this.n44=v*E+x*A+t*O+H*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*= +a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,d=this.n13,e=this.n14,g=this.n21,f=this.n22,h=this.n23,c=this.n24,k=this.n31,l=this.n32,q=this.n33,C=this.n34,o=this.n41,v=this.n42,x=this.n43,t=this.n44;return e*h*l*o-d*c*l*o-e*f*q*o+b*c*q*o+d*f*C*o-b*h*C*o-e*h*k*v+d*c*k*v+e*g*q*v-a*c*q*v-d*g*C*v+a*h*C*v+e*f*k*x-b*c*k*x-e*g*l*x+a*c*l*x+b*g*C*x-a*f*C*x-d*f*k*t+b*h*k*t+d*g*l*t-a*h*l*t-b*g*q*t+a*f*q*t},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),h=1-d,f=a.x,g=a.y,c=a.z,k=h*f,l=h*g;this.set(k*f+d,k*g-e*c,k*c+e*g,0,k*g+e*c,l*g+d,l*c-e*f,0,k*c-e*g,l*c+e*f,h*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,h=a.y,c=a.z,k=g*f,l=g*h;this.set(k*f+d,k*h-e*c,k*c+e*h,0,k*h+e*c,l*h+d,l*c-e*f,0,k*c-e*h,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,h=a.n14,f=a.n21,g=a.n22,c=a.n23,k=a.n24,l=a.n31,q=a.n32,C=a.n33,p=a.n34,u=a.n41,w=a.n42,t=a.n43,H=a.n44,v=new THREE.Matrix4;v.n11=c*p*w-k*C*w+k*q*t-g*p*t-c*q*H+g*C*H;v.n12=h*C*w-e*p*w-h*q*t+d*p*t+e*q*H-d*C*H;v.n13=e*k*w-h*c*w+h*g*t-d*k*t-e*g*H+d*c*H;v.n14=h*c*q-e*k*q-h*g*C+d*k*C+e*g*p-d*c*p;v.n21=k*C*u-c*p*u-k*l*t+f*p*t+c*l*H-f*C*H;v.n22=e*p*u-h*C*u+h*l*t-b*p*t-e*l*H+b*C*H;v.n23=h*c*u-e*k*u-h*f*t+b*k*t+e*f*H-b*c*H;v.n24=e*k*l-h*c*l+ -h*f*C-b*k*C-e*f*p+b*c*p;v.n31=g*p*u-k*q*u+k*l*w-f*p*w-g*l*H+f*q*H;v.n32=h*q*u-d*p*u-h*l*w+b*p*w+d*l*H-b*q*H;v.n33=e*k*u-h*g*u+h*f*w-b*k*w-d*f*H+b*g*H;v.n34=h*g*l-d*k*l-h*f*q+b*k*q+d*f*p-b*g*p;v.n41=c*q*u-g*C*u-c*l*w+f*C*w+g*l*t-f*q*t;v.n42=d*C*u-e*q*u+e*l*w-b*C*w-d*l*t+b*q*t;v.n43=e*g*u-d*c*u-e*f*w+b*c*w+d*f*t-b*g*t;v.n44=d*c*l-e*g*l+e*f*q-b*c*q-d*f*C+b*g*C;v.multiplyScalar(1/a.determinant());return v}; -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],h=-b[10]*b[1]+b[2]*b[9],f=b[6]*b[1]-b[2]*b[5],g=-b[10]*b[4]+b[6]*b[8],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],q=-b[9]*b[0]+b[1]*b[8],C=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*g+b[2]*l;if(b==0)throw"matrix not invertible";b=1/b;d[0]=b*e;d[1]=b*h;d[2]=b*f;d[3]=b*g;d[4]=b*c;d[5]=b*k;d[6]=b*l;d[7]=b*q;d[8]=b*C;return a}; -THREE.Matrix4.makeFrustum=function(a,b,d,e,h,f){var g,c,k;g=new THREE.Matrix4;c=2*h/(b-a);k=2*h/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(f+h)/(f-h);h=-2*f*h/(f-h);g.n11=c;g.n12=0;g.n13=a;g.n14=0;g.n21=0;g.n22=k;g.n23=d;g.n24=0;g.n31=0;g.n32=0;g.n33=e;g.n34=h;g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,d,e){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,d,e)}; -THREE.Matrix4.makeOrtho=function(a,b,d,e,h,f){var g,c,k,l;g=new THREE.Matrix4;c=b-a;k=d-e;l=f-h;a=(b+a)/c;d=(d+e)/k;h=(f+h)/l;g.n11=2/c;g.n12=0;g.n13=0;g.n14=-a;g.n21=0;g.n22=2/k;g.n23=0;g.n24=-d;g.n31=0;g.n32=0;g.n33=-2/l;g.n34=-h;g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};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,h=a.n22,c=a.n23,k=a.n24,l=a.n31,q=a.n32,C=a.n33,o=a.n34,v=a.n41,x=a.n42,t=a.n43,H=a.n44,w=new THREE.Matrix4;w.n11=c*o*x-k*C*x+k*q*t-h*o*t-c*q*H+h*C*H;w.n12=g*C*x-e*o*x-g*q*t+d*o*t+e*q*H-d*C*H;w.n13=e*k*x-g*c*x+g*h*t-d*k*t-e*h*H+d*c*H;w.n14=g*c*q-e*k*q-g*h*C+d*k*C+e*h*o-d*c*o;w.n21=k*C*v-c*o*v-k*l*t+f*o*t+c*l*H-f*C*H;w.n22=e*o*v-g*C*v+g*l*t-b*o*t-e*l*H+b*C*H;w.n23=g*c*v-e*k*v-g*f*t+b*k*t+e*f*H-b*c*H;w.n24=e*k*l-g*c*l+ +g*f*C-b*k*C-e*f*o+b*c*o;w.n31=h*o*v-k*q*v+k*l*x-f*o*x-h*l*H+f*q*H;w.n32=g*q*v-d*o*v-g*l*x+b*o*x+d*l*H-b*q*H;w.n33=e*k*v-g*h*v+g*f*x-b*k*x-d*f*H+b*h*H;w.n34=g*h*l-d*k*l-g*f*q+b*k*q+d*f*o-b*h*o;w.n41=c*q*v-h*C*v-c*l*x+f*C*x+h*l*t-f*q*t;w.n42=d*C*v-e*q*v+e*l*x-b*C*x-d*l*t+b*q*t;w.n43=e*h*v-d*c*v-e*f*x+b*c*x+d*f*t-b*h*t;w.n44=d*c*l-e*h*l+e*f*q-b*c*q-d*f*C+b*h*C;w.multiplyScalar(1/a.determinant());return w}; +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],h=-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],q=-b[9]*b[0]+b[1]*b[8],C=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*h+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*h;d[4]=b*c;d[5]=b*k;d[6]=b*l;d[7]=b*q;d[8]=b*C;return a}; +THREE.Matrix4.makeFrustum=function(a,b,d,e,g,f){var h,c,k;h=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);h.n11=c;h.n12=0;h.n13=a;h.n14=0;h.n21=0;h.n22=k;h.n23=d;h.n24=0;h.n31=0;h.n32=0;h.n33=e;h.n34=g;h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};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 h,c,k,l;h=new THREE.Matrix4;c=b-a;k=d-e;l=f-g;a=(b+a)/c;d=(d+e)/k;g=(f+g)/l;h.n11=2/c;h.n12=0;h.n13=0;h.n14=-a;h.n21=0;h.n22=2/k;h.n23=0;h.n24=-d;h.n31=0;h.n32=0;h.n33=-2/l;h.n34=-g;h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};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,h){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,b,d,e,h,f){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.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.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,A,O,K,U,W,P){f=E.vertices[A].position;h=E.vertices[O].position;c=E.vertices[K].position;k=g[U];l=g[W];q=g[P];C=h.x-f.x;o=c.x-f.x;v=h.y-f.y;x=c.y-f.y; +t=h.z-f.z;H=c.z-f.z;w=l.u-k.u;J=q.u-k.u;n=l.v-k.v;j=q.v-k.v;m=1/(w*j-J*n);p.set((j*C-n*o)*m,(j*v-n*x)*m,(j*t-n*H)*m);M.set((w*o-J*C)*m,(w*x-J*v)*m,(w*H-J*t)*m);B[A].addSelf(p);B[O].addSelf(p);B[K].addSelf(p);u[A].addSelf(M);u[O].addSelf(M);u[K].addSelf(M)}var b,d,e,g,f,h,c,k,l,q,C,o,v,x,t,H,w,J,n,j,m,B=[],u=[],p=new THREE.Vector3,M=new THREE.Vector3,y=new THREE.Vector3,D=new THREE.Vector3,F=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:g,vertices:0}}this.geometryChunks[k].faces.push(e);this.geometryChunks[k].vertices+=f}},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:h,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(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)}; -this.translateZ=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);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,100 +89,100 @@ 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,h,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=h!==undefined?h:THREE.LinearFilter;this.min_filter=f!==undefined?f: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,h={};for(b in a){h[b]={};for(d in a[b]){e=a[b][d];h[b][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return h},merge:function(a){var b,d,e,h={};for(b=0;b=0&&F>=0&&E>=0&&z>=0)return true;else if(D<0&&F<0||E<0&&z<0)return false;else{if(D<0)M=Math.max(M,D/(D-F));else if(F<0)y=Math.min(y,D/(D-F));if(E<0)M=Math.max(M,E/(E-z));else if(z<0)y=Math.min(y,E/(E-z));if(yD&&K.z=0&&F>=0&&E>=0&&A>=0)return true;else if(D<0&&F<0||E<0&&A<0)return false;else{if(D<0)M=Math.max(M,D/(D-F));else if(F<0)y=Math.min(y,D/(D-F));if(E<0)M=Math.max(M,E/(E-A));else if(A<0)y=Math.min(y,E/(E-A));if(yD&&K.z0&&H.z<1){p=w[u]=w[u]||new THREE.RenderableParticle;p.x=H.x/H.w;p.y=H.y/H.w;p.z=H.z;p.rotation=P.rotation.z;p.scale.x=P.scale.x*Math.abs(p.x-(H.x+A.projectionMatrix.n11)/(H.w+A.projectionMatrix.n14)); -p.scale.y=P.scale.y*Math.abs(p.y-(H.y+A.projectionMatrix.n22)/(H.w+A.projectionMatrix.n24));p.materials=P.materials;y.push(p);u++}}}}M&&y.sort(a);return y};this.unprojectVector=function(o,A){var M=THREE.Matrix4.makeInvert(A.matrix);M.multiplySelf(THREE.Matrix4.makeInvert(A.projectionMatrix));M.multiplyVector3(o);return o}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,h,f;this.domElement=document.createElement("div");this.setSize=function(g,c){d=g;e=c;h=d/2;f=e/2};this.render=function(g,c){var k,l,q,C,p,u,w,t;a=b.projectScene(g,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){I.sub(fa.position,ea);I.normalize();fa=aa.dot(I)*na;if(fa>0){Q.r+=la.r*fa;Q.g+=la.g*fa;Q.b+=la.b*fa}}}}function Qa(N,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;G.set(N.x-aa,N.y-Q,N.x+aa,N.y+Q);if(ba.instersects(G)){l.save();l.translate(N.x,N.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){V.r=ia.r+ha.r+x.r;V.g=ia.g+ha.g+x.g;V.b=ia.b+ha.b+x.b;y.r=aa.color.r* +f.v3.positionWorld.copy(V.positionWorld);f.v1.positionScreen.copy(K.positionScreen);f.v2.positionScreen.copy(U.positionScreen);f.v3.positionScreen.copy(V.positionScreen);f.normalWorld.copy(G.normal);X.multiplyVector3(f.normalWorld);f.centroidWorld.copy(G.centroid);da.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);w.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=R;f.faceMaterials=G.materials;f.overdraw=T;if(P.geometry.uvs[A]){f.uvs[0]=P.geometry.uvs[A][0]; +f.uvs[1]=P.geometry.uvs[A][1];f.uvs[2]=P.geometry.uvs[A][3]}y.push(f);c++;h=k[c]=k[c]||new THREE.RenderableFace3;h.v1.positionWorld.copy(U.positionWorld);h.v2.positionWorld.copy(S.positionWorld);h.v3.positionWorld.copy(V.positionWorld);h.v1.positionScreen.copy(U.positionScreen);h.v2.positionScreen.copy(S.positionScreen);h.v3.positionScreen.copy(V.positionScreen);h.normalWorld.copy(f.normalWorld);h.centroidWorld.copy(f.centroidWorld);h.centroidScreen.copy(f.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials= +R;h.faceMaterials=G.materials;h.overdraw=T;if(P.geometry.uvs[A]){h.uvs[0]=P.geometry.uvs[A][1];h.uvs[1]=P.geometry.uvs[A][2];h.uvs[2]=P.geometry.uvs[A][3]}y.push(h);c++}}}}else if(P instanceof THREE.Line){J.multiply(w,da);Y=P.geometry.vertices;G=Y[0];G.positionScreen.copy(G.position);J.multiplyVector4(G.positionScreen);A=1;for(O=Y.length;A0&&H.z<1){o=x[v]=x[v]||new THREE.RenderableParticle;o.x=H.x/H.w;o.y=H.y/H.w;o.z=H.z;o.rotation=P.rotation.z;o.scale.x=P.scale.x*Math.abs(o.x-(H.x+p.projectionMatrix.n11)/(H.w+p.projectionMatrix.n14)); +o.scale.y=P.scale.y*Math.abs(o.y-(H.y+p.projectionMatrix.n22)/(H.w+p.projectionMatrix.n24));o.materials=P.materials;y.push(o);v++}}}}M&&y.sort(a);return y};this.unprojectVector=function(u,p){var M=THREE.Matrix4.makeInvert(p.matrix);M.multiplySelf(THREE.Matrix4.makeInvert(p.projectionMatrix));M.multiplyVector3(u);return u}}; +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(h,c){d=h;e=c;g=d/2;f=e/2};this.render=function(h,c){var k,l,q,C,o,v,x,t;a=b.projectScene(h,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){I.sub(fa.position,ea);I.normalize();fa=aa.dot(I)*na;if(fa>0){Q.r+=la.r*fa;Q.g+=la.g*fa;Q.b+=la.b*fa}}}}function Qa(N,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;G.set(N.x-aa,N.y-Q,N.x+aa,N.y+Q);if(ba.instersects(G)){l.save();l.translate(N.x,N.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){V.r=ia.r+ha.r+z.r;V.g=ia.g+ha.g+z.g;V.b=ia.b+ha.b+z.b;y.r=aa.color.r* V.r;y.g=aa.color.g*V.g;y.b=aa.color.b*V.b;y.updateStyleString()}else y.__styleString=aa.color.__styleString;aa=ea.scale.x*c;Q=ea.scale.y*k;G.set(N.x-aa,N.y-Q,N.x+aa,N.y+Q);if(ba.instersects(G)){$=y.__styleString;if(t!=$)l.fillStyle=t=$;l.save();l.translate(N.x,N.y);l.rotate(-ea.rotation);l.scale(aa,Q);l.beginPath();l.arc(0,0,1,0,L,true);l.closePath();l.fill();l.restore()}}}}function Ra(N,ea,aa,Q){if(Q.opacity!=0){a(Q.opacity);b(Q.blending);l.beginPath();l.moveTo(N.positionScreen.x,N.positionScreen.y); -l.lineTo(ea.positionScreen.x,ea.positionScreen.y);l.closePath();if(Q instanceof THREE.LineBasicMaterial){y.__styleString=Q.color.__styleString;N=Q.linewidth;if(H!=N)l.lineWidth=H=N;N=y.__styleString;if(w!=N)l.strokeStyle=w=N;l.stroke();G.inflate(Q.linewidth*2)}}}function La(N,ea,aa,Q,$,fa){if($.opacity!=0){a($.opacity);b($.blending);j=N.positionScreen.x;m=N.positionScreen.y;B=ea.positionScreen.x;o=ea.positionScreen.y;A=aa.positionScreen.x;M=aa.positionScreen.y;l.beginPath();l.moveTo(j,m);l.lineTo(B, -o);l.lineTo(A,M);l.lineTo(j,m);l.closePath();if($ instanceof THREE.MeshBasicMaterial)if($.map)$.map.image.loaded&&$.map.mapping instanceof THREE.UVMapping&&Aa(j,m,B,o,A,M,$.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){N=wa.matrix;I.copy(Q.vertexNormalsWorld[0]);W=(I.x*N.n11+I.y*N.n12+I.z*N.n13)*0.5+0.5;P=-(I.x*N.n21+I.y*N.n22+I.z*N.n23)*0.5+0.5;I.copy(Q.vertexNormalsWorld[1]); -da=(I.x*N.n11+I.y*N.n12+I.z*N.n13)*0.5+0.5;X=-(I.x*N.n21+I.y*N.n22+I.z*N.n23)*0.5+0.5;I.copy(Q.vertexNormalsWorld[2]);R=(I.x*N.n11+I.y*N.n12+I.z*N.n13)*0.5+0.5;T=-(I.x*N.n21+I.y*N.n22+I.z*N.n23)*0.5+0.5;Aa(j,m,B,o,A,M,$.env_map.image,W,P,da,X,R,T)}}else $.wireframe?Ea($.color.__styleString,$.wireframe_linewidth):Fa($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&!$.wireframe){$.map.mapping instanceof THREE.UVMapping&&Aa(j,m,B,o,A,M,$.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=F.r=E.r=ia.r;D.g=F.g=E.g=ia.g;D.b=F.b=E.b=ia.b;Da(fa,Q.v1.positionWorld,Q.vertexNormalsWorld[0],D);Da(fa,Q.v2.positionWorld,Q.vertexNormalsWorld[1],F);Da(fa,Q.v3.positionWorld,Q.vertexNormalsWorld[2],E);z.r=(F.r+E.r)*0.5;z.g=(F.g+E.g)*0.5;z.b=(F.b+E.b)*0.5;U=Ma(D,F,E,z);Aa(j,m,B,o,A,M,U,0,0,1,0,0,1)}else{V.r=ia.r;V.g=ia.g;V.b=ia.b;Da(fa, -Q.centroidWorld,Q.normalWorld,V);y.r=$.color.r*V.r;y.g=$.color.g*V.g;y.b=$.color.b*V.b;y.updateStyleString();$.wireframe?Ea(y.__styleString,$.wireframe_linewidth):Fa(y.__styleString)}else $.wireframe?Ea($.color.__styleString,$.wireframe_linewidth):Fa($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){O=wa.near;K=wa.far;D.r=D.g=D.b=1-Ha(N.positionScreen.z,O,K);F.r=F.g=F.b=1-Ha(ea.positionScreen.z,O,K);E.r=E.g=E.b=1-Ha(aa.positionScreen.z,O,K);z.r=(F.r+E.r)*0.5;z.g=(F.g+E.g)*0.5;z.b= -(F.b+E.b)*0.5;U=Ma(D,F,E,z);Aa(j,m,B,o,A,M,U,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){y.r=Ia(Q.normalWorld.x);y.g=Ia(Q.normalWorld.y);y.b=Ia(Q.normalWorld.z);y.updateStyleString();$.wireframe?Ea(y.__styleString,$.wireframe_linewidth):Fa(y.__styleString)}}}function Ea(N,ea){if(w!=N)l.strokeStyle=w=N;if(H!=ea)l.lineWidth=H=ea;l.stroke();G.inflate(ea*2)}function Fa(N){if(t!=N)l.fillStyle=t=N;l.fill()}function Aa(N,ea,aa,Q,$,fa,la,na,oa,ta,pa,ua,Ba){var xa,va;xa=la.width-1;va=la.height- +l.lineTo(ea.positionScreen.x,ea.positionScreen.y);l.closePath();if(Q instanceof THREE.LineBasicMaterial){y.__styleString=Q.color.__styleString;N=Q.linewidth;if(H!=N)l.lineWidth=H=N;N=y.__styleString;if(x!=N)l.strokeStyle=x=N;l.stroke();G.inflate(Q.linewidth*2)}}}function La(N,ea,aa,Q,$,fa){if($.opacity!=0){a($.opacity);b($.blending);j=N.positionScreen.x;m=N.positionScreen.y;B=ea.positionScreen.x;u=ea.positionScreen.y;p=aa.positionScreen.x;M=aa.positionScreen.y;l.beginPath();l.moveTo(j,m);l.lineTo(B, +u);l.lineTo(p,M);l.lineTo(j,m);l.closePath();if($ instanceof THREE.MeshBasicMaterial)if($.map)$.map.image.loaded&&$.map.mapping instanceof THREE.UVMapping&&Aa(j,m,B,u,p,M,$.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){N=wa.matrix;I.copy(Q.vertexNormalsWorld[0]);W=(I.x*N.n11+I.y*N.n12+I.z*N.n13)*0.5+0.5;P=-(I.x*N.n21+I.y*N.n22+I.z*N.n23)*0.5+0.5;I.copy(Q.vertexNormalsWorld[1]); +da=(I.x*N.n11+I.y*N.n12+I.z*N.n13)*0.5+0.5;X=-(I.x*N.n21+I.y*N.n22+I.z*N.n23)*0.5+0.5;I.copy(Q.vertexNormalsWorld[2]);R=(I.x*N.n11+I.y*N.n12+I.z*N.n13)*0.5+0.5;T=-(I.x*N.n21+I.y*N.n22+I.z*N.n23)*0.5+0.5;Aa(j,m,B,u,p,M,$.env_map.image,W,P,da,X,R,T)}}else $.wireframe?Ea($.color.__styleString,$.wireframe_linewidth):Fa($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&!$.wireframe){$.map.mapping instanceof THREE.UVMapping&&Aa(j,m,B,u,p,M,$.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=F.r=E.r=ia.r;D.g=F.g=E.g=ia.g;D.b=F.b=E.b=ia.b;Da(fa,Q.v1.positionWorld,Q.vertexNormalsWorld[0],D);Da(fa,Q.v2.positionWorld,Q.vertexNormalsWorld[1],F);Da(fa,Q.v3.positionWorld,Q.vertexNormalsWorld[2],E);A.r=(F.r+E.r)*0.5;A.g=(F.g+E.g)*0.5;A.b=(F.b+E.b)*0.5;U=Ma(D,F,E,A);Aa(j,m,B,u,p,M,U,0,0,1,0,0,1)}else{V.r=ia.r;V.g=ia.g;V.b=ia.b;Da(fa, +Q.centroidWorld,Q.normalWorld,V);y.r=$.color.r*V.r;y.g=$.color.g*V.g;y.b=$.color.b*V.b;y.updateStyleString();$.wireframe?Ea(y.__styleString,$.wireframe_linewidth):Fa(y.__styleString)}else $.wireframe?Ea($.color.__styleString,$.wireframe_linewidth):Fa($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){O=wa.near;K=wa.far;D.r=D.g=D.b=1-Ha(N.positionScreen.z,O,K);F.r=F.g=F.b=1-Ha(ea.positionScreen.z,O,K);E.r=E.g=E.b=1-Ha(aa.positionScreen.z,O,K);A.r=(F.r+E.r)*0.5;A.g=(F.g+E.g)*0.5;A.b= +(F.b+E.b)*0.5;U=Ma(D,F,E,A);Aa(j,m,B,u,p,M,U,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){y.r=Ia(Q.normalWorld.x);y.g=Ia(Q.normalWorld.y);y.b=Ia(Q.normalWorld.z);y.updateStyleString();$.wireframe?Ea(y.__styleString,$.wireframe_linewidth):Fa(y.__styleString)}}}function Ea(N,ea){if(x!=N)l.strokeStyle=x=N;if(H!=ea)l.lineWidth=H=ea;l.stroke();G.inflate(ea*2)}function Fa(N){if(t!=N)l.fillStyle=t=N;l.fill()}function Aa(N,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-=N;Q-=ea;$-=N;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;N=N-xa*na-aa*oa;ea=ea-pa*na-Q*oa;l.save();l.transform(xa,pa,aa,Q,N,ea);l.clip();l.drawImage(la,0,0);l.restore()}function Ma(N,ea,aa,Q){var $=~~(N.r*255),fa=~~(N.g*255);N=~~(N.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]=N<0?0:N>255?255:N;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(N,ea,aa){N=(N-ea)/(aa-ea);return N*N*(3-2*N)}function Ia(N){N=(N+1)*0.5;return N<0?0:N>1?1:N}function Ja(N, -ea){var aa=ea.x-N.x,Q=ea.y-N.y,$=1/Math.sqrt(aa*aa+Q*Q);aa*=$;Q*=$;ea.x+=aa;ea.y+=Q;N.x-=aa;N.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)&&Pa(ma);Ga=0;for(Na=d.length;Ga0){da.r+=T.color.r*ba;da.g+=T.color.g*ba;da.b+=T.color.b*ba}}else if(T instanceof THREE.PointLight){M.sub(T.position,P.centroidWorld);M.normalize();ba=P.normalWorld.dot(M)*T.intensity;if(ba>0){da.r+=T.color.r*ba;da.g+=T.color.g*ba;da.b+=T.color.b*ba}}}}function b(W,P,da,X,R,T){E=e(z++);E.setAttribute("d", -"M "+W.positionScreen.x+" "+W.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+"z");if(R instanceof THREE.MeshBasicMaterial)n.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshLambertMaterial)if(J){j.r=m.r;j.g=m.g;j.b=m.b;a(T,X,j);n.r=R.color.r*j.r;n.g=R.color.g*j.g;n.b=R.color.b*j.b;n.updateStyleString()}else n.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshDepthMaterial){A=1-R.__2near/(R.__farPlusNear- -X.z*R.__farMinusNear);n.setRGB(A,A,A)}else R instanceof THREE.MeshNormalMaterial&&n.setRGB(h(X.normalWorld.x),h(X.normalWorld.y),h(X.normalWorld.z));R.wireframe?E.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+R.wireframe_linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.wireframe_linecap+"; stroke-linejoin: "+R.wireframe_linejoin):E.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+R.opacity);c.appendChild(E)}function d(W,P,da,X,R,T,ba){E= -e(z++);E.setAttribute("d","M "+W.positionScreen.x+" "+W.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(T instanceof THREE.MeshBasicMaterial)n.__styleString=T.color.__styleString;else if(T instanceof THREE.MeshLambertMaterial)if(J){j.r=m.r;j.g=m.g;j.b=m.b;a(ba,R,j);n.r=T.color.r*j.r;n.g=T.color.g*j.g;n.b=T.color.b*j.b;n.updateStyleString()}else n.__styleString=T.color.__styleString; -else if(T instanceof THREE.MeshDepthMaterial){A=1-T.__2near/(T.__farPlusNear-R.z*T.__farMinusNear);n.setRGB(A,A,A)}else T instanceof THREE.MeshNormalMaterial&&n.setRGB(h(R.normalWorld.x),h(R.normalWorld.y),h(R.normalWorld.z));T.wireframe?E.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+T.wireframe_linewidth+"; stroke-opacity: "+T.opacity+"; stroke-linecap: "+T.wireframe_linecap+"; stroke-linejoin: "+T.wireframe_linejoin):E.setAttribute("style","fill: "+n.__styleString+ -"; fill-opacity: "+T.opacity);c.appendChild(E)}function e(W){if(y[W]==null){y[W]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&y[W].setAttribute("shape-rendering","crispEdges");return y[W]}return y[W]}function h(W){return W<0?Math.min((1+W)*0.5,0.5):0.5+Math.min(W*0.5,0.5)}var f=null,g=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,l,q,C,p,u,w,t,H=new THREE.Rectangle,v=new THREE.Rectangle,J=false,n=new THREE.Color(16777215),j=new THREE.Color(16777215), -m=new THREE.Color(0),B=new THREE.Color(0),o=new THREE.Color(0),A,M=new THREE.Vector3,y=[],D=[],F=[],E,z,O,K,U=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(W){switch(W){case "high":U=1;break;case "low":U=0}};this.setSize=function(W,P){k=W;l=P;q=k/2;C=l/2;c.setAttribute("viewBox",-q+" "+-C+" "+k+" "+l);c.setAttribute("width",k);c.setAttribute("height",l);H.set(-q,-C,q,C)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])}; -this.render=function(W,P){var da,X,R,T,ba,Y,G,S;this.autoClear&&this.clear();f=g.projectScene(W,P,this.sortElements);K=O=z=0;if(J=W.lights.length>0){G=W.lights;m.setRGB(0,0,0);B.setRGB(0,0,0);o.setRGB(0,0,0);da=0;for(X=G.length;da0){da.r+=T.color.r*ba;da.g+=T.color.g*ba;da.b+=T.color.b*ba}}else if(T instanceof THREE.PointLight){M.sub(T.position,P.centroidWorld);M.normalize();ba=P.normalWorld.dot(M)*T.intensity;if(ba>0){da.r+=T.color.r*ba;da.g+=T.color.g*ba;da.b+=T.color.b*ba}}}}function b(W,P,da,X,R,T){E=e(A++);E.setAttribute("d", +"M "+W.positionScreen.x+" "+W.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+"z");if(R instanceof THREE.MeshBasicMaterial)n.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshLambertMaterial)if(J){j.r=m.r;j.g=m.g;j.b=m.b;a(T,X,j);n.r=R.color.r*j.r;n.g=R.color.g*j.g;n.b=R.color.b*j.b;n.updateStyleString()}else n.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshDepthMaterial){p=1-R.__2near/(R.__farPlusNear- +X.z*R.__farMinusNear);n.setRGB(p,p,p)}else R instanceof THREE.MeshNormalMaterial&&n.setRGB(g(X.normalWorld.x),g(X.normalWorld.y),g(X.normalWorld.z));R.wireframe?E.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+R.wireframe_linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.wireframe_linecap+"; stroke-linejoin: "+R.wireframe_linejoin):E.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+R.opacity);c.appendChild(E)}function d(W,P,da,X,R,T,ba){E= +e(A++);E.setAttribute("d","M "+W.positionScreen.x+" "+W.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(T instanceof THREE.MeshBasicMaterial)n.__styleString=T.color.__styleString;else if(T instanceof THREE.MeshLambertMaterial)if(J){j.r=m.r;j.g=m.g;j.b=m.b;a(ba,R,j);n.r=T.color.r*j.r;n.g=T.color.g*j.g;n.b=T.color.b*j.b;n.updateStyleString()}else n.__styleString=T.color.__styleString; +else if(T instanceof THREE.MeshDepthMaterial){p=1-T.__2near/(T.__farPlusNear-R.z*T.__farMinusNear);n.setRGB(p,p,p)}else T instanceof THREE.MeshNormalMaterial&&n.setRGB(g(R.normalWorld.x),g(R.normalWorld.y),g(R.normalWorld.z));T.wireframe?E.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+T.wireframe_linewidth+"; stroke-opacity: "+T.opacity+"; stroke-linecap: "+T.wireframe_linecap+"; stroke-linejoin: "+T.wireframe_linejoin):E.setAttribute("style","fill: "+n.__styleString+ +"; fill-opacity: "+T.opacity);c.appendChild(E)}function e(W){if(y[W]==null){y[W]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&y[W].setAttribute("shape-rendering","crispEdges");return y[W]}return y[W]}function g(W){return W<0?Math.min((1+W)*0.5,0.5):0.5+Math.min(W*0.5,0.5)}var f=null,h=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,l,q,C,o,v,x,t,H=new THREE.Rectangle,w=new THREE.Rectangle,J=false,n=new THREE.Color(16777215),j=new THREE.Color(16777215), +m=new THREE.Color(0),B=new THREE.Color(0),u=new THREE.Color(0),p,M=new THREE.Vector3,y=[],D=[],F=[],E,A,O,K,U=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(W){switch(W){case "high":U=1;break;case "low":U=0}};this.setSize=function(W,P){k=W;l=P;q=k/2;C=l/2;c.setAttribute("viewBox",-q+" "+-C+" "+k+" "+l);c.setAttribute("width",k);c.setAttribute("height",l);H.set(-q,-C,q,C)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])}; +this.render=function(W,P){var da,X,R,T,ba,Y,G,S;this.autoClear&&this.clear();f=h.projectScene(W,P,this.sortElements);K=O=A=0;if(J=W.lights.length>0){G=W.lights;m.setRGB(0,0,0);B.setRGB(0,0,0);u.setRGB(0,0,0);da=0;for(X=G.length;da0){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,ia,B)}if(A){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, -j.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,L,B);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,j.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,I,B)}};this.setLineBuffers=function(j,m,B,o){var A,M,y=j.vertices,D=y.length,F=j.__vertexArray,E=j.__lineArray;if(B)for(B=0;B0){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,ia,B)}if(p){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +j.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,L,B);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,j.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,I,B)}};this.setLineBuffers=function(j,m,B,u){var p,M,y=j.vertices,D=y.length,F=j.__vertexArray,E=j.__lineArray;if(B)for(B=0;B0?"#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(O,h("fragment",K+D));c.attachShader(O,h("vertex",E+z));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={};o.program=O;D=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(y in o.uniforms)D.push(y);y=o.program;z=0;for(O=D.length;z=0){c.bindBuffer(c.ARRAY_BUFFER,A.__webGLNormalBuffer);c.vertexAttribPointer(F.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(F.normal)}if(F.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,A.__webGLTangentBuffer); -c.vertexAttribPointer(F.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(F.tangent)}if(F.uv>=0)if(A.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,A.__webGLUVBuffer);c.vertexAttribPointer(F.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(F.uv)}else c.disableVertexAttribArray(F.uv);if(o.wireframe||o instanceof THREE.LineBasicMaterial){F=o.wireframe_linewidth!==undefined?o.wireframe_linewidth:o.linewidth!==undefined?o.linewidth:1;o=o instanceof THREE.LineBasicMaterial&&M.type==THREE.LineStrip? -c.LINE_STRIP:c.LINES;c.lineWidth(F);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.__webGLLineBuffer);c.drawElements(o,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(j,m,B,o,A,M,y){var D,F,E,z,O;E=0;for(z=o.materials.length;E=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(F.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(F.normal)}if(F.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer); +c.vertexAttribPointer(F.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(F.tangent)}if(F.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.vertexAttribPointer(F.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(F.uv)}else c.disableVertexAttribArray(F.uv);if(u.wireframe||u instanceof THREE.LineBasicMaterial){F=u.wireframe_linewidth!==undefined?u.wireframe_linewidth:u.linewidth!==undefined?u.linewidth:1;u=u instanceof THREE.LineBasicMaterial&&M.type==THREE.LineStrip? +c.LINE_STRIP:c.LINES;c.lineWidth(F);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(u,p.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,p.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(j,m,B,u,p,M,y){var D,F,E,A,O;E=0;for(A=u.materials.length;E=0;B--){o=j.__webGLObjects[B].object;m==o&&j.__webGLObjects.splice(B,1)}};this.setupMatrices=function(j,m){j.autoUpdateMatrix&& -j.updateMatrix();q.multiply(m.matrix,j.matrix);u.set(q.flatten());C=THREE.Matrix4.makeInvert3x3(q).transpose();t.set(C.m);H.set(j.matrix.flatten())};this.loadMatrices=function(j){c.uniformMatrix4fv(j.uniforms.viewMatrix,false,p);c.uniformMatrix4fv(j.uniforms.modelViewMatrix,false,u);c.uniformMatrix4fv(j.uniforms.projectionMatrix,false,w);c.uniformMatrix3fv(j.uniforms.normalMatrix,false,t);c.uniformMatrix4fv(j.uniforms.objectMatrix,false,H)};this.loadCamera=function(j,m){c.uniform3f(j.uniforms.cameraPosition, +function(j){function m(E,A,O,K){if(E[A]==undefined){j.__webGLObjects.push({buffer:O,object:K});E[A]=1}}var B,u,p,M,y,D,F;if(!j.__webGLObjects){j.__webGLObjects=[];j.__webGLObjectsMap={}}B=0;for(u=j.objects.length;B=0;B--){u=j.__webGLObjects[B].object;m==u&&j.__webGLObjects.splice(B,1)}};this.setupMatrices=function(j,m){j.autoUpdateMatrix&& +j.updateMatrix();q.multiply(m.matrix,j.matrix);v.set(q.flatten());C=THREE.Matrix4.makeInvert3x3(q).transpose();t.set(C.m);H.set(j.matrix.flatten())};this.loadMatrices=function(j){c.uniformMatrix4fv(j.uniforms.viewMatrix,false,o);c.uniformMatrix4fv(j.uniforms.modelViewMatrix,false,v);c.uniformMatrix4fv(j.uniforms.projectionMatrix,false,x);c.uniformMatrix3fv(j.uniforms.normalMatrix,false,t);c.uniformMatrix4fv(j.uniforms.objectMatrix,false,H)};this.loadCamera=function(j,m){c.uniform3f(j.uniforms.cameraPosition, m.position.x,m.position.y,m.position.z)};this.setBlending=function(j){switch(j){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(j,m){if(j){!m||m=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(j=="back")c.cullFace(c.BACK);else j=="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", @@ -201,62 +201,63 @@ 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,h=d?b.geometry:b,f=a.vertices,g=h.vertices,c=a.faces,k=h.faces,l=a.uvs;h=h.uvs;d&&b.autoUpdateMatrix&&b.updateMatrix();for(var q=0,C=g.length;q= 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,h,f,g,c){function k(t,H,v,J,n,j,m,B){var o,A,M=e||1,y=h||1,D=M+1,F=y+1,E=n/2,z=j/2;n=n/M;var O=j/y,K=l.vertices.length;if(t=="x"&&H=="y"||t=="y"&&H=="x")o="z";else if(t=="x"&&H=="z"||t=="z"&&H=="x")o="y";else if(t=="z"&&H=="y"||t=="y"&&H=="z")o="x";for(A=0;A0||(q=this.vertices.push(new THREE.Vertex(new THREE.Vector3(C,c,p)))-1);l.push(q)}b.push(l)}var u,w,t;h=b.length;for(d=0;d0)for(e=0;e1){u=this.vertices[g].position.clone(); -w=this.vertices[k].position.clone();t=this.vertices[l].position.clone();u.normalize();w.normalize();t.normalize();this.faces.push(new THREE.Face3(g,k,l,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(t.x,t.y,t.z)]));this.uvs.push([q,C,H])}}}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 h=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(h))*Math.cos(e),(this.radius+this.tube*Math.cos(h))*Math.sin(e),this.tube*Math.sin(h))));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;h=(this.segmentsT+1)*b+d-1;var f=(this.segmentsT+1)*(b-1)+d-1,g=(this.segmentsT+1)*(b-1)+d;this.faces.push(new THREE.Face4(e,h,f,g));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[h][0],a[h][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][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(C,p,u){var w=Math.sqrt(C*C+p*p+u*u);return h.vertices.push(new THREE.Vertex(new THREE.Vector3(C/w,p/w,u/w)))-1}function d(C,p,u,w){w.faces.push(new THREE.Face3(C,p,u))}function e(C,p){var u=h.vertices[C].position,w=h.vertices[p].position;return b((u.x+w.x)/2,(u.y+w.y)/2,(u.z+w.z)/2)}var h=this,f=new THREE.Geometry,g;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;a0||(q=this.vertices.push(new THREE.Vertex(new THREE.Vector3(C,c,o)))-1);l.push(q)}b.push(l)}var v,x,t;g=b.length;for(d=0;d0)for(e=0;e1){v=this.vertices[h].position.clone(); +x=this.vertices[k].position.clone();t=this.vertices[l].position.clone();v.normalize();x.normalize();t.normalize();this.faces.push(new THREE.Face3(h,k,l,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(t.x,t.y,t.z)]));this.uvs.push([q,C,H])}}}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,h=(this.segmentsT+1)*(b-1)+d;this.faces.push(new THREE.Face4(e,g,f,h));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[h][0],a[h][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(C,o,v){var x=Math.sqrt(C*C+o*o+v*v);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(C/x,o/x,v/x)))-1}function d(C,o,v,x){x.faces.push(new THREE.Face3(C,o,v))}function e(C,o){var v=g.vertices[C].position,x=g.vertices[o].position;return b((v.x+x.x)/2,(v.y+x.y)/2,(v.z+x.z)/2)}var g=this,f=new THREE.Geometry,h;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;I=(ca&127)<<16|Z<<8|I;if(I==0&&ja==-127)return 0;return(1-2*(ga>>7))*(1+I*Math.pow(2,-23))*Math.pow(2,ja)}function c(x,L){var I=q(x,L),Z=q(x,L+1),ca=q(x,L+2);return(q(x,L+3)<<24)+(ca<<16)+(Z<<8)+I}function k(x,L){var I=q(x,L);return(q(x,L+1)<<8)+I}function l(x,L){var I=q(x,L);return I>127?I-256:I}function q(x,L){return x.charCodeAt(L)&255}function C(x){var L, -I,Z;L=c(a,x);I=c(a,x+B);Z=c(a,x+o);x=k(a,x+A);THREE.Loader.prototype.f3(v,L,I,Z,x)}function p(x){var L,I,Z,ca,ga,ja;L=c(a,x);I=c(a,x+B);Z=c(a,x+o);ca=k(a,x+A);ga=c(a,x+M);ja=c(a,x+y);x=c(a,x+D);THREE.Loader.prototype.f3n(v,j,L,I,Z,ca,ga,ja,x)}function u(x){var L,I,Z,ca;L=c(a,x);I=c(a,x+F);Z=c(a,x+E);ca=c(a,x+z);x=k(a,x+O);THREE.Loader.prototype.f4(v,L,I,Z,ca,x)}function w(x){var L,I,Z,ca,ga,ja,qa,sa;L=c(a,x);I=c(a,x+F);Z=c(a,x+E);ca=c(a,x+z);ga=k(a,x+O);ja=c(a,x+K);qa=c(a,x+U);sa=c(a,x+W);x=c(a,x+ -P);THREE.Loader.prototype.f4n(v,j,L,I,Z,ca,ga,ja,qa,sa,x)}function t(x){var L,I;L=c(a,x);I=c(a,x+da);x=c(a,x+X);THREE.Loader.prototype.uv3(v,m[L*2],m[L*2+1],m[I*2],m[I*2+1],m[x*2],m[x*2+1])}function H(x){var L,I,Z;L=c(a,x);I=c(a,x+R);Z=c(a,x+T);x=c(a,x+ba);THREE.Loader.prototype.uv4(v,m[L*2],m[L*2+1],m[I*2],m[I*2+1],m[Z*2],m[Z*2+1],m[x*2],m[x*2+1])}var v=this,J=0,n,j=[],m=[],B,o,A,M,y,D,F,E,z,O,K,U,W,P,da,X,R,T,ba,Y,G,S,V,ia,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,e,f); +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(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,d,g,e,f)};b.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,d,e,g,f){var h=new XMLHttpRequest,c=e+"/"+a,k=0; +h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,d,g,b):alert("Couldn't load ["+c+"] ["+h.status+"]");else if(h.readyState==3){if(f){if(k==0)k=h.getResponseHeader("Content-Length");f({total:k,loaded:h.responseText.length})}}else if(h.readyState==2)k=h.getResponseHeader("Content-Length")};h.open("GET",c,true);h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)}, +createBinModel:function(a,b,d,e){var g=function(f){function h(z,L){var I=q(z,L),Z=q(z,L+1),ca=q(z,L+2),ga=q(z,L+3),ja=(ga<<1&255|ca>>7)-127;I=(ca&127)<<16|Z<<8|I;if(I==0&&ja==-127)return 0;return(1-2*(ga>>7))*(1+I*Math.pow(2,-23))*Math.pow(2,ja)}function c(z,L){var I=q(z,L),Z=q(z,L+1),ca=q(z,L+2);return(q(z,L+3)<<24)+(ca<<16)+(Z<<8)+I}function k(z,L){var I=q(z,L);return(q(z,L+1)<<8)+I}function l(z,L){var I=q(z,L);return I>127?I-256:I}function q(z,L){return z.charCodeAt(L)&255}function C(z){var L, +I,Z;L=c(a,z);I=c(a,z+B);Z=c(a,z+u);z=k(a,z+p);THREE.Loader.prototype.f3(w,L,I,Z,z)}function o(z){var L,I,Z,ca,ga,ja;L=c(a,z);I=c(a,z+B);Z=c(a,z+u);ca=k(a,z+p);ga=c(a,z+M);ja=c(a,z+y);z=c(a,z+D);THREE.Loader.prototype.f3n(w,j,L,I,Z,ca,ga,ja,z)}function v(z){var L,I,Z,ca;L=c(a,z);I=c(a,z+F);Z=c(a,z+E);ca=c(a,z+A);z=k(a,z+O);THREE.Loader.prototype.f4(w,L,I,Z,ca,z)}function x(z){var L,I,Z,ca,ga,ja,qa,sa;L=c(a,z);I=c(a,z+F);Z=c(a,z+E);ca=c(a,z+A);ga=k(a,z+O);ja=c(a,z+K);qa=c(a,z+U);sa=c(a,z+W);z=c(a,z+ +P);THREE.Loader.prototype.f4n(w,j,L,I,Z,ca,ga,ja,qa,sa,z)}function t(z){var L,I;L=c(a,z);I=c(a,z+da);z=c(a,z+X);THREE.Loader.prototype.uv3(w,m[L*2],m[L*2+1],m[I*2],m[I*2+1],m[z*2],m[z*2+1])}function H(z){var L,I,Z;L=c(a,z);I=c(a,z+R);Z=c(a,z+T);z=c(a,z+ba);THREE.Loader.prototype.uv4(w,m[L*2],m[L*2+1],m[I*2],m[I*2+1],m[Z*2],m[Z*2+1],m[z*2],m[z*2+1])}var w=this,J=0,n,j=[],m=[],B,u,p,M,y,D,F,E,A,O,K,U,W,P,da,X,R,T,ba,Y,G,S,V,ia,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,e,f); n={signature:a.substr(J,8),header_bytes:q(a,J+8),vertex_coordinate_bytes:q(a,J+9),normal_coordinate_bytes:q(a,J+10),uv_coordinate_bytes:q(a,J+11),vertex_index_bytes:q(a,J+12),normal_index_bytes:q(a,J+13),uv_index_bytes:q(a,J+14),material_index_bytes:q(a,J+15),nvertices:c(a,J+16),nnormals:c(a,J+16+4),nuvs:c(a,J+16+8),ntri_flat:c(a,J+16+12),ntri_smooth:c(a,J+16+16),ntri_flat_uv:c(a,J+16+20),ntri_smooth_uv:c(a,J+16+24),nquad_flat:c(a,J+16+28),nquad_smooth:c(a,J+16+32),nquad_flat_uv:c(a,J+16+36),nquad_smooth_uv:c(a, -J+16+40)};J+=n.header_bytes;B=n.vertex_index_bytes;o=n.vertex_index_bytes*2;A=n.vertex_index_bytes*3;M=n.vertex_index_bytes*3+n.material_index_bytes;y=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;D=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;F=n.vertex_index_bytes;E=n.vertex_index_bytes*2;z=n.vertex_index_bytes*3;O=n.vertex_index_bytes*4;K=n.vertex_index_bytes*4+n.material_index_bytes;U=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes; +J+16+40)};J+=n.header_bytes;B=n.vertex_index_bytes;u=n.vertex_index_bytes*2;p=n.vertex_index_bytes*3;M=n.vertex_index_bytes*3+n.material_index_bytes;y=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;D=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;F=n.vertex_index_bytes;E=n.vertex_index_bytes*2;A=n.vertex_index_bytes*3;O=n.vertex_index_bytes*4;K=n.vertex_index_bytes*4+n.material_index_bytes;U=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes; W=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;P=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;da=n.uv_index_bytes;X=n.uv_index_bytes*2;R=n.uv_index_bytes;T=n.uv_index_bytes*2;ba=n.uv_index_bytes*3;f=n.vertex_index_bytes*3+n.material_index_bytes;ha=n.vertex_index_bytes*4+n.material_index_bytes;Y=n.ntri_flat*f;G=n.ntri_smooth*(f+n.normal_index_bytes*3);S=n.ntri_flat_uv*(f+n.uv_index_bytes*3);V=n.ntri_smooth_uv*(f+n.normal_index_bytes*3+n.uv_index_bytes* -3);ia=n.nquad_flat*ha;f=n.nquad_smooth*(ha+n.normal_index_bytes*4);ha=n.nquad_flat_uv*(ha+n.uv_index_bytes*4);J+=function(x){var L,I,Z,ca=n.vertex_coordinate_bytes*3,ga=x+n.nvertices*ca;for(x=x;x