|
@@ -14,28 +14,30 @@ THREE.Vector4.prototype={set:function(a,c,d,e){this.x=a;this.y=c;this.z=d;this.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,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},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,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
|
|
|
THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,j=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)j=j.concat(this.intersectObject(d))}j.sort(function(g,b){return g.distance-b.distance});return j},intersectObject:function(a){function c(H,f,p,h){h=h.clone().subSelf(f);p=p.clone().subSelf(f);var l=H.clone().subSelf(f);H=h.dot(h);f=h.dot(p);h=h.dot(l);var t=p.dot(p);p=p.dot(l);l=1/(H*t-f*f);t=(t*h-f*p)*l;H=(H*p-f*h)*l;return t>0&&H>0&&t+H<1}var d,e,j,g,b,m,k,n,o,y,
|
|
|
-u,q=a.geometry,z=q.vertices,B=[];d=0;for(e=q.faces.length;d<e;d++){j=q.faces[d];y=this.origin.clone();u=this.direction.clone();g=a.matrix.multiplyVector3(z[j.a].position.clone());b=a.matrix.multiplyVector3(z[j.b].position.clone());m=a.matrix.multiplyVector3(z[j.c].position.clone());k=j instanceof THREE.Face4?a.matrix.multiplyVector3(z[j.d].position.clone()):null;n=a.rotationMatrix.multiplyVector3(j.normal.clone());o=u.dot(n);if(o<0){n=n.dot((new THREE.Vector3).sub(g,y))/o;y=y.addSelf(u.multiplyScalar(n));
|
|
|
+v,q=a.geometry,z=q.vertices,B=[];d=0;for(e=q.faces.length;d<e;d++){j=q.faces[d];y=this.origin.clone();v=this.direction.clone();g=a.matrix.multiplyVector3(z[j.a].position.clone());b=a.matrix.multiplyVector3(z[j.b].position.clone());m=a.matrix.multiplyVector3(z[j.c].position.clone());k=j instanceof THREE.Face4?a.matrix.multiplyVector3(z[j.d].position.clone()):null;n=a.rotationMatrix.multiplyVector3(j.normal.clone());o=v.dot(n);if(o<0){n=n.dot((new THREE.Vector3).sub(g,y))/o;y=y.addSelf(v.multiplyScalar(n));
|
|
|
if(j instanceof THREE.Face3){if(c(y,g,b,m)){j={distance:this.origin.distanceTo(y),point:y,face:j,object:a};B.push(j)}}else if(j instanceof THREE.Face4)if(c(y,g,b,k)||c(y,b,m,k)){j={distance:this.origin.distanceTo(y),point:y,face:j,object:a};B.push(j)}}}return B}};
|
|
|
THREE.Rectangle=function(){function a(){g=e-c;b=j-d}var c,d,e,j,g,b,m=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return g};this.getHeight=function(){return b};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return j};this.set=function(k,n,o,y){m=false;c=k;d=n;e=o;j=y;a()};this.addPoint=function(k,n){if(m){m=false;c=k;d=n;e=k;j=n}else{c=c<k?c:k;d=d<n?d:n;e=e>k?e:k;j=j>n?
|
|
|
-j:n}a()};this.add3Points=function(k,n,o,y,u,q){if(m){m=false;c=k<o?k<u?k:u:o<u?o:u;d=n<y?n<q?n:q:y<q?y:q;e=k>o?k>u?k:u:o>u?o:u;j=n>y?n>q?n:q:y>q?y:q}else{c=k<o?k<u?k<c?k:c:u<c?u:c:o<u?o<c?o:c:u<c?u:c;d=n<y?n<q?n<d?n:d:q<d?q:d:y<q?y<d?y:d:q<d?q:d;e=k>o?k>u?k>e?k:e:u>e?u:e:o>u?o>e?o:e:u>e?u:e;j=n>y?n>q?n>j?n:j:q>j?q:j:y>q?y>j?y:j:q>j?q:j}a()};this.addRectangle=function(k){if(m){m=false;c=k.getLeft();d=k.getTop();e=k.getRight();j=k.getBottom()}else{c=c<k.getLeft()?c:k.getLeft();d=d<k.getTop()?d:k.getTop();
|
|
|
+j:n}a()};this.add3Points=function(k,n,o,y,v,q){if(m){m=false;c=k<o?k<v?k:v:o<v?o:v;d=n<y?n<q?n:q:y<q?y:q;e=k>o?k>v?k:v:o>v?o:v;j=n>y?n>q?n:q:y>q?y:q}else{c=k<o?k<v?k<c?k:c:v<c?v:c:o<v?o<c?o:c:v<c?v:c;d=n<y?n<q?n<d?n:d:q<d?q:d:y<q?y<d?y:d:q<d?q:d;e=k>o?k>v?k>e?k:e:v>e?v:e:o>v?o>e?o:e:v>e?v:e;j=n>y?n>q?n>j?n:j:q>j?q:j:y>q?y>j?y:j:q>j?q:j}a()};this.addRectangle=function(k){if(m){m=false;c=k.getLeft();d=k.getTop();e=k.getRight();j=k.getBottom()}else{c=c<k.getLeft()?c:k.getLeft();d=d<k.getTop()?d:k.getTop();
|
|
|
e=e>k.getRight()?e:k.getRight();j=j>k.getBottom()?j:k.getBottom()}a()};this.inflate=function(k){c-=k;d-=k;e+=k;j+=k;a()};this.minSelf=function(k){c=c>k.getLeft()?c:k.getLeft();d=d>k.getTop()?d:k.getTop();e=e<k.getRight()?e:k.getRight();j=j<k.getBottom()?j:k.getBottom();a()};this.instersects=function(k){return Math.min(e,k.getRight())-Math.max(c,k.getLeft())>=0&&Math.min(j,k.getBottom())-Math.max(d,k.getTop())>=0};this.empty=function(){m=true;j=e=d=c=0;a()};this.isEmpty=function(){return m};this.toString=
|
|
|
-function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+j+", width: "+g+", height: "+b+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this}};
|
|
|
-THREE.Matrix4=function(a,c,d,e,j,g,b,m,k,n,o,y,u,q,z,B){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=j||0;this.n22=g||1;this.n23=b||0;this.n24=m||0;this.n31=k||0;this.n32=n||0;this.n33=o||1;this.n34=y||0;this.n41=u||0;this.n42=q||0;this.n43=z||0;this.n44=B||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,c,d,e,j,g,b,m,k,n,o,y,u,q,z,B){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=j;this.n22=g;this.n23=b;this.n24=m;this.n31=k;this.n32=n;this.n33=o;this.n34=y;this.n41=u;this.n42=q;this.n43=z;this.n44=B;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
|
|
|
+function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+j+", width: "+g+", height: "+b+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
|
|
|
+THREE.Matrix4=function(a,c,d,e,j,g,b,m,k,n,o,y,v,q,z,B){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=j||0;this.n22=g||1;this.n23=b||0;this.n24=m||0;this.n31=k||0;this.n32=n||0;this.n33=o||1;this.n34=y||0;this.n41=v||0;this.n42=q||0;this.n43=z||0;this.n44=B||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,c,d,e,j,g,b,m,k,n,o,y,v,q,z,B){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=j;this.n22=g;this.n23=b;this.n24=m;this.n31=k;this.n32=n;this.n33=o;this.n34=y;this.n41=v;this.n42=q;this.n43=z;this.n44=B;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,c,d){var e=THREE.Matrix4.__tmpVec1,j=THREE.Matrix4.__tmpVec2,g=THREE.Matrix4.__tmpVec3;g.sub(a,c).normalize();e.cross(d,g).normalize();j.cross(g,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);
|
|
|
this.n31=g.x;this.n32=g.y;this.n33=g.z;this.n34=-g.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,e=a.z,j=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*j;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*j;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*j;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,j=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*j;a.y=this.n21*c+this.n22*d+this.n23*
|
|
|
e+this.n24*j;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*j;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*j;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,e=a.n12,j=a.n13,g=a.n14,b=a.n21,m=a.n22,k=a.n23,n=a.n24,o=a.n31,
|
|
|
-y=a.n32,u=a.n33,q=a.n34,z=a.n41,B=a.n42,H=a.n43,f=a.n44,p=c.n11,h=c.n12,l=c.n13,t=c.n14,w=c.n21,x=c.n22,v=c.n23,A=c.n24,C=c.n31,E=c.n32,F=c.n33,D=c.n34,I=c.n41,T=c.n42,P=c.n43,X=c.n44;this.n11=d*p+e*w+j*C+g*I;this.n12=d*h+e*x+j*E+g*T;this.n13=d*l+e*v+j*F+g*P;this.n14=d*t+e*A+j*D+g*X;this.n21=b*p+m*w+k*C+n*I;this.n22=b*h+m*x+k*E+n*T;this.n23=b*l+m*v+k*F+n*P;this.n24=b*t+m*A+k*D+n*X;this.n31=o*p+y*w+u*C+q*I;this.n32=o*h+y*x+u*E+q*T;this.n33=o*l+y*v+u*F+q*P;this.n34=o*t+y*A+u*D+q*X;this.n41=z*p+B*w+
|
|
|
-H*C+f*I;this.n42=z*h+B*x+H*E+f*T;this.n43=z*l+B*v+H*F+f*P;this.n44=z*t+B*A+H*D+f*X;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,j=this.n14,g=this.n21,b=this.n22,m=this.n23,k=this.n24,n=this.n31,o=this.n32,y=this.n33,u=this.n34,q=this.n41,z=this.n42,B=this.n43,H=this.n44,f=a.n11,p=a.n21,h=a.n31,l=a.n41,t=a.n12,w=a.n22,x=a.n32,v=a.n42,A=a.n13,C=a.n23,E=a.n33,F=a.n43,D=a.n14,I=a.n24,T=a.n34;a=a.n44;this.n11=c*f+d*p+e*h+j*l;this.n12=c*t+d*w+e*x+j*v;this.n13=c*A+d*C+e*E+j*
|
|
|
-F;this.n14=c*D+d*I+e*T+j*a;this.n21=g*f+b*p+m*h+k*l;this.n22=g*t+b*w+m*x+k*v;this.n23=g*A+b*C+m*E+k*F;this.n24=g*D+b*I+m*T+k*a;this.n31=n*f+o*p+y*h+u*l;this.n32=n*t+o*w+y*x+u*v;this.n33=n*A+o*C+y*E+u*F;this.n34=n*D+o*I+y*T+u*a;this.n41=q*f+z*p+B*h+H*l;this.n42=q*t+z*w+B*x+H*v;this.n43=q*A+z*C+B*E+H*F;this.n44=q*D+z*I+B*T+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,c=this.n12,d=this.n13,e=this.n14,j=this.n21,g=this.n22,b=this.n23,m=this.n24,k=this.n31,n=this.n32,o=this.n33,y=this.n34,u=this.n41,q=this.n42,z=this.n43,B=this.n44;return e*b*n*u-d*m*n*u-e*g*o*u+c*m*o*u+d*g*y*u-c*b*y*u-e*b*k*q+d*m*k*q+e*j*o*q-a*m*o*q-d*j*y*q+a*b*y*q+e*g*k*z-c*m*k*z-e*j*n*z+a*m*n*z+c*j*y*z-a*g*y*z-d*g*k*B+c*b*k*B+d*j*n*B-a*b*n*B-c*j*o*B+a*g*o*B},transpose:function(){function a(c,d,
|
|
|
-e){var j=c[d];c[d]=c[e];c[e]=j}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){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,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=
|
|
|
-Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),j=1-d,g=a.x,b=a.y,m=a.z,k=j*g,n=j*b;this.set(k*g+d,k*b-e*m,k*m+e*b,0,k*b+e*m,n*b+d,n*m-e*g,0,k*m-e*b,n*m+e*g,j*m*m+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,c,d){var e=new THREE.Matrix4;e.setTranslation(a,c,d);return e};THREE.Matrix4.scaleMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setScale(a,c,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};
|
|
|
-THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
|
|
|
-THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,j=a.n14,g=a.n21,b=a.n22,m=a.n23,k=a.n24,n=a.n31,o=a.n32,y=a.n33,u=a.n34,q=a.n41,z=a.n42,B=a.n43,H=a.n44,f=new THREE.Matrix4;f.n11=m*u*z-k*y*z+k*o*B-b*u*B-m*o*H+b*y*H;f.n12=j*y*z-e*u*z-j*o*B+d*u*B+e*o*H-d*y*H;f.n13=e*k*z-j*m*z+j*b*B-d*k*B-e*b*H+d*m*H;f.n14=j*m*o-e*k*o-j*b*y+d*k*y+e*b*u-d*m*u;f.n21=k*y*q-m*u*q-k*n*B+g*u*B+m*n*H-g*y*H;f.n22=e*u*q-j*y*q+j*n*B-c*u*B-e*n*H+c*y*H;f.n23=j*m*q-e*k*q-j*g*B+c*k*B+e*g*H-c*m*H;f.n24=e*k*n-j*m*n+
|
|
|
-j*g*y-c*k*y-e*g*u+c*m*u;f.n31=b*u*q-k*o*q+k*n*z-g*u*z-b*n*H+g*o*H;f.n32=j*o*q-d*u*q-j*n*z+c*u*z+d*n*H-c*o*H;f.n33=e*k*q-j*b*q+j*g*z-c*k*z-d*g*H+c*b*H;f.n34=j*b*n-d*k*n-j*g*o+c*k*o+d*g*u-c*b*u;f.n41=m*o*q-b*y*q-m*n*z+g*y*z+b*n*B-g*o*B;f.n42=d*y*q-e*o*q+e*n*z-c*y*z-d*n*B+c*o*B;f.n43=e*b*q-d*m*q-e*g*z+c*m*z+d*g*B-c*b*B;f.n44=d*m*n-e*b*n+e*g*o-c*m*o-d*g*y+c*b*y;f.multiplyScalar(1/a.determinant());return f};
|
|
|
+y=a.n32,v=a.n33,q=a.n34,z=a.n41,B=a.n42,H=a.n43,f=a.n44,p=c.n11,h=c.n12,l=c.n13,t=c.n14,w=c.n21,x=c.n22,u=c.n23,A=c.n24,C=c.n31,E=c.n32,F=c.n33,D=c.n34,I=c.n41,S=c.n42,N=c.n43,X=c.n44;this.n11=d*p+e*w+j*C+g*I;this.n12=d*h+e*x+j*E+g*S;this.n13=d*l+e*u+j*F+g*N;this.n14=d*t+e*A+j*D+g*X;this.n21=b*p+m*w+k*C+n*I;this.n22=b*h+m*x+k*E+n*S;this.n23=b*l+m*u+k*F+n*N;this.n24=b*t+m*A+k*D+n*X;this.n31=o*p+y*w+v*C+q*I;this.n32=o*h+y*x+v*E+q*S;this.n33=o*l+y*u+v*F+q*N;this.n34=o*t+y*A+v*D+q*X;this.n41=z*p+B*w+
|
|
|
+H*C+f*I;this.n42=z*h+B*x+H*E+f*S;this.n43=z*l+B*u+H*F+f*N;this.n44=z*t+B*A+H*D+f*X;return this},multiplyToArray:function(a,c,d){var e=a.n11,j=a.n12,g=a.n13,b=a.n14,m=a.n21,k=a.n22,n=a.n23,o=a.n24,y=a.n31,v=a.n32,q=a.n33,z=a.n34,B=a.n41,H=a.n42,f=a.n43;a=a.n44;var p=c.n11,h=c.n12,l=c.n13,t=c.n14,w=c.n21,x=c.n22,u=c.n23,A=c.n24,C=c.n31,E=c.n32,F=c.n33,D=c.n34,I=c.n41,S=c.n42,N=c.n43;c=c.n44;this.n11=e*p+j*w+g*C+b*I;this.n12=e*h+j*x+g*E+b*S;this.n13=e*l+j*u+g*F+b*N;this.n14=e*t+j*A+g*D+b*c;this.n21=
|
|
|
+m*p+k*w+n*C+o*I;this.n22=m*h+k*x+n*E+o*S;this.n23=m*l+k*u+n*F+o*N;this.n24=m*t+k*A+n*D+o*c;this.n31=y*p+v*w+q*C+z*I;this.n32=y*h+v*x+q*E+z*S;this.n33=y*l+v*u+q*F+z*N;this.n34=y*t+v*A+q*D+z*c;this.n41=B*p+H*w+f*C+a*I;this.n42=B*h+H*x+f*E+a*S;this.n43=B*l+H*u+f*F+a*N;this.n44=B*t+H*A+f*D+a*c;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;
|
|
|
+d[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,j=this.n14,g=this.n21,b=this.n22,m=this.n23,k=this.n24,n=this.n31,o=this.n32,y=this.n33,v=this.n34,q=this.n41,z=this.n42,B=this.n43,H=this.n44,f=a.n11,p=a.n21,h=a.n31,l=a.n41,t=a.n12,w=a.n22,x=a.n32,u=a.n42,A=a.n13,C=a.n23,E=a.n33,F=a.n43,D=a.n14,I=a.n24,S=a.n34;a=a.n44;this.n11=c*f+d*p+e*h+j*l;this.n12=c*t+d*w+e*x+j*u;this.n13=c*A+d*C+e*E+j*F;this.n14=c*D+d*I+e*S+j*a;this.n21=g*f+b*p+m*h+k*l;this.n22=g*t+b*
|
|
|
+w+m*x+k*u;this.n23=g*A+b*C+m*E+k*F;this.n24=g*D+b*I+m*S+k*a;this.n31=n*f+o*p+y*h+v*l;this.n32=n*t+o*w+y*x+v*u;this.n33=n*A+o*C+y*E+v*F;this.n34=n*D+o*I+y*S+v*a;this.n41=q*f+z*p+B*h+H*l;this.n42=q*t+z*w+B*x+H*u;this.n43=q*A+z*C+B*E+H*F;this.n44=q*D+z*I+B*S+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,c=this.n12,d=this.n13,e=this.n14,j=this.n21,g=this.n22,b=this.n23,m=this.n24,k=this.n31,n=this.n32,o=this.n33,y=this.n34,v=this.n41,q=this.n42,z=this.n43,B=this.n44;return e*b*n*v-d*m*n*v-e*g*o*v+c*m*o*v+d*g*y*v-c*b*y*v-e*b*k*q+d*m*k*q+e*j*o*q-a*m*o*q-d*j*y*q+a*b*y*q+e*g*k*z-c*m*k*z-e*j*n*z+a*m*n*z+c*j*y*z-a*g*y*z-d*g*k*B+c*b*k*B+d*j*n*B-a*b*n*B-c*j*o*B+a*g*o*B},transpose:function(){function a(c,d,e){var j=c[d];c[d]=c[e];c[e]=j}a(this,"n21","n12");a(this,"n31",
|
|
|
+"n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){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,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,
|
|
|
+0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),j=1-d,g=a.x,b=a.y,m=a.z,k=j*g,n=j*b;this.set(k*g+d,k*b-e*m,k*m+e*b,0,k*b+e*m,n*b+d,n*m-e*g,0,k*m-e*b,n*m+e*g,j*m*m+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,c,d){var e=new THREE.Matrix4;e.setTranslation(a,c,d);return e};THREE.Matrix4.scaleMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setScale(a,c,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};
|
|
|
+THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
|
|
|
+THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,j=a.n14,g=a.n21,b=a.n22,m=a.n23,k=a.n24,n=a.n31,o=a.n32,y=a.n33,v=a.n34,q=a.n41,z=a.n42,B=a.n43,H=a.n44,f=new THREE.Matrix4;f.n11=m*v*z-k*y*z+k*o*B-b*v*B-m*o*H+b*y*H;f.n12=j*y*z-e*v*z-j*o*B+d*v*B+e*o*H-d*y*H;f.n13=e*k*z-j*m*z+j*b*B-d*k*B-e*b*H+d*m*H;f.n14=j*m*o-e*k*o-j*b*y+d*k*y+e*b*v-d*m*v;f.n21=k*y*q-m*v*q-k*n*B+g*v*B+m*n*H-g*y*H;f.n22=e*v*q-j*y*q+j*n*B-c*v*B-e*n*H+c*y*H;f.n23=j*m*q-e*k*q-j*g*B+c*k*B+e*g*H-c*m*H;f.n24=e*k*n-j*m*n+
|
|
|
+j*g*y-c*k*y-e*g*v+c*m*v;f.n31=b*v*q-k*o*q+k*n*z-g*v*z-b*n*H+g*o*H;f.n32=j*o*q-d*v*q-j*n*z+c*v*z+d*n*H-c*o*H;f.n33=e*k*q-j*b*q+j*g*z-c*k*z-d*g*H+c*b*H;f.n34=j*b*n-d*k*n-j*g*o+c*k*o+d*g*v-c*b*v;f.n41=m*o*q-b*y*q-m*n*z+g*y*z+b*n*B-g*o*B;f.n42=d*y*q-e*o*q+e*n*z-c*y*z-d*n*B+c*o*B;f.n43=e*b*q-d*m*q-e*g*z+c*m*z+d*g*B-c*b*B;f.n44=d*m*n-e*b*n+e*g*o-c*m*o-d*g*y+c*b*y;f.multiplyScalar(1/a.determinant());return f};
|
|
|
THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],j=-c[10]*c[1]+c[2]*c[9],g=c[6]*c[1]-c[2]*c[5],b=-c[10]*c[4]+c[6]*c[8],m=c[10]*c[0]-c[2]*c[8],k=-c[6]*c[0]+c[2]*c[4],n=c[9]*c[4]-c[5]*c[8],o=-c[9]*c[0]+c[1]*c[8],y=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*b+c[2]*n;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*j;d[2]=c*g;d[3]=c*b;d[4]=c*m;d[5]=c*k;d[6]=c*n;d[7]=c*o;d[8]=c*y;return a};
|
|
|
THREE.Matrix4.makeFrustum=function(a,c,d,e,j,g){var b,m,k;b=new THREE.Matrix4;m=2*j/(c-a);k=2*j/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(g+j)/(g-j);j=-2*g*j/(g-j);b.n11=m;b.n12=0;b.n13=a;b.n14=0;b.n21=0;b.n22=k;b.n23=d;b.n24=0;b.n31=0;b.n32=0;b.n33=e;b.n34=j;b.n41=0;b.n42=0;b.n43=-1;b.n44=0;return b};THREE.Matrix4.makePerspective=function(a,c,d,e){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*c,a*c,j,a,d,e)};
|
|
|
THREE.Matrix4.makeOrtho=function(a,c,d,e,j,g){var b,m,k,n;b=new THREE.Matrix4;m=c-a;k=d-e;n=g-j;a=(c+a)/m;d=(d+e)/k;j=(g+j)/n;b.n11=2/m;b.n12=0;b.n13=0;b.n14=-a;b.n21=0;b.n22=2/k;b.n23=0;b.n24=-d;b.n31=0;b.n32=0;b.n33=-2/n;b.n34=-j;b.n41=0;b.n42=0;b.n43=0;b.n44=1;return b};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
|
|
@@ -47,8 +49,8 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.f
|
|
|
d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,e,j,g,b,m=new THREE.Vector3,k=new THREE.Vector3;e=0;for(j=this.vertices.length;e<j;e++){g=this.vertices[e];g.normal.set(0,0,0)}e=0;for(j=this.faces.length;e<j;e++){g=this.faces[e];if(a&&g.vertexNormals.length){m.set(0,0,0);c=0;for(d=g.normal.length;c<d;c++)m.addSelf(g.vertexNormals[c]);m.divideScalar(3)}else{c=this.vertices[g.a];d=this.vertices[g.b];b=this.vertices[g.c];m.sub(b.position,
|
|
|
d.position);k.sub(c.position,d.position);m.crossSelf(k)}m.isZero()||m.normalize();g.normal.copy(m)}},computeVertexNormals:function(){var a,c,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)e[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
|
|
|
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)e[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal);e[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)e[a].normalize();a=0;for(c=this.faces.length;a<
|
|
|
-c;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(D,I,T,P,X,Y,S){g=D.vertices[I].position;b=D.vertices[T].position;m=D.vertices[P].position;k=j[X];n=j[Y];o=j[S];y=b.x-g.x;u=m.x-g.x;q=b.y-g.y;z=m.y-g.y;
|
|
|
-B=b.z-g.z;H=m.z-g.z;f=n.u-k.u;p=o.u-k.u;h=n.v-k.v;l=o.v-k.v;t=1/(f*l-p*h);v.set((l*y-h*u)*t,(l*q-h*z)*t,(l*B-h*H)*t);A.set((f*u-p*y)*t,(f*z-p*q)*t,(f*H-p*B)*t);w[I].addSelf(v);w[T].addSelf(v);w[P].addSelf(v);x[I].addSelf(A);x[T].addSelf(A);x[P].addSelf(A)}var c,d,e,j,g,b,m,k,n,o,y,u,q,z,B,H,f,p,h,l,t,w=[],x=[],v=new THREE.Vector3,A=new THREE.Vector3,C=new THREE.Vector3,E=new THREE.Vector3,F=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){w[c]=new THREE.Vector3;x[c]=new THREE.Vector3}c=0;
|
|
|
+c;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(D,I,S,N,X,Y,T){g=D.vertices[I].position;b=D.vertices[S].position;m=D.vertices[N].position;k=j[X];n=j[Y];o=j[T];y=b.x-g.x;v=m.x-g.x;q=b.y-g.y;z=m.y-g.y;
|
|
|
+B=b.z-g.z;H=m.z-g.z;f=n.u-k.u;p=o.u-k.u;h=n.v-k.v;l=o.v-k.v;t=1/(f*l-p*h);u.set((l*y-h*v)*t,(l*q-h*z)*t,(l*B-h*H)*t);A.set((f*v-p*y)*t,(f*z-p*q)*t,(f*H-p*B)*t);w[I].addSelf(u);w[S].addSelf(u);w[N].addSelf(u);x[I].addSelf(A);x[S].addSelf(A);x[N].addSelf(A)}var c,d,e,j,g,b,m,k,n,o,y,v,q,z,B,H,f,p,h,l,t,w=[],x=[],u=new THREE.Vector3,A=new THREE.Vector3,C=new THREE.Vector3,E=new THREE.Vector3,F=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){w[c]=new THREE.Vector3;x[c]=new THREE.Vector3}c=0;
|
|
|
for(d=this.faces.length;c<d;c++){e=this.faces[c];j=this.uvs[c];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
|
|
|
this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){F.copy(this.vertices[c].normal);e=w[c];C.copy(e);C.subSelf(F.multiplyScalar(F.dot(e))).normalize();E.cross(this.vertices[c].normal,e);e=E.dot(x[c]);e=e<0?-1:1;this.vertices[c].tangent.set(C.x,C.y,C.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){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 c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
|
|
@@ -102,76 +104,76 @@ var Uniforms={clone:function(a){var c,d,e,j={};for(c in a){j[c]={};for(d in a[c]
|
|
|
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
|
|
|
THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
|
|
|
THREE.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
|
|
|
-THREE.Projector=function(){function a(x,v){return v.z-x.z}function c(x,v){var A=0,C=1,E=x.z+x.w,F=v.z+v.w,D=-x.z+x.w,I=-v.z+v.w;if(E>=0&&F>=0&&D>=0&&I>=0)return true;else if(E<0&&F<0||D<0&&I<0)return false;else{if(E<0)A=Math.max(A,E/(E-F));else if(F<0)C=Math.min(C,E/(E-F));if(D<0)A=Math.max(A,D/(D-I));else if(I<0)C=Math.min(C,D/(D-I));if(C<A)return false;else{x.lerpSelf(v,A);v.lerpSelf(x,1-C);return true}}}var d,e,j=[],g,b,m,k=[],n,o,y=[],u,q,z=[],B=new THREE.Vector4,H=new THREE.Vector4,f=new THREE.Matrix4,
|
|
|
-p=new THREE.Matrix4,h=[],l=new THREE.Vector4,t=new THREE.Vector4,w;this.projectObjects=function(x,v,A){var C=[],E,F;e=0;f.multiply(v.projectionMatrix,v.matrix);h[0]=new THREE.Vector4(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);h[1]=new THREE.Vector4(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);h[2]=new THREE.Vector4(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);h[3]=new THREE.Vector4(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);h[4]=new THREE.Vector4(f.n41-f.n31,f.n42-f.n32,f.n43-
|
|
|
-f.n33,f.n44-f.n34);h[5]=new THREE.Vector4(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);v=0;for(E=h.length;v<E;v++){F=h[v];F.divideScalar(Math.sqrt(F.x*F.x+F.y*F.y+F.z*F.z))}E=x.objects;x=0;for(v=E.length;x<v;x++){F=E[x];var D;if(!(D=!F.visible)){if(D=F instanceof THREE.Mesh){a:{D=void 0;for(var I=F.position,T=-F.geometry.boundingSphere.radius*Math.max(F.scale.x,Math.max(F.scale.y,F.scale.z)),P=0;P<6;P++){D=h[P].x*I.x+h[P].y*I.y+h[P].z*I.z+h[P].w;if(D<=T){D=false;break a}}D=true}D=!D}D=D}if(!D){d=
|
|
|
-j[e]=j[e]||new THREE.RenderableObject;B.copy(F.position);f.multiplyVector3(B);d.object=F;d.z=B.z;C.push(d);e++}}A&&C.sort(a);return C};this.projectScene=function(x,v,A){var C=[],E=v.near,F=v.far,D,I,T,P,X,Y,S,V,da,R,N,ba,aa,K,O,U;m=o=q=0;v.autoUpdateMatrix&&v.updateMatrix();f.multiply(v.projectionMatrix,v.matrix);Y=this.projectObjects(x,v,true);x=0;for(D=Y.length;x<D;x++){S=Y[x].object;if(S.visible){S.autoUpdateMatrix&&S.updateMatrix();V=S.matrix;da=S.rotationMatrix;R=S.materials;N=S.overdraw;if(S instanceof
|
|
|
-THREE.Mesh){ba=S.geometry;aa=ba.vertices;I=0;for(T=aa.length;I<T;I++){K=aa[I];K.positionWorld.copy(K.position);V.multiplyVector3(K.positionWorld);P=K.positionScreen;P.copy(K.positionWorld);f.multiplyVector4(P);P.x/=P.w;P.y/=P.w;K.__visible=P.z>E&&P.z<F}ba=ba.faces;I=0;for(T=ba.length;I<T;I++){K=ba[I];if(K instanceof THREE.Face3){P=aa[K.a];X=aa[K.b];O=aa[K.c];if(P.__visible&&X.__visible&&O.__visible)if(S.doubleSided||S.flipSided!=(O.positionScreen.x-P.positionScreen.x)*(X.positionScreen.y-P.positionScreen.y)-
|
|
|
-(O.positionScreen.y-P.positionScreen.y)*(X.positionScreen.x-P.positionScreen.x)<0){g=k[m]=k[m]||new THREE.RenderableFace3;g.v1.positionWorld.copy(P.positionWorld);g.v2.positionWorld.copy(X.positionWorld);g.v3.positionWorld.copy(O.positionWorld);g.v1.positionScreen.copy(P.positionScreen);g.v2.positionScreen.copy(X.positionScreen);g.v3.positionScreen.copy(O.positionScreen);g.normalWorld.copy(K.normal);da.multiplyVector3(g.normalWorld);g.centroidWorld.copy(K.centroid);V.multiplyVector3(g.centroidWorld);
|
|
|
-g.centroidScreen.copy(g.centroidWorld);f.multiplyVector3(g.centroidScreen);O=K.vertexNormals;w=g.vertexNormalsWorld;P=0;for(X=O.length;P<X;P++){U=w[P]=w[P]||new THREE.Vector3;U.copy(O[P]);da.multiplyVector3(U)}g.z=g.centroidScreen.z;g.meshMaterials=R;g.faceMaterials=K.materials;g.overdraw=N;if(S.geometry.uvs[I]){g.uvs[0]=S.geometry.uvs[I][0];g.uvs[1]=S.geometry.uvs[I][1];g.uvs[2]=S.geometry.uvs[I][2]}C.push(g);m++}}else if(K instanceof THREE.Face4){P=aa[K.a];X=aa[K.b];O=aa[K.c];U=aa[K.d];if(P.__visible&&
|
|
|
-X.__visible&&O.__visible&&U.__visible)if(S.doubleSided||S.flipSided!=((U.positionScreen.x-P.positionScreen.x)*(X.positionScreen.y-P.positionScreen.y)-(U.positionScreen.y-P.positionScreen.y)*(X.positionScreen.x-P.positionScreen.x)<0||(X.positionScreen.x-O.positionScreen.x)*(U.positionScreen.y-O.positionScreen.y)-(X.positionScreen.y-O.positionScreen.y)*(U.positionScreen.x-O.positionScreen.x)<0)){g=k[m]=k[m]||new THREE.RenderableFace3;g.v1.positionWorld.copy(P.positionWorld);g.v2.positionWorld.copy(X.positionWorld);
|
|
|
-g.v3.positionWorld.copy(U.positionWorld);g.v1.positionScreen.copy(P.positionScreen);g.v2.positionScreen.copy(X.positionScreen);g.v3.positionScreen.copy(U.positionScreen);g.normalWorld.copy(K.normal);da.multiplyVector3(g.normalWorld);g.centroidWorld.copy(K.centroid);V.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);f.multiplyVector3(g.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=R;g.faceMaterials=K.materials;g.overdraw=N;if(S.geometry.uvs[I]){g.uvs[0]=S.geometry.uvs[I][0];
|
|
|
-g.uvs[1]=S.geometry.uvs[I][1];g.uvs[2]=S.geometry.uvs[I][3]}C.push(g);m++;b=k[m]=k[m]||new THREE.RenderableFace3;b.v1.positionWorld.copy(X.positionWorld);b.v2.positionWorld.copy(O.positionWorld);b.v3.positionWorld.copy(U.positionWorld);b.v1.positionScreen.copy(X.positionScreen);b.v2.positionScreen.copy(O.positionScreen);b.v3.positionScreen.copy(U.positionScreen);b.normalWorld.copy(g.normalWorld);b.centroidWorld.copy(g.centroidWorld);b.centroidScreen.copy(g.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterials=
|
|
|
-R;b.faceMaterials=K.materials;b.overdraw=N;if(S.geometry.uvs[I]){b.uvs[0]=S.geometry.uvs[I][1];b.uvs[1]=S.geometry.uvs[I][2];b.uvs[2]=S.geometry.uvs[I][3]}C.push(b);m++}}}}else if(S instanceof THREE.Line){p.multiply(f,V);aa=S.geometry.vertices;K=aa[0];K.positionScreen.copy(K.position);p.multiplyVector4(K.positionScreen);I=1;for(T=aa.length;I<T;I++){P=aa[I];P.positionScreen.copy(P.position);p.multiplyVector4(P.positionScreen);X=aa[I-1];l.copy(P.positionScreen);t.copy(X.positionScreen);if(c(l,t)){l.multiplyScalar(1/
|
|
|
-l.w);t.multiplyScalar(1/t.w);n=y[o]=y[o]||new THREE.RenderableLine;n.v1.positionScreen.copy(l);n.v2.positionScreen.copy(t);n.z=Math.max(l.z,t.z);n.materials=S.materials;C.push(n);o++}}}else if(S instanceof THREE.Particle){H.set(S.position.x,S.position.y,S.position.z,1);f.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){u=z[q]=z[q]||new THREE.RenderableParticle;u.x=H.x/H.w;u.y=H.y/H.w;u.z=H.z;u.rotation=S.rotation.z;u.scale.x=S.scale.x*Math.abs(u.x-(H.x+v.projectionMatrix.n11)/(H.w+v.projectionMatrix.n14));
|
|
|
-u.scale.y=S.scale.y*Math.abs(u.y-(H.y+v.projectionMatrix.n22)/(H.w+v.projectionMatrix.n24));u.materials=S.materials;C.push(u);q++}}}}A&&C.sort(a);return C};this.unprojectVector=function(x,v){var A=THREE.Matrix4.makeInvert(v.matrix);A.multiplySelf(THREE.Matrix4.makeInvert(v.projectionMatrix));A.multiplyVector3(x);return x}};
|
|
|
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,j,g;this.domElement=document.createElement("div");this.setSize=function(b,m){d=b;e=m;j=d/2;g=e/2};this.render=function(b,m){var k,n,o,y,u,q,z,B;a=c.projectScene(b,m);k=0;for(n=a.length;k<n;k++){u=a[k];if(u instanceof THREE.RenderableParticle){z=u.x*j+j;B=u.y*g+g;o=0;for(y=u.material.length;o<y;o++){q=u.material[o];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=z+"px";q.style.top=B+"px"}}}}}};
|
|
|
-THREE.CanvasRenderer=function(){function a(ka){if(u!=ka)n.globalAlpha=u=ka}function c(ka){if(q!=ka){switch(ka){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}q=ka}}var d=null,e=new THREE.Projector,j=document.createElement("canvas"),g,b,m,k,n=j.getContext("2d"),o=new THREE.Color(0),y=0,u=1,q=0,z=null,B=null,H=1,f,p,h,l,t,w,x,v,A,C=new THREE.Color,
|
|
|
-E=new THREE.Color,F=new THREE.Color,D=new THREE.Color,I=new THREE.Color,T,P,X,Y,S,V,da,R,N,ba=new THREE.Rectangle,aa=new THREE.Rectangle,K=new THREE.Rectangle,O=false,U=new THREE.Color,ha=new THREE.Color,ga=new THREE.Color,G=new THREE.Color,J=Math.PI*2,L=new THREE.Vector3,W,ca,ma,ia,ra,la,wa=16;W=document.createElement("canvas");W.width=W.height=2;ca=W.getContext("2d");ca.fillStyle="rgba(0,0,0,1)";ca.fillRect(0,0,2,2);ma=ca.getImageData(0,0,2,2);ia=ma.data;ra=document.createElement("canvas");ra.width=
|
|
|
-ra.height=wa;la=ra.getContext("2d");la.translate(-wa/2,-wa/2);la.scale(wa,wa);wa--;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ka,sa){g=ka;b=sa;m=g/2;k=b/2;j.width=g;j.height=b;ba.set(-m,-k,m,k);u=1;q=0;B=z=null;H=1};this.setClearColor=function(ka,sa){o=ka;y=sa;aa.set(-m,-k,m,k);n.setTransform(1,0,0,-1,m,k);this.clear()};this.setClearColorHex=function(ka,sa){o.setHex(ka);y=sa;aa.set(-m,-k,m,k);n.setTransform(1,0,0,-1,m,k);this.clear()};this.clear=
|
|
|
+THREE.Projector=function(){function a(x,u){return u.z-x.z}function c(x,u){var A=0,C=1,E=x.z+x.w,F=u.z+u.w,D=-x.z+x.w,I=-u.z+u.w;if(E>=0&&F>=0&&D>=0&&I>=0)return true;else if(E<0&&F<0||D<0&&I<0)return false;else{if(E<0)A=Math.max(A,E/(E-F));else if(F<0)C=Math.min(C,E/(E-F));if(D<0)A=Math.max(A,D/(D-I));else if(I<0)C=Math.min(C,D/(D-I));if(C<A)return false;else{x.lerpSelf(u,A);u.lerpSelf(x,1-C);return true}}}var d,e,j=[],g,b,m,k=[],n,o,y=[],v,q,z=[],B=new THREE.Vector4,H=new THREE.Vector4,f=new THREE.Matrix4,
|
|
|
+p=new THREE.Matrix4,h=[],l=new THREE.Vector4,t=new THREE.Vector4,w;this.projectObjects=function(x,u,A){var C=[],E,F;e=0;f.multiply(u.projectionMatrix,u.matrix);h[0]=new THREE.Vector4(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);h[1]=new THREE.Vector4(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);h[2]=new THREE.Vector4(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);h[3]=new THREE.Vector4(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);h[4]=new THREE.Vector4(f.n41-f.n31,f.n42-f.n32,f.n43-
|
|
|
+f.n33,f.n44-f.n34);h[5]=new THREE.Vector4(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);u=0;for(E=h.length;u<E;u++){F=h[u];F.divideScalar(Math.sqrt(F.x*F.x+F.y*F.y+F.z*F.z))}E=x.objects;x=0;for(u=E.length;x<u;x++){F=E[x];var D;if(!(D=!F.visible)){if(D=F instanceof THREE.Mesh){a:{D=void 0;for(var I=F.position,S=-F.geometry.boundingSphere.radius*Math.max(F.scale.x,Math.max(F.scale.y,F.scale.z)),N=0;N<6;N++){D=h[N].x*I.x+h[N].y*I.y+h[N].z*I.z+h[N].w;if(D<=S){D=false;break a}}D=true}D=!D}D=D}if(!D){d=
|
|
|
+j[e]=j[e]||new THREE.RenderableObject;B.copy(F.position);f.multiplyVector3(B);d.object=F;d.z=B.z;C.push(d);e++}}A&&C.sort(a);return C};this.projectScene=function(x,u,A){var C=[],E=u.near,F=u.far,D,I,S,N,X,Y,T,V,da,R,O,ba,aa,K,P,U;m=o=q=0;u.autoUpdateMatrix&&u.updateMatrix();f.multiply(u.projectionMatrix,u.matrix);Y=this.projectObjects(x,u,true);x=0;for(D=Y.length;x<D;x++){T=Y[x].object;if(T.visible){T.autoUpdateMatrix&&T.updateMatrix();V=T.matrix;da=T.rotationMatrix;R=T.materials;O=T.overdraw;if(T instanceof
|
|
|
+THREE.Mesh){ba=T.geometry;aa=ba.vertices;I=0;for(S=aa.length;I<S;I++){K=aa[I];K.positionWorld.copy(K.position);V.multiplyVector3(K.positionWorld);N=K.positionScreen;N.copy(K.positionWorld);f.multiplyVector4(N);N.x/=N.w;N.y/=N.w;K.__visible=N.z>E&&N.z<F}ba=ba.faces;I=0;for(S=ba.length;I<S;I++){K=ba[I];if(K instanceof THREE.Face3){N=aa[K.a];X=aa[K.b];P=aa[K.c];if(N.__visible&&X.__visible&&P.__visible)if(T.doubleSided||T.flipSided!=(P.positionScreen.x-N.positionScreen.x)*(X.positionScreen.y-N.positionScreen.y)-
|
|
|
+(P.positionScreen.y-N.positionScreen.y)*(X.positionScreen.x-N.positionScreen.x)<0){g=k[m]=k[m]||new THREE.RenderableFace3;g.v1.positionWorld.copy(N.positionWorld);g.v2.positionWorld.copy(X.positionWorld);g.v3.positionWorld.copy(P.positionWorld);g.v1.positionScreen.copy(N.positionScreen);g.v2.positionScreen.copy(X.positionScreen);g.v3.positionScreen.copy(P.positionScreen);g.normalWorld.copy(K.normal);da.multiplyVector3(g.normalWorld);g.centroidWorld.copy(K.centroid);V.multiplyVector3(g.centroidWorld);
|
|
|
+g.centroidScreen.copy(g.centroidWorld);f.multiplyVector3(g.centroidScreen);P=K.vertexNormals;w=g.vertexNormalsWorld;N=0;for(X=P.length;N<X;N++){U=w[N]=w[N]||new THREE.Vector3;U.copy(P[N]);da.multiplyVector3(U)}g.z=g.centroidScreen.z;g.meshMaterials=R;g.faceMaterials=K.materials;g.overdraw=O;if(T.geometry.uvs[I]){g.uvs[0]=T.geometry.uvs[I][0];g.uvs[1]=T.geometry.uvs[I][1];g.uvs[2]=T.geometry.uvs[I][2]}C.push(g);m++}}else if(K instanceof THREE.Face4){N=aa[K.a];X=aa[K.b];P=aa[K.c];U=aa[K.d];if(N.__visible&&
|
|
|
+X.__visible&&P.__visible&&U.__visible)if(T.doubleSided||T.flipSided!=((U.positionScreen.x-N.positionScreen.x)*(X.positionScreen.y-N.positionScreen.y)-(U.positionScreen.y-N.positionScreen.y)*(X.positionScreen.x-N.positionScreen.x)<0||(X.positionScreen.x-P.positionScreen.x)*(U.positionScreen.y-P.positionScreen.y)-(X.positionScreen.y-P.positionScreen.y)*(U.positionScreen.x-P.positionScreen.x)<0)){g=k[m]=k[m]||new THREE.RenderableFace3;g.v1.positionWorld.copy(N.positionWorld);g.v2.positionWorld.copy(X.positionWorld);
|
|
|
+g.v3.positionWorld.copy(U.positionWorld);g.v1.positionScreen.copy(N.positionScreen);g.v2.positionScreen.copy(X.positionScreen);g.v3.positionScreen.copy(U.positionScreen);g.normalWorld.copy(K.normal);da.multiplyVector3(g.normalWorld);g.centroidWorld.copy(K.centroid);V.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);f.multiplyVector3(g.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=R;g.faceMaterials=K.materials;g.overdraw=O;if(T.geometry.uvs[I]){g.uvs[0]=T.geometry.uvs[I][0];
|
|
|
+g.uvs[1]=T.geometry.uvs[I][1];g.uvs[2]=T.geometry.uvs[I][3]}C.push(g);m++;b=k[m]=k[m]||new THREE.RenderableFace3;b.v1.positionWorld.copy(X.positionWorld);b.v2.positionWorld.copy(P.positionWorld);b.v3.positionWorld.copy(U.positionWorld);b.v1.positionScreen.copy(X.positionScreen);b.v2.positionScreen.copy(P.positionScreen);b.v3.positionScreen.copy(U.positionScreen);b.normalWorld.copy(g.normalWorld);b.centroidWorld.copy(g.centroidWorld);b.centroidScreen.copy(g.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterials=
|
|
|
+R;b.faceMaterials=K.materials;b.overdraw=O;if(T.geometry.uvs[I]){b.uvs[0]=T.geometry.uvs[I][1];b.uvs[1]=T.geometry.uvs[I][2];b.uvs[2]=T.geometry.uvs[I][3]}C.push(b);m++}}}}else if(T instanceof THREE.Line){p.multiply(f,V);aa=T.geometry.vertices;K=aa[0];K.positionScreen.copy(K.position);p.multiplyVector4(K.positionScreen);I=1;for(S=aa.length;I<S;I++){N=aa[I];N.positionScreen.copy(N.position);p.multiplyVector4(N.positionScreen);X=aa[I-1];l.copy(N.positionScreen);t.copy(X.positionScreen);if(c(l,t)){l.multiplyScalar(1/
|
|
|
+l.w);t.multiplyScalar(1/t.w);n=y[o]=y[o]||new THREE.RenderableLine;n.v1.positionScreen.copy(l);n.v2.positionScreen.copy(t);n.z=Math.max(l.z,t.z);n.materials=T.materials;C.push(n);o++}}}else if(T instanceof THREE.Particle){H.set(T.position.x,T.position.y,T.position.z,1);f.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){v=z[q]=z[q]||new THREE.RenderableParticle;v.x=H.x/H.w;v.y=H.y/H.w;v.z=H.z;v.rotation=T.rotation.z;v.scale.x=T.scale.x*Math.abs(v.x-(H.x+u.projectionMatrix.n11)/(H.w+u.projectionMatrix.n14));
|
|
|
+v.scale.y=T.scale.y*Math.abs(v.y-(H.y+u.projectionMatrix.n22)/(H.w+u.projectionMatrix.n24));v.materials=T.materials;C.push(v);q++}}}}A&&C.sort(a);return C};this.unprojectVector=function(x,u){var A=THREE.Matrix4.makeInvert(u.matrix);A.multiplySelf(THREE.Matrix4.makeInvert(u.projectionMatrix));A.multiplyVector3(x);return x}};
|
|
|
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,j,g;this.domElement=document.createElement("div");this.setSize=function(b,m){d=b;e=m;j=d/2;g=e/2};this.render=function(b,m){var k,n,o,y,v,q,z,B;a=c.projectScene(b,m);k=0;for(n=a.length;k<n;k++){v=a[k];if(v instanceof THREE.RenderableParticle){z=v.x*j+j;B=v.y*g+g;o=0;for(y=v.material.length;o<y;o++){q=v.material[o];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=z+"px";q.style.top=B+"px"}}}}}};
|
|
|
+THREE.CanvasRenderer=function(){function a(ka){if(v!=ka)n.globalAlpha=v=ka}function c(ka){if(q!=ka){switch(ka){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}q=ka}}var d=null,e=new THREE.Projector,j=document.createElement("canvas"),g,b,m,k,n=j.getContext("2d"),o=new THREE.Color(0),y=0,v=1,q=0,z=null,B=null,H=1,f,p,h,l,t,w,x,u,A,C=new THREE.Color,
|
|
|
+E=new THREE.Color,F=new THREE.Color,D=new THREE.Color,I=new THREE.Color,S,N,X,Y,T,V,da,R,O,ba=new THREE.Rectangle,aa=new THREE.Rectangle,K=new THREE.Rectangle,P=false,U=new THREE.Color,ha=new THREE.Color,ga=new THREE.Color,G=new THREE.Color,J=Math.PI*2,L=new THREE.Vector3,W,ca,ma,ia,ra,la,wa=16;W=document.createElement("canvas");W.width=W.height=2;ca=W.getContext("2d");ca.fillStyle="rgba(0,0,0,1)";ca.fillRect(0,0,2,2);ma=ca.getImageData(0,0,2,2);ia=ma.data;ra=document.createElement("canvas");ra.width=
|
|
|
+ra.height=wa;la=ra.getContext("2d");la.translate(-wa/2,-wa/2);la.scale(wa,wa);wa--;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ka,sa){g=ka;b=sa;m=g/2;k=b/2;j.width=g;j.height=b;ba.set(-m,-k,m,k);v=1;q=0;B=z=null;H=1};this.setClearColor=function(ka,sa){o=ka;y=sa;aa.set(-m,-k,m,k);n.setTransform(1,0,0,-1,m,k);this.clear()};this.setClearColorHex=function(ka,sa){o.setHex(ka);y=sa;aa.set(-m,-k,m,k);n.setTransform(1,0,0,-1,m,k);this.clear()};this.clear=
|
|
|
function(){n.setTransform(1,0,0,-1,m,k);if(!aa.isEmpty()){aa.inflate(1);aa.minSelf(ba);if(o.hex==0&&y==0)n.clearRect(aa.getX(),aa.getY(),aa.getWidth(),aa.getHeight());else{c(THREE.NormalBlending);a(1);n.fillStyle="rgba("+Math.floor(o.r*255)+","+Math.floor(o.g*255)+","+Math.floor(o.b*255)+","+y+")";n.fillRect(aa.getX(),aa.getY(),aa.getWidth(),aa.getHeight())}aa.empty()}};this.render=function(ka,sa){function Ha(M){var ea,$,Q,Z=M.lights;ha.setRGB(0,0,0);ga.setRGB(0,0,0);G.setRGB(0,0,0);M=0;for(ea=Z.length;M<
|
|
|
ea;M++){$=Z[M];Q=$.color;if($ instanceof THREE.AmbientLight){ha.r+=Q.r;ha.g+=Q.g;ha.b+=Q.b}else if($ instanceof THREE.DirectionalLight){ga.r+=Q.r;ga.g+=Q.g;ga.b+=Q.b}else if($ instanceof THREE.PointLight){G.r+=Q.r;G.g+=Q.g;G.b+=Q.b}}}function qa(M,ea,$,Q){var Z,fa,na,oa,pa=M.lights;M=0;for(Z=pa.length;M<Z;M++){fa=pa[M];na=fa.color;oa=fa.intensity;if(fa instanceof THREE.DirectionalLight){fa=$.dot(fa.position)*oa;if(fa>0){Q.r+=na.r*fa;Q.g+=na.g*fa;Q.b+=na.b*fa}}else if(fa instanceof THREE.PointLight){L.sub(fa.position,
|
|
|
ea);L.normalize();fa=$.dot(L)*oa;if(fa>0){Q.r+=na.r*fa;Q.g+=na.g*fa;Q.b+=na.b*fa}}}}function Qa(M,ea,$){if($.opacity!=0){a($.opacity);c($.blending);var Q,Z,fa,na,oa,pa;if($ instanceof THREE.ParticleBasicMaterial){if($.map&&$.map.image.loaded){na=$.map.image;oa=na.width>>1;pa=na.height>>1;Z=ea.scale.x*m;fa=ea.scale.y*k;$=Z*oa;Q=fa*pa;K.set(M.x-$,M.y-Q,M.x+$,M.y+Q);if(ba.instersects(K)){n.save();n.translate(M.x,M.y);n.rotate(-ea.rotation);n.scale(Z,-fa);n.translate(-oa,-pa);n.drawImage(na,0,0);n.restore()}}}else if($ instanceof
|
|
|
-THREE.ParticleCircleMaterial){if(O){U.r=ha.r+ga.r+G.r;U.g=ha.g+ga.g+G.g;U.b=ha.b+ga.b+G.b;C.r=$.color.r*U.r;C.g=$.color.g*U.g;C.b=$.color.b*U.b;C.updateStyleString()}else C.__styleString=$.color.__styleString;$=ea.scale.x*m;Q=ea.scale.y*k;K.set(M.x-$,M.y-Q,M.x+$,M.y+Q);if(ba.instersects(K)){Z=C.__styleString;if(B!=Z)n.fillStyle=B=Z;n.save();n.translate(M.x,M.y);n.rotate(-ea.rotation);n.scale($,Q);n.beginPath();n.arc(0,0,1,0,J,true);n.closePath();n.fill();n.restore()}}}}function Ra(M,ea,$,Q){if(Q.opacity!=
|
|
|
+THREE.ParticleCircleMaterial){if(P){U.r=ha.r+ga.r+G.r;U.g=ha.g+ga.g+G.g;U.b=ha.b+ga.b+G.b;C.r=$.color.r*U.r;C.g=$.color.g*U.g;C.b=$.color.b*U.b;C.updateStyleString()}else C.__styleString=$.color.__styleString;$=ea.scale.x*m;Q=ea.scale.y*k;K.set(M.x-$,M.y-Q,M.x+$,M.y+Q);if(ba.instersects(K)){Z=C.__styleString;if(B!=Z)n.fillStyle=B=Z;n.save();n.translate(M.x,M.y);n.rotate(-ea.rotation);n.scale($,Q);n.beginPath();n.arc(0,0,1,0,J,true);n.closePath();n.fill();n.restore()}}}}function Ra(M,ea,$,Q){if(Q.opacity!=
|
|
|
0){a(Q.opacity);c(Q.blending);n.beginPath();n.moveTo(M.positionScreen.x,M.positionScreen.y);n.lineTo(ea.positionScreen.x,ea.positionScreen.y);n.closePath();if(Q instanceof THREE.LineBasicMaterial){C.__styleString=Q.color.__styleString;M=Q.linewidth;if(H!=M)n.lineWidth=H=M;M=C.__styleString;if(z!=M)n.strokeStyle=z=M;n.stroke();K.inflate(Q.linewidth*2)}}}function Ma(M,ea,$,Q,Z,fa){if(Z.opacity!=0){a(Z.opacity);c(Z.blending);l=M.positionScreen.x;t=M.positionScreen.y;w=ea.positionScreen.x;x=ea.positionScreen.y;
|
|
|
-v=$.positionScreen.x;A=$.positionScreen.y;n.beginPath();n.moveTo(l,t);n.lineTo(w,x);n.lineTo(v,A);n.lineTo(l,t);n.closePath();if(Z instanceof THREE.MeshBasicMaterial)if(Z.map)Z.map.image.loaded&&Z.map.mapping instanceof THREE.UVMapping&&Ba(l,t,w,x,v,A,Z.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(Z.env_map){if(Z.env_map.image.loaded)if(Z.env_map.mapping instanceof THREE.SphericalReflectionMapping){M=sa.matrix;L.copy(Q.vertexNormalsWorld[0]);Y=(L.x*M.n11+L.y*
|
|
|
-M.n12+L.z*M.n13)*0.5+0.5;S=-(L.x*M.n21+L.y*M.n22+L.z*M.n23)*0.5+0.5;L.copy(Q.vertexNormalsWorld[1]);V=(L.x*M.n11+L.y*M.n12+L.z*M.n13)*0.5+0.5;da=-(L.x*M.n21+L.y*M.n22+L.z*M.n23)*0.5+0.5;L.copy(Q.vertexNormalsWorld[2]);R=(L.x*M.n11+L.y*M.n12+L.z*M.n13)*0.5+0.5;N=-(L.x*M.n21+L.y*M.n22+L.z*M.n23)*0.5+0.5;Ba(l,t,w,x,v,A,Z.env_map.image,Y,S,V,da,R,N)}}else Z.wireframe?Ea(Z.color.__styleString,Z.wireframe_linewidth):Fa(Z.color.__styleString);else if(Z instanceof THREE.MeshLambertMaterial){if(Z.map&&!Z.wireframe){Z.map.mapping instanceof
|
|
|
-THREE.UVMapping&&Ba(l,t,w,x,v,A,Z.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);c(THREE.SubtractiveBlending)}if(O)if(!Z.wireframe&&Z.shading==THREE.SmoothShading&&Q.vertexNormalsWorld.length==3){E.r=F.r=D.r=ha.r;E.g=F.g=D.g=ha.g;E.b=F.b=D.b=ha.b;qa(fa,Q.v1.positionWorld,Q.vertexNormalsWorld[0],E);qa(fa,Q.v2.positionWorld,Q.vertexNormalsWorld[1],F);qa(fa,Q.v3.positionWorld,Q.vertexNormalsWorld[2],D);I.r=(F.r+D.r)*0.5;I.g=(F.g+D.g)*0.5;I.b=(F.b+D.b)*0.5;X=Na(E,F,D,I);
|
|
|
-Ba(l,t,w,x,v,A,X,0,0,1,0,0,1)}else{U.r=ha.r;U.g=ha.g;U.b=ha.b;qa(fa,Q.centroidWorld,Q.normalWorld,U);C.r=Z.color.r*U.r;C.g=Z.color.g*U.g;C.b=Z.color.b*U.b;C.updateStyleString();Z.wireframe?Ea(C.__styleString,Z.wireframe_linewidth):Fa(C.__styleString)}else Z.wireframe?Ea(Z.color.__styleString,Z.wireframe_linewidth):Fa(Z.color.__styleString)}else if(Z instanceof THREE.MeshDepthMaterial){T=sa.near;P=sa.far;E.r=E.g=E.b=1-Ia(M.positionScreen.z,T,P);F.r=F.g=F.b=1-Ia(ea.positionScreen.z,T,P);D.r=D.g=D.b=
|
|
|
-1-Ia($.positionScreen.z,T,P);I.r=(F.r+D.r)*0.5;I.g=(F.g+D.g)*0.5;I.b=(F.b+D.b)*0.5;X=Na(E,F,D,I);Ba(l,t,w,x,v,A,X,0,0,1,0,0,1)}else if(Z instanceof THREE.MeshNormalMaterial){C.r=Ja(Q.normalWorld.x);C.g=Ja(Q.normalWorld.y);C.b=Ja(Q.normalWorld.z);C.updateStyleString();Z.wireframe?Ea(C.__styleString,Z.wireframe_linewidth):Fa(C.__styleString)}}}function Ea(M,ea){if(z!=M)n.strokeStyle=z=M;if(H!=ea)n.lineWidth=H=ea;n.stroke();K.inflate(ea*2)}function Fa(M){if(B!=M)n.fillStyle=B=M;n.fill()}function Ba(M,
|
|
|
+u=$.positionScreen.x;A=$.positionScreen.y;n.beginPath();n.moveTo(l,t);n.lineTo(w,x);n.lineTo(u,A);n.lineTo(l,t);n.closePath();if(Z instanceof THREE.MeshBasicMaterial)if(Z.map)Z.map.image.loaded&&Z.map.mapping instanceof THREE.UVMapping&&Ba(l,t,w,x,u,A,Z.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(Z.env_map){if(Z.env_map.image.loaded)if(Z.env_map.mapping instanceof THREE.SphericalReflectionMapping){M=sa.matrix;L.copy(Q.vertexNormalsWorld[0]);Y=(L.x*M.n11+L.y*
|
|
|
+M.n12+L.z*M.n13)*0.5+0.5;T=-(L.x*M.n21+L.y*M.n22+L.z*M.n23)*0.5+0.5;L.copy(Q.vertexNormalsWorld[1]);V=(L.x*M.n11+L.y*M.n12+L.z*M.n13)*0.5+0.5;da=-(L.x*M.n21+L.y*M.n22+L.z*M.n23)*0.5+0.5;L.copy(Q.vertexNormalsWorld[2]);R=(L.x*M.n11+L.y*M.n12+L.z*M.n13)*0.5+0.5;O=-(L.x*M.n21+L.y*M.n22+L.z*M.n23)*0.5+0.5;Ba(l,t,w,x,u,A,Z.env_map.image,Y,T,V,da,R,O)}}else Z.wireframe?Ea(Z.color.__styleString,Z.wireframe_linewidth):Fa(Z.color.__styleString);else if(Z instanceof THREE.MeshLambertMaterial){if(Z.map&&!Z.wireframe){Z.map.mapping instanceof
|
|
|
+THREE.UVMapping&&Ba(l,t,w,x,u,A,Z.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);c(THREE.SubtractiveBlending)}if(P)if(!Z.wireframe&&Z.shading==THREE.SmoothShading&&Q.vertexNormalsWorld.length==3){E.r=F.r=D.r=ha.r;E.g=F.g=D.g=ha.g;E.b=F.b=D.b=ha.b;qa(fa,Q.v1.positionWorld,Q.vertexNormalsWorld[0],E);qa(fa,Q.v2.positionWorld,Q.vertexNormalsWorld[1],F);qa(fa,Q.v3.positionWorld,Q.vertexNormalsWorld[2],D);I.r=(F.r+D.r)*0.5;I.g=(F.g+D.g)*0.5;I.b=(F.b+D.b)*0.5;X=Na(E,F,D,I);
|
|
|
+Ba(l,t,w,x,u,A,X,0,0,1,0,0,1)}else{U.r=ha.r;U.g=ha.g;U.b=ha.b;qa(fa,Q.centroidWorld,Q.normalWorld,U);C.r=Z.color.r*U.r;C.g=Z.color.g*U.g;C.b=Z.color.b*U.b;C.updateStyleString();Z.wireframe?Ea(C.__styleString,Z.wireframe_linewidth):Fa(C.__styleString)}else Z.wireframe?Ea(Z.color.__styleString,Z.wireframe_linewidth):Fa(Z.color.__styleString)}else if(Z instanceof THREE.MeshDepthMaterial){S=sa.near;N=sa.far;E.r=E.g=E.b=1-Ia(M.positionScreen.z,S,N);F.r=F.g=F.b=1-Ia(ea.positionScreen.z,S,N);D.r=D.g=D.b=
|
|
|
+1-Ia($.positionScreen.z,S,N);I.r=(F.r+D.r)*0.5;I.g=(F.g+D.g)*0.5;I.b=(F.b+D.b)*0.5;X=Na(E,F,D,I);Ba(l,t,w,x,u,A,X,0,0,1,0,0,1)}else if(Z instanceof THREE.MeshNormalMaterial){C.r=Ja(Q.normalWorld.x);C.g=Ja(Q.normalWorld.y);C.b=Ja(Q.normalWorld.z);C.updateStyleString();Z.wireframe?Ea(C.__styleString,Z.wireframe_linewidth):Fa(C.__styleString)}}}function Ea(M,ea){if(z!=M)n.strokeStyle=z=M;if(H!=ea)n.lineWidth=H=ea;n.stroke();K.inflate(ea*2)}function Fa(M){if(B!=M)n.fillStyle=B=M;n.fill()}function Ba(M,
|
|
|
ea,$,Q,Z,fa,na,oa,pa,xa,ta,ya,Ca){var ua,za;ua=na.width-1;za=na.height-1;oa*=ua;pa*=za;xa*=ua;ta*=za;ya*=ua;Ca*=za;$-=M;Q-=ea;Z-=M;fa-=ea;xa-=oa;ta-=pa;ya-=oa;Ca-=pa;ua=xa*Ca-ya*ta;if(ua!=0){za=1/ua;ua=(Ca*$-ta*Z)*za;ta=(Ca*Q-ta*fa)*za;$=(xa*Z-ya*$)*za;Q=(xa*fa-ya*Q)*za;M=M-ua*oa-$*pa;ea=ea-ta*oa-Q*pa;n.save();n.transform(ua,ta,$,Q,M,ea);n.clip();n.drawImage(na,0,0);n.restore()}}function Na(M,ea,$,Q){var Z=~~(M.r*255),fa=~~(M.g*255);M=~~(M.b*255);var na=~~(ea.r*255),oa=~~(ea.g*255);ea=~~(ea.b*255);
|
|
|
var pa=~~($.r*255),xa=~~($.g*255);$=~~($.b*255);var ta=~~(Q.r*255),ya=~~(Q.g*255);Q=~~(Q.b*255);ia[0]=Z<0?0:Z>255?255:Z;ia[1]=fa<0?0:fa>255?255:fa;ia[2]=M<0?0:M>255?255:M;ia[4]=na<0?0:na>255?255:na;ia[5]=oa<0?0:oa>255?255:oa;ia[6]=ea<0?0:ea>255?255:ea;ia[8]=pa<0?0:pa>255?255:pa;ia[9]=xa<0?0:xa>255?255:xa;ia[10]=$<0?0:$>255?255:$;ia[12]=ta<0?0:ta>255?255:ta;ia[13]=ya<0?0:ya>255?255:ya;ia[14]=Q<0?0:Q>255?255:Q;ca.putImageData(ma,0,0);la.drawImage(W,0,0);return ra}function Ia(M,ea,$){M=(M-ea)/($-ea);
|
|
|
-return M*M*(3-2*M)}function Ja(M){M=(M+1)*0.5;return M<0?0:M>1?1:M}function Ka(M,ea){var $=ea.x-M.x,Q=ea.y-M.y,Z=1/Math.sqrt($*$+Q*Q);$*=Z;Q*=Z;ea.x+=$;ea.y+=Q;M.x-=$;M.y-=Q}var Ga,Oa,ja,va,Aa,La,Pa,Da;this.autoClear?this.clear():n.setTransform(1,0,0,-1,m,k);d=e.projectScene(ka,sa,this.sortElements);(O=ka.lights.length>0)&&Ha(ka);Ga=0;for(Oa=d.length;Ga<Oa;Ga++){ja=d[Ga];K.empty();if(ja instanceof THREE.RenderableParticle){f=ja;f.x*=m;f.y*=k;va=0;for(Aa=ja.materials.length;va<Aa;va++)Qa(f,ja,ja.materials[va],
|
|
|
+return M*M*(3-2*M)}function Ja(M){M=(M+1)*0.5;return M<0?0:M>1?1:M}function Ka(M,ea){var $=ea.x-M.x,Q=ea.y-M.y,Z=1/Math.sqrt($*$+Q*Q);$*=Z;Q*=Z;ea.x+=$;ea.y+=Q;M.x-=$;M.y-=Q}var Ga,Oa,ja,va,Aa,La,Pa,Da;this.autoClear?this.clear():n.setTransform(1,0,0,-1,m,k);d=e.projectScene(ka,sa,this.sortElements);(P=ka.lights.length>0)&&Ha(ka);Ga=0;for(Oa=d.length;Ga<Oa;Ga++){ja=d[Ga];K.empty();if(ja instanceof THREE.RenderableParticle){f=ja;f.x*=m;f.y*=k;va=0;for(Aa=ja.materials.length;va<Aa;va++)Qa(f,ja,ja.materials[va],
|
|
|
ka)}else if(ja instanceof THREE.RenderableLine){f=ja.v1;p=ja.v2;f.positionScreen.x*=m;f.positionScreen.y*=k;p.positionScreen.x*=m;p.positionScreen.y*=k;K.addPoint(f.positionScreen.x,f.positionScreen.y);K.addPoint(p.positionScreen.x,p.positionScreen.y);if(ba.instersects(K)){va=0;for(Aa=ja.materials.length;va<Aa;)Ra(f,p,ja,ja.materials[va++],ka)}}else if(ja instanceof THREE.RenderableFace3){f=ja.v1;p=ja.v2;h=ja.v3;f.positionScreen.x*=m;f.positionScreen.y*=k;p.positionScreen.x*=m;p.positionScreen.y*=
|
|
|
k;h.positionScreen.x*=m;h.positionScreen.y*=k;if(ja.overdraw){Ka(f.positionScreen,p.positionScreen);Ka(p.positionScreen,h.positionScreen);Ka(h.positionScreen,f.positionScreen)}K.add3Points(f.positionScreen.x,f.positionScreen.y,p.positionScreen.x,p.positionScreen.y,h.positionScreen.x,h.positionScreen.y);if(ba.instersects(K)){va=0;for(Aa=ja.meshMaterials.length;va<Aa;){Da=ja.meshMaterials[va++];if(Da instanceof THREE.MeshFaceMaterial){La=0;for(Pa=ja.faceMaterials.length;La<Pa;)(Da=ja.faceMaterials[La++])&&
|
|
|
Ma(f,p,h,ja,Da,ka)}else Ma(f,p,h,ja,Da,ka)}}}aa.addRectangle(K)}n.setTransform(1,0,0,1,0,0)}};
|
|
|
-THREE.SVGRenderer=function(){function a(Y,S,V){var da,R,N,ba;da=0;for(R=Y.lights.length;da<R;da++){N=Y.lights[da];if(N instanceof THREE.DirectionalLight){ba=S.normalWorld.dot(N.position)*N.intensity;if(ba>0){V.r+=N.color.r*ba;V.g+=N.color.g*ba;V.b+=N.color.b*ba}}else if(N instanceof THREE.PointLight){A.sub(N.position,S.centroidWorld);A.normalize();ba=S.normalWorld.dot(A)*N.intensity;if(ba>0){V.r+=N.color.r*ba;V.g+=N.color.g*ba;V.b+=N.color.b*ba}}}}function c(Y,S,V,da,R,N){D=e(I++);D.setAttribute("d",
|
|
|
-"M "+Y.positionScreen.x+" "+Y.positionScreen.y+" L "+S.positionScreen.x+" "+S.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(R instanceof THREE.MeshBasicMaterial)h.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshLambertMaterial)if(p){l.r=t.r;l.g=t.g;l.b=t.b;a(N,da,l);h.r=R.color.r*l.r;h.g=R.color.g*l.g;h.b=R.color.b*l.b;h.updateStyleString()}else h.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshDepthMaterial){v=1-R.__2near/(R.__farPlusNear-
|
|
|
-da.z*R.__farMinusNear);h.setRGB(v,v,v)}else R instanceof THREE.MeshNormalMaterial&&h.setRGB(j(da.normalWorld.x),j(da.normalWorld.y),j(da.normalWorld.z));R.wireframe?D.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+R.wireframe_linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.wireframe_linecap+"; stroke-linejoin: "+R.wireframe_linejoin):D.setAttribute("style","fill: "+h.__styleString+"; fill-opacity: "+R.opacity);m.appendChild(D)}function d(Y,S,V,da,R,
|
|
|
-N,ba){D=e(I++);D.setAttribute("d","M "+Y.positionScreen.x+" "+Y.positionScreen.y+" L "+S.positionScreen.x+" "+S.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+"z");if(N instanceof THREE.MeshBasicMaterial)h.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshLambertMaterial)if(p){l.r=t.r;l.g=t.g;l.b=t.b;a(ba,R,l);h.r=N.color.r*l.r;h.g=N.color.g*l.g;h.b=N.color.b*l.b;h.updateStyleString()}else h.__styleString=N.color.__styleString;
|
|
|
-else if(N instanceof THREE.MeshDepthMaterial){v=1-N.__2near/(N.__farPlusNear-R.z*N.__farMinusNear);h.setRGB(v,v,v)}else N instanceof THREE.MeshNormalMaterial&&h.setRGB(j(R.normalWorld.x),j(R.normalWorld.y),j(R.normalWorld.z));N.wireframe?D.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+N.wireframe_linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.wireframe_linecap+"; stroke-linejoin: "+N.wireframe_linejoin):D.setAttribute("style","fill: "+h.__styleString+
|
|
|
-"; fill-opacity: "+N.opacity);m.appendChild(D)}function e(Y){if(C[Y]==null){C[Y]=document.createElementNS("http://www.w3.org/2000/svg","path");X==0&&C[Y].setAttribute("shape-rendering","crispEdges");return C[Y]}return C[Y]}function j(Y){return Y<0?Math.min((1+Y)*0.5,0.5):0.5+Math.min(Y*0.5,0.5)}var g=null,b=new THREE.Projector,m=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,n,o,y,u,q,z,B,H=new THREE.Rectangle,f=new THREE.Rectangle,p=false,h=new THREE.Color(16777215),l=new THREE.Color(16777215),
|
|
|
-t=new THREE.Color(0),w=new THREE.Color(0),x=new THREE.Color(0),v,A=new THREE.Vector3,C=[],E=[],F=[],D,I,T,P,X=1;this.domElement=m;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(Y){switch(Y){case "high":X=1;break;case "low":X=0}};this.setSize=function(Y,S){k=Y;n=S;o=k/2;y=n/2;m.setAttribute("viewBox",-o+" "+-y+" "+k+" "+n);m.setAttribute("width",k);m.setAttribute("height",n);H.set(-o,-y,o,y)};this.clear=function(){for(;m.childNodes.length>0;)m.removeChild(m.childNodes[0])};
|
|
|
-this.render=function(Y,S){var V,da,R,N,ba,aa,K,O;this.autoClear&&this.clear();g=b.projectScene(Y,S,this.sortElements);P=T=I=0;if(p=Y.lights.length>0){K=Y.lights;t.setRGB(0,0,0);w.setRGB(0,0,0);x.setRGB(0,0,0);V=0;for(da=K.length;V<da;V++){R=K[V];N=R.color;if(R instanceof THREE.AmbientLight){t.r+=N.r;t.g+=N.g;t.b+=N.b}else if(R instanceof THREE.DirectionalLight){w.r+=N.r;w.g+=N.g;w.b+=N.b}else if(R instanceof THREE.PointLight){x.r+=N.r;x.g+=N.g;x.b+=N.b}}}V=0;for(da=g.length;V<da;V++){K=g[V];f.empty();
|
|
|
-if(K instanceof THREE.RenderableParticle){u=K;u.x*=o;u.y*=-y;R=0;for(N=K.materials.length;R<N;R++)if(O=K.materials[R]){ba=u;aa=K;O=O;var U=T++;if(E[U]==null){E[U]=document.createElementNS("http://www.w3.org/2000/svg","circle");X==0&&E[U].setAttribute("shape-rendering","crispEdges")}D=E[U];D.setAttribute("cx",ba.x);D.setAttribute("cy",ba.y);D.setAttribute("r",aa.scale.x*o);if(O instanceof THREE.ParticleCircleMaterial){if(p){l.r=t.r+w.r+x.r;l.g=t.g+w.g+x.g;l.b=t.b+w.b+x.b;h.r=O.color.r*l.r;h.g=O.color.g*
|
|
|
-l.g;h.b=O.color.b*l.b;h.updateStyleString()}else h=O.color;D.setAttribute("style","fill: "+h.__styleString)}m.appendChild(D)}}else if(K instanceof THREE.RenderableLine){u=K.v1;q=K.v2;u.positionScreen.x*=o;u.positionScreen.y*=-y;q.positionScreen.x*=o;q.positionScreen.y*=-y;f.addPoint(u.positionScreen.x,u.positionScreen.y);f.addPoint(q.positionScreen.x,q.positionScreen.y);if(H.instersects(f)){R=0;for(N=K.materials.length;R<N;)if(O=K.materials[R++]){ba=u;aa=q;O=O;U=P++;if(F[U]==null){F[U]=document.createElementNS("http://www.w3.org/2000/svg",
|
|
|
-"line");X==0&&F[U].setAttribute("shape-rendering","crispEdges")}D=F[U];D.setAttribute("x1",ba.positionScreen.x);D.setAttribute("y1",ba.positionScreen.y);D.setAttribute("x2",aa.positionScreen.x);D.setAttribute("y2",aa.positionScreen.y);if(O instanceof THREE.LineBasicMaterial){h.__styleString=O.color.__styleString;D.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+O.linewidth+"; stroke-opacity: "+O.opacity+"; stroke-linecap: "+O.linecap+"; stroke-linejoin: "+O.linejoin);
|
|
|
-m.appendChild(D)}}}}else if(K instanceof THREE.RenderableFace3){u=K.v1;q=K.v2;z=K.v3;u.positionScreen.x*=o;u.positionScreen.y*=-y;q.positionScreen.x*=o;q.positionScreen.y*=-y;z.positionScreen.x*=o;z.positionScreen.y*=-y;f.addPoint(u.positionScreen.x,u.positionScreen.y);f.addPoint(q.positionScreen.x,q.positionScreen.y);f.addPoint(z.positionScreen.x,z.positionScreen.y);if(H.instersects(f)){R=0;for(N=K.meshMaterials.length;R<N;){O=K.meshMaterials[R++];if(O instanceof THREE.MeshFaceMaterial){ba=0;for(aa=
|
|
|
-K.faceMaterials.length;ba<aa;)(O=K.faceMaterials[ba++])&&c(u,q,z,K,O,Y)}else O&&c(u,q,z,K,O,Y)}}}else if(K instanceof THREE.RenderableFace4){u=K.v1;q=K.v2;z=K.v3;B=K.v4;u.positionScreen.x*=o;u.positionScreen.y*=-y;q.positionScreen.x*=o;q.positionScreen.y*=-y;z.positionScreen.x*=o;z.positionScreen.y*=-y;B.positionScreen.x*=o;B.positionScreen.y*=-y;f.addPoint(u.positionScreen.x,u.positionScreen.y);f.addPoint(q.positionScreen.x,q.positionScreen.y);f.addPoint(z.positionScreen.x,z.positionScreen.y);f.addPoint(B.positionScreen.x,
|
|
|
-B.positionScreen.y);if(H.instersects(f)){R=0;for(N=K.meshMaterials.length;R<N;){O=K.meshMaterials[R++];if(O instanceof THREE.MeshFaceMaterial){ba=0;for(aa=K.faceMaterials.length;ba<aa;)(O=K.faceMaterials[ba++])&&d(u,q,z,B,K,O,Y)}else O&&d(u,q,z,B,K,O,Y)}}}}}};
|
|
|
+THREE.SVGRenderer=function(){function a(Y,T,V){var da,R,O,ba;da=0;for(R=Y.lights.length;da<R;da++){O=Y.lights[da];if(O instanceof THREE.DirectionalLight){ba=T.normalWorld.dot(O.position)*O.intensity;if(ba>0){V.r+=O.color.r*ba;V.g+=O.color.g*ba;V.b+=O.color.b*ba}}else if(O instanceof THREE.PointLight){A.sub(O.position,T.centroidWorld);A.normalize();ba=T.normalWorld.dot(A)*O.intensity;if(ba>0){V.r+=O.color.r*ba;V.g+=O.color.g*ba;V.b+=O.color.b*ba}}}}function c(Y,T,V,da,R,O){D=e(I++);D.setAttribute("d",
|
|
|
+"M "+Y.positionScreen.x+" "+Y.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(R instanceof THREE.MeshBasicMaterial)h.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshLambertMaterial)if(p){l.r=t.r;l.g=t.g;l.b=t.b;a(O,da,l);h.r=R.color.r*l.r;h.g=R.color.g*l.g;h.b=R.color.b*l.b;h.updateStyleString()}else h.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshDepthMaterial){u=1-R.__2near/(R.__farPlusNear-
|
|
|
+da.z*R.__farMinusNear);h.setRGB(u,u,u)}else R instanceof THREE.MeshNormalMaterial&&h.setRGB(j(da.normalWorld.x),j(da.normalWorld.y),j(da.normalWorld.z));R.wireframe?D.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+R.wireframe_linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.wireframe_linecap+"; stroke-linejoin: "+R.wireframe_linejoin):D.setAttribute("style","fill: "+h.__styleString+"; fill-opacity: "+R.opacity);m.appendChild(D)}function d(Y,T,V,da,R,
|
|
|
+O,ba){D=e(I++);D.setAttribute("d","M "+Y.positionScreen.x+" "+Y.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+"z");if(O instanceof THREE.MeshBasicMaterial)h.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshLambertMaterial)if(p){l.r=t.r;l.g=t.g;l.b=t.b;a(ba,R,l);h.r=O.color.r*l.r;h.g=O.color.g*l.g;h.b=O.color.b*l.b;h.updateStyleString()}else h.__styleString=O.color.__styleString;
|
|
|
+else if(O instanceof THREE.MeshDepthMaterial){u=1-O.__2near/(O.__farPlusNear-R.z*O.__farMinusNear);h.setRGB(u,u,u)}else O instanceof THREE.MeshNormalMaterial&&h.setRGB(j(R.normalWorld.x),j(R.normalWorld.y),j(R.normalWorld.z));O.wireframe?D.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+O.wireframe_linewidth+"; stroke-opacity: "+O.opacity+"; stroke-linecap: "+O.wireframe_linecap+"; stroke-linejoin: "+O.wireframe_linejoin):D.setAttribute("style","fill: "+h.__styleString+
|
|
|
+"; fill-opacity: "+O.opacity);m.appendChild(D)}function e(Y){if(C[Y]==null){C[Y]=document.createElementNS("http://www.w3.org/2000/svg","path");X==0&&C[Y].setAttribute("shape-rendering","crispEdges");return C[Y]}return C[Y]}function j(Y){return Y<0?Math.min((1+Y)*0.5,0.5):0.5+Math.min(Y*0.5,0.5)}var g=null,b=new THREE.Projector,m=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,n,o,y,v,q,z,B,H=new THREE.Rectangle,f=new THREE.Rectangle,p=false,h=new THREE.Color(16777215),l=new THREE.Color(16777215),
|
|
|
+t=new THREE.Color(0),w=new THREE.Color(0),x=new THREE.Color(0),u,A=new THREE.Vector3,C=[],E=[],F=[],D,I,S,N,X=1;this.domElement=m;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(Y){switch(Y){case "high":X=1;break;case "low":X=0}};this.setSize=function(Y,T){k=Y;n=T;o=k/2;y=n/2;m.setAttribute("viewBox",-o+" "+-y+" "+k+" "+n);m.setAttribute("width",k);m.setAttribute("height",n);H.set(-o,-y,o,y)};this.clear=function(){for(;m.childNodes.length>0;)m.removeChild(m.childNodes[0])};
|
|
|
+this.render=function(Y,T){var V,da,R,O,ba,aa,K,P;this.autoClear&&this.clear();g=b.projectScene(Y,T,this.sortElements);N=S=I=0;if(p=Y.lights.length>0){K=Y.lights;t.setRGB(0,0,0);w.setRGB(0,0,0);x.setRGB(0,0,0);V=0;for(da=K.length;V<da;V++){R=K[V];O=R.color;if(R instanceof THREE.AmbientLight){t.r+=O.r;t.g+=O.g;t.b+=O.b}else if(R instanceof THREE.DirectionalLight){w.r+=O.r;w.g+=O.g;w.b+=O.b}else if(R instanceof THREE.PointLight){x.r+=O.r;x.g+=O.g;x.b+=O.b}}}V=0;for(da=g.length;V<da;V++){K=g[V];f.empty();
|
|
|
+if(K instanceof THREE.RenderableParticle){v=K;v.x*=o;v.y*=-y;R=0;for(O=K.materials.length;R<O;R++)if(P=K.materials[R]){ba=v;aa=K;P=P;var U=S++;if(E[U]==null){E[U]=document.createElementNS("http://www.w3.org/2000/svg","circle");X==0&&E[U].setAttribute("shape-rendering","crispEdges")}D=E[U];D.setAttribute("cx",ba.x);D.setAttribute("cy",ba.y);D.setAttribute("r",aa.scale.x*o);if(P instanceof THREE.ParticleCircleMaterial){if(p){l.r=t.r+w.r+x.r;l.g=t.g+w.g+x.g;l.b=t.b+w.b+x.b;h.r=P.color.r*l.r;h.g=P.color.g*
|
|
|
+l.g;h.b=P.color.b*l.b;h.updateStyleString()}else h=P.color;D.setAttribute("style","fill: "+h.__styleString)}m.appendChild(D)}}else if(K instanceof THREE.RenderableLine){v=K.v1;q=K.v2;v.positionScreen.x*=o;v.positionScreen.y*=-y;q.positionScreen.x*=o;q.positionScreen.y*=-y;f.addPoint(v.positionScreen.x,v.positionScreen.y);f.addPoint(q.positionScreen.x,q.positionScreen.y);if(H.instersects(f)){R=0;for(O=K.materials.length;R<O;)if(P=K.materials[R++]){ba=v;aa=q;P=P;U=N++;if(F[U]==null){F[U]=document.createElementNS("http://www.w3.org/2000/svg",
|
|
|
+"line");X==0&&F[U].setAttribute("shape-rendering","crispEdges")}D=F[U];D.setAttribute("x1",ba.positionScreen.x);D.setAttribute("y1",ba.positionScreen.y);D.setAttribute("x2",aa.positionScreen.x);D.setAttribute("y2",aa.positionScreen.y);if(P instanceof THREE.LineBasicMaterial){h.__styleString=P.color.__styleString;D.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+P.linewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.linecap+"; stroke-linejoin: "+P.linejoin);
|
|
|
+m.appendChild(D)}}}}else if(K instanceof THREE.RenderableFace3){v=K.v1;q=K.v2;z=K.v3;v.positionScreen.x*=o;v.positionScreen.y*=-y;q.positionScreen.x*=o;q.positionScreen.y*=-y;z.positionScreen.x*=o;z.positionScreen.y*=-y;f.addPoint(v.positionScreen.x,v.positionScreen.y);f.addPoint(q.positionScreen.x,q.positionScreen.y);f.addPoint(z.positionScreen.x,z.positionScreen.y);if(H.instersects(f)){R=0;for(O=K.meshMaterials.length;R<O;){P=K.meshMaterials[R++];if(P instanceof THREE.MeshFaceMaterial){ba=0;for(aa=
|
|
|
+K.faceMaterials.length;ba<aa;)(P=K.faceMaterials[ba++])&&c(v,q,z,K,P,Y)}else P&&c(v,q,z,K,P,Y)}}}else if(K instanceof THREE.RenderableFace4){v=K.v1;q=K.v2;z=K.v3;B=K.v4;v.positionScreen.x*=o;v.positionScreen.y*=-y;q.positionScreen.x*=o;q.positionScreen.y*=-y;z.positionScreen.x*=o;z.positionScreen.y*=-y;B.positionScreen.x*=o;B.positionScreen.y*=-y;f.addPoint(v.positionScreen.x,v.positionScreen.y);f.addPoint(q.positionScreen.x,q.positionScreen.y);f.addPoint(z.positionScreen.x,z.positionScreen.y);f.addPoint(B.positionScreen.x,
|
|
|
+B.positionScreen.y);if(H.instersects(f)){R=0;for(O=K.meshMaterials.length;R<O;){P=K.meshMaterials[R++];if(P instanceof THREE.MeshFaceMaterial){ba=0;for(aa=K.faceMaterials.length;ba<aa;)(P=K.faceMaterials[ba++])&&d(v,q,z,B,K,P,Y)}else P&&d(v,q,z,B,K,P,Y)}}}}}};
|
|
|
THREE.WebGLRenderer=function(a){function c(f,p){f.fragment_shader=p.fragment_shader;f.vertex_shader=p.vertex_shader;f.uniforms=Uniforms.clone(p.uniforms)}function d(f){if(f.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);f.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}function e(f,p){var h;if(f=="fragment")h=b.createShader(b.FRAGMENT_SHADER);else if(f=="vertex")h=b.createShader(b.VERTEX_SHADER);b.shaderSource(h,p);b.compileShader(h);if(!b.getShaderParameter(h,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(h));
|
|
|
return null}return h}function j(f){switch(f){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;
|
|
|
case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}
|
|
|
-var g=document.createElement("canvas"),b,m=null,k=null,n=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],o=new THREE.Matrix4,y=new Float32Array(16),u=new Float32Array(16),q=new THREE.Vector4,z=true,B=new THREE.Color(0),H=0;if(a){if(a.antialias!==undefined)z=a.antialias;a.clearColor!==undefined&&B.setHex(a.clearColor);if(a.clearAlpha!==undefined)H=a.clearAlpha}this.domElement=g;this.autoClear=true;(function(f,p,h){try{b=g.getContext("experimental-webgl",
|
|
|
+var g=document.createElement("canvas"),b,m=null,k=null,n=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],o=new THREE.Matrix4,y=new Float32Array(16),v=new Float32Array(16),q=new THREE.Vector4,z=true,B=new THREE.Color(0),H=0;if(a){if(a.antialias!==undefined)z=a.antialias;a.clearColor!==undefined&&B.setHex(a.clearColor);if(a.clearAlpha!==undefined)H=a.clearAlpha}this.domElement=g;this.autoClear=true;(function(f,p,h){try{b=g.getContext("experimental-webgl",
|
|
|
{antialias:f})}catch(l){console.log(l)}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(p.r,p.g,p.b,h)})(z,B,H);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,
|
|
|
-p){g.width=f;g.height=p;b.viewport(0,0,g.width,g.height)};this.setClearColorHex=function(f,p){var h=new THREE.Color(f);b.clearColor(h.r,h.g,h.b,p)};this.setClearColor=function(f,p){b.clearColor(f.r,f.g,f.b,p)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(f,p){var h,l,t,w=0,x=0,v=0,A,C,E,F=this.lights,D=F.directional.colors,I=F.directional.positions,T=F.point.colors,P=F.point.positions,X=0,Y=0;h=t=t=0;for(l=p.length;h<l;h++){t=p[h];A=t.color;C=t.position;
|
|
|
-E=t.intensity;if(t instanceof THREE.AmbientLight){w+=A.r;x+=A.g;v+=A.b}else if(t instanceof THREE.DirectionalLight){t=X*3;D[t]=A.r*E;D[t+1]=A.g*E;D[t+2]=A.b*E;I[t]=C.x;I[t+1]=C.y;I[t+2]=C.z;X+=1}else if(t instanceof THREE.PointLight){t=Y*3;T[t]=A.r*E;T[t+1]=A.g*E;T[t+2]=A.b*E;P[t]=C.x;P[t+1]=C.y;P[t+2]=C.z;Y+=1}}for(h=X*3;h<D.length;h++)D[h]=0;for(h=Y*3;h<T.length;h++)T[h]=0;F.point.length=Y;F.directional.length=X;F.ambient[0]=w;F.ambient[1]=x;F.ambient[2]=v};this.createParticleBuffers=function(f){f.__webGLVertexBuffer=
|
|
|
+p){g.width=f;g.height=p;b.viewport(0,0,g.width,g.height)};this.setClearColorHex=function(f,p){var h=new THREE.Color(f);b.clearColor(h.r,h.g,h.b,p)};this.setClearColor=function(f,p){b.clearColor(f.r,f.g,f.b,p)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(f,p){var h,l,t,w=0,x=0,u=0,A,C,E,F=this.lights,D=F.directional.colors,I=F.directional.positions,S=F.point.colors,N=F.point.positions,X=0,Y=0;h=t=t=0;for(l=p.length;h<l;h++){t=p[h];A=t.color;C=t.position;
|
|
|
+E=t.intensity;if(t instanceof THREE.AmbientLight){w+=A.r;x+=A.g;u+=A.b}else if(t instanceof THREE.DirectionalLight){t=X*3;D[t]=A.r*E;D[t+1]=A.g*E;D[t+2]=A.b*E;I[t]=C.x;I[t+1]=C.y;I[t+2]=C.z;X+=1}else if(t instanceof THREE.PointLight){t=Y*3;S[t]=A.r*E;S[t+1]=A.g*E;S[t+2]=A.b*E;N[t]=C.x;N[t+1]=C.y;N[t+2]=C.z;Y+=1}}for(h=X*3;h<D.length;h++)D[h]=0;for(h=Y*3;h<S.length;h++)S[h]=0;F.point.length=Y;F.directional.length=X;F.ambient[0]=w;F.ambient[1]=x;F.ambient[2]=u};this.createParticleBuffers=function(f){f.__webGLVertexBuffer=
|
|
|
b.createBuffer();f.__webGLColorBuffer=b.createBuffer();f.__webGLParticleBuffer=b.createBuffer()};this.createLineBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();f.__webGLColorBuffer=b.createBuffer();f.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();f.__webGLNormalBuffer=b.createBuffer();f.__webGLTangentBuffer=b.createBuffer();f.__webGLColorBuffer=b.createBuffer();f.__webGLUVBuffer=b.createBuffer();f.__webGLUV2Buffer=b.createBuffer();
|
|
|
f.__webGLFaceBuffer=b.createBuffer();f.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(f){var p=f.vertices.length;f.__vertexArray=new Float32Array(p*3);f.__colorArray=new Float32Array(p*3);f.__lineArray=new Uint16Array(p);f.__webGLLineCount=p};this.initParticleBuffers=function(f){var p=f.vertices.length;f.__vertexArray=new Float32Array(p*3);f.__colorArray=new Float32Array(p*3);f.__particleArray=new Uint16Array(p);f.__sortArray=[];f.__webGLParticleCount=p};this.initMeshBuffers=function(f,
|
|
|
-p){var h,l,t=0,w=0,x=0,v=p.geometry.faces,A=f.faces;h=0;for(l=A.length;h<l;h++){fi=A[h];face=v[fi];if(face instanceof THREE.Face3){t+=3;w+=1;x+=3}else if(face instanceof THREE.Face4){t+=4;w+=2;x+=4}}f.__vertexArray=new Float32Array(t*3);f.__normalArray=new Float32Array(t*3);f.__tangentArray=new Float32Array(t*4);f.__colorArray=new Float32Array(t*3);f.__uvArray=new Float32Array(t*2);f.__uv2Array=new Float32Array(t*2);f.__faceArray=new Uint16Array(w*3);f.__lineArray=new Uint16Array(x*2);t=false;h=0;
|
|
|
-for(l=p.materials.length;h<l;h++){v=p.materials[h];if(v instanceof THREE.MeshFaceMaterial){v=0;for(A=f.materials.length;v<A;v++)if(f.materials[v]&&f.materials[v].shading!=undefined&&f.materials[v].shading==THREE.SmoothShading){t=true;break}}else if(v&&v.shading!=undefined&&v.shading==THREE.SmoothShading){t=true;break}if(t)break}f.__needsSmoothNormals=t;f.__webGLFaceCount=w*3;f.__webGLLineCount=x*2};this.setMeshBuffers=function(f,p,h){var l,t,w,x,v,A,C,E,F,D,I=0,T=0,P=0,X=0,Y=0,S=0,V=0,da=0,R=0,N=
|
|
|
-f.__vertexArray,ba=f.__uvArray,aa=f.__uv2Array,K=f.__normalArray,O=f.__tangentArray,U=f.__colorArray,ha=f.__faceArray,ga=f.__lineArray,G=f.__needsSmoothNormals,J=p.geometry,L=J.__dirtyVertices,W=J.__dirtyElements,ca=J.__dirtyUvs,ma=J.__dirtyNormals,ia=J.__dirtyTangents,ra=J.__dirtyColors,la=J.vertices,wa=f.faces,ka=J.faces,sa=J.uvs,Ha=J.uvs2,qa=J.colors;p=0;for(l=wa.length;p<l;p++){t=wa[p];w=ka[t];A=sa[t];t=Ha[t];x=w.vertexNormals;v=w.normal;if(w instanceof THREE.Face3){if(L){C=la[w.a].position;E=
|
|
|
-la[w.b].position;F=la[w.c].position;N[T]=C.x;N[T+1]=C.y;N[T+2]=C.z;N[T+3]=E.x;N[T+4]=E.y;N[T+5]=E.z;N[T+6]=F.x;N[T+7]=F.y;N[T+8]=F.z;T+=9}if(ra&&qa.length){C=qa[w.a];E=qa[w.b];F=qa[w.c];U[R]=C.r;U[R+1]=C.g;U[R+2]=C.b;U[R+3]=E.r;U[R+4]=E.g;U[R+5]=E.b;U[R+6]=F.r;U[R+7]=F.g;U[R+8]=F.b;R+=9}if(ia&&J.hasTangents){C=la[w.a].tangent;E=la[w.b].tangent;F=la[w.c].tangent;O[V]=C.x;O[V+1]=C.y;O[V+2]=C.z;O[V+3]=C.w;O[V+4]=E.x;O[V+5]=E.y;O[V+6]=E.z;O[V+7]=E.w;O[V+8]=F.x;O[V+9]=F.y;O[V+10]=F.z;O[V+11]=F.w;V+=12}if(ma)if(x.length==
|
|
|
-3&&G)for(w=0;w<3;w++){v=x[w];K[S]=v.x;K[S+1]=v.y;K[S+2]=v.z;S+=3}else for(w=0;w<3;w++){K[S]=v.x;K[S+1]=v.y;K[S+2]=v.z;S+=3}if(ca&&A)for(w=0;w<3;w++){x=A[w];ba[P]=x.u;ba[P+1]=x.v;P+=2}if(ca&&t)for(w=0;w<3;w++){A=t[w];aa[X]=A.u;aa[X+1]=A.v;X+=2}if(W){ha[Y]=I;ha[Y+1]=I+1;ha[Y+2]=I+2;Y+=3;ga[da]=I;ga[da+1]=I+1;ga[da+2]=I;ga[da+3]=I+2;ga[da+4]=I+1;ga[da+5]=I+2;da+=6;I+=3}}else if(w instanceof THREE.Face4){if(L){C=la[w.a].position;E=la[w.b].position;F=la[w.c].position;D=la[w.d].position;N[T]=C.x;N[T+1]=
|
|
|
-C.y;N[T+2]=C.z;N[T+3]=E.x;N[T+4]=E.y;N[T+5]=E.z;N[T+6]=F.x;N[T+7]=F.y;N[T+8]=F.z;N[T+9]=D.x;N[T+10]=D.y;N[T+11]=D.z;T+=12}if(ra&&qa.length){C=qa[w.a];E=qa[w.b];F=qa[w.d];U[R]=C.r;U[R+1]=C.g;U[R+2]=C.b;U[R+3]=E.r;U[R+4]=E.g;U[R+5]=E.b;U[R+6]=F.r;U[R+7]=F.g;U[R+8]=F.b;U[R+9]=(void 0).r;U[R+10]=(void 0).g;U[R+11]=(void 0).b;R+=12}if(ia&&J.hasTangents){C=la[w.a].tangent;E=la[w.b].tangent;F=la[w.c].tangent;w=la[w.d].tangent;O[V]=C.x;O[V+1]=C.y;O[V+2]=C.z;O[V+3]=C.w;O[V+4]=E.x;O[V+5]=E.y;O[V+6]=E.z;O[V+
|
|
|
-7]=E.w;O[V+8]=F.x;O[V+9]=F.y;O[V+10]=F.z;O[V+11]=F.w;O[V+12]=w.x;O[V+13]=w.y;O[V+14]=w.z;O[V+15]=w.w;V+=16}if(ma)if(x.length==4&&G)for(w=0;w<4;w++){v=x[w];K[S]=v.x;K[S+1]=v.y;K[S+2]=v.z;S+=3}else for(w=0;w<4;w++){K[S]=v.x;K[S+1]=v.y;K[S+2]=v.z;S+=3}if(ca&&A)for(w=0;w<4;w++){x=A[w];ba[P]=x.u;ba[P+1]=x.v;P+=2}if(ca&&t)for(w=0;w<4;w++){A=t[w];aa[X]=A.u;aa[X+1]=A.v;X+=2}if(W){ha[Y]=I;ha[Y+1]=I+1;ha[Y+2]=I+2;ha[Y+3]=I;ha[Y+4]=I+2;ha[Y+5]=I+3;Y+=6;ga[da]=I;ga[da+1]=I+1;ga[da+2]=I;ga[da+3]=I+3;ga[da+4]=
|
|
|
-I+1;ga[da+5]=I+2;ga[da+6]=I+2;ga[da+7]=I+3;da+=8;I+=4}}}if(L){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,N,h)}if(ra&&qa.length){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,U,h)}if(ma){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,K,h)}if(ia&&J.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,O,h)}if(ca&&P>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUVBuffer);
|
|
|
-b.bufferData(b.ARRAY_BUFFER,ba,h)}if(ca&&X>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,aa,h)}if(W){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ha,h);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ga,h)}};this.setLineBuffers=function(f,p){var h,l,t,w=f.vertices,x=f.colors,v=w.length,A=x.length,C=f.__vertexArray,E=f.__colorArray,F=f.__lineArray,D=f.__dirtyColors,I=f.__dirtyElements;
|
|
|
-if(f.__dirtyVertices){for(h=0;h<v;h++){l=w[h].position;t=h*3;C[t]=l.x;C[t+1]=l.y;C[t+2]=l.z}b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,C,p)}if(D){for(h=0;h<A;h++){color=x[h];t=h*3;E[t]=color.r;E[t+1]=color.g;E[t+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,E,p)}if(I){for(h=0;h<v;h++)F[h]=h;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,F,p)}};this.setParticleBuffers=function(f,
|
|
|
-p,h){var l,t,w,x=f.vertices,v=x.length,A=f.colors,C=A.length,E=f.__vertexArray,F=f.__particleArray,D=f.__colorArray,I=f.__sortArray,T=f.__dirtyVertices,P=f.__dirtyElements,X=f.__dirtyColors;if(h.sortParticles){o.multiplySelf(h.matrix);for(l=0;l<v;l++){t=x[l].position;q.copy(t);o.multiplyVector3(q);I[l]=[q.z,l]}I.sort(function(Y,S){return S[0]-Y[0]});for(l=0;l<v;l++){t=x[I[l][1]].position;w=l*3;E[w]=t.x;E[w+1]=t.y;E[w+2]=t.z}for(l=0;l<C;l++){w=l*3;color=A[I[l][1]];D[w]=color.r;D[w+1]=color.g;D[w+2]=
|
|
|
-color.b}}else{if(T)for(l=0;l<v;l++){t=x[l].position;w=l*3;E[w]=t.x;E[w+1]=t.y;E[w+2]=t.z}if(X)for(l=0;l<C;l++){color=A[l];w=l*3;D[w]=color.r;D[w+1]=color.g;D[w+2]=color.b}}if(P){for(l=0;l<v;l++)F[l]=l;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,F,p)}if(T||h.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,E,p)}if(X||h.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,
|
|
|
+p){var h,l,t=0,w=0,x=0,u=p.geometry.faces,A=f.faces;h=0;for(l=A.length;h<l;h++){fi=A[h];face=u[fi];if(face instanceof THREE.Face3){t+=3;w+=1;x+=3}else if(face instanceof THREE.Face4){t+=4;w+=2;x+=4}}f.__vertexArray=new Float32Array(t*3);f.__normalArray=new Float32Array(t*3);f.__tangentArray=new Float32Array(t*4);f.__colorArray=new Float32Array(t*3);f.__uvArray=new Float32Array(t*2);f.__uv2Array=new Float32Array(t*2);f.__faceArray=new Uint16Array(w*3);f.__lineArray=new Uint16Array(x*2);t=false;h=0;
|
|
|
+for(l=p.materials.length;h<l;h++){u=p.materials[h];if(u instanceof THREE.MeshFaceMaterial){u=0;for(A=f.materials.length;u<A;u++)if(f.materials[u]&&f.materials[u].shading!=undefined&&f.materials[u].shading==THREE.SmoothShading){t=true;break}}else if(u&&u.shading!=undefined&&u.shading==THREE.SmoothShading){t=true;break}if(t)break}f.__needsSmoothNormals=t;f.__webGLFaceCount=w*3;f.__webGLLineCount=x*2};this.setMeshBuffers=function(f,p,h){var l,t,w,x,u,A,C,E,F,D,I=0,S=0,N=0,X=0,Y=0,T=0,V=0,da=0,R=0,O=
|
|
|
+f.__vertexArray,ba=f.__uvArray,aa=f.__uv2Array,K=f.__normalArray,P=f.__tangentArray,U=f.__colorArray,ha=f.__faceArray,ga=f.__lineArray,G=f.__needsSmoothNormals,J=p.geometry,L=J.__dirtyVertices,W=J.__dirtyElements,ca=J.__dirtyUvs,ma=J.__dirtyNormals,ia=J.__dirtyTangents,ra=J.__dirtyColors,la=J.vertices,wa=f.faces,ka=J.faces,sa=J.uvs,Ha=J.uvs2,qa=J.colors;p=0;for(l=wa.length;p<l;p++){t=wa[p];w=ka[t];A=sa[t];t=Ha[t];x=w.vertexNormals;u=w.normal;if(w instanceof THREE.Face3){if(L){C=la[w.a].position;E=
|
|
|
+la[w.b].position;F=la[w.c].position;O[S]=C.x;O[S+1]=C.y;O[S+2]=C.z;O[S+3]=E.x;O[S+4]=E.y;O[S+5]=E.z;O[S+6]=F.x;O[S+7]=F.y;O[S+8]=F.z;S+=9}if(ra&&qa.length){C=qa[w.a];E=qa[w.b];F=qa[w.c];U[R]=C.r;U[R+1]=C.g;U[R+2]=C.b;U[R+3]=E.r;U[R+4]=E.g;U[R+5]=E.b;U[R+6]=F.r;U[R+7]=F.g;U[R+8]=F.b;R+=9}if(ia&&J.hasTangents){C=la[w.a].tangent;E=la[w.b].tangent;F=la[w.c].tangent;P[V]=C.x;P[V+1]=C.y;P[V+2]=C.z;P[V+3]=C.w;P[V+4]=E.x;P[V+5]=E.y;P[V+6]=E.z;P[V+7]=E.w;P[V+8]=F.x;P[V+9]=F.y;P[V+10]=F.z;P[V+11]=F.w;V+=12}if(ma)if(x.length==
|
|
|
+3&&G)for(w=0;w<3;w++){u=x[w];K[T]=u.x;K[T+1]=u.y;K[T+2]=u.z;T+=3}else for(w=0;w<3;w++){K[T]=u.x;K[T+1]=u.y;K[T+2]=u.z;T+=3}if(ca&&A)for(w=0;w<3;w++){x=A[w];ba[N]=x.u;ba[N+1]=x.v;N+=2}if(ca&&t)for(w=0;w<3;w++){A=t[w];aa[X]=A.u;aa[X+1]=A.v;X+=2}if(W){ha[Y]=I;ha[Y+1]=I+1;ha[Y+2]=I+2;Y+=3;ga[da]=I;ga[da+1]=I+1;ga[da+2]=I;ga[da+3]=I+2;ga[da+4]=I+1;ga[da+5]=I+2;da+=6;I+=3}}else if(w instanceof THREE.Face4){if(L){C=la[w.a].position;E=la[w.b].position;F=la[w.c].position;D=la[w.d].position;O[S]=C.x;O[S+1]=
|
|
|
+C.y;O[S+2]=C.z;O[S+3]=E.x;O[S+4]=E.y;O[S+5]=E.z;O[S+6]=F.x;O[S+7]=F.y;O[S+8]=F.z;O[S+9]=D.x;O[S+10]=D.y;O[S+11]=D.z;S+=12}if(ra&&qa.length){C=qa[w.a];E=qa[w.b];F=qa[w.d];U[R]=C.r;U[R+1]=C.g;U[R+2]=C.b;U[R+3]=E.r;U[R+4]=E.g;U[R+5]=E.b;U[R+6]=F.r;U[R+7]=F.g;U[R+8]=F.b;U[R+9]=(void 0).r;U[R+10]=(void 0).g;U[R+11]=(void 0).b;R+=12}if(ia&&J.hasTangents){C=la[w.a].tangent;E=la[w.b].tangent;F=la[w.c].tangent;w=la[w.d].tangent;P[V]=C.x;P[V+1]=C.y;P[V+2]=C.z;P[V+3]=C.w;P[V+4]=E.x;P[V+5]=E.y;P[V+6]=E.z;P[V+
|
|
|
+7]=E.w;P[V+8]=F.x;P[V+9]=F.y;P[V+10]=F.z;P[V+11]=F.w;P[V+12]=w.x;P[V+13]=w.y;P[V+14]=w.z;P[V+15]=w.w;V+=16}if(ma)if(x.length==4&&G)for(w=0;w<4;w++){u=x[w];K[T]=u.x;K[T+1]=u.y;K[T+2]=u.z;T+=3}else for(w=0;w<4;w++){K[T]=u.x;K[T+1]=u.y;K[T+2]=u.z;T+=3}if(ca&&A)for(w=0;w<4;w++){x=A[w];ba[N]=x.u;ba[N+1]=x.v;N+=2}if(ca&&t)for(w=0;w<4;w++){A=t[w];aa[X]=A.u;aa[X+1]=A.v;X+=2}if(W){ha[Y]=I;ha[Y+1]=I+1;ha[Y+2]=I+2;ha[Y+3]=I;ha[Y+4]=I+2;ha[Y+5]=I+3;Y+=6;ga[da]=I;ga[da+1]=I+1;ga[da+2]=I;ga[da+3]=I+3;ga[da+4]=
|
|
|
+I+1;ga[da+5]=I+2;ga[da+6]=I+2;ga[da+7]=I+3;da+=8;I+=4}}}if(L){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,O,h)}if(ra&&qa.length){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,U,h)}if(ma){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,K,h)}if(ia&&J.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,P,h)}if(ca&&N>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUVBuffer);
|
|
|
+b.bufferData(b.ARRAY_BUFFER,ba,h)}if(ca&&X>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,aa,h)}if(W){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ha,h);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ga,h)}};this.setLineBuffers=function(f,p){var h,l,t,w=f.vertices,x=f.colors,u=w.length,A=x.length,C=f.__vertexArray,E=f.__colorArray,F=f.__lineArray,D=f.__dirtyColors,I=f.__dirtyElements;
|
|
|
+if(f.__dirtyVertices){for(h=0;h<u;h++){l=w[h].position;t=h*3;C[t]=l.x;C[t+1]=l.y;C[t+2]=l.z}b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,C,p)}if(D){for(h=0;h<A;h++){color=x[h];t=h*3;E[t]=color.r;E[t+1]=color.g;E[t+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,E,p)}if(I){for(h=0;h<u;h++)F[h]=h;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,F,p)}};this.setParticleBuffers=function(f,
|
|
|
+p,h){var l,t,w,x=f.vertices,u=x.length,A=f.colors,C=A.length,E=f.__vertexArray,F=f.__particleArray,D=f.__colorArray,I=f.__sortArray,S=f.__dirtyVertices,N=f.__dirtyElements,X=f.__dirtyColors;if(h.sortParticles){o.multiplySelf(h.matrix);for(l=0;l<u;l++){t=x[l].position;q.copy(t);o.multiplyVector3(q);I[l]=[q.z,l]}I.sort(function(Y,T){return T[0]-Y[0]});for(l=0;l<u;l++){t=x[I[l][1]].position;w=l*3;E[w]=t.x;E[w+1]=t.y;E[w+2]=t.z}for(l=0;l<C;l++){w=l*3;color=A[I[l][1]];D[w]=color.r;D[w+1]=color.g;D[w+2]=
|
|
|
+color.b}}else{if(S)for(l=0;l<u;l++){t=x[l].position;w=l*3;E[w]=t.x;E[w+1]=t.y;E[w+2]=t.z}if(X)for(l=0;l<C;l++){color=A[l];w=l*3;D[w]=color.r;D[w+1]=color.g;D[w+2]=color.b}}if(N){for(l=0;l<u;l++)F[l]=l;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,F,p)}if(S||h.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,E,p)}if(X||h.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,
|
|
|
D,p)}};this.initMaterial=function(f,p,h){if(!f.program){var l,t;if(f instanceof THREE.MeshDepthMaterial)c(f,THREE.ShaderLib.depth);else if(f instanceof THREE.MeshNormalMaterial)c(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)c(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)c(f,THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)c(f,THREE.ShaderLib.phong);else if(f instanceof THREE.LineBasicMaterial)c(f,THREE.ShaderLib.basic);else f instanceof
|
|
|
-THREE.ParticleBasicMaterial&&c(f,THREE.ShaderLib.particle_basic);var w,x,v,A;t=v=A=0;for(w=p.length;t<w;t++){x=p[t];x instanceof THREE.DirectionalLight&&v++;x instanceof THREE.PointLight&&A++}if(A+v<=4){p=v;A=A}else{p=Math.ceil(4*v/(A+v));A=4-p}t={directional:p,point:A};A=f.fragment_shader;p=f.vertex_shader;w={fog:h,map:f.map,env_map:f.env_map,light_map:f.light_map,vertex_colors:f.vertex_colors,maxDirLights:t.directional,maxPointLights:t.point};h=b.createProgram();t=["#ifdef GL_ES\nprecision highp float;\n#endif",
|
|
|
+THREE.ParticleBasicMaterial&&c(f,THREE.ShaderLib.particle_basic);var w,x,u,A;t=u=A=0;for(w=p.length;t<w;t++){x=p[t];x instanceof THREE.DirectionalLight&&u++;x instanceof THREE.PointLight&&A++}if(A+u<=4){p=u;A=A}else{p=Math.ceil(4*u/(A+u));A=4-p}t={directional:p,point:A};A=f.fragment_shader;p=f.vertex_shader;w={fog:h,map:f.map,env_map:f.env_map,light_map:f.light_map,vertex_colors:f.vertex_colors,maxDirLights:t.directional,maxPointLights:t.point};h=b.createProgram();t=["#ifdef GL_ES\nprecision highp float;\n#endif",
|
|
|
"#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+w.maxPointLights,w.fog?"#define USE_FOG":"",w.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",w.map?"#define USE_MAP":"",w.env_map?"#define USE_ENVMAP":"",w.light_map?"#define USE_LIGHTMAP":"",w.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");w=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+
|
|
|
w.maxPointLights,w.map?"#define USE_MAP":"",w.env_map?"#define USE_ENVMAP":"",w.light_map?"#define USE_LIGHTMAP":"",w.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(h,e("fragment",t+A));b.attachShader(h,
|
|
|
e("vertex",w+p));b.linkProgram(h);b.getProgramParameter(h,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(h,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");h.uniforms={};h.attributes={};f.program=h;h=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(l in f.uniforms)h.push(l);l=f.program;A=0;for(p=h.length;A<p;A++){t=h[A];l.uniforms[t]=b.getUniformLocation(l,t)}f=f.program;l=["position","normal",
|
|
@@ -187,24 +189,24 @@ b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(p=0;p<6;++p)b.texImage2D(b.TEXT
|
|
|
p,h,l,w).attributes;b.bindBuffer(b.ARRAY_BUFFER,t.__webGLVertexBuffer);b.vertexAttribPointer(f.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.position);if(f.color>=0){b.bindBuffer(b.ARRAY_BUFFER,t.__webGLColorBuffer);b.vertexAttribPointer(f.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.color)}if(f.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,t.__webGLNormalBuffer);b.vertexAttribPointer(f.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.normal)}if(f.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,
|
|
|
t.__webGLTangentBuffer);b.vertexAttribPointer(f.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.tangent)}if(f.uv>=0)if(t.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,t.__webGLUVBuffer);b.vertexAttribPointer(f.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.uv)}else b.disableVertexAttribArray(f.uv);if(f.uv2>=0)if(t.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,t.__webGLUV2Buffer);b.vertexAttribPointer(f.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.uv2)}else b.disableVertexAttribArray(f.uv2);
|
|
|
if(l.wireframe||l instanceof THREE.LineBasicMaterial){f=l.wireframe_linewidth!==undefined?l.wireframe_linewidth:l.linewidth!==undefined?l.linewidth:1;l=l instanceof THREE.LineBasicMaterial&&w.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(f);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,t.__webGLLineBuffer);b.drawElements(l,t.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(l instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,t.__webGLParticleBuffer);b.drawElements(b.POINTS,t.__webGLParticleCount,
|
|
|
-b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,t.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,t.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(f,p,h,l,t,w,x){var v,A,C,E,F;C=0;for(E=l.materials.length;C<E;C++){v=l.materials[C];if(v instanceof THREE.MeshFaceMaterial){v=0;for(A=t.materials.length;v<A;v++)if((F=t.materials[v])&&F.blending==w&&F.opacity<1==x){this.setBlending(F.blending);this.setDepthTest(F.depth_test);this.renderBuffer(f,p,h,F,t,l)}}else if((F=v)&&F.blending==
|
|
|
-w&&F.opacity<1==x){this.setBlending(F.blending);this.setDepthTest(F.depth_test);this.renderBuffer(f,p,h,F,t,l)}}};this.renderPassImmediate=function(f,p,h,l,t,w){var x,v,A,C;x=0;for(v=l.materials.length;x<v;x++)if((A=l.materials[x])&&A.blending==t&&A.opacity<1==w){this.setBlending(A.blending);this.setDepthTest(A.depth_test);C=this.setProgram(f,p,h,A,l);l.render(function(E){var F=C;if(!E.__webGLVertexBuffer)E.__webGLVertexBuffer=b.createBuffer();if(!E.__webGLNormalBuffer)E.__webGLNormalBuffer=b.createBuffer();
|
|
|
+b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,t.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,t.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(f,p,h,l,t,w,x){var u,A,C,E,F;C=0;for(E=l.materials.length;C<E;C++){u=l.materials[C];if(u instanceof THREE.MeshFaceMaterial){u=0;for(A=t.materials.length;u<A;u++)if((F=t.materials[u])&&F.blending==w&&F.opacity<1==x){this.setBlending(F.blending);this.setDepthTest(F.depth_test);this.renderBuffer(f,p,h,F,t,l)}}else if((F=u)&&F.blending==
|
|
|
+w&&F.opacity<1==x){this.setBlending(F.blending);this.setDepthTest(F.depth_test);this.renderBuffer(f,p,h,F,t,l)}}};this.renderPassImmediate=function(f,p,h,l,t,w){var x,u,A,C;x=0;for(u=l.materials.length;x<u;x++)if((A=l.materials[x])&&A.blending==t&&A.opacity<1==w){this.setBlending(A.blending);this.setDepthTest(A.depth_test);C=this.setProgram(f,p,h,A,l);l.render(function(E){var F=C;if(!E.__webGLVertexBuffer)E.__webGLVertexBuffer=b.createBuffer();if(!E.__webGLNormalBuffer)E.__webGLNormalBuffer=b.createBuffer();
|
|
|
if(E.hasPos){b.bindBuffer(b.ARRAY_BUFFER,E.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,E.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(F.attributes.position);b.vertexAttribPointer(F.attributes.position,3,b.FLOAT,false,0,0)}if(E.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,E.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,E.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(F.attributes.normal);b.vertexAttribPointer(F.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,E.count);
|
|
|
-E.count=0})}};this.render=function(f,p,h,l){var t,w,x,v,A=f.lights,C=f.fog;p.autoUpdateMatrix&&p.updateMatrix();u.set(p.matrix.flatten());y.set(p.projectionMatrix.flatten());o.multiply(p.projectionMatrix,p.matrix);n[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);n[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);n[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);n[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);n[4].set(o.n41-o.n31,o.n42-o.n32,o.n43-o.n33,o.n44-o.n34);
|
|
|
-n[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(t=0;t<5;t++){v=n[t];v.divideScalar(Math.sqrt(v.x*v.x+v.y*v.y+v.z*v.z))}this.initWebGLObjects(f,p);l=l!==undefined?l:true;if(h&&!h.__webGLFramebuffer){h.__webGLFramebuffer=b.createFramebuffer();h.__webGLRenderbuffer=b.createRenderbuffer();h.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,h.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,h.width,h.height);b.bindTexture(b.TEXTURE_2D,h.__webGLTexture);
|
|
|
+E.count=0})}};this.render=function(f,p,h,l){var t,w,x,u,A=f.lights,C=f.fog;p.autoUpdateMatrix&&p.updateMatrix();v.set(p.matrix.flatten());y.set(p.projectionMatrix.flatten());o.multiply(p.projectionMatrix,p.matrix);n[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);n[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);n[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);n[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);n[4].set(o.n41-o.n31,o.n42-o.n32,o.n43-o.n33,o.n44-o.n34);
|
|
|
+n[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(t=0;t<5;t++){u=n[t];u.divideScalar(Math.sqrt(u.x*u.x+u.y*u.y+u.z*u.z))}this.initWebGLObjects(f,p);l=l!==undefined?l:true;if(h&&!h.__webGLFramebuffer){h.__webGLFramebuffer=b.createFramebuffer();h.__webGLRenderbuffer=b.createRenderbuffer();h.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,h.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,h.width,h.height);b.bindTexture(b.TEXTURE_2D,h.__webGLTexture);
|
|
|
b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,j(h.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,j(h.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,j(h.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,j(h.min_filter));b.texImage2D(b.TEXTURE_2D,0,j(h.format),h.width,h.height,0,j(h.format),j(h.type),null);b.bindFramebuffer(b.FRAMEBUFFER,h.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,h.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,
|
|
|
-b.DEPTH_ATTACHMENT,b.RENDERBUFFER,h.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(h){t=h.__webGLFramebuffer;v=h.width;x=h.height}else{t=null;v=g.width;x=g.height}if(t!=k){b.bindFramebuffer(b.FRAMEBUFFER,t);b.viewport(0,0,v,x);l&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);k=t}this.autoClear&&this.clear();t=f.__webGLObjects.length;for(l=0;l<t;l++){x=f.__webGLObjects[l];v=x.object;if(w=v.visible){if(!(w=!(v instanceof
|
|
|
-THREE.Mesh)))a:{w=void 0;for(var E=v.matrix,F=-v.geometry.boundingSphere.radius*Math.max(v.scale.x,Math.max(v.scale.y,v.scale.z)),D=0;D<6;D++){w=n[D].x*E.n14+n[D].y*E.n24+n[D].z*E.n34+n[D].w;if(w<=F){w=false;break a}}w=true}w=w}if(w){v.autoUpdateMatrix&&v.updateMatrix();this.setupMatrices(v,p);x.render=true}else x.render=false}w=f.__webGLObjectsImmediate.length;for(l=0;l<w;l++){v=f.__webGLObjectsImmediate[l].object;if(v.visible){v.autoUpdateMatrix&&v.updateMatrix();this.setupMatrices(v,p)}}for(l=
|
|
|
-0;l<t;l++){x=f.__webGLObjects[l];if(x.render){v=x.object;x=x.buffer;d(v);this.renderPass(p,A,C,v,x,THREE.NormalBlending,false)}}for(l=0;l<w;l++){v=f.__webGLObjectsImmediate[l].object;if(v.visible){d(v);this.renderPassImmediate(p,A,C,v,THREE.NormalBlending,false)}}for(l=0;l<t;l++){x=f.__webGLObjects[l];if(x.render){v=x.object;x=x.buffer;d(v);this.renderPass(p,A,C,v,x,THREE.AdditiveBlending,false);this.renderPass(p,A,C,v,x,THREE.SubtractiveBlending,false);this.renderPass(p,A,C,v,x,THREE.AdditiveBlending,
|
|
|
-true);this.renderPass(p,A,C,v,x,THREE.SubtractiveBlending,true);this.renderPass(p,A,C,v,x,THREE.NormalBlending,true);this.renderPass(p,A,C,v,x,THREE.BillboardBlending,false)}}for(l=0;l<w;l++){v=f.__webGLObjectsImmediate[l].object;if(v.visible){d(v);this.renderPassImmediate(p,A,C,v,THREE.NormalBlending,true)}}if(h&&h.min_filter!==THREE.NearestFilter&&h.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,h.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=
|
|
|
-function(f,p){function h(F,D,I,T){if(F[D]==undefined){f.__webGLObjects.push({buffer:I,object:T});F[D]=1}}function l(F,D,I){if(F[D]==undefined){f.__webGLObjectsImmediate.push({object:I});F[D]=1}}var t,w,x,v,A,C,E;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={};f.__webGLObjectsImmediate=[]}t=0;for(w=f.objects.length;t<w;t++){x=f.objects[t];A=x.geometry;if(f.__webGLObjectsMap[x.id]==undefined){f.__webGLObjectsMap[x.id]={};x._modelViewMatrix=new THREE.Matrix4;x._normalMatrixArray=new Float32Array(9);
|
|
|
-x._modelViewMatrixArray=new Float32Array(16);x._objectMatrixArray=new Float32Array(16)}E=f.__webGLObjectsMap[x.id];if(x instanceof THREE.Mesh){for(v in A.geometryChunks){C=A.geometryChunks[v];if(!C.__webGLVertexBuffer){this.createMeshBuffers(C);this.initMeshBuffers(C,x);A.__dirtyVertices=true;A.__dirtyElements=true;A.__dirtyUvs=true;A.__dirtyNormals=true;A.__dirtyTangents=true;A.__dirtyColors=true}if(A.__dirtyVertices||A.__dirtyElements||A.__dirtyUvs||A.__dirtyNormals||A.__dirtyColors||A.__dirtyTangents)this.setMeshBuffers(C,
|
|
|
-x,b.DYNAMIC_DRAW);h(E,v,C,x)}A.__dirtyVertices=false;A.__dirtyElements=false;A.__dirtyUvs=false;A.__dirtyNormals=false;A.__dirtyTangents=false;A.__dirtyColors=false}else if(x instanceof THREE.Line){if(!A.__webGLVertexBuffer){this.createLineBuffers(A);this.initLineBuffers(A);A.__dirtyVertices=true;A.__dirtyElements=true;A.__dirtyColors=true}if(A.__dirtyVertices||A.__dirtyColors)this.setLineBuffers(A,b.DYNAMIC_DRAW);h(E,0,A,x);A.__dirtyVertices=false;A.__dirtyElements=false;A.__dirtyColors=false}else if(x instanceof
|
|
|
-THREE.ParticleSystem){if(!A.__webGLVertexBuffer){this.createParticleBuffers(A);this.initParticleBuffers(A);A.__dirtyVertices=true;A.__dirtyColors=true;A.__dirtyElements=true}if(A.__dirtyVertices||A.__dirtyColors||x.sortParticles)this.setParticleBuffers(A,b.DYNAMIC_DRAW,x,p);h(E,0,A,x);A.__dirtyVertices=false;A.__dirtyColors=false;A.__dirtyElements=false}else x instanceof THREE.MarchingCubes&&l(E,0,x)}};this.removeObject=function(f,p){var h,l;for(h=f.__webGLObjects.length-1;h>=0;h--){l=f.__webGLObjects[h].object;
|
|
|
-p==l&&f.__webGLObjects.splice(h,1)}};this.setupMatrices=function(f,p){f._modelViewMatrix.multiply(p.matrix,f.matrix);f._modelViewMatrixArray.set(f._modelViewMatrix.flatten());f._normalMatrix=THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transpose();f._normalMatrixArray.set(f._normalMatrix.m);f._objectMatrixArray.set(f.matrix.flatten())};this.loadMatrices=function(f,p){b.uniformMatrix4fv(f.uniforms.viewMatrix,false,u);b.uniformMatrix4fv(f.uniforms.projectionMatrix,false,y);b.uniformMatrix4fv(f.uniforms.modelViewMatrix,
|
|
|
-false,p._modelViewMatrixArray);b.uniformMatrix3fv(f.uniforms.normalMatrix,false,p._normalMatrixArray);b.uniformMatrix4fv(f.uniforms.objectMatrix,false,p._objectMatrixArray)};this.loadCamera=function(f,p){b.uniform3f(f.uniforms.cameraPosition,p.position.x,p.position.y,p.position.z)};this.setDepthTest=function(f){f?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};this.setBlending=function(f){switch(f){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,
|
|
|
-b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(f,p){if(f){!p||p=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(f=="back")b.cullFace(b.BACK);else f=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
|
|
|
-0}};
|
|
|
+b.DEPTH_ATTACHMENT,b.RENDERBUFFER,h.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(h){t=h.__webGLFramebuffer;u=h.width;x=h.height}else{t=null;u=g.width;x=g.height}if(t!=k){b.bindFramebuffer(b.FRAMEBUFFER,t);b.viewport(0,0,u,x);l&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);k=t}this.autoClear&&this.clear();t=f.__webGLObjects.length;for(l=0;l<t;l++){x=f.__webGLObjects[l];u=x.object;if(w=u.visible){if(!(w=!(u instanceof
|
|
|
+THREE.Mesh)))a:{w=void 0;for(var E=u.matrix,F=-u.geometry.boundingSphere.radius*Math.max(u.scale.x,Math.max(u.scale.y,u.scale.z)),D=0;D<6;D++){w=n[D].x*E.n14+n[D].y*E.n24+n[D].z*E.n34+n[D].w;if(w<=F){w=false;break a}}w=true}w=w}if(w){if(u.autoUpdateMatrix){u.updateMatrix();u._objectMatrixArray.set(u.matrix.flatten())}this.setupMatrices(u,p);x.render=true}else x.render=false}w=f.__webGLObjectsImmediate.length;for(l=0;l<w;l++){u=f.__webGLObjectsImmediate[l].object;if(u.visible){if(u.autoUpdateMatrix){u.updateMatrix();
|
|
|
+u._objectMatrixArray.set(u.matrix.flatten())}this.setupMatrices(u,p)}}for(l=0;l<t;l++){x=f.__webGLObjects[l];if(x.render){u=x.object;x=x.buffer;d(u);this.renderPass(p,A,C,u,x,THREE.NormalBlending,false)}}for(l=0;l<w;l++){u=f.__webGLObjectsImmediate[l].object;if(u.visible){d(u);this.renderPassImmediate(p,A,C,u,THREE.NormalBlending,false)}}for(l=0;l<t;l++){x=f.__webGLObjects[l];if(x.render){u=x.object;x=x.buffer;d(u);this.renderPass(p,A,C,u,x,THREE.AdditiveBlending,false);this.renderPass(p,A,C,u,x,
|
|
|
+THREE.SubtractiveBlending,false);this.renderPass(p,A,C,u,x,THREE.AdditiveBlending,true);this.renderPass(p,A,C,u,x,THREE.SubtractiveBlending,true);this.renderPass(p,A,C,u,x,THREE.NormalBlending,true);this.renderPass(p,A,C,u,x,THREE.BillboardBlending,false)}}for(l=0;l<w;l++){u=f.__webGLObjectsImmediate[l].object;if(u.visible){d(u);this.renderPassImmediate(p,A,C,u,THREE.NormalBlending,true)}}if(h&&h.min_filter!==THREE.NearestFilter&&h.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,h.__webGLTexture);
|
|
|
+b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(f,p){function h(F,D,I,S){if(F[D]==undefined){f.__webGLObjects.push({buffer:I,object:S});F[D]=1}}function l(F,D,I){if(F[D]==undefined){f.__webGLObjectsImmediate.push({object:I});F[D]=1}}var t,w,x,u,A,C,E;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={};f.__webGLObjectsImmediate=[]}t=0;for(w=f.objects.length;t<w;t++){x=f.objects[t];A=x.geometry;if(f.__webGLObjectsMap[x.id]==undefined){f.__webGLObjectsMap[x.id]=
|
|
|
+{};x._modelViewMatrix=new THREE.Matrix4;x._normalMatrixArray=new Float32Array(9);x._modelViewMatrixArray=new Float32Array(16);x._objectMatrixArray=new Float32Array(16);x._objectMatrixArray.set(x.matrix.flatten())}E=f.__webGLObjectsMap[x.id];if(x instanceof THREE.Mesh){for(u in A.geometryChunks){C=A.geometryChunks[u];if(!C.__webGLVertexBuffer){this.createMeshBuffers(C);this.initMeshBuffers(C,x);A.__dirtyVertices=true;A.__dirtyElements=true;A.__dirtyUvs=true;A.__dirtyNormals=true;A.__dirtyTangents=
|
|
|
+true;A.__dirtyColors=true}if(A.__dirtyVertices||A.__dirtyElements||A.__dirtyUvs||A.__dirtyNormals||A.__dirtyColors||A.__dirtyTangents)this.setMeshBuffers(C,x,b.DYNAMIC_DRAW);h(E,u,C,x)}A.__dirtyVertices=false;A.__dirtyElements=false;A.__dirtyUvs=false;A.__dirtyNormals=false;A.__dirtyTangents=false;A.__dirtyColors=false}else if(x instanceof THREE.Line){if(!A.__webGLVertexBuffer){this.createLineBuffers(A);this.initLineBuffers(A);A.__dirtyVertices=true;A.__dirtyElements=true;A.__dirtyColors=true}if(A.__dirtyVertices||
|
|
|
+A.__dirtyColors)this.setLineBuffers(A,b.DYNAMIC_DRAW);h(E,0,A,x);A.__dirtyVertices=false;A.__dirtyElements=false;A.__dirtyColors=false}else if(x instanceof THREE.ParticleSystem){if(!A.__webGLVertexBuffer){this.createParticleBuffers(A);this.initParticleBuffers(A);A.__dirtyVertices=true;A.__dirtyColors=true;A.__dirtyElements=true}if(A.__dirtyVertices||A.__dirtyColors||x.sortParticles)this.setParticleBuffers(A,b.DYNAMIC_DRAW,x,p);h(E,0,A,x);A.__dirtyVertices=false;A.__dirtyColors=false;A.__dirtyElements=
|
|
|
+false}else x instanceof THREE.MarchingCubes&&l(E,0,x)}};this.removeObject=function(f,p){var h,l;for(h=f.__webGLObjects.length-1;h>=0;h--){l=f.__webGLObjects[h].object;p==l&&f.__webGLObjects.splice(h,1)}};this.setupMatrices=function(f,p){f._modelViewMatrix.multiplyToArray(p.matrix,f.matrix,f._modelViewMatrixArray);f._normalMatrix=THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)};this.loadMatrices=function(f,p){b.uniformMatrix4fv(f.uniforms.viewMatrix,false,v);
|
|
|
+b.uniformMatrix4fv(f.uniforms.projectionMatrix,false,y);b.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,p._modelViewMatrixArray);b.uniformMatrix3fv(f.uniforms.normalMatrix,false,p._normalMatrixArray);b.uniformMatrix4fv(f.uniforms.objectMatrix,false,p._objectMatrixArray)};this.loadCamera=function(f,p){b.uniform3f(f.uniforms.cameraPosition,p.position.x,p.position.y,p.position.z)};this.setDepthTest=function(f){f?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};this.setBlending=function(f){switch(f){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);
|
|
|
+b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(f,p){if(f){!p||p=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(f=="back")b.cullFace(b.BACK);else f=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};
|
|
|
+this.supportsVertexTextures=function(){return b.getParameter(b.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, gl_FragColor.w ), 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\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\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",
|
|
|
map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",
|
|
@@ -227,15 +229,15 @@ THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,"void main()
|
|
|
"void main() {",THREE.Snippets.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\ngl_PointSize = size;\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,c){var d=c instanceof THREE.Mesh,e=a.vertices.length,j=d?c.geometry:c,g=a.vertices,b=j.vertices,m=a.faces,k=j.faces,n=a.uvs;j=j.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var o=0,y=b.length;o<y;o++){var u=new THREE.Vertex(b[o].position.clone());d&&c.matrix.multiplyVector3(u.position);g.push(u)}o=0;for(y=k.length;o<y;o++){b=k[o];var q,z=b.vertexNormals;if(b instanceof THREE.Face3)q=new THREE.Face3(b.a+e,b.b+e,b.c+e);else if(b instanceof THREE.Face4)q=new THREE.Face4(b.a+
|
|
|
-e,b.b+e,b.c+e,b.d+e);q.centroid.copy(b.centroid);q.normal.copy(b.normal);d=0;for(g=z.length;d<g;d++){u=z[d];q.vertexNormals.push(u.clone())}q.materials=b.materials.slice();m.push(q)}o=0;for(y=j.length;o<y;o++){e=j[o];m=[];d=0;for(g=e.length;d<g;d++)m.push(new THREE.UV(e[d].u,e[d].v));n.push(m)}}},ImageUtils={loadTexture:function(a,c,d){var e=new Image;e.onload=function(){this.loaded=true;d&&d(this)};e.src=a;return new THREE.Texture(e,c)},loadArray:function(a,c){var d,e,j=[];d=j.loadCount=0;for(e=
|
|
|
+var GeometryUtils={merge:function(a,c){var d=c instanceof THREE.Mesh,e=a.vertices.length,j=d?c.geometry:c,g=a.vertices,b=j.vertices,m=a.faces,k=j.faces,n=a.uvs;j=j.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var o=0,y=b.length;o<y;o++){var v=new THREE.Vertex(b[o].position.clone());d&&c.matrix.multiplyVector3(v.position);g.push(v)}o=0;for(y=k.length;o<y;o++){b=k[o];var q,z=b.vertexNormals;if(b instanceof THREE.Face3)q=new THREE.Face3(b.a+e,b.b+e,b.c+e);else if(b instanceof THREE.Face4)q=new THREE.Face4(b.a+
|
|
|
+e,b.b+e,b.c+e,b.d+e);q.centroid.copy(b.centroid);q.normal.copy(b.normal);d=0;for(g=z.length;d<g;d++){v=z[d];q.vertexNormals.push(v.clone())}q.materials=b.materials.slice();m.push(q)}o=0;for(y=j.length;o<y;o++){e=j[o];m=[];d=0;for(g=e.length;d<g;d++)m.push(new THREE.UV(e[d].u,e[d].v));n.push(m)}}},ImageUtils={loadTexture:function(a,c,d){var e=new Image;e.onload=function(){this.loaded=true;d&&d(this)};e.src=a;return new THREE.Texture(e,c)},loadArray:function(a,c){var d,e,j=[];d=j.loadCount=0;for(e=
|
|
|
a.length;d<e;++d){j[d]=new Image;j[d].loaded=0;j[d].onload=function(){j.loadCount+=1;this.loaded=true;c&&c(this)};j[d].src=a[d]}return j}},SceneUtils={loadScene:function(a,c,d,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(j){function g(){for(o in x.objects)if(!D.objects[o]){B=x.objects[o];if(h=D.geometries[B.geometry]){w=[];for(i=0;i<B.materials.length;i++)w[i]=D.materials[B.materials[i]];H=B.position;r=B.rotation;s=B.scale;object=new THREE.Mesh(h,w);object.position.set(H[0],H[1],H[2]);
|
|
|
-object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=B.visible;D.scene.addObject(object);D.objects[o]=object}}}function b(I){return function(T){D.geometries[I]=T;g();A-=1;m()}}function m(){e({total_models:E,total_textures:F,loaded_models:E-A,loaded_textures:F-C},D);A==0&&C==0&&d(D)}var k,n,o,y,u,q,z,B,H,f,p,h,l,t,w,x,v,A,C,E,F,D;x=j.data;v=new THREE.Loader;C=A=0;D={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
|
|
|
-j=function(){C-=1;m()};for(u in x.cameras){f=x.cameras[u];if(f.type=="perspective")l=new THREE.Camera(f.fov,f.aspect,f.near,f.far);else if(f.type=="ortho"){l=new THREE.Camera;l.projectionMatrix=THREE.Matrix4.makeOrtho(f.left,f.right,f.top,f.bottom,f.near,f.far)}H=f.position;f=f.target;l.position.set(H[0],H[1],H[2]);l.target.position.set(f[0],f[1],f[2]);D.cameras[u]=l}for(y in x.lights){u=x.lights[y];if(u.type=="directional"){H=u.direction;light=new THREE.DirectionalLight;light.position.set(H[0],H[1],
|
|
|
-H[2]);light.position.normalize()}else if(u.type=="point"){H=u.position;light=new THREE.PointLight;light.position.set(H[0],H[1],H[2])}f=u.color;i=u.intensity||1;light.color.setRGB(f[0]*i,f[1]*i,f[2]*i);D.scene.addLight(light);D.lights[y]=light}for(q in x.fogs){y=x.fogs[q];if(y.type=="linear")t=new THREE.Fog(0,y.near,y.far);else if(y.type=="exp2")t=new THREE.FogExp2(0,y.density);f=y.color;t.color.setRGB(f[0],f[1],f[2]);D.fogs[q]=t}if(D.cameras&&x.defaults.camera)D.currentCamera=D.cameras[x.defaults.camera];
|
|
|
+object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=B.visible;D.scene.addObject(object);D.objects[o]=object}}}function b(I){return function(S){D.geometries[I]=S;g();A-=1;m()}}function m(){e({total_models:E,total_textures:F,loaded_models:E-A,loaded_textures:F-C},D);A==0&&C==0&&d(D)}var k,n,o,y,v,q,z,B,H,f,p,h,l,t,w,x,u,A,C,E,F,D;x=j.data;u=new THREE.Loader;C=A=0;D={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
|
|
|
+j=function(){C-=1;m()};for(v in x.cameras){f=x.cameras[v];if(f.type=="perspective")l=new THREE.Camera(f.fov,f.aspect,f.near,f.far);else if(f.type=="ortho"){l=new THREE.Camera;l.projectionMatrix=THREE.Matrix4.makeOrtho(f.left,f.right,f.top,f.bottom,f.near,f.far)}H=f.position;f=f.target;l.position.set(H[0],H[1],H[2]);l.target.position.set(f[0],f[1],f[2]);D.cameras[v]=l}for(y in x.lights){v=x.lights[y];if(v.type=="directional"){H=v.direction;light=new THREE.DirectionalLight;light.position.set(H[0],H[1],
|
|
|
+H[2]);light.position.normalize()}else if(v.type=="point"){H=v.position;light=new THREE.PointLight;light.position.set(H[0],H[1],H[2])}f=v.color;i=v.intensity||1;light.color.setRGB(f[0]*i,f[1]*i,f[2]*i);D.scene.addLight(light);D.lights[y]=light}for(q in x.fogs){y=x.fogs[q];if(y.type=="linear")t=new THREE.Fog(0,y.near,y.far);else if(y.type=="exp2")t=new THREE.FogExp2(0,y.density);f=y.color;t.color.setRGB(f[0],f[1],f[2]);D.fogs[q]=t}if(D.cameras&&x.defaults.camera)D.currentCamera=D.cameras[x.defaults.camera];
|
|
|
if(D.fogs&&x.defaults.fog)D.scene.fog=D.fogs[x.defaults.fog];f=x.defaults.bgcolor;D.bgColor=new THREE.Color;D.bgColor.setRGB(f[0],f[1],f[2]);D.bgColorAlpha=x.defaults.bgalpha;for(k in x.geometries){q=x.geometries[k];if(q.type=="bin_mesh"||q.type=="ascii_mesh")A+=1}E=A;for(k in x.geometries){q=x.geometries[k];if(q.type=="cube"){h=new Cube(q.width,q.height,q.depth,q.segments_width,q.segments_height,null,q.flipped,q.sides);D.geometries[k]=h}else if(q.type=="plane"){h=new Plane(q.width,q.height,q.segments_width,
|
|
|
-q.segments_height);D.geometries[k]=h}else if(q.type=="sphere"){h=new Sphere(q.radius,q.segments_width,q.segments_height);D.geometries[k]=h}else if(q.type=="cylinder"){h=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);D.geometries[k]=h}else if(q.type=="torus"){h=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);D.geometries[k]=h}else if(q.type=="icosahedron"){h=new Icosahedron(q.subdivisions);D.geometries[k]=h}else if(q.type=="bin_mesh")v.loadBinary({model:q.url,callback:b(k)});
|
|
|
-else q.type=="ascii_mesh"&&v.loadAscii({model:q.url,callback:b(k)})}for(z in x.textures){k=x.textures[z];C+=k.url instanceof Array?k.url.length:1}F=C;for(z in x.textures){k=x.textures[z];if(k.mapping!=undefined&&THREE[k.mapping]!=undefined)k.mapping=new THREE[k.mapping];if(k.url instanceof Array){q=ImageUtils.loadArray(k.url,j);q=new THREE.Texture(q,k.mapping)}else{q=ImageUtils.loadTexture(k.url,k.mapping,j);if(THREE[k.min_filter]!=undefined)q.min_filter=THREE[k.min_filter];if(THREE[k.mag_filter]!=
|
|
|
+q.segments_height);D.geometries[k]=h}else if(q.type=="sphere"){h=new Sphere(q.radius,q.segments_width,q.segments_height);D.geometries[k]=h}else if(q.type=="cylinder"){h=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);D.geometries[k]=h}else if(q.type=="torus"){h=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);D.geometries[k]=h}else if(q.type=="icosahedron"){h=new Icosahedron(q.subdivisions);D.geometries[k]=h}else if(q.type=="bin_mesh")u.loadBinary({model:q.url,callback:b(k)});
|
|
|
+else q.type=="ascii_mesh"&&u.loadAscii({model:q.url,callback:b(k)})}for(z in x.textures){k=x.textures[z];C+=k.url instanceof Array?k.url.length:1}F=C;for(z in x.textures){k=x.textures[z];if(k.mapping!=undefined&&THREE[k.mapping]!=undefined)k.mapping=new THREE[k.mapping];if(k.url instanceof Array){q=ImageUtils.loadArray(k.url,j);q=new THREE.Texture(q,k.mapping)}else{q=ImageUtils.loadTexture(k.url,k.mapping,j);if(THREE[k.min_filter]!=undefined)q.min_filter=THREE[k.min_filter];if(THREE[k.mag_filter]!=
|
|
|
undefined)q.mag_filter=THREE[k.mag_filter]}D.textures[z]=q}for(n in x.materials){z=x.materials[n];for(p in z.parameters)if(p=="env_map"||p=="map"||p=="light_map")z.parameters[p]=D.textures[z.parameters[p]];else if(p=="shading")z.parameters[p]=z.parameters[p]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(p=="blending")z.parameters[p]=THREE[z.parameters[p]]?THREE[z.parameters[p]]:THREE.NormalBlending;else if(p=="combine")z.parameters[p]=z.parameters[p]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
|
|
|
z=new THREE[z.type](z.parameters);D.materials[n]=z}g();c(D)}},addMesh:function(a,c,d,e,j,g,b,m,k,n){c=new THREE.Mesh(c,n);c.scale.x=c.scale.y=c.scale.z=d;c.position.x=e;c.position.y=j;c.position.z=g;c.rotation.x=b;c.rotation.y=m;c.rotation.z=k;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,d){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=d;d=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,uniforms:e.uniforms});c=new THREE.Mesh(new Cube(c,
|
|
|
c,c,1,1,null,true),d);a.addObject(c);return c},addPanoramaCube:function(a,c,d){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));c=new THREE.Mesh(new Cube(c,
|
|
@@ -249,21 +251,21 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying ve
|
|
|
value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertex_shader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
|
|
|
film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},grayscale:{type:"i",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nconst float fNintensity = 0.35;\nconst float fSintensity = 0.35;\nconst float fScount = 4096.0;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time * 1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin(vUv.y * fScount), cos(vUv.y * fScount) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * fSintensity;\ncResult = cTextureScreen.rgb + clamp( fNintensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor = vec4( cResult, cTextureScreen.a );\n}"},
|
|
|
screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\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}"}},buildKernel:function(a){var c,d,e,j,g=2*Math.ceil(a*3)+1;if(g>25)g=25;j=(g-1)*0.5;d=Array(g);for(c=e=0;c<g;++c){d[c]=Math.exp(-((c-j)*(c-j))/(2*a*a));e+=d[c]}for(c=0;c<g;++c)d[c]/=e;return d}},Cube=function(a,c,d,e,j,g,b,m){function k(B,H,f,p,h,l,t,w){var x,v,A=e||1,C=j||1,E=A+1,F=C+1,D=h/2,I=l/2;h=h/A;var T=l/C,P=n.vertices.length;if(B=="x"&&H=="y"||B=="y"&&H=="x")x="z";else if(B=="x"&&H=="z"||B=="z"&&H=="x")x="y";else if(B==
|
|
|
-"z"&&H=="y"||B=="y"&&H=="z")x="x";for(v=0;v<F;v++)for(l=0;l<E;l++){var X=new THREE.Vector3;X[B]=(l*h-D)*f;X[H]=(v*T-I)*p;X[x]=t;n.vertices.push(new THREE.Vertex(X))}for(v=0;v<C;v++)for(l=0;l<A;l++){n.faces.push(new THREE.Face4(l+E*v+P,l+E*(v+1)+P,l+1+E*(v+1)+P,l+1+E*v+P,null,w));n.uvs.push([new THREE.UV(l/A,v/C),new THREE.UV(l/A,(v+1)/C),new THREE.UV((l+1)/A,(v+1)/C),new THREE.UV((l+1)/A,v/C)])}}THREE.Geometry.call(this);var n=this,o=a/2,y=c/2,u=d/2;b=b?-1:1;if(g!==undefined)if(g instanceof Array)this.materials=
|
|
|
-g;else{this.materials=[];for(var q=0;q<6;q++)this.materials.push([g])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(m!=undefined)for(var z in m)if(this.sides[z]!=undefined)this.sides[z]=m[z];this.sides.px&&k("z","y",1*b,-1,d,c,-o,this.materials[0]);this.sides.nx&&k("z","y",-1*b,-1,d,c,o,this.materials[1]);this.sides.py&&k("x","z",1*b,1,a,d,y,this.materials[2]);this.sides.ny&&k("x","z",1*b,-1,a,d,-y,this.materials[3]);this.sides.pz&&k("x","y",1*b,-1,a,c,u,this.materials[4]);
|
|
|
-this.sides.nz&&k("x","y",-1*b,-1,a,c,-u,this.materials[5]);(function(){for(var B=[],H=[],f=0,p=n.vertices.length;f<p;f++){for(var h=n.vertices[f],l=false,t=0,w=B.length;t<w;t++){var x=B[t];if(h.position.x==x.position.x&&h.position.y==x.position.y&&h.position.z==x.position.z){H[f]=t;l=true;break}}if(!l){H[f]=B.length;B.push(new THREE.Vertex(h.position.clone()))}}f=0;for(p=n.faces.length;f<p;f++){h=n.faces[f];h.a=H[h.a];h.b=H[h.b];h.c=H[h.c];h.d=H[h.d]}n.vertices=B})();this.computeCentroids();this.computeFaceNormals();
|
|
|
+fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,d,e,j,g=2*Math.ceil(a*3)+1;if(g>25)g=25;j=(g-1)*0.5;d=Array(g);for(c=e=0;c<g;++c){d[c]=Math.exp(-((c-j)*(c-j))/(2*a*a));e+=d[c]}for(c=0;c<g;++c)d[c]/=e;return d}},Cube=function(a,c,d,e,j,g,b,m){function k(B,H,f,p,h,l,t,w){var x,u,A=e||1,C=j||1,E=A+1,F=C+1,D=h/2,I=l/2;h=h/A;var S=l/C,N=n.vertices.length;if(B=="x"&&H=="y"||B=="y"&&H=="x")x="z";else if(B=="x"&&H=="z"||B=="z"&&H=="x")x="y";else if(B==
|
|
|
+"z"&&H=="y"||B=="y"&&H=="z")x="x";for(u=0;u<F;u++)for(l=0;l<E;l++){var X=new THREE.Vector3;X[B]=(l*h-D)*f;X[H]=(u*S-I)*p;X[x]=t;n.vertices.push(new THREE.Vertex(X))}for(u=0;u<C;u++)for(l=0;l<A;l++){n.faces.push(new THREE.Face4(l+E*u+N,l+E*(u+1)+N,l+1+E*(u+1)+N,l+1+E*u+N,null,w));n.uvs.push([new THREE.UV(l/A,u/C),new THREE.UV(l/A,(u+1)/C),new THREE.UV((l+1)/A,(u+1)/C),new THREE.UV((l+1)/A,u/C)])}}THREE.Geometry.call(this);var n=this,o=a/2,y=c/2,v=d/2;b=b?-1:1;if(g!==undefined)if(g instanceof Array)this.materials=
|
|
|
+g;else{this.materials=[];for(var q=0;q<6;q++)this.materials.push([g])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(m!=undefined)for(var z in m)if(this.sides[z]!=undefined)this.sides[z]=m[z];this.sides.px&&k("z","y",1*b,-1,d,c,-o,this.materials[0]);this.sides.nx&&k("z","y",-1*b,-1,d,c,o,this.materials[1]);this.sides.py&&k("x","z",1*b,1,a,d,y,this.materials[2]);this.sides.ny&&k("x","z",1*b,-1,a,d,-y,this.materials[3]);this.sides.pz&&k("x","y",1*b,-1,a,c,v,this.materials[4]);
|
|
|
+this.sides.nz&&k("x","y",-1*b,-1,a,c,-v,this.materials[5]);(function(){for(var B=[],H=[],f=0,p=n.vertices.length;f<p;f++){for(var h=n.vertices[f],l=false,t=0,w=B.length;t<w;t++){var x=B[t];if(h.position.x==x.position.x&&h.position.y==x.position.y&&h.position.z==x.position.z){H[f]=t;l=true;break}}if(!l){H[f]=B.length;B.push(new THREE.Vertex(h.position.clone()))}}f=0;for(p=n.faces.length;f<p;f++){h=n.faces[f];h.a=H[h.a];h.b=H[h.b];h.c=H[h.c];h.d=H[h.d]}n.vertices=B})();this.computeCentroids();this.computeFaceNormals();
|
|
|
this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
|
|
|
var Cylinder=function(a,c,d,e,j){function g(n,o,y){b.vertices.push(new THREE.Vertex(new THREE.Vector3(n,o,y)))}THREE.Geometry.call(this);var b=this,m=Math.PI,k;for(k=0;k<a;k++)g(Math.sin(2*m*k/a)*c,Math.cos(2*m*k/a)*c,0);for(k=0;k<a;k++)g(Math.sin(2*m*k/a)*d,Math.cos(2*m*k/a)*d,e);for(k=0;k<a;k++)b.faces.push(new THREE.Face4(k,k+a,a+(k+1)%a,(k+1)%a));if(d!=0){g(0,0,-j);for(k=a;k<a+a/2;k++)b.faces.push(new THREE.Face4(2*a,(2*k-2*a)%a,(2*k-2*a+1)%a,(2*k-2*a+2)%a))}if(c!=0){g(0,0,e+j);for(k=a+a/2;k<
|
|
|
2*a;k++)b.faces.push(new THREE.Face4((2*k-2*a+2)%a+a,(2*k-2*a+1)%a+a,(2*k-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
|
|
|
var Plane=function(a,c,d,e){THREE.Geometry.call(this);var j,g=a/2,b=c/2;d=d||1;e=e||1;var m=d+1,k=e+1;a=a/d;var n=c/e;for(j=0;j<k;j++)for(c=0;c<m;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-g,-(j*n-b),0)));for(j=0;j<e;j++)for(c=0;c<d;c++){this.faces.push(new THREE.Face4(c+m*j,c+m*(j+1),c+1+m*(j+1),c+1+m*j));this.uvs.push([new THREE.UV(c/d,j/e),new THREE.UV(c/d,(j+1)/e),new THREE.UV((c+1)/d,(j+1)/e),new THREE.UV((c+1)/d,j/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
|
|
|
Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
|
|
|
-var Sphere=function(a,c,d){THREE.Geometry.call(this);var e,j=Math.PI,g=Math.max(3,c||8),b=Math.max(2,d||6);c=[];for(d=0;d<b+1;d++){e=d/b;var m=a*Math.cos(e*j),k=a*Math.sin(e*j),n=[],o=0;for(e=0;e<g;e++){var y=2*e/g,u=k*Math.sin(y*j);y=k*Math.cos(y*j);(d==0||d==b)&&e>0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,m,u)))-1);n.push(o)}c.push(n)}var q,z,B;j=c.length;for(d=0;d<j;d++){g=c[d].length;if(d>0)for(e=0;e<g;e++){n=e==g-1;b=c[d][n?0:e+1];m=c[d][n?g-1:e];k=c[d-1][n?g-1:e];n=c[d-1][n?
|
|
|
-0:e+1];u=d/(j-1);q=(d-1)/(j-1);z=(e+1)/g;y=e/g;o=new THREE.UV(1-z,u);u=new THREE.UV(1-y,u);y=new THREE.UV(1-y,q);var H=new THREE.UV(1-z,q);if(d<c.length-1){q=this.vertices[b].position.clone();z=this.vertices[m].position.clone();B=this.vertices[k].position.clone();q.normalize();z.normalize();B.normalize();this.faces.push(new THREE.Face3(b,m,k,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(B.x,B.y,B.z)]));this.uvs.push([o,u,y])}if(d>1){q=this.vertices[b].position.clone();
|
|
|
+var Sphere=function(a,c,d){THREE.Geometry.call(this);var e,j=Math.PI,g=Math.max(3,c||8),b=Math.max(2,d||6);c=[];for(d=0;d<b+1;d++){e=d/b;var m=a*Math.cos(e*j),k=a*Math.sin(e*j),n=[],o=0;for(e=0;e<g;e++){var y=2*e/g,v=k*Math.sin(y*j);y=k*Math.cos(y*j);(d==0||d==b)&&e>0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,m,v)))-1);n.push(o)}c.push(n)}var q,z,B;j=c.length;for(d=0;d<j;d++){g=c[d].length;if(d>0)for(e=0;e<g;e++){n=e==g-1;b=c[d][n?0:e+1];m=c[d][n?g-1:e];k=c[d-1][n?g-1:e];n=c[d-1][n?
|
|
|
+0:e+1];v=d/(j-1);q=(d-1)/(j-1);z=(e+1)/g;y=e/g;o=new THREE.UV(1-z,v);v=new THREE.UV(1-y,v);y=new THREE.UV(1-y,q);var H=new THREE.UV(1-z,q);if(d<c.length-1){q=this.vertices[b].position.clone();z=this.vertices[m].position.clone();B=this.vertices[k].position.clone();q.normalize();z.normalize();B.normalize();this.faces.push(new THREE.Face3(b,m,k,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(B.x,B.y,B.z)]));this.uvs.push([o,v,y])}if(d>1){q=this.vertices[b].position.clone();
|
|
|
z=this.vertices[k].position.clone();B=this.vertices[n].position.clone();q.normalize();z.normalize();B.normalize();this.faces.push(new THREE.Face3(b,k,n,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(B.x,B.y,B.z)]));this.uvs.push([o,y,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,c,d,e){this.radius=a||100;this.tube=c||40;this.segmentsR=d||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(d=0;d<=this.segmentsT;++d){e=d/this.segmentsT*2*Math.PI;var j=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(j))*Math.cos(e),(this.radius+this.tube*Math.cos(j))*Math.sin(e),this.tube*Math.sin(j))));a.push([d/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(d=
|
|
|
1;d<=this.segmentsT;++d){e=(this.segmentsT+1)*c+d;j=(this.segmentsT+1)*c+d-1;var g=(this.segmentsT+1)*(c-1)+d-1,b=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,j,g,b));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[j][0],a[j][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[b][0],a[b][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 c(y,u,q){var z=Math.sqrt(y*y+u*u+q*q);return j.vertices.push(new THREE.Vertex(new THREE.Vector3(y/z,u/z,q/z)))-1}function d(y,u,q,z){z.faces.push(new THREE.Face3(y,u,q))}function e(y,u){var q=j.vertices[y].position,z=j.vertices[u].position;return c((q.x+z.x)/2,(q.y+z.y)/2,(q.z+z.z)/2)}var j=this,g=new THREE.Geometry,b;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
|
|
|
+var Icosahedron=function(a){function c(y,v,q){var z=Math.sqrt(y*y+v*v+q*q);return j.vertices.push(new THREE.Vertex(new THREE.Vector3(y/z,v/z,q/z)))-1}function d(y,v,q,z){z.faces.push(new THREE.Face3(y,v,q))}function e(y,v){var q=j.vertices[y].position,z=j.vertices[v].position;return c((q.x+z.x)/2,(q.y+z.y)/2,(q.z+z.z)/2)}var j=this,g=new THREE.Geometry,b;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
|
|
|
1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);d(0,11,5,g);d(0,5,1,g);d(0,1,7,g);d(0,7,10,g);d(0,10,11,g);d(1,5,9,g);d(5,11,4,g);d(11,10,2,g);d(10,7,6,g);d(7,1,8,g);d(3,9,4,g);d(3,4,2,g);d(3,2,6,g);d(3,6,8,g);d(3,8,9,g);d(4,9,5,g);d(2,4,11,g);d(6,2,10,g);d(8,6,7,g);d(9,8,1,g);for(a=0;a<this.subdivisions;a++){b=new THREE.Geometry;for(var m in g.faces){var k=e(g.faces[m].a,g.faces[m].b),n=e(g.faces[m].b,g.faces[m].c),o=e(g.faces[m].c,g.faces[m].a);d(g.faces[m].a,k,o,b);d(g.faces[m].b,n,k,b);d(g.faces[m].c,
|
|
|
o,n,b);d(k,n,o,b)}g.faces=b.faces}j.faces=g.faces;delete g;delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
|
|
|
function LathedObject(a,c,d){THREE.Geometry.call(this);c=c||12;d=d||2*Math.PI;c=d/c;for(var e=[],j=[],g=[],b=[],m=0;m<a.length;m++){this.vertices.push(new THREE.Vertex(a[m]));j[m]=this.vertices.length-1;e[m]=new THREE.Vector3(a[m].x,a[m].y,a[m].z)}for(var k=THREE.Matrix4.rotationZMatrix(c),n=0;n<=d+0.0010;n+=c){for(m=0;m<e.length;m++)if(n<d){e[m]=k.multiplyVector3(e[m].clone());this.vertices.push(new THREE.Vertex(e[m]));g[m]=this.vertices.length-1}else g=b;if(n==0)b=j;for(m=0;m<j.length-1;m++){this.faces.push(new THREE.Face4(g[m],
|
|
@@ -271,16 +273,16 @@ g[m+1],j[m+1],j[m]));this.uvs.push([new THREE.UV(n/d,m/a.length),new THREE.UV(n/
|
|
|
THREE.MarchingCubes=function(a,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(d){this.isolation=80;this.size=d;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=true;this.maxCount=4096;this.count=
|
|
|
0;this.hasNormal=this.hasPos=false;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(d,e,j){return d+(e-d)*j};this.VIntX=function(d,e,j,g,b,m,k,n,o,y){b=(b-o)/(y-o);o=this.normal_cache;e[g]=m+b*this.delta;e[g+1]=k;e[g+2]=n;j[g]=this.lerp(o[d],o[d+3],b);j[g+1]=this.lerp(o[d+1],o[d+4],b);j[g+2]=this.lerp(o[d+2],o[d+5],b)};this.VIntY=function(d,e,j,g,b,m,k,n,o,y){b=(b-o)/(y-o);o=this.normal_cache;e[g]=m;e[g+1]=k+b*this.delta;e[g+
|
|
|
2]=n;e=d+this.yd*3;j[g]=this.lerp(o[d],o[e],b);j[g+1]=this.lerp(o[d+1],o[e+1],b);j[g+2]=this.lerp(o[d+2],o[e+2],b)};this.VIntZ=function(d,e,j,g,b,m,k,n,o,y){b=(b-o)/(y-o);o=this.normal_cache;e[g]=m;e[g+1]=k;e[g+2]=n+b*this.delta;e=d+this.zd*3;j[g]=this.lerp(o[d],o[e],b);j[g+1]=this.lerp(o[d+1],o[e+1],b);j[g+2]=this.lerp(o[d+2],o[e+2],b)};this.compNorm=function(d){var e=d*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[d-1]-this.field[d+1];this.normal_cache[e+1]=this.field[d-this.yd]-
|
|
|
-this.field[d+this.yd];this.normal_cache[e+2]=this.field[d-this.zd]-this.field[d+this.zd]}};this.polygonize=function(d,e,j,g,b,m){var k=g+1,n=g+this.yd,o=g+this.zd,y=k+this.yd,u=k+this.zd,q=g+this.yd+this.zd,z=k+this.yd+this.zd,B=0,H=this.field[g],f=this.field[k],p=this.field[n],h=this.field[y],l=this.field[o],t=this.field[u],w=this.field[q],x=this.field[z];if(H<b)B|=1;if(f<b)B|=2;if(p<b)B|=8;if(h<b)B|=4;if(l<b)B|=16;if(t<b)B|=32;if(w<b)B|=128;if(x<b)B|=64;var v=THREE.edgeTable[B];if(v==0)return 0;
|
|
|
-var A=this.delta,C=d+A,E=e+A;A=j+A;if(v&1){this.compNorm(g);this.compNorm(k);this.VIntX(g*3,this.vlist,this.nlist,0,b,d,e,j,H,f)}if(v&2){this.compNorm(k);this.compNorm(y);this.VIntY(k*3,this.vlist,this.nlist,3,b,C,e,j,f,h)}if(v&4){this.compNorm(n);this.compNorm(y);this.VIntX(n*3,this.vlist,this.nlist,6,b,d,E,j,p,h)}if(v&8){this.compNorm(g);this.compNorm(n);this.VIntY(g*3,this.vlist,this.nlist,9,b,d,e,j,H,p)}if(v&16){this.compNorm(o);this.compNorm(u);this.VIntX(o*3,this.vlist,this.nlist,12,b,d,e,A,
|
|
|
-l,t)}if(v&32){this.compNorm(u);this.compNorm(z);this.VIntY(u*3,this.vlist,this.nlist,15,b,C,e,A,t,x)}if(v&64){this.compNorm(q);this.compNorm(z);this.VIntX(q*3,this.vlist,this.nlist,18,b,d,E,A,w,x)}if(v&128){this.compNorm(o);this.compNorm(q);this.VIntY(o*3,this.vlist,this.nlist,21,b,d,e,A,l,w)}if(v&256){this.compNorm(g);this.compNorm(o);this.VIntZ(g*3,this.vlist,this.nlist,24,b,d,e,j,H,l)}if(v&512){this.compNorm(k);this.compNorm(u);this.VIntZ(k*3,this.vlist,this.nlist,27,b,C,e,j,f,t)}if(v&1024){this.compNorm(y);
|
|
|
-this.compNorm(z);this.VIntZ(y*3,this.vlist,this.nlist,30,b,C,E,j,h,x)}if(v&2048){this.compNorm(n);this.compNorm(q);this.VIntZ(n*3,this.vlist,this.nlist,33,b,d,E,j,p,w)}B<<=4;for(b=g=0;THREE.triTable[B+b]!=-1;){d=B+b;e=d+1;j=d+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[d],3*THREE.triTable[e],3*THREE.triTable[j],m);b+=3;g++}return g};this.posnormtriv=function(d,e,j,g,b,m){var k=this.count*3;this.positionArray[k]=d[j];this.positionArray[k+1]=d[j+1];this.positionArray[k+2]=d[j+2];this.positionArray[k+
|
|
|
+this.field[d+this.yd];this.normal_cache[e+2]=this.field[d-this.zd]-this.field[d+this.zd]}};this.polygonize=function(d,e,j,g,b,m){var k=g+1,n=g+this.yd,o=g+this.zd,y=k+this.yd,v=k+this.zd,q=g+this.yd+this.zd,z=k+this.yd+this.zd,B=0,H=this.field[g],f=this.field[k],p=this.field[n],h=this.field[y],l=this.field[o],t=this.field[v],w=this.field[q],x=this.field[z];if(H<b)B|=1;if(f<b)B|=2;if(p<b)B|=8;if(h<b)B|=4;if(l<b)B|=16;if(t<b)B|=32;if(w<b)B|=128;if(x<b)B|=64;var u=THREE.edgeTable[B];if(u==0)return 0;
|
|
|
+var A=this.delta,C=d+A,E=e+A;A=j+A;if(u&1){this.compNorm(g);this.compNorm(k);this.VIntX(g*3,this.vlist,this.nlist,0,b,d,e,j,H,f)}if(u&2){this.compNorm(k);this.compNorm(y);this.VIntY(k*3,this.vlist,this.nlist,3,b,C,e,j,f,h)}if(u&4){this.compNorm(n);this.compNorm(y);this.VIntX(n*3,this.vlist,this.nlist,6,b,d,E,j,p,h)}if(u&8){this.compNorm(g);this.compNorm(n);this.VIntY(g*3,this.vlist,this.nlist,9,b,d,e,j,H,p)}if(u&16){this.compNorm(o);this.compNorm(v);this.VIntX(o*3,this.vlist,this.nlist,12,b,d,e,A,
|
|
|
+l,t)}if(u&32){this.compNorm(v);this.compNorm(z);this.VIntY(v*3,this.vlist,this.nlist,15,b,C,e,A,t,x)}if(u&64){this.compNorm(q);this.compNorm(z);this.VIntX(q*3,this.vlist,this.nlist,18,b,d,E,A,w,x)}if(u&128){this.compNorm(o);this.compNorm(q);this.VIntY(o*3,this.vlist,this.nlist,21,b,d,e,A,l,w)}if(u&256){this.compNorm(g);this.compNorm(o);this.VIntZ(g*3,this.vlist,this.nlist,24,b,d,e,j,H,l)}if(u&512){this.compNorm(k);this.compNorm(v);this.VIntZ(k*3,this.vlist,this.nlist,27,b,C,e,j,f,t)}if(u&1024){this.compNorm(y);
|
|
|
+this.compNorm(z);this.VIntZ(y*3,this.vlist,this.nlist,30,b,C,E,j,h,x)}if(u&2048){this.compNorm(n);this.compNorm(q);this.VIntZ(n*3,this.vlist,this.nlist,33,b,d,E,j,p,w)}B<<=4;for(b=g=0;THREE.triTable[B+b]!=-1;){d=B+b;e=d+1;j=d+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[d],3*THREE.triTable[e],3*THREE.triTable[j],m);b+=3;g++}return g};this.posnormtriv=function(d,e,j,g,b,m){var k=this.count*3;this.positionArray[k]=d[j];this.positionArray[k+1]=d[j+1];this.positionArray[k+2]=d[j+2];this.positionArray[k+
|
|
|
3]=d[g];this.positionArray[k+4]=d[g+1];this.positionArray[k+5]=d[g+2];this.positionArray[k+6]=d[b];this.positionArray[k+7]=d[b+1];this.positionArray[k+8]=d[b+2];this.normalArray[k]=e[j];this.normalArray[k+1]=e[j+1];this.normalArray[k+2]=e[j+2];this.normalArray[k+3]=e[g];this.normalArray[k+4]=e[g+1];this.normalArray[k+5]=e[g+2];this.normalArray[k+6]=e[b];this.normalArray[k+7]=e[b+1];this.normalArray[k+8]=e[b+2];this.hasNormal=this.hasPos=true;this.count+=3;this.count>=this.maxCount-3&&m(this)};this.begin=
|
|
|
-function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(d){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;d(this)}};this.addBall=function(d,e,j,g,b){var m=this.size*Math.sqrt(g/b),k=j*this.size,n=e*this.size,o=d*this.size,y=Math.floor(k-m);if(y<1)y=1;k=Math.floor(k+m);if(k>this.size-1)k=this.size-1;var u=Math.floor(n-m);if(u<1)u=1;n=Math.floor(n+m);if(n>this.size-1)n=this.size-1;var q=Math.floor(o-m);if(q<1)q=1;m=Math.floor(o+m);
|
|
|
-if(m>this.size-1)m=this.size-1;var z,B,H,f,p,h;for(y=y;y<k;y++){o=this.size2*y;B=y/this.size-j;p=B*B;for(B=u;B<n;B++){H=o+this.size*B;z=B/this.size-e;h=z*z;for(z=q;z<m;z++){f=z/this.size-d;f=g/(1.0E-6+f*f+h+p)-b;if(f>0)this.field[H+z]+=f}}}};this.addPlaneX=function(d,e){var j,g,b,m,k,n=this.size,o=this.yd,y=this.zd,u=this.field,q=n*Math.sqrt(d/e);if(q>n)q=n;for(j=0;j<q;j++){g=j/n;g=g*g;m=d/(1.0E-4+g)-e;if(m>0)for(g=0;g<n;g++){k=j+g*o;for(b=0;b<n;b++)u[y*b+k]+=m}}};this.addPlaneY=function(d,e){var j,
|
|
|
-g,b,m,k,n,o=this.size,y=this.yd,u=this.zd,q=this.field,z=o*Math.sqrt(d/e);if(z>o)z=o;for(g=0;g<z;g++){j=g/o;j=j*j;m=d/(1.0E-4+j)-e;if(m>0){k=g*y;for(j=0;j<o;j++){n=k+j;for(b=0;b<o;b++)q[u*b+n]+=m}}}};this.addPlaneZ=function(d,e){var j,g,b,m,k,n;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(d/e);if(dist>size)dist=size;for(b=0;b<dist;b++){j=b/size;j=j*j;m=d/(1.0E-4+j)-e;if(m>0){k=zd*b;for(g=0;g<size;g++){n=k+g*yd;for(j=0;j<size;j++)field[n+j]+=m}}}};this.reset=function(){var d;
|
|
|
-for(d=0;d<this.size3;d++){this.normal_cache[d*3]=0;this.field[d]=0}};this.render=function(d){this.begin();var e,j,g,b,m,k,n,o,y,u=this.size-2;for(b=1;b<u;b++){y=this.size2*b;n=(b-this.halfsize)/this.halfsize;for(g=1;g<u;g++){o=y+this.size*g;k=(g-this.halfsize)/this.halfsize;for(j=1;j<u;j++){m=(j-this.halfsize)/this.halfsize;e=o+j;this.polygonize(m,k,n,e,this.isolation,d)}}}this.end(d)};this.generateGeometry=function(){var d=0,e=new THREE.Geometry;this.render(function(j){var g,b,m,k,n,o,y,u;for(g=
|
|
|
-0;g<j.count;g++){n=g*3;y=n+1;u=n+2;b=j.positionArray[n];m=j.positionArray[y];k=j.positionArray[u];o=new THREE.Vector3(b,m,k);b=j.normalArray[n];m=j.normalArray[y];k=j.normalArray[u];n=new THREE.Vector3(b,m,k);n.normalize();n=new THREE.Vertex(o,n);e.vertices.push(n)}nfaces=j.count/3;for(g=0;g<nfaces;g++){n=(d+g)*3;y=n+1;u=n+2;o=e.vertices[n].normal;b=e.vertices[y].normal;m=e.vertices[u].normal;n=new THREE.Face3(n,y,u,[o,b,m]);e.faces.push(n)}d+=nfaces;j.count=0});e.sortFacesByMaterial();return e};
|
|
|
+function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(d){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;d(this)}};this.addBall=function(d,e,j,g,b){var m=this.size*Math.sqrt(g/b),k=j*this.size,n=e*this.size,o=d*this.size,y=Math.floor(k-m);if(y<1)y=1;k=Math.floor(k+m);if(k>this.size-1)k=this.size-1;var v=Math.floor(n-m);if(v<1)v=1;n=Math.floor(n+m);if(n>this.size-1)n=this.size-1;var q=Math.floor(o-m);if(q<1)q=1;m=Math.floor(o+m);
|
|
|
+if(m>this.size-1)m=this.size-1;var z,B,H,f,p,h;for(y=y;y<k;y++){o=this.size2*y;B=y/this.size-j;p=B*B;for(B=v;B<n;B++){H=o+this.size*B;z=B/this.size-e;h=z*z;for(z=q;z<m;z++){f=z/this.size-d;f=g/(1.0E-6+f*f+h+p)-b;if(f>0)this.field[H+z]+=f}}}};this.addPlaneX=function(d,e){var j,g,b,m,k,n=this.size,o=this.yd,y=this.zd,v=this.field,q=n*Math.sqrt(d/e);if(q>n)q=n;for(j=0;j<q;j++){g=j/n;g=g*g;m=d/(1.0E-4+g)-e;if(m>0)for(g=0;g<n;g++){k=j+g*o;for(b=0;b<n;b++)v[y*b+k]+=m}}};this.addPlaneY=function(d,e){var j,
|
|
|
+g,b,m,k,n,o=this.size,y=this.yd,v=this.zd,q=this.field,z=o*Math.sqrt(d/e);if(z>o)z=o;for(g=0;g<z;g++){j=g/o;j=j*j;m=d/(1.0E-4+j)-e;if(m>0){k=g*y;for(j=0;j<o;j++){n=k+j;for(b=0;b<o;b++)q[v*b+n]+=m}}}};this.addPlaneZ=function(d,e){var j,g,b,m,k,n;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(d/e);if(dist>size)dist=size;for(b=0;b<dist;b++){j=b/size;j=j*j;m=d/(1.0E-4+j)-e;if(m>0){k=zd*b;for(g=0;g<size;g++){n=k+g*yd;for(j=0;j<size;j++)field[n+j]+=m}}}};this.reset=function(){var d;
|
|
|
+for(d=0;d<this.size3;d++){this.normal_cache[d*3]=0;this.field[d]=0}};this.render=function(d){this.begin();var e,j,g,b,m,k,n,o,y,v=this.size-2;for(b=1;b<v;b++){y=this.size2*b;n=(b-this.halfsize)/this.halfsize;for(g=1;g<v;g++){o=y+this.size*g;k=(g-this.halfsize)/this.halfsize;for(j=1;j<v;j++){m=(j-this.halfsize)/this.halfsize;e=o+j;this.polygonize(m,k,n,e,this.isolation,d)}}}this.end(d)};this.generateGeometry=function(){var d=0,e=new THREE.Geometry;this.render(function(j){var g,b,m,k,n,o,y,v;for(g=
|
|
|
+0;g<j.count;g++){n=g*3;y=n+1;v=n+2;b=j.positionArray[n];m=j.positionArray[y];k=j.positionArray[v];o=new THREE.Vector3(b,m,k);b=j.normalArray[n];m=j.normalArray[y];k=j.normalArray[v];n=new THREE.Vector3(b,m,k);n.normalize();n=new THREE.Vertex(o,n);e.vertices.push(n)}nfaces=j.count/3;for(g=0;g<nfaces;g++){n=(d+g)*3;y=n+1;v=n+2;o=e.vertices[n].normal;b=e.vertices[y].normal;m=e.vertices[v].normal;n=new THREE.Face3(n,y,v,[o,b,m]);e.faces.push(n)}d+=nfaces;j.count=0});e.sortFacesByMaterial();return e};
|
|
|
this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
|
|
|
THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
|
|
|
1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
|
|
@@ -311,22 +313,22 @@ c},loadAsciiOld:function(a,c){var d=document.createElement("script");d.type="tex
|
|
|
THREE.Loader.prototype.extractUrlbase(c),j=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(b){THREE.Loader.prototype.loadAjaxBuffers(b.data.buffers,b.data.materials,d,j,e,g)};c.onerror=function(b){alert("worker.onerror: "+b.message+"\n"+b.data);b.preventDefault()};c.postMessage(a)},loadAjaxBuffers:function(a,c,d,e,j,g){var b=new XMLHttpRequest,m=e+"/"+a,k=0;
|
|
|
b.onreadystatechange=function(){if(b.readyState==4)b.status==200||b.status==0?THREE.Loader.prototype.createBinModel(b.responseText,d,j,c):alert("Couldn't load ["+m+"] ["+b.status+"]");else if(b.readyState==3){if(g){if(k==0)k=b.getResponseHeader("Content-Length");g({total:k,loaded:b.responseText.length})}}else if(b.readyState==2)k=b.getResponseHeader("Content-Length")};b.open("GET",m,true);b.overrideMimeType("text/plain; charset=x-user-defined");b.setRequestHeader("Content-Type","text/plain");b.send(null)},
|
|
|
createBinModel:function(a,c,d,e){var j=function(g){function b(G,J){var L=o(G,J),W=o(G,J+1),ca=o(G,J+2),ma=o(G,J+3),ia=(ma<<1&255|ca>>7)-127;L=(ca&127)<<16|W<<8|L;if(L==0&&ia==-127)return 0;return(1-2*(ma>>7))*(1+L*Math.pow(2,-23))*Math.pow(2,ia)}function m(G,J){var L=o(G,J),W=o(G,J+1),ca=o(G,J+2);return(o(G,J+3)<<24)+(ca<<16)+(W<<8)+L}function k(G,J){var L=o(G,J);return(o(G,J+1)<<8)+L}function n(G,J){var L=o(G,J);return L>127?L-256:L}function o(G,J){return G.charCodeAt(J)&255}function y(G){var J,
|
|
|
-L,W;J=m(a,G);L=m(a,G+w);W=m(a,G+x);G=k(a,G+v);THREE.Loader.prototype.f3(f,J,L,W,G)}function u(G){var J,L,W,ca,ma,ia;J=m(a,G);L=m(a,G+w);W=m(a,G+x);ca=k(a,G+v);ma=m(a,G+A);ia=m(a,G+C);G=m(a,G+E);THREE.Loader.prototype.f3n(f,l,J,L,W,ca,ma,ia,G)}function q(G){var J,L,W,ca;J=m(a,G);L=m(a,G+F);W=m(a,G+D);ca=m(a,G+I);G=k(a,G+T);THREE.Loader.prototype.f4(f,J,L,W,ca,G)}function z(G){var J,L,W,ca,ma,ia,ra,la;J=m(a,G);L=m(a,G+F);W=m(a,G+D);ca=m(a,G+I);ma=k(a,G+T);ia=m(a,G+P);ra=m(a,G+X);la=m(a,G+Y);G=m(a,G+
|
|
|
-S);THREE.Loader.prototype.f4n(f,l,J,L,W,ca,ma,ia,ra,la,G)}function B(G){var J,L;J=m(a,G);L=m(a,G+V);G=m(a,G+da);THREE.Loader.prototype.uv3(f.uvs,t[J*2],t[J*2+1],t[L*2],t[L*2+1],t[G*2],t[G*2+1])}function H(G){var J,L,W;J=m(a,G);L=m(a,G+R);W=m(a,G+N);G=m(a,G+ba);THREE.Loader.prototype.uv4(f.uvs,t[J*2],t[J*2+1],t[L*2],t[L*2+1],t[W*2],t[W*2+1],t[G*2],t[G*2+1])}var f=this,p=0,h,l=[],t=[],w,x,v,A,C,E,F,D,I,T,P,X,Y,S,V,da,R,N,ba,aa,K,O,U,ha,ga;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,
|
|
|
+L,W;J=m(a,G);L=m(a,G+w);W=m(a,G+x);G=k(a,G+u);THREE.Loader.prototype.f3(f,J,L,W,G)}function v(G){var J,L,W,ca,ma,ia;J=m(a,G);L=m(a,G+w);W=m(a,G+x);ca=k(a,G+u);ma=m(a,G+A);ia=m(a,G+C);G=m(a,G+E);THREE.Loader.prototype.f3n(f,l,J,L,W,ca,ma,ia,G)}function q(G){var J,L,W,ca;J=m(a,G);L=m(a,G+F);W=m(a,G+D);ca=m(a,G+I);G=k(a,G+S);THREE.Loader.prototype.f4(f,J,L,W,ca,G)}function z(G){var J,L,W,ca,ma,ia,ra,la;J=m(a,G);L=m(a,G+F);W=m(a,G+D);ca=m(a,G+I);ma=k(a,G+S);ia=m(a,G+N);ra=m(a,G+X);la=m(a,G+Y);G=m(a,G+
|
|
|
+T);THREE.Loader.prototype.f4n(f,l,J,L,W,ca,ma,ia,ra,la,G)}function B(G){var J,L;J=m(a,G);L=m(a,G+V);G=m(a,G+da);THREE.Loader.prototype.uv3(f.uvs,t[J*2],t[J*2+1],t[L*2],t[L*2+1],t[G*2],t[G*2+1])}function H(G){var J,L,W;J=m(a,G);L=m(a,G+R);W=m(a,G+O);G=m(a,G+ba);THREE.Loader.prototype.uv4(f.uvs,t[J*2],t[J*2+1],t[L*2],t[L*2+1],t[W*2],t[W*2+1],t[G*2],t[G*2+1])}var f=this,p=0,h,l=[],t=[],w,x,u,A,C,E,F,D,I,S,N,X,Y,T,V,da,R,O,ba,aa,K,P,U,ha,ga;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,
|
|
|
e,g);h={signature:a.substr(p,8),header_bytes:o(a,p+8),vertex_coordinate_bytes:o(a,p+9),normal_coordinate_bytes:o(a,p+10),uv_coordinate_bytes:o(a,p+11),vertex_index_bytes:o(a,p+12),normal_index_bytes:o(a,p+13),uv_index_bytes:o(a,p+14),material_index_bytes:o(a,p+15),nvertices:m(a,p+16),nnormals:m(a,p+16+4),nuvs:m(a,p+16+8),ntri_flat:m(a,p+16+12),ntri_smooth:m(a,p+16+16),ntri_flat_uv:m(a,p+16+20),ntri_smooth_uv:m(a,p+16+24),nquad_flat:m(a,p+16+28),nquad_smooth:m(a,p+16+32),nquad_flat_uv:m(a,p+16+36),
|
|
|
-nquad_smooth_uv:m(a,p+16+40)};p+=h.header_bytes;w=h.vertex_index_bytes;x=h.vertex_index_bytes*2;v=h.vertex_index_bytes*3;A=h.vertex_index_bytes*3+h.material_index_bytes;C=h.vertex_index_bytes*3+h.material_index_bytes+h.normal_index_bytes;E=h.vertex_index_bytes*3+h.material_index_bytes+h.normal_index_bytes*2;F=h.vertex_index_bytes;D=h.vertex_index_bytes*2;I=h.vertex_index_bytes*3;T=h.vertex_index_bytes*4;P=h.vertex_index_bytes*4+h.material_index_bytes;X=h.vertex_index_bytes*4+h.material_index_bytes+
|
|
|
-h.normal_index_bytes;Y=h.vertex_index_bytes*4+h.material_index_bytes+h.normal_index_bytes*2;S=h.vertex_index_bytes*4+h.material_index_bytes+h.normal_index_bytes*3;V=h.uv_index_bytes;da=h.uv_index_bytes*2;R=h.uv_index_bytes;N=h.uv_index_bytes*2;ba=h.uv_index_bytes*3;g=h.vertex_index_bytes*3+h.material_index_bytes;ga=h.vertex_index_bytes*4+h.material_index_bytes;aa=h.ntri_flat*g;K=h.ntri_smooth*(g+h.normal_index_bytes*3);O=h.ntri_flat_uv*(g+h.uv_index_bytes*3);U=h.ntri_smooth_uv*(g+h.normal_index_bytes*
|
|
|
+nquad_smooth_uv:m(a,p+16+40)};p+=h.header_bytes;w=h.vertex_index_bytes;x=h.vertex_index_bytes*2;u=h.vertex_index_bytes*3;A=h.vertex_index_bytes*3+h.material_index_bytes;C=h.vertex_index_bytes*3+h.material_index_bytes+h.normal_index_bytes;E=h.vertex_index_bytes*3+h.material_index_bytes+h.normal_index_bytes*2;F=h.vertex_index_bytes;D=h.vertex_index_bytes*2;I=h.vertex_index_bytes*3;S=h.vertex_index_bytes*4;N=h.vertex_index_bytes*4+h.material_index_bytes;X=h.vertex_index_bytes*4+h.material_index_bytes+
|
|
|
+h.normal_index_bytes;Y=h.vertex_index_bytes*4+h.material_index_bytes+h.normal_index_bytes*2;T=h.vertex_index_bytes*4+h.material_index_bytes+h.normal_index_bytes*3;V=h.uv_index_bytes;da=h.uv_index_bytes*2;R=h.uv_index_bytes;O=h.uv_index_bytes*2;ba=h.uv_index_bytes*3;g=h.vertex_index_bytes*3+h.material_index_bytes;ga=h.vertex_index_bytes*4+h.material_index_bytes;aa=h.ntri_flat*g;K=h.ntri_smooth*(g+h.normal_index_bytes*3);P=h.ntri_flat_uv*(g+h.uv_index_bytes*3);U=h.ntri_smooth_uv*(g+h.normal_index_bytes*
|
|
|
3+h.uv_index_bytes*3);ha=h.nquad_flat*ga;g=h.nquad_smooth*(ga+h.normal_index_bytes*4);ga=h.nquad_flat_uv*(ga+h.uv_index_bytes*4);p+=function(G){var J,L,W,ca=h.vertex_coordinate_bytes*3,ma=G+h.nvertices*ca;for(G=G;G<ma;G+=ca){J=b(a,G);L=b(a,G+h.vertex_coordinate_bytes);W=b(a,G+h.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(f,J,L,W)}return h.nvertices*ca}(p);p+=function(G){var J,L,W,ca=h.normal_coordinate_bytes*3,ma=G+h.nnormals*ca;for(G=G;G<ma;G+=ca){J=n(a,G);L=n(a,G+h.normal_coordinate_bytes);
|
|
|
-W=n(a,G+h.normal_coordinate_bytes*2);l.push(J/127,L/127,W/127)}return h.nnormals*ca}(p);p+=function(G){var J,L,W=h.uv_coordinate_bytes*2,ca=G+h.nuvs*W;for(G=G;G<ca;G+=W){J=b(a,G);L=b(a,G+h.uv_coordinate_bytes);t.push(J,L)}return h.nuvs*W}(p);p=p;aa=p+aa;K=aa+K;O=K+O;U=O+U;ha=U+ha;g=ha+g;ga=g+ga;(function(G){var J,L=h.vertex_index_bytes*3+h.material_index_bytes,W=L+h.uv_index_bytes*3,ca=G+h.ntri_flat_uv*W;for(J=G;J<ca;J+=W){y(J);B(J+L)}return ca-G})(K);(function(G){var J,L=h.vertex_index_bytes*3+h.material_index_bytes+
|
|
|
-h.normal_index_bytes*3,W=L+h.uv_index_bytes*3,ca=G+h.ntri_smooth_uv*W;for(J=G;J<ca;J+=W){u(J);B(J+L)}return ca-G})(O);(function(G){var J,L=h.vertex_index_bytes*4+h.material_index_bytes,W=L+h.uv_index_bytes*4,ca=G+h.nquad_flat_uv*W;for(J=G;J<ca;J+=W){q(J);H(J+L)}return ca-G})(g);(function(G){var J,L=h.vertex_index_bytes*4+h.material_index_bytes+h.normal_index_bytes*4,W=L+h.uv_index_bytes*4,ca=G+h.nquad_smooth_uv*W;for(J=G;J<ca;J+=W){z(J);H(J+L)}return ca-G})(ga);(function(G){var J,L=h.vertex_index_bytes*
|
|
|
-3+h.material_index_bytes,W=G+h.ntri_flat*L;for(J=G;J<W;J+=L)y(J);return W-G})(p);(function(G){var J,L=h.vertex_index_bytes*3+h.material_index_bytes+h.normal_index_bytes*3,W=G+h.ntri_smooth*L;for(J=G;J<W;J+=L)u(J);return W-G})(aa);(function(G){var J,L=h.vertex_index_bytes*4+h.material_index_bytes,W=G+h.nquad_flat*L;for(J=G;J<W;J+=L)q(J);return W-G})(U);(function(G){var J,L=h.vertex_index_bytes*4+h.material_index_bytes+h.normal_index_bytes*4,W=G+h.nquad_smooth*L;for(J=G;J<W;J+=L)z(J);return W-G})(ha);
|
|
|
+W=n(a,G+h.normal_coordinate_bytes*2);l.push(J/127,L/127,W/127)}return h.nnormals*ca}(p);p+=function(G){var J,L,W=h.uv_coordinate_bytes*2,ca=G+h.nuvs*W;for(G=G;G<ca;G+=W){J=b(a,G);L=b(a,G+h.uv_coordinate_bytes);t.push(J,L)}return h.nuvs*W}(p);p=p;aa=p+aa;K=aa+K;P=K+P;U=P+U;ha=U+ha;g=ha+g;ga=g+ga;(function(G){var J,L=h.vertex_index_bytes*3+h.material_index_bytes,W=L+h.uv_index_bytes*3,ca=G+h.ntri_flat_uv*W;for(J=G;J<ca;J+=W){y(J);B(J+L)}return ca-G})(K);(function(G){var J,L=h.vertex_index_bytes*3+h.material_index_bytes+
|
|
|
+h.normal_index_bytes*3,W=L+h.uv_index_bytes*3,ca=G+h.ntri_smooth_uv*W;for(J=G;J<ca;J+=W){v(J);B(J+L)}return ca-G})(P);(function(G){var J,L=h.vertex_index_bytes*4+h.material_index_bytes,W=L+h.uv_index_bytes*4,ca=G+h.nquad_flat_uv*W;for(J=G;J<ca;J+=W){q(J);H(J+L)}return ca-G})(g);(function(G){var J,L=h.vertex_index_bytes*4+h.material_index_bytes+h.normal_index_bytes*4,W=L+h.uv_index_bytes*4,ca=G+h.nquad_smooth_uv*W;for(J=G;J<ca;J+=W){z(J);H(J+L)}return ca-G})(ga);(function(G){var J,L=h.vertex_index_bytes*
|
|
|
+3+h.material_index_bytes,W=G+h.ntri_flat*L;for(J=G;J<W;J+=L)y(J);return W-G})(p);(function(G){var J,L=h.vertex_index_bytes*3+h.material_index_bytes+h.normal_index_bytes*3,W=G+h.ntri_smooth*L;for(J=G;J<W;J+=L)v(J);return W-G})(aa);(function(G){var J,L=h.vertex_index_bytes*4+h.material_index_bytes,W=G+h.nquad_flat*L;for(J=G;J<W;J+=L)q(J);return W-G})(U);(function(G){var J,L=h.vertex_index_bytes*4+h.material_index_bytes+h.normal_index_bytes*4,W=G+h.nquad_smooth*L;for(J=G;J<W;J+=L)z(J);return W-G})(ha);
|
|
|
this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};j.prototype=new THREE.Geometry;j.prototype.constructor=j;c(new j(d))},createModel:function(a,c,d){var e=function(j){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,a.materials,j);(function(){var b,m,k,n,o;b=0;for(m=a.vertices.length;b<m;b+=3){k=a.vertices[b];n=a.vertices[b+1];o=a.vertices[b+2];THREE.Loader.prototype.v(g,k,n,o)}})();(function(){function b(z,B){THREE.Loader.prototype.f3(g,z[B],
|
|
|
-z[B+1],z[B+2],z[B+3])}function m(z,B){THREE.Loader.prototype.f3n(g,a.normals,z[B],z[B+1],z[B+2],z[B+3],z[B+4],z[B+5],z[B+6])}function k(z,B){THREE.Loader.prototype.f4(g,z[B],z[B+1],z[B+2],z[B+3],z[B+4])}function n(z,B){THREE.Loader.prototype.f4n(g,a.normals,z[B],z[B+1],z[B+2],z[B+3],z[B+4],z[B+5],z[B+6],z[B+7],z[B+8])}function o(z,B){var H,f,p,h,l,t,w,x,v;H=z[B];f=z[B+1];p=z[B+2];h=a.uvs[H*2];w=a.uvs[H*2+1];l=a.uvs[f*2];x=a.uvs[f*2+1];t=a.uvs[p*2];v=a.uvs[p*2+1];THREE.Loader.prototype.uv3(g.uvs,h,
|
|
|
-w,l,x,t,v);if(a.uvs2){h=a.uvs2[H*2];w=a.uvs2[H*2+1];l=a.uvs2[f*2];x=a.uvs2[f*2+1];t=a.uvs2[p*2];v=a.uvs2[p*2+1];THREE.Loader.prototype.uv3(g.uvs2,h,1-w,l,1-x,t,1-v)}}function y(z,B){var H,f,p,h,l,t,w,x,v,A,C,E;H=z[B];f=z[B+1];p=z[B+2];h=z[B+3];l=a.uvs[H*2];v=a.uvs[H*2+1];t=a.uvs[f*2];A=a.uvs[f*2+1];w=a.uvs[p*2];C=a.uvs[p*2+1];x=a.uvs[h*2];E=a.uvs[h*2+1];THREE.Loader.prototype.uv4(g.uvs,l,v,t,A,w,C,x,E);if(a.uvs2){l=a.uvs2[H*2];v=a.uvs2[H*2+1];t=a.uvs2[f*2];A=a.uvs2[f*2+1];w=a.uvs2[p*2];C=a.uvs2[p*
|
|
|
-2+1];x=a.uvs2[h*2];E=a.uvs2[h*2+1];THREE.Loader.prototype.uv4(g.uvs2,l,1-v,t,1-A,w,1-C,x,1-E)}}var u,q;u=0;for(q=a.triangles_uv.length;u<q;u+=7){b(a.triangles_uv,u);o(a.triangles_uv,u+4)}u=0;for(q=a.triangles_n_uv.length;u<q;u+=10){m(a.triangles_n_uv,u);o(a.triangles_n_uv,u+7)}u=0;for(q=a.quads_uv.length;u<q;u+=9){k(a.quads_uv,u);y(a.quads_uv,u+5)}u=0;for(q=a.quads_n_uv.length;u<q;u+=13){n(a.quads_n_uv,u);y(a.quads_n_uv,u+9)}u=0;for(q=a.triangles.length;u<q;u+=4)b(a.triangles,u);u=0;for(q=a.triangles_n.length;u<
|
|
|
-q;u+=7)m(a.triangles_n,u);u=0;for(q=a.quads.length;u<q;u+=5)k(a.quads,u);u=0;for(q=a.quads_n.length;u<q;u+=9)n(a.quads_n,u)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;c(new e(d))},v:function(a,c,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,d,e)))},f3:function(a,c,d,e,j){a.faces.push(new THREE.Face3(c,d,e,null,a.materials[j]))},f4:function(a,c,d,e,j,g){a.faces.push(new THREE.Face4(c,d,e,j,null,
|
|
|
-a.materials[g]))},f3n:function(a,c,d,e,j,g,b,m,k){g=a.materials[g];var n=c[m*3],o=c[m*3+1];m=c[m*3+2];var y=c[k*3],u=c[k*3+1];k=c[k*3+2];a.faces.push(new THREE.Face3(d,e,j,[new THREE.Vector3(c[b*3],c[b*3+1],c[b*3+2]),new THREE.Vector3(n,o,m),new THREE.Vector3(y,u,k)],g))},f4n:function(a,c,d,e,j,g,b,m,k,n,o){b=a.materials[b];var y=c[k*3],u=c[k*3+1];k=c[k*3+2];var q=c[n*3],z=c[n*3+1];n=c[n*3+2];var B=c[o*3],H=c[o*3+1];o=c[o*3+2];a.faces.push(new THREE.Face4(d,e,j,g,[new THREE.Vector3(c[m*3],c[m*3+1],
|
|
|
-c[m*3+2]),new THREE.Vector3(y,u,k),new THREE.Vector3(q,z,n),new THREE.Vector3(B,H,o)],b))},uv3:function(a,c,d,e,j,g,b){var m=[];m.push(new THREE.UV(c,d));m.push(new THREE.UV(e,j));m.push(new THREE.UV(g,b));a.push(m)},uv4:function(a,c,d,e,j,g,b,m,k){var n=[];n.push(new THREE.UV(c,d));n.push(new THREE.UV(e,j));n.push(new THREE.UV(g,b));n.push(new THREE.UV(m,k));a.push(n)},init_materials:function(a,c,d){a.materials=[];for(var e=0;e<c.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(c[e],
|
|
|
+z[B+1],z[B+2],z[B+3])}function m(z,B){THREE.Loader.prototype.f3n(g,a.normals,z[B],z[B+1],z[B+2],z[B+3],z[B+4],z[B+5],z[B+6])}function k(z,B){THREE.Loader.prototype.f4(g,z[B],z[B+1],z[B+2],z[B+3],z[B+4])}function n(z,B){THREE.Loader.prototype.f4n(g,a.normals,z[B],z[B+1],z[B+2],z[B+3],z[B+4],z[B+5],z[B+6],z[B+7],z[B+8])}function o(z,B){var H,f,p,h,l,t,w,x,u;H=z[B];f=z[B+1];p=z[B+2];h=a.uvs[H*2];w=a.uvs[H*2+1];l=a.uvs[f*2];x=a.uvs[f*2+1];t=a.uvs[p*2];u=a.uvs[p*2+1];THREE.Loader.prototype.uv3(g.uvs,h,
|
|
|
+w,l,x,t,u);if(a.uvs2){h=a.uvs2[H*2];w=a.uvs2[H*2+1];l=a.uvs2[f*2];x=a.uvs2[f*2+1];t=a.uvs2[p*2];u=a.uvs2[p*2+1];THREE.Loader.prototype.uv3(g.uvs2,h,1-w,l,1-x,t,1-u)}}function y(z,B){var H,f,p,h,l,t,w,x,u,A,C,E;H=z[B];f=z[B+1];p=z[B+2];h=z[B+3];l=a.uvs[H*2];u=a.uvs[H*2+1];t=a.uvs[f*2];A=a.uvs[f*2+1];w=a.uvs[p*2];C=a.uvs[p*2+1];x=a.uvs[h*2];E=a.uvs[h*2+1];THREE.Loader.prototype.uv4(g.uvs,l,u,t,A,w,C,x,E);if(a.uvs2){l=a.uvs2[H*2];u=a.uvs2[H*2+1];t=a.uvs2[f*2];A=a.uvs2[f*2+1];w=a.uvs2[p*2];C=a.uvs2[p*
|
|
|
+2+1];x=a.uvs2[h*2];E=a.uvs2[h*2+1];THREE.Loader.prototype.uv4(g.uvs2,l,1-u,t,1-A,w,1-C,x,1-E)}}var v,q;v=0;for(q=a.triangles_uv.length;v<q;v+=7){b(a.triangles_uv,v);o(a.triangles_uv,v+4)}v=0;for(q=a.triangles_n_uv.length;v<q;v+=10){m(a.triangles_n_uv,v);o(a.triangles_n_uv,v+7)}v=0;for(q=a.quads_uv.length;v<q;v+=9){k(a.quads_uv,v);y(a.quads_uv,v+5)}v=0;for(q=a.quads_n_uv.length;v<q;v+=13){n(a.quads_n_uv,v);y(a.quads_n_uv,v+9)}v=0;for(q=a.triangles.length;v<q;v+=4)b(a.triangles,v);v=0;for(q=a.triangles_n.length;v<
|
|
|
+q;v+=7)m(a.triangles_n,v);v=0;for(q=a.quads.length;v<q;v+=5)k(a.quads,v);v=0;for(q=a.quads_n.length;v<q;v+=9)n(a.quads_n,v)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;c(new e(d))},v:function(a,c,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,d,e)))},f3:function(a,c,d,e,j){a.faces.push(new THREE.Face3(c,d,e,null,a.materials[j]))},f4:function(a,c,d,e,j,g){a.faces.push(new THREE.Face4(c,d,e,j,null,
|
|
|
+a.materials[g]))},f3n:function(a,c,d,e,j,g,b,m,k){g=a.materials[g];var n=c[m*3],o=c[m*3+1];m=c[m*3+2];var y=c[k*3],v=c[k*3+1];k=c[k*3+2];a.faces.push(new THREE.Face3(d,e,j,[new THREE.Vector3(c[b*3],c[b*3+1],c[b*3+2]),new THREE.Vector3(n,o,m),new THREE.Vector3(y,v,k)],g))},f4n:function(a,c,d,e,j,g,b,m,k,n,o){b=a.materials[b];var y=c[k*3],v=c[k*3+1];k=c[k*3+2];var q=c[n*3],z=c[n*3+1];n=c[n*3+2];var B=c[o*3],H=c[o*3+1];o=c[o*3+2];a.faces.push(new THREE.Face4(d,e,j,g,[new THREE.Vector3(c[m*3],c[m*3+1],
|
|
|
+c[m*3+2]),new THREE.Vector3(y,v,k),new THREE.Vector3(q,z,n),new THREE.Vector3(B,H,o)],b))},uv3:function(a,c,d,e,j,g,b){var m=[];m.push(new THREE.UV(c,d));m.push(new THREE.UV(e,j));m.push(new THREE.UV(g,b));a.push(m)},uv4:function(a,c,d,e,j,g,b,m,k){var n=[];n.push(new THREE.UV(c,d));n.push(new THREE.UV(e,j));n.push(new THREE.UV(g,b));n.push(new THREE.UV(m,k));a.push(n)},init_materials:function(a,c,d){a.materials=[];for(var e=0;e<c.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(c[e],
|
|
|
d)]},createMaterial:function(a,c){function d(b){b=Math.log(b)/Math.LN2;return Math.floor(b)==b}function e(b,m){var k=new Image;k.onload=function(){if(!d(this.width)||!d(this.height)){var n=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),o=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));b.image.width=n;b.image.height=o;b.image.getContext("2d").drawImage(this,0,0,n,o)}else b.image=this;b.image.loaded=1};k.src=m}var j,g;if(a.map_diffuse&&c){g=document.createElement("canvas");j=new THREE.MeshLambertMaterial({map:new THREE.Texture(g)});
|
|
|
e(j.map,c+"/"+a.map_diffuse)}else if(a.col_diffuse){j=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;j=new THREE.MeshLambertMaterial({color:j,opacity:a.transparency})}else j=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):new THREE.MeshLambertMaterial({color:15658734});if(a.map_lightmap&&c){g=document.createElement("canvas");j.light_map=new THREE.Texture(g);e(j.light_map,c+"/"+a.map_lightmap)}return j},extractUrlbase:function(a){a=a.split("/");a.pop();
|
|
|
return a.join("/")}};
|