mirror of
https://github.com/wahyd4/three.js.git
synced 2026-08-13 15:05:56 +10:00
Synced with mrdoob's branch.
This commit is contained in:
+67
-67
@@ -12,21 +12,21 @@ THREE.Vector4=function(a,c,d,f){this.x=a||0;this.y=c||0;this.z=d||0;this.w=f||1}
|
||||
THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;this.z=d;this.w=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
|
||||
return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
|
||||
THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
|
||||
THREE.Ray.prototype={intersectScene:function(a){var c,d,f=a.objects,g=[];a=0;for(c=f.length;a<c;a++){d=f[a];if(d instanceof THREE.Mesh)g=g.concat(this.intersectObject(d))}g.sort(function(i,q){return i.distance-q.distance});return g},intersectObject:function(a){function c(U,u,R,C){C=C.clone().subSelf(u);R=R.clone().subSelf(u);var e=U.clone().subSelf(u);U=C.dot(C);u=C.dot(R);C=C.dot(e);var h=R.dot(R);R=R.dot(e);e=1/(U*h-u*u);h=(h*C-u*R)*e;U=(U*R-u*C)*e;return h>0&&U>0&&h+U<1}var d,f,g,i,q,b,m,p,D,F,
|
||||
y,B=a.geometry,S=B.vertices,V=[];d=0;for(f=B.faces.length;d<f;d++){g=B.faces[d];F=this.origin.clone();y=this.direction.clone();i=a.matrix.multiplyVector3(S[g.a].position.clone());q=a.matrix.multiplyVector3(S[g.b].position.clone());b=a.matrix.multiplyVector3(S[g.c].position.clone());m=g instanceof THREE.Face4?a.matrix.multiplyVector3(S[g.d].position.clone()):null;p=a.rotationMatrix.multiplyVector3(g.normal.clone());D=y.dot(p);if(D<0){p=p.dot((new THREE.Vector3).sub(i,F))/D;F=F.addSelf(y.multiplyScalar(p));
|
||||
THREE.Ray.prototype={intersectScene:function(a){var c,d,f=a.objects,g=[];a=0;for(c=f.length;a<c;a++){d=f[a];if(d instanceof THREE.Mesh)g=g.concat(this.intersectObject(d))}g.sort(function(i,q){return i.distance-q.distance});return g},intersectObject:function(a){function c(T,u,R,C){C=C.clone().subSelf(u);R=R.clone().subSelf(u);var e=T.clone().subSelf(u);T=C.dot(C);u=C.dot(R);C=C.dot(e);var h=R.dot(R);R=R.dot(e);e=1/(T*h-u*u);h=(h*C-u*R)*e;T=(T*R-u*C)*e;return h>0&&T>0&&h+T<1}var d,f,g,i,q,b,m,p,D,F,
|
||||
w,A=a.geometry,S=A.vertices,V=[];d=0;for(f=A.faces.length;d<f;d++){g=A.faces[d];F=this.origin.clone();w=this.direction.clone();i=a.matrix.multiplyVector3(S[g.a].position.clone());q=a.matrix.multiplyVector3(S[g.b].position.clone());b=a.matrix.multiplyVector3(S[g.c].position.clone());m=g instanceof THREE.Face4?a.matrix.multiplyVector3(S[g.d].position.clone()):null;p=a.rotationMatrix.multiplyVector3(g.normal.clone());D=w.dot(p);if(D<0){p=p.dot((new THREE.Vector3).sub(i,F))/D;F=F.addSelf(w.multiplyScalar(p));
|
||||
if(g instanceof THREE.Face3){if(c(F,i,q,b)){g={distance:this.origin.distanceTo(F),point:F,face:g,object:a};V.push(g)}}else if(g instanceof THREE.Face4)if(c(F,i,q,m)||c(F,q,b,m)){g={distance:this.origin.distanceTo(F),point:F,face:g,object:a};V.push(g)}}}return V}};
|
||||
THREE.Rectangle=function(){function a(){i=f-c;q=g-d}var c,d,f,g,i,q,b=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return i};this.getHeight=function(){return q};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(m,p,D,F){b=false;c=m;d=p;f=D;g=F;a()};this.addPoint=function(m,p){if(b){b=false;c=m;d=p;f=m;g=p}else{c=c<m?c:m;d=d<p?d:p;f=f>m?f:m;g=g>p?
|
||||
g:p}a()};this.add3Points=function(m,p,D,F,y,B){if(b){b=false;c=m<D?m<y?m:y:D<y?D:y;d=p<F?p<B?p:B:F<B?F:B;f=m>D?m>y?m:y:D>y?D:y;g=p>F?p>B?p:B:F>B?F:B}else{c=m<D?m<y?m<c?m:c:y<c?y:c:D<y?D<c?D:c:y<c?y:c;d=p<F?p<B?p<d?p:d:B<d?B:d:F<B?F<d?F:d:B<d?B:d;f=m>D?m>y?m>f?m:f:y>f?y:f:D>y?D>f?D:f:y>f?y:f;g=p>F?p>B?p>g?p:g:B>g?B:g:F>B?F>g?F:g:B>g?B:g}a()};this.addRectangle=function(m){if(b){b=false;c=m.getLeft();d=m.getTop();f=m.getRight();g=m.getBottom()}else{c=c<m.getLeft()?c:m.getLeft();d=d<m.getTop()?d:m.getTop();
|
||||
g:p}a()};this.add3Points=function(m,p,D,F,w,A){if(b){b=false;c=m<D?m<w?m:w:D<w?D:w;d=p<F?p<A?p:A:F<A?F:A;f=m>D?m>w?m:w:D>w?D:w;g=p>F?p>A?p:A:F>A?F:A}else{c=m<D?m<w?m<c?m:c:w<c?w:c:D<w?D<c?D:c:w<c?w:c;d=p<F?p<A?p<d?p:d:A<d?A:d:F<A?F<d?F:d:A<d?A:d;f=m>D?m>w?m>f?m:f:w>f?w:f:D>w?D>f?D:f:w>f?w:f;g=p>F?p>A?p>g?p:g:A>g?A:g:F>A?F>g?F:g:A>g?A:g}a()};this.addRectangle=function(m){if(b){b=false;c=m.getLeft();d=m.getTop();f=m.getRight();g=m.getBottom()}else{c=c<m.getLeft()?c:m.getLeft();d=d<m.getTop()?d:m.getTop();
|
||||
f=f>m.getRight()?f:m.getRight();g=g>m.getBottom()?g:m.getBottom()}a()};this.inflate=function(m){c-=m;d-=m;f+=m;g+=m;a()};this.minSelf=function(m){c=c>m.getLeft()?c:m.getLeft();d=d>m.getTop()?d:m.getTop();f=f<m.getRight()?f:m.getRight();g=g<m.getBottom()?g:m.getBottom();a()};this.instersects=function(m){return Math.min(f,m.getRight())-Math.max(c,m.getLeft())>=0&&Math.min(g,m.getBottom())-Math.max(d,m.getTop())>=0};this.empty=function(){b=true;g=f=d=c=0;a()};this.isEmpty=function(){return b};this.toString=
|
||||
function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+g+", width: "+i+", 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,c,d,f,g,i,q,b,m,p,D,F,y,B,S,V){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=g||0;this.n22=i||1;this.n23=q||0;this.n24=b||0;this.n31=m||0;this.n32=p||0;this.n33=D||1;this.n34=F||0;this.n41=y||0;this.n42=B||0;this.n43=S||0;this.n44=V||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,c,d,f,g,i,q,b,m,p,D,F,y,B,S,V){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=g;this.n22=i;this.n23=q;this.n24=b;this.n31=m;this.n32=p;this.n33=D;this.n34=F;this.n41=y;this.n42=B;this.n43=S;this.n44=V;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
|
||||
THREE.Matrix4=function(a,c,d,f,g,i,q,b,m,p,D,F,w,A,S,V){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=g||0;this.n22=i||1;this.n23=q||0;this.n24=b||0;this.n31=m||0;this.n32=p||0;this.n33=D||1;this.n34=F||0;this.n41=w||0;this.n42=A||0;this.n43=S||0;this.n44=V||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,c,d,f,g,i,q,b,m,p,D,F,w,A,S,V){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=g;this.n22=i;this.n23=q;this.n24=b;this.n31=m;this.n32=p;this.n33=D;this.n34=F;this.n41=w;this.n42=A;this.n43=S;this.n44=V;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
|
||||
a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var f=new THREE.Vector3,g=new THREE.Vector3,i=new THREE.Vector3;i.sub(a,c).normalize();f.cross(d,i).normalize();g.cross(i,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=i.x;
|
||||
this.n32=i.y;this.n33=i.z;this.n34=-i.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,g=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*g;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*g;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*g;return a},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,g=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*g;a.y=this.n21*c+this.n22*d+this.n23*f+this.n24*
|
||||
g;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*g;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*g;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,f=a.n12,g=a.n13,i=a.n14,q=a.n21,b=a.n22,m=a.n23,p=a.n24,D=a.n31,F=a.n32,
|
||||
y=a.n33,B=a.n34,S=a.n41,V=a.n42,U=a.n43,u=a.n44,R=c.n11,C=c.n12,e=c.n13,h=c.n14,n=c.n21,j=c.n22,o=c.n23,z=c.n24,l=c.n31,s=c.n32,t=c.n33,r=c.n34,k=c.n41,H=c.n42,w=c.n43,L=c.n44;this.n11=d*R+f*n+g*l+i*k;this.n12=d*C+f*j+g*s+i*H;this.n13=d*e+f*o+g*t+i*w;this.n14=d*h+f*z+g*r+i*L;this.n21=q*R+b*n+m*l+p*k;this.n22=q*C+b*j+m*s+p*H;this.n23=q*e+b*o+m*t+p*w;this.n24=q*h+b*z+m*r+p*L;this.n31=D*R+F*n+y*l+B*k;this.n32=D*C+F*j+y*s+B*H;this.n33=D*e+F*o+y*t+B*w;this.n34=D*h+F*z+y*r+B*L;this.n41=S*R+V*n+U*l+u*k;
|
||||
this.n42=S*C+V*j+U*s+u*H;this.n43=S*e+V*o+U*t+u*w;this.n44=S*h+V*z+U*r+u*L;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,g=this.n14,i=this.n21,q=this.n22,b=this.n23,m=this.n24,p=this.n31,D=this.n32,F=this.n33,y=this.n34,B=this.n41,S=this.n42,V=this.n43,U=this.n44,u=a.n11,R=a.n21,C=a.n31,e=a.n41,h=a.n12,n=a.n22,j=a.n32,o=a.n42,z=a.n13,l=a.n23,s=a.n33,t=a.n43,r=a.n14,k=a.n24,H=a.n34;a=a.n44;this.n11=c*u+d*R+f*C+g*e;this.n12=c*h+d*n+f*j+g*o;this.n13=c*z+d*l+f*s+g*t;this.n14=
|
||||
c*r+d*k+f*H+g*a;this.n21=i*u+q*R+b*C+m*e;this.n22=i*h+q*n+b*j+m*o;this.n23=i*z+q*l+b*s+m*t;this.n24=i*r+q*k+b*H+m*a;this.n31=p*u+D*R+F*C+y*e;this.n32=p*h+D*n+F*j+y*o;this.n33=p*z+D*l+F*s+y*t;this.n34=p*r+D*k+F*H+y*a;this.n41=B*u+S*R+V*C+U*e;this.n42=B*h+S*n+V*j+U*o;this.n43=B*z+S*l+V*s+U*t;this.n44=B*r+S*k+V*H+U*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*=
|
||||
w=a.n33,A=a.n34,S=a.n41,V=a.n42,T=a.n43,u=a.n44,R=c.n11,C=c.n12,e=c.n13,h=c.n14,n=c.n21,j=c.n22,o=c.n23,z=c.n24,l=c.n31,s=c.n32,t=c.n33,r=c.n34,k=c.n41,H=c.n42,x=c.n43,L=c.n44;this.n11=d*R+f*n+g*l+i*k;this.n12=d*C+f*j+g*s+i*H;this.n13=d*e+f*o+g*t+i*x;this.n14=d*h+f*z+g*r+i*L;this.n21=q*R+b*n+m*l+p*k;this.n22=q*C+b*j+m*s+p*H;this.n23=q*e+b*o+m*t+p*x;this.n24=q*h+b*z+m*r+p*L;this.n31=D*R+F*n+w*l+A*k;this.n32=D*C+F*j+w*s+A*H;this.n33=D*e+F*o+w*t+A*x;this.n34=D*h+F*z+w*r+A*L;this.n41=S*R+V*n+T*l+u*k;
|
||||
this.n42=S*C+V*j+T*s+u*H;this.n43=S*e+V*o+T*t+u*x;this.n44=S*h+V*z+T*r+u*L;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,g=this.n14,i=this.n21,q=this.n22,b=this.n23,m=this.n24,p=this.n31,D=this.n32,F=this.n33,w=this.n34,A=this.n41,S=this.n42,V=this.n43,T=this.n44,u=a.n11,R=a.n21,C=a.n31,e=a.n41,h=a.n12,n=a.n22,j=a.n32,o=a.n42,z=a.n13,l=a.n23,s=a.n33,t=a.n43,r=a.n14,k=a.n24,H=a.n34;a=a.n44;this.n11=c*u+d*R+f*C+g*e;this.n12=c*h+d*n+f*j+g*o;this.n13=c*z+d*l+f*s+g*t;this.n14=
|
||||
c*r+d*k+f*H+g*a;this.n21=i*u+q*R+b*C+m*e;this.n22=i*h+q*n+b*j+m*o;this.n23=i*z+q*l+b*s+m*t;this.n24=i*r+q*k+b*H+m*a;this.n31=p*u+D*R+F*C+w*e;this.n32=p*h+D*n+F*j+w*o;this.n33=p*z+D*l+F*s+w*t;this.n34=p*r+D*k+F*H+w*a;this.n41=A*u+S*R+V*C+T*e;this.n42=A*h+S*n+V*j+T*o;this.n43=A*z+S*l+V*s+T*t;this.n44=A*r+S*k+V*H+T*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=
|
||||
a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*
|
||||
this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(c,d,f){var g=c[d];c[d]=c[f];
|
||||
c[f]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
|
||||
@@ -48,8 +48,8 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.f
|
||||
d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,f,g,i,q,b=new THREE.Vector3,m=new THREE.Vector3;f=0;for(g=this.vertices.length;f<g;f++){i=this.vertices[f];i.normal.set(0,0,0)}f=0;for(g=this.faces.length;f<g;f++){i=this.faces[f];if(a&&i.vertexNormals.length){b.set(0,0,0);c=0;for(d=i.normal.length;c<d;c++)b.addSelf(i.vertexNormals[c]);b.divideScalar(3)}else{c=this.vertices[i.a];d=this.vertices[i.b];q=this.vertices[i.c];b.sub(q.position,
|
||||
d.position);m.sub(c.position,d.position);b.crossSelf(m)}b.isZero()||b.normalize();i.normal.copy(b)}},computeVertexNormals:function(){var a,c,d,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
|
||||
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal);f[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
|
||||
c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c]);d.vertexNormals[3].copy(f[d.d])}}},computeTangents:function(){function a(r,k,H,w,L,K,G){i=r.vertices[k].position;q=r.vertices[H].position;b=r.vertices[w].position;m=g[L];p=g[K];D=g[G];F=q.x-i.x;y=b.x-i.x;B=q.y-i.y;S=b.y-i.y;
|
||||
V=q.z-i.z;U=b.z-i.z;u=p.u-m.u;R=D.u-m.u;C=p.v-m.v;e=D.v-m.v;h=1/(u*e-R*C);o.set((e*F-C*y)*h,(e*B-C*S)*h,(e*V-C*U)*h);z.set((u*y-R*F)*h,(u*S-R*B)*h,(u*U-R*V)*h);n[k].addSelf(o);n[H].addSelf(o);n[w].addSelf(o);j[k].addSelf(z);j[H].addSelf(z);j[w].addSelf(z)}var c,d,f,g,i,q,b,m,p,D,F,y,B,S,V,U,u,R,C,e,h,n=[],j=[],o=new THREE.Vector3,z=new THREE.Vector3,l=new THREE.Vector3,s=new THREE.Vector3,t=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){n[c]=new THREE.Vector3;j[c]=new THREE.Vector3}c=0;
|
||||
c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c]);d.vertexNormals[3].copy(f[d.d])}}},computeTangents:function(){function a(r,k,H,x,L,K,G){i=r.vertices[k].position;q=r.vertices[H].position;b=r.vertices[x].position;m=g[L];p=g[K];D=g[G];F=q.x-i.x;w=b.x-i.x;A=q.y-i.y;S=b.y-i.y;
|
||||
V=q.z-i.z;T=b.z-i.z;u=p.u-m.u;R=D.u-m.u;C=p.v-m.v;e=D.v-m.v;h=1/(u*e-R*C);o.set((e*F-C*w)*h,(e*A-C*S)*h,(e*V-C*T)*h);z.set((u*w-R*F)*h,(u*S-R*A)*h,(u*T-R*V)*h);n[k].addSelf(o);n[H].addSelf(o);n[x].addSelf(o);j[k].addSelf(z);j[H].addSelf(z);j[x].addSelf(z)}var c,d,f,g,i,q,b,m,p,D,F,w,A,S,V,T,u,R,C,e,h,n=[],j=[],o=new THREE.Vector3,z=new THREE.Vector3,l=new THREE.Vector3,s=new THREE.Vector3,t=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){n[c]=new THREE.Vector3;j[c]=new THREE.Vector3}c=0;
|
||||
for(d=this.faces.length;c<d;c++){f=this.faces[c];g=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
|
||||
this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){t.copy(this.vertices[c].normal);f=n[c];l.copy(f);l.subSelf(t.multiplyScalar(t.dot(f))).normalize();s.cross(this.vertices[c].normal,f);f=s.dot(j[c]);f=f<0?-1:1;this.vertices[c].tangent.set(l.x,l.y,l.z,f)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
|
||||
z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
|
||||
@@ -99,74 +99,74 @@ var Uniforms={clone:function(a){var c,d,f,g={};for(c in a){g[c]={};for(d in a[c]
|
||||
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
|
||||
THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
|
||||
THREE.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
|
||||
THREE.Projector=function(){function a(j,o){return o.z-j.z}function c(j,o){var z=0,l=1,s=j.z+j.w,t=o.z+o.w,r=-j.z+j.w,k=-o.z+o.w;if(s>=0&&t>=0&&r>=0&&k>=0)return true;else if(s<0&&t<0||r<0&&k<0)return false;else{if(s<0)z=Math.max(z,s/(s-t));else if(t<0)l=Math.min(l,s/(s-t));if(r<0)z=Math.max(z,r/(r-k));else if(k<0)l=Math.min(l,r/(r-k));if(l<z)return false;else{j.lerpSelf(o,z);o.lerpSelf(j,1-l);return true}}}var d,f,g=[],i,q,b,m=[],p,D,F=[],y,B,S=[],V=new THREE.Vector4,U=new THREE.Vector4,u=new THREE.Matrix4,
|
||||
THREE.Projector=function(){function a(j,o){return o.z-j.z}function c(j,o){var z=0,l=1,s=j.z+j.w,t=o.z+o.w,r=-j.z+j.w,k=-o.z+o.w;if(s>=0&&t>=0&&r>=0&&k>=0)return true;else if(s<0&&t<0||r<0&&k<0)return false;else{if(s<0)z=Math.max(z,s/(s-t));else if(t<0)l=Math.min(l,s/(s-t));if(r<0)z=Math.max(z,r/(r-k));else if(k<0)l=Math.min(l,r/(r-k));if(l<z)return false;else{j.lerpSelf(o,z);o.lerpSelf(j,1-l);return true}}}var d,f,g=[],i,q,b,m=[],p,D,F=[],w,A,S=[],V=new THREE.Vector4,T=new THREE.Vector4,u=new THREE.Matrix4,
|
||||
R=new THREE.Matrix4,C=[],e=new THREE.Vector4,h=new THREE.Vector4,n;this.projectObjects=function(j,o,z){var l=[],s,t;f=0;u.multiply(o.projectionMatrix,o.matrix);C[0]=new THREE.Vector4(u.n41-u.n11,u.n42-u.n12,u.n43-u.n13,u.n44-u.n14);C[1]=new THREE.Vector4(u.n41+u.n11,u.n42+u.n12,u.n43+u.n13,u.n44+u.n14);C[2]=new THREE.Vector4(u.n41+u.n21,u.n42+u.n22,u.n43+u.n23,u.n44+u.n24);C[3]=new THREE.Vector4(u.n41-u.n21,u.n42-u.n22,u.n43-u.n23,u.n44-u.n24);C[4]=new THREE.Vector4(u.n41-u.n31,u.n42-u.n32,u.n43-
|
||||
u.n33,u.n44-u.n34);C[5]=new THREE.Vector4(u.n41+u.n31,u.n42+u.n32,u.n43+u.n33,u.n44+u.n34);o=0;for(s=C.length;o<s;o++){t=C[o];t.divideScalar(Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z))}s=j.objects;j=0;for(o=s.length;j<o;j++){t=s[j];var r;if(!(r=!t.visible)){if(r=t instanceof THREE.Mesh){a:{r=void 0;for(var k=t.position,H=-t.geometry.boundingSphere.radius*Math.max(t.scale.x,Math.max(t.scale.y,t.scale.z)),w=0;w<6;w++){r=C[w].x*k.x+C[w].y*k.y+C[w].z*k.z+C[w].w;if(r<=H){r=false;break a}}r=true}r=!r}r=r}if(!r){d=
|
||||
g[f]=g[f]||new THREE.RenderableObject;V.copy(t.position);u.multiplyVector3(V);d.object=t;d.z=V.z;l.push(d);f++}}z&&l.sort(a);return l};this.projectScene=function(j,o,z){var l=[],s=o.near,t=o.far,r,k,H,w,L,K,G,Z,Q,E,J,T,O,v,I,M;b=D=B=0;o.autoUpdateMatrix&&o.updateMatrix();u.multiply(o.projectionMatrix,o.matrix);K=this.projectObjects(j,o,true);j=0;for(r=K.length;j<r;j++){G=K[j].object;if(G.visible){G.autoUpdateMatrix&&G.updateMatrix();Z=G.matrix;Q=G.rotationMatrix;E=G.materials;J=G.overdraw;if(G instanceof
|
||||
THREE.Mesh){T=G.geometry;O=T.vertices;k=0;for(H=O.length;k<H;k++){v=O[k];v.positionWorld.copy(v.position);Z.multiplyVector3(v.positionWorld);w=v.positionScreen;w.copy(v.positionWorld);u.multiplyVector4(w);w.x/=w.w;w.y/=w.w;v.__visible=w.z>s&&w.z<t}T=T.faces;k=0;for(H=T.length;k<H;k++){v=T[k];if(v instanceof THREE.Face3){w=O[v.a];L=O[v.b];I=O[v.c];if(w.__visible&&L.__visible&&I.__visible)if(G.doubleSided||G.flipSided!=(I.positionScreen.x-w.positionScreen.x)*(L.positionScreen.y-w.positionScreen.y)-
|
||||
(I.positionScreen.y-w.positionScreen.y)*(L.positionScreen.x-w.positionScreen.x)<0){i=m[b]=m[b]||new THREE.RenderableFace3;i.v1.positionWorld.copy(w.positionWorld);i.v2.positionWorld.copy(L.positionWorld);i.v3.positionWorld.copy(I.positionWorld);i.v1.positionScreen.copy(w.positionScreen);i.v2.positionScreen.copy(L.positionScreen);i.v3.positionScreen.copy(I.positionScreen);i.normalWorld.copy(v.normal);Q.multiplyVector3(i.normalWorld);i.centroidWorld.copy(v.centroid);Z.multiplyVector3(i.centroidWorld);
|
||||
i.centroidScreen.copy(i.centroidWorld);u.multiplyVector3(i.centroidScreen);I=v.vertexNormals;n=i.vertexNormalsWorld;w=0;for(L=I.length;w<L;w++){M=n[w]=n[w]||new THREE.Vector3;M.copy(I[w]);Q.multiplyVector3(M)}i.z=i.centroidScreen.z;i.meshMaterials=E;i.faceMaterials=v.materials;i.overdraw=J;if(G.geometry.uvs[k]){i.uvs[0]=G.geometry.uvs[k][0];i.uvs[1]=G.geometry.uvs[k][1];i.uvs[2]=G.geometry.uvs[k][2]}l.push(i);b++}}else if(v instanceof THREE.Face4){w=O[v.a];L=O[v.b];I=O[v.c];M=O[v.d];if(w.__visible&&
|
||||
L.__visible&&I.__visible&&M.__visible)if(G.doubleSided||G.flipSided!=((M.positionScreen.x-w.positionScreen.x)*(L.positionScreen.y-w.positionScreen.y)-(M.positionScreen.y-w.positionScreen.y)*(L.positionScreen.x-w.positionScreen.x)<0||(L.positionScreen.x-I.positionScreen.x)*(M.positionScreen.y-I.positionScreen.y)-(L.positionScreen.y-I.positionScreen.y)*(M.positionScreen.x-I.positionScreen.x)<0)){i=m[b]=m[b]||new THREE.RenderableFace3;i.v1.positionWorld.copy(w.positionWorld);i.v2.positionWorld.copy(L.positionWorld);
|
||||
i.v3.positionWorld.copy(M.positionWorld);i.v1.positionScreen.copy(w.positionScreen);i.v2.positionScreen.copy(L.positionScreen);i.v3.positionScreen.copy(M.positionScreen);i.normalWorld.copy(v.normal);Q.multiplyVector3(i.normalWorld);i.centroidWorld.copy(v.centroid);Z.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);u.multiplyVector3(i.centroidScreen);i.z=i.centroidScreen.z;i.meshMaterials=E;i.faceMaterials=v.materials;i.overdraw=J;if(G.geometry.uvs[k]){i.uvs[0]=G.geometry.uvs[k][0];
|
||||
u.n33,u.n44-u.n34);C[5]=new THREE.Vector4(u.n41+u.n31,u.n42+u.n32,u.n43+u.n33,u.n44+u.n34);o=0;for(s=C.length;o<s;o++){t=C[o];t.divideScalar(Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z))}s=j.objects;j=0;for(o=s.length;j<o;j++){t=s[j];var r;if(!(r=!t.visible)){if(r=t instanceof THREE.Mesh){a:{r=void 0;for(var k=t.position,H=-t.geometry.boundingSphere.radius*Math.max(t.scale.x,Math.max(t.scale.y,t.scale.z)),x=0;x<6;x++){r=C[x].x*k.x+C[x].y*k.y+C[x].z*k.z+C[x].w;if(r<=H){r=false;break a}}r=true}r=!r}r=r}if(!r){d=
|
||||
g[f]=g[f]||new THREE.RenderableObject;V.copy(t.position);u.multiplyVector3(V);d.object=t;d.z=V.z;l.push(d);f++}}z&&l.sort(a);return l};this.projectScene=function(j,o,z){var l=[],s=o.near,t=o.far,r,k,H,x,L,K,G,Z,Q,E,J,U,O,v,I,M;b=D=A=0;o.autoUpdateMatrix&&o.updateMatrix();u.multiply(o.projectionMatrix,o.matrix);K=this.projectObjects(j,o,true);j=0;for(r=K.length;j<r;j++){G=K[j].object;if(G.visible){G.autoUpdateMatrix&&G.updateMatrix();Z=G.matrix;Q=G.rotationMatrix;E=G.materials;J=G.overdraw;if(G instanceof
|
||||
THREE.Mesh){U=G.geometry;O=U.vertices;k=0;for(H=O.length;k<H;k++){v=O[k];v.positionWorld.copy(v.position);Z.multiplyVector3(v.positionWorld);x=v.positionScreen;x.copy(v.positionWorld);u.multiplyVector4(x);x.x/=x.w;x.y/=x.w;v.__visible=x.z>s&&x.z<t}U=U.faces;k=0;for(H=U.length;k<H;k++){v=U[k];if(v instanceof THREE.Face3){x=O[v.a];L=O[v.b];I=O[v.c];if(x.__visible&&L.__visible&&I.__visible)if(G.doubleSided||G.flipSided!=(I.positionScreen.x-x.positionScreen.x)*(L.positionScreen.y-x.positionScreen.y)-
|
||||
(I.positionScreen.y-x.positionScreen.y)*(L.positionScreen.x-x.positionScreen.x)<0){i=m[b]=m[b]||new THREE.RenderableFace3;i.v1.positionWorld.copy(x.positionWorld);i.v2.positionWorld.copy(L.positionWorld);i.v3.positionWorld.copy(I.positionWorld);i.v1.positionScreen.copy(x.positionScreen);i.v2.positionScreen.copy(L.positionScreen);i.v3.positionScreen.copy(I.positionScreen);i.normalWorld.copy(v.normal);Q.multiplyVector3(i.normalWorld);i.centroidWorld.copy(v.centroid);Z.multiplyVector3(i.centroidWorld);
|
||||
i.centroidScreen.copy(i.centroidWorld);u.multiplyVector3(i.centroidScreen);I=v.vertexNormals;n=i.vertexNormalsWorld;x=0;for(L=I.length;x<L;x++){M=n[x]=n[x]||new THREE.Vector3;M.copy(I[x]);Q.multiplyVector3(M)}i.z=i.centroidScreen.z;i.meshMaterials=E;i.faceMaterials=v.materials;i.overdraw=J;if(G.geometry.uvs[k]){i.uvs[0]=G.geometry.uvs[k][0];i.uvs[1]=G.geometry.uvs[k][1];i.uvs[2]=G.geometry.uvs[k][2]}l.push(i);b++}}else if(v instanceof THREE.Face4){x=O[v.a];L=O[v.b];I=O[v.c];M=O[v.d];if(x.__visible&&
|
||||
L.__visible&&I.__visible&&M.__visible)if(G.doubleSided||G.flipSided!=((M.positionScreen.x-x.positionScreen.x)*(L.positionScreen.y-x.positionScreen.y)-(M.positionScreen.y-x.positionScreen.y)*(L.positionScreen.x-x.positionScreen.x)<0||(L.positionScreen.x-I.positionScreen.x)*(M.positionScreen.y-I.positionScreen.y)-(L.positionScreen.y-I.positionScreen.y)*(M.positionScreen.x-I.positionScreen.x)<0)){i=m[b]=m[b]||new THREE.RenderableFace3;i.v1.positionWorld.copy(x.positionWorld);i.v2.positionWorld.copy(L.positionWorld);
|
||||
i.v3.positionWorld.copy(M.positionWorld);i.v1.positionScreen.copy(x.positionScreen);i.v2.positionScreen.copy(L.positionScreen);i.v3.positionScreen.copy(M.positionScreen);i.normalWorld.copy(v.normal);Q.multiplyVector3(i.normalWorld);i.centroidWorld.copy(v.centroid);Z.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);u.multiplyVector3(i.centroidScreen);i.z=i.centroidScreen.z;i.meshMaterials=E;i.faceMaterials=v.materials;i.overdraw=J;if(G.geometry.uvs[k]){i.uvs[0]=G.geometry.uvs[k][0];
|
||||
i.uvs[1]=G.geometry.uvs[k][1];i.uvs[2]=G.geometry.uvs[k][3]}l.push(i);b++;q=m[b]=m[b]||new THREE.RenderableFace3;q.v1.positionWorld.copy(L.positionWorld);q.v2.positionWorld.copy(I.positionWorld);q.v3.positionWorld.copy(M.positionWorld);q.v1.positionScreen.copy(L.positionScreen);q.v2.positionScreen.copy(I.positionScreen);q.v3.positionScreen.copy(M.positionScreen);q.normalWorld.copy(i.normalWorld);q.centroidWorld.copy(i.centroidWorld);q.centroidScreen.copy(i.centroidScreen);q.z=q.centroidScreen.z;q.meshMaterials=
|
||||
E;q.faceMaterials=v.materials;q.overdraw=J;if(G.geometry.uvs[k]){q.uvs[0]=G.geometry.uvs[k][1];q.uvs[1]=G.geometry.uvs[k][2];q.uvs[2]=G.geometry.uvs[k][3]}l.push(q);b++}}}}else if(G instanceof THREE.Line){R.multiply(u,Z);O=G.geometry.vertices;v=O[0];v.positionScreen.copy(v.position);R.multiplyVector4(v.positionScreen);k=1;for(H=O.length;k<H;k++){w=O[k];w.positionScreen.copy(w.position);R.multiplyVector4(w.positionScreen);L=O[k-1];e.copy(w.positionScreen);h.copy(L.positionScreen);if(c(e,h)){e.multiplyScalar(1/
|
||||
e.w);h.multiplyScalar(1/h.w);p=F[D]=F[D]||new THREE.RenderableLine;p.v1.positionScreen.copy(e);p.v2.positionScreen.copy(h);p.z=Math.max(e.z,h.z);p.materials=G.materials;l.push(p);D++}}}else if(G instanceof THREE.Particle){U.set(G.position.x,G.position.y,G.position.z,1);u.multiplyVector4(U);U.z/=U.w;if(U.z>0&&U.z<1){y=S[B]=S[B]||new THREE.RenderableParticle;y.x=U.x/U.w;y.y=U.y/U.w;y.z=U.z;y.rotation=G.rotation.z;y.scale.x=G.scale.x*Math.abs(y.x-(U.x+o.projectionMatrix.n11)/(U.w+o.projectionMatrix.n14));
|
||||
y.scale.y=G.scale.y*Math.abs(y.y-(U.y+o.projectionMatrix.n22)/(U.w+o.projectionMatrix.n24));y.materials=G.materials;l.push(y);B++}}}}z&&l.sort(a);return l};this.unprojectVector=function(j,o){var z=new THREE.Matrix4;z.multiply(THREE.Matrix4.makeInvert(o.matrix),THREE.Matrix4.makeInvert(o.projectionMatrix));z.multiplyVector3(j);return j}};
|
||||
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,g,i;this.domElement=document.createElement("div");this.setSize=function(q,b){d=q;f=b;g=d/2;i=f/2};this.render=function(q,b){var m,p,D,F,y,B,S,V;a=c.projectScene(q,b);m=0;for(p=a.length;m<p;m++){y=a[m];if(y instanceof THREE.RenderableParticle){S=y.x*g+g;V=y.y*i+i;D=0;for(F=y.material.length;D<F;D++){B=y.material[D];if(B instanceof THREE.ParticleDOMMaterial){B=B.domElement;B.style.left=S+"px";B.style.top=V+"px"}}}}}};
|
||||
THREE.CanvasRenderer=function(){function a(da){if(y!=da)p.globalAlpha=y=da}function c(da){if(B!=da){switch(da){case THREE.NormalBlending:p.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:p.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:p.globalCompositeOperation="darker"}B=da}}var d=null,f=new THREE.Projector,g=document.createElement("canvas"),i,q,b,m,p=g.getContext("2d"),D=null,F=null,y=1,B=0,S=null,V=null,U=1,u,R,C,e,h,n,j,o,z,l=new THREE.Color,
|
||||
s=new THREE.Color,t=new THREE.Color,r=new THREE.Color,k=new THREE.Color,H,w,L,K,G,Z,Q,E,J,T=new THREE.Rectangle,O=new THREE.Rectangle,v=new THREE.Rectangle,I=false,M=new THREE.Color,ea=new THREE.Color,ba=new THREE.Color,Y=new THREE.Color,ja=Math.PI*2,X=new THREE.Vector3,qa,ka,fa,ha,sa,ua,va=16;qa=document.createElement("canvas");qa.width=qa.height=2;ka=qa.getContext("2d");ka.fillStyle="rgba(0,0,0,1)";ka.fillRect(0,0,2,2);fa=ka.getImageData(0,0,2,2);ha=fa.data;sa=document.createElement("canvas");sa.width=
|
||||
sa.height=va;ua=sa.getContext("2d");ua.translate(-va/2,-va/2);ua.scale(va,va);va--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(da,ra){i=da;q=ra;b=i/2;m=q/2;g.width=i;g.height=q;T.set(-b,-m,b,m)};this.setClearColor=function(da,ra){D=da!==null?new THREE.Color(da):null;F=ra;O.set(-b,-m,b,m);p.setTransform(1,0,0,-1,b,m);this.clear()};this.clear=function(){if(!O.isEmpty()){O.inflate(1);O.minSelf(T);if(D!==null){c(THREE.NormalBlending);a(1);p.fillStyle=
|
||||
"rgba("+Math.floor(D.r*255)+","+Math.floor(D.g*255)+","+Math.floor(D.b*255)+","+F+")";p.fillRect(O.getX(),O.getY(),O.getWidth(),O.getHeight())}else p.clearRect(O.getX(),O.getY(),O.getWidth(),O.getHeight());O.empty()}};this.render=function(da,ra){function Ma(x){var W,P,A,N=x.lights;ea.setRGB(0,0,0);ba.setRGB(0,0,0);Y.setRGB(0,0,0);x=0;for(W=N.length;x<W;x++){P=N[x];A=P.color;if(P instanceof THREE.AmbientLight){ea.r+=A.r;ea.g+=A.g;ea.b+=A.b}else if(P instanceof THREE.DirectionalLight){ba.r+=A.r;ba.g+=
|
||||
A.g;ba.b+=A.b}else if(P instanceof THREE.PointLight){Y.r+=A.r;Y.g+=A.g;Y.b+=A.b}}}function Aa(x,W,P,A){var N,$,ca,ga,ia=x.lights;x=0;for(N=ia.length;x<N;x++){$=ia[x];ca=$.color;ga=$.intensity;if($ instanceof THREE.DirectionalLight){$=P.dot($.position)*ga;if($>0){A.r+=ca.r*$;A.g+=ca.g*$;A.b+=ca.b*$}}else if($ instanceof THREE.PointLight){X.sub($.position,W);X.normalize();$=P.dot(X)*ga;if($>0){A.r+=ca.r*$;A.g+=ca.g*$;A.b+=ca.b*$}}}}function Na(x,W,P){if(P.opacity!=0){a(P.opacity);c(P.blending);var A,
|
||||
N,$,ca,ga,ia;if(P instanceof THREE.ParticleBasicMaterial){if(P.map){ca=P.map;ga=ca.width>>1;ia=ca.height>>1;N=W.scale.x*b;$=W.scale.y*m;P=N*ga;A=$*ia;v.set(x.x-P,x.y-A,x.x+P,x.y+A);if(T.instersects(v)){p.save();p.translate(x.x,x.y);p.rotate(-W.rotation);p.scale(N,-$);p.translate(-ga,-ia);p.drawImage(ca,0,0);p.restore()}}}else if(P instanceof THREE.ParticleCircleMaterial){if(I){M.r=ea.r+ba.r+Y.r;M.g=ea.g+ba.g+Y.g;M.b=ea.b+ba.b+Y.b;l.r=P.color.r*M.r;l.g=P.color.g*M.g;l.b=P.color.b*M.b;l.updateStyleString()}else l.__styleString=
|
||||
P.color.__styleString;P=W.scale.x*b;A=W.scale.y*m;v.set(x.x-P,x.y-A,x.x+P,x.y+A);if(T.instersects(v)){N=l.__styleString;if(V!=N)p.fillStyle=V=N;p.save();p.translate(x.x,x.y);p.rotate(-W.rotation);p.scale(P,A);p.beginPath();p.arc(0,0,1,0,ja,true);p.closePath();p.fill();p.restore()}}}}function Oa(x,W,P,A){if(A.opacity!=0){a(A.opacity);c(A.blending);p.beginPath();p.moveTo(x.positionScreen.x,x.positionScreen.y);p.lineTo(W.positionScreen.x,W.positionScreen.y);p.closePath();if(A instanceof THREE.LineBasicMaterial){l.__styleString=
|
||||
A.color.__styleString;x=A.linewidth;if(U!=x)p.lineWidth=U=x;x=l.__styleString;if(S!=x)p.strokeStyle=S=x;p.stroke();v.inflate(A.linewidth*2)}}}function Ia(x,W,P,A,N,$){if(N.opacity!=0){a(N.opacity);c(N.blending);e=x.positionScreen.x;h=x.positionScreen.y;n=W.positionScreen.x;j=W.positionScreen.y;o=P.positionScreen.x;z=P.positionScreen.y;p.beginPath();p.moveTo(e,h);p.lineTo(n,j);p.lineTo(o,z);p.lineTo(e,h);p.closePath();if(N instanceof THREE.MeshBasicMaterial)if(N.map)N.map.image.loaded&&N.map.mapping instanceof
|
||||
THREE.UVMapping&&xa(e,h,n,j,o,z,N.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(N.env_map){if(N.env_map.image.loaded)if(N.env_map.mapping instanceof THREE.SphericalReflectionMapping){x=ra.matrix;X.copy(A.vertexNormalsWorld[0]);K=(X.x*x.n11+X.y*x.n12+X.z*x.n13)*0.5+0.5;G=-(X.x*x.n21+X.y*x.n22+X.z*x.n23)*0.5+0.5;X.copy(A.vertexNormalsWorld[1]);Z=(X.x*x.n11+X.y*x.n12+X.z*x.n13)*0.5+0.5;Q=-(X.x*x.n21+X.y*x.n22+X.z*x.n23)*0.5+0.5;X.copy(A.vertexNormalsWorld[2]);E=
|
||||
(X.x*x.n11+X.y*x.n12+X.z*x.n13)*0.5+0.5;J=-(X.x*x.n21+X.y*x.n22+X.z*x.n23)*0.5+0.5;xa(e,h,n,j,o,z,N.env_map.image,K,G,Z,Q,E,J)}}else N.wireframe?Ba(N.color.__styleString,N.wireframe_linewidth):Ca(N.color.__styleString);else if(N instanceof THREE.MeshLambertMaterial){if(N.map&&!N.wireframe){N.map.mapping instanceof THREE.UVMapping&&xa(e,h,n,j,o,z,N.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);c(THREE.SubtractiveBlending)}if(I)if(!N.wireframe&&N.shading==THREE.SmoothShading&&
|
||||
A.vertexNormalsWorld.length==3){s.r=t.r=r.r=ea.r;s.g=t.g=r.g=ea.g;s.b=t.b=r.b=ea.b;Aa($,A.v1.positionWorld,A.vertexNormalsWorld[0],s);Aa($,A.v2.positionWorld,A.vertexNormalsWorld[1],t);Aa($,A.v3.positionWorld,A.vertexNormalsWorld[2],r);k.r=(t.r+r.r)*0.5;k.g=(t.g+r.g)*0.5;k.b=(t.b+r.b)*0.5;L=Ja(s,t,r,k);xa(e,h,n,j,o,z,L,0,0,1,0,0,1)}else{M.r=ea.r;M.g=ea.g;M.b=ea.b;Aa($,A.centroidWorld,A.normalWorld,M);l.r=N.color.r*M.r;l.g=N.color.g*M.g;l.b=N.color.b*M.b;l.updateStyleString();N.wireframe?Ba(l.__styleString,
|
||||
N.wireframe_linewidth):Ca(l.__styleString)}else N.wireframe?Ba(N.color.__styleString,N.wireframe_linewidth):Ca(N.color.__styleString)}else if(N instanceof THREE.MeshDepthMaterial){H=ra.near;w=ra.far;s.r=s.g=s.b=1-Ea(x.positionScreen.z,H,w);t.r=t.g=t.b=1-Ea(W.positionScreen.z,H,w);r.r=r.g=r.b=1-Ea(P.positionScreen.z,H,w);k.r=(t.r+r.r)*0.5;k.g=(t.g+r.g)*0.5;k.b=(t.b+r.b)*0.5;L=Ja(s,t,r,k);xa(e,h,n,j,o,z,L,0,0,1,0,0,1)}else if(N instanceof THREE.MeshNormalMaterial){l.r=Fa(A.normalWorld.x);l.g=Fa(A.normalWorld.y);
|
||||
l.b=Fa(A.normalWorld.z);l.updateStyleString();N.wireframe?Ba(l.__styleString,N.wireframe_linewidth):Ca(l.__styleString)}}}function Ba(x,W){if(S!=x)p.strokeStyle=S=x;if(U!=W)p.lineWidth=U=W;p.stroke();v.inflate(W*2)}function Ca(x){if(V!=x)p.fillStyle=V=x;p.fill()}function xa(x,W,P,A,N,$,ca,ga,ia,na,la,oa,ya){var ta,pa;ta=ca.width-1;pa=ca.height-1;ga*=ta;ia*=pa;na*=ta;la*=pa;oa*=ta;ya*=pa;P-=x;A-=W;N-=x;$-=W;na-=ga;la-=ia;oa-=ga;ya-=ia;pa=1/(na*ya-oa*la);ta=(ya*P-la*N)*pa;la=(ya*A-la*$)*pa;P=(na*N-
|
||||
oa*P)*pa;A=(na*$-oa*A)*pa;x=x-ta*ga-P*ia;W=W-la*ga-A*ia;p.save();p.transform(ta,la,P,A,x,W);p.clip();p.drawImage(ca,0,0);p.restore()}function Ja(x,W,P,A){var N=~~(x.r*255),$=~~(x.g*255);x=~~(x.b*255);var ca=~~(W.r*255),ga=~~(W.g*255);W=~~(W.b*255);var ia=~~(P.r*255),na=~~(P.g*255);P=~~(P.b*255);var la=~~(A.r*255),oa=~~(A.g*255);A=~~(A.b*255);ha[0]=N<0?0:N>255?255:N;ha[1]=$<0?0:$>255?255:$;ha[2]=x<0?0:x>255?255:x;ha[4]=ca<0?0:ca>255?255:ca;ha[5]=ga<0?0:ga>255?255:ga;ha[6]=W<0?0:W>255?255:W;ha[8]=ia<
|
||||
0?0:ia>255?255:ia;ha[9]=na<0?0:na>255?255:na;ha[10]=P<0?0:P>255?255:P;ha[12]=la<0?0:la>255?255:la;ha[13]=oa<0?0:oa>255?255:oa;ha[14]=A<0?0:A>255?255:A;ka.putImageData(fa,0,0);ua.drawImage(qa,0,0);return sa}function Ea(x,W,P){x=(x-W)/(P-W);return x*x*(3-2*x)}function Fa(x){x=(x+1)*0.5;return x<0?0:x>1?1:x}function Ga(x,W){var P=W.x-x.x,A=W.y-x.y,N=1/Math.sqrt(P*P+A*A);P*=N;A*=N;W.x+=P;W.y+=A;x.x-=P;x.y-=A}var Da,Ka,aa,ma,wa,Ha,La,za;p.setTransform(1,0,0,-1,b,m);this.autoClear&&this.clear();d=f.projectScene(da,
|
||||
ra,this.sortElements);(I=da.lights.length>0)&&Ma(da);Da=0;for(Ka=d.length;Da<Ka;Da++){aa=d[Da];v.empty();if(aa instanceof THREE.RenderableParticle){u=aa;u.x*=b;u.y*=m;ma=0;for(wa=aa.materials.length;ma<wa;ma++)Na(u,aa,aa.materials[ma],da)}else if(aa instanceof THREE.RenderableLine){u=aa.v1;R=aa.v2;u.positionScreen.x*=b;u.positionScreen.y*=m;R.positionScreen.x*=b;R.positionScreen.y*=m;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(R.positionScreen.x,R.positionScreen.y);if(T.instersects(v)){ma=
|
||||
E;q.faceMaterials=v.materials;q.overdraw=J;if(G.geometry.uvs[k]){q.uvs[0]=G.geometry.uvs[k][1];q.uvs[1]=G.geometry.uvs[k][2];q.uvs[2]=G.geometry.uvs[k][3]}l.push(q);b++}}}}else if(G instanceof THREE.Line){R.multiply(u,Z);O=G.geometry.vertices;v=O[0];v.positionScreen.copy(v.position);R.multiplyVector4(v.positionScreen);k=1;for(H=O.length;k<H;k++){x=O[k];x.positionScreen.copy(x.position);R.multiplyVector4(x.positionScreen);L=O[k-1];e.copy(x.positionScreen);h.copy(L.positionScreen);if(c(e,h)){e.multiplyScalar(1/
|
||||
e.w);h.multiplyScalar(1/h.w);p=F[D]=F[D]||new THREE.RenderableLine;p.v1.positionScreen.copy(e);p.v2.positionScreen.copy(h);p.z=Math.max(e.z,h.z);p.materials=G.materials;l.push(p);D++}}}else if(G instanceof THREE.Particle){T.set(G.position.x,G.position.y,G.position.z,1);u.multiplyVector4(T);T.z/=T.w;if(T.z>0&&T.z<1){w=S[A]=S[A]||new THREE.RenderableParticle;w.x=T.x/T.w;w.y=T.y/T.w;w.z=T.z;w.rotation=G.rotation.z;w.scale.x=G.scale.x*Math.abs(w.x-(T.x+o.projectionMatrix.n11)/(T.w+o.projectionMatrix.n14));
|
||||
w.scale.y=G.scale.y*Math.abs(w.y-(T.y+o.projectionMatrix.n22)/(T.w+o.projectionMatrix.n24));w.materials=G.materials;l.push(w);A++}}}}z&&l.sort(a);return l};this.unprojectVector=function(j,o){var z=new THREE.Matrix4;z.multiply(THREE.Matrix4.makeInvert(o.matrix),THREE.Matrix4.makeInvert(o.projectionMatrix));z.multiplyVector3(j);return j}};
|
||||
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,g,i;this.domElement=document.createElement("div");this.setSize=function(q,b){d=q;f=b;g=d/2;i=f/2};this.render=function(q,b){var m,p,D,F,w,A,S,V;a=c.projectScene(q,b);m=0;for(p=a.length;m<p;m++){w=a[m];if(w instanceof THREE.RenderableParticle){S=w.x*g+g;V=w.y*i+i;D=0;for(F=w.material.length;D<F;D++){A=w.material[D];if(A instanceof THREE.ParticleDOMMaterial){A=A.domElement;A.style.left=S+"px";A.style.top=V+"px"}}}}}};
|
||||
THREE.CanvasRenderer=function(){function a(da){if(w!=da)p.globalAlpha=w=da}function c(da){if(A!=da){switch(da){case THREE.NormalBlending:p.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:p.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:p.globalCompositeOperation="darker"}A=da}}var d=null,f=new THREE.Projector,g=document.createElement("canvas"),i,q,b,m,p=g.getContext("2d"),D=null,F=null,w=1,A=0,S=null,V=null,T=1,u,R,C,e,h,n,j,o,z,l=new THREE.Color,
|
||||
s=new THREE.Color,t=new THREE.Color,r=new THREE.Color,k=new THREE.Color,H,x,L,K,G,Z,Q,E,J,U=new THREE.Rectangle,O=new THREE.Rectangle,v=new THREE.Rectangle,I=false,M=new THREE.Color,ea=new THREE.Color,ba=new THREE.Color,Y=new THREE.Color,ja=Math.PI*2,X=new THREE.Vector3,qa,ka,fa,ha,sa,ua,va=16;qa=document.createElement("canvas");qa.width=qa.height=2;ka=qa.getContext("2d");ka.fillStyle="rgba(0,0,0,1)";ka.fillRect(0,0,2,2);fa=ka.getImageData(0,0,2,2);ha=fa.data;sa=document.createElement("canvas");sa.width=
|
||||
sa.height=va;ua=sa.getContext("2d");ua.translate(-va/2,-va/2);ua.scale(va,va);va--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(da,ra){i=da;q=ra;b=i/2;m=q/2;g.width=i;g.height=q;U.set(-b,-m,b,m);w=1;A=0;V=S=null;T=1};this.setClearColor=function(da,ra){D=da!==null?new THREE.Color(da):null;F=ra;O.set(-b,-m,b,m);p.setTransform(1,0,0,-1,b,m);this.clear()};this.clear=function(){if(!O.isEmpty()){O.inflate(1);O.minSelf(U);if(D!==null){c(THREE.NormalBlending);
|
||||
a(1);p.fillStyle="rgba("+Math.floor(D.r*255)+","+Math.floor(D.g*255)+","+Math.floor(D.b*255)+","+F+")";p.fillRect(O.getX(),O.getY(),O.getWidth(),O.getHeight())}else p.clearRect(O.getX(),O.getY(),O.getWidth(),O.getHeight());O.empty()}};this.render=function(da,ra){function Ma(y){var W,P,B,N=y.lights;ea.setRGB(0,0,0);ba.setRGB(0,0,0);Y.setRGB(0,0,0);y=0;for(W=N.length;y<W;y++){P=N[y];B=P.color;if(P instanceof THREE.AmbientLight){ea.r+=B.r;ea.g+=B.g;ea.b+=B.b}else if(P instanceof THREE.DirectionalLight){ba.r+=
|
||||
B.r;ba.g+=B.g;ba.b+=B.b}else if(P instanceof THREE.PointLight){Y.r+=B.r;Y.g+=B.g;Y.b+=B.b}}}function Aa(y,W,P,B){var N,$,ca,ga,ia=y.lights;y=0;for(N=ia.length;y<N;y++){$=ia[y];ca=$.color;ga=$.intensity;if($ instanceof THREE.DirectionalLight){$=P.dot($.position)*ga;if($>0){B.r+=ca.r*$;B.g+=ca.g*$;B.b+=ca.b*$}}else if($ instanceof THREE.PointLight){X.sub($.position,W);X.normalize();$=P.dot(X)*ga;if($>0){B.r+=ca.r*$;B.g+=ca.g*$;B.b+=ca.b*$}}}}function Na(y,W,P){if(P.opacity!=0){a(P.opacity);c(P.blending);
|
||||
var B,N,$,ca,ga,ia;if(P instanceof THREE.ParticleBasicMaterial){if(P.map){ca=P.map;ga=ca.width>>1;ia=ca.height>>1;N=W.scale.x*b;$=W.scale.y*m;P=N*ga;B=$*ia;v.set(y.x-P,y.y-B,y.x+P,y.y+B);if(U.instersects(v)){p.save();p.translate(y.x,y.y);p.rotate(-W.rotation);p.scale(N,-$);p.translate(-ga,-ia);p.drawImage(ca,0,0);p.restore()}}}else if(P instanceof THREE.ParticleCircleMaterial){if(I){M.r=ea.r+ba.r+Y.r;M.g=ea.g+ba.g+Y.g;M.b=ea.b+ba.b+Y.b;l.r=P.color.r*M.r;l.g=P.color.g*M.g;l.b=P.color.b*M.b;l.updateStyleString()}else l.__styleString=
|
||||
P.color.__styleString;P=W.scale.x*b;B=W.scale.y*m;v.set(y.x-P,y.y-B,y.x+P,y.y+B);if(U.instersects(v)){N=l.__styleString;if(V!=N)p.fillStyle=V=N;p.save();p.translate(y.x,y.y);p.rotate(-W.rotation);p.scale(P,B);p.beginPath();p.arc(0,0,1,0,ja,true);p.closePath();p.fill();p.restore()}}}}function Oa(y,W,P,B){if(B.opacity!=0){a(B.opacity);c(B.blending);p.beginPath();p.moveTo(y.positionScreen.x,y.positionScreen.y);p.lineTo(W.positionScreen.x,W.positionScreen.y);p.closePath();if(B instanceof THREE.LineBasicMaterial){l.__styleString=
|
||||
B.color.__styleString;y=B.linewidth;if(T!=y)p.lineWidth=T=y;y=l.__styleString;if(S!=y)p.strokeStyle=S=y;p.stroke();v.inflate(B.linewidth*2)}}}function Ia(y,W,P,B,N,$){if(N.opacity!=0){a(N.opacity);c(N.blending);e=y.positionScreen.x;h=y.positionScreen.y;n=W.positionScreen.x;j=W.positionScreen.y;o=P.positionScreen.x;z=P.positionScreen.y;p.beginPath();p.moveTo(e,h);p.lineTo(n,j);p.lineTo(o,z);p.lineTo(e,h);p.closePath();if(N instanceof THREE.MeshBasicMaterial)if(N.map)N.map.image.loaded&&N.map.mapping instanceof
|
||||
THREE.UVMapping&&xa(e,h,n,j,o,z,N.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);else if(N.env_map){if(N.env_map.image.loaded)if(N.env_map.mapping instanceof THREE.SphericalReflectionMapping){y=ra.matrix;X.copy(B.vertexNormalsWorld[0]);K=(X.x*y.n11+X.y*y.n12+X.z*y.n13)*0.5+0.5;G=-(X.x*y.n21+X.y*y.n22+X.z*y.n23)*0.5+0.5;X.copy(B.vertexNormalsWorld[1]);Z=(X.x*y.n11+X.y*y.n12+X.z*y.n13)*0.5+0.5;Q=-(X.x*y.n21+X.y*y.n22+X.z*y.n23)*0.5+0.5;X.copy(B.vertexNormalsWorld[2]);E=
|
||||
(X.x*y.n11+X.y*y.n12+X.z*y.n13)*0.5+0.5;J=-(X.x*y.n21+X.y*y.n22+X.z*y.n23)*0.5+0.5;xa(e,h,n,j,o,z,N.env_map.image,K,G,Z,Q,E,J)}}else N.wireframe?Ba(N.color.__styleString,N.wireframe_linewidth):Ca(N.color.__styleString);else if(N instanceof THREE.MeshLambertMaterial){if(N.map&&!N.wireframe){N.map.mapping instanceof THREE.UVMapping&&xa(e,h,n,j,o,z,N.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);c(THREE.SubtractiveBlending)}if(I)if(!N.wireframe&&N.shading==THREE.SmoothShading&&
|
||||
B.vertexNormalsWorld.length==3){s.r=t.r=r.r=ea.r;s.g=t.g=r.g=ea.g;s.b=t.b=r.b=ea.b;Aa($,B.v1.positionWorld,B.vertexNormalsWorld[0],s);Aa($,B.v2.positionWorld,B.vertexNormalsWorld[1],t);Aa($,B.v3.positionWorld,B.vertexNormalsWorld[2],r);k.r=(t.r+r.r)*0.5;k.g=(t.g+r.g)*0.5;k.b=(t.b+r.b)*0.5;L=Ja(s,t,r,k);xa(e,h,n,j,o,z,L,0,0,1,0,0,1)}else{M.r=ea.r;M.g=ea.g;M.b=ea.b;Aa($,B.centroidWorld,B.normalWorld,M);l.r=N.color.r*M.r;l.g=N.color.g*M.g;l.b=N.color.b*M.b;l.updateStyleString();N.wireframe?Ba(l.__styleString,
|
||||
N.wireframe_linewidth):Ca(l.__styleString)}else N.wireframe?Ba(N.color.__styleString,N.wireframe_linewidth):Ca(N.color.__styleString)}else if(N instanceof THREE.MeshDepthMaterial){H=ra.near;x=ra.far;s.r=s.g=s.b=1-Ea(y.positionScreen.z,H,x);t.r=t.g=t.b=1-Ea(W.positionScreen.z,H,x);r.r=r.g=r.b=1-Ea(P.positionScreen.z,H,x);k.r=(t.r+r.r)*0.5;k.g=(t.g+r.g)*0.5;k.b=(t.b+r.b)*0.5;L=Ja(s,t,r,k);xa(e,h,n,j,o,z,L,0,0,1,0,0,1)}else if(N instanceof THREE.MeshNormalMaterial){l.r=Fa(B.normalWorld.x);l.g=Fa(B.normalWorld.y);
|
||||
l.b=Fa(B.normalWorld.z);l.updateStyleString();N.wireframe?Ba(l.__styleString,N.wireframe_linewidth):Ca(l.__styleString)}}}function Ba(y,W){if(S!=y)p.strokeStyle=S=y;if(T!=W)p.lineWidth=T=W;p.stroke();v.inflate(W*2)}function Ca(y){if(V!=y)p.fillStyle=V=y;p.fill()}function xa(y,W,P,B,N,$,ca,ga,ia,na,la,oa,ya){var ta,pa;ta=ca.width-1;pa=ca.height-1;ga*=ta;ia*=pa;na*=ta;la*=pa;oa*=ta;ya*=pa;P-=y;B-=W;N-=y;$-=W;na-=ga;la-=ia;oa-=ga;ya-=ia;pa=1/(na*ya-oa*la);ta=(ya*P-la*N)*pa;la=(ya*B-la*$)*pa;P=(na*N-
|
||||
oa*P)*pa;B=(na*$-oa*B)*pa;y=y-ta*ga-P*ia;W=W-la*ga-B*ia;p.save();p.transform(ta,la,P,B,y,W);p.clip();p.drawImage(ca,0,0);p.restore()}function Ja(y,W,P,B){var N=~~(y.r*255),$=~~(y.g*255);y=~~(y.b*255);var ca=~~(W.r*255),ga=~~(W.g*255);W=~~(W.b*255);var ia=~~(P.r*255),na=~~(P.g*255);P=~~(P.b*255);var la=~~(B.r*255),oa=~~(B.g*255);B=~~(B.b*255);ha[0]=N<0?0:N>255?255:N;ha[1]=$<0?0:$>255?255:$;ha[2]=y<0?0:y>255?255:y;ha[4]=ca<0?0:ca>255?255:ca;ha[5]=ga<0?0:ga>255?255:ga;ha[6]=W<0?0:W>255?255:W;ha[8]=ia<
|
||||
0?0:ia>255?255:ia;ha[9]=na<0?0:na>255?255:na;ha[10]=P<0?0:P>255?255:P;ha[12]=la<0?0:la>255?255:la;ha[13]=oa<0?0:oa>255?255:oa;ha[14]=B<0?0:B>255?255:B;ka.putImageData(fa,0,0);ua.drawImage(qa,0,0);return sa}function Ea(y,W,P){y=(y-W)/(P-W);return y*y*(3-2*y)}function Fa(y){y=(y+1)*0.5;return y<0?0:y>1?1:y}function Ga(y,W){var P=W.x-y.x,B=W.y-y.y,N=1/Math.sqrt(P*P+B*B);P*=N;B*=N;W.x+=P;W.y+=B;y.x-=P;y.y-=B}var Da,Ka,aa,ma,wa,Ha,La,za;p.setTransform(1,0,0,-1,b,m);this.autoClear&&this.clear();d=f.projectScene(da,
|
||||
ra,this.sortElements);(I=da.lights.length>0)&&Ma(da);Da=0;for(Ka=d.length;Da<Ka;Da++){aa=d[Da];v.empty();if(aa instanceof THREE.RenderableParticle){u=aa;u.x*=b;u.y*=m;ma=0;for(wa=aa.materials.length;ma<wa;ma++)Na(u,aa,aa.materials[ma],da)}else if(aa instanceof THREE.RenderableLine){u=aa.v1;R=aa.v2;u.positionScreen.x*=b;u.positionScreen.y*=m;R.positionScreen.x*=b;R.positionScreen.y*=m;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(R.positionScreen.x,R.positionScreen.y);if(U.instersects(v)){ma=
|
||||
0;for(wa=aa.materials.length;ma<wa;)Oa(u,R,aa,aa.materials[ma++],da)}}else if(aa instanceof THREE.RenderableFace3){u=aa.v1;R=aa.v2;C=aa.v3;u.positionScreen.x*=b;u.positionScreen.y*=m;R.positionScreen.x*=b;R.positionScreen.y*=m;C.positionScreen.x*=b;C.positionScreen.y*=m;if(aa.overdraw){Ga(u.positionScreen,R.positionScreen);Ga(R.positionScreen,C.positionScreen);Ga(C.positionScreen,u.positionScreen)}v.add3Points(u.positionScreen.x,u.positionScreen.y,R.positionScreen.x,R.positionScreen.y,C.positionScreen.x,
|
||||
C.positionScreen.y);if(T.instersects(v)){ma=0;for(wa=aa.meshMaterials.length;ma<wa;){za=aa.meshMaterials[ma++];if(za instanceof THREE.MeshFaceMaterial){Ha=0;for(La=aa.faceMaterials.length;Ha<La;)(za=aa.faceMaterials[Ha++])&&Ia(u,R,C,aa,za,da)}else Ia(u,R,C,aa,za,da)}}}O.addRectangle(v)}p.setTransform(1,0,0,1,0,0)}};
|
||||
THREE.SVGRenderer=function(){function a(K,G,Z){var Q,E,J,T;Q=0;for(E=K.lights.length;Q<E;Q++){J=K.lights[Q];if(J instanceof THREE.DirectionalLight){T=G.normalWorld.dot(J.position)*J.intensity;if(T>0){Z.r+=J.color.r*T;Z.g+=J.color.g*T;Z.b+=J.color.b*T}}else if(J instanceof THREE.PointLight){z.sub(J.position,G.centroidWorld);z.normalize();T=G.normalWorld.dot(z)*J.intensity;if(T>0){Z.r+=J.color.r*T;Z.g+=J.color.g*T;Z.b+=J.color.b*T}}}}function c(K,G,Z,Q,E,J){r=f(k++);r.setAttribute("d","M "+K.positionScreen.x+
|
||||
C.positionScreen.y);if(U.instersects(v)){ma=0;for(wa=aa.meshMaterials.length;ma<wa;){za=aa.meshMaterials[ma++];if(za instanceof THREE.MeshFaceMaterial){Ha=0;for(La=aa.faceMaterials.length;Ha<La;)(za=aa.faceMaterials[Ha++])&&Ia(u,R,C,aa,za,da)}else Ia(u,R,C,aa,za,da)}}}O.addRectangle(v)}p.setTransform(1,0,0,1,0,0)}};
|
||||
THREE.SVGRenderer=function(){function a(K,G,Z){var Q,E,J,U;Q=0;for(E=K.lights.length;Q<E;Q++){J=K.lights[Q];if(J instanceof THREE.DirectionalLight){U=G.normalWorld.dot(J.position)*J.intensity;if(U>0){Z.r+=J.color.r*U;Z.g+=J.color.g*U;Z.b+=J.color.b*U}}else if(J instanceof THREE.PointLight){z.sub(J.position,G.centroidWorld);z.normalize();U=G.normalWorld.dot(z)*J.intensity;if(U>0){Z.r+=J.color.r*U;Z.g+=J.color.g*U;Z.b+=J.color.b*U}}}}function c(K,G,Z,Q,E,J){r=f(k++);r.setAttribute("d","M "+K.positionScreen.x+
|
||||
" "+K.positionScreen.y+" L "+G.positionScreen.x+" "+G.positionScreen.y+" L "+Z.positionScreen.x+","+Z.positionScreen.y+"z");if(E instanceof THREE.MeshBasicMaterial)C.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshLambertMaterial)if(R){e.r=h.r;e.g=h.g;e.b=h.b;a(J,Q,e);C.r=E.color.r*e.r;C.g=E.color.g*e.g;C.b=E.color.b*e.b;C.updateStyleString()}else C.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshDepthMaterial){o=1-E.__2near/(E.__farPlusNear-Q.z*E.__farMinusNear);
|
||||
C.setRGB(o,o,o)}else E instanceof THREE.MeshNormalMaterial&&C.setRGB(g(Q.normalWorld.x),g(Q.normalWorld.y),g(Q.normalWorld.z));E.wireframe?r.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframe_linecap+"; stroke-linejoin: "+E.wireframe_linejoin):r.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+E.opacity);b.appendChild(r)}function d(K,G,Z,Q,E,J,T){r=f(k++);r.setAttribute("d",
|
||||
"M "+K.positionScreen.x+" "+K.positionScreen.y+" L "+G.positionScreen.x+" "+G.positionScreen.y+" L "+Z.positionScreen.x+","+Z.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)C.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(R){e.r=h.r;e.g=h.g;e.b=h.b;a(T,E,e);C.r=J.color.r*e.r;C.g=J.color.g*e.g;C.b=J.color.b*e.b;C.updateStyleString()}else C.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){o=
|
||||
C.setRGB(o,o,o)}else E instanceof THREE.MeshNormalMaterial&&C.setRGB(g(Q.normalWorld.x),g(Q.normalWorld.y),g(Q.normalWorld.z));E.wireframe?r.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframe_linecap+"; stroke-linejoin: "+E.wireframe_linejoin):r.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+E.opacity);b.appendChild(r)}function d(K,G,Z,Q,E,J,U){r=f(k++);r.setAttribute("d",
|
||||
"M "+K.positionScreen.x+" "+K.positionScreen.y+" L "+G.positionScreen.x+" "+G.positionScreen.y+" L "+Z.positionScreen.x+","+Z.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)C.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(R){e.r=h.r;e.g=h.g;e.b=h.b;a(U,E,e);C.r=J.color.r*e.r;C.g=J.color.g*e.g;C.b=J.color.b*e.b;C.updateStyleString()}else C.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){o=
|
||||
1-J.__2near/(J.__farPlusNear-E.z*J.__farMinusNear);C.setRGB(o,o,o)}else J instanceof THREE.MeshNormalMaterial&&C.setRGB(g(E.normalWorld.x),g(E.normalWorld.y),g(E.normalWorld.z));J.wireframe?r.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):r.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+J.opacity);b.appendChild(r)}
|
||||
function f(K){if(l[K]==null){l[K]=document.createElementNS("http://www.w3.org/2000/svg","path");L==0&&l[K].setAttribute("shape-rendering","crispEdges");return l[K]}return l[K]}function g(K){return K<0?Math.min((1+K)*0.5,0.5):0.5+Math.min(K*0.5,0.5)}var i=null,q=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,p,D,F,y,B,S,V,U=new THREE.Rectangle,u=new THREE.Rectangle,R=false,C=new THREE.Color(16777215),e=new THREE.Color(16777215),h=new THREE.Color(0),n=new THREE.Color(0),
|
||||
j=new THREE.Color(0),o,z=new THREE.Vector3,l=[],s=[],t=[],r,k,H,w,L=1;this.domElement=b;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(K){switch(K){case "high":L=1;break;case "low":L=0}};this.setSize=function(K,G){m=K;p=G;D=m/2;F=p/2;b.setAttribute("viewBox",-D+" "+-F+" "+m+" "+p);b.setAttribute("width",m);b.setAttribute("height",p);U.set(-D,-F,D,F)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])};this.render=function(K,G){var Z,Q,
|
||||
E,J,T,O,v,I;this.autoClear&&this.clear();i=q.projectScene(K,G,this.sortElements);w=H=k=0;if(R=K.lights.length>0){v=K.lights;h.setRGB(0,0,0);n.setRGB(0,0,0);j.setRGB(0,0,0);Z=0;for(Q=v.length;Z<Q;Z++){E=v[Z];J=E.color;if(E instanceof THREE.AmbientLight){h.r+=J.r;h.g+=J.g;h.b+=J.b}else if(E instanceof THREE.DirectionalLight){n.r+=J.r;n.g+=J.g;n.b+=J.b}else if(E instanceof THREE.PointLight){j.r+=J.r;j.g+=J.g;j.b+=J.b}}}Z=0;for(Q=i.length;Z<Q;Z++){v=i[Z];u.empty();if(v instanceof THREE.RenderableParticle){y=
|
||||
v;y.x*=D;y.y*=-F;E=0;for(J=v.materials.length;E<J;E++)if(I=v.materials[E]){T=y;O=v;I=I;var M=H++;if(s[M]==null){s[M]=document.createElementNS("http://www.w3.org/2000/svg","circle");L==0&&s[M].setAttribute("shape-rendering","crispEdges")}r=s[M];r.setAttribute("cx",T.x);r.setAttribute("cy",T.y);r.setAttribute("r",O.scale.x*D);if(I instanceof THREE.ParticleCircleMaterial){if(R){e.r=h.r+n.r+j.r;e.g=h.g+n.g+j.g;e.b=h.b+n.b+j.b;C.r=I.color.r*e.r;C.g=I.color.g*e.g;C.b=I.color.b*e.b;C.updateStyleString()}else C=
|
||||
I.color;r.setAttribute("style","fill: "+C.__styleString)}b.appendChild(r)}}else if(v instanceof THREE.RenderableLine){y=v.v1;B=v.v2;y.positionScreen.x*=D;y.positionScreen.y*=-F;B.positionScreen.x*=D;B.positionScreen.y*=-F;u.addPoint(y.positionScreen.x,y.positionScreen.y);u.addPoint(B.positionScreen.x,B.positionScreen.y);if(U.instersects(u)){E=0;for(J=v.materials.length;E<J;)if(I=v.materials[E++]){T=y;O=B;I=I;M=w++;if(t[M]==null){t[M]=document.createElementNS("http://www.w3.org/2000/svg","line");L==
|
||||
0&&t[M].setAttribute("shape-rendering","crispEdges")}r=t[M];r.setAttribute("x1",T.positionScreen.x);r.setAttribute("y1",T.positionScreen.y);r.setAttribute("x2",O.positionScreen.x);r.setAttribute("y2",O.positionScreen.y);if(I instanceof THREE.LineBasicMaterial){C.__styleString=I.color.__styleString;r.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+I.linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: "+I.linecap+"; stroke-linejoin: "+I.linejoin);b.appendChild(r)}}}}else if(v instanceof
|
||||
THREE.RenderableFace3){y=v.v1;B=v.v2;S=v.v3;y.positionScreen.x*=D;y.positionScreen.y*=-F;B.positionScreen.x*=D;B.positionScreen.y*=-F;S.positionScreen.x*=D;S.positionScreen.y*=-F;u.addPoint(y.positionScreen.x,y.positionScreen.y);u.addPoint(B.positionScreen.x,B.positionScreen.y);u.addPoint(S.positionScreen.x,S.positionScreen.y);if(U.instersects(u)){E=0;for(J=v.meshMaterials.length;E<J;){I=v.meshMaterials[E++];if(I instanceof THREE.MeshFaceMaterial){T=0;for(O=v.faceMaterials.length;T<O;)(I=v.faceMaterials[T++])&&
|
||||
c(y,B,S,v,I,K)}else I&&c(y,B,S,v,I,K)}}}else if(v instanceof THREE.RenderableFace4){y=v.v1;B=v.v2;S=v.v3;V=v.v4;y.positionScreen.x*=D;y.positionScreen.y*=-F;B.positionScreen.x*=D;B.positionScreen.y*=-F;S.positionScreen.x*=D;S.positionScreen.y*=-F;V.positionScreen.x*=D;V.positionScreen.y*=-F;u.addPoint(y.positionScreen.x,y.positionScreen.y);u.addPoint(B.positionScreen.x,B.positionScreen.y);u.addPoint(S.positionScreen.x,S.positionScreen.y);u.addPoint(V.positionScreen.x,V.positionScreen.y);if(U.instersects(u)){E=
|
||||
0;for(J=v.meshMaterials.length;E<J;){I=v.meshMaterials[E++];if(I instanceof THREE.MeshFaceMaterial){T=0;for(O=v.faceMaterials.length;T<O;)(I=v.faceMaterials[T++])&&d(y,B,S,V,v,I,K)}else I&&d(y,B,S,V,v,I,K)}}}}}};
|
||||
function f(K){if(l[K]==null){l[K]=document.createElementNS("http://www.w3.org/2000/svg","path");L==0&&l[K].setAttribute("shape-rendering","crispEdges");return l[K]}return l[K]}function g(K){return K<0?Math.min((1+K)*0.5,0.5):0.5+Math.min(K*0.5,0.5)}var i=null,q=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,p,D,F,w,A,S,V,T=new THREE.Rectangle,u=new THREE.Rectangle,R=false,C=new THREE.Color(16777215),e=new THREE.Color(16777215),h=new THREE.Color(0),n=new THREE.Color(0),
|
||||
j=new THREE.Color(0),o,z=new THREE.Vector3,l=[],s=[],t=[],r,k,H,x,L=1;this.domElement=b;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(K){switch(K){case "high":L=1;break;case "low":L=0}};this.setSize=function(K,G){m=K;p=G;D=m/2;F=p/2;b.setAttribute("viewBox",-D+" "+-F+" "+m+" "+p);b.setAttribute("width",m);b.setAttribute("height",p);T.set(-D,-F,D,F)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])};this.render=function(K,G){var Z,Q,
|
||||
E,J,U,O,v,I;this.autoClear&&this.clear();i=q.projectScene(K,G,this.sortElements);x=H=k=0;if(R=K.lights.length>0){v=K.lights;h.setRGB(0,0,0);n.setRGB(0,0,0);j.setRGB(0,0,0);Z=0;for(Q=v.length;Z<Q;Z++){E=v[Z];J=E.color;if(E instanceof THREE.AmbientLight){h.r+=J.r;h.g+=J.g;h.b+=J.b}else if(E instanceof THREE.DirectionalLight){n.r+=J.r;n.g+=J.g;n.b+=J.b}else if(E instanceof THREE.PointLight){j.r+=J.r;j.g+=J.g;j.b+=J.b}}}Z=0;for(Q=i.length;Z<Q;Z++){v=i[Z];u.empty();if(v instanceof THREE.RenderableParticle){w=
|
||||
v;w.x*=D;w.y*=-F;E=0;for(J=v.materials.length;E<J;E++)if(I=v.materials[E]){U=w;O=v;I=I;var M=H++;if(s[M]==null){s[M]=document.createElementNS("http://www.w3.org/2000/svg","circle");L==0&&s[M].setAttribute("shape-rendering","crispEdges")}r=s[M];r.setAttribute("cx",U.x);r.setAttribute("cy",U.y);r.setAttribute("r",O.scale.x*D);if(I instanceof THREE.ParticleCircleMaterial){if(R){e.r=h.r+n.r+j.r;e.g=h.g+n.g+j.g;e.b=h.b+n.b+j.b;C.r=I.color.r*e.r;C.g=I.color.g*e.g;C.b=I.color.b*e.b;C.updateStyleString()}else C=
|
||||
I.color;r.setAttribute("style","fill: "+C.__styleString)}b.appendChild(r)}}else if(v instanceof THREE.RenderableLine){w=v.v1;A=v.v2;w.positionScreen.x*=D;w.positionScreen.y*=-F;A.positionScreen.x*=D;A.positionScreen.y*=-F;u.addPoint(w.positionScreen.x,w.positionScreen.y);u.addPoint(A.positionScreen.x,A.positionScreen.y);if(T.instersects(u)){E=0;for(J=v.materials.length;E<J;)if(I=v.materials[E++]){U=w;O=A;I=I;M=x++;if(t[M]==null){t[M]=document.createElementNS("http://www.w3.org/2000/svg","line");L==
|
||||
0&&t[M].setAttribute("shape-rendering","crispEdges")}r=t[M];r.setAttribute("x1",U.positionScreen.x);r.setAttribute("y1",U.positionScreen.y);r.setAttribute("x2",O.positionScreen.x);r.setAttribute("y2",O.positionScreen.y);if(I instanceof THREE.LineBasicMaterial){C.__styleString=I.color.__styleString;r.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+I.linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: "+I.linecap+"; stroke-linejoin: "+I.linejoin);b.appendChild(r)}}}}else if(v instanceof
|
||||
THREE.RenderableFace3){w=v.v1;A=v.v2;S=v.v3;w.positionScreen.x*=D;w.positionScreen.y*=-F;A.positionScreen.x*=D;A.positionScreen.y*=-F;S.positionScreen.x*=D;S.positionScreen.y*=-F;u.addPoint(w.positionScreen.x,w.positionScreen.y);u.addPoint(A.positionScreen.x,A.positionScreen.y);u.addPoint(S.positionScreen.x,S.positionScreen.y);if(T.instersects(u)){E=0;for(J=v.meshMaterials.length;E<J;){I=v.meshMaterials[E++];if(I instanceof THREE.MeshFaceMaterial){U=0;for(O=v.faceMaterials.length;U<O;)(I=v.faceMaterials[U++])&&
|
||||
c(w,A,S,v,I,K)}else I&&c(w,A,S,v,I,K)}}}else if(v instanceof THREE.RenderableFace4){w=v.v1;A=v.v2;S=v.v3;V=v.v4;w.positionScreen.x*=D;w.positionScreen.y*=-F;A.positionScreen.x*=D;A.positionScreen.y*=-F;S.positionScreen.x*=D;S.positionScreen.y*=-F;V.positionScreen.x*=D;V.positionScreen.y*=-F;u.addPoint(w.positionScreen.x,w.positionScreen.y);u.addPoint(A.positionScreen.x,A.positionScreen.y);u.addPoint(S.positionScreen.x,S.positionScreen.y);u.addPoint(V.positionScreen.x,V.positionScreen.y);if(T.instersects(u)){E=
|
||||
0;for(J=v.meshMaterials.length;E<J;){I=v.meshMaterials[E++];if(I instanceof THREE.MeshFaceMaterial){U=0;for(O=v.faceMaterials.length;U<O;)(I=v.faceMaterials[U++])&&d(w,A,S,V,v,I,K)}else I&&d(w,A,S,V,v,I,K)}}}}}};
|
||||
THREE.WebGLRenderer=function(a){function c(e,h){e.fragment_shader=h.fragment_shader;e.vertex_shader=h.vertex_shader;e.uniforms=Uniforms.clone(h.uniforms)}function d(e,h){e.uniforms.color.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;e.uniforms.map.texture=e.map;e.uniforms.env_map.texture=e.env_map;e.uniforms.reflectivity.value=e.reflectivity;e.uniforms.refraction_ratio.value=e.refraction_ratio;e.uniforms.combine.value=e.combine;e.uniforms.useRefract.value=
|
||||
e.env_map&&e.env_map.mapping instanceof THREE.CubeRefractionMapping;if(h){e.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){e.uniforms.fogNear.value=h.near;e.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)e.uniforms.fogDensity.value=h.density}}function f(e,h){e.uniforms.color.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;if(h){e.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){e.uniforms.fogNear.value=
|
||||
h.near;e.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)e.uniforms.fogDensity.value=h.density}}function g(e,h){var n;if(e=="fragment")n=b.createShader(b.FRAGMENT_SHADER);else if(e=="vertex")n=b.createShader(b.VERTEX_SHADER);b.shaderSource(n,h);b.compileShader(n);if(!b.getShaderParameter(n,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(n));return null}return n}function i(e){switch(e){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;
|
||||
case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;
|
||||
case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var q=document.createElement("canvas"),b,m=null,p=null,D=new THREE.Matrix4,F,y=new Float32Array(16),B=new Float32Array(16),S=new Float32Array(16),V=new Float32Array(9),
|
||||
U=new Float32Array(16),u=true,R=new THREE.Color(0),C=0;if(a){if(a.antialias!==undefined)u=a.antialias;a.clearColor!==undefined&&R.setHex(a.clearColor);if(a.clearAlpha!==undefined)C=a.clearAlpha}this.domElement=q;this.autoClear=true;(function(e,h,n){try{b=q.getContext("experimental-webgl",{antialias:e})}catch(j){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);
|
||||
b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(h.r,h.g,h.b,n)})(u,R,C);this.context=b;this.setSize=function(e,h){q.width=e;q.height=h;b.viewport(0,0,q.width,q.height)};this.setClearColor=function(e,h){var n=new THREE.Color(e);b.clearColor(n.r,n.g,n.b,h)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(e,h){var n,j,o,z=0,l=0,s=0,t,r,k,H=[],w=[],L=[],K=[];n=0;for(j=h.length;n<j;n++){o=h[n];t=o.color;r=o.position;
|
||||
k=o.intensity;if(o instanceof THREE.AmbientLight){z+=t.r;l+=t.g;s+=t.b}else if(o instanceof THREE.DirectionalLight){H.push(t.r*k,t.g*k,t.b*k);w.push(r.x,r.y,r.z)}else if(o instanceof THREE.PointLight){L.push(t.r*k,t.g*k,t.b*k);K.push(r.x,r.y,r.z)}}return{ambient:[z,l,s],directional:{colors:H,positions:w},point:{colors:L,positions:K}}};this.createParticleBuffers=function(e){e.__webGLVertexBuffer=b.createBuffer();e.__webGLFaceBuffer=b.createBuffer()};this.createLineBuffers=function(e){e.__webGLVertexBuffer=
|
||||
case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var q=document.createElement("canvas"),b,m=null,p=null,D=new THREE.Matrix4,F,w=new Float32Array(16),A=new Float32Array(16),S=new Float32Array(16),V=new Float32Array(9),
|
||||
T=new Float32Array(16),u=true,R=new THREE.Color(0),C=0;if(a){if(a.antialias!==undefined)u=a.antialias;a.clearColor!==undefined&&R.setHex(a.clearColor);if(a.clearAlpha!==undefined)C=a.clearAlpha}this.domElement=q;this.autoClear=true;(function(e,h,n){try{b=q.getContext("experimental-webgl",{antialias:e})}catch(j){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);
|
||||
b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(h.r,h.g,h.b,n)})(u,R,C);this.context=b;this.setSize=function(e,h){q.width=e;q.height=h;b.viewport(0,0,q.width,q.height)};this.setClearColor=function(e,h){var n=new THREE.Color(e);b.clearColor(n.r,n.g,n.b,h)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(e,h){var n,j,o,z=0,l=0,s=0,t,r,k,H=[],x=[],L=[],K=[];n=0;for(j=h.length;n<j;n++){o=h[n];t=o.color;r=o.position;
|
||||
k=o.intensity;if(o instanceof THREE.AmbientLight){z+=t.r;l+=t.g;s+=t.b}else if(o instanceof THREE.DirectionalLight){H.push(t.r*k,t.g*k,t.b*k);x.push(r.x,r.y,r.z)}else if(o instanceof THREE.PointLight){L.push(t.r*k,t.g*k,t.b*k);K.push(r.x,r.y,r.z)}}return{ambient:[z,l,s],directional:{colors:H,positions:x},point:{colors:L,positions:K}}};this.createParticleBuffers=function(e){e.__webGLVertexBuffer=b.createBuffer();e.__webGLFaceBuffer=b.createBuffer()};this.createLineBuffers=function(e){e.__webGLVertexBuffer=
|
||||
b.createBuffer();e.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=function(e){e.__webGLVertexBuffer=b.createBuffer();e.__webGLNormalBuffer=b.createBuffer();e.__webGLTangentBuffer=b.createBuffer();e.__webGLUVBuffer=b.createBuffer();e.__webGLFaceBuffer=b.createBuffer();e.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(e){var h=e.vertices.length;e.__vertexArray=new Float32Array(h*3);e.__lineArray=new Uint16Array(h);e.__webGLLineCount=h};this.initMeshBuffers=function(e,h){var n,
|
||||
j,o=0,z=0,l=0,s=h.geometry.faces,t=e.faces;n=0;for(j=t.length;n<j;n++){fi=t[n];face=s[fi];if(face instanceof THREE.Face3){o+=3;z+=1;l+=3}else if(face instanceof THREE.Face4){o+=4;z+=2;l+=5}}e.__vertexArray=new Float32Array(o*3);e.__normalArray=new Float32Array(o*3);e.__tangentArray=new Float32Array(o*4);e.__uvArray=new Float32Array(o*2);e.__faceArray=new Uint16Array(z*3);e.__lineArray=new Uint16Array(l*2);o=false;n=0;for(j=h.materials.length;n<j;n++){s=h.materials[n];if(s instanceof THREE.MeshFaceMaterial){s=
|
||||
0;for(t=e.materials.length;s<t;s++)if(e.materials[s]&&e.materials[s].shading!=undefined&&e.materials[s].shading==THREE.SmoothShading){o=true;break}}else if(s&&s.shading!=undefined&&s.shading==THREE.SmoothShading){o=true;break}if(o)break}e.__needsSmoothNormals=o;e.__webGLFaceCount=z*3;e.__webGLLineCount=l*2};this.setMeshBuffers=function(e,h,n,j,o,z,l,s){var t,r,k,H,w,L,K,G,Z,Q=0,E=0,J=0,T=0,O=0,v=0,I=0,M=e.__vertexArray,ea=e.__uvArray,ba=e.__normalArray,Y=e.__tangentArray,ja=e.__faceArray,X=e.__lineArray,
|
||||
qa=e.__needsSmoothNormals,ka=h.geometry,fa=ka.vertices,ha=e.faces,sa=ka.faces,ua=ka.uvs;h=0;for(t=ha.length;h<t;h++){r=ha[h];k=sa[r];r=ua[r];H=k.vertexNormals;w=k.normal;if(k instanceof THREE.Face3){if(j){L=fa[k.a].position;K=fa[k.b].position;G=fa[k.c].position;M[E]=L.x;M[E+1]=L.y;M[E+2]=L.z;M[E+3]=K.x;M[E+4]=K.y;M[E+5]=K.z;M[E+6]=G.x;M[E+7]=G.y;M[E+8]=G.z;E+=9}if(s&&ka.hasTangents){L=fa[k.a].tangent;K=fa[k.b].tangent;G=fa[k.c].tangent;Y[v]=L.x;Y[v+1]=L.y;Y[v+2]=L.z;Y[v+3]=L.w;Y[v+4]=K.x;Y[v+5]=K.y;
|
||||
Y[v+6]=K.z;Y[v+7]=K.w;Y[v+8]=G.x;Y[v+9]=G.y;Y[v+10]=G.z;Y[v+11]=G.w;v+=12}if(l)if(H.length==3&&qa)for(k=0;k<3;k++){w=H[k];ba[O]=w.x;ba[O+1]=w.y;ba[O+2]=w.z;O+=3}else for(k=0;k<3;k++){ba[O]=w.x;ba[O+1]=w.y;ba[O+2]=w.z;O+=3}if(z&&r)for(k=0;k<3;k++){H=r[k];ea[J]=H.u;ea[J+1]=H.v;J+=2}if(o){ja[T]=Q;ja[T+1]=Q+1;ja[T+2]=Q+2;T+=3;X[I]=Q;X[I+1]=Q+1;X[I+2]=Q;X[I+3]=Q+2;X[I+4]=Q+1;X[I+5]=Q+2;I+=6;Q+=3}}else if(k instanceof THREE.Face4){if(j){L=fa[k.a].position;K=fa[k.b].position;G=fa[k.c].position;Z=fa[k.d].position;
|
||||
M[E]=L.x;M[E+1]=L.y;M[E+2]=L.z;M[E+3]=K.x;M[E+4]=K.y;M[E+5]=K.z;M[E+6]=G.x;M[E+7]=G.y;M[E+8]=G.z;M[E+9]=Z.x;M[E+10]=Z.y;M[E+11]=Z.z;E+=12}if(s&&ka.hasTangents){L=fa[k.a].tangent;K=fa[k.b].tangent;G=fa[k.c].tangent;k=fa[k.d].tangent;Y[v]=L.x;Y[v+1]=L.y;Y[v+2]=L.z;Y[v+3]=L.w;Y[v+4]=K.x;Y[v+5]=K.y;Y[v+6]=K.z;Y[v+7]=K.w;Y[v+8]=G.x;Y[v+9]=G.y;Y[v+10]=G.z;Y[v+11]=G.w;Y[v+12]=k.x;Y[v+13]=k.y;Y[v+14]=k.z;Y[v+15]=k.w;v+=16}if(l)if(H.length==4&&qa)for(k=0;k<4;k++){w=H[k];ba[O]=w.x;ba[O+1]=w.y;ba[O+2]=w.z;O+=
|
||||
3}else for(k=0;k<4;k++){ba[O]=w.x;ba[O+1]=w.y;ba[O+2]=w.z;O+=3}if(z&&r)for(k=0;k<4;k++){H=r[k];ea[J]=H.u;ea[J+1]=H.v;J+=2}if(o){ja[T]=Q;ja[T+1]=Q+1;ja[T+2]=Q+2;ja[T+3]=Q;ja[T+4]=Q+2;ja[T+5]=Q+3;T+=6;X[I]=Q;X[I+1]=Q+1;X[I+2]=Q;X[I+3]=Q+2;X[I+4]=Q;X[I+5]=Q+3;X[I+6]=Q+1;X[I+7]=Q+2;X[I+8]=Q+2;X[I+9]=Q+3;I+=10;Q+=4}}}if(j){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,M,n)}if(l){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ba,n)}if(s&&
|
||||
0;for(t=e.materials.length;s<t;s++)if(e.materials[s]&&e.materials[s].shading!=undefined&&e.materials[s].shading==THREE.SmoothShading){o=true;break}}else if(s&&s.shading!=undefined&&s.shading==THREE.SmoothShading){o=true;break}if(o)break}e.__needsSmoothNormals=o;e.__webGLFaceCount=z*3;e.__webGLLineCount=l*2};this.setMeshBuffers=function(e,h,n,j,o,z,l,s){var t,r,k,H,x,L,K,G,Z,Q=0,E=0,J=0,U=0,O=0,v=0,I=0,M=e.__vertexArray,ea=e.__uvArray,ba=e.__normalArray,Y=e.__tangentArray,ja=e.__faceArray,X=e.__lineArray,
|
||||
qa=e.__needsSmoothNormals,ka=h.geometry,fa=ka.vertices,ha=e.faces,sa=ka.faces,ua=ka.uvs;h=0;for(t=ha.length;h<t;h++){r=ha[h];k=sa[r];r=ua[r];H=k.vertexNormals;x=k.normal;if(k instanceof THREE.Face3){if(j){L=fa[k.a].position;K=fa[k.b].position;G=fa[k.c].position;M[E]=L.x;M[E+1]=L.y;M[E+2]=L.z;M[E+3]=K.x;M[E+4]=K.y;M[E+5]=K.z;M[E+6]=G.x;M[E+7]=G.y;M[E+8]=G.z;E+=9}if(s&&ka.hasTangents){L=fa[k.a].tangent;K=fa[k.b].tangent;G=fa[k.c].tangent;Y[v]=L.x;Y[v+1]=L.y;Y[v+2]=L.z;Y[v+3]=L.w;Y[v+4]=K.x;Y[v+5]=K.y;
|
||||
Y[v+6]=K.z;Y[v+7]=K.w;Y[v+8]=G.x;Y[v+9]=G.y;Y[v+10]=G.z;Y[v+11]=G.w;v+=12}if(l)if(H.length==3&&qa)for(k=0;k<3;k++){x=H[k];ba[O]=x.x;ba[O+1]=x.y;ba[O+2]=x.z;O+=3}else for(k=0;k<3;k++){ba[O]=x.x;ba[O+1]=x.y;ba[O+2]=x.z;O+=3}if(z&&r)for(k=0;k<3;k++){H=r[k];ea[J]=H.u;ea[J+1]=H.v;J+=2}if(o){ja[U]=Q;ja[U+1]=Q+1;ja[U+2]=Q+2;U+=3;X[I]=Q;X[I+1]=Q+1;X[I+2]=Q;X[I+3]=Q+2;X[I+4]=Q+1;X[I+5]=Q+2;I+=6;Q+=3}}else if(k instanceof THREE.Face4){if(j){L=fa[k.a].position;K=fa[k.b].position;G=fa[k.c].position;Z=fa[k.d].position;
|
||||
M[E]=L.x;M[E+1]=L.y;M[E+2]=L.z;M[E+3]=K.x;M[E+4]=K.y;M[E+5]=K.z;M[E+6]=G.x;M[E+7]=G.y;M[E+8]=G.z;M[E+9]=Z.x;M[E+10]=Z.y;M[E+11]=Z.z;E+=12}if(s&&ka.hasTangents){L=fa[k.a].tangent;K=fa[k.b].tangent;G=fa[k.c].tangent;k=fa[k.d].tangent;Y[v]=L.x;Y[v+1]=L.y;Y[v+2]=L.z;Y[v+3]=L.w;Y[v+4]=K.x;Y[v+5]=K.y;Y[v+6]=K.z;Y[v+7]=K.w;Y[v+8]=G.x;Y[v+9]=G.y;Y[v+10]=G.z;Y[v+11]=G.w;Y[v+12]=k.x;Y[v+13]=k.y;Y[v+14]=k.z;Y[v+15]=k.w;v+=16}if(l)if(H.length==4&&qa)for(k=0;k<4;k++){x=H[k];ba[O]=x.x;ba[O+1]=x.y;ba[O+2]=x.z;O+=
|
||||
3}else for(k=0;k<4;k++){ba[O]=x.x;ba[O+1]=x.y;ba[O+2]=x.z;O+=3}if(z&&r)for(k=0;k<4;k++){H=r[k];ea[J]=H.u;ea[J+1]=H.v;J+=2}if(o){ja[U]=Q;ja[U+1]=Q+1;ja[U+2]=Q+2;ja[U+3]=Q;ja[U+4]=Q+2;ja[U+5]=Q+3;U+=6;X[I]=Q;X[I+1]=Q+1;X[I+2]=Q;X[I+3]=Q+2;X[I+4]=Q;X[I+5]=Q+3;X[I+6]=Q+1;X[I+7]=Q+2;X[I+8]=Q+2;X[I+9]=Q+3;I+=10;Q+=4}}}if(j){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,M,n)}if(l){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ba,n)}if(s&&
|
||||
ka.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,Y,n)}if(z&&J>0){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,ea,n)}if(o){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ja,n);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,X,n)}};this.setLineBuffers=function(e,h,n,j){var o,z,l=e.vertices,s=l.length,t=e.__vertexArray,r=e.__lineArray;
|
||||
if(n)for(n=0;n<s;n++){o=l[n].position;z=n*3;t[z]=o.x;t[z+1]=o.y;t[z+2]=o.z}if(j)for(n=0;n<s;n++)r[n]=n;b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,t,h);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,r,h)};this.setParticleBuffers=function(){};this.renderBuffer=function(e,h,n,j,o,z){var l,s,t,r;if(!j.program){if(j instanceof THREE.MeshDepthMaterial){c(j,THREE.ShaderLib.depth);j.uniforms.mNear.value=e.near;j.uniforms.mFar.value=
|
||||
e.far}else if(j instanceof THREE.MeshNormalMaterial)c(j,THREE.ShaderLib.normal);else if(j instanceof THREE.MeshBasicMaterial){c(j,THREE.ShaderLib.basic);d(j,n)}else if(j instanceof THREE.MeshLambertMaterial){c(j,THREE.ShaderLib.lambert);d(j,n)}else if(j instanceof THREE.MeshPhongMaterial){c(j,THREE.ShaderLib.phong);d(j,n)}else if(j instanceof THREE.LineBasicMaterial){c(j,THREE.ShaderLib.basic);f(j,n)}var k,H,w;k=r=s=0;for(H=h.length;k<H;k++){w=h[k];w instanceof THREE.DirectionalLight&&r++;w instanceof
|
||||
THREE.PointLight&&s++}if(s+r<=4){k=r;s=s}else{k=Math.ceil(4*r/(s+r));s=4-k}s={directional:k,point:s};r={fog:n,map:j.map,env_map:j.env_map,maxDirLights:s.directional,maxPointLights:s.point};s=j.fragment_shader;k=j.vertex_shader;H=b.createProgram();w=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+r.maxDirLights,"#define MAX_POINT_LIGHTS "+r.maxPointLights,r.fog?"#define USE_FOG":"",r.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.env_map?"#define USE_ENVMAP":
|
||||
e.far}else if(j instanceof THREE.MeshNormalMaterial)c(j,THREE.ShaderLib.normal);else if(j instanceof THREE.MeshBasicMaterial){c(j,THREE.ShaderLib.basic);d(j,n)}else if(j instanceof THREE.MeshLambertMaterial){c(j,THREE.ShaderLib.lambert);d(j,n)}else if(j instanceof THREE.MeshPhongMaterial){c(j,THREE.ShaderLib.phong);d(j,n)}else if(j instanceof THREE.LineBasicMaterial){c(j,THREE.ShaderLib.basic);f(j,n)}var k,H,x;k=r=s=0;for(H=h.length;k<H;k++){x=h[k];x instanceof THREE.DirectionalLight&&r++;x instanceof
|
||||
THREE.PointLight&&s++}if(s+r<=4){k=r;s=s}else{k=Math.ceil(4*r/(s+r));s=4-k}s={directional:k,point:s};r={fog:n,map:j.map,env_map:j.env_map,maxDirLights:s.directional,maxPointLights:s.point};s=j.fragment_shader;k=j.vertex_shader;H=b.createProgram();x=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+r.maxDirLights,"#define MAX_POINT_LIGHTS "+r.maxPointLights,r.fog?"#define USE_FOG":"",r.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.env_map?"#define USE_ENVMAP":
|
||||
"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");r=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+r.maxDirLights,"#define MAX_POINT_LIGHTS "+r.maxPointLights,r.map?"#define USE_MAP":"",r.env_map?"#define USE_ENVMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");
|
||||
b.attachShader(H,g("fragment",w+s));b.attachShader(H,g("vertex",r+k));b.linkProgram(H);b.getProgramParameter(H,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(H,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");H.uniforms={};H.attributes={};j.program=H;s=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(l in j.uniforms)s.push(l);l=j.program;k=0;for(H=s.length;k<H;k++){w=s[k];l.uniforms[w]=b.getUniformLocation(l,
|
||||
w)}l=j.program;s=["position","normal","uv","tangent"];k=0;for(H=s.length;k<H;k++){w=s[k];l.attributes[w]=b.getAttribLocation(l,w)}}l=j.program;if(l!=m){b.useProgram(l);m=l}this.loadCamera(l,e);this.loadMatrices(l);if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){e=this.setupLights(l,h);j.uniforms.enableLighting.value=e.directional.positions.length+e.point.positions.length;j.uniforms.ambientLightColor.value=e.ambient;j.uniforms.directionalLightColor.value=e.directional.colors;
|
||||
b.attachShader(H,g("fragment",x+s));b.attachShader(H,g("vertex",r+k));b.linkProgram(H);b.getProgramParameter(H,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(H,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");H.uniforms={};H.attributes={};j.program=H;s=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(l in j.uniforms)s.push(l);l=j.program;k=0;for(H=s.length;k<H;k++){x=s[k];l.uniforms[x]=b.getUniformLocation(l,
|
||||
x)}l=j.program;s=["position","normal","uv","tangent"];k=0;for(H=s.length;k<H;k++){x=s[k];l.attributes[x]=b.getAttribLocation(l,x)}}l=j.program;if(l!=m){b.useProgram(l);m=l}this.loadCamera(l,e);this.loadMatrices(l);if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){e=this.setupLights(l,h);j.uniforms.enableLighting.value=e.directional.positions.length+e.point.positions.length;j.uniforms.ambientLightColor.value=e.ambient;j.uniforms.directionalLightColor.value=e.directional.colors;
|
||||
j.uniforms.directionalLightDirection.value=e.directional.positions;j.uniforms.pointLightColor.value=e.point.colors;j.uniforms.pointLightPosition.value=e.point.positions}if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial)d(j,n);j instanceof THREE.LineBasicMaterial&&f(j,n);if(j instanceof THREE.MeshPhongMaterial){j.uniforms.ambient.value.setRGB(j.ambient.r,j.ambient.g,j.ambient.b);j.uniforms.specular.value.setRGB(j.specular.r,j.specular.g,
|
||||
j.specular.b);j.uniforms.shininess.value=j.shininess}n=j.uniforms;for(t in n)if(k=l.uniforms[t]){h=n[t];s=h.type;e=h.value;if(s=="i")b.uniform1i(k,e);else if(s=="f")b.uniform1f(k,e);else if(s=="fv1")b.uniform1fv(k,e);else if(s=="fv")b.uniform3fv(k,e);else if(s=="v2")b.uniform2f(k,e.x,e.y);else if(s=="v3")b.uniform3f(k,e.x,e.y,e.z);else if(s=="c")b.uniform3f(k,e.r,e.g,e.b);else if(s=="t"){b.uniform1i(k,e);if(h=h.texture)if(h.image instanceof Array&&h.image.length==6){h=h;e=e;if(h.image.length==6){if(!h.image.__webGLTextureCube&&
|
||||
!h.image.__cubeMapInitialized&&h.image.loadCount==6){h.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,h.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(s=0;s<6;++s)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+
|
||||
@@ -177,12 +177,12 @@ j instanceof THREE.LineBasicMaterial){t=j.wireframe_linewidth!==undefined?j.wire
|
||||
h,n,j,o,z,l){var s,t,r,k,H;r=0;for(k=j.materials.length;r<k;r++){s=j.materials[r];if(s instanceof THREE.MeshFaceMaterial){s=0;for(t=o.materials.length;s<t;s++)if((H=o.materials[s])&&H.blending==z&&H.opacity<1==l){this.setBlending(H.blending);this.renderBuffer(e,h,n,H,o,j)}}else if((H=s)&&H.blending==z&&H.opacity<1==l){this.setBlending(H.blending);this.renderBuffer(e,h,n,H,o,j)}}};this.render=function(e,h,n,j){var o,z,l,s=e.lights,t=e.fog;this.initWebGLObjects(e);j=j!==undefined?j:true;if(n&&!n.__webGLFramebuffer){n.__webGLFramebuffer=
|
||||
b.createFramebuffer();n.__webGLRenderbuffer=b.createRenderbuffer();n.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,n.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,n.width,n.height);b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,i(n.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,i(n.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,i(n.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,
|
||||
i(n.min_filter));b.texImage2D(b.TEXTURE_2D,0,i(n.format),n.width,n.height,0,i(n.format),i(n.type),null);b.bindFramebuffer(b.FRAMEBUFFER,n.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,n.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,n.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(n){o=n.__webGLFramebuffer;l=n.width;z=n.height}else{o=
|
||||
null;l=q.width;z=q.height}if(o!=p){b.bindFramebuffer(b.FRAMEBUFFER,o);b.viewport(0,0,l,z);j&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);p=o}this.autoClear&&this.clear();h.autoUpdateMatrix&&h.updateMatrix();y.set(h.matrix.flatten());S.set(h.projectionMatrix.flatten());j=0;for(o=e.__webGLObjects.length;j<o;j++){z=e.__webGLObjects[j];l=z.object;z=z.buffer;if(l.visible){this.setupMatrices(l,h);this.renderPass(h,s,t,l,z,THREE.NormalBlending,false)}}j=0;for(o=e.__webGLObjects.length;j<o;j++){z=e.__webGLObjects[j];
|
||||
null;l=q.width;z=q.height}if(o!=p){b.bindFramebuffer(b.FRAMEBUFFER,o);b.viewport(0,0,l,z);j&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);p=o}this.autoClear&&this.clear();h.autoUpdateMatrix&&h.updateMatrix();w.set(h.matrix.flatten());S.set(h.projectionMatrix.flatten());j=0;for(o=e.__webGLObjects.length;j<o;j++){z=e.__webGLObjects[j];l=z.object;z=z.buffer;if(l.visible){this.setupMatrices(l,h);this.renderPass(h,s,t,l,z,THREE.NormalBlending,false)}}j=0;for(o=e.__webGLObjects.length;j<o;j++){z=e.__webGLObjects[j];
|
||||
l=z.object;z=z.buffer;if(l.visible){this.setupMatrices(l,h);this.renderPass(h,s,t,l,z,THREE.AdditiveBlending,false);this.renderPass(h,s,t,l,z,THREE.SubtractiveBlending,false);this.renderPass(h,s,t,l,z,THREE.AdditiveBlending,true);this.renderPass(h,s,t,l,z,THREE.SubtractiveBlending,true);this.renderPass(h,s,t,l,z,THREE.NormalBlending,true)}}if(n&&n.min_filter!==THREE.NearestFilter&&n.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,
|
||||
null)}};this.initWebGLObjects=function(e){function h(r,k,H,w){if(r[k]==undefined){e.__webGLObjects.push({buffer:H,object:w});r[k]=1}}var n,j,o,z,l,s,t;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={}}n=0;for(j=e.objects.length;n<j;n++){o=e.objects[n];l=o.geometry;if(e.__webGLObjectsMap[o.id]==undefined)e.__webGLObjectsMap[o.id]={};t=e.__webGLObjectsMap[o.id];if(o instanceof THREE.Mesh){for(z in l.geometryChunks){s=l.geometryChunks[z];if(!s.__webGLVertexBuffer){this.createMeshBuffers(s);
|
||||
null)}};this.initWebGLObjects=function(e){function h(r,k,H,x){if(r[k]==undefined){e.__webGLObjects.push({buffer:H,object:x});r[k]=1}}var n,j,o,z,l,s,t;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={}}n=0;for(j=e.objects.length;n<j;n++){o=e.objects[n];l=o.geometry;if(e.__webGLObjectsMap[o.id]==undefined)e.__webGLObjectsMap[o.id]={};t=e.__webGLObjectsMap[o.id];if(o instanceof THREE.Mesh){for(z in l.geometryChunks){s=l.geometryChunks[z];if(!s.__webGLVertexBuffer){this.createMeshBuffers(s);
|
||||
this.initMeshBuffers(s,o);l.__dirtyVertices=true;l.__dirtyElements=true;l.__dirtyUvs=true;l.__dirtyNormals=true;l.__dirtyTangents=true}if(l.__dirtyVertices||l.__dirtyElements||l.__dirtyUvs)this.setMeshBuffers(s,o,b.DYNAMIC_DRAW,l.__dirtyVertices,l.__dirtyElements,l.__dirtyUvs,l.__dirtyNormals,l.__dirtyTangents);h(t,z,s,o)}l.__dirtyVertices=false;l.__dirtyElements=false;l.__dirtyUvs=false;l.__dirtyNormals=false;l.__dirtyTangents=false}else if(o instanceof THREE.Line){if(!l.__webGLVertexBuffer){this.createLineBuffers(l);
|
||||
this.initLineBuffers(l);l.__dirtyVertices=true;l.__dirtyElements=true}l.__dirtyVertices&&this.setLineBuffers(l,b.DYNAMIC_DRAW,l.__dirtyVertices,l.__dirtyElements);h(t,0,l,o);l.__dirtyVertices=false;l.__dirtyElements=false}else if(o instanceof THREE.ParticleSystem){l.__webGLVertexBuffer||this.createParticleBuffers(l);h(t,0,l,o)}}};this.removeObject=function(e,h){var n,j;for(n=e.__webGLObjects.length-1;n>=0;n--){j=e.__webGLObjects[n].object;h==j&&e.__webGLObjects.splice(n,1)}};this.setupMatrices=function(e,
|
||||
h){e.autoUpdateMatrix&&e.updateMatrix();D.multiply(h.matrix,e.matrix);B.set(D.flatten());F=THREE.Matrix4.makeInvert3x3(D).transpose();V.set(F.m);U.set(e.matrix.flatten())};this.loadMatrices=function(e){b.uniformMatrix4fv(e.uniforms.viewMatrix,false,y);b.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,B);b.uniformMatrix4fv(e.uniforms.projectionMatrix,false,S);b.uniformMatrix3fv(e.uniforms.normalMatrix,false,V);b.uniformMatrix4fv(e.uniforms.objectMatrix,false,U)};this.loadCamera=function(e,h){b.uniform3f(e.uniforms.cameraPosition,
|
||||
h){e.autoUpdateMatrix&&e.updateMatrix();D.multiply(h.matrix,e.matrix);A.set(D.flatten());F=THREE.Matrix4.makeInvert3x3(D).transpose();V.set(F.m);T.set(e.matrix.flatten())};this.loadMatrices=function(e){b.uniformMatrix4fv(e.uniforms.viewMatrix,false,w);b.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,A);b.uniformMatrix4fv(e.uniforms.projectionMatrix,false,S);b.uniformMatrix3fv(e.uniforms.normalMatrix,false,V);b.uniformMatrix4fv(e.uniforms.objectMatrix,false,T)};this.loadCamera=function(e,h){b.uniform3f(e.uniforms.cameraPosition,
|
||||
h.position.x,h.position.y,h.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,h){if(e){!h||h=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(e=="back")b.cullFace(b.BACK);else e=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);
|
||||
b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
|
||||
THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
|
||||
|
||||
+60
-60
@@ -13,20 +13,20 @@ THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;this.z=d;this.w
|
||||
return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
|
||||
THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
|
||||
THREE.Ray.prototype={intersectScene:function(a){var c,d,f=a.objects,g=[];a=0;for(c=f.length;a<c;a++){d=f[a];if(d instanceof THREE.Mesh)g=g.concat(this.intersectObject(d))}g.sort(function(i,q){return i.distance-q.distance});return g},intersectObject:function(a){function c(U,u,S,C){C=C.clone().subSelf(u);S=S.clone().subSelf(u);var e=U.clone().subSelf(u);U=C.dot(C);u=C.dot(S);C=C.dot(e);var h=S.dot(S);S=S.dot(e);e=1/(U*h-u*u);h=(h*C-u*S)*e;U=(U*S-u*C)*e;return h>0&&U>0&&h+U<1}var d,f,g,i,q,b,m,n,D,F,
|
||||
y,B=a.geometry,T=B.vertices,V=[];d=0;for(f=B.faces.length;d<f;d++){g=B.faces[d];F=this.origin.clone();y=this.direction.clone();i=a.matrix.multiplyVector3(T[g.a].position.clone());q=a.matrix.multiplyVector3(T[g.b].position.clone());b=a.matrix.multiplyVector3(T[g.c].position.clone());m=g instanceof THREE.Face4?a.matrix.multiplyVector3(T[g.d].position.clone()):null;n=a.rotationMatrix.multiplyVector3(g.normal.clone());D=y.dot(n);if(D<0){n=n.dot((new THREE.Vector3).sub(i,F))/D;F=F.addSelf(y.multiplyScalar(n));
|
||||
x,A=a.geometry,T=A.vertices,V=[];d=0;for(f=A.faces.length;d<f;d++){g=A.faces[d];F=this.origin.clone();x=this.direction.clone();i=a.matrix.multiplyVector3(T[g.a].position.clone());q=a.matrix.multiplyVector3(T[g.b].position.clone());b=a.matrix.multiplyVector3(T[g.c].position.clone());m=g instanceof THREE.Face4?a.matrix.multiplyVector3(T[g.d].position.clone()):null;n=a.rotationMatrix.multiplyVector3(g.normal.clone());D=x.dot(n);if(D<0){n=n.dot((new THREE.Vector3).sub(i,F))/D;F=F.addSelf(x.multiplyScalar(n));
|
||||
if(g instanceof THREE.Face3){if(c(F,i,q,b)){g={distance:this.origin.distanceTo(F),point:F,face:g,object:a};V.push(g)}}else if(g instanceof THREE.Face4)if(c(F,i,q,m)||c(F,q,b,m)){g={distance:this.origin.distanceTo(F),point:F,face:g,object:a};V.push(g)}}}return V}};
|
||||
THREE.Rectangle=function(){function a(){i=f-c;q=g-d}var c,d,f,g,i,q,b=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return i};this.getHeight=function(){return q};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(m,n,D,F){b=false;c=m;d=n;f=D;g=F;a()};this.addPoint=function(m,n){if(b){b=false;c=m;d=n;f=m;g=n}else{c=c<m?c:m;d=d<n?d:n;f=f>m?f:m;g=g>n?
|
||||
g:n}a()};this.add3Points=function(m,n,D,F,y,B){if(b){b=false;c=m<D?m<y?m:y:D<y?D:y;d=n<F?n<B?n:B:F<B?F:B;f=m>D?m>y?m:y:D>y?D:y;g=n>F?n>B?n:B:F>B?F:B}else{c=m<D?m<y?m<c?m:c:y<c?y:c:D<y?D<c?D:c:y<c?y:c;d=n<F?n<B?n<d?n:d:B<d?B:d:F<B?F<d?F:d:B<d?B:d;f=m>D?m>y?m>f?m:f:y>f?y:f:D>y?D>f?D:f:y>f?y:f;g=n>F?n>B?n>g?n:g:B>g?B:g:F>B?F>g?F:g:B>g?B:g}a()};this.addRectangle=function(m){if(b){b=false;c=m.getLeft();d=m.getTop();f=m.getRight();g=m.getBottom()}else{c=c<m.getLeft()?c:m.getLeft();d=d<m.getTop()?d:m.getTop();
|
||||
g:n}a()};this.add3Points=function(m,n,D,F,x,A){if(b){b=false;c=m<D?m<x?m:x:D<x?D:x;d=n<F?n<A?n:A:F<A?F:A;f=m>D?m>x?m:x:D>x?D:x;g=n>F?n>A?n:A:F>A?F:A}else{c=m<D?m<x?m<c?m:c:x<c?x:c:D<x?D<c?D:c:x<c?x:c;d=n<F?n<A?n<d?n:d:A<d?A:d:F<A?F<d?F:d:A<d?A:d;f=m>D?m>x?m>f?m:f:x>f?x:f:D>x?D>f?D:f:x>f?x:f;g=n>F?n>A?n>g?n:g:A>g?A:g:F>A?F>g?F:g:A>g?A:g}a()};this.addRectangle=function(m){if(b){b=false;c=m.getLeft();d=m.getTop();f=m.getRight();g=m.getBottom()}else{c=c<m.getLeft()?c:m.getLeft();d=d<m.getTop()?d:m.getTop();
|
||||
f=f>m.getRight()?f:m.getRight();g=g>m.getBottom()?g:m.getBottom()}a()};this.inflate=function(m){c-=m;d-=m;f+=m;g+=m;a()};this.minSelf=function(m){c=c>m.getLeft()?c:m.getLeft();d=d>m.getTop()?d:m.getTop();f=f<m.getRight()?f:m.getRight();g=g<m.getBottom()?g:m.getBottom();a()};this.instersects=function(m){return Math.min(f,m.getRight())-Math.max(c,m.getLeft())>=0&&Math.min(g,m.getBottom())-Math.max(d,m.getTop())>=0};this.empty=function(){b=true;g=f=d=c=0;a()};this.isEmpty=function(){return b};this.toString=
|
||||
function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+g+", width: "+i+", 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,c,d,f,g,i,q,b,m,n,D,F,y,B,T,V){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=g||0;this.n22=i||1;this.n23=q||0;this.n24=b||0;this.n31=m||0;this.n32=n||0;this.n33=D||1;this.n34=F||0;this.n41=y||0;this.n42=B||0;this.n43=T||0;this.n44=V||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,c,d,f,g,i,q,b,m,n,D,F,y,B,T,V){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=g;this.n22=i;this.n23=q;this.n24=b;this.n31=m;this.n32=n;this.n33=D;this.n34=F;this.n41=y;this.n42=B;this.n43=T;this.n44=V;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
|
||||
THREE.Matrix4=function(a,c,d,f,g,i,q,b,m,n,D,F,x,A,T,V){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=g||0;this.n22=i||1;this.n23=q||0;this.n24=b||0;this.n31=m||0;this.n32=n||0;this.n33=D||1;this.n34=F||0;this.n41=x||0;this.n42=A||0;this.n43=T||0;this.n44=V||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,c,d,f,g,i,q,b,m,n,D,F,x,A,T,V){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=g;this.n22=i;this.n23=q;this.n24=b;this.n31=m;this.n32=n;this.n33=D;this.n34=F;this.n41=x;this.n42=A;this.n43=T;this.n44=V;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
|
||||
a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var f=new THREE.Vector3,g=new THREE.Vector3,i=new THREE.Vector3;i.sub(a,c).normalize();f.cross(d,i).normalize();g.cross(i,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=i.x;
|
||||
this.n32=i.y;this.n33=i.z;this.n34=-i.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,g=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*g;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*g;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*g;return a},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,g=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*g;a.y=this.n21*c+this.n22*d+this.n23*f+this.n24*
|
||||
g;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*g;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*g;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,f=a.n12,g=a.n13,i=a.n14,q=a.n21,b=a.n22,m=a.n23,n=a.n24,D=a.n31,F=a.n32,
|
||||
y=a.n33,B=a.n34,T=a.n41,V=a.n42,U=a.n43,u=a.n44,S=c.n11,C=c.n12,e=c.n13,h=c.n14,o=c.n21,j=c.n22,p=c.n23,z=c.n24,l=c.n31,s=c.n32,t=c.n33,r=c.n34,k=c.n41,H=c.n42,x=c.n43,M=c.n44;this.n11=d*S+f*o+g*l+i*k;this.n12=d*C+f*j+g*s+i*H;this.n13=d*e+f*p+g*t+i*x;this.n14=d*h+f*z+g*r+i*M;this.n21=q*S+b*o+m*l+n*k;this.n22=q*C+b*j+m*s+n*H;this.n23=q*e+b*p+m*t+n*x;this.n24=q*h+b*z+m*r+n*M;this.n31=D*S+F*o+y*l+B*k;this.n32=D*C+F*j+y*s+B*H;this.n33=D*e+F*p+y*t+B*x;this.n34=D*h+F*z+y*r+B*M;this.n41=T*S+V*o+U*l+u*k;
|
||||
this.n42=T*C+V*j+U*s+u*H;this.n43=T*e+V*p+U*t+u*x;this.n44=T*h+V*z+U*r+u*M;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,g=this.n14,i=this.n21,q=this.n22,b=this.n23,m=this.n24,n=this.n31,D=this.n32,F=this.n33,y=this.n34,B=this.n41,T=this.n42,V=this.n43,U=this.n44,u=a.n11,S=a.n21,C=a.n31,e=a.n41,h=a.n12,o=a.n22,j=a.n32,p=a.n42,z=a.n13,l=a.n23,s=a.n33,t=a.n43,r=a.n14,k=a.n24,H=a.n34;a=a.n44;this.n11=c*u+d*S+f*C+g*e;this.n12=c*h+d*o+f*j+g*p;this.n13=c*z+d*l+f*s+g*t;this.n14=
|
||||
c*r+d*k+f*H+g*a;this.n21=i*u+q*S+b*C+m*e;this.n22=i*h+q*o+b*j+m*p;this.n23=i*z+q*l+b*s+m*t;this.n24=i*r+q*k+b*H+m*a;this.n31=n*u+D*S+F*C+y*e;this.n32=n*h+D*o+F*j+y*p;this.n33=n*z+D*l+F*s+y*t;this.n34=n*r+D*k+F*H+y*a;this.n41=B*u+T*S+V*C+U*e;this.n42=B*h+T*o+V*j+U*p;this.n43=B*z+T*l+V*s+U*t;this.n44=B*r+T*k+V*H+U*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*=
|
||||
x=a.n33,A=a.n34,T=a.n41,V=a.n42,U=a.n43,u=a.n44,S=c.n11,C=c.n12,e=c.n13,h=c.n14,o=c.n21,j=c.n22,p=c.n23,z=c.n24,l=c.n31,s=c.n32,t=c.n33,r=c.n34,k=c.n41,H=c.n42,y=c.n43,M=c.n44;this.n11=d*S+f*o+g*l+i*k;this.n12=d*C+f*j+g*s+i*H;this.n13=d*e+f*p+g*t+i*y;this.n14=d*h+f*z+g*r+i*M;this.n21=q*S+b*o+m*l+n*k;this.n22=q*C+b*j+m*s+n*H;this.n23=q*e+b*p+m*t+n*y;this.n24=q*h+b*z+m*r+n*M;this.n31=D*S+F*o+x*l+A*k;this.n32=D*C+F*j+x*s+A*H;this.n33=D*e+F*p+x*t+A*y;this.n34=D*h+F*z+x*r+A*M;this.n41=T*S+V*o+U*l+u*k;
|
||||
this.n42=T*C+V*j+U*s+u*H;this.n43=T*e+V*p+U*t+u*y;this.n44=T*h+V*z+U*r+u*M;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,g=this.n14,i=this.n21,q=this.n22,b=this.n23,m=this.n24,n=this.n31,D=this.n32,F=this.n33,x=this.n34,A=this.n41,T=this.n42,V=this.n43,U=this.n44,u=a.n11,S=a.n21,C=a.n31,e=a.n41,h=a.n12,o=a.n22,j=a.n32,p=a.n42,z=a.n13,l=a.n23,s=a.n33,t=a.n43,r=a.n14,k=a.n24,H=a.n34;a=a.n44;this.n11=c*u+d*S+f*C+g*e;this.n12=c*h+d*o+f*j+g*p;this.n13=c*z+d*l+f*s+g*t;this.n14=
|
||||
c*r+d*k+f*H+g*a;this.n21=i*u+q*S+b*C+m*e;this.n22=i*h+q*o+b*j+m*p;this.n23=i*z+q*l+b*s+m*t;this.n24=i*r+q*k+b*H+m*a;this.n31=n*u+D*S+F*C+x*e;this.n32=n*h+D*o+F*j+x*p;this.n33=n*z+D*l+F*s+x*t;this.n34=n*r+D*k+F*H+x*a;this.n41=A*u+T*S+V*C+U*e;this.n42=A*h+T*o+V*j+U*p;this.n43=A*z+T*l+V*s+U*t;this.n44=A*r+T*k+V*H+U*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=
|
||||
a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*
|
||||
this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(c,d,f){var g=c[d];c[d]=c[f];
|
||||
c[f]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
|
||||
@@ -48,8 +48,8 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.f
|
||||
d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,f,g,i,q,b=new THREE.Vector3,m=new THREE.Vector3;f=0;for(g=this.vertices.length;f<g;f++){i=this.vertices[f];i.normal.set(0,0,0)}f=0;for(g=this.faces.length;f<g;f++){i=this.faces[f];if(a&&i.vertexNormals.length){b.set(0,0,0);c=0;for(d=i.normal.length;c<d;c++)b.addSelf(i.vertexNormals[c]);b.divideScalar(3)}else{c=this.vertices[i.a];d=this.vertices[i.b];q=this.vertices[i.c];b.sub(q.position,
|
||||
d.position);m.sub(c.position,d.position);b.crossSelf(m)}b.isZero()||b.normalize();i.normal.copy(b)}},computeVertexNormals:function(){var a,c,d,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
|
||||
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal);f[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
|
||||
c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c]);d.vertexNormals[3].copy(f[d.d])}}},computeTangents:function(){function a(r,k,H,x,M,K,G){i=r.vertices[k].position;q=r.vertices[H].position;b=r.vertices[x].position;m=g[M];n=g[K];D=g[G];F=q.x-i.x;y=b.x-i.x;B=q.y-i.y;T=b.y-i.y;
|
||||
V=q.z-i.z;U=b.z-i.z;u=n.u-m.u;S=D.u-m.u;C=n.v-m.v;e=D.v-m.v;h=1/(u*e-S*C);p.set((e*F-C*y)*h,(e*B-C*T)*h,(e*V-C*U)*h);z.set((u*y-S*F)*h,(u*T-S*B)*h,(u*U-S*V)*h);o[k].addSelf(p);o[H].addSelf(p);o[x].addSelf(p);j[k].addSelf(z);j[H].addSelf(z);j[x].addSelf(z)}var c,d,f,g,i,q,b,m,n,D,F,y,B,T,V,U,u,S,C,e,h,o=[],j=[],p=new THREE.Vector3,z=new THREE.Vector3,l=new THREE.Vector3,s=new THREE.Vector3,t=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){o[c]=new THREE.Vector3;j[c]=new THREE.Vector3}c=0;
|
||||
c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c]);d.vertexNormals[3].copy(f[d.d])}}},computeTangents:function(){function a(r,k,H,y,M,K,G){i=r.vertices[k].position;q=r.vertices[H].position;b=r.vertices[y].position;m=g[M];n=g[K];D=g[G];F=q.x-i.x;x=b.x-i.x;A=q.y-i.y;T=b.y-i.y;
|
||||
V=q.z-i.z;U=b.z-i.z;u=n.u-m.u;S=D.u-m.u;C=n.v-m.v;e=D.v-m.v;h=1/(u*e-S*C);p.set((e*F-C*x)*h,(e*A-C*T)*h,(e*V-C*U)*h);z.set((u*x-S*F)*h,(u*T-S*A)*h,(u*U-S*V)*h);o[k].addSelf(p);o[H].addSelf(p);o[y].addSelf(p);j[k].addSelf(z);j[H].addSelf(z);j[y].addSelf(z)}var c,d,f,g,i,q,b,m,n,D,F,x,A,T,V,U,u,S,C,e,h,o=[],j=[],p=new THREE.Vector3,z=new THREE.Vector3,l=new THREE.Vector3,s=new THREE.Vector3,t=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){o[c]=new THREE.Vector3;j[c]=new THREE.Vector3}c=0;
|
||||
for(d=this.faces.length;c<d;c++){f=this.faces[c];g=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
|
||||
this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){t.copy(this.vertices[c].normal);f=o[c];l.copy(f);l.subSelf(t.multiplyScalar(t.dot(f))).normalize();s.cross(this.vertices[c].normal,f);f=s.dot(j[c]);f=f<0?-1:1;this.vertices[c].tangent.set(l.x,l.y,l.z,f)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
|
||||
z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
|
||||
@@ -99,36 +99,36 @@ var Uniforms={clone:function(a){var c,d,f,g={};for(c in a){g[c]={};for(d in a[c]
|
||||
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
|
||||
THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
|
||||
THREE.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
|
||||
THREE.Projector=function(){function a(j,p){return p.z-j.z}function c(j,p){var z=0,l=1,s=j.z+j.w,t=p.z+p.w,r=-j.z+j.w,k=-p.z+p.w;if(s>=0&&t>=0&&r>=0&&k>=0)return true;else if(s<0&&t<0||r<0&&k<0)return false;else{if(s<0)z=Math.max(z,s/(s-t));else if(t<0)l=Math.min(l,s/(s-t));if(r<0)z=Math.max(z,r/(r-k));else if(k<0)l=Math.min(l,r/(r-k));if(l<z)return false;else{j.lerpSelf(p,z);p.lerpSelf(j,1-l);return true}}}var d,f,g=[],i,q,b,m=[],n,D,F=[],y,B,T=[],V=new THREE.Vector4,U=new THREE.Vector4,u=new THREE.Matrix4,
|
||||
THREE.Projector=function(){function a(j,p){return p.z-j.z}function c(j,p){var z=0,l=1,s=j.z+j.w,t=p.z+p.w,r=-j.z+j.w,k=-p.z+p.w;if(s>=0&&t>=0&&r>=0&&k>=0)return true;else if(s<0&&t<0||r<0&&k<0)return false;else{if(s<0)z=Math.max(z,s/(s-t));else if(t<0)l=Math.min(l,s/(s-t));if(r<0)z=Math.max(z,r/(r-k));else if(k<0)l=Math.min(l,r/(r-k));if(l<z)return false;else{j.lerpSelf(p,z);p.lerpSelf(j,1-l);return true}}}var d,f,g=[],i,q,b,m=[],n,D,F=[],x,A,T=[],V=new THREE.Vector4,U=new THREE.Vector4,u=new THREE.Matrix4,
|
||||
S=new THREE.Matrix4,C=[],e=new THREE.Vector4,h=new THREE.Vector4,o;this.projectObjects=function(j,p,z){var l=[],s,t;f=0;u.multiply(p.projectionMatrix,p.matrix);C[0]=new THREE.Vector4(u.n41-u.n11,u.n42-u.n12,u.n43-u.n13,u.n44-u.n14);C[1]=new THREE.Vector4(u.n41+u.n11,u.n42+u.n12,u.n43+u.n13,u.n44+u.n14);C[2]=new THREE.Vector4(u.n41+u.n21,u.n42+u.n22,u.n43+u.n23,u.n44+u.n24);C[3]=new THREE.Vector4(u.n41-u.n21,u.n42-u.n22,u.n43-u.n23,u.n44-u.n24);C[4]=new THREE.Vector4(u.n41-u.n31,u.n42-u.n32,u.n43-
|
||||
u.n33,u.n44-u.n34);C[5]=new THREE.Vector4(u.n41+u.n31,u.n42+u.n32,u.n43+u.n33,u.n44+u.n34);p=0;for(s=C.length;p<s;p++){t=C[p];t.divideScalar(Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z))}s=j.objects;j=0;for(p=s.length;j<p;j++){t=s[j];var r;if(!(r=!t.visible)){if(r=t instanceof THREE.Mesh){a:{r=void 0;for(var k=t.position,H=-t.geometry.boundingSphere.radius*Math.max(t.scale.x,Math.max(t.scale.y,t.scale.z)),x=0;x<6;x++){r=C[x].x*k.x+C[x].y*k.y+C[x].z*k.z+C[x].w;if(r<=H){r=false;break a}}r=true}r=!r}r=r}if(!r){d=
|
||||
g[f]=g[f]||new THREE.RenderableObject;V.copy(t.position);u.multiplyVector3(V);d.object=t;d.z=V.z;l.push(d);f++}}z&&l.sort(a);return l};this.projectScene=function(j,p,z){var l=[],s=p.near,t=p.far,r,k,H,x,M,K,G,Z,R,E,J,P,L,v,I,N;b=D=B=0;p.autoUpdateMatrix&&p.updateMatrix();u.multiply(p.projectionMatrix,p.matrix);K=this.projectObjects(j,p,true);j=0;for(r=K.length;j<r;j++){G=K[j].object;if(G.visible){G.autoUpdateMatrix&&G.updateMatrix();Z=G.matrix;R=G.rotationMatrix;E=G.materials;J=G.overdraw;if(G instanceof
|
||||
THREE.Mesh){P=G.geometry;L=P.vertices;k=0;for(H=L.length;k<H;k++){v=L[k];v.positionWorld.copy(v.position);Z.multiplyVector3(v.positionWorld);x=v.positionScreen;x.copy(v.positionWorld);u.multiplyVector4(x);x.x/=x.w;x.y/=x.w;v.__visible=x.z>s&&x.z<t}P=P.faces;k=0;for(H=P.length;k<H;k++){v=P[k];if(v instanceof THREE.Face3){x=L[v.a];M=L[v.b];I=L[v.c];if(x.__visible&&M.__visible&&I.__visible)if(G.doubleSided||G.flipSided!=(I.positionScreen.x-x.positionScreen.x)*(M.positionScreen.y-x.positionScreen.y)-
|
||||
(I.positionScreen.y-x.positionScreen.y)*(M.positionScreen.x-x.positionScreen.x)<0){i=m[b]=m[b]||new THREE.RenderableFace3;i.v1.positionWorld.copy(x.positionWorld);i.v2.positionWorld.copy(M.positionWorld);i.v3.positionWorld.copy(I.positionWorld);i.v1.positionScreen.copy(x.positionScreen);i.v2.positionScreen.copy(M.positionScreen);i.v3.positionScreen.copy(I.positionScreen);i.normalWorld.copy(v.normal);R.multiplyVector3(i.normalWorld);i.centroidWorld.copy(v.centroid);Z.multiplyVector3(i.centroidWorld);
|
||||
i.centroidScreen.copy(i.centroidWorld);u.multiplyVector3(i.centroidScreen);I=v.vertexNormals;o=i.vertexNormalsWorld;x=0;for(M=I.length;x<M;x++){N=o[x]=o[x]||new THREE.Vector3;N.copy(I[x]);R.multiplyVector3(N)}i.z=i.centroidScreen.z;i.meshMaterials=E;i.faceMaterials=v.materials;i.overdraw=J;if(G.geometry.uvs[k]){i.uvs[0]=G.geometry.uvs[k][0];i.uvs[1]=G.geometry.uvs[k][1];i.uvs[2]=G.geometry.uvs[k][2]}l.push(i);b++}}else if(v instanceof THREE.Face4){x=L[v.a];M=L[v.b];I=L[v.c];N=L[v.d];if(x.__visible&&
|
||||
M.__visible&&I.__visible&&N.__visible)if(G.doubleSided||G.flipSided!=((N.positionScreen.x-x.positionScreen.x)*(M.positionScreen.y-x.positionScreen.y)-(N.positionScreen.y-x.positionScreen.y)*(M.positionScreen.x-x.positionScreen.x)<0||(M.positionScreen.x-I.positionScreen.x)*(N.positionScreen.y-I.positionScreen.y)-(M.positionScreen.y-I.positionScreen.y)*(N.positionScreen.x-I.positionScreen.x)<0)){i=m[b]=m[b]||new THREE.RenderableFace3;i.v1.positionWorld.copy(x.positionWorld);i.v2.positionWorld.copy(M.positionWorld);
|
||||
i.v3.positionWorld.copy(N.positionWorld);i.v1.positionScreen.copy(x.positionScreen);i.v2.positionScreen.copy(M.positionScreen);i.v3.positionScreen.copy(N.positionScreen);i.normalWorld.copy(v.normal);R.multiplyVector3(i.normalWorld);i.centroidWorld.copy(v.centroid);Z.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);u.multiplyVector3(i.centroidScreen);i.z=i.centroidScreen.z;i.meshMaterials=E;i.faceMaterials=v.materials;i.overdraw=J;if(G.geometry.uvs[k]){i.uvs[0]=G.geometry.uvs[k][0];
|
||||
u.n33,u.n44-u.n34);C[5]=new THREE.Vector4(u.n41+u.n31,u.n42+u.n32,u.n43+u.n33,u.n44+u.n34);p=0;for(s=C.length;p<s;p++){t=C[p];t.divideScalar(Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z))}s=j.objects;j=0;for(p=s.length;j<p;j++){t=s[j];var r;if(!(r=!t.visible)){if(r=t instanceof THREE.Mesh){a:{r=void 0;for(var k=t.position,H=-t.geometry.boundingSphere.radius*Math.max(t.scale.x,Math.max(t.scale.y,t.scale.z)),y=0;y<6;y++){r=C[y].x*k.x+C[y].y*k.y+C[y].z*k.z+C[y].w;if(r<=H){r=false;break a}}r=true}r=!r}r=r}if(!r){d=
|
||||
g[f]=g[f]||new THREE.RenderableObject;V.copy(t.position);u.multiplyVector3(V);d.object=t;d.z=V.z;l.push(d);f++}}z&&l.sort(a);return l};this.projectScene=function(j,p,z){var l=[],s=p.near,t=p.far,r,k,H,y,M,K,G,Z,R,E,J,P,L,v,I,N;b=D=A=0;p.autoUpdateMatrix&&p.updateMatrix();u.multiply(p.projectionMatrix,p.matrix);K=this.projectObjects(j,p,true);j=0;for(r=K.length;j<r;j++){G=K[j].object;if(G.visible){G.autoUpdateMatrix&&G.updateMatrix();Z=G.matrix;R=G.rotationMatrix;E=G.materials;J=G.overdraw;if(G instanceof
|
||||
THREE.Mesh){P=G.geometry;L=P.vertices;k=0;for(H=L.length;k<H;k++){v=L[k];v.positionWorld.copy(v.position);Z.multiplyVector3(v.positionWorld);y=v.positionScreen;y.copy(v.positionWorld);u.multiplyVector4(y);y.x/=y.w;y.y/=y.w;v.__visible=y.z>s&&y.z<t}P=P.faces;k=0;for(H=P.length;k<H;k++){v=P[k];if(v instanceof THREE.Face3){y=L[v.a];M=L[v.b];I=L[v.c];if(y.__visible&&M.__visible&&I.__visible)if(G.doubleSided||G.flipSided!=(I.positionScreen.x-y.positionScreen.x)*(M.positionScreen.y-y.positionScreen.y)-
|
||||
(I.positionScreen.y-y.positionScreen.y)*(M.positionScreen.x-y.positionScreen.x)<0){i=m[b]=m[b]||new THREE.RenderableFace3;i.v1.positionWorld.copy(y.positionWorld);i.v2.positionWorld.copy(M.positionWorld);i.v3.positionWorld.copy(I.positionWorld);i.v1.positionScreen.copy(y.positionScreen);i.v2.positionScreen.copy(M.positionScreen);i.v3.positionScreen.copy(I.positionScreen);i.normalWorld.copy(v.normal);R.multiplyVector3(i.normalWorld);i.centroidWorld.copy(v.centroid);Z.multiplyVector3(i.centroidWorld);
|
||||
i.centroidScreen.copy(i.centroidWorld);u.multiplyVector3(i.centroidScreen);I=v.vertexNormals;o=i.vertexNormalsWorld;y=0;for(M=I.length;y<M;y++){N=o[y]=o[y]||new THREE.Vector3;N.copy(I[y]);R.multiplyVector3(N)}i.z=i.centroidScreen.z;i.meshMaterials=E;i.faceMaterials=v.materials;i.overdraw=J;if(G.geometry.uvs[k]){i.uvs[0]=G.geometry.uvs[k][0];i.uvs[1]=G.geometry.uvs[k][1];i.uvs[2]=G.geometry.uvs[k][2]}l.push(i);b++}}else if(v instanceof THREE.Face4){y=L[v.a];M=L[v.b];I=L[v.c];N=L[v.d];if(y.__visible&&
|
||||
M.__visible&&I.__visible&&N.__visible)if(G.doubleSided||G.flipSided!=((N.positionScreen.x-y.positionScreen.x)*(M.positionScreen.y-y.positionScreen.y)-(N.positionScreen.y-y.positionScreen.y)*(M.positionScreen.x-y.positionScreen.x)<0||(M.positionScreen.x-I.positionScreen.x)*(N.positionScreen.y-I.positionScreen.y)-(M.positionScreen.y-I.positionScreen.y)*(N.positionScreen.x-I.positionScreen.x)<0)){i=m[b]=m[b]||new THREE.RenderableFace3;i.v1.positionWorld.copy(y.positionWorld);i.v2.positionWorld.copy(M.positionWorld);
|
||||
i.v3.positionWorld.copy(N.positionWorld);i.v1.positionScreen.copy(y.positionScreen);i.v2.positionScreen.copy(M.positionScreen);i.v3.positionScreen.copy(N.positionScreen);i.normalWorld.copy(v.normal);R.multiplyVector3(i.normalWorld);i.centroidWorld.copy(v.centroid);Z.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);u.multiplyVector3(i.centroidScreen);i.z=i.centroidScreen.z;i.meshMaterials=E;i.faceMaterials=v.materials;i.overdraw=J;if(G.geometry.uvs[k]){i.uvs[0]=G.geometry.uvs[k][0];
|
||||
i.uvs[1]=G.geometry.uvs[k][1];i.uvs[2]=G.geometry.uvs[k][3]}l.push(i);b++;q=m[b]=m[b]||new THREE.RenderableFace3;q.v1.positionWorld.copy(M.positionWorld);q.v2.positionWorld.copy(I.positionWorld);q.v3.positionWorld.copy(N.positionWorld);q.v1.positionScreen.copy(M.positionScreen);q.v2.positionScreen.copy(I.positionScreen);q.v3.positionScreen.copy(N.positionScreen);q.normalWorld.copy(i.normalWorld);q.centroidWorld.copy(i.centroidWorld);q.centroidScreen.copy(i.centroidScreen);q.z=q.centroidScreen.z;q.meshMaterials=
|
||||
E;q.faceMaterials=v.materials;q.overdraw=J;if(G.geometry.uvs[k]){q.uvs[0]=G.geometry.uvs[k][1];q.uvs[1]=G.geometry.uvs[k][2];q.uvs[2]=G.geometry.uvs[k][3]}l.push(q);b++}}}}else if(G instanceof THREE.Line){S.multiply(u,Z);L=G.geometry.vertices;v=L[0];v.positionScreen.copy(v.position);S.multiplyVector4(v.positionScreen);k=1;for(H=L.length;k<H;k++){x=L[k];x.positionScreen.copy(x.position);S.multiplyVector4(x.positionScreen);M=L[k-1];e.copy(x.positionScreen);h.copy(M.positionScreen);if(c(e,h)){e.multiplyScalar(1/
|
||||
e.w);h.multiplyScalar(1/h.w);n=F[D]=F[D]||new THREE.RenderableLine;n.v1.positionScreen.copy(e);n.v2.positionScreen.copy(h);n.z=Math.max(e.z,h.z);n.materials=G.materials;l.push(n);D++}}}else if(G instanceof THREE.Particle){U.set(G.position.x,G.position.y,G.position.z,1);u.multiplyVector4(U);U.z/=U.w;if(U.z>0&&U.z<1){y=T[B]=T[B]||new THREE.RenderableParticle;y.x=U.x/U.w;y.y=U.y/U.w;y.z=U.z;y.rotation=G.rotation.z;y.scale.x=G.scale.x*Math.abs(y.x-(U.x+p.projectionMatrix.n11)/(U.w+p.projectionMatrix.n14));
|
||||
y.scale.y=G.scale.y*Math.abs(y.y-(U.y+p.projectionMatrix.n22)/(U.w+p.projectionMatrix.n24));y.materials=G.materials;l.push(y);B++}}}}z&&l.sort(a);return l};this.unprojectVector=function(j,p){var z=new THREE.Matrix4;z.multiply(THREE.Matrix4.makeInvert(p.matrix),THREE.Matrix4.makeInvert(p.projectionMatrix));z.multiplyVector3(j);return j}};
|
||||
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,g,i;this.domElement=document.createElement("div");this.setSize=function(q,b){d=q;f=b;g=d/2;i=f/2};this.render=function(q,b){var m,n,D,F,y,B,T,V;a=c.projectScene(q,b);m=0;for(n=a.length;m<n;m++){y=a[m];if(y instanceof THREE.RenderableParticle){T=y.x*g+g;V=y.y*i+i;D=0;for(F=y.material.length;D<F;D++){B=y.material[D];if(B instanceof THREE.ParticleDOMMaterial){B=B.domElement;B.style.left=T+"px";B.style.top=V+"px"}}}}}};
|
||||
THREE.CanvasRenderer=function(){function a(da){if(y!=da)n.globalAlpha=y=da}function c(da){if(B!=da){switch(da){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}B=da}}var d=null,f=new THREE.Projector,g=document.createElement("canvas"),i,q,b,m,n=g.getContext("2d"),D=null,F=null,y=1,B=0,T=null,V=null,U=1,u,S,C,e,h,o,j,p,z,l=new THREE.Color,
|
||||
s=new THREE.Color,t=new THREE.Color,r=new THREE.Color,k=new THREE.Color,H,x,M,K,G,Z,R,E,J,P=new THREE.Rectangle,L=new THREE.Rectangle,v=new THREE.Rectangle,I=false,N=new THREE.Color,ea=new THREE.Color,ba=new THREE.Color,Y=new THREE.Color,ja=Math.PI*2,X=new THREE.Vector3,qa,ka,fa,ha,sa,ua,va=16;qa=document.createElement("canvas");qa.width=qa.height=2;ka=qa.getContext("2d");ka.fillStyle="rgba(0,0,0,1)";ka.fillRect(0,0,2,2);fa=ka.getImageData(0,0,2,2);ha=fa.data;sa=document.createElement("canvas");sa.width=
|
||||
sa.height=va;ua=sa.getContext("2d");ua.translate(-va/2,-va/2);ua.scale(va,va);va--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(da,ra){i=da;q=ra;b=i/2;m=q/2;g.width=i;g.height=q;P.set(-b,-m,b,m)};this.setClearColor=function(da,ra){D=da!==null?new THREE.Color(da):null;F=ra;L.set(-b,-m,b,m);n.setTransform(1,0,0,-1,b,m);this.clear()};this.clear=function(){if(!L.isEmpty()){L.inflate(1);L.minSelf(P);if(D!==null){c(THREE.NormalBlending);a(1);n.fillStyle=
|
||||
"rgba("+Math.floor(D.r*255)+","+Math.floor(D.g*255)+","+Math.floor(D.b*255)+","+F+")";n.fillRect(L.getX(),L.getY(),L.getWidth(),L.getHeight())}else n.clearRect(L.getX(),L.getY(),L.getWidth(),L.getHeight());L.empty()}};this.render=function(da,ra){function Ma(w){var W,Q,A,O=w.lights;ea.setRGB(0,0,0);ba.setRGB(0,0,0);Y.setRGB(0,0,0);w=0;for(W=O.length;w<W;w++){Q=O[w];A=Q.color;if(Q instanceof THREE.AmbientLight){ea.r+=A.r;ea.g+=A.g;ea.b+=A.b}else if(Q instanceof THREE.DirectionalLight){ba.r+=A.r;ba.g+=
|
||||
A.g;ba.b+=A.b}else if(Q instanceof THREE.PointLight){Y.r+=A.r;Y.g+=A.g;Y.b+=A.b}}}function Aa(w,W,Q,A){var O,$,ca,ga,ia=w.lights;w=0;for(O=ia.length;w<O;w++){$=ia[w];ca=$.color;ga=$.intensity;if($ instanceof THREE.DirectionalLight){$=Q.dot($.position)*ga;if($>0){A.r+=ca.r*$;A.g+=ca.g*$;A.b+=ca.b*$}}else if($ instanceof THREE.PointLight){X.sub($.position,W);X.normalize();$=Q.dot(X)*ga;if($>0){A.r+=ca.r*$;A.g+=ca.g*$;A.b+=ca.b*$}}}}function Na(w,W,Q){if(Q.opacity!=0){a(Q.opacity);c(Q.blending);var A,
|
||||
O,$,ca,ga,ia;if(Q instanceof THREE.ParticleBasicMaterial){if(Q.map){ca=Q.map;ga=ca.width>>1;ia=ca.height>>1;O=W.scale.x*b;$=W.scale.y*m;Q=O*ga;A=$*ia;v.set(w.x-Q,w.y-A,w.x+Q,w.y+A);if(!P.instersects(v))return;n.save();n.translate(w.x,w.y);n.rotate(-W.rotation);n.scale(O,-$);n.translate(-ga,-ia);n.drawImage(ca,0,0);n.restore()}n.beginPath();n.moveTo(w.x-10,w.y);n.lineTo(w.x+10,w.y);n.moveTo(w.x,w.y-10);n.lineTo(w.x,w.y+10);n.closePath();n.strokeStyle="rgb(255,255,0)";n.stroke()}else if(Q instanceof
|
||||
THREE.ParticleCircleMaterial){if(I){N.r=ea.r+ba.r+Y.r;N.g=ea.g+ba.g+Y.g;N.b=ea.b+ba.b+Y.b;l.r=Q.color.r*N.r;l.g=Q.color.g*N.g;l.b=Q.color.b*N.b;l.updateStyleString()}else l.__styleString=Q.color.__styleString;Q=W.scale.x*b;A=W.scale.y*m;v.set(w.x-Q,w.y-A,w.x+Q,w.y+A);if(P.instersects(v)){O=l.__styleString;if(V!=O)n.fillStyle=V=O;n.save();n.translate(w.x,w.y);n.rotate(-W.rotation);n.scale(Q,A);n.beginPath();n.arc(0,0,1,0,ja,true);n.closePath();n.fill();n.restore()}}}}function Oa(w,W,Q,A){if(A.opacity!=
|
||||
0){a(A.opacity);c(A.blending);n.beginPath();n.moveTo(w.positionScreen.x,w.positionScreen.y);n.lineTo(W.positionScreen.x,W.positionScreen.y);n.closePath();if(A instanceof THREE.LineBasicMaterial){l.__styleString=A.color.__styleString;w=A.linewidth;if(U!=w)n.lineWidth=U=w;w=l.__styleString;if(T!=w)n.strokeStyle=T=w;n.stroke();v.inflate(A.linewidth*2)}}}function Ia(w,W,Q,A,O,$){if(O.opacity!=0){a(O.opacity);c(O.blending);e=w.positionScreen.x;h=w.positionScreen.y;o=W.positionScreen.x;j=W.positionScreen.y;
|
||||
p=Q.positionScreen.x;z=Q.positionScreen.y;n.beginPath();n.moveTo(e,h);n.lineTo(o,j);n.lineTo(p,z);n.lineTo(e,h);n.closePath();if(O instanceof THREE.MeshBasicMaterial)if(O.map)O.map.image.loaded&&O.map.mapping instanceof THREE.UVMapping&&xa(e,h,o,j,p,z,O.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(O.env_map){if(O.env_map.image.loaded)if(O.env_map.mapping instanceof THREE.SphericalReflectionMapping){w=ra.matrix;X.copy(A.vertexNormalsWorld[0]);K=(X.x*w.n11+X.y*
|
||||
w.n12+X.z*w.n13)*0.5+0.5;G=-(X.x*w.n21+X.y*w.n22+X.z*w.n23)*0.5+0.5;X.copy(A.vertexNormalsWorld[1]);Z=(X.x*w.n11+X.y*w.n12+X.z*w.n13)*0.5+0.5;R=-(X.x*w.n21+X.y*w.n22+X.z*w.n23)*0.5+0.5;X.copy(A.vertexNormalsWorld[2]);E=(X.x*w.n11+X.y*w.n12+X.z*w.n13)*0.5+0.5;J=-(X.x*w.n21+X.y*w.n22+X.z*w.n23)*0.5+0.5;xa(e,h,o,j,p,z,O.env_map.image,K,G,Z,R,E,J)}}else O.wireframe?Ba(O.color.__styleString,O.wireframe_linewidth):Ca(O.color.__styleString);else if(O instanceof THREE.MeshLambertMaterial){if(O.map&&!O.wireframe){O.map.mapping instanceof
|
||||
THREE.UVMapping&&xa(e,h,o,j,p,z,O.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);c(THREE.SubtractiveBlending)}if(I)if(!O.wireframe&&O.shading==THREE.SmoothShading&&A.vertexNormalsWorld.length==3){s.r=t.r=r.r=ea.r;s.g=t.g=r.g=ea.g;s.b=t.b=r.b=ea.b;Aa($,A.v1.positionWorld,A.vertexNormalsWorld[0],s);Aa($,A.v2.positionWorld,A.vertexNormalsWorld[1],t);Aa($,A.v3.positionWorld,A.vertexNormalsWorld[2],r);k.r=(t.r+r.r)*0.5;k.g=(t.g+r.g)*0.5;k.b=(t.b+r.b)*0.5;M=Ja(s,t,r,k);xa(e,
|
||||
h,o,j,p,z,M,0,0,1,0,0,1)}else{N.r=ea.r;N.g=ea.g;N.b=ea.b;Aa($,A.centroidWorld,A.normalWorld,N);l.r=O.color.r*N.r;l.g=O.color.g*N.g;l.b=O.color.b*N.b;l.updateStyleString();O.wireframe?Ba(l.__styleString,O.wireframe_linewidth):Ca(l.__styleString)}else O.wireframe?Ba(O.color.__styleString,O.wireframe_linewidth):Ca(O.color.__styleString)}else if(O instanceof THREE.MeshDepthMaterial){H=ra.near;x=ra.far;s.r=s.g=s.b=1-Ea(w.positionScreen.z,H,x);t.r=t.g=t.b=1-Ea(W.positionScreen.z,H,x);r.r=r.g=r.b=1-Ea(Q.positionScreen.z,
|
||||
H,x);k.r=(t.r+r.r)*0.5;k.g=(t.g+r.g)*0.5;k.b=(t.b+r.b)*0.5;M=Ja(s,t,r,k);xa(e,h,o,j,p,z,M,0,0,1,0,0,1)}else if(O instanceof THREE.MeshNormalMaterial){l.r=Fa(A.normalWorld.x);l.g=Fa(A.normalWorld.y);l.b=Fa(A.normalWorld.z);l.updateStyleString();O.wireframe?Ba(l.__styleString,O.wireframe_linewidth):Ca(l.__styleString)}}}function Ba(w,W){if(T!=w)n.strokeStyle=T=w;if(U!=W)n.lineWidth=U=W;n.stroke();v.inflate(W*2)}function Ca(w){if(V!=w)n.fillStyle=V=w;n.fill()}function xa(w,W,Q,A,O,$,ca,ga,ia,na,la,oa,
|
||||
ya){var ta,pa;ta=ca.width-1;pa=ca.height-1;ga*=ta;ia*=pa;na*=ta;la*=pa;oa*=ta;ya*=pa;Q-=w;A-=W;O-=w;$-=W;na-=ga;la-=ia;oa-=ga;ya-=ia;pa=1/(na*ya-oa*la);ta=(ya*Q-la*O)*pa;la=(ya*A-la*$)*pa;Q=(na*O-oa*Q)*pa;A=(na*$-oa*A)*pa;w=w-ta*ga-Q*ia;W=W-la*ga-A*ia;n.save();n.transform(ta,la,Q,A,w,W);n.clip();n.drawImage(ca,0,0);n.restore()}function Ja(w,W,Q,A){var O=~~(w.r*255),$=~~(w.g*255);w=~~(w.b*255);var ca=~~(W.r*255),ga=~~(W.g*255);W=~~(W.b*255);var ia=~~(Q.r*255),na=~~(Q.g*255);Q=~~(Q.b*255);var la=~~(A.r*
|
||||
255),oa=~~(A.g*255);A=~~(A.b*255);ha[0]=O<0?0:O>255?255:O;ha[1]=$<0?0:$>255?255:$;ha[2]=w<0?0:w>255?255:w;ha[4]=ca<0?0:ca>255?255:ca;ha[5]=ga<0?0:ga>255?255:ga;ha[6]=W<0?0:W>255?255:W;ha[8]=ia<0?0:ia>255?255:ia;ha[9]=na<0?0:na>255?255:na;ha[10]=Q<0?0:Q>255?255:Q;ha[12]=la<0?0:la>255?255:la;ha[13]=oa<0?0:oa>255?255:oa;ha[14]=A<0?0:A>255?255:A;ka.putImageData(fa,0,0);ua.drawImage(qa,0,0);return sa}function Ea(w,W,Q){w=(w-W)/(Q-W);return w*w*(3-2*w)}function Fa(w){w=(w+1)*0.5;return w<0?0:w>1?1:w}function Ga(w,
|
||||
W){var Q=W.x-w.x,A=W.y-w.y,O=1/Math.sqrt(Q*Q+A*A);Q*=O;A*=O;W.x+=Q;W.y+=A;w.x-=Q;w.y-=A}var Da,Ka,aa,ma,wa,Ha,La,za;n.setTransform(1,0,0,-1,b,m);this.autoClear&&this.clear();d=f.projectScene(da,ra,this.sortElements);n.fillStyle="rgba( 0, 255, 255, 0.5 )";n.fillRect(P.getX(),P.getY(),P.getWidth(),P.getHeight());(I=da.lights.length>0)&&Ma(da);Da=0;for(Ka=d.length;Da<Ka;Da++){aa=d[Da];v.empty();if(aa instanceof THREE.RenderableParticle){u=aa;u.x*=b;u.y*=m;ma=0;for(wa=aa.materials.length;ma<wa;ma++)Na(u,
|
||||
E;q.faceMaterials=v.materials;q.overdraw=J;if(G.geometry.uvs[k]){q.uvs[0]=G.geometry.uvs[k][1];q.uvs[1]=G.geometry.uvs[k][2];q.uvs[2]=G.geometry.uvs[k][3]}l.push(q);b++}}}}else if(G instanceof THREE.Line){S.multiply(u,Z);L=G.geometry.vertices;v=L[0];v.positionScreen.copy(v.position);S.multiplyVector4(v.positionScreen);k=1;for(H=L.length;k<H;k++){y=L[k];y.positionScreen.copy(y.position);S.multiplyVector4(y.positionScreen);M=L[k-1];e.copy(y.positionScreen);h.copy(M.positionScreen);if(c(e,h)){e.multiplyScalar(1/
|
||||
e.w);h.multiplyScalar(1/h.w);n=F[D]=F[D]||new THREE.RenderableLine;n.v1.positionScreen.copy(e);n.v2.positionScreen.copy(h);n.z=Math.max(e.z,h.z);n.materials=G.materials;l.push(n);D++}}}else if(G instanceof THREE.Particle){U.set(G.position.x,G.position.y,G.position.z,1);u.multiplyVector4(U);U.z/=U.w;if(U.z>0&&U.z<1){x=T[A]=T[A]||new THREE.RenderableParticle;x.x=U.x/U.w;x.y=U.y/U.w;x.z=U.z;x.rotation=G.rotation.z;x.scale.x=G.scale.x*Math.abs(x.x-(U.x+p.projectionMatrix.n11)/(U.w+p.projectionMatrix.n14));
|
||||
x.scale.y=G.scale.y*Math.abs(x.y-(U.y+p.projectionMatrix.n22)/(U.w+p.projectionMatrix.n24));x.materials=G.materials;l.push(x);A++}}}}z&&l.sort(a);return l};this.unprojectVector=function(j,p){var z=new THREE.Matrix4;z.multiply(THREE.Matrix4.makeInvert(p.matrix),THREE.Matrix4.makeInvert(p.projectionMatrix));z.multiplyVector3(j);return j}};
|
||||
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,g,i;this.domElement=document.createElement("div");this.setSize=function(q,b){d=q;f=b;g=d/2;i=f/2};this.render=function(q,b){var m,n,D,F,x,A,T,V;a=c.projectScene(q,b);m=0;for(n=a.length;m<n;m++){x=a[m];if(x instanceof THREE.RenderableParticle){T=x.x*g+g;V=x.y*i+i;D=0;for(F=x.material.length;D<F;D++){A=x.material[D];if(A instanceof THREE.ParticleDOMMaterial){A=A.domElement;A.style.left=T+"px";A.style.top=V+"px"}}}}}};
|
||||
THREE.CanvasRenderer=function(){function a(da){if(x!=da)n.globalAlpha=x=da}function c(da){if(A!=da){switch(da){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}A=da}}var d=null,f=new THREE.Projector,g=document.createElement("canvas"),i,q,b,m,n=g.getContext("2d"),D=null,F=null,x=1,A=0,T=null,V=null,U=1,u,S,C,e,h,o,j,p,z,l=new THREE.Color,
|
||||
s=new THREE.Color,t=new THREE.Color,r=new THREE.Color,k=new THREE.Color,H,y,M,K,G,Z,R,E,J,P=new THREE.Rectangle,L=new THREE.Rectangle,v=new THREE.Rectangle,I=false,N=new THREE.Color,ea=new THREE.Color,ba=new THREE.Color,Y=new THREE.Color,ja=Math.PI*2,X=new THREE.Vector3,qa,ka,fa,ha,sa,ua,va=16;qa=document.createElement("canvas");qa.width=qa.height=2;ka=qa.getContext("2d");ka.fillStyle="rgba(0,0,0,1)";ka.fillRect(0,0,2,2);fa=ka.getImageData(0,0,2,2);ha=fa.data;sa=document.createElement("canvas");sa.width=
|
||||
sa.height=va;ua=sa.getContext("2d");ua.translate(-va/2,-va/2);ua.scale(va,va);va--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(da,ra){i=da;q=ra;b=i/2;m=q/2;g.width=i;g.height=q;P.set(-b,-m,b,m);x=1;A=0;V=T=null;U=1};this.setClearColor=function(da,ra){D=da!==null?new THREE.Color(da):null;F=ra;L.set(-b,-m,b,m);n.setTransform(1,0,0,-1,b,m);this.clear()};this.clear=function(){if(!L.isEmpty()){L.inflate(1);L.minSelf(P);if(D!==null){c(THREE.NormalBlending);
|
||||
a(1);n.fillStyle="rgba("+Math.floor(D.r*255)+","+Math.floor(D.g*255)+","+Math.floor(D.b*255)+","+F+")";n.fillRect(L.getX(),L.getY(),L.getWidth(),L.getHeight())}else n.clearRect(L.getX(),L.getY(),L.getWidth(),L.getHeight());L.empty()}};this.render=function(da,ra){function Ma(w){var W,Q,B,O=w.lights;ea.setRGB(0,0,0);ba.setRGB(0,0,0);Y.setRGB(0,0,0);w=0;for(W=O.length;w<W;w++){Q=O[w];B=Q.color;if(Q instanceof THREE.AmbientLight){ea.r+=B.r;ea.g+=B.g;ea.b+=B.b}else if(Q instanceof THREE.DirectionalLight){ba.r+=
|
||||
B.r;ba.g+=B.g;ba.b+=B.b}else if(Q instanceof THREE.PointLight){Y.r+=B.r;Y.g+=B.g;Y.b+=B.b}}}function Aa(w,W,Q,B){var O,$,ca,ga,ia=w.lights;w=0;for(O=ia.length;w<O;w++){$=ia[w];ca=$.color;ga=$.intensity;if($ instanceof THREE.DirectionalLight){$=Q.dot($.position)*ga;if($>0){B.r+=ca.r*$;B.g+=ca.g*$;B.b+=ca.b*$}}else if($ instanceof THREE.PointLight){X.sub($.position,W);X.normalize();$=Q.dot(X)*ga;if($>0){B.r+=ca.r*$;B.g+=ca.g*$;B.b+=ca.b*$}}}}function Na(w,W,Q){if(Q.opacity!=0){a(Q.opacity);c(Q.blending);
|
||||
var B,O,$,ca,ga,ia;if(Q instanceof THREE.ParticleBasicMaterial){if(Q.map){ca=Q.map;ga=ca.width>>1;ia=ca.height>>1;O=W.scale.x*b;$=W.scale.y*m;Q=O*ga;B=$*ia;v.set(w.x-Q,w.y-B,w.x+Q,w.y+B);if(!P.instersects(v))return;n.save();n.translate(w.x,w.y);n.rotate(-W.rotation);n.scale(O,-$);n.translate(-ga,-ia);n.drawImage(ca,0,0);n.restore()}n.beginPath();n.moveTo(w.x-10,w.y);n.lineTo(w.x+10,w.y);n.moveTo(w.x,w.y-10);n.lineTo(w.x,w.y+10);n.closePath();n.strokeStyle="rgb(255,255,0)";n.stroke()}else if(Q instanceof
|
||||
THREE.ParticleCircleMaterial){if(I){N.r=ea.r+ba.r+Y.r;N.g=ea.g+ba.g+Y.g;N.b=ea.b+ba.b+Y.b;l.r=Q.color.r*N.r;l.g=Q.color.g*N.g;l.b=Q.color.b*N.b;l.updateStyleString()}else l.__styleString=Q.color.__styleString;Q=W.scale.x*b;B=W.scale.y*m;v.set(w.x-Q,w.y-B,w.x+Q,w.y+B);if(P.instersects(v)){O=l.__styleString;if(V!=O)n.fillStyle=V=O;n.save();n.translate(w.x,w.y);n.rotate(-W.rotation);n.scale(Q,B);n.beginPath();n.arc(0,0,1,0,ja,true);n.closePath();n.fill();n.restore()}}}}function Oa(w,W,Q,B){if(B.opacity!=
|
||||
0){a(B.opacity);c(B.blending);n.beginPath();n.moveTo(w.positionScreen.x,w.positionScreen.y);n.lineTo(W.positionScreen.x,W.positionScreen.y);n.closePath();if(B instanceof THREE.LineBasicMaterial){l.__styleString=B.color.__styleString;w=B.linewidth;if(U!=w)n.lineWidth=U=w;w=l.__styleString;if(T!=w)n.strokeStyle=T=w;n.stroke();v.inflate(B.linewidth*2)}}}function Ia(w,W,Q,B,O,$){if(O.opacity!=0){a(O.opacity);c(O.blending);e=w.positionScreen.x;h=w.positionScreen.y;o=W.positionScreen.x;j=W.positionScreen.y;
|
||||
p=Q.positionScreen.x;z=Q.positionScreen.y;n.beginPath();n.moveTo(e,h);n.lineTo(o,j);n.lineTo(p,z);n.lineTo(e,h);n.closePath();if(O instanceof THREE.MeshBasicMaterial)if(O.map)O.map.image.loaded&&O.map.mapping instanceof THREE.UVMapping&&xa(e,h,o,j,p,z,O.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);else if(O.env_map){if(O.env_map.image.loaded)if(O.env_map.mapping instanceof THREE.SphericalReflectionMapping){w=ra.matrix;X.copy(B.vertexNormalsWorld[0]);K=(X.x*w.n11+X.y*
|
||||
w.n12+X.z*w.n13)*0.5+0.5;G=-(X.x*w.n21+X.y*w.n22+X.z*w.n23)*0.5+0.5;X.copy(B.vertexNormalsWorld[1]);Z=(X.x*w.n11+X.y*w.n12+X.z*w.n13)*0.5+0.5;R=-(X.x*w.n21+X.y*w.n22+X.z*w.n23)*0.5+0.5;X.copy(B.vertexNormalsWorld[2]);E=(X.x*w.n11+X.y*w.n12+X.z*w.n13)*0.5+0.5;J=-(X.x*w.n21+X.y*w.n22+X.z*w.n23)*0.5+0.5;xa(e,h,o,j,p,z,O.env_map.image,K,G,Z,R,E,J)}}else O.wireframe?Ba(O.color.__styleString,O.wireframe_linewidth):Ca(O.color.__styleString);else if(O instanceof THREE.MeshLambertMaterial){if(O.map&&!O.wireframe){O.map.mapping instanceof
|
||||
THREE.UVMapping&&xa(e,h,o,j,p,z,O.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);c(THREE.SubtractiveBlending)}if(I)if(!O.wireframe&&O.shading==THREE.SmoothShading&&B.vertexNormalsWorld.length==3){s.r=t.r=r.r=ea.r;s.g=t.g=r.g=ea.g;s.b=t.b=r.b=ea.b;Aa($,B.v1.positionWorld,B.vertexNormalsWorld[0],s);Aa($,B.v2.positionWorld,B.vertexNormalsWorld[1],t);Aa($,B.v3.positionWorld,B.vertexNormalsWorld[2],r);k.r=(t.r+r.r)*0.5;k.g=(t.g+r.g)*0.5;k.b=(t.b+r.b)*0.5;M=Ja(s,t,r,k);xa(e,
|
||||
h,o,j,p,z,M,0,0,1,0,0,1)}else{N.r=ea.r;N.g=ea.g;N.b=ea.b;Aa($,B.centroidWorld,B.normalWorld,N);l.r=O.color.r*N.r;l.g=O.color.g*N.g;l.b=O.color.b*N.b;l.updateStyleString();O.wireframe?Ba(l.__styleString,O.wireframe_linewidth):Ca(l.__styleString)}else O.wireframe?Ba(O.color.__styleString,O.wireframe_linewidth):Ca(O.color.__styleString)}else if(O instanceof THREE.MeshDepthMaterial){H=ra.near;y=ra.far;s.r=s.g=s.b=1-Ea(w.positionScreen.z,H,y);t.r=t.g=t.b=1-Ea(W.positionScreen.z,H,y);r.r=r.g=r.b=1-Ea(Q.positionScreen.z,
|
||||
H,y);k.r=(t.r+r.r)*0.5;k.g=(t.g+r.g)*0.5;k.b=(t.b+r.b)*0.5;M=Ja(s,t,r,k);xa(e,h,o,j,p,z,M,0,0,1,0,0,1)}else if(O instanceof THREE.MeshNormalMaterial){l.r=Fa(B.normalWorld.x);l.g=Fa(B.normalWorld.y);l.b=Fa(B.normalWorld.z);l.updateStyleString();O.wireframe?Ba(l.__styleString,O.wireframe_linewidth):Ca(l.__styleString)}}}function Ba(w,W){if(T!=w)n.strokeStyle=T=w;if(U!=W)n.lineWidth=U=W;n.stroke();v.inflate(W*2)}function Ca(w){if(V!=w)n.fillStyle=V=w;n.fill()}function xa(w,W,Q,B,O,$,ca,ga,ia,na,la,oa,
|
||||
ya){var ta,pa;ta=ca.width-1;pa=ca.height-1;ga*=ta;ia*=pa;na*=ta;la*=pa;oa*=ta;ya*=pa;Q-=w;B-=W;O-=w;$-=W;na-=ga;la-=ia;oa-=ga;ya-=ia;pa=1/(na*ya-oa*la);ta=(ya*Q-la*O)*pa;la=(ya*B-la*$)*pa;Q=(na*O-oa*Q)*pa;B=(na*$-oa*B)*pa;w=w-ta*ga-Q*ia;W=W-la*ga-B*ia;n.save();n.transform(ta,la,Q,B,w,W);n.clip();n.drawImage(ca,0,0);n.restore()}function Ja(w,W,Q,B){var O=~~(w.r*255),$=~~(w.g*255);w=~~(w.b*255);var ca=~~(W.r*255),ga=~~(W.g*255);W=~~(W.b*255);var ia=~~(Q.r*255),na=~~(Q.g*255);Q=~~(Q.b*255);var la=~~(B.r*
|
||||
255),oa=~~(B.g*255);B=~~(B.b*255);ha[0]=O<0?0:O>255?255:O;ha[1]=$<0?0:$>255?255:$;ha[2]=w<0?0:w>255?255:w;ha[4]=ca<0?0:ca>255?255:ca;ha[5]=ga<0?0:ga>255?255:ga;ha[6]=W<0?0:W>255?255:W;ha[8]=ia<0?0:ia>255?255:ia;ha[9]=na<0?0:na>255?255:na;ha[10]=Q<0?0:Q>255?255:Q;ha[12]=la<0?0:la>255?255:la;ha[13]=oa<0?0:oa>255?255:oa;ha[14]=B<0?0:B>255?255:B;ka.putImageData(fa,0,0);ua.drawImage(qa,0,0);return sa}function Ea(w,W,Q){w=(w-W)/(Q-W);return w*w*(3-2*w)}function Fa(w){w=(w+1)*0.5;return w<0?0:w>1?1:w}function Ga(w,
|
||||
W){var Q=W.x-w.x,B=W.y-w.y,O=1/Math.sqrt(Q*Q+B*B);Q*=O;B*=O;W.x+=Q;W.y+=B;w.x-=Q;w.y-=B}var Da,Ka,aa,ma,wa,Ha,La,za;n.setTransform(1,0,0,-1,b,m);this.autoClear&&this.clear();d=f.projectScene(da,ra,this.sortElements);n.fillStyle="rgba( 0, 255, 255, 0.5 )";n.fillRect(P.getX(),P.getY(),P.getWidth(),P.getHeight());(I=da.lights.length>0)&&Ma(da);Da=0;for(Ka=d.length;Da<Ka;Da++){aa=d[Da];v.empty();if(aa instanceof THREE.RenderableParticle){u=aa;u.x*=b;u.y*=m;ma=0;for(wa=aa.materials.length;ma<wa;ma++)Na(u,
|
||||
aa,aa.materials[ma],da)}else if(aa instanceof THREE.RenderableLine){u=aa.v1;S=aa.v2;u.positionScreen.x*=b;u.positionScreen.y*=m;S.positionScreen.x*=b;S.positionScreen.y*=m;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(S.positionScreen.x,S.positionScreen.y);if(P.instersects(v)){ma=0;for(wa=aa.materials.length;ma<wa;)Oa(u,S,aa,aa.materials[ma++],da)}}else if(aa instanceof THREE.RenderableFace3){u=aa.v1;S=aa.v2;C=aa.v3;u.positionScreen.x*=b;u.positionScreen.y*=m;S.positionScreen.x*=b;
|
||||
S.positionScreen.y*=m;C.positionScreen.x*=b;C.positionScreen.y*=m;if(aa.overdraw){Ga(u.positionScreen,S.positionScreen);Ga(S.positionScreen,C.positionScreen);Ga(C.positionScreen,u.positionScreen)}v.add3Points(u.positionScreen.x,u.positionScreen.y,S.positionScreen.x,S.positionScreen.y,C.positionScreen.x,C.positionScreen.y);if(P.instersects(v)){ma=0;for(wa=aa.meshMaterials.length;ma<wa;){za=aa.meshMaterials[ma++];if(za instanceof THREE.MeshFaceMaterial){Ha=0;for(La=aa.faceMaterials.length;Ha<La;)(za=
|
||||
aa.faceMaterials[Ha++])&&Ia(u,S,C,aa,za,da)}else Ia(u,S,C,aa,za,da)}}}L.addRectangle(v)}n.lineWidth=1;n.strokeStyle="rgba( 255, 0, 0, 0.5 )";n.strokeRect(L.getX(),L.getY(),L.getWidth(),L.getHeight());n.setTransform(1,0,0,1,0,0)}};
|
||||
@@ -137,37 +137,37 @@ THREE.SVGRenderer=function(){function a(K,G,Z){var R,E,J,P;R=0;for(E=K.lights.le
|
||||
C.setRGB(p,p,p)}else E instanceof THREE.MeshNormalMaterial&&C.setRGB(g(R.normalWorld.x),g(R.normalWorld.y),g(R.normalWorld.z));E.wireframe?r.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframe_linecap+"; stroke-linejoin: "+E.wireframe_linejoin):r.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+E.opacity);b.appendChild(r)}function d(K,G,Z,R,E,J,P){r=f(k++);r.setAttribute("d",
|
||||
"M "+K.positionScreen.x+" "+K.positionScreen.y+" L "+G.positionScreen.x+" "+G.positionScreen.y+" L "+Z.positionScreen.x+","+Z.positionScreen.y+" L "+R.positionScreen.x+","+R.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)C.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(S){e.r=h.r;e.g=h.g;e.b=h.b;a(P,E,e);C.r=J.color.r*e.r;C.g=J.color.g*e.g;C.b=J.color.b*e.b;C.updateStyleString()}else C.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){p=
|
||||
1-J.__2near/(J.__farPlusNear-E.z*J.__farMinusNear);C.setRGB(p,p,p)}else J instanceof THREE.MeshNormalMaterial&&C.setRGB(g(E.normalWorld.x),g(E.normalWorld.y),g(E.normalWorld.z));J.wireframe?r.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):r.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+J.opacity);b.appendChild(r)}
|
||||
function f(K){if(l[K]==null){l[K]=document.createElementNS("http://www.w3.org/2000/svg","path");M==0&&l[K].setAttribute("shape-rendering","crispEdges");return l[K]}return l[K]}function g(K){return K<0?Math.min((1+K)*0.5,0.5):0.5+Math.min(K*0.5,0.5)}var i=null,q=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,n,D,F,y,B,T,V,U=new THREE.Rectangle,u=new THREE.Rectangle,S=false,C=new THREE.Color(16777215),e=new THREE.Color(16777215),h=new THREE.Color(0),o=new THREE.Color(0),
|
||||
j=new THREE.Color(0),p,z=new THREE.Vector3,l=[],s=[],t=[],r,k,H,x,M=1;this.domElement=b;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(K){switch(K){case "high":M=1;break;case "low":M=0}};this.setSize=function(K,G){m=K;n=G;D=m/2;F=n/2;b.setAttribute("viewBox",-D+" "+-F+" "+m+" "+n);b.setAttribute("width",m);b.setAttribute("height",n);U.set(-D,-F,D,F)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])};this.render=function(K,G){var Z,R,
|
||||
E,J,P,L,v,I;this.autoClear&&this.clear();i=q.projectScene(K,G,this.sortElements);x=H=k=0;if(S=K.lights.length>0){v=K.lights;h.setRGB(0,0,0);o.setRGB(0,0,0);j.setRGB(0,0,0);Z=0;for(R=v.length;Z<R;Z++){E=v[Z];J=E.color;if(E instanceof THREE.AmbientLight){h.r+=J.r;h.g+=J.g;h.b+=J.b}else if(E instanceof THREE.DirectionalLight){o.r+=J.r;o.g+=J.g;o.b+=J.b}else if(E instanceof THREE.PointLight){j.r+=J.r;j.g+=J.g;j.b+=J.b}}}Z=0;for(R=i.length;Z<R;Z++){v=i[Z];u.empty();if(v instanceof THREE.RenderableParticle){y=
|
||||
v;y.x*=D;y.y*=-F;E=0;for(J=v.materials.length;E<J;E++)if(I=v.materials[E]){P=y;L=v;I=I;var N=H++;if(s[N]==null){s[N]=document.createElementNS("http://www.w3.org/2000/svg","circle");M==0&&s[N].setAttribute("shape-rendering","crispEdges")}r=s[N];r.setAttribute("cx",P.x);r.setAttribute("cy",P.y);r.setAttribute("r",L.scale.x*D);if(I instanceof THREE.ParticleCircleMaterial){if(S){e.r=h.r+o.r+j.r;e.g=h.g+o.g+j.g;e.b=h.b+o.b+j.b;C.r=I.color.r*e.r;C.g=I.color.g*e.g;C.b=I.color.b*e.b;C.updateStyleString()}else C=
|
||||
I.color;r.setAttribute("style","fill: "+C.__styleString)}b.appendChild(r)}}else if(v instanceof THREE.RenderableLine){y=v.v1;B=v.v2;y.positionScreen.x*=D;y.positionScreen.y*=-F;B.positionScreen.x*=D;B.positionScreen.y*=-F;u.addPoint(y.positionScreen.x,y.positionScreen.y);u.addPoint(B.positionScreen.x,B.positionScreen.y);if(U.instersects(u)){E=0;for(J=v.materials.length;E<J;)if(I=v.materials[E++]){P=y;L=B;I=I;N=x++;if(t[N]==null){t[N]=document.createElementNS("http://www.w3.org/2000/svg","line");M==
|
||||
function f(K){if(l[K]==null){l[K]=document.createElementNS("http://www.w3.org/2000/svg","path");M==0&&l[K].setAttribute("shape-rendering","crispEdges");return l[K]}return l[K]}function g(K){return K<0?Math.min((1+K)*0.5,0.5):0.5+Math.min(K*0.5,0.5)}var i=null,q=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,n,D,F,x,A,T,V,U=new THREE.Rectangle,u=new THREE.Rectangle,S=false,C=new THREE.Color(16777215),e=new THREE.Color(16777215),h=new THREE.Color(0),o=new THREE.Color(0),
|
||||
j=new THREE.Color(0),p,z=new THREE.Vector3,l=[],s=[],t=[],r,k,H,y,M=1;this.domElement=b;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(K){switch(K){case "high":M=1;break;case "low":M=0}};this.setSize=function(K,G){m=K;n=G;D=m/2;F=n/2;b.setAttribute("viewBox",-D+" "+-F+" "+m+" "+n);b.setAttribute("width",m);b.setAttribute("height",n);U.set(-D,-F,D,F)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])};this.render=function(K,G){var Z,R,
|
||||
E,J,P,L,v,I;this.autoClear&&this.clear();i=q.projectScene(K,G,this.sortElements);y=H=k=0;if(S=K.lights.length>0){v=K.lights;h.setRGB(0,0,0);o.setRGB(0,0,0);j.setRGB(0,0,0);Z=0;for(R=v.length;Z<R;Z++){E=v[Z];J=E.color;if(E instanceof THREE.AmbientLight){h.r+=J.r;h.g+=J.g;h.b+=J.b}else if(E instanceof THREE.DirectionalLight){o.r+=J.r;o.g+=J.g;o.b+=J.b}else if(E instanceof THREE.PointLight){j.r+=J.r;j.g+=J.g;j.b+=J.b}}}Z=0;for(R=i.length;Z<R;Z++){v=i[Z];u.empty();if(v instanceof THREE.RenderableParticle){x=
|
||||
v;x.x*=D;x.y*=-F;E=0;for(J=v.materials.length;E<J;E++)if(I=v.materials[E]){P=x;L=v;I=I;var N=H++;if(s[N]==null){s[N]=document.createElementNS("http://www.w3.org/2000/svg","circle");M==0&&s[N].setAttribute("shape-rendering","crispEdges")}r=s[N];r.setAttribute("cx",P.x);r.setAttribute("cy",P.y);r.setAttribute("r",L.scale.x*D);if(I instanceof THREE.ParticleCircleMaterial){if(S){e.r=h.r+o.r+j.r;e.g=h.g+o.g+j.g;e.b=h.b+o.b+j.b;C.r=I.color.r*e.r;C.g=I.color.g*e.g;C.b=I.color.b*e.b;C.updateStyleString()}else C=
|
||||
I.color;r.setAttribute("style","fill: "+C.__styleString)}b.appendChild(r)}}else if(v instanceof THREE.RenderableLine){x=v.v1;A=v.v2;x.positionScreen.x*=D;x.positionScreen.y*=-F;A.positionScreen.x*=D;A.positionScreen.y*=-F;u.addPoint(x.positionScreen.x,x.positionScreen.y);u.addPoint(A.positionScreen.x,A.positionScreen.y);if(U.instersects(u)){E=0;for(J=v.materials.length;E<J;)if(I=v.materials[E++]){P=x;L=A;I=I;N=y++;if(t[N]==null){t[N]=document.createElementNS("http://www.w3.org/2000/svg","line");M==
|
||||
0&&t[N].setAttribute("shape-rendering","crispEdges")}r=t[N];r.setAttribute("x1",P.positionScreen.x);r.setAttribute("y1",P.positionScreen.y);r.setAttribute("x2",L.positionScreen.x);r.setAttribute("y2",L.positionScreen.y);if(I instanceof THREE.LineBasicMaterial){C.__styleString=I.color.__styleString;r.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+I.linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: "+I.linecap+"; stroke-linejoin: "+I.linejoin);b.appendChild(r)}}}}else if(v instanceof
|
||||
THREE.RenderableFace3){y=v.v1;B=v.v2;T=v.v3;y.positionScreen.x*=D;y.positionScreen.y*=-F;B.positionScreen.x*=D;B.positionScreen.y*=-F;T.positionScreen.x*=D;T.positionScreen.y*=-F;u.addPoint(y.positionScreen.x,y.positionScreen.y);u.addPoint(B.positionScreen.x,B.positionScreen.y);u.addPoint(T.positionScreen.x,T.positionScreen.y);if(U.instersects(u)){E=0;for(J=v.meshMaterials.length;E<J;){I=v.meshMaterials[E++];if(I instanceof THREE.MeshFaceMaterial){P=0;for(L=v.faceMaterials.length;P<L;)(I=v.faceMaterials[P++])&&
|
||||
c(y,B,T,v,I,K)}else I&&c(y,B,T,v,I,K)}}}else if(v instanceof THREE.RenderableFace4){y=v.v1;B=v.v2;T=v.v3;V=v.v4;y.positionScreen.x*=D;y.positionScreen.y*=-F;B.positionScreen.x*=D;B.positionScreen.y*=-F;T.positionScreen.x*=D;T.positionScreen.y*=-F;V.positionScreen.x*=D;V.positionScreen.y*=-F;u.addPoint(y.positionScreen.x,y.positionScreen.y);u.addPoint(B.positionScreen.x,B.positionScreen.y);u.addPoint(T.positionScreen.x,T.positionScreen.y);u.addPoint(V.positionScreen.x,V.positionScreen.y);if(U.instersects(u)){E=
|
||||
0;for(J=v.meshMaterials.length;E<J;){I=v.meshMaterials[E++];if(I instanceof THREE.MeshFaceMaterial){P=0;for(L=v.faceMaterials.length;P<L;)(I=v.faceMaterials[P++])&&d(y,B,T,V,v,I,K)}else I&&d(y,B,T,V,v,I,K)}}}}}};
|
||||
THREE.RenderableFace3){x=v.v1;A=v.v2;T=v.v3;x.positionScreen.x*=D;x.positionScreen.y*=-F;A.positionScreen.x*=D;A.positionScreen.y*=-F;T.positionScreen.x*=D;T.positionScreen.y*=-F;u.addPoint(x.positionScreen.x,x.positionScreen.y);u.addPoint(A.positionScreen.x,A.positionScreen.y);u.addPoint(T.positionScreen.x,T.positionScreen.y);if(U.instersects(u)){E=0;for(J=v.meshMaterials.length;E<J;){I=v.meshMaterials[E++];if(I instanceof THREE.MeshFaceMaterial){P=0;for(L=v.faceMaterials.length;P<L;)(I=v.faceMaterials[P++])&&
|
||||
c(x,A,T,v,I,K)}else I&&c(x,A,T,v,I,K)}}}else if(v instanceof THREE.RenderableFace4){x=v.v1;A=v.v2;T=v.v3;V=v.v4;x.positionScreen.x*=D;x.positionScreen.y*=-F;A.positionScreen.x*=D;A.positionScreen.y*=-F;T.positionScreen.x*=D;T.positionScreen.y*=-F;V.positionScreen.x*=D;V.positionScreen.y*=-F;u.addPoint(x.positionScreen.x,x.positionScreen.y);u.addPoint(A.positionScreen.x,A.positionScreen.y);u.addPoint(T.positionScreen.x,T.positionScreen.y);u.addPoint(V.positionScreen.x,V.positionScreen.y);if(U.instersects(u)){E=
|
||||
0;for(J=v.meshMaterials.length;E<J;){I=v.meshMaterials[E++];if(I instanceof THREE.MeshFaceMaterial){P=0;for(L=v.faceMaterials.length;P<L;)(I=v.faceMaterials[P++])&&d(x,A,T,V,v,I,K)}else I&&d(x,A,T,V,v,I,K)}}}}}};
|
||||
THREE.WebGLRenderer=function(a){function c(e,h){e.fragment_shader=h.fragment_shader;e.vertex_shader=h.vertex_shader;e.uniforms=Uniforms.clone(h.uniforms)}function d(e,h){e.uniforms.color.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;e.uniforms.map.texture=e.map;e.uniforms.env_map.texture=e.env_map;e.uniforms.reflectivity.value=e.reflectivity;e.uniforms.refraction_ratio.value=e.refraction_ratio;e.uniforms.combine.value=e.combine;e.uniforms.useRefract.value=
|
||||
e.env_map&&e.env_map.mapping instanceof THREE.CubeRefractionMapping;if(h){e.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){e.uniforms.fogNear.value=h.near;e.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)e.uniforms.fogDensity.value=h.density}}function f(e,h){e.uniforms.color.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;if(h){e.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){e.uniforms.fogNear.value=
|
||||
h.near;e.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)e.uniforms.fogDensity.value=h.density}}function g(e,h){var o;if(e=="fragment")o=b.createShader(b.FRAGMENT_SHADER);else if(e=="vertex")o=b.createShader(b.VERTEX_SHADER);b.shaderSource(o,h);b.compileShader(o);if(!b.getShaderParameter(o,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(o));return null}return o}function i(e){switch(e){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;
|
||||
case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;
|
||||
case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var q=document.createElement("canvas"),b,m=null,n=null,D=new THREE.Matrix4,F,y=new Float32Array(16),B=new Float32Array(16),T=new Float32Array(16),V=new Float32Array(9),
|
||||
case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var q=document.createElement("canvas"),b,m=null,n=null,D=new THREE.Matrix4,F,x=new Float32Array(16),A=new Float32Array(16),T=new Float32Array(16),V=new Float32Array(9),
|
||||
U=new Float32Array(16),u=true,S=new THREE.Color(0),C=0;if(a){if(a.antialias!==undefined)u=a.antialias;a.clearColor!==undefined&&S.setHex(a.clearColor);if(a.clearAlpha!==undefined)C=a.clearAlpha}this.domElement=q;this.autoClear=true;(function(e,h,o){try{b=q.getContext("experimental-webgl",{antialias:e})}catch(j){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);
|
||||
b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(h.r,h.g,h.b,o)})(u,S,C);this.context=b;this.setSize=function(e,h){q.width=e;q.height=h;b.viewport(0,0,q.width,q.height)};this.setClearColor=function(e,h){var o=new THREE.Color(e);b.clearColor(o.r,o.g,o.b,h)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(e,h){var o,j,p,z=0,l=0,s=0,t,r,k,H=[],x=[],M=[],K=[];o=0;for(j=h.length;o<j;o++){p=h[o];t=p.color;r=p.position;
|
||||
k=p.intensity;if(p instanceof THREE.AmbientLight){z+=t.r;l+=t.g;s+=t.b}else if(p instanceof THREE.DirectionalLight){H.push(t.r*k,t.g*k,t.b*k);x.push(r.x,r.y,r.z)}else if(p instanceof THREE.PointLight){M.push(t.r*k,t.g*k,t.b*k);K.push(r.x,r.y,r.z)}}return{ambient:[z,l,s],directional:{colors:H,positions:x},point:{colors:M,positions:K}}};this.createParticleBuffers=function(e){e.__webGLVertexBuffer=b.createBuffer();e.__webGLFaceBuffer=b.createBuffer()};this.createLineBuffers=function(e){e.__webGLVertexBuffer=
|
||||
b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(h.r,h.g,h.b,o)})(u,S,C);this.context=b;this.setSize=function(e,h){q.width=e;q.height=h;b.viewport(0,0,q.width,q.height)};this.setClearColor=function(e,h){var o=new THREE.Color(e);b.clearColor(o.r,o.g,o.b,h)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(e,h){var o,j,p,z=0,l=0,s=0,t,r,k,H=[],y=[],M=[],K=[];o=0;for(j=h.length;o<j;o++){p=h[o];t=p.color;r=p.position;
|
||||
k=p.intensity;if(p instanceof THREE.AmbientLight){z+=t.r;l+=t.g;s+=t.b}else if(p instanceof THREE.DirectionalLight){H.push(t.r*k,t.g*k,t.b*k);y.push(r.x,r.y,r.z)}else if(p instanceof THREE.PointLight){M.push(t.r*k,t.g*k,t.b*k);K.push(r.x,r.y,r.z)}}return{ambient:[z,l,s],directional:{colors:H,positions:y},point:{colors:M,positions:K}}};this.createParticleBuffers=function(e){e.__webGLVertexBuffer=b.createBuffer();e.__webGLFaceBuffer=b.createBuffer()};this.createLineBuffers=function(e){e.__webGLVertexBuffer=
|
||||
b.createBuffer();e.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=function(e){e.__webGLVertexBuffer=b.createBuffer();e.__webGLNormalBuffer=b.createBuffer();e.__webGLTangentBuffer=b.createBuffer();e.__webGLUVBuffer=b.createBuffer();e.__webGLFaceBuffer=b.createBuffer();e.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(e){var h=e.vertices.length;e.__vertexArray=new Float32Array(h*3);e.__lineArray=new Uint16Array(h);e.__webGLLineCount=h};this.initMeshBuffers=function(e,h){var o,
|
||||
j,p=0,z=0,l=0,s=h.geometry.faces,t=e.faces;o=0;for(j=t.length;o<j;o++){fi=t[o];face=s[fi];if(face instanceof THREE.Face3){p+=3;z+=1;l+=3}else if(face instanceof THREE.Face4){p+=4;z+=2;l+=5}}e.__vertexArray=new Float32Array(p*3);e.__normalArray=new Float32Array(p*3);e.__tangentArray=new Float32Array(p*4);e.__uvArray=new Float32Array(p*2);e.__faceArray=new Uint16Array(z*3);e.__lineArray=new Uint16Array(l*2);p=false;o=0;for(j=h.materials.length;o<j;o++){s=h.materials[o];if(s instanceof THREE.MeshFaceMaterial){s=
|
||||
0;for(t=e.materials.length;s<t;s++)if(e.materials[s]&&e.materials[s].shading!=undefined&&e.materials[s].shading==THREE.SmoothShading){p=true;break}}else if(s&&s.shading!=undefined&&s.shading==THREE.SmoothShading){p=true;break}if(p)break}e.__needsSmoothNormals=p;e.__webGLFaceCount=z*3;e.__webGLLineCount=l*2};this.setMeshBuffers=function(e,h,o,j,p,z,l,s){var t,r,k,H,x,M,K,G,Z,R=0,E=0,J=0,P=0,L=0,v=0,I=0,N=e.__vertexArray,ea=e.__uvArray,ba=e.__normalArray,Y=e.__tangentArray,ja=e.__faceArray,X=e.__lineArray,
|
||||
qa=e.__needsSmoothNormals,ka=h.geometry,fa=ka.vertices,ha=e.faces,sa=ka.faces,ua=ka.uvs;h=0;for(t=ha.length;h<t;h++){r=ha[h];k=sa[r];r=ua[r];H=k.vertexNormals;x=k.normal;if(k instanceof THREE.Face3){if(j){M=fa[k.a].position;K=fa[k.b].position;G=fa[k.c].position;N[E]=M.x;N[E+1]=M.y;N[E+2]=M.z;N[E+3]=K.x;N[E+4]=K.y;N[E+5]=K.z;N[E+6]=G.x;N[E+7]=G.y;N[E+8]=G.z;E+=9}if(s&&ka.hasTangents){M=fa[k.a].tangent;K=fa[k.b].tangent;G=fa[k.c].tangent;Y[v]=M.x;Y[v+1]=M.y;Y[v+2]=M.z;Y[v+3]=M.w;Y[v+4]=K.x;Y[v+5]=K.y;
|
||||
Y[v+6]=K.z;Y[v+7]=K.w;Y[v+8]=G.x;Y[v+9]=G.y;Y[v+10]=G.z;Y[v+11]=G.w;v+=12}if(l)if(H.length==3&&qa)for(k=0;k<3;k++){x=H[k];ba[L]=x.x;ba[L+1]=x.y;ba[L+2]=x.z;L+=3}else for(k=0;k<3;k++){ba[L]=x.x;ba[L+1]=x.y;ba[L+2]=x.z;L+=3}if(z&&r)for(k=0;k<3;k++){H=r[k];ea[J]=H.u;ea[J+1]=H.v;J+=2}if(p){ja[P]=R;ja[P+1]=R+1;ja[P+2]=R+2;P+=3;X[I]=R;X[I+1]=R+1;X[I+2]=R;X[I+3]=R+2;X[I+4]=R+1;X[I+5]=R+2;I+=6;R+=3}}else if(k instanceof THREE.Face4){if(j){M=fa[k.a].position;K=fa[k.b].position;G=fa[k.c].position;Z=fa[k.d].position;
|
||||
N[E]=M.x;N[E+1]=M.y;N[E+2]=M.z;N[E+3]=K.x;N[E+4]=K.y;N[E+5]=K.z;N[E+6]=G.x;N[E+7]=G.y;N[E+8]=G.z;N[E+9]=Z.x;N[E+10]=Z.y;N[E+11]=Z.z;E+=12}if(s&&ka.hasTangents){M=fa[k.a].tangent;K=fa[k.b].tangent;G=fa[k.c].tangent;k=fa[k.d].tangent;Y[v]=M.x;Y[v+1]=M.y;Y[v+2]=M.z;Y[v+3]=M.w;Y[v+4]=K.x;Y[v+5]=K.y;Y[v+6]=K.z;Y[v+7]=K.w;Y[v+8]=G.x;Y[v+9]=G.y;Y[v+10]=G.z;Y[v+11]=G.w;Y[v+12]=k.x;Y[v+13]=k.y;Y[v+14]=k.z;Y[v+15]=k.w;v+=16}if(l)if(H.length==4&&qa)for(k=0;k<4;k++){x=H[k];ba[L]=x.x;ba[L+1]=x.y;ba[L+2]=x.z;L+=
|
||||
3}else for(k=0;k<4;k++){ba[L]=x.x;ba[L+1]=x.y;ba[L+2]=x.z;L+=3}if(z&&r)for(k=0;k<4;k++){H=r[k];ea[J]=H.u;ea[J+1]=H.v;J+=2}if(p){ja[P]=R;ja[P+1]=R+1;ja[P+2]=R+2;ja[P+3]=R;ja[P+4]=R+2;ja[P+5]=R+3;P+=6;X[I]=R;X[I+1]=R+1;X[I+2]=R;X[I+3]=R+2;X[I+4]=R;X[I+5]=R+3;X[I+6]=R+1;X[I+7]=R+2;X[I+8]=R+2;X[I+9]=R+3;I+=10;R+=4}}}if(j){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,N,o)}if(l){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ba,o)}if(s&&
|
||||
0;for(t=e.materials.length;s<t;s++)if(e.materials[s]&&e.materials[s].shading!=undefined&&e.materials[s].shading==THREE.SmoothShading){p=true;break}}else if(s&&s.shading!=undefined&&s.shading==THREE.SmoothShading){p=true;break}if(p)break}e.__needsSmoothNormals=p;e.__webGLFaceCount=z*3;e.__webGLLineCount=l*2};this.setMeshBuffers=function(e,h,o,j,p,z,l,s){var t,r,k,H,y,M,K,G,Z,R=0,E=0,J=0,P=0,L=0,v=0,I=0,N=e.__vertexArray,ea=e.__uvArray,ba=e.__normalArray,Y=e.__tangentArray,ja=e.__faceArray,X=e.__lineArray,
|
||||
qa=e.__needsSmoothNormals,ka=h.geometry,fa=ka.vertices,ha=e.faces,sa=ka.faces,ua=ka.uvs;h=0;for(t=ha.length;h<t;h++){r=ha[h];k=sa[r];r=ua[r];H=k.vertexNormals;y=k.normal;if(k instanceof THREE.Face3){if(j){M=fa[k.a].position;K=fa[k.b].position;G=fa[k.c].position;N[E]=M.x;N[E+1]=M.y;N[E+2]=M.z;N[E+3]=K.x;N[E+4]=K.y;N[E+5]=K.z;N[E+6]=G.x;N[E+7]=G.y;N[E+8]=G.z;E+=9}if(s&&ka.hasTangents){M=fa[k.a].tangent;K=fa[k.b].tangent;G=fa[k.c].tangent;Y[v]=M.x;Y[v+1]=M.y;Y[v+2]=M.z;Y[v+3]=M.w;Y[v+4]=K.x;Y[v+5]=K.y;
|
||||
Y[v+6]=K.z;Y[v+7]=K.w;Y[v+8]=G.x;Y[v+9]=G.y;Y[v+10]=G.z;Y[v+11]=G.w;v+=12}if(l)if(H.length==3&&qa)for(k=0;k<3;k++){y=H[k];ba[L]=y.x;ba[L+1]=y.y;ba[L+2]=y.z;L+=3}else for(k=0;k<3;k++){ba[L]=y.x;ba[L+1]=y.y;ba[L+2]=y.z;L+=3}if(z&&r)for(k=0;k<3;k++){H=r[k];ea[J]=H.u;ea[J+1]=H.v;J+=2}if(p){ja[P]=R;ja[P+1]=R+1;ja[P+2]=R+2;P+=3;X[I]=R;X[I+1]=R+1;X[I+2]=R;X[I+3]=R+2;X[I+4]=R+1;X[I+5]=R+2;I+=6;R+=3}}else if(k instanceof THREE.Face4){if(j){M=fa[k.a].position;K=fa[k.b].position;G=fa[k.c].position;Z=fa[k.d].position;
|
||||
N[E]=M.x;N[E+1]=M.y;N[E+2]=M.z;N[E+3]=K.x;N[E+4]=K.y;N[E+5]=K.z;N[E+6]=G.x;N[E+7]=G.y;N[E+8]=G.z;N[E+9]=Z.x;N[E+10]=Z.y;N[E+11]=Z.z;E+=12}if(s&&ka.hasTangents){M=fa[k.a].tangent;K=fa[k.b].tangent;G=fa[k.c].tangent;k=fa[k.d].tangent;Y[v]=M.x;Y[v+1]=M.y;Y[v+2]=M.z;Y[v+3]=M.w;Y[v+4]=K.x;Y[v+5]=K.y;Y[v+6]=K.z;Y[v+7]=K.w;Y[v+8]=G.x;Y[v+9]=G.y;Y[v+10]=G.z;Y[v+11]=G.w;Y[v+12]=k.x;Y[v+13]=k.y;Y[v+14]=k.z;Y[v+15]=k.w;v+=16}if(l)if(H.length==4&&qa)for(k=0;k<4;k++){y=H[k];ba[L]=y.x;ba[L+1]=y.y;ba[L+2]=y.z;L+=
|
||||
3}else for(k=0;k<4;k++){ba[L]=y.x;ba[L+1]=y.y;ba[L+2]=y.z;L+=3}if(z&&r)for(k=0;k<4;k++){H=r[k];ea[J]=H.u;ea[J+1]=H.v;J+=2}if(p){ja[P]=R;ja[P+1]=R+1;ja[P+2]=R+2;ja[P+3]=R;ja[P+4]=R+2;ja[P+5]=R+3;P+=6;X[I]=R;X[I+1]=R+1;X[I+2]=R;X[I+3]=R+2;X[I+4]=R;X[I+5]=R+3;X[I+6]=R+1;X[I+7]=R+2;X[I+8]=R+2;X[I+9]=R+3;I+=10;R+=4}}}if(j){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,N,o)}if(l){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ba,o)}if(s&&
|
||||
ka.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,Y,o)}if(z&&J>0){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,ea,o)}if(p){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ja,o);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,X,o)}};this.setLineBuffers=function(e,h,o,j){var p,z,l=e.vertices,s=l.length,t=e.__vertexArray,r=e.__lineArray;
|
||||
if(o)for(o=0;o<s;o++){p=l[o].position;z=o*3;t[z]=p.x;t[z+1]=p.y;t[z+2]=p.z}if(j)for(o=0;o<s;o++)r[o]=o;b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,t,h);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,r,h)};this.setParticleBuffers=function(){};this.renderBuffer=function(e,h,o,j,p,z){var l,s,t,r;if(!j.program){if(j instanceof THREE.MeshDepthMaterial){c(j,THREE.ShaderLib.depth);j.uniforms.mNear.value=e.near;j.uniforms.mFar.value=
|
||||
e.far}else if(j instanceof THREE.MeshNormalMaterial)c(j,THREE.ShaderLib.normal);else if(j instanceof THREE.MeshBasicMaterial){c(j,THREE.ShaderLib.basic);d(j,o)}else if(j instanceof THREE.MeshLambertMaterial){c(j,THREE.ShaderLib.lambert);d(j,o)}else if(j instanceof THREE.MeshPhongMaterial){c(j,THREE.ShaderLib.phong);d(j,o)}else if(j instanceof THREE.LineBasicMaterial){c(j,THREE.ShaderLib.basic);f(j,o)}var k,H,x;k=r=s=0;for(H=h.length;k<H;k++){x=h[k];x instanceof THREE.DirectionalLight&&r++;x instanceof
|
||||
THREE.PointLight&&s++}if(s+r<=4){k=r;s=s}else{k=Math.ceil(4*r/(s+r));s=4-k}s={directional:k,point:s};r={fog:o,map:j.map,env_map:j.env_map,maxDirLights:s.directional,maxPointLights:s.point};s=j.fragment_shader;k=j.vertex_shader;H=b.createProgram();x=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+r.maxDirLights,"#define MAX_POINT_LIGHTS "+r.maxPointLights,r.fog?"#define USE_FOG":"",r.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.env_map?"#define USE_ENVMAP":
|
||||
e.far}else if(j instanceof THREE.MeshNormalMaterial)c(j,THREE.ShaderLib.normal);else if(j instanceof THREE.MeshBasicMaterial){c(j,THREE.ShaderLib.basic);d(j,o)}else if(j instanceof THREE.MeshLambertMaterial){c(j,THREE.ShaderLib.lambert);d(j,o)}else if(j instanceof THREE.MeshPhongMaterial){c(j,THREE.ShaderLib.phong);d(j,o)}else if(j instanceof THREE.LineBasicMaterial){c(j,THREE.ShaderLib.basic);f(j,o)}var k,H,y;k=r=s=0;for(H=h.length;k<H;k++){y=h[k];y instanceof THREE.DirectionalLight&&r++;y instanceof
|
||||
THREE.PointLight&&s++}if(s+r<=4){k=r;s=s}else{k=Math.ceil(4*r/(s+r));s=4-k}s={directional:k,point:s};r={fog:o,map:j.map,env_map:j.env_map,maxDirLights:s.directional,maxPointLights:s.point};s=j.fragment_shader;k=j.vertex_shader;H=b.createProgram();y=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+r.maxDirLights,"#define MAX_POINT_LIGHTS "+r.maxPointLights,r.fog?"#define USE_FOG":"",r.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.env_map?"#define USE_ENVMAP":
|
||||
"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");r=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+r.maxDirLights,"#define MAX_POINT_LIGHTS "+r.maxPointLights,r.map?"#define USE_MAP":"",r.env_map?"#define USE_ENVMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");
|
||||
b.attachShader(H,g("fragment",x+s));b.attachShader(H,g("vertex",r+k));b.linkProgram(H);b.getProgramParameter(H,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(H,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");H.uniforms={};H.attributes={};j.program=H;s=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(l in j.uniforms)s.push(l);l=j.program;k=0;for(H=s.length;k<H;k++){x=s[k];l.uniforms[x]=b.getUniformLocation(l,
|
||||
x)}l=j.program;s=["position","normal","uv","tangent"];k=0;for(H=s.length;k<H;k++){x=s[k];l.attributes[x]=b.getAttribLocation(l,x)}}l=j.program;if(l!=m){b.useProgram(l);m=l}this.loadCamera(l,e);this.loadMatrices(l);if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){e=this.setupLights(l,h);j.uniforms.enableLighting.value=e.directional.positions.length+e.point.positions.length;j.uniforms.ambientLightColor.value=e.ambient;j.uniforms.directionalLightColor.value=e.directional.colors;
|
||||
b.attachShader(H,g("fragment",y+s));b.attachShader(H,g("vertex",r+k));b.linkProgram(H);b.getProgramParameter(H,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(H,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");H.uniforms={};H.attributes={};j.program=H;s=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(l in j.uniforms)s.push(l);l=j.program;k=0;for(H=s.length;k<H;k++){y=s[k];l.uniforms[y]=b.getUniformLocation(l,
|
||||
y)}l=j.program;s=["position","normal","uv","tangent"];k=0;for(H=s.length;k<H;k++){y=s[k];l.attributes[y]=b.getAttribLocation(l,y)}}l=j.program;if(l!=m){b.useProgram(l);m=l}this.loadCamera(l,e);this.loadMatrices(l);if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){e=this.setupLights(l,h);j.uniforms.enableLighting.value=e.directional.positions.length+e.point.positions.length;j.uniforms.ambientLightColor.value=e.ambient;j.uniforms.directionalLightColor.value=e.directional.colors;
|
||||
j.uniforms.directionalLightDirection.value=e.directional.positions;j.uniforms.pointLightColor.value=e.point.colors;j.uniforms.pointLightPosition.value=e.point.positions}if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial)d(j,o);j instanceof THREE.LineBasicMaterial&&f(j,o);if(j instanceof THREE.MeshPhongMaterial){j.uniforms.ambient.value.setRGB(j.ambient.r,j.ambient.g,j.ambient.b);j.uniforms.specular.value.setRGB(j.specular.r,j.specular.g,
|
||||
j.specular.b);j.uniforms.shininess.value=j.shininess}o=j.uniforms;for(t in o)if(k=l.uniforms[t]){h=o[t];s=h.type;e=h.value;if(s=="i")b.uniform1i(k,e);else if(s=="f")b.uniform1f(k,e);else if(s=="fv1")b.uniform1fv(k,e);else if(s=="fv")b.uniform3fv(k,e);else if(s=="v2")b.uniform2f(k,e.x,e.y);else if(s=="v3")b.uniform3f(k,e.x,e.y,e.z);else if(s=="c")b.uniform3f(k,e.r,e.g,e.b);else if(s=="t"){b.uniform1i(k,e);if(h=h.texture)if(h.image instanceof Array&&h.image.length==6){h=h;e=e;if(h.image.length==6){if(!h.image.__webGLTextureCube&&
|
||||
!h.image.__cubeMapInitialized&&h.image.loadCount==6){h.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,h.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(s=0;s<6;++s)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+
|
||||
@@ -178,12 +178,12 @@ j instanceof THREE.LineBasicMaterial){t=j.wireframe_linewidth!==undefined?j.wire
|
||||
h,o,j,p,z,l){var s,t,r,k,H;r=0;for(k=j.materials.length;r<k;r++){s=j.materials[r];if(s instanceof THREE.MeshFaceMaterial){s=0;for(t=p.materials.length;s<t;s++)if((H=p.materials[s])&&H.blending==z&&H.opacity<1==l){this.setBlending(H.blending);this.renderBuffer(e,h,o,H,p,j)}}else if((H=s)&&H.blending==z&&H.opacity<1==l){this.setBlending(H.blending);this.renderBuffer(e,h,o,H,p,j)}}};this.render=function(e,h,o,j){var p,z,l,s=e.lights,t=e.fog;this.initWebGLObjects(e);j=j!==undefined?j:true;if(o&&!o.__webGLFramebuffer){o.__webGLFramebuffer=
|
||||
b.createFramebuffer();o.__webGLRenderbuffer=b.createRenderbuffer();o.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,o.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,o.width,o.height);b.bindTexture(b.TEXTURE_2D,o.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,i(o.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,i(o.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,i(o.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,
|
||||
i(o.min_filter));b.texImage2D(b.TEXTURE_2D,0,i(o.format),o.width,o.height,0,i(o.format),i(o.type),null);b.bindFramebuffer(b.FRAMEBUFFER,o.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,o.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,o.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(o){p=o.__webGLFramebuffer;l=o.width;z=o.height}else{p=
|
||||
null;l=q.width;z=q.height}if(p!=n){b.bindFramebuffer(b.FRAMEBUFFER,p);b.viewport(0,0,l,z);j&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);n=p}this.autoClear&&this.clear();h.autoUpdateMatrix&&h.updateMatrix();y.set(h.matrix.flatten());T.set(h.projectionMatrix.flatten());j=0;for(p=e.__webGLObjects.length;j<p;j++){z=e.__webGLObjects[j];l=z.object;z=z.buffer;if(l.visible){this.setupMatrices(l,h);this.renderPass(h,s,t,l,z,THREE.NormalBlending,false)}}j=0;for(p=e.__webGLObjects.length;j<p;j++){z=e.__webGLObjects[j];
|
||||
null;l=q.width;z=q.height}if(p!=n){b.bindFramebuffer(b.FRAMEBUFFER,p);b.viewport(0,0,l,z);j&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);n=p}this.autoClear&&this.clear();h.autoUpdateMatrix&&h.updateMatrix();x.set(h.matrix.flatten());T.set(h.projectionMatrix.flatten());j=0;for(p=e.__webGLObjects.length;j<p;j++){z=e.__webGLObjects[j];l=z.object;z=z.buffer;if(l.visible){this.setupMatrices(l,h);this.renderPass(h,s,t,l,z,THREE.NormalBlending,false)}}j=0;for(p=e.__webGLObjects.length;j<p;j++){z=e.__webGLObjects[j];
|
||||
l=z.object;z=z.buffer;if(l.visible){this.setupMatrices(l,h);this.renderPass(h,s,t,l,z,THREE.AdditiveBlending,false);this.renderPass(h,s,t,l,z,THREE.SubtractiveBlending,false);this.renderPass(h,s,t,l,z,THREE.AdditiveBlending,true);this.renderPass(h,s,t,l,z,THREE.SubtractiveBlending,true);this.renderPass(h,s,t,l,z,THREE.NormalBlending,true)}}if(o&&o.min_filter!==THREE.NearestFilter&&o.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,o.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,
|
||||
null)}};this.initWebGLObjects=function(e){function h(r,k,H,x){if(r[k]==undefined){e.__webGLObjects.push({buffer:H,object:x});r[k]=1}}var o,j,p,z,l,s,t;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={}}o=0;for(j=e.objects.length;o<j;o++){p=e.objects[o];l=p.geometry;if(e.__webGLObjectsMap[p.id]==undefined)e.__webGLObjectsMap[p.id]={};t=e.__webGLObjectsMap[p.id];if(p instanceof THREE.Mesh){for(z in l.geometryChunks){s=l.geometryChunks[z];if(!s.__webGLVertexBuffer){this.createMeshBuffers(s);
|
||||
null)}};this.initWebGLObjects=function(e){function h(r,k,H,y){if(r[k]==undefined){e.__webGLObjects.push({buffer:H,object:y});r[k]=1}}var o,j,p,z,l,s,t;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={}}o=0;for(j=e.objects.length;o<j;o++){p=e.objects[o];l=p.geometry;if(e.__webGLObjectsMap[p.id]==undefined)e.__webGLObjectsMap[p.id]={};t=e.__webGLObjectsMap[p.id];if(p instanceof THREE.Mesh){for(z in l.geometryChunks){s=l.geometryChunks[z];if(!s.__webGLVertexBuffer){this.createMeshBuffers(s);
|
||||
this.initMeshBuffers(s,p);l.__dirtyVertices=true;l.__dirtyElements=true;l.__dirtyUvs=true;l.__dirtyNormals=true;l.__dirtyTangents=true}if(l.__dirtyVertices||l.__dirtyElements||l.__dirtyUvs)this.setMeshBuffers(s,p,b.DYNAMIC_DRAW,l.__dirtyVertices,l.__dirtyElements,l.__dirtyUvs,l.__dirtyNormals,l.__dirtyTangents);h(t,z,s,p)}l.__dirtyVertices=false;l.__dirtyElements=false;l.__dirtyUvs=false;l.__dirtyNormals=false;l.__dirtyTangents=false}else if(p instanceof THREE.Line){if(!l.__webGLVertexBuffer){this.createLineBuffers(l);
|
||||
this.initLineBuffers(l);l.__dirtyVertices=true;l.__dirtyElements=true}l.__dirtyVertices&&this.setLineBuffers(l,b.DYNAMIC_DRAW,l.__dirtyVertices,l.__dirtyElements);h(t,0,l,p);l.__dirtyVertices=false;l.__dirtyElements=false}else if(p instanceof THREE.ParticleSystem){l.__webGLVertexBuffer||this.createParticleBuffers(l);h(t,0,l,p)}}};this.removeObject=function(e,h){var o,j;for(o=e.__webGLObjects.length-1;o>=0;o--){j=e.__webGLObjects[o].object;h==j&&e.__webGLObjects.splice(o,1)}};this.setupMatrices=function(e,
|
||||
h){e.autoUpdateMatrix&&e.updateMatrix();D.multiply(h.matrix,e.matrix);B.set(D.flatten());F=THREE.Matrix4.makeInvert3x3(D).transpose();V.set(F.m);U.set(e.matrix.flatten())};this.loadMatrices=function(e){b.uniformMatrix4fv(e.uniforms.viewMatrix,false,y);b.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,B);b.uniformMatrix4fv(e.uniforms.projectionMatrix,false,T);b.uniformMatrix3fv(e.uniforms.normalMatrix,false,V);b.uniformMatrix4fv(e.uniforms.objectMatrix,false,U)};this.loadCamera=function(e,h){b.uniform3f(e.uniforms.cameraPosition,
|
||||
h){e.autoUpdateMatrix&&e.updateMatrix();D.multiply(h.matrix,e.matrix);A.set(D.flatten());F=THREE.Matrix4.makeInvert3x3(D).transpose();V.set(F.m);U.set(e.matrix.flatten())};this.loadMatrices=function(e){b.uniformMatrix4fv(e.uniforms.viewMatrix,false,x);b.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,A);b.uniformMatrix4fv(e.uniforms.projectionMatrix,false,T);b.uniformMatrix3fv(e.uniforms.normalMatrix,false,V);b.uniformMatrix4fv(e.uniforms.objectMatrix,false,U)};this.loadCamera=function(e,h){b.uniform3f(e.uniforms.cameraPosition,
|
||||
h.position.x,h.position.y,h.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,h){if(e){!h||h=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(e=="back")b.cullFace(b.BACK);else e=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);
|
||||
b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
|
||||
THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
|
||||
|
||||
+98
-98
@@ -12,21 +12,21 @@ THREE.Vector4=function(a,b,d,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1}
|
||||
THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
|
||||
return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
|
||||
THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
|
||||
THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){d=e[a];if(d instanceof THREE.Mesh)g=g.concat(this.intersectObject(d))}g.sort(function(h,j){return h.distance-j.distance});return g},intersectObject:function(a){function b(M,t,H,k){k=k.clone().subSelf(t);H=H.clone().subSelf(t);var f=M.clone().subSelf(t);M=k.dot(k);t=k.dot(H);k=k.dot(f);var l=H.dot(H);H=H.dot(f);f=1/(M*l-t*t);l=(l*k-t*H)*f;M=(M*H-t*k)*f;return l>0&&M>0&&l+M<1}var d,e,g,h,j,c,i,m,v,D,
|
||||
s,y=a.geometry,B=y.vertices,C=[];d=0;for(e=y.faces.length;d<e;d++){g=y.faces[d];D=this.origin.clone();s=this.direction.clone();h=a.matrix.multiplyVector3(B[g.a].position.clone());j=a.matrix.multiplyVector3(B[g.b].position.clone());c=a.matrix.multiplyVector3(B[g.c].position.clone());i=g instanceof THREE.Face4?a.matrix.multiplyVector3(B[g.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(g.normal.clone());v=s.dot(m);if(v<0){m=m.dot((new THREE.Vector3).sub(h,D))/v;D=D.addSelf(s.multiplyScalar(m));
|
||||
THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){d=e[a];if(d instanceof THREE.Mesh)g=g.concat(this.intersectObject(d))}g.sort(function(h,j){return h.distance-j.distance});return g},intersectObject:function(a){function b(L,t,H,k){k=k.clone().subSelf(t);H=H.clone().subSelf(t);var f=L.clone().subSelf(t);L=k.dot(k);t=k.dot(H);k=k.dot(f);var l=H.dot(H);H=H.dot(f);f=1/(L*l-t*t);l=(l*k-t*H)*f;L=(L*H-t*k)*f;return l>0&&L>0&&l+L<1}var d,e,g,h,j,c,i,m,v,D,
|
||||
r,y=a.geometry,A=y.vertices,C=[];d=0;for(e=y.faces.length;d<e;d++){g=y.faces[d];D=this.origin.clone();r=this.direction.clone();h=a.matrix.multiplyVector3(A[g.a].position.clone());j=a.matrix.multiplyVector3(A[g.b].position.clone());c=a.matrix.multiplyVector3(A[g.c].position.clone());i=g instanceof THREE.Face4?a.matrix.multiplyVector3(A[g.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(g.normal.clone());v=r.dot(m);if(v<0){m=m.dot((new THREE.Vector3).sub(h,D))/v;D=D.addSelf(r.multiplyScalar(m));
|
||||
if(g instanceof THREE.Face3){if(b(D,h,j,c)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};C.push(g)}}else if(g instanceof THREE.Face4)if(b(D,h,j,i)||b(D,j,c,i)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};C.push(g)}}}return C}};
|
||||
THREE.Rectangle=function(){function a(){h=e-b;j=g-d}var b,d,e,g,h,j,c=true;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return h};this.getHeight=function(){return j};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(i,m,v,D){c=false;b=i;d=m;e=v;g=D;a()};this.addPoint=function(i,m){if(c){c=false;b=i;d=m;e=i;g=m}else{b=b<i?b:i;d=d<m?d:m;e=e>i?e:i;g=g>m?
|
||||
g:m}a()};this.add3Points=function(i,m,v,D,s,y){if(c){c=false;b=i<v?i<s?i:s:v<s?v:s;d=m<D?m<y?m:y:D<y?D:y;e=i>v?i>s?i:s:v>s?v:s;g=m>D?m>y?m:y:D>y?D:y}else{b=i<v?i<s?i<b?i:b:s<b?s:b:v<s?v<b?v:b:s<b?s:b;d=m<D?m<y?m<d?m:d:y<d?y:d:D<y?D<d?D:d:y<d?y:d;e=i>v?i>s?i>e?i:e:s>e?s:e:v>s?v>e?v:e:s>e?s:e;g=m>D?m>y?m>g?m:g:y>g?y:g:D>y?D>g?D:g:y>g?y:g}a()};this.addRectangle=function(i){if(c){c=false;b=i.getLeft();d=i.getTop();e=i.getRight();g=i.getBottom()}else{b=b<i.getLeft()?b:i.getLeft();d=d<i.getTop()?d:i.getTop();
|
||||
g:m}a()};this.add3Points=function(i,m,v,D,r,y){if(c){c=false;b=i<v?i<r?i:r:v<r?v:r;d=m<D?m<y?m:y:D<y?D:y;e=i>v?i>r?i:r:v>r?v:r;g=m>D?m>y?m:y:D>y?D:y}else{b=i<v?i<r?i<b?i:b:r<b?r:b:v<r?v<b?v:b:r<b?r:b;d=m<D?m<y?m<d?m:d:y<d?y:d:D<y?D<d?D:d:y<d?y:d;e=i>v?i>r?i>e?i:e:r>e?r:e:v>r?v>e?v:e:r>e?r:e;g=m>D?m>y?m>g?m:g:y>g?y:g:D>y?D>g?D:g:y>g?y:g}a()};this.addRectangle=function(i){if(c){c=false;b=i.getLeft();d=i.getTop();e=i.getRight();g=i.getBottom()}else{b=b<i.getLeft()?b:i.getLeft();d=d<i.getTop()?d:i.getTop();
|
||||
e=e>i.getRight()?e:i.getRight();g=g>i.getBottom()?g:i.getBottom()}a()};this.inflate=function(i){b-=i;d-=i;e+=i;g+=i;a()};this.minSelf=function(i){b=b>i.getLeft()?b:i.getLeft();d=d>i.getTop()?d:i.getTop();e=e<i.getRight()?e:i.getRight();g=g<i.getBottom()?g:i.getBottom();a()};this.instersects=function(i){return Math.min(e,i.getRight())-Math.max(b,i.getLeft())>=0&&Math.min(g,i.getBottom())-Math.max(d,i.getTop())>=0};this.empty=function(){c=true;g=e=d=b=0;a()};this.isEmpty=function(){return c};this.toString=
|
||||
function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+g+", width: "+h+", height: "+j+" )"}};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,d,e,g,h,j,c,i,m,v,D,s,y,B,C){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=g||0;this.n22=h||1;this.n23=j||0;this.n24=c||0;this.n31=i||0;this.n32=m||0;this.n33=v||1;this.n34=D||0;this.n41=s||0;this.n42=y||0;this.n43=B||0;this.n44=C||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,d,e,g,h,j,c,i,m,v,D,s,y,B,C){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=g;this.n22=h;this.n23=j;this.n24=c;this.n31=i;this.n32=m;this.n33=v;this.n34=D;this.n41=s;this.n42=y;this.n43=B;this.n44=C;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
|
||||
THREE.Matrix4=function(a,b,d,e,g,h,j,c,i,m,v,D,r,y,A,C){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=g||0;this.n22=h||1;this.n23=j||0;this.n24=c||0;this.n31=i||0;this.n32=m||0;this.n33=v||1;this.n34=D||0;this.n41=r||0;this.n42=y||0;this.n43=A||0;this.n44=C||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,d,e,g,h,j,c,i,m,v,D,r,y,A,C){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=g;this.n22=h;this.n23=j;this.n24=c;this.n31=i;this.n32=m;this.n33=v;this.n34=D;this.n41=r;this.n42=y;this.n43=A;this.n44=C;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
|
||||
a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,d){var e=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3;h.sub(a,b).normalize();e.cross(d,h).normalize();g.cross(h,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=h.x;
|
||||
this.n32=h.y;this.n33=h.z;this.n34=-h.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,g=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*
|
||||
g;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,g=a.n13,h=a.n14,j=a.n21,c=a.n22,i=a.n23,m=a.n24,v=a.n31,D=a.n32,
|
||||
s=a.n33,y=a.n34,B=a.n41,C=a.n42,M=a.n43,t=a.n44,H=b.n11,k=b.n12,f=b.n13,l=b.n14,u=b.n21,n=b.n22,r=b.n23,I=b.n24,p=b.n31,w=b.n32,z=b.n33,x=b.n34,q=b.n41,N=b.n42,G=b.n43,R=b.n44;this.n11=d*H+e*u+g*p+h*q;this.n12=d*k+e*n+g*w+h*N;this.n13=d*f+e*r+g*z+h*G;this.n14=d*l+e*I+g*x+h*R;this.n21=j*H+c*u+i*p+m*q;this.n22=j*k+c*n+i*w+m*N;this.n23=j*f+c*r+i*z+m*G;this.n24=j*l+c*I+i*x+m*R;this.n31=v*H+D*u+s*p+y*q;this.n32=v*k+D*n+s*w+y*N;this.n33=v*f+D*r+s*z+y*G;this.n34=v*l+D*I+s*x+y*R;this.n41=B*H+C*u+M*p+t*q;
|
||||
this.n42=B*k+C*n+M*w+t*N;this.n43=B*f+C*r+M*z+t*G;this.n44=B*l+C*I+M*x+t*R;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,g=this.n14,h=this.n21,j=this.n22,c=this.n23,i=this.n24,m=this.n31,v=this.n32,D=this.n33,s=this.n34,y=this.n41,B=this.n42,C=this.n43,M=this.n44,t=a.n11,H=a.n21,k=a.n31,f=a.n41,l=a.n12,u=a.n22,n=a.n32,r=a.n42,I=a.n13,p=a.n23,w=a.n33,z=a.n43,x=a.n14,q=a.n24,N=a.n34;a=a.n44;this.n11=b*t+d*H+e*k+g*f;this.n12=b*l+d*u+e*n+g*r;this.n13=b*I+d*p+e*w+g*z;this.n14=
|
||||
b*x+d*q+e*N+g*a;this.n21=h*t+j*H+c*k+i*f;this.n22=h*l+j*u+c*n+i*r;this.n23=h*I+j*p+c*w+i*z;this.n24=h*x+j*q+c*N+i*a;this.n31=m*t+v*H+D*k+s*f;this.n32=m*l+v*u+D*n+s*r;this.n33=m*I+v*p+D*w+s*z;this.n34=m*x+v*q+D*N+s*a;this.n41=y*t+B*H+C*k+M*f;this.n42=y*l+B*u+C*n+M*r;this.n43=y*I+B*p+C*w+M*z;this.n44=y*x+B*q+C*N+M*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*=
|
||||
r=a.n33,y=a.n34,A=a.n41,C=a.n42,L=a.n43,t=a.n44,H=b.n11,k=b.n12,f=b.n13,l=b.n14,u=b.n21,n=b.n22,s=b.n23,I=b.n24,p=b.n31,w=b.n32,z=b.n33,x=b.n34,q=b.n41,N=b.n42,G=b.n43,R=b.n44;this.n11=d*H+e*u+g*p+h*q;this.n12=d*k+e*n+g*w+h*N;this.n13=d*f+e*s+g*z+h*G;this.n14=d*l+e*I+g*x+h*R;this.n21=j*H+c*u+i*p+m*q;this.n22=j*k+c*n+i*w+m*N;this.n23=j*f+c*s+i*z+m*G;this.n24=j*l+c*I+i*x+m*R;this.n31=v*H+D*u+r*p+y*q;this.n32=v*k+D*n+r*w+y*N;this.n33=v*f+D*s+r*z+y*G;this.n34=v*l+D*I+r*x+y*R;this.n41=A*H+C*u+L*p+t*q;
|
||||
this.n42=A*k+C*n+L*w+t*N;this.n43=A*f+C*s+L*z+t*G;this.n44=A*l+C*I+L*x+t*R;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,g=this.n14,h=this.n21,j=this.n22,c=this.n23,i=this.n24,m=this.n31,v=this.n32,D=this.n33,r=this.n34,y=this.n41,A=this.n42,C=this.n43,L=this.n44,t=a.n11,H=a.n21,k=a.n31,f=a.n41,l=a.n12,u=a.n22,n=a.n32,s=a.n42,I=a.n13,p=a.n23,w=a.n33,z=a.n43,x=a.n14,q=a.n24,N=a.n34;a=a.n44;this.n11=b*t+d*H+e*k+g*f;this.n12=b*l+d*u+e*n+g*s;this.n13=b*I+d*p+e*w+g*z;this.n14=
|
||||
b*x+d*q+e*N+g*a;this.n21=h*t+j*H+c*k+i*f;this.n22=h*l+j*u+c*n+i*s;this.n23=h*I+j*p+c*w+i*z;this.n24=h*x+j*q+c*N+i*a;this.n31=m*t+v*H+D*k+r*f;this.n32=m*l+v*u+D*n+r*s;this.n33=m*I+v*p+D*w+r*z;this.n34=m*x+v*q+D*N+r*a;this.n41=y*t+A*H+C*k+L*f;this.n42=y*l+A*u+C*n+L*s;this.n43=y*I+A*p+C*w+L*z;this.n44=y*x+A*q+C*N+L*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=
|
||||
a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*
|
||||
this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,d,e){var g=b[d];b[d]=b[e];
|
||||
b[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
|
||||
@@ -48,8 +48,8 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.f
|
||||
d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,g,h,j,c=new THREE.Vector3,i=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){h=this.vertices[e];h.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){h=this.faces[e];if(a&&h.vertexNormals.length){c.set(0,0,0);b=0;for(d=h.normal.length;b<d;b++)c.addSelf(h.vertexNormals[b]);c.divideScalar(3)}else{b=this.vertices[h.a];d=this.vertices[h.b];j=this.vertices[h.c];c.sub(j.position,
|
||||
d.position);i.sub(b.position,d.position);c.crossSelf(i)}c.isZero()||c.normalize();h.normal.copy(c)}},computeVertexNormals:function(){var a,b,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)e[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
|
||||
new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)e[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];if(d instanceof THREE.Face3){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal);e[d.d].addSelf(d.normal)}}a=0;for(b=this.vertices.length;a<b;a++)e[a].normalize();a=0;for(b=this.faces.length;a<
|
||||
b;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(x,q,N,G,R,T,O){h=x.vertices[q].position;j=x.vertices[N].position;c=x.vertices[G].position;i=g[R];m=g[T];v=g[O];D=j.x-h.x;s=c.x-h.x;y=j.y-h.y;B=c.y-h.y;
|
||||
C=j.z-h.z;M=c.z-h.z;t=m.u-i.u;H=v.u-i.u;k=m.v-i.v;f=v.v-i.v;l=1/(t*f-H*k);r.set((f*D-k*s)*l,(f*y-k*B)*l,(f*C-k*M)*l);I.set((t*s-H*D)*l,(t*B-H*y)*l,(t*M-H*C)*l);u[q].addSelf(r);u[N].addSelf(r);u[G].addSelf(r);n[q].addSelf(I);n[N].addSelf(I);n[G].addSelf(I)}var b,d,e,g,h,j,c,i,m,v,D,s,y,B,C,M,t,H,k,f,l,u=[],n=[],r=new THREE.Vector3,I=new THREE.Vector3,p=new THREE.Vector3,w=new THREE.Vector3,z=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++){u[b]=new THREE.Vector3;n[b]=new THREE.Vector3}b=0;
|
||||
b;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(x,q,N,G,R,T,O){h=x.vertices[q].position;j=x.vertices[N].position;c=x.vertices[G].position;i=g[R];m=g[T];v=g[O];D=j.x-h.x;r=c.x-h.x;y=j.y-h.y;A=c.y-h.y;
|
||||
C=j.z-h.z;L=c.z-h.z;t=m.u-i.u;H=v.u-i.u;k=m.v-i.v;f=v.v-i.v;l=1/(t*f-H*k);s.set((f*D-k*r)*l,(f*y-k*A)*l,(f*C-k*L)*l);I.set((t*r-H*D)*l,(t*A-H*y)*l,(t*L-H*C)*l);u[q].addSelf(s);u[N].addSelf(s);u[G].addSelf(s);n[q].addSelf(I);n[N].addSelf(I);n[G].addSelf(I)}var b,d,e,g,h,j,c,i,m,v,D,r,y,A,C,L,t,H,k,f,l,u=[],n=[],s=new THREE.Vector3,I=new THREE.Vector3,p=new THREE.Vector3,w=new THREE.Vector3,z=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++){u[b]=new THREE.Vector3;n[b]=new THREE.Vector3}b=0;
|
||||
for(d=this.faces.length;b<d;b++){e=this.faces[b];g=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
|
||||
this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(d=this.vertices.length;b<d;b++){z.copy(this.vertices[b].normal);e=u[b];p.copy(e);p.subSelf(z.multiplyScalar(z.dot(e))).normalize();w.cross(this.vertices[b].normal,e);e=w.dot(n[b]);e=e<0?-1:1;this.vertices[b].tangent.set(p.x,p.y,p.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
|
||||
z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,d=this.vertices.length;b<d;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>
|
||||
@@ -99,69 +99,69 @@ var Uniforms={clone:function(a){var b,d,e,g={};for(b in a){g[b]={};for(d in a[b]
|
||||
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
|
||||
THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
|
||||
THREE.Fog=function(a,b,d){this.color=new THREE.Color(a);this.near=b||1;this.far=d||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
|
||||
THREE.Projector=function(){function a(n,r){return r.z-n.z}function b(n,r){var I=0,p=1,w=n.z+n.w,z=r.z+r.w,x=-n.z+n.w,q=-r.z+r.w;if(w>=0&&z>=0&&x>=0&&q>=0)return true;else if(w<0&&z<0||x<0&&q<0)return false;else{if(w<0)I=Math.max(I,w/(w-z));else if(z<0)p=Math.min(p,w/(w-z));if(x<0)I=Math.max(I,x/(x-q));else if(q<0)p=Math.min(p,x/(x-q));if(p<I)return false;else{n.lerpSelf(r,I);r.lerpSelf(n,1-p);return true}}}var d,e,g=[],h,j,c,i=[],m,v,D=[],s,y,B=[],C=new THREE.Vector4,M=new THREE.Vector4,t=new THREE.Matrix4,
|
||||
H=new THREE.Matrix4,k=[],f=new THREE.Vector4,l=new THREE.Vector4,u;this.projectObjects=function(n,r,I){var p=[],w,z;e=0;t.multiply(r.projectionMatrix,r.matrix);k[0]=new THREE.Vector4(t.n41-t.n11,t.n42-t.n12,t.n43-t.n13,t.n44-t.n14);k[1]=new THREE.Vector4(t.n41+t.n11,t.n42+t.n12,t.n43+t.n13,t.n44+t.n14);k[2]=new THREE.Vector4(t.n41+t.n21,t.n42+t.n22,t.n43+t.n23,t.n44+t.n24);k[3]=new THREE.Vector4(t.n41-t.n21,t.n42-t.n22,t.n43-t.n23,t.n44-t.n24);k[4]=new THREE.Vector4(t.n41-t.n31,t.n42-t.n32,t.n43-
|
||||
t.n33,t.n44-t.n34);k[5]=new THREE.Vector4(t.n41+t.n31,t.n42+t.n32,t.n43+t.n33,t.n44+t.n34);r=0;for(w=k.length;r<w;r++){z=k[r];z.divideScalar(Math.sqrt(z.x*z.x+z.y*z.y+z.z*z.z))}w=n.objects;n=0;for(r=w.length;n<r;n++){z=w[n];var x;if(!(x=!z.visible)){if(x=z instanceof THREE.Mesh){a:{x=void 0;for(var q=z.position,N=-z.geometry.boundingSphere.radius*Math.max(z.scale.x,Math.max(z.scale.y,z.scale.z)),G=0;G<6;G++){x=k[G].x*q.x+k[G].y*q.y+k[G].z*q.z+k[G].w;if(x<=N){x=false;break a}}x=true}x=!x}x=x}if(!x){d=
|
||||
g[e]=g[e]||new THREE.RenderableObject;C.copy(z.position);t.multiplyVector3(C);d.object=z;d.z=C.z;p.push(d);e++}}I&&p.sort(a);return p};this.projectScene=function(n,r,I){var p=[],w=r.near,z=r.far,x,q,N,G,R,T,O,ba,X,L,Q,Z,U,A,P,S;c=v=y=0;r.autoUpdateMatrix&&r.updateMatrix();t.multiply(r.projectionMatrix,r.matrix);T=this.projectObjects(n,r,true);n=0;for(x=T.length;n<x;n++){O=T[n].object;if(O.visible){O.autoUpdateMatrix&&O.updateMatrix();ba=O.matrix;X=O.rotationMatrix;L=O.materials;Q=O.overdraw;if(O instanceof
|
||||
THREE.Mesh){Z=O.geometry;U=Z.vertices;q=0;for(N=U.length;q<N;q++){A=U[q];A.positionWorld.copy(A.position);ba.multiplyVector3(A.positionWorld);G=A.positionScreen;G.copy(A.positionWorld);t.multiplyVector4(G);G.x/=G.w;G.y/=G.w;A.__visible=G.z>w&&G.z<z}Z=Z.faces;q=0;for(N=Z.length;q<N;q++){A=Z[q];if(A instanceof THREE.Face3){G=U[A.a];R=U[A.b];P=U[A.c];if(G.__visible&&R.__visible&&P.__visible)if(O.doubleSided||O.flipSided!=(P.positionScreen.x-G.positionScreen.x)*(R.positionScreen.y-G.positionScreen.y)-
|
||||
(P.positionScreen.y-G.positionScreen.y)*(R.positionScreen.x-G.positionScreen.x)<0){h=i[c]=i[c]||new THREE.RenderableFace3;h.v1.positionWorld.copy(G.positionWorld);h.v2.positionWorld.copy(R.positionWorld);h.v3.positionWorld.copy(P.positionWorld);h.v1.positionScreen.copy(G.positionScreen);h.v2.positionScreen.copy(R.positionScreen);h.v3.positionScreen.copy(P.positionScreen);h.normalWorld.copy(A.normal);X.multiplyVector3(h.normalWorld);h.centroidWorld.copy(A.centroid);ba.multiplyVector3(h.centroidWorld);
|
||||
h.centroidScreen.copy(h.centroidWorld);t.multiplyVector3(h.centroidScreen);P=A.vertexNormals;u=h.vertexNormalsWorld;G=0;for(R=P.length;G<R;G++){S=u[G]=u[G]||new THREE.Vector3;S.copy(P[G]);X.multiplyVector3(S)}h.z=h.centroidScreen.z;h.meshMaterials=L;h.faceMaterials=A.materials;h.overdraw=Q;if(O.geometry.uvs[q]){h.uvs[0]=O.geometry.uvs[q][0];h.uvs[1]=O.geometry.uvs[q][1];h.uvs[2]=O.geometry.uvs[q][2]}p.push(h);c++}}else if(A instanceof THREE.Face4){G=U[A.a];R=U[A.b];P=U[A.c];S=U[A.d];if(G.__visible&&
|
||||
THREE.Projector=function(){function a(n,s){return s.z-n.z}function b(n,s){var I=0,p=1,w=n.z+n.w,z=s.z+s.w,x=-n.z+n.w,q=-s.z+s.w;if(w>=0&&z>=0&&x>=0&&q>=0)return true;else if(w<0&&z<0||x<0&&q<0)return false;else{if(w<0)I=Math.max(I,w/(w-z));else if(z<0)p=Math.min(p,w/(w-z));if(x<0)I=Math.max(I,x/(x-q));else if(q<0)p=Math.min(p,x/(x-q));if(p<I)return false;else{n.lerpSelf(s,I);s.lerpSelf(n,1-p);return true}}}var d,e,g=[],h,j,c,i=[],m,v,D=[],r,y,A=[],C=new THREE.Vector4,L=new THREE.Vector4,t=new THREE.Matrix4,
|
||||
H=new THREE.Matrix4,k=[],f=new THREE.Vector4,l=new THREE.Vector4,u;this.projectObjects=function(n,s,I){var p=[],w,z;e=0;t.multiply(s.projectionMatrix,s.matrix);k[0]=new THREE.Vector4(t.n41-t.n11,t.n42-t.n12,t.n43-t.n13,t.n44-t.n14);k[1]=new THREE.Vector4(t.n41+t.n11,t.n42+t.n12,t.n43+t.n13,t.n44+t.n14);k[2]=new THREE.Vector4(t.n41+t.n21,t.n42+t.n22,t.n43+t.n23,t.n44+t.n24);k[3]=new THREE.Vector4(t.n41-t.n21,t.n42-t.n22,t.n43-t.n23,t.n44-t.n24);k[4]=new THREE.Vector4(t.n41-t.n31,t.n42-t.n32,t.n43-
|
||||
t.n33,t.n44-t.n34);k[5]=new THREE.Vector4(t.n41+t.n31,t.n42+t.n32,t.n43+t.n33,t.n44+t.n34);s=0;for(w=k.length;s<w;s++){z=k[s];z.divideScalar(Math.sqrt(z.x*z.x+z.y*z.y+z.z*z.z))}w=n.objects;n=0;for(s=w.length;n<s;n++){z=w[n];var x;if(!(x=!z.visible)){if(x=z instanceof THREE.Mesh){a:{x=void 0;for(var q=z.position,N=-z.geometry.boundingSphere.radius*Math.max(z.scale.x,Math.max(z.scale.y,z.scale.z)),G=0;G<6;G++){x=k[G].x*q.x+k[G].y*q.y+k[G].z*q.z+k[G].w;if(x<=N){x=false;break a}}x=true}x=!x}x=x}if(!x){d=
|
||||
g[e]=g[e]||new THREE.RenderableObject;C.copy(z.position);t.multiplyVector3(C);d.object=z;d.z=C.z;p.push(d);e++}}I&&p.sort(a);return p};this.projectScene=function(n,s,I){var p=[],w=s.near,z=s.far,x,q,N,G,R,T,O,ba,X,M,Q,Z,U,B,P,S;c=v=y=0;s.autoUpdateMatrix&&s.updateMatrix();t.multiply(s.projectionMatrix,s.matrix);T=this.projectObjects(n,s,true);n=0;for(x=T.length;n<x;n++){O=T[n].object;if(O.visible){O.autoUpdateMatrix&&O.updateMatrix();ba=O.matrix;X=O.rotationMatrix;M=O.materials;Q=O.overdraw;if(O instanceof
|
||||
THREE.Mesh){Z=O.geometry;U=Z.vertices;q=0;for(N=U.length;q<N;q++){B=U[q];B.positionWorld.copy(B.position);ba.multiplyVector3(B.positionWorld);G=B.positionScreen;G.copy(B.positionWorld);t.multiplyVector4(G);G.x/=G.w;G.y/=G.w;B.__visible=G.z>w&&G.z<z}Z=Z.faces;q=0;for(N=Z.length;q<N;q++){B=Z[q];if(B instanceof THREE.Face3){G=U[B.a];R=U[B.b];P=U[B.c];if(G.__visible&&R.__visible&&P.__visible)if(O.doubleSided||O.flipSided!=(P.positionScreen.x-G.positionScreen.x)*(R.positionScreen.y-G.positionScreen.y)-
|
||||
(P.positionScreen.y-G.positionScreen.y)*(R.positionScreen.x-G.positionScreen.x)<0){h=i[c]=i[c]||new THREE.RenderableFace3;h.v1.positionWorld.copy(G.positionWorld);h.v2.positionWorld.copy(R.positionWorld);h.v3.positionWorld.copy(P.positionWorld);h.v1.positionScreen.copy(G.positionScreen);h.v2.positionScreen.copy(R.positionScreen);h.v3.positionScreen.copy(P.positionScreen);h.normalWorld.copy(B.normal);X.multiplyVector3(h.normalWorld);h.centroidWorld.copy(B.centroid);ba.multiplyVector3(h.centroidWorld);
|
||||
h.centroidScreen.copy(h.centroidWorld);t.multiplyVector3(h.centroidScreen);P=B.vertexNormals;u=h.vertexNormalsWorld;G=0;for(R=P.length;G<R;G++){S=u[G]=u[G]||new THREE.Vector3;S.copy(P[G]);X.multiplyVector3(S)}h.z=h.centroidScreen.z;h.meshMaterials=M;h.faceMaterials=B.materials;h.overdraw=Q;if(O.geometry.uvs[q]){h.uvs[0]=O.geometry.uvs[q][0];h.uvs[1]=O.geometry.uvs[q][1];h.uvs[2]=O.geometry.uvs[q][2]}p.push(h);c++}}else if(B instanceof THREE.Face4){G=U[B.a];R=U[B.b];P=U[B.c];S=U[B.d];if(G.__visible&&
|
||||
R.__visible&&P.__visible&&S.__visible)if(O.doubleSided||O.flipSided!=((S.positionScreen.x-G.positionScreen.x)*(R.positionScreen.y-G.positionScreen.y)-(S.positionScreen.y-G.positionScreen.y)*(R.positionScreen.x-G.positionScreen.x)<0||(R.positionScreen.x-P.positionScreen.x)*(S.positionScreen.y-P.positionScreen.y)-(R.positionScreen.y-P.positionScreen.y)*(S.positionScreen.x-P.positionScreen.x)<0)){h=i[c]=i[c]||new THREE.RenderableFace3;h.v1.positionWorld.copy(G.positionWorld);h.v2.positionWorld.copy(R.positionWorld);
|
||||
h.v3.positionWorld.copy(S.positionWorld);h.v1.positionScreen.copy(G.positionScreen);h.v2.positionScreen.copy(R.positionScreen);h.v3.positionScreen.copy(S.positionScreen);h.normalWorld.copy(A.normal);X.multiplyVector3(h.normalWorld);h.centroidWorld.copy(A.centroid);ba.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);t.multiplyVector3(h.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=L;h.faceMaterials=A.materials;h.overdraw=Q;if(O.geometry.uvs[q]){h.uvs[0]=O.geometry.uvs[q][0];
|
||||
h.v3.positionWorld.copy(S.positionWorld);h.v1.positionScreen.copy(G.positionScreen);h.v2.positionScreen.copy(R.positionScreen);h.v3.positionScreen.copy(S.positionScreen);h.normalWorld.copy(B.normal);X.multiplyVector3(h.normalWorld);h.centroidWorld.copy(B.centroid);ba.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);t.multiplyVector3(h.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=M;h.faceMaterials=B.materials;h.overdraw=Q;if(O.geometry.uvs[q]){h.uvs[0]=O.geometry.uvs[q][0];
|
||||
h.uvs[1]=O.geometry.uvs[q][1];h.uvs[2]=O.geometry.uvs[q][3]}p.push(h);c++;j=i[c]=i[c]||new THREE.RenderableFace3;j.v1.positionWorld.copy(R.positionWorld);j.v2.positionWorld.copy(P.positionWorld);j.v3.positionWorld.copy(S.positionWorld);j.v1.positionScreen.copy(R.positionScreen);j.v2.positionScreen.copy(P.positionScreen);j.v3.positionScreen.copy(S.positionScreen);j.normalWorld.copy(h.normalWorld);j.centroidWorld.copy(h.centroidWorld);j.centroidScreen.copy(h.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=
|
||||
L;j.faceMaterials=A.materials;j.overdraw=Q;if(O.geometry.uvs[q]){j.uvs[0]=O.geometry.uvs[q][1];j.uvs[1]=O.geometry.uvs[q][2];j.uvs[2]=O.geometry.uvs[q][3]}p.push(j);c++}}}}else if(O instanceof THREE.Line){H.multiply(t,ba);U=O.geometry.vertices;A=U[0];A.positionScreen.copy(A.position);H.multiplyVector4(A.positionScreen);q=1;for(N=U.length;q<N;q++){G=U[q];G.positionScreen.copy(G.position);H.multiplyVector4(G.positionScreen);R=U[q-1];f.copy(G.positionScreen);l.copy(R.positionScreen);if(b(f,l)){f.multiplyScalar(1/
|
||||
f.w);l.multiplyScalar(1/l.w);m=D[v]=D[v]||new THREE.RenderableLine;m.v1.positionScreen.copy(f);m.v2.positionScreen.copy(l);m.z=Math.max(f.z,l.z);m.materials=O.materials;p.push(m);v++}}}else if(O instanceof THREE.Particle){M.set(O.position.x,O.position.y,O.position.z,1);t.multiplyVector4(M);M.z/=M.w;if(M.z>0&&M.z<1){s=B[y]=B[y]||new THREE.RenderableParticle;s.x=M.x/M.w;s.y=M.y/M.w;s.z=M.z;s.rotation=O.rotation.z;s.scale.x=O.scale.x*Math.abs(s.x-(M.x+r.projectionMatrix.n11)/(M.w+r.projectionMatrix.n14));
|
||||
s.scale.y=O.scale.y*Math.abs(s.y-(M.y+r.projectionMatrix.n22)/(M.w+r.projectionMatrix.n24));s.materials=O.materials;p.push(s);y++}}}}I&&p.sort(a);return p};this.unprojectVector=function(n,r){var I=new THREE.Matrix4;I.multiply(THREE.Matrix4.makeInvert(r.matrix),THREE.Matrix4.makeInvert(r.projectionMatrix));I.multiplyVector3(n);return n}};
|
||||
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,g,h;this.domElement=document.createElement("div");this.setSize=function(j,c){d=j;e=c;g=d/2;h=e/2};this.render=function(j,c){var i,m,v,D,s,y,B,C;a=b.projectScene(j,c);i=0;for(m=a.length;i<m;i++){s=a[i];if(s instanceof THREE.RenderableParticle){B=s.x*g+g;C=s.y*h+h;v=0;for(D=s.material.length;v<D;v++){y=s.material[v];if(y instanceof THREE.ParticleDOMMaterial){y=y.domElement;y.style.left=B+"px";y.style.top=C+"px"}}}}}};
|
||||
THREE.CanvasRenderer=function(){function a(ja){if(s!=ja)m.globalAlpha=s=ja}function b(ja){if(y!=ja){switch(ja){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}y=ja}}var d=null,e=new THREE.Projector,g=document.createElement("canvas"),h,j,c,i,m=g.getContext("2d"),v=null,D=null,s=1,y=0,B=null,C=null,M=1,t,H,k,f,l,u,n,r,I,p=new THREE.Color,
|
||||
w=new THREE.Color,z=new THREE.Color,x=new THREE.Color,q=new THREE.Color,N,G,R,T,O,ba,X,L,Q,Z=new THREE.Rectangle,U=new THREE.Rectangle,A=new THREE.Rectangle,P=false,S=new THREE.Color,fa=new THREE.Color,ea=new THREE.Color,o=new THREE.Color,F=Math.PI*2,E=new THREE.Vector3,V,$,da,ga,na,pa,va=16;V=document.createElement("canvas");V.width=V.height=2;$=V.getContext("2d");$.fillStyle="rgba(0,0,0,1)";$.fillRect(0,0,2,2);da=$.getImageData(0,0,2,2);ga=da.data;na=document.createElement("canvas");na.width=na.height=
|
||||
va;pa=na.getContext("2d");pa.translate(-va/2,-va/2);pa.scale(va,va);va--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ja,ta){h=ja;j=ta;c=h/2;i=j/2;g.width=h;g.height=j;Z.set(-c,-i,c,i)};this.setClearColor=function(ja,ta){v=ja!==null?new THREE.Color(ja):null;D=ta;U.set(-c,-i,c,i);m.setTransform(1,0,0,-1,c,i);this.clear()};this.clear=function(){if(!U.isEmpty()){U.inflate(1);U.minSelf(Z);if(v!==null){b(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(v.r*
|
||||
255)+","+Math.floor(v.g*255)+","+Math.floor(v.b*255)+","+D+")";m.fillRect(U.getX(),U.getY(),U.getWidth(),U.getHeight())}else m.clearRect(U.getX(),U.getY(),U.getWidth(),U.getHeight());U.empty()}};this.render=function(ja,ta){function Ma(J){var aa,Y,K,W=J.lights;fa.setRGB(0,0,0);ea.setRGB(0,0,0);o.setRGB(0,0,0);J=0;for(aa=W.length;J<aa;J++){Y=W[J];K=Y.color;if(Y instanceof THREE.AmbientLight){fa.r+=K.r;fa.g+=K.g;fa.b+=K.b}else if(Y instanceof THREE.DirectionalLight){ea.r+=K.r;ea.g+=K.g;ea.b+=K.b}else if(Y instanceof
|
||||
THREE.PointLight){o.r+=K.r;o.g+=K.g;o.b+=K.b}}}function Aa(J,aa,Y,K){var W,ca,ia,ka,la=J.lights;J=0;for(W=la.length;J<W;J++){ca=la[J];ia=ca.color;ka=ca.intensity;if(ca instanceof THREE.DirectionalLight){ca=Y.dot(ca.position)*ka;if(ca>0){K.r+=ia.r*ca;K.g+=ia.g*ca;K.b+=ia.b*ca}}else if(ca instanceof THREE.PointLight){E.sub(ca.position,aa);E.normalize();ca=Y.dot(E)*ka;if(ca>0){K.r+=ia.r*ca;K.g+=ia.g*ca;K.b+=ia.b*ca}}}}function Na(J,aa,Y){if(Y.opacity!=0){a(Y.opacity);b(Y.blending);var K,W,ca,ia,ka,la;
|
||||
if(Y instanceof THREE.ParticleBasicMaterial){if(Y.map){ia=Y.map;ka=ia.width>>1;la=ia.height>>1;W=aa.scale.x*c;ca=aa.scale.y*i;Y=W*ka;K=ca*la;A.set(J.x-Y,J.y-K,J.x+Y,J.y+K);if(Z.instersects(A)){m.save();m.translate(J.x,J.y);m.rotate(-aa.rotation);m.scale(W,-ca);m.translate(-ka,-la);m.drawImage(ia,0,0);m.restore()}}}else if(Y instanceof THREE.ParticleCircleMaterial){if(P){S.r=fa.r+ea.r+o.r;S.g=fa.g+ea.g+o.g;S.b=fa.b+ea.b+o.b;p.r=Y.color.r*S.r;p.g=Y.color.g*S.g;p.b=Y.color.b*S.b;p.updateStyleString()}else p.__styleString=
|
||||
Y.color.__styleString;Y=aa.scale.x*c;K=aa.scale.y*i;A.set(J.x-Y,J.y-K,J.x+Y,J.y+K);if(Z.instersects(A)){W=p.__styleString;if(C!=W)m.fillStyle=C=W;m.save();m.translate(J.x,J.y);m.rotate(-aa.rotation);m.scale(Y,K);m.beginPath();m.arc(0,0,1,0,F,true);m.closePath();m.fill();m.restore()}}}}function Oa(J,aa,Y,K){if(K.opacity!=0){a(K.opacity);b(K.blending);m.beginPath();m.moveTo(J.positionScreen.x,J.positionScreen.y);m.lineTo(aa.positionScreen.x,aa.positionScreen.y);m.closePath();if(K instanceof THREE.LineBasicMaterial){p.__styleString=
|
||||
K.color.__styleString;J=K.linewidth;if(M!=J)m.lineWidth=M=J;J=p.__styleString;if(B!=J)m.strokeStyle=B=J;m.stroke();A.inflate(K.linewidth*2)}}}function Ia(J,aa,Y,K,W,ca){if(W.opacity!=0){a(W.opacity);b(W.blending);f=J.positionScreen.x;l=J.positionScreen.y;u=aa.positionScreen.x;n=aa.positionScreen.y;r=Y.positionScreen.x;I=Y.positionScreen.y;m.beginPath();m.moveTo(f,l);m.lineTo(u,n);m.lineTo(r,I);m.lineTo(f,l);m.closePath();if(W instanceof THREE.MeshBasicMaterial)if(W.map)W.map.image.loaded&&W.map.mapping instanceof
|
||||
THREE.UVMapping&&xa(f,l,u,n,r,I,W.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);else if(W.env_map){if(W.env_map.image.loaded)if(W.env_map.mapping instanceof THREE.SphericalReflectionMapping){J=ta.matrix;E.copy(K.vertexNormalsWorld[0]);T=(E.x*J.n11+E.y*J.n12+E.z*J.n13)*0.5+0.5;O=-(E.x*J.n21+E.y*J.n22+E.z*J.n23)*0.5+0.5;E.copy(K.vertexNormalsWorld[1]);ba=(E.x*J.n11+E.y*J.n12+E.z*J.n13)*0.5+0.5;X=-(E.x*J.n21+E.y*J.n22+E.z*J.n23)*0.5+0.5;E.copy(K.vertexNormalsWorld[2]);
|
||||
L=(E.x*J.n11+E.y*J.n12+E.z*J.n13)*0.5+0.5;Q=-(E.x*J.n21+E.y*J.n22+E.z*J.n23)*0.5+0.5;xa(f,l,u,n,r,I,W.env_map.image,T,O,ba,X,L,Q)}}else W.wireframe?Ba(W.color.__styleString,W.wireframe_linewidth):Ca(W.color.__styleString);else if(W instanceof THREE.MeshLambertMaterial){if(W.map&&!W.wireframe){W.map.mapping instanceof THREE.UVMapping&&xa(f,l,u,n,r,I,W.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);b(THREE.SubtractiveBlending)}if(P)if(!W.wireframe&&W.shading==THREE.SmoothShading&&
|
||||
K.vertexNormalsWorld.length==3){w.r=z.r=x.r=fa.r;w.g=z.g=x.g=fa.g;w.b=z.b=x.b=fa.b;Aa(ca,K.v1.positionWorld,K.vertexNormalsWorld[0],w);Aa(ca,K.v2.positionWorld,K.vertexNormalsWorld[1],z);Aa(ca,K.v3.positionWorld,K.vertexNormalsWorld[2],x);q.r=(z.r+x.r)*0.5;q.g=(z.g+x.g)*0.5;q.b=(z.b+x.b)*0.5;R=Ja(w,z,x,q);xa(f,l,u,n,r,I,R,0,0,1,0,0,1)}else{S.r=fa.r;S.g=fa.g;S.b=fa.b;Aa(ca,K.centroidWorld,K.normalWorld,S);p.r=W.color.r*S.r;p.g=W.color.g*S.g;p.b=W.color.b*S.b;p.updateStyleString();W.wireframe?Ba(p.__styleString,
|
||||
W.wireframe_linewidth):Ca(p.__styleString)}else W.wireframe?Ba(W.color.__styleString,W.wireframe_linewidth):Ca(W.color.__styleString)}else if(W instanceof THREE.MeshDepthMaterial){N=ta.near;G=ta.far;w.r=w.g=w.b=1-Ea(J.positionScreen.z,N,G);z.r=z.g=z.b=1-Ea(aa.positionScreen.z,N,G);x.r=x.g=x.b=1-Ea(Y.positionScreen.z,N,G);q.r=(z.r+x.r)*0.5;q.g=(z.g+x.g)*0.5;q.b=(z.b+x.b)*0.5;R=Ja(w,z,x,q);xa(f,l,u,n,r,I,R,0,0,1,0,0,1)}else if(W instanceof THREE.MeshNormalMaterial){p.r=Fa(K.normalWorld.x);p.g=Fa(K.normalWorld.y);
|
||||
p.b=Fa(K.normalWorld.z);p.updateStyleString();W.wireframe?Ba(p.__styleString,W.wireframe_linewidth):Ca(p.__styleString)}}}function Ba(J,aa){if(B!=J)m.strokeStyle=B=J;if(M!=aa)m.lineWidth=M=aa;m.stroke();A.inflate(aa*2)}function Ca(J){if(C!=J)m.fillStyle=C=J;m.fill()}function xa(J,aa,Y,K,W,ca,ia,ka,la,qa,ma,ra,ya){var ua,sa;ua=ia.width-1;sa=ia.height-1;ka*=ua;la*=sa;qa*=ua;ma*=sa;ra*=ua;ya*=sa;Y-=J;K-=aa;W-=J;ca-=aa;qa-=ka;ma-=la;ra-=ka;ya-=la;sa=1/(qa*ya-ra*ma);ua=(ya*Y-ma*W)*sa;ma=(ya*K-ma*ca)*sa;
|
||||
Y=(qa*W-ra*Y)*sa;K=(qa*ca-ra*K)*sa;J=J-ua*ka-Y*la;aa=aa-ma*ka-K*la;m.save();m.transform(ua,ma,Y,K,J,aa);m.clip();m.drawImage(ia,0,0);m.restore()}function Ja(J,aa,Y,K){var W=~~(J.r*255),ca=~~(J.g*255);J=~~(J.b*255);var ia=~~(aa.r*255),ka=~~(aa.g*255);aa=~~(aa.b*255);var la=~~(Y.r*255),qa=~~(Y.g*255);Y=~~(Y.b*255);var ma=~~(K.r*255),ra=~~(K.g*255);K=~~(K.b*255);ga[0]=W<0?0:W>255?255:W;ga[1]=ca<0?0:ca>255?255:ca;ga[2]=J<0?0:J>255?255:J;ga[4]=ia<0?0:ia>255?255:ia;ga[5]=ka<0?0:ka>255?255:ka;ga[6]=aa<0?
|
||||
0:aa>255?255:aa;ga[8]=la<0?0:la>255?255:la;ga[9]=qa<0?0:qa>255?255:qa;ga[10]=Y<0?0:Y>255?255:Y;ga[12]=ma<0?0:ma>255?255:ma;ga[13]=ra<0?0:ra>255?255:ra;ga[14]=K<0?0:K>255?255:K;$.putImageData(da,0,0);pa.drawImage(V,0,0);return na}function Ea(J,aa,Y){J=(J-aa)/(Y-aa);return J*J*(3-2*J)}function Fa(J){J=(J+1)*0.5;return J<0?0:J>1?1:J}function Ga(J,aa){var Y=aa.x-J.x,K=aa.y-J.y,W=1/Math.sqrt(Y*Y+K*K);Y*=W;K*=W;aa.x+=Y;aa.y+=K;J.x-=Y;J.y-=K}var Da,Ka,ha,oa,wa,Ha,La,za;m.setTransform(1,0,0,-1,c,i);this.autoClear&&
|
||||
this.clear();d=e.projectScene(ja,ta,this.sortElements);(P=ja.lights.length>0)&&Ma(ja);Da=0;for(Ka=d.length;Da<Ka;Da++){ha=d[Da];A.empty();if(ha instanceof THREE.RenderableParticle){t=ha;t.x*=c;t.y*=i;oa=0;for(wa=ha.materials.length;oa<wa;oa++)Na(t,ha,ha.materials[oa],ja)}else if(ha instanceof THREE.RenderableLine){t=ha.v1;H=ha.v2;t.positionScreen.x*=c;t.positionScreen.y*=i;H.positionScreen.x*=c;H.positionScreen.y*=i;A.addPoint(t.positionScreen.x,t.positionScreen.y);A.addPoint(H.positionScreen.x,H.positionScreen.y);
|
||||
if(Z.instersects(A)){oa=0;for(wa=ha.materials.length;oa<wa;)Oa(t,H,ha,ha.materials[oa++],ja)}}else if(ha instanceof THREE.RenderableFace3){t=ha.v1;H=ha.v2;k=ha.v3;t.positionScreen.x*=c;t.positionScreen.y*=i;H.positionScreen.x*=c;H.positionScreen.y*=i;k.positionScreen.x*=c;k.positionScreen.y*=i;if(ha.overdraw){Ga(t.positionScreen,H.positionScreen);Ga(H.positionScreen,k.positionScreen);Ga(k.positionScreen,t.positionScreen)}A.add3Points(t.positionScreen.x,t.positionScreen.y,H.positionScreen.x,H.positionScreen.y,
|
||||
k.positionScreen.x,k.positionScreen.y);if(Z.instersects(A)){oa=0;for(wa=ha.meshMaterials.length;oa<wa;){za=ha.meshMaterials[oa++];if(za instanceof THREE.MeshFaceMaterial){Ha=0;for(La=ha.faceMaterials.length;Ha<La;)(za=ha.faceMaterials[Ha++])&&Ia(t,H,k,ha,za,ja)}else Ia(t,H,k,ha,za,ja)}}}U.addRectangle(A)}m.setTransform(1,0,0,1,0,0)}};
|
||||
THREE.SVGRenderer=function(){function a(T,O,ba){var X,L,Q,Z;X=0;for(L=T.lights.length;X<L;X++){Q=T.lights[X];if(Q instanceof THREE.DirectionalLight){Z=O.normalWorld.dot(Q.position)*Q.intensity;if(Z>0){ba.r+=Q.color.r*Z;ba.g+=Q.color.g*Z;ba.b+=Q.color.b*Z}}else if(Q instanceof THREE.PointLight){I.sub(Q.position,O.centroidWorld);I.normalize();Z=O.normalWorld.dot(I)*Q.intensity;if(Z>0){ba.r+=Q.color.r*Z;ba.g+=Q.color.g*Z;ba.b+=Q.color.b*Z}}}}function b(T,O,ba,X,L,Q){x=e(q++);x.setAttribute("d","M "+
|
||||
T.positionScreen.x+" "+T.positionScreen.y+" L "+O.positionScreen.x+" "+O.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+"z");if(L instanceof THREE.MeshBasicMaterial)k.__styleString=L.color.__styleString;else if(L instanceof THREE.MeshLambertMaterial)if(H){f.r=l.r;f.g=l.g;f.b=l.b;a(Q,X,f);k.r=L.color.r*f.r;k.g=L.color.g*f.g;k.b=L.color.b*f.b;k.updateStyleString()}else k.__styleString=L.color.__styleString;else if(L instanceof THREE.MeshDepthMaterial){r=1-L.__2near/(L.__farPlusNear-
|
||||
X.z*L.__farMinusNear);k.setRGB(r,r,r)}else L instanceof THREE.MeshNormalMaterial&&k.setRGB(g(X.normalWorld.x),g(X.normalWorld.y),g(X.normalWorld.z));L.wireframe?x.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+L.wireframe_linewidth+"; stroke-opacity: "+L.opacity+"; stroke-linecap: "+L.wireframe_linecap+"; stroke-linejoin: "+L.wireframe_linejoin):x.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+L.opacity);c.appendChild(x)}function d(T,O,ba,X,L,Q,Z){x=
|
||||
e(q++);x.setAttribute("d","M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+O.positionScreen.x+" "+O.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(Q instanceof THREE.MeshBasicMaterial)k.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshLambertMaterial)if(H){f.r=l.r;f.g=l.g;f.b=l.b;a(Z,L,f);k.r=Q.color.r*f.r;k.g=Q.color.g*f.g;k.b=Q.color.b*f.b;k.updateStyleString()}else k.__styleString=Q.color.__styleString;
|
||||
else if(Q instanceof THREE.MeshDepthMaterial){r=1-Q.__2near/(Q.__farPlusNear-L.z*Q.__farMinusNear);k.setRGB(r,r,r)}else Q instanceof THREE.MeshNormalMaterial&&k.setRGB(g(L.normalWorld.x),g(L.normalWorld.y),g(L.normalWorld.z));Q.wireframe?x.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+Q.wireframe_linewidth+"; stroke-opacity: "+Q.opacity+"; stroke-linecap: "+Q.wireframe_linecap+"; stroke-linejoin: "+Q.wireframe_linejoin):x.setAttribute("style","fill: "+k.__styleString+
|
||||
"; fill-opacity: "+Q.opacity);c.appendChild(x)}function e(T){if(p[T]==null){p[T]=document.createElementNS("http://www.w3.org/2000/svg","path");R==0&&p[T].setAttribute("shape-rendering","crispEdges");return p[T]}return p[T]}function g(T){return T<0?Math.min((1+T)*0.5,0.5):0.5+Math.min(T*0.5,0.5)}var h=null,j=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),i,m,v,D,s,y,B,C,M=new THREE.Rectangle,t=new THREE.Rectangle,H=false,k=new THREE.Color(16777215),f=new THREE.Color(16777215),
|
||||
l=new THREE.Color(0),u=new THREE.Color(0),n=new THREE.Color(0),r,I=new THREE.Vector3,p=[],w=[],z=[],x,q,N,G,R=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(T){switch(T){case "high":R=1;break;case "low":R=0}};this.setSize=function(T,O){i=T;m=O;v=i/2;D=m/2;c.setAttribute("viewBox",-v+" "+-D+" "+i+" "+m);c.setAttribute("width",i);c.setAttribute("height",m);M.set(-v,-D,v,D)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};
|
||||
this.render=function(T,O){var ba,X,L,Q,Z,U,A,P;this.autoClear&&this.clear();h=j.projectScene(T,O,this.sortElements);G=N=q=0;if(H=T.lights.length>0){A=T.lights;l.setRGB(0,0,0);u.setRGB(0,0,0);n.setRGB(0,0,0);ba=0;for(X=A.length;ba<X;ba++){L=A[ba];Q=L.color;if(L instanceof THREE.AmbientLight){l.r+=Q.r;l.g+=Q.g;l.b+=Q.b}else if(L instanceof THREE.DirectionalLight){u.r+=Q.r;u.g+=Q.g;u.b+=Q.b}else if(L instanceof THREE.PointLight){n.r+=Q.r;n.g+=Q.g;n.b+=Q.b}}}ba=0;for(X=h.length;ba<X;ba++){A=h[ba];t.empty();
|
||||
if(A instanceof THREE.RenderableParticle){s=A;s.x*=v;s.y*=-D;L=0;for(Q=A.materials.length;L<Q;L++)if(P=A.materials[L]){Z=s;U=A;P=P;var S=N++;if(w[S]==null){w[S]=document.createElementNS("http://www.w3.org/2000/svg","circle");R==0&&w[S].setAttribute("shape-rendering","crispEdges")}x=w[S];x.setAttribute("cx",Z.x);x.setAttribute("cy",Z.y);x.setAttribute("r",U.scale.x*v);if(P instanceof THREE.ParticleCircleMaterial){if(H){f.r=l.r+u.r+n.r;f.g=l.g+u.g+n.g;f.b=l.b+u.b+n.b;k.r=P.color.r*f.r;k.g=P.color.g*
|
||||
f.g;k.b=P.color.b*f.b;k.updateStyleString()}else k=P.color;x.setAttribute("style","fill: "+k.__styleString)}c.appendChild(x)}}else if(A instanceof THREE.RenderableLine){s=A.v1;y=A.v2;s.positionScreen.x*=v;s.positionScreen.y*=-D;y.positionScreen.x*=v;y.positionScreen.y*=-D;t.addPoint(s.positionScreen.x,s.positionScreen.y);t.addPoint(y.positionScreen.x,y.positionScreen.y);if(M.instersects(t)){L=0;for(Q=A.materials.length;L<Q;)if(P=A.materials[L++]){Z=s;U=y;P=P;S=G++;if(z[S]==null){z[S]=document.createElementNS("http://www.w3.org/2000/svg",
|
||||
"line");R==0&&z[S].setAttribute("shape-rendering","crispEdges")}x=z[S];x.setAttribute("x1",Z.positionScreen.x);x.setAttribute("y1",Z.positionScreen.y);x.setAttribute("x2",U.positionScreen.x);x.setAttribute("y2",U.positionScreen.y);if(P instanceof THREE.LineBasicMaterial){k.__styleString=P.color.__styleString;x.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+P.linewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.linecap+"; stroke-linejoin: "+P.linejoin);c.appendChild(x)}}}}else if(A instanceof
|
||||
THREE.RenderableFace3){s=A.v1;y=A.v2;B=A.v3;s.positionScreen.x*=v;s.positionScreen.y*=-D;y.positionScreen.x*=v;y.positionScreen.y*=-D;B.positionScreen.x*=v;B.positionScreen.y*=-D;t.addPoint(s.positionScreen.x,s.positionScreen.y);t.addPoint(y.positionScreen.x,y.positionScreen.y);t.addPoint(B.positionScreen.x,B.positionScreen.y);if(M.instersects(t)){L=0;for(Q=A.meshMaterials.length;L<Q;){P=A.meshMaterials[L++];if(P instanceof THREE.MeshFaceMaterial){Z=0;for(U=A.faceMaterials.length;Z<U;)(P=A.faceMaterials[Z++])&&
|
||||
b(s,y,B,A,P,T)}else P&&b(s,y,B,A,P,T)}}}else if(A instanceof THREE.RenderableFace4){s=A.v1;y=A.v2;B=A.v3;C=A.v4;s.positionScreen.x*=v;s.positionScreen.y*=-D;y.positionScreen.x*=v;y.positionScreen.y*=-D;B.positionScreen.x*=v;B.positionScreen.y*=-D;C.positionScreen.x*=v;C.positionScreen.y*=-D;t.addPoint(s.positionScreen.x,s.positionScreen.y);t.addPoint(y.positionScreen.x,y.positionScreen.y);t.addPoint(B.positionScreen.x,B.positionScreen.y);t.addPoint(C.positionScreen.x,C.positionScreen.y);if(M.instersects(t)){L=
|
||||
0;for(Q=A.meshMaterials.length;L<Q;){P=A.meshMaterials[L++];if(P instanceof THREE.MeshFaceMaterial){Z=0;for(U=A.faceMaterials.length;Z<U;)(P=A.faceMaterials[Z++])&&d(s,y,B,C,A,P,T)}else P&&d(s,y,B,C,A,P,T)}}}}}};
|
||||
M;j.faceMaterials=B.materials;j.overdraw=Q;if(O.geometry.uvs[q]){j.uvs[0]=O.geometry.uvs[q][1];j.uvs[1]=O.geometry.uvs[q][2];j.uvs[2]=O.geometry.uvs[q][3]}p.push(j);c++}}}}else if(O instanceof THREE.Line){H.multiply(t,ba);U=O.geometry.vertices;B=U[0];B.positionScreen.copy(B.position);H.multiplyVector4(B.positionScreen);q=1;for(N=U.length;q<N;q++){G=U[q];G.positionScreen.copy(G.position);H.multiplyVector4(G.positionScreen);R=U[q-1];f.copy(G.positionScreen);l.copy(R.positionScreen);if(b(f,l)){f.multiplyScalar(1/
|
||||
f.w);l.multiplyScalar(1/l.w);m=D[v]=D[v]||new THREE.RenderableLine;m.v1.positionScreen.copy(f);m.v2.positionScreen.copy(l);m.z=Math.max(f.z,l.z);m.materials=O.materials;p.push(m);v++}}}else if(O instanceof THREE.Particle){L.set(O.position.x,O.position.y,O.position.z,1);t.multiplyVector4(L);L.z/=L.w;if(L.z>0&&L.z<1){r=A[y]=A[y]||new THREE.RenderableParticle;r.x=L.x/L.w;r.y=L.y/L.w;r.z=L.z;r.rotation=O.rotation.z;r.scale.x=O.scale.x*Math.abs(r.x-(L.x+s.projectionMatrix.n11)/(L.w+s.projectionMatrix.n14));
|
||||
r.scale.y=O.scale.y*Math.abs(r.y-(L.y+s.projectionMatrix.n22)/(L.w+s.projectionMatrix.n24));r.materials=O.materials;p.push(r);y++}}}}I&&p.sort(a);return p};this.unprojectVector=function(n,s){var I=new THREE.Matrix4;I.multiply(THREE.Matrix4.makeInvert(s.matrix),THREE.Matrix4.makeInvert(s.projectionMatrix));I.multiplyVector3(n);return n}};
|
||||
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,g,h;this.domElement=document.createElement("div");this.setSize=function(j,c){d=j;e=c;g=d/2;h=e/2};this.render=function(j,c){var i,m,v,D,r,y,A,C;a=b.projectScene(j,c);i=0;for(m=a.length;i<m;i++){r=a[i];if(r instanceof THREE.RenderableParticle){A=r.x*g+g;C=r.y*h+h;v=0;for(D=r.material.length;v<D;v++){y=r.material[v];if(y instanceof THREE.ParticleDOMMaterial){y=y.domElement;y.style.left=A+"px";y.style.top=C+"px"}}}}}};
|
||||
THREE.CanvasRenderer=function(){function a(ja){if(r!=ja)m.globalAlpha=r=ja}function b(ja){if(y!=ja){switch(ja){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}y=ja}}var d=null,e=new THREE.Projector,g=document.createElement("canvas"),h,j,c,i,m=g.getContext("2d"),v=null,D=null,r=1,y=0,A=null,C=null,L=1,t,H,k,f,l,u,n,s,I,p=new THREE.Color,
|
||||
w=new THREE.Color,z=new THREE.Color,x=new THREE.Color,q=new THREE.Color,N,G,R,T,O,ba,X,M,Q,Z=new THREE.Rectangle,U=new THREE.Rectangle,B=new THREE.Rectangle,P=false,S=new THREE.Color,fa=new THREE.Color,ea=new THREE.Color,o=new THREE.Color,F=Math.PI*2,E=new THREE.Vector3,V,$,da,ga,na,pa,va=16;V=document.createElement("canvas");V.width=V.height=2;$=V.getContext("2d");$.fillStyle="rgba(0,0,0,1)";$.fillRect(0,0,2,2);da=$.getImageData(0,0,2,2);ga=da.data;na=document.createElement("canvas");na.width=na.height=
|
||||
va;pa=na.getContext("2d");pa.translate(-va/2,-va/2);pa.scale(va,va);va--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ja,ta){h=ja;j=ta;c=h/2;i=j/2;g.width=h;g.height=j;Z.set(-c,-i,c,i);r=1;y=0;C=A=null;L=1};this.setClearColor=function(ja,ta){v=ja!==null?new THREE.Color(ja):null;D=ta;U.set(-c,-i,c,i);m.setTransform(1,0,0,-1,c,i);this.clear()};this.clear=function(){if(!U.isEmpty()){U.inflate(1);U.minSelf(Z);if(v!==null){b(THREE.NormalBlending);a(1);
|
||||
m.fillStyle="rgba("+Math.floor(v.r*255)+","+Math.floor(v.g*255)+","+Math.floor(v.b*255)+","+D+")";m.fillRect(U.getX(),U.getY(),U.getWidth(),U.getHeight())}else m.clearRect(U.getX(),U.getY(),U.getWidth(),U.getHeight());U.empty()}};this.render=function(ja,ta){function Ma(J){var aa,Y,K,W=J.lights;fa.setRGB(0,0,0);ea.setRGB(0,0,0);o.setRGB(0,0,0);J=0;for(aa=W.length;J<aa;J++){Y=W[J];K=Y.color;if(Y instanceof THREE.AmbientLight){fa.r+=K.r;fa.g+=K.g;fa.b+=K.b}else if(Y instanceof THREE.DirectionalLight){ea.r+=
|
||||
K.r;ea.g+=K.g;ea.b+=K.b}else if(Y instanceof THREE.PointLight){o.r+=K.r;o.g+=K.g;o.b+=K.b}}}function Aa(J,aa,Y,K){var W,ca,ia,ka,la=J.lights;J=0;for(W=la.length;J<W;J++){ca=la[J];ia=ca.color;ka=ca.intensity;if(ca instanceof THREE.DirectionalLight){ca=Y.dot(ca.position)*ka;if(ca>0){K.r+=ia.r*ca;K.g+=ia.g*ca;K.b+=ia.b*ca}}else if(ca instanceof THREE.PointLight){E.sub(ca.position,aa);E.normalize();ca=Y.dot(E)*ka;if(ca>0){K.r+=ia.r*ca;K.g+=ia.g*ca;K.b+=ia.b*ca}}}}function Na(J,aa,Y){if(Y.opacity!=0){a(Y.opacity);
|
||||
b(Y.blending);var K,W,ca,ia,ka,la;if(Y instanceof THREE.ParticleBasicMaterial){if(Y.map){ia=Y.map;ka=ia.width>>1;la=ia.height>>1;W=aa.scale.x*c;ca=aa.scale.y*i;Y=W*ka;K=ca*la;B.set(J.x-Y,J.y-K,J.x+Y,J.y+K);if(Z.instersects(B)){m.save();m.translate(J.x,J.y);m.rotate(-aa.rotation);m.scale(W,-ca);m.translate(-ka,-la);m.drawImage(ia,0,0);m.restore()}}}else if(Y instanceof THREE.ParticleCircleMaterial){if(P){S.r=fa.r+ea.r+o.r;S.g=fa.g+ea.g+o.g;S.b=fa.b+ea.b+o.b;p.r=Y.color.r*S.r;p.g=Y.color.g*S.g;p.b=
|
||||
Y.color.b*S.b;p.updateStyleString()}else p.__styleString=Y.color.__styleString;Y=aa.scale.x*c;K=aa.scale.y*i;B.set(J.x-Y,J.y-K,J.x+Y,J.y+K);if(Z.instersects(B)){W=p.__styleString;if(C!=W)m.fillStyle=C=W;m.save();m.translate(J.x,J.y);m.rotate(-aa.rotation);m.scale(Y,K);m.beginPath();m.arc(0,0,1,0,F,true);m.closePath();m.fill();m.restore()}}}}function Oa(J,aa,Y,K){if(K.opacity!=0){a(K.opacity);b(K.blending);m.beginPath();m.moveTo(J.positionScreen.x,J.positionScreen.y);m.lineTo(aa.positionScreen.x,aa.positionScreen.y);
|
||||
m.closePath();if(K instanceof THREE.LineBasicMaterial){p.__styleString=K.color.__styleString;J=K.linewidth;if(L!=J)m.lineWidth=L=J;J=p.__styleString;if(A!=J)m.strokeStyle=A=J;m.stroke();B.inflate(K.linewidth*2)}}}function Ia(J,aa,Y,K,W,ca){if(W.opacity!=0){a(W.opacity);b(W.blending);f=J.positionScreen.x;l=J.positionScreen.y;u=aa.positionScreen.x;n=aa.positionScreen.y;s=Y.positionScreen.x;I=Y.positionScreen.y;m.beginPath();m.moveTo(f,l);m.lineTo(u,n);m.lineTo(s,I);m.lineTo(f,l);m.closePath();if(W instanceof
|
||||
THREE.MeshBasicMaterial)if(W.map)W.map.image.loaded&&W.map.mapping instanceof THREE.UVMapping&&xa(f,l,u,n,s,I,W.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);else if(W.env_map){if(W.env_map.image.loaded)if(W.env_map.mapping instanceof THREE.SphericalReflectionMapping){J=ta.matrix;E.copy(K.vertexNormalsWorld[0]);T=(E.x*J.n11+E.y*J.n12+E.z*J.n13)*0.5+0.5;O=-(E.x*J.n21+E.y*J.n22+E.z*J.n23)*0.5+0.5;E.copy(K.vertexNormalsWorld[1]);ba=(E.x*J.n11+E.y*J.n12+E.z*J.n13)*0.5+0.5;
|
||||
X=-(E.x*J.n21+E.y*J.n22+E.z*J.n23)*0.5+0.5;E.copy(K.vertexNormalsWorld[2]);M=(E.x*J.n11+E.y*J.n12+E.z*J.n13)*0.5+0.5;Q=-(E.x*J.n21+E.y*J.n22+E.z*J.n23)*0.5+0.5;xa(f,l,u,n,s,I,W.env_map.image,T,O,ba,X,M,Q)}}else W.wireframe?Ba(W.color.__styleString,W.wireframe_linewidth):Ca(W.color.__styleString);else if(W instanceof THREE.MeshLambertMaterial){if(W.map&&!W.wireframe){W.map.mapping instanceof THREE.UVMapping&&xa(f,l,u,n,s,I,W.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);
|
||||
b(THREE.SubtractiveBlending)}if(P)if(!W.wireframe&&W.shading==THREE.SmoothShading&&K.vertexNormalsWorld.length==3){w.r=z.r=x.r=fa.r;w.g=z.g=x.g=fa.g;w.b=z.b=x.b=fa.b;Aa(ca,K.v1.positionWorld,K.vertexNormalsWorld[0],w);Aa(ca,K.v2.positionWorld,K.vertexNormalsWorld[1],z);Aa(ca,K.v3.positionWorld,K.vertexNormalsWorld[2],x);q.r=(z.r+x.r)*0.5;q.g=(z.g+x.g)*0.5;q.b=(z.b+x.b)*0.5;R=Ja(w,z,x,q);xa(f,l,u,n,s,I,R,0,0,1,0,0,1)}else{S.r=fa.r;S.g=fa.g;S.b=fa.b;Aa(ca,K.centroidWorld,K.normalWorld,S);p.r=W.color.r*
|
||||
S.r;p.g=W.color.g*S.g;p.b=W.color.b*S.b;p.updateStyleString();W.wireframe?Ba(p.__styleString,W.wireframe_linewidth):Ca(p.__styleString)}else W.wireframe?Ba(W.color.__styleString,W.wireframe_linewidth):Ca(W.color.__styleString)}else if(W instanceof THREE.MeshDepthMaterial){N=ta.near;G=ta.far;w.r=w.g=w.b=1-Ea(J.positionScreen.z,N,G);z.r=z.g=z.b=1-Ea(aa.positionScreen.z,N,G);x.r=x.g=x.b=1-Ea(Y.positionScreen.z,N,G);q.r=(z.r+x.r)*0.5;q.g=(z.g+x.g)*0.5;q.b=(z.b+x.b)*0.5;R=Ja(w,z,x,q);xa(f,l,u,n,s,I,R,
|
||||
0,0,1,0,0,1)}else if(W instanceof THREE.MeshNormalMaterial){p.r=Fa(K.normalWorld.x);p.g=Fa(K.normalWorld.y);p.b=Fa(K.normalWorld.z);p.updateStyleString();W.wireframe?Ba(p.__styleString,W.wireframe_linewidth):Ca(p.__styleString)}}}function Ba(J,aa){if(A!=J)m.strokeStyle=A=J;if(L!=aa)m.lineWidth=L=aa;m.stroke();B.inflate(aa*2)}function Ca(J){if(C!=J)m.fillStyle=C=J;m.fill()}function xa(J,aa,Y,K,W,ca,ia,ka,la,qa,ma,ra,ya){var ua,sa;ua=ia.width-1;sa=ia.height-1;ka*=ua;la*=sa;qa*=ua;ma*=sa;ra*=ua;ya*=
|
||||
sa;Y-=J;K-=aa;W-=J;ca-=aa;qa-=ka;ma-=la;ra-=ka;ya-=la;sa=1/(qa*ya-ra*ma);ua=(ya*Y-ma*W)*sa;ma=(ya*K-ma*ca)*sa;Y=(qa*W-ra*Y)*sa;K=(qa*ca-ra*K)*sa;J=J-ua*ka-Y*la;aa=aa-ma*ka-K*la;m.save();m.transform(ua,ma,Y,K,J,aa);m.clip();m.drawImage(ia,0,0);m.restore()}function Ja(J,aa,Y,K){var W=~~(J.r*255),ca=~~(J.g*255);J=~~(J.b*255);var ia=~~(aa.r*255),ka=~~(aa.g*255);aa=~~(aa.b*255);var la=~~(Y.r*255),qa=~~(Y.g*255);Y=~~(Y.b*255);var ma=~~(K.r*255),ra=~~(K.g*255);K=~~(K.b*255);ga[0]=W<0?0:W>255?255:W;ga[1]=
|
||||
ca<0?0:ca>255?255:ca;ga[2]=J<0?0:J>255?255:J;ga[4]=ia<0?0:ia>255?255:ia;ga[5]=ka<0?0:ka>255?255:ka;ga[6]=aa<0?0:aa>255?255:aa;ga[8]=la<0?0:la>255?255:la;ga[9]=qa<0?0:qa>255?255:qa;ga[10]=Y<0?0:Y>255?255:Y;ga[12]=ma<0?0:ma>255?255:ma;ga[13]=ra<0?0:ra>255?255:ra;ga[14]=K<0?0:K>255?255:K;$.putImageData(da,0,0);pa.drawImage(V,0,0);return na}function Ea(J,aa,Y){J=(J-aa)/(Y-aa);return J*J*(3-2*J)}function Fa(J){J=(J+1)*0.5;return J<0?0:J>1?1:J}function Ga(J,aa){var Y=aa.x-J.x,K=aa.y-J.y,W=1/Math.sqrt(Y*
|
||||
Y+K*K);Y*=W;K*=W;aa.x+=Y;aa.y+=K;J.x-=Y;J.y-=K}var Da,Ka,ha,oa,wa,Ha,La,za;m.setTransform(1,0,0,-1,c,i);this.autoClear&&this.clear();d=e.projectScene(ja,ta,this.sortElements);(P=ja.lights.length>0)&&Ma(ja);Da=0;for(Ka=d.length;Da<Ka;Da++){ha=d[Da];B.empty();if(ha instanceof THREE.RenderableParticle){t=ha;t.x*=c;t.y*=i;oa=0;for(wa=ha.materials.length;oa<wa;oa++)Na(t,ha,ha.materials[oa],ja)}else if(ha instanceof THREE.RenderableLine){t=ha.v1;H=ha.v2;t.positionScreen.x*=c;t.positionScreen.y*=i;H.positionScreen.x*=
|
||||
c;H.positionScreen.y*=i;B.addPoint(t.positionScreen.x,t.positionScreen.y);B.addPoint(H.positionScreen.x,H.positionScreen.y);if(Z.instersects(B)){oa=0;for(wa=ha.materials.length;oa<wa;)Oa(t,H,ha,ha.materials[oa++],ja)}}else if(ha instanceof THREE.RenderableFace3){t=ha.v1;H=ha.v2;k=ha.v3;t.positionScreen.x*=c;t.positionScreen.y*=i;H.positionScreen.x*=c;H.positionScreen.y*=i;k.positionScreen.x*=c;k.positionScreen.y*=i;if(ha.overdraw){Ga(t.positionScreen,H.positionScreen);Ga(H.positionScreen,k.positionScreen);
|
||||
Ga(k.positionScreen,t.positionScreen)}B.add3Points(t.positionScreen.x,t.positionScreen.y,H.positionScreen.x,H.positionScreen.y,k.positionScreen.x,k.positionScreen.y);if(Z.instersects(B)){oa=0;for(wa=ha.meshMaterials.length;oa<wa;){za=ha.meshMaterials[oa++];if(za instanceof THREE.MeshFaceMaterial){Ha=0;for(La=ha.faceMaterials.length;Ha<La;)(za=ha.faceMaterials[Ha++])&&Ia(t,H,k,ha,za,ja)}else Ia(t,H,k,ha,za,ja)}}}U.addRectangle(B)}m.setTransform(1,0,0,1,0,0)}};
|
||||
THREE.SVGRenderer=function(){function a(T,O,ba){var X,M,Q,Z;X=0;for(M=T.lights.length;X<M;X++){Q=T.lights[X];if(Q instanceof THREE.DirectionalLight){Z=O.normalWorld.dot(Q.position)*Q.intensity;if(Z>0){ba.r+=Q.color.r*Z;ba.g+=Q.color.g*Z;ba.b+=Q.color.b*Z}}else if(Q instanceof THREE.PointLight){I.sub(Q.position,O.centroidWorld);I.normalize();Z=O.normalWorld.dot(I)*Q.intensity;if(Z>0){ba.r+=Q.color.r*Z;ba.g+=Q.color.g*Z;ba.b+=Q.color.b*Z}}}}function b(T,O,ba,X,M,Q){x=e(q++);x.setAttribute("d","M "+
|
||||
T.positionScreen.x+" "+T.positionScreen.y+" L "+O.positionScreen.x+" "+O.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)k.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(H){f.r=l.r;f.g=l.g;f.b=l.b;a(Q,X,f);k.r=M.color.r*f.r;k.g=M.color.g*f.g;k.b=M.color.b*f.b;k.updateStyleString()}else k.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){s=1-M.__2near/(M.__farPlusNear-
|
||||
X.z*M.__farMinusNear);k.setRGB(s,s,s)}else M instanceof THREE.MeshNormalMaterial&&k.setRGB(g(X.normalWorld.x),g(X.normalWorld.y),g(X.normalWorld.z));M.wireframe?x.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+M.wireframe_linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframe_linecap+"; stroke-linejoin: "+M.wireframe_linejoin):x.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+M.opacity);c.appendChild(x)}function d(T,O,ba,X,M,Q,Z){x=
|
||||
e(q++);x.setAttribute("d","M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+O.positionScreen.x+" "+O.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(Q instanceof THREE.MeshBasicMaterial)k.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshLambertMaterial)if(H){f.r=l.r;f.g=l.g;f.b=l.b;a(Z,M,f);k.r=Q.color.r*f.r;k.g=Q.color.g*f.g;k.b=Q.color.b*f.b;k.updateStyleString()}else k.__styleString=Q.color.__styleString;
|
||||
else if(Q instanceof THREE.MeshDepthMaterial){s=1-Q.__2near/(Q.__farPlusNear-M.z*Q.__farMinusNear);k.setRGB(s,s,s)}else Q instanceof THREE.MeshNormalMaterial&&k.setRGB(g(M.normalWorld.x),g(M.normalWorld.y),g(M.normalWorld.z));Q.wireframe?x.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+Q.wireframe_linewidth+"; stroke-opacity: "+Q.opacity+"; stroke-linecap: "+Q.wireframe_linecap+"; stroke-linejoin: "+Q.wireframe_linejoin):x.setAttribute("style","fill: "+k.__styleString+
|
||||
"; fill-opacity: "+Q.opacity);c.appendChild(x)}function e(T){if(p[T]==null){p[T]=document.createElementNS("http://www.w3.org/2000/svg","path");R==0&&p[T].setAttribute("shape-rendering","crispEdges");return p[T]}return p[T]}function g(T){return T<0?Math.min((1+T)*0.5,0.5):0.5+Math.min(T*0.5,0.5)}var h=null,j=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),i,m,v,D,r,y,A,C,L=new THREE.Rectangle,t=new THREE.Rectangle,H=false,k=new THREE.Color(16777215),f=new THREE.Color(16777215),
|
||||
l=new THREE.Color(0),u=new THREE.Color(0),n=new THREE.Color(0),s,I=new THREE.Vector3,p=[],w=[],z=[],x,q,N,G,R=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(T){switch(T){case "high":R=1;break;case "low":R=0}};this.setSize=function(T,O){i=T;m=O;v=i/2;D=m/2;c.setAttribute("viewBox",-v+" "+-D+" "+i+" "+m);c.setAttribute("width",i);c.setAttribute("height",m);L.set(-v,-D,v,D)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};
|
||||
this.render=function(T,O){var ba,X,M,Q,Z,U,B,P;this.autoClear&&this.clear();h=j.projectScene(T,O,this.sortElements);G=N=q=0;if(H=T.lights.length>0){B=T.lights;l.setRGB(0,0,0);u.setRGB(0,0,0);n.setRGB(0,0,0);ba=0;for(X=B.length;ba<X;ba++){M=B[ba];Q=M.color;if(M instanceof THREE.AmbientLight){l.r+=Q.r;l.g+=Q.g;l.b+=Q.b}else if(M instanceof THREE.DirectionalLight){u.r+=Q.r;u.g+=Q.g;u.b+=Q.b}else if(M instanceof THREE.PointLight){n.r+=Q.r;n.g+=Q.g;n.b+=Q.b}}}ba=0;for(X=h.length;ba<X;ba++){B=h[ba];t.empty();
|
||||
if(B instanceof THREE.RenderableParticle){r=B;r.x*=v;r.y*=-D;M=0;for(Q=B.materials.length;M<Q;M++)if(P=B.materials[M]){Z=r;U=B;P=P;var S=N++;if(w[S]==null){w[S]=document.createElementNS("http://www.w3.org/2000/svg","circle");R==0&&w[S].setAttribute("shape-rendering","crispEdges")}x=w[S];x.setAttribute("cx",Z.x);x.setAttribute("cy",Z.y);x.setAttribute("r",U.scale.x*v);if(P instanceof THREE.ParticleCircleMaterial){if(H){f.r=l.r+u.r+n.r;f.g=l.g+u.g+n.g;f.b=l.b+u.b+n.b;k.r=P.color.r*f.r;k.g=P.color.g*
|
||||
f.g;k.b=P.color.b*f.b;k.updateStyleString()}else k=P.color;x.setAttribute("style","fill: "+k.__styleString)}c.appendChild(x)}}else if(B instanceof THREE.RenderableLine){r=B.v1;y=B.v2;r.positionScreen.x*=v;r.positionScreen.y*=-D;y.positionScreen.x*=v;y.positionScreen.y*=-D;t.addPoint(r.positionScreen.x,r.positionScreen.y);t.addPoint(y.positionScreen.x,y.positionScreen.y);if(L.instersects(t)){M=0;for(Q=B.materials.length;M<Q;)if(P=B.materials[M++]){Z=r;U=y;P=P;S=G++;if(z[S]==null){z[S]=document.createElementNS("http://www.w3.org/2000/svg",
|
||||
"line");R==0&&z[S].setAttribute("shape-rendering","crispEdges")}x=z[S];x.setAttribute("x1",Z.positionScreen.x);x.setAttribute("y1",Z.positionScreen.y);x.setAttribute("x2",U.positionScreen.x);x.setAttribute("y2",U.positionScreen.y);if(P instanceof THREE.LineBasicMaterial){k.__styleString=P.color.__styleString;x.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+P.linewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.linecap+"; stroke-linejoin: "+P.linejoin);c.appendChild(x)}}}}else if(B instanceof
|
||||
THREE.RenderableFace3){r=B.v1;y=B.v2;A=B.v3;r.positionScreen.x*=v;r.positionScreen.y*=-D;y.positionScreen.x*=v;y.positionScreen.y*=-D;A.positionScreen.x*=v;A.positionScreen.y*=-D;t.addPoint(r.positionScreen.x,r.positionScreen.y);t.addPoint(y.positionScreen.x,y.positionScreen.y);t.addPoint(A.positionScreen.x,A.positionScreen.y);if(L.instersects(t)){M=0;for(Q=B.meshMaterials.length;M<Q;){P=B.meshMaterials[M++];if(P instanceof THREE.MeshFaceMaterial){Z=0;for(U=B.faceMaterials.length;Z<U;)(P=B.faceMaterials[Z++])&&
|
||||
b(r,y,A,B,P,T)}else P&&b(r,y,A,B,P,T)}}}else if(B instanceof THREE.RenderableFace4){r=B.v1;y=B.v2;A=B.v3;C=B.v4;r.positionScreen.x*=v;r.positionScreen.y*=-D;y.positionScreen.x*=v;y.positionScreen.y*=-D;A.positionScreen.x*=v;A.positionScreen.y*=-D;C.positionScreen.x*=v;C.positionScreen.y*=-D;t.addPoint(r.positionScreen.x,r.positionScreen.y);t.addPoint(y.positionScreen.x,y.positionScreen.y);t.addPoint(A.positionScreen.x,A.positionScreen.y);t.addPoint(C.positionScreen.x,C.positionScreen.y);if(L.instersects(t)){M=
|
||||
0;for(Q=B.meshMaterials.length;M<Q;){P=B.meshMaterials[M++];if(P instanceof THREE.MeshFaceMaterial){Z=0;for(U=B.faceMaterials.length;Z<U;)(P=B.faceMaterials[Z++])&&d(r,y,A,C,B,P,T)}else P&&d(r,y,A,C,B,P,T)}}}}}};
|
||||
THREE.WebGLRenderer=function(a){function b(f,l){f.fragment_shader=l.fragment_shader;f.vertex_shader=l.vertex_shader;f.uniforms=Uniforms.clone(l.uniforms)}function d(f,l){f.uniforms.color.value.setRGB(f.color.r*f.opacity,f.color.g*f.opacity,f.color.b*f.opacity);f.uniforms.opacity.value=f.opacity;f.uniforms.map.texture=f.map;f.uniforms.env_map.texture=f.env_map;f.uniforms.reflectivity.value=f.reflectivity;f.uniforms.refraction_ratio.value=f.refraction_ratio;f.uniforms.combine.value=f.combine;f.uniforms.useRefract.value=
|
||||
f.env_map&&f.env_map.mapping instanceof THREE.CubeRefractionMapping;if(l){f.uniforms.fogColor.value.setHex(l.color.hex);if(l instanceof THREE.Fog){f.uniforms.fogNear.value=l.near;f.uniforms.fogFar.value=l.far}else if(l instanceof THREE.FogExp2)f.uniforms.fogDensity.value=l.density}}function e(f,l){f.uniforms.color.value.setRGB(f.color.r*f.opacity,f.color.g*f.opacity,f.color.b*f.opacity);f.uniforms.opacity.value=f.opacity;if(l){f.uniforms.fogColor.value.setHex(l.color.hex);if(l instanceof THREE.Fog){f.uniforms.fogNear.value=
|
||||
l.near;f.uniforms.fogFar.value=l.far}else if(l instanceof THREE.FogExp2)f.uniforms.fogDensity.value=l.density}}function g(f,l){var u;if(f=="fragment")u=c.createShader(c.FRAGMENT_SHADER);else if(f=="vertex")u=c.createShader(c.VERTEX_SHADER);c.shaderSource(u,l);c.compileShader(u);if(!c.getShaderParameter(u,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(u));return null}return u}function h(f){switch(f){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;case THREE.ByteType:return c.BYTE;case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;
|
||||
case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var j=document.createElement("canvas"),c,i=null,m=null,v=new THREE.Matrix4,D,s=new Float32Array(16),y=new Float32Array(16),B=new Float32Array(16),C=new Float32Array(9),
|
||||
M=new Float32Array(16),t=true,H=new THREE.Color(0),k=0;if(a){if(a.antialias!==undefined)t=a.antialias;a.clearColor!==undefined&&H.setHex(a.clearColor);if(a.clearAlpha!==undefined)k=a.clearAlpha}this.domElement=j;this.autoClear=true;(function(f,l,u){try{c=j.getContext("experimental-webgl",{antialias:f})}catch(n){}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(l.r,l.g,l.b,u)})(t,H,k);this.context=c;this.setSize=function(f,l){j.width=f;j.height=l;c.viewport(0,0,j.width,j.height)};this.setClearColor=function(f,l){var u=new THREE.Color(f);c.clearColor(u.r,u.g,u.b,l)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(f,l){var u,n,r,I=0,p=0,w=0,z,x,q,N=[],G=[],R=[],T=[];u=0;for(n=l.length;u<n;u++){r=l[u];z=r.color;x=r.position;
|
||||
q=r.intensity;if(r instanceof THREE.AmbientLight){I+=z.r;p+=z.g;w+=z.b}else if(r instanceof THREE.DirectionalLight){N.push(z.r*q,z.g*q,z.b*q);G.push(x.x,x.y,x.z)}else if(r instanceof THREE.PointLight){R.push(z.r*q,z.g*q,z.b*q);T.push(x.x,x.y,x.z)}}return{ambient:[I,p,w],directional:{colors:N,positions:G},point:{colors:R,positions:T}}};this.createParticleBuffers=function(f){f.__webGLVertexBuffer=c.createBuffer();f.__webGLFaceBuffer=c.createBuffer()};this.createLineBuffers=function(f){f.__webGLVertexBuffer=
|
||||
case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var j=document.createElement("canvas"),c,i=null,m=null,v=new THREE.Matrix4,D,r=new Float32Array(16),y=new Float32Array(16),A=new Float32Array(16),C=new Float32Array(9),
|
||||
L=new Float32Array(16),t=true,H=new THREE.Color(0),k=0;if(a){if(a.antialias!==undefined)t=a.antialias;a.clearColor!==undefined&&H.setHex(a.clearColor);if(a.clearAlpha!==undefined)k=a.clearAlpha}this.domElement=j;this.autoClear=true;(function(f,l,u){try{c=j.getContext("experimental-webgl",{antialias:f})}catch(n){}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(l.r,l.g,l.b,u)})(t,H,k);this.context=c;this.setSize=function(f,l){j.width=f;j.height=l;c.viewport(0,0,j.width,j.height)};this.setClearColor=function(f,l){var u=new THREE.Color(f);c.clearColor(u.r,u.g,u.b,l)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(f,l){var u,n,s,I=0,p=0,w=0,z,x,q,N=[],G=[],R=[],T=[];u=0;for(n=l.length;u<n;u++){s=l[u];z=s.color;x=s.position;
|
||||
q=s.intensity;if(s instanceof THREE.AmbientLight){I+=z.r;p+=z.g;w+=z.b}else if(s instanceof THREE.DirectionalLight){N.push(z.r*q,z.g*q,z.b*q);G.push(x.x,x.y,x.z)}else if(s instanceof THREE.PointLight){R.push(z.r*q,z.g*q,z.b*q);T.push(x.x,x.y,x.z)}}return{ambient:[I,p,w],directional:{colors:N,positions:G},point:{colors:R,positions:T}}};this.createParticleBuffers=function(f){f.__webGLVertexBuffer=c.createBuffer();f.__webGLFaceBuffer=c.createBuffer()};this.createLineBuffers=function(f){f.__webGLVertexBuffer=
|
||||
c.createBuffer();f.__webGLLineBuffer=c.createBuffer()};this.createMeshBuffers=function(f){f.__webGLVertexBuffer=c.createBuffer();f.__webGLNormalBuffer=c.createBuffer();f.__webGLTangentBuffer=c.createBuffer();f.__webGLUVBuffer=c.createBuffer();f.__webGLFaceBuffer=c.createBuffer();f.__webGLLineBuffer=c.createBuffer()};this.initLineBuffers=function(f){var l=f.vertices.length;f.__vertexArray=new Float32Array(l*3);f.__lineArray=new Uint16Array(l);f.__webGLLineCount=l};this.initMeshBuffers=function(f,l){var u,
|
||||
n,r=0,I=0,p=0,w=l.geometry.faces,z=f.faces;u=0;for(n=z.length;u<n;u++){fi=z[u];face=w[fi];if(face instanceof THREE.Face3){r+=3;I+=1;p+=3}else if(face instanceof THREE.Face4){r+=4;I+=2;p+=5}}f.__vertexArray=new Float32Array(r*3);f.__normalArray=new Float32Array(r*3);f.__tangentArray=new Float32Array(r*4);f.__uvArray=new Float32Array(r*2);f.__faceArray=new Uint16Array(I*3);f.__lineArray=new Uint16Array(p*2);r=false;u=0;for(n=l.materials.length;u<n;u++){w=l.materials[u];if(w instanceof THREE.MeshFaceMaterial){w=
|
||||
0;for(z=f.materials.length;w<z;w++)if(f.materials[w]&&f.materials[w].shading!=undefined&&f.materials[w].shading==THREE.SmoothShading){r=true;break}}else if(w&&w.shading!=undefined&&w.shading==THREE.SmoothShading){r=true;break}if(r)break}f.__needsSmoothNormals=r;f.__webGLFaceCount=I*3;f.__webGLLineCount=p*2};this.setMeshBuffers=function(f,l,u,n,r,I,p,w){var z,x,q,N,G,R,T,O,ba,X=0,L=0,Q=0,Z=0,U=0,A=0,P=0,S=f.__vertexArray,fa=f.__uvArray,ea=f.__normalArray,o=f.__tangentArray,F=f.__faceArray,E=f.__lineArray,
|
||||
V=f.__needsSmoothNormals,$=l.geometry,da=$.vertices,ga=f.faces,na=$.faces,pa=$.uvs;l=0;for(z=ga.length;l<z;l++){x=ga[l];q=na[x];x=pa[x];N=q.vertexNormals;G=q.normal;if(q instanceof THREE.Face3){if(n){R=da[q.a].position;T=da[q.b].position;O=da[q.c].position;S[L]=R.x;S[L+1]=R.y;S[L+2]=R.z;S[L+3]=T.x;S[L+4]=T.y;S[L+5]=T.z;S[L+6]=O.x;S[L+7]=O.y;S[L+8]=O.z;L+=9}if(w&&$.hasTangents){R=da[q.a].tangent;T=da[q.b].tangent;O=da[q.c].tangent;o[A]=R.x;o[A+1]=R.y;o[A+2]=R.z;o[A+3]=R.w;o[A+4]=T.x;o[A+5]=T.y;o[A+
|
||||
6]=T.z;o[A+7]=T.w;o[A+8]=O.x;o[A+9]=O.y;o[A+10]=O.z;o[A+11]=O.w;A+=12}if(p)if(N.length==3&&V)for(q=0;q<3;q++){G=N[q];ea[U]=G.x;ea[U+1]=G.y;ea[U+2]=G.z;U+=3}else for(q=0;q<3;q++){ea[U]=G.x;ea[U+1]=G.y;ea[U+2]=G.z;U+=3}if(I&&x)for(q=0;q<3;q++){N=x[q];fa[Q]=N.u;fa[Q+1]=N.v;Q+=2}if(r){F[Z]=X;F[Z+1]=X+1;F[Z+2]=X+2;Z+=3;E[P]=X;E[P+1]=X+1;E[P+2]=X;E[P+3]=X+2;E[P+4]=X+1;E[P+5]=X+2;P+=6;X+=3}}else if(q instanceof THREE.Face4){if(n){R=da[q.a].position;T=da[q.b].position;O=da[q.c].position;ba=da[q.d].position;
|
||||
S[L]=R.x;S[L+1]=R.y;S[L+2]=R.z;S[L+3]=T.x;S[L+4]=T.y;S[L+5]=T.z;S[L+6]=O.x;S[L+7]=O.y;S[L+8]=O.z;S[L+9]=ba.x;S[L+10]=ba.y;S[L+11]=ba.z;L+=12}if(w&&$.hasTangents){R=da[q.a].tangent;T=da[q.b].tangent;O=da[q.c].tangent;q=da[q.d].tangent;o[A]=R.x;o[A+1]=R.y;o[A+2]=R.z;o[A+3]=R.w;o[A+4]=T.x;o[A+5]=T.y;o[A+6]=T.z;o[A+7]=T.w;o[A+8]=O.x;o[A+9]=O.y;o[A+10]=O.z;o[A+11]=O.w;o[A+12]=q.x;o[A+13]=q.y;o[A+14]=q.z;o[A+15]=q.w;A+=16}if(p)if(N.length==4&&V)for(q=0;q<4;q++){G=N[q];ea[U]=G.x;ea[U+1]=G.y;ea[U+2]=G.z;
|
||||
U+=3}else for(q=0;q<4;q++){ea[U]=G.x;ea[U+1]=G.y;ea[U+2]=G.z;U+=3}if(I&&x)for(q=0;q<4;q++){N=x[q];fa[Q]=N.u;fa[Q+1]=N.v;Q+=2}if(r){F[Z]=X;F[Z+1]=X+1;F[Z+2]=X+2;F[Z+3]=X;F[Z+4]=X+2;F[Z+5]=X+3;Z+=6;E[P]=X;E[P+1]=X+1;E[P+2]=X;E[P+3]=X+2;E[P+4]=X;E[P+5]=X+3;E[P+6]=X+1;E[P+7]=X+2;E[P+8]=X+2;E[P+9]=X+3;P+=10;X+=4}}}if(n){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,S,u)}if(p){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,ea,u)}if(w&&$.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,
|
||||
f.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,o,u)}if(I&&Q>0){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,fa,u)}if(r){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,f.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,F,u);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,E,u)}};this.setLineBuffers=function(f,l,u,n){var r,I,p=f.vertices,w=p.length,z=f.__vertexArray,x=f.__lineArray;if(u)for(u=0;u<w;u++){r=p[u].position;I=u*3;
|
||||
z[I]=r.x;z[I+1]=r.y;z[I+2]=r.z}if(n)for(u=0;u<w;u++)x[u]=u;c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,z,l);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,x,l)};this.setParticleBuffers=function(){};this.renderBuffer=function(f,l,u,n,r,I){var p,w,z,x;if(!n.program){if(n instanceof THREE.MeshDepthMaterial){b(n,THREE.ShaderLib.depth);n.uniforms.mNear.value=f.near;n.uniforms.mFar.value=f.far}else if(n instanceof THREE.MeshNormalMaterial)b(n,
|
||||
n,s=0,I=0,p=0,w=l.geometry.faces,z=f.faces;u=0;for(n=z.length;u<n;u++){fi=z[u];face=w[fi];if(face instanceof THREE.Face3){s+=3;I+=1;p+=3}else if(face instanceof THREE.Face4){s+=4;I+=2;p+=5}}f.__vertexArray=new Float32Array(s*3);f.__normalArray=new Float32Array(s*3);f.__tangentArray=new Float32Array(s*4);f.__uvArray=new Float32Array(s*2);f.__faceArray=new Uint16Array(I*3);f.__lineArray=new Uint16Array(p*2);s=false;u=0;for(n=l.materials.length;u<n;u++){w=l.materials[u];if(w instanceof THREE.MeshFaceMaterial){w=
|
||||
0;for(z=f.materials.length;w<z;w++)if(f.materials[w]&&f.materials[w].shading!=undefined&&f.materials[w].shading==THREE.SmoothShading){s=true;break}}else if(w&&w.shading!=undefined&&w.shading==THREE.SmoothShading){s=true;break}if(s)break}f.__needsSmoothNormals=s;f.__webGLFaceCount=I*3;f.__webGLLineCount=p*2};this.setMeshBuffers=function(f,l,u,n,s,I,p,w){var z,x,q,N,G,R,T,O,ba,X=0,M=0,Q=0,Z=0,U=0,B=0,P=0,S=f.__vertexArray,fa=f.__uvArray,ea=f.__normalArray,o=f.__tangentArray,F=f.__faceArray,E=f.__lineArray,
|
||||
V=f.__needsSmoothNormals,$=l.geometry,da=$.vertices,ga=f.faces,na=$.faces,pa=$.uvs;l=0;for(z=ga.length;l<z;l++){x=ga[l];q=na[x];x=pa[x];N=q.vertexNormals;G=q.normal;if(q instanceof THREE.Face3){if(n){R=da[q.a].position;T=da[q.b].position;O=da[q.c].position;S[M]=R.x;S[M+1]=R.y;S[M+2]=R.z;S[M+3]=T.x;S[M+4]=T.y;S[M+5]=T.z;S[M+6]=O.x;S[M+7]=O.y;S[M+8]=O.z;M+=9}if(w&&$.hasTangents){R=da[q.a].tangent;T=da[q.b].tangent;O=da[q.c].tangent;o[B]=R.x;o[B+1]=R.y;o[B+2]=R.z;o[B+3]=R.w;o[B+4]=T.x;o[B+5]=T.y;o[B+
|
||||
6]=T.z;o[B+7]=T.w;o[B+8]=O.x;o[B+9]=O.y;o[B+10]=O.z;o[B+11]=O.w;B+=12}if(p)if(N.length==3&&V)for(q=0;q<3;q++){G=N[q];ea[U]=G.x;ea[U+1]=G.y;ea[U+2]=G.z;U+=3}else for(q=0;q<3;q++){ea[U]=G.x;ea[U+1]=G.y;ea[U+2]=G.z;U+=3}if(I&&x)for(q=0;q<3;q++){N=x[q];fa[Q]=N.u;fa[Q+1]=N.v;Q+=2}if(s){F[Z]=X;F[Z+1]=X+1;F[Z+2]=X+2;Z+=3;E[P]=X;E[P+1]=X+1;E[P+2]=X;E[P+3]=X+2;E[P+4]=X+1;E[P+5]=X+2;P+=6;X+=3}}else if(q instanceof THREE.Face4){if(n){R=da[q.a].position;T=da[q.b].position;O=da[q.c].position;ba=da[q.d].position;
|
||||
S[M]=R.x;S[M+1]=R.y;S[M+2]=R.z;S[M+3]=T.x;S[M+4]=T.y;S[M+5]=T.z;S[M+6]=O.x;S[M+7]=O.y;S[M+8]=O.z;S[M+9]=ba.x;S[M+10]=ba.y;S[M+11]=ba.z;M+=12}if(w&&$.hasTangents){R=da[q.a].tangent;T=da[q.b].tangent;O=da[q.c].tangent;q=da[q.d].tangent;o[B]=R.x;o[B+1]=R.y;o[B+2]=R.z;o[B+3]=R.w;o[B+4]=T.x;o[B+5]=T.y;o[B+6]=T.z;o[B+7]=T.w;o[B+8]=O.x;o[B+9]=O.y;o[B+10]=O.z;o[B+11]=O.w;o[B+12]=q.x;o[B+13]=q.y;o[B+14]=q.z;o[B+15]=q.w;B+=16}if(p)if(N.length==4&&V)for(q=0;q<4;q++){G=N[q];ea[U]=G.x;ea[U+1]=G.y;ea[U+2]=G.z;
|
||||
U+=3}else for(q=0;q<4;q++){ea[U]=G.x;ea[U+1]=G.y;ea[U+2]=G.z;U+=3}if(I&&x)for(q=0;q<4;q++){N=x[q];fa[Q]=N.u;fa[Q+1]=N.v;Q+=2}if(s){F[Z]=X;F[Z+1]=X+1;F[Z+2]=X+2;F[Z+3]=X;F[Z+4]=X+2;F[Z+5]=X+3;Z+=6;E[P]=X;E[P+1]=X+1;E[P+2]=X;E[P+3]=X+2;E[P+4]=X;E[P+5]=X+3;E[P+6]=X+1;E[P+7]=X+2;E[P+8]=X+2;E[P+9]=X+3;P+=10;X+=4}}}if(n){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,S,u)}if(p){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,ea,u)}if(w&&$.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,
|
||||
f.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,o,u)}if(I&&Q>0){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,fa,u)}if(s){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,f.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,F,u);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,E,u)}};this.setLineBuffers=function(f,l,u,n){var s,I,p=f.vertices,w=p.length,z=f.__vertexArray,x=f.__lineArray;if(u)for(u=0;u<w;u++){s=p[u].position;I=u*3;
|
||||
z[I]=s.x;z[I+1]=s.y;z[I+2]=s.z}if(n)for(u=0;u<w;u++)x[u]=u;c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,z,l);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,x,l)};this.setParticleBuffers=function(){};this.renderBuffer=function(f,l,u,n,s,I){var p,w,z,x;if(!n.program){if(n instanceof THREE.MeshDepthMaterial){b(n,THREE.ShaderLib.depth);n.uniforms.mNear.value=f.near;n.uniforms.mFar.value=f.far}else if(n instanceof THREE.MeshNormalMaterial)b(n,
|
||||
THREE.ShaderLib.normal);else if(n instanceof THREE.MeshBasicMaterial){b(n,THREE.ShaderLib.basic);d(n,u)}else if(n instanceof THREE.MeshLambertMaterial){b(n,THREE.ShaderLib.lambert);d(n,u)}else if(n instanceof THREE.MeshPhongMaterial){b(n,THREE.ShaderLib.phong);d(n,u)}else if(n instanceof THREE.LineBasicMaterial){b(n,THREE.ShaderLib.basic);e(n,u)}var q,N,G;q=x=w=0;for(N=l.length;q<N;q++){G=l[q];G instanceof THREE.DirectionalLight&&x++;G instanceof THREE.PointLight&&w++}if(w+x<=4){q=x;w=w}else{q=Math.ceil(4*
|
||||
x/(w+x));w=4-q}w={directional:q,point:w};x={fog:u,map:n.map,env_map:n.env_map,maxDirLights:w.directional,maxPointLights:w.point};w=n.fragment_shader;q=n.vertex_shader;N=c.createProgram();G=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+x.maxDirLights,"#define MAX_POINT_LIGHTS "+x.maxPointLights,x.fog?"#define USE_FOG":"",x.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",x.map?"#define USE_MAP":"",x.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");
|
||||
x=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+x.maxDirLights,"#define MAX_POINT_LIGHTS "+x.maxPointLights,x.map?"#define USE_MAP":"",x.env_map?"#define USE_ENVMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(N,
|
||||
@@ -171,18 +171,18 @@ n.uniforms.directionalLightDirection.value=f.directional.positions;n.uniforms.po
|
||||
n.specular.b);n.uniforms.shininess.value=n.shininess}u=n.uniforms;for(z in u)if(q=p.uniforms[z]){l=u[z];w=l.type;f=l.value;if(w=="i")c.uniform1i(q,f);else if(w=="f")c.uniform1f(q,f);else if(w=="fv1")c.uniform1fv(q,f);else if(w=="fv")c.uniform3fv(q,f);else if(w=="v2")c.uniform2f(q,f.x,f.y);else if(w=="v3")c.uniform3f(q,f.x,f.y,f.z);else if(w=="c")c.uniform3f(q,f.r,f.g,f.b);else if(w=="t"){c.uniform1i(q,f);if(l=l.texture)if(l.image instanceof Array&&l.image.length==6){l=l;f=f;if(l.image.length==6){if(!l.image.__webGLTextureCube&&
|
||||
!l.image.__cubeMapInitialized&&l.image.loadCount==6){l.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,l.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(w=0;w<6;++w)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+
|
||||
w,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,l.image[w]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);l.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+f);c.bindTexture(c.TEXTURE_CUBE_MAP,l.image.__webGLTextureCube)}}else{l=l;f=f;if(!l.__webGLTexture&&l.image.loaded){l.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,l.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,l.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,h(l.wrap_s));
|
||||
c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,h(l.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(l.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,h(l.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+f);c.bindTexture(c.TEXTURE_2D,l.__webGLTexture)}}}z=p.attributes;c.bindBuffer(c.ARRAY_BUFFER,r.__webGLVertexBuffer);c.vertexAttribPointer(z.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(z.position);if(z.normal>=
|
||||
0){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLNormalBuffer);c.vertexAttribPointer(z.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(z.normal)}if(z.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLTangentBuffer);c.vertexAttribPointer(z.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(z.tangent)}if(z.uv>=0)if(r.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLUVBuffer);c.vertexAttribPointer(z.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(z.uv)}else c.disableVertexAttribArray(z.uv);if(n.wireframe||
|
||||
n instanceof THREE.LineBasicMaterial){z=n.wireframe_linewidth!==undefined?n.wireframe_linewidth:n.linewidth!==undefined?n.linewidth:1;n=n instanceof THREE.LineBasicMaterial&&I.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(z);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,r.__webGLLineBuffer);c.drawElements(n,r.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,r.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,r.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(f,
|
||||
l,u,n,r,I,p){var w,z,x,q,N;x=0;for(q=n.materials.length;x<q;x++){w=n.materials[x];if(w instanceof THREE.MeshFaceMaterial){w=0;for(z=r.materials.length;w<z;w++)if((N=r.materials[w])&&N.blending==I&&N.opacity<1==p){this.setBlending(N.blending);this.renderBuffer(f,l,u,N,r,n)}}else if((N=w)&&N.blending==I&&N.opacity<1==p){this.setBlending(N.blending);this.renderBuffer(f,l,u,N,r,n)}}};this.render=function(f,l,u,n){var r,I,p,w=f.lights,z=f.fog;this.initWebGLObjects(f);n=n!==undefined?n:true;if(u&&!u.__webGLFramebuffer){u.__webGLFramebuffer=
|
||||
c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,h(l.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(l.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,h(l.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+f);c.bindTexture(c.TEXTURE_2D,l.__webGLTexture)}}}z=p.attributes;c.bindBuffer(c.ARRAY_BUFFER,s.__webGLVertexBuffer);c.vertexAttribPointer(z.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(z.position);if(z.normal>=
|
||||
0){c.bindBuffer(c.ARRAY_BUFFER,s.__webGLNormalBuffer);c.vertexAttribPointer(z.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(z.normal)}if(z.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,s.__webGLTangentBuffer);c.vertexAttribPointer(z.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(z.tangent)}if(z.uv>=0)if(s.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,s.__webGLUVBuffer);c.vertexAttribPointer(z.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(z.uv)}else c.disableVertexAttribArray(z.uv);if(n.wireframe||
|
||||
n instanceof THREE.LineBasicMaterial){z=n.wireframe_linewidth!==undefined?n.wireframe_linewidth:n.linewidth!==undefined?n.linewidth:1;n=n instanceof THREE.LineBasicMaterial&&I.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(z);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,s.__webGLLineBuffer);c.drawElements(n,s.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,s.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,s.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(f,
|
||||
l,u,n,s,I,p){var w,z,x,q,N;x=0;for(q=n.materials.length;x<q;x++){w=n.materials[x];if(w instanceof THREE.MeshFaceMaterial){w=0;for(z=s.materials.length;w<z;w++)if((N=s.materials[w])&&N.blending==I&&N.opacity<1==p){this.setBlending(N.blending);this.renderBuffer(f,l,u,N,s,n)}}else if((N=w)&&N.blending==I&&N.opacity<1==p){this.setBlending(N.blending);this.renderBuffer(f,l,u,N,s,n)}}};this.render=function(f,l,u,n){var s,I,p,w=f.lights,z=f.fog;this.initWebGLObjects(f);n=n!==undefined?n:true;if(u&&!u.__webGLFramebuffer){u.__webGLFramebuffer=
|
||||
c.createFramebuffer();u.__webGLRenderbuffer=c.createRenderbuffer();u.__webGLTexture=c.createTexture();c.bindRenderbuffer(c.RENDERBUFFER,u.__webGLRenderbuffer);c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,u.width,u.height);c.bindTexture(c.TEXTURE_2D,u.__webGLTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,h(u.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,h(u.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(u.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
|
||||
h(u.min_filter));c.texImage2D(c.TEXTURE_2D,0,h(u.format),u.width,u.height,0,h(u.format),h(u.type),null);c.bindFramebuffer(c.FRAMEBUFFER,u.__webGLFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,u.__webGLTexture,0);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,u.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}if(u){r=u.__webGLFramebuffer;p=u.width;I=u.height}else{r=
|
||||
null;p=j.width;I=j.height}if(r!=m){c.bindFramebuffer(c.FRAMEBUFFER,r);c.viewport(0,0,p,I);n&&c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT);m=r}this.autoClear&&this.clear();l.autoUpdateMatrix&&l.updateMatrix();s.set(l.matrix.flatten());B.set(l.projectionMatrix.flatten());n=0;for(r=f.__webGLObjects.length;n<r;n++){I=f.__webGLObjects[n];p=I.object;I=I.buffer;if(p.visible){this.setupMatrices(p,l);this.renderPass(l,w,z,p,I,THREE.NormalBlending,false)}}n=0;for(r=f.__webGLObjects.length;n<r;n++){I=f.__webGLObjects[n];
|
||||
h(u.min_filter));c.texImage2D(c.TEXTURE_2D,0,h(u.format),u.width,u.height,0,h(u.format),h(u.type),null);c.bindFramebuffer(c.FRAMEBUFFER,u.__webGLFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,u.__webGLTexture,0);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,u.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}if(u){s=u.__webGLFramebuffer;p=u.width;I=u.height}else{s=
|
||||
null;p=j.width;I=j.height}if(s!=m){c.bindFramebuffer(c.FRAMEBUFFER,s);c.viewport(0,0,p,I);n&&c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT);m=s}this.autoClear&&this.clear();l.autoUpdateMatrix&&l.updateMatrix();r.set(l.matrix.flatten());A.set(l.projectionMatrix.flatten());n=0;for(s=f.__webGLObjects.length;n<s;n++){I=f.__webGLObjects[n];p=I.object;I=I.buffer;if(p.visible){this.setupMatrices(p,l);this.renderPass(l,w,z,p,I,THREE.NormalBlending,false)}}n=0;for(s=f.__webGLObjects.length;n<s;n++){I=f.__webGLObjects[n];
|
||||
p=I.object;I=I.buffer;if(p.visible){this.setupMatrices(p,l);this.renderPass(l,w,z,p,I,THREE.AdditiveBlending,false);this.renderPass(l,w,z,p,I,THREE.SubtractiveBlending,false);this.renderPass(l,w,z,p,I,THREE.AdditiveBlending,true);this.renderPass(l,w,z,p,I,THREE.SubtractiveBlending,true);this.renderPass(l,w,z,p,I,THREE.NormalBlending,true)}}if(u&&u.min_filter!==THREE.NearestFilter&&u.min_filter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,u.__webGLTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,
|
||||
null)}};this.initWebGLObjects=function(f){function l(x,q,N,G){if(x[q]==undefined){f.__webGLObjects.push({buffer:N,object:G});x[q]=1}}var u,n,r,I,p,w,z;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={}}u=0;for(n=f.objects.length;u<n;u++){r=f.objects[u];p=r.geometry;if(f.__webGLObjectsMap[r.id]==undefined)f.__webGLObjectsMap[r.id]={};z=f.__webGLObjectsMap[r.id];if(r instanceof THREE.Mesh){for(I in p.geometryChunks){w=p.geometryChunks[I];if(!w.__webGLVertexBuffer){this.createMeshBuffers(w);
|
||||
this.initMeshBuffers(w,r);p.__dirtyVertices=true;p.__dirtyElements=true;p.__dirtyUvs=true;p.__dirtyNormals=true;p.__dirtyTangents=true}if(p.__dirtyVertices||p.__dirtyElements||p.__dirtyUvs)this.setMeshBuffers(w,r,c.DYNAMIC_DRAW,p.__dirtyVertices,p.__dirtyElements,p.__dirtyUvs,p.__dirtyNormals,p.__dirtyTangents);l(z,I,w,r)}p.__dirtyVertices=false;p.__dirtyElements=false;p.__dirtyUvs=false;p.__dirtyNormals=false;p.__dirtyTangents=false}else if(r instanceof THREE.Line){if(!p.__webGLVertexBuffer){this.createLineBuffers(p);
|
||||
this.initLineBuffers(p);p.__dirtyVertices=true;p.__dirtyElements=true}p.__dirtyVertices&&this.setLineBuffers(p,c.DYNAMIC_DRAW,p.__dirtyVertices,p.__dirtyElements);l(z,0,p,r);p.__dirtyVertices=false;p.__dirtyElements=false}else if(r instanceof THREE.ParticleSystem){p.__webGLVertexBuffer||this.createParticleBuffers(p);l(z,0,p,r)}}};this.removeObject=function(f,l){var u,n;for(u=f.__webGLObjects.length-1;u>=0;u--){n=f.__webGLObjects[u].object;l==n&&f.__webGLObjects.splice(u,1)}};this.setupMatrices=function(f,
|
||||
l){f.autoUpdateMatrix&&f.updateMatrix();v.multiply(l.matrix,f.matrix);y.set(v.flatten());D=THREE.Matrix4.makeInvert3x3(v).transpose();C.set(D.m);M.set(f.matrix.flatten())};this.loadMatrices=function(f){c.uniformMatrix4fv(f.uniforms.viewMatrix,false,s);c.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,y);c.uniformMatrix4fv(f.uniforms.projectionMatrix,false,B);c.uniformMatrix3fv(f.uniforms.normalMatrix,false,C);c.uniformMatrix4fv(f.uniforms.objectMatrix,false,M)};this.loadCamera=function(f,l){c.uniform3f(f.uniforms.cameraPosition,
|
||||
null)}};this.initWebGLObjects=function(f){function l(x,q,N,G){if(x[q]==undefined){f.__webGLObjects.push({buffer:N,object:G});x[q]=1}}var u,n,s,I,p,w,z;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={}}u=0;for(n=f.objects.length;u<n;u++){s=f.objects[u];p=s.geometry;if(f.__webGLObjectsMap[s.id]==undefined)f.__webGLObjectsMap[s.id]={};z=f.__webGLObjectsMap[s.id];if(s instanceof THREE.Mesh){for(I in p.geometryChunks){w=p.geometryChunks[I];if(!w.__webGLVertexBuffer){this.createMeshBuffers(w);
|
||||
this.initMeshBuffers(w,s);p.__dirtyVertices=true;p.__dirtyElements=true;p.__dirtyUvs=true;p.__dirtyNormals=true;p.__dirtyTangents=true}if(p.__dirtyVertices||p.__dirtyElements||p.__dirtyUvs)this.setMeshBuffers(w,s,c.DYNAMIC_DRAW,p.__dirtyVertices,p.__dirtyElements,p.__dirtyUvs,p.__dirtyNormals,p.__dirtyTangents);l(z,I,w,s)}p.__dirtyVertices=false;p.__dirtyElements=false;p.__dirtyUvs=false;p.__dirtyNormals=false;p.__dirtyTangents=false}else if(s instanceof THREE.Line){if(!p.__webGLVertexBuffer){this.createLineBuffers(p);
|
||||
this.initLineBuffers(p);p.__dirtyVertices=true;p.__dirtyElements=true}p.__dirtyVertices&&this.setLineBuffers(p,c.DYNAMIC_DRAW,p.__dirtyVertices,p.__dirtyElements);l(z,0,p,s);p.__dirtyVertices=false;p.__dirtyElements=false}else if(s instanceof THREE.ParticleSystem){p.__webGLVertexBuffer||this.createParticleBuffers(p);l(z,0,p,s)}}};this.removeObject=function(f,l){var u,n;for(u=f.__webGLObjects.length-1;u>=0;u--){n=f.__webGLObjects[u].object;l==n&&f.__webGLObjects.splice(u,1)}};this.setupMatrices=function(f,
|
||||
l){f.autoUpdateMatrix&&f.updateMatrix();v.multiply(l.matrix,f.matrix);y.set(v.flatten());D=THREE.Matrix4.makeInvert3x3(v).transpose();C.set(D.m);L.set(f.matrix.flatten())};this.loadMatrices=function(f){c.uniformMatrix4fv(f.uniforms.viewMatrix,false,r);c.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,y);c.uniformMatrix4fv(f.uniforms.projectionMatrix,false,A);c.uniformMatrix3fv(f.uniforms.normalMatrix,false,C);c.uniformMatrix4fv(f.uniforms.objectMatrix,false,L)};this.loadCamera=function(f,l){c.uniform3f(f.uniforms.cameraPosition,
|
||||
l.position.x,l.position.y,l.position.z)};this.setBlending=function(f){switch(f){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(f,l){if(f){!l||l=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(f=="back")c.cullFace(c.BACK);else f=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);
|
||||
c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
|
||||
THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
|
||||
@@ -201,8 +201,8 @@ shininess:{type:"f",value:30}}]),fragment_shader:["uniform vec3 color;\nuniform
|
||||
"gl_FragColor = mapColor * totalLight * vec4( vLightWeighting, 1.0 );",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.Snippets.map_pars_vertex,THREE.Snippets.envmap_pars_vertex,THREE.Snippets.lights_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.envmap_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",
|
||||
THREE.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=false;this.uvs=[null,null,null]};
|
||||
THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
|
||||
var GeometryUtils={merge:function(a,b){var d=b instanceof THREE.Mesh,e=a.vertices.length,g=d?b.geometry:b,h=a.vertices,j=g.vertices,c=a.faces,i=g.faces,m=a.uvs;g=g.uvs;d&&b.updateMatrix();for(var v=0,D=j.length;v<D;v++){var s=new THREE.Vertex(j[v].position.clone());d&&b.matrix.multiplyVector3(s.position);h.push(s)}v=0;for(D=i.length;v<D;v++){j=i[v];var y,B=j.vertexNormals;if(j instanceof THREE.Face3)y=new THREE.Face3(j.a+e,j.b+e,j.c+e);else if(j instanceof THREE.Face4)y=new THREE.Face4(j.a+e,j.b+
|
||||
e,j.c+e,j.d+e);y.centroid.copy(j.centroid);y.normal.copy(j.normal);d=0;for(h=B.length;d<h;d++){s=B[d];y.vertexNormals.push(s.clone())}y.materials=j.materials.slice();c.push(y)}v=0;for(D=g.length;v<D;v++){e=g[v];c=[];d=0;for(h=e.length;d<h;d++)c.push(new THREE.UV(e[d].u,e[d].v));m.push(c)}}},ImageUtils={loadTexture:function(a,b){var d=new Image;d.onload=function(){this.loaded=true};d.src=a;return new THREE.Texture(d,b)},loadArray:function(a){var b,d,e=[];b=e.loadCount=0;for(d=a.length;b<d;++b){e[b]=
|
||||
var GeometryUtils={merge:function(a,b){var d=b instanceof THREE.Mesh,e=a.vertices.length,g=d?b.geometry:b,h=a.vertices,j=g.vertices,c=a.faces,i=g.faces,m=a.uvs;g=g.uvs;d&&b.updateMatrix();for(var v=0,D=j.length;v<D;v++){var r=new THREE.Vertex(j[v].position.clone());d&&b.matrix.multiplyVector3(r.position);h.push(r)}v=0;for(D=i.length;v<D;v++){j=i[v];var y,A=j.vertexNormals;if(j instanceof THREE.Face3)y=new THREE.Face3(j.a+e,j.b+e,j.c+e);else if(j instanceof THREE.Face4)y=new THREE.Face4(j.a+e,j.b+
|
||||
e,j.c+e,j.d+e);y.centroid.copy(j.centroid);y.normal.copy(j.normal);d=0;for(h=A.length;d<h;d++){r=A[d];y.vertexNormals.push(r.clone())}y.materials=j.materials.slice();c.push(y)}v=0;for(D=g.length;v<D;v++){e=g[v];c=[];d=0;for(h=e.length;d<h;d++)c.push(new THREE.UV(e[d].u,e[d].v));m.push(c)}}},ImageUtils={loadTexture:function(a,b){var d=new Image;d.onload=function(){this.loaded=true};d.src=a;return new THREE.Texture(d,b)},loadArray:function(a){var b,d,e=[];b=e.loadCount=0;for(d=a.length;b<d;++b){e[b]=
|
||||
new Image;e[b].loaded=0;e[b].onload=function(){e.loadCount+=1;this.loaded=true};e[b].src=a[b]}return e}},SceneUtils={addMesh:function(a,b,d,e,g,h,j,c,i,m){b=new THREE.Mesh(b,m);b.scale.x=b.scale.y=b.scale.z=d;b.position.x=e;b.position.y=g;b.position.z=h;b.rotation.x=j;b.rotation.y=c;b.rotation.z=i;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,d){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=d;d=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,
|
||||
uniforms:e.uniforms});b=new THREE.Mesh(new Cube(b,b,b,1,1,null,true),d);a.addObject(b);return b},addPanoramaCube:function(a,b,d){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));
|
||||
b=new THREE.Mesh(new Cube(b,b,b,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(b);return b},addPanoramaCubePlanes:function(a,b,d){var e=b/2;b=new Plane(b,b);var g=Math.PI/2,h=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));SceneUtils.addMesh(a,b,1,-e,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,b,1,e,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,
|
||||
@@ -212,38 +212,38 @@ normal:{uniforms:{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},t
|
||||
uDirLightColor:{type:"c",value:new THREE.Color(15658734)},uAmbientLightColor:{type:"c",value:new THREE.Color(328965)},uDiffuseColor:{type:"c",value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30}},fragment_shader:"uniform vec3 uDirLightPos;\nuniform vec3 uAmbientLightColor;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform bool enableDiffuse;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nuniform float uNormalScale;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 diffuseTex = vec3( 1.0, 1.0, 1.0 );\nvec3 aoTex = vec3( 1.0, 1.0, 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ndiffuseTex = texture2D( tDiffuse, vUv ).xyz;\nif( enableAO )\naoTex = texture2D( tAO, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec3 pointVector = normalize( vPointLightVector );\nvec3 pointHalfVector = normalize( vPointLightVector + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}",
|
||||
vertex_shader:"attribute vec4 tangent;\nuniform vec3 uPointLightPos;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"},
|
||||
basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"void main() {\ngl_FragColor = vec4(1.0, 0.0, 0.0, 0.5);\n}"},cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
|
||||
fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"}}},Cube=function(a,b,d,e,g,h,j,c){function i(C,M,t,H,k,f,l,u){var n,r,I=e||1,p=g||1,w=I+1,z=p+1,x=k/2,q=f/2;k=k/I;var N=f/p,G=m.vertices.length;if(C=="x"&&M=="y"||C=="y"&&M=="x")n="z";else if(C=="x"&&M=="z"||C=="z"&&M=="x")n="y";else if(C=="z"&&M=="y"||C=="y"&&M=="z")n="x";for(r=0;r<z;r++)for(f=0;f<
|
||||
w;f++){var R=new THREE.Vector3;R[C]=(f*k-x)*t;R[M]=(r*N-q)*H;R[n]=l;m.vertices.push(new THREE.Vertex(R))}for(r=0;r<p;r++)for(f=0;f<I;f++){m.faces.push(new THREE.Face4(f+w*r+G,f+w*(r+1)+G,f+1+w*(r+1)+G,f+1+w*r+G,null,u));m.uvs.push([new THREE.UV(f/I,r/p),new THREE.UV(f/I,(r+1)/p),new THREE.UV((f+1)/I,(r+1)/p),new THREE.UV((f+1)/I,r/p)])}}THREE.Geometry.call(this);var m=this,v=a/2,D=b/2,s=d/2;j=j?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var y=0;y<6;y++)this.materials.push([h])}else this.materials=
|
||||
[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(c!=undefined)for(var B in c)if(this.sides[B]!=undefined)this.sides[B]=c[B];this.sides.px&&i("z","y",1*j,-1,d,b,-v,this.materials[0]);this.sides.nx&&i("z","y",-1*j,-1,d,b,v,this.materials[1]);this.sides.py&&i("x","z",1*j,1,a,d,D,this.materials[2]);this.sides.ny&&i("x","z",1*j,-1,a,d,-D,this.materials[3]);this.sides.pz&&i("x","y",1*j,-1,a,b,s,this.materials[4]);this.sides.nz&&i("x","y",-1*j,-1,a,b,-s,this.materials[5]);(function(){for(var C=
|
||||
[],M=[],t=0,H=m.vertices.length;t<H;t++){for(var k=m.vertices[t],f=false,l=0,u=C.length;l<u;l++){var n=C[l];if(k.position.x==n.position.x&&k.position.y==n.position.y&&k.position.z==n.position.z){M[t]=l;f=true;break}}if(!f){M[t]=C.length;C.push(new THREE.Vertex(k.position.clone()))}}t=0;for(H=m.faces.length;t<H;t++){k=m.faces[t];k.a=M[k.a];k.b=M[k.b];k.c=M[k.c];k.d=M[k.d]}m.vertices=C})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;
|
||||
fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"}}},Cube=function(a,b,d,e,g,h,j,c){function i(C,L,t,H,k,f,l,u){var n,s,I=e||1,p=g||1,w=I+1,z=p+1,x=k/2,q=f/2;k=k/I;var N=f/p,G=m.vertices.length;if(C=="x"&&L=="y"||C=="y"&&L=="x")n="z";else if(C=="x"&&L=="z"||C=="z"&&L=="x")n="y";else if(C=="z"&&L=="y"||C=="y"&&L=="z")n="x";for(s=0;s<z;s++)for(f=0;f<
|
||||
w;f++){var R=new THREE.Vector3;R[C]=(f*k-x)*t;R[L]=(s*N-q)*H;R[n]=l;m.vertices.push(new THREE.Vertex(R))}for(s=0;s<p;s++)for(f=0;f<I;f++){m.faces.push(new THREE.Face4(f+w*s+G,f+w*(s+1)+G,f+1+w*(s+1)+G,f+1+w*s+G,null,u));m.uvs.push([new THREE.UV(f/I,s/p),new THREE.UV(f/I,(s+1)/p),new THREE.UV((f+1)/I,(s+1)/p),new THREE.UV((f+1)/I,s/p)])}}THREE.Geometry.call(this);var m=this,v=a/2,D=b/2,r=d/2;j=j?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var y=0;y<6;y++)this.materials.push([h])}else this.materials=
|
||||
[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(c!=undefined)for(var A in c)if(this.sides[A]!=undefined)this.sides[A]=c[A];this.sides.px&&i("z","y",1*j,-1,d,b,-v,this.materials[0]);this.sides.nx&&i("z","y",-1*j,-1,d,b,v,this.materials[1]);this.sides.py&&i("x","z",1*j,1,a,d,D,this.materials[2]);this.sides.ny&&i("x","z",1*j,-1,a,d,-D,this.materials[3]);this.sides.pz&&i("x","y",1*j,-1,a,b,r,this.materials[4]);this.sides.nz&&i("x","y",-1*j,-1,a,b,-r,this.materials[5]);(function(){for(var C=
|
||||
[],L=[],t=0,H=m.vertices.length;t<H;t++){for(var k=m.vertices[t],f=false,l=0,u=C.length;l<u;l++){var n=C[l];if(k.position.x==n.position.x&&k.position.y==n.position.y&&k.position.z==n.position.z){L[t]=l;f=true;break}}if(!f){L[t]=C.length;C.push(new THREE.Vertex(k.position.clone()))}}t=0;for(H=m.faces.length;t<H;t++){k=m.faces[t];k.a=L[k.a];k.b=L[k.b];k.c=L[k.c];k.d=L[k.d]}m.vertices=C})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;
|
||||
Cube.prototype.constructor=Cube;
|
||||
var Cylinder=function(a,b,d,e,g){function h(m,v,D){j.vertices.push(new THREE.Vertex(new THREE.Vector3(m,v,D)))}THREE.Geometry.call(this);var j=this,c=Math.PI,i;for(i=0;i<a;i++)h(Math.sin(2*c*i/a)*b,Math.cos(2*c*i/a)*b,0);for(i=0;i<a;i++)h(Math.sin(2*c*i/a)*d,Math.cos(2*c*i/a)*d,e);for(i=0;i<a;i++)j.faces.push(new THREE.Face4(i,i+a,a+(i+1)%a,(i+1)%a));if(d!=0){h(0,0,-g);for(i=a;i<a+a/2;i++)j.faces.push(new THREE.Face4(2*a,(2*i-2*a)%a,(2*i-2*a+1)%a,(2*i-2*a+2)%a))}if(b!=0){h(0,0,e+g);for(i=a+a/2;i<
|
||||
2*a;i++)j.faces.push(new THREE.Face4((2*i-2*a+2)%a+a,(2*i-2*a+1)%a+a,(2*i-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
|
||||
var Plane=function(a,b,d,e){THREE.Geometry.call(this);var g,h=a/2,j=b/2;d=d||1;e=e||1;var c=d+1,i=e+1;a=a/d;var m=b/e;for(g=0;g<i;g++)for(b=0;b<c;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-h,-(g*m-j),0)));for(g=0;g<e;g++)for(b=0;b<d;b++){this.faces.push(new THREE.Face4(b+c*g,b+c*(g+1),b+1+c*(g+1),b+1+c*g));this.uvs.push([new THREE.UV(b/d,g/e),new THREE.UV(b/d,(g+1)/e),new THREE.UV((b+1)/d,(g+1)/e),new THREE.UV((b+1)/d,g/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
|
||||
Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
|
||||
var Sphere=function(a,b,d){THREE.Geometry.call(this);var e,g=Math.PI,h=Math.max(3,b||8),j=Math.max(2,d||6);b=[];for(d=0;d<j+1;d++){e=d/j;var c=a*Math.cos(e*g),i=a*Math.sin(e*g),m=[],v=0;for(e=0;e<h;e++){var D=2*e/h,s=i*Math.sin(D*g);D=i*Math.cos(D*g);(d==0||d==j)&&e>0||(v=this.vertices.push(new THREE.Vertex(new THREE.Vector3(D,c,s)))-1);m.push(v)}b.push(m)}var y,B,C;g=b.length;for(d=0;d<g;d++){h=b[d].length;if(d>0)for(e=0;e<h;e++){m=e==h-1;j=b[d][m?0:e+1];c=b[d][m?h-1:e];i=b[d-1][m?h-1:e];m=b[d-1][m?
|
||||
0:e+1];s=d/(g-1);y=(d-1)/(g-1);B=(e+1)/h;D=e/h;v=new THREE.UV(1-B,s);s=new THREE.UV(1-D,s);D=new THREE.UV(1-D,y);var M=new THREE.UV(1-B,y);if(d<b.length-1){y=this.vertices[j].position.clone();B=this.vertices[c].position.clone();C=this.vertices[i].position.clone();y.normalize();B.normalize();C.normalize();this.faces.push(new THREE.Face3(j,c,i,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(B.x,B.y,B.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([v,s,D])}if(d>1){y=this.vertices[j].position.clone();
|
||||
B=this.vertices[i].position.clone();C=this.vertices[m].position.clone();y.normalize();B.normalize();C.normalize();this.faces.push(new THREE.Face3(j,i,m,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(B.x,B.y,B.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([v,D,M])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
|
||||
var Sphere=function(a,b,d){THREE.Geometry.call(this);var e,g=Math.PI,h=Math.max(3,b||8),j=Math.max(2,d||6);b=[];for(d=0;d<j+1;d++){e=d/j;var c=a*Math.cos(e*g),i=a*Math.sin(e*g),m=[],v=0;for(e=0;e<h;e++){var D=2*e/h,r=i*Math.sin(D*g);D=i*Math.cos(D*g);(d==0||d==j)&&e>0||(v=this.vertices.push(new THREE.Vertex(new THREE.Vector3(D,c,r)))-1);m.push(v)}b.push(m)}var y,A,C;g=b.length;for(d=0;d<g;d++){h=b[d].length;if(d>0)for(e=0;e<h;e++){m=e==h-1;j=b[d][m?0:e+1];c=b[d][m?h-1:e];i=b[d-1][m?h-1:e];m=b[d-1][m?
|
||||
0:e+1];r=d/(g-1);y=(d-1)/(g-1);A=(e+1)/h;D=e/h;v=new THREE.UV(1-A,r);r=new THREE.UV(1-D,r);D=new THREE.UV(1-D,y);var L=new THREE.UV(1-A,y);if(d<b.length-1){y=this.vertices[j].position.clone();A=this.vertices[c].position.clone();C=this.vertices[i].position.clone();y.normalize();A.normalize();C.normalize();this.faces.push(new THREE.Face3(j,c,i,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([v,r,D])}if(d>1){y=this.vertices[j].position.clone();
|
||||
A=this.vertices[i].position.clone();C=this.vertices[m].position.clone();y.normalize();A.normalize();C.normalize();this.faces.push(new THREE.Face3(j,i,m,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([v,D,L])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
|
||||
THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
|
||||
THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
|
||||
b},loadAsciiOld:function(a,b){var d=document.createElement("script");d.type="text/javascript";d.onload=b;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a){var b=a.model,d=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);b.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,d,e)};b.postMessage(a)},loadBinary:function(a){var b=a.model,d=a.callback,e=a.texture_path?a.texture_path:
|
||||
THREE.Loader.prototype.extractUrlbase(b),g=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);var h=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers,j.data.materials,d,g,e,h)};b.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,d,e,g,h){var j=new XMLHttpRequest,c=e+"/"+a,i=0;
|
||||
j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.Loader.prototype.createBinModel(j.responseText,d,g,b):alert("Couldn't load ["+c+"] ["+j.status+"]");else if(j.readyState==3){if(h){if(i==0)i=j.getResponseHeader("Content-Length");h({total:i,loaded:j.responseText.length})}}else if(j.readyState==2)i=j.getResponseHeader("Content-Length")};j.open("GET",c,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)},
|
||||
createBinModel:function(a,b,d,e){var g=function(h){function j(o,F){var E=v(o,F),V=v(o,F+1),$=v(o,F+2),da=v(o,F+3),ga=(da<<1&255|$>>7)-127;E=($&127)<<16|V<<8|E;if(E==0&&ga==-127)return 0;return(1-2*(da>>7))*(1+E*Math.pow(2,-23))*Math.pow(2,ga)}function c(o,F){var E=v(o,F),V=v(o,F+1),$=v(o,F+2);return(v(o,F+3)<<24)+($<<16)+(V<<8)+E}function i(o,F){var E=v(o,F);return(v(o,F+1)<<8)+E}function m(o,F){var E=v(o,F);return E>127?E-256:E}function v(o,F){return o.charCodeAt(F)&255}function D(o){var F,E,V;F=
|
||||
c(a,o);E=c(a,o+u);V=c(a,o+n);o=i(a,o+r);THREE.Loader.prototype.f3(t,F,E,V,o)}function s(o){var F,E,V,$,da,ga;F=c(a,o);E=c(a,o+u);V=c(a,o+n);$=i(a,o+r);da=c(a,o+I);ga=c(a,o+p);o=c(a,o+w);THREE.Loader.prototype.f3n(t,f,F,E,V,$,da,ga,o)}function y(o){var F,E,V,$;F=c(a,o);E=c(a,o+z);V=c(a,o+x);$=c(a,o+q);o=i(a,o+N);THREE.Loader.prototype.f4(t,F,E,V,$,o)}function B(o){var F,E,V,$,da,ga,na,pa;F=c(a,o);E=c(a,o+z);V=c(a,o+x);$=c(a,o+q);da=i(a,o+N);ga=c(a,o+G);na=c(a,o+R);pa=c(a,o+T);o=c(a,o+O);THREE.Loader.prototype.f4n(t,
|
||||
f,F,E,V,$,da,ga,na,pa,o)}function C(o){var F,E;F=c(a,o);E=c(a,o+ba);o=c(a,o+X);THREE.Loader.prototype.uv3(t,l[F*2],l[F*2+1],l[E*2],l[E*2+1],l[o*2],l[o*2+1])}function M(o){var F,E,V;F=c(a,o);E=c(a,o+L);V=c(a,o+Q);o=c(a,o+Z);THREE.Loader.prototype.uv4(t,l[F*2],l[F*2+1],l[E*2],l[E*2+1],l[V*2],l[V*2+1],l[o*2],l[o*2+1])}var t=this,H=0,k,f=[],l=[],u,n,r,I,p,w,z,x,q,N,G,R,T,O,ba,X,L,Q,Z,U,A,P,S,fa,ea;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(t,e,h);k={signature:a.substr(H,8),header_bytes:v(a,
|
||||
c(a,o);E=c(a,o+u);V=c(a,o+n);o=i(a,o+s);THREE.Loader.prototype.f3(t,F,E,V,o)}function r(o){var F,E,V,$,da,ga;F=c(a,o);E=c(a,o+u);V=c(a,o+n);$=i(a,o+s);da=c(a,o+I);ga=c(a,o+p);o=c(a,o+w);THREE.Loader.prototype.f3n(t,f,F,E,V,$,da,ga,o)}function y(o){var F,E,V,$;F=c(a,o);E=c(a,o+z);V=c(a,o+x);$=c(a,o+q);o=i(a,o+N);THREE.Loader.prototype.f4(t,F,E,V,$,o)}function A(o){var F,E,V,$,da,ga,na,pa;F=c(a,o);E=c(a,o+z);V=c(a,o+x);$=c(a,o+q);da=i(a,o+N);ga=c(a,o+G);na=c(a,o+R);pa=c(a,o+T);o=c(a,o+O);THREE.Loader.prototype.f4n(t,
|
||||
f,F,E,V,$,da,ga,na,pa,o)}function C(o){var F,E;F=c(a,o);E=c(a,o+ba);o=c(a,o+X);THREE.Loader.prototype.uv3(t,l[F*2],l[F*2+1],l[E*2],l[E*2+1],l[o*2],l[o*2+1])}function L(o){var F,E,V;F=c(a,o);E=c(a,o+M);V=c(a,o+Q);o=c(a,o+Z);THREE.Loader.prototype.uv4(t,l[F*2],l[F*2+1],l[E*2],l[E*2+1],l[V*2],l[V*2+1],l[o*2],l[o*2+1])}var t=this,H=0,k,f=[],l=[],u,n,s,I,p,w,z,x,q,N,G,R,T,O,ba,X,M,Q,Z,U,B,P,S,fa,ea;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(t,e,h);k={signature:a.substr(H,8),header_bytes:v(a,
|
||||
H+8),vertex_coordinate_bytes:v(a,H+9),normal_coordinate_bytes:v(a,H+10),uv_coordinate_bytes:v(a,H+11),vertex_index_bytes:v(a,H+12),normal_index_bytes:v(a,H+13),uv_index_bytes:v(a,H+14),material_index_bytes:v(a,H+15),nvertices:c(a,H+16),nnormals:c(a,H+16+4),nuvs:c(a,H+16+8),ntri_flat:c(a,H+16+12),ntri_smooth:c(a,H+16+16),ntri_flat_uv:c(a,H+16+20),ntri_smooth_uv:c(a,H+16+24),nquad_flat:c(a,H+16+28),nquad_smooth:c(a,H+16+32),nquad_flat_uv:c(a,H+16+36),nquad_smooth_uv:c(a,H+16+40)};H+=k.header_bytes;
|
||||
u=k.vertex_index_bytes;n=k.vertex_index_bytes*2;r=k.vertex_index_bytes*3;I=k.vertex_index_bytes*3+k.material_index_bytes;p=k.vertex_index_bytes*3+k.material_index_bytes+k.normal_index_bytes;w=k.vertex_index_bytes*3+k.material_index_bytes+k.normal_index_bytes*2;z=k.vertex_index_bytes;x=k.vertex_index_bytes*2;q=k.vertex_index_bytes*3;N=k.vertex_index_bytes*4;G=k.vertex_index_bytes*4+k.material_index_bytes;R=k.vertex_index_bytes*4+k.material_index_bytes+k.normal_index_bytes;T=k.vertex_index_bytes*4+
|
||||
k.material_index_bytes+k.normal_index_bytes*2;O=k.vertex_index_bytes*4+k.material_index_bytes+k.normal_index_bytes*3;ba=k.uv_index_bytes;X=k.uv_index_bytes*2;L=k.uv_index_bytes;Q=k.uv_index_bytes*2;Z=k.uv_index_bytes*3;h=k.vertex_index_bytes*3+k.material_index_bytes;ea=k.vertex_index_bytes*4+k.material_index_bytes;U=k.ntri_flat*h;A=k.ntri_smooth*(h+k.normal_index_bytes*3);P=k.ntri_flat_uv*(h+k.uv_index_bytes*3);S=k.ntri_smooth_uv*(h+k.normal_index_bytes*3+k.uv_index_bytes*3);fa=k.nquad_flat*ea;h=
|
||||
u=k.vertex_index_bytes;n=k.vertex_index_bytes*2;s=k.vertex_index_bytes*3;I=k.vertex_index_bytes*3+k.material_index_bytes;p=k.vertex_index_bytes*3+k.material_index_bytes+k.normal_index_bytes;w=k.vertex_index_bytes*3+k.material_index_bytes+k.normal_index_bytes*2;z=k.vertex_index_bytes;x=k.vertex_index_bytes*2;q=k.vertex_index_bytes*3;N=k.vertex_index_bytes*4;G=k.vertex_index_bytes*4+k.material_index_bytes;R=k.vertex_index_bytes*4+k.material_index_bytes+k.normal_index_bytes;T=k.vertex_index_bytes*4+
|
||||
k.material_index_bytes+k.normal_index_bytes*2;O=k.vertex_index_bytes*4+k.material_index_bytes+k.normal_index_bytes*3;ba=k.uv_index_bytes;X=k.uv_index_bytes*2;M=k.uv_index_bytes;Q=k.uv_index_bytes*2;Z=k.uv_index_bytes*3;h=k.vertex_index_bytes*3+k.material_index_bytes;ea=k.vertex_index_bytes*4+k.material_index_bytes;U=k.ntri_flat*h;B=k.ntri_smooth*(h+k.normal_index_bytes*3);P=k.ntri_flat_uv*(h+k.uv_index_bytes*3);S=k.ntri_smooth_uv*(h+k.normal_index_bytes*3+k.uv_index_bytes*3);fa=k.nquad_flat*ea;h=
|
||||
k.nquad_smooth*(ea+k.normal_index_bytes*4);ea=k.nquad_flat_uv*(ea+k.uv_index_bytes*4);H+=function(o){var F,E,V,$=k.vertex_coordinate_bytes*3,da=o+k.nvertices*$;for(o=o;o<da;o+=$){F=j(a,o);E=j(a,o+k.vertex_coordinate_bytes);V=j(a,o+k.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(t,F,E,V)}return k.nvertices*$}(H);H+=function(o){var F,E,V,$=k.normal_coordinate_bytes*3,da=o+k.nnormals*$;for(o=o;o<da;o+=$){F=m(a,o);E=m(a,o+k.normal_coordinate_bytes);V=m(a,o+k.normal_coordinate_bytes*2);f.push(F/
|
||||
127,E/127,V/127)}return k.nnormals*$}(H);H+=function(o){var F,E,V=k.uv_coordinate_bytes*2,$=o+k.nuvs*V;for(o=o;o<$;o+=V){F=j(a,o);E=j(a,o+k.uv_coordinate_bytes);l.push(F,E)}return k.nuvs*V}(H);H=H;U=H+U;A=U+A;P=A+P;S=P+S;fa=S+fa;h=fa+h;ea=h+ea;(function(o){var F,E=k.vertex_index_bytes*3+k.material_index_bytes,V=E+k.uv_index_bytes*3,$=o+k.ntri_flat_uv*V;for(F=o;F<$;F+=V){D(F);C(F+E)}return $-o})(A);(function(o){var F,E=k.vertex_index_bytes*3+k.material_index_bytes+k.normal_index_bytes*3,V=E+k.uv_index_bytes*
|
||||
3,$=o+k.ntri_smooth_uv*V;for(F=o;F<$;F+=V){s(F);C(F+E)}return $-o})(P);(function(o){var F,E=k.vertex_index_bytes*4+k.material_index_bytes,V=E+k.uv_index_bytes*4,$=o+k.nquad_flat_uv*V;for(F=o;F<$;F+=V){y(F);M(F+E)}return $-o})(h);(function(o){var F,E=k.vertex_index_bytes*4+k.material_index_bytes+k.normal_index_bytes*4,V=E+k.uv_index_bytes*4,$=o+k.nquad_smooth_uv*V;for(F=o;F<$;F+=V){B(F);M(F+E)}return $-o})(ea);(function(o){var F,E=k.vertex_index_bytes*3+k.material_index_bytes,V=o+k.ntri_flat*E;for(F=
|
||||
o;F<V;F+=E)D(F);return V-o})(H);(function(o){var F,E=k.vertex_index_bytes*3+k.material_index_bytes+k.normal_index_bytes*3,V=o+k.ntri_smooth*E;for(F=o;F<V;F+=E)s(F);return V-o})(U);(function(o){var F,E=k.vertex_index_bytes*4+k.material_index_bytes,V=o+k.nquad_flat*E;for(F=o;F<V;F+=E)y(F);return V-o})(S);(function(o){var F,E=k.vertex_index_bytes*4+k.material_index_bytes+k.normal_index_bytes*4,V=o+k.nquad_smooth*E;for(F=o;F<V;F+=E)B(F);return V-o})(fa);this.computeCentroids();this.computeFaceNormals();
|
||||
this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g(d))},createModel:function(a,b,d){var e=function(g){var h=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(h,a.materials,g);(function(){var j,c,i,m,v;j=0;for(c=a.vertices.length;j<c;j+=3){i=a.vertices[j];m=a.vertices[j+1];v=a.vertices[j+2];THREE.Loader.prototype.v(h,i,m,v)}})();(function(){function j(B,C){THREE.Loader.prototype.f3(h,B[C],B[C+1],B[C+2],B[C+3])}function c(B,C){THREE.Loader.prototype.f3n(h,
|
||||
a.normals,B[C],B[C+1],B[C+2],B[C+3],B[C+4],B[C+5],B[C+6])}function i(B,C){THREE.Loader.prototype.f4(h,B[C],B[C+1],B[C+2],B[C+3],B[C+4])}function m(B,C){THREE.Loader.prototype.f4n(h,a.normals,B[C],B[C+1],B[C+2],B[C+3],B[C+4],B[C+5],B[C+6],B[C+7],B[C+8])}function v(B,C){var M,t,H;M=B[C];t=B[C+1];H=B[C+2];THREE.Loader.prototype.uv3(h,a.uvs[M*2],a.uvs[M*2+1],a.uvs[t*2],a.uvs[t*2+1],a.uvs[H*2],a.uvs[H*2+1])}function D(B,C){var M,t,H,k;M=B[C];t=B[C+1];H=B[C+2];k=B[C+3];THREE.Loader.prototype.uv4(h,a.uvs[M*
|
||||
2],a.uvs[M*2+1],a.uvs[t*2],a.uvs[t*2+1],a.uvs[H*2],a.uvs[H*2+1],a.uvs[k*2],a.uvs[k*2+1])}var s,y;s=0;for(y=a.triangles_uv.length;s<y;s+=7){j(a.triangles_uv,s);v(a.triangles_uv,s+4)}s=0;for(y=a.triangles_n_uv.length;s<y;s+=10){c(a.triangles_n_uv,s);v(a.triangles_n_uv,s+7)}s=0;for(y=a.quads_uv.length;s<y;s+=9){i(a.quads_uv,s);D(a.quads_uv,s+5)}s=0;for(y=a.quads_n_uv.length;s<y;s+=13){m(a.quads_n_uv,s);D(a.quads_n_uv,s+9)}s=0;for(y=a.triangles.length;s<y;s+=4)j(a.triangles,s);s=0;for(y=a.triangles_n.length;s<
|
||||
y;s+=7)c(a.triangles_n,s);s=0;for(y=a.quads.length;s<y;s+=5)i(a.quads,s);s=0;for(y=a.quads_n.length;s<y;s+=9)m(a.quads_n,s)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(d))},v:function(a,b,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,d,e)))},f3:function(a,b,d,e,g){a.faces.push(new THREE.Face3(b,d,e,null,a.materials[g]))},f4:function(a,b,d,e,g,h){a.faces.push(new THREE.Face4(b,d,e,g,null,
|
||||
a.materials[h]))},f3n:function(a,b,d,e,g,h,j,c,i){h=a.materials[h];var m=b[c*3],v=b[c*3+1];c=b[c*3+2];var D=b[i*3],s=b[i*3+1];i=b[i*3+2];a.faces.push(new THREE.Face3(d,e,g,[new THREE.Vector3(b[j*3],b[j*3+1],b[j*3+2]),new THREE.Vector3(m,v,c),new THREE.Vector3(D,s,i)],h))},f4n:function(a,b,d,e,g,h,j,c,i,m,v){j=a.materials[j];var D=b[i*3],s=b[i*3+1];i=b[i*3+2];var y=b[m*3],B=b[m*3+1];m=b[m*3+2];var C=b[v*3],M=b[v*3+1];v=b[v*3+2];a.faces.push(new THREE.Face4(d,e,g,h,[new THREE.Vector3(b[c*3],b[c*3+1],
|
||||
b[c*3+2]),new THREE.Vector3(D,s,i),new THREE.Vector3(y,B,m),new THREE.Vector3(C,M,v)],j))},uv3:function(a,b,d,e,g,h,j){var c=[];c.push(new THREE.UV(b,d));c.push(new THREE.UV(e,g));c.push(new THREE.UV(h,j));a.uvs.push(c)},uv4:function(a,b,d,e,g,h,j,c,i){var m=[];m.push(new THREE.UV(b,d));m.push(new THREE.UV(e,g));m.push(new THREE.UV(h,j));m.push(new THREE.UV(c,i));a.uvs.push(m)},init_materials:function(a,b,d){a.materials=[];for(var e=0;e<b.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(b[e],
|
||||
127,E/127,V/127)}return k.nnormals*$}(H);H+=function(o){var F,E,V=k.uv_coordinate_bytes*2,$=o+k.nuvs*V;for(o=o;o<$;o+=V){F=j(a,o);E=j(a,o+k.uv_coordinate_bytes);l.push(F,E)}return k.nuvs*V}(H);H=H;U=H+U;B=U+B;P=B+P;S=P+S;fa=S+fa;h=fa+h;ea=h+ea;(function(o){var F,E=k.vertex_index_bytes*3+k.material_index_bytes,V=E+k.uv_index_bytes*3,$=o+k.ntri_flat_uv*V;for(F=o;F<$;F+=V){D(F);C(F+E)}return $-o})(B);(function(o){var F,E=k.vertex_index_bytes*3+k.material_index_bytes+k.normal_index_bytes*3,V=E+k.uv_index_bytes*
|
||||
3,$=o+k.ntri_smooth_uv*V;for(F=o;F<$;F+=V){r(F);C(F+E)}return $-o})(P);(function(o){var F,E=k.vertex_index_bytes*4+k.material_index_bytes,V=E+k.uv_index_bytes*4,$=o+k.nquad_flat_uv*V;for(F=o;F<$;F+=V){y(F);L(F+E)}return $-o})(h);(function(o){var F,E=k.vertex_index_bytes*4+k.material_index_bytes+k.normal_index_bytes*4,V=E+k.uv_index_bytes*4,$=o+k.nquad_smooth_uv*V;for(F=o;F<$;F+=V){A(F);L(F+E)}return $-o})(ea);(function(o){var F,E=k.vertex_index_bytes*3+k.material_index_bytes,V=o+k.ntri_flat*E;for(F=
|
||||
o;F<V;F+=E)D(F);return V-o})(H);(function(o){var F,E=k.vertex_index_bytes*3+k.material_index_bytes+k.normal_index_bytes*3,V=o+k.ntri_smooth*E;for(F=o;F<V;F+=E)r(F);return V-o})(U);(function(o){var F,E=k.vertex_index_bytes*4+k.material_index_bytes,V=o+k.nquad_flat*E;for(F=o;F<V;F+=E)y(F);return V-o})(S);(function(o){var F,E=k.vertex_index_bytes*4+k.material_index_bytes+k.normal_index_bytes*4,V=o+k.nquad_smooth*E;for(F=o;F<V;F+=E)A(F);return V-o})(fa);this.computeCentroids();this.computeFaceNormals();
|
||||
this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g(d))},createModel:function(a,b,d){var e=function(g){var h=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(h,a.materials,g);(function(){var j,c,i,m,v;j=0;for(c=a.vertices.length;j<c;j+=3){i=a.vertices[j];m=a.vertices[j+1];v=a.vertices[j+2];THREE.Loader.prototype.v(h,i,m,v)}})();(function(){function j(A,C){THREE.Loader.prototype.f3(h,A[C],A[C+1],A[C+2],A[C+3])}function c(A,C){THREE.Loader.prototype.f3n(h,
|
||||
a.normals,A[C],A[C+1],A[C+2],A[C+3],A[C+4],A[C+5],A[C+6])}function i(A,C){THREE.Loader.prototype.f4(h,A[C],A[C+1],A[C+2],A[C+3],A[C+4])}function m(A,C){THREE.Loader.prototype.f4n(h,a.normals,A[C],A[C+1],A[C+2],A[C+3],A[C+4],A[C+5],A[C+6],A[C+7],A[C+8])}function v(A,C){var L,t,H;L=A[C];t=A[C+1];H=A[C+2];THREE.Loader.prototype.uv3(h,a.uvs[L*2],a.uvs[L*2+1],a.uvs[t*2],a.uvs[t*2+1],a.uvs[H*2],a.uvs[H*2+1])}function D(A,C){var L,t,H,k;L=A[C];t=A[C+1];H=A[C+2];k=A[C+3];THREE.Loader.prototype.uv4(h,a.uvs[L*
|
||||
2],a.uvs[L*2+1],a.uvs[t*2],a.uvs[t*2+1],a.uvs[H*2],a.uvs[H*2+1],a.uvs[k*2],a.uvs[k*2+1])}var r,y;r=0;for(y=a.triangles_uv.length;r<y;r+=7){j(a.triangles_uv,r);v(a.triangles_uv,r+4)}r=0;for(y=a.triangles_n_uv.length;r<y;r+=10){c(a.triangles_n_uv,r);v(a.triangles_n_uv,r+7)}r=0;for(y=a.quads_uv.length;r<y;r+=9){i(a.quads_uv,r);D(a.quads_uv,r+5)}r=0;for(y=a.quads_n_uv.length;r<y;r+=13){m(a.quads_n_uv,r);D(a.quads_n_uv,r+9)}r=0;for(y=a.triangles.length;r<y;r+=4)j(a.triangles,r);r=0;for(y=a.triangles_n.length;r<
|
||||
y;r+=7)c(a.triangles_n,r);r=0;for(y=a.quads.length;r<y;r+=5)i(a.quads,r);r=0;for(y=a.quads_n.length;r<y;r+=9)m(a.quads_n,r)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(d))},v:function(a,b,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,d,e)))},f3:function(a,b,d,e,g){a.faces.push(new THREE.Face3(b,d,e,null,a.materials[g]))},f4:function(a,b,d,e,g,h){a.faces.push(new THREE.Face4(b,d,e,g,null,
|
||||
a.materials[h]))},f3n:function(a,b,d,e,g,h,j,c,i){h=a.materials[h];var m=b[c*3],v=b[c*3+1];c=b[c*3+2];var D=b[i*3],r=b[i*3+1];i=b[i*3+2];a.faces.push(new THREE.Face3(d,e,g,[new THREE.Vector3(b[j*3],b[j*3+1],b[j*3+2]),new THREE.Vector3(m,v,c),new THREE.Vector3(D,r,i)],h))},f4n:function(a,b,d,e,g,h,j,c,i,m,v){j=a.materials[j];var D=b[i*3],r=b[i*3+1];i=b[i*3+2];var y=b[m*3],A=b[m*3+1];m=b[m*3+2];var C=b[v*3],L=b[v*3+1];v=b[v*3+2];a.faces.push(new THREE.Face4(d,e,g,h,[new THREE.Vector3(b[c*3],b[c*3+1],
|
||||
b[c*3+2]),new THREE.Vector3(D,r,i),new THREE.Vector3(y,A,m),new THREE.Vector3(C,L,v)],j))},uv3:function(a,b,d,e,g,h,j){var c=[];c.push(new THREE.UV(b,d));c.push(new THREE.UV(e,g));c.push(new THREE.UV(h,j));a.uvs.push(c)},uv4:function(a,b,d,e,g,h,j,c,i){var m=[];m.push(new THREE.UV(b,d));m.push(new THREE.UV(e,g));m.push(new THREE.UV(h,j));m.push(new THREE.UV(c,i));a.uvs.push(m)},init_materials:function(a,b,d){a.materials=[];for(var e=0;e<b.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(b[e],
|
||||
d)]},createMaterial:function(a,b){function d(h){h=Math.log(h)/Math.LN2;return Math.floor(h)==h}var e,g;if(a.map_diffuse&&b){g=document.createElement("canvas");e=new THREE.MeshLambertMaterial({map:new THREE.Texture(g)});g=new Image;g.onload=function(){if(!d(this.width)||!d(this.height)){var h=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),j=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));e.map.image.width=h;e.map.image.height=j;e.map.image.getContext("2d").drawImage(this,0,0,h,j)}else e.map.image=
|
||||
this;e.map.image.loaded=1};g.src=b+"/"+a.map_diffuse}else if(a.col_diffuse){g=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;e=new THREE.MeshLambertMaterial({color:g,opacity:a.transparency})}else e=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):new THREE.MeshLambertMaterial({color:15658734});return e},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
|
||||
|
||||
Reference in New Issue
Block a user