|
@@ -12,51 +12,51 @@ THREE.Vector4=function(a,b,f,d){this.x=a||0;this.y=b||0;this.z=f||0;this.w=d||1}
|
|
THREE.Vector4.prototype={set:function(a,b,f,d){this.x=a;this.y=b;this.z=f;this.w=d;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;
|
|
THREE.Vector4.prototype={set:function(a,b,f,d){this.x=a;this.y=b;this.z=f;this.w=d;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+")"}};
|
|
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=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
|
|
-THREE.Ray.prototype={intersectScene:function(a){var b,f,d=a.objects,i=[];a=0;for(b=d.length;a<b;a++){f=d[a];if(f instanceof THREE.Mesh)i=i.concat(this.intersectObject(f))}i.sort(function(k,p){return k.distance-p.distance});return i},intersectObject:function(a){function b(Q,t,U,B){B=B.clone().subSelf(t);U=U.clone().subSelf(t);var L=Q.clone().subSelf(t);Q=B.dot(B);t=B.dot(U);B=B.dot(L);var N=U.dot(U);U=U.dot(L);L=1/(Q*N-t*t);N=(N*B-t*U)*L;Q=(Q*U-t*B)*L;return N>0&&Q>0&&N+Q<1}var f,d,i,k,p,l,o,z,c,C,
|
|
|
|
-w,v=a.geometry,J=v.vertices,S=[];f=0;for(d=v.faces.length;f<d;f++){i=v.faces[f];C=this.origin.clone();w=this.direction.clone();k=a.matrix.multiplyVector3(J[i.a].position.clone());p=a.matrix.multiplyVector3(J[i.b].position.clone());l=a.matrix.multiplyVector3(J[i.c].position.clone());o=i instanceof THREE.Face4?a.matrix.multiplyVector3(J[i.d].position.clone()):null;z=a.rotationMatrix.multiplyVector3(i.normal.clone());c=w.dot(z);if(c<0){z=z.dot((new THREE.Vector3).sub(k,C))/c;C=C.addSelf(w.multiplyScalar(z));
|
|
|
|
-if(i instanceof THREE.Face3){if(b(C,k,p,l)){i={distance:this.origin.distanceTo(C),point:C,face:i,object:a};S.push(i)}}else if(i instanceof THREE.Face4)if(b(C,k,p,o)||b(C,p,l,o)){i={distance:this.origin.distanceTo(C),point:C,face:i,object:a};S.push(i)}}}return S}};
|
|
|
|
-THREE.Rectangle=function(){function a(){k=d-b;p=i-f}var b,f,d,i,k,p,l=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return k};this.getHeight=function(){return p};this.getLeft=function(){return b};this.getTop=function(){return f};this.getRight=function(){return d};this.getBottom=function(){return i};this.set=function(o,z,c,C){l=false;b=o;f=z;d=c;i=C;a()};this.addPoint=function(o,z){if(l){l=false;b=o;f=z;d=o;i=z}else{b=b<o?b:o;f=f<z?f:z;d=d>o?d:o;i=i>z?
|
|
|
|
-i:z}a()};this.add3Points=function(o,z,c,C,w,v){if(l){l=false;b=o<c?o<w?o:w:c<w?c:w;f=z<C?z<v?z:v:C<v?C:v;d=o>c?o>w?o:w:c>w?c:w;i=z>C?z>v?z:v:C>v?C:v}else{b=o<c?o<w?o<b?o:b:w<b?w:b:c<w?c<b?c:b:w<b?w:b;f=z<C?z<v?z<f?z:f:v<f?v:f:C<v?C<f?C:f:v<f?v:f;d=o>c?o>w?o>d?o:d:w>d?w:d:c>w?c>d?c:d:w>d?w:d;i=z>C?z>v?z>i?z:i:v>i?v:i:C>v?C>i?C:i:v>i?v:i}a()};this.addRectangle=function(o){if(l){l=false;b=o.getLeft();f=o.getTop();d=o.getRight();i=o.getBottom()}else{b=b<o.getLeft()?b:o.getLeft();f=f<o.getTop()?f:o.getTop();
|
|
|
|
-d=d>o.getRight()?d:o.getRight();i=i>o.getBottom()?i:o.getBottom()}a()};this.inflate=function(o){b-=o;f-=o;d+=o;i+=o;a()};this.minSelf=function(o){b=b>o.getLeft()?b:o.getLeft();f=f>o.getTop()?f:o.getTop();d=d<o.getRight()?d:o.getRight();i=i<o.getBottom()?i:o.getBottom();a()};this.instersects=function(o){return Math.min(d,o.getRight())-Math.max(b,o.getLeft())>=0&&Math.min(i,o.getBottom())-Math.max(f,o.getTop())>=0};this.empty=function(){l=true;i=d=f=b=0;a()};this.isEmpty=function(){return l};this.toString=
|
|
|
|
-function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+f+", bottom: "+i+", width: "+k+", 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,d,i,k,p,l,o,z,c,C,w,v,J,S){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=i||0;this.n22=k||1;this.n23=p||0;this.n24=l||0;this.n31=o||0;this.n32=z||0;this.n33=c||1;this.n34=C||0;this.n41=w||0;this.n42=v||0;this.n43=J||0;this.n44=S||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,d,i,k,p,l,o,z,c,C,w,v,J,S){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=i;this.n22=k;this.n23=p;this.n24=l;this.n31=o;this.n32=z;this.n33=c;this.n34=C;this.n41=w;this.n42=v;this.n43=J;this.n44=S;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 d=new THREE.Vector3,i=new THREE.Vector3,k=new THREE.Vector3;k.sub(a,b).normalize();d.cross(f,k).normalize();i.cross(k,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=i.x;this.n22=i.y;this.n23=i.z;this.n24=-i.dot(a);this.n31=k.x;
|
|
|
|
-this.n32=k.y;this.n33=k.z;this.n34=-k.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,d=a.z,i=1/(this.n41*b+this.n42*f+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*d+this.n14)*i;a.y=(this.n21*b+this.n22*f+this.n23*d+this.n24)*i;a.z=(this.n31*b+this.n32*f+this.n33*d+this.n34)*i;return a},multiplyVector4:function(a){var b=a.x,f=a.y,d=a.z,i=a.w;a.x=this.n11*b+this.n12*f+this.n13*d+this.n14*i;a.y=this.n21*b+this.n22*f+this.n23*d+this.n24*
|
|
|
|
-i;a.z=this.n31*b+this.n32*f+this.n33*d+this.n34*i;a.w=this.n41*b+this.n42*f+this.n43*d+this.n44*i;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,d=a.n12,i=a.n13,k=a.n14,p=a.n21,l=a.n22,o=a.n23,z=a.n24,c=a.n31,C=a.n32,
|
|
|
|
-w=a.n33,v=a.n34,J=a.n41,S=a.n42,Q=a.n43,t=a.n44,U=b.n11,B=b.n12,L=b.n13,N=b.n14,e=b.n21,j=b.n22,g=b.n23,h=b.n24,n=b.n31,m=b.n32,q=b.n33,r=b.n34,y=b.n41,K=b.n42,F=b.n43,E=b.n44;this.n11=f*U+d*e+i*n+k*y;this.n12=f*B+d*j+i*m+k*K;this.n13=f*L+d*g+i*q+k*F;this.n14=f*N+d*h+i*r+k*E;this.n21=p*U+l*e+o*n+z*y;this.n22=p*B+l*j+o*m+z*K;this.n23=p*L+l*g+o*q+z*F;this.n24=p*N+l*h+o*r+z*E;this.n31=c*U+C*e+w*n+v*y;this.n32=c*B+C*j+w*m+v*K;this.n33=c*L+C*g+w*q+v*F;this.n34=c*N+C*h+w*r+v*E;this.n41=J*U+S*e+Q*n+t*y;
|
|
|
|
-this.n42=J*B+S*j+Q*m+t*K;this.n43=J*L+S*g+Q*q+t*F;this.n44=J*N+S*h+Q*r+t*E;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,i=this.n14,k=this.n21,p=this.n22,l=this.n23,o=this.n24,z=this.n31,c=this.n32,C=this.n33,w=this.n34,v=this.n41,J=this.n42,S=this.n43,Q=this.n44,t=a.n11,U=a.n21,B=a.n31,L=a.n41,N=a.n12,e=a.n22,j=a.n32,g=a.n42,h=a.n13,n=a.n23,m=a.n33,q=a.n43,r=a.n14,y=a.n24,K=a.n34;a=a.n44;this.n11=b*t+f*U+d*B+i*L;this.n12=b*N+f*e+d*j+i*g;this.n13=b*h+f*n+d*m+i*q;this.n14=
|
|
|
|
-b*r+f*y+d*K+i*a;this.n21=k*t+p*U+l*B+o*L;this.n22=k*N+p*e+l*j+o*g;this.n23=k*h+p*n+l*m+o*q;this.n24=k*r+p*y+l*K+o*a;this.n31=z*t+c*U+C*B+w*L;this.n32=z*N+c*e+C*j+w*g;this.n33=z*h+c*n+C*m+w*q;this.n34=z*r+c*y+C*K+w*a;this.n41=v*t+J*U+S*B+Q*L;this.n42=v*N+J*e+S*j+Q*g;this.n43=v*h+J*n+S*m+Q*q;this.n44=v*r+J*y+S*K+Q*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,d=a.objects,h=[];a=0;for(b=d.length;a<b;a++){f=d[a];if(f instanceof THREE.Mesh)h=h.concat(this.intersectObject(f))}h.sort(function(m,q){return m.distance-q.distance});return h},intersectObject:function(a){function b(R,s,O,B){B=B.clone().subSelf(s);O=O.clone().subSelf(s);var J=R.clone().subSelf(s);R=B.dot(B);s=B.dot(O);B=B.dot(J);var M=O.dot(O);O=O.dot(J);J=1/(R*M-s*s);M=(M*B-s*O)*J;R=(R*O-s*B)*J;return M>0&&R>0&&M+R<1}var f,d,h,m,q,t,n,o,c,D,
|
|
|
|
+x,z=a.geometry,P=z.vertices,T=[];f=0;for(d=z.faces.length;f<d;f++){h=z.faces[f];D=this.origin.clone();x=this.direction.clone();m=a.matrix.multiplyVector3(P[h.a].position.clone());q=a.matrix.multiplyVector3(P[h.b].position.clone());t=a.matrix.multiplyVector3(P[h.c].position.clone());n=h instanceof THREE.Face4?a.matrix.multiplyVector3(P[h.d].position.clone()):null;o=a.rotationMatrix.multiplyVector3(h.normal.clone());c=x.dot(o);if(c<0){o=o.dot((new THREE.Vector3).sub(m,D))/c;D=D.addSelf(x.multiplyScalar(o));
|
|
|
|
+if(h instanceof THREE.Face3){if(b(D,m,q,t)){h={distance:this.origin.distanceTo(D),point:D,face:h,object:a};T.push(h)}}else if(h instanceof THREE.Face4)if(b(D,m,q,n)||b(D,q,t,n)){h={distance:this.origin.distanceTo(D),point:D,face:h,object:a};T.push(h)}}}return T}};
|
|
|
|
+THREE.Rectangle=function(){function a(){m=d-b;q=h-f}var b,f,d,h,m,q,t=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return m};this.getHeight=function(){return q};this.getLeft=function(){return b};this.getTop=function(){return f};this.getRight=function(){return d};this.getBottom=function(){return h};this.set=function(n,o,c,D){t=false;b=n;f=o;d=c;h=D;a()};this.addPoint=function(n,o){if(t){t=false;b=n;f=o;d=n;h=o}else{b=b<n?b:n;f=f<o?f:o;d=d>n?d:n;h=h>o?
|
|
|
|
+h:o}a()};this.add3Points=function(n,o,c,D,x,z){if(t){t=false;b=n<c?n<x?n:x:c<x?c:x;f=o<D?o<z?o:z:D<z?D:z;d=n>c?n>x?n:x:c>x?c:x;h=o>D?o>z?o:z:D>z?D:z}else{b=n<c?n<x?n<b?n:b:x<b?x:b:c<x?c<b?c:b:x<b?x:b;f=o<D?o<z?o<f?o:f:z<f?z:f:D<z?D<f?D:f:z<f?z:f;d=n>c?n>x?n>d?n:d:x>d?x:d:c>x?c>d?c:d:x>d?x:d;h=o>D?o>z?o>h?o:h:z>h?z:h:D>z?D>h?D:h:z>h?z:h}a()};this.addRectangle=function(n){if(t){t=false;b=n.getLeft();f=n.getTop();d=n.getRight();h=n.getBottom()}else{b=b<n.getLeft()?b:n.getLeft();f=f<n.getTop()?f:n.getTop();
|
|
|
|
+d=d>n.getRight()?d:n.getRight();h=h>n.getBottom()?h:n.getBottom()}a()};this.inflate=function(n){b-=n;f-=n;d+=n;h+=n;a()};this.minSelf=function(n){b=b>n.getLeft()?b:n.getLeft();f=f>n.getTop()?f:n.getTop();d=d<n.getRight()?d:n.getRight();h=h<n.getBottom()?h:n.getBottom();a()};this.instersects=function(n){return Math.min(d,n.getRight())-Math.max(b,n.getLeft())>=0&&Math.min(h,n.getBottom())-Math.max(f,n.getTop())>=0};this.empty=function(){t=true;h=d=f=b=0;a()};this.isEmpty=function(){return t};this.toString=
|
|
|
|
+function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+f+", bottom: "+h+", width: "+m+", height: "+q+" )"}};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,d,h,m,q,t,n,o,c,D,x,z,P,T){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=h||0;this.n22=m||1;this.n23=q||0;this.n24=t||0;this.n31=n||0;this.n32=o||0;this.n33=c||1;this.n34=D||0;this.n41=x||0;this.n42=z||0;this.n43=P||0;this.n44=T||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,d,h,m,q,t,n,o,c,D,x,z,P,T){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=h;this.n22=m;this.n23=q;this.n24=t;this.n31=n;this.n32=o;this.n33=c;this.n34=D;this.n41=x;this.n42=z;this.n43=P;this.n44=T;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
|
|
|
|
+a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,f){var d=new THREE.Vector3,h=new THREE.Vector3,m=new THREE.Vector3;m.sub(a,b).normalize();d.cross(f,m).normalize();h.cross(m,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);this.n31=m.x;
|
|
|
|
+this.n32=m.y;this.n33=m.z;this.n34=-m.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,d=a.z,h=1/(this.n41*b+this.n42*f+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*d+this.n14)*h;a.y=(this.n21*b+this.n22*f+this.n23*d+this.n24)*h;a.z=(this.n31*b+this.n32*f+this.n33*d+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,f=a.y,d=a.z,h=a.w;a.x=this.n11*b+this.n12*f+this.n13*d+this.n14*h;a.y=this.n21*b+this.n22*f+this.n23*d+this.n24*
|
|
|
|
+h;a.z=this.n31*b+this.n32*f+this.n33*d+this.n34*h;a.w=this.n41*b+this.n42*f+this.n43*d+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,d=a.n12,h=a.n13,m=a.n14,q=a.n21,t=a.n22,n=a.n23,o=a.n24,c=a.n31,D=a.n32,
|
|
|
|
+x=a.n33,z=a.n34,P=a.n41,T=a.n42,R=a.n43,s=a.n44,O=b.n11,B=b.n12,J=b.n13,M=b.n14,e=b.n21,i=b.n22,g=b.n23,k=b.n24,j=b.n31,l=b.n32,p=b.n33,r=b.n34,w=b.n41,G=b.n42,F=b.n43,E=b.n44;this.n11=f*O+d*e+h*j+m*w;this.n12=f*B+d*i+h*l+m*G;this.n13=f*J+d*g+h*p+m*F;this.n14=f*M+d*k+h*r+m*E;this.n21=q*O+t*e+n*j+o*w;this.n22=q*B+t*i+n*l+o*G;this.n23=q*J+t*g+n*p+o*F;this.n24=q*M+t*k+n*r+o*E;this.n31=c*O+D*e+x*j+z*w;this.n32=c*B+D*i+x*l+z*G;this.n33=c*J+D*g+x*p+z*F;this.n34=c*M+D*k+x*r+z*E;this.n41=P*O+T*e+R*j+s*w;
|
|
|
|
+this.n42=P*B+T*i+R*l+s*G;this.n43=P*J+T*g+R*p+s*F;this.n44=P*M+T*k+R*r+s*E;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,h=this.n14,m=this.n21,q=this.n22,t=this.n23,n=this.n24,o=this.n31,c=this.n32,D=this.n33,x=this.n34,z=this.n41,P=this.n42,T=this.n43,R=this.n44,s=a.n11,O=a.n21,B=a.n31,J=a.n41,M=a.n12,e=a.n22,i=a.n32,g=a.n42,k=a.n13,j=a.n23,l=a.n33,p=a.n43,r=a.n14,w=a.n24,G=a.n34;a=a.n44;this.n11=b*s+f*O+d*B+h*J;this.n12=b*M+f*e+d*i+h*g;this.n13=b*k+f*j+d*l+h*p;this.n14=
|
|
|
|
+b*r+f*w+d*G+h*a;this.n21=m*s+q*O+t*B+n*J;this.n22=m*M+q*e+t*i+n*g;this.n23=m*k+q*j+t*l+n*p;this.n24=m*r+q*w+t*G+n*a;this.n31=o*s+c*O+D*B+x*J;this.n32=o*M+c*e+D*i+x*g;this.n33=o*k+c*j+D*l+x*p;this.n34=o*r+c*w+D*G+x*a;this.n41=z*s+P*O+T*B+R*J;this.n42=z*M+P*e+T*i+R*g;this.n43=z*k+P*j+T*l+R*p;this.n44=z*r+P*w+T*G+R*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*
|
|
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,d){var i=b[f];b[f]=b[d];
|
|
|
|
-b[d]=i}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,d){var h=b[f];b[f]=b[d];
|
|
|
|
+b[d]=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.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 d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=f;return d};
|
|
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 d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=f;return d};
|
|
THREE.Matrix4.scaleMatrix=function(a,b,f){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=f;return d};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.scaleMatrix=function(a,b,f){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=f;return d};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,d=Math.cos(b),i=Math.sin(b),k=1-d,p=a.x,l=a.y,o=a.z;f.n11=k*p*p+d;f.n12=k*p*l-i*o;f.n13=k*p*o+i*l;f.n21=k*p*l+i*o;f.n22=k*l*l+d;f.n23=k*l*o-i*p;f.n31=k*p*o-i*l;f.n32=k*l*o+i*p;f.n33=k*o*o+d;return f};
|
|
|
|
|
|
+THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var f=new THREE.Matrix4,d=Math.cos(b),h=Math.sin(b),m=1-d,q=a.x,t=a.y,n=a.z;f.n11=m*q*q+d;f.n12=m*q*t-h*n;f.n13=m*q*n+h*t;f.n21=m*q*t+h*n;f.n22=m*t*t+d;f.n23=m*t*n-h*q;f.n31=m*q*n-h*t;f.n32=m*t*n+h*q;f.n33=m*n*n+d;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*
|
|
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.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.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};
|
|
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],d=-b[10]*b[1]+b[2]*b[9],i=b[6]*b[1]-b[2]*b[5],k=-b[10]*b[4]+b[6]*b[8],p=b[10]*b[0]-b[2]*b[8],l=-b[6]*b[0]+b[2]*b[4],o=b[9]*b[4]-b[5]*b[8],z=-b[9]*b[0]+b[1]*b[8],c=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*k+b[2]*o;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*d;a.m[2]=b*i;a.m[3]=b*k;a.m[4]=b*p;a.m[5]=b*l;a.m[6]=b*o;a.m[7]=b*z;a.m[8]=b*c;return a};
|
|
|
|
-THREE.Matrix4.makeFrustum=function(a,b,f,d,i,k){var p,l,o;p=new THREE.Matrix4;l=2*i/(b-a);o=2*i/(d-f);a=(b+a)/(b-a);f=(d+f)/(d-f);d=-(k+i)/(k-i);i=-2*k*i/(k-i);p.n11=l;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=o;p.n23=f;p.n24=0;p.n31=0;p.n32=0;p.n33=d;p.n34=i;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,b,f,d){var i;a=f*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*b,a*b,i,a,f,d)};
|
|
|
|
-THREE.Matrix4.makeOrtho=function(a,b,f,d,i,k){var p,l,o,z;p=new THREE.Matrix4;l=b-a;o=f-d;z=k-i;a=(b+a)/l;f=(f+d)/o;i=(k+i)/z;p.n11=2/l;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/o;p.n23=0;p.n24=-f;p.n31=0;p.n32=0;p.n33=-2/z;p.n34=-i;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],d=-b[10]*b[1]+b[2]*b[9],h=b[6]*b[1]-b[2]*b[5],m=-b[10]*b[4]+b[6]*b[8],q=b[10]*b[0]-b[2]*b[8],t=-b[6]*b[0]+b[2]*b[4],n=b[9]*b[4]-b[5]*b[8],o=-b[9]*b[0]+b[1]*b[8],c=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*m+b[2]*n;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*d;a.m[2]=b*h;a.m[3]=b*m;a.m[4]=b*q;a.m[5]=b*t;a.m[6]=b*n;a.m[7]=b*o;a.m[8]=b*c;return a};
|
|
|
|
+THREE.Matrix4.makeFrustum=function(a,b,f,d,h,m){var q,t,n;q=new THREE.Matrix4;t=2*h/(b-a);n=2*h/(d-f);a=(b+a)/(b-a);f=(d+f)/(d-f);d=-(m+h)/(m-h);h=-2*m*h/(m-h);q.n11=t;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=n;q.n23=f;q.n24=0;q.n31=0;q.n32=0;q.n33=d;q.n34=h;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,b,f,d){var h;a=f*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,f,d)};
|
|
|
|
+THREE.Matrix4.makeOrtho=function(a,b,f,d,h,m){var q,t,n,o;q=new THREE.Matrix4;t=b-a;n=f-d;o=m-h;a=(b+a)/t;f=(f+d)/n;h=(m+h)/o;q.n11=2/t;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/n;q.n23=0;q.n24=-f;q.n31=0;q.n32=0;q.n33=-2/o;q.n34=-h;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};
|
|
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.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,d,i){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=i instanceof Array?i:[i]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
|
|
|
|
-THREE.Face4=function(a,b,f,d,i,k){this.a=a;this.b=b;this.c=f;this.d=d;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];this.materials=k instanceof Array?k:[k]};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,d,h){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];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,d,h,m){this.a=a;this.b=b;this.c=f;this.d=d;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=m instanceof Array?m:[m]};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.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);
|
|
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,d,i,k,p,l=new THREE.Vector3,o=new THREE.Vector3;d=0;for(i=this.vertices.length;d<i;d++){k=this.vertices[d];k.normal.set(0,0,0)}d=0;for(i=this.faces.length;d<i;d++){k=this.faces[d];if(a&&k.vertexNormals.length){l.set(0,0,0);b=0;for(f=k.normal.length;b<f;b++)l.addSelf(k.vertexNormals[b]);l.divideScalar(3)}else{b=this.vertices[k.a];f=this.vertices[k.b];p=this.vertices[k.c];l.sub(p.position,
|
|
|
|
-f.position);o.sub(b.position,f.position);l.crossSelf(o)}l.isZero()||l.normalize();k.normal.copy(l)}},computeVertexNormals:function(){var a,b=[],f,d;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(f=this.faces.length;a<f;a++){d=this.faces[a];if(d instanceof THREE.Face3){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal);b[d.d].addSelf(d.normal)}}a=
|
|
|
|
-0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(f=this.faces.length;a<f;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone()}else if(d instanceof THREE.Face4){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone();d.vertexNormals[3]=b[d.d].clone()}}},computeTangents:function(){function a(r,y,K,F,E,I,u){k=r.vertices[y].position;p=r.vertices[K].position;
|
|
|
|
-l=r.vertices[F].position;o=i[E];z=i[I];c=i[u];C=p.x-k.x;w=l.x-k.x;v=p.y-k.y;J=l.y-k.y;S=p.z-k.z;Q=l.z-k.z;t=z.u-o.u;U=c.u-o.u;B=z.v-o.v;L=c.v-o.v;N=1/(t*L-U*B);h.set((L*C-B*w)*N,(L*v-B*J)*N,(L*S-B*Q)*N);n.set((t*w-U*C)*N,(t*J-U*v)*N,(t*Q-U*S)*N);j[y].addSelf(h);j[K].addSelf(h);j[F].addSelf(h);g[y].addSelf(n);g[K].addSelf(n);g[F].addSelf(n)}var b,f,d,i,k,p,l,o,z,c,C,w,v,J,S,Q,t,U,B,L,N,e,j=[],g=[],h=new THREE.Vector3,n=new THREE.Vector3,m=new THREE.Vector3,q=new THREE.Vector3;e=new THREE.Vector3;b=
|
|
|
|
-0;for(f=this.vertices.length;b<f;b++){j[b]=new THREE.Vector3;g[b]=new THREE.Vector3}b=0;for(f=this.faces.length;b<f;b++){d=this.faces[b];i=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c,0,1,2);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c,0,1,2);a(this,d.a,d.b,d.d,0,1,3);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);
|
|
|
|
-this.vertices[d.c].normal.copy(d.vertexNormals[2]);this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(f=this.vertices.length;b<f;b++){e.copy(this.vertices[b].normal);d=j[b];m.copy(d);m.subSelf(e.multiplyScalar(e.dot(d))).normalize();q.cross(this.vertices[b].normal,d);test=q.dot(g[b]);d=test<0?-1:1;this.vertices[b].tangent.set(m.x,m.y,m.z,d)}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],
|
|
|
|
|
|
+f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,f,d,h,m,q,t=new THREE.Vector3,n=new THREE.Vector3;d=0;for(h=this.vertices.length;d<h;d++){m=this.vertices[d];m.normal.set(0,0,0)}d=0;for(h=this.faces.length;d<h;d++){m=this.faces[d];if(a&&m.vertexNormals.length){t.set(0,0,0);b=0;for(f=m.normal.length;b<f;b++)t.addSelf(m.vertexNormals[b]);t.divideScalar(3)}else{b=this.vertices[m.a];f=this.vertices[m.b];q=this.vertices[m.c];t.sub(q.position,
|
|
|
|
+f.position);n.sub(b.position,f.position);t.crossSelf(n)}t.isZero()||t.normalize();m.normal.copy(t)}},computeVertexNormals:function(){var a,b=[],f,d;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(f=this.faces.length;a<f;a++){d=this.faces[a];if(d instanceof THREE.Face3){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal);b[d.d].addSelf(d.normal)}}a=
|
|
|
|
+0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(f=this.faces.length;a<f;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone()}else if(d instanceof THREE.Face4){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone();d.vertexNormals[3]=b[d.d].clone()}}},computeTangents:function(){function a(r,w,G,F,E,H,u){m=r.vertices[w].position;q=r.vertices[G].position;
|
|
|
|
+t=r.vertices[F].position;n=h[E];o=h[H];c=h[u];D=q.x-m.x;x=t.x-m.x;z=q.y-m.y;P=t.y-m.y;T=q.z-m.z;R=t.z-m.z;s=o.u-n.u;O=c.u-n.u;B=o.v-n.v;J=c.v-n.v;M=1/(s*J-O*B);k.set((J*D-B*x)*M,(J*z-B*P)*M,(J*T-B*R)*M);j.set((s*x-O*D)*M,(s*P-O*z)*M,(s*R-O*T)*M);i[w].addSelf(k);i[G].addSelf(k);i[F].addSelf(k);g[w].addSelf(j);g[G].addSelf(j);g[F].addSelf(j)}var b,f,d,h,m,q,t,n,o,c,D,x,z,P,T,R,s,O,B,J,M,e,i=[],g=[],k=new THREE.Vector3,j=new THREE.Vector3,l=new THREE.Vector3,p=new THREE.Vector3;e=new THREE.Vector3;b=
|
|
|
|
+0;for(f=this.vertices.length;b<f;b++){i[b]=new THREE.Vector3;g[b]=new THREE.Vector3}b=0;for(f=this.faces.length;b<f;b++){d=this.faces[b];h=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c,0,1,2);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c,0,1,2);a(this,d.a,d.b,d.d,0,1,3);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);
|
|
|
|
+this.vertices[d.c].normal.copy(d.vertexNormals[2]);this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(f=this.vertices.length;b<f;b++){e.copy(this.vertices[b].normal);d=i[b];l.copy(d);l.subSelf(e.multiplyScalar(e.dot(d))).normalize();p.cross(this.vertices[b].normal,d);test=p.dot(g[b]);d=test<0?-1:1;this.vertices[b].tangent.set(l.x,l.y,l.z,d)}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<
|
|
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(z){var c=[];b=0;for(f=z.length;b<f;b++)z[b]==undefined?c.push("undefined"):c.push(z[b].toString());return c.join("_")}
|
|
|
|
-var b,f,d,i,k,p,l,o={};d=0;for(i=this.faces.length;d<i;d++){k=this.faces[d];materials=k.materials;p=a(materials);if(o[p]==undefined)o[p]={hash:p,counter:0};l=o[p].hash+"_"+o[p].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:materials,vertices:0};k=k instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+k>65535){o[p].counter+=1;l=o[p].hash+"_"+o[p].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:materials,vertices:0}}this.geometryChunks[l].faces.push(d);
|
|
|
|
-this.geometryChunks[l].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
|
|
|
|
-THREE.Camera=function(a,b,f,d){this.fov=a;this.aspect=b;this.near=f;this.far=d;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=null;this.autoUpdateMatrix=true;this.translateX=function(i){i=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(i);i.cross(i.clone(),this.up);this.position.addSelf(i);this.target.position.addSelf(i)};this.translateZ=function(i){i=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(i);
|
|
|
|
-this.position.subSelf(i);this.target.position.subSelf(i)};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();this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};
|
|
|
|
|
|
+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(o){var c=[];b=0;for(f=o.length;b<f;b++)o[b]==undefined?c.push("undefined"):c.push(o[b].toString());return c.join("_")}
|
|
|
|
+var b,f,d,h,m,q,t,n={};d=0;for(h=this.faces.length;d<h;d++){m=this.faces[d];materials=m.materials;q=a(materials);if(n[q]==undefined)n[q]={hash:q,counter:0};t=n[q].hash+"_"+n[q].counter;if(this.geometryChunks[t]==undefined)this.geometryChunks[t]={faces:[],materials:materials,vertices:0};m=m instanceof THREE.Face3?3:4;if(this.geometryChunks[t].vertices+m>65535){n[q].counter+=1;t=n[q].hash+"_"+n[q].counter;if(this.geometryChunks[t]==undefined)this.geometryChunks[t]={faces:[],materials:materials,vertices:0}}this.geometryChunks[t].faces.push(d);
|
|
|
|
+this.geometryChunks[t].vertices+=m}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
|
|
|
|
+THREE.Camera=function(a,b,f,d){this.fov=a;this.aspect=b;this.near=f;this.far=d;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.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.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.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=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};
|
|
@@ -89,101 +89,102 @@ 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=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.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.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,d,i,k){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=k!==undefined?k:THREE.LinearMipMapLinearFilter};
|
|
|
|
|
|
+THREE.Texture=function(a,b,f,d,h,m){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=m!==undefined?m: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.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;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
|
|
THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;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.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.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(j,g){return g.z-j.z}function b(j,g){var h=0,n=1,m=j.z+j.w,q=g.z+g.w,r=-j.z+j.w,y=-g.z+g.w;if(m>=0&&q>=0&&r>=0&&y>=0)return true;else if(m<0&&q<0||r<0&&y<0)return false;else{if(m<0)h=Math.max(h,m/(m-q));else if(q<0)n=Math.min(n,m/(m-q));if(r<0)h=Math.max(h,r/(r-y));else if(y<0)n=Math.min(n,r/(r-y));if(n<h)return false;else{j.lerpSelf(g,h);g.lerpSelf(j,1-n);return true}}}var f,d,i=[],k,p,l,o=[],z,c,C=[],w,v,J=[],S=new THREE.Vector4,Q=new THREE.Vector4,t=new THREE.Matrix4,
|
|
|
|
-U=new THREE.Matrix4,B=[],L=new THREE.Vector4,N=new THREE.Vector4,e;this.projectObjects=function(j,g,h){var n=[],m,q;d=0;t.multiply(g.projectionMatrix,g.matrix);B[0]=new THREE.Vector4(t.n41-t.n11,t.n42-t.n12,t.n43-t.n13,t.n44-t.n14);B[1]=new THREE.Vector4(t.n41+t.n11,t.n42+t.n12,t.n43+t.n13,t.n44+t.n14);B[2]=new THREE.Vector4(t.n41+t.n21,t.n42+t.n22,t.n43+t.n23,t.n44+t.n24);B[3]=new THREE.Vector4(t.n41-t.n21,t.n42-t.n22,t.n43-t.n23,t.n44-t.n24);B[4]=new THREE.Vector4(t.n41-t.n31,t.n42-t.n32,t.n43-
|
|
|
|
-t.n33,t.n44-t.n34);B[5]=new THREE.Vector4(t.n41+t.n31,t.n42+t.n32,t.n43+t.n33,t.n44+t.n34);g=0;for(m=B.length;g<m;g++){q=B[g];q.divideScalar(Math.sqrt(q.x*q.x+q.y*q.y+q.z*q.z))}m=j.objects;j=0;for(g=m.length;j<g;j++){q=m[j];var r;if(!(r=!q.visible)){if(r=q instanceof THREE.Mesh){a:{r=void 0;for(var y=q.position,K=-q.geometry.boundingSphere.radius*Math.max(q.scale.x,Math.max(q.scale.y,q.scale.z)),F=0;F<6;F++){r=B[F].x*y.x+B[F].y*y.y+B[F].z*y.z+B[F].w;if(r<=K){r=false;break a}}r=true}r=!r}r=r}if(!r){f=
|
|
|
|
-i[d]=i[d]||new THREE.RenderableObject;S.copy(q.position);t.multiplyVector3(S);f.object=q;f.z=S.z;n.push(f);d++}}h&&n.sort(a);return n};this.projectScene=function(j,g,h){var n=[],m=g.near,q=g.far,r,y,K,F,E,I,u,R,T,G,x,H,V,D,O,Y;l=c=v=0;g.autoUpdateMatrix&&g.updateMatrix();t.multiply(g.projectionMatrix,g.matrix);I=this.projectObjects(j,g,true);j=0;for(r=I.length;j<r;j++){u=I[j].object;if(u.visible){u.autoUpdateMatrix&&u.updateMatrix();R=u.matrix;T=u.rotationMatrix;G=u.materials;x=u.overdraw;if(u instanceof
|
|
|
|
-THREE.Mesh){H=u.geometry;V=H.vertices;y=0;for(K=V.length;y<K;y++){D=V[y];D.positionWorld.copy(D.position);R.multiplyVector3(D.positionWorld);F=D.positionScreen;F.copy(D.positionWorld);t.multiplyVector4(F);F.x/=F.w;F.y/=F.w;D.__visible=F.z>m&&F.z<q}H=H.faces;y=0;for(K=H.length;y<K;y++){D=H[y];if(D instanceof THREE.Face3){F=V[D.a];E=V[D.b];O=V[D.c];if(F.__visible&&E.__visible&&O.__visible)if(u.doubleSided||u.flipSided!=(O.positionScreen.x-F.positionScreen.x)*(E.positionScreen.y-F.positionScreen.y)-
|
|
|
|
-(O.positionScreen.y-F.positionScreen.y)*(E.positionScreen.x-F.positionScreen.x)<0){k=o[l]=o[l]||new THREE.RenderableFace3;k.v1.positionWorld.copy(F.positionWorld);k.v2.positionWorld.copy(E.positionWorld);k.v3.positionWorld.copy(O.positionWorld);k.v1.positionScreen.copy(F.positionScreen);k.v2.positionScreen.copy(E.positionScreen);k.v3.positionScreen.copy(O.positionScreen);k.normalWorld.copy(D.normal);T.multiplyVector3(k.normalWorld);k.centroidWorld.copy(D.centroid);R.multiplyVector3(k.centroidWorld);
|
|
|
|
-k.centroidScreen.copy(k.centroidWorld);t.multiplyVector3(k.centroidScreen);O=D.vertexNormals;e=k.vertexNormalsWorld;F=0;for(E=O.length;F<E;F++){Y=e[F]=e[F]||new THREE.Vector3;Y.copy(O[F]);T.multiplyVector3(Y)}k.z=k.centroidScreen.z;k.meshMaterials=G;k.faceMaterials=D.materials;k.overdraw=x;if(u.geometry.uvs[y]){k.uvs[0]=u.geometry.uvs[y][0];k.uvs[1]=u.geometry.uvs[y][1];k.uvs[2]=u.geometry.uvs[y][2]}n.push(k);l++}}else if(D instanceof THREE.Face4){F=V[D.a];E=V[D.b];O=V[D.c];Y=V[D.d];if(F.__visible&&
|
|
|
|
-E.__visible&&O.__visible&&Y.__visible)if(u.doubleSided||u.flipSided!=((Y.positionScreen.x-F.positionScreen.x)*(E.positionScreen.y-F.positionScreen.y)-(Y.positionScreen.y-F.positionScreen.y)*(E.positionScreen.x-F.positionScreen.x)<0||(E.positionScreen.x-O.positionScreen.x)*(Y.positionScreen.y-O.positionScreen.y)-(E.positionScreen.y-O.positionScreen.y)*(Y.positionScreen.x-O.positionScreen.x)<0)){k=o[l]=o[l]||new THREE.RenderableFace3;k.v1.positionWorld.copy(F.positionWorld);k.v2.positionWorld.copy(E.positionWorld);
|
|
|
|
-k.v3.positionWorld.copy(Y.positionWorld);k.v1.positionScreen.copy(F.positionScreen);k.v2.positionScreen.copy(E.positionScreen);k.v3.positionScreen.copy(Y.positionScreen);k.normalWorld.copy(D.normal);T.multiplyVector3(k.normalWorld);k.centroidWorld.copy(D.centroid);R.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);t.multiplyVector3(k.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterials=G;k.faceMaterials=D.materials;k.overdraw=x;if(u.geometry.uvs[y]){k.uvs[0]=u.geometry.uvs[y][0];
|
|
|
|
-k.uvs[1]=u.geometry.uvs[y][1];k.uvs[2]=u.geometry.uvs[y][3]}n.push(k);l++;p=o[l]=o[l]||new THREE.RenderableFace3;p.v1.positionWorld.copy(E.positionWorld);p.v2.positionWorld.copy(O.positionWorld);p.v3.positionWorld.copy(Y.positionWorld);p.v1.positionScreen.copy(E.positionScreen);p.v2.positionScreen.copy(O.positionScreen);p.v3.positionScreen.copy(Y.positionScreen);p.normalWorld.copy(k.normalWorld);p.centroidWorld.copy(k.centroidWorld);p.centroidScreen.copy(k.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterials=
|
|
|
|
-G;p.faceMaterials=D.materials;p.overdraw=x;if(u.geometry.uvs[y]){p.uvs[0]=u.geometry.uvs[y][1];p.uvs[1]=u.geometry.uvs[y][2];p.uvs[2]=u.geometry.uvs[y][3]}n.push(p);l++}}}}else if(u instanceof THREE.Line){U.multiply(t,R);V=u.geometry.vertices;D=V[0];D.positionScreen.copy(D.position);U.multiplyVector4(D.positionScreen);y=1;for(K=V.length;y<K;y++){F=V[y];F.positionScreen.copy(F.position);U.multiplyVector4(F.positionScreen);E=V[y-1];L.copy(F.positionScreen);N.copy(E.positionScreen);if(b(L,N)){L.multiplyScalar(1/
|
|
|
|
-L.w);N.multiplyScalar(1/N.w);z=C[c]=C[c]||new THREE.RenderableLine;z.v1.positionScreen.copy(L);z.v2.positionScreen.copy(N);z.z=Math.max(L.z,N.z);z.materials=u.materials;n.push(z);c++}}}else if(u instanceof THREE.Particle){Q.set(u.position.x,u.position.y,u.position.z,1);t.multiplyVector4(Q);Q.z/=Q.w;if(Q.z>0&&Q.z<1){w=J[v]=J[v]||new THREE.RenderableParticle;w.x=Q.x/Q.w;w.y=Q.y/Q.w;w.z=Q.z;w.rotation=u.rotation.z;w.scale.x=u.scale.x*Math.abs(w.x-(Q.x+g.projectionMatrix.n11)/(Q.w+g.projectionMatrix.n14));
|
|
|
|
-w.scale.y=u.scale.y*Math.abs(w.y-(Q.y+g.projectionMatrix.n22)/(Q.w+g.projectionMatrix.n24));w.materials=u.materials;n.push(w);v++}}}}h&&n.sort(a);return n};this.unprojectVector=function(j,g){var h=new THREE.Matrix4;h.multiply(THREE.Matrix4.makeInvert(g.matrix),THREE.Matrix4.makeInvert(g.projectionMatrix));h.multiplyVector3(j);return j}};
|
|
|
|
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,i,k;this.domElement=document.createElement("div");this.setSize=function(p,l){f=p;d=l;i=f/2;k=d/2};this.render=function(p,l){var o,z,c,C,w,v,J,S;a=b.projectScene(p,l);o=0;for(z=a.length;o<z;o++){w=a[o];if(w instanceof THREE.RenderableParticle){J=w.x*i+i;S=w.y*k+k;c=0;for(C=w.material.length;c<C;c++){v=w.material[c];if(v instanceof THREE.ParticleDOMMaterial){v=v.domElement;v.style.left=J+"px";v.style.top=S+"px"}}}}}};
|
|
|
|
-THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,f=document.createElement("canvas"),d,i,k,p,l=f.getContext("2d"),o=1,z=0,c=null,C=null,w=1,v,J,S,Q,t,U,B,L,N,e=new THREE.Color,j=new THREE.Color,g=new THREE.Color,h=new THREE.Color,n=new THREE.Color,m,q,r,y,K,F,E,I,u,R=new THREE.Rectangle,T=new THREE.Rectangle,G=new THREE.Rectangle,x=false,H=new THREE.Color,V=new THREE.Color,D=new THREE.Color,O=new THREE.Color,Y=Math.PI*2,Z=new THREE.Vector3,oa,pa,Aa,da,qa,ua,la=16;oa=document.createElement("canvas");
|
|
|
|
-oa.width=oa.height=2;pa=oa.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);Aa=pa.getImageData(0,0,2,2);da=Aa.data;qa=document.createElement("canvas");qa.width=qa.height=la;ua=qa.getContext("2d");ua.translate(-la/2,-la/2);ua.scale(la,la);la--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ga,ma){d=ga;i=ma;k=d/2;p=i/2;f.width=d;f.height=i;R.set(-k,-p,k,p)};this.clear=function(){if(!T.isEmpty()){T.inflate(1);T.minSelf(R);l.clearRect(T.getX(),
|
|
|
|
-T.getY(),T.getWidth(),T.getHeight());T.empty()}};this.render=function(ga,ma){function Ka(s){var W,P,A,M=s.lights;V.setRGB(0,0,0);D.setRGB(0,0,0);O.setRGB(0,0,0);s=0;for(W=M.length;s<W;s++){P=M[s];A=P.color;if(P instanceof THREE.AmbientLight){V.r+=A.r;V.g+=A.g;V.b+=A.b}else if(P instanceof THREE.DirectionalLight){D.r+=A.r;D.g+=A.g;D.b+=A.b}else if(P instanceof THREE.PointLight){O.r+=A.r;O.g+=A.g;O.b+=A.b}}}function va(s,W,P,A){var M,X,aa,ba,ca=s.lights;s=0;for(M=ca.length;s<M;s++){X=ca[s];aa=X.color;
|
|
|
|
-ba=X.intensity;if(X instanceof THREE.DirectionalLight){X=P.dot(X.position)*ba;if(X>0){A.r+=aa.r*X;A.g+=aa.g*X;A.b+=aa.b*X}}else if(X instanceof THREE.PointLight){Z.sub(X.position,W);Z.normalize();X=P.dot(Z)*ba;if(X>0){A.r+=aa.r*X;A.g+=aa.g*X;A.b+=aa.b*X}}}}function La(s,W,P){if(P.opacity!=0){Ba(P.opacity);wa(P.blending);var A,M,X,aa,ba,ca;if(P instanceof THREE.ParticleBasicMaterial){if(P.map){aa=P.map;ba=aa.width>>1;ca=aa.height>>1;M=W.scale.x*k;X=W.scale.y*p;P=M*ba;A=X*ca;G.set(s.x-P,s.y-A,s.x+P,
|
|
|
|
-s.y+A);if(!R.instersects(G))return;l.save();l.translate(s.x,s.y);l.rotate(-W.rotation);l.scale(M,-X);l.translate(-ba,-ca);l.drawImage(aa,0,0);l.restore()}l.beginPath();l.moveTo(s.x-10,s.y);l.lineTo(s.x+10,s.y);l.moveTo(s.x,s.y-10);l.lineTo(s.x,s.y+10);l.closePath();l.strokeStyle="rgb(255,255,0)";l.stroke()}else if(P instanceof THREE.ParticleCircleMaterial){if(x){H.r=V.r+D.r+O.r;H.g=V.g+D.g+O.g;H.b=V.b+D.b+O.b;e.r=P.color.r*H.r;e.g=P.color.g*H.g;e.b=P.color.b*H.b;e.updateStyleString()}else e.__styleString=
|
|
|
|
-P.color.__styleString;P=W.scale.x*k;A=W.scale.y*p;G.set(s.x-P,s.y-A,s.x+P,s.y+A);if(R.instersects(G)){M=e.__styleString;if(C!=M)l.fillStyle=C=M;l.save();l.translate(s.x,s.y);l.rotate(-W.rotation);l.scale(P,A);l.beginPath();l.arc(0,0,1,0,Y,true);l.closePath();l.fill();l.restore()}}}}function Ma(s,W,P,A){if(A.opacity!=0){Ba(A.opacity);wa(A.blending);l.beginPath();l.moveTo(s.positionScreen.x,s.positionScreen.y);l.lineTo(W.positionScreen.x,W.positionScreen.y);l.closePath();if(A instanceof THREE.LineBasicMaterial){e.__styleString=
|
|
|
|
-A.color.__styleString;s=A.linewidth;if(w!=s)l.lineWidth=w=s;s=e.__styleString;if(c!=s)l.strokeStyle=c=s;l.stroke();G.inflate(A.linewidth*2)}}}function Ga(s,W,P,A,M,X){if(M.opacity!=0){Ba(M.opacity);wa(M.blending);Q=s.positionScreen.x;t=s.positionScreen.y;U=W.positionScreen.x;B=W.positionScreen.y;L=P.positionScreen.x;N=P.positionScreen.y;l.beginPath();l.moveTo(Q,t);l.lineTo(U,B);l.lineTo(L,N);l.lineTo(Q,t);l.closePath();if(M instanceof THREE.MeshBasicMaterial)if(M.map)M.map.image.loaded&&M.map.mapping instanceof
|
|
|
|
-THREE.UVMapping&&ra(Q,t,U,B,L,N,M.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);else if(M.env_map){if(M.env_map.image.loaded)if(M.env_map.mapping instanceof THREE.SphericalReflectionMapping){s=ma.matrix;Z.copy(A.vertexNormalsWorld[0]);y=(Z.x*s.n11+Z.y*s.n12+Z.z*s.n13)*0.5+0.5;K=-(Z.x*s.n21+Z.y*s.n22+Z.z*s.n23)*0.5+0.5;Z.copy(A.vertexNormalsWorld[1]);F=(Z.x*s.n11+Z.y*s.n12+Z.z*s.n13)*0.5+0.5;E=-(Z.x*s.n21+Z.y*s.n22+Z.z*s.n23)*0.5+0.5;Z.copy(A.vertexNormalsWorld[2]);I=
|
|
|
|
-(Z.x*s.n11+Z.y*s.n12+Z.z*s.n13)*0.5+0.5;u=-(Z.x*s.n21+Z.y*s.n22+Z.z*s.n23)*0.5+0.5;ra(Q,t,U,B,L,N,M.env_map.image,y,K,F,E,I,u)}}else M.wireframe?xa(M.color.__styleString,M.wireframe_linewidth):ya(M.color.__styleString);else if(M instanceof THREE.MeshLambertMaterial){if(M.map&&!M.wireframe){M.map.mapping instanceof THREE.UVMapping&&ra(Q,t,U,B,L,N,M.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);wa(THREE.SubtractiveBlending)}if(x)if(!M.wireframe&&M.shading==THREE.SmoothShading&&
|
|
|
|
-A.vertexNormalsWorld.length==3){j.r=g.r=h.r=V.r;j.g=g.g=h.g=V.g;j.b=g.b=h.b=V.b;va(X,A.v1.positionWorld,A.vertexNormalsWorld[0],j);va(X,A.v2.positionWorld,A.vertexNormalsWorld[1],g);va(X,A.v3.positionWorld,A.vertexNormalsWorld[2],h);n.r=(g.r+h.r)*0.5;n.g=(g.g+h.g)*0.5;n.b=(g.b+h.b)*0.5;r=Ha(j,g,h,n);ra(Q,t,U,B,L,N,r,0,0,1,0,0,1)}else{H.r=V.r;H.g=V.g;H.b=V.b;va(X,A.centroidWorld,A.normalWorld,H);e.r=M.color.r*H.r;e.g=M.color.g*H.g;e.b=M.color.b*H.b;e.updateStyleString();M.wireframe?xa(e.__styleString,
|
|
|
|
-M.wireframe_linewidth):ya(e.__styleString)}else M.wireframe?xa(M.color.__styleString,M.wireframe_linewidth):ya(M.color.__styleString)}else if(M instanceof THREE.MeshDepthMaterial){m=ma.near;q=ma.far;j.r=j.g=j.b=1-Ca(s.positionScreen.z,m,q);g.r=g.g=g.b=1-Ca(W.positionScreen.z,m,q);h.r=h.g=h.b=1-Ca(P.positionScreen.z,m,q);n.r=(g.r+h.r)*0.5;n.g=(g.g+h.g)*0.5;n.b=(g.b+h.b)*0.5;r=Ha(j,g,h,n);ra(Q,t,U,B,L,N,r,0,0,1,0,0,1)}else if(M instanceof THREE.MeshNormalMaterial){e.r=Da(A.normalWorld.x);e.g=Da(A.normalWorld.y);
|
|
|
|
-e.b=Da(A.normalWorld.z);e.updateStyleString();M.wireframe?xa(e.__styleString,M.wireframe_linewidth):ya(e.__styleString)}}}function xa(s,W){if(c!=s)l.strokeStyle=c=s;if(w!=W)l.lineWidth=w=W;l.stroke();G.inflate(W*2)}function ya(s){if(C!=s)l.fillStyle=C=s;l.fill()}function ra(s,W,P,A,M,X,aa,ba,ca,ha,ea,ia,sa){var ka,ja;ka=aa.width-1;ja=aa.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;sa*=ja;P-=s;A-=W;M-=s;X-=W;ha-=ba;ea-=ca;ia-=ba;sa-=ca;ja=1/(ha*sa-ia*ea);ka=(sa*P-ea*M)*ja;ea=(sa*A-ea*X)*ja;P=(ha*M-
|
|
|
|
-ia*P)*ja;A=(ha*X-ia*A)*ja;s=s-ka*ba-P*ca;W=W-ea*ba-A*ca;l.save();l.transform(ka,ea,P,A,s,W);l.clip();l.drawImage(aa,0,0);l.restore()}function Ba(s){if(o!=s)l.globalAlpha=o=s}function wa(s){if(z!=s){switch(s){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}z=s}}function Ha(s,W,P,A){var M=~~(s.r*255),X=~~(s.g*255);s=~~(s.b*255);var aa=~~(W.r*
|
|
|
|
-255),ba=~~(W.g*255);W=~~(W.b*255);var ca=~~(P.r*255),ha=~~(P.g*255);P=~~(P.b*255);var ea=~~(A.r*255),ia=~~(A.g*255);A=~~(A.b*255);da[0]=M<0?0:M>255?255:M;da[1]=X<0?0:X>255?255:X;da[2]=s<0?0:s>255?255:s;da[4]=aa<0?0:aa>255?255:aa;da[5]=ba<0?0:ba>255?255:ba;da[6]=W<0?0:W>255?255:W;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=P<0?0:P>255?255:P;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=A<0?0:A>255?255:A;pa.putImageData(Aa,0,0);ua.drawImage(oa,0,0);return qa}function Ca(s,
|
|
|
|
-W,P){s=(s-W)/(P-W);return s*s*(3-2*s)}function Da(s){s=(s+1)*0.5;return s<0?0:s>1?1:s}function Ea(s,W){var P=W.x-s.x,A=W.y-s.y,M=1/Math.sqrt(P*P+A*A);P*=M;A*=M;W.x+=P;W.y+=A;s.x-=P;s.y-=A}var za,Ia,$,fa,na,Fa,Ja,ta;l.setTransform(1,0,0,-1,k,p);this.autoClear&&this.clear();a=b.projectScene(ga,ma,this.sortElements);l.fillStyle="rgba( 0, 255, 255, 0.5 )";l.fillRect(R.getX(),R.getY(),R.getWidth(),R.getHeight());(x=ga.lights.length>0)&&Ka(ga);za=0;for(Ia=a.length;za<Ia;za++){$=a[za];G.empty();if($ instanceof
|
|
|
|
-THREE.RenderableParticle){v=$;v.x*=k;v.y*=p;fa=0;for(na=$.materials.length;fa<na;fa++)La(v,$,$.materials[fa],ga)}else if($ instanceof THREE.RenderableLine){v=$.v1;J=$.v2;v.positionScreen.x*=k;v.positionScreen.y*=p;J.positionScreen.x*=k;J.positionScreen.y*=p;G.addPoint(v.positionScreen.x,v.positionScreen.y);G.addPoint(J.positionScreen.x,J.positionScreen.y);if(R.instersects(G)){fa=0;for(na=$.materials.length;fa<na;)Ma(v,J,$,$.materials[fa++],ga)}}else if($ instanceof THREE.RenderableFace3){v=$.v1;J=
|
|
|
|
-$.v2;S=$.v3;v.positionScreen.x*=k;v.positionScreen.y*=p;J.positionScreen.x*=k;J.positionScreen.y*=p;S.positionScreen.x*=k;S.positionScreen.y*=p;if($.overdraw){Ea(v.positionScreen,J.positionScreen);Ea(J.positionScreen,S.positionScreen);Ea(S.positionScreen,v.positionScreen)}G.add3Points(v.positionScreen.x,v.positionScreen.y,J.positionScreen.x,J.positionScreen.y,S.positionScreen.x,S.positionScreen.y);if(R.instersects(G)){fa=0;for(na=$.meshMaterials.length;fa<na;){ta=$.meshMaterials[fa++];if(ta instanceof
|
|
|
|
-THREE.MeshFaceMaterial){Fa=0;for(Ja=$.faceMaterials.length;Fa<Ja;)(ta=$.faceMaterials[Fa++])&&Ga(v,J,S,$,ta,ga)}else Ga(v,J,S,$,ta,ga)}}}T.addRectangle(G)}l.lineWidth=1;l.strokeStyle="rgba( 255, 0, 0, 0.5 )";l.strokeRect(T.getX(),T.getY(),T.getWidth(),T.getHeight());l.setTransform(1,0,0,1,0,0)}};
|
|
|
|
-THREE.SVGRenderer=function(){function a(I,u,R){var T,G,x,H;T=0;for(G=I.lights.length;T<G;T++){x=I.lights[T];if(x instanceof THREE.DirectionalLight){H=u.normalWorld.dot(x.position)*x.intensity;if(H>0){R.r+=x.color.r*H;R.g+=x.color.g*H;R.b+=x.color.b*H}}else if(x instanceof THREE.PointLight){h.sub(x.position,u.centroidWorld);h.normalize();H=u.normalWorld.dot(h)*x.intensity;if(H>0){R.r+=x.color.r*H;R.g+=x.color.g*H;R.b+=x.color.b*H}}}}function b(I,u,R,T,G,x){r=d(y++);r.setAttribute("d","M "+I.positionScreen.x+
|
|
|
|
-" "+I.positionScreen.y+" L "+u.positionScreen.x+" "+u.positionScreen.y+" L "+R.positionScreen.x+","+R.positionScreen.y+"z");if(G instanceof THREE.MeshBasicMaterial)B.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshLambertMaterial)if(U){L.r=N.r;L.g=N.g;L.b=N.b;a(x,T,L);B.r=G.color.r*L.r;B.g=G.color.g*L.g;B.b=G.color.b*L.b;B.updateStyleString()}else B.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshDepthMaterial){g=1-G.__2near/(G.__farPlusNear-T.z*G.__farMinusNear);
|
|
|
|
-B.setRGB(g,g,g)}else G instanceof THREE.MeshNormalMaterial&&B.setRGB(i(T.normalWorld.x),i(T.normalWorld.y),i(T.normalWorld.z));G.wireframe?r.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+G.wireframe_linewidth+"; stroke-opacity: "+G.opacity+"; stroke-linecap: "+G.wireframe_linecap+"; stroke-linejoin: "+G.wireframe_linejoin):r.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+G.opacity);l.appendChild(r)}function f(I,u,R,T,G,x,H){r=d(y++);r.setAttribute("d",
|
|
|
|
-"M "+I.positionScreen.x+" "+I.positionScreen.y+" L "+u.positionScreen.x+" "+u.positionScreen.y+" L "+R.positionScreen.x+","+R.positionScreen.y+" L "+T.positionScreen.x+","+T.positionScreen.y+"z");if(x instanceof THREE.MeshBasicMaterial)B.__styleString=x.color.__styleString;else if(x instanceof THREE.MeshLambertMaterial)if(U){L.r=N.r;L.g=N.g;L.b=N.b;a(H,G,L);B.r=x.color.r*L.r;B.g=x.color.g*L.g;B.b=x.color.b*L.b;B.updateStyleString()}else B.__styleString=x.color.__styleString;else if(x instanceof THREE.MeshDepthMaterial){g=
|
|
|
|
-1-x.__2near/(x.__farPlusNear-G.z*x.__farMinusNear);B.setRGB(g,g,g)}else x instanceof THREE.MeshNormalMaterial&&B.setRGB(i(G.normalWorld.x),i(G.normalWorld.y),i(G.normalWorld.z));x.wireframe?r.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+x.wireframe_linewidth+"; stroke-opacity: "+x.opacity+"; stroke-linecap: "+x.wireframe_linecap+"; stroke-linejoin: "+x.wireframe_linejoin):r.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+x.opacity);l.appendChild(r)}
|
|
|
|
-function d(I){if(n[I]==null){n[I]=document.createElementNS("http://www.w3.org/2000/svg","path");E==0&&n[I].setAttribute("shape-rendering","crispEdges");return n[I]}return n[I]}function i(I){return I<0?Math.min((1+I)*0.5,0.5):0.5+Math.min(I*0.5,0.5)}var k=null,p=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,z,c,C,w,v,J,S,Q=new THREE.Rectangle,t=new THREE.Rectangle,U=false,B=new THREE.Color(16777215),L=new THREE.Color(16777215),N=new THREE.Color(0),e=new THREE.Color(0),
|
|
|
|
-j=new THREE.Color(0),g,h=new THREE.Vector3,n=[],m=[],q=[],r,y,K,F,E=1;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(I){switch(I){case "high":E=1;break;case "low":E=0}};this.setSize=function(I,u){o=I;z=u;c=o/2;C=z/2;l.setAttribute("viewBox",-c+" "+-C+" "+o+" "+z);l.setAttribute("width",o);l.setAttribute("height",z);Q.set(-c,-C,c,C)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(I,u){var R,T,
|
|
|
|
-G,x,H,V,D,O;this.autoClear&&this.clear();k=p.projectScene(I,u,this.sortElements);F=K=y=0;if(U=I.lights.length>0){D=I.lights;N.setRGB(0,0,0);e.setRGB(0,0,0);j.setRGB(0,0,0);R=0;for(T=D.length;R<T;R++){G=D[R];x=G.color;if(G instanceof THREE.AmbientLight){N.r+=x.r;N.g+=x.g;N.b+=x.b}else if(G instanceof THREE.DirectionalLight){e.r+=x.r;e.g+=x.g;e.b+=x.b}else if(G instanceof THREE.PointLight){j.r+=x.r;j.g+=x.g;j.b+=x.b}}}R=0;for(T=k.length;R<T;R++){D=k[R];t.empty();if(D instanceof THREE.RenderableParticle){w=
|
|
|
|
-D;w.x*=c;w.y*=-C;G=0;for(x=D.materials.length;G<x;G++)if(O=D.materials[G]){H=w;V=D;O=O;var Y=K++;if(m[Y]==null){m[Y]=document.createElementNS("http://www.w3.org/2000/svg","circle");E==0&&m[Y].setAttribute("shape-rendering","crispEdges")}r=m[Y];r.setAttribute("cx",H.x);r.setAttribute("cy",H.y);r.setAttribute("r",V.scale.x*c);if(O instanceof THREE.ParticleCircleMaterial){if(U){L.r=N.r+e.r+j.r;L.g=N.g+e.g+j.g;L.b=N.b+e.b+j.b;B.r=O.color.r*L.r;B.g=O.color.g*L.g;B.b=O.color.b*L.b;B.updateStyleString()}else B=
|
|
|
|
-O.color;r.setAttribute("style","fill: "+B.__styleString)}l.appendChild(r)}}else if(D instanceof THREE.RenderableLine){w=D.v1;v=D.v2;w.positionScreen.x*=c;w.positionScreen.y*=-C;v.positionScreen.x*=c;v.positionScreen.y*=-C;t.addPoint(w.positionScreen.x,w.positionScreen.y);t.addPoint(v.positionScreen.x,v.positionScreen.y);if(Q.instersects(t)){G=0;for(x=D.materials.length;G<x;)if(O=D.materials[G++]){H=w;V=v;O=O;Y=F++;if(q[Y]==null){q[Y]=document.createElementNS("http://www.w3.org/2000/svg","line");E==
|
|
|
|
-0&&q[Y].setAttribute("shape-rendering","crispEdges")}r=q[Y];r.setAttribute("x1",H.positionScreen.x);r.setAttribute("y1",H.positionScreen.y);r.setAttribute("x2",V.positionScreen.x);r.setAttribute("y2",V.positionScreen.y);if(O instanceof THREE.LineBasicMaterial){B.__styleString=O.color.__styleString;r.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+O.linewidth+"; stroke-opacity: "+O.opacity+"; stroke-linecap: "+O.linecap+"; stroke-linejoin: "+O.linejoin);l.appendChild(r)}}}}else if(D instanceof
|
|
|
|
-THREE.RenderableFace3){w=D.v1;v=D.v2;J=D.v3;w.positionScreen.x*=c;w.positionScreen.y*=-C;v.positionScreen.x*=c;v.positionScreen.y*=-C;J.positionScreen.x*=c;J.positionScreen.y*=-C;t.addPoint(w.positionScreen.x,w.positionScreen.y);t.addPoint(v.positionScreen.x,v.positionScreen.y);t.addPoint(J.positionScreen.x,J.positionScreen.y);if(Q.instersects(t)){G=0;for(x=D.meshMaterials.length;G<x;){O=D.meshMaterials[G++];if(O instanceof THREE.MeshFaceMaterial){H=0;for(V=D.faceMaterials.length;H<V;)(O=D.faceMaterials[H++])&&
|
|
|
|
-b(w,v,J,D,O,I)}else O&&b(w,v,J,D,O,I)}}}else if(D instanceof THREE.RenderableFace4){w=D.v1;v=D.v2;J=D.v3;S=D.v4;w.positionScreen.x*=c;w.positionScreen.y*=-C;v.positionScreen.x*=c;v.positionScreen.y*=-C;J.positionScreen.x*=c;J.positionScreen.y*=-C;S.positionScreen.x*=c;S.positionScreen.y*=-C;t.addPoint(w.positionScreen.x,w.positionScreen.y);t.addPoint(v.positionScreen.x,v.positionScreen.y);t.addPoint(J.positionScreen.x,J.positionScreen.y);t.addPoint(S.positionScreen.x,S.positionScreen.y);if(Q.instersects(t)){G=
|
|
|
|
-0;for(x=D.meshMaterials.length;G<x;){O=D.meshMaterials[G++];if(O instanceof THREE.MeshFaceMaterial){H=0;for(V=D.faceMaterials.length;H<V;)(O=D.faceMaterials[H++])&&f(w,v,J,S,D,O,I)}else O&&f(w,v,J,S,D,O,I)}}}}}};
|
|
|
|
-THREE.WebGLRenderer=function(a){function b(e,j){e.fragment_shader=j.fragment_shader;e.vertex_shader=j.vertex_shader;var g=j.uniforms,h,n,m={};for(h in g){m[h]={};for(n in uniforms[h]){parameter_src=g[h][n];parameter_dst=m[h][n];parameter_dst=parameter_src instanceof THREE.Color||parameter_src instanceof THREE.Vector3||parameter_src instanceof THREE.Texture?parameter_src.clone():parameter_src}}e.uniforms=m}function f(e,j,g){var h=c.createProgram();g=["#ifdef GL_ES\nprecision highp float;\n#endif",
|
|
|
|
-g?"#define USE_FOG":"",g instanceof THREE.FogExp2?"#define FOG_EXP2":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");var n=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","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(h,
|
|
|
|
-l("fragment",g+e));c.attachShader(h,l("vertex",n+j));c.linkProgram(h);c.getProgramParameter(h,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(h,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");h.uniforms={};h.attributes={};return h}function d(e,j){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);
|
|
|
|
|
|
+THREE.Projector=function(){function a(i,g){return g.z-i.z}function b(i,g){var k=0,j=1,l=i.z+i.w,p=g.z+g.w,r=-i.z+i.w,w=-g.z+g.w;if(l>=0&&p>=0&&r>=0&&w>=0)return true;else if(l<0&&p<0||r<0&&w<0)return false;else{if(l<0)k=Math.max(k,l/(l-p));else if(p<0)j=Math.min(j,l/(l-p));if(r<0)k=Math.max(k,r/(r-w));else if(w<0)j=Math.min(j,r/(r-w));if(j<k)return false;else{i.lerpSelf(g,k);g.lerpSelf(i,1-j);return true}}}var f,d,h=[],m,q,t,n=[],o,c,D=[],x,z,P=[],T=new THREE.Vector4,R=new THREE.Vector4,s=new THREE.Matrix4,
|
|
|
|
+O=new THREE.Matrix4,B=[],J=new THREE.Vector4,M=new THREE.Vector4,e;this.projectObjects=function(i,g,k){var j=[],l,p;d=0;s.multiply(g.projectionMatrix,g.matrix);B[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);B[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);B[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);B[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);B[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
|
|
|
|
+s.n33,s.n44-s.n34);B[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);g=0;for(l=B.length;g<l;g++){p=B[g];p.divideScalar(Math.sqrt(p.x*p.x+p.y*p.y+p.z*p.z))}l=i.objects;i=0;for(g=l.length;i<g;i++){p=l[i];var r;if(!(r=!p.visible)){if(r=p instanceof THREE.Mesh){a:{r=void 0;for(var w=p.position,G=-p.geometry.boundingSphere.radius*Math.max(p.scale.x,Math.max(p.scale.y,p.scale.z)),F=0;F<6;F++){r=B[F].x*w.x+B[F].y*w.y+B[F].z*w.z+B[F].w;if(r<=G){r=false;break a}}r=true}r=!r}r=r}if(!r){f=
|
|
|
|
+h[d]=h[d]||new THREE.RenderableObject;T.copy(p.position);s.multiplyVector3(T);f.object=p;f.z=T.z;j.push(f);d++}}k&&j.sort(a);return j};this.projectScene=function(i,g,k){var j=[],l=g.near,p=g.far,r,w,G,F,E,H,u,V,X,L,y,I,S,C,Q,W;t=c=z=0;g.autoUpdateMatrix&&g.updateMatrix();s.multiply(g.projectionMatrix,g.matrix);H=this.projectObjects(i,g,true);i=0;for(r=H.length;i<r;i++){u=H[i].object;if(u.visible){u.autoUpdateMatrix&&u.updateMatrix();V=u.matrix;X=u.rotationMatrix;L=u.materials;y=u.overdraw;if(u instanceof
|
|
|
|
+THREE.Mesh){I=u.geometry;S=I.vertices;w=0;for(G=S.length;w<G;w++){C=S[w];C.positionWorld.copy(C.position);V.multiplyVector3(C.positionWorld);F=C.positionScreen;F.copy(C.positionWorld);s.multiplyVector4(F);F.x/=F.w;F.y/=F.w;C.__visible=F.z>l&&F.z<p}I=I.faces;w=0;for(G=I.length;w<G;w++){C=I[w];if(C instanceof THREE.Face3){F=S[C.a];E=S[C.b];Q=S[C.c];if(F.__visible&&E.__visible&&Q.__visible)if(u.doubleSided||u.flipSided!=(Q.positionScreen.x-F.positionScreen.x)*(E.positionScreen.y-F.positionScreen.y)-
|
|
|
|
+(Q.positionScreen.y-F.positionScreen.y)*(E.positionScreen.x-F.positionScreen.x)<0){m=n[t]=n[t]||new THREE.RenderableFace3;m.v1.positionWorld.copy(F.positionWorld);m.v2.positionWorld.copy(E.positionWorld);m.v3.positionWorld.copy(Q.positionWorld);m.v1.positionScreen.copy(F.positionScreen);m.v2.positionScreen.copy(E.positionScreen);m.v3.positionScreen.copy(Q.positionScreen);m.normalWorld.copy(C.normal);X.multiplyVector3(m.normalWorld);m.centroidWorld.copy(C.centroid);V.multiplyVector3(m.centroidWorld);
|
|
|
|
+m.centroidScreen.copy(m.centroidWorld);s.multiplyVector3(m.centroidScreen);Q=C.vertexNormals;e=m.vertexNormalsWorld;F=0;for(E=Q.length;F<E;F++){W=e[F]=e[F]||new THREE.Vector3;W.copy(Q[F]);X.multiplyVector3(W)}m.z=m.centroidScreen.z;m.meshMaterials=L;m.faceMaterials=C.materials;m.overdraw=y;if(u.geometry.uvs[w]){m.uvs[0]=u.geometry.uvs[w][0];m.uvs[1]=u.geometry.uvs[w][1];m.uvs[2]=u.geometry.uvs[w][2]}j.push(m);t++}}else if(C instanceof THREE.Face4){F=S[C.a];E=S[C.b];Q=S[C.c];W=S[C.d];if(F.__visible&&
|
|
|
|
+E.__visible&&Q.__visible&&W.__visible)if(u.doubleSided||u.flipSided!=((W.positionScreen.x-F.positionScreen.x)*(E.positionScreen.y-F.positionScreen.y)-(W.positionScreen.y-F.positionScreen.y)*(E.positionScreen.x-F.positionScreen.x)<0||(E.positionScreen.x-Q.positionScreen.x)*(W.positionScreen.y-Q.positionScreen.y)-(E.positionScreen.y-Q.positionScreen.y)*(W.positionScreen.x-Q.positionScreen.x)<0)){m=n[t]=n[t]||new THREE.RenderableFace3;m.v1.positionWorld.copy(F.positionWorld);m.v2.positionWorld.copy(E.positionWorld);
|
|
|
|
+m.v3.positionWorld.copy(W.positionWorld);m.v1.positionScreen.copy(F.positionScreen);m.v2.positionScreen.copy(E.positionScreen);m.v3.positionScreen.copy(W.positionScreen);m.normalWorld.copy(C.normal);X.multiplyVector3(m.normalWorld);m.centroidWorld.copy(C.centroid);V.multiplyVector3(m.centroidWorld);m.centroidScreen.copy(m.centroidWorld);s.multiplyVector3(m.centroidScreen);m.z=m.centroidScreen.z;m.meshMaterials=L;m.faceMaterials=C.materials;m.overdraw=y;if(u.geometry.uvs[w]){m.uvs[0]=u.geometry.uvs[w][0];
|
|
|
|
+m.uvs[1]=u.geometry.uvs[w][1];m.uvs[2]=u.geometry.uvs[w][3]}j.push(m);t++;q=n[t]=n[t]||new THREE.RenderableFace3;q.v1.positionWorld.copy(E.positionWorld);q.v2.positionWorld.copy(Q.positionWorld);q.v3.positionWorld.copy(W.positionWorld);q.v1.positionScreen.copy(E.positionScreen);q.v2.positionScreen.copy(Q.positionScreen);q.v3.positionScreen.copy(W.positionScreen);q.normalWorld.copy(m.normalWorld);q.centroidWorld.copy(m.centroidWorld);q.centroidScreen.copy(m.centroidScreen);q.z=q.centroidScreen.z;q.meshMaterials=
|
|
|
|
+L;q.faceMaterials=C.materials;q.overdraw=y;if(u.geometry.uvs[w]){q.uvs[0]=u.geometry.uvs[w][1];q.uvs[1]=u.geometry.uvs[w][2];q.uvs[2]=u.geometry.uvs[w][3]}j.push(q);t++}}}}else if(u instanceof THREE.Line){O.multiply(s,V);S=u.geometry.vertices;C=S[0];C.positionScreen.copy(C.position);O.multiplyVector4(C.positionScreen);w=1;for(G=S.length;w<G;w++){F=S[w];F.positionScreen.copy(F.position);O.multiplyVector4(F.positionScreen);E=S[w-1];J.copy(F.positionScreen);M.copy(E.positionScreen);if(b(J,M)){J.multiplyScalar(1/
|
|
|
|
+J.w);M.multiplyScalar(1/M.w);o=D[c]=D[c]||new THREE.RenderableLine;o.v1.positionScreen.copy(J);o.v2.positionScreen.copy(M);o.z=Math.max(J.z,M.z);o.materials=u.materials;j.push(o);c++}}}else if(u instanceof THREE.Particle){R.set(u.position.x,u.position.y,u.position.z,1);s.multiplyVector4(R);R.z/=R.w;if(R.z>0&&R.z<1){x=P[z]=P[z]||new THREE.RenderableParticle;x.x=R.x/R.w;x.y=R.y/R.w;x.z=R.z;x.rotation=u.rotation.z;x.scale.x=u.scale.x*Math.abs(x.x-(R.x+g.projectionMatrix.n11)/(R.w+g.projectionMatrix.n14));
|
|
|
|
+x.scale.y=u.scale.y*Math.abs(x.y-(R.y+g.projectionMatrix.n22)/(R.w+g.projectionMatrix.n24));x.materials=u.materials;j.push(x);z++}}}}k&&j.sort(a);return j};this.unprojectVector=function(i,g){var k=new THREE.Matrix4;k.multiply(THREE.Matrix4.makeInvert(g.matrix),THREE.Matrix4.makeInvert(g.projectionMatrix));k.multiplyVector3(i);return i}};
|
|
|
|
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,h,m;this.domElement=document.createElement("div");this.setSize=function(q,t){f=q;d=t;h=f/2;m=d/2};this.render=function(q,t){var n,o,c,D,x,z,P,T;a=b.projectScene(q,t);n=0;for(o=a.length;n<o;n++){x=a[n];if(x instanceof THREE.RenderableParticle){P=x.x*h+h;T=x.y*m+m;c=0;for(D=x.material.length;c<D;c++){z=x.material[c];if(z instanceof THREE.ParticleDOMMaterial){z=z.domElement;z.style.left=P+"px";z.style.top=T+"px"}}}}}};
|
|
|
|
+THREE.CanvasRenderer=function(){function a(ba){if(x!=ba)o.globalAlpha=x=ba}function b(ba){if(z!=ba){switch(ba){case THREE.NormalBlending:o.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:o.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:o.globalCompositeOperation="darker"}z=ba}}var f=null,d=new THREE.Projector,h=document.createElement("canvas"),m,q,t,n,o=h.getContext("2d"),c=null,D=null,x=1,z=0,P=null,T=null,R=1,s,O,B,J,M,e,i,g,k,j=new THREE.Color,
|
|
|
|
+l=new THREE.Color,p=new THREE.Color,r=new THREE.Color,w=new THREE.Color,G,F,E,H,u,V,X,L,y,I=new THREE.Rectangle,S=new THREE.Rectangle,C=new THREE.Rectangle,Q=false,W=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){m=ba;q=la;t=m/2;n=q/2;h.width=m;h.height=q;I.set(-t,-n,t,n)};this.setClearColor=function(ba,la){c=ba!==null?new THREE.Color(ba):null;D=la;S.set(-t,-n,t,n);o.setTransform(1,0,0,-1,t,n);this.clear()};this.clear=function(){if(!S.isEmpty()){S.inflate(1);S.minSelf(I);if(c!==null){b(THREE.NormalBlending);a(1);o.fillStyle=
|
|
|
|
+"rgba("+Math.floor(c.r*255)+","+Math.floor(c.g*255)+","+Math.floor(c.b*255)+","+D+")";o.fillRect(S.getX(),S.getY(),S.getWidth(),S.getHeight())}else o.clearRect(S.getX(),S.getY(),S.getWidth(),S.getHeight());S.empty()}};this.render=function(ba,la){function Ma(v){var U,N,A,K=v.lights;ea.setRGB(0,0,0);ma.setRGB(0,0,0);na.setRGB(0,0,0);v=0;for(U=K.length;v<U;v++){N=K[v];A=N.color;if(N instanceof THREE.AmbientLight){ea.r+=A.r;ea.g+=A.g;ea.b+=A.b}else if(N instanceof THREE.DirectionalLight){ma.r+=A.r;ma.g+=
|
|
|
|
+A.g;ma.b+=A.b}else if(N instanceof THREE.PointLight){na.r+=A.r;na.g+=A.g;na.b+=A.b}}}function ya(v,U,N,A){var K,Y,aa,ca,da=v.lights;v=0;for(K=da.length;v<K;v++){Y=da[v];aa=Y.color;ca=Y.intensity;if(Y instanceof THREE.DirectionalLight){Y=N.dot(Y.position)*ca;if(Y>0){A.r+=aa.r*Y;A.g+=aa.g*Y;A.b+=aa.b*Y}}else if(Y instanceof THREE.PointLight){Z.sub(Y.position,U);Z.normalize();Y=N.dot(Z)*ca;if(Y>0){A.r+=aa.r*Y;A.g+=aa.g*Y;A.b+=aa.b*Y}}}}function Na(v,U,N){if(N.opacity!=0){a(N.opacity);b(N.blending);var A,
|
|
|
|
+K,Y,aa,ca,da;if(N instanceof THREE.ParticleBasicMaterial){if(N.map){aa=N.map;ca=aa.width>>1;da=aa.height>>1;K=U.scale.x*t;Y=U.scale.y*n;N=K*ca;A=Y*da;C.set(v.x-N,v.y-A,v.x+N,v.y+A);if(!I.instersects(C))return;o.save();o.translate(v.x,v.y);o.rotate(-U.rotation);o.scale(K,-Y);o.translate(-ca,-da);o.drawImage(aa,0,0);o.restore()}o.beginPath();o.moveTo(v.x-10,v.y);o.lineTo(v.x+10,v.y);o.moveTo(v.x,v.y-10);o.lineTo(v.x,v.y+10);o.closePath();o.strokeStyle="rgb(255,255,0)";o.stroke()}else if(N instanceof
|
|
|
|
+THREE.ParticleCircleMaterial){if(Q){W.r=ea.r+ma.r+na.r;W.g=ea.g+ma.g+na.g;W.b=ea.b+ma.b+na.b;j.r=N.color.r*W.r;j.g=N.color.g*W.g;j.b=N.color.b*W.b;j.updateStyleString()}else j.__styleString=N.color.__styleString;N=U.scale.x*t;A=U.scale.y*n;C.set(v.x-N,v.y-A,v.x+N,v.y+A);if(I.instersects(C)){K=j.__styleString;if(T!=K)o.fillStyle=T=K;o.save();o.translate(v.x,v.y);o.rotate(-U.rotation);o.scale(N,A);o.beginPath();o.arc(0,0,1,0,La,true);o.closePath();o.fill();o.restore()}}}}function Oa(v,U,N,A){if(A.opacity!=
|
|
|
|
+0){a(A.opacity);b(A.blending);o.beginPath();o.moveTo(v.positionScreen.x,v.positionScreen.y);o.lineTo(U.positionScreen.x,U.positionScreen.y);o.closePath();if(A instanceof THREE.LineBasicMaterial){j.__styleString=A.color.__styleString;v=A.linewidth;if(R!=v)o.lineWidth=R=v;v=j.__styleString;if(P!=v)o.strokeStyle=P=v;o.stroke();C.inflate(A.linewidth*2)}}}function Ha(v,U,N,A,K,Y){if(K.opacity!=0){a(K.opacity);b(K.blending);J=v.positionScreen.x;M=v.positionScreen.y;e=U.positionScreen.x;i=U.positionScreen.y;
|
|
|
|
+g=N.positionScreen.x;k=N.positionScreen.y;o.beginPath();o.moveTo(J,M);o.lineTo(e,i);o.lineTo(g,k);o.lineTo(J,M);o.closePath();if(K instanceof THREE.MeshBasicMaterial)if(K.map)K.map.image.loaded&&K.map.mapping instanceof THREE.UVMapping&&ua(J,M,e,i,g,k,K.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);else if(K.env_map){if(K.env_map.image.loaded)if(K.env_map.mapping instanceof THREE.SphericalReflectionMapping){v=la.matrix;Z.copy(A.vertexNormalsWorld[0]);H=(Z.x*v.n11+Z.y*
|
|
|
|
+v.n12+Z.z*v.n13)*0.5+0.5;u=-(Z.x*v.n21+Z.y*v.n22+Z.z*v.n23)*0.5+0.5;Z.copy(A.vertexNormalsWorld[1]);V=(Z.x*v.n11+Z.y*v.n12+Z.z*v.n13)*0.5+0.5;X=-(Z.x*v.n21+Z.y*v.n22+Z.z*v.n23)*0.5+0.5;Z.copy(A.vertexNormalsWorld[2]);L=(Z.x*v.n11+Z.y*v.n12+Z.z*v.n13)*0.5+0.5;y=-(Z.x*v.n21+Z.y*v.n22+Z.z*v.n23)*0.5+0.5;ua(J,M,e,i,g,k,K.env_map.image,H,u,V,X,L,y)}}else K.wireframe?za(K.color.__styleString,K.wireframe_linewidth):Aa(K.color.__styleString);else if(K instanceof THREE.MeshLambertMaterial){if(K.map&&!K.wireframe){K.map.mapping instanceof
|
|
|
|
+THREE.UVMapping&&ua(J,M,e,i,g,k,K.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);b(THREE.SubtractiveBlending)}if(Q)if(!K.wireframe&&K.shading==THREE.SmoothShading&&A.vertexNormalsWorld.length==3){l.r=p.r=r.r=ea.r;l.g=p.g=r.g=ea.g;l.b=p.b=r.b=ea.b;ya(Y,A.v1.positionWorld,A.vertexNormalsWorld[0],l);ya(Y,A.v2.positionWorld,A.vertexNormalsWorld[1],p);ya(Y,A.v3.positionWorld,A.vertexNormalsWorld[2],r);w.r=(p.r+r.r)*0.5;w.g=(p.g+r.g)*0.5;w.b=(p.b+r.b)*0.5;E=Ia(l,p,r,w);ua(J,
|
|
|
|
+M,e,i,g,k,E,0,0,1,0,0,1)}else{W.r=ea.r;W.g=ea.g;W.b=ea.b;ya(Y,A.centroidWorld,A.normalWorld,W);j.r=K.color.r*W.r;j.g=K.color.g*W.g;j.b=K.color.b*W.b;j.updateStyleString();K.wireframe?za(j.__styleString,K.wireframe_linewidth):Aa(j.__styleString)}else K.wireframe?za(K.color.__styleString,K.wireframe_linewidth):Aa(K.color.__styleString)}else if(K instanceof THREE.MeshDepthMaterial){G=la.near;F=la.far;l.r=l.g=l.b=1-Da(v.positionScreen.z,G,F);p.r=p.g=p.b=1-Da(U.positionScreen.z,G,F);r.r=r.g=r.b=1-Da(N.positionScreen.z,
|
|
|
|
+G,F);w.r=(p.r+r.r)*0.5;w.g=(p.g+r.g)*0.5;w.b=(p.b+r.b)*0.5;E=Ia(l,p,r,w);ua(J,M,e,i,g,k,E,0,0,1,0,0,1)}else if(K instanceof THREE.MeshNormalMaterial){j.r=Ea(A.normalWorld.x);j.g=Ea(A.normalWorld.y);j.b=Ea(A.normalWorld.z);j.updateStyleString();K.wireframe?za(j.__styleString,K.wireframe_linewidth):Aa(j.__styleString)}}}function za(v,U){if(P!=v)o.strokeStyle=P=v;if(R!=U)o.lineWidth=R=U;o.stroke();C.inflate(U*2)}function Aa(v){if(T!=v)o.fillStyle=T=v;o.fill()}function ua(v,U,N,A,K,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;N-=v;A-=U;K-=v;Y-=U;ia-=ca;ga-=da;ja-=ca;va-=da;ka=1/(ia*va-ja*ga);oa=(va*N-ga*K)*ka;ga=(va*A-ga*Y)*ka;N=(ia*K-ja*N)*ka;A=(ia*Y-ja*A)*ka;v=v-oa*ca-N*da;U=U-ga*ca-A*da;o.save();o.transform(oa,ga,N,A,v,U);o.clip();o.drawImage(aa,0,0);o.restore()}function Ia(v,U,N,A){var K=~~(v.r*255),Y=~~(v.g*255);v=~~(v.b*255);var aa=~~(U.r*255),ca=~~(U.g*255);U=~~(U.b*255);var da=~~(N.r*255),ia=~~(N.g*255);N=~~(N.b*255);var ga=~~(A.r*
|
|
|
|
+255),ja=~~(A.g*255);A=~~(A.b*255);fa[0]=K<0?0:K>255?255:K;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]=U<0?0:U>255?255:U;fa[8]=da<0?0:da>255?255:da;fa[9]=ia<0?0:ia>255?255:ia;fa[10]=N<0?0:N>255?255:N;fa[12]=ga<0?0:ga>255?255:ga;fa[13]=ja<0?0:ja>255?255:ja;fa[14]=A<0?0:A>255?255:A;sa.putImageData(Ca,0,0);xa.drawImage(ra,0,0);return ta}function Da(v,U,N){v=(v-U)/(N-U);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,
|
|
|
|
+U){var N=U.x-v.x,A=U.y-v.y,K=1/Math.sqrt(N*N+A*A);N*=K;A*=K;U.x+=N;U.y+=A;v.x-=N;v.y-=A}var Ba,Ja,$,ha,qa,Ga,Ka,wa;o.setTransform(1,0,0,-1,t,n);this.autoClear&&this.clear();f=d.projectScene(ba,la,this.sortElements);o.fillStyle="rgba( 0, 255, 255, 0.5 )";o.fillRect(I.getX(),I.getY(),I.getWidth(),I.getHeight());(Q=ba.lights.length>0)&&Ma(ba);Ba=0;for(Ja=f.length;Ba<Ja;Ba++){$=f[Ba];C.empty();if($ instanceof THREE.RenderableParticle){s=$;s.x*=t;s.y*=n;ha=0;for(qa=$.materials.length;ha<qa;ha++)Na(s,$,
|
|
|
|
+$.materials[ha],ba)}else if($ instanceof THREE.RenderableLine){s=$.v1;O=$.v2;s.positionScreen.x*=t;s.positionScreen.y*=n;O.positionScreen.x*=t;O.positionScreen.y*=n;C.addPoint(s.positionScreen.x,s.positionScreen.y);C.addPoint(O.positionScreen.x,O.positionScreen.y);if(I.instersects(C)){ha=0;for(qa=$.materials.length;ha<qa;)Oa(s,O,$,$.materials[ha++],ba)}}else if($ instanceof THREE.RenderableFace3){s=$.v1;O=$.v2;B=$.v3;s.positionScreen.x*=t;s.positionScreen.y*=n;O.positionScreen.x*=t;O.positionScreen.y*=
|
|
|
|
+n;B.positionScreen.x*=t;B.positionScreen.y*=n;if($.overdraw){Fa(s.positionScreen,O.positionScreen);Fa(O.positionScreen,B.positionScreen);Fa(B.positionScreen,s.positionScreen)}C.add3Points(s.positionScreen.x,s.positionScreen.y,O.positionScreen.x,O.positionScreen.y,B.positionScreen.x,B.positionScreen.y);if(I.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(s,O,B,$,wa,ba)}else Ha(s,O,B,$,wa,ba)}}}S.addRectangle(C)}o.lineWidth=1;o.strokeStyle="rgba( 255, 0, 0, 0.5 )";o.strokeRect(S.getX(),S.getY(),S.getWidth(),S.getHeight());o.setTransform(1,0,0,1,0,0)}};
|
|
|
|
+THREE.SVGRenderer=function(){function a(H,u,V){var X,L,y,I;X=0;for(L=H.lights.length;X<L;X++){y=H.lights[X];if(y instanceof THREE.DirectionalLight){I=u.normalWorld.dot(y.position)*y.intensity;if(I>0){V.r+=y.color.r*I;V.g+=y.color.g*I;V.b+=y.color.b*I}}else if(y instanceof THREE.PointLight){k.sub(y.position,u.centroidWorld);k.normalize();I=u.normalWorld.dot(k)*y.intensity;if(I>0){V.r+=y.color.r*I;V.g+=y.color.g*I;V.b+=y.color.b*I}}}}function b(H,u,V,X,L,y){r=d(w++);r.setAttribute("d","M "+H.positionScreen.x+
|
|
|
|
+" "+H.positionScreen.y+" L "+u.positionScreen.x+" "+u.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(L instanceof THREE.MeshBasicMaterial)B.__styleString=L.color.__styleString;else if(L instanceof THREE.MeshLambertMaterial)if(O){J.r=M.r;J.g=M.g;J.b=M.b;a(y,X,J);B.r=L.color.r*J.r;B.g=L.color.g*J.g;B.b=L.color.b*J.b;B.updateStyleString()}else B.__styleString=L.color.__styleString;else if(L instanceof THREE.MeshDepthMaterial){g=1-L.__2near/(L.__farPlusNear-X.z*L.__farMinusNear);
|
|
|
|
+B.setRGB(g,g,g)}else L instanceof THREE.MeshNormalMaterial&&B.setRGB(h(X.normalWorld.x),h(X.normalWorld.y),h(X.normalWorld.z));L.wireframe?r.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+L.wireframe_linewidth+"; stroke-opacity: "+L.opacity+"; stroke-linecap: "+L.wireframe_linecap+"; stroke-linejoin: "+L.wireframe_linejoin):r.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+L.opacity);t.appendChild(r)}function f(H,u,V,X,L,y,I){r=d(w++);r.setAttribute("d",
|
|
|
|
+"M "+H.positionScreen.x+" "+H.positionScreen.y+" L "+u.positionScreen.x+" "+u.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(y instanceof THREE.MeshBasicMaterial)B.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshLambertMaterial)if(O){J.r=M.r;J.g=M.g;J.b=M.b;a(I,L,J);B.r=y.color.r*J.r;B.g=y.color.g*J.g;B.b=y.color.b*J.b;B.updateStyleString()}else B.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshDepthMaterial){g=
|
|
|
|
+1-y.__2near/(y.__farPlusNear-L.z*y.__farMinusNear);B.setRGB(g,g,g)}else y instanceof THREE.MeshNormalMaterial&&B.setRGB(h(L.normalWorld.x),h(L.normalWorld.y),h(L.normalWorld.z));y.wireframe?r.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+y.wireframe_linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframe_linecap+"; stroke-linejoin: "+y.wireframe_linejoin):r.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+y.opacity);t.appendChild(r)}
|
|
|
|
+function d(H){if(j[H]==null){j[H]=document.createElementNS("http://www.w3.org/2000/svg","path");E==0&&j[H].setAttribute("shape-rendering","crispEdges");return j[H]}return j[H]}function h(H){return H<0?Math.min((1+H)*0.5,0.5):0.5+Math.min(H*0.5,0.5)}var m=null,q=new THREE.Projector,t=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,o,c,D,x,z,P,T,R=new THREE.Rectangle,s=new THREE.Rectangle,O=false,B=new THREE.Color(16777215),J=new THREE.Color(16777215),M=new THREE.Color(0),e=new THREE.Color(0),
|
|
|
|
+i=new THREE.Color(0),g,k=new THREE.Vector3,j=[],l=[],p=[],r,w,G,F,E=1;this.domElement=t;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(H){switch(H){case "high":E=1;break;case "low":E=0}};this.setSize=function(H,u){n=H;o=u;c=n/2;D=o/2;t.setAttribute("viewBox",-c+" "+-D+" "+n+" "+o);t.setAttribute("width",n);t.setAttribute("height",o);R.set(-c,-D,c,D)};this.clear=function(){for(;t.childNodes.length>0;)t.removeChild(t.childNodes[0])};this.render=function(H,u){var V,X,
|
|
|
|
+L,y,I,S,C,Q;this.autoClear&&this.clear();m=q.projectScene(H,u,this.sortElements);F=G=w=0;if(O=H.lights.length>0){C=H.lights;M.setRGB(0,0,0);e.setRGB(0,0,0);i.setRGB(0,0,0);V=0;for(X=C.length;V<X;V++){L=C[V];y=L.color;if(L instanceof THREE.AmbientLight){M.r+=y.r;M.g+=y.g;M.b+=y.b}else if(L instanceof THREE.DirectionalLight){e.r+=y.r;e.g+=y.g;e.b+=y.b}else if(L instanceof THREE.PointLight){i.r+=y.r;i.g+=y.g;i.b+=y.b}}}V=0;for(X=m.length;V<X;V++){C=m[V];s.empty();if(C instanceof THREE.RenderableParticle){x=
|
|
|
|
+C;x.x*=c;x.y*=-D;L=0;for(y=C.materials.length;L<y;L++)if(Q=C.materials[L]){I=x;S=C;Q=Q;var W=G++;if(l[W]==null){l[W]=document.createElementNS("http://www.w3.org/2000/svg","circle");E==0&&l[W].setAttribute("shape-rendering","crispEdges")}r=l[W];r.setAttribute("cx",I.x);r.setAttribute("cy",I.y);r.setAttribute("r",S.scale.x*c);if(Q instanceof THREE.ParticleCircleMaterial){if(O){J.r=M.r+e.r+i.r;J.g=M.g+e.g+i.g;J.b=M.b+e.b+i.b;B.r=Q.color.r*J.r;B.g=Q.color.g*J.g;B.b=Q.color.b*J.b;B.updateStyleString()}else B=
|
|
|
|
+Q.color;r.setAttribute("style","fill: "+B.__styleString)}t.appendChild(r)}}else if(C instanceof THREE.RenderableLine){x=C.v1;z=C.v2;x.positionScreen.x*=c;x.positionScreen.y*=-D;z.positionScreen.x*=c;z.positionScreen.y*=-D;s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(z.positionScreen.x,z.positionScreen.y);if(R.instersects(s)){L=0;for(y=C.materials.length;L<y;)if(Q=C.materials[L++]){I=x;S=z;Q=Q;W=F++;if(p[W]==null){p[W]=document.createElementNS("http://www.w3.org/2000/svg","line");E==
|
|
|
|
+0&&p[W].setAttribute("shape-rendering","crispEdges")}r=p[W];r.setAttribute("x1",I.positionScreen.x);r.setAttribute("y1",I.positionScreen.y);r.setAttribute("x2",S.positionScreen.x);r.setAttribute("y2",S.positionScreen.y);if(Q instanceof THREE.LineBasicMaterial){B.__styleString=Q.color.__styleString;r.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+Q.linewidth+"; stroke-opacity: "+Q.opacity+"; stroke-linecap: "+Q.linecap+"; stroke-linejoin: "+Q.linejoin);t.appendChild(r)}}}}else if(C instanceof
|
|
|
|
+THREE.RenderableFace3){x=C.v1;z=C.v2;P=C.v3;x.positionScreen.x*=c;x.positionScreen.y*=-D;z.positionScreen.x*=c;z.positionScreen.y*=-D;P.positionScreen.x*=c;P.positionScreen.y*=-D;s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(z.positionScreen.x,z.positionScreen.y);s.addPoint(P.positionScreen.x,P.positionScreen.y);if(R.instersects(s)){L=0;for(y=C.meshMaterials.length;L<y;){Q=C.meshMaterials[L++];if(Q instanceof THREE.MeshFaceMaterial){I=0;for(S=C.faceMaterials.length;I<S;)(Q=C.faceMaterials[I++])&&
|
|
|
|
+b(x,z,P,C,Q,H)}else Q&&b(x,z,P,C,Q,H)}}}else if(C instanceof THREE.RenderableFace4){x=C.v1;z=C.v2;P=C.v3;T=C.v4;x.positionScreen.x*=c;x.positionScreen.y*=-D;z.positionScreen.x*=c;z.positionScreen.y*=-D;P.positionScreen.x*=c;P.positionScreen.y*=-D;T.positionScreen.x*=c;T.positionScreen.y*=-D;s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(z.positionScreen.x,z.positionScreen.y);s.addPoint(P.positionScreen.x,P.positionScreen.y);s.addPoint(T.positionScreen.x,T.positionScreen.y);if(R.instersects(s)){L=
|
|
|
|
+0;for(y=C.meshMaterials.length;L<y;){Q=C.meshMaterials[L++];if(Q instanceof THREE.MeshFaceMaterial){I=0;for(S=C.faceMaterials.length;I<S;)(Q=C.faceMaterials[I++])&&f(x,z,P,T,C,Q,H)}else Q&&f(x,z,P,T,C,Q,H)}}}}}};
|
|
|
|
+THREE.WebGLRenderer=function(a){function b(e,i){e.fragment_shader=i.fragment_shader;e.vertex_shader=i.vertex_shader;var g=i.uniforms,k,j,l={};for(k in g){l[k]={};for(j in uniforms[k]){parameter_src=g[k][j];parameter_dst=l[k][j];parameter_dst=parameter_src instanceof THREE.Color||parameter_src instanceof THREE.Vector3||parameter_src instanceof THREE.Texture?parameter_src.clone():parameter_src}}e.uniforms=l}function f(e,i,g){var k=c.createProgram();g=["#ifdef GL_ES\nprecision highp float;\n#endif",
|
|
|
|
+g?"#define USE_FOG":"",g instanceof THREE.FogExp2?"#define FOG_EXP2":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");var j=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","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(k,
|
|
|
|
+t("fragment",g+e));c.attachShader(k,t("vertex",j+i));c.linkProgram(k);c.getProgramParameter(k,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(k,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");k.uniforms={};k.attributes={};return k}function d(e,i){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.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(var g=0;g<6;++g)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[g]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+
|
|
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(var g=0;g<6;++g)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[g]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+
|
|
-j);c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}function i(e,j){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,o(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,o(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,o(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
|
|
|
|
-o(e.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+j);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function k(e,j){var g,h,n;g=0;for(h=j.length;g<h;g++){n=j[g];e.uniforms[n]=c.getUniformLocation(e,n)}}function p(e,j){var g,h,n;g=0;for(h=j.length;g<h;g++){n=j[g];e.attributes[n]=c.getAttribLocation(e,n)}}function l(e,j){var g;if(e=="fragment")g=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")g=c.createShader(c.VERTEX_SHADER);c.shaderSource(g,
|
|
|
|
-j);c.compileShader(g);if(!c.getShaderParameter(g,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(g));return null}return g}function o(e){switch(e){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 z=document.createElement("canvas"),c,C,w,v=new THREE.Matrix4,J,S=new Float32Array(16),Q=new Float32Array(16),t=new Float32Array(16),U=new Float32Array(9),B=new Float32Array(16),L=function(e,j){if(e){var g,h,n,m=pointLights=maxDirLights=maxPointLights=0;g=0;for(h=e.lights.length;g<h;g++){n=e.lights[g];n instanceof THREE.DirectionalLight&&m++;n instanceof
|
|
|
|
-THREE.PointLight&&pointLights++}if(pointLights+m<=j){maxDirLights=m;maxPointLights=pointLights}else{maxDirLights=Math.ceil(j*m/(pointLights+m));maxPointLights=j-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:j-1}}(a.scene,4);fog=a.scene?a.scene.fog:null;antialias=a.antialias!=undefined?a.antialias:true;clearColor=a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0);clearAlpha=a.clearAlpha?a.clearAlpha:0;this.domElement=z;this.autoClear=true;
|
|
|
|
-(function(e,j,g){try{c=z.getContext("experimental-webgl",{antialias:e})}catch(h){}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(j.r,j.g,j.b,g)})(antialias,clearColor,clearAlpha);C=w=function(e,j,g){var h=[e?"#define MAX_DIR_LIGHTS "+e:"",j?"#define MAX_POINT_LIGHTS "+
|
|
|
|
-j:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",e?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",j?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",j?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",j?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":
|
|
|
|
|
|
+i);c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}function h(e,i){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,n(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,n(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,n(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
|
|
|
|
+n(e.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+i);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function m(e,i){var g,k,j;g=0;for(k=i.length;g<k;g++){j=i[g];e.uniforms[j]=c.getUniformLocation(e,j)}}function q(e,i){var g,k,j;g=0;for(k=i.length;g<k;g++){j=i[g];e.attributes[j]=c.getAttribLocation(e,j)}}function t(e,i){var g;if(e=="fragment")g=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")g=c.createShader(c.VERTEX_SHADER);c.shaderSource(g,
|
|
|
|
+i);c.compileShader(g);if(!c.getShaderParameter(g,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(g));return null}return g}function n(e){switch(e){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,D,x,z=new THREE.Matrix4,P,T=new Float32Array(16),R=new Float32Array(16),s=new Float32Array(16),O=new Float32Array(9),B=new Float32Array(16),J=function(e,i){if(e){var g,k,j,l=pointLights=maxDirLights=maxPointLights=0;g=0;for(k=e.lights.length;g<k;g++){j=e.lights[g];j instanceof THREE.DirectionalLight&&l++;j instanceof
|
|
|
|
+THREE.PointLight&&pointLights++}if(pointLights+l<=i){maxDirLights=l;maxPointLights=pointLights}else{maxDirLights=Math.ceil(i*l/(pointLights+l));maxPointLights=i-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:i-1}}(a.scene,4);fog=a.scene?a.scene.fog:null;antialias=a.antialias!=undefined?a.antialias:true;clearColor=a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0);clearAlpha=a.clearAlpha?a.clearAlpha:0;this.domElement=o;this.autoClear=true;
|
|
|
|
+(function(e,i,g){try{c=o.getContext("experimental-webgl",{antialias:e})}catch(k){}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,g)})(antialias,clearColor,clearAlpha);D=x=function(e,i,g){var k=[e?"#define MAX_DIR_LIGHTS "+e:"",i?"#define MAX_POINT_LIGHTS "+
|
|
|
|
+i:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",e?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",i?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",i?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",i?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":
|
|
"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
|
|
"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
|
|
-e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",e?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",e?"}":"",j?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",j?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",j?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
|
|
|
|
-"",j?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",j?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",j?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
|
|
|
|
-n=[e?"#define MAX_DIR_LIGHTS "+e:"",j?"#define MAX_POINT_LIGHTS "+j:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\n#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\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
|
|
|
|
-e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",j?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
|
|
|
|
-j?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",j?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",j?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",j?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",j?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",j?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",j?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",j?"float pointSpecularWeight = 0.0;":"",j?"if ( pointDotNormalHalf >= 0.0 )":
|
|
|
|
-"",j?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",j?"pointDiffuse += mColor * pointDiffuseWeight;":"",j?"pointSpecular += mSpecular * pointSpecularWeight;":"",j?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
|
|
|
|
-"",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",j?"totalLight += pointDiffuse + pointSpecular;":
|
|
|
|
|
|
+e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",e?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",e?"}":"",i?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",i?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",i?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
|
|
|
|
+"",i?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",i?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",i?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
|
|
|
|
+j=[e?"#define MAX_DIR_LIGHTS "+e:"",i?"#define MAX_POINT_LIGHTS "+i:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\n#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\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
|
|
|
|
+e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",i?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
|
|
|
|
+i?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",i?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",i?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",i?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",i?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",i?"float pointSpecularWeight = 0.0;":"",i?"if ( pointDotNormalHalf >= 0.0 )":
|
|
|
|
+"",i?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",i?"pointDiffuse += mColor * pointDiffuseWeight;":"",i?"pointSpecular += mSpecular * pointSpecularWeight;":"",i?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
|
|
|
|
+"",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",i?"totalLight += pointDiffuse + pointSpecular;":
|
|
"","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n#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\n}"].join("\n");
|
|
"","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n#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\n}"].join("\n");
|
|
-h=f(n,h,g);c.useProgram(h);k(h,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);g&&k(h,["fogColor","fogNear","fogFar","fogDensity"]);e&&k(h,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);j&&k(h,["pointLightNumber",
|
|
|
|
-"pointLightColor","pointLightPosition"]);c.uniform1i(h.uniforms.enableMap,0);c.uniform1i(h.uniforms.tMap,0);c.uniform1i(h.uniforms.enableCubeMap,0);c.uniform1i(h.uniforms.tCube,1);c.uniform1i(h.uniforms.mixEnvMap,0);c.uniform1i(h.uniforms.useRefract,0);p(h,["position","normal","uv"]);return h}(L.directional,L.point,fog);this.setSize=function(e,j){z.width=e;z.height=j;c.viewport(0,0,z.width,z.height)};this.setClearColor=function(e,j){var g=new THREE.Color(e);c.clearColor(g.r,g.g,g.b,j)};this.clear=
|
|
|
|
-function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,j){var g,h,n,m,q,r=[],y=[],K=[];m=[];q=[];c.uniform1i(e.uniforms.enableLighting,j.length);g=0;for(h=j.length;g<h;g++){n=j[g];if(n instanceof THREE.AmbientLight)r.push(n);else if(n instanceof THREE.DirectionalLight)K.push(n);else n instanceof THREE.PointLight&&y.push(n)}g=n=m=q=0;for(h=r.length;g<h;g++){n+=r[g].color.r;m+=r[g].color.g;q+=r[g].color.b}c.uniform3f(e.uniforms.ambientLightColor,n,m,q);m=[];q=[];g=0;
|
|
|
|
-for(h=K.length;g<h;g++){n=K[g];m.push(n.color.r*n.intensity);m.push(n.color.g*n.intensity);m.push(n.color.b*n.intensity);q.push(n.position.x);q.push(n.position.y);q.push(n.position.z)}if(K.length){c.uniform1i(e.uniforms.directionalLightNumber,K.length);c.uniform3fv(e.uniforms.directionalLightDirection,q);c.uniform3fv(e.uniforms.directionalLightColor,m)}m=[];q=[];g=0;for(h=y.length;g<h;g++){n=y[g];m.push(n.color.r*n.intensity);m.push(n.color.g*n.intensity);m.push(n.color.b*n.intensity);q.push(n.position.x);
|
|
|
|
-q.push(n.position.y);q.push(n.position.z)}if(y.length){c.uniform1i(e.uniforms.pointLightNumber,y.length);c.uniform3fv(e.uniforms.pointLightPosition,q);c.uniform3fv(e.uniforms.pointLightColor,m)}};this.createBuffers=function(e,j){var g,h,n,m,q,r,y,K,F,E=[],I=[],u=[],R=[],T=[],G=[],x=0,H=e.geometry.geometryChunks[j],V;n=false;g=0;for(h=e.materials.length;g<h;g++){meshMaterial=e.materials[g];if(meshMaterial instanceof THREE.MeshFaceMaterial){q=0;for(V=H.materials.length;q<V;q++)if(H.materials[q]&&H.materials[q].shading!=
|
|
|
|
-undefined&&H.materials[q].shading==THREE.SmoothShading){n=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){n=true;break}if(n)break}V=n;g=0;for(h=H.faces.length;g<h;g++){n=H.faces[g];m=e.geometry.faces[n];q=m.vertexNormals;faceNormal=m.normal;n=e.geometry.uvs[n];if(m instanceof THREE.Face3){r=e.geometry.vertices[m.a].position;y=e.geometry.vertices[m.b].position;K=e.geometry.vertices[m.c].position;u.push(r.x,r.y,r.z);u.push(y.x,y.y,y.z);u.push(K.x,
|
|
|
|
-K.y,K.z);if(e.geometry.hasTangents){r=e.geometry.vertices[m.a].tangent;y=e.geometry.vertices[m.b].tangent;K=e.geometry.vertices[m.c].tangent;T.push(r.x,r.y,r.z,r.w);T.push(y.x,y.y,y.z,y.w);T.push(K.x,K.y,K.z,K.w)}if(q.length==3&&V)for(m=0;m<3;m++)R.push(q[m].x,q[m].y,q[m].z);else for(m=0;m<3;m++)R.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(m=0;m<3;m++)G.push(n[m].u,n[m].v);E.push(x,x+1,x+2);I.push(x,x+1);I.push(x,x+2);I.push(x+1,x+2);x+=3}else if(m instanceof THREE.Face4){r=e.geometry.vertices[m.a].position;
|
|
|
|
-y=e.geometry.vertices[m.b].position;K=e.geometry.vertices[m.c].position;F=e.geometry.vertices[m.d].position;u.push(r.x,r.y,r.z);u.push(y.x,y.y,y.z);u.push(K.x,K.y,K.z);u.push(F.x,F.y,F.z);if(e.geometry.hasTangents){r=e.geometry.vertices[m.a].tangent;y=e.geometry.vertices[m.b].tangent;K=e.geometry.vertices[m.c].tangent;m=e.geometry.vertices[m.d].tangent;T.push(r.x,r.y,r.z,r.w);T.push(y.x,y.y,y.z,y.w);T.push(K.x,K.y,K.z,K.w);T.push(m.x,m.y,m.z,m.w)}if(q.length==4&&V)for(m=0;m<4;m++)R.push(q[m].x,q[m].y,
|
|
|
|
-q[m].z);else for(m=0;m<4;m++)R.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(m=0;m<4;m++)G.push(n[m].u,n[m].v);E.push(x,x+1,x+2);E.push(x,x+2,x+3);I.push(x,x+1);I.push(x,x+2);I.push(x,x+3);I.push(x+1,x+2);I.push(x+2,x+3);x+=4}}if(u.length){H.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(u),c.STATIC_DRAW);H.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,
|
|
|
|
-new Float32Array(R),c.STATIC_DRAW);if(e.geometry.hasTangents){H.__webGLTangentBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(T),c.STATIC_DRAW)}if(G.length>0){H.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(G),c.STATIC_DRAW)}H.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,H.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,
|
|
|
|
-new Uint16Array(E),c.STATIC_DRAW);H.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,H.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(I),c.STATIC_DRAW);H.__webGLFaceCount=E.length;H.__webGLLineCount=I.length}};this.renderBuffer=function(e,j,g,h,n){var m,q,r,y,K,F,E,I,u;if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshDepthMaterial||h instanceof THREE.MeshNormalMaterial){if(!h.program){if(h instanceof THREE.MeshDepthMaterial){b(h,N.depth);
|
|
|
|
-h.uniforms.mNear.value=e.near;h.uniforms.mFar.value=e.far}else h instanceof THREE.MeshNormalMaterial&&b(h,N.normal);h.program=f(h.fragment_shader,h.vertex_shader,null);E=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(u in h.uniforms)E.push(u);k(h.program,E);p(h.program,["position","normal","uv","tangent"])}u=h.program}else u=w;if(u!=C){c.useProgram(u);C=u}u==w&&this.setupLights(u,j);this.loadCamera(u,e);this.loadMatrices(u);if(h instanceof THREE.MeshShaderMaterial||
|
|
|
|
-h instanceof THREE.MeshDepthMaterial||h instanceof THREE.MeshNormalMaterial){r=h.wireframe;y=h.wireframe_linewidth;e=u;j=h.uniforms;var R;for(m in j){I=j[m].type;E=j[m].value;R=e.uniforms[m];if(I=="i")c.uniform1i(R,E);else if(I=="f")c.uniform1f(R,E);else if(I=="v3")c.uniform3f(R,E.x,E.y,E.z);else if(I=="c")c.uniform3f(R,E.r,E.g,E.b);else if(I=="t"){c.uniform1i(R,E);if(I=j[m].texture)I.image instanceof Array&&I.image.length==6?d(I,E):i(I,E)}}}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||
|
|
|
|
-h instanceof THREE.MeshBasicMaterial){m=h.color;q=h.opacity;r=h.wireframe;y=h.wireframe_linewidth;K=h.map;F=h.env_map;j=h.combine==THREE.MixOperation;e=h.reflectivity;I=h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping;E=h.refraction_ratio;c.uniform4f(u.uniforms.mColor,m.r*q,m.g*q,m.b*q,q);c.uniform1i(u.uniforms.mixEnvMap,j);c.uniform1f(u.uniforms.mReflectivity,e);c.uniform1i(u.uniforms.useRefract,I);c.uniform1f(u.uniforms.mRefractionRatio,E);if(g){c.uniform3f(u.uniforms.fogColor,
|
|
|
|
-g.color.r,g.color.g,g.color.b);if(g instanceof THREE.Fog){c.uniform1f(u.uniforms.fogNear,g.near);c.uniform1f(u.uniforms.fogFar,g.far)}else g instanceof THREE.FogExp2&&c.uniform1f(u.uniforms.fogDensity,g.density)}}if(h instanceof THREE.MeshPhongMaterial){g=h.ambient;m=h.specular;h=h.shininess;c.uniform4f(u.uniforms.mAmbient,g.r,g.g,g.b,q);c.uniform4f(u.uniforms.mSpecular,m.r,m.g,m.b,q);c.uniform1f(u.uniforms.mShininess,h);c.uniform1i(u.uniforms.material,2)}else if(h instanceof THREE.MeshLambertMaterial)c.uniform1i(u.uniforms.material,
|
|
|
|
-1);else h instanceof THREE.MeshBasicMaterial&&c.uniform1i(u.uniforms.material,0);if(K){i(K,0);c.uniform1i(u.uniforms.tMap,0);c.uniform1i(u.uniforms.enableMap,1)}else c.uniform1i(u.uniforms.enableMap,0);if(F){d(F,1);c.uniform1i(u.uniforms.tCube,1);c.uniform1i(u.uniforms.enableCubeMap,1)}else c.uniform1i(u.uniforms.enableCubeMap,0);q=u.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(r){c.lineWidth(y);
|
|
|
|
-c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);c.drawElements(c.LINES,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(e,j,g,h,n,m,q){var r,y,K,F,E;K=0;for(F=h.materials.length;K<F;K++){r=h.materials[K];if(r instanceof THREE.MeshFaceMaterial){r=0;for(y=n.materials.length;r<y;r++)if((E=n.materials[r])&&E.blending==m&&E.opacity<1==q){this.setBlending(E.blending);
|
|
|
|
-this.renderBuffer(e,j,g,E,n)}}else if((E=r)&&E.blending==m&&E.opacity<1==q){this.setBlending(E.blending);this.renderBuffer(e,j,g,E,n)}}};this.render=function(e,j){var g,h,n,m,q=e.lights,r=e.fog;this.initWebGLObjects(e);this.autoClear&&this.clear();j.autoUpdateMatrix&&j.updateMatrix();S.set(j.matrix.flatten());t.set(j.projectionMatrix.flatten());g=0;for(h=e.__webGLObjects.length;g<h;g++){n=e.__webGLObjects[g];m=n.object;n=n.buffer;if(m.visible){this.setupMatrices(m,j);this.renderPass(j,q,r,m,n,THREE.NormalBlending,
|
|
|
|
-false)}}g=0;for(h=e.__webGLObjects.length;g<h;g++){n=e.__webGLObjects[g];m=n.object;n=n.buffer;if(m.visible){this.setupMatrices(m,j);this.renderPass(j,q,r,m,n,THREE.AdditiveBlending,false);this.renderPass(j,q,r,m,n,THREE.SubtractiveBlending,false);this.renderPass(j,q,r,m,n,THREE.AdditiveBlending,true);this.renderPass(j,q,r,m,n,THREE.SubtractiveBlending,true);this.renderPass(j,q,r,m,n,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var j,g,h,n,m,q;if(!e.__webGLObjects){e.__webGLObjects=
|
|
|
|
-[];e.__webGLObjectsMap={}}j=0;for(g=e.objects.length;j<g;j++){h=e.objects[j];if(e.__webGLObjectsMap[h.id]==undefined)e.__webGLObjectsMap[h.id]={};q=e.__webGLObjectsMap[h.id];if(h instanceof THREE.Mesh)for(m in h.geometry.geometryChunks){n=h.geometry.geometryChunks[m];n.__webGLVertexBuffer||this.createBuffers(h,m);if(q[m]==undefined){n={buffer:n,object:h};e.__webGLObjects.push(n);q[m]=1}}}};this.removeObject=function(e,j){var g,h;for(g=e.__webGLObjects.length-1;g>=0;g--){h=e.__webGLObjects[g].object;
|
|
|
|
-j==h&&e.__webGLObjects.splice(g,1)}};this.setupMatrices=function(e,j){e.autoUpdateMatrix&&e.updateMatrix();v.multiply(j.matrix,e.matrix);Q.set(v.flatten());J=THREE.Matrix4.makeInvert3x3(v).transpose();U.set(J.m);B.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,S);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,Q);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,t);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,U);c.uniformMatrix4fv(e.uniforms.objectMatrix,
|
|
|
|
-false,B)};this.loadCamera=function(e,j){c.uniform3f(e.uniforms.cameraPosition,j.position.x,j.position.y,j.position.z)};this.setBlending=function(e){switch(e){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(e,j){if(e){!j||j=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);
|
|
|
|
-else e=="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};var N={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}",
|
|
|
|
|
|
+k=f(j,k,g);c.useProgram(k);m(k,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);g&&m(k,["fogColor","fogNear","fogFar","fogDensity"]);e&&m(k,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);i&&m(k,["pointLightNumber",
|
|
|
|
+"pointLightColor","pointLightPosition"]);c.uniform1i(k.uniforms.enableMap,0);c.uniform1i(k.uniforms.tMap,0);c.uniform1i(k.uniforms.enableCubeMap,0);c.uniform1i(k.uniforms.tCube,1);c.uniform1i(k.uniforms.mixEnvMap,0);c.uniform1i(k.uniforms.useRefract,0);q(k,["position","normal","uv"]);return k}(J.directional,J.point,fog);this.setSize=function(e,i){o.width=e;o.height=i;c.viewport(0,0,o.width,o.height)};this.setClearColor=function(e,i){var g=new THREE.Color(e);c.clearColor(g.r,g.g,g.b,i)};this.clear=
|
|
|
|
+function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,i){var g,k,j,l,p,r=[],w=[],G=[];l=[];p=[];c.uniform1i(e.uniforms.enableLighting,i.length);g=0;for(k=i.length;g<k;g++){j=i[g];if(j instanceof THREE.AmbientLight)r.push(j);else if(j instanceof THREE.DirectionalLight)G.push(j);else j instanceof THREE.PointLight&&w.push(j)}g=j=l=p=0;for(k=r.length;g<k;g++){j+=r[g].color.r;l+=r[g].color.g;p+=r[g].color.b}c.uniform3f(e.uniforms.ambientLightColor,j,l,p);l=[];p=[];g=0;
|
|
|
|
+for(k=G.length;g<k;g++){j=G[g];l.push(j.color.r*j.intensity);l.push(j.color.g*j.intensity);l.push(j.color.b*j.intensity);p.push(j.position.x);p.push(j.position.y);p.push(j.position.z)}if(G.length){c.uniform1i(e.uniforms.directionalLightNumber,G.length);c.uniform3fv(e.uniforms.directionalLightDirection,p);c.uniform3fv(e.uniforms.directionalLightColor,l)}l=[];p=[];g=0;for(k=w.length;g<k;g++){j=w[g];l.push(j.color.r*j.intensity);l.push(j.color.g*j.intensity);l.push(j.color.b*j.intensity);p.push(j.position.x);
|
|
|
|
+p.push(j.position.y);p.push(j.position.z)}if(w.length){c.uniform1i(e.uniforms.pointLightNumber,w.length);c.uniform3fv(e.uniforms.pointLightPosition,p);c.uniform3fv(e.uniforms.pointLightColor,l)}};this.createBuffers=function(e,i){var g,k,j,l,p,r,w,G,F,E=[],H=[],u=[],V=[],X=[],L=[],y=0,I=e.geometry.geometryChunks[i],S;j=false;g=0;for(k=e.materials.length;g<k;g++){meshMaterial=e.materials[g];if(meshMaterial instanceof THREE.MeshFaceMaterial){p=0;for(S=I.materials.length;p<S;p++)if(I.materials[p]&&I.materials[p].shading!=
|
|
|
|
+undefined&&I.materials[p].shading==THREE.SmoothShading){j=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){j=true;break}if(j)break}S=j;g=0;for(k=I.faces.length;g<k;g++){j=I.faces[g];l=e.geometry.faces[j];p=l.vertexNormals;faceNormal=l.normal;j=e.geometry.uvs[j];if(l instanceof THREE.Face3){r=e.geometry.vertices[l.a].position;w=e.geometry.vertices[l.b].position;G=e.geometry.vertices[l.c].position;u.push(r.x,r.y,r.z);u.push(w.x,w.y,w.z);u.push(G.x,
|
|
|
|
+G.y,G.z);if(e.geometry.hasTangents){r=e.geometry.vertices[l.a].tangent;w=e.geometry.vertices[l.b].tangent;G=e.geometry.vertices[l.c].tangent;X.push(r.x,r.y,r.z,r.w);X.push(w.x,w.y,w.z,w.w);X.push(G.x,G.y,G.z,G.w)}if(p.length==3&&S)for(l=0;l<3;l++)V.push(p[l].x,p[l].y,p[l].z);else for(l=0;l<3;l++)V.push(faceNormal.x,faceNormal.y,faceNormal.z);if(j)for(l=0;l<3;l++)L.push(j[l].u,j[l].v);E.push(y,y+1,y+2);H.push(y,y+1);H.push(y,y+2);H.push(y+1,y+2);y+=3}else if(l instanceof THREE.Face4){r=e.geometry.vertices[l.a].position;
|
|
|
|
+w=e.geometry.vertices[l.b].position;G=e.geometry.vertices[l.c].position;F=e.geometry.vertices[l.d].position;u.push(r.x,r.y,r.z);u.push(w.x,w.y,w.z);u.push(G.x,G.y,G.z);u.push(F.x,F.y,F.z);if(e.geometry.hasTangents){r=e.geometry.vertices[l.a].tangent;w=e.geometry.vertices[l.b].tangent;G=e.geometry.vertices[l.c].tangent;l=e.geometry.vertices[l.d].tangent;X.push(r.x,r.y,r.z,r.w);X.push(w.x,w.y,w.z,w.w);X.push(G.x,G.y,G.z,G.w);X.push(l.x,l.y,l.z,l.w)}if(p.length==4&&S)for(l=0;l<4;l++)V.push(p[l].x,p[l].y,
|
|
|
|
+p[l].z);else for(l=0;l<4;l++)V.push(faceNormal.x,faceNormal.y,faceNormal.z);if(j)for(l=0;l<4;l++)L.push(j[l].u,j[l].v);E.push(y,y+1,y+2);E.push(y,y+2,y+3);H.push(y,y+1);H.push(y,y+2);H.push(y,y+3);H.push(y+1,y+2);H.push(y+2,y+3);y+=4}}if(u.length){I.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,I.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(u),c.STATIC_DRAW);I.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,I.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,
|
|
|
|
+new Float32Array(V),c.STATIC_DRAW);if(e.geometry.hasTangents){I.__webGLTangentBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,I.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(X),c.STATIC_DRAW)}if(L.length>0){I.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,I.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(L),c.STATIC_DRAW)}I.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,I.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,
|
|
|
|
+new Uint16Array(E),c.STATIC_DRAW);I.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,I.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(H),c.STATIC_DRAW);I.__webGLFaceCount=E.length;I.__webGLLineCount=H.length}};this.renderBuffer=function(e,i,g,k,j){var l,p,r,w,G,F,E,H,u;if(k instanceof THREE.MeshShaderMaterial||k instanceof THREE.MeshDepthMaterial||k instanceof THREE.MeshNormalMaterial){if(!k.program){if(k instanceof THREE.MeshDepthMaterial){b(k,M.depth);
|
|
|
|
+k.uniforms.mNear.value=e.near;k.uniforms.mFar.value=e.far}else k instanceof THREE.MeshNormalMaterial&&b(k,M.normal);k.program=f(k.fragment_shader,k.vertex_shader,null);E=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(u in k.uniforms)E.push(u);m(k.program,E);q(k.program,["position","normal","uv","tangent"])}u=k.program}else u=x;if(u!=D){c.useProgram(u);D=u}u==x&&this.setupLights(u,i);this.loadCamera(u,e);this.loadMatrices(u);if(k instanceof THREE.MeshShaderMaterial||
|
|
|
|
+k instanceof THREE.MeshDepthMaterial||k instanceof THREE.MeshNormalMaterial){r=k.wireframe;w=k.wireframe_linewidth;e=u;i=k.uniforms;var V;for(l in i){H=i[l].type;E=i[l].value;V=e.uniforms[l];if(H=="i")c.uniform1i(V,E);else if(H=="f")c.uniform1f(V,E);else if(H=="v3")c.uniform3f(V,E.x,E.y,E.z);else if(H=="c")c.uniform3f(V,E.r,E.g,E.b);else if(H=="t"){c.uniform1i(V,E);if(H=i[l].texture)H.image instanceof Array&&H.image.length==6?d(H,E):h(H,E)}}}if(k instanceof THREE.MeshPhongMaterial||k instanceof THREE.MeshLambertMaterial||
|
|
|
|
+k instanceof THREE.MeshBasicMaterial){l=k.color;p=k.opacity;r=k.wireframe;w=k.wireframe_linewidth;G=k.map;F=k.env_map;i=k.combine==THREE.MixOperation;e=k.reflectivity;H=k.env_map&&k.env_map.mapping instanceof THREE.CubeRefractionMapping;E=k.refraction_ratio;c.uniform4f(u.uniforms.mColor,l.r*p,l.g*p,l.b*p,p);c.uniform1i(u.uniforms.mixEnvMap,i);c.uniform1f(u.uniforms.mReflectivity,e);c.uniform1i(u.uniforms.useRefract,H);c.uniform1f(u.uniforms.mRefractionRatio,E);if(g){c.uniform3f(u.uniforms.fogColor,
|
|
|
|
+g.color.r,g.color.g,g.color.b);if(g instanceof THREE.Fog){c.uniform1f(u.uniforms.fogNear,g.near);c.uniform1f(u.uniforms.fogFar,g.far)}else g instanceof THREE.FogExp2&&c.uniform1f(u.uniforms.fogDensity,g.density)}}if(k instanceof THREE.MeshPhongMaterial){g=k.ambient;l=k.specular;k=k.shininess;c.uniform4f(u.uniforms.mAmbient,g.r,g.g,g.b,p);c.uniform4f(u.uniforms.mSpecular,l.r,l.g,l.b,p);c.uniform1f(u.uniforms.mShininess,k);c.uniform1i(u.uniforms.material,2)}else if(k instanceof THREE.MeshLambertMaterial)c.uniform1i(u.uniforms.material,
|
|
|
|
+1);else k instanceof THREE.MeshBasicMaterial&&c.uniform1i(u.uniforms.material,0);if(G){h(G,0);c.uniform1i(u.uniforms.tMap,0);c.uniform1i(u.uniforms.enableMap,1)}else c.uniform1i(u.uniforms.enableMap,0);if(F){d(F,1);c.uniform1i(u.uniforms.tCube,1);c.uniform1i(u.uniforms.enableCubeMap,1)}else c.uniform1i(u.uniforms.enableCubeMap,0);p=u.attributes;c.bindBuffer(c.ARRAY_BUFFER,j.__webGLVertexBuffer);c.vertexAttribPointer(p.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(p.position);if(p.normal>=
|
|
|
|
+0){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLNormalBuffer);c.vertexAttribPointer(p.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(p.normal)}if(p.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLTangentBuffer);c.vertexAttribPointer(p.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(p.tangent)}if(p.uv>=0)if(j.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLUVBuffer);c.vertexAttribPointer(p.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(p.uv)}else c.disableVertexAttribArray(p.uv);if(r){c.lineWidth(w);
|
|
|
|
+c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,j.__webGLLineBuffer);c.drawElements(c.LINES,j.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,j.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,j.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(e,i,g,k,j,l,p){var r,w,G,F,E;G=0;for(F=k.materials.length;G<F;G++){r=k.materials[G];if(r instanceof THREE.MeshFaceMaterial){r=0;for(w=j.materials.length;r<w;r++)if((E=j.materials[r])&&E.blending==l&&E.opacity<1==p){this.setBlending(E.blending);
|
|
|
|
+this.renderBuffer(e,i,g,E,j)}}else if((E=r)&&E.blending==l&&E.opacity<1==p){this.setBlending(E.blending);this.renderBuffer(e,i,g,E,j)}}};this.render=function(e,i){var g,k,j,l,p=e.lights,r=e.fog;this.initWebGLObjects(e);this.autoClear&&this.clear();i.autoUpdateMatrix&&i.updateMatrix();T.set(i.matrix.flatten());s.set(i.projectionMatrix.flatten());g=0;for(k=e.__webGLObjects.length;g<k;g++){j=e.__webGLObjects[g];l=j.object;j=j.buffer;if(l.visible){this.setupMatrices(l,i);this.renderPass(i,p,r,l,j,THREE.NormalBlending,
|
|
|
|
+false)}}g=0;for(k=e.__webGLObjects.length;g<k;g++){j=e.__webGLObjects[g];l=j.object;j=j.buffer;if(l.visible){this.setupMatrices(l,i);this.renderPass(i,p,r,l,j,THREE.AdditiveBlending,false);this.renderPass(i,p,r,l,j,THREE.SubtractiveBlending,false);this.renderPass(i,p,r,l,j,THREE.AdditiveBlending,true);this.renderPass(i,p,r,l,j,THREE.SubtractiveBlending,true);this.renderPass(i,p,r,l,j,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var i,g,k,j,l,p;if(!e.__webGLObjects){e.__webGLObjects=
|
|
|
|
+[];e.__webGLObjectsMap={}}i=0;for(g=e.objects.length;i<g;i++){k=e.objects[i];if(e.__webGLObjectsMap[k.id]==undefined)e.__webGLObjectsMap[k.id]={};p=e.__webGLObjectsMap[k.id];if(k instanceof THREE.Mesh)for(l in k.geometry.geometryChunks){j=k.geometry.geometryChunks[l];j.__webGLVertexBuffer||this.createBuffers(k,l);if(p[l]==undefined){j={buffer:j,object:k};e.__webGLObjects.push(j);p[l]=1}}}};this.removeObject=function(e,i){var g,k;for(g=e.__webGLObjects.length-1;g>=0;g--){k=e.__webGLObjects[g].object;
|
|
|
|
+i==k&&e.__webGLObjects.splice(g,1)}};this.setupMatrices=function(e,i){e.autoUpdateMatrix&&e.updateMatrix();z.multiply(i.matrix,e.matrix);R.set(z.flatten());P=THREE.Matrix4.makeInvert3x3(z).transpose();O.set(P.m);B.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,T);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,R);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,s);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,O);c.uniformMatrix4fv(e.uniforms.objectMatrix,
|
|
|
|
+false,B)};this.loadCamera=function(e,i){c.uniform3f(e.uniforms.cameraPosition,i.position.x,i.position.y,i.position.z)};this.setBlending=function(e){switch(e){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(e,i){if(e){!i||i=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);
|
|
|
|
+else e=="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};var M={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}",
|
|
vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{},fragment_shader:"varying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );\n}",vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"}}};
|
|
vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{},fragment_shader:"varying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );\n}",vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"}}};
|
|
THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=false;this.uvs=[null,null,null]};
|
|
THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=false;this.uvs=[null,null,null]};
|
|
THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
|
|
THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
|