|
@@ -12,58 +12,58 @@ THREE.Vector4=function(a,b,f,e){this.x=a||0;this.y=b||0;this.z=f||0;this.w=e||1}
|
|
|
THREE.Vector4.prototype={set:function(a,b,f,e){this.x=a;this.y=b;this.z=f;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
|
|
|
return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
|
|
|
THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
|
|
|
-THREE.Ray.prototype={intersectScene:function(a){var b,f,e=a.objects,h=[];a=0;for(b=e.length;a<b;a++){f=e[a];if(f instanceof THREE.Mesh)h=h.concat(this.intersectObject(f))}h.sort(function(j,p){return j.distance-p.distance});return h},intersectObject:function(a){function b(O,r,L,d){d=d.clone().subSelf(r);L=L.clone().subSelf(r);var i=O.clone().subSelf(r);O=d.dot(d);r=d.dot(L);d=d.dot(i);var o=L.dot(L);L=L.dot(i);i=1/(O*o-r*r);o=(o*d-r*L)*i;O=(O*L-r*d)*i;return o>0&&O>0&&o+O<1}var f,e,h,j,p,c,k,m,B,D,
|
|
|
-x,A=a.geometry,M=A.vertices,Q=[];f=0;for(e=A.faces.length;f<e;f++){h=A.faces[f];D=this.origin.clone();x=this.direction.clone();j=a.matrix.multiplyVector3(M[h.a].position.clone());p=a.matrix.multiplyVector3(M[h.b].position.clone());c=a.matrix.multiplyVector3(M[h.c].position.clone());k=h instanceof THREE.Face4?a.matrix.multiplyVector3(M[h.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(h.normal.clone());B=x.dot(m);if(B<0){m=m.dot((new THREE.Vector3).sub(j,D))/B;D=D.addSelf(x.multiplyScalar(m));
|
|
|
-if(h instanceof THREE.Face3){if(b(D,j,p,c)){h={distance:this.origin.distanceTo(D),point:D,face:h,object:a};Q.push(h)}}else if(h instanceof THREE.Face4)if(b(D,j,p,k)||b(D,p,c,k)){h={distance:this.origin.distanceTo(D),point:D,face:h,object:a};Q.push(h)}}}return Q}};
|
|
|
-THREE.Rectangle=function(){function a(){j=e-b;p=h-f}var b,f,e,h,j,p,c=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return j};this.getHeight=function(){return p};this.getLeft=function(){return b};this.getTop=function(){return f};this.getRight=function(){return e};this.getBottom=function(){return h};this.set=function(k,m,B,D){c=false;b=k;f=m;e=B;h=D;a()};this.addPoint=function(k,m){if(c){c=false;b=k;f=m;e=k;h=m}else{b=b<k?b:k;f=f<m?f:m;e=e>k?e:k;h=h>m?
|
|
|
-h:m}a()};this.add3Points=function(k,m,B,D,x,A){if(c){c=false;b=k<B?k<x?k:x:B<x?B:x;f=m<D?m<A?m:A:D<A?D:A;e=k>B?k>x?k:x:B>x?B:x;h=m>D?m>A?m:A:D>A?D:A}else{b=k<B?k<x?k<b?k:b:x<b?x:b:B<x?B<b?B:b:x<b?x:b;f=m<D?m<A?m<f?m:f:A<f?A:f:D<A?D<f?D:f:A<f?A:f;e=k>B?k>x?k>e?k:e:x>e?x:e:B>x?B>e?B:e:x>e?x:e;h=m>D?m>A?m>h?m:h:A>h?A:h:D>A?D>h?D:h:A>h?A:h}a()};this.addRectangle=function(k){if(c){c=false;b=k.getLeft();f=k.getTop();e=k.getRight();h=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();f=f<k.getTop()?f:k.getTop();
|
|
|
-e=e>k.getRight()?e:k.getRight();h=h>k.getBottom()?h:k.getBottom()}a()};this.inflate=function(k){b-=k;f-=k;e+=k;h+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();f=f>k.getTop()?f:k.getTop();e=e<k.getRight()?e:k.getRight();h=h<k.getBottom()?h:k.getBottom();a()};this.instersects=function(k){return Math.min(e,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(h,k.getBottom())-Math.max(f,k.getTop())>=0};this.empty=function(){c=true;h=e=f=b=0;a()};this.isEmpty=function(){return c};this.toString=
|
|
|
-function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+f+", bottom: "+h+", width: "+j+", height: "+p+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
|
|
|
-THREE.Matrix4=function(a,b,f,e,h,j,p,c,k,m,B,D,x,A,M,Q){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=e||0;this.n21=h||0;this.n22=j||1;this.n23=p||0;this.n24=c||0;this.n31=k||0;this.n32=m||0;this.n33=B||1;this.n34=D||0;this.n41=x||0;this.n42=A||0;this.n43=M||0;this.n44=Q||1};
|
|
|
-THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,f,e,h,j,p,c,k,m,B,D,x,A,M,Q){this.n11=a;this.n12=b;this.n13=f;this.n14=e;this.n21=h;this.n22=j;this.n23=p;this.n24=c;this.n31=k;this.n32=m;this.n33=B;this.n34=D;this.n41=x;this.n42=A;this.n43=M;this.n44=Q;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
|
|
|
-a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,f){var e=new THREE.Vector3,h=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(f,j).normalize();h.cross(j,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);this.n31=j.x;
|
|
|
-this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,e=a.z,h=1/(this.n41*b+this.n42*f+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*e+this.n14)*h;a.y=(this.n21*b+this.n22*f+this.n23*e+this.n24)*h;a.z=(this.n31*b+this.n32*f+this.n33*e+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,f=a.y,e=a.z,h=a.w;a.x=this.n11*b+this.n12*f+this.n13*e+this.n14*h;a.y=this.n21*b+this.n22*f+this.n23*e+this.n24*
|
|
|
-h;a.z=this.n31*b+this.n32*f+this.n33*e+this.n34*h;a.w=this.n41*b+this.n42*f+this.n43*e+this.n44*h;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var f=a.n11,e=a.n12,h=a.n13,j=a.n14,p=a.n21,c=a.n22,k=a.n23,m=a.n24,B=a.n31,D=a.n32,
|
|
|
-x=a.n33,A=a.n34,M=a.n41,Q=a.n42,O=a.n43,r=a.n44,L=b.n11,d=b.n12,i=b.n13,o=b.n14,l=b.n21,n=b.n22,g=b.n23,t=b.n24,q=b.n31,y=b.n32,u=b.n33,s=b.n34,w=b.n41,W=b.n42,G=b.n43,T=b.n44;this.n11=f*L+e*l+h*q+j*w;this.n12=f*d+e*n+h*y+j*W;this.n13=f*i+e*g+h*u+j*G;this.n14=f*o+e*t+h*s+j*T;this.n21=p*L+c*l+k*q+m*w;this.n22=p*d+c*n+k*y+m*W;this.n23=p*i+c*g+k*u+m*G;this.n24=p*o+c*t+k*s+m*T;this.n31=B*L+D*l+x*q+A*w;this.n32=B*d+D*n+x*y+A*W;this.n33=B*i+D*g+x*u+A*G;this.n34=B*o+D*t+x*s+A*T;this.n41=M*L+Q*l+O*q+r*w;
|
|
|
-this.n42=M*d+Q*n+O*y+r*W;this.n43=M*i+Q*g+O*u+r*G;this.n44=M*o+Q*t+O*s+r*T;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,e=this.n13,h=this.n14,j=this.n21,p=this.n22,c=this.n23,k=this.n24,m=this.n31,B=this.n32,D=this.n33,x=this.n34,A=this.n41,M=this.n42,Q=this.n43,O=this.n44,r=a.n11,L=a.n21,d=a.n31,i=a.n41,o=a.n12,l=a.n22,n=a.n32,g=a.n42,t=a.n13,q=a.n23,y=a.n33,u=a.n43,s=a.n14,w=a.n24,W=a.n34;a=a.n44;this.n11=b*r+f*L+e*d+h*i;this.n12=b*o+f*l+e*n+h*g;this.n13=b*t+f*q+e*y+h*u;this.n14=
|
|
|
-b*s+f*w+e*W+h*a;this.n21=j*r+p*L+c*d+k*i;this.n22=j*o+p*l+c*n+k*g;this.n23=j*t+p*q+c*y+k*u;this.n24=j*s+p*w+c*W+k*a;this.n31=m*r+B*L+D*d+x*i;this.n32=m*o+B*l+D*n+x*g;this.n33=m*t+B*q+D*y+x*u;this.n34=m*s+B*w+D*W+x*a;this.n41=A*r+M*L+Q*d+O*i;this.n42=A*o+M*l+Q*n+O*g;this.n43=A*t+M*q+Q*y+O*u;this.n44=A*s+M*w+Q*W+O*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=
|
|
|
+THREE.Ray.prototype={intersectScene:function(a){var b,f,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){f=e[a];if(f instanceof THREE.Mesh)g=g.concat(this.intersectObject(f))}g.sort(function(j,o){return j.distance-o.distance});return g},intersectObject:function(a){function b(O,q,L,d){d=d.clone().subSelf(q);L=L.clone().subSelf(q);var h=O.clone().subSelf(q);O=d.dot(d);q=d.dot(L);d=d.dot(h);var r=L.dot(L);L=L.dot(h);h=1/(O*r-q*q);r=(r*d-q*L)*h;O=(O*L-q*d)*h;return r>0&&O>0&&r+O<1}var f,e,g,j,o,c,k,l,B,D,
|
|
|
+x,A=a.geometry,M=A.vertices,Q=[];f=0;for(e=A.faces.length;f<e;f++){g=A.faces[f];D=this.origin.clone();x=this.direction.clone();j=a.matrix.multiplyVector3(M[g.a].position.clone());o=a.matrix.multiplyVector3(M[g.b].position.clone());c=a.matrix.multiplyVector3(M[g.c].position.clone());k=g instanceof THREE.Face4?a.matrix.multiplyVector3(M[g.d].position.clone()):null;l=a.rotationMatrix.multiplyVector3(g.normal.clone());B=x.dot(l);if(B<0){l=l.dot((new THREE.Vector3).sub(j,D))/B;D=D.addSelf(x.multiplyScalar(l));
|
|
|
+if(g instanceof THREE.Face3){if(b(D,j,o,c)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};Q.push(g)}}else if(g instanceof THREE.Face4)if(b(D,j,o,k)||b(D,o,c,k)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};Q.push(g)}}}return Q}};
|
|
|
+THREE.Rectangle=function(){function a(){j=e-b;o=g-f}var b,f,e,g,j,o,c=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return j};this.getHeight=function(){return o};this.getLeft=function(){return b};this.getTop=function(){return f};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(k,l,B,D){c=false;b=k;f=l;e=B;g=D;a()};this.addPoint=function(k,l){if(c){c=false;b=k;f=l;e=k;g=l}else{b=b<k?b:k;f=f<l?f:l;e=e>k?e:k;g=g>l?
|
|
|
+g:l}a()};this.add3Points=function(k,l,B,D,x,A){if(c){c=false;b=k<B?k<x?k:x:B<x?B:x;f=l<D?l<A?l:A:D<A?D:A;e=k>B?k>x?k:x:B>x?B:x;g=l>D?l>A?l:A:D>A?D:A}else{b=k<B?k<x?k<b?k:b:x<b?x:b:B<x?B<b?B:b:x<b?x:b;f=l<D?l<A?l<f?l:f:A<f?A:f:D<A?D<f?D:f:A<f?A:f;e=k>B?k>x?k>e?k:e:x>e?x:e:B>x?B>e?B:e:x>e?x:e;g=l>D?l>A?l>g?l:g:A>g?A:g:D>A?D>g?D:g:A>g?A:g}a()};this.addRectangle=function(k){if(c){c=false;b=k.getLeft();f=k.getTop();e=k.getRight();g=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();f=f<k.getTop()?f:k.getTop();
|
|
|
+e=e>k.getRight()?e:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;f-=k;e+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();f=f>k.getTop()?f:k.getTop();e=e<k.getRight()?e:k.getRight();g=g<k.getBottom()?g:k.getBottom();a()};this.instersects=function(k){return Math.min(e,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(g,k.getBottom())-Math.max(f,k.getTop())>=0};this.empty=function(){c=true;g=e=f=b=0;a()};this.isEmpty=function(){return c};this.toString=
|
|
|
+function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+f+", bottom: "+g+", width: "+j+", height: "+o+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
|
|
|
+THREE.Matrix4=function(a,b,f,e,g,j,o,c,k,l,B,D,x,A,M,Q){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=e||0;this.n21=g||0;this.n22=j||1;this.n23=o||0;this.n24=c||0;this.n31=k||0;this.n32=l||0;this.n33=B||1;this.n34=D||0;this.n41=x||0;this.n42=A||0;this.n43=M||0;this.n44=Q||1};
|
|
|
+THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,f,e,g,j,o,c,k,l,B,D,x,A,M,Q){this.n11=a;this.n12=b;this.n13=f;this.n14=e;this.n21=g;this.n22=j;this.n23=o;this.n24=c;this.n31=k;this.n32=l;this.n33=B;this.n34=D;this.n41=x;this.n42=A;this.n43=M;this.n44=Q;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
|
|
|
+a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,f){var e=new THREE.Vector3,g=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(f,j).normalize();g.cross(j,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=j.x;
|
|
|
+this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,e=a.z,g=1/(this.n41*b+this.n42*f+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*f+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*f+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,f=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*f+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*f+this.n23*e+this.n24*
|
|
|
+g;a.z=this.n31*b+this.n32*f+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*f+this.n43*e+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var f=a.n11,e=a.n12,g=a.n13,j=a.n14,o=a.n21,c=a.n22,k=a.n23,l=a.n24,B=a.n31,D=a.n32,
|
|
|
+x=a.n33,A=a.n34,M=a.n41,Q=a.n42,O=a.n43,q=a.n44,L=b.n11,d=b.n12,h=b.n13,r=b.n14,m=b.n21,n=b.n22,i=b.n23,t=b.n24,p=b.n31,y=b.n32,u=b.n33,s=b.n34,w=b.n41,W=b.n42,G=b.n43,T=b.n44;this.n11=f*L+e*m+g*p+j*w;this.n12=f*d+e*n+g*y+j*W;this.n13=f*h+e*i+g*u+j*G;this.n14=f*r+e*t+g*s+j*T;this.n21=o*L+c*m+k*p+l*w;this.n22=o*d+c*n+k*y+l*W;this.n23=o*h+c*i+k*u+l*G;this.n24=o*r+c*t+k*s+l*T;this.n31=B*L+D*m+x*p+A*w;this.n32=B*d+D*n+x*y+A*W;this.n33=B*h+D*i+x*u+A*G;this.n34=B*r+D*t+x*s+A*T;this.n41=M*L+Q*m+O*p+q*w;
|
|
|
+this.n42=M*d+Q*n+O*y+q*W;this.n43=M*h+Q*i+O*u+q*G;this.n44=M*r+Q*t+O*s+q*T;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,e=this.n13,g=this.n14,j=this.n21,o=this.n22,c=this.n23,k=this.n24,l=this.n31,B=this.n32,D=this.n33,x=this.n34,A=this.n41,M=this.n42,Q=this.n43,O=this.n44,q=a.n11,L=a.n21,d=a.n31,h=a.n41,r=a.n12,m=a.n22,n=a.n32,i=a.n42,t=a.n13,p=a.n23,y=a.n33,u=a.n43,s=a.n14,w=a.n24,W=a.n34;a=a.n44;this.n11=b*q+f*L+e*d+g*h;this.n12=b*r+f*m+e*n+g*i;this.n13=b*t+f*p+e*y+g*u;this.n14=
|
|
|
+b*s+f*w+e*W+g*a;this.n21=j*q+o*L+c*d+k*h;this.n22=j*r+o*m+c*n+k*i;this.n23=j*t+o*p+c*y+k*u;this.n24=j*s+o*w+c*W+k*a;this.n31=l*q+B*L+D*d+x*h;this.n32=l*r+B*m+D*n+x*i;this.n33=l*t+B*p+D*y+x*u;this.n34=l*s+B*w+D*W+x*a;this.n41=A*q+M*L+Q*d+O*h;this.n42=A*r+M*m+Q*n+O*i;this.n43=A*t+M*p+Q*y+O*u;this.n44=A*s+M*w+Q*W+O*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=
|
|
|
a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*
|
|
|
-this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,f,e){var h=b[f];b[f]=b[e];
|
|
|
-b[e]=h}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
|
|
|
+this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,f,e){var g=b[f];b[f]=b[e];
|
|
|
+b[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
|
|
|
this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,f){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=f;return e};
|
|
|
THREE.Matrix4.scaleMatrix=function(a,b,f){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=f;return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b};
|
|
|
-THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var f=new THREE.Matrix4,e=Math.cos(b),h=Math.sin(b),j=1-e,p=a.x,c=a.y,k=a.z;f.n11=j*p*p+e;f.n12=j*p*c-h*k;f.n13=j*p*k+h*c;f.n21=j*p*c+h*k;f.n22=j*c*c+e;f.n23=j*c*k-h*p;f.n31=j*p*k-h*c;f.n32=j*c*k+h*p;f.n33=j*k*k+e;return f};
|
|
|
+THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var f=new THREE.Matrix4,e=Math.cos(b),g=Math.sin(b),j=1-e,o=a.x,c=a.y,k=a.z;f.n11=j*o*o+e;f.n12=j*o*c-g*k;f.n13=j*o*k+g*c;f.n21=j*o*c+g*k;f.n22=j*c*c+e;f.n23=j*c*k-g*o;f.n31=j*o*k-g*c;f.n32=j*c*k+g*o;f.n33=j*k*k+e;return f};
|
|
|
THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
|
|
|
a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
|
|
|
a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
|
|
|
a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b};
|
|
|
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var f=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],h=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],p=b[10]*b[0]-b[2]*b[8],c=-b[6]*b[0]+b[2]*b[4],k=b[9]*b[4]-b[5]*b[8],m=-b[9]*b[0]+b[1]*b[8],B=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*j+b[2]*k;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*e;a.m[2]=b*h;a.m[3]=b*j;a.m[4]=b*p;a.m[5]=b*c;a.m[6]=b*k;a.m[7]=b*m;a.m[8]=b*B;return a};
|
|
|
-THREE.Matrix4.makeFrustum=function(a,b,f,e,h,j){var p,c,k;p=new THREE.Matrix4;c=2*h/(b-a);k=2*h/(e-f);a=(b+a)/(b-a);f=(e+f)/(e-f);e=-(j+h)/(j-h);h=-2*j*h/(j-h);p.n11=c;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=k;p.n23=f;p.n24=0;p.n31=0;p.n32=0;p.n33=e;p.n34=h;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,b,f,e){var h;a=f*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,f,e)};
|
|
|
-THREE.Matrix4.makeOrtho=function(a,b,f,e,h,j){var p,c,k,m;p=new THREE.Matrix4;c=b-a;k=f-e;m=j-h;a=(b+a)/c;f=(f+e)/k;h=(j+h)/m;p.n11=2/c;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/k;p.n23=0;p.n24=-f;p.n31=0;p.n32=0;p.n33=-2/m;p.n34=-h;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p};
|
|
|
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var f=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],o=b[10]*b[0]-b[2]*b[8],c=-b[6]*b[0]+b[2]*b[4],k=b[9]*b[4]-b[5]*b[8],l=-b[9]*b[0]+b[1]*b[8],B=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*j+b[2]*k;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*e;a.m[2]=b*g;a.m[3]=b*j;a.m[4]=b*o;a.m[5]=b*c;a.m[6]=b*k;a.m[7]=b*l;a.m[8]=b*B;return a};
|
|
|
+THREE.Matrix4.makeFrustum=function(a,b,f,e,g,j){var o,c,k;o=new THREE.Matrix4;c=2*g/(b-a);k=2*g/(e-f);a=(b+a)/(b-a);f=(e+f)/(e-f);e=-(j+g)/(j-g);g=-2*j*g/(j-g);o.n11=c;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=k;o.n23=f;o.n24=0;o.n31=0;o.n32=0;o.n33=e;o.n34=g;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,b,f,e){var g;a=f*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,f,e)};
|
|
|
+THREE.Matrix4.makeOrtho=function(a,b,f,e,g,j){var o,c,k,l;o=new THREE.Matrix4;c=b-a;k=f-e;l=j-g;a=(b+a)/c;f=(f+e)/k;g=(j+g)/l;o.n11=2/c;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/k;o.n23=0;o.n24=-f;o.n31=0;o.n32=0;o.n33=-2/l;o.n34=-g;o.n41=0;o.n42=0;o.n43=0;o.n44=1;return o};
|
|
|
THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
|
|
|
-THREE.Face3=function(a,b,f,e,h){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
|
|
|
-THREE.Face4=function(a,b,f,e,h,j){this.a=a;this.b=b;this.c=f;this.d=e;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
|
|
|
+THREE.Face3=function(a,b,f,e,g){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
|
|
|
+THREE.Face4=function(a,b,f,e,g,j){this.a=a;this.b=b;this.c=f;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
|
|
|
THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
|
|
|
THREE.Geometry.prototype={computeCentroids:function(){var a,b,f;a=0;for(b=this.faces.length;a<b;a++){f=this.faces[a];f.centroid.set(0,0,0);if(f instanceof THREE.Face3){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);f.centroid.divideScalar(3)}else if(f instanceof THREE.Face4){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);
|
|
|
-f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,f,e,h,j,p,c=new THREE.Vector3,k=new THREE.Vector3;e=0;for(h=this.vertices.length;e<h;e++){j=this.vertices[e];j.normal.set(0,0,0)}e=0;for(h=this.faces.length;e<h;e++){j=this.faces[e];if(a&&j.vertexNormals.length){c.set(0,0,0);b=0;for(f=j.normal.length;b<f;b++)c.addSelf(j.vertexNormals[b]);c.divideScalar(3)}else{b=this.vertices[j.a];f=this.vertices[j.b];p=this.vertices[j.c];c.sub(p.position,
|
|
|
+f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,f,e,g,j,o,c=new THREE.Vector3,k=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){j=this.vertices[e];j.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){j=this.faces[e];if(a&&j.vertexNormals.length){c.set(0,0,0);b=0;for(f=j.normal.length;b<f;b++)c.addSelf(j.vertexNormals[b]);c.divideScalar(3)}else{b=this.vertices[j.a];f=this.vertices[j.b];o=this.vertices[j.c];c.sub(o.position,
|
|
|
f.position);k.sub(b.position,f.position);c.crossSelf(k)}c.isZero()||c.normalize();j.normal.copy(c)}},computeVertexNormals:function(){var a,b,f=[],e;a=0;for(b=this.vertices.length;a<b;a++)f[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){e=this.faces[a];if(e instanceof THREE.Face3){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal);f[e.d].addSelf(e.normal)}}a=
|
|
|
-0;for(b=this.vertices.length;a<b;a++)f[a].normalize();a=0;for(b=this.faces.length;a<b;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0]=f[e.a].clone();e.vertexNormals[1]=f[e.b].clone();e.vertexNormals[2]=f[e.c].clone()}else if(e instanceof THREE.Face4){e.vertexNormals[0]=f[e.a].clone();e.vertexNormals[1]=f[e.b].clone();e.vertexNormals[2]=f[e.c].clone();e.vertexNormals[3]=f[e.d].clone()}}},computeTangents:function(){function a(s,w,W,G,T,P,H){j=s.vertices[w].position;p=s.vertices[W].position;
|
|
|
-c=s.vertices[G].position;k=h[T];m=h[P];B=h[H];D=p.x-j.x;x=c.x-j.x;A=p.y-j.y;M=c.y-j.y;Q=p.z-j.z;O=c.z-j.z;r=m.u-k.u;L=B.u-k.u;d=m.v-k.v;i=B.v-k.v;o=1/(r*i-L*d);g.set((i*D-d*x)*o,(i*A-d*M)*o,(i*Q-d*O)*o);t.set((r*x-L*D)*o,(r*M-L*A)*o,(r*O-L*Q)*o);l[w].addSelf(g);l[W].addSelf(g);l[G].addSelf(g);n[w].addSelf(t);n[W].addSelf(t);n[G].addSelf(t)}var b,f,e,h,j,p,c,k,m,B,D,x,A,M,Q,O,r,L,d,i,o,l=[],n=[],g=new THREE.Vector3,t=new THREE.Vector3,q=new THREE.Vector3,y=new THREE.Vector3,u=new THREE.Vector3;b=0;
|
|
|
-for(f=this.vertices.length;b<f;b++){l[b]=new THREE.Vector3;n[b]=new THREE.Vector3}b=0;for(f=this.faces.length;b<f;b++){e=this.faces[b];h=this.uvs[b];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])}}b=0;for(f=this.vertices.length;b<f;b++){u.copy(this.vertices[b].normal);e=l[b];q.copy(e);q.subSelf(u.multiplyScalar(u.dot(e))).normalize();y.cross(this.vertices[b].normal,e);e=y.dot(n[b]);e=e<0?-1:1;this.vertices[b].tangent.set(q.x,q.y,q.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],
|
|
|
+0;for(b=this.vertices.length;a<b;a++)f[a].normalize();a=0;for(b=this.faces.length;a<b;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0]=f[e.a].clone();e.vertexNormals[1]=f[e.b].clone();e.vertexNormals[2]=f[e.c].clone()}else if(e instanceof THREE.Face4){e.vertexNormals[0]=f[e.a].clone();e.vertexNormals[1]=f[e.b].clone();e.vertexNormals[2]=f[e.c].clone();e.vertexNormals[3]=f[e.d].clone()}}},computeTangents:function(){function a(s,w,W,G,T,P,H){j=s.vertices[w].position;o=s.vertices[W].position;
|
|
|
+c=s.vertices[G].position;k=g[T];l=g[P];B=g[H];D=o.x-j.x;x=c.x-j.x;A=o.y-j.y;M=c.y-j.y;Q=o.z-j.z;O=c.z-j.z;q=l.u-k.u;L=B.u-k.u;d=l.v-k.v;h=B.v-k.v;r=1/(q*h-L*d);i.set((h*D-d*x)*r,(h*A-d*M)*r,(h*Q-d*O)*r);t.set((q*x-L*D)*r,(q*M-L*A)*r,(q*O-L*Q)*r);m[w].addSelf(i);m[W].addSelf(i);m[G].addSelf(i);n[w].addSelf(t);n[W].addSelf(t);n[G].addSelf(t)}var b,f,e,g,j,o,c,k,l,B,D,x,A,M,Q,O,q,L,d,h,r,m=[],n=[],i=new THREE.Vector3,t=new THREE.Vector3,p=new THREE.Vector3,y=new THREE.Vector3,u=new THREE.Vector3;b=0;
|
|
|
+for(f=this.vertices.length;b<f;b++){m[b]=new THREE.Vector3;n[b]=new THREE.Vector3}b=0;for(f=this.faces.length;b<f;b++){e=this.faces[b];g=this.uvs[b];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])}}b=0;for(f=this.vertices.length;b<f;b++){u.copy(this.vertices[b].normal);e=m[b];p.copy(e);p.subSelf(u.multiplyScalar(u.dot(e))).normalize();y.cross(this.vertices[b].normal,e);e=y.dot(n[b]);e=e<0?-1:1;this.vertices[b].tangent.set(p.x,p.y,p.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 b=1,f=this.vertices.length;b<f;b++){a=this.vertices[b];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,b=0,f=this.vertices.length;b<f;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(B){var D=[];b=0;for(f=B.length;b<f;b++)B[b]==undefined?D.push("undefined"):D.push(B[b].toString());return D.join("_")}
|
|
|
-var b,f,e,h,j,p,c,k,m={};e=0;for(h=this.faces.length;e<h;e++){j=this.faces[e];p=j.materials;c=a(p);if(m[c]==undefined)m[c]={hash:c,counter:0};k=m[c].hash+"_"+m[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:p,vertices:0};j=j instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+j>65535){m[c].counter+=1;k=m[c].hash+"_"+m[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:p,vertices:0}}this.geometryChunks[k].faces.push(e);
|
|
|
+var b,f,e,g,j,o,c,k,l={};e=0;for(g=this.faces.length;e<g;e++){j=this.faces[e];o=j.materials;c=a(o);if(l[c]==undefined)l[c]={hash:c,counter:0};k=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:o,vertices:0};j=j instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+j>65535){l[c].counter+=1;k=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:o,vertices:0}}this.geometryChunks[k].faces.push(e);
|
|
|
this.geometryChunks[k].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
|
|
|
-THREE.Camera=function(a,b,f,e){this.fov=a;this.aspect=b;this.near=f;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.translateX=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);h.cross(h.clone(),this.up);this.position.addSelf(h);this.target.position.addSelf(h)};this.translateZ=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);
|
|
|
-this.position.subSelf(h);this.target.position.subSelf(h)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};
|
|
|
+THREE.Camera=function(a,b,f,e){this.fov=a;this.aspect=b;this.near=f;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.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);
|
|
|
+this.position.subSelf(g);this.target.position.subSelf(g)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};
|
|
|
THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;
|
|
|
THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
|
|
|
THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
|
|
|
THREE.Object3D.prototype={updateMatrix:function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);
|
|
|
-this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b,f){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=f!==undefined?f:THREE.LineContinuous};
|
|
|
-THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];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;
|
|
|
+this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.autoUpdateMatrix=false};
|
|
|
+THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,f){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=f!==undefined?f:THREE.LineContinuous};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
|
|
|
+THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];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.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}};
|
|
|
THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>)"}};
|
|
|
THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
|
|
@@ -90,93 +90,92 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM
|
|
|
THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
|
|
|
THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
|
|
|
THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
|
|
|
-THREE.Texture=function(a,b,f,e,h,j){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=j!==undefined?j:THREE.LinearMipMapLinearFilter};
|
|
|
+THREE.Texture=function(a,b,f,e,g,j){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=j!==undefined?j:THREE.LinearMipMapLinearFilter};
|
|
|
THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},toString:function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;
|
|
|
-THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;var Uniforms={clone:function(a){var b,f,e,h={};for(b in a){h[b]={};for(f in a[b]){e=a[b][f];h[b][f]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return h},merge:function(a){var b,f,e,h={};for(b=0;b<a.length;b++){e=this.clone(a[b]);for(f in e)h[f]=e[f]}return h}};
|
|
|
+THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;var Uniforms={clone:function(a){var b,f,e,g={};for(b in a){g[b]={};for(f in a[b]){e=a[b][f];g[b][f]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var b,f,e,g={};for(b=0;b<a.length;b++){e=this.clone(a[b]);for(f in e)g[f]=e[f]}return g}};
|
|
|
THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
|
|
|
THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
|
|
|
THREE.Fog=function(a,b,f){this.color=new THREE.Color(a);this.near=b||1;this.far=f||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
|
|
|
-THREE.Projector=function(){function a(n,g){return g.z-n.z}function b(n,g){var t=0,q=1,y=n.z+n.w,u=g.z+g.w,s=-n.z+n.w,w=-g.z+g.w;if(y>=0&&u>=0&&s>=0&&w>=0)return true;else if(y<0&&u<0||s<0&&w<0)return false;else{if(y<0)t=Math.max(t,y/(y-u));else if(u<0)q=Math.min(q,y/(y-u));if(s<0)t=Math.max(t,s/(s-w));else if(w<0)q=Math.min(q,s/(s-w));if(q<t)return false;else{n.lerpSelf(g,t);g.lerpSelf(n,1-q);return true}}}var f,e,h=[],j,p,c,k=[],m,B,D=[],x,A,M=[],Q=new THREE.Vector4,O=new THREE.Vector4,r=new THREE.Matrix4,
|
|
|
-L=new THREE.Matrix4,d=[],i=new THREE.Vector4,o=new THREE.Vector4,l;this.projectObjects=function(n,g,t){var q=[],y,u;e=0;r.multiply(g.projectionMatrix,g.matrix);d[0]=new THREE.Vector4(r.n41-r.n11,r.n42-r.n12,r.n43-r.n13,r.n44-r.n14);d[1]=new THREE.Vector4(r.n41+r.n11,r.n42+r.n12,r.n43+r.n13,r.n44+r.n14);d[2]=new THREE.Vector4(r.n41+r.n21,r.n42+r.n22,r.n43+r.n23,r.n44+r.n24);d[3]=new THREE.Vector4(r.n41-r.n21,r.n42-r.n22,r.n43-r.n23,r.n44-r.n24);d[4]=new THREE.Vector4(r.n41-r.n31,r.n42-r.n32,r.n43-
|
|
|
-r.n33,r.n44-r.n34);d[5]=new THREE.Vector4(r.n41+r.n31,r.n42+r.n32,r.n43+r.n33,r.n44+r.n34);g=0;for(y=d.length;g<y;g++){u=d[g];u.divideScalar(Math.sqrt(u.x*u.x+u.y*u.y+u.z*u.z))}y=n.objects;n=0;for(g=y.length;n<g;n++){u=y[n];var s;if(!(s=!u.visible)){if(s=u instanceof THREE.Mesh){a:{s=void 0;for(var w=u.position,W=-u.geometry.boundingSphere.radius*Math.max(u.scale.x,Math.max(u.scale.y,u.scale.z)),G=0;G<6;G++){s=d[G].x*w.x+d[G].y*w.y+d[G].z*w.z+d[G].w;if(s<=W){s=false;break a}}s=true}s=!s}s=s}if(!s){f=
|
|
|
-h[e]=h[e]||new THREE.RenderableObject;Q.copy(u.position);r.multiplyVector3(Q);f.object=u;f.z=Q.z;q.push(f);e++}}t&&q.sort(a);return q};this.projectScene=function(n,g,t){var q=[],y=g.near,u=g.far,s,w,W,G,T,P,H,X,K,E,F,U,R,C,N,V;c=B=A=0;g.autoUpdateMatrix&&g.updateMatrix();r.multiply(g.projectionMatrix,g.matrix);P=this.projectObjects(n,g,true);n=0;for(s=P.length;n<s;n++){H=P[n].object;if(H.visible){H.autoUpdateMatrix&&H.updateMatrix();X=H.matrix;K=H.rotationMatrix;E=H.materials;F=H.overdraw;if(H instanceof
|
|
|
-THREE.Mesh){U=H.geometry;R=U.vertices;w=0;for(W=R.length;w<W;w++){C=R[w];C.positionWorld.copy(C.position);X.multiplyVector3(C.positionWorld);G=C.positionScreen;G.copy(C.positionWorld);r.multiplyVector4(G);G.x/=G.w;G.y/=G.w;C.__visible=G.z>y&&G.z<u}U=U.faces;w=0;for(W=U.length;w<W;w++){C=U[w];if(C instanceof THREE.Face3){G=R[C.a];T=R[C.b];N=R[C.c];if(G.__visible&&T.__visible&&N.__visible)if(H.doubleSided||H.flipSided!=(N.positionScreen.x-G.positionScreen.x)*(T.positionScreen.y-G.positionScreen.y)-
|
|
|
+THREE.Projector=function(){function a(n,i){return i.z-n.z}function b(n,i){var t=0,p=1,y=n.z+n.w,u=i.z+i.w,s=-n.z+n.w,w=-i.z+i.w;if(y>=0&&u>=0&&s>=0&&w>=0)return true;else if(y<0&&u<0||s<0&&w<0)return false;else{if(y<0)t=Math.max(t,y/(y-u));else if(u<0)p=Math.min(p,y/(y-u));if(s<0)t=Math.max(t,s/(s-w));else if(w<0)p=Math.min(p,s/(s-w));if(p<t)return false;else{n.lerpSelf(i,t);i.lerpSelf(n,1-p);return true}}}var f,e,g=[],j,o,c,k=[],l,B,D=[],x,A,M=[],Q=new THREE.Vector4,O=new THREE.Vector4,q=new THREE.Matrix4,
|
|
|
+L=new THREE.Matrix4,d=[],h=new THREE.Vector4,r=new THREE.Vector4,m;this.projectObjects=function(n,i,t){var p=[],y,u;e=0;q.multiply(i.projectionMatrix,i.matrix);d[0]=new THREE.Vector4(q.n41-q.n11,q.n42-q.n12,q.n43-q.n13,q.n44-q.n14);d[1]=new THREE.Vector4(q.n41+q.n11,q.n42+q.n12,q.n43+q.n13,q.n44+q.n14);d[2]=new THREE.Vector4(q.n41+q.n21,q.n42+q.n22,q.n43+q.n23,q.n44+q.n24);d[3]=new THREE.Vector4(q.n41-q.n21,q.n42-q.n22,q.n43-q.n23,q.n44-q.n24);d[4]=new THREE.Vector4(q.n41-q.n31,q.n42-q.n32,q.n43-
|
|
|
+q.n33,q.n44-q.n34);d[5]=new THREE.Vector4(q.n41+q.n31,q.n42+q.n32,q.n43+q.n33,q.n44+q.n34);i=0;for(y=d.length;i<y;i++){u=d[i];u.divideScalar(Math.sqrt(u.x*u.x+u.y*u.y+u.z*u.z))}y=n.objects;n=0;for(i=y.length;n<i;n++){u=y[n];var s;if(!(s=!u.visible)){if(s=u instanceof THREE.Mesh){a:{s=void 0;for(var w=u.position,W=-u.geometry.boundingSphere.radius*Math.max(u.scale.x,Math.max(u.scale.y,u.scale.z)),G=0;G<6;G++){s=d[G].x*w.x+d[G].y*w.y+d[G].z*w.z+d[G].w;if(s<=W){s=false;break a}}s=true}s=!s}s=s}if(!s){f=
|
|
|
+g[e]=g[e]||new THREE.RenderableObject;Q.copy(u.position);q.multiplyVector3(Q);f.object=u;f.z=Q.z;p.push(f);e++}}t&&p.sort(a);return p};this.projectScene=function(n,i,t){var p=[],y=i.near,u=i.far,s,w,W,G,T,P,H,X,K,E,F,U,R,C,N,V;c=B=A=0;i.autoUpdateMatrix&&i.updateMatrix();q.multiply(i.projectionMatrix,i.matrix);P=this.projectObjects(n,i,true);n=0;for(s=P.length;n<s;n++){H=P[n].object;if(H.visible){H.autoUpdateMatrix&&H.updateMatrix();X=H.matrix;K=H.rotationMatrix;E=H.materials;F=H.overdraw;if(H instanceof
|
|
|
+THREE.Mesh){U=H.geometry;R=U.vertices;w=0;for(W=R.length;w<W;w++){C=R[w];C.positionWorld.copy(C.position);X.multiplyVector3(C.positionWorld);G=C.positionScreen;G.copy(C.positionWorld);q.multiplyVector4(G);G.x/=G.w;G.y/=G.w;C.__visible=G.z>y&&G.z<u}U=U.faces;w=0;for(W=U.length;w<W;w++){C=U[w];if(C instanceof THREE.Face3){G=R[C.a];T=R[C.b];N=R[C.c];if(G.__visible&&T.__visible&&N.__visible)if(H.doubleSided||H.flipSided!=(N.positionScreen.x-G.positionScreen.x)*(T.positionScreen.y-G.positionScreen.y)-
|
|
|
(N.positionScreen.y-G.positionScreen.y)*(T.positionScreen.x-G.positionScreen.x)<0){j=k[c]=k[c]||new THREE.RenderableFace3;j.v1.positionWorld.copy(G.positionWorld);j.v2.positionWorld.copy(T.positionWorld);j.v3.positionWorld.copy(N.positionWorld);j.v1.positionScreen.copy(G.positionScreen);j.v2.positionScreen.copy(T.positionScreen);j.v3.positionScreen.copy(N.positionScreen);j.normalWorld.copy(C.normal);K.multiplyVector3(j.normalWorld);j.centroidWorld.copy(C.centroid);X.multiplyVector3(j.centroidWorld);
|
|
|
-j.centroidScreen.copy(j.centroidWorld);r.multiplyVector3(j.centroidScreen);N=C.vertexNormals;l=j.vertexNormalsWorld;G=0;for(T=N.length;G<T;G++){V=l[G]=l[G]||new THREE.Vector3;V.copy(N[G]);K.multiplyVector3(V)}j.z=j.centroidScreen.z;j.meshMaterials=E;j.faceMaterials=C.materials;j.overdraw=F;if(H.geometry.uvs[w]){j.uvs[0]=H.geometry.uvs[w][0];j.uvs[1]=H.geometry.uvs[w][1];j.uvs[2]=H.geometry.uvs[w][2]}q.push(j);c++}}else if(C instanceof THREE.Face4){G=R[C.a];T=R[C.b];N=R[C.c];V=R[C.d];if(G.__visible&&
|
|
|
+j.centroidScreen.copy(j.centroidWorld);q.multiplyVector3(j.centroidScreen);N=C.vertexNormals;m=j.vertexNormalsWorld;G=0;for(T=N.length;G<T;G++){V=m[G]=m[G]||new THREE.Vector3;V.copy(N[G]);K.multiplyVector3(V)}j.z=j.centroidScreen.z;j.meshMaterials=E;j.faceMaterials=C.materials;j.overdraw=F;if(H.geometry.uvs[w]){j.uvs[0]=H.geometry.uvs[w][0];j.uvs[1]=H.geometry.uvs[w][1];j.uvs[2]=H.geometry.uvs[w][2]}p.push(j);c++}}else if(C instanceof THREE.Face4){G=R[C.a];T=R[C.b];N=R[C.c];V=R[C.d];if(G.__visible&&
|
|
|
T.__visible&&N.__visible&&V.__visible)if(H.doubleSided||H.flipSided!=((V.positionScreen.x-G.positionScreen.x)*(T.positionScreen.y-G.positionScreen.y)-(V.positionScreen.y-G.positionScreen.y)*(T.positionScreen.x-G.positionScreen.x)<0||(T.positionScreen.x-N.positionScreen.x)*(V.positionScreen.y-N.positionScreen.y)-(T.positionScreen.y-N.positionScreen.y)*(V.positionScreen.x-N.positionScreen.x)<0)){j=k[c]=k[c]||new THREE.RenderableFace3;j.v1.positionWorld.copy(G.positionWorld);j.v2.positionWorld.copy(T.positionWorld);
|
|
|
-j.v3.positionWorld.copy(V.positionWorld);j.v1.positionScreen.copy(G.positionScreen);j.v2.positionScreen.copy(T.positionScreen);j.v3.positionScreen.copy(V.positionScreen);j.normalWorld.copy(C.normal);K.multiplyVector3(j.normalWorld);j.centroidWorld.copy(C.centroid);X.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);r.multiplyVector3(j.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=E;j.faceMaterials=C.materials;j.overdraw=F;if(H.geometry.uvs[w]){j.uvs[0]=H.geometry.uvs[w][0];
|
|
|
-j.uvs[1]=H.geometry.uvs[w][1];j.uvs[2]=H.geometry.uvs[w][3]}q.push(j);c++;p=k[c]=k[c]||new THREE.RenderableFace3;p.v1.positionWorld.copy(T.positionWorld);p.v2.positionWorld.copy(N.positionWorld);p.v3.positionWorld.copy(V.positionWorld);p.v1.positionScreen.copy(T.positionScreen);p.v2.positionScreen.copy(N.positionScreen);p.v3.positionScreen.copy(V.positionScreen);p.normalWorld.copy(j.normalWorld);p.centroidWorld.copy(j.centroidWorld);p.centroidScreen.copy(j.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterials=
|
|
|
-E;p.faceMaterials=C.materials;p.overdraw=F;if(H.geometry.uvs[w]){p.uvs[0]=H.geometry.uvs[w][1];p.uvs[1]=H.geometry.uvs[w][2];p.uvs[2]=H.geometry.uvs[w][3]}q.push(p);c++}}}}else if(H instanceof THREE.Line){L.multiply(r,X);R=H.geometry.vertices;C=R[0];C.positionScreen.copy(C.position);L.multiplyVector4(C.positionScreen);w=1;for(W=R.length;w<W;w++){G=R[w];G.positionScreen.copy(G.position);L.multiplyVector4(G.positionScreen);T=R[w-1];i.copy(G.positionScreen);o.copy(T.positionScreen);if(b(i,o)){i.multiplyScalar(1/
|
|
|
-i.w);o.multiplyScalar(1/o.w);m=D[B]=D[B]||new THREE.RenderableLine;m.v1.positionScreen.copy(i);m.v2.positionScreen.copy(o);m.z=Math.max(i.z,o.z);m.materials=H.materials;q.push(m);B++}}}else if(H instanceof THREE.Particle){O.set(H.position.x,H.position.y,H.position.z,1);r.multiplyVector4(O);O.z/=O.w;if(O.z>0&&O.z<1){x=M[A]=M[A]||new THREE.RenderableParticle;x.x=O.x/O.w;x.y=O.y/O.w;x.z=O.z;x.rotation=H.rotation.z;x.scale.x=H.scale.x*Math.abs(x.x-(O.x+g.projectionMatrix.n11)/(O.w+g.projectionMatrix.n14));
|
|
|
-x.scale.y=H.scale.y*Math.abs(x.y-(O.y+g.projectionMatrix.n22)/(O.w+g.projectionMatrix.n24));x.materials=H.materials;q.push(x);A++}}}}t&&q.sort(a);return q};this.unprojectVector=function(n,g){var t=new THREE.Matrix4;t.multiply(THREE.Matrix4.makeInvert(g.matrix),THREE.Matrix4.makeInvert(g.projectionMatrix));t.multiplyVector3(n);return n}};
|
|
|
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,e,h,j;this.domElement=document.createElement("div");this.setSize=function(p,c){f=p;e=c;h=f/2;j=e/2};this.render=function(p,c){var k,m,B,D,x,A,M,Q;a=b.projectScene(p,c);k=0;for(m=a.length;k<m;k++){x=a[k];if(x instanceof THREE.RenderableParticle){M=x.x*h+h;Q=x.y*j+j;B=0;for(D=x.material.length;B<D;B++){A=x.material[B];if(A instanceof THREE.ParticleDOMMaterial){A=A.domElement;A.style.left=M+"px";A.style.top=Q+"px"}}}}}};
|
|
|
-THREE.CanvasRenderer=function(){function a(ba){if(x!=ba)m.globalAlpha=x=ba}function b(ba){if(A!=ba){switch(ba){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}A=ba}}var f=null,e=new THREE.Projector,h=document.createElement("canvas"),j,p,c,k,m=h.getContext("2d"),B=null,D=null,x=1,A=0,M=null,Q=null,O=1,r,L,d,i,o,l,n,g,t,q=new THREE.Color,
|
|
|
+j.v3.positionWorld.copy(V.positionWorld);j.v1.positionScreen.copy(G.positionScreen);j.v2.positionScreen.copy(T.positionScreen);j.v3.positionScreen.copy(V.positionScreen);j.normalWorld.copy(C.normal);K.multiplyVector3(j.normalWorld);j.centroidWorld.copy(C.centroid);X.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);q.multiplyVector3(j.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=E;j.faceMaterials=C.materials;j.overdraw=F;if(H.geometry.uvs[w]){j.uvs[0]=H.geometry.uvs[w][0];
|
|
|
+j.uvs[1]=H.geometry.uvs[w][1];j.uvs[2]=H.geometry.uvs[w][3]}p.push(j);c++;o=k[c]=k[c]||new THREE.RenderableFace3;o.v1.positionWorld.copy(T.positionWorld);o.v2.positionWorld.copy(N.positionWorld);o.v3.positionWorld.copy(V.positionWorld);o.v1.positionScreen.copy(T.positionScreen);o.v2.positionScreen.copy(N.positionScreen);o.v3.positionScreen.copy(V.positionScreen);o.normalWorld.copy(j.normalWorld);o.centroidWorld.copy(j.centroidWorld);o.centroidScreen.copy(j.centroidScreen);o.z=o.centroidScreen.z;o.meshMaterials=
|
|
|
+E;o.faceMaterials=C.materials;o.overdraw=F;if(H.geometry.uvs[w]){o.uvs[0]=H.geometry.uvs[w][1];o.uvs[1]=H.geometry.uvs[w][2];o.uvs[2]=H.geometry.uvs[w][3]}p.push(o);c++}}}}else if(H instanceof THREE.Line){L.multiply(q,X);R=H.geometry.vertices;C=R[0];C.positionScreen.copy(C.position);L.multiplyVector4(C.positionScreen);w=1;for(W=R.length;w<W;w++){G=R[w];G.positionScreen.copy(G.position);L.multiplyVector4(G.positionScreen);T=R[w-1];h.copy(G.positionScreen);r.copy(T.positionScreen);if(b(h,r)){h.multiplyScalar(1/
|
|
|
+h.w);r.multiplyScalar(1/r.w);l=D[B]=D[B]||new THREE.RenderableLine;l.v1.positionScreen.copy(h);l.v2.positionScreen.copy(r);l.z=Math.max(h.z,r.z);l.materials=H.materials;p.push(l);B++}}}else if(H instanceof THREE.Particle){O.set(H.position.x,H.position.y,H.position.z,1);q.multiplyVector4(O);O.z/=O.w;if(O.z>0&&O.z<1){x=M[A]=M[A]||new THREE.RenderableParticle;x.x=O.x/O.w;x.y=O.y/O.w;x.z=O.z;x.rotation=H.rotation.z;x.scale.x=H.scale.x*Math.abs(x.x-(O.x+i.projectionMatrix.n11)/(O.w+i.projectionMatrix.n14));
|
|
|
+x.scale.y=H.scale.y*Math.abs(x.y-(O.y+i.projectionMatrix.n22)/(O.w+i.projectionMatrix.n24));x.materials=H.materials;p.push(x);A++}}}}t&&p.sort(a);return p};this.unprojectVector=function(n,i){var t=new THREE.Matrix4;t.multiply(THREE.Matrix4.makeInvert(i.matrix),THREE.Matrix4.makeInvert(i.projectionMatrix));t.multiplyVector3(n);return n}};
|
|
|
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,e,g,j;this.domElement=document.createElement("div");this.setSize=function(o,c){f=o;e=c;g=f/2;j=e/2};this.render=function(o,c){var k,l,B,D,x,A,M,Q;a=b.projectScene(o,c);k=0;for(l=a.length;k<l;k++){x=a[k];if(x instanceof THREE.RenderableParticle){M=x.x*g+g;Q=x.y*j+j;B=0;for(D=x.material.length;B<D;B++){A=x.material[B];if(A instanceof THREE.ParticleDOMMaterial){A=A.domElement;A.style.left=M+"px";A.style.top=Q+"px"}}}}}};
|
|
|
+THREE.CanvasRenderer=function(){function a(ba){if(x!=ba)l.globalAlpha=x=ba}function b(ba){if(A!=ba){switch(ba){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}A=ba}}var f=null,e=new THREE.Projector,g=document.createElement("canvas"),j,o,c,k,l=g.getContext("2d"),B=null,D=null,x=1,A=0,M=null,Q=null,O=1,q,L,d,h,r,m,n,i,t,p=new THREE.Color,
|
|
|
y=new THREE.Color,u=new THREE.Color,s=new THREE.Color,w=new THREE.Color,W,G,T,P,H,X,K,E,F,U=new THREE.Rectangle,R=new THREE.Rectangle,C=new THREE.Rectangle,N=false,V=new THREE.Color,ea=new THREE.Color,ma=new THREE.Color,na=new THREE.Color,La=Math.PI*2,Z=new THREE.Vector3,ra,sa,Ca,fa,ta,xa,pa=16;ra=document.createElement("canvas");ra.width=ra.height=2;sa=ra.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);Ca=sa.getImageData(0,0,2,2);fa=Ca.data;ta=document.createElement("canvas");
|
|
|
-ta.width=ta.height=pa;xa=ta.getContext("2d");xa.translate(-pa/2,-pa/2);xa.scale(pa,pa);pa--;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ba,la){j=ba;p=la;c=j/2;k=p/2;h.width=j;h.height=p;U.set(-c,-k,c,k)};this.setClearColor=function(ba,la){B=ba!==null?new THREE.Color(ba):null;D=la;R.set(-c,-k,c,k);m.setTransform(1,0,0,-1,c,k);this.clear()};this.clear=function(){if(!R.isEmpty()){R.inflate(1);R.minSelf(U);if(B!==null){b(THREE.NormalBlending);a(1);m.fillStyle=
|
|
|
-"rgba("+Math.floor(B.r*255)+","+Math.floor(B.g*255)+","+Math.floor(B.b*255)+","+D+")";m.fillRect(R.getX(),R.getY(),R.getWidth(),R.getHeight())}else m.clearRect(R.getX(),R.getY(),R.getWidth(),R.getHeight());R.empty()}};this.render=function(ba,la){function Ma(v){var S,J,z,I=v.lights;ea.setRGB(0,0,0);ma.setRGB(0,0,0);na.setRGB(0,0,0);v=0;for(S=I.length;v<S;v++){J=I[v];z=J.color;if(J instanceof THREE.AmbientLight){ea.r+=z.r;ea.g+=z.g;ea.b+=z.b}else if(J instanceof THREE.DirectionalLight){ma.r+=z.r;ma.g+=
|
|
|
+ta.width=ta.height=pa;xa=ta.getContext("2d");xa.translate(-pa/2,-pa/2);xa.scale(pa,pa);pa--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ba,la){j=ba;o=la;c=j/2;k=o/2;g.width=j;g.height=o;U.set(-c,-k,c,k)};this.setClearColor=function(ba,la){B=ba!==null?new THREE.Color(ba):null;D=la;R.set(-c,-k,c,k);l.setTransform(1,0,0,-1,c,k);this.clear()};this.clear=function(){if(!R.isEmpty()){R.inflate(1);R.minSelf(U);if(B!==null){b(THREE.NormalBlending);a(1);l.fillStyle=
|
|
|
+"rgba("+Math.floor(B.r*255)+","+Math.floor(B.g*255)+","+Math.floor(B.b*255)+","+D+")";l.fillRect(R.getX(),R.getY(),R.getWidth(),R.getHeight())}else l.clearRect(R.getX(),R.getY(),R.getWidth(),R.getHeight());R.empty()}};this.render=function(ba,la){function Ma(v){var S,J,z,I=v.lights;ea.setRGB(0,0,0);ma.setRGB(0,0,0);na.setRGB(0,0,0);v=0;for(S=I.length;v<S;v++){J=I[v];z=J.color;if(J instanceof THREE.AmbientLight){ea.r+=z.r;ea.g+=z.g;ea.b+=z.b}else if(J instanceof THREE.DirectionalLight){ma.r+=z.r;ma.g+=
|
|
|
z.g;ma.b+=z.b}else if(J instanceof THREE.PointLight){na.r+=z.r;na.g+=z.g;na.b+=z.b}}}function ya(v,S,J,z){var I,Y,aa,ca,da=v.lights;v=0;for(I=da.length;v<I;v++){Y=da[v];aa=Y.color;ca=Y.intensity;if(Y instanceof THREE.DirectionalLight){Y=J.dot(Y.position)*ca;if(Y>0){z.r+=aa.r*Y;z.g+=aa.g*Y;z.b+=aa.b*Y}}else if(Y instanceof THREE.PointLight){Z.sub(Y.position,S);Z.normalize();Y=J.dot(Z)*ca;if(Y>0){z.r+=aa.r*Y;z.g+=aa.g*Y;z.b+=aa.b*Y}}}}function Na(v,S,J){if(J.opacity!=0){a(J.opacity);b(J.blending);var z,
|
|
|
-I,Y,aa,ca,da;if(J instanceof THREE.ParticleBasicMaterial){if(J.map){aa=J.map;ca=aa.width>>1;da=aa.height>>1;I=S.scale.x*c;Y=S.scale.y*k;J=I*ca;z=Y*da;C.set(v.x-J,v.y-z,v.x+J,v.y+z);if(!U.instersects(C))return;m.save();m.translate(v.x,v.y);m.rotate(-S.rotation);m.scale(I,-Y);m.translate(-ca,-da);m.drawImage(aa,0,0);m.restore()}m.beginPath();m.moveTo(v.x-10,v.y);m.lineTo(v.x+10,v.y);m.moveTo(v.x,v.y-10);m.lineTo(v.x,v.y+10);m.closePath();m.strokeStyle="rgb(255,255,0)";m.stroke()}else if(J instanceof
|
|
|
-THREE.ParticleCircleMaterial){if(N){V.r=ea.r+ma.r+na.r;V.g=ea.g+ma.g+na.g;V.b=ea.b+ma.b+na.b;q.r=J.color.r*V.r;q.g=J.color.g*V.g;q.b=J.color.b*V.b;q.updateStyleString()}else q.__styleString=J.color.__styleString;J=S.scale.x*c;z=S.scale.y*k;C.set(v.x-J,v.y-z,v.x+J,v.y+z);if(U.instersects(C)){I=q.__styleString;if(Q!=I)m.fillStyle=Q=I;m.save();m.translate(v.x,v.y);m.rotate(-S.rotation);m.scale(J,z);m.beginPath();m.arc(0,0,1,0,La,true);m.closePath();m.fill();m.restore()}}}}function Oa(v,S,J,z){if(z.opacity!=
|
|
|
-0){a(z.opacity);b(z.blending);m.beginPath();m.moveTo(v.positionScreen.x,v.positionScreen.y);m.lineTo(S.positionScreen.x,S.positionScreen.y);m.closePath();if(z instanceof THREE.LineBasicMaterial){q.__styleString=z.color.__styleString;v=z.linewidth;if(O!=v)m.lineWidth=O=v;v=q.__styleString;if(M!=v)m.strokeStyle=M=v;m.stroke();C.inflate(z.linewidth*2)}}}function Ha(v,S,J,z,I,Y){if(I.opacity!=0){a(I.opacity);b(I.blending);i=v.positionScreen.x;o=v.positionScreen.y;l=S.positionScreen.x;n=S.positionScreen.y;
|
|
|
-g=J.positionScreen.x;t=J.positionScreen.y;m.beginPath();m.moveTo(i,o);m.lineTo(l,n);m.lineTo(g,t);m.lineTo(i,o);m.closePath();if(I instanceof THREE.MeshBasicMaterial)if(I.map)I.map.image.loaded&&I.map.mapping instanceof THREE.UVMapping&&ua(i,o,l,n,g,t,I.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);else if(I.env_map){if(I.env_map.image.loaded)if(I.env_map.mapping instanceof THREE.SphericalReflectionMapping){v=la.matrix;Z.copy(z.vertexNormalsWorld[0]);P=(Z.x*v.n11+Z.y*
|
|
|
-v.n12+Z.z*v.n13)*0.5+0.5;H=-(Z.x*v.n21+Z.y*v.n22+Z.z*v.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[1]);X=(Z.x*v.n11+Z.y*v.n12+Z.z*v.n13)*0.5+0.5;K=-(Z.x*v.n21+Z.y*v.n22+Z.z*v.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[2]);E=(Z.x*v.n11+Z.y*v.n12+Z.z*v.n13)*0.5+0.5;F=-(Z.x*v.n21+Z.y*v.n22+Z.z*v.n23)*0.5+0.5;ua(i,o,l,n,g,t,I.env_map.image,P,H,X,K,E,F)}}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString);else if(I instanceof THREE.MeshLambertMaterial){if(I.map&&!I.wireframe){I.map.mapping instanceof
|
|
|
-THREE.UVMapping&&ua(i,o,l,n,g,t,I.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);b(THREE.SubtractiveBlending)}if(N)if(!I.wireframe&&I.shading==THREE.SmoothShading&&z.vertexNormalsWorld.length==3){y.r=u.r=s.r=ea.r;y.g=u.g=s.g=ea.g;y.b=u.b=s.b=ea.b;ya(Y,z.v1.positionWorld,z.vertexNormalsWorld[0],y);ya(Y,z.v2.positionWorld,z.vertexNormalsWorld[1],u);ya(Y,z.v3.positionWorld,z.vertexNormalsWorld[2],s);w.r=(u.r+s.r)*0.5;w.g=(u.g+s.g)*0.5;w.b=(u.b+s.b)*0.5;T=Ia(y,u,s,w);ua(i,
|
|
|
-o,l,n,g,t,T,0,0,1,0,0,1)}else{V.r=ea.r;V.g=ea.g;V.b=ea.b;ya(Y,z.centroidWorld,z.normalWorld,V);q.r=I.color.r*V.r;q.g=I.color.g*V.g;q.b=I.color.b*V.b;q.updateStyleString();I.wireframe?za(q.__styleString,I.wireframe_linewidth):Aa(q.__styleString)}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString)}else if(I instanceof THREE.MeshDepthMaterial){W=la.near;G=la.far;y.r=y.g=y.b=1-Da(v.positionScreen.z,W,G);u.r=u.g=u.b=1-Da(S.positionScreen.z,W,G);s.r=s.g=s.b=1-Da(J.positionScreen.z,
|
|
|
-W,G);w.r=(u.r+s.r)*0.5;w.g=(u.g+s.g)*0.5;w.b=(u.b+s.b)*0.5;T=Ia(y,u,s,w);ua(i,o,l,n,g,t,T,0,0,1,0,0,1)}else if(I instanceof THREE.MeshNormalMaterial){q.r=Ea(z.normalWorld.x);q.g=Ea(z.normalWorld.y);q.b=Ea(z.normalWorld.z);q.updateStyleString();I.wireframe?za(q.__styleString,I.wireframe_linewidth):Aa(q.__styleString)}}}function za(v,S){if(M!=v)m.strokeStyle=M=v;if(O!=S)m.lineWidth=O=S;m.stroke();C.inflate(S*2)}function Aa(v){if(Q!=v)m.fillStyle=Q=v;m.fill()}function ua(v,S,J,z,I,Y,aa,ca,da,ia,ga,ja,
|
|
|
-va){var oa,ka;oa=aa.width-1;ka=aa.height-1;ca*=oa;da*=ka;ia*=oa;ga*=ka;ja*=oa;va*=ka;J-=v;z-=S;I-=v;Y-=S;ia-=ca;ga-=da;ja-=ca;va-=da;ka=1/(ia*va-ja*ga);oa=(va*J-ga*I)*ka;ga=(va*z-ga*Y)*ka;J=(ia*I-ja*J)*ka;z=(ia*Y-ja*z)*ka;v=v-oa*ca-J*da;S=S-ga*ca-z*da;m.save();m.transform(oa,ga,J,z,v,S);m.clip();m.drawImage(aa,0,0);m.restore()}function Ia(v,S,J,z){var I=~~(v.r*255),Y=~~(v.g*255);v=~~(v.b*255);var aa=~~(S.r*255),ca=~~(S.g*255);S=~~(S.b*255);var da=~~(J.r*255),ia=~~(J.g*255);J=~~(J.b*255);var ga=~~(z.r*
|
|
|
+I,Y,aa,ca,da;if(J instanceof THREE.ParticleBasicMaterial){if(J.map){aa=J.map;ca=aa.width>>1;da=aa.height>>1;I=S.scale.x*c;Y=S.scale.y*k;J=I*ca;z=Y*da;C.set(v.x-J,v.y-z,v.x+J,v.y+z);if(!U.instersects(C))return;l.save();l.translate(v.x,v.y);l.rotate(-S.rotation);l.scale(I,-Y);l.translate(-ca,-da);l.drawImage(aa,0,0);l.restore()}l.beginPath();l.moveTo(v.x-10,v.y);l.lineTo(v.x+10,v.y);l.moveTo(v.x,v.y-10);l.lineTo(v.x,v.y+10);l.closePath();l.strokeStyle="rgb(255,255,0)";l.stroke()}else if(J instanceof
|
|
|
+THREE.ParticleCircleMaterial){if(N){V.r=ea.r+ma.r+na.r;V.g=ea.g+ma.g+na.g;V.b=ea.b+ma.b+na.b;p.r=J.color.r*V.r;p.g=J.color.g*V.g;p.b=J.color.b*V.b;p.updateStyleString()}else p.__styleString=J.color.__styleString;J=S.scale.x*c;z=S.scale.y*k;C.set(v.x-J,v.y-z,v.x+J,v.y+z);if(U.instersects(C)){I=p.__styleString;if(Q!=I)l.fillStyle=Q=I;l.save();l.translate(v.x,v.y);l.rotate(-S.rotation);l.scale(J,z);l.beginPath();l.arc(0,0,1,0,La,true);l.closePath();l.fill();l.restore()}}}}function Oa(v,S,J,z){if(z.opacity!=
|
|
|
+0){a(z.opacity);b(z.blending);l.beginPath();l.moveTo(v.positionScreen.x,v.positionScreen.y);l.lineTo(S.positionScreen.x,S.positionScreen.y);l.closePath();if(z instanceof THREE.LineBasicMaterial){p.__styleString=z.color.__styleString;v=z.linewidth;if(O!=v)l.lineWidth=O=v;v=p.__styleString;if(M!=v)l.strokeStyle=M=v;l.stroke();C.inflate(z.linewidth*2)}}}function Ha(v,S,J,z,I,Y){if(I.opacity!=0){a(I.opacity);b(I.blending);h=v.positionScreen.x;r=v.positionScreen.y;m=S.positionScreen.x;n=S.positionScreen.y;
|
|
|
+i=J.positionScreen.x;t=J.positionScreen.y;l.beginPath();l.moveTo(h,r);l.lineTo(m,n);l.lineTo(i,t);l.lineTo(h,r);l.closePath();if(I instanceof THREE.MeshBasicMaterial)if(I.map)I.map.image.loaded&&I.map.mapping instanceof THREE.UVMapping&&ua(h,r,m,n,i,t,I.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);else if(I.env_map){if(I.env_map.image.loaded)if(I.env_map.mapping instanceof THREE.SphericalReflectionMapping){v=la.matrix;Z.copy(z.vertexNormalsWorld[0]);P=(Z.x*v.n11+Z.y*
|
|
|
+v.n12+Z.z*v.n13)*0.5+0.5;H=-(Z.x*v.n21+Z.y*v.n22+Z.z*v.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[1]);X=(Z.x*v.n11+Z.y*v.n12+Z.z*v.n13)*0.5+0.5;K=-(Z.x*v.n21+Z.y*v.n22+Z.z*v.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[2]);E=(Z.x*v.n11+Z.y*v.n12+Z.z*v.n13)*0.5+0.5;F=-(Z.x*v.n21+Z.y*v.n22+Z.z*v.n23)*0.5+0.5;ua(h,r,m,n,i,t,I.env_map.image,P,H,X,K,E,F)}}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString);else if(I instanceof THREE.MeshLambertMaterial){if(I.map&&!I.wireframe){I.map.mapping instanceof
|
|
|
+THREE.UVMapping&&ua(h,r,m,n,i,t,I.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);b(THREE.SubtractiveBlending)}if(N)if(!I.wireframe&&I.shading==THREE.SmoothShading&&z.vertexNormalsWorld.length==3){y.r=u.r=s.r=ea.r;y.g=u.g=s.g=ea.g;y.b=u.b=s.b=ea.b;ya(Y,z.v1.positionWorld,z.vertexNormalsWorld[0],y);ya(Y,z.v2.positionWorld,z.vertexNormalsWorld[1],u);ya(Y,z.v3.positionWorld,z.vertexNormalsWorld[2],s);w.r=(u.r+s.r)*0.5;w.g=(u.g+s.g)*0.5;w.b=(u.b+s.b)*0.5;T=Ia(y,u,s,w);ua(h,
|
|
|
+r,m,n,i,t,T,0,0,1,0,0,1)}else{V.r=ea.r;V.g=ea.g;V.b=ea.b;ya(Y,z.centroidWorld,z.normalWorld,V);p.r=I.color.r*V.r;p.g=I.color.g*V.g;p.b=I.color.b*V.b;p.updateStyleString();I.wireframe?za(p.__styleString,I.wireframe_linewidth):Aa(p.__styleString)}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString)}else if(I instanceof THREE.MeshDepthMaterial){W=la.near;G=la.far;y.r=y.g=y.b=1-Da(v.positionScreen.z,W,G);u.r=u.g=u.b=1-Da(S.positionScreen.z,W,G);s.r=s.g=s.b=1-Da(J.positionScreen.z,
|
|
|
+W,G);w.r=(u.r+s.r)*0.5;w.g=(u.g+s.g)*0.5;w.b=(u.b+s.b)*0.5;T=Ia(y,u,s,w);ua(h,r,m,n,i,t,T,0,0,1,0,0,1)}else if(I instanceof THREE.MeshNormalMaterial){p.r=Ea(z.normalWorld.x);p.g=Ea(z.normalWorld.y);p.b=Ea(z.normalWorld.z);p.updateStyleString();I.wireframe?za(p.__styleString,I.wireframe_linewidth):Aa(p.__styleString)}}}function za(v,S){if(M!=v)l.strokeStyle=M=v;if(O!=S)l.lineWidth=O=S;l.stroke();C.inflate(S*2)}function Aa(v){if(Q!=v)l.fillStyle=Q=v;l.fill()}function ua(v,S,J,z,I,Y,aa,ca,da,ia,ga,ja,
|
|
|
+va){var oa,ka;oa=aa.width-1;ka=aa.height-1;ca*=oa;da*=ka;ia*=oa;ga*=ka;ja*=oa;va*=ka;J-=v;z-=S;I-=v;Y-=S;ia-=ca;ga-=da;ja-=ca;va-=da;ka=1/(ia*va-ja*ga);oa=(va*J-ga*I)*ka;ga=(va*z-ga*Y)*ka;J=(ia*I-ja*J)*ka;z=(ia*Y-ja*z)*ka;v=v-oa*ca-J*da;S=S-ga*ca-z*da;l.save();l.transform(oa,ga,J,z,v,S);l.clip();l.drawImage(aa,0,0);l.restore()}function Ia(v,S,J,z){var I=~~(v.r*255),Y=~~(v.g*255);v=~~(v.b*255);var aa=~~(S.r*255),ca=~~(S.g*255);S=~~(S.b*255);var da=~~(J.r*255),ia=~~(J.g*255);J=~~(J.b*255);var ga=~~(z.r*
|
|
|
255),ja=~~(z.g*255);z=~~(z.b*255);fa[0]=I<0?0:I>255?255:I;fa[1]=Y<0?0:Y>255?255:Y;fa[2]=v<0?0:v>255?255:v;fa[4]=aa<0?0:aa>255?255:aa;fa[5]=ca<0?0:ca>255?255:ca;fa[6]=S<0?0:S>255?255:S;fa[8]=da<0?0:da>255?255:da;fa[9]=ia<0?0:ia>255?255:ia;fa[10]=J<0?0:J>255?255:J;fa[12]=ga<0?0:ga>255?255:ga;fa[13]=ja<0?0:ja>255?255:ja;fa[14]=z<0?0:z>255?255:z;sa.putImageData(Ca,0,0);xa.drawImage(ra,0,0);return ta}function Da(v,S,J){v=(v-S)/(J-S);return v*v*(3-2*v)}function Ea(v){v=(v+1)*0.5;return v<0?0:v>1?1:v}function Fa(v,
|
|
|
-S){var J=S.x-v.x,z=S.y-v.y,I=1/Math.sqrt(J*J+z*z);J*=I;z*=I;S.x+=J;S.y+=z;v.x-=J;v.y-=z}var Ba,Ja,$,ha,qa,Ga,Ka,wa;m.setTransform(1,0,0,-1,c,k);this.autoClear&&this.clear();f=e.projectScene(ba,la,this.sortElements);m.fillStyle="rgba( 0, 255, 255, 0.5 )";m.fillRect(U.getX(),U.getY(),U.getWidth(),U.getHeight());(N=ba.lights.length>0)&&Ma(ba);Ba=0;for(Ja=f.length;Ba<Ja;Ba++){$=f[Ba];C.empty();if($ instanceof THREE.RenderableParticle){r=$;r.x*=c;r.y*=k;ha=0;for(qa=$.materials.length;ha<qa;ha++)Na(r,$,
|
|
|
-$.materials[ha],ba)}else if($ instanceof THREE.RenderableLine){r=$.v1;L=$.v2;r.positionScreen.x*=c;r.positionScreen.y*=k;L.positionScreen.x*=c;L.positionScreen.y*=k;C.addPoint(r.positionScreen.x,r.positionScreen.y);C.addPoint(L.positionScreen.x,L.positionScreen.y);if(U.instersects(C)){ha=0;for(qa=$.materials.length;ha<qa;)Oa(r,L,$,$.materials[ha++],ba)}}else if($ instanceof THREE.RenderableFace3){r=$.v1;L=$.v2;d=$.v3;r.positionScreen.x*=c;r.positionScreen.y*=k;L.positionScreen.x*=c;L.positionScreen.y*=
|
|
|
-k;d.positionScreen.x*=c;d.positionScreen.y*=k;if($.overdraw){Fa(r.positionScreen,L.positionScreen);Fa(L.positionScreen,d.positionScreen);Fa(d.positionScreen,r.positionScreen)}C.add3Points(r.positionScreen.x,r.positionScreen.y,L.positionScreen.x,L.positionScreen.y,d.positionScreen.x,d.positionScreen.y);if(U.instersects(C)){ha=0;for(qa=$.meshMaterials.length;ha<qa;){wa=$.meshMaterials[ha++];if(wa instanceof THREE.MeshFaceMaterial){Ga=0;for(Ka=$.faceMaterials.length;Ga<Ka;)(wa=$.faceMaterials[Ga++])&&
|
|
|
-Ha(r,L,d,$,wa,ba)}else Ha(r,L,d,$,wa,ba)}}}R.addRectangle(C)}m.lineWidth=1;m.strokeStyle="rgba( 255, 0, 0, 0.5 )";m.strokeRect(R.getX(),R.getY(),R.getWidth(),R.getHeight());m.setTransform(1,0,0,1,0,0)}};
|
|
|
+S){var J=S.x-v.x,z=S.y-v.y,I=1/Math.sqrt(J*J+z*z);J*=I;z*=I;S.x+=J;S.y+=z;v.x-=J;v.y-=z}var Ba,Ja,$,ha,qa,Ga,Ka,wa;l.setTransform(1,0,0,-1,c,k);this.autoClear&&this.clear();f=e.projectScene(ba,la,this.sortElements);l.fillStyle="rgba( 0, 255, 255, 0.5 )";l.fillRect(U.getX(),U.getY(),U.getWidth(),U.getHeight());(N=ba.lights.length>0)&&Ma(ba);Ba=0;for(Ja=f.length;Ba<Ja;Ba++){$=f[Ba];C.empty();if($ instanceof THREE.RenderableParticle){q=$;q.x*=c;q.y*=k;ha=0;for(qa=$.materials.length;ha<qa;ha++)Na(q,$,
|
|
|
+$.materials[ha],ba)}else if($ instanceof THREE.RenderableLine){q=$.v1;L=$.v2;q.positionScreen.x*=c;q.positionScreen.y*=k;L.positionScreen.x*=c;L.positionScreen.y*=k;C.addPoint(q.positionScreen.x,q.positionScreen.y);C.addPoint(L.positionScreen.x,L.positionScreen.y);if(U.instersects(C)){ha=0;for(qa=$.materials.length;ha<qa;)Oa(q,L,$,$.materials[ha++],ba)}}else if($ instanceof THREE.RenderableFace3){q=$.v1;L=$.v2;d=$.v3;q.positionScreen.x*=c;q.positionScreen.y*=k;L.positionScreen.x*=c;L.positionScreen.y*=
|
|
|
+k;d.positionScreen.x*=c;d.positionScreen.y*=k;if($.overdraw){Fa(q.positionScreen,L.positionScreen);Fa(L.positionScreen,d.positionScreen);Fa(d.positionScreen,q.positionScreen)}C.add3Points(q.positionScreen.x,q.positionScreen.y,L.positionScreen.x,L.positionScreen.y,d.positionScreen.x,d.positionScreen.y);if(U.instersects(C)){ha=0;for(qa=$.meshMaterials.length;ha<qa;){wa=$.meshMaterials[ha++];if(wa instanceof THREE.MeshFaceMaterial){Ga=0;for(Ka=$.faceMaterials.length;Ga<Ka;)(wa=$.faceMaterials[Ga++])&&
|
|
|
+Ha(q,L,d,$,wa,ba)}else Ha(q,L,d,$,wa,ba)}}}R.addRectangle(C)}l.lineWidth=1;l.strokeStyle="rgba( 255, 0, 0, 0.5 )";l.strokeRect(R.getX(),R.getY(),R.getWidth(),R.getHeight());l.setTransform(1,0,0,1,0,0)}};
|
|
|
THREE.SVGRenderer=function(){function a(P,H,X){var K,E,F,U;K=0;for(E=P.lights.length;K<E;K++){F=P.lights[K];if(F instanceof THREE.DirectionalLight){U=H.normalWorld.dot(F.position)*F.intensity;if(U>0){X.r+=F.color.r*U;X.g+=F.color.g*U;X.b+=F.color.b*U}}else if(F instanceof THREE.PointLight){t.sub(F.position,H.centroidWorld);t.normalize();U=H.normalWorld.dot(t)*F.intensity;if(U>0){X.r+=F.color.r*U;X.g+=F.color.g*U;X.b+=F.color.b*U}}}}function b(P,H,X,K,E,F){s=e(w++);s.setAttribute("d","M "+P.positionScreen.x+
|
|
|
-" "+P.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(E instanceof THREE.MeshBasicMaterial)d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshLambertMaterial)if(L){i.r=o.r;i.g=o.g;i.b=o.b;a(F,K,i);d.r=E.color.r*i.r;d.g=E.color.g*i.g;d.b=E.color.b*i.b;d.updateStyleString()}else d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshDepthMaterial){g=1-E.__2near/(E.__farPlusNear-K.z*E.__farMinusNear);
|
|
|
-d.setRGB(g,g,g)}else E instanceof THREE.MeshNormalMaterial&&d.setRGB(h(K.normalWorld.x),h(K.normalWorld.y),h(K.normalWorld.z));E.wireframe?s.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframe_linecap+"; stroke-linejoin: "+E.wireframe_linejoin):s.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+E.opacity);c.appendChild(s)}function f(P,H,X,K,E,F,U){s=e(w++);s.setAttribute("d",
|
|
|
-"M "+P.positionScreen.x+" "+P.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)d.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(L){i.r=o.r;i.g=o.g;i.b=o.b;a(U,E,i);d.r=F.color.r*i.r;d.g=F.color.g*i.g;d.b=F.color.b*i.b;d.updateStyleString()}else d.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){g=
|
|
|
-1-F.__2near/(F.__farPlusNear-E.z*F.__farMinusNear);d.setRGB(g,g,g)}else F instanceof THREE.MeshNormalMaterial&&d.setRGB(h(E.normalWorld.x),h(E.normalWorld.y),h(E.normalWorld.z));F.wireframe?s.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):s.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+F.opacity);c.appendChild(s)}
|
|
|
-function e(P){if(q[P]==null){q[P]=document.createElementNS("http://www.w3.org/2000/svg","path");T==0&&q[P].setAttribute("shape-rendering","crispEdges");return q[P]}return q[P]}function h(P){return P<0?Math.min((1+P)*0.5,0.5):0.5+Math.min(P*0.5,0.5)}var j=null,p=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,m,B,D,x,A,M,Q,O=new THREE.Rectangle,r=new THREE.Rectangle,L=false,d=new THREE.Color(16777215),i=new THREE.Color(16777215),o=new THREE.Color(0),l=new THREE.Color(0),
|
|
|
-n=new THREE.Color(0),g,t=new THREE.Vector3,q=[],y=[],u=[],s,w,W,G,T=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(P){switch(P){case "high":T=1;break;case "low":T=0}};this.setSize=function(P,H){k=P;m=H;B=k/2;D=m/2;c.setAttribute("viewBox",-B+" "+-D+" "+k+" "+m);c.setAttribute("width",k);c.setAttribute("height",m);O.set(-B,-D,B,D)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};this.render=function(P,H){var X,K,
|
|
|
-E,F,U,R,C,N;this.autoClear&&this.clear();j=p.projectScene(P,H,this.sortElements);G=W=w=0;if(L=P.lights.length>0){C=P.lights;o.setRGB(0,0,0);l.setRGB(0,0,0);n.setRGB(0,0,0);X=0;for(K=C.length;X<K;X++){E=C[X];F=E.color;if(E instanceof THREE.AmbientLight){o.r+=F.r;o.g+=F.g;o.b+=F.b}else if(E instanceof THREE.DirectionalLight){l.r+=F.r;l.g+=F.g;l.b+=F.b}else if(E instanceof THREE.PointLight){n.r+=F.r;n.g+=F.g;n.b+=F.b}}}X=0;for(K=j.length;X<K;X++){C=j[X];r.empty();if(C instanceof THREE.RenderableParticle){x=
|
|
|
-C;x.x*=B;x.y*=-D;E=0;for(F=C.materials.length;E<F;E++)if(N=C.materials[E]){U=x;R=C;N=N;var V=W++;if(y[V]==null){y[V]=document.createElementNS("http://www.w3.org/2000/svg","circle");T==0&&y[V].setAttribute("shape-rendering","crispEdges")}s=y[V];s.setAttribute("cx",U.x);s.setAttribute("cy",U.y);s.setAttribute("r",R.scale.x*B);if(N instanceof THREE.ParticleCircleMaterial){if(L){i.r=o.r+l.r+n.r;i.g=o.g+l.g+n.g;i.b=o.b+l.b+n.b;d.r=N.color.r*i.r;d.g=N.color.g*i.g;d.b=N.color.b*i.b;d.updateStyleString()}else d=
|
|
|
-N.color;s.setAttribute("style","fill: "+d.__styleString)}c.appendChild(s)}}else if(C instanceof THREE.RenderableLine){x=C.v1;A=C.v2;x.positionScreen.x*=B;x.positionScreen.y*=-D;A.positionScreen.x*=B;A.positionScreen.y*=-D;r.addPoint(x.positionScreen.x,x.positionScreen.y);r.addPoint(A.positionScreen.x,A.positionScreen.y);if(O.instersects(r)){E=0;for(F=C.materials.length;E<F;)if(N=C.materials[E++]){U=x;R=A;N=N;V=G++;if(u[V]==null){u[V]=document.createElementNS("http://www.w3.org/2000/svg","line");T==
|
|
|
+" "+P.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(E instanceof THREE.MeshBasicMaterial)d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshLambertMaterial)if(L){h.r=r.r;h.g=r.g;h.b=r.b;a(F,K,h);d.r=E.color.r*h.r;d.g=E.color.g*h.g;d.b=E.color.b*h.b;d.updateStyleString()}else d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshDepthMaterial){i=1-E.__2near/(E.__farPlusNear-K.z*E.__farMinusNear);
|
|
|
+d.setRGB(i,i,i)}else E instanceof THREE.MeshNormalMaterial&&d.setRGB(g(K.normalWorld.x),g(K.normalWorld.y),g(K.normalWorld.z));E.wireframe?s.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframe_linecap+"; stroke-linejoin: "+E.wireframe_linejoin):s.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+E.opacity);c.appendChild(s)}function f(P,H,X,K,E,F,U){s=e(w++);s.setAttribute("d",
|
|
|
+"M "+P.positionScreen.x+" "+P.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)d.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(L){h.r=r.r;h.g=r.g;h.b=r.b;a(U,E,h);d.r=F.color.r*h.r;d.g=F.color.g*h.g;d.b=F.color.b*h.b;d.updateStyleString()}else d.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){i=
|
|
|
+1-F.__2near/(F.__farPlusNear-E.z*F.__farMinusNear);d.setRGB(i,i,i)}else F instanceof THREE.MeshNormalMaterial&&d.setRGB(g(E.normalWorld.x),g(E.normalWorld.y),g(E.normalWorld.z));F.wireframe?s.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):s.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+F.opacity);c.appendChild(s)}
|
|
|
+function e(P){if(p[P]==null){p[P]=document.createElementNS("http://www.w3.org/2000/svg","path");T==0&&p[P].setAttribute("shape-rendering","crispEdges");return p[P]}return p[P]}function g(P){return P<0?Math.min((1+P)*0.5,0.5):0.5+Math.min(P*0.5,0.5)}var j=null,o=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,l,B,D,x,A,M,Q,O=new THREE.Rectangle,q=new THREE.Rectangle,L=false,d=new THREE.Color(16777215),h=new THREE.Color(16777215),r=new THREE.Color(0),m=new THREE.Color(0),
|
|
|
+n=new THREE.Color(0),i,t=new THREE.Vector3,p=[],y=[],u=[],s,w,W,G,T=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(P){switch(P){case "high":T=1;break;case "low":T=0}};this.setSize=function(P,H){k=P;l=H;B=k/2;D=l/2;c.setAttribute("viewBox",-B+" "+-D+" "+k+" "+l);c.setAttribute("width",k);c.setAttribute("height",l);O.set(-B,-D,B,D)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};this.render=function(P,H){var X,K,
|
|
|
+E,F,U,R,C,N;this.autoClear&&this.clear();j=o.projectScene(P,H,this.sortElements);G=W=w=0;if(L=P.lights.length>0){C=P.lights;r.setRGB(0,0,0);m.setRGB(0,0,0);n.setRGB(0,0,0);X=0;for(K=C.length;X<K;X++){E=C[X];F=E.color;if(E instanceof THREE.AmbientLight){r.r+=F.r;r.g+=F.g;r.b+=F.b}else if(E instanceof THREE.DirectionalLight){m.r+=F.r;m.g+=F.g;m.b+=F.b}else if(E instanceof THREE.PointLight){n.r+=F.r;n.g+=F.g;n.b+=F.b}}}X=0;for(K=j.length;X<K;X++){C=j[X];q.empty();if(C instanceof THREE.RenderableParticle){x=
|
|
|
+C;x.x*=B;x.y*=-D;E=0;for(F=C.materials.length;E<F;E++)if(N=C.materials[E]){U=x;R=C;N=N;var V=W++;if(y[V]==null){y[V]=document.createElementNS("http://www.w3.org/2000/svg","circle");T==0&&y[V].setAttribute("shape-rendering","crispEdges")}s=y[V];s.setAttribute("cx",U.x);s.setAttribute("cy",U.y);s.setAttribute("r",R.scale.x*B);if(N instanceof THREE.ParticleCircleMaterial){if(L){h.r=r.r+m.r+n.r;h.g=r.g+m.g+n.g;h.b=r.b+m.b+n.b;d.r=N.color.r*h.r;d.g=N.color.g*h.g;d.b=N.color.b*h.b;d.updateStyleString()}else d=
|
|
|
+N.color;s.setAttribute("style","fill: "+d.__styleString)}c.appendChild(s)}}else if(C instanceof THREE.RenderableLine){x=C.v1;A=C.v2;x.positionScreen.x*=B;x.positionScreen.y*=-D;A.positionScreen.x*=B;A.positionScreen.y*=-D;q.addPoint(x.positionScreen.x,x.positionScreen.y);q.addPoint(A.positionScreen.x,A.positionScreen.y);if(O.instersects(q)){E=0;for(F=C.materials.length;E<F;)if(N=C.materials[E++]){U=x;R=A;N=N;V=G++;if(u[V]==null){u[V]=document.createElementNS("http://www.w3.org/2000/svg","line");T==
|
|
|
0&&u[V].setAttribute("shape-rendering","crispEdges")}s=u[V];s.setAttribute("x1",U.positionScreen.x);s.setAttribute("y1",U.positionScreen.y);s.setAttribute("x2",R.positionScreen.x);s.setAttribute("y2",R.positionScreen.y);if(N instanceof THREE.LineBasicMaterial){d.__styleString=N.color.__styleString;s.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+N.linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.linecap+"; stroke-linejoin: "+N.linejoin);c.appendChild(s)}}}}else if(C instanceof
|
|
|
-THREE.RenderableFace3){x=C.v1;A=C.v2;M=C.v3;x.positionScreen.x*=B;x.positionScreen.y*=-D;A.positionScreen.x*=B;A.positionScreen.y*=-D;M.positionScreen.x*=B;M.positionScreen.y*=-D;r.addPoint(x.positionScreen.x,x.positionScreen.y);r.addPoint(A.positionScreen.x,A.positionScreen.y);r.addPoint(M.positionScreen.x,M.positionScreen.y);if(O.instersects(r)){E=0;for(F=C.meshMaterials.length;E<F;){N=C.meshMaterials[E++];if(N instanceof THREE.MeshFaceMaterial){U=0;for(R=C.faceMaterials.length;U<R;)(N=C.faceMaterials[U++])&&
|
|
|
-b(x,A,M,C,N,P)}else N&&b(x,A,M,C,N,P)}}}else if(C instanceof THREE.RenderableFace4){x=C.v1;A=C.v2;M=C.v3;Q=C.v4;x.positionScreen.x*=B;x.positionScreen.y*=-D;A.positionScreen.x*=B;A.positionScreen.y*=-D;M.positionScreen.x*=B;M.positionScreen.y*=-D;Q.positionScreen.x*=B;Q.positionScreen.y*=-D;r.addPoint(x.positionScreen.x,x.positionScreen.y);r.addPoint(A.positionScreen.x,A.positionScreen.y);r.addPoint(M.positionScreen.x,M.positionScreen.y);r.addPoint(Q.positionScreen.x,Q.positionScreen.y);if(O.instersects(r)){E=
|
|
|
+THREE.RenderableFace3){x=C.v1;A=C.v2;M=C.v3;x.positionScreen.x*=B;x.positionScreen.y*=-D;A.positionScreen.x*=B;A.positionScreen.y*=-D;M.positionScreen.x*=B;M.positionScreen.y*=-D;q.addPoint(x.positionScreen.x,x.positionScreen.y);q.addPoint(A.positionScreen.x,A.positionScreen.y);q.addPoint(M.positionScreen.x,M.positionScreen.y);if(O.instersects(q)){E=0;for(F=C.meshMaterials.length;E<F;){N=C.meshMaterials[E++];if(N instanceof THREE.MeshFaceMaterial){U=0;for(R=C.faceMaterials.length;U<R;)(N=C.faceMaterials[U++])&&
|
|
|
+b(x,A,M,C,N,P)}else N&&b(x,A,M,C,N,P)}}}else if(C instanceof THREE.RenderableFace4){x=C.v1;A=C.v2;M=C.v3;Q=C.v4;x.positionScreen.x*=B;x.positionScreen.y*=-D;A.positionScreen.x*=B;A.positionScreen.y*=-D;M.positionScreen.x*=B;M.positionScreen.y*=-D;Q.positionScreen.x*=B;Q.positionScreen.y*=-D;q.addPoint(x.positionScreen.x,x.positionScreen.y);q.addPoint(A.positionScreen.x,A.positionScreen.y);q.addPoint(M.positionScreen.x,M.positionScreen.y);q.addPoint(Q.positionScreen.x,Q.positionScreen.y);if(O.instersects(q)){E=
|
|
|
0;for(F=C.meshMaterials.length;E<F;){N=C.meshMaterials[E++];if(N instanceof THREE.MeshFaceMaterial){U=0;for(R=C.faceMaterials.length;U<R;)(N=C.faceMaterials[U++])&&f(x,A,M,Q,C,N,P)}else N&&f(x,A,M,Q,C,N,P)}}}}}};
|
|
|
-THREE.WebGLRenderer=function(a){function b(d,i){d.fragment_shader=i.fragment_shader;d.vertex_shader=i.vertex_shader;d.uniforms=Uniforms.clone(i.uniforms)}function f(d,i){d.uniforms.color.value.setRGB(d.color.r*d.opacity,d.color.g*d.opacity,d.color.b*d.opacity);d.uniforms.opacity.value=d.opacity;d.uniforms.map.texture=d.map;d.uniforms.env_map.texture=d.env_map;d.uniforms.reflectivity.value=d.reflectivity;d.uniforms.refraction_ratio.value=d.refraction_ratio;d.uniforms.combine.value=d.combine;d.uniforms.useRefract.value=
|
|
|
-d.env_map&&d.env_map.mapping instanceof THREE.CubeRefractionMapping;if(i){d.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){d.uniforms.fogNear.value=i.near;d.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)d.uniforms.fogDensity.value=i.density}}function e(d,i){d.uniforms.color.value.setRGB(d.color.r*d.opacity,d.color.g*d.opacity,d.color.b*d.opacity);d.uniforms.opacity.value=d.opacity;if(i){d.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){d.uniforms.fogNear.value=
|
|
|
-i.near;d.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)d.uniforms.fogDensity.value=i.density}}function h(d,i){var o;if(d=="fragment")o=c.createShader(c.FRAGMENT_SHADER);else if(d=="vertex")o=c.createShader(c.VERTEX_SHADER);c.shaderSource(o,i);c.compileShader(o);if(!c.getShaderParameter(o,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(o));return null}return o}function j(d){switch(d){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;
|
|
|
-case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var p=document.createElement("canvas"),c,k=null,m=new THREE.Matrix4,B,D=new Float32Array(16),x=new Float32Array(16),A=new Float32Array(16),
|
|
|
-M=new Float32Array(9),Q=new Float32Array(16),O=true,r=new THREE.Color(0),L=0;if(a){if(a.antialias!==undefined)O=a.antialias;a.clearColor!==undefined&&r.setHex(a.clearColor);if(a.clearAlpha!==undefined)L=a.clearAlpha}this.domElement=p;this.autoClear=true;(function(d,i,o){try{c=p.getContext("experimental-webgl",{antialias:d})}catch(l){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);
|
|
|
-c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(i.r,i.g,i.b,o)})(O,r,L);this.setSize=function(d,i){p.width=d;p.height=i;c.viewport(0,0,p.width,p.height)};this.setClearColor=function(d,i){var o=new THREE.Color(d);c.clearColor(o.r,o.g,o.b,i)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(d,i){var o,l,n,g=0,t=0,q=0,y=[],u=[],s=[],w=[];o=0;for(l=i.length;o<l;o++){n=i[o];if(n instanceof THREE.AmbientLight){g+=
|
|
|
-n.color.r;t+=n.color.g;q+=n.color.b}else if(n instanceof THREE.DirectionalLight){y.push(n.color.r*n.intensity,n.color.g*n.intensity,n.color.b*n.intensity);u.push(n.position.x,n.position.y,n.position.z)}else if(n instanceof THREE.PointLight){s.push(n.color.r*n.intensity,n.color.g*n.intensity,n.color.b*n.intensity);w.push(n.position.x,n.position.y,n.position.z)}}return{ambient:[g,t,q],directional:{colors:y,positions:u},point:{colors:s,positions:w}}};this.createLineBuffers=function(d){var i,o,l,n=[],
|
|
|
-g=[],t=d.geometry.vertices;i=0;for(o=t.length;i<o;i++){l=t[i].position;n.push(l.x,l.y,l.z);g.push(i)}if(n.length){d.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,d.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(n),c.STATIC_DRAW);d.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(g),c.STATIC_DRAW);d.__webGLLineCount=g.length}};this.createBuffers=function(d,i){var o,l,
|
|
|
-n,g,t,q,y,u,s,w,W=[],G=[],T=[],P=[],H=[],X=[],K=0,E=d.geometry.geometryChunks[i],F;t=false;o=0;for(l=d.materials.length;o<l;o++){q=d.materials[o];if(q instanceof THREE.MeshFaceMaterial){q=0;for(F=E.materials.length;q<F;q++)if(E.materials[q]&&E.materials[q].shading!=undefined&&E.materials[q].shading==THREE.SmoothShading){t=true;break}}else if(q&&q.shading!=undefined&&q.shading==THREE.SmoothShading){t=true;break}if(t)break}F=t;o=0;for(l=E.faces.length;o<l;o++){n=E.faces[o];g=d.geometry.faces[n];t=g.vertexNormals;
|
|
|
-q=g.normal;n=d.geometry.uvs[n];if(g instanceof THREE.Face3){y=d.geometry.vertices[g.a].position;u=d.geometry.vertices[g.b].position;s=d.geometry.vertices[g.c].position;T.push(y.x,y.y,y.z,u.x,u.y,u.z,s.x,s.y,s.z);if(d.geometry.hasTangents){y=d.geometry.vertices[g.a].tangent;u=d.geometry.vertices[g.b].tangent;s=d.geometry.vertices[g.c].tangent;H.push(y.x,y.y,y.z,y.w,u.x,u.y,u.z,u.w,s.x,s.y,s.z,s.w)}if(t.length==3&&F)for(g=0;g<3;g++)P.push(t[g].x,t[g].y,t[g].z);else for(g=0;g<3;g++)P.push(q.x,q.y,q.z);
|
|
|
-if(n)for(g=0;g<3;g++)X.push(n[g].u,n[g].v);W.push(K,K+1,K+2);G.push(K,K+1,K,K+2,K+1,K+2);K+=3}else if(g instanceof THREE.Face4){y=d.geometry.vertices[g.a].position;u=d.geometry.vertices[g.b].position;s=d.geometry.vertices[g.c].position;w=d.geometry.vertices[g.d].position;T.push(y.x,y.y,y.z,u.x,u.y,u.z,s.x,s.y,s.z,w.x,w.y,w.z);if(d.geometry.hasTangents){y=d.geometry.vertices[g.a].tangent;u=d.geometry.vertices[g.b].tangent;s=d.geometry.vertices[g.c].tangent;g=d.geometry.vertices[g.d].tangent;H.push(y.x,
|
|
|
-y.y,y.z,y.w,u.x,u.y,u.z,u.w,s.x,s.y,s.z,s.w,g.x,g.y,g.z,g.w)}if(t.length==4&&F)for(g=0;g<4;g++)P.push(t[g].x,t[g].y,t[g].z);else for(g=0;g<4;g++)P.push(q.x,q.y,q.z);if(n)for(g=0;g<4;g++)X.push(n[g].u,n[g].v);W.push(K,K+1,K+2,K,K+2,K+3);G.push(K,K+1,K,K+2,K,K+3,K+1,K+2,K+2,K+3);K+=4}}if(T.length){E.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(T),c.STATIC_DRAW);E.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,
|
|
|
+THREE.WebGLRenderer=function(a){function b(d,h){d.fragment_shader=h.fragment_shader;d.vertex_shader=h.vertex_shader;d.uniforms=Uniforms.clone(h.uniforms)}function f(d,h){d.uniforms.color.value.setRGB(d.color.r*d.opacity,d.color.g*d.opacity,d.color.b*d.opacity);d.uniforms.opacity.value=d.opacity;d.uniforms.map.texture=d.map;d.uniforms.env_map.texture=d.env_map;d.uniforms.reflectivity.value=d.reflectivity;d.uniforms.refraction_ratio.value=d.refraction_ratio;d.uniforms.combine.value=d.combine;d.uniforms.useRefract.value=
|
|
|
+d.env_map&&d.env_map.mapping instanceof THREE.CubeRefractionMapping;if(h){d.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){d.uniforms.fogNear.value=h.near;d.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)d.uniforms.fogDensity.value=h.density}}function e(d,h){d.uniforms.color.value.setRGB(d.color.r*d.opacity,d.color.g*d.opacity,d.color.b*d.opacity);d.uniforms.opacity.value=d.opacity;if(h){d.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){d.uniforms.fogNear.value=
|
|
|
+h.near;d.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)d.uniforms.fogDensity.value=h.density}}function g(d,h){var r;if(d=="fragment")r=c.createShader(c.FRAGMENT_SHADER);else if(d=="vertex")r=c.createShader(c.VERTEX_SHADER);c.shaderSource(r,h);c.compileShader(r);if(!c.getShaderParameter(r,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(r));return null}return r}function j(d){switch(d){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;
|
|
|
+case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var o=document.createElement("canvas"),c,k=null,l=new THREE.Matrix4,B,D=new Float32Array(16),x=new Float32Array(16),A=new Float32Array(16),
|
|
|
+M=new Float32Array(9),Q=new Float32Array(16),O=true,q=new THREE.Color(0),L=0;if(a){if(a.antialias!==undefined)O=a.antialias;a.clearColor!==undefined&&q.setHex(a.clearColor);if(a.clearAlpha!==undefined)L=a.clearAlpha}this.domElement=o;this.autoClear=true;(function(d,h,r){try{c=o.getContext("experimental-webgl",{antialias:d})}catch(m){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);
|
|
|
+c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(h.r,h.g,h.b,r)})(O,q,L);this.setSize=function(d,h){o.width=d;o.height=h;c.viewport(0,0,o.width,o.height)};this.setClearColor=function(d,h){var r=new THREE.Color(d);c.clearColor(r.r,r.g,r.b,h)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(d,h){var r,m,n,i=0,t=0,p=0,y=[],u=[],s=[],w=[];r=0;for(m=h.length;r<m;r++){n=h[r];if(n instanceof THREE.AmbientLight){i+=
|
|
|
+n.color.r;t+=n.color.g;p+=n.color.b}else if(n instanceof THREE.DirectionalLight){y.push(n.color.r*n.intensity,n.color.g*n.intensity,n.color.b*n.intensity);u.push(n.position.x,n.position.y,n.position.z)}else if(n instanceof THREE.PointLight){s.push(n.color.r*n.intensity,n.color.g*n.intensity,n.color.b*n.intensity);w.push(n.position.x,n.position.y,n.position.z)}}return{ambient:[i,t,p],directional:{colors:y,positions:u},point:{colors:s,positions:w}}};this.createLineBuffers=function(d){var h,r,m,n=[],
|
|
|
+i=[],t=d.geometry.vertices;h=0;for(r=t.length;h<r;h++){m=t[h].position;n.push(m.x,m.y,m.z);i.push(h)}if(n.length){d.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,d.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(n),c.STATIC_DRAW);d.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(i),c.STATIC_DRAW);d.__webGLLineCount=i.length}};this.createBuffers=function(d,h){var r,m,
|
|
|
+n,i,t,p,y,u,s,w,W=[],G=[],T=[],P=[],H=[],X=[],K=0,E=d.geometry.geometryChunks[h],F;t=false;r=0;for(m=d.materials.length;r<m;r++){p=d.materials[r];if(p instanceof THREE.MeshFaceMaterial){p=0;for(F=E.materials.length;p<F;p++)if(E.materials[p]&&E.materials[p].shading!=undefined&&E.materials[p].shading==THREE.SmoothShading){t=true;break}}else if(p&&p.shading!=undefined&&p.shading==THREE.SmoothShading){t=true;break}if(t)break}F=t;r=0;for(m=E.faces.length;r<m;r++){n=E.faces[r];i=d.geometry.faces[n];t=i.vertexNormals;
|
|
|
+p=i.normal;n=d.geometry.uvs[n];if(i instanceof THREE.Face3){y=d.geometry.vertices[i.a].position;u=d.geometry.vertices[i.b].position;s=d.geometry.vertices[i.c].position;T.push(y.x,y.y,y.z,u.x,u.y,u.z,s.x,s.y,s.z);if(d.geometry.hasTangents){y=d.geometry.vertices[i.a].tangent;u=d.geometry.vertices[i.b].tangent;s=d.geometry.vertices[i.c].tangent;H.push(y.x,y.y,y.z,y.w,u.x,u.y,u.z,u.w,s.x,s.y,s.z,s.w)}if(t.length==3&&F)for(i=0;i<3;i++)P.push(t[i].x,t[i].y,t[i].z);else for(i=0;i<3;i++)P.push(p.x,p.y,p.z);
|
|
|
+if(n)for(i=0;i<3;i++)X.push(n[i].u,n[i].v);W.push(K,K+1,K+2);G.push(K,K+1,K,K+2,K+1,K+2);K+=3}else if(i instanceof THREE.Face4){y=d.geometry.vertices[i.a].position;u=d.geometry.vertices[i.b].position;s=d.geometry.vertices[i.c].position;w=d.geometry.vertices[i.d].position;T.push(y.x,y.y,y.z,u.x,u.y,u.z,s.x,s.y,s.z,w.x,w.y,w.z);if(d.geometry.hasTangents){y=d.geometry.vertices[i.a].tangent;u=d.geometry.vertices[i.b].tangent;s=d.geometry.vertices[i.c].tangent;i=d.geometry.vertices[i.d].tangent;H.push(y.x,
|
|
|
+y.y,y.z,y.w,u.x,u.y,u.z,u.w,s.x,s.y,s.z,s.w,i.x,i.y,i.z,i.w)}if(t.length==4&&F)for(i=0;i<4;i++)P.push(t[i].x,t[i].y,t[i].z);else for(i=0;i<4;i++)P.push(p.x,p.y,p.z);if(n)for(i=0;i<4;i++)X.push(n[i].u,n[i].v);W.push(K,K+1,K+2,K,K+2,K+3);G.push(K,K+1,K,K+2,K,K+3,K+1,K+2,K+2,K+3);K+=4}}if(T.length){E.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(T),c.STATIC_DRAW);E.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,
|
|
|
E.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(P),c.STATIC_DRAW);if(d.geometry.hasTangents){E.__webGLTangentBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(H),c.STATIC_DRAW)}if(X.length>0){E.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(X),c.STATIC_DRAW)}E.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
|
|
|
-E.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(W),c.STATIC_DRAW);E.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,E.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(G),c.STATIC_DRAW);E.__webGLFaceCount=W.length;E.__webGLLineCount=G.length}};this.renderBuffer=function(d,i,o,l,n){var g,t,q,y;if(!l.program){if(l instanceof THREE.MeshDepthMaterial){b(l,THREE.ShaderLib.depth);l.uniforms.mNear.value=d.near;l.uniforms.mFar.value=d.far}else if(l instanceof
|
|
|
-THREE.MeshNormalMaterial)b(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial){b(l,THREE.ShaderLib.basic);f(l,o)}else if(l instanceof THREE.MeshLambertMaterial){b(l,THREE.ShaderLib.lambert);f(l,o)}else if(l instanceof THREE.MeshPhongMaterial){b(l,THREE.ShaderLib.phong);f(l,o)}else if(l instanceof THREE.LineBasicMaterial){b(l,THREE.ShaderLib.basic);e(l,o)}if(scene){var u,s,w;u=y=t=0;for(s=i.length;u<s;u++){w=i[u];w instanceof THREE.DirectionalLight&&y++;w instanceof THREE.PointLight&&
|
|
|
-t++}if(t+y<=4){u=y;t=t}else{u=Math.ceil(4*y/(t+y));t=4-u}t={directional:u,point:t}}else t={directional:1,point:3};y={fog:o,map:l.map,env_map:l.env_map,maxDirLights:t.directional,maxPointLights:t.point};t=l.fragment_shader;u=l.vertex_shader;s=c.createProgram();w=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,y.fog?"#define USE_FOG":"",y.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",y.map?"#define USE_MAP":"",
|
|
|
+E.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(W),c.STATIC_DRAW);E.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,E.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(G),c.STATIC_DRAW);E.__webGLFaceCount=W.length;E.__webGLLineCount=G.length}};this.renderBuffer=function(d,h,r,m,n){var i,t,p,y;if(!m.program){if(m instanceof THREE.MeshDepthMaterial){b(m,THREE.ShaderLib.depth);m.uniforms.mNear.value=d.near;m.uniforms.mFar.value=d.far}else if(m instanceof
|
|
|
+THREE.MeshNormalMaterial)b(m,THREE.ShaderLib.normal);else if(m instanceof THREE.MeshBasicMaterial){b(m,THREE.ShaderLib.basic);f(m,r)}else if(m instanceof THREE.MeshLambertMaterial){b(m,THREE.ShaderLib.lambert);f(m,r)}else if(m instanceof THREE.MeshPhongMaterial){b(m,THREE.ShaderLib.phong);f(m,r)}else if(m instanceof THREE.LineBasicMaterial){b(m,THREE.ShaderLib.basic);e(m,r)}if(scene){var u,s,w;u=y=t=0;for(s=h.length;u<s;u++){w=h[u];w instanceof THREE.DirectionalLight&&y++;w instanceof THREE.PointLight&&
|
|
|
+t++}if(t+y<=4){u=y;t=t}else{u=Math.ceil(4*y/(t+y));t=4-u}t={directional:u,point:t}}else t={directional:1,point:3};y={fog:r,map:m.map,env_map:m.env_map,maxDirLights:t.directional,maxPointLights:t.point};t=m.fragment_shader;u=m.vertex_shader;s=c.createProgram();w=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,y.fog?"#define USE_FOG":"",y.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",y.map?"#define USE_MAP":"",
|
|
|
y.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");y=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,y.map?"#define USE_MAP":"",y.env_map?"#define USE_ENVMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");
|
|
|
-c.attachShader(s,h("fragment",w+t));c.attachShader(s,h("vertex",y+u));c.linkProgram(s);c.getProgramParameter(s,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(s,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");s.uniforms={};s.attributes={};l.program=s;t=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(g in l.uniforms)t.push(g);g=l.program;u=0;for(s=t.length;u<s;u++){w=t[u];g.uniforms[w]=c.getUniformLocation(g,
|
|
|
-w)}g=l.program;t=["position","normal","uv","tangent"];u=0;for(s=t.length;u<s;u++){w=t[u];g.attributes[w]=c.getAttribLocation(g,w)}}g=l.program;if(g!=k){c.useProgram(g);k=g}this.loadCamera(g,d);this.loadMatrices(g);if(l instanceof THREE.MeshPhongMaterial||l instanceof THREE.MeshLambertMaterial){d=this.setupLights(g,i);l.uniforms.enableLighting.value=d.directional.positions.length+d.point.positions.length;l.uniforms.ambientLightColor.value=d.ambient;l.uniforms.directionalLightColor.value=d.directional.colors;
|
|
|
-l.uniforms.directionalLightDirection.value=d.directional.positions;l.uniforms.pointLightColor.value=d.point.colors;l.uniforms.pointLightPosition.value=d.point.positions}if(l instanceof THREE.MeshBasicMaterial||l instanceof THREE.MeshLambertMaterial||l instanceof THREE.MeshPhongMaterial)f(l,o);l instanceof THREE.LineBasicMaterial&&e(l,o);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}o=l.uniforms;for(q in o)if(t=g.uniforms[q]){i=o[q].type;d=o[q].value;if(i=="i")c.uniform1i(t,d);else if(i=="f")c.uniform1f(t,d);else if(i=="fv")c.uniform3fv(t,d);else if(i=="v2")c.uniform2f(t,d.x,d.y);else if(i=="v3")c.uniform3f(t,d.x,d.y,d.z);else if(i=="c")c.uniform3f(t,d.r,d.g,d.b);else if(i=="t"){c.uniform1i(t,d);if(i=o[q].texture)if(i.image instanceof Array&&i.image.length==6){i=i;d=d;if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&
|
|
|
-i.image.loadCount==6){i.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(t=0;t<6;++t)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,
|
|
|
-i.image[t]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);i.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube)}}else{i=i;d=d;if(!i.__webGLTexture&&i.image.loaded){i.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,i.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,j(i.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,
|
|
|
-j(i.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,j(i.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,j(i.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_2D,i.__webGLTexture)}}}q=g.attributes;c.bindBuffer(c.ARRAY_BUFFER,n.__webGLVertexBuffer);c.vertexAttribPointer(q.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.position);if(q.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer);
|
|
|
-c.vertexAttribPointer(q.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.normal)}if(q.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLTangentBuffer);c.vertexAttribPointer(q.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.tangent)}if(q.uv>=0)if(n.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.vertexAttribPointer(q.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.uv)}else c.disableVertexAttribArray(q.uv);if(l.wireframe||l instanceof THREE.LineBasicMaterial){q=
|
|
|
-l.wireframe_linewidth!==undefined?l.wireframe_linewidth:l.linewidth!==undefined?l.linewidth:1;l=l instanceof THREE.LineBasicMaterial&&n.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(q);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);c.drawElements(l,n.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(d,i,o,l,n,g,t){var q,y,u,s,w;u=0;for(s=
|
|
|
-l.materials.length;u<s;u++){q=l.materials[u];if(q instanceof THREE.MeshFaceMaterial){q=0;for(y=n.materials.length;q<y;q++)if((w=n.materials[q])&&w.blending==g&&w.opacity<1==t){this.setBlending(w.blending);this.renderBuffer(d,i,o,w,n)}}else if((w=q)&&w.blending==g&&w.opacity<1==t){this.setBlending(w.blending);this.renderBuffer(d,i,o,w,n)}}};this.renderPassLines=function(d,i,o,l){var n,g,t;n=0;for(g=l.materials.length;n<g;n++){t=l.materials[n];this.setBlending(t.blending);this.renderBuffer(d,i,o,t,
|
|
|
-l)}};this.render=function(d,i){var o,l,n,g,t=d.lights,q=d.fog;this.initWebGLObjects(d);this.autoClear&&this.clear();i.autoUpdateMatrix&&i.updateMatrix();D.set(i.matrix.flatten());A.set(i.projectionMatrix.flatten());o=0;for(l=d.__webGLLines.length;o<l;o++){n=d.__webGLLines[o];g=n.object;if(g.visible){this.setupMatrices(g,i);this.renderPassLines(i,t,q,g)}}o=0;for(l=d.__webGLObjects.length;o<l;o++){n=d.__webGLObjects[o];g=n.object;n=n.buffer;if(g.visible){this.setupMatrices(g,i);this.renderPass(i,t,
|
|
|
-q,g,n,THREE.NormalBlending,false)}}o=0;for(l=d.__webGLObjects.length;o<l;o++){n=d.__webGLObjects[o];g=n.object;n=n.buffer;if(g.visible){this.setupMatrices(g,i);this.renderPass(i,t,q,g,n,THREE.AdditiveBlending,false);this.renderPass(i,t,q,g,n,THREE.SubtractiveBlending,false);this.renderPass(i,t,q,g,n,THREE.AdditiveBlending,true);this.renderPass(i,t,q,g,n,THREE.SubtractiveBlending,true);this.renderPass(i,t,q,g,n,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(d){var i,o,l,n,g,t;if(!d.__webGLObjects){d.__webGLObjects=
|
|
|
-[];d.__webGLObjectsMap={}}if(!d.__webGLLines){d.__webGLLines=[];d.__webGLLinesMap={}}i=0;for(o=d.objects.length;i<o;i++){l=d.objects[i];if(l instanceof THREE.Mesh){if(d.__webGLObjectsMap[l.id]==undefined)d.__webGLObjectsMap[l.id]={};t=d.__webGLObjectsMap[l.id];for(g in l.geometry.geometryChunks){n=l.geometry.geometryChunks[g];n.__webGLVertexBuffer||this.createBuffers(l,g);if(t[g]==undefined){n={buffer:n,object:l};d.__webGLObjects.push(n);t[g]=1}}}else if(l instanceof THREE.Line){if(d.__webGLLinesMap[l.id]==
|
|
|
-undefined)d.__webGLLinesMap[l.id]={};lmap=d.__webGLLinesMap[l.id];l.__webGLVertexBuffer||this.createLineBuffers(l);g=0;if(lmap[g]==undefined){n={object:l};d.__webGLLines.push(n);lmap[g]=1}}}};this.removeObject=function(d,i){var o,l;for(o=d.__webGLObjects.length-1;o>=0;o--){l=d.__webGLObjects[o].object;i==l&&d.__webGLObjects.splice(o,1)}};this.setupMatrices=function(d,i){d.autoUpdateMatrix&&d.updateMatrix();m.multiply(i.matrix,d.matrix);x.set(m.flatten());B=THREE.Matrix4.makeInvert3x3(m).transpose();
|
|
|
-M.set(B.m);Q.set(d.matrix.flatten())};this.loadMatrices=function(d){c.uniformMatrix4fv(d.uniforms.viewMatrix,false,D);c.uniformMatrix4fv(d.uniforms.modelViewMatrix,false,x);c.uniformMatrix4fv(d.uniforms.projectionMatrix,false,A);c.uniformMatrix3fv(d.uniforms.normalMatrix,false,M);c.uniformMatrix4fv(d.uniforms.objectMatrix,false,Q)};this.loadCamera=function(d,i){c.uniform3f(d.uniforms.cameraPosition,i.position.x,i.position.y,i.position.z)};this.setBlending=function(d){switch(d){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);
|
|
|
-c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(d,i){if(d){!i||i=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(d=="back")c.cullFace(c.BACK);else d=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
|
|
|
-0}};
|
|
|
+c.attachShader(s,g("fragment",w+t));c.attachShader(s,g("vertex",y+u));c.linkProgram(s);c.getProgramParameter(s,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(s,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");s.uniforms={};s.attributes={};m.program=s;t=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(i in m.uniforms)t.push(i);i=m.program;u=0;for(s=t.length;u<s;u++){w=t[u];i.uniforms[w]=c.getUniformLocation(i,
|
|
|
+w)}i=m.program;t=["position","normal","uv","tangent"];u=0;for(s=t.length;u<s;u++){w=t[u];i.attributes[w]=c.getAttribLocation(i,w)}}i=m.program;if(i!=k){c.useProgram(i);k=i}this.loadCamera(i,d);this.loadMatrices(i);if(m instanceof THREE.MeshPhongMaterial||m instanceof THREE.MeshLambertMaterial){d=this.setupLights(i,h);m.uniforms.enableLighting.value=d.directional.positions.length+d.point.positions.length;m.uniforms.ambientLightColor.value=d.ambient;m.uniforms.directionalLightColor.value=d.directional.colors;
|
|
|
+m.uniforms.directionalLightDirection.value=d.directional.positions;m.uniforms.pointLightColor.value=d.point.colors;m.uniforms.pointLightPosition.value=d.point.positions}if(m instanceof THREE.MeshBasicMaterial||m instanceof THREE.MeshLambertMaterial||m instanceof THREE.MeshPhongMaterial)f(m,r);m instanceof THREE.LineBasicMaterial&&e(m,r);if(m instanceof THREE.MeshPhongMaterial){m.uniforms.ambient.value.setRGB(m.ambient.r,m.ambient.g,m.ambient.b);m.uniforms.specular.value.setRGB(m.specular.r,m.specular.g,
|
|
|
+m.specular.b);m.uniforms.shininess.value=m.shininess}r=m.uniforms;for(p in r)if(t=i.uniforms[p]){h=r[p].type;d=r[p].value;if(h=="i")c.uniform1i(t,d);else if(h=="f")c.uniform1f(t,d);else if(h=="fv")c.uniform3fv(t,d);else if(h=="v2")c.uniform2f(t,d.x,d.y);else if(h=="v3")c.uniform3f(t,d.x,d.y,d.z);else if(h=="c")c.uniform3f(t,d.r,d.g,d.b);else if(h=="t"){c.uniform1i(t,d);if(h=r[p].texture)if(h.image instanceof Array&&h.image.length==6){h=h;d=d;if(h.image.length==6){if(!h.image.__webGLTextureCube&&!h.image.__cubeMapInitialized&&
|
|
|
+h.image.loadCount==6){h.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,h.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(t=0;t<6;++t)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,
|
|
|
+h.image[t]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);h.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_CUBE_MAP,h.image.__webGLTextureCube)}}else{h=h;d=d;if(!h.__webGLTexture&&h.image.loaded){h.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,h.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,h.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,j(h.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,
|
|
|
+j(h.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,j(h.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,j(h.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_2D,h.__webGLTexture)}}}p=i.attributes;c.bindBuffer(c.ARRAY_BUFFER,n.__webGLVertexBuffer);c.vertexAttribPointer(p.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(p.position);if(p.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer);
|
|
|
+c.vertexAttribPointer(p.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(p.normal)}if(p.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLTangentBuffer);c.vertexAttribPointer(p.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(p.tangent)}if(p.uv>=0)if(n.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.vertexAttribPointer(p.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(p.uv)}else c.disableVertexAttribArray(p.uv);if(m.wireframe||m instanceof THREE.LineBasicMaterial){p=
|
|
|
+m.wireframe_linewidth!==undefined?m.wireframe_linewidth:m.linewidth!==undefined?m.linewidth:1;m=m instanceof THREE.LineBasicMaterial&&n.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(p);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);c.drawElements(m,n.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(d,h,r,m,n,i,t){var p,y,u,s,w;u=0;for(s=
|
|
|
+m.materials.length;u<s;u++){p=m.materials[u];if(p instanceof THREE.MeshFaceMaterial){p=0;for(y=n.materials.length;p<y;p++)if((w=n.materials[p])&&w.blending==i&&w.opacity<1==t){this.setBlending(w.blending);this.renderBuffer(d,h,r,w,n)}}else if((w=p)&&w.blending==i&&w.opacity<1==t){this.setBlending(w.blending);this.renderBuffer(d,h,r,w,n)}}};this.render=function(d,h){var r,m,n,i,t=d.lights,p=d.fog;this.initWebGLObjects(d);this.autoClear&&this.clear();h.autoUpdateMatrix&&h.updateMatrix();D.set(h.matrix.flatten());
|
|
|
+A.set(h.projectionMatrix.flatten());r=0;for(m=d.__webGLObjects.length;r<m;r++){n=d.__webGLObjects[r];i=n.object;n=n.buffer;if(i.visible){this.setupMatrices(i,h);this.renderPass(h,t,p,i,n,THREE.NormalBlending,false)}}r=0;for(m=d.__webGLObjects.length;r<m;r++){n=d.__webGLObjects[r];i=n.object;n=n.buffer;if(i.visible){this.setupMatrices(i,h);this.renderPass(h,t,p,i,n,THREE.AdditiveBlending,false);this.renderPass(h,t,p,i,n,THREE.SubtractiveBlending,false);this.renderPass(h,t,p,i,n,THREE.AdditiveBlending,
|
|
|
+true);this.renderPass(h,t,p,i,n,THREE.SubtractiveBlending,true);this.renderPass(h,t,p,i,n,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(d){var h,r,m,n,i,t;if(!d.__webGLObjects){d.__webGLObjects=[];d.__webGLObjectsMap={}}h=0;for(r=d.objects.length;h<r;h++){m=d.objects[h];if(d.__webGLObjectsMap[m.id]==undefined)d.__webGLObjectsMap[m.id]={};t=d.__webGLObjectsMap[m.id];if(m instanceof THREE.Mesh)for(i in m.geometry.geometryChunks){n=m.geometry.geometryChunks[i];n.__webGLVertexBuffer||this.createBuffers(m,
|
|
|
+i);if(t[i]==undefined){n={buffer:n,object:m};d.__webGLObjects.push(n);t[i]=1}}else if(m instanceof THREE.Line){m.__webGLVertexBuffer||this.createLineBuffers(m);i=0;if(t[i]==undefined){n={buffer:m,object:m};d.__webGLObjects.push(n);t[i]=1}}}};this.removeObject=function(d,h){var r,m;for(r=d.__webGLObjects.length-1;r>=0;r--){m=d.__webGLObjects[r].object;h==m&&d.__webGLObjects.splice(r,1)}};this.setupMatrices=function(d,h){d.autoUpdateMatrix&&d.updateMatrix();l.multiply(h.matrix,d.matrix);x.set(l.flatten());
|
|
|
+B=THREE.Matrix4.makeInvert3x3(l).transpose();M.set(B.m);Q.set(d.matrix.flatten())};this.loadMatrices=function(d){c.uniformMatrix4fv(d.uniforms.viewMatrix,false,D);c.uniformMatrix4fv(d.uniforms.modelViewMatrix,false,x);c.uniformMatrix4fv(d.uniforms.projectionMatrix,false,A);c.uniformMatrix3fv(d.uniforms.normalMatrix,false,M);c.uniformMatrix4fv(d.uniforms.objectMatrix,false,Q)};this.loadCamera=function(d,h){c.uniform3f(d.uniforms.cameraPosition,h.position.x,h.position.y,h.position.z)};this.setBlending=
|
|
|
+function(d){switch(d){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(d,h){if(d){!h||h=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(d=="back")c.cullFace(c.BACK);else d=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=
|
|
|
+function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
|
|
|
THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
|
|
|
envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
|
|
|
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",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
|