|
@@ -13,30 +13,30 @@ THREE.Vector4=function(a,c,d,e){this.x=a||0;this.y=c||0;this.z=d||0;this.w=e||1}
|
|
|
THREE.Vector4.prototype={set:function(a,c,d,e){this.x=a;this.y=c;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
|
|
|
return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,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,f=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)f=f.concat(this.intersectObject(d))}f.sort(function(b,j){return b.distance-j.distance});return f},intersectObject:function(a){function c(H,t,I,o){o=o.clone().subSelf(t);I=I.clone().subSelf(t);var k=H.clone().subSelf(t);H=o.dot(o);t=o.dot(I);o=o.dot(k);var p=I.dot(I);I=I.dot(k);k=1/(H*p-t*t);p=(p*o-t*I)*k;H=(H*I-t*o)*k;return p>0&&H>0&&p+H<1}var d,e,f,b,j,h,g,m,w,B,
|
|
|
-u,q=a.geometry,x=q.vertices,E=[];d=0;for(e=q.faces.length;d<e;d++){f=q.faces[d];B=this.origin.clone();u=this.direction.clone();b=a.matrix.multiplyVector3(x[f.a].position.clone());j=a.matrix.multiplyVector3(x[f.b].position.clone());h=a.matrix.multiplyVector3(x[f.c].position.clone());g=f instanceof THREE.Face4?a.matrix.multiplyVector3(x[f.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(f.normal.clone());w=u.dot(m);if(w<0){m=m.dot((new THREE.Vector3).sub(b,B))/w;B=B.addSelf(u.multiplyScalar(m));
|
|
|
-if(f instanceof THREE.Face3){if(c(B,b,j,h)){f={distance:this.origin.distanceTo(B),point:B,face:f,object:a};E.push(f)}}else if(f instanceof THREE.Face4)if(c(B,b,j,g)||c(B,j,h,g)){f={distance:this.origin.distanceTo(B),point:B,face:f,object:a};E.push(f)}}}return E}};
|
|
|
-THREE.Rectangle=function(){function a(){b=e-c;j=f-d}var c,d,e,f,b,j,h=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return b};this.getHeight=function(){return j};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(g,m,w,B){h=false;c=g;d=m;e=w;f=B;a()};this.addPoint=function(g,m){if(h){h=false;c=g;d=m;e=g;f=m}else{c=c<g?c:g;d=d<m?d:m;e=e>g?e:g;f=f>m?
|
|
|
-f:m}a()};this.add3Points=function(g,m,w,B,u,q){if(h){h=false;c=g<w?g<u?g:u:w<u?w:u;d=m<B?m<q?m:q:B<q?B:q;e=g>w?g>u?g:u:w>u?w:u;f=m>B?m>q?m:q:B>q?B:q}else{c=g<w?g<u?g<c?g:c:u<c?u:c:w<u?w<c?w:c:u<c?u:c;d=m<B?m<q?m<d?m:d:q<d?q:d:B<q?B<d?B:d:q<d?q:d;e=g>w?g>u?g>e?g:e:u>e?u:e:w>u?w>e?w:e:u>e?u:e;f=m>B?m>q?m>f?m:f:q>f?q:f:B>q?B>f?B:f:q>f?q:f}a()};this.addRectangle=function(g){if(h){h=false;c=g.getLeft();d=g.getTop();e=g.getRight();f=g.getBottom()}else{c=c<g.getLeft()?c:g.getLeft();d=d<g.getTop()?d:g.getTop();
|
|
|
+THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,f=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)f=f.concat(this.intersectObject(d))}f.sort(function(b,j){return b.distance-j.distance});return f},intersectObject:function(a){function c(G,t,H,o){o=o.clone().subSelf(t);H=H.clone().subSelf(t);var l=G.clone().subSelf(t);G=o.dot(o);t=o.dot(H);o=o.dot(l);var p=H.dot(H);H=H.dot(l);l=1/(G*p-t*t);p=(p*o-t*H)*l;G=(G*H-t*o)*l;return p>0&&G>0&&p+G<1}var d,e,f,b,j,h,g,m,y,C,
|
|
|
+u,q=a.geometry,A=q.vertices,F=[];d=0;for(e=q.faces.length;d<e;d++){f=q.faces[d];C=this.origin.clone();u=this.direction.clone();b=a.matrix.multiplyVector3(A[f.a].position.clone());j=a.matrix.multiplyVector3(A[f.b].position.clone());h=a.matrix.multiplyVector3(A[f.c].position.clone());g=f instanceof THREE.Face4?a.matrix.multiplyVector3(A[f.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(f.normal.clone());y=u.dot(m);if(y<0){m=m.dot((new THREE.Vector3).sub(b,C))/y;C=C.addSelf(u.multiplyScalar(m));
|
|
|
+if(f instanceof THREE.Face3){if(c(C,b,j,h)){f={distance:this.origin.distanceTo(C),point:C,face:f,object:a};F.push(f)}}else if(f instanceof THREE.Face4)if(c(C,b,j,g)||c(C,j,h,g)){f={distance:this.origin.distanceTo(C),point:C,face:f,object:a};F.push(f)}}}return F}};
|
|
|
+THREE.Rectangle=function(){function a(){b=e-c;j=f-d}var c,d,e,f,b,j,h=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return b};this.getHeight=function(){return j};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(g,m,y,C){h=false;c=g;d=m;e=y;f=C;a()};this.addPoint=function(g,m){if(h){h=false;c=g;d=m;e=g;f=m}else{c=c<g?c:g;d=d<m?d:m;e=e>g?e:g;f=f>m?
|
|
|
+f:m}a()};this.add3Points=function(g,m,y,C,u,q){if(h){h=false;c=g<y?g<u?g:u:y<u?y:u;d=m<C?m<q?m:q:C<q?C:q;e=g>y?g>u?g:u:y>u?y:u;f=m>C?m>q?m:q:C>q?C:q}else{c=g<y?g<u?g<c?g:c:u<c?u:c:y<u?y<c?y:c:u<c?u:c;d=m<C?m<q?m<d?m:d:q<d?q:d:C<q?C<d?C:d:q<d?q:d;e=g>y?g>u?g>e?g:e:u>e?u:e:y>u?y>e?y:e:u>e?u:e;f=m>C?m>q?m>f?m:f:q>f?q:f:C>q?C>f?C:f:q>f?q:f}a()};this.addRectangle=function(g){if(h){h=false;c=g.getLeft();d=g.getTop();e=g.getRight();f=g.getBottom()}else{c=c<g.getLeft()?c:g.getLeft();d=d<g.getTop()?d:g.getTop();
|
|
|
e=e>g.getRight()?e:g.getRight();f=f>g.getBottom()?f:g.getBottom()}a()};this.inflate=function(g){c-=g;d-=g;e+=g;f+=g;a()};this.minSelf=function(g){c=c>g.getLeft()?c:g.getLeft();d=d>g.getTop()?d:g.getTop();e=e<g.getRight()?e:g.getRight();f=f<g.getBottom()?f:g.getBottom();a()};this.instersects=function(g){return Math.min(e,g.getRight())-Math.max(c,g.getLeft())>=0&&Math.min(f,g.getBottom())-Math.max(d,g.getTop())>=0};this.empty=function(){h=true;f=e=d=c=0;a()};this.isEmpty=function(){return h};this.toString=
|
|
|
function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+f+", width: "+b+", height: "+j+" )"}};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,f,b,j,h,g,m,w,B,u,q,x,E){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=f||0;this.n22=b||1;this.n23=j||0;this.n24=h||0;this.n31=g||0;this.n32=m||0;this.n33=w||1;this.n34=B||0;this.n41=u||0;this.n42=q||0;this.n43=x||0;this.n44=E||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,f,b,j,h,g,m,w,B,u,q,x,E){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=f;this.n22=b;this.n23=j;this.n24=h;this.n31=g;this.n32=m;this.n33=w;this.n34=B;this.n41=u;this.n42=q;this.n43=x;this.n44=E;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
|
|
|
+THREE.Matrix4=function(a,c,d,e,f,b,j,h,g,m,y,C,u,q,A,F){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=f||0;this.n22=b||1;this.n23=j||0;this.n24=h||0;this.n31=g||0;this.n32=m||0;this.n33=y||1;this.n34=C||0;this.n41=u||0;this.n42=q||0;this.n43=A||0;this.n44=F||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,f,b,j,h,g,m,y,C,u,q,A,F){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=f;this.n22=b;this.n23=j;this.n24=h;this.n31=g;this.n32=m;this.n33=y;this.n34=C;this.n41=u;this.n42=q;this.n43=A;this.n44=F;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
|
|
|
a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var e=THREE.Matrix4.__tmpVec1,f=THREE.Matrix4.__tmpVec2,b=THREE.Matrix4.__tmpVec3;b.sub(a,c).normalize();e.cross(d,b).normalize();f.cross(b,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);
|
|
|
this.n31=b.x;this.n32=b.y;this.n33=b.z;this.n34=-b.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,f=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)*f;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*c+this.n22*d+this.n23*
|
|
|
-e+this.n24*f;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*f;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,f=a.n13,b=a.n14,j=a.n21,h=a.n22,g=a.n23,m=a.n24,w=a.n31,
|
|
|
-B=a.n32,u=a.n33,q=a.n34,x=a.n41,E=a.n42,H=a.n43,t=a.n44,I=c.n11,o=c.n12,k=c.n13,p=c.n14,n=c.n21,l=c.n22,v=c.n23,C=c.n24,y=c.n31,z=c.n32,D=c.n33,A=c.n34,F=c.n41,T=c.n42,N=c.n43,X=c.n44;this.n11=d*I+e*n+f*y+b*F;this.n12=d*o+e*l+f*z+b*T;this.n13=d*k+e*v+f*D+b*N;this.n14=d*p+e*C+f*A+b*X;this.n21=j*I+h*n+g*y+m*F;this.n22=j*o+h*l+g*z+m*T;this.n23=j*k+h*v+g*D+m*N;this.n24=j*p+h*C+g*A+m*X;this.n31=w*I+B*n+u*y+q*F;this.n32=w*o+B*l+u*z+q*T;this.n33=w*k+B*v+u*D+q*N;this.n34=w*p+B*C+u*A+q*X;this.n41=x*I+E*n+
|
|
|
-H*y+t*F;this.n42=x*o+E*l+H*z+t*T;this.n43=x*k+E*v+H*D+t*N;this.n44=x*p+E*C+H*A+t*X;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,f=this.n14,b=this.n21,j=this.n22,h=this.n23,g=this.n24,m=this.n31,w=this.n32,B=this.n33,u=this.n34,q=this.n41,x=this.n42,E=this.n43,H=this.n44,t=a.n11,I=a.n21,o=a.n31,k=a.n41,p=a.n12,n=a.n22,l=a.n32,v=a.n42,C=a.n13,y=a.n23,z=a.n33,D=a.n43,A=a.n14,F=a.n24,T=a.n34;a=a.n44;this.n11=c*t+d*I+e*o+f*k;this.n12=c*p+d*n+e*l+f*v;this.n13=c*C+d*y+e*z+f*
|
|
|
-D;this.n14=c*A+d*F+e*T+f*a;this.n21=b*t+j*I+h*o+g*k;this.n22=b*p+j*n+h*l+g*v;this.n23=b*C+j*y+h*z+g*D;this.n24=b*A+j*F+h*T+g*a;this.n31=m*t+w*I+B*o+u*k;this.n32=m*p+w*n+B*l+u*v;this.n33=m*C+w*y+B*z+u*D;this.n34=m*A+w*F+B*T+u*a;this.n41=q*t+x*I+E*o+H*k;this.n42=q*p+x*n+E*l+H*v;this.n43=q*C+x*y+E*z+H*D;this.n44=q*A+x*F+E*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,f=this.n21,b=this.n22,j=this.n23,h=this.n24,g=this.n31,m=this.n32,w=this.n33,B=this.n34,u=this.n41,q=this.n42,x=this.n43,E=this.n44;return e*j*m*u-d*h*m*u-e*b*w*u+c*h*w*u+d*b*B*u-c*j*B*u-e*j*g*q+d*h*g*q+e*f*w*q-a*h*w*q-d*f*B*q+a*j*B*q+e*b*g*x-c*h*g*x-e*f*m*x+a*h*m*x+c*f*B*x-a*b*B*x-d*b*g*E+c*j*g*E+d*f*m*E-a*j*m*E-c*f*w*E+a*b*w*E},transpose:function(){function a(c,d,
|
|
|
+e+this.n24*f;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*f;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,f=a.n13,b=a.n14,j=a.n21,h=a.n22,g=a.n23,m=a.n24,y=a.n31,
|
|
|
+C=a.n32,u=a.n33,q=a.n34,A=a.n41,F=a.n42,G=a.n43,t=a.n44,H=c.n11,o=c.n12,l=c.n13,p=c.n14,n=c.n21,k=c.n22,w=c.n23,v=c.n24,x=c.n31,z=c.n32,D=c.n33,B=c.n34,I=c.n41,O=c.n42,Q=c.n43,R=c.n44;this.n11=d*H+e*n+f*x+b*I;this.n12=d*o+e*k+f*z+b*O;this.n13=d*l+e*w+f*D+b*Q;this.n14=d*p+e*v+f*B+b*R;this.n21=j*H+h*n+g*x+m*I;this.n22=j*o+h*k+g*z+m*O;this.n23=j*l+h*w+g*D+m*Q;this.n24=j*p+h*v+g*B+m*R;this.n31=y*H+C*n+u*x+q*I;this.n32=y*o+C*k+u*z+q*O;this.n33=y*l+C*w+u*D+q*Q;this.n34=y*p+C*v+u*B+q*R;this.n41=A*H+F*n+
|
|
|
+G*x+t*I;this.n42=A*o+F*k+G*z+t*O;this.n43=A*l+F*w+G*D+t*Q;this.n44=A*p+F*v+G*B+t*R;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,f=this.n14,b=this.n21,j=this.n22,h=this.n23,g=this.n24,m=this.n31,y=this.n32,C=this.n33,u=this.n34,q=this.n41,A=this.n42,F=this.n43,G=this.n44,t=a.n11,H=a.n21,o=a.n31,l=a.n41,p=a.n12,n=a.n22,k=a.n32,w=a.n42,v=a.n13,x=a.n23,z=a.n33,D=a.n43,B=a.n14,I=a.n24,O=a.n34;a=a.n44;this.n11=c*t+d*H+e*o+f*l;this.n12=c*p+d*n+e*k+f*w;this.n13=c*v+d*x+e*z+f*
|
|
|
+D;this.n14=c*B+d*I+e*O+f*a;this.n21=b*t+j*H+h*o+g*l;this.n22=b*p+j*n+h*k+g*w;this.n23=b*v+j*x+h*z+g*D;this.n24=b*B+j*I+h*O+g*a;this.n31=m*t+y*H+C*o+u*l;this.n32=m*p+y*n+C*k+u*w;this.n33=m*v+y*x+C*z+u*D;this.n34=m*B+y*I+C*O+u*a;this.n41=q*t+A*H+F*o+G*l;this.n42=q*p+A*n+F*k+G*w;this.n43=q*v+A*x+F*z+G*D;this.n44=q*B+A*I+F*O+G*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=
|
|
|
+a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,b=this.n22,j=this.n23,h=this.n24,g=this.n31,m=this.n32,y=this.n33,C=this.n34,u=this.n41,q=this.n42,A=this.n43,F=this.n44;return e*j*m*u-d*h*m*u-e*b*y*u+c*h*y*u+d*b*C*u-c*j*C*u-e*j*g*q+d*h*g*q+e*f*y*q-a*h*y*q-d*f*C*q+a*j*C*q+e*b*g*A-c*h*g*A-e*f*m*A+a*h*m*A+c*f*C*A-a*b*C*A-d*b*g*F+c*j*g*F+d*f*m*F-a*j*m*F-c*f*y*F+a*b*y*F},transpose:function(){function a(c,d,
|
|
|
e){var f=c[d];c[d]=c[e];c[e]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;
|
|
|
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),f=1-d,b=a.x,j=a.y,h=a.z,g=f*b,m=f*j;this.set(g*b+d,g*j-e*h,g*h+e*j,0,g*j+e*h,m*j+d,m*h-e*b,0,g*h-e*j,m*h+e*b,f*h*h+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,f=a.n14,b=a.n21,j=a.n22,h=a.n23,g=a.n24,m=a.n31,w=a.n32,B=a.n33,u=a.n34,q=a.n41,x=a.n42,E=a.n43,H=a.n44,t=new THREE.Matrix4;t.n11=h*u*x-g*B*x+g*w*E-j*u*E-h*w*H+j*B*H;t.n12=f*B*x-e*u*x-f*w*E+d*u*E+e*w*H-d*B*H;t.n13=e*g*x-f*h*x+f*j*E-d*g*E-e*j*H+d*h*H;t.n14=f*h*w-e*g*w-f*j*B+d*g*B+e*j*u-d*h*u;t.n21=g*B*q-h*u*q-g*m*E+b*u*E+h*m*H-b*B*H;t.n22=e*u*q-f*B*q+f*m*E-c*u*E-e*m*H+c*B*H;t.n23=f*h*q-e*g*q-f*b*E+c*g*E+e*b*H-c*h*H;t.n24=e*g*m-f*h*m+
|
|
|
-f*b*B-c*g*B-e*b*u+c*h*u;t.n31=j*u*q-g*w*q+g*m*x-b*u*x-j*m*H+b*w*H;t.n32=f*w*q-d*u*q-f*m*x+c*u*x+d*m*H-c*w*H;t.n33=e*g*q-f*j*q+f*b*x-c*g*x-d*b*H+c*j*H;t.n34=f*j*m-d*g*m-f*b*w+c*g*w+d*b*u-c*j*u;t.n41=h*w*q-j*B*q-h*m*x+b*B*x+j*m*E-b*w*E;t.n42=d*B*q-e*w*q+e*m*x-c*B*x-d*m*E+c*w*E;t.n43=e*j*q-d*h*q-e*b*x+c*h*x+d*b*E-c*j*E;t.n44=d*h*m-e*j*m+e*b*w-c*h*w-d*b*B+c*j*B;t.multiplyScalar(1/a.determinant());return t};
|
|
|
-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],f=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],j=-c[10]*c[4]+c[6]*c[8],h=c[10]*c[0]-c[2]*c[8],g=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],w=-c[9]*c[0]+c[1]*c[8],B=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*j+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*f;d[2]=c*b;d[3]=c*j;d[4]=c*h;d[5]=c*g;d[6]=c*m;d[7]=c*w;d[8]=c*B;return a};
|
|
|
+THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,b=a.n21,j=a.n22,h=a.n23,g=a.n24,m=a.n31,y=a.n32,C=a.n33,u=a.n34,q=a.n41,A=a.n42,F=a.n43,G=a.n44,t=new THREE.Matrix4;t.n11=h*u*A-g*C*A+g*y*F-j*u*F-h*y*G+j*C*G;t.n12=f*C*A-e*u*A-f*y*F+d*u*F+e*y*G-d*C*G;t.n13=e*g*A-f*h*A+f*j*F-d*g*F-e*j*G+d*h*G;t.n14=f*h*y-e*g*y-f*j*C+d*g*C+e*j*u-d*h*u;t.n21=g*C*q-h*u*q-g*m*F+b*u*F+h*m*G-b*C*G;t.n22=e*u*q-f*C*q+f*m*F-c*u*F-e*m*G+c*C*G;t.n23=f*h*q-e*g*q-f*b*F+c*g*F+e*b*G-c*h*G;t.n24=e*g*m-f*h*m+
|
|
|
+f*b*C-c*g*C-e*b*u+c*h*u;t.n31=j*u*q-g*y*q+g*m*A-b*u*A-j*m*G+b*y*G;t.n32=f*y*q-d*u*q-f*m*A+c*u*A+d*m*G-c*y*G;t.n33=e*g*q-f*j*q+f*b*A-c*g*A-d*b*G+c*j*G;t.n34=f*j*m-d*g*m-f*b*y+c*g*y+d*b*u-c*j*u;t.n41=h*y*q-j*C*q-h*m*A+b*C*A+j*m*F-b*y*F;t.n42=d*C*q-e*y*q+e*m*A-c*C*A-d*m*F+c*y*F;t.n43=e*j*q-d*h*q-e*b*A+c*h*A+d*b*F-c*j*F;t.n44=d*h*m-e*j*m+e*b*y-c*h*y-d*b*C+c*j*C;t.multiplyScalar(1/a.determinant());return t};
|
|
|
+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],f=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],j=-c[10]*c[4]+c[6]*c[8],h=c[10]*c[0]-c[2]*c[8],g=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],y=-c[9]*c[0]+c[1]*c[8],C=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*j+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*f;d[2]=c*b;d[3]=c*j;d[4]=c*h;d[5]=c*g;d[6]=c*m;d[7]=c*y;d[8]=c*C;return a};
|
|
|
THREE.Matrix4.makeFrustum=function(a,c,d,e,f,b){var j,h,g;j=new THREE.Matrix4;h=2*f/(c-a);g=2*f/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(b+f)/(b-f);f=-2*b*f/(b-f);j.n11=h;j.n12=0;j.n13=a;j.n14=0;j.n21=0;j.n22=g;j.n23=d;j.n24=0;j.n31=0;j.n32=0;j.n33=e;j.n34=f;j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(a,c,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,d,e)};
|
|
|
THREE.Matrix4.makeOrtho=function(a,c,d,e,f,b){var j,h,g,m;j=new THREE.Matrix4;h=c-a;g=d-e;m=b-f;a=(c+a)/h;d=(d+e)/g;f=(b+f)/m;j.n11=2/h;j.n12=0;j.n13=0;j.n14=-a;j.n21=0;j.n22=2/g;j.n23=0;j.n24=-d;j.n31=0;j.n32=0;j.n33=-2/m;j.n34=-f;j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
|
|
|
THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
|
|
@@ -47,12 +47,12 @@ 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,f,b,j,h=new THREE.Vector3,g=new THREE.Vector3;e=0;for(f=this.vertices.length;e<f;e++){b=this.vertices[e];b.normal.set(0,0,0)}e=0;for(f=this.faces.length;e<f;e++){b=this.faces[e];if(a&&b.vertexNormals.length){h.set(0,0,0);c=0;for(d=b.normal.length;c<d;c++)h.addSelf(b.vertexNormals[c]);h.divideScalar(3)}else{c=this.vertices[b.a];d=this.vertices[b.b];j=this.vertices[b.c];h.sub(j.position,
|
|
|
d.position);g.sub(c.position,d.position);h.crossSelf(g)}h.isZero()||h.normalize();b.normal.copy(h)}},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(A,F,T,N,X,W,R){b=A.vertices[F].position;j=A.vertices[T].position;h=A.vertices[N].position;g=f[X];m=f[W];w=f[R];B=j.x-b.x;u=h.x-b.x;q=j.y-b.y;x=h.y-b.y;
|
|
|
-E=j.z-b.z;H=h.z-b.z;t=m.u-g.u;I=w.u-g.u;o=m.v-g.v;k=w.v-g.v;p=1/(t*k-I*o);v.set((k*B-o*u)*p,(k*q-o*x)*p,(k*E-o*H)*p);C.set((t*u-I*B)*p,(t*x-I*q)*p,(t*H-I*E)*p);n[F].addSelf(v);n[T].addSelf(v);n[N].addSelf(v);l[F].addSelf(C);l[T].addSelf(C);l[N].addSelf(C)}var c,d,e,f,b,j,h,g,m,w,B,u,q,x,E,H,t,I,o,k,p,n=[],l=[],v=new THREE.Vector3,C=new THREE.Vector3,y=new THREE.Vector3,z=new THREE.Vector3,D=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){n[c]=new THREE.Vector3;l[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(B,I,O,Q,R,U,T){b=B.vertices[I].position;j=B.vertices[O].position;h=B.vertices[Q].position;g=f[R];m=f[U];y=f[T];C=j.x-b.x;u=h.x-b.x;q=j.y-b.y;A=h.y-b.y;
|
|
|
+F=j.z-b.z;G=h.z-b.z;t=m.u-g.u;H=y.u-g.u;o=m.v-g.v;l=y.v-g.v;p=1/(t*l-H*o);w.set((l*C-o*u)*p,(l*q-o*A)*p,(l*F-o*G)*p);v.set((t*u-H*C)*p,(t*A-H*q)*p,(t*G-H*F)*p);n[I].addSelf(w);n[O].addSelf(w);n[Q].addSelf(w);k[I].addSelf(v);k[O].addSelf(v);k[Q].addSelf(v)}var c,d,e,f,b,j,h,g,m,y,C,u,q,A,F,G,t,H,o,l,p,n=[],k=[],w=new THREE.Vector3,v=new THREE.Vector3,x=new THREE.Vector3,z=new THREE.Vector3,D=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){n[c]=new THREE.Vector3;k[c]=new THREE.Vector3}c=0;
|
|
|
for(d=this.faces.length;c<d;c++){e=this.faces[c];f=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++){D.copy(this.vertices[c].normal);e=n[c];y.copy(e);y.subSelf(D.multiplyScalar(D.dot(e))).normalize();z.cross(this.vertices[c].normal,e);e=z.dot(l[c]);e=e<0?-1:1;this.vertices[c].tangent.set(y.x,y.y,y.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],
|
|
|
+this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){D.copy(this.vertices[c].normal);e=n[c];x.copy(e);x.subSelf(D.multiplyScalar(D.dot(e))).normalize();z.cross(this.vertices[c].normal,e);e=z.dot(k[c]);e=e<0?-1:1;this.vertices[c].tangent.set(x.x,x.y,x.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>
|
|
|
-this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(w){var B=[];c=0;for(d=w.length;c<d;c++)w[c]==undefined?B.push("undefined"):B.push(w[c].toString());return B.join("_")}var c,d,e,f,b,j,h,g,m={};e=0;for(f=this.faces.length;e<f;e++){b=this.faces[e];
|
|
|
+this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(y){var C=[];c=0;for(d=y.length;c<d;c++)y[c]==undefined?C.push("undefined"):C.push(y[c].toString());return C.join("_")}var c,d,e,f,b,j,h,g,m={};e=0;for(f=this.faces.length;e<f;e++){b=this.faces[e];
|
|
|
j=b.materials;h=a(j);if(m[h]==undefined)m[h]={hash:h,counter:0};g=m[h].hash+"_"+m[h].counter;if(this.geometryChunks[g]==undefined)this.geometryChunks[g]={faces:[],materials:j,vertices:0};b=b instanceof THREE.Face3?3:4;if(this.geometryChunks[g].vertices+b>65535){m[h].counter+=1;g=m[h].hash+"_"+m[h].counter;if(this.geometryChunks[g]==undefined)this.geometryChunks[g]={faces:[],materials:j,vertices:0}}this.geometryChunks[g].faces.push(e);this.geometryChunks[g].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+
|
|
|
this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
|
|
|
THREE.Camera=function(a,c,d,e){this.fov=a;this.aspect=c;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(f){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
|
|
@@ -61,7 +61,7 @@ THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.positio
|
|
|
THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
|
|
|
THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
|
|
|
THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,e=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){e.setRotY(c.y);this.rotationMatrix.multiplySelf(e)}if(c.z!=0){e.setRotZ(c.z);this.rotationMatrix.multiplySelf(e)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){e.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(e)}}};THREE.Object3DCounter={value:0};
|
|
|
-THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
|
|
|
+THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.colors=[];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
|
|
|
THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
|
|
|
THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;
|
|
|
THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}};
|
|
@@ -98,98 +98,100 @@ var Uniforms={clone:function(a){var c,d,e,f={};for(c in a){f[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(l,v){return v.z-l.z}function c(l,v){var C=0,y=1,z=l.z+l.w,D=v.z+v.w,A=-l.z+l.w,F=-v.z+v.w;if(z>=0&&D>=0&&A>=0&&F>=0)return true;else if(z<0&&D<0||A<0&&F<0)return false;else{if(z<0)C=Math.max(C,z/(z-D));else if(D<0)y=Math.min(y,z/(z-D));if(A<0)C=Math.max(C,A/(A-F));else if(F<0)y=Math.min(y,A/(A-F));if(y<C)return false;else{l.lerpSelf(v,C);v.lerpSelf(l,1-y);return true}}}var d,e,f=[],b,j,h,g=[],m,w,B=[],u,q,x=[],E=new THREE.Vector4,H=new THREE.Vector4,t=new THREE.Matrix4,
|
|
|
-I=new THREE.Matrix4,o=[],k=new THREE.Vector4,p=new THREE.Vector4,n;this.projectObjects=function(l,v,C){var y=[],z,D;e=0;t.multiply(v.projectionMatrix,v.matrix);o[0]=new THREE.Vector4(t.n41-t.n11,t.n42-t.n12,t.n43-t.n13,t.n44-t.n14);o[1]=new THREE.Vector4(t.n41+t.n11,t.n42+t.n12,t.n43+t.n13,t.n44+t.n14);o[2]=new THREE.Vector4(t.n41+t.n21,t.n42+t.n22,t.n43+t.n23,t.n44+t.n24);o[3]=new THREE.Vector4(t.n41-t.n21,t.n42-t.n22,t.n43-t.n23,t.n44-t.n24);o[4]=new THREE.Vector4(t.n41-t.n31,t.n42-t.n32,t.n43-
|
|
|
-t.n33,t.n44-t.n34);o[5]=new THREE.Vector4(t.n41+t.n31,t.n42+t.n32,t.n43+t.n33,t.n44+t.n34);v=0;for(z=o.length;v<z;v++){D=o[v];D.divideScalar(Math.sqrt(D.x*D.x+D.y*D.y+D.z*D.z))}z=l.objects;l=0;for(v=z.length;l<v;l++){D=z[l];var A;if(!(A=!D.visible)){if(A=D instanceof THREE.Mesh){a:{A=void 0;for(var F=D.position,T=-D.geometry.boundingSphere.radius*Math.max(D.scale.x,Math.max(D.scale.y,D.scale.z)),N=0;N<6;N++){A=o[N].x*F.x+o[N].y*F.y+o[N].z*F.z+o[N].w;if(A<=T){A=false;break a}}A=true}A=!A}A=A}if(!A){d=
|
|
|
-f[e]=f[e]||new THREE.RenderableObject;E.copy(D.position);t.multiplyVector3(E);d.object=D;d.z=E.z;y.push(d);e++}}C&&y.sort(a);return y};this.projectScene=function(l,v,C){var y=[],z=v.near,D=v.far,A,F,T,N,X,W,R,Y,ea,Q,P,ca,aa,K,U,V;h=w=q=0;v.autoUpdateMatrix&&v.updateMatrix();t.multiply(v.projectionMatrix,v.matrix);W=this.projectObjects(l,v,true);l=0;for(A=W.length;l<A;l++){R=W[l].object;if(R.visible){R.autoUpdateMatrix&&R.updateMatrix();Y=R.matrix;ea=R.rotationMatrix;Q=R.materials;P=R.overdraw;if(R instanceof
|
|
|
-THREE.Mesh){ca=R.geometry;aa=ca.vertices;F=0;for(T=aa.length;F<T;F++){K=aa[F];K.positionWorld.copy(K.position);Y.multiplyVector3(K.positionWorld);N=K.positionScreen;N.copy(K.positionWorld);t.multiplyVector4(N);N.x/=N.w;N.y/=N.w;K.__visible=N.z>z&&N.z<D}ca=ca.faces;F=0;for(T=ca.length;F<T;F++){K=ca[F];if(K instanceof THREE.Face3){N=aa[K.a];X=aa[K.b];U=aa[K.c];if(N.__visible&&X.__visible&&U.__visible)if(R.doubleSided||R.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){b=g[h]=g[h]||new THREE.RenderableFace3;b.v1.positionWorld.copy(N.positionWorld);b.v2.positionWorld.copy(X.positionWorld);b.v3.positionWorld.copy(U.positionWorld);b.v1.positionScreen.copy(N.positionScreen);b.v2.positionScreen.copy(X.positionScreen);b.v3.positionScreen.copy(U.positionScreen);b.normalWorld.copy(K.normal);ea.multiplyVector3(b.normalWorld);b.centroidWorld.copy(K.centroid);Y.multiplyVector3(b.centroidWorld);
|
|
|
-b.centroidScreen.copy(b.centroidWorld);t.multiplyVector3(b.centroidScreen);U=K.vertexNormals;n=b.vertexNormalsWorld;N=0;for(X=U.length;N<X;N++){V=n[N]=n[N]||new THREE.Vector3;V.copy(U[N]);ea.multiplyVector3(V)}b.z=b.centroidScreen.z;b.meshMaterials=Q;b.faceMaterials=K.materials;b.overdraw=P;if(R.geometry.uvs[F]){b.uvs[0]=R.geometry.uvs[F][0];b.uvs[1]=R.geometry.uvs[F][1];b.uvs[2]=R.geometry.uvs[F][2]}y.push(b);h++}}else if(K instanceof THREE.Face4){N=aa[K.a];X=aa[K.b];U=aa[K.c];V=aa[K.d];if(N.__visible&&
|
|
|
-X.__visible&&U.__visible&&V.__visible)if(R.doubleSided||R.flipSided!=((V.positionScreen.x-N.positionScreen.x)*(X.positionScreen.y-N.positionScreen.y)-(V.positionScreen.y-N.positionScreen.y)*(X.positionScreen.x-N.positionScreen.x)<0||(X.positionScreen.x-U.positionScreen.x)*(V.positionScreen.y-U.positionScreen.y)-(X.positionScreen.y-U.positionScreen.y)*(V.positionScreen.x-U.positionScreen.x)<0)){b=g[h]=g[h]||new THREE.RenderableFace3;b.v1.positionWorld.copy(N.positionWorld);b.v2.positionWorld.copy(X.positionWorld);
|
|
|
-b.v3.positionWorld.copy(V.positionWorld);b.v1.positionScreen.copy(N.positionScreen);b.v2.positionScreen.copy(X.positionScreen);b.v3.positionScreen.copy(V.positionScreen);b.normalWorld.copy(K.normal);ea.multiplyVector3(b.normalWorld);b.centroidWorld.copy(K.centroid);Y.multiplyVector3(b.centroidWorld);b.centroidScreen.copy(b.centroidWorld);t.multiplyVector3(b.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterials=Q;b.faceMaterials=K.materials;b.overdraw=P;if(R.geometry.uvs[F]){b.uvs[0]=R.geometry.uvs[F][0];
|
|
|
-b.uvs[1]=R.geometry.uvs[F][1];b.uvs[2]=R.geometry.uvs[F][3]}y.push(b);h++;j=g[h]=g[h]||new THREE.RenderableFace3;j.v1.positionWorld.copy(X.positionWorld);j.v2.positionWorld.copy(U.positionWorld);j.v3.positionWorld.copy(V.positionWorld);j.v1.positionScreen.copy(X.positionScreen);j.v2.positionScreen.copy(U.positionScreen);j.v3.positionScreen.copy(V.positionScreen);j.normalWorld.copy(b.normalWorld);j.centroidWorld.copy(b.centroidWorld);j.centroidScreen.copy(b.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=
|
|
|
-Q;j.faceMaterials=K.materials;j.overdraw=P;if(R.geometry.uvs[F]){j.uvs[0]=R.geometry.uvs[F][1];j.uvs[1]=R.geometry.uvs[F][2];j.uvs[2]=R.geometry.uvs[F][3]}y.push(j);h++}}}}else if(R instanceof THREE.Line){I.multiply(t,Y);aa=R.geometry.vertices;K=aa[0];K.positionScreen.copy(K.position);I.multiplyVector4(K.positionScreen);F=1;for(T=aa.length;F<T;F++){N=aa[F];N.positionScreen.copy(N.position);I.multiplyVector4(N.positionScreen);X=aa[F-1];k.copy(N.positionScreen);p.copy(X.positionScreen);if(c(k,p)){k.multiplyScalar(1/
|
|
|
-k.w);p.multiplyScalar(1/p.w);m=B[w]=B[w]||new THREE.RenderableLine;m.v1.positionScreen.copy(k);m.v2.positionScreen.copy(p);m.z=Math.max(k.z,p.z);m.materials=R.materials;y.push(m);w++}}}else if(R instanceof THREE.Particle){H.set(R.position.x,R.position.y,R.position.z,1);t.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){u=x[q]=x[q]||new THREE.RenderableParticle;u.x=H.x/H.w;u.y=H.y/H.w;u.z=H.z;u.rotation=R.rotation.z;u.scale.x=R.scale.x*Math.abs(u.x-(H.x+v.projectionMatrix.n11)/(H.w+v.projectionMatrix.n14));
|
|
|
-u.scale.y=R.scale.y*Math.abs(u.y-(H.y+v.projectionMatrix.n22)/(H.w+v.projectionMatrix.n24));u.materials=R.materials;y.push(u);q++}}}}C&&y.sort(a);return y};this.unprojectVector=function(l,v){var C=THREE.Matrix4.makeInvert(v.matrix);C.multiplySelf(THREE.Matrix4.makeInvert(v.projectionMatrix));C.multiplyVector3(l);return l}};
|
|
|
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,f,b;this.domElement=document.createElement("div");this.setSize=function(j,h){d=j;e=h;f=d/2;b=e/2};this.render=function(j,h){var g,m,w,B,u,q,x,E;a=c.projectScene(j,h);g=0;for(m=a.length;g<m;g++){u=a[g];if(u instanceof THREE.RenderableParticle){x=u.x*f+f;E=u.y*b+b;w=0;for(B=u.material.length;w<B;w++){q=u.material[w];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=x+"px";q.style.top=E+"px"}}}}}};
|
|
|
-THREE.CanvasRenderer=function(){function a(ma){if(u!=ma)m.globalAlpha=u=ma}function c(ma){if(q!=ma){switch(ma){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}q=ma}}var d=null,e=new THREE.Projector,f=document.createElement("canvas"),b,j,h,g,m=f.getContext("2d"),w=new THREE.Color(0),B=0,u=1,q=0,x=null,E=null,H=1,t,I,o,k,p,n,l,v,C,y=new THREE.Color,
|
|
|
-z=new THREE.Color,D=new THREE.Color,A=new THREE.Color,F=new THREE.Color,T,N,X,W,R,Y,ea,Q,P,ca=new THREE.Rectangle,aa=new THREE.Rectangle,K=new THREE.Rectangle,U=false,V=new THREE.Color,ga=new THREE.Color,fa=new THREE.Color,G=new THREE.Color,L=Math.PI*2,J=new THREE.Vector3,O,ba,ia,ja,pa,la,ua=16;O=document.createElement("canvas");O.width=O.height=2;ba=O.getContext("2d");ba.fillStyle="rgba(0,0,0,1)";ba.fillRect(0,0,2,2);ia=ba.getImageData(0,0,2,2);ja=ia.data;pa=document.createElement("canvas");pa.width=
|
|
|
-pa.height=ua;la=pa.getContext("2d");la.translate(-ua/2,-ua/2);la.scale(ua,ua);ua--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ma,sa){b=ma;j=sa;h=b/2;g=j/2;f.width=b;f.height=j;ca.set(-h,-g,h,g);u=1;q=0;E=x=null;H=1};this.setClearColor=function(ma,sa){w.setHex(ma);B=sa;aa.set(-h,-g,h,g);m.setTransform(1,0,0,-1,h,g);this.clear()};this.clear=function(){m.setTransform(1,0,0,-1,h,g);if(!aa.isEmpty()){aa.inflate(1);aa.minSelf(ca);if(w.hex==0&&B==0)m.clearRect(aa.getX(),
|
|
|
-aa.getY(),aa.getWidth(),aa.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(w.r*255)+","+Math.floor(w.g*255)+","+Math.floor(w.b*255)+","+B+")";m.fillRect(aa.getX(),aa.getY(),aa.getWidth(),aa.getHeight())}aa.empty()}};this.render=function(ma,sa){function Ha(M){var da,$,S,Z=M.lights;ga.setRGB(0,0,0);fa.setRGB(0,0,0);G.setRGB(0,0,0);M=0;for(da=Z.length;M<da;M++){$=Z[M];S=$.color;if($ instanceof THREE.AmbientLight){ga.r+=S.r;ga.g+=S.g;ga.b+=S.b}else if($ instanceof THREE.DirectionalLight){fa.r+=
|
|
|
-S.r;fa.g+=S.g;fa.b+=S.b}else if($ instanceof THREE.PointLight){G.r+=S.r;G.g+=S.g;G.b+=S.b}}}function Da(M,da,$,S){var Z,ha,na,oa,qa=M.lights;M=0;for(Z=qa.length;M<Z;M++){ha=qa[M];na=ha.color;oa=ha.intensity;if(ha instanceof THREE.DirectionalLight){ha=$.dot(ha.position)*oa;if(ha>0){S.r+=na.r*ha;S.g+=na.g*ha;S.b+=na.b*ha}}else if(ha instanceof THREE.PointLight){J.sub(ha.position,da);J.normalize();ha=$.dot(J)*oa;if(ha>0){S.r+=na.r*ha;S.g+=na.g*ha;S.b+=na.b*ha}}}}function Qa(M,da,$){if($.opacity!=0){a($.opacity);
|
|
|
-c($.blending);var S,Z,ha,na,oa,qa;if($ instanceof THREE.ParticleBasicMaterial){if($.map&&$.map.image.loaded){na=$.map.image;oa=na.width>>1;qa=na.height>>1;Z=da.scale.x*h;ha=da.scale.y*g;$=Z*oa;S=ha*qa;K.set(M.x-$,M.y-S,M.x+$,M.y+S);if(ca.instersects(K)){m.save();m.translate(M.x,M.y);m.rotate(-da.rotation);m.scale(Z,-ha);m.translate(-oa,-qa);m.drawImage(na,0,0);m.restore()}}}else if($ instanceof THREE.ParticleCircleMaterial){if(U){V.r=ga.r+fa.r+G.r;V.g=ga.g+fa.g+G.g;V.b=ga.b+fa.b+G.b;y.r=$.color.r*
|
|
|
-V.r;y.g=$.color.g*V.g;y.b=$.color.b*V.b;y.updateStyleString()}else y.__styleString=$.color.__styleString;$=da.scale.x*h;S=da.scale.y*g;K.set(M.x-$,M.y-S,M.x+$,M.y+S);if(ca.instersects(K)){Z=y.__styleString;if(E!=Z)m.fillStyle=E=Z;m.save();m.translate(M.x,M.y);m.rotate(-da.rotation);m.scale($,S);m.beginPath();m.arc(0,0,1,0,L,true);m.closePath();m.fill();m.restore()}}}}function Ra(M,da,$,S){if(S.opacity!=0){a(S.opacity);c(S.blending);m.beginPath();m.moveTo(M.positionScreen.x,M.positionScreen.y);m.lineTo(da.positionScreen.x,
|
|
|
-da.positionScreen.y);m.closePath();if(S instanceof THREE.LineBasicMaterial){y.__styleString=S.color.__styleString;M=S.linewidth;if(H!=M)m.lineWidth=H=M;M=y.__styleString;if(x!=M)m.strokeStyle=x=M;m.stroke();K.inflate(S.linewidth*2)}}}function Ma(M,da,$,S,Z,ha){if(Z.opacity!=0){a(Z.opacity);c(Z.blending);k=M.positionScreen.x;p=M.positionScreen.y;n=da.positionScreen.x;l=da.positionScreen.y;v=$.positionScreen.x;C=$.positionScreen.y;m.beginPath();m.moveTo(k,p);m.lineTo(n,l);m.lineTo(v,C);m.lineTo(k,p);
|
|
|
-m.closePath();if(Z instanceof THREE.MeshBasicMaterial)if(Z.map)Z.map.image.loaded&&Z.map.mapping instanceof THREE.UVMapping&&Aa(k,p,n,l,v,C,Z.map.image,S.uvs[0].u,S.uvs[0].v,S.uvs[1].u,S.uvs[1].v,S.uvs[2].u,S.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;J.copy(S.vertexNormalsWorld[0]);W=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;R=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;J.copy(S.vertexNormalsWorld[1]);Y=(J.x*M.n11+
|
|
|
-J.y*M.n12+J.z*M.n13)*0.5+0.5;ea=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;J.copy(S.vertexNormalsWorld[2]);Q=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;P=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;Aa(k,p,n,l,v,C,Z.env_map.image,W,R,Y,ea,Q,P)}}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&&Aa(k,p,n,l,v,C,Z.map.image,S.uvs[0].u,S.uvs[0].v,S.uvs[1].u,
|
|
|
-S.uvs[1].v,S.uvs[2].u,S.uvs[2].v);c(THREE.SubtractiveBlending)}if(U)if(!Z.wireframe&&Z.shading==THREE.SmoothShading&&S.vertexNormalsWorld.length==3){z.r=D.r=A.r=ga.r;z.g=D.g=A.g=ga.g;z.b=D.b=A.b=ga.b;Da(ha,S.v1.positionWorld,S.vertexNormalsWorld[0],z);Da(ha,S.v2.positionWorld,S.vertexNormalsWorld[1],D);Da(ha,S.v3.positionWorld,S.vertexNormalsWorld[2],A);F.r=(D.r+A.r)*0.5;F.g=(D.g+A.g)*0.5;F.b=(D.b+A.b)*0.5;X=Na(z,D,A,F);Aa(k,p,n,l,v,C,X,0,0,1,0,0,1)}else{V.r=ga.r;V.g=ga.g;V.b=ga.b;Da(ha,S.centroidWorld,
|
|
|
-S.normalWorld,V);y.r=Z.color.r*V.r;y.g=Z.color.g*V.g;y.b=Z.color.b*V.b;y.updateStyleString();Z.wireframe?Ea(y.__styleString,Z.wireframe_linewidth):Fa(y.__styleString)}else Z.wireframe?Ea(Z.color.__styleString,Z.wireframe_linewidth):Fa(Z.color.__styleString)}else if(Z instanceof THREE.MeshDepthMaterial){T=sa.near;N=sa.far;z.r=z.g=z.b=1-Ia(M.positionScreen.z,T,N);D.r=D.g=D.b=1-Ia(da.positionScreen.z,T,N);A.r=A.g=A.b=1-Ia($.positionScreen.z,T,N);F.r=(D.r+A.r)*0.5;F.g=(D.g+A.g)*0.5;F.b=(D.b+A.b)*0.5;
|
|
|
-X=Na(z,D,A,F);Aa(k,p,n,l,v,C,X,0,0,1,0,0,1)}else if(Z instanceof THREE.MeshNormalMaterial){y.r=Ja(S.normalWorld.x);y.g=Ja(S.normalWorld.y);y.b=Ja(S.normalWorld.z);y.updateStyleString();Z.wireframe?Ea(y.__styleString,Z.wireframe_linewidth):Fa(y.__styleString)}}}function Ea(M,da){if(x!=M)m.strokeStyle=x=M;if(H!=da)m.lineWidth=H=da;m.stroke();K.inflate(da*2)}function Fa(M){if(E!=M)m.fillStyle=E=M;m.fill()}function Aa(M,da,$,S,Z,ha,na,oa,qa,va,ra,wa,Ba){var ya,xa;ya=na.width-1;xa=na.height-1;oa*=ya;qa*=
|
|
|
-xa;va*=ya;ra*=xa;wa*=ya;Ba*=xa;$-=M;S-=da;Z-=M;ha-=da;va-=oa;ra-=qa;wa-=oa;Ba-=qa;xa=1/(va*Ba-wa*ra);ya=(Ba*$-ra*Z)*xa;ra=(Ba*S-ra*ha)*xa;$=(va*Z-wa*$)*xa;S=(va*ha-wa*S)*xa;M=M-ya*oa-$*qa;da=da-ra*oa-S*qa;m.save();m.transform(ya,ra,$,S,M,da);m.clip();m.drawImage(na,0,0);m.restore()}function Na(M,da,$,S){var Z=~~(M.r*255),ha=~~(M.g*255);M=~~(M.b*255);var na=~~(da.r*255),oa=~~(da.g*255);da=~~(da.b*255);var qa=~~($.r*255),va=~~($.g*255);$=~~($.b*255);var ra=~~(S.r*255),wa=~~(S.g*255);S=~~(S.b*255);ja[0]=
|
|
|
-Z<0?0:Z>255?255:Z;ja[1]=ha<0?0:ha>255?255:ha;ja[2]=M<0?0:M>255?255:M;ja[4]=na<0?0:na>255?255:na;ja[5]=oa<0?0:oa>255?255:oa;ja[6]=da<0?0:da>255?255:da;ja[8]=qa<0?0:qa>255?255:qa;ja[9]=va<0?0:va>255?255:va;ja[10]=$<0?0:$>255?255:$;ja[12]=ra<0?0:ra>255?255:ra;ja[13]=wa<0?0:wa>255?255:wa;ja[14]=S<0?0:S>255?255:S;ba.putImageData(ia,0,0);la.drawImage(O,0,0);return pa}function Ia(M,da,$){M=(M-da)/($-da);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,da){var $=da.x-M.x,S=
|
|
|
-da.y-M.y,Z=1/Math.sqrt($*$+S*S);$*=Z;S*=Z;da.x+=$;da.y+=S;M.x-=$;M.y-=S}var Ga,Oa,ka,ta,za,La,Pa,Ca;this.autoClear?this.clear():m.setTransform(1,0,0,-1,h,g);d=e.projectScene(ma,sa,this.sortElements);(U=ma.lights.length>0)&&Ha(ma);Ga=0;for(Oa=d.length;Ga<Oa;Ga++){ka=d[Ga];K.empty();if(ka instanceof THREE.RenderableParticle){t=ka;t.x*=h;t.y*=g;ta=0;for(za=ka.materials.length;ta<za;ta++)Qa(t,ka,ka.materials[ta],ma)}else if(ka instanceof THREE.RenderableLine){t=ka.v1;I=ka.v2;t.positionScreen.x*=h;t.positionScreen.y*=
|
|
|
-g;I.positionScreen.x*=h;I.positionScreen.y*=g;K.addPoint(t.positionScreen.x,t.positionScreen.y);K.addPoint(I.positionScreen.x,I.positionScreen.y);if(ca.instersects(K)){ta=0;for(za=ka.materials.length;ta<za;)Ra(t,I,ka,ka.materials[ta++],ma)}}else if(ka instanceof THREE.RenderableFace3){t=ka.v1;I=ka.v2;o=ka.v3;t.positionScreen.x*=h;t.positionScreen.y*=g;I.positionScreen.x*=h;I.positionScreen.y*=g;o.positionScreen.x*=h;o.positionScreen.y*=g;if(ka.overdraw){Ka(t.positionScreen,I.positionScreen);Ka(I.positionScreen,
|
|
|
-o.positionScreen);Ka(o.positionScreen,t.positionScreen)}K.add3Points(t.positionScreen.x,t.positionScreen.y,I.positionScreen.x,I.positionScreen.y,o.positionScreen.x,o.positionScreen.y);if(ca.instersects(K)){ta=0;for(za=ka.meshMaterials.length;ta<za;){Ca=ka.meshMaterials[ta++];if(Ca instanceof THREE.MeshFaceMaterial){La=0;for(Pa=ka.faceMaterials.length;La<Pa;)(Ca=ka.faceMaterials[La++])&&Ma(t,I,o,ka,Ca,ma)}else Ma(t,I,o,ka,Ca,ma)}}}aa.addRectangle(K)}m.setTransform(1,0,0,1,0,0)}};
|
|
|
-THREE.SVGRenderer=function(){function a(W,R,Y){var ea,Q,P,ca;ea=0;for(Q=W.lights.length;ea<Q;ea++){P=W.lights[ea];if(P instanceof THREE.DirectionalLight){ca=R.normalWorld.dot(P.position)*P.intensity;if(ca>0){Y.r+=P.color.r*ca;Y.g+=P.color.g*ca;Y.b+=P.color.b*ca}}else if(P instanceof THREE.PointLight){C.sub(P.position,R.centroidWorld);C.normalize();ca=R.normalWorld.dot(C)*P.intensity;if(ca>0){Y.r+=P.color.r*ca;Y.g+=P.color.g*ca;Y.b+=P.color.b*ca}}}}function c(W,R,Y,ea,Q,P){A=e(F++);A.setAttribute("d",
|
|
|
-"M "+W.positionScreen.x+" "+W.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+Y.positionScreen.x+","+Y.positionScreen.y+"z");if(Q instanceof THREE.MeshBasicMaterial)o.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshLambertMaterial)if(I){k.r=p.r;k.g=p.g;k.b=p.b;a(P,ea,k);o.r=Q.color.r*k.r;o.g=Q.color.g*k.g;o.b=Q.color.b*k.b;o.updateStyleString()}else o.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshDepthMaterial){v=1-Q.__2near/(Q.__farPlusNear-
|
|
|
-ea.z*Q.__farMinusNear);o.setRGB(v,v,v)}else Q instanceof THREE.MeshNormalMaterial&&o.setRGB(f(ea.normalWorld.x),f(ea.normalWorld.y),f(ea.normalWorld.z));Q.wireframe?A.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+Q.wireframe_linewidth+"; stroke-opacity: "+Q.opacity+"; stroke-linecap: "+Q.wireframe_linecap+"; stroke-linejoin: "+Q.wireframe_linejoin):A.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+Q.opacity);h.appendChild(A)}function d(W,R,Y,ea,Q,
|
|
|
-P,ca){A=e(F++);A.setAttribute("d","M "+W.positionScreen.x+" "+W.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+Y.positionScreen.x+","+Y.positionScreen.y+" L "+ea.positionScreen.x+","+ea.positionScreen.y+"z");if(P instanceof THREE.MeshBasicMaterial)o.__styleString=P.color.__styleString;else if(P instanceof THREE.MeshLambertMaterial)if(I){k.r=p.r;k.g=p.g;k.b=p.b;a(ca,Q,k);o.r=P.color.r*k.r;o.g=P.color.g*k.g;o.b=P.color.b*k.b;o.updateStyleString()}else o.__styleString=P.color.__styleString;
|
|
|
-else if(P instanceof THREE.MeshDepthMaterial){v=1-P.__2near/(P.__farPlusNear-Q.z*P.__farMinusNear);o.setRGB(v,v,v)}else P instanceof THREE.MeshNormalMaterial&&o.setRGB(f(Q.normalWorld.x),f(Q.normalWorld.y),f(Q.normalWorld.z));P.wireframe?A.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+P.wireframe_linewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.wireframe_linecap+"; stroke-linejoin: "+P.wireframe_linejoin):A.setAttribute("style","fill: "+o.__styleString+
|
|
|
-"; fill-opacity: "+P.opacity);h.appendChild(A)}function e(W){if(y[W]==null){y[W]=document.createElementNS("http://www.w3.org/2000/svg","path");X==0&&y[W].setAttribute("shape-rendering","crispEdges");return y[W]}return y[W]}function f(W){return W<0?Math.min((1+W)*0.5,0.5):0.5+Math.min(W*0.5,0.5)}var b=null,j=new THREE.Projector,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),g,m,w,B,u,q,x,E,H=new THREE.Rectangle,t=new THREE.Rectangle,I=false,o=new THREE.Color(16777215),k=new THREE.Color(16777215),
|
|
|
-p=new THREE.Color(0),n=new THREE.Color(0),l=new THREE.Color(0),v,C=new THREE.Vector3,y=[],z=[],D=[],A,F,T,N,X=1;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(W){switch(W){case "high":X=1;break;case "low":X=0}};this.setSize=function(W,R){g=W;m=R;w=g/2;B=m/2;h.setAttribute("viewBox",-w+" "+-B+" "+g+" "+m);h.setAttribute("width",g);h.setAttribute("height",m);H.set(-w,-B,w,B)};this.clear=function(){for(;h.childNodes.length>0;)h.removeChild(h.childNodes[0])};
|
|
|
-this.render=function(W,R){var Y,ea,Q,P,ca,aa,K,U;this.autoClear&&this.clear();b=j.projectScene(W,R,this.sortElements);N=T=F=0;if(I=W.lights.length>0){K=W.lights;p.setRGB(0,0,0);n.setRGB(0,0,0);l.setRGB(0,0,0);Y=0;for(ea=K.length;Y<ea;Y++){Q=K[Y];P=Q.color;if(Q instanceof THREE.AmbientLight){p.r+=P.r;p.g+=P.g;p.b+=P.b}else if(Q instanceof THREE.DirectionalLight){n.r+=P.r;n.g+=P.g;n.b+=P.b}else if(Q instanceof THREE.PointLight){l.r+=P.r;l.g+=P.g;l.b+=P.b}}}Y=0;for(ea=b.length;Y<ea;Y++){K=b[Y];t.empty();
|
|
|
-if(K instanceof THREE.RenderableParticle){u=K;u.x*=w;u.y*=-B;Q=0;for(P=K.materials.length;Q<P;Q++)if(U=K.materials[Q]){ca=u;aa=K;U=U;var V=T++;if(z[V]==null){z[V]=document.createElementNS("http://www.w3.org/2000/svg","circle");X==0&&z[V].setAttribute("shape-rendering","crispEdges")}A=z[V];A.setAttribute("cx",ca.x);A.setAttribute("cy",ca.y);A.setAttribute("r",aa.scale.x*w);if(U instanceof THREE.ParticleCircleMaterial){if(I){k.r=p.r+n.r+l.r;k.g=p.g+n.g+l.g;k.b=p.b+n.b+l.b;o.r=U.color.r*k.r;o.g=U.color.g*
|
|
|
-k.g;o.b=U.color.b*k.b;o.updateStyleString()}else o=U.color;A.setAttribute("style","fill: "+o.__styleString)}h.appendChild(A)}}else if(K instanceof THREE.RenderableLine){u=K.v1;q=K.v2;u.positionScreen.x*=w;u.positionScreen.y*=-B;q.positionScreen.x*=w;q.positionScreen.y*=-B;t.addPoint(u.positionScreen.x,u.positionScreen.y);t.addPoint(q.positionScreen.x,q.positionScreen.y);if(H.instersects(t)){Q=0;for(P=K.materials.length;Q<P;)if(U=K.materials[Q++]){ca=u;aa=q;U=U;V=N++;if(D[V]==null){D[V]=document.createElementNS("http://www.w3.org/2000/svg",
|
|
|
-"line");X==0&&D[V].setAttribute("shape-rendering","crispEdges")}A=D[V];A.setAttribute("x1",ca.positionScreen.x);A.setAttribute("y1",ca.positionScreen.y);A.setAttribute("x2",aa.positionScreen.x);A.setAttribute("y2",aa.positionScreen.y);if(U instanceof THREE.LineBasicMaterial){o.__styleString=U.color.__styleString;A.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+U.linewidth+"; stroke-opacity: "+U.opacity+"; stroke-linecap: "+U.linecap+"; stroke-linejoin: "+U.linejoin);
|
|
|
-h.appendChild(A)}}}}else if(K instanceof THREE.RenderableFace3){u=K.v1;q=K.v2;x=K.v3;u.positionScreen.x*=w;u.positionScreen.y*=-B;q.positionScreen.x*=w;q.positionScreen.y*=-B;x.positionScreen.x*=w;x.positionScreen.y*=-B;t.addPoint(u.positionScreen.x,u.positionScreen.y);t.addPoint(q.positionScreen.x,q.positionScreen.y);t.addPoint(x.positionScreen.x,x.positionScreen.y);if(H.instersects(t)){Q=0;for(P=K.meshMaterials.length;Q<P;){U=K.meshMaterials[Q++];if(U instanceof THREE.MeshFaceMaterial){ca=0;for(aa=
|
|
|
-K.faceMaterials.length;ca<aa;)(U=K.faceMaterials[ca++])&&c(u,q,x,K,U,W)}else U&&c(u,q,x,K,U,W)}}}else if(K instanceof THREE.RenderableFace4){u=K.v1;q=K.v2;x=K.v3;E=K.v4;u.positionScreen.x*=w;u.positionScreen.y*=-B;q.positionScreen.x*=w;q.positionScreen.y*=-B;x.positionScreen.x*=w;x.positionScreen.y*=-B;E.positionScreen.x*=w;E.positionScreen.y*=-B;t.addPoint(u.positionScreen.x,u.positionScreen.y);t.addPoint(q.positionScreen.x,q.positionScreen.y);t.addPoint(x.positionScreen.x,x.positionScreen.y);t.addPoint(E.positionScreen.x,
|
|
|
-E.positionScreen.y);if(H.instersects(t)){Q=0;for(P=K.meshMaterials.length;Q<P;){U=K.meshMaterials[Q++];if(U instanceof THREE.MeshFaceMaterial){ca=0;for(aa=K.faceMaterials.length;ca<aa;)(U=K.faceMaterials[ca++])&&d(u,q,x,E,K,U,W)}else U&&d(u,q,x,E,K,U,W)}}}}}};
|
|
|
-THREE.WebGLRenderer=function(a){function c(k,p){k.fragment_shader=p.fragment_shader;k.vertex_shader=p.vertex_shader;k.uniforms=Uniforms.clone(p.uniforms)}function d(k,p){var n;if(k=="fragment")n=b.createShader(b.FRAGMENT_SHADER);else if(k=="vertex")n=b.createShader(b.VERTEX_SHADER);b.shaderSource(n,p);b.compileShader(n);if(!b.getShaderParameter(n,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(n));return null}return n}function e(k){switch(k){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;
|
|
|
+THREE.Projector=function(){function a(k,w){return w.z-k.z}function c(k,w){var v=0,x=1,z=k.z+k.w,D=w.z+w.w,B=-k.z+k.w,I=-w.z+w.w;if(z>=0&&D>=0&&B>=0&&I>=0)return true;else if(z<0&&D<0||B<0&&I<0)return false;else{if(z<0)v=Math.max(v,z/(z-D));else if(D<0)x=Math.min(x,z/(z-D));if(B<0)v=Math.max(v,B/(B-I));else if(I<0)x=Math.min(x,B/(B-I));if(x<v)return false;else{k.lerpSelf(w,v);w.lerpSelf(k,1-x);return true}}}var d,e,f=[],b,j,h,g=[],m,y,C=[],u,q,A=[],F=new THREE.Vector4,G=new THREE.Vector4,t=new THREE.Matrix4,
|
|
|
+H=new THREE.Matrix4,o=[],l=new THREE.Vector4,p=new THREE.Vector4,n;this.projectObjects=function(k,w,v){var x=[],z,D;e=0;t.multiply(w.projectionMatrix,w.matrix);o[0]=new THREE.Vector4(t.n41-t.n11,t.n42-t.n12,t.n43-t.n13,t.n44-t.n14);o[1]=new THREE.Vector4(t.n41+t.n11,t.n42+t.n12,t.n43+t.n13,t.n44+t.n14);o[2]=new THREE.Vector4(t.n41+t.n21,t.n42+t.n22,t.n43+t.n23,t.n44+t.n24);o[3]=new THREE.Vector4(t.n41-t.n21,t.n42-t.n22,t.n43-t.n23,t.n44-t.n24);o[4]=new THREE.Vector4(t.n41-t.n31,t.n42-t.n32,t.n43-
|
|
|
+t.n33,t.n44-t.n34);o[5]=new THREE.Vector4(t.n41+t.n31,t.n42+t.n32,t.n43+t.n33,t.n44+t.n34);w=0;for(z=o.length;w<z;w++){D=o[w];D.divideScalar(Math.sqrt(D.x*D.x+D.y*D.y+D.z*D.z))}z=k.objects;k=0;for(w=z.length;k<w;k++){D=z[k];var B;if(!(B=!D.visible)){if(B=D instanceof THREE.Mesh){a:{B=void 0;for(var I=D.position,O=-D.geometry.boundingSphere.radius*Math.max(D.scale.x,Math.max(D.scale.y,D.scale.z)),Q=0;Q<6;Q++){B=o[Q].x*I.x+o[Q].y*I.y+o[Q].z*I.z+o[Q].w;if(B<=O){B=false;break a}}B=true}B=!B}B=B}if(!B){d=
|
|
|
+f[e]=f[e]||new THREE.RenderableObject;F.copy(D.position);t.multiplyVector3(F);d.object=D;d.z=F.z;x.push(d);e++}}v&&x.sort(a);return x};this.projectScene=function(k,w,v){var x=[],z=w.near,D=w.far,B,I,O,Q,R,U,T,ba,ca,S,K,Z,V,N,W,$;h=y=q=0;w.autoUpdateMatrix&&w.updateMatrix();t.multiply(w.projectionMatrix,w.matrix);U=this.projectObjects(k,w,true);k=0;for(B=U.length;k<B;k++){T=U[k].object;if(T.visible){T.autoUpdateMatrix&&T.updateMatrix();ba=T.matrix;ca=T.rotationMatrix;S=T.materials;K=T.overdraw;if(T instanceof
|
|
|
+THREE.Mesh){Z=T.geometry;V=Z.vertices;I=0;for(O=V.length;I<O;I++){N=V[I];N.positionWorld.copy(N.position);ba.multiplyVector3(N.positionWorld);Q=N.positionScreen;Q.copy(N.positionWorld);t.multiplyVector4(Q);Q.x/=Q.w;Q.y/=Q.w;N.__visible=Q.z>z&&Q.z<D}Z=Z.faces;I=0;for(O=Z.length;I<O;I++){N=Z[I];if(N instanceof THREE.Face3){Q=V[N.a];R=V[N.b];W=V[N.c];if(Q.__visible&&R.__visible&&W.__visible)if(T.doubleSided||T.flipSided!=(W.positionScreen.x-Q.positionScreen.x)*(R.positionScreen.y-Q.positionScreen.y)-
|
|
|
+(W.positionScreen.y-Q.positionScreen.y)*(R.positionScreen.x-Q.positionScreen.x)<0){b=g[h]=g[h]||new THREE.RenderableFace3;b.v1.positionWorld.copy(Q.positionWorld);b.v2.positionWorld.copy(R.positionWorld);b.v3.positionWorld.copy(W.positionWorld);b.v1.positionScreen.copy(Q.positionScreen);b.v2.positionScreen.copy(R.positionScreen);b.v3.positionScreen.copy(W.positionScreen);b.normalWorld.copy(N.normal);ca.multiplyVector3(b.normalWorld);b.centroidWorld.copy(N.centroid);ba.multiplyVector3(b.centroidWorld);
|
|
|
+b.centroidScreen.copy(b.centroidWorld);t.multiplyVector3(b.centroidScreen);W=N.vertexNormals;n=b.vertexNormalsWorld;Q=0;for(R=W.length;Q<R;Q++){$=n[Q]=n[Q]||new THREE.Vector3;$.copy(W[Q]);ca.multiplyVector3($)}b.z=b.centroidScreen.z;b.meshMaterials=S;b.faceMaterials=N.materials;b.overdraw=K;if(T.geometry.uvs[I]){b.uvs[0]=T.geometry.uvs[I][0];b.uvs[1]=T.geometry.uvs[I][1];b.uvs[2]=T.geometry.uvs[I][2]}x.push(b);h++}}else if(N instanceof THREE.Face4){Q=V[N.a];R=V[N.b];W=V[N.c];$=V[N.d];if(Q.__visible&&
|
|
|
+R.__visible&&W.__visible&&$.__visible)if(T.doubleSided||T.flipSided!=(($.positionScreen.x-Q.positionScreen.x)*(R.positionScreen.y-Q.positionScreen.y)-($.positionScreen.y-Q.positionScreen.y)*(R.positionScreen.x-Q.positionScreen.x)<0||(R.positionScreen.x-W.positionScreen.x)*($.positionScreen.y-W.positionScreen.y)-(R.positionScreen.y-W.positionScreen.y)*($.positionScreen.x-W.positionScreen.x)<0)){b=g[h]=g[h]||new THREE.RenderableFace3;b.v1.positionWorld.copy(Q.positionWorld);b.v2.positionWorld.copy(R.positionWorld);
|
|
|
+b.v3.positionWorld.copy($.positionWorld);b.v1.positionScreen.copy(Q.positionScreen);b.v2.positionScreen.copy(R.positionScreen);b.v3.positionScreen.copy($.positionScreen);b.normalWorld.copy(N.normal);ca.multiplyVector3(b.normalWorld);b.centroidWorld.copy(N.centroid);ba.multiplyVector3(b.centroidWorld);b.centroidScreen.copy(b.centroidWorld);t.multiplyVector3(b.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterials=S;b.faceMaterials=N.materials;b.overdraw=K;if(T.geometry.uvs[I]){b.uvs[0]=T.geometry.uvs[I][0];
|
|
|
+b.uvs[1]=T.geometry.uvs[I][1];b.uvs[2]=T.geometry.uvs[I][3]}x.push(b);h++;j=g[h]=g[h]||new THREE.RenderableFace3;j.v1.positionWorld.copy(R.positionWorld);j.v2.positionWorld.copy(W.positionWorld);j.v3.positionWorld.copy($.positionWorld);j.v1.positionScreen.copy(R.positionScreen);j.v2.positionScreen.copy(W.positionScreen);j.v3.positionScreen.copy($.positionScreen);j.normalWorld.copy(b.normalWorld);j.centroidWorld.copy(b.centroidWorld);j.centroidScreen.copy(b.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=
|
|
|
+S;j.faceMaterials=N.materials;j.overdraw=K;if(T.geometry.uvs[I]){j.uvs[0]=T.geometry.uvs[I][1];j.uvs[1]=T.geometry.uvs[I][2];j.uvs[2]=T.geometry.uvs[I][3]}x.push(j);h++}}}}else if(T instanceof THREE.Line){H.multiply(t,ba);V=T.geometry.vertices;N=V[0];N.positionScreen.copy(N.position);H.multiplyVector4(N.positionScreen);I=1;for(O=V.length;I<O;I++){Q=V[I];Q.positionScreen.copy(Q.position);H.multiplyVector4(Q.positionScreen);R=V[I-1];l.copy(Q.positionScreen);p.copy(R.positionScreen);if(c(l,p)){l.multiplyScalar(1/
|
|
|
+l.w);p.multiplyScalar(1/p.w);m=C[y]=C[y]||new THREE.RenderableLine;m.v1.positionScreen.copy(l);m.v2.positionScreen.copy(p);m.z=Math.max(l.z,p.z);m.materials=T.materials;x.push(m);y++}}}else if(T instanceof THREE.Particle){G.set(T.position.x,T.position.y,T.position.z,1);t.multiplyVector4(G);G.z/=G.w;if(G.z>0&&G.z<1){u=A[q]=A[q]||new THREE.RenderableParticle;u.x=G.x/G.w;u.y=G.y/G.w;u.z=G.z;u.rotation=T.rotation.z;u.scale.x=T.scale.x*Math.abs(u.x-(G.x+w.projectionMatrix.n11)/(G.w+w.projectionMatrix.n14));
|
|
|
+u.scale.y=T.scale.y*Math.abs(u.y-(G.y+w.projectionMatrix.n22)/(G.w+w.projectionMatrix.n24));u.materials=T.materials;x.push(u);q++}}}}v&&x.sort(a);return x};this.unprojectVector=function(k,w){var v=THREE.Matrix4.makeInvert(w.matrix);v.multiplySelf(THREE.Matrix4.makeInvert(w.projectionMatrix));v.multiplyVector3(k);return k}};
|
|
|
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,f,b;this.domElement=document.createElement("div");this.setSize=function(j,h){d=j;e=h;f=d/2;b=e/2};this.render=function(j,h){var g,m,y,C,u,q,A,F;a=c.projectScene(j,h);g=0;for(m=a.length;g<m;g++){u=a[g];if(u instanceof THREE.RenderableParticle){A=u.x*f+f;F=u.y*b+b;y=0;for(C=u.material.length;y<C;y++){q=u.material[y];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=A+"px";q.style.top=F+"px"}}}}}};
|
|
|
+THREE.CanvasRenderer=function(){function a(ma){if(u!=ma)m.globalAlpha=u=ma}function c(ma){if(q!=ma){switch(ma){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}q=ma}}var d=null,e=new THREE.Projector,f=document.createElement("canvas"),b,j,h,g,m=f.getContext("2d"),y=new THREE.Color(0),C=0,u=1,q=0,A=null,F=null,G=1,t,H,o,l,p,n,k,w,v,x=new THREE.Color,
|
|
|
+z=new THREE.Color,D=new THREE.Color,B=new THREE.Color,I=new THREE.Color,O,Q,R,U,T,ba,ca,S,K,Z=new THREE.Rectangle,V=new THREE.Rectangle,N=new THREE.Rectangle,W=false,$=new THREE.Color,da=new THREE.Color,ha=new THREE.Color,E=new THREE.Color,L=Math.PI*2,J=new THREE.Vector3,X,ea,ja,ia,qa,la,ua=16;X=document.createElement("canvas");X.width=X.height=2;ea=X.getContext("2d");ea.fillStyle="rgba(0,0,0,1)";ea.fillRect(0,0,2,2);ja=ea.getImageData(0,0,2,2);ia=ja.data;qa=document.createElement("canvas");qa.width=
|
|
|
+qa.height=ua;la=qa.getContext("2d");la.translate(-ua/2,-ua/2);la.scale(ua,ua);ua--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ma,sa){b=ma;j=sa;h=b/2;g=j/2;f.width=b;f.height=j;Z.set(-h,-g,h,g);u=1;q=0;F=A=null;G=1};this.setClearColor=function(ma,sa){y.setHex(ma);C=sa;V.set(-h,-g,h,g);m.setTransform(1,0,0,-1,h,g);this.clear()};this.clear=function(){m.setTransform(1,0,0,-1,h,g);if(!V.isEmpty()){V.inflate(1);V.minSelf(Z);if(y.hex==0&&C==0)m.clearRect(V.getX(),
|
|
|
+V.getY(),V.getWidth(),V.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b*255)+","+C+")";m.fillRect(V.getX(),V.getY(),V.getWidth(),V.getHeight())}V.empty()}};this.render=function(ma,sa){function Ha(M){var fa,aa,P,Y=M.lights;da.setRGB(0,0,0);ha.setRGB(0,0,0);E.setRGB(0,0,0);M=0;for(fa=Y.length;M<fa;M++){aa=Y[M];P=aa.color;if(aa instanceof THREE.AmbientLight){da.r+=P.r;da.g+=P.g;da.b+=P.b}else if(aa instanceof THREE.DirectionalLight){ha.r+=
|
|
|
+P.r;ha.g+=P.g;ha.b+=P.b}else if(aa instanceof THREE.PointLight){E.r+=P.r;E.g+=P.g;E.b+=P.b}}}function Da(M,fa,aa,P){var Y,ga,na,oa,pa=M.lights;M=0;for(Y=pa.length;M<Y;M++){ga=pa[M];na=ga.color;oa=ga.intensity;if(ga instanceof THREE.DirectionalLight){ga=aa.dot(ga.position)*oa;if(ga>0){P.r+=na.r*ga;P.g+=na.g*ga;P.b+=na.b*ga}}else if(ga instanceof THREE.PointLight){J.sub(ga.position,fa);J.normalize();ga=aa.dot(J)*oa;if(ga>0){P.r+=na.r*ga;P.g+=na.g*ga;P.b+=na.b*ga}}}}function Qa(M,fa,aa){if(aa.opacity!=
|
|
|
+0){a(aa.opacity);c(aa.blending);var P,Y,ga,na,oa,pa;if(aa instanceof THREE.ParticleBasicMaterial){if(aa.map&&aa.map.image.loaded){na=aa.map.image;oa=na.width>>1;pa=na.height>>1;Y=fa.scale.x*h;ga=fa.scale.y*g;aa=Y*oa;P=ga*pa;N.set(M.x-aa,M.y-P,M.x+aa,M.y+P);if(Z.instersects(N)){m.save();m.translate(M.x,M.y);m.rotate(-fa.rotation);m.scale(Y,-ga);m.translate(-oa,-pa);m.drawImage(na,0,0);m.restore()}}}else if(aa instanceof THREE.ParticleCircleMaterial){if(W){$.r=da.r+ha.r+E.r;$.g=da.g+ha.g+E.g;$.b=da.b+
|
|
|
+ha.b+E.b;x.r=aa.color.r*$.r;x.g=aa.color.g*$.g;x.b=aa.color.b*$.b;x.updateStyleString()}else x.__styleString=aa.color.__styleString;aa=fa.scale.x*h;P=fa.scale.y*g;N.set(M.x-aa,M.y-P,M.x+aa,M.y+P);if(Z.instersects(N)){Y=x.__styleString;if(F!=Y)m.fillStyle=F=Y;m.save();m.translate(M.x,M.y);m.rotate(-fa.rotation);m.scale(aa,P);m.beginPath();m.arc(0,0,1,0,L,true);m.closePath();m.fill();m.restore()}}}}function Ra(M,fa,aa,P){if(P.opacity!=0){a(P.opacity);c(P.blending);m.beginPath();m.moveTo(M.positionScreen.x,
|
|
|
+M.positionScreen.y);m.lineTo(fa.positionScreen.x,fa.positionScreen.y);m.closePath();if(P instanceof THREE.LineBasicMaterial){x.__styleString=P.color.__styleString;M=P.linewidth;if(G!=M)m.lineWidth=G=M;M=x.__styleString;if(A!=M)m.strokeStyle=A=M;m.stroke();N.inflate(P.linewidth*2)}}}function Ma(M,fa,aa,P,Y,ga){if(Y.opacity!=0){a(Y.opacity);c(Y.blending);l=M.positionScreen.x;p=M.positionScreen.y;n=fa.positionScreen.x;k=fa.positionScreen.y;w=aa.positionScreen.x;v=aa.positionScreen.y;m.beginPath();m.moveTo(l,
|
|
|
+p);m.lineTo(n,k);m.lineTo(w,v);m.lineTo(l,p);m.closePath();if(Y instanceof THREE.MeshBasicMaterial)if(Y.map)Y.map.image.loaded&&Y.map.mapping instanceof THREE.UVMapping&&Aa(l,p,n,k,w,v,Y.map.image,P.uvs[0].u,P.uvs[0].v,P.uvs[1].u,P.uvs[1].v,P.uvs[2].u,P.uvs[2].v);else if(Y.env_map){if(Y.env_map.image.loaded)if(Y.env_map.mapping instanceof THREE.SphericalReflectionMapping){M=sa.matrix;J.copy(P.vertexNormalsWorld[0]);U=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;T=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;
|
|
|
+J.copy(P.vertexNormalsWorld[1]);ba=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;ca=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;J.copy(P.vertexNormalsWorld[2]);S=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;K=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;Aa(l,p,n,k,w,v,Y.env_map.image,U,T,ba,ca,S,K)}}else Y.wireframe?Ea(Y.color.__styleString,Y.wireframe_linewidth):Fa(Y.color.__styleString);else if(Y instanceof THREE.MeshLambertMaterial){if(Y.map&&!Y.wireframe){Y.map.mapping instanceof THREE.UVMapping&&Aa(l,p,n,k,w,
|
|
|
+v,Y.map.image,P.uvs[0].u,P.uvs[0].v,P.uvs[1].u,P.uvs[1].v,P.uvs[2].u,P.uvs[2].v);c(THREE.SubtractiveBlending)}if(W)if(!Y.wireframe&&Y.shading==THREE.SmoothShading&&P.vertexNormalsWorld.length==3){z.r=D.r=B.r=da.r;z.g=D.g=B.g=da.g;z.b=D.b=B.b=da.b;Da(ga,P.v1.positionWorld,P.vertexNormalsWorld[0],z);Da(ga,P.v2.positionWorld,P.vertexNormalsWorld[1],D);Da(ga,P.v3.positionWorld,P.vertexNormalsWorld[2],B);I.r=(D.r+B.r)*0.5;I.g=(D.g+B.g)*0.5;I.b=(D.b+B.b)*0.5;R=Na(z,D,B,I);Aa(l,p,n,k,w,v,R,0,0,1,0,0,1)}else{$.r=
|
|
|
+da.r;$.g=da.g;$.b=da.b;Da(ga,P.centroidWorld,P.normalWorld,$);x.r=Y.color.r*$.r;x.g=Y.color.g*$.g;x.b=Y.color.b*$.b;x.updateStyleString();Y.wireframe?Ea(x.__styleString,Y.wireframe_linewidth):Fa(x.__styleString)}else Y.wireframe?Ea(Y.color.__styleString,Y.wireframe_linewidth):Fa(Y.color.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){O=sa.near;Q=sa.far;z.r=z.g=z.b=1-Ia(M.positionScreen.z,O,Q);D.r=D.g=D.b=1-Ia(fa.positionScreen.z,O,Q);B.r=B.g=B.b=1-Ia(aa.positionScreen.z,O,Q);I.r=(D.r+
|
|
|
+B.r)*0.5;I.g=(D.g+B.g)*0.5;I.b=(D.b+B.b)*0.5;R=Na(z,D,B,I);Aa(l,p,n,k,w,v,R,0,0,1,0,0,1)}else if(Y instanceof THREE.MeshNormalMaterial){x.r=Ja(P.normalWorld.x);x.g=Ja(P.normalWorld.y);x.b=Ja(P.normalWorld.z);x.updateStyleString();Y.wireframe?Ea(x.__styleString,Y.wireframe_linewidth):Fa(x.__styleString)}}}function Ea(M,fa){if(A!=M)m.strokeStyle=A=M;if(G!=fa)m.lineWidth=G=fa;m.stroke();N.inflate(fa*2)}function Fa(M){if(F!=M)m.fillStyle=F=M;m.fill()}function Aa(M,fa,aa,P,Y,ga,na,oa,pa,va,ra,wa,Ba){var ya,
|
|
|
+xa;ya=na.width-1;xa=na.height-1;oa*=ya;pa*=xa;va*=ya;ra*=xa;wa*=ya;Ba*=xa;aa-=M;P-=fa;Y-=M;ga-=fa;va-=oa;ra-=pa;wa-=oa;Ba-=pa;xa=1/(va*Ba-wa*ra);ya=(Ba*aa-ra*Y)*xa;ra=(Ba*P-ra*ga)*xa;aa=(va*Y-wa*aa)*xa;P=(va*ga-wa*P)*xa;M=M-ya*oa-aa*pa;fa=fa-ra*oa-P*pa;m.save();m.transform(ya,ra,aa,P,M,fa);m.clip();m.drawImage(na,0,0);m.restore()}function Na(M,fa,aa,P){var Y=~~(M.r*255),ga=~~(M.g*255);M=~~(M.b*255);var na=~~(fa.r*255),oa=~~(fa.g*255);fa=~~(fa.b*255);var pa=~~(aa.r*255),va=~~(aa.g*255);aa=~~(aa.b*
|
|
|
+255);var ra=~~(P.r*255),wa=~~(P.g*255);P=~~(P.b*255);ia[0]=Y<0?0:Y>255?255:Y;ia[1]=ga<0?0:ga>255?255:ga;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]=fa<0?0:fa>255?255:fa;ia[8]=pa<0?0:pa>255?255:pa;ia[9]=va<0?0:va>255?255:va;ia[10]=aa<0?0:aa>255?255:aa;ia[12]=ra<0?0:ra>255?255:ra;ia[13]=wa<0?0:wa>255?255:wa;ia[14]=P<0?0:P>255?255:P;ea.putImageData(ja,0,0);la.drawImage(X,0,0);return qa}function Ia(M,fa,aa){M=(M-fa)/(aa-fa);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,fa){var aa=fa.x-M.x,P=fa.y-M.y,Y=1/Math.sqrt(aa*aa+P*P);aa*=Y;P*=Y;fa.x+=aa;fa.y+=P;M.x-=aa;M.y-=P}var Ga,Oa,ka,ta,za,La,Pa,Ca;this.autoClear?this.clear():m.setTransform(1,0,0,-1,h,g);d=e.projectScene(ma,sa,this.sortElements);(W=ma.lights.length>0)&&Ha(ma);Ga=0;for(Oa=d.length;Ga<Oa;Ga++){ka=d[Ga];N.empty();if(ka instanceof THREE.RenderableParticle){t=ka;t.x*=h;t.y*=g;ta=0;for(za=ka.materials.length;ta<za;ta++)Qa(t,ka,ka.materials[ta],ma)}else if(ka instanceof
|
|
|
+THREE.RenderableLine){t=ka.v1;H=ka.v2;t.positionScreen.x*=h;t.positionScreen.y*=g;H.positionScreen.x*=h;H.positionScreen.y*=g;N.addPoint(t.positionScreen.x,t.positionScreen.y);N.addPoint(H.positionScreen.x,H.positionScreen.y);if(Z.instersects(N)){ta=0;for(za=ka.materials.length;ta<za;)Ra(t,H,ka,ka.materials[ta++],ma)}}else if(ka instanceof THREE.RenderableFace3){t=ka.v1;H=ka.v2;o=ka.v3;t.positionScreen.x*=h;t.positionScreen.y*=g;H.positionScreen.x*=h;H.positionScreen.y*=g;o.positionScreen.x*=h;o.positionScreen.y*=
|
|
|
+g;if(ka.overdraw){Ka(t.positionScreen,H.positionScreen);Ka(H.positionScreen,o.positionScreen);Ka(o.positionScreen,t.positionScreen)}N.add3Points(t.positionScreen.x,t.positionScreen.y,H.positionScreen.x,H.positionScreen.y,o.positionScreen.x,o.positionScreen.y);if(Z.instersects(N)){ta=0;for(za=ka.meshMaterials.length;ta<za;){Ca=ka.meshMaterials[ta++];if(Ca instanceof THREE.MeshFaceMaterial){La=0;for(Pa=ka.faceMaterials.length;La<Pa;)(Ca=ka.faceMaterials[La++])&&Ma(t,H,o,ka,Ca,ma)}else Ma(t,H,o,ka,Ca,
|
|
|
+ma)}}}V.addRectangle(N)}m.setTransform(1,0,0,1,0,0)}};
|
|
|
+THREE.SVGRenderer=function(){function a(U,T,ba){var ca,S,K,Z;ca=0;for(S=U.lights.length;ca<S;ca++){K=U.lights[ca];if(K instanceof THREE.DirectionalLight){Z=T.normalWorld.dot(K.position)*K.intensity;if(Z>0){ba.r+=K.color.r*Z;ba.g+=K.color.g*Z;ba.b+=K.color.b*Z}}else if(K instanceof THREE.PointLight){v.sub(K.position,T.centroidWorld);v.normalize();Z=T.normalWorld.dot(v)*K.intensity;if(Z>0){ba.r+=K.color.r*Z;ba.g+=K.color.g*Z;ba.b+=K.color.b*Z}}}}function c(U,T,ba,ca,S,K){B=e(I++);B.setAttribute("d",
|
|
|
+"M "+U.positionScreen.x+" "+U.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)o.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(H){l.r=p.r;l.g=p.g;l.b=p.b;a(K,ca,l);o.r=S.color.r*l.r;o.g=S.color.g*l.g;o.b=S.color.b*l.b;o.updateStyleString()}else o.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){w=1-S.__2near/(S.__farPlusNear-
|
|
|
+ca.z*S.__farMinusNear);o.setRGB(w,w,w)}else S instanceof THREE.MeshNormalMaterial&&o.setRGB(f(ca.normalWorld.x),f(ca.normalWorld.y),f(ca.normalWorld.z));S.wireframe?B.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+S.wireframe_linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframe_linecap+"; stroke-linejoin: "+S.wireframe_linejoin):B.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+S.opacity);h.appendChild(B)}function d(U,T,ba,ca,S,
|
|
|
+K,Z){B=e(I++);B.setAttribute("d","M "+U.positionScreen.x+" "+U.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");if(K instanceof THREE.MeshBasicMaterial)o.__styleString=K.color.__styleString;else if(K instanceof THREE.MeshLambertMaterial)if(H){l.r=p.r;l.g=p.g;l.b=p.b;a(Z,S,l);o.r=K.color.r*l.r;o.g=K.color.g*l.g;o.b=K.color.b*l.b;o.updateStyleString()}else o.__styleString=K.color.__styleString;
|
|
|
+else if(K instanceof THREE.MeshDepthMaterial){w=1-K.__2near/(K.__farPlusNear-S.z*K.__farMinusNear);o.setRGB(w,w,w)}else K instanceof THREE.MeshNormalMaterial&&o.setRGB(f(S.normalWorld.x),f(S.normalWorld.y),f(S.normalWorld.z));K.wireframe?B.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+K.wireframe_linewidth+"; stroke-opacity: "+K.opacity+"; stroke-linecap: "+K.wireframe_linecap+"; stroke-linejoin: "+K.wireframe_linejoin):B.setAttribute("style","fill: "+o.__styleString+
|
|
|
+"; fill-opacity: "+K.opacity);h.appendChild(B)}function e(U){if(x[U]==null){x[U]=document.createElementNS("http://www.w3.org/2000/svg","path");R==0&&x[U].setAttribute("shape-rendering","crispEdges");return x[U]}return x[U]}function f(U){return U<0?Math.min((1+U)*0.5,0.5):0.5+Math.min(U*0.5,0.5)}var b=null,j=new THREE.Projector,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),g,m,y,C,u,q,A,F,G=new THREE.Rectangle,t=new THREE.Rectangle,H=false,o=new THREE.Color(16777215),l=new THREE.Color(16777215),
|
|
|
+p=new THREE.Color(0),n=new THREE.Color(0),k=new THREE.Color(0),w,v=new THREE.Vector3,x=[],z=[],D=[],B,I,O,Q,R=1;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(U){switch(U){case "high":R=1;break;case "low":R=0}};this.setSize=function(U,T){g=U;m=T;y=g/2;C=m/2;h.setAttribute("viewBox",-y+" "+-C+" "+g+" "+m);h.setAttribute("width",g);h.setAttribute("height",m);G.set(-y,-C,y,C)};this.clear=function(){for(;h.childNodes.length>0;)h.removeChild(h.childNodes[0])};
|
|
|
+this.render=function(U,T){var ba,ca,S,K,Z,V,N,W;this.autoClear&&this.clear();b=j.projectScene(U,T,this.sortElements);Q=O=I=0;if(H=U.lights.length>0){N=U.lights;p.setRGB(0,0,0);n.setRGB(0,0,0);k.setRGB(0,0,0);ba=0;for(ca=N.length;ba<ca;ba++){S=N[ba];K=S.color;if(S instanceof THREE.AmbientLight){p.r+=K.r;p.g+=K.g;p.b+=K.b}else if(S instanceof THREE.DirectionalLight){n.r+=K.r;n.g+=K.g;n.b+=K.b}else if(S instanceof THREE.PointLight){k.r+=K.r;k.g+=K.g;k.b+=K.b}}}ba=0;for(ca=b.length;ba<ca;ba++){N=b[ba];
|
|
|
+t.empty();if(N instanceof THREE.RenderableParticle){u=N;u.x*=y;u.y*=-C;S=0;for(K=N.materials.length;S<K;S++)if(W=N.materials[S]){Z=u;V=N;W=W;var $=O++;if(z[$]==null){z[$]=document.createElementNS("http://www.w3.org/2000/svg","circle");R==0&&z[$].setAttribute("shape-rendering","crispEdges")}B=z[$];B.setAttribute("cx",Z.x);B.setAttribute("cy",Z.y);B.setAttribute("r",V.scale.x*y);if(W instanceof THREE.ParticleCircleMaterial){if(H){l.r=p.r+n.r+k.r;l.g=p.g+n.g+k.g;l.b=p.b+n.b+k.b;o.r=W.color.r*l.r;o.g=
|
|
|
+W.color.g*l.g;o.b=W.color.b*l.b;o.updateStyleString()}else o=W.color;B.setAttribute("style","fill: "+o.__styleString)}h.appendChild(B)}}else if(N instanceof THREE.RenderableLine){u=N.v1;q=N.v2;u.positionScreen.x*=y;u.positionScreen.y*=-C;q.positionScreen.x*=y;q.positionScreen.y*=-C;t.addPoint(u.positionScreen.x,u.positionScreen.y);t.addPoint(q.positionScreen.x,q.positionScreen.y);if(G.instersects(t)){S=0;for(K=N.materials.length;S<K;)if(W=N.materials[S++]){Z=u;V=q;W=W;$=Q++;if(D[$]==null){D[$]=document.createElementNS("http://www.w3.org/2000/svg",
|
|
|
+"line");R==0&&D[$].setAttribute("shape-rendering","crispEdges")}B=D[$];B.setAttribute("x1",Z.positionScreen.x);B.setAttribute("y1",Z.positionScreen.y);B.setAttribute("x2",V.positionScreen.x);B.setAttribute("y2",V.positionScreen.y);if(W instanceof THREE.LineBasicMaterial){o.__styleString=W.color.__styleString;B.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+W.linewidth+"; stroke-opacity: "+W.opacity+"; stroke-linecap: "+W.linecap+"; stroke-linejoin: "+W.linejoin);h.appendChild(B)}}}}else if(N instanceof
|
|
|
+THREE.RenderableFace3){u=N.v1;q=N.v2;A=N.v3;u.positionScreen.x*=y;u.positionScreen.y*=-C;q.positionScreen.x*=y;q.positionScreen.y*=-C;A.positionScreen.x*=y;A.positionScreen.y*=-C;t.addPoint(u.positionScreen.x,u.positionScreen.y);t.addPoint(q.positionScreen.x,q.positionScreen.y);t.addPoint(A.positionScreen.x,A.positionScreen.y);if(G.instersects(t)){S=0;for(K=N.meshMaterials.length;S<K;){W=N.meshMaterials[S++];if(W instanceof THREE.MeshFaceMaterial){Z=0;for(V=N.faceMaterials.length;Z<V;)(W=N.faceMaterials[Z++])&&
|
|
|
+c(u,q,A,N,W,U)}else W&&c(u,q,A,N,W,U)}}}else if(N instanceof THREE.RenderableFace4){u=N.v1;q=N.v2;A=N.v3;F=N.v4;u.positionScreen.x*=y;u.positionScreen.y*=-C;q.positionScreen.x*=y;q.positionScreen.y*=-C;A.positionScreen.x*=y;A.positionScreen.y*=-C;F.positionScreen.x*=y;F.positionScreen.y*=-C;t.addPoint(u.positionScreen.x,u.positionScreen.y);t.addPoint(q.positionScreen.x,q.positionScreen.y);t.addPoint(A.positionScreen.x,A.positionScreen.y);t.addPoint(F.positionScreen.x,F.positionScreen.y);if(G.instersects(t)){S=
|
|
|
+0;for(K=N.meshMaterials.length;S<K;){W=N.meshMaterials[S++];if(W instanceof THREE.MeshFaceMaterial){Z=0;for(V=N.faceMaterials.length;Z<V;)(W=N.faceMaterials[Z++])&&d(u,q,A,F,N,W,U)}else W&&d(u,q,A,F,N,W,U)}}}}}};
|
|
|
+THREE.WebGLRenderer=function(a){function c(l,p){l.fragment_shader=p.fragment_shader;l.vertex_shader=p.vertex_shader;l.uniforms=Uniforms.clone(p.uniforms)}function d(l,p){var n;if(l=="fragment")n=b.createShader(b.FRAGMENT_SHADER);else if(l=="vertex")n=b.createShader(b.VERTEX_SHADER);b.shaderSource(n,p);b.compileShader(n);if(!b.getShaderParameter(n,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(n));return null}return n}function e(l){switch(l){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 f=document.createElement("canvas"),b,j=null,h=null,g=new THREE.Matrix4,m,w=new Float32Array(16),B=new Float32Array(16),
|
|
|
-u=new Float32Array(16),q=new Float32Array(9),x=new Float32Array(16),E=new THREE.Matrix4,H=new THREE.Vector4,t=true,I=new THREE.Color(0),o=0;if(a){if(a.antialias!==undefined)t=a.antialias;a.clearColor!==undefined&&I.setHex(a.clearColor);if(a.clearAlpha!==undefined)o=a.clearAlpha}this.domElement=f;this.autoClear=true;(function(k,p,n){try{b=f.getContext("experimental-webgl",{antialias:k})}catch(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,n)})(t,I,o);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(k,p){f.width=k;f.height=p;b.viewport(0,0,f.width,f.height)};this.setClearColor=function(k,p){var n=new THREE.Color(k);b.clearColor(n.r,n.g,n.b,p)};
|
|
|
-this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(k,p){var n,l,v,C=0,y=0,z=0,D,A,F,T=this.lights,N=T.directional.colors,X=T.directional.positions,W=T.point.colors,R=T.point.positions,Y=0,ea=0;n=0;for(l=p.length;n<l;n++){v=p[n];D=v.color;A=v.position;F=v.intensity;if(v instanceof THREE.AmbientLight){C+=D.r;y+=D.g;z+=D.b}else if(v instanceof THREE.DirectionalLight){N[Y*3]=D.r*F;N[Y*3+1]=D.g*F;N[Y*3+2]=D.b*F;X[Y*3]=A.x;X[Y*3+1]=A.y;X[Y*3+2]=A.z;Y+=1}else if(v instanceof
|
|
|
-THREE.PointLight){W[ea*3]=D.r*F;W[ea*3+1]=D.g*F;W[ea*3+2]=D.b*F;R[ea*3]=A.x;R[ea*3+1]=A.y;R[ea*3+2]=A.z;ea+=1}}T.point.length=ea;T.directional.length=Y;T.ambient[0]=C;T.ambient[1]=y;T.ambient[2]=z};this.createParticleBuffers=function(k){k.__webGLVertexBuffer=b.createBuffer();k.__webGLParticleBuffer=b.createBuffer()};this.createLineBuffers=function(k){k.__webGLVertexBuffer=b.createBuffer();k.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=function(k){k.__webGLVertexBuffer=b.createBuffer();
|
|
|
-k.__webGLNormalBuffer=b.createBuffer();k.__webGLTangentBuffer=b.createBuffer();k.__webGLUVBuffer=b.createBuffer();k.__webGLUV2Buffer=b.createBuffer();k.__webGLFaceBuffer=b.createBuffer();k.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(k){var p=k.vertices.length;k.__vertexArray=new Float32Array(p*3);k.__lineArray=new Uint16Array(p);k.__webGLLineCount=p};this.initParticleBuffers=function(k){var p=k.vertices.length;k.__vertexArray=new Float32Array(p*3);k.__particleArray=new Uint16Array(p);
|
|
|
-k.__sortArray=[];k.__webGLParticleCount=p};this.initMeshBuffers=function(k,p){var n,l,v=0,C=0,y=0,z=p.geometry.faces,D=k.faces;n=0;for(l=D.length;n<l;n++){fi=D[n];face=z[fi];if(face instanceof THREE.Face3){v+=3;C+=1;y+=3}else if(face instanceof THREE.Face4){v+=4;C+=2;y+=4}}k.__vertexArray=new Float32Array(v*3);k.__normalArray=new Float32Array(v*3);k.__tangentArray=new Float32Array(v*4);k.__uvArray=new Float32Array(v*2);k.__uv2Array=new Float32Array(v*2);k.__faceArray=new Uint16Array(C*3);k.__lineArray=
|
|
|
-new Uint16Array(y*2);v=false;n=0;for(l=p.materials.length;n<l;n++){z=p.materials[n];if(z instanceof THREE.MeshFaceMaterial){z=0;for(D=k.materials.length;z<D;z++)if(k.materials[z]&&k.materials[z].shading!=undefined&&k.materials[z].shading==THREE.SmoothShading){v=true;break}}else if(z&&z.shading!=undefined&&z.shading==THREE.SmoothShading){v=true;break}if(v)break}k.__needsSmoothNormals=v;k.__webGLFaceCount=C*3;k.__webGLLineCount=y*2};this.setMeshBuffers=function(k,p,n,l,v,C,y,z){var D,A,F,T,N,X,W,R,
|
|
|
-Y,ea,Q=0,P=0,ca=0,aa=0,K=0,U=0,V=0,ga=0,fa=k.__vertexArray,G=k.__uvArray,L=k.__uv2Array,J=k.__normalArray,O=k.__tangentArray,ba=k.__faceArray,ia=k.__lineArray,ja=k.__needsSmoothNormals,pa=p.geometry,la=pa.vertices,ua=k.faces,ma=pa.faces,sa=pa.uvs,Ha=pa.uvs2;p=0;for(D=ua.length;p<D;p++){A=ua[p];F=ma[A];X=sa[A];A=Ha[A];T=F.vertexNormals;N=F.normal;if(F instanceof THREE.Face3){if(l){W=la[F.a].position;R=la[F.b].position;Y=la[F.c].position;fa[P]=W.x;fa[P+1]=W.y;fa[P+2]=W.z;fa[P+3]=R.x;fa[P+4]=R.y;fa[P+
|
|
|
-5]=R.z;fa[P+6]=Y.x;fa[P+7]=Y.y;fa[P+8]=Y.z;P+=9}if(z&&pa.hasTangents){W=la[F.a].tangent;R=la[F.b].tangent;Y=la[F.c].tangent;O[V]=W.x;O[V+1]=W.y;O[V+2]=W.z;O[V+3]=W.w;O[V+4]=R.x;O[V+5]=R.y;O[V+6]=R.z;O[V+7]=R.w;O[V+8]=Y.x;O[V+9]=Y.y;O[V+10]=Y.z;O[V+11]=Y.w;V+=12}if(y)if(T.length==3&&ja)for(F=0;F<3;F++){N=T[F];J[U]=N.x;J[U+1]=N.y;J[U+2]=N.z;U+=3}else for(F=0;F<3;F++){J[U]=N.x;J[U+1]=N.y;J[U+2]=N.z;U+=3}if(C&&X)for(F=0;F<3;F++){T=X[F];G[ca]=T.u;G[ca+1]=T.v;ca+=2}if(C&&A)for(F=0;F<3;F++){X=A[F];L[aa]=
|
|
|
-X.u;L[aa+1]=X.v;aa+=2}if(v){ba[K]=Q;ba[K+1]=Q+1;ba[K+2]=Q+2;K+=3;ia[ga]=Q;ia[ga+1]=Q+1;ia[ga+2]=Q;ia[ga+3]=Q+2;ia[ga+4]=Q+1;ia[ga+5]=Q+2;ga+=6;Q+=3}}else if(F instanceof THREE.Face4){if(l){W=la[F.a].position;R=la[F.b].position;Y=la[F.c].position;ea=la[F.d].position;fa[P]=W.x;fa[P+1]=W.y;fa[P+2]=W.z;fa[P+3]=R.x;fa[P+4]=R.y;fa[P+5]=R.z;fa[P+6]=Y.x;fa[P+7]=Y.y;fa[P+8]=Y.z;fa[P+9]=ea.x;fa[P+10]=ea.y;fa[P+11]=ea.z;P+=12}if(z&&pa.hasTangents){W=la[F.a].tangent;R=la[F.b].tangent;Y=la[F.c].tangent;F=la[F.d].tangent;
|
|
|
-O[V]=W.x;O[V+1]=W.y;O[V+2]=W.z;O[V+3]=W.w;O[V+4]=R.x;O[V+5]=R.y;O[V+6]=R.z;O[V+7]=R.w;O[V+8]=Y.x;O[V+9]=Y.y;O[V+10]=Y.z;O[V+11]=Y.w;O[V+12]=F.x;O[V+13]=F.y;O[V+14]=F.z;O[V+15]=F.w;V+=16}if(y)if(T.length==4&&ja)for(F=0;F<4;F++){N=T[F];J[U]=N.x;J[U+1]=N.y;J[U+2]=N.z;U+=3}else for(F=0;F<4;F++){J[U]=N.x;J[U+1]=N.y;J[U+2]=N.z;U+=3}if(C&&X)for(F=0;F<4;F++){T=X[F];G[ca]=T.u;G[ca+1]=T.v;ca+=2}if(C&&A)for(F=0;F<4;F++){X=A[F];L[aa]=X.u;L[aa+1]=X.v;aa+=2}if(v){ba[K]=Q;ba[K+1]=Q+1;ba[K+2]=Q+2;ba[K+3]=Q;ba[K+
|
|
|
-4]=Q+2;ba[K+5]=Q+3;K+=6;ia[ga]=Q;ia[ga+1]=Q+1;ia[ga+2]=Q;ia[ga+3]=Q+3;ia[ga+4]=Q+1;ia[ga+5]=Q+2;ia[ga+6]=Q+2;ia[ga+7]=Q+3;ga+=8;Q+=4}}}if(l){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,fa,n)}if(y){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,J,n)}if(z&&pa.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,O,n)}if(C&&ca>0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,
|
|
|
-G,n)}if(C&&aa>0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,L,n)}if(v){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ba,n);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ia,n)}};this.setLineBuffers=function(k,p,n,l){var v,C,y=k.vertices,z=y.length,D=k.__vertexArray,A=k.__lineArray;if(n)for(n=0;n<z;n++){v=y[n].position;C=n*3;D[C]=v.x;D[C+1]=v.y;D[C+2]=v.z}if(l)for(n=0;n<z;n++)A[n]=
|
|
|
-n;b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,D,p);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,A,p)};this.setParticleBuffers=function(k,p,n,l,v,C){var y=k.vertices,z=y.length,D=k.__vertexArray,A=k.__particleArray,F=k.__sortArray;if(v.sortParticles){E.multiply(C.projectionMatrix,C.matrix);E.multiplySelf(v.matrix);for(n=0;n<z;n++){v=y[n].position;H.copy(v);E.multiplyVector3(H);F[n]=[H.z,n]}F.sort(function(T,N){return N[0]-
|
|
|
-T[0]});for(n=0;n<z;n++){v=y[F[n][1]].position;C=n*3;D[C]=v.x;D[C+1]=v.y;D[C+2]=v.z}}else if(n)for(n=0;n<z;n++){v=y[n].position;C=n*3;D[C]=v.x;D[C+1]=v.y;D[C+2]=v.z}if(l)for(n=0;n<z;n++)A[n]=n;b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,D,p);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,A,p)};this.initMaterial=function(k,p,n){if(!k.program){var l,v;if(k instanceof THREE.MeshDepthMaterial)c(k,THREE.ShaderLib.depth);
|
|
|
-else if(k instanceof THREE.MeshNormalMaterial)c(k,THREE.ShaderLib.normal);else if(k instanceof THREE.MeshBasicMaterial)c(k,THREE.ShaderLib.basic);else if(k instanceof THREE.MeshLambertMaterial)c(k,THREE.ShaderLib.lambert);else if(k instanceof THREE.MeshPhongMaterial)c(k,THREE.ShaderLib.phong);else if(k instanceof THREE.LineBasicMaterial)c(k,THREE.ShaderLib.basic);else k instanceof THREE.ParticleBasicMaterial&&c(k,THREE.ShaderLib.particle_basic);var C,y,z,D;v=z=D=0;for(C=p.length;v<C;v++){y=p[v];y instanceof
|
|
|
-THREE.DirectionalLight&&z++;y instanceof THREE.PointLight&&D++}if(D+z<=4){p=z;D=D}else{p=Math.ceil(4*z/(D+z));D=4-p}v={directional:p,point:D};D=k.fragment_shader;p=k.vertex_shader;C={fog:n,map:k.map,env_map:k.env_map,light_map:k.light_map,maxDirLights:v.directional,maxPointLights:v.point};n=b.createProgram();v=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+C.maxDirLights,"#define MAX_POINT_LIGHTS "+C.maxPointLights,C.fog?"#define USE_FOG":"",C.fog instanceof THREE.FogExp2?
|
|
|
-"#define FOG_EXP2":"",C.map?"#define USE_MAP":"",C.env_map?"#define USE_ENVMAP":"",C.light_map?"#define USE_LIGHTMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");C=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+C.maxDirLights,"#define MAX_POINT_LIGHTS "+C.maxPointLights,C.map?"#define USE_MAP":"",C.env_map?"#define USE_ENVMAP":"",C.light_map?"#define USE_LIGHTMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");
|
|
|
-b.attachShader(n,d("fragment",v+D));b.attachShader(n,d("vertex",C+p));b.linkProgram(n);b.getProgramParameter(n,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(n,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");n.uniforms={};n.attributes={};k.program=n;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(l in k.uniforms)n.push(l);l=k.program;D=0;for(p=n.length;D<p;D++){v=n[D];l.uniforms[v]=b.getUniformLocation(l,
|
|
|
-v)}k=k.program;l=["position","normal","uv","uv2","tangent"];n=0;for(D=l.length;n<D;n++){p=l[n];k.attributes[p]=b.getAttribLocation(k,p)}}};this.renderBuffer=function(k,p,n,l,v,C){var y;this.initMaterial(l,p,n);y=l.program;if(y!=j){b.useProgram(y);j=y}this.loadCamera(y,k);this.loadMatrices(y);if(l instanceof THREE.MeshPhongMaterial||l instanceof THREE.MeshLambertMaterial){this.setupLights(y,p);p=this.lights;l.uniforms.enableLighting.value=p.directional.length+p.point.length;l.uniforms.ambientLightColor.value=
|
|
|
-p.ambient;l.uniforms.directionalLightColor.value=p.directional.colors;l.uniforms.directionalLightDirection.value=p.directional.positions;l.uniforms.pointLightColor.value=p.point.colors;l.uniforms.pointLightPosition.value=p.point.positions}if(l instanceof THREE.MeshBasicMaterial||l instanceof THREE.MeshLambertMaterial||l instanceof THREE.MeshPhongMaterial){l.uniforms.color.value.setRGB(l.color.r*l.opacity,l.color.g*l.opacity,l.color.b*l.opacity);l.uniforms.opacity.value=l.opacity;l.uniforms.map.texture=
|
|
|
-l.map;l.uniforms.light_map.texture=l.light_map;l.uniforms.env_map.texture=l.env_map;l.uniforms.reflectivity.value=l.reflectivity;l.uniforms.refraction_ratio.value=l.refraction_ratio;l.uniforms.combine.value=l.combine;l.uniforms.useRefract.value=l.env_map&&l.env_map.mapping instanceof THREE.CubeRefractionMapping;if(n){l.uniforms.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){l.uniforms.fogNear.value=n.near;l.uniforms.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)l.uniforms.fogDensity.value=
|
|
|
-n.density}}if(l instanceof THREE.LineBasicMaterial){l.uniforms.color.value.setRGB(l.color.r*l.opacity,l.color.g*l.opacity,l.color.b*l.opacity);l.uniforms.opacity.value=l.opacity;if(n){l.uniforms.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){l.uniforms.fogNear.value=n.near;l.uniforms.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)l.uniforms.fogDensity.value=n.density}}if(l instanceof THREE.ParticleBasicMaterial){l.uniforms.color.value.setRGB(l.color.r*l.opacity,l.color.g*l.opacity,
|
|
|
-l.color.b*l.opacity);l.uniforms.opacity.value=l.opacity;l.uniforms.size.value=l.size;l.uniforms.map.texture=l.map;if(n){l.uniforms.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){l.uniforms.fogNear.value=n.near;l.uniforms.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)l.uniforms.fogDensity.value=n.density}}if(l instanceof THREE.MeshPhongMaterial){l.uniforms.ambient.value.setRGB(l.ambient.r,l.ambient.g,l.ambient.b);l.uniforms.specular.value.setRGB(l.specular.r,l.specular.g,l.specular.b);
|
|
|
-l.uniforms.shininess.value=l.shininess}if(l instanceof THREE.MeshDepthMaterial){l.uniforms.mNear.value=k.near;l.uniforms.mFar.value=k.far}k=l.uniforms;var z,D,A;for(z in k)if(A=y.uniforms[z]){p=k[z];D=p.type;n=p.value;if(D=="i")b.uniform1i(A,n);else if(D=="f")b.uniform1f(A,n);else if(D=="fv1")b.uniform1fv(A,n);else if(D=="fv")b.uniform3fv(A,n);else if(D=="v2")b.uniform2f(A,n.x,n.y);else if(D=="v3")b.uniform3f(A,n.x,n.y,n.z);else if(D=="c")b.uniform3f(A,n.r,n.g,n.b);else if(D=="t"){b.uniform1i(A,n);
|
|
|
-if(p=p.texture)if(p.image instanceof Array&&p.image.length==6){p=p;n=n;if(p.image.length==6){if(!p.image.__webGLTextureCube&&!p.image.__cubeMapInitialized&&p.image.loadCount==6){p.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,
|
|
|
-b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(D=0;D<6;++D)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,p.image[D]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);p.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+n);b.bindTexture(b.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube)}}else{p=p;n=n;if(!p.__webGLTexture&&p.image.loaded){p.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,p.__webGLTexture);b.texImage2D(b.TEXTURE_2D,
|
|
|
-0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,p.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,e(p.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,e(p.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,e(p.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e(p.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+n);b.bindTexture(b.TEXTURE_2D,p.__webGLTexture)}}}y=y.attributes;b.bindBuffer(b.ARRAY_BUFFER,v.__webGLVertexBuffer);b.vertexAttribPointer(y.position,
|
|
|
-3,b.FLOAT,false,0,0);b.enableVertexAttribArray(y.position);if(y.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLNormalBuffer);b.vertexAttribPointer(y.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(y.normal)}if(y.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLTangentBuffer);b.vertexAttribPointer(y.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(y.tangent)}if(y.uv>=0)if(v.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLUVBuffer);b.vertexAttribPointer(y.uv,2,b.FLOAT,false,0,0);
|
|
|
-b.enableVertexAttribArray(y.uv)}else b.disableVertexAttribArray(y.uv);if(y.uv2>=0)if(v.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLUV2Buffer);b.vertexAttribPointer(y.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(y.uv2)}else b.disableVertexAttribArray(y.uv2);if(l.wireframe||l instanceof THREE.LineBasicMaterial){y=l.wireframe_linewidth!==undefined?l.wireframe_linewidth:l.linewidth!==undefined?l.linewidth:1;l=l instanceof THREE.LineBasicMaterial&&C.type==THREE.LineStrip?b.LINE_STRIP:
|
|
|
-b.LINES;b.lineWidth(y);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,v.__webGLLineBuffer);b.drawElements(l,v.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(l instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,v.__webGLParticleBuffer);b.drawElements(b.POINTS,v.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,v.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,v.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(k,p,n,l,v,C,y){var z,D,A,F,T;A=0;
|
|
|
-for(F=l.materials.length;A<F;A++){z=l.materials[A];if(z instanceof THREE.MeshFaceMaterial){z=0;for(D=v.materials.length;z<D;z++)if((T=v.materials[z])&&T.blending==C&&T.opacity<1==y){this.setBlending(T.blending);this.renderBuffer(k,p,n,T,v,l)}}else if((T=z)&&T.blending==C&&T.opacity<1==y){this.setBlending(T.blending);this.renderBuffer(k,p,n,T,v,l)}}};this.render=function(k,p,n,l){var v,C,y,z=k.lights,D=k.fog;p.autoUpdateMatrix&&p.updateMatrix();w.set(p.matrix.flatten());u.set(p.projectionMatrix.flatten());
|
|
|
-this.initWebGLObjects(k,p);l=l!==undefined?l:true;if(n&&!n.__webGLFramebuffer){n.__webGLFramebuffer=b.createFramebuffer();n.__webGLRenderbuffer=b.createRenderbuffer();n.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,n.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,n.width,n.height);b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,e(n.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,e(n.wrap_t));b.texParameteri(b.TEXTURE_2D,
|
|
|
-b.TEXTURE_MAG_FILTER,e(n.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e(n.min_filter));b.texImage2D(b.TEXTURE_2D,0,e(n.format),n.width,n.height,0,e(n.format),e(n.type),null);b.bindFramebuffer(b.FRAMEBUFFER,n.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,n.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,n.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);
|
|
|
-b.bindFramebuffer(b.FRAMEBUFFER,null)}if(n){v=n.__webGLFramebuffer;y=n.width;C=n.height}else{v=null;y=f.width;C=f.height}if(v!=h){b.bindFramebuffer(b.FRAMEBUFFER,v);b.viewport(0,0,y,C);l&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);h=v}this.autoClear&&this.clear();v=k.__webGLObjects.length;for(l=0;l<v;l++){C=k.__webGLObjects[l];y=C.object;if(y.visible){y.autoUpdateMatrix&&y.updateMatrix();if(y.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);y.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}}for(l=
|
|
|
-0;l<v;l++){C=k.__webGLObjects[l];y=C.object;C=C.buffer;if(y.visible){this.setupMatrices(y,p);this.renderPass(p,z,D,y,C,THREE.NormalBlending,false)}}for(l=0;l<v;l++){C=k.__webGLObjects[l];y=C.object;C=C.buffer;if(y.visible){this.setupMatrices(y,p);this.renderPass(p,z,D,y,C,THREE.AdditiveBlending,false);this.renderPass(p,z,D,y,C,THREE.SubtractiveBlending,false);this.renderPass(p,z,D,y,C,THREE.AdditiveBlending,true);this.renderPass(p,z,D,y,C,THREE.SubtractiveBlending,true);this.renderPass(p,z,D,y,C,
|
|
|
-THREE.NormalBlending,true);this.renderPass(p,z,D,y,C,THREE.BillboardBlending,false)}}if(n&&n.min_filter!==THREE.NearestFilter&&n.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(k,p){function n(F,T,N,X){if(F[T]==undefined){k.__webGLObjects.push({buffer:N,object:X});F[T]=1}}var l,v,C,y,z,D,A;if(!k.__webGLObjects){k.__webGLObjects=[];k.__webGLObjectsMap={}}l=0;for(v=k.objects.length;l<
|
|
|
-v;l++){C=k.objects[l];z=C.geometry;if(k.__webGLObjectsMap[C.id]==undefined)k.__webGLObjectsMap[C.id]={};A=k.__webGLObjectsMap[C.id];if(C instanceof THREE.Mesh){for(y in z.geometryChunks){D=z.geometryChunks[y];if(!D.__webGLVertexBuffer){this.createMeshBuffers(D);this.initMeshBuffers(D,C);z.__dirtyVertices=true;z.__dirtyElements=true;z.__dirtyUvs=true;z.__dirtyNormals=true;z.__dirtyTangents=true}if(z.__dirtyVertices||z.__dirtyElements||z.__dirtyUvs)this.setMeshBuffers(D,C,b.DYNAMIC_DRAW,z.__dirtyVertices,
|
|
|
-z.__dirtyElements,z.__dirtyUvs,z.__dirtyNormals,z.__dirtyTangents);n(A,y,D,C)}z.__dirtyVertices=false;z.__dirtyElements=false;z.__dirtyUvs=false;z.__dirtyNormals=false;z.__dirtyTangents=false}else if(C instanceof THREE.Line){if(!z.__webGLVertexBuffer){this.createLineBuffers(z);this.initLineBuffers(z);z.__dirtyVertices=true;z.__dirtyElements=true}z.__dirtyVertices&&this.setLineBuffers(z,b.DYNAMIC_DRAW,z.__dirtyVertices,z.__dirtyElements);n(A,0,z,C);z.__dirtyVertices=false;z.__dirtyElements=false}else if(C instanceof
|
|
|
-THREE.ParticleSystem){if(!z.__webGLVertexBuffer){this.createParticleBuffers(z);this.initParticleBuffers(z);z.__dirtyVertices=true;z.__dirtyElements=true}if(z.__dirtyVertices||C.sortParticles)this.setParticleBuffers(z,b.DYNAMIC_DRAW,z.__dirtyVertices,z.__dirtyElements,C,p);n(A,0,z,C);z.__dirtyVertices=false;z.__dirtyElements=false}}};this.removeObject=function(k,p){var n,l;for(n=k.__webGLObjects.length-1;n>=0;n--){l=k.__webGLObjects[n].object;p==l&&k.__webGLObjects.splice(n,1)}};this.setupMatrices=
|
|
|
-function(k,p){g.multiply(p.matrix,k.matrix);B.set(g.flatten());m=THREE.Matrix4.makeInvert3x3(g).transpose();q.set(m.m);x.set(k.matrix.flatten())};this.loadMatrices=function(k){b.uniformMatrix4fv(k.uniforms.viewMatrix,false,w);b.uniformMatrix4fv(k.uniforms.modelViewMatrix,false,B);b.uniformMatrix4fv(k.uniforms.projectionMatrix,false,u);b.uniformMatrix3fv(k.uniforms.normalMatrix,false,q);b.uniformMatrix4fv(k.uniforms.objectMatrix,false,x)};this.loadCamera=function(k,p){b.uniform3f(k.uniforms.cameraPosition,
|
|
|
-p.position.x,p.position.y,p.position.z)};this.setBlending=function(k){switch(k){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(k,p){if(k){!p||p=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);
|
|
|
-if(k=="back")b.cullFace(b.BACK);else k=="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}};
|
|
|
+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 f=document.createElement("canvas"),b,j=null,h=null,g=new THREE.Matrix4,m,y=new Float32Array(16),C=new Float32Array(16),
|
|
|
+u=new Float32Array(16),q=new Float32Array(9),A=new Float32Array(16),F=new THREE.Matrix4,G=new THREE.Vector4,t=true,H=new THREE.Color(0),o=0;if(a){if(a.antialias!==undefined)t=a.antialias;a.clearColor!==undefined&&H.setHex(a.clearColor);if(a.clearAlpha!==undefined)o=a.clearAlpha}this.domElement=f;this.autoClear=true;(function(l,p,n){try{b=f.getContext("experimental-webgl",{antialias:l})}catch(k){}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,n)})(t,H,o);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,p){f.width=l;f.height=p;b.viewport(0,0,f.width,f.height)};this.setClearColor=function(l,p){var n=new THREE.Color(l);b.clearColor(n.r,n.g,n.b,p)};
|
|
|
+this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(l,p){var n,k,w,v=0,x=0,z=0,D,B,I,O=this.lights,Q=O.directional.colors,R=O.directional.positions,U=O.point.colors,T=O.point.positions,ba=0,ca=0;n=0;for(k=p.length;n<k;n++){w=p[n];D=w.color;B=w.position;I=w.intensity;if(w instanceof THREE.AmbientLight){v+=D.r;x+=D.g;z+=D.b}else if(w instanceof THREE.DirectionalLight){Q[ba*3]=D.r*I;Q[ba*3+1]=D.g*I;Q[ba*3+2]=D.b*I;R[ba*3]=B.x;R[ba*3+1]=B.y;R[ba*3+2]=B.z;ba+=
|
|
|
+1}else if(w instanceof THREE.PointLight){U[ca*3]=D.r*I;U[ca*3+1]=D.g*I;U[ca*3+2]=D.b*I;T[ca*3]=B.x;T[ca*3+1]=B.y;T[ca*3+2]=B.z;ca+=1}}O.point.length=ca;O.directional.length=ba;O.ambient[0]=v;O.ambient[1]=x;O.ambient[2]=z};this.createParticleBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLParticleBuffer=b.createBuffer();l.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=
|
|
|
+function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLNormalBuffer=b.createBuffer();l.__webGLTangentBuffer=b.createBuffer();l.__webGLUVBuffer=b.createBuffer();l.__webGLUV2Buffer=b.createBuffer();l.__webGLFaceBuffer=b.createBuffer();l.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(l){var p=l.vertices.length;l.__vertexArray=new Float32Array(p*3);l.__lineArray=new Uint16Array(p);l.__webGLLineCount=p};this.initParticleBuffers=function(l){var p=l.vertices.length;l.__vertexArray=
|
|
|
+new Float32Array(p*3);l.__particleArray=new Uint16Array(p);l.__sortArray=[];l.__webGLParticleCount=p};this.initMeshBuffers=function(l,p){var n,k,w=0,v=0,x=0,z=p.geometry.faces,D=l.faces;n=0;for(k=D.length;n<k;n++){fi=D[n];face=z[fi];if(face instanceof THREE.Face3){w+=3;v+=1;x+=3}else if(face instanceof THREE.Face4){w+=4;v+=2;x+=4}}l.__vertexArray=new Float32Array(w*3);l.__normalArray=new Float32Array(w*3);l.__tangentArray=new Float32Array(w*4);l.__uvArray=new Float32Array(w*2);l.__uv2Array=new Float32Array(w*
|
|
|
+2);l.__faceArray=new Uint16Array(v*3);l.__lineArray=new Uint16Array(x*2);w=false;n=0;for(k=p.materials.length;n<k;n++){z=p.materials[n];if(z instanceof THREE.MeshFaceMaterial){z=0;for(D=l.materials.length;z<D;z++)if(l.materials[z]&&l.materials[z].shading!=undefined&&l.materials[z].shading==THREE.SmoothShading){w=true;break}}else if(z&&z.shading!=undefined&&z.shading==THREE.SmoothShading){w=true;break}if(w)break}l.__needsSmoothNormals=w;l.__webGLFaceCount=v*3;l.__webGLLineCount=x*2};this.setMeshBuffers=
|
|
|
+function(l,p,n){var k,w,v,x,z,D,B,I,O,Q,R=0,U=0,T=0,ba=0,ca=0,S=0,K=0,Z=0,V=l.__vertexArray,N=l.__uvArray,W=l.__uv2Array,$=l.__normalArray,da=l.__tangentArray,ha=l.__faceArray,E=l.__lineArray,L=l.__needsSmoothNormals,J=p.geometry,X=J.__dirtyVertices,ea=J.__dirtyElements,ja=J.__dirtyUvs,ia=J.__dirtyNormals,qa=J.__dirtyTangents,la=J.vertices,ua=l.faces,ma=J.faces,sa=J.uvs,Ha=J.uvs2;p=0;for(k=ua.length;p<k;p++){w=ua[p];v=ma[w];D=sa[w];w=Ha[w];x=v.vertexNormals;z=v.normal;if(v instanceof THREE.Face3){if(X){B=
|
|
|
+la[v.a].position;I=la[v.b].position;O=la[v.c].position;V[U]=B.x;V[U+1]=B.y;V[U+2]=B.z;V[U+3]=I.x;V[U+4]=I.y;V[U+5]=I.z;V[U+6]=O.x;V[U+7]=O.y;V[U+8]=O.z;U+=9}if(qa&&J.hasTangents){B=la[v.a].tangent;I=la[v.b].tangent;O=la[v.c].tangent;da[K]=B.x;da[K+1]=B.y;da[K+2]=B.z;da[K+3]=B.w;da[K+4]=I.x;da[K+5]=I.y;da[K+6]=I.z;da[K+7]=I.w;da[K+8]=O.x;da[K+9]=O.y;da[K+10]=O.z;da[K+11]=O.w;K+=12}if(ia)if(x.length==3&&L)for(v=0;v<3;v++){z=x[v];$[S]=z.x;$[S+1]=z.y;$[S+2]=z.z;S+=3}else for(v=0;v<3;v++){$[S]=z.x;$[S+
|
|
|
+1]=z.y;$[S+2]=z.z;S+=3}if(ja&&D)for(v=0;v<3;v++){x=D[v];N[T]=x.u;N[T+1]=x.v;T+=2}if(ja&&w)for(v=0;v<3;v++){D=w[v];W[ba]=D.u;W[ba+1]=D.v;ba+=2}if(ea){ha[ca]=R;ha[ca+1]=R+1;ha[ca+2]=R+2;ca+=3;E[Z]=R;E[Z+1]=R+1;E[Z+2]=R;E[Z+3]=R+2;E[Z+4]=R+1;E[Z+5]=R+2;Z+=6;R+=3}}else if(v instanceof THREE.Face4){if(X){B=la[v.a].position;I=la[v.b].position;O=la[v.c].position;Q=la[v.d].position;V[U]=B.x;V[U+1]=B.y;V[U+2]=B.z;V[U+3]=I.x;V[U+4]=I.y;V[U+5]=I.z;V[U+6]=O.x;V[U+7]=O.y;V[U+8]=O.z;V[U+9]=Q.x;V[U+10]=Q.y;V[U+
|
|
|
+11]=Q.z;U+=12}if(qa&&J.hasTangents){B=la[v.a].tangent;I=la[v.b].tangent;O=la[v.c].tangent;v=la[v.d].tangent;da[K]=B.x;da[K+1]=B.y;da[K+2]=B.z;da[K+3]=B.w;da[K+4]=I.x;da[K+5]=I.y;da[K+6]=I.z;da[K+7]=I.w;da[K+8]=O.x;da[K+9]=O.y;da[K+10]=O.z;da[K+11]=O.w;da[K+12]=v.x;da[K+13]=v.y;da[K+14]=v.z;da[K+15]=v.w;K+=16}if(ia)if(x.length==4&&L)for(v=0;v<4;v++){z=x[v];$[S]=z.x;$[S+1]=z.y;$[S+2]=z.z;S+=3}else for(v=0;v<4;v++){$[S]=z.x;$[S+1]=z.y;$[S+2]=z.z;S+=3}if(ja&&D)for(v=0;v<4;v++){x=D[v];N[T]=x.u;N[T+1]=
|
|
|
+x.v;T+=2}if(ja&&w)for(v=0;v<4;v++){D=w[v];W[ba]=D.u;W[ba+1]=D.v;ba+=2}if(ea){ha[ca]=R;ha[ca+1]=R+1;ha[ca+2]=R+2;ha[ca+3]=R;ha[ca+4]=R+2;ha[ca+5]=R+3;ca+=6;E[Z]=R;E[Z+1]=R+1;E[Z+2]=R;E[Z+3]=R+3;E[Z+4]=R+1;E[Z+5]=R+2;E[Z+6]=R+2;E[Z+7]=R+3;Z+=8;R+=4}}}if(X){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,V,n)}if(ia){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,$,n)}if(qa&&J.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLTangentBuffer);
|
|
|
+b.bufferData(b.ARRAY_BUFFER,da,n)}if(ja&&T>0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,N,n)}if(ja&&ba>0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,W,n)}if(ea){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ha,n);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,E,n)}};this.setLineBuffers=function(l,p){var n,k,w,v=l.vertices,x=v.length,z=l.__vertexArray,
|
|
|
+D=l.__lineArray,B=l.__dirtyElements;if(l.__dirtyVertices)for(n=0;n<x;n++){k=v[n].position;w=n*3;z[w]=k.x;z[w+1]=k.y;z[w+2]=k.z}if(B)for(n=0;n<x;n++)D[n]=n;b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,z,p);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,D,p)};this.setParticleBuffers=function(l,p,n,k){var w,v=l.vertices,x=v.length,z=l.__vertexArray,D=l.__particleArray,B=l.__sortArray;w=l.__dirtyVertices;var I=l.__dirtyElements;
|
|
|
+if(n.sortParticles){F.multiply(k.projectionMatrix,k.matrix);F.multiplySelf(n.matrix);for(n=0;n<x;n++){k=v[n].position;G.copy(k);F.multiplyVector3(G);B[n]=[G.z,n]}B.sort(function(O,Q){return Q[0]-O[0]});for(n=0;n<x;n++){k=v[B[n][1]].position;w=n*3;z[w]=k.x;z[w+1]=k.y;z[w+2]=k.z}}else if(w)for(n=0;n<x;n++){k=v[n].position;w=n*3;z[w]=k.x;z[w+1]=k.y;z[w+2]=k.z}if(I)for(n=0;n<x;n++)D[n]=n;b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,z,p);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
|
|
|
+l.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,D,p)};this.initMaterial=function(l,p,n){if(!l.program){var k,w;if(l instanceof THREE.MeshDepthMaterial)c(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)c(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)c(l,THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)c(l,THREE.ShaderLib.phong);else if(l instanceof
|
|
|
+THREE.LineBasicMaterial)c(l,THREE.ShaderLib.basic);else l instanceof THREE.ParticleBasicMaterial&&c(l,THREE.ShaderLib.particle_basic);var v,x,z,D;w=z=D=0;for(v=p.length;w<v;w++){x=p[w];x instanceof THREE.DirectionalLight&&z++;x instanceof THREE.PointLight&&D++}if(D+z<=4){p=z;D=D}else{p=Math.ceil(4*z/(D+z));D=4-p}w={directional:p,point:D};D=l.fragment_shader;p=l.vertex_shader;v={fog:n,map:l.map,env_map:l.env_map,light_map:l.light_map,maxDirLights:w.directional,maxPointLights:w.point};n=b.createProgram();
|
|
|
+w=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+v.maxDirLights,"#define MAX_POINT_LIGHTS "+v.maxPointLights,v.fog?"#define USE_FOG":"",v.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",v.map?"#define USE_MAP":"",v.env_map?"#define USE_ENVMAP":"",v.light_map?"#define USE_LIGHTMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");v=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+v.maxDirLights,
|
|
|
+"#define MAX_POINT_LIGHTS "+v.maxPointLights,v.map?"#define USE_MAP":"",v.env_map?"#define USE_ENVMAP":"",v.light_map?"#define USE_LIGHTMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(n,d("fragment",w+D));b.attachShader(n,d("vertex",v+p));b.linkProgram(n);
|
|
|
+b.getProgramParameter(n,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(n,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");n.uniforms={};n.attributes={};l.program=n;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(k in l.uniforms)n.push(k);k=l.program;D=0;for(p=n.length;D<p;D++){w=n[D];k.uniforms[w]=b.getUniformLocation(k,w)}l=l.program;k=["position","normal","uv","uv2","tangent"];n=0;for(D=k.length;n<
|
|
|
+D;n++){p=k[n];l.attributes[p]=b.getAttribLocation(l,p)}}};this.renderBuffer=function(l,p,n,k,w,v){var x;this.initMaterial(k,p,n);x=k.program;if(x!=j){b.useProgram(x);j=x}this.loadCamera(x,l);this.loadMatrices(x);if(k instanceof THREE.MeshPhongMaterial||k instanceof THREE.MeshLambertMaterial){this.setupLights(x,p);p=this.lights;k.uniforms.enableLighting.value=p.directional.length+p.point.length;k.uniforms.ambientLightColor.value=p.ambient;k.uniforms.directionalLightColor.value=p.directional.colors;
|
|
|
+k.uniforms.directionalLightDirection.value=p.directional.positions;k.uniforms.pointLightColor.value=p.point.colors;k.uniforms.pointLightPosition.value=p.point.positions}if(k instanceof THREE.MeshBasicMaterial||k instanceof THREE.MeshLambertMaterial||k instanceof THREE.MeshPhongMaterial){k.uniforms.color.value.setRGB(k.color.r*k.opacity,k.color.g*k.opacity,k.color.b*k.opacity);k.uniforms.opacity.value=k.opacity;k.uniforms.map.texture=k.map;k.uniforms.light_map.texture=k.light_map;k.uniforms.env_map.texture=
|
|
|
+k.env_map;k.uniforms.reflectivity.value=k.reflectivity;k.uniforms.refraction_ratio.value=k.refraction_ratio;k.uniforms.combine.value=k.combine;k.uniforms.useRefract.value=k.env_map&&k.env_map.mapping instanceof THREE.CubeRefractionMapping;if(n){k.uniforms.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){k.uniforms.fogNear.value=n.near;k.uniforms.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)k.uniforms.fogDensity.value=n.density}}if(k instanceof THREE.LineBasicMaterial){k.uniforms.color.value.setRGB(k.color.r*
|
|
|
+k.opacity,k.color.g*k.opacity,k.color.b*k.opacity);k.uniforms.opacity.value=k.opacity;if(n){k.uniforms.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){k.uniforms.fogNear.value=n.near;k.uniforms.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)k.uniforms.fogDensity.value=n.density}}if(k instanceof THREE.ParticleBasicMaterial){k.uniforms.color.value.setRGB(k.color.r*k.opacity,k.color.g*k.opacity,k.color.b*k.opacity);k.uniforms.opacity.value=k.opacity;k.uniforms.size.value=k.size;
|
|
|
+k.uniforms.map.texture=k.map;if(n){k.uniforms.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){k.uniforms.fogNear.value=n.near;k.uniforms.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)k.uniforms.fogDensity.value=n.density}}if(k instanceof THREE.MeshPhongMaterial){k.uniforms.ambient.value.setRGB(k.ambient.r,k.ambient.g,k.ambient.b);k.uniforms.specular.value.setRGB(k.specular.r,k.specular.g,k.specular.b);k.uniforms.shininess.value=k.shininess}if(k instanceof THREE.MeshDepthMaterial){k.uniforms.mNear.value=
|
|
|
+l.near;k.uniforms.mFar.value=l.far}l=k.uniforms;var z,D,B;for(z in l)if(B=x.uniforms[z]){p=l[z];D=p.type;n=p.value;if(D=="i")b.uniform1i(B,n);else if(D=="f")b.uniform1f(B,n);else if(D=="fv1")b.uniform1fv(B,n);else if(D=="fv")b.uniform3fv(B,n);else if(D=="v2")b.uniform2f(B,n.x,n.y);else if(D=="v3")b.uniform3f(B,n.x,n.y,n.z);else if(D=="c")b.uniform3f(B,n.r,n.g,n.b);else if(D=="t"){b.uniform1i(B,n);if(p=p.texture)if(p.image instanceof Array&&p.image.length==6){p=p;n=n;if(p.image.length==6){if(!p.image.__webGLTextureCube&&
|
|
|
+!p.image.__cubeMapInitialized&&p.image.loadCount==6){p.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(D=0;D<6;++D)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+
|
|
|
+D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,p.image[D]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);p.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+n);b.bindTexture(b.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube)}}else{p=p;n=n;if(!p.__webGLTexture&&p.image.loaded){p.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,p.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,p.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,e(p.wrap_s));
|
|
|
+b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,e(p.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,e(p.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e(p.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+n);b.bindTexture(b.TEXTURE_2D,p.__webGLTexture)}}}x=x.attributes;b.bindBuffer(b.ARRAY_BUFFER,w.__webGLVertexBuffer);b.vertexAttribPointer(x.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(x.position);if(x.normal>=
|
|
|
+0){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLNormalBuffer);b.vertexAttribPointer(x.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(x.normal)}if(x.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLTangentBuffer);b.vertexAttribPointer(x.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(x.tangent)}if(x.uv>=0)if(w.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLUVBuffer);b.vertexAttribPointer(x.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(x.uv)}else b.disableVertexAttribArray(x.uv);if(x.uv2>=
|
|
|
+0)if(w.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLUV2Buffer);b.vertexAttribPointer(x.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(x.uv2)}else b.disableVertexAttribArray(x.uv2);if(k.wireframe||k instanceof THREE.LineBasicMaterial){x=k.wireframe_linewidth!==undefined?k.wireframe_linewidth:k.linewidth!==undefined?k.linewidth:1;k=k instanceof THREE.LineBasicMaterial&&v.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(x);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,w.__webGLLineBuffer);
|
|
|
+b.drawElements(k,w.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(k instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,w.__webGLParticleBuffer);b.drawElements(b.POINTS,w.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,w.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(l,p,n,k,w,v,x){var z,D,B,I,O;B=0;for(I=k.materials.length;B<I;B++){z=k.materials[B];if(z instanceof THREE.MeshFaceMaterial){z=
|
|
|
+0;for(D=w.materials.length;z<D;z++)if((O=w.materials[z])&&O.blending==v&&O.opacity<1==x){this.setBlending(O.blending);this.renderBuffer(l,p,n,O,w,k)}}else if((O=z)&&O.blending==v&&O.opacity<1==x){this.setBlending(O.blending);this.renderBuffer(l,p,n,O,w,k)}}};this.render=function(l,p,n,k){var w,v,x,z=l.lights,D=l.fog;p.autoUpdateMatrix&&p.updateMatrix();y.set(p.matrix.flatten());u.set(p.projectionMatrix.flatten());this.initWebGLObjects(l,p);k=k!==undefined?k:true;if(n&&!n.__webGLFramebuffer){n.__webGLFramebuffer=
|
|
|
+b.createFramebuffer();n.__webGLRenderbuffer=b.createRenderbuffer();n.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,n.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,n.width,n.height);b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,e(n.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,e(n.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,e(n.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,
|
|
|
+e(n.min_filter));b.texImage2D(b.TEXTURE_2D,0,e(n.format),n.width,n.height,0,e(n.format),e(n.type),null);b.bindFramebuffer(b.FRAMEBUFFER,n.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,n.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,n.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(n){w=n.__webGLFramebuffer;x=n.width;v=n.height}else{w=
|
|
|
+null;x=f.width;v=f.height}if(w!=h){b.bindFramebuffer(b.FRAMEBUFFER,w);b.viewport(0,0,x,v);k&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);h=w}this.autoClear&&this.clear();w=l.__webGLObjects.length;for(k=0;k<w;k++){v=l.__webGLObjects[k];x=v.object;if(x.visible){x.autoUpdateMatrix&&x.updateMatrix();if(x.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);x.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}}for(k=0;k<w;k++){v=l.__webGLObjects[k];x=v.object;v=v.buffer;if(x.visible){this.setupMatrices(x,
|
|
|
+p);this.renderPass(p,z,D,x,v,THREE.NormalBlending,false)}}for(k=0;k<w;k++){v=l.__webGLObjects[k];x=v.object;v=v.buffer;if(x.visible){this.setupMatrices(x,p);this.renderPass(p,z,D,x,v,THREE.AdditiveBlending,false);this.renderPass(p,z,D,x,v,THREE.SubtractiveBlending,false);this.renderPass(p,z,D,x,v,THREE.AdditiveBlending,true);this.renderPass(p,z,D,x,v,THREE.SubtractiveBlending,true);this.renderPass(p,z,D,x,v,THREE.NormalBlending,true);this.renderPass(p,z,D,x,v,THREE.BillboardBlending,false)}}if(n&&
|
|
|
+n.min_filter!==THREE.NearestFilter&&n.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(l,p){function n(I,O,Q,R){if(I[O]==undefined){l.__webGLObjects.push({buffer:Q,object:R});I[O]=1}}var k,w,v,x,z,D,B;if(!l.__webGLObjects){l.__webGLObjects=[];l.__webGLObjectsMap={}}k=0;for(w=l.objects.length;k<w;k++){v=l.objects[k];z=v.geometry;if(l.__webGLObjectsMap[v.id]==undefined)l.__webGLObjectsMap[v.id]=
|
|
|
+{};B=l.__webGLObjectsMap[v.id];if(v instanceof THREE.Mesh){for(x in z.geometryChunks){D=z.geometryChunks[x];if(!D.__webGLVertexBuffer){this.createMeshBuffers(D);this.initMeshBuffers(D,v);z.__dirtyVertices=true;z.__dirtyElements=true;z.__dirtyUvs=true;z.__dirtyNormals=true;z.__dirtyTangents=true}if(z.__dirtyVertices||z.__dirtyElements||z.__dirtyUvs)this.setMeshBuffers(D,v,b.DYNAMIC_DRAW);n(B,x,D,v)}z.__dirtyVertices=false;z.__dirtyElements=false;z.__dirtyUvs=false;z.__dirtyNormals=false;z.__dirtyTangents=
|
|
|
+false}else if(v instanceof THREE.Line){if(!z.__webGLVertexBuffer){this.createLineBuffers(z);this.initLineBuffers(z);z.__dirtyVertices=true;z.__dirtyElements=true}z.__dirtyVertices&&this.setLineBuffers(z,b.DYNAMIC_DRAW);n(B,0,z,v);z.__dirtyVertices=false;z.__dirtyElements=false}else if(v instanceof THREE.ParticleSystem){if(!z.__webGLVertexBuffer){this.createParticleBuffers(z);this.initParticleBuffers(z);z.__dirtyVertices=true;z.__dirtyColors=true;z.__dirtyElements=true}if(z.__dirtyVertices||z.__dirtyColors||
|
|
|
+v.sortParticles)this.setParticleBuffers(z,b.DYNAMIC_DRAW,v,p);n(B,0,z,v);z.__dirtyVertices=false;z.__dirtyColors=false;z.__dirtyElements=false}}};this.removeObject=function(l,p){var n,k;for(n=l.__webGLObjects.length-1;n>=0;n--){k=l.__webGLObjects[n].object;p==k&&l.__webGLObjects.splice(n,1)}};this.setupMatrices=function(l,p){g.multiply(p.matrix,l.matrix);C.set(g.flatten());m=THREE.Matrix4.makeInvert3x3(g).transpose();q.set(m.m);A.set(l.matrix.flatten())};this.loadMatrices=function(l){b.uniformMatrix4fv(l.uniforms.viewMatrix,
|
|
|
+false,y);b.uniformMatrix4fv(l.uniforms.modelViewMatrix,false,C);b.uniformMatrix4fv(l.uniforms.projectionMatrix,false,u);b.uniformMatrix3fv(l.uniforms.normalMatrix,false,q);b.uniformMatrix4fv(l.uniforms.objectMatrix,false,A)};this.loadCamera=function(l,p){b.uniform3f(l.uniforms.cameraPosition,p.position.x,p.position.y,p.position.z)};this.setBlending=function(l){switch(l){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(l,p){if(l){!p||p=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(l=="back")b.cullFace(b.BACK);else l=="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\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
|
|
|
map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\nmapColor = 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\nmapColor = 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",
|
|
@@ -209,16 +211,16 @@ THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),verte
|
|
|
THREE.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragment_shader:["uniform vec3 color;\nuniform float opacity;",THREE.Snippets.map_particle_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );",THREE.Snippets.map_particle_fragment,"gl_FragColor = mColor * mapColor;",THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:"uniform float size;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\ngl_PointSize = size;\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,f=d?c.geometry:c,b=a.vertices,j=f.vertices,h=a.faces,g=f.faces,m=a.uvs;f=f.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var w=0,B=j.length;w<B;w++){var u=new THREE.Vertex(j[w].position.clone());d&&c.matrix.multiplyVector3(u.position);b.push(u)}w=0;for(B=g.length;w<B;w++){j=g[w];var q,x=j.vertexNormals;if(j instanceof THREE.Face3)q=new THREE.Face3(j.a+e,j.b+e,j.c+e);else if(j instanceof THREE.Face4)q=new THREE.Face4(j.a+
|
|
|
-e,j.b+e,j.c+e,j.d+e);q.centroid.copy(j.centroid);q.normal.copy(j.normal);d=0;for(b=x.length;d<b;d++){u=x[d];q.vertexNormals.push(u.clone())}q.materials=j.materials.slice();h.push(q)}w=0;for(B=f.length;w<B;w++){e=f[w];h=[];d=0;for(b=e.length;d<b;d++)h.push(new THREE.UV(e[d].u,e[d].v));m.push(h)}}},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,f=[];d=f.loadCount=0;for(e=
|
|
|
-a.length;d<e;++d){f[d]=new Image;f[d].loaded=0;f[d].onload=function(){f.loadCount+=1;this.loaded=true;c&&c(this)};f[d].src=a[d]}return f}},SceneUtils={loadScene:function(a,c,d,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(f){function b(){for(w in l.objects)if(!A.objects[w]){E=l.objects[w];if(o=A.geometries[E.geometry]){n=[];for(i=0;i<E.materials.length;i++)n[i]=A.materials[E.materials[i]];H=E.position;r=E.rotation;s=E.scale;object=new THREE.Mesh(o,n);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=E.visible;A.scene.addObject(object);A.objects[w]=object}}}function j(F){return function(T){A.geometries[F]=T;b();C-=1;h()}}function h(){e({total_models:z,total_textures:D,loaded_models:z-C,loaded_textures:D-y},A);C==0&&y==0&&d(A)}var g,m,w,B,u,q,x,E,H,t,I,o,k,p,n,l,v,C,y,z,D,A;l=f.data;v=new THREE.Loader;y=C=0;A={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
|
|
|
-f=function(){y-=1;h()};for(u in l.cameras){t=l.cameras[u];if(t.type=="perspective")k=new THREE.Camera(t.fov,t.aspect,t.near,t.far);else if(t.type=="ortho"){k=new THREE.Camera;k.projectionMatrix=THREE.Matrix4.makeOrtho(t.left,t.right,t.top,t.bottom,t.near,t.far)}H=t.position;t=t.target;k.position.set(H[0],H[1],H[2]);k.target.position.set(t[0],t[1],t[2]);A.cameras[u]=k}for(B in l.lights){u=l.lights[B];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])}t=u.color;i=u.intensity||1;light.color.setRGB(t[0]*i,t[1]*i,t[2]*i);A.scene.addLight(light);A.lights[B]=light}for(q in l.fogs){B=l.fogs[q];if(B.type=="linear")p=new THREE.Fog(0,B.near,B.far);else if(B.type=="exp2")p=new THREE.FogExp2(0,B.density);t=B.color;p.color.setRGB(t[0],t[1],t[2]);A.fogs[q]=p}if(A.cameras&&l.defaults.camera)A.currentCamera=A.cameras[l.defaults.camera];
|
|
|
-if(A.fogs&&l.defaults.fog)A.scene.fog=A.fogs[l.defaults.fog];t=l.defaults.bgcolor;A.bgColor=new THREE.Color;A.bgColor.setRGB(t[0],t[1],t[2]);A.bgColorAlpha=l.defaults.bgalpha;for(g in l.geometries){q=l.geometries[g];if(q.type=="bin_mesh"||q.type=="ascii_mesh")C+=1}z=C;for(g in l.geometries){q=l.geometries[g];if(q.type=="cube"){o=new Cube(q.width,q.height,q.depth,q.segments_width,q.segments_height,null,q.flipped,q.sides);A.geometries[g]=o}else if(q.type=="plane"){o=new Plane(q.width,q.height,q.segments_width,
|
|
|
-q.segments_height);A.geometries[g]=o}else if(q.type=="sphere"){o=new Sphere(q.radius,q.segments_width,q.segments_height);A.geometries[g]=o}else if(q.type=="cylinder"){o=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);A.geometries[g]=o}else if(q.type=="torus"){o=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);A.geometries[g]=o}else if(q.type=="icosahedron"){o=new Icosahedron(q.subdivisions);A.geometries[g]=o}else if(q.type=="bin_mesh")v.loadBinary({model:q.url,callback:j(g)});
|
|
|
-else q.type=="ascii_mesh"&&v.loadAscii({model:q.url,callback:j(g)})}for(x in l.textures){g=l.textures[x];y+=g.url instanceof Array?g.url.length:1}D=y;for(x in l.textures){g=l.textures[x];if(g.mapping!=undefined&&THREE[g.mapping]!=undefined)g.mapping=new THREE[g.mapping];if(g.url instanceof Array){q=ImageUtils.loadArray(g.url,f);q=new THREE.Texture(q,g.mapping)}else{q=ImageUtils.loadTexture(g.url,g.mapping,f);if(THREE[g.min_filter]!=undefined)q.min_filter=THREE[g.min_filter];if(THREE[g.mag_filter]!=
|
|
|
-undefined)q.mag_filter=THREE[g.mag_filter]}A.textures[x]=q}for(m in l.materials){x=l.materials[m];for(I in x.parameters)if(I=="env_map"||I=="map"||I=="light_map")x.parameters[I]=A.textures[x.parameters[I]];else if(I=="shading")x.parameters[I]=x.parameters[I]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(I=="combine")x.parameters[I]=x.parameters[I]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;x=new THREE[x.type](x.parameters);A.materials[m]=x}b();c(A)}},addMesh:function(a,c,d,
|
|
|
+var GeometryUtils={merge:function(a,c){var d=c instanceof THREE.Mesh,e=a.vertices.length,f=d?c.geometry:c,b=a.vertices,j=f.vertices,h=a.faces,g=f.faces,m=a.uvs;f=f.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var y=0,C=j.length;y<C;y++){var u=new THREE.Vertex(j[y].position.clone());d&&c.matrix.multiplyVector3(u.position);b.push(u)}y=0;for(C=g.length;y<C;y++){j=g[y];var q,A=j.vertexNormals;if(j instanceof THREE.Face3)q=new THREE.Face3(j.a+e,j.b+e,j.c+e);else if(j instanceof THREE.Face4)q=new THREE.Face4(j.a+
|
|
|
+e,j.b+e,j.c+e,j.d+e);q.centroid.copy(j.centroid);q.normal.copy(j.normal);d=0;for(b=A.length;d<b;d++){u=A[d];q.vertexNormals.push(u.clone())}q.materials=j.materials.slice();h.push(q)}y=0;for(C=f.length;y<C;y++){e=f[y];h=[];d=0;for(b=e.length;d<b;d++)h.push(new THREE.UV(e[d].u,e[d].v));m.push(h)}}},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,f=[];d=f.loadCount=0;for(e=
|
|
|
+a.length;d<e;++d){f[d]=new Image;f[d].loaded=0;f[d].onload=function(){f.loadCount+=1;this.loaded=true;c&&c(this)};f[d].src=a[d]}return f}},SceneUtils={loadScene:function(a,c,d,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(f){function b(){for(y in k.objects)if(!B.objects[y]){F=k.objects[y];if(o=B.geometries[F.geometry]){n=[];for(i=0;i<F.materials.length;i++)n[i]=B.materials[F.materials[i]];G=F.position;r=F.rotation;s=F.scale;object=new THREE.Mesh(o,n);object.position.set(G[0],G[1],G[2]);
|
|
|
+object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=F.visible;B.scene.addObject(object);B.objects[y]=object}}}function j(I){return function(O){B.geometries[I]=O;b();v-=1;h()}}function h(){e({total_models:z,total_textures:D,loaded_models:z-v,loaded_textures:D-x},B);v==0&&x==0&&d(B)}var g,m,y,C,u,q,A,F,G,t,H,o,l,p,n,k,w,v,x,z,D,B;k=f.data;w=new THREE.Loader;x=v=0;B={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
|
|
|
+f=function(){x-=1;h()};for(u in k.cameras){t=k.cameras[u];if(t.type=="perspective")l=new THREE.Camera(t.fov,t.aspect,t.near,t.far);else if(t.type=="ortho"){l=new THREE.Camera;l.projectionMatrix=THREE.Matrix4.makeOrtho(t.left,t.right,t.top,t.bottom,t.near,t.far)}G=t.position;t=t.target;l.position.set(G[0],G[1],G[2]);l.target.position.set(t[0],t[1],t[2]);B.cameras[u]=l}for(C in k.lights){u=k.lights[C];if(u.type=="directional"){G=u.direction;light=new THREE.DirectionalLight;light.position.set(G[0],G[1],
|
|
|
+G[2]);light.position.normalize()}else if(u.type=="point"){G=u.position;light=new THREE.PointLight;light.position.set(G[0],G[1],G[2])}t=u.color;i=u.intensity||1;light.color.setRGB(t[0]*i,t[1]*i,t[2]*i);B.scene.addLight(light);B.lights[C]=light}for(q in k.fogs){C=k.fogs[q];if(C.type=="linear")p=new THREE.Fog(0,C.near,C.far);else if(C.type=="exp2")p=new THREE.FogExp2(0,C.density);t=C.color;p.color.setRGB(t[0],t[1],t[2]);B.fogs[q]=p}if(B.cameras&&k.defaults.camera)B.currentCamera=B.cameras[k.defaults.camera];
|
|
|
+if(B.fogs&&k.defaults.fog)B.scene.fog=B.fogs[k.defaults.fog];t=k.defaults.bgcolor;B.bgColor=new THREE.Color;B.bgColor.setRGB(t[0],t[1],t[2]);B.bgColorAlpha=k.defaults.bgalpha;for(g in k.geometries){q=k.geometries[g];if(q.type=="bin_mesh"||q.type=="ascii_mesh")v+=1}z=v;for(g in k.geometries){q=k.geometries[g];if(q.type=="cube"){o=new Cube(q.width,q.height,q.depth,q.segments_width,q.segments_height,null,q.flipped,q.sides);B.geometries[g]=o}else if(q.type=="plane"){o=new Plane(q.width,q.height,q.segments_width,
|
|
|
+q.segments_height);B.geometries[g]=o}else if(q.type=="sphere"){o=new Sphere(q.radius,q.segments_width,q.segments_height);B.geometries[g]=o}else if(q.type=="cylinder"){o=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);B.geometries[g]=o}else if(q.type=="torus"){o=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);B.geometries[g]=o}else if(q.type=="icosahedron"){o=new Icosahedron(q.subdivisions);B.geometries[g]=o}else if(q.type=="bin_mesh")w.loadBinary({model:q.url,callback:j(g)});
|
|
|
+else q.type=="ascii_mesh"&&w.loadAscii({model:q.url,callback:j(g)})}for(A in k.textures){g=k.textures[A];x+=g.url instanceof Array?g.url.length:1}D=x;for(A in k.textures){g=k.textures[A];if(g.mapping!=undefined&&THREE[g.mapping]!=undefined)g.mapping=new THREE[g.mapping];if(g.url instanceof Array){q=ImageUtils.loadArray(g.url,f);q=new THREE.Texture(q,g.mapping)}else{q=ImageUtils.loadTexture(g.url,g.mapping,f);if(THREE[g.min_filter]!=undefined)q.min_filter=THREE[g.min_filter];if(THREE[g.mag_filter]!=
|
|
|
+undefined)q.mag_filter=THREE[g.mag_filter]}B.textures[A]=q}for(m in k.materials){A=k.materials[m];for(H in A.parameters)if(H=="env_map"||H=="map"||H=="light_map")A.parameters[H]=B.textures[A.parameters[H]];else if(H=="shading")A.parameters[H]=A.parameters[H]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(H=="combine")A.parameters[H]=A.parameters[H]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;A=new THREE[A.type](A.parameters);B.materials[m]=A}b();c(B)}},addMesh:function(a,c,d,
|
|
|
e,f,b,j,h,g,m){c=new THREE.Mesh(c,m);c.scale.x=c.scale.y=c.scale.z=d;c.position.x=e;c.position.y=f;c.position.z=b;c.rotation.x=j;c.rotation.y=h;c.rotation.z=g;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,c,c,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(c);return c},
|
|
|
addPanoramaCubePlanes:function(a,c,d){var e=c/2;c=new Plane(c,c);var f=Math.PI/2,b=Math.PI;SceneUtils.addMesh(a,c,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));SceneUtils.addMesh(a,c,1,-e,0,0,0,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,c,1,e,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,c,1,0,e,0,f,0,b,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));SceneUtils.addMesh(a,
|
|
@@ -231,46 +233,46 @@ 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}},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;\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 );\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\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,f,b=2*Math.ceil(a*3)+1;if(b>25)b=25;f=(b-1)*0.5;d=Array(b);for(c=e=0;c<b;++c){d[c]=Math.exp(-((c-f)*(c-f))/(2*a*a));e+=d[c]}for(c=0;c<b;++c)d[c]/=e;return d}},Cube=function(a,c,d,e,f,b,j,h){function g(E,H,t,I,o,k,p,n){var l,v,C=e||1,y=f||1,z=C+1,D=y+1,A=o/2,F=k/2;o=o/C;var T=k/y,N=m.vertices.length;if(E=="x"&&H=="y"||E=="y"&&H=="x")l="z";else if(E=="x"&&H=="z"||E=="z"&&H=="x")l="y";else if(E==
|
|
|
-"z"&&H=="y"||E=="y"&&H=="z")l="x";for(v=0;v<D;v++)for(k=0;k<z;k++){var X=new THREE.Vector3;X[E]=(k*o-A)*t;X[H]=(v*T-F)*I;X[l]=p;m.vertices.push(new THREE.Vertex(X))}for(v=0;v<y;v++)for(k=0;k<C;k++){m.faces.push(new THREE.Face4(k+z*v+N,k+z*(v+1)+N,k+1+z*(v+1)+N,k+1+z*v+N,null,n));m.uvs.push([new THREE.UV(k/C,v/y),new THREE.UV(k/C,(v+1)/y),new THREE.UV((k+1)/C,(v+1)/y),new THREE.UV((k+1)/C,v/y)])}}THREE.Geometry.call(this);var m=this,w=a/2,B=c/2,u=d/2;j=j?-1:1;if(b!==undefined)if(b instanceof Array)this.materials=
|
|
|
-b;else{this.materials=[];for(var q=0;q<6;q++)this.materials.push([b])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(h!=undefined)for(var x in h)if(this.sides[x]!=undefined)this.sides[x]=h[x];this.sides.px&&g("z","y",1*j,-1,d,c,-w,this.materials[0]);this.sides.nx&&g("z","y",-1*j,-1,d,c,w,this.materials[1]);this.sides.py&&g("x","z",1*j,1,a,d,B,this.materials[2]);this.sides.ny&&g("x","z",1*j,-1,a,d,-B,this.materials[3]);this.sides.pz&&g("x","y",1*j,-1,a,c,u,this.materials[4]);
|
|
|
-this.sides.nz&&g("x","y",-1*j,-1,a,c,-u,this.materials[5]);(function(){for(var E=[],H=[],t=0,I=m.vertices.length;t<I;t++){for(var o=m.vertices[t],k=false,p=0,n=E.length;p<n;p++){var l=E[p];if(o.position.x==l.position.x&&o.position.y==l.position.y&&o.position.z==l.position.z){H[t]=p;k=true;break}}if(!k){H[t]=E.length;E.push(new THREE.Vertex(o.position.clone()))}}t=0;for(I=m.faces.length;t<I;t++){o=m.faces[t];o.a=H[o.a];o.b=H[o.b];o.c=H[o.c];o.d=H[o.d]}m.vertices=E})();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,f,b=2*Math.ceil(a*3)+1;if(b>25)b=25;f=(b-1)*0.5;d=Array(b);for(c=e=0;c<b;++c){d[c]=Math.exp(-((c-f)*(c-f))/(2*a*a));e+=d[c]}for(c=0;c<b;++c)d[c]/=e;return d}},Cube=function(a,c,d,e,f,b,j,h){function g(F,G,t,H,o,l,p,n){var k,w,v=e||1,x=f||1,z=v+1,D=x+1,B=o/2,I=l/2;o=o/v;var O=l/x,Q=m.vertices.length;if(F=="x"&&G=="y"||F=="y"&&G=="x")k="z";else if(F=="x"&&G=="z"||F=="z"&&G=="x")k="y";else if(F==
|
|
|
+"z"&&G=="y"||F=="y"&&G=="z")k="x";for(w=0;w<D;w++)for(l=0;l<z;l++){var R=new THREE.Vector3;R[F]=(l*o-B)*t;R[G]=(w*O-I)*H;R[k]=p;m.vertices.push(new THREE.Vertex(R))}for(w=0;w<x;w++)for(l=0;l<v;l++){m.faces.push(new THREE.Face4(l+z*w+Q,l+z*(w+1)+Q,l+1+z*(w+1)+Q,l+1+z*w+Q,null,n));m.uvs.push([new THREE.UV(l/v,w/x),new THREE.UV(l/v,(w+1)/x),new THREE.UV((l+1)/v,(w+1)/x),new THREE.UV((l+1)/v,w/x)])}}THREE.Geometry.call(this);var m=this,y=a/2,C=c/2,u=d/2;j=j?-1:1;if(b!==undefined)if(b instanceof Array)this.materials=
|
|
|
+b;else{this.materials=[];for(var q=0;q<6;q++)this.materials.push([b])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(h!=undefined)for(var A in h)if(this.sides[A]!=undefined)this.sides[A]=h[A];this.sides.px&&g("z","y",1*j,-1,d,c,-y,this.materials[0]);this.sides.nx&&g("z","y",-1*j,-1,d,c,y,this.materials[1]);this.sides.py&&g("x","z",1*j,1,a,d,C,this.materials[2]);this.sides.ny&&g("x","z",1*j,-1,a,d,-C,this.materials[3]);this.sides.pz&&g("x","y",1*j,-1,a,c,u,this.materials[4]);
|
|
|
+this.sides.nz&&g("x","y",-1*j,-1,a,c,-u,this.materials[5]);(function(){for(var F=[],G=[],t=0,H=m.vertices.length;t<H;t++){for(var o=m.vertices[t],l=false,p=0,n=F.length;p<n;p++){var k=F[p];if(o.position.x==k.position.x&&o.position.y==k.position.y&&o.position.z==k.position.z){G[t]=p;l=true;break}}if(!l){G[t]=F.length;F.push(new THREE.Vertex(o.position.clone()))}}t=0;for(H=m.faces.length;t<H;t++){o=m.faces[t];o.a=G[o.a];o.b=G[o.b];o.c=G[o.c];o.d=G[o.d]}m.vertices=F})();this.computeCentroids();this.computeFaceNormals();
|
|
|
this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
|
|
|
-var Cylinder=function(a,c,d,e,f){function b(m,w,B){j.vertices.push(new THREE.Vertex(new THREE.Vector3(m,w,B)))}THREE.Geometry.call(this);var j=this,h=Math.PI,g;for(g=0;g<a;g++)b(Math.sin(2*h*g/a)*c,Math.cos(2*h*g/a)*c,0);for(g=0;g<a;g++)b(Math.sin(2*h*g/a)*d,Math.cos(2*h*g/a)*d,e);for(g=0;g<a;g++)j.faces.push(new THREE.Face4(g,g+a,a+(g+1)%a,(g+1)%a));if(d!=0){b(0,0,-f);for(g=a;g<a+a/2;g++)j.faces.push(new THREE.Face4(2*a,(2*g-2*a)%a,(2*g-2*a+1)%a,(2*g-2*a+2)%a))}if(c!=0){b(0,0,e+f);for(g=a+a/2;g<
|
|
|
+var Cylinder=function(a,c,d,e,f){function b(m,y,C){j.vertices.push(new THREE.Vertex(new THREE.Vector3(m,y,C)))}THREE.Geometry.call(this);var j=this,h=Math.PI,g;for(g=0;g<a;g++)b(Math.sin(2*h*g/a)*c,Math.cos(2*h*g/a)*c,0);for(g=0;g<a;g++)b(Math.sin(2*h*g/a)*d,Math.cos(2*h*g/a)*d,e);for(g=0;g<a;g++)j.faces.push(new THREE.Face4(g,g+a,a+(g+1)%a,(g+1)%a));if(d!=0){b(0,0,-f);for(g=a;g<a+a/2;g++)j.faces.push(new THREE.Face4(2*a,(2*g-2*a)%a,(2*g-2*a+1)%a,(2*g-2*a+2)%a))}if(c!=0){b(0,0,e+f);for(g=a+a/2;g<
|
|
|
2*a;g++)j.faces.push(new THREE.Face4((2*g-2*a+2)%a+a,(2*g-2*a+1)%a+a,(2*g-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 f,b=a/2,j=c/2;d=d||1;e=e||1;var h=d+1,g=e+1;a=a/d;var m=c/e;for(f=0;f<g;f++)for(c=0;c<h;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-b,-(f*m-j),0)));for(f=0;f<e;f++)for(c=0;c<d;c++){this.faces.push(new THREE.Face4(c+h*f,c+h*(f+1),c+1+h*(f+1),c+1+h*f));this.uvs.push([new THREE.UV(c/d,f/e),new THREE.UV(c/d,(f+1)/e),new THREE.UV((c+1)/d,(f+1)/e),new THREE.UV((c+1)/d,f/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,f=Math.PI,b=Math.max(3,c||8),j=Math.max(2,d||6);c=[];for(d=0;d<j+1;d++){e=d/j;var h=a*Math.cos(e*f),g=a*Math.sin(e*f),m=[],w=0;for(e=0;e<b;e++){var B=2*e/b,u=g*Math.sin(B*f);B=g*Math.cos(B*f);(d==0||d==j)&&e>0||(w=this.vertices.push(new THREE.Vertex(new THREE.Vector3(B,h,u)))-1);m.push(w)}c.push(m)}var q,x,E;f=c.length;for(d=0;d<f;d++){b=c[d].length;if(d>0)for(e=0;e<b;e++){m=e==b-1;j=c[d][m?0:e+1];h=c[d][m?b-1:e];g=c[d-1][m?b-1:e];m=c[d-1][m?
|
|
|
-0:e+1];u=d/(f-1);q=(d-1)/(f-1);x=(e+1)/b;B=e/b;w=new THREE.UV(1-x,u);u=new THREE.UV(1-B,u);B=new THREE.UV(1-B,q);var H=new THREE.UV(1-x,q);if(d<c.length-1){q=this.vertices[j].position.clone();x=this.vertices[h].position.clone();E=this.vertices[g].position.clone();q.normalize();x.normalize();E.normalize();this.faces.push(new THREE.Face3(j,h,g,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(E.x,E.y,E.z)]));this.uvs.push([w,u,B])}if(d>1){q=this.vertices[j].position.clone();
|
|
|
-x=this.vertices[g].position.clone();E=this.vertices[m].position.clone();q.normalize();x.normalize();E.normalize();this.faces.push(new THREE.Face3(j,g,m,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(E.x,E.y,E.z)]));this.uvs.push([w,B,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
|
|
|
+var Sphere=function(a,c,d){THREE.Geometry.call(this);var e,f=Math.PI,b=Math.max(3,c||8),j=Math.max(2,d||6);c=[];for(d=0;d<j+1;d++){e=d/j;var h=a*Math.cos(e*f),g=a*Math.sin(e*f),m=[],y=0;for(e=0;e<b;e++){var C=2*e/b,u=g*Math.sin(C*f);C=g*Math.cos(C*f);(d==0||d==j)&&e>0||(y=this.vertices.push(new THREE.Vertex(new THREE.Vector3(C,h,u)))-1);m.push(y)}c.push(m)}var q,A,F;f=c.length;for(d=0;d<f;d++){b=c[d].length;if(d>0)for(e=0;e<b;e++){m=e==b-1;j=c[d][m?0:e+1];h=c[d][m?b-1:e];g=c[d-1][m?b-1:e];m=c[d-1][m?
|
|
|
+0:e+1];u=d/(f-1);q=(d-1)/(f-1);A=(e+1)/b;C=e/b;y=new THREE.UV(1-A,u);u=new THREE.UV(1-C,u);C=new THREE.UV(1-C,q);var G=new THREE.UV(1-A,q);if(d<c.length-1){q=this.vertices[j].position.clone();A=this.vertices[h].position.clone();F=this.vertices[g].position.clone();q.normalize();A.normalize();F.normalize();this.faces.push(new THREE.Face3(j,h,g,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(F.x,F.y,F.z)]));this.uvs.push([y,u,C])}if(d>1){q=this.vertices[j].position.clone();
|
|
|
+A=this.vertices[g].position.clone();F=this.vertices[m].position.clone();q.normalize();A.normalize();F.normalize();this.faces.push(new THREE.Face3(j,g,m,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(F.x,F.y,F.z)]));this.uvs.push([y,C,G])}}}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 f=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(e),(this.radius+this.tube*Math.cos(f))*Math.sin(e),this.tube*Math.sin(f))));a.push([d/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(d=
|
|
|
1;d<=this.segmentsT;++d){e=(this.segmentsT+1)*c+d;f=(this.segmentsT+1)*c+d-1;var b=(this.segmentsT+1)*(c-1)+d-1,j=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,f,b,j));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[b][0],a[b][1]),new THREE.UV(a[j][0],a[j][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
|
|
|
-var Icosahedron=function(a){function c(B,u,q){var x=Math.sqrt(B*B+u*u+q*q);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(B/x,u/x,q/x)))-1}function d(B,u,q,x){x.faces.push(new THREE.Face3(B,u,q))}function e(B,u){var q=f.vertices[B].position,x=f.vertices[u].position;return c((q.x+x.x)/2,(q.y+x.y)/2,(q.z+x.z)/2)}var f=this,b=new THREE.Geometry,j;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,b);d(0,5,1,b);d(0,1,7,b);d(0,7,10,b);d(0,10,11,b);d(1,5,9,b);d(5,11,4,b);d(11,10,2,b);d(10,7,6,b);d(7,1,8,b);d(3,9,4,b);d(3,4,2,b);d(3,2,6,b);d(3,6,8,b);d(3,8,9,b);d(4,9,5,b);d(2,4,11,b);d(6,2,10,b);d(8,6,7,b);d(9,8,1,b);for(a=0;a<this.subdivisions;a++){j=new THREE.Geometry;for(var h in b.faces){var g=e(b.faces[h].a,b.faces[h].b),m=e(b.faces[h].b,b.faces[h].c),w=e(b.faces[h].c,b.faces[h].a);d(b.faces[h].a,g,w,j);d(b.faces[h].b,m,g,j);d(b.faces[h].c,
|
|
|
-w,m,j);d(g,m,w,j)}b.faces=j.faces}f.faces=b.faces;delete b;delete j;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
|
|
|
+var Icosahedron=function(a){function c(C,u,q){var A=Math.sqrt(C*C+u*u+q*q);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(C/A,u/A,q/A)))-1}function d(C,u,q,A){A.faces.push(new THREE.Face3(C,u,q))}function e(C,u){var q=f.vertices[C].position,A=f.vertices[u].position;return c((q.x+A.x)/2,(q.y+A.y)/2,(q.z+A.z)/2)}var f=this,b=new THREE.Geometry,j;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,b);d(0,5,1,b);d(0,1,7,b);d(0,7,10,b);d(0,10,11,b);d(1,5,9,b);d(5,11,4,b);d(11,10,2,b);d(10,7,6,b);d(7,1,8,b);d(3,9,4,b);d(3,4,2,b);d(3,2,6,b);d(3,6,8,b);d(3,8,9,b);d(4,9,5,b);d(2,4,11,b);d(6,2,10,b);d(8,6,7,b);d(9,8,1,b);for(a=0;a<this.subdivisions;a++){j=new THREE.Geometry;for(var h in b.faces){var g=e(b.faces[h].a,b.faces[h].b),m=e(b.faces[h].b,b.faces[h].c),y=e(b.faces[h].c,b.faces[h].a);d(b.faces[h].a,g,y,j);d(b.faces[h].b,m,g,j);d(b.faces[h].c,
|
|
|
+y,m,j);d(g,m,y,j)}b.faces=j.faces}f.faces=b.faces;delete b;delete j;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=[],f=[],b=[],j=[],h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));f[h]=this.vertices.length-1;e[h]=new THREE.Vector3(a[h].x,a[h].y,a[h].z)}for(var g=THREE.Matrix4.rotationZMatrix(c),m=0;m<=d+0.0010;m+=c){for(h=0;h<e.length;h++)if(m<d){e[h]=g.multiplyVector3(e[h].clone());this.vertices.push(new THREE.Vertex(e[h]));b[h]=this.vertices.length-1}else b=j;if(m==0)j=f;for(h=0;h<f.length-1;h++){this.faces.push(new THREE.Face4(b[h],
|
|
|
b[h+1],f[h+1],f[h]));this.uvs.push([new THREE.UV(m/d,h/a.length),new THREE.UV(m/d,(h+1)/a.length),new THREE.UV((m-c)/d,(h+1)/a.length),new THREE.UV((m-c)/d,h/a.length)])}f=b;b=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
|
|
|
THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var c="Loaded ";c+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
|
|
|
c},loadAsciiOld:function(a,c){var d=document.createElement("script");d.type="text/javascript";d.onload=c;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a){var c=a.model,d=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);c.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,d,e)};c.postMessage(a)},loadBinary:function(a){var c=a.model,d=a.callback,e=a.texture_path?a.texture_path:
|
|
|
THREE.Loader.prototype.extractUrlbase(c),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var b=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers,j.data.materials,d,f,e,b)};c.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};c.postMessage(a)},loadAjaxBuffers:function(a,c,d,e,f,b){var j=new XMLHttpRequest,h=e+"/"+a,g=0;
|
|
|
j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.Loader.prototype.createBinModel(j.responseText,d,f,c):alert("Couldn't load ["+h+"] ["+j.status+"]");else if(j.readyState==3){if(b){if(g==0)g=j.getResponseHeader("Content-Length");b({total:g,loaded:j.responseText.length})}}else if(j.readyState==2)g=j.getResponseHeader("Content-Length")};j.open("GET",h,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)},
|
|
|
-createBinModel:function(a,c,d,e){var f=function(b){function j(G,L){var J=w(G,L),O=w(G,L+1),ba=w(G,L+2),ia=w(G,L+3),ja=(ia<<1&255|ba>>7)-127;J=(ba&127)<<16|O<<8|J;if(J==0&&ja==-127)return 0;return(1-2*(ia>>7))*(1+J*Math.pow(2,-23))*Math.pow(2,ja)}function h(G,L){var J=w(G,L),O=w(G,L+1),ba=w(G,L+2);return(w(G,L+3)<<24)+(ba<<16)+(O<<8)+J}function g(G,L){var J=w(G,L);return(w(G,L+1)<<8)+J}function m(G,L){var J=w(G,L);return J>127?J-256:J}function w(G,L){return G.charCodeAt(L)&255}function B(G){var L,
|
|
|
-J,O;L=h(a,G);J=h(a,G+n);O=h(a,G+l);G=g(a,G+v);THREE.Loader.prototype.f3(t,L,J,O,G)}function u(G){var L,J,O,ba,ia,ja;L=h(a,G);J=h(a,G+n);O=h(a,G+l);ba=g(a,G+v);ia=h(a,G+C);ja=h(a,G+y);G=h(a,G+z);THREE.Loader.prototype.f3n(t,k,L,J,O,ba,ia,ja,G)}function q(G){var L,J,O,ba;L=h(a,G);J=h(a,G+D);O=h(a,G+A);ba=h(a,G+F);G=g(a,G+T);THREE.Loader.prototype.f4(t,L,J,O,ba,G)}function x(G){var L,J,O,ba,ia,ja,pa,la;L=h(a,G);J=h(a,G+D);O=h(a,G+A);ba=h(a,G+F);ia=g(a,G+T);ja=h(a,G+N);pa=h(a,G+X);la=h(a,G+W);G=h(a,G+
|
|
|
-R);THREE.Loader.prototype.f4n(t,k,L,J,O,ba,ia,ja,pa,la,G)}function E(G){var L,J;L=h(a,G);J=h(a,G+Y);G=h(a,G+ea);THREE.Loader.prototype.uv3(t.uvs,p[L*2],p[L*2+1],p[J*2],p[J*2+1],p[G*2],p[G*2+1])}function H(G){var L,J,O;L=h(a,G);J=h(a,G+Q);O=h(a,G+P);G=h(a,G+ca);THREE.Loader.prototype.uv4(t.uvs,p[L*2],p[L*2+1],p[J*2],p[J*2+1],p[O*2],p[O*2+1],p[G*2],p[G*2+1])}var t=this,I=0,o,k=[],p=[],n,l,v,C,y,z,D,A,F,T,N,X,W,R,Y,ea,Q,P,ca,aa,K,U,V,ga,fa;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(t,
|
|
|
-e,b);o={signature:a.substr(I,8),header_bytes:w(a,I+8),vertex_coordinate_bytes:w(a,I+9),normal_coordinate_bytes:w(a,I+10),uv_coordinate_bytes:w(a,I+11),vertex_index_bytes:w(a,I+12),normal_index_bytes:w(a,I+13),uv_index_bytes:w(a,I+14),material_index_bytes:w(a,I+15),nvertices:h(a,I+16),nnormals:h(a,I+16+4),nuvs:h(a,I+16+8),ntri_flat:h(a,I+16+12),ntri_smooth:h(a,I+16+16),ntri_flat_uv:h(a,I+16+20),ntri_smooth_uv:h(a,I+16+24),nquad_flat:h(a,I+16+28),nquad_smooth:h(a,I+16+32),nquad_flat_uv:h(a,I+16+36),
|
|
|
-nquad_smooth_uv:h(a,I+16+40)};I+=o.header_bytes;n=o.vertex_index_bytes;l=o.vertex_index_bytes*2;v=o.vertex_index_bytes*3;C=o.vertex_index_bytes*3+o.material_index_bytes;y=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;z=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;D=o.vertex_index_bytes;A=o.vertex_index_bytes*2;F=o.vertex_index_bytes*3;T=o.vertex_index_bytes*4;N=o.vertex_index_bytes*4+o.material_index_bytes;X=o.vertex_index_bytes*4+o.material_index_bytes+
|
|
|
-o.normal_index_bytes;W=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*2;R=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*3;Y=o.uv_index_bytes;ea=o.uv_index_bytes*2;Q=o.uv_index_bytes;P=o.uv_index_bytes*2;ca=o.uv_index_bytes*3;b=o.vertex_index_bytes*3+o.material_index_bytes;fa=o.vertex_index_bytes*4+o.material_index_bytes;aa=o.ntri_flat*b;K=o.ntri_smooth*(b+o.normal_index_bytes*3);U=o.ntri_flat_uv*(b+o.uv_index_bytes*3);V=o.ntri_smooth_uv*(b+o.normal_index_bytes*
|
|
|
-3+o.uv_index_bytes*3);ga=o.nquad_flat*fa;b=o.nquad_smooth*(fa+o.normal_index_bytes*4);fa=o.nquad_flat_uv*(fa+o.uv_index_bytes*4);I+=function(G){var L,J,O,ba=o.vertex_coordinate_bytes*3,ia=G+o.nvertices*ba;for(G=G;G<ia;G+=ba){L=j(a,G);J=j(a,G+o.vertex_coordinate_bytes);O=j(a,G+o.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(t,L,J,O)}return o.nvertices*ba}(I);I+=function(G){var L,J,O,ba=o.normal_coordinate_bytes*3,ia=G+o.nnormals*ba;for(G=G;G<ia;G+=ba){L=m(a,G);J=m(a,G+o.normal_coordinate_bytes);
|
|
|
-O=m(a,G+o.normal_coordinate_bytes*2);k.push(L/127,J/127,O/127)}return o.nnormals*ba}(I);I+=function(G){var L,J,O=o.uv_coordinate_bytes*2,ba=G+o.nuvs*O;for(G=G;G<ba;G+=O){L=j(a,G);J=j(a,G+o.uv_coordinate_bytes);p.push(L,J)}return o.nuvs*O}(I);I=I;aa=I+aa;K=aa+K;U=K+U;V=U+V;ga=V+ga;b=ga+b;fa=b+fa;(function(G){var L,J=o.vertex_index_bytes*3+o.material_index_bytes,O=J+o.uv_index_bytes*3,ba=G+o.ntri_flat_uv*O;for(L=G;L<ba;L+=O){B(L);E(L+J)}return ba-G})(K);(function(G){var L,J=o.vertex_index_bytes*3+o.material_index_bytes+
|
|
|
-o.normal_index_bytes*3,O=J+o.uv_index_bytes*3,ba=G+o.ntri_smooth_uv*O;for(L=G;L<ba;L+=O){u(L);E(L+J)}return ba-G})(U);(function(G){var L,J=o.vertex_index_bytes*4+o.material_index_bytes,O=J+o.uv_index_bytes*4,ba=G+o.nquad_flat_uv*O;for(L=G;L<ba;L+=O){q(L);H(L+J)}return ba-G})(b);(function(G){var L,J=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,O=J+o.uv_index_bytes*4,ba=G+o.nquad_smooth_uv*O;for(L=G;L<ba;L+=O){x(L);H(L+J)}return ba-G})(fa);(function(G){var L,J=o.vertex_index_bytes*
|
|
|
-3+o.material_index_bytes,O=G+o.ntri_flat*J;for(L=G;L<O;L+=J)B(L);return O-G})(I);(function(G){var L,J=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*3,O=G+o.ntri_smooth*J;for(L=G;L<O;L+=J)u(L);return O-G})(aa);(function(G){var L,J=o.vertex_index_bytes*4+o.material_index_bytes,O=G+o.nquad_flat*J;for(L=G;L<O;L+=J)q(L);return O-G})(V);(function(G){var L,J=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,O=G+o.nquad_smooth*J;for(L=G;L<O;L+=J)x(L);return O-G})(ga);
|
|
|
-this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f(d))},createModel:function(a,c,d){var e=function(f){var b=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(b,a.materials,f);(function(){var j,h,g,m,w;j=0;for(h=a.vertices.length;j<h;j+=3){g=a.vertices[j];m=a.vertices[j+1];w=a.vertices[j+2];THREE.Loader.prototype.v(b,g,m,w)}})();(function(){function j(x,E){THREE.Loader.prototype.f3(b,x[E],
|
|
|
-x[E+1],x[E+2],x[E+3])}function h(x,E){THREE.Loader.prototype.f3n(b,a.normals,x[E],x[E+1],x[E+2],x[E+3],x[E+4],x[E+5],x[E+6])}function g(x,E){THREE.Loader.prototype.f4(b,x[E],x[E+1],x[E+2],x[E+3],x[E+4])}function m(x,E){THREE.Loader.prototype.f4n(b,a.normals,x[E],x[E+1],x[E+2],x[E+3],x[E+4],x[E+5],x[E+6],x[E+7],x[E+8])}function w(x,E){var H,t,I,o,k,p,n,l,v;H=x[E];t=x[E+1];I=x[E+2];o=a.uvs[H*2];n=a.uvs[H*2+1];k=a.uvs[t*2];l=a.uvs[t*2+1];p=a.uvs[I*2];v=a.uvs[I*2+1];THREE.Loader.prototype.uv3(b.uvs,o,
|
|
|
-n,k,l,p,v);if(a.uvs2){o=a.uvs2[H*2];n=a.uvs2[H*2+1];k=a.uvs2[t*2];l=a.uvs2[t*2+1];p=a.uvs2[I*2];v=a.uvs2[I*2+1];THREE.Loader.prototype.uv3(b.uvs2,o,1-n,k,1-l,p,1-v)}}function B(x,E){var H,t,I,o,k,p,n,l,v,C,y,z;H=x[E];t=x[E+1];I=x[E+2];o=x[E+3];k=a.uvs[H*2];v=a.uvs[H*2+1];p=a.uvs[t*2];C=a.uvs[t*2+1];n=a.uvs[I*2];y=a.uvs[I*2+1];l=a.uvs[o*2];z=a.uvs[o*2+1];THREE.Loader.prototype.uv4(b.uvs,k,v,p,C,n,y,l,z);if(a.uvs2){k=a.uvs2[H*2];v=a.uvs2[H*2+1];p=a.uvs2[t*2];C=a.uvs2[t*2+1];n=a.uvs2[I*2];y=a.uvs2[I*
|
|
|
-2+1];l=a.uvs2[o*2];z=a.uvs2[o*2+1];THREE.Loader.prototype.uv4(b.uvs2,k,1-v,p,1-C,n,1-y,l,1-z)}}var u,q;u=0;for(q=a.triangles_uv.length;u<q;u+=7){j(a.triangles_uv,u);w(a.triangles_uv,u+4)}u=0;for(q=a.triangles_n_uv.length;u<q;u+=10){h(a.triangles_n_uv,u);w(a.triangles_n_uv,u+7)}u=0;for(q=a.quads_uv.length;u<q;u+=9){g(a.quads_uv,u);B(a.quads_uv,u+5)}u=0;for(q=a.quads_n_uv.length;u<q;u+=13){m(a.quads_n_uv,u);B(a.quads_n_uv,u+9)}u=0;for(q=a.triangles.length;u<q;u+=4)j(a.triangles,u);u=0;for(q=a.triangles_n.length;u<
|
|
|
+createBinModel:function(a,c,d,e){var f=function(b){function j(E,L){var J=y(E,L),X=y(E,L+1),ea=y(E,L+2),ja=y(E,L+3),ia=(ja<<1&255|ea>>7)-127;J=(ea&127)<<16|X<<8|J;if(J==0&&ia==-127)return 0;return(1-2*(ja>>7))*(1+J*Math.pow(2,-23))*Math.pow(2,ia)}function h(E,L){var J=y(E,L),X=y(E,L+1),ea=y(E,L+2);return(y(E,L+3)<<24)+(ea<<16)+(X<<8)+J}function g(E,L){var J=y(E,L);return(y(E,L+1)<<8)+J}function m(E,L){var J=y(E,L);return J>127?J-256:J}function y(E,L){return E.charCodeAt(L)&255}function C(E){var L,
|
|
|
+J,X;L=h(a,E);J=h(a,E+n);X=h(a,E+k);E=g(a,E+w);THREE.Loader.prototype.f3(t,L,J,X,E)}function u(E){var L,J,X,ea,ja,ia;L=h(a,E);J=h(a,E+n);X=h(a,E+k);ea=g(a,E+w);ja=h(a,E+v);ia=h(a,E+x);E=h(a,E+z);THREE.Loader.prototype.f3n(t,l,L,J,X,ea,ja,ia,E)}function q(E){var L,J,X,ea;L=h(a,E);J=h(a,E+D);X=h(a,E+B);ea=h(a,E+I);E=g(a,E+O);THREE.Loader.prototype.f4(t,L,J,X,ea,E)}function A(E){var L,J,X,ea,ja,ia,qa,la;L=h(a,E);J=h(a,E+D);X=h(a,E+B);ea=h(a,E+I);ja=g(a,E+O);ia=h(a,E+Q);qa=h(a,E+R);la=h(a,E+U);E=h(a,E+
|
|
|
+T);THREE.Loader.prototype.f4n(t,l,L,J,X,ea,ja,ia,qa,la,E)}function F(E){var L,J;L=h(a,E);J=h(a,E+ba);E=h(a,E+ca);THREE.Loader.prototype.uv3(t.uvs,p[L*2],p[L*2+1],p[J*2],p[J*2+1],p[E*2],p[E*2+1])}function G(E){var L,J,X;L=h(a,E);J=h(a,E+S);X=h(a,E+K);E=h(a,E+Z);THREE.Loader.prototype.uv4(t.uvs,p[L*2],p[L*2+1],p[J*2],p[J*2+1],p[X*2],p[X*2+1],p[E*2],p[E*2+1])}var t=this,H=0,o,l=[],p=[],n,k,w,v,x,z,D,B,I,O,Q,R,U,T,ba,ca,S,K,Z,V,N,W,$,da,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(t,
|
|
|
+e,b);o={signature:a.substr(H,8),header_bytes:y(a,H+8),vertex_coordinate_bytes:y(a,H+9),normal_coordinate_bytes:y(a,H+10),uv_coordinate_bytes:y(a,H+11),vertex_index_bytes:y(a,H+12),normal_index_bytes:y(a,H+13),uv_index_bytes:y(a,H+14),material_index_bytes:y(a,H+15),nvertices:h(a,H+16),nnormals:h(a,H+16+4),nuvs:h(a,H+16+8),ntri_flat:h(a,H+16+12),ntri_smooth:h(a,H+16+16),ntri_flat_uv:h(a,H+16+20),ntri_smooth_uv:h(a,H+16+24),nquad_flat:h(a,H+16+28),nquad_smooth:h(a,H+16+32),nquad_flat_uv:h(a,H+16+36),
|
|
|
+nquad_smooth_uv:h(a,H+16+40)};H+=o.header_bytes;n=o.vertex_index_bytes;k=o.vertex_index_bytes*2;w=o.vertex_index_bytes*3;v=o.vertex_index_bytes*3+o.material_index_bytes;x=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;z=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;D=o.vertex_index_bytes;B=o.vertex_index_bytes*2;I=o.vertex_index_bytes*3;O=o.vertex_index_bytes*4;Q=o.vertex_index_bytes*4+o.material_index_bytes;R=o.vertex_index_bytes*4+o.material_index_bytes+
|
|
|
+o.normal_index_bytes;U=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*2;T=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*3;ba=o.uv_index_bytes;ca=o.uv_index_bytes*2;S=o.uv_index_bytes;K=o.uv_index_bytes*2;Z=o.uv_index_bytes*3;b=o.vertex_index_bytes*3+o.material_index_bytes;ha=o.vertex_index_bytes*4+o.material_index_bytes;V=o.ntri_flat*b;N=o.ntri_smooth*(b+o.normal_index_bytes*3);W=o.ntri_flat_uv*(b+o.uv_index_bytes*3);$=o.ntri_smooth_uv*(b+o.normal_index_bytes*
|
|
|
+3+o.uv_index_bytes*3);da=o.nquad_flat*ha;b=o.nquad_smooth*(ha+o.normal_index_bytes*4);ha=o.nquad_flat_uv*(ha+o.uv_index_bytes*4);H+=function(E){var L,J,X,ea=o.vertex_coordinate_bytes*3,ja=E+o.nvertices*ea;for(E=E;E<ja;E+=ea){L=j(a,E);J=j(a,E+o.vertex_coordinate_bytes);X=j(a,E+o.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(t,L,J,X)}return o.nvertices*ea}(H);H+=function(E){var L,J,X,ea=o.normal_coordinate_bytes*3,ja=E+o.nnormals*ea;for(E=E;E<ja;E+=ea){L=m(a,E);J=m(a,E+o.normal_coordinate_bytes);
|
|
|
+X=m(a,E+o.normal_coordinate_bytes*2);l.push(L/127,J/127,X/127)}return o.nnormals*ea}(H);H+=function(E){var L,J,X=o.uv_coordinate_bytes*2,ea=E+o.nuvs*X;for(E=E;E<ea;E+=X){L=j(a,E);J=j(a,E+o.uv_coordinate_bytes);p.push(L,J)}return o.nuvs*X}(H);H=H;V=H+V;N=V+N;W=N+W;$=W+$;da=$+da;b=da+b;ha=b+ha;(function(E){var L,J=o.vertex_index_bytes*3+o.material_index_bytes,X=J+o.uv_index_bytes*3,ea=E+o.ntri_flat_uv*X;for(L=E;L<ea;L+=X){C(L);F(L+J)}return ea-E})(N);(function(E){var L,J=o.vertex_index_bytes*3+o.material_index_bytes+
|
|
|
+o.normal_index_bytes*3,X=J+o.uv_index_bytes*3,ea=E+o.ntri_smooth_uv*X;for(L=E;L<ea;L+=X){u(L);F(L+J)}return ea-E})(W);(function(E){var L,J=o.vertex_index_bytes*4+o.material_index_bytes,X=J+o.uv_index_bytes*4,ea=E+o.nquad_flat_uv*X;for(L=E;L<ea;L+=X){q(L);G(L+J)}return ea-E})(b);(function(E){var L,J=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,X=J+o.uv_index_bytes*4,ea=E+o.nquad_smooth_uv*X;for(L=E;L<ea;L+=X){A(L);G(L+J)}return ea-E})(ha);(function(E){var L,J=o.vertex_index_bytes*
|
|
|
+3+o.material_index_bytes,X=E+o.ntri_flat*J;for(L=E;L<X;L+=J)C(L);return X-E})(H);(function(E){var L,J=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*3,X=E+o.ntri_smooth*J;for(L=E;L<X;L+=J)u(L);return X-E})(V);(function(E){var L,J=o.vertex_index_bytes*4+o.material_index_bytes,X=E+o.nquad_flat*J;for(L=E;L<X;L+=J)q(L);return X-E})($);(function(E){var L,J=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,X=E+o.nquad_smooth*J;for(L=E;L<X;L+=J)A(L);return X-E})(da);
|
|
|
+this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f(d))},createModel:function(a,c,d){var e=function(f){var b=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(b,a.materials,f);(function(){var j,h,g,m,y;j=0;for(h=a.vertices.length;j<h;j+=3){g=a.vertices[j];m=a.vertices[j+1];y=a.vertices[j+2];THREE.Loader.prototype.v(b,g,m,y)}})();(function(){function j(A,F){THREE.Loader.prototype.f3(b,A[F],
|
|
|
+A[F+1],A[F+2],A[F+3])}function h(A,F){THREE.Loader.prototype.f3n(b,a.normals,A[F],A[F+1],A[F+2],A[F+3],A[F+4],A[F+5],A[F+6])}function g(A,F){THREE.Loader.prototype.f4(b,A[F],A[F+1],A[F+2],A[F+3],A[F+4])}function m(A,F){THREE.Loader.prototype.f4n(b,a.normals,A[F],A[F+1],A[F+2],A[F+3],A[F+4],A[F+5],A[F+6],A[F+7],A[F+8])}function y(A,F){var G,t,H,o,l,p,n,k,w;G=A[F];t=A[F+1];H=A[F+2];o=a.uvs[G*2];n=a.uvs[G*2+1];l=a.uvs[t*2];k=a.uvs[t*2+1];p=a.uvs[H*2];w=a.uvs[H*2+1];THREE.Loader.prototype.uv3(b.uvs,o,
|
|
|
+n,l,k,p,w);if(a.uvs2){o=a.uvs2[G*2];n=a.uvs2[G*2+1];l=a.uvs2[t*2];k=a.uvs2[t*2+1];p=a.uvs2[H*2];w=a.uvs2[H*2+1];THREE.Loader.prototype.uv3(b.uvs2,o,1-n,l,1-k,p,1-w)}}function C(A,F){var G,t,H,o,l,p,n,k,w,v,x,z;G=A[F];t=A[F+1];H=A[F+2];o=A[F+3];l=a.uvs[G*2];w=a.uvs[G*2+1];p=a.uvs[t*2];v=a.uvs[t*2+1];n=a.uvs[H*2];x=a.uvs[H*2+1];k=a.uvs[o*2];z=a.uvs[o*2+1];THREE.Loader.prototype.uv4(b.uvs,l,w,p,v,n,x,k,z);if(a.uvs2){l=a.uvs2[G*2];w=a.uvs2[G*2+1];p=a.uvs2[t*2];v=a.uvs2[t*2+1];n=a.uvs2[H*2];x=a.uvs2[H*
|
|
|
+2+1];k=a.uvs2[o*2];z=a.uvs2[o*2+1];THREE.Loader.prototype.uv4(b.uvs2,l,1-w,p,1-v,n,1-x,k,1-z)}}var u,q;u=0;for(q=a.triangles_uv.length;u<q;u+=7){j(a.triangles_uv,u);y(a.triangles_uv,u+4)}u=0;for(q=a.triangles_n_uv.length;u<q;u+=10){h(a.triangles_n_uv,u);y(a.triangles_n_uv,u+7)}u=0;for(q=a.quads_uv.length;u<q;u+=9){g(a.quads_uv,u);C(a.quads_uv,u+5)}u=0;for(q=a.quads_n_uv.length;u<q;u+=13){m(a.quads_n_uv,u);C(a.quads_n_uv,u+9)}u=0;for(q=a.triangles.length;u<q;u+=4)j(a.triangles,u);u=0;for(q=a.triangles_n.length;u<
|
|
|
q;u+=7)h(a.triangles_n,u);u=0;for(q=a.quads.length;u<q;u+=5)g(a.quads,u);u=0;for(q=a.quads_n.length;u<q;u+=9)m(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,f){a.faces.push(new THREE.Face3(c,d,e,null,a.materials[f]))},f4:function(a,c,d,e,f,b){a.faces.push(new THREE.Face4(c,d,e,f,null,
|
|
|
-a.materials[b]))},f3n:function(a,c,d,e,f,b,j,h,g){b=a.materials[b];var m=c[h*3],w=c[h*3+1];h=c[h*3+2];var B=c[g*3],u=c[g*3+1];g=c[g*3+2];a.faces.push(new THREE.Face3(d,e,f,[new THREE.Vector3(c[j*3],c[j*3+1],c[j*3+2]),new THREE.Vector3(m,w,h),new THREE.Vector3(B,u,g)],b))},f4n:function(a,c,d,e,f,b,j,h,g,m,w){j=a.materials[j];var B=c[g*3],u=c[g*3+1];g=c[g*3+2];var q=c[m*3],x=c[m*3+1];m=c[m*3+2];var E=c[w*3],H=c[w*3+1];w=c[w*3+2];a.faces.push(new THREE.Face4(d,e,f,b,[new THREE.Vector3(c[h*3],c[h*3+1],
|
|
|
-c[h*3+2]),new THREE.Vector3(B,u,g),new THREE.Vector3(q,x,m),new THREE.Vector3(E,H,w)],j))},uv3:function(a,c,d,e,f,b,j){var h=[];h.push(new THREE.UV(c,d));h.push(new THREE.UV(e,f));h.push(new THREE.UV(b,j));a.push(h)},uv4:function(a,c,d,e,f,b,j,h,g){var m=[];m.push(new THREE.UV(c,d));m.push(new THREE.UV(e,f));m.push(new THREE.UV(b,j));m.push(new THREE.UV(h,g));a.push(m)},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(j){j=Math.log(j)/Math.LN2;return Math.floor(j)==j}function e(j,h){var g=new Image;g.onload=function(){if(!d(this.width)||!d(this.height)){var m=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),w=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));j.image.width=m;j.image.height=w;j.image.getContext("2d").drawImage(this,0,0,m,w)}else j.image=this;j.image.loaded=1};g.src=h}var f,b;if(a.map_diffuse&&c){b=document.createElement("canvas");f=new THREE.MeshLambertMaterial({map:new THREE.Texture(b)});
|
|
|
+a.materials[b]))},f3n:function(a,c,d,e,f,b,j,h,g){b=a.materials[b];var m=c[h*3],y=c[h*3+1];h=c[h*3+2];var C=c[g*3],u=c[g*3+1];g=c[g*3+2];a.faces.push(new THREE.Face3(d,e,f,[new THREE.Vector3(c[j*3],c[j*3+1],c[j*3+2]),new THREE.Vector3(m,y,h),new THREE.Vector3(C,u,g)],b))},f4n:function(a,c,d,e,f,b,j,h,g,m,y){j=a.materials[j];var C=c[g*3],u=c[g*3+1];g=c[g*3+2];var q=c[m*3],A=c[m*3+1];m=c[m*3+2];var F=c[y*3],G=c[y*3+1];y=c[y*3+2];a.faces.push(new THREE.Face4(d,e,f,b,[new THREE.Vector3(c[h*3],c[h*3+1],
|
|
|
+c[h*3+2]),new THREE.Vector3(C,u,g),new THREE.Vector3(q,A,m),new THREE.Vector3(F,G,y)],j))},uv3:function(a,c,d,e,f,b,j){var h=[];h.push(new THREE.UV(c,d));h.push(new THREE.UV(e,f));h.push(new THREE.UV(b,j));a.push(h)},uv4:function(a,c,d,e,f,b,j,h,g){var m=[];m.push(new THREE.UV(c,d));m.push(new THREE.UV(e,f));m.push(new THREE.UV(b,j));m.push(new THREE.UV(h,g));a.push(m)},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(j){j=Math.log(j)/Math.LN2;return Math.floor(j)==j}function e(j,h){var g=new Image;g.onload=function(){if(!d(this.width)||!d(this.height)){var m=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),y=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));j.image.width=m;j.image.height=y;j.image.getContext("2d").drawImage(this,0,0,m,y)}else j.image=this;j.image.loaded=1};g.src=h}var f,b;if(a.map_diffuse&&c){b=document.createElement("canvas");f=new THREE.MeshLambertMaterial({map:new THREE.Texture(b)});
|
|
|
e(f.map,c+"/"+a.map_diffuse)}else if(a.col_diffuse){f=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;f=new THREE.MeshLambertMaterial({color:f,opacity:a.transparency})}else f=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):new THREE.MeshLambertMaterial({color:15658734});if(a.map_lightmap&&c){b=document.createElement("canvas");f.light_map=new THREE.Texture(b);e(f.light_map,c+"/"+a.map_lightmap)}return f},extractUrlbase:function(a){a=a.split("/");a.pop();
|
|
|
return a.join("/")}};
|