mirror of
https://github.com/wahyd4/three.js.git
synced 2026-08-17 17:05:57 +10:00
Added to scene loader support for Icosahedron primitive and material shading parameter.
This commit is contained in:
+163
-159
@@ -12,50 +12,50 @@ 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,f=[];a=0;for(b=e.length;a<b;a++){d=e[a];if(d instanceof THREE.Mesh)f=f.concat(this.intersectObject(d))}f.sort(function(h,j){return h.distance-j.distance});return f},intersectObject:function(a){function b(K,t,L,m){m=m.clone().subSelf(t);L=L.clone().subSelf(t);var g=K.clone().subSelf(t);K=m.dot(m);t=m.dot(L);m=m.dot(g);var o=L.dot(L);L=L.dot(g);g=1/(K*o-t*t);o=(o*m-t*L)*g;K=(K*L-t*m)*g;return o>0&&K>0&&o+K<1}var d,e,f,h,j,c,k,l,n,C,
|
||||
p,x=a.geometry,z=x.vertices,u=[];d=0;for(e=x.faces.length;d<e;d++){f=x.faces[d];C=this.origin.clone();p=this.direction.clone();h=a.matrix.multiplyVector3(z[f.a].position.clone());j=a.matrix.multiplyVector3(z[f.b].position.clone());c=a.matrix.multiplyVector3(z[f.c].position.clone());k=f instanceof THREE.Face4?a.matrix.multiplyVector3(z[f.d].position.clone()):null;l=a.rotationMatrix.multiplyVector3(f.normal.clone());n=p.dot(l);if(n<0){l=l.dot((new THREE.Vector3).sub(h,C))/n;C=C.addSelf(p.multiplyScalar(l));
|
||||
if(f instanceof THREE.Face3){if(b(C,h,j,c)){f={distance:this.origin.distanceTo(C),point:C,face:f,object:a};u.push(f)}}else if(f instanceof THREE.Face4)if(b(C,h,j,k)||b(C,j,c,k)){f={distance:this.origin.distanceTo(C),point:C,face:f,object:a};u.push(f)}}}return u}};
|
||||
THREE.Rectangle=function(){function a(){h=e-b;j=f-d}var b,d,e,f,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 f};this.set=function(k,l,n,C){c=false;b=k;d=l;e=n;f=C;a()};this.addPoint=function(k,l){if(c){c=false;b=k;d=l;e=k;f=l}else{b=b<k?b:k;d=d<l?d:l;e=e>k?e:k;f=f>l?
|
||||
f:l}a()};this.add3Points=function(k,l,n,C,p,x){if(c){c=false;b=k<n?k<p?k:p:n<p?n:p;d=l<C?l<x?l:x:C<x?C:x;e=k>n?k>p?k:p:n>p?n:p;f=l>C?l>x?l:x:C>x?C:x}else{b=k<n?k<p?k<b?k:b:p<b?p:b:n<p?n<b?n:b:p<b?p:b;d=l<C?l<x?l<d?l:d:x<d?x:d:C<x?C<d?C:d:x<d?x:d;e=k>n?k>p?k>e?k:e:p>e?p:e:n>p?n>e?n:e:p>e?p:e;f=l>C?l>x?l>f?l:f:x>f?x:f:C>x?C>f?C:f:x>f?x:f}a()};this.addRectangle=function(k){if(c){c=false;b=k.getLeft();d=k.getTop();e=k.getRight();f=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();d=d<k.getTop()?d:k.getTop();
|
||||
e=e>k.getRight()?e:k.getRight();f=f>k.getBottom()?f:k.getBottom()}a()};this.inflate=function(k){b-=k;d-=k;e+=k;f+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();d=d>k.getTop()?d:k.getTop();e=e<k.getRight()?e:k.getRight();f=f<k.getBottom()?f:k.getBottom();a()};this.instersects=function(k){return Math.min(e,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(f,k.getBottom())-Math.max(d,k.getTop())>=0};this.empty=function(){c=true;f=e=d=b=0;a()};this.isEmpty=function(){return c};this.toString=
|
||||
function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+f+", width: "+h+", height: "+j+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this}};
|
||||
THREE.Matrix4=function(a,b,d,e,f,h,j,c,k,l,n,C,p,x,z,u){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=f||0;this.n22=h||1;this.n23=j||0;this.n24=c||0;this.n31=k||0;this.n32=l||0;this.n33=n||1;this.n34=C||0;this.n41=p||0;this.n42=x||0;this.n43=z||0;this.n44=u||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
|
||||
THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,d,e,f,h,j,c,k,l,n,C,p,x,z,u){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=f;this.n22=h;this.n23=j;this.n24=c;this.n31=k;this.n32=l;this.n33=n;this.n34=C;this.n41=p;this.n42=x;this.n43=z;this.n44=u;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=THREE.Matrix4.__tmpVec1,f=THREE.Matrix4.__tmpVec2,h=THREE.Matrix4.__tmpVec3;h.sub(a,b).normalize();e.cross(d,h).normalize();f.cross(h,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);
|
||||
this.n31=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,f=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)*f;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*b+this.n22*d+this.n23*
|
||||
e+this.n24*f;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*f;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,f=a.n13,h=a.n14,j=a.n21,c=a.n22,k=a.n23,l=a.n24,n=a.n31,
|
||||
C=a.n32,p=a.n33,x=a.n34,z=a.n41,u=a.n42,K=a.n43,t=a.n44,L=b.n11,m=b.n12,g=b.n13,o=b.n14,B=b.n21,q=b.n22,A=b.n23,N=b.n24,v=b.n31,D=b.n32,G=b.n33,E=b.n34,y=b.n41,I=b.n42,F=b.n43,T=b.n44;this.n11=d*L+e*B+f*v+h*y;this.n12=d*m+e*q+f*D+h*I;this.n13=d*g+e*A+f*G+h*F;this.n14=d*o+e*N+f*E+h*T;this.n21=j*L+c*B+k*v+l*y;this.n22=j*m+c*q+k*D+l*I;this.n23=j*g+c*A+k*G+l*F;this.n24=j*o+c*N+k*E+l*T;this.n31=n*L+C*B+p*v+x*y;this.n32=n*m+C*q+p*D+x*I;this.n33=n*g+C*A+p*G+x*F;this.n34=n*o+C*N+p*E+x*T;this.n41=z*L+u*B+
|
||||
K*v+t*y;this.n42=z*m+u*q+K*D+t*I;this.n43=z*g+u*A+K*G+t*F;this.n44=z*o+u*N+K*E+t*T;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,f=this.n14,h=this.n21,j=this.n22,c=this.n23,k=this.n24,l=this.n31,n=this.n32,C=this.n33,p=this.n34,x=this.n41,z=this.n42,u=this.n43,K=this.n44,t=a.n11,L=a.n21,m=a.n31,g=a.n41,o=a.n12,B=a.n22,q=a.n32,A=a.n42,N=a.n13,v=a.n23,D=a.n33,G=a.n43,E=a.n14,y=a.n24,I=a.n34;a=a.n44;this.n11=b*t+d*L+e*m+f*g;this.n12=b*o+d*B+e*q+f*A;this.n13=b*N+d*v+e*D+f*
|
||||
G;this.n14=b*E+d*y+e*I+f*a;this.n21=h*t+j*L+c*m+k*g;this.n22=h*o+j*B+c*q+k*A;this.n23=h*N+j*v+c*D+k*G;this.n24=h*E+j*y+c*I+k*a;this.n31=l*t+n*L+C*m+p*g;this.n32=l*o+n*B+C*q+p*A;this.n33=l*N+n*v+C*D+p*G;this.n34=l*E+n*y+C*I+p*a;this.n41=x*t+z*L+u*m+K*g;this.n42=x*o+z*B+u*q+K*A;this.n43=x*N+z*v+u*D+K*G;this.n44=x*E+z*y+u*I+K*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=
|
||||
a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,d=this.n13,e=this.n14,f=this.n21,h=this.n22,j=this.n23,c=this.n24,k=this.n31,l=this.n32,n=this.n33,C=this.n34,p=this.n41,x=this.n42,z=this.n43,u=this.n44;return e*j*l*p-d*c*l*p-e*h*n*p+b*c*n*p+d*h*C*p-b*j*C*p-e*j*k*x+d*c*k*x+e*f*n*x-a*c*n*x-d*f*C*x+a*j*C*x+e*h*k*z-b*c*k*z-e*f*l*z+a*c*l*z+b*f*C*z-a*h*C*z-d*h*k*u+b*j*k*u+d*f*l*u-a*j*l*u-b*f*n*u+a*h*n*u},transpose:function(){function a(b,d,
|
||||
e){var f=b[d];b[d]=b[e];b[e]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;
|
||||
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(f,j){return f.distance-j.distance});return g},intersectObject:function(a){function b(K,t,L,m){m=m.clone().subSelf(t);L=L.clone().subSelf(t);var h=K.clone().subSelf(t);K=m.dot(m);t=m.dot(L);m=m.dot(h);var p=L.dot(L);L=L.dot(h);h=1/(K*p-t*t);p=(p*m-t*L)*h;K=(K*L-t*m)*h;return p>0&&K>0&&p+K<1}var d,e,g,f,j,c,k,l,n,B,
|
||||
o,u=a.geometry,v=u.vertices,w=[];d=0;for(e=u.faces.length;d<e;d++){g=u.faces[d];B=this.origin.clone();o=this.direction.clone();f=a.matrix.multiplyVector3(v[g.a].position.clone());j=a.matrix.multiplyVector3(v[g.b].position.clone());c=a.matrix.multiplyVector3(v[g.c].position.clone());k=g instanceof THREE.Face4?a.matrix.multiplyVector3(v[g.d].position.clone()):null;l=a.rotationMatrix.multiplyVector3(g.normal.clone());n=o.dot(l);if(n<0){l=l.dot((new THREE.Vector3).sub(f,B))/n;B=B.addSelf(o.multiplyScalar(l));
|
||||
if(g instanceof THREE.Face3){if(b(B,f,j,c)){g={distance:this.origin.distanceTo(B),point:B,face:g,object:a};w.push(g)}}else if(g instanceof THREE.Face4)if(b(B,f,j,k)||b(B,j,c,k)){g={distance:this.origin.distanceTo(B),point:B,face:g,object:a};w.push(g)}}}return w}};
|
||||
THREE.Rectangle=function(){function a(){f=e-b;j=g-d}var b,d,e,g,f,j,c=true;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return f};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(k,l,n,B){c=false;b=k;d=l;e=n;g=B;a()};this.addPoint=function(k,l){if(c){c=false;b=k;d=l;e=k;g=l}else{b=b<k?b:k;d=d<l?d:l;e=e>k?e:k;g=g>l?
|
||||
g:l}a()};this.add3Points=function(k,l,n,B,o,u){if(c){c=false;b=k<n?k<o?k:o:n<o?n:o;d=l<B?l<u?l:u:B<u?B:u;e=k>n?k>o?k:o:n>o?n:o;g=l>B?l>u?l:u:B>u?B:u}else{b=k<n?k<o?k<b?k:b:o<b?o:b:n<o?n<b?n:b:o<b?o:b;d=l<B?l<u?l<d?l:d:u<d?u:d:B<u?B<d?B:d:u<d?u:d;e=k>n?k>o?k>e?k:e:o>e?o:e:n>o?n>e?n:e:o>e?o:e;g=l>B?l>u?l>g?l:g:u>g?u:g:B>u?B>g?B:g:u>g?u:g}a()};this.addRectangle=function(k){if(c){c=false;b=k.getLeft();d=k.getTop();e=k.getRight();g=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();d=d<k.getTop()?d:k.getTop();
|
||||
e=e>k.getRight()?e:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;d-=k;e+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();d=d>k.getTop()?d:k.getTop();e=e<k.getRight()?e:k.getRight();g=g<k.getBottom()?g:k.getBottom();a()};this.instersects=function(k){return Math.min(e,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(g,k.getBottom())-Math.max(d,k.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: "+f+", height: "+j+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this}};
|
||||
THREE.Matrix4=function(a,b,d,e,g,f,j,c,k,l,n,B,o,u,v,w){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=g||0;this.n22=f||1;this.n23=j||0;this.n24=c||0;this.n31=k||0;this.n32=l||0;this.n33=n||1;this.n34=B||0;this.n41=o||0;this.n42=u||0;this.n43=v||0;this.n44=w||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
|
||||
THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,d,e,g,f,j,c,k,l,n,B,o,u,v,w){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=g;this.n22=f;this.n23=j;this.n24=c;this.n31=k;this.n32=l;this.n33=n;this.n34=B;this.n41=o;this.n42=u;this.n43=v;this.n44=w;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=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();e.cross(d,f).normalize();g.cross(f,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=f.x;this.n32=f.y;this.n33=f.z;this.n34=-f.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,f=a.n14,j=a.n21,c=a.n22,k=a.n23,l=a.n24,n=a.n31,
|
||||
B=a.n32,o=a.n33,u=a.n34,v=a.n41,w=a.n42,K=a.n43,t=a.n44,L=b.n11,m=b.n12,h=b.n13,p=b.n14,C=b.n21,q=b.n22,A=b.n23,N=b.n24,x=b.n31,D=b.n32,G=b.n33,E=b.n34,z=b.n41,I=b.n42,F=b.n43,T=b.n44;this.n11=d*L+e*C+g*x+f*z;this.n12=d*m+e*q+g*D+f*I;this.n13=d*h+e*A+g*G+f*F;this.n14=d*p+e*N+g*E+f*T;this.n21=j*L+c*C+k*x+l*z;this.n22=j*m+c*q+k*D+l*I;this.n23=j*h+c*A+k*G+l*F;this.n24=j*p+c*N+k*E+l*T;this.n31=n*L+B*C+o*x+u*z;this.n32=n*m+B*q+o*D+u*I;this.n33=n*h+B*A+o*G+u*F;this.n34=n*p+B*N+o*E+u*T;this.n41=v*L+w*C+
|
||||
K*x+t*z;this.n42=v*m+w*q+K*D+t*I;this.n43=v*h+w*A+K*G+t*F;this.n44=v*p+w*N+K*E+t*T;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,g=this.n14,f=this.n21,j=this.n22,c=this.n23,k=this.n24,l=this.n31,n=this.n32,B=this.n33,o=this.n34,u=this.n41,v=this.n42,w=this.n43,K=this.n44,t=a.n11,L=a.n21,m=a.n31,h=a.n41,p=a.n12,C=a.n22,q=a.n32,A=a.n42,N=a.n13,x=a.n23,D=a.n33,G=a.n43,E=a.n14,z=a.n24,I=a.n34;a=a.n44;this.n11=b*t+d*L+e*m+g*h;this.n12=b*p+d*C+e*q+g*A;this.n13=b*N+d*x+e*D+g*
|
||||
G;this.n14=b*E+d*z+e*I+g*a;this.n21=f*t+j*L+c*m+k*h;this.n22=f*p+j*C+c*q+k*A;this.n23=f*N+j*x+c*D+k*G;this.n24=f*E+j*z+c*I+k*a;this.n31=l*t+n*L+B*m+o*h;this.n32=l*p+n*C+B*q+o*A;this.n33=l*N+n*x+B*D+o*G;this.n34=l*E+n*z+B*I+o*a;this.n41=u*t+v*L+w*m+K*h;this.n42=u*p+v*C+w*q+K*A;this.n43=u*N+v*x+w*D+K*G;this.n44=u*E+v*z+w*I+K*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=
|
||||
a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,d=this.n13,e=this.n14,g=this.n21,f=this.n22,j=this.n23,c=this.n24,k=this.n31,l=this.n32,n=this.n33,B=this.n34,o=this.n41,u=this.n42,v=this.n43,w=this.n44;return e*j*l*o-d*c*l*o-e*f*n*o+b*c*n*o+d*f*B*o-b*j*B*o-e*j*k*u+d*c*k*u+e*g*n*u-a*c*n*u-d*g*B*u+a*j*B*u+e*f*k*v-b*c*k*v-e*g*l*v+a*c*l*v+b*g*B*v-a*f*B*v-d*f*k*w+b*j*k*w+d*g*l*w-a*j*l*w-b*g*n*w+a*f*n*w},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(){var a=this.flat;a[0]=this.n11;
|
||||
a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,b,d){this.set(1,0,0,a,0,1,0,b,0,0,1,d,0,0,0,1);return this},setScale:function(a,b,d){this.set(a,0,0,0,0,b,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=
|
||||
Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var d=Math.cos(b),e=Math.sin(b),f=1-d,h=a.x,j=a.y,c=a.z,k=f*h,l=f*j;this.set(k*h+d,k*j-e*c,k*c+e*j,0,k*j+e*c,l*j+d,l*c-e*h,0,k*c-e*j,l*c+e*h,f*c*c+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+
|
||||
Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var d=Math.cos(b),e=Math.sin(b),g=1-d,f=a.x,j=a.y,c=a.z,k=g*f,l=g*j;this.set(k*f+d,k*j-e*c,k*c+e*j,0,k*j+e*c,l*j+d,l*c-e*f,0,k*c-e*j,l*c+e*f,g*c*c+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+
|
||||
this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,d){var e=new THREE.Matrix4;e.setTranslation(a,b,d);return e};THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.setScale(a,b,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};
|
||||
THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4;d.setRotAxis(a,b);return d};
|
||||
THREE.Matrix4.makeInvert=function(a){var b=a.n11,d=a.n12,e=a.n13,f=a.n14,h=a.n21,j=a.n22,c=a.n23,k=a.n24,l=a.n31,n=a.n32,C=a.n33,p=a.n34,x=a.n41,z=a.n42,u=a.n43,K=a.n44,t=new THREE.Matrix4;t.n11=c*p*z-k*C*z+k*n*u-j*p*u-c*n*K+j*C*K;t.n12=f*C*z-e*p*z-f*n*u+d*p*u+e*n*K-d*C*K;t.n13=e*k*z-f*c*z+f*j*u-d*k*u-e*j*K+d*c*K;t.n14=f*c*n-e*k*n-f*j*C+d*k*C+e*j*p-d*c*p;t.n21=k*C*x-c*p*x-k*l*u+h*p*u+c*l*K-h*C*K;t.n22=e*p*x-f*C*x+f*l*u-b*p*u-e*l*K+b*C*K;t.n23=f*c*x-e*k*x-f*h*u+b*k*u+e*h*K-b*c*K;t.n24=e*k*l-f*c*l+
|
||||
f*h*C-b*k*C-e*h*p+b*c*p;t.n31=j*p*x-k*n*x+k*l*z-h*p*z-j*l*K+h*n*K;t.n32=f*n*x-d*p*x-f*l*z+b*p*z+d*l*K-b*n*K;t.n33=e*k*x-f*j*x+f*h*z-b*k*z-d*h*K+b*j*K;t.n34=f*j*l-d*k*l-f*h*n+b*k*n+d*h*p-b*j*p;t.n41=c*n*x-j*C*x-c*l*z+h*C*z+j*l*u-h*n*u;t.n42=d*C*x-e*n*x+e*l*z-b*C*z-d*l*u+b*n*u;t.n43=e*j*x-d*c*x-e*h*z+b*c*z+d*h*u-b*j*u;t.n44=d*c*l-e*j*l+e*h*n-b*c*n-d*h*C+b*j*C;t.multiplyScalar(1/a.determinant());return t};
|
||||
THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=a.m33;var d=a.m,e=b[10]*b[5]-b[6]*b[9],f=-b[10]*b[1]+b[2]*b[9],h=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],c=b[10]*b[0]-b[2]*b[8],k=-b[6]*b[0]+b[2]*b[4],l=b[9]*b[4]-b[5]*b[8],n=-b[9]*b[0]+b[1]*b[8],C=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*j+b[2]*l;if(b==0)throw"matrix not invertible";b=1/b;d[0]=b*e;d[1]=b*f;d[2]=b*h;d[3]=b*j;d[4]=b*c;d[5]=b*k;d[6]=b*l;d[7]=b*n;d[8]=b*C;return a};
|
||||
THREE.Matrix4.makeFrustum=function(a,b,d,e,f,h){var j,c,k;j=new THREE.Matrix4;c=2*f/(b-a);k=2*f/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(h+f)/(h-f);f=-2*h*f/(h-f);j.n11=c;j.n12=0;j.n13=a;j.n14=0;j.n21=0;j.n22=k;j.n23=d;j.n24=0;j.n31=0;j.n32=0;j.n33=e;j.n34=f;j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(a,b,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,d,e)};
|
||||
THREE.Matrix4.makeOrtho=function(a,b,d,e,f,h){var j,c,k,l;j=new THREE.Matrix4;c=b-a;k=d-e;l=h-f;a=(b+a)/c;d=(d+e)/k;f=(h+f)/l;j.n11=2/c;j.n12=0;j.n13=0;j.n14=-a;j.n21=0;j.n22=2/k;j.n23=0;j.n24=-d;j.n31=0;j.n32=0;j.n33=-2/l;j.n34=-f;j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
|
||||
THREE.Matrix4.makeInvert=function(a){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,j=a.n22,c=a.n23,k=a.n24,l=a.n31,n=a.n32,B=a.n33,o=a.n34,u=a.n41,v=a.n42,w=a.n43,K=a.n44,t=new THREE.Matrix4;t.n11=c*o*v-k*B*v+k*n*w-j*o*w-c*n*K+j*B*K;t.n12=g*B*v-e*o*v-g*n*w+d*o*w+e*n*K-d*B*K;t.n13=e*k*v-g*c*v+g*j*w-d*k*w-e*j*K+d*c*K;t.n14=g*c*n-e*k*n-g*j*B+d*k*B+e*j*o-d*c*o;t.n21=k*B*u-c*o*u-k*l*w+f*o*w+c*l*K-f*B*K;t.n22=e*o*u-g*B*u+g*l*w-b*o*w-e*l*K+b*B*K;t.n23=g*c*u-e*k*u-g*f*w+b*k*w+e*f*K-b*c*K;t.n24=e*k*l-g*c*l+
|
||||
g*f*B-b*k*B-e*f*o+b*c*o;t.n31=j*o*u-k*n*u+k*l*v-f*o*v-j*l*K+f*n*K;t.n32=g*n*u-d*o*u-g*l*v+b*o*v+d*l*K-b*n*K;t.n33=e*k*u-g*j*u+g*f*v-b*k*v-d*f*K+b*j*K;t.n34=g*j*l-d*k*l-g*f*n+b*k*n+d*f*o-b*j*o;t.n41=c*n*u-j*B*u-c*l*v+f*B*v+j*l*w-f*n*w;t.n42=d*B*u-e*n*u+e*l*v-b*B*v-d*l*w+b*n*w;t.n43=e*j*u-d*c*u-e*f*v+b*c*v+d*f*w-b*j*w;t.n44=d*c*l-e*j*l+e*f*n-b*c*n-d*f*B+b*j*B;t.multiplyScalar(1/a.determinant());return t};
|
||||
THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=a.m33;var d=a.m,e=b[10]*b[5]-b[6]*b[9],g=-b[10]*b[1]+b[2]*b[9],f=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],c=b[10]*b[0]-b[2]*b[8],k=-b[6]*b[0]+b[2]*b[4],l=b[9]*b[4]-b[5]*b[8],n=-b[9]*b[0]+b[1]*b[8],B=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*j+b[2]*l;if(b==0)throw"matrix not invertible";b=1/b;d[0]=b*e;d[1]=b*g;d[2]=b*f;d[3]=b*j;d[4]=b*c;d[5]=b*k;d[6]=b*l;d[7]=b*n;d[8]=b*B;return a};
|
||||
THREE.Matrix4.makeFrustum=function(a,b,d,e,g,f){var j,c,k;j=new THREE.Matrix4;c=2*g/(b-a);k=2*g/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(f+g)/(f-g);g=-2*f*g/(f-g);j.n11=c;j.n12=0;j.n13=a;j.n14=0;j.n21=0;j.n22=k;j.n23=d;j.n24=0;j.n31=0;j.n32=0;j.n33=e;j.n34=g;j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(a,b,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,d,e)};
|
||||
THREE.Matrix4.makeOrtho=function(a,b,d,e,g,f){var j,c,k,l;j=new THREE.Matrix4;c=b-a;k=d-e;l=f-g;a=(b+a)/c;d=(d+e)/k;g=(f+g)/l;j.n11=2/c;j.n12=0;j.n13=0;j.n14=-a;j.n21=0;j.n22=2/k;j.n23=0;j.n24=-d;j.n31=0;j.n32=0;j.n33=-2/l;j.n34=-g;j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
|
||||
THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
|
||||
THREE.Face3=function(a,b,d,e,f){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
|
||||
THREE.Face4=function(a,b,d,e,f,h){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=h instanceof Array?h:[h]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
|
||||
THREE.Face3=function(a,b,d,e,g){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
|
||||
THREE.Face4=function(a,b,d,e,g,f){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=f instanceof Array?f:[f]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
|
||||
THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
|
||||
THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
|
||||
d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,f,h,j,c=new THREE.Vector3,k=new THREE.Vector3;e=0;for(f=this.vertices.length;e<f;e++){h=this.vertices[e];h.normal.set(0,0,0)}e=0;for(f=this.faces.length;e<f;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);k.sub(b.position,d.position);c.crossSelf(k)}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,
|
||||
d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,g,f,j,c=new THREE.Vector3,k=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){f=this.vertices[e];f.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];if(a&&f.vertexNormals.length){c.set(0,0,0);b=0;for(d=f.normal.length;b<d;b++)c.addSelf(f.vertexNormals[b]);c.divideScalar(3)}else{b=this.vertices[f.a];d=this.vertices[f.b];j=this.vertices[f.c];c.sub(j.position,
|
||||
d.position);k.sub(b.position,d.position);c.crossSelf(k)}c.isZero()||c.normalize();f.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(E,y,I,F,T,V,P){h=E.vertices[y].position;j=E.vertices[I].position;c=E.vertices[F].position;k=f[T];l=f[V];n=f[P];C=j.x-h.x;p=c.x-h.x;x=j.y-h.y;z=c.y-h.y;
|
||||
u=j.z-h.z;K=c.z-h.z;t=l.u-k.u;L=n.u-k.u;m=l.v-k.v;g=n.v-k.v;o=1/(t*g-L*m);A.set((g*C-m*p)*o,(g*x-m*z)*o,(g*u-m*K)*o);N.set((t*p-L*C)*o,(t*z-L*x)*o,(t*K-L*u)*o);B[y].addSelf(A);B[I].addSelf(A);B[F].addSelf(A);q[y].addSelf(N);q[I].addSelf(N);q[F].addSelf(N)}var b,d,e,f,h,j,c,k,l,n,C,p,x,z,u,K,t,L,m,g,o,B=[],q=[],A=new THREE.Vector3,N=new THREE.Vector3,v=new THREE.Vector3,D=new THREE.Vector3,G=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++){B[b]=new THREE.Vector3;q[b]=new THREE.Vector3}b=0;
|
||||
for(d=this.faces.length;b<d;b++){e=this.faces[b];f=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++){G.copy(this.vertices[b].normal);e=B[b];v.copy(e);v.subSelf(G.multiplyScalar(G.dot(e))).normalize();D.cross(this.vertices[b].normal,e);e=D.dot(q[b]);e=e<0?-1:1;this.vertices[b].tangent.set(v.x,v.y,v.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],
|
||||
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(E,z,I,F,T,V,P){f=E.vertices[z].position;j=E.vertices[I].position;c=E.vertices[F].position;k=g[T];l=g[V];n=g[P];B=j.x-f.x;o=c.x-f.x;u=j.y-f.y;v=c.y-f.y;
|
||||
w=j.z-f.z;K=c.z-f.z;t=l.u-k.u;L=n.u-k.u;m=l.v-k.v;h=n.v-k.v;p=1/(t*h-L*m);A.set((h*B-m*o)*p,(h*u-m*v)*p,(h*w-m*K)*p);N.set((t*o-L*B)*p,(t*v-L*u)*p,(t*K-L*w)*p);C[z].addSelf(A);C[I].addSelf(A);C[F].addSelf(A);q[z].addSelf(N);q[I].addSelf(N);q[F].addSelf(N)}var b,d,e,g,f,j,c,k,l,n,B,o,u,v,w,K,t,L,m,h,p,C=[],q=[],A=new THREE.Vector3,N=new THREE.Vector3,x=new THREE.Vector3,D=new THREE.Vector3,G=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++){C[b]=new THREE.Vector3;q[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++){G.copy(this.vertices[b].normal);e=C[b];x.copy(e);x.subSelf(G.multiplyScalar(G.dot(e))).normalize();D.cross(this.vertices[b].normal,e);e=D.dot(q[b]);e=e<0?-1:1;this.vertices[b].tangent.set(x.x,x.y,x.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
|
||||
z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var 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>
|
||||
this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,d=this.vertices.length;b<d;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(n){var C=[];b=0;for(d=n.length;b<d;b++)n[b]==undefined?C.push("undefined"):C.push(n[b].toString());return C.join("_")}var b,d,e,f,h,j,c,k,l={};e=0;for(f=this.faces.length;e<f;e++){h=this.faces[e];
|
||||
j=h.materials;c=a(j);if(l[c]==undefined)l[c]={hash:c,counter:0};k=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:j,vertices:0};h=h instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+h>65535){l[c].counter+=1;k=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:j,vertices:0}}this.geometryChunks[k].faces.push(e);this.geometryChunks[k].vertices+=h}},toString:function(){return"THREE.Geometry ( vertices: "+
|
||||
this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,d=this.vertices.length;b<d;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(n){var B=[];b=0;for(d=n.length;b<d;b++)n[b]==undefined?B.push("undefined"):B.push(n[b].toString());return B.join("_")}var b,d,e,g,f,j,c,k,l={};e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];
|
||||
j=f.materials;c=a(j);if(l[c]==undefined)l[c]={hash:c,counter:0};k=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:j,vertices:0};f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+f>65535){l[c].counter+=1;k=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:j,vertices:0}}this.geometryChunks[k].faces.push(e);this.geometryChunks[k].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+
|
||||
this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
|
||||
THREE.Camera=function(a,b,d,e){this.fov=a;this.aspect=b;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(f){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
|
||||
this.translateZ=function(f){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
|
||||
THREE.Camera=function(a,b,d,e){this.fov=a;this.aspect=b;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
|
||||
this.translateZ=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
|
||||
THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;
|
||||
THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
|
||||
THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
|
||||
@@ -89,101 +89,101 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM
|
||||
THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
|
||||
THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
|
||||
THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
|
||||
THREE.Texture=function(a,b,d,e,f,h){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=f!==undefined?f:THREE.LinearFilter;this.min_filter=h!==undefined?h:THREE.LinearMipMapLinearFilter};
|
||||
THREE.Texture=function(a,b,d,e,g,f){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=f!==undefined?f:THREE.LinearMipMapLinearFilter};
|
||||
THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},toString:function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;
|
||||
THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
|
||||
THREE.RenderTarget=function(a,b,d){this.width=a;this.height=b;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType};
|
||||
var Uniforms={clone:function(a){var b,d,e,f={};for(b in a){f[b]={};for(d in a[b]){e=a[b][d];f[b][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return f},merge:function(a){var b,d,e,f={};for(b=0;b<a.length;b++){e=this.clone(a[b]);for(d in e)f[d]=e[d]}return f}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
|
||||
var Uniforms={clone:function(a){var b,d,e,g={};for(b in a){g[b]={};for(d in a[b]){e=a[b][d];g[b][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var b,d,e,g={};for(b=0;b<a.length;b++){e=this.clone(a[b]);for(d in e)g[d]=e[d]}return g}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
|
||||
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
|
||||
THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
|
||||
THREE.Fog=function(a,b,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(q,A){return A.z-q.z}function b(q,A){var N=0,v=1,D=q.z+q.w,G=A.z+A.w,E=-q.z+q.w,y=-A.z+A.w;if(D>=0&&G>=0&&E>=0&&y>=0)return true;else if(D<0&&G<0||E<0&&y<0)return false;else{if(D<0)N=Math.max(N,D/(D-G));else if(G<0)v=Math.min(v,D/(D-G));if(E<0)N=Math.max(N,E/(E-y));else if(y<0)v=Math.min(v,E/(E-y));if(v<N)return false;else{q.lerpSelf(A,N);A.lerpSelf(q,1-v);return true}}}var d,e,f=[],h,j,c,k=[],l,n,C=[],p,x,z=[],u=new THREE.Vector4,K=new THREE.Vector4,t=new THREE.Matrix4,
|
||||
L=new THREE.Matrix4,m=[],g=new THREE.Vector4,o=new THREE.Vector4,B;this.projectObjects=function(q,A,N){var v=[],D,G;e=0;t.multiply(A.projectionMatrix,A.matrix);m[0]=new THREE.Vector4(t.n41-t.n11,t.n42-t.n12,t.n43-t.n13,t.n44-t.n14);m[1]=new THREE.Vector4(t.n41+t.n11,t.n42+t.n12,t.n43+t.n13,t.n44+t.n14);m[2]=new THREE.Vector4(t.n41+t.n21,t.n42+t.n22,t.n43+t.n23,t.n44+t.n24);m[3]=new THREE.Vector4(t.n41-t.n21,t.n42-t.n22,t.n43-t.n23,t.n44-t.n24);m[4]=new THREE.Vector4(t.n41-t.n31,t.n42-t.n32,t.n43-
|
||||
t.n33,t.n44-t.n34);m[5]=new THREE.Vector4(t.n41+t.n31,t.n42+t.n32,t.n43+t.n33,t.n44+t.n34);A=0;for(D=m.length;A<D;A++){G=m[A];G.divideScalar(Math.sqrt(G.x*G.x+G.y*G.y+G.z*G.z))}D=q.objects;q=0;for(A=D.length;q<A;q++){G=D[q];var E;if(!(E=!G.visible)){if(E=G instanceof THREE.Mesh){a:{E=void 0;for(var y=G.position,I=-G.geometry.boundingSphere.radius*Math.max(G.scale.x,Math.max(G.scale.y,G.scale.z)),F=0;F<6;F++){E=m[F].x*y.x+m[F].y*y.y+m[F].z*y.z+m[F].w;if(E<=I){E=false;break a}}E=true}E=!E}E=E}if(!E){d=
|
||||
f[e]=f[e]||new THREE.RenderableObject;u.copy(G.position);t.multiplyVector3(u);d.object=G;d.z=u.z;v.push(d);e++}}N&&v.sort(a);return v};this.projectScene=function(q,A,N){var v=[],D=A.near,G=A.far,E,y,I,F,T,V,P,da,X,R,U,ba,Y,H,S,W;c=n=x=0;A.autoUpdateMatrix&&A.updateMatrix();t.multiply(A.projectionMatrix,A.matrix);V=this.projectObjects(q,A,true);q=0;for(E=V.length;q<E;q++){P=V[q].object;if(P.visible){P.autoUpdateMatrix&&P.updateMatrix();da=P.matrix;X=P.rotationMatrix;R=P.materials;U=P.overdraw;if(P instanceof
|
||||
THREE.Mesh){ba=P.geometry;Y=ba.vertices;y=0;for(I=Y.length;y<I;y++){H=Y[y];H.positionWorld.copy(H.position);da.multiplyVector3(H.positionWorld);F=H.positionScreen;F.copy(H.positionWorld);t.multiplyVector4(F);F.x/=F.w;F.y/=F.w;H.__visible=F.z>D&&F.z<G}ba=ba.faces;y=0;for(I=ba.length;y<I;y++){H=ba[y];if(H instanceof THREE.Face3){F=Y[H.a];T=Y[H.b];S=Y[H.c];if(F.__visible&&T.__visible&&S.__visible)if(P.doubleSided||P.flipSided!=(S.positionScreen.x-F.positionScreen.x)*(T.positionScreen.y-F.positionScreen.y)-
|
||||
(S.positionScreen.y-F.positionScreen.y)*(T.positionScreen.x-F.positionScreen.x)<0){h=k[c]=k[c]||new THREE.RenderableFace3;h.v1.positionWorld.copy(F.positionWorld);h.v2.positionWorld.copy(T.positionWorld);h.v3.positionWorld.copy(S.positionWorld);h.v1.positionScreen.copy(F.positionScreen);h.v2.positionScreen.copy(T.positionScreen);h.v3.positionScreen.copy(S.positionScreen);h.normalWorld.copy(H.normal);X.multiplyVector3(h.normalWorld);h.centroidWorld.copy(H.centroid);da.multiplyVector3(h.centroidWorld);
|
||||
h.centroidScreen.copy(h.centroidWorld);t.multiplyVector3(h.centroidScreen);S=H.vertexNormals;B=h.vertexNormalsWorld;F=0;for(T=S.length;F<T;F++){W=B[F]=B[F]||new THREE.Vector3;W.copy(S[F]);X.multiplyVector3(W)}h.z=h.centroidScreen.z;h.meshMaterials=R;h.faceMaterials=H.materials;h.overdraw=U;if(P.geometry.uvs[y]){h.uvs[0]=P.geometry.uvs[y][0];h.uvs[1]=P.geometry.uvs[y][1];h.uvs[2]=P.geometry.uvs[y][2]}v.push(h);c++}}else if(H instanceof THREE.Face4){F=Y[H.a];T=Y[H.b];S=Y[H.c];W=Y[H.d];if(F.__visible&&
|
||||
T.__visible&&S.__visible&&W.__visible)if(P.doubleSided||P.flipSided!=((W.positionScreen.x-F.positionScreen.x)*(T.positionScreen.y-F.positionScreen.y)-(W.positionScreen.y-F.positionScreen.y)*(T.positionScreen.x-F.positionScreen.x)<0||(T.positionScreen.x-S.positionScreen.x)*(W.positionScreen.y-S.positionScreen.y)-(T.positionScreen.y-S.positionScreen.y)*(W.positionScreen.x-S.positionScreen.x)<0)){h=k[c]=k[c]||new THREE.RenderableFace3;h.v1.positionWorld.copy(F.positionWorld);h.v2.positionWorld.copy(T.positionWorld);
|
||||
h.v3.positionWorld.copy(W.positionWorld);h.v1.positionScreen.copy(F.positionScreen);h.v2.positionScreen.copy(T.positionScreen);h.v3.positionScreen.copy(W.positionScreen);h.normalWorld.copy(H.normal);X.multiplyVector3(h.normalWorld);h.centroidWorld.copy(H.centroid);da.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);t.multiplyVector3(h.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=R;h.faceMaterials=H.materials;h.overdraw=U;if(P.geometry.uvs[y]){h.uvs[0]=P.geometry.uvs[y][0];
|
||||
h.uvs[1]=P.geometry.uvs[y][1];h.uvs[2]=P.geometry.uvs[y][3]}v.push(h);c++;j=k[c]=k[c]||new THREE.RenderableFace3;j.v1.positionWorld.copy(T.positionWorld);j.v2.positionWorld.copy(S.positionWorld);j.v3.positionWorld.copy(W.positionWorld);j.v1.positionScreen.copy(T.positionScreen);j.v2.positionScreen.copy(S.positionScreen);j.v3.positionScreen.copy(W.positionScreen);j.normalWorld.copy(h.normalWorld);j.centroidWorld.copy(h.centroidWorld);j.centroidScreen.copy(h.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=
|
||||
R;j.faceMaterials=H.materials;j.overdraw=U;if(P.geometry.uvs[y]){j.uvs[0]=P.geometry.uvs[y][1];j.uvs[1]=P.geometry.uvs[y][2];j.uvs[2]=P.geometry.uvs[y][3]}v.push(j);c++}}}}else if(P instanceof THREE.Line){L.multiply(t,da);Y=P.geometry.vertices;H=Y[0];H.positionScreen.copy(H.position);L.multiplyVector4(H.positionScreen);y=1;for(I=Y.length;y<I;y++){F=Y[y];F.positionScreen.copy(F.position);L.multiplyVector4(F.positionScreen);T=Y[y-1];g.copy(F.positionScreen);o.copy(T.positionScreen);if(b(g,o)){g.multiplyScalar(1/
|
||||
g.w);o.multiplyScalar(1/o.w);l=C[n]=C[n]||new THREE.RenderableLine;l.v1.positionScreen.copy(g);l.v2.positionScreen.copy(o);l.z=Math.max(g.z,o.z);l.materials=P.materials;v.push(l);n++}}}else if(P instanceof THREE.Particle){K.set(P.position.x,P.position.y,P.position.z,1);t.multiplyVector4(K);K.z/=K.w;if(K.z>0&&K.z<1){p=z[x]=z[x]||new THREE.RenderableParticle;p.x=K.x/K.w;p.y=K.y/K.w;p.z=K.z;p.rotation=P.rotation.z;p.scale.x=P.scale.x*Math.abs(p.x-(K.x+A.projectionMatrix.n11)/(K.w+A.projectionMatrix.n14));
|
||||
p.scale.y=P.scale.y*Math.abs(p.y-(K.y+A.projectionMatrix.n22)/(K.w+A.projectionMatrix.n24));p.materials=P.materials;v.push(p);x++}}}}N&&v.sort(a);return v};this.unprojectVector=function(q,A){var N=THREE.Matrix4.makeInvert(A.matrix);N.multiplySelf(THREE.Matrix4.makeInvert(A.projectionMatrix));N.multiplyVector3(q);return q}};
|
||||
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,f,h;this.domElement=document.createElement("div");this.setSize=function(j,c){d=j;e=c;f=d/2;h=e/2};this.render=function(j,c){var k,l,n,C,p,x,z,u;a=b.projectScene(j,c);k=0;for(l=a.length;k<l;k++){p=a[k];if(p instanceof THREE.RenderableParticle){z=p.x*f+f;u=p.y*h+h;n=0;for(C=p.material.length;n<C;n++){x=p.material[n];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=z+"px";x.style.top=u+"px"}}}}}};
|
||||
THREE.CanvasRenderer=function(){function a(ma){if(p!=ma)l.globalAlpha=p=ma}function b(ma){if(x!=ma){switch(ma){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}x=ma}}var d=null,e=new THREE.Projector,f=document.createElement("canvas"),h,j,c,k,l=f.getContext("2d"),n=null,C=null,p=1,x=0,z=null,u=null,K=1,t,L,m,g,o,B,q,A,N,v=new THREE.Color,
|
||||
D=new THREE.Color,G=new THREE.Color,E=new THREE.Color,y=new THREE.Color,I,F,T,V,P,da,X,R,U,ba=new THREE.Rectangle,Y=new THREE.Rectangle,H=new THREE.Rectangle,S=false,W=new THREE.Color,ia=new THREE.Color,ha=new THREE.Color,w=new THREE.Color,M=Math.PI*2,J=new THREE.Vector3,Z,ca,ga,ja,qa,sa,ya=16;Z=document.createElement("canvas");Z.width=Z.height=2;ca=Z.getContext("2d");ca.fillStyle="rgba(0,0,0,1)";ca.fillRect(0,0,2,2);ga=ca.getImageData(0,0,2,2);ja=ga.data;qa=document.createElement("canvas");qa.width=
|
||||
qa.height=ya;sa=qa.getContext("2d");sa.translate(-ya/2,-ya/2);sa.scale(ya,ya);ya--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ma,wa){h=ma;j=wa;c=h/2;k=j/2;f.width=h;f.height=j;ba.set(-c,-k,c,k);p=1;x=0;u=z=null;K=1};this.setClearColor=function(ma,wa){n=ma!==null?new THREE.Color(ma):null;C=wa;Y.set(-c,-k,c,k);l.setTransform(1,0,0,-1,c,k);this.clear()};this.clear=function(){if(!Y.isEmpty()){Y.inflate(1);Y.minSelf(ba);if(n!==null){b(THREE.NormalBlending);
|
||||
a(1);l.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+C+")";l.fillRect(Y.getX(),Y.getY(),Y.getWidth(),Y.getHeight())}else l.clearRect(Y.getX(),Y.getY(),Y.getWidth(),Y.getHeight());Y.empty()}};this.render=function(ma,wa){function Pa(O){var ea,aa,Q,$=O.lights;ia.setRGB(0,0,0);ha.setRGB(0,0,0);w.setRGB(0,0,0);O=0;for(ea=$.length;O<ea;O++){aa=$[O];Q=aa.color;if(aa instanceof THREE.AmbientLight){ia.r+=Q.r;ia.g+=Q.g;ia.b+=Q.b}else if(aa instanceof THREE.DirectionalLight){ha.r+=
|
||||
Q.r;ha.g+=Q.g;ha.b+=Q.b}else if(aa instanceof THREE.PointLight){w.r+=Q.r;w.g+=Q.g;w.b+=Q.b}}}function Da(O,ea,aa,Q){var $,fa,la,na,oa=O.lights;O=0;for($=oa.length;O<$;O++){fa=oa[O];la=fa.color;na=fa.intensity;if(fa instanceof THREE.DirectionalLight){fa=aa.dot(fa.position)*na;if(fa>0){Q.r+=la.r*fa;Q.g+=la.g*fa;Q.b+=la.b*fa}}else if(fa instanceof THREE.PointLight){J.sub(fa.position,ea);J.normalize();fa=aa.dot(J)*na;if(fa>0){Q.r+=la.r*fa;Q.g+=la.g*fa;Q.b+=la.b*fa}}}}function Qa(O,ea,aa){if(aa.opacity!=
|
||||
0){a(aa.opacity);b(aa.blending);var Q,$,fa,la,na,oa;if(aa instanceof THREE.ParticleBasicMaterial){if(aa.map){la=aa.map;na=la.width>>1;oa=la.height>>1;$=ea.scale.x*c;fa=ea.scale.y*k;aa=$*na;Q=fa*oa;H.set(O.x-aa,O.y-Q,O.x+aa,O.y+Q);if(ba.instersects(H)){l.save();l.translate(O.x,O.y);l.rotate(-ea.rotation);l.scale($,-fa);l.translate(-na,-oa);l.drawImage(la,0,0);l.restore()}}}else if(aa instanceof THREE.ParticleCircleMaterial){if(S){W.r=ia.r+ha.r+w.r;W.g=ia.g+ha.g+w.g;W.b=ia.b+ha.b+w.b;v.r=aa.color.r*
|
||||
W.r;v.g=aa.color.g*W.g;v.b=aa.color.b*W.b;v.updateStyleString()}else v.__styleString=aa.color.__styleString;aa=ea.scale.x*c;Q=ea.scale.y*k;H.set(O.x-aa,O.y-Q,O.x+aa,O.y+Q);if(ba.instersects(H)){$=v.__styleString;if(u!=$)l.fillStyle=u=$;l.save();l.translate(O.x,O.y);l.rotate(-ea.rotation);l.scale(aa,Q);l.beginPath();l.arc(0,0,1,0,M,true);l.closePath();l.fill();l.restore()}}}}function Ra(O,ea,aa,Q){if(Q.opacity!=0){a(Q.opacity);b(Q.blending);l.beginPath();l.moveTo(O.positionScreen.x,O.positionScreen.y);
|
||||
l.lineTo(ea.positionScreen.x,ea.positionScreen.y);l.closePath();if(Q instanceof THREE.LineBasicMaterial){v.__styleString=Q.color.__styleString;O=Q.linewidth;if(K!=O)l.lineWidth=K=O;O=v.__styleString;if(z!=O)l.strokeStyle=z=O;l.stroke();H.inflate(Q.linewidth*2)}}}function La(O,ea,aa,Q,$,fa){if($.opacity!=0){a($.opacity);b($.blending);g=O.positionScreen.x;o=O.positionScreen.y;B=ea.positionScreen.x;q=ea.positionScreen.y;A=aa.positionScreen.x;N=aa.positionScreen.y;l.beginPath();l.moveTo(g,o);l.lineTo(B,
|
||||
q);l.lineTo(A,N);l.lineTo(g,o);l.closePath();if($ instanceof THREE.MeshBasicMaterial)if($.map)$.map.image.loaded&&$.map.mapping instanceof THREE.UVMapping&&Aa(g,o,B,q,A,N,$.map.image,Q.uvs[0].u,Q.uvs[0].v,Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);else if($.env_map){if($.env_map.image.loaded)if($.env_map.mapping instanceof THREE.SphericalReflectionMapping){O=wa.matrix;J.copy(Q.vertexNormalsWorld[0]);V=(J.x*O.n11+J.y*O.n12+J.z*O.n13)*0.5+0.5;P=-(J.x*O.n21+J.y*O.n22+J.z*O.n23)*0.5+0.5;J.copy(Q.vertexNormalsWorld[1]);
|
||||
da=(J.x*O.n11+J.y*O.n12+J.z*O.n13)*0.5+0.5;X=-(J.x*O.n21+J.y*O.n22+J.z*O.n23)*0.5+0.5;J.copy(Q.vertexNormalsWorld[2]);R=(J.x*O.n11+J.y*O.n12+J.z*O.n13)*0.5+0.5;U=-(J.x*O.n21+J.y*O.n22+J.z*O.n23)*0.5+0.5;Aa(g,o,B,q,A,N,$.env_map.image,V,P,da,X,R,U)}}else $.wireframe?Ea($.color.__styleString,$.wireframe_linewidth):Fa($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&!$.wireframe){$.map.mapping instanceof THREE.UVMapping&&Aa(g,o,B,q,A,N,$.map.image,Q.uvs[0].u,Q.uvs[0].v,
|
||||
Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);b(THREE.SubtractiveBlending)}if(S)if(!$.wireframe&&$.shading==THREE.SmoothShading&&Q.vertexNormalsWorld.length==3){D.r=G.r=E.r=ia.r;D.g=G.g=E.g=ia.g;D.b=G.b=E.b=ia.b;Da(fa,Q.v1.positionWorld,Q.vertexNormalsWorld[0],D);Da(fa,Q.v2.positionWorld,Q.vertexNormalsWorld[1],G);Da(fa,Q.v3.positionWorld,Q.vertexNormalsWorld[2],E);y.r=(G.r+E.r)*0.5;y.g=(G.g+E.g)*0.5;y.b=(G.b+E.b)*0.5;T=Ma(D,G,E,y);Aa(g,o,B,q,A,N,T,0,0,1,0,0,1)}else{W.r=ia.r;W.g=ia.g;W.b=ia.b;Da(fa,
|
||||
Q.centroidWorld,Q.normalWorld,W);v.r=$.color.r*W.r;v.g=$.color.g*W.g;v.b=$.color.b*W.b;v.updateStyleString();$.wireframe?Ea(v.__styleString,$.wireframe_linewidth):Fa(v.__styleString)}else $.wireframe?Ea($.color.__styleString,$.wireframe_linewidth):Fa($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){I=wa.near;F=wa.far;D.r=D.g=D.b=1-Ha(O.positionScreen.z,I,F);G.r=G.g=G.b=1-Ha(ea.positionScreen.z,I,F);E.r=E.g=E.b=1-Ha(aa.positionScreen.z,I,F);y.r=(G.r+E.r)*0.5;y.g=(G.g+E.g)*0.5;y.b=
|
||||
(G.b+E.b)*0.5;T=Ma(D,G,E,y);Aa(g,o,B,q,A,N,T,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){v.r=Ia(Q.normalWorld.x);v.g=Ia(Q.normalWorld.y);v.b=Ia(Q.normalWorld.z);v.updateStyleString();$.wireframe?Ea(v.__styleString,$.wireframe_linewidth):Fa(v.__styleString)}}}function Ea(O,ea){if(z!=O)l.strokeStyle=z=O;if(K!=ea)l.lineWidth=K=ea;l.stroke();H.inflate(ea*2)}function Fa(O){if(u!=O)l.fillStyle=u=O;l.fill()}function Aa(O,ea,aa,Q,$,fa,la,na,oa,ta,pa,ua,Ba){var xa,va;xa=la.width-1;va=la.height-
|
||||
THREE.Projector=function(){function a(q,A){return A.z-q.z}function b(q,A){var N=0,x=1,D=q.z+q.w,G=A.z+A.w,E=-q.z+q.w,z=-A.z+A.w;if(D>=0&&G>=0&&E>=0&&z>=0)return true;else if(D<0&&G<0||E<0&&z<0)return false;else{if(D<0)N=Math.max(N,D/(D-G));else if(G<0)x=Math.min(x,D/(D-G));if(E<0)N=Math.max(N,E/(E-z));else if(z<0)x=Math.min(x,E/(E-z));if(x<N)return false;else{q.lerpSelf(A,N);A.lerpSelf(q,1-x);return true}}}var d,e,g=[],f,j,c,k=[],l,n,B=[],o,u,v=[],w=new THREE.Vector4,K=new THREE.Vector4,t=new THREE.Matrix4,
|
||||
L=new THREE.Matrix4,m=[],h=new THREE.Vector4,p=new THREE.Vector4,C;this.projectObjects=function(q,A,N){var x=[],D,G;e=0;t.multiply(A.projectionMatrix,A.matrix);m[0]=new THREE.Vector4(t.n41-t.n11,t.n42-t.n12,t.n43-t.n13,t.n44-t.n14);m[1]=new THREE.Vector4(t.n41+t.n11,t.n42+t.n12,t.n43+t.n13,t.n44+t.n14);m[2]=new THREE.Vector4(t.n41+t.n21,t.n42+t.n22,t.n43+t.n23,t.n44+t.n24);m[3]=new THREE.Vector4(t.n41-t.n21,t.n42-t.n22,t.n43-t.n23,t.n44-t.n24);m[4]=new THREE.Vector4(t.n41-t.n31,t.n42-t.n32,t.n43-
|
||||
t.n33,t.n44-t.n34);m[5]=new THREE.Vector4(t.n41+t.n31,t.n42+t.n32,t.n43+t.n33,t.n44+t.n34);A=0;for(D=m.length;A<D;A++){G=m[A];G.divideScalar(Math.sqrt(G.x*G.x+G.y*G.y+G.z*G.z))}D=q.objects;q=0;for(A=D.length;q<A;q++){G=D[q];var E;if(!(E=!G.visible)){if(E=G instanceof THREE.Mesh){a:{E=void 0;for(var z=G.position,I=-G.geometry.boundingSphere.radius*Math.max(G.scale.x,Math.max(G.scale.y,G.scale.z)),F=0;F<6;F++){E=m[F].x*z.x+m[F].y*z.y+m[F].z*z.z+m[F].w;if(E<=I){E=false;break a}}E=true}E=!E}E=E}if(!E){d=
|
||||
g[e]=g[e]||new THREE.RenderableObject;w.copy(G.position);t.multiplyVector3(w);d.object=G;d.z=w.z;x.push(d);e++}}N&&x.sort(a);return x};this.projectScene=function(q,A,N){var x=[],D=A.near,G=A.far,E,z,I,F,T,V,P,da,X,R,U,ba,Y,H,S,W;c=n=u=0;A.autoUpdateMatrix&&A.updateMatrix();t.multiply(A.projectionMatrix,A.matrix);V=this.projectObjects(q,A,true);q=0;for(E=V.length;q<E;q++){P=V[q].object;if(P.visible){P.autoUpdateMatrix&&P.updateMatrix();da=P.matrix;X=P.rotationMatrix;R=P.materials;U=P.overdraw;if(P instanceof
|
||||
THREE.Mesh){ba=P.geometry;Y=ba.vertices;z=0;for(I=Y.length;z<I;z++){H=Y[z];H.positionWorld.copy(H.position);da.multiplyVector3(H.positionWorld);F=H.positionScreen;F.copy(H.positionWorld);t.multiplyVector4(F);F.x/=F.w;F.y/=F.w;H.__visible=F.z>D&&F.z<G}ba=ba.faces;z=0;for(I=ba.length;z<I;z++){H=ba[z];if(H instanceof THREE.Face3){F=Y[H.a];T=Y[H.b];S=Y[H.c];if(F.__visible&&T.__visible&&S.__visible)if(P.doubleSided||P.flipSided!=(S.positionScreen.x-F.positionScreen.x)*(T.positionScreen.y-F.positionScreen.y)-
|
||||
(S.positionScreen.y-F.positionScreen.y)*(T.positionScreen.x-F.positionScreen.x)<0){f=k[c]=k[c]||new THREE.RenderableFace3;f.v1.positionWorld.copy(F.positionWorld);f.v2.positionWorld.copy(T.positionWorld);f.v3.positionWorld.copy(S.positionWorld);f.v1.positionScreen.copy(F.positionScreen);f.v2.positionScreen.copy(T.positionScreen);f.v3.positionScreen.copy(S.positionScreen);f.normalWorld.copy(H.normal);X.multiplyVector3(f.normalWorld);f.centroidWorld.copy(H.centroid);da.multiplyVector3(f.centroidWorld);
|
||||
f.centroidScreen.copy(f.centroidWorld);t.multiplyVector3(f.centroidScreen);S=H.vertexNormals;C=f.vertexNormalsWorld;F=0;for(T=S.length;F<T;F++){W=C[F]=C[F]||new THREE.Vector3;W.copy(S[F]);X.multiplyVector3(W)}f.z=f.centroidScreen.z;f.meshMaterials=R;f.faceMaterials=H.materials;f.overdraw=U;if(P.geometry.uvs[z]){f.uvs[0]=P.geometry.uvs[z][0];f.uvs[1]=P.geometry.uvs[z][1];f.uvs[2]=P.geometry.uvs[z][2]}x.push(f);c++}}else if(H instanceof THREE.Face4){F=Y[H.a];T=Y[H.b];S=Y[H.c];W=Y[H.d];if(F.__visible&&
|
||||
T.__visible&&S.__visible&&W.__visible)if(P.doubleSided||P.flipSided!=((W.positionScreen.x-F.positionScreen.x)*(T.positionScreen.y-F.positionScreen.y)-(W.positionScreen.y-F.positionScreen.y)*(T.positionScreen.x-F.positionScreen.x)<0||(T.positionScreen.x-S.positionScreen.x)*(W.positionScreen.y-S.positionScreen.y)-(T.positionScreen.y-S.positionScreen.y)*(W.positionScreen.x-S.positionScreen.x)<0)){f=k[c]=k[c]||new THREE.RenderableFace3;f.v1.positionWorld.copy(F.positionWorld);f.v2.positionWorld.copy(T.positionWorld);
|
||||
f.v3.positionWorld.copy(W.positionWorld);f.v1.positionScreen.copy(F.positionScreen);f.v2.positionScreen.copy(T.positionScreen);f.v3.positionScreen.copy(W.positionScreen);f.normalWorld.copy(H.normal);X.multiplyVector3(f.normalWorld);f.centroidWorld.copy(H.centroid);da.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);t.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=R;f.faceMaterials=H.materials;f.overdraw=U;if(P.geometry.uvs[z]){f.uvs[0]=P.geometry.uvs[z][0];
|
||||
f.uvs[1]=P.geometry.uvs[z][1];f.uvs[2]=P.geometry.uvs[z][3]}x.push(f);c++;j=k[c]=k[c]||new THREE.RenderableFace3;j.v1.positionWorld.copy(T.positionWorld);j.v2.positionWorld.copy(S.positionWorld);j.v3.positionWorld.copy(W.positionWorld);j.v1.positionScreen.copy(T.positionScreen);j.v2.positionScreen.copy(S.positionScreen);j.v3.positionScreen.copy(W.positionScreen);j.normalWorld.copy(f.normalWorld);j.centroidWorld.copy(f.centroidWorld);j.centroidScreen.copy(f.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=
|
||||
R;j.faceMaterials=H.materials;j.overdraw=U;if(P.geometry.uvs[z]){j.uvs[0]=P.geometry.uvs[z][1];j.uvs[1]=P.geometry.uvs[z][2];j.uvs[2]=P.geometry.uvs[z][3]}x.push(j);c++}}}}else if(P instanceof THREE.Line){L.multiply(t,da);Y=P.geometry.vertices;H=Y[0];H.positionScreen.copy(H.position);L.multiplyVector4(H.positionScreen);z=1;for(I=Y.length;z<I;z++){F=Y[z];F.positionScreen.copy(F.position);L.multiplyVector4(F.positionScreen);T=Y[z-1];h.copy(F.positionScreen);p.copy(T.positionScreen);if(b(h,p)){h.multiplyScalar(1/
|
||||
h.w);p.multiplyScalar(1/p.w);l=B[n]=B[n]||new THREE.RenderableLine;l.v1.positionScreen.copy(h);l.v2.positionScreen.copy(p);l.z=Math.max(h.z,p.z);l.materials=P.materials;x.push(l);n++}}}else if(P instanceof THREE.Particle){K.set(P.position.x,P.position.y,P.position.z,1);t.multiplyVector4(K);K.z/=K.w;if(K.z>0&&K.z<1){o=v[u]=v[u]||new THREE.RenderableParticle;o.x=K.x/K.w;o.y=K.y/K.w;o.z=K.z;o.rotation=P.rotation.z;o.scale.x=P.scale.x*Math.abs(o.x-(K.x+A.projectionMatrix.n11)/(K.w+A.projectionMatrix.n14));
|
||||
o.scale.y=P.scale.y*Math.abs(o.y-(K.y+A.projectionMatrix.n22)/(K.w+A.projectionMatrix.n24));o.materials=P.materials;x.push(o);u++}}}}N&&x.sort(a);return x};this.unprojectVector=function(q,A){var N=THREE.Matrix4.makeInvert(A.matrix);N.multiplySelf(THREE.Matrix4.makeInvert(A.projectionMatrix));N.multiplyVector3(q);return q}};
|
||||
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,g,f;this.domElement=document.createElement("div");this.setSize=function(j,c){d=j;e=c;g=d/2;f=e/2};this.render=function(j,c){var k,l,n,B,o,u,v,w;a=b.projectScene(j,c);k=0;for(l=a.length;k<l;k++){o=a[k];if(o instanceof THREE.RenderableParticle){v=o.x*g+g;w=o.y*f+f;n=0;for(B=o.material.length;n<B;n++){u=o.material[n];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=v+"px";u.style.top=w+"px"}}}}}};
|
||||
THREE.CanvasRenderer=function(){function a(ma){if(o!=ma)l.globalAlpha=o=ma}function b(ma){if(u!=ma){switch(ma){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}u=ma}}var d=null,e=new THREE.Projector,g=document.createElement("canvas"),f,j,c,k,l=g.getContext("2d"),n=null,B=null,o=1,u=0,v=null,w=null,K=1,t,L,m,h,p,C,q,A,N,x=new THREE.Color,
|
||||
D=new THREE.Color,G=new THREE.Color,E=new THREE.Color,z=new THREE.Color,I,F,T,V,P,da,X,R,U,ba=new THREE.Rectangle,Y=new THREE.Rectangle,H=new THREE.Rectangle,S=false,W=new THREE.Color,ia=new THREE.Color,ha=new THREE.Color,y=new THREE.Color,M=Math.PI*2,J=new THREE.Vector3,Z,ca,ga,ja,qa,sa,ya=16;Z=document.createElement("canvas");Z.width=Z.height=2;ca=Z.getContext("2d");ca.fillStyle="rgba(0,0,0,1)";ca.fillRect(0,0,2,2);ga=ca.getImageData(0,0,2,2);ja=ga.data;qa=document.createElement("canvas");qa.width=
|
||||
qa.height=ya;sa=qa.getContext("2d");sa.translate(-ya/2,-ya/2);sa.scale(ya,ya);ya--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ma,wa){f=ma;j=wa;c=f/2;k=j/2;g.width=f;g.height=j;ba.set(-c,-k,c,k);o=1;u=0;w=v=null;K=1};this.setClearColor=function(ma,wa){n=ma!==null?new THREE.Color(ma):null;B=wa;Y.set(-c,-k,c,k);l.setTransform(1,0,0,-1,c,k);this.clear()};this.clear=function(){if(!Y.isEmpty()){Y.inflate(1);Y.minSelf(ba);if(n!==null){b(THREE.NormalBlending);
|
||||
a(1);l.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+B+")";l.fillRect(Y.getX(),Y.getY(),Y.getWidth(),Y.getHeight())}else l.clearRect(Y.getX(),Y.getY(),Y.getWidth(),Y.getHeight());Y.empty()}};this.render=function(ma,wa){function Pa(O){var ea,aa,Q,$=O.lights;ia.setRGB(0,0,0);ha.setRGB(0,0,0);y.setRGB(0,0,0);O=0;for(ea=$.length;O<ea;O++){aa=$[O];Q=aa.color;if(aa instanceof THREE.AmbientLight){ia.r+=Q.r;ia.g+=Q.g;ia.b+=Q.b}else if(aa instanceof THREE.DirectionalLight){ha.r+=
|
||||
Q.r;ha.g+=Q.g;ha.b+=Q.b}else if(aa instanceof THREE.PointLight){y.r+=Q.r;y.g+=Q.g;y.b+=Q.b}}}function Da(O,ea,aa,Q){var $,fa,la,na,oa=O.lights;O=0;for($=oa.length;O<$;O++){fa=oa[O];la=fa.color;na=fa.intensity;if(fa instanceof THREE.DirectionalLight){fa=aa.dot(fa.position)*na;if(fa>0){Q.r+=la.r*fa;Q.g+=la.g*fa;Q.b+=la.b*fa}}else if(fa instanceof THREE.PointLight){J.sub(fa.position,ea);J.normalize();fa=aa.dot(J)*na;if(fa>0){Q.r+=la.r*fa;Q.g+=la.g*fa;Q.b+=la.b*fa}}}}function Qa(O,ea,aa){if(aa.opacity!=
|
||||
0){a(aa.opacity);b(aa.blending);var Q,$,fa,la,na,oa;if(aa instanceof THREE.ParticleBasicMaterial){if(aa.map){la=aa.map;na=la.width>>1;oa=la.height>>1;$=ea.scale.x*c;fa=ea.scale.y*k;aa=$*na;Q=fa*oa;H.set(O.x-aa,O.y-Q,O.x+aa,O.y+Q);if(ba.instersects(H)){l.save();l.translate(O.x,O.y);l.rotate(-ea.rotation);l.scale($,-fa);l.translate(-na,-oa);l.drawImage(la,0,0);l.restore()}}}else if(aa instanceof THREE.ParticleCircleMaterial){if(S){W.r=ia.r+ha.r+y.r;W.g=ia.g+ha.g+y.g;W.b=ia.b+ha.b+y.b;x.r=aa.color.r*
|
||||
W.r;x.g=aa.color.g*W.g;x.b=aa.color.b*W.b;x.updateStyleString()}else x.__styleString=aa.color.__styleString;aa=ea.scale.x*c;Q=ea.scale.y*k;H.set(O.x-aa,O.y-Q,O.x+aa,O.y+Q);if(ba.instersects(H)){$=x.__styleString;if(w!=$)l.fillStyle=w=$;l.save();l.translate(O.x,O.y);l.rotate(-ea.rotation);l.scale(aa,Q);l.beginPath();l.arc(0,0,1,0,M,true);l.closePath();l.fill();l.restore()}}}}function Ra(O,ea,aa,Q){if(Q.opacity!=0){a(Q.opacity);b(Q.blending);l.beginPath();l.moveTo(O.positionScreen.x,O.positionScreen.y);
|
||||
l.lineTo(ea.positionScreen.x,ea.positionScreen.y);l.closePath();if(Q instanceof THREE.LineBasicMaterial){x.__styleString=Q.color.__styleString;O=Q.linewidth;if(K!=O)l.lineWidth=K=O;O=x.__styleString;if(v!=O)l.strokeStyle=v=O;l.stroke();H.inflate(Q.linewidth*2)}}}function La(O,ea,aa,Q,$,fa){if($.opacity!=0){a($.opacity);b($.blending);h=O.positionScreen.x;p=O.positionScreen.y;C=ea.positionScreen.x;q=ea.positionScreen.y;A=aa.positionScreen.x;N=aa.positionScreen.y;l.beginPath();l.moveTo(h,p);l.lineTo(C,
|
||||
q);l.lineTo(A,N);l.lineTo(h,p);l.closePath();if($ instanceof THREE.MeshBasicMaterial)if($.map)$.map.image.loaded&&$.map.mapping instanceof THREE.UVMapping&&Aa(h,p,C,q,A,N,$.map.image,Q.uvs[0].u,Q.uvs[0].v,Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);else if($.env_map){if($.env_map.image.loaded)if($.env_map.mapping instanceof THREE.SphericalReflectionMapping){O=wa.matrix;J.copy(Q.vertexNormalsWorld[0]);V=(J.x*O.n11+J.y*O.n12+J.z*O.n13)*0.5+0.5;P=-(J.x*O.n21+J.y*O.n22+J.z*O.n23)*0.5+0.5;J.copy(Q.vertexNormalsWorld[1]);
|
||||
da=(J.x*O.n11+J.y*O.n12+J.z*O.n13)*0.5+0.5;X=-(J.x*O.n21+J.y*O.n22+J.z*O.n23)*0.5+0.5;J.copy(Q.vertexNormalsWorld[2]);R=(J.x*O.n11+J.y*O.n12+J.z*O.n13)*0.5+0.5;U=-(J.x*O.n21+J.y*O.n22+J.z*O.n23)*0.5+0.5;Aa(h,p,C,q,A,N,$.env_map.image,V,P,da,X,R,U)}}else $.wireframe?Ea($.color.__styleString,$.wireframe_linewidth):Fa($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&!$.wireframe){$.map.mapping instanceof THREE.UVMapping&&Aa(h,p,C,q,A,N,$.map.image,Q.uvs[0].u,Q.uvs[0].v,
|
||||
Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);b(THREE.SubtractiveBlending)}if(S)if(!$.wireframe&&$.shading==THREE.SmoothShading&&Q.vertexNormalsWorld.length==3){D.r=G.r=E.r=ia.r;D.g=G.g=E.g=ia.g;D.b=G.b=E.b=ia.b;Da(fa,Q.v1.positionWorld,Q.vertexNormalsWorld[0],D);Da(fa,Q.v2.positionWorld,Q.vertexNormalsWorld[1],G);Da(fa,Q.v3.positionWorld,Q.vertexNormalsWorld[2],E);z.r=(G.r+E.r)*0.5;z.g=(G.g+E.g)*0.5;z.b=(G.b+E.b)*0.5;T=Ma(D,G,E,z);Aa(h,p,C,q,A,N,T,0,0,1,0,0,1)}else{W.r=ia.r;W.g=ia.g;W.b=ia.b;Da(fa,
|
||||
Q.centroidWorld,Q.normalWorld,W);x.r=$.color.r*W.r;x.g=$.color.g*W.g;x.b=$.color.b*W.b;x.updateStyleString();$.wireframe?Ea(x.__styleString,$.wireframe_linewidth):Fa(x.__styleString)}else $.wireframe?Ea($.color.__styleString,$.wireframe_linewidth):Fa($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){I=wa.near;F=wa.far;D.r=D.g=D.b=1-Ha(O.positionScreen.z,I,F);G.r=G.g=G.b=1-Ha(ea.positionScreen.z,I,F);E.r=E.g=E.b=1-Ha(aa.positionScreen.z,I,F);z.r=(G.r+E.r)*0.5;z.g=(G.g+E.g)*0.5;z.b=
|
||||
(G.b+E.b)*0.5;T=Ma(D,G,E,z);Aa(h,p,C,q,A,N,T,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){x.r=Ia(Q.normalWorld.x);x.g=Ia(Q.normalWorld.y);x.b=Ia(Q.normalWorld.z);x.updateStyleString();$.wireframe?Ea(x.__styleString,$.wireframe_linewidth):Fa(x.__styleString)}}}function Ea(O,ea){if(v!=O)l.strokeStyle=v=O;if(K!=ea)l.lineWidth=K=ea;l.stroke();H.inflate(ea*2)}function Fa(O){if(w!=O)l.fillStyle=w=O;l.fill()}function Aa(O,ea,aa,Q,$,fa,la,na,oa,ta,pa,ua,Ba){var xa,va;xa=la.width-1;va=la.height-
|
||||
1;na*=xa;oa*=va;ta*=xa;pa*=va;ua*=xa;Ba*=va;aa-=O;Q-=ea;$-=O;fa-=ea;ta-=na;pa-=oa;ua-=na;Ba-=oa;va=1/(ta*Ba-ua*pa);xa=(Ba*aa-pa*$)*va;pa=(Ba*Q-pa*fa)*va;aa=(ta*$-ua*aa)*va;Q=(ta*fa-ua*Q)*va;O=O-xa*na-aa*oa;ea=ea-pa*na-Q*oa;l.save();l.transform(xa,pa,aa,Q,O,ea);l.clip();l.drawImage(la,0,0);l.restore()}function Ma(O,ea,aa,Q){var $=~~(O.r*255),fa=~~(O.g*255);O=~~(O.b*255);var la=~~(ea.r*255),na=~~(ea.g*255);ea=~~(ea.b*255);var oa=~~(aa.r*255),ta=~~(aa.g*255);aa=~~(aa.b*255);var pa=~~(Q.r*255),ua=~~(Q.g*
|
||||
255);Q=~~(Q.b*255);ja[0]=$<0?0:$>255?255:$;ja[1]=fa<0?0:fa>255?255:fa;ja[2]=O<0?0:O>255?255:O;ja[4]=la<0?0:la>255?255:la;ja[5]=na<0?0:na>255?255:na;ja[6]=ea<0?0:ea>255?255:ea;ja[8]=oa<0?0:oa>255?255:oa;ja[9]=ta<0?0:ta>255?255:ta;ja[10]=aa<0?0:aa>255?255:aa;ja[12]=pa<0?0:pa>255?255:pa;ja[13]=ua<0?0:ua>255?255:ua;ja[14]=Q<0?0:Q>255?255:Q;ca.putImageData(ga,0,0);sa.drawImage(Z,0,0);return qa}function Ha(O,ea,aa){O=(O-ea)/(aa-ea);return O*O*(3-2*O)}function Ia(O){O=(O+1)*0.5;return O<0?0:O>1?1:O}function Ja(O,
|
||||
ea){var aa=ea.x-O.x,Q=ea.y-O.y,$=1/Math.sqrt(aa*aa+Q*Q);aa*=$;Q*=$;ea.x+=aa;ea.y+=Q;O.x-=aa;O.y-=Q}var Ga,Na,ka,ra,za,Ka,Oa,Ca;l.setTransform(1,0,0,-1,c,k);this.autoClear&&this.clear();d=e.projectScene(ma,wa,this.sortElements);(S=ma.lights.length>0)&&Pa(ma);Ga=0;for(Na=d.length;Ga<Na;Ga++){ka=d[Ga];H.empty();if(ka instanceof THREE.RenderableParticle){t=ka;t.x*=c;t.y*=k;ra=0;for(za=ka.materials.length;ra<za;ra++)Qa(t,ka,ka.materials[ra],ma)}else if(ka instanceof THREE.RenderableLine){t=ka.v1;L=ka.v2;
|
||||
t.positionScreen.x*=c;t.positionScreen.y*=k;L.positionScreen.x*=c;L.positionScreen.y*=k;H.addPoint(t.positionScreen.x,t.positionScreen.y);H.addPoint(L.positionScreen.x,L.positionScreen.y);if(ba.instersects(H)){ra=0;for(za=ka.materials.length;ra<za;)Ra(t,L,ka,ka.materials[ra++],ma)}}else if(ka instanceof THREE.RenderableFace3){t=ka.v1;L=ka.v2;m=ka.v3;t.positionScreen.x*=c;t.positionScreen.y*=k;L.positionScreen.x*=c;L.positionScreen.y*=k;m.positionScreen.x*=c;m.positionScreen.y*=k;if(ka.overdraw){Ja(t.positionScreen,
|
||||
L.positionScreen);Ja(L.positionScreen,m.positionScreen);Ja(m.positionScreen,t.positionScreen)}H.add3Points(t.positionScreen.x,t.positionScreen.y,L.positionScreen.x,L.positionScreen.y,m.positionScreen.x,m.positionScreen.y);if(ba.instersects(H)){ra=0;for(za=ka.meshMaterials.length;ra<za;){Ca=ka.meshMaterials[ra++];if(Ca instanceof THREE.MeshFaceMaterial){Ka=0;for(Oa=ka.faceMaterials.length;Ka<Oa;)(Ca=ka.faceMaterials[Ka++])&&La(t,L,m,ka,Ca,ma)}else La(t,L,m,ka,Ca,ma)}}}Y.addRectangle(H)}l.setTransform(1,
|
||||
0,0,1,0,0)}};
|
||||
THREE.SVGRenderer=function(){function a(V,P,da){var X,R,U,ba;X=0;for(R=V.lights.length;X<R;X++){U=V.lights[X];if(U instanceof THREE.DirectionalLight){ba=P.normalWorld.dot(U.position)*U.intensity;if(ba>0){da.r+=U.color.r*ba;da.g+=U.color.g*ba;da.b+=U.color.b*ba}}else if(U instanceof THREE.PointLight){N.sub(U.position,P.centroidWorld);N.normalize();ba=P.normalWorld.dot(N)*U.intensity;if(ba>0){da.r+=U.color.r*ba;da.g+=U.color.g*ba;da.b+=U.color.b*ba}}}}function b(V,P,da,X,R,U){E=e(y++);E.setAttribute("d",
|
||||
"M "+V.positionScreen.x+" "+V.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+"z");if(R instanceof THREE.MeshBasicMaterial)m.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshLambertMaterial)if(L){g.r=o.r;g.g=o.g;g.b=o.b;a(U,X,g);m.r=R.color.r*g.r;m.g=R.color.g*g.g;m.b=R.color.b*g.b;m.updateStyleString()}else m.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshDepthMaterial){A=1-R.__2near/(R.__farPlusNear-
|
||||
X.z*R.__farMinusNear);m.setRGB(A,A,A)}else R instanceof THREE.MeshNormalMaterial&&m.setRGB(f(X.normalWorld.x),f(X.normalWorld.y),f(X.normalWorld.z));R.wireframe?E.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+R.wireframe_linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.wireframe_linecap+"; stroke-linejoin: "+R.wireframe_linejoin):E.setAttribute("style","fill: "+m.__styleString+"; fill-opacity: "+R.opacity);c.appendChild(E)}function d(V,P,da,X,R,U,ba){E=
|
||||
e(y++);E.setAttribute("d","M "+V.positionScreen.x+" "+V.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(U instanceof THREE.MeshBasicMaterial)m.__styleString=U.color.__styleString;else if(U instanceof THREE.MeshLambertMaterial)if(L){g.r=o.r;g.g=o.g;g.b=o.b;a(ba,R,g);m.r=U.color.r*g.r;m.g=U.color.g*g.g;m.b=U.color.b*g.b;m.updateStyleString()}else m.__styleString=U.color.__styleString;
|
||||
else if(U instanceof THREE.MeshDepthMaterial){A=1-U.__2near/(U.__farPlusNear-R.z*U.__farMinusNear);m.setRGB(A,A,A)}else U instanceof THREE.MeshNormalMaterial&&m.setRGB(f(R.normalWorld.x),f(R.normalWorld.y),f(R.normalWorld.z));U.wireframe?E.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+U.wireframe_linewidth+"; stroke-opacity: "+U.opacity+"; stroke-linecap: "+U.wireframe_linecap+"; stroke-linejoin: "+U.wireframe_linejoin):E.setAttribute("style","fill: "+m.__styleString+
|
||||
"; fill-opacity: "+U.opacity);c.appendChild(E)}function e(V){if(v[V]==null){v[V]=document.createElementNS("http://www.w3.org/2000/svg","path");T==0&&v[V].setAttribute("shape-rendering","crispEdges");return v[V]}return v[V]}function f(V){return V<0?Math.min((1+V)*0.5,0.5):0.5+Math.min(V*0.5,0.5)}var h=null,j=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,l,n,C,p,x,z,u,K=new THREE.Rectangle,t=new THREE.Rectangle,L=false,m=new THREE.Color(16777215),g=new THREE.Color(16777215),
|
||||
o=new THREE.Color(0),B=new THREE.Color(0),q=new THREE.Color(0),A,N=new THREE.Vector3,v=[],D=[],G=[],E,y,I,F,T=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(V){switch(V){case "high":T=1;break;case "low":T=0}};this.setSize=function(V,P){k=V;l=P;n=k/2;C=l/2;c.setAttribute("viewBox",-n+" "+-C+" "+k+" "+l);c.setAttribute("width",k);c.setAttribute("height",l);K.set(-n,-C,n,C)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};
|
||||
this.render=function(V,P){var da,X,R,U,ba,Y,H,S;this.autoClear&&this.clear();h=j.projectScene(V,P,this.sortElements);F=I=y=0;if(L=V.lights.length>0){H=V.lights;o.setRGB(0,0,0);B.setRGB(0,0,0);q.setRGB(0,0,0);da=0;for(X=H.length;da<X;da++){R=H[da];U=R.color;if(R instanceof THREE.AmbientLight){o.r+=U.r;o.g+=U.g;o.b+=U.b}else if(R instanceof THREE.DirectionalLight){B.r+=U.r;B.g+=U.g;B.b+=U.b}else if(R instanceof THREE.PointLight){q.r+=U.r;q.g+=U.g;q.b+=U.b}}}da=0;for(X=h.length;da<X;da++){H=h[da];t.empty();
|
||||
if(H instanceof THREE.RenderableParticle){p=H;p.x*=n;p.y*=-C;R=0;for(U=H.materials.length;R<U;R++)if(S=H.materials[R]){ba=p;Y=H;S=S;var W=I++;if(D[W]==null){D[W]=document.createElementNS("http://www.w3.org/2000/svg","circle");T==0&&D[W].setAttribute("shape-rendering","crispEdges")}E=D[W];E.setAttribute("cx",ba.x);E.setAttribute("cy",ba.y);E.setAttribute("r",Y.scale.x*n);if(S instanceof THREE.ParticleCircleMaterial){if(L){g.r=o.r+B.r+q.r;g.g=o.g+B.g+q.g;g.b=o.b+B.b+q.b;m.r=S.color.r*g.r;m.g=S.color.g*
|
||||
g.g;m.b=S.color.b*g.b;m.updateStyleString()}else m=S.color;E.setAttribute("style","fill: "+m.__styleString)}c.appendChild(E)}}else if(H instanceof THREE.RenderableLine){p=H.v1;x=H.v2;p.positionScreen.x*=n;p.positionScreen.y*=-C;x.positionScreen.x*=n;x.positionScreen.y*=-C;t.addPoint(p.positionScreen.x,p.positionScreen.y);t.addPoint(x.positionScreen.x,x.positionScreen.y);if(K.instersects(t)){R=0;for(U=H.materials.length;R<U;)if(S=H.materials[R++]){ba=p;Y=x;S=S;W=F++;if(G[W]==null){G[W]=document.createElementNS("http://www.w3.org/2000/svg",
|
||||
THREE.SVGRenderer=function(){function a(V,P,da){var X,R,U,ba;X=0;for(R=V.lights.length;X<R;X++){U=V.lights[X];if(U instanceof THREE.DirectionalLight){ba=P.normalWorld.dot(U.position)*U.intensity;if(ba>0){da.r+=U.color.r*ba;da.g+=U.color.g*ba;da.b+=U.color.b*ba}}else if(U instanceof THREE.PointLight){N.sub(U.position,P.centroidWorld);N.normalize();ba=P.normalWorld.dot(N)*U.intensity;if(ba>0){da.r+=U.color.r*ba;da.g+=U.color.g*ba;da.b+=U.color.b*ba}}}}function b(V,P,da,X,R,U){E=e(z++);E.setAttribute("d",
|
||||
"M "+V.positionScreen.x+" "+V.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+"z");if(R instanceof THREE.MeshBasicMaterial)m.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshLambertMaterial)if(L){h.r=p.r;h.g=p.g;h.b=p.b;a(U,X,h);m.r=R.color.r*h.r;m.g=R.color.g*h.g;m.b=R.color.b*h.b;m.updateStyleString()}else m.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshDepthMaterial){A=1-R.__2near/(R.__farPlusNear-
|
||||
X.z*R.__farMinusNear);m.setRGB(A,A,A)}else R instanceof THREE.MeshNormalMaterial&&m.setRGB(g(X.normalWorld.x),g(X.normalWorld.y),g(X.normalWorld.z));R.wireframe?E.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+R.wireframe_linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.wireframe_linecap+"; stroke-linejoin: "+R.wireframe_linejoin):E.setAttribute("style","fill: "+m.__styleString+"; fill-opacity: "+R.opacity);c.appendChild(E)}function d(V,P,da,X,R,U,ba){E=
|
||||
e(z++);E.setAttribute("d","M "+V.positionScreen.x+" "+V.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(U instanceof THREE.MeshBasicMaterial)m.__styleString=U.color.__styleString;else if(U instanceof THREE.MeshLambertMaterial)if(L){h.r=p.r;h.g=p.g;h.b=p.b;a(ba,R,h);m.r=U.color.r*h.r;m.g=U.color.g*h.g;m.b=U.color.b*h.b;m.updateStyleString()}else m.__styleString=U.color.__styleString;
|
||||
else if(U instanceof THREE.MeshDepthMaterial){A=1-U.__2near/(U.__farPlusNear-R.z*U.__farMinusNear);m.setRGB(A,A,A)}else U instanceof THREE.MeshNormalMaterial&&m.setRGB(g(R.normalWorld.x),g(R.normalWorld.y),g(R.normalWorld.z));U.wireframe?E.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+U.wireframe_linewidth+"; stroke-opacity: "+U.opacity+"; stroke-linecap: "+U.wireframe_linecap+"; stroke-linejoin: "+U.wireframe_linejoin):E.setAttribute("style","fill: "+m.__styleString+
|
||||
"; fill-opacity: "+U.opacity);c.appendChild(E)}function e(V){if(x[V]==null){x[V]=document.createElementNS("http://www.w3.org/2000/svg","path");T==0&&x[V].setAttribute("shape-rendering","crispEdges");return x[V]}return x[V]}function g(V){return V<0?Math.min((1+V)*0.5,0.5):0.5+Math.min(V*0.5,0.5)}var f=null,j=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,l,n,B,o,u,v,w,K=new THREE.Rectangle,t=new THREE.Rectangle,L=false,m=new THREE.Color(16777215),h=new THREE.Color(16777215),
|
||||
p=new THREE.Color(0),C=new THREE.Color(0),q=new THREE.Color(0),A,N=new THREE.Vector3,x=[],D=[],G=[],E,z,I,F,T=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(V){switch(V){case "high":T=1;break;case "low":T=0}};this.setSize=function(V,P){k=V;l=P;n=k/2;B=l/2;c.setAttribute("viewBox",-n+" "+-B+" "+k+" "+l);c.setAttribute("width",k);c.setAttribute("height",l);K.set(-n,-B,n,B)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};
|
||||
this.render=function(V,P){var da,X,R,U,ba,Y,H,S;this.autoClear&&this.clear();f=j.projectScene(V,P,this.sortElements);F=I=z=0;if(L=V.lights.length>0){H=V.lights;p.setRGB(0,0,0);C.setRGB(0,0,0);q.setRGB(0,0,0);da=0;for(X=H.length;da<X;da++){R=H[da];U=R.color;if(R instanceof THREE.AmbientLight){p.r+=U.r;p.g+=U.g;p.b+=U.b}else if(R instanceof THREE.DirectionalLight){C.r+=U.r;C.g+=U.g;C.b+=U.b}else if(R instanceof THREE.PointLight){q.r+=U.r;q.g+=U.g;q.b+=U.b}}}da=0;for(X=f.length;da<X;da++){H=f[da];t.empty();
|
||||
if(H instanceof THREE.RenderableParticle){o=H;o.x*=n;o.y*=-B;R=0;for(U=H.materials.length;R<U;R++)if(S=H.materials[R]){ba=o;Y=H;S=S;var W=I++;if(D[W]==null){D[W]=document.createElementNS("http://www.w3.org/2000/svg","circle");T==0&&D[W].setAttribute("shape-rendering","crispEdges")}E=D[W];E.setAttribute("cx",ba.x);E.setAttribute("cy",ba.y);E.setAttribute("r",Y.scale.x*n);if(S instanceof THREE.ParticleCircleMaterial){if(L){h.r=p.r+C.r+q.r;h.g=p.g+C.g+q.g;h.b=p.b+C.b+q.b;m.r=S.color.r*h.r;m.g=S.color.g*
|
||||
h.g;m.b=S.color.b*h.b;m.updateStyleString()}else m=S.color;E.setAttribute("style","fill: "+m.__styleString)}c.appendChild(E)}}else if(H instanceof THREE.RenderableLine){o=H.v1;u=H.v2;o.positionScreen.x*=n;o.positionScreen.y*=-B;u.positionScreen.x*=n;u.positionScreen.y*=-B;t.addPoint(o.positionScreen.x,o.positionScreen.y);t.addPoint(u.positionScreen.x,u.positionScreen.y);if(K.instersects(t)){R=0;for(U=H.materials.length;R<U;)if(S=H.materials[R++]){ba=o;Y=u;S=S;W=F++;if(G[W]==null){G[W]=document.createElementNS("http://www.w3.org/2000/svg",
|
||||
"line");T==0&&G[W].setAttribute("shape-rendering","crispEdges")}E=G[W];E.setAttribute("x1",ba.positionScreen.x);E.setAttribute("y1",ba.positionScreen.y);E.setAttribute("x2",Y.positionScreen.x);E.setAttribute("y2",Y.positionScreen.y);if(S instanceof THREE.LineBasicMaterial){m.__styleString=S.color.__styleString;E.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+S.linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.linecap+"; stroke-linejoin: "+S.linejoin);
|
||||
c.appendChild(E)}}}}else if(H instanceof THREE.RenderableFace3){p=H.v1;x=H.v2;z=H.v3;p.positionScreen.x*=n;p.positionScreen.y*=-C;x.positionScreen.x*=n;x.positionScreen.y*=-C;z.positionScreen.x*=n;z.positionScreen.y*=-C;t.addPoint(p.positionScreen.x,p.positionScreen.y);t.addPoint(x.positionScreen.x,x.positionScreen.y);t.addPoint(z.positionScreen.x,z.positionScreen.y);if(K.instersects(t)){R=0;for(U=H.meshMaterials.length;R<U;){S=H.meshMaterials[R++];if(S instanceof THREE.MeshFaceMaterial){ba=0;for(Y=
|
||||
H.faceMaterials.length;ba<Y;)(S=H.faceMaterials[ba++])&&b(p,x,z,H,S,V)}else S&&b(p,x,z,H,S,V)}}}else if(H instanceof THREE.RenderableFace4){p=H.v1;x=H.v2;z=H.v3;u=H.v4;p.positionScreen.x*=n;p.positionScreen.y*=-C;x.positionScreen.x*=n;x.positionScreen.y*=-C;z.positionScreen.x*=n;z.positionScreen.y*=-C;u.positionScreen.x*=n;u.positionScreen.y*=-C;t.addPoint(p.positionScreen.x,p.positionScreen.y);t.addPoint(x.positionScreen.x,x.positionScreen.y);t.addPoint(z.positionScreen.x,z.positionScreen.y);t.addPoint(u.positionScreen.x,
|
||||
u.positionScreen.y);if(K.instersects(t)){R=0;for(U=H.meshMaterials.length;R<U;){S=H.meshMaterials[R++];if(S instanceof THREE.MeshFaceMaterial){ba=0;for(Y=H.faceMaterials.length;ba<Y;)(S=H.faceMaterials[ba++])&&d(p,x,z,u,H,S,V)}else S&&d(p,x,z,u,H,S,V)}}}}}};
|
||||
THREE.WebGLRenderer=function(a){function b(g,o){g.fragment_shader=o.fragment_shader;g.vertex_shader=o.vertex_shader;g.uniforms=Uniforms.clone(o.uniforms)}function d(g,o){g.uniforms.color.value.setRGB(g.color.r*g.opacity,g.color.g*g.opacity,g.color.b*g.opacity);g.uniforms.opacity.value=g.opacity;g.uniforms.map.texture=g.map;g.uniforms.env_map.texture=g.env_map;g.uniforms.reflectivity.value=g.reflectivity;g.uniforms.refraction_ratio.value=g.refraction_ratio;g.uniforms.combine.value=g.combine;g.uniforms.useRefract.value=
|
||||
g.env_map&&g.env_map.mapping instanceof THREE.CubeRefractionMapping;if(o){g.uniforms.fogColor.value.setHex(o.color.hex);if(o instanceof THREE.Fog){g.uniforms.fogNear.value=o.near;g.uniforms.fogFar.value=o.far}else if(o instanceof THREE.FogExp2)g.uniforms.fogDensity.value=o.density}}function e(g,o){g.uniforms.color.value.setRGB(g.color.r*g.opacity,g.color.g*g.opacity,g.color.b*g.opacity);g.uniforms.opacity.value=g.opacity;if(o){g.uniforms.fogColor.value.setHex(o.color.hex);if(o instanceof THREE.Fog){g.uniforms.fogNear.value=
|
||||
o.near;g.uniforms.fogFar.value=o.far}else if(o instanceof THREE.FogExp2)g.uniforms.fogDensity.value=o.density}}function f(g,o){var B;if(g=="fragment")B=c.createShader(c.FRAGMENT_SHADER);else if(g=="vertex")B=c.createShader(c.VERTEX_SHADER);c.shaderSource(B,o);c.compileShader(B);if(!c.getShaderParameter(B,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(B));return null}return B}function h(g){switch(g){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;
|
||||
c.appendChild(E)}}}}else if(H instanceof THREE.RenderableFace3){o=H.v1;u=H.v2;v=H.v3;o.positionScreen.x*=n;o.positionScreen.y*=-B;u.positionScreen.x*=n;u.positionScreen.y*=-B;v.positionScreen.x*=n;v.positionScreen.y*=-B;t.addPoint(o.positionScreen.x,o.positionScreen.y);t.addPoint(u.positionScreen.x,u.positionScreen.y);t.addPoint(v.positionScreen.x,v.positionScreen.y);if(K.instersects(t)){R=0;for(U=H.meshMaterials.length;R<U;){S=H.meshMaterials[R++];if(S instanceof THREE.MeshFaceMaterial){ba=0;for(Y=
|
||||
H.faceMaterials.length;ba<Y;)(S=H.faceMaterials[ba++])&&b(o,u,v,H,S,V)}else S&&b(o,u,v,H,S,V)}}}else if(H instanceof THREE.RenderableFace4){o=H.v1;u=H.v2;v=H.v3;w=H.v4;o.positionScreen.x*=n;o.positionScreen.y*=-B;u.positionScreen.x*=n;u.positionScreen.y*=-B;v.positionScreen.x*=n;v.positionScreen.y*=-B;w.positionScreen.x*=n;w.positionScreen.y*=-B;t.addPoint(o.positionScreen.x,o.positionScreen.y);t.addPoint(u.positionScreen.x,u.positionScreen.y);t.addPoint(v.positionScreen.x,v.positionScreen.y);t.addPoint(w.positionScreen.x,
|
||||
w.positionScreen.y);if(K.instersects(t)){R=0;for(U=H.meshMaterials.length;R<U;){S=H.meshMaterials[R++];if(S instanceof THREE.MeshFaceMaterial){ba=0;for(Y=H.faceMaterials.length;ba<Y;)(S=H.faceMaterials[ba++])&&d(o,u,v,w,H,S,V)}else S&&d(o,u,v,w,H,S,V)}}}}}};
|
||||
THREE.WebGLRenderer=function(a){function b(h,p){h.fragment_shader=p.fragment_shader;h.vertex_shader=p.vertex_shader;h.uniforms=Uniforms.clone(p.uniforms)}function d(h,p){h.uniforms.color.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);h.uniforms.opacity.value=h.opacity;h.uniforms.map.texture=h.map;h.uniforms.env_map.texture=h.env_map;h.uniforms.reflectivity.value=h.reflectivity;h.uniforms.refraction_ratio.value=h.refraction_ratio;h.uniforms.combine.value=h.combine;h.uniforms.useRefract.value=
|
||||
h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping;if(p){h.uniforms.fogColor.value.setHex(p.color.hex);if(p instanceof THREE.Fog){h.uniforms.fogNear.value=p.near;h.uniforms.fogFar.value=p.far}else if(p instanceof THREE.FogExp2)h.uniforms.fogDensity.value=p.density}}function e(h,p){h.uniforms.color.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);h.uniforms.opacity.value=h.opacity;if(p){h.uniforms.fogColor.value.setHex(p.color.hex);if(p instanceof THREE.Fog){h.uniforms.fogNear.value=
|
||||
p.near;h.uniforms.fogFar.value=p.far}else if(p instanceof THREE.FogExp2)h.uniforms.fogDensity.value=p.density}}function g(h,p){var C;if(h=="fragment")C=c.createShader(c.FRAGMENT_SHADER);else if(h=="vertex")C=c.createShader(c.VERTEX_SHADER);c.shaderSource(C,p);c.compileShader(C);if(!c.getShaderParameter(C,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(C));return null}return C}function f(h){switch(h){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,k=null,l=null,n=new THREE.Matrix4,C,p=new Float32Array(16),x=new Float32Array(16),z=new Float32Array(16),u=new Float32Array(9),
|
||||
K=new Float32Array(16),t=true,L=new THREE.Color(0),m=0;if(a){if(a.antialias!==undefined)t=a.antialias;a.clearColor!==undefined&&L.setHex(a.clearColor);if(a.clearAlpha!==undefined)m=a.clearAlpha}this.domElement=j;this.autoClear=true;(function(g,o,B){try{c=j.getContext("experimental-webgl",{antialias:g})}catch(q){}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(o.r,o.g,o.b,B)})(t,L,m);this.context=c;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(g,o){j.width=g;j.height=o;c.viewport(0,0,j.width,j.height)};this.setClearColor=function(g,o){var B=new THREE.Color(g);c.clearColor(B.r,B.g,B.b,o)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=
|
||||
function(g,o){var B,q,A,N=0,v=0,D=0,G,E,y,I=this.lights,F=I.directional.colors,T=I.directional.positions,V=I.point.colors,P=I.point.positions,da=0,X=0;B=0;for(q=o.length;B<q;B++){A=o[B];G=A.color;E=A.position;y=A.intensity;if(A instanceof THREE.AmbientLight){N+=G.r;v+=G.g;D+=G.b}else if(A instanceof THREE.DirectionalLight){F[da*3]=G.r*y;F[da*3+1]=G.g*y;F[da*3+2]=G.b*y;T[da*3]=E.x;T[da*3+1]=E.y;T[da*3+2]=E.z;da+=1}else if(A instanceof THREE.PointLight){V[X*3]=G.r*y;V[X*3+1]=G.g*y;V[X*3+2]=G.b*y;P[X*
|
||||
3]=E.x;P[X*3+1]=E.y;P[X*3+2]=E.z;X+=1}}I.point.length=X;I.directional.length=da;I.ambient[0]=N;I.ambient[1]=v;I.ambient[2]=D};this.createParticleBuffers=function(g){g.__webGLVertexBuffer=c.createBuffer();g.__webGLFaceBuffer=c.createBuffer()};this.createLineBuffers=function(g){g.__webGLVertexBuffer=c.createBuffer();g.__webGLLineBuffer=c.createBuffer()};this.createMeshBuffers=function(g){g.__webGLVertexBuffer=c.createBuffer();g.__webGLNormalBuffer=c.createBuffer();g.__webGLTangentBuffer=c.createBuffer();
|
||||
g.__webGLUVBuffer=c.createBuffer();g.__webGLFaceBuffer=c.createBuffer();g.__webGLLineBuffer=c.createBuffer()};this.initLineBuffers=function(g){var o=g.vertices.length;g.__vertexArray=new Float32Array(o*3);g.__lineArray=new Uint16Array(o);g.__webGLLineCount=o};this.initMeshBuffers=function(g,o){var B,q,A=0,N=0,v=0,D=o.geometry.faces,G=g.faces;B=0;for(q=G.length;B<q;B++){fi=G[B];face=D[fi];if(face instanceof THREE.Face3){A+=3;N+=1;v+=3}else if(face instanceof THREE.Face4){A+=4;N+=2;v+=4}}g.__vertexArray=
|
||||
new Float32Array(A*3);g.__normalArray=new Float32Array(A*3);g.__tangentArray=new Float32Array(A*4);g.__uvArray=new Float32Array(A*2);g.__faceArray=new Uint16Array(N*3);g.__lineArray=new Uint16Array(v*2);A=false;B=0;for(q=o.materials.length;B<q;B++){D=o.materials[B];if(D instanceof THREE.MeshFaceMaterial){D=0;for(G=g.materials.length;D<G;D++)if(g.materials[D]&&g.materials[D].shading!=undefined&&g.materials[D].shading==THREE.SmoothShading){A=true;break}}else if(D&&D.shading!=undefined&&D.shading==THREE.SmoothShading){A=
|
||||
true;break}if(A)break}g.__needsSmoothNormals=A;g.__webGLFaceCount=N*3;g.__webGLLineCount=v*2};this.setMeshBuffers=function(g,o,B,q,A,N,v,D){var G,E,y,I,F,T,V,P,da,X=0,R=0,U=0,ba=0,Y=0,H=0,S=0,W=g.__vertexArray,ia=g.__uvArray,ha=g.__normalArray,w=g.__tangentArray,M=g.__faceArray,J=g.__lineArray,Z=g.__needsSmoothNormals,ca=o.geometry,ga=ca.vertices,ja=g.faces,qa=ca.faces,sa=ca.uvs;o=0;for(G=ja.length;o<G;o++){E=ja[o];y=qa[E];E=sa[E];I=y.vertexNormals;F=y.normal;if(y instanceof THREE.Face3){if(q){T=
|
||||
ga[y.a].position;V=ga[y.b].position;P=ga[y.c].position;W[R]=T.x;W[R+1]=T.y;W[R+2]=T.z;W[R+3]=V.x;W[R+4]=V.y;W[R+5]=V.z;W[R+6]=P.x;W[R+7]=P.y;W[R+8]=P.z;R+=9}if(D&&ca.hasTangents){T=ga[y.a].tangent;V=ga[y.b].tangent;P=ga[y.c].tangent;w[H]=T.x;w[H+1]=T.y;w[H+2]=T.z;w[H+3]=T.w;w[H+4]=V.x;w[H+5]=V.y;w[H+6]=V.z;w[H+7]=V.w;w[H+8]=P.x;w[H+9]=P.y;w[H+10]=P.z;w[H+11]=P.w;H+=12}if(v)if(I.length==3&&Z)for(y=0;y<3;y++){F=I[y];ha[Y]=F.x;ha[Y+1]=F.y;ha[Y+2]=F.z;Y+=3}else for(y=0;y<3;y++){ha[Y]=F.x;ha[Y+1]=F.y;
|
||||
ha[Y+2]=F.z;Y+=3}if(N&&E)for(y=0;y<3;y++){I=E[y];ia[U]=I.u;ia[U+1]=I.v;U+=2}if(A){M[ba]=X;M[ba+1]=X+1;M[ba+2]=X+2;ba+=3;J[S]=X;J[S+1]=X+1;J[S+2]=X;J[S+3]=X+2;J[S+4]=X+1;J[S+5]=X+2;S+=6;X+=3}}else if(y instanceof THREE.Face4){if(q){T=ga[y.a].position;V=ga[y.b].position;P=ga[y.c].position;da=ga[y.d].position;W[R]=T.x;W[R+1]=T.y;W[R+2]=T.z;W[R+3]=V.x;W[R+4]=V.y;W[R+5]=V.z;W[R+6]=P.x;W[R+7]=P.y;W[R+8]=P.z;W[R+9]=da.x;W[R+10]=da.y;W[R+11]=da.z;R+=12}if(D&&ca.hasTangents){T=ga[y.a].tangent;V=ga[y.b].tangent;
|
||||
P=ga[y.c].tangent;y=ga[y.d].tangent;w[H]=T.x;w[H+1]=T.y;w[H+2]=T.z;w[H+3]=T.w;w[H+4]=V.x;w[H+5]=V.y;w[H+6]=V.z;w[H+7]=V.w;w[H+8]=P.x;w[H+9]=P.y;w[H+10]=P.z;w[H+11]=P.w;w[H+12]=y.x;w[H+13]=y.y;w[H+14]=y.z;w[H+15]=y.w;H+=16}if(v)if(I.length==4&&Z)for(y=0;y<4;y++){F=I[y];ha[Y]=F.x;ha[Y+1]=F.y;ha[Y+2]=F.z;Y+=3}else for(y=0;y<4;y++){ha[Y]=F.x;ha[Y+1]=F.y;ha[Y+2]=F.z;Y+=3}if(N&&E)for(y=0;y<4;y++){I=E[y];ia[U]=I.u;ia[U+1]=I.v;U+=2}if(A){M[ba]=X;M[ba+1]=X+1;M[ba+2]=X+2;M[ba+3]=X;M[ba+4]=X+2;M[ba+5]=X+3;ba+=
|
||||
6;J[S]=X;J[S+1]=X+1;J[S+2]=X;J[S+3]=X+3;J[S+4]=X+1;J[S+5]=X+2;J[S+6]=X+2;J[S+7]=X+3;S+=8;X+=4}}}if(q){c.bindBuffer(c.ARRAY_BUFFER,g.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,W,B)}if(v){c.bindBuffer(c.ARRAY_BUFFER,g.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,ha,B)}if(D&&ca.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,g.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,w,B)}if(N&&U>0){c.bindBuffer(c.ARRAY_BUFFER,g.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,ia,B)}if(A){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
|
||||
g.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,M,B);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,J,B)}};this.setLineBuffers=function(g,o,B,q){var A,N,v=g.vertices,D=v.length,G=g.__vertexArray,E=g.__lineArray;if(B)for(B=0;B<D;B++){A=v[B].position;N=B*3;G[N]=A.x;G[N+1]=A.y;G[N+2]=A.z}if(q)for(B=0;B<D;B++)E[B]=B;c.bindBuffer(c.ARRAY_BUFFER,g.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,G,o);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);
|
||||
c.bufferData(c.ELEMENT_ARRAY_BUFFER,E,o)};this.setParticleBuffers=function(){};this.renderBuffer=function(g,o,B,q,A,N){var v,D,G,E;if(!q.program){if(q instanceof THREE.MeshDepthMaterial){b(q,THREE.ShaderLib.depth);q.uniforms.mNear.value=g.near;q.uniforms.mFar.value=g.far}else if(q instanceof THREE.MeshNormalMaterial)b(q,THREE.ShaderLib.normal);else if(q instanceof THREE.MeshBasicMaterial){b(q,THREE.ShaderLib.basic);d(q,B)}else if(q instanceof THREE.MeshLambertMaterial){b(q,THREE.ShaderLib.lambert);
|
||||
d(q,B)}else if(q instanceof THREE.MeshPhongMaterial){b(q,THREE.ShaderLib.phong);d(q,B)}else if(q instanceof THREE.LineBasicMaterial){b(q,THREE.ShaderLib.basic);e(q,B)}var y,I,F;y=E=D=0;for(I=o.length;y<I;y++){F=o[y];F instanceof THREE.DirectionalLight&&E++;F instanceof THREE.PointLight&&D++}if(D+E<=4){y=E;D=D}else{y=Math.ceil(4*E/(D+E));D=4-y}D={directional:y,point:D};E={fog:B,map:q.map,env_map:q.env_map,maxDirLights:D.directional,maxPointLights:D.point};D=q.fragment_shader;y=q.vertex_shader;I=c.createProgram();
|
||||
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,k=null,l=null,n=new THREE.Matrix4,B,o=new Float32Array(16),u=new Float32Array(16),v=new Float32Array(16),w=new Float32Array(9),
|
||||
K=new Float32Array(16),t=true,L=new THREE.Color(0),m=0;if(a){if(a.antialias!==undefined)t=a.antialias;a.clearColor!==undefined&&L.setHex(a.clearColor);if(a.clearAlpha!==undefined)m=a.clearAlpha}this.domElement=j;this.autoClear=true;(function(h,p,C){try{c=j.getContext("experimental-webgl",{antialias:h})}catch(q){}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(p.r,p.g,p.b,C)})(t,L,m);this.context=c;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(h,p){j.width=h;j.height=p;c.viewport(0,0,j.width,j.height)};this.setClearColor=function(h,p){var C=new THREE.Color(h);c.clearColor(C.r,C.g,C.b,p)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=
|
||||
function(h,p){var C,q,A,N=0,x=0,D=0,G,E,z,I=this.lights,F=I.directional.colors,T=I.directional.positions,V=I.point.colors,P=I.point.positions,da=0,X=0;C=0;for(q=p.length;C<q;C++){A=p[C];G=A.color;E=A.position;z=A.intensity;if(A instanceof THREE.AmbientLight){N+=G.r;x+=G.g;D+=G.b}else if(A instanceof THREE.DirectionalLight){F[da*3]=G.r*z;F[da*3+1]=G.g*z;F[da*3+2]=G.b*z;T[da*3]=E.x;T[da*3+1]=E.y;T[da*3+2]=E.z;da+=1}else if(A instanceof THREE.PointLight){V[X*3]=G.r*z;V[X*3+1]=G.g*z;V[X*3+2]=G.b*z;P[X*
|
||||
3]=E.x;P[X*3+1]=E.y;P[X*3+2]=E.z;X+=1}}I.point.length=X;I.directional.length=da;I.ambient[0]=N;I.ambient[1]=x;I.ambient[2]=D};this.createParticleBuffers=function(h){h.__webGLVertexBuffer=c.createBuffer();h.__webGLFaceBuffer=c.createBuffer()};this.createLineBuffers=function(h){h.__webGLVertexBuffer=c.createBuffer();h.__webGLLineBuffer=c.createBuffer()};this.createMeshBuffers=function(h){h.__webGLVertexBuffer=c.createBuffer();h.__webGLNormalBuffer=c.createBuffer();h.__webGLTangentBuffer=c.createBuffer();
|
||||
h.__webGLUVBuffer=c.createBuffer();h.__webGLFaceBuffer=c.createBuffer();h.__webGLLineBuffer=c.createBuffer()};this.initLineBuffers=function(h){var p=h.vertices.length;h.__vertexArray=new Float32Array(p*3);h.__lineArray=new Uint16Array(p);h.__webGLLineCount=p};this.initMeshBuffers=function(h,p){var C,q,A=0,N=0,x=0,D=p.geometry.faces,G=h.faces;C=0;for(q=G.length;C<q;C++){fi=G[C];face=D[fi];if(face instanceof THREE.Face3){A+=3;N+=1;x+=3}else if(face instanceof THREE.Face4){A+=4;N+=2;x+=4}}h.__vertexArray=
|
||||
new Float32Array(A*3);h.__normalArray=new Float32Array(A*3);h.__tangentArray=new Float32Array(A*4);h.__uvArray=new Float32Array(A*2);h.__faceArray=new Uint16Array(N*3);h.__lineArray=new Uint16Array(x*2);A=false;C=0;for(q=p.materials.length;C<q;C++){D=p.materials[C];if(D instanceof THREE.MeshFaceMaterial){D=0;for(G=h.materials.length;D<G;D++)if(h.materials[D]&&h.materials[D].shading!=undefined&&h.materials[D].shading==THREE.SmoothShading){A=true;break}}else if(D&&D.shading!=undefined&&D.shading==THREE.SmoothShading){A=
|
||||
true;break}if(A)break}h.__needsSmoothNormals=A;h.__webGLFaceCount=N*3;h.__webGLLineCount=x*2};this.setMeshBuffers=function(h,p,C,q,A,N,x,D){var G,E,z,I,F,T,V,P,da,X=0,R=0,U=0,ba=0,Y=0,H=0,S=0,W=h.__vertexArray,ia=h.__uvArray,ha=h.__normalArray,y=h.__tangentArray,M=h.__faceArray,J=h.__lineArray,Z=h.__needsSmoothNormals,ca=p.geometry,ga=ca.vertices,ja=h.faces,qa=ca.faces,sa=ca.uvs;p=0;for(G=ja.length;p<G;p++){E=ja[p];z=qa[E];E=sa[E];I=z.vertexNormals;F=z.normal;if(z instanceof THREE.Face3){if(q){T=
|
||||
ga[z.a].position;V=ga[z.b].position;P=ga[z.c].position;W[R]=T.x;W[R+1]=T.y;W[R+2]=T.z;W[R+3]=V.x;W[R+4]=V.y;W[R+5]=V.z;W[R+6]=P.x;W[R+7]=P.y;W[R+8]=P.z;R+=9}if(D&&ca.hasTangents){T=ga[z.a].tangent;V=ga[z.b].tangent;P=ga[z.c].tangent;y[H]=T.x;y[H+1]=T.y;y[H+2]=T.z;y[H+3]=T.w;y[H+4]=V.x;y[H+5]=V.y;y[H+6]=V.z;y[H+7]=V.w;y[H+8]=P.x;y[H+9]=P.y;y[H+10]=P.z;y[H+11]=P.w;H+=12}if(x)if(I.length==3&&Z)for(z=0;z<3;z++){F=I[z];ha[Y]=F.x;ha[Y+1]=F.y;ha[Y+2]=F.z;Y+=3}else for(z=0;z<3;z++){ha[Y]=F.x;ha[Y+1]=F.y;
|
||||
ha[Y+2]=F.z;Y+=3}if(N&&E)for(z=0;z<3;z++){I=E[z];ia[U]=I.u;ia[U+1]=I.v;U+=2}if(A){M[ba]=X;M[ba+1]=X+1;M[ba+2]=X+2;ba+=3;J[S]=X;J[S+1]=X+1;J[S+2]=X;J[S+3]=X+2;J[S+4]=X+1;J[S+5]=X+2;S+=6;X+=3}}else if(z instanceof THREE.Face4){if(q){T=ga[z.a].position;V=ga[z.b].position;P=ga[z.c].position;da=ga[z.d].position;W[R]=T.x;W[R+1]=T.y;W[R+2]=T.z;W[R+3]=V.x;W[R+4]=V.y;W[R+5]=V.z;W[R+6]=P.x;W[R+7]=P.y;W[R+8]=P.z;W[R+9]=da.x;W[R+10]=da.y;W[R+11]=da.z;R+=12}if(D&&ca.hasTangents){T=ga[z.a].tangent;V=ga[z.b].tangent;
|
||||
P=ga[z.c].tangent;z=ga[z.d].tangent;y[H]=T.x;y[H+1]=T.y;y[H+2]=T.z;y[H+3]=T.w;y[H+4]=V.x;y[H+5]=V.y;y[H+6]=V.z;y[H+7]=V.w;y[H+8]=P.x;y[H+9]=P.y;y[H+10]=P.z;y[H+11]=P.w;y[H+12]=z.x;y[H+13]=z.y;y[H+14]=z.z;y[H+15]=z.w;H+=16}if(x)if(I.length==4&&Z)for(z=0;z<4;z++){F=I[z];ha[Y]=F.x;ha[Y+1]=F.y;ha[Y+2]=F.z;Y+=3}else for(z=0;z<4;z++){ha[Y]=F.x;ha[Y+1]=F.y;ha[Y+2]=F.z;Y+=3}if(N&&E)for(z=0;z<4;z++){I=E[z];ia[U]=I.u;ia[U+1]=I.v;U+=2}if(A){M[ba]=X;M[ba+1]=X+1;M[ba+2]=X+2;M[ba+3]=X;M[ba+4]=X+2;M[ba+5]=X+3;ba+=
|
||||
6;J[S]=X;J[S+1]=X+1;J[S+2]=X;J[S+3]=X+3;J[S+4]=X+1;J[S+5]=X+2;J[S+6]=X+2;J[S+7]=X+3;S+=8;X+=4}}}if(q){c.bindBuffer(c.ARRAY_BUFFER,h.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,W,C)}if(x){c.bindBuffer(c.ARRAY_BUFFER,h.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,ha,C)}if(D&&ca.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,h.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,y,C)}if(N&&U>0){c.bindBuffer(c.ARRAY_BUFFER,h.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,ia,C)}if(A){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
|
||||
h.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,M,C);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,J,C)}};this.setLineBuffers=function(h,p,C,q){var A,N,x=h.vertices,D=x.length,G=h.__vertexArray,E=h.__lineArray;if(C)for(C=0;C<D;C++){A=x[C].position;N=C*3;G[N]=A.x;G[N+1]=A.y;G[N+2]=A.z}if(q)for(C=0;C<D;C++)E[C]=C;c.bindBuffer(c.ARRAY_BUFFER,h.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,G,p);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webGLLineBuffer);
|
||||
c.bufferData(c.ELEMENT_ARRAY_BUFFER,E,p)};this.setParticleBuffers=function(){};this.renderBuffer=function(h,p,C,q,A,N){var x,D,G,E;if(!q.program){if(q instanceof THREE.MeshDepthMaterial){b(q,THREE.ShaderLib.depth);q.uniforms.mNear.value=h.near;q.uniforms.mFar.value=h.far}else if(q instanceof THREE.MeshNormalMaterial)b(q,THREE.ShaderLib.normal);else if(q instanceof THREE.MeshBasicMaterial){b(q,THREE.ShaderLib.basic);d(q,C)}else if(q instanceof THREE.MeshLambertMaterial){b(q,THREE.ShaderLib.lambert);
|
||||
d(q,C)}else if(q instanceof THREE.MeshPhongMaterial){b(q,THREE.ShaderLib.phong);d(q,C)}else if(q instanceof THREE.LineBasicMaterial){b(q,THREE.ShaderLib.basic);e(q,C)}var z,I,F;z=E=D=0;for(I=p.length;z<I;z++){F=p[z];F instanceof THREE.DirectionalLight&&E++;F instanceof THREE.PointLight&&D++}if(D+E<=4){z=E;D=D}else{z=Math.ceil(4*E/(D+E));D=4-z}D={directional:z,point:D};E={fog:C,map:q.map,env_map:q.env_map,maxDirLights:D.directional,maxPointLights:D.point};D=q.fragment_shader;z=q.vertex_shader;I=c.createProgram();
|
||||
F=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+E.maxDirLights,"#define MAX_POINT_LIGHTS "+E.maxPointLights,E.fog?"#define USE_FOG":"",E.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",E.map?"#define USE_MAP":"",E.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");E=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+E.maxDirLights,"#define MAX_POINT_LIGHTS "+E.maxPointLights,
|
||||
E.map?"#define USE_MAP":"",E.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(I,f("fragment",F+D));c.attachShader(I,f("vertex",E+y));c.linkProgram(I);c.getProgramParameter(I,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+
|
||||
c.getProgramParameter(I,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");I.uniforms={};I.attributes={};q.program=I;D=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(v in q.uniforms)D.push(v);v=q.program;y=0;for(I=D.length;y<I;y++){F=D[y];v.uniforms[F]=c.getUniformLocation(v,F)}v=q.program;D=["position","normal","uv","tangent"];y=0;for(I=D.length;y<I;y++){F=D[y];v.attributes[F]=c.getAttribLocation(v,F)}}v=q.program;if(v!=k){c.useProgram(v);
|
||||
k=v}this.loadCamera(v,g);this.loadMatrices(v);if(q instanceof THREE.MeshPhongMaterial||q instanceof THREE.MeshLambertMaterial){this.setupLights(v,o);g=this.lights;q.uniforms.enableLighting.value=g.directional.length+g.point.length;q.uniforms.ambientLightColor.value=g.ambient;q.uniforms.directionalLightColor.value=g.directional.colors;q.uniforms.directionalLightDirection.value=g.directional.positions;q.uniforms.pointLightColor.value=g.point.colors;q.uniforms.pointLightPosition.value=g.point.positions}if(q instanceof
|
||||
THREE.MeshBasicMaterial||q instanceof THREE.MeshLambertMaterial||q instanceof THREE.MeshPhongMaterial)d(q,B);q instanceof THREE.LineBasicMaterial&&e(q,B);if(q instanceof THREE.MeshPhongMaterial){q.uniforms.ambient.value.setRGB(q.ambient.r,q.ambient.g,q.ambient.b);q.uniforms.specular.value.setRGB(q.specular.r,q.specular.g,q.specular.b);q.uniforms.shininess.value=q.shininess}B=q.uniforms;for(G in B)if(y=v.uniforms[G]){o=B[G];D=o.type;g=o.value;if(D=="i")c.uniform1i(y,g);else if(D=="f")c.uniform1f(y,
|
||||
g);else if(D=="fv1")c.uniform1fv(y,g);else if(D=="fv")c.uniform3fv(y,g);else if(D=="v2")c.uniform2f(y,g.x,g.y);else if(D=="v3")c.uniform3f(y,g.x,g.y,g.z);else if(D=="c")c.uniform3f(y,g.r,g.g,g.b);else if(D=="t"){c.uniform1i(y,g);if(o=o.texture)if(o.image instanceof Array&&o.image.length==6){o=o;g=g;if(o.image.length==6){if(!o.image.__webGLTextureCube&&!o.image.__cubeMapInitialized&&o.image.loadCount==6){o.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,o.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(D=0;D<6;++D)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,o.image[D]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);o.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+
|
||||
g);c.bindTexture(c.TEXTURE_CUBE_MAP,o.image.__webGLTextureCube)}}else{o=o;g=g;if(!o.__webGLTexture&&o.image.loaded){o.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,o.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,o.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,h(o.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,h(o.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(o.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,h(o.min_filter));
|
||||
c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+g);c.bindTexture(c.TEXTURE_2D,o.__webGLTexture)}}}G=v.attributes;c.bindBuffer(c.ARRAY_BUFFER,A.__webGLVertexBuffer);c.vertexAttribPointer(G.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(G.position);if(G.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,A.__webGLNormalBuffer);c.vertexAttribPointer(G.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(G.normal)}if(G.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,A.__webGLTangentBuffer);
|
||||
E.map?"#define USE_MAP":"",E.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(I,g("fragment",F+D));c.attachShader(I,g("vertex",E+z));c.linkProgram(I);c.getProgramParameter(I,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+
|
||||
c.getProgramParameter(I,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");I.uniforms={};I.attributes={};q.program=I;D=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(x in q.uniforms)D.push(x);x=q.program;z=0;for(I=D.length;z<I;z++){F=D[z];x.uniforms[F]=c.getUniformLocation(x,F)}x=q.program;D=["position","normal","uv","tangent"];z=0;for(I=D.length;z<I;z++){F=D[z];x.attributes[F]=c.getAttribLocation(x,F)}}x=q.program;if(x!=k){c.useProgram(x);
|
||||
k=x}this.loadCamera(x,h);this.loadMatrices(x);if(q instanceof THREE.MeshPhongMaterial||q instanceof THREE.MeshLambertMaterial){this.setupLights(x,p);h=this.lights;q.uniforms.enableLighting.value=h.directional.length+h.point.length;q.uniforms.ambientLightColor.value=h.ambient;q.uniforms.directionalLightColor.value=h.directional.colors;q.uniforms.directionalLightDirection.value=h.directional.positions;q.uniforms.pointLightColor.value=h.point.colors;q.uniforms.pointLightPosition.value=h.point.positions}if(q instanceof
|
||||
THREE.MeshBasicMaterial||q instanceof THREE.MeshLambertMaterial||q instanceof THREE.MeshPhongMaterial)d(q,C);q instanceof THREE.LineBasicMaterial&&e(q,C);if(q instanceof THREE.MeshPhongMaterial){q.uniforms.ambient.value.setRGB(q.ambient.r,q.ambient.g,q.ambient.b);q.uniforms.specular.value.setRGB(q.specular.r,q.specular.g,q.specular.b);q.uniforms.shininess.value=q.shininess}C=q.uniforms;for(G in C)if(z=x.uniforms[G]){p=C[G];D=p.type;h=p.value;if(D=="i")c.uniform1i(z,h);else if(D=="f")c.uniform1f(z,
|
||||
h);else if(D=="fv1")c.uniform1fv(z,h);else if(D=="fv")c.uniform3fv(z,h);else if(D=="v2")c.uniform2f(z,h.x,h.y);else if(D=="v3")c.uniform3f(z,h.x,h.y,h.z);else if(D=="c")c.uniform3f(z,h.r,h.g,h.b);else if(D=="t"){c.uniform1i(z,h);if(p=p.texture)if(p.image instanceof Array&&p.image.length==6){p=p;h=h;if(p.image.length==6){if(!p.image.__webGLTextureCube&&!p.image.__cubeMapInitialized&&p.image.loadCount==6){p.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,p.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(D=0;D<6;++D)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,p.image[D]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);p.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+
|
||||
h);c.bindTexture(c.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube)}}else{p=p;h=h;if(!p.__webGLTexture&&p.image.loaded){p.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,p.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,p.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,f(p.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,f(p.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,f(p.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,f(p.min_filter));
|
||||
c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+h);c.bindTexture(c.TEXTURE_2D,p.__webGLTexture)}}}G=x.attributes;c.bindBuffer(c.ARRAY_BUFFER,A.__webGLVertexBuffer);c.vertexAttribPointer(G.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(G.position);if(G.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,A.__webGLNormalBuffer);c.vertexAttribPointer(G.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(G.normal)}if(G.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,A.__webGLTangentBuffer);
|
||||
c.vertexAttribPointer(G.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(G.tangent)}if(G.uv>=0)if(A.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,A.__webGLUVBuffer);c.vertexAttribPointer(G.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(G.uv)}else c.disableVertexAttribArray(G.uv);if(q.wireframe||q instanceof THREE.LineBasicMaterial){G=q.wireframe_linewidth!==undefined?q.wireframe_linewidth:q.linewidth!==undefined?q.linewidth:1;q=q instanceof THREE.LineBasicMaterial&&N.type==THREE.LineStrip?
|
||||
c.LINE_STRIP:c.LINES;c.lineWidth(G);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.__webGLLineBuffer);c.drawElements(q,A.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,A.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(g,o,B,q,A,N,v){var D,G,E,y,I;E=0;for(y=q.materials.length;E<y;E++){D=q.materials[E];if(D instanceof THREE.MeshFaceMaterial){D=0;for(G=A.materials.length;D<G;D++)if((I=A.materials[D])&&I.blending==N&&
|
||||
I.opacity<1==v){this.setBlending(I.blending);this.renderBuffer(g,o,B,I,A,q)}}else if((I=D)&&I.blending==N&&I.opacity<1==v){this.setBlending(I.blending);this.renderBuffer(g,o,B,I,A,q)}}};this.render=function(g,o,B,q){var A,N,v,D=g.lights,G=g.fog;this.initWebGLObjects(g);q=q!==undefined?q:true;if(B&&!B.__webGLFramebuffer){B.__webGLFramebuffer=c.createFramebuffer();B.__webGLRenderbuffer=c.createRenderbuffer();B.__webGLTexture=c.createTexture();c.bindRenderbuffer(c.RENDERBUFFER,B.__webGLRenderbuffer);
|
||||
c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,B.width,B.height);c.bindTexture(c.TEXTURE_2D,B.__webGLTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,h(B.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,h(B.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(B.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,h(B.min_filter));c.texImage2D(c.TEXTURE_2D,0,h(B.format),B.width,B.height,0,h(B.format),h(B.type),null);c.bindFramebuffer(c.FRAMEBUFFER,B.__webGLFramebuffer);
|
||||
c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,B.__webGLTexture,0);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,B.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}if(B){A=B.__webGLFramebuffer;v=B.width;N=B.height}else{A=null;v=j.width;N=j.height}if(A!=l){c.bindFramebuffer(c.FRAMEBUFFER,A);c.viewport(0,0,v,N);q&&c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT);l=A}this.autoClear&&
|
||||
this.clear();o.autoUpdateMatrix&&o.updateMatrix();p.set(o.matrix.flatten());z.set(o.projectionMatrix.flatten());q=0;for(A=g.__webGLObjects.length;q<A;q++){N=g.__webGLObjects[q];v=N.object;N=N.buffer;if(v.visible){this.setupMatrices(v,o);this.renderPass(o,D,G,v,N,THREE.NormalBlending,false)}}q=0;for(A=g.__webGLObjects.length;q<A;q++){N=g.__webGLObjects[q];v=N.object;N=N.buffer;if(v.visible){this.setupMatrices(v,o);if(v.doubleSided)c.disable(c.CULL_FACE);else{c.enable(c.CULL_FACE);v.flipSided?c.frontFace(c.CW):
|
||||
c.frontFace(c.CCW)}this.renderPass(o,D,G,v,N,THREE.AdditiveBlending,false);this.renderPass(o,D,G,v,N,THREE.SubtractiveBlending,false);this.renderPass(o,D,G,v,N,THREE.AdditiveBlending,true);this.renderPass(o,D,G,v,N,THREE.SubtractiveBlending,true);this.renderPass(o,D,G,v,N,THREE.NormalBlending,true)}}if(B&&B.min_filter!==THREE.NearestFilter&&B.min_filter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,B.__webGLTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}};this.initWebGLObjects=
|
||||
function(g){function o(E,y,I,F){if(E[y]==undefined){g.__webGLObjects.push({buffer:I,object:F});E[y]=1}}var B,q,A,N,v,D,G;if(!g.__webGLObjects){g.__webGLObjects=[];g.__webGLObjectsMap={}}B=0;for(q=g.objects.length;B<q;B++){A=g.objects[B];v=A.geometry;if(g.__webGLObjectsMap[A.id]==undefined)g.__webGLObjectsMap[A.id]={};G=g.__webGLObjectsMap[A.id];if(A instanceof THREE.Mesh){for(N in v.geometryChunks){D=v.geometryChunks[N];if(!D.__webGLVertexBuffer){this.createMeshBuffers(D);this.initMeshBuffers(D,A);
|
||||
v.__dirtyVertices=true;v.__dirtyElements=true;v.__dirtyUvs=true;v.__dirtyNormals=true;v.__dirtyTangents=true}if(v.__dirtyVertices||v.__dirtyElements||v.__dirtyUvs)this.setMeshBuffers(D,A,c.DYNAMIC_DRAW,v.__dirtyVertices,v.__dirtyElements,v.__dirtyUvs,v.__dirtyNormals,v.__dirtyTangents);o(G,N,D,A)}v.__dirtyVertices=false;v.__dirtyElements=false;v.__dirtyUvs=false;v.__dirtyNormals=false;v.__dirtyTangents=false}else if(A instanceof THREE.Line){if(!v.__webGLVertexBuffer){this.createLineBuffers(v);this.initLineBuffers(v);
|
||||
v.__dirtyVertices=true;v.__dirtyElements=true}v.__dirtyVertices&&this.setLineBuffers(v,c.DYNAMIC_DRAW,v.__dirtyVertices,v.__dirtyElements);o(G,0,v,A);v.__dirtyVertices=false;v.__dirtyElements=false}else if(A instanceof THREE.ParticleSystem){v.__webGLVertexBuffer||this.createParticleBuffers(v);o(G,0,v,A)}}};this.removeObject=function(g,o){var B,q;for(B=g.__webGLObjects.length-1;B>=0;B--){q=g.__webGLObjects[B].object;o==q&&g.__webGLObjects.splice(B,1)}};this.setupMatrices=function(g,o){g.autoUpdateMatrix&&
|
||||
g.updateMatrix();n.multiply(o.matrix,g.matrix);x.set(n.flatten());C=THREE.Matrix4.makeInvert3x3(n).transpose();u.set(C.m);K.set(g.matrix.flatten())};this.loadMatrices=function(g){c.uniformMatrix4fv(g.uniforms.viewMatrix,false,p);c.uniformMatrix4fv(g.uniforms.modelViewMatrix,false,x);c.uniformMatrix4fv(g.uniforms.projectionMatrix,false,z);c.uniformMatrix3fv(g.uniforms.normalMatrix,false,u);c.uniformMatrix4fv(g.uniforms.objectMatrix,false,K)};this.loadCamera=function(g,o){c.uniform3f(g.uniforms.cameraPosition,
|
||||
o.position.x,o.position.y,o.position.z)};this.setBlending=function(g){switch(g){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(g,o){if(g){!o||o=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(g=="back")c.cullFace(c.BACK);else g=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);
|
||||
c.LINE_STRIP:c.LINES;c.lineWidth(G);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.__webGLLineBuffer);c.drawElements(q,A.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,A.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(h,p,C,q,A,N,x){var D,G,E,z,I;E=0;for(z=q.materials.length;E<z;E++){D=q.materials[E];if(D instanceof THREE.MeshFaceMaterial){D=0;for(G=A.materials.length;D<G;D++)if((I=A.materials[D])&&I.blending==N&&
|
||||
I.opacity<1==x){this.setBlending(I.blending);this.renderBuffer(h,p,C,I,A,q)}}else if((I=D)&&I.blending==N&&I.opacity<1==x){this.setBlending(I.blending);this.renderBuffer(h,p,C,I,A,q)}}};this.render=function(h,p,C,q){var A,N,x,D=h.lights,G=h.fog;this.initWebGLObjects(h);q=q!==undefined?q:true;if(C&&!C.__webGLFramebuffer){C.__webGLFramebuffer=c.createFramebuffer();C.__webGLRenderbuffer=c.createRenderbuffer();C.__webGLTexture=c.createTexture();c.bindRenderbuffer(c.RENDERBUFFER,C.__webGLRenderbuffer);
|
||||
c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,C.width,C.height);c.bindTexture(c.TEXTURE_2D,C.__webGLTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,f(C.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,f(C.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,f(C.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,f(C.min_filter));c.texImage2D(c.TEXTURE_2D,0,f(C.format),C.width,C.height,0,f(C.format),f(C.type),null);c.bindFramebuffer(c.FRAMEBUFFER,C.__webGLFramebuffer);
|
||||
c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,C.__webGLTexture,0);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,C.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}if(C){A=C.__webGLFramebuffer;x=C.width;N=C.height}else{A=null;x=j.width;N=j.height}if(A!=l){c.bindFramebuffer(c.FRAMEBUFFER,A);c.viewport(0,0,x,N);q&&c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT);l=A}this.autoClear&&
|
||||
this.clear();p.autoUpdateMatrix&&p.updateMatrix();o.set(p.matrix.flatten());v.set(p.projectionMatrix.flatten());q=0;for(A=h.__webGLObjects.length;q<A;q++){N=h.__webGLObjects[q];x=N.object;N=N.buffer;if(x.visible){this.setupMatrices(x,p);this.renderPass(p,D,G,x,N,THREE.NormalBlending,false)}}q=0;for(A=h.__webGLObjects.length;q<A;q++){N=h.__webGLObjects[q];x=N.object;N=N.buffer;if(x.visible){this.setupMatrices(x,p);if(x.doubleSided)c.disable(c.CULL_FACE);else{c.enable(c.CULL_FACE);x.flipSided?c.frontFace(c.CW):
|
||||
c.frontFace(c.CCW)}this.renderPass(p,D,G,x,N,THREE.AdditiveBlending,false);this.renderPass(p,D,G,x,N,THREE.SubtractiveBlending,false);this.renderPass(p,D,G,x,N,THREE.AdditiveBlending,true);this.renderPass(p,D,G,x,N,THREE.SubtractiveBlending,true);this.renderPass(p,D,G,x,N,THREE.NormalBlending,true)}}if(C&&C.min_filter!==THREE.NearestFilter&&C.min_filter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,C.__webGLTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}};this.initWebGLObjects=
|
||||
function(h){function p(E,z,I,F){if(E[z]==undefined){h.__webGLObjects.push({buffer:I,object:F});E[z]=1}}var C,q,A,N,x,D,G;if(!h.__webGLObjects){h.__webGLObjects=[];h.__webGLObjectsMap={}}C=0;for(q=h.objects.length;C<q;C++){A=h.objects[C];x=A.geometry;if(h.__webGLObjectsMap[A.id]==undefined)h.__webGLObjectsMap[A.id]={};G=h.__webGLObjectsMap[A.id];if(A instanceof THREE.Mesh){for(N in x.geometryChunks){D=x.geometryChunks[N];if(!D.__webGLVertexBuffer){this.createMeshBuffers(D);this.initMeshBuffers(D,A);
|
||||
x.__dirtyVertices=true;x.__dirtyElements=true;x.__dirtyUvs=true;x.__dirtyNormals=true;x.__dirtyTangents=true}if(x.__dirtyVertices||x.__dirtyElements||x.__dirtyUvs)this.setMeshBuffers(D,A,c.DYNAMIC_DRAW,x.__dirtyVertices,x.__dirtyElements,x.__dirtyUvs,x.__dirtyNormals,x.__dirtyTangents);p(G,N,D,A)}x.__dirtyVertices=false;x.__dirtyElements=false;x.__dirtyUvs=false;x.__dirtyNormals=false;x.__dirtyTangents=false}else if(A instanceof THREE.Line){if(!x.__webGLVertexBuffer){this.createLineBuffers(x);this.initLineBuffers(x);
|
||||
x.__dirtyVertices=true;x.__dirtyElements=true}x.__dirtyVertices&&this.setLineBuffers(x,c.DYNAMIC_DRAW,x.__dirtyVertices,x.__dirtyElements);p(G,0,x,A);x.__dirtyVertices=false;x.__dirtyElements=false}else if(A instanceof THREE.ParticleSystem){x.__webGLVertexBuffer||this.createParticleBuffers(x);p(G,0,x,A)}}};this.removeObject=function(h,p){var C,q;for(C=h.__webGLObjects.length-1;C>=0;C--){q=h.__webGLObjects[C].object;p==q&&h.__webGLObjects.splice(C,1)}};this.setupMatrices=function(h,p){h.autoUpdateMatrix&&
|
||||
h.updateMatrix();n.multiply(p.matrix,h.matrix);u.set(n.flatten());B=THREE.Matrix4.makeInvert3x3(n).transpose();w.set(B.m);K.set(h.matrix.flatten())};this.loadMatrices=function(h){c.uniformMatrix4fv(h.uniforms.viewMatrix,false,o);c.uniformMatrix4fv(h.uniforms.modelViewMatrix,false,u);c.uniformMatrix4fv(h.uniforms.projectionMatrix,false,v);c.uniformMatrix3fv(h.uniforms.normalMatrix,false,w);c.uniformMatrix4fv(h.uniforms.objectMatrix,false,K)};this.loadCamera=function(h,p){c.uniform3f(h.uniforms.cameraPosition,
|
||||
p.position.x,p.position.y,p.position.z)};this.setBlending=function(h){switch(h){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(h,p){if(h){!p||p=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(h=="back")c.cullFace(c.BACK);else h=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);
|
||||
c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
|
||||
THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
|
||||
envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
|
||||
@@ -201,58 +201,62 @@ 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,f=d?b.geometry:b,h=a.vertices,j=f.vertices,c=a.faces,k=f.faces,l=a.uvs;f=f.uvs;d&&b.autoUpdateMatrix&&b.updateMatrix();for(var n=0,C=j.length;n<C;n++){var p=new THREE.Vertex(j[n].position.clone());d&&b.matrix.multiplyVector3(p.position);h.push(p)}n=0;for(C=k.length;n<C;n++){j=k[n];var x,z=j.vertexNormals;if(j instanceof THREE.Face3)x=new THREE.Face3(j.a+e,j.b+e,j.c+e);else if(j instanceof THREE.Face4)x=new THREE.Face4(j.a+
|
||||
e,j.b+e,j.c+e,j.d+e);x.centroid.copy(j.centroid);x.normal.copy(j.normal);d=0;for(h=z.length;d<h;d++){p=z[d];x.vertexNormals.push(p.clone())}x.materials=j.materials.slice();c.push(x)}n=0;for(C=f.length;n<C;n++){e=f[n];c=[];d=0;for(h=e.length;d<h;d++)c.push(new THREE.UV(e[d].u,e[d].v));l.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={loadScene:function(a,b,d){var e,f,h,j,c,k,l,n,C,p,x,z,u,K,t,L,m,g,o,B,q,A,N,v,D;a=new Worker(a);D=new THREE.Loader;a.onmessage=function(G){function E(){for(h in I.objects)if(!F.objects[h]){C=I.objects[h];if(g=F.geometries[C.geometry]){v=[];for(i=0;i<C.materials.length;i++)v[i]=F.materials[C.materials[i]];z=C.position;r=C.rotation;s=C.scale;object=new THREE.Mesh(g,v);object.position.set(z[0],
|
||||
z[1],z[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=C.visible;F.scene.addObject(object);F.objects[h]=object}}}function y(V){return function(P){F.geometries[V]=P;E();T-=1;T==0&&d(F)}}var I=G.data,F={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}},T=0;for(e in I.geometries){n=I.geometries[e];if(n.type=="bin_mesh"||n.type=="ascii_mesh")T+=1}for(e in I.geometries){n=I.geometries[e];if(n.type=="cube"){g=new Cube(n.width,
|
||||
n.height,n.depth,n.segments_width,n.segments_height,null,n.flipped,n.sides);F.geometries[e]=g}else if(n.type=="plane"){g=new Plane(n.width,n.height,n.segments_width,n.segments_height);F.geometries[e]=g}else if(n.type=="sphere"){g=new Sphere(n.radius,n.segments_width,n.segments_height);F.geometries[e]=g}else if(n.type=="cylinder"){g=new Cylinder(n.numSegs,n.topRad,n.botRad,n.height,n.topOffset,n.botOffset);F.geometries[e]=g}else if(n.type=="torus"){g=new Torus(n.radius,n.tube,n.segmentsR,n.segmentsT);
|
||||
F.geometries[e]=g}else if(n.type=="bin_mesh")D.loadBinary({model:n.url,callback:y(e)});else n.type=="ascii_mesh"&&D.loadAscii({model:n.url,callback:y(e)})}for(l in I.textures){L=I.textures[l];if(L.url instanceof Array){N=ImageUtils.loadArray(L.url);A=new THREE.Texture(N)}else A=ImageUtils.loadTexture(L.url);F.textures[l]=A}for(f in I.materials){p=I.materials[f];for(m in p.parameters)if(m=="env_map"||m=="map")p.parameters[m]=F.textures[p.parameters[m]];o=new THREE[p.type](p.parameters);F.materials[f]=
|
||||
o}E();for(j in I.lights){x=I.lights[j];if(x.type=="directional"){z=x.direction;light=new THREE.DirectionalLight;light.position.set(z[0],z[1],z[2]);light.position.normalize()}else if(x.type=="point"){z=x.position;light=new THREE.PointLight;light.position.set(z[0],z[1],z[2])}u=x.color;light.color.setRGB(u[0],u[1],u[2]);F.scene.addLight(light);F.lights[j]=light}for(c in I.cameras){u=I.cameras[c];if(u.type=="perspective")B=new THREE.Camera(u.fov,u.aspect,u.near,u.far);else if(u.type=="ortho"){B=new THREE.Camera;
|
||||
B.projectionMatrix=THREE.Matrix4.makeOrtho(u.left,u.right,u.top,u.bottom,u.near,u.far)}z=u.position;K=u.target;B.position.set(z[0],z[1],z[2]);B.target.position.set(K[0],K[1],K[2]);F.cameras[c]=B}for(k in I.fogs){t=I.fogs[k];if(t.type=="linear")q=new THREE.Fog(0,t.near,t.far);else if(t.type=="exp2")q=new THREE.FogExp2(0,t.density);u=t.color;q.color.setRGB(u[0],u[1],u[2]);F.fogs[k]=q}F.currentCamera=F.cameras[I.defaults.camera];if(F.fogs&&I.defaults.fog)F.scene.fog=F.fogs[I.defaults.fog];u=I.defaults.bgcolor;
|
||||
F.bgColor=new THREE.Color;F.bgColor.setRGB(u[0],u[1],u[2]);F.bgColorAlpha=I.defaults.bgalpha;b(F)};a.postMessage(0)},addMesh:function(a,b,d,e,f,h,j,c,k,l){b=new THREE.Mesh(b,l);b.scale.x=b.scale.y=b.scale.z=d;b.position.x=e;b.position.y=f;b.position.z=h;b.rotation.x=j;b.rotation.y=c;b.rotation.z=k;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 f=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,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,b,1,e,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,
|
||||
b,1,0,e,0,f,0,h,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));SceneUtils.addMesh(a,b,1,0,-e,0,-f,0,h,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
|
||||
var GeometryUtils={merge:function(a,b){var d=b instanceof THREE.Mesh,e=a.vertices.length,g=d?b.geometry:b,f=a.vertices,j=g.vertices,c=a.faces,k=g.faces,l=a.uvs;g=g.uvs;d&&b.autoUpdateMatrix&&b.updateMatrix();for(var n=0,B=j.length;n<B;n++){var o=new THREE.Vertex(j[n].position.clone());d&&b.matrix.multiplyVector3(o.position);f.push(o)}n=0;for(B=k.length;n<B;n++){j=k[n];var u,v=j.vertexNormals;if(j instanceof THREE.Face3)u=new THREE.Face3(j.a+e,j.b+e,j.c+e);else if(j instanceof THREE.Face4)u=new THREE.Face4(j.a+
|
||||
e,j.b+e,j.c+e,j.d+e);u.centroid.copy(j.centroid);u.normal.copy(j.normal);d=0;for(f=v.length;d<f;d++){o=v[d];u.vertexNormals.push(o.clone())}u.materials=j.materials.slice();c.push(u)}n=0;for(B=g.length;n<B;n++){e=g[n];c=[];d=0;for(f=e.length;d<f;d++)c.push(new THREE.UV(e[d].u,e[d].v));l.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={loadScene:function(a,b,d){var e,g,f,j,c,k,l,n,B,o,u,v,w,K,t,L,m,h,p,C,q,A,N,x,D;a=new Worker(a);D=new THREE.Loader;a.onmessage=function(G){function E(){for(f in I.objects)if(!F.objects[f]){B=I.objects[f];if(h=F.geometries[B.geometry]){x=[];for(i=0;i<B.materials.length;i++)x[i]=F.materials[B.materials[i]];v=B.position;r=B.rotation;s=B.scale;object=new THREE.Mesh(h,x);object.position.set(v[0],
|
||||
v[1],v[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=B.visible;F.scene.addObject(object);F.objects[f]=object}}}function z(V){return function(P){F.geometries[V]=P;E();T-=1;T==0&&d(F)}}var I=G.data,F={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}},T=0;for(e in I.geometries){n=I.geometries[e];if(n.type=="bin_mesh"||n.type=="ascii_mesh")T+=1}for(e in I.geometries){n=I.geometries[e];if(n.type=="cube"){h=new Cube(n.width,
|
||||
n.height,n.depth,n.segments_width,n.segments_height,null,n.flipped,n.sides);F.geometries[e]=h}else if(n.type=="plane"){h=new Plane(n.width,n.height,n.segments_width,n.segments_height);F.geometries[e]=h}else if(n.type=="sphere"){h=new Sphere(n.radius,n.segments_width,n.segments_height);F.geometries[e]=h}else if(n.type=="cylinder"){h=new Cylinder(n.numSegs,n.topRad,n.botRad,n.height,n.topOffset,n.botOffset);F.geometries[e]=h}else if(n.type=="torus"){h=new Torus(n.radius,n.tube,n.segmentsR,n.segmentsT);
|
||||
F.geometries[e]=h}else if(n.type=="icosahedron"){h=new Icosahedron(n.subdivisions);F.geometries[e]=h}else if(n.type=="bin_mesh")D.loadBinary({model:n.url,callback:z(e)});else n.type=="ascii_mesh"&&D.loadAscii({model:n.url,callback:z(e)})}for(l in I.textures){L=I.textures[l];if(L.url instanceof Array){N=ImageUtils.loadArray(L.url);A=new THREE.Texture(N)}else A=ImageUtils.loadTexture(L.url);F.textures[l]=A}for(g in I.materials){o=I.materials[g];for(m in o.parameters)if(m=="env_map"||m=="map")o.parameters[m]=
|
||||
F.textures[o.parameters[m]];else if(m=="shading")o.parameters[m]=o.parameters[m]=="flat"?THREE.FlatShading:THREE.SmoothShading;p=new THREE[o.type](o.parameters);F.materials[g]=p}E();for(j in I.lights){u=I.lights[j];if(u.type=="directional"){v=u.direction;light=new THREE.DirectionalLight;light.position.set(v[0],v[1],v[2]);light.position.normalize()}else if(u.type=="point"){v=u.position;light=new THREE.PointLight;light.position.set(v[0],v[1],v[2])}w=u.color;light.color.setRGB(w[0],w[1],w[2]);F.scene.addLight(light);
|
||||
F.lights[j]=light}for(c in I.cameras){w=I.cameras[c];if(w.type=="perspective")C=new THREE.Camera(w.fov,w.aspect,w.near,w.far);else if(w.type=="ortho"){C=new THREE.Camera;C.projectionMatrix=THREE.Matrix4.makeOrtho(w.left,w.right,w.top,w.bottom,w.near,w.far)}v=w.position;K=w.target;C.position.set(v[0],v[1],v[2]);C.target.position.set(K[0],K[1],K[2]);F.cameras[c]=C}for(k in I.fogs){t=I.fogs[k];if(t.type=="linear")q=new THREE.Fog(0,t.near,t.far);else if(t.type=="exp2")q=new THREE.FogExp2(0,t.density);
|
||||
w=t.color;q.color.setRGB(w[0],w[1],w[2]);F.fogs[k]=q}F.currentCamera=F.cameras[I.defaults.camera];if(F.fogs&&I.defaults.fog)F.scene.fog=F.fogs[I.defaults.fog];w=I.defaults.bgcolor;F.bgColor=new THREE.Color;F.bgColor.setRGB(w[0],w[1],w[2]);F.bgColorAlpha=I.defaults.bgalpha;b(F)};a.postMessage(0)},addMesh:function(a,b,d,e,g,f,j,c,k,l){b=new THREE.Mesh(b,l);b.scale.x=b.scale.y=b.scale.z=d;b.position.x=e;b.position.y=g;b.position.z=f;b.rotation.x=j;b.rotation.y=c;b.rotation.z=k;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,f=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,b,1,0,e,0,g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));SceneUtils.addMesh(a,b,1,0,-e,0,-g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",
|
||||
value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
|
||||
vertex_shader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main(void) {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
|
||||
normal:{uniforms:{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:4,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",value:new THREE.Color(15658734)},uDirLightPos:{type:"v3",value:new THREE.Vector3},
|
||||
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}"},
|
||||
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}"},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=function(a,b,d,e,f,h,j,c){function k(u,K,t,L,m,g,o,B){var q,A,N=e||1,v=f||1,D=N+1,G=v+1,E=m/2,y=g/2;m=m/N;var I=g/v,F=l.vertices.length;if(u=="x"&&K=="y"||u=="y"&&K=="x")q="z";else if(u=="x"&&K=="z"||u=="z"&&K=="x")q="y";else if(u=="z"&&K=="y"||u=="y"&&K=="z")q="x";for(A=0;A<G;A++)for(g=0;g<D;g++){var T=new THREE.Vector3;
|
||||
T[u]=(g*m-E)*t;T[K]=(A*I-y)*L;T[q]=o;l.vertices.push(new THREE.Vertex(T))}for(A=0;A<v;A++)for(g=0;g<N;g++){l.faces.push(new THREE.Face4(g+D*A+F,g+D*(A+1)+F,g+1+D*(A+1)+F,g+1+D*A+F,null,B));l.uvs.push([new THREE.UV(g/N,A/v),new THREE.UV(g/N,(A+1)/v),new THREE.UV((g+1)/N,(A+1)/v),new THREE.UV((g+1)/N,A/v)])}}THREE.Geometry.call(this);var l=this,n=a/2,C=b/2,p=d/2;j=j?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var x=0;x<6;x++)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 z in c)if(this.sides[z]!=undefined)this.sides[z]=c[z];this.sides.px&&k("z","y",1*j,-1,d,b,-n,this.materials[0]);this.sides.nx&&k("z","y",-1*j,-1,d,b,n,this.materials[1]);this.sides.py&&k("x","z",1*j,1,a,d,C,this.materials[2]);this.sides.ny&&k("x","z",1*j,-1,a,d,-C,this.materials[3]);this.sides.pz&&k("x","y",1*j,-1,a,b,p,this.materials[4]);this.sides.nz&&k("x","y",-1*j,-1,a,b,-p,this.materials[5]);(function(){for(var u=
|
||||
[],K=[],t=0,L=l.vertices.length;t<L;t++){for(var m=l.vertices[t],g=false,o=0,B=u.length;o<B;o++){var q=u[o];if(m.position.x==q.position.x&&m.position.y==q.position.y&&m.position.z==q.position.z){K[t]=o;g=true;break}}if(!g){K[t]=u.length;u.push(new THREE.Vertex(m.position.clone()))}}t=0;for(L=l.faces.length;t<L;t++){m=l.faces[t];m.a=K[m.a];m.b=K[m.b];m.c=K[m.c];m.d=K[m.d]}l.vertices=u})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;
|
||||
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=function(a,b,d,e,g,f,j,c){function k(w,K,t,L,m,h,p,C){var q,A,N=e||1,x=g||1,D=N+1,G=x+1,E=m/2,z=h/2;m=m/N;var I=h/x,F=l.vertices.length;if(w=="x"&&K=="y"||w=="y"&&K=="x")q="z";else if(w=="x"&&K=="z"||w=="z"&&K=="x")q="y";else if(w=="z"&&K=="y"||w=="y"&&K=="z")q="x";for(A=0;A<G;A++)for(h=0;h<D;h++){var T=new THREE.Vector3;
|
||||
T[w]=(h*m-E)*t;T[K]=(A*I-z)*L;T[q]=p;l.vertices.push(new THREE.Vertex(T))}for(A=0;A<x;A++)for(h=0;h<N;h++){l.faces.push(new THREE.Face4(h+D*A+F,h+D*(A+1)+F,h+1+D*(A+1)+F,h+1+D*A+F,null,C));l.uvs.push([new THREE.UV(h/N,A/x),new THREE.UV(h/N,(A+1)/x),new THREE.UV((h+1)/N,(A+1)/x),new THREE.UV((h+1)/N,A/x)])}}THREE.Geometry.call(this);var l=this,n=a/2,B=b/2,o=d/2;j=j?-1:1;if(f!==undefined)if(f instanceof Array)this.materials=f;else{this.materials=[];for(var u=0;u<6;u++)this.materials.push([f])}else this.materials=
|
||||
[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(c!=undefined)for(var v in c)if(this.sides[v]!=undefined)this.sides[v]=c[v];this.sides.px&&k("z","y",1*j,-1,d,b,-n,this.materials[0]);this.sides.nx&&k("z","y",-1*j,-1,d,b,n,this.materials[1]);this.sides.py&&k("x","z",1*j,1,a,d,B,this.materials[2]);this.sides.ny&&k("x","z",1*j,-1,a,d,-B,this.materials[3]);this.sides.pz&&k("x","y",1*j,-1,a,b,o,this.materials[4]);this.sides.nz&&k("x","y",-1*j,-1,a,b,-o,this.materials[5]);(function(){for(var w=
|
||||
[],K=[],t=0,L=l.vertices.length;t<L;t++){for(var m=l.vertices[t],h=false,p=0,C=w.length;p<C;p++){var q=w[p];if(m.position.x==q.position.x&&m.position.y==q.position.y&&m.position.z==q.position.z){K[t]=p;h=true;break}}if(!h){K[t]=w.length;w.push(new THREE.Vertex(m.position.clone()))}}t=0;for(L=l.faces.length;t<L;t++){m=l.faces[t];m.a=K[m.a];m.b=K[m.b];m.c=K[m.c];m.d=K[m.d]}l.vertices=w})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;
|
||||
Cube.prototype.constructor=Cube;
|
||||
var Cylinder=function(a,b,d,e,f){function h(l,n,C){j.vertices.push(new THREE.Vertex(new THREE.Vector3(l,n,C)))}THREE.Geometry.call(this);var j=this,c=Math.PI,k;for(k=0;k<a;k++)h(Math.sin(2*c*k/a)*b,Math.cos(2*c*k/a)*b,0);for(k=0;k<a;k++)h(Math.sin(2*c*k/a)*d,Math.cos(2*c*k/a)*d,e);for(k=0;k<a;k++)j.faces.push(new THREE.Face4(k,k+a,a+(k+1)%a,(k+1)%a));if(d!=0){h(0,0,-f);for(k=a;k<a+a/2;k++)j.faces.push(new THREE.Face4(2*a,(2*k-2*a)%a,(2*k-2*a+1)%a,(2*k-2*a+2)%a))}if(b!=0){h(0,0,e+f);for(k=a+a/2;k<
|
||||
var Cylinder=function(a,b,d,e,g){function f(l,n,B){j.vertices.push(new THREE.Vertex(new THREE.Vector3(l,n,B)))}THREE.Geometry.call(this);var j=this,c=Math.PI,k;for(k=0;k<a;k++)f(Math.sin(2*c*k/a)*b,Math.cos(2*c*k/a)*b,0);for(k=0;k<a;k++)f(Math.sin(2*c*k/a)*d,Math.cos(2*c*k/a)*d,e);for(k=0;k<a;k++)j.faces.push(new THREE.Face4(k,k+a,a+(k+1)%a,(k+1)%a));if(d!=0){f(0,0,-g);for(k=a;k<a+a/2;k++)j.faces.push(new THREE.Face4(2*a,(2*k-2*a)%a,(2*k-2*a+1)%a,(2*k-2*a+2)%a))}if(b!=0){f(0,0,e+g);for(k=a+a/2;k<
|
||||
2*a;k++)j.faces.push(new THREE.Face4((2*k-2*a+2)%a+a,(2*k-2*a+1)%a+a,(2*k-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
|
||||
var Plane=function(a,b,d,e){THREE.Geometry.call(this);var f,h=a/2,j=b/2;d=d||1;e=e||1;var c=d+1,k=e+1;a=a/d;var l=b/e;for(f=0;f<k;f++)for(b=0;b<c;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-h,-(f*l-j),0)));for(f=0;f<e;f++)for(b=0;b<d;b++){this.faces.push(new THREE.Face4(b+c*f,b+c*(f+1),b+1+c*(f+1),b+1+c*f));this.uvs.push([new THREE.UV(b/d,f/e),new THREE.UV(b/d,(f+1)/e),new THREE.UV((b+1)/d,(f+1)/e),new THREE.UV((b+1)/d,f/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
|
||||
var Plane=function(a,b,d,e){THREE.Geometry.call(this);var g,f=a/2,j=b/2;d=d||1;e=e||1;var c=d+1,k=e+1;a=a/d;var l=b/e;for(g=0;g<k;g++)for(b=0;b<c;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-f,-(g*l-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,f=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*f),k=a*Math.sin(e*f),l=[],n=0;for(e=0;e<h;e++){var C=2*e/h,p=k*Math.sin(C*f);C=k*Math.cos(C*f);(d==0||d==j)&&e>0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(C,c,p)))-1);l.push(n)}b.push(l)}var x,z,u;f=b.length;for(d=0;d<f;d++){h=b[d].length;if(d>0)for(e=0;e<h;e++){l=e==h-1;j=b[d][l?0:e+1];c=b[d][l?h-1:e];k=b[d-1][l?h-1:e];l=b[d-1][l?
|
||||
0:e+1];p=d/(f-1);x=(d-1)/(f-1);z=(e+1)/h;C=e/h;n=new THREE.UV(1-z,p);p=new THREE.UV(1-C,p);C=new THREE.UV(1-C,x);var K=new THREE.UV(1-z,x);if(d<b.length-1){x=this.vertices[j].position.clone();z=this.vertices[c].position.clone();u=this.vertices[k].position.clone();x.normalize();z.normalize();u.normalize();this.faces.push(new THREE.Face3(j,c,k,[new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(u.x,u.y,u.z)]));this.uvs.push([n,p,C])}if(d>1){x=this.vertices[j].position.clone();
|
||||
z=this.vertices[k].position.clone();u=this.vertices[l].position.clone();x.normalize();z.normalize();u.normalize();this.faces.push(new THREE.Face3(j,k,l,[new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(u.x,u.y,u.z)]));this.uvs.push([n,C,K])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
|
||||
var Torus=function(a,b,d,e){this.radius=a||100;this.tube=b||40;this.segmentsR=d||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(d=0;d<=this.segmentsT;++d){e=d/this.segmentsT*2*Math.PI;var f=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(e),(this.radius+this.tube*Math.cos(f))*Math.sin(e),this.tube*Math.sin(f))));a.push([d/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(d=
|
||||
1;d<=this.segmentsT;++d){e=(this.segmentsT+1)*b+d;f=(this.segmentsT+1)*b+d-1;var h=(this.segmentsT+1)*(b-1)+d-1,j=(this.segmentsT+1)*(b-1)+d;this.faces.push(new THREE.Face4(e,f,h,j));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[h][0],a[h][1]),new THREE.UV(a[j][0],a[j][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
|
||||
function LathedObject(a,b,d){THREE.Geometry.call(this);b=b||12;d=d||2*Math.PI;b=d/b;for(var e=[],f=[],h=[],j=[],c=0;c<a.length;c++){this.vertices.push(new THREE.Vertex(a[c]));f[c]=this.vertices.length-1;e[c]=new THREE.Vector3(a[c].x,a[c].y,a[c].z)}for(var k=THREE.Matrix4.rotationZMatrix(b),l=0;l<=d+0.0010;l+=b){for(c=0;c<e.length;c++)if(l<d){e[c]=k.multiplyVector3(e[c].clone());this.vertices.push(new THREE.Vertex(e[c]));h[c]=this.vertices.length-1}else h=j;if(l==0)j=f;for(c=0;c<f.length-1;c++){this.faces.push(new THREE.Face4(h[c],
|
||||
h[c+1],f[c+1],f[c]));this.uvs.push([new THREE.UV(l/d,c/a.length),new THREE.UV(l/d,(c+1)/a.length),new THREE.UV((l-b)/d,(c+1)/a.length),new THREE.UV((l-b)/d,c/a.length)])}f=h;h=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
|
||||
var Sphere=function(a,b,d){THREE.Geometry.call(this);var e,g=Math.PI,f=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),k=a*Math.sin(e*g),l=[],n=0;for(e=0;e<f;e++){var B=2*e/f,o=k*Math.sin(B*g);B=k*Math.cos(B*g);(d==0||d==j)&&e>0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(B,c,o)))-1);l.push(n)}b.push(l)}var u,v,w;g=b.length;for(d=0;d<g;d++){f=b[d].length;if(d>0)for(e=0;e<f;e++){l=e==f-1;j=b[d][l?0:e+1];c=b[d][l?f-1:e];k=b[d-1][l?f-1:e];l=b[d-1][l?
|
||||
0:e+1];o=d/(g-1);u=(d-1)/(g-1);v=(e+1)/f;B=e/f;n=new THREE.UV(1-v,o);o=new THREE.UV(1-B,o);B=new THREE.UV(1-B,u);var K=new THREE.UV(1-v,u);if(d<b.length-1){u=this.vertices[j].position.clone();v=this.vertices[c].position.clone();w=this.vertices[k].position.clone();u.normalize();v.normalize();w.normalize();this.faces.push(new THREE.Face3(j,c,k,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(w.x,w.y,w.z)]));this.uvs.push([n,o,B])}if(d>1){u=this.vertices[j].position.clone();
|
||||
v=this.vertices[k].position.clone();w=this.vertices[l].position.clone();u.normalize();v.normalize();w.normalize();this.faces.push(new THREE.Face3(j,k,l,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(w.x,w.y,w.z)]));this.uvs.push([n,B,K])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
|
||||
var Torus=function(a,b,d,e){this.radius=a||100;this.tube=b||40;this.segmentsR=d||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(d=0;d<=this.segmentsT;++d){e=d/this.segmentsT*2*Math.PI;var g=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(e),(this.radius+this.tube*Math.cos(g))*Math.sin(e),this.tube*Math.sin(g))));a.push([d/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(d=
|
||||
1;d<=this.segmentsT;++d){e=(this.segmentsT+1)*b+d;g=(this.segmentsT+1)*b+d-1;var f=(this.segmentsT+1)*(b-1)+d-1,j=(this.segmentsT+1)*(b-1)+d;this.faces.push(new THREE.Face4(e,g,f,j));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[j][0],a[j][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
|
||||
var Icosahedron=function(a){function b(B,o,u){var v=Math.sqrt(B*B+o*o+u*u);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(B/v,o/v,u/v)))-1}function d(B,o,u,v){v.faces.push(new THREE.Face3(B,o,u))}function e(B,o){var u=g.vertices[B].position,v=g.vertices[o].position;return b((u.x+v.x)/2,(u.y+v.y)/2,(u.z+v.z)/2)}var g=this,f=new THREE.Geometry,j;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0,
|
||||
1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);d(0,11,5,f);d(0,5,1,f);d(0,1,7,f);d(0,7,10,f);d(0,10,11,f);d(1,5,9,f);d(5,11,4,f);d(11,10,2,f);d(10,7,6,f);d(7,1,8,f);d(3,9,4,f);d(3,4,2,f);d(3,2,6,f);d(3,6,8,f);d(3,8,9,f);d(4,9,5,f);d(2,4,11,f);d(6,2,10,f);d(8,6,7,f);d(9,8,1,f);for(a=0;a<this.subdivisions;a++){j=new THREE.Geometry;for(var c in f.faces){var k=e(f.faces[c].a,f.faces[c].b),l=e(f.faces[c].b,f.faces[c].c),n=e(f.faces[c].c,f.faces[c].a);d(f.faces[c].a,k,n,j);d(f.faces[c].b,l,k,j);d(f.faces[c].c,
|
||||
n,l,j);d(k,l,n,j)}f.faces=j.faces}g.faces=f.faces;delete f;delete j;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
|
||||
function LathedObject(a,b,d){THREE.Geometry.call(this);b=b||12;d=d||2*Math.PI;b=d/b;for(var e=[],g=[],f=[],j=[],c=0;c<a.length;c++){this.vertices.push(new THREE.Vertex(a[c]));g[c]=this.vertices.length-1;e[c]=new THREE.Vector3(a[c].x,a[c].y,a[c].z)}for(var k=THREE.Matrix4.rotationZMatrix(b),l=0;l<=d+0.0010;l+=b){for(c=0;c<e.length;c++)if(l<d){e[c]=k.multiplyVector3(e[c].clone());this.vertices.push(new THREE.Vertex(e[c]));f[c]=this.vertices.length-1}else f=j;if(l==0)j=g;for(c=0;c<g.length-1;c++){this.faces.push(new THREE.Face4(f[c],
|
||||
f[c+1],g[c+1],g[c]));this.uvs.push([new THREE.UV(l/d,c/a.length),new THREE.UV(l/d,(c+1)/a.length),new THREE.UV((l-b)/d,(c+1)/a.length),new THREE.UV((l-b)/d,c/a.length)])}g=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
|
||||
THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var 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(f){THREE.Loader.prototype.createModel(f.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),f=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,f,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,f,h){var j=new XMLHttpRequest,c=e+"/"+a,k=0;
|
||||
j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.Loader.prototype.createBinModel(j.responseText,d,f,b):alert("Couldn't load ["+c+"] ["+j.status+"]");else if(j.readyState==3){if(h){if(k==0)k=j.getResponseHeader("Content-Length");h({total:k,loaded:j.responseText.length})}}else if(j.readyState==2)k=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 f=function(h){function j(w,M){var J=n(w,M),Z=n(w,M+1),ca=n(w,M+2),ga=n(w,M+3),ja=(ga<<1&255|ca>>7)-127;J=(ca&127)<<16|Z<<8|J;if(J==0&&ja==-127)return 0;return(1-2*(ga>>7))*(1+J*Math.pow(2,-23))*Math.pow(2,ja)}function c(w,M){var J=n(w,M),Z=n(w,M+1),ca=n(w,M+2);return(n(w,M+3)<<24)+(ca<<16)+(Z<<8)+J}function k(w,M){var J=n(w,M);return(n(w,M+1)<<8)+J}function l(w,M){var J=n(w,M);return J>127?J-256:J}function n(w,M){return w.charCodeAt(M)&255}function C(w){var M,
|
||||
J,Z;M=c(a,w);J=c(a,w+B);Z=c(a,w+q);w=k(a,w+A);THREE.Loader.prototype.f3(t,M,J,Z,w)}function p(w){var M,J,Z,ca,ga,ja;M=c(a,w);J=c(a,w+B);Z=c(a,w+q);ca=k(a,w+A);ga=c(a,w+N);ja=c(a,w+v);w=c(a,w+D);THREE.Loader.prototype.f3n(t,g,M,J,Z,ca,ga,ja,w)}function x(w){var M,J,Z,ca;M=c(a,w);J=c(a,w+G);Z=c(a,w+E);ca=c(a,w+y);w=k(a,w+I);THREE.Loader.prototype.f4(t,M,J,Z,ca,w)}function z(w){var M,J,Z,ca,ga,ja,qa,sa;M=c(a,w);J=c(a,w+G);Z=c(a,w+E);ca=c(a,w+y);ga=k(a,w+I);ja=c(a,w+F);qa=c(a,w+T);sa=c(a,w+V);w=c(a,w+
|
||||
P);THREE.Loader.prototype.f4n(t,g,M,J,Z,ca,ga,ja,qa,sa,w)}function u(w){var M,J;M=c(a,w);J=c(a,w+da);w=c(a,w+X);THREE.Loader.prototype.uv3(t,o[M*2],o[M*2+1],o[J*2],o[J*2+1],o[w*2],o[w*2+1])}function K(w){var M,J,Z;M=c(a,w);J=c(a,w+R);Z=c(a,w+U);w=c(a,w+ba);THREE.Loader.prototype.uv4(t,o[M*2],o[M*2+1],o[J*2],o[J*2+1],o[Z*2],o[Z*2+1],o[w*2],o[w*2+1])}var t=this,L=0,m,g=[],o=[],B,q,A,N,v,D,G,E,y,I,F,T,V,P,da,X,R,U,ba,Y,H,S,W,ia,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(t,e,h);
|
||||
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 f=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers,j.data.materials,d,g,e,f)};b.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,d,e,g,f){var j=new XMLHttpRequest,c=e+"/"+a,k=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(f){if(k==0)k=j.getResponseHeader("Content-Length");f({total:k,loaded:j.responseText.length})}}else if(j.readyState==2)k=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(f){function j(y,M){var J=n(y,M),Z=n(y,M+1),ca=n(y,M+2),ga=n(y,M+3),ja=(ga<<1&255|ca>>7)-127;J=(ca&127)<<16|Z<<8|J;if(J==0&&ja==-127)return 0;return(1-2*(ga>>7))*(1+J*Math.pow(2,-23))*Math.pow(2,ja)}function c(y,M){var J=n(y,M),Z=n(y,M+1),ca=n(y,M+2);return(n(y,M+3)<<24)+(ca<<16)+(Z<<8)+J}function k(y,M){var J=n(y,M);return(n(y,M+1)<<8)+J}function l(y,M){var J=n(y,M);return J>127?J-256:J}function n(y,M){return y.charCodeAt(M)&255}function B(y){var M,
|
||||
J,Z;M=c(a,y);J=c(a,y+C);Z=c(a,y+q);y=k(a,y+A);THREE.Loader.prototype.f3(t,M,J,Z,y)}function o(y){var M,J,Z,ca,ga,ja;M=c(a,y);J=c(a,y+C);Z=c(a,y+q);ca=k(a,y+A);ga=c(a,y+N);ja=c(a,y+x);y=c(a,y+D);THREE.Loader.prototype.f3n(t,h,M,J,Z,ca,ga,ja,y)}function u(y){var M,J,Z,ca;M=c(a,y);J=c(a,y+G);Z=c(a,y+E);ca=c(a,y+z);y=k(a,y+I);THREE.Loader.prototype.f4(t,M,J,Z,ca,y)}function v(y){var M,J,Z,ca,ga,ja,qa,sa;M=c(a,y);J=c(a,y+G);Z=c(a,y+E);ca=c(a,y+z);ga=k(a,y+I);ja=c(a,y+F);qa=c(a,y+T);sa=c(a,y+V);y=c(a,y+
|
||||
P);THREE.Loader.prototype.f4n(t,h,M,J,Z,ca,ga,ja,qa,sa,y)}function w(y){var M,J;M=c(a,y);J=c(a,y+da);y=c(a,y+X);THREE.Loader.prototype.uv3(t,p[M*2],p[M*2+1],p[J*2],p[J*2+1],p[y*2],p[y*2+1])}function K(y){var M,J,Z;M=c(a,y);J=c(a,y+R);Z=c(a,y+U);y=c(a,y+ba);THREE.Loader.prototype.uv4(t,p[M*2],p[M*2+1],p[J*2],p[J*2+1],p[Z*2],p[Z*2+1],p[y*2],p[y*2+1])}var t=this,L=0,m,h=[],p=[],C,q,A,N,x,D,G,E,z,I,F,T,V,P,da,X,R,U,ba,Y,H,S,W,ia,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(t,e,f);
|
||||
m={signature:a.substr(L,8),header_bytes:n(a,L+8),vertex_coordinate_bytes:n(a,L+9),normal_coordinate_bytes:n(a,L+10),uv_coordinate_bytes:n(a,L+11),vertex_index_bytes:n(a,L+12),normal_index_bytes:n(a,L+13),uv_index_bytes:n(a,L+14),material_index_bytes:n(a,L+15),nvertices:c(a,L+16),nnormals:c(a,L+16+4),nuvs:c(a,L+16+8),ntri_flat:c(a,L+16+12),ntri_smooth:c(a,L+16+16),ntri_flat_uv:c(a,L+16+20),ntri_smooth_uv:c(a,L+16+24),nquad_flat:c(a,L+16+28),nquad_smooth:c(a,L+16+32),nquad_flat_uv:c(a,L+16+36),nquad_smooth_uv:c(a,
|
||||
L+16+40)};L+=m.header_bytes;B=m.vertex_index_bytes;q=m.vertex_index_bytes*2;A=m.vertex_index_bytes*3;N=m.vertex_index_bytes*3+m.material_index_bytes;v=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes;D=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*2;G=m.vertex_index_bytes;E=m.vertex_index_bytes*2;y=m.vertex_index_bytes*3;I=m.vertex_index_bytes*4;F=m.vertex_index_bytes*4+m.material_index_bytes;T=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes;
|
||||
V=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*2;P=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*3;da=m.uv_index_bytes;X=m.uv_index_bytes*2;R=m.uv_index_bytes;U=m.uv_index_bytes*2;ba=m.uv_index_bytes*3;h=m.vertex_index_bytes*3+m.material_index_bytes;ha=m.vertex_index_bytes*4+m.material_index_bytes;Y=m.ntri_flat*h;H=m.ntri_smooth*(h+m.normal_index_bytes*3);S=m.ntri_flat_uv*(h+m.uv_index_bytes*3);W=m.ntri_smooth_uv*(h+m.normal_index_bytes*3+m.uv_index_bytes*
|
||||
3);ia=m.nquad_flat*ha;h=m.nquad_smooth*(ha+m.normal_index_bytes*4);ha=m.nquad_flat_uv*(ha+m.uv_index_bytes*4);L+=function(w){var M,J,Z,ca=m.vertex_coordinate_bytes*3,ga=w+m.nvertices*ca;for(w=w;w<ga;w+=ca){M=j(a,w);J=j(a,w+m.vertex_coordinate_bytes);Z=j(a,w+m.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(t,M,J,Z)}return m.nvertices*ca}(L);L+=function(w){var M,J,Z,ca=m.normal_coordinate_bytes*3,ga=w+m.nnormals*ca;for(w=w;w<ga;w+=ca){M=l(a,w);J=l(a,w+m.normal_coordinate_bytes);Z=l(a,w+m.normal_coordinate_bytes*
|
||||
2);g.push(M/127,J/127,Z/127)}return m.nnormals*ca}(L);L+=function(w){var M,J,Z=m.uv_coordinate_bytes*2,ca=w+m.nuvs*Z;for(w=w;w<ca;w+=Z){M=j(a,w);J=j(a,w+m.uv_coordinate_bytes);o.push(M,J)}return m.nuvs*Z}(L);L=L;Y=L+Y;H=Y+H;S=H+S;W=S+W;ia=W+ia;h=ia+h;ha=h+ha;(function(w){var M,J=m.vertex_index_bytes*3+m.material_index_bytes,Z=J+m.uv_index_bytes*3,ca=w+m.ntri_flat_uv*Z;for(M=w;M<ca;M+=Z){C(M);u(M+J)}return ca-w})(H);(function(w){var M,J=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*
|
||||
3,Z=J+m.uv_index_bytes*3,ca=w+m.ntri_smooth_uv*Z;for(M=w;M<ca;M+=Z){p(M);u(M+J)}return ca-w})(S);(function(w){var M,J=m.vertex_index_bytes*4+m.material_index_bytes,Z=J+m.uv_index_bytes*4,ca=w+m.nquad_flat_uv*Z;for(M=w;M<ca;M+=Z){x(M);K(M+J)}return ca-w})(h);(function(w){var M,J=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,Z=J+m.uv_index_bytes*4,ca=w+m.nquad_smooth_uv*Z;for(M=w;M<ca;M+=Z){z(M);K(M+J)}return ca-w})(ha);(function(w){var M,J=m.vertex_index_bytes*3+m.material_index_bytes,
|
||||
Z=w+m.ntri_flat*J;for(M=w;M<Z;M+=J)C(M);return Z-w})(L);(function(w){var M,J=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*3,Z=w+m.ntri_smooth*J;for(M=w;M<Z;M+=J)p(M);return Z-w})(Y);(function(w){var M,J=m.vertex_index_bytes*4+m.material_index_bytes,Z=w+m.nquad_flat*J;for(M=w;M<Z;M+=J)x(M);return Z-w})(W);(function(w){var M,J=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,Z=w+m.nquad_smooth*J;for(M=w;M<Z;M+=J)z(M);return Z-w})(ia);this.computeCentroids();
|
||||
this.computeFaceNormals();this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(d))},createModel:function(a,b,d){var e=function(f){var h=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(h,a.materials,f);(function(){var j,c,k,l,n;j=0;for(c=a.vertices.length;j<c;j+=3){k=a.vertices[j];l=a.vertices[j+1];n=a.vertices[j+2];THREE.Loader.prototype.v(h,k,l,n)}})();(function(){function j(z,u){THREE.Loader.prototype.f3(h,z[u],z[u+1],z[u+2],z[u+3])}function c(z,
|
||||
u){THREE.Loader.prototype.f3n(h,a.normals,z[u],z[u+1],z[u+2],z[u+3],z[u+4],z[u+5],z[u+6])}function k(z,u){THREE.Loader.prototype.f4(h,z[u],z[u+1],z[u+2],z[u+3],z[u+4])}function l(z,u){THREE.Loader.prototype.f4n(h,a.normals,z[u],z[u+1],z[u+2],z[u+3],z[u+4],z[u+5],z[u+6],z[u+7],z[u+8])}function n(z,u){var K,t,L;K=z[u];t=z[u+1];L=z[u+2];THREE.Loader.prototype.uv3(h,a.uvs[K*2],a.uvs[K*2+1],a.uvs[t*2],a.uvs[t*2+1],a.uvs[L*2],a.uvs[L*2+1])}function C(z,u){var K,t,L,m;K=z[u];t=z[u+1];L=z[u+2];m=z[u+3];THREE.Loader.prototype.uv4(h,
|
||||
a.uvs[K*2],a.uvs[K*2+1],a.uvs[t*2],a.uvs[t*2+1],a.uvs[L*2],a.uvs[L*2+1],a.uvs[m*2],a.uvs[m*2+1])}var p,x;p=0;for(x=a.triangles_uv.length;p<x;p+=7){j(a.triangles_uv,p);n(a.triangles_uv,p+4)}p=0;for(x=a.triangles_n_uv.length;p<x;p+=10){c(a.triangles_n_uv,p);n(a.triangles_n_uv,p+7)}p=0;for(x=a.quads_uv.length;p<x;p+=9){k(a.quads_uv,p);C(a.quads_uv,p+5)}p=0;for(x=a.quads_n_uv.length;p<x;p+=13){l(a.quads_n_uv,p);C(a.quads_n_uv,p+9)}p=0;for(x=a.triangles.length;p<x;p+=4)j(a.triangles,p);p=0;for(x=a.triangles_n.length;p<
|
||||
x;p+=7)c(a.triangles_n,p);p=0;for(x=a.quads.length;p<x;p+=5)k(a.quads,p);p=0;for(x=a.quads_n.length;p<x;p+=9)l(a.quads_n,p)})();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,f){a.faces.push(new THREE.Face3(b,d,e,null,a.materials[f]))},f4:function(a,b,d,e,f,h){a.faces.push(new THREE.Face4(b,d,e,f,null,
|
||||
a.materials[h]))},f3n:function(a,b,d,e,f,h,j,c,k){h=a.materials[h];var l=b[c*3],n=b[c*3+1];c=b[c*3+2];var C=b[k*3],p=b[k*3+1];k=b[k*3+2];a.faces.push(new THREE.Face3(d,e,f,[new THREE.Vector3(b[j*3],b[j*3+1],b[j*3+2]),new THREE.Vector3(l,n,c),new THREE.Vector3(C,p,k)],h))},f4n:function(a,b,d,e,f,h,j,c,k,l,n){j=a.materials[j];var C=b[k*3],p=b[k*3+1];k=b[k*3+2];var x=b[l*3],z=b[l*3+1];l=b[l*3+2];var u=b[n*3],K=b[n*3+1];n=b[n*3+2];a.faces.push(new THREE.Face4(d,e,f,h,[new THREE.Vector3(b[c*3],b[c*3+1],
|
||||
b[c*3+2]),new THREE.Vector3(C,p,k),new THREE.Vector3(x,z,l),new THREE.Vector3(u,K,n)],j))},uv3:function(a,b,d,e,f,h,j){var c=[];c.push(new THREE.UV(b,d));c.push(new THREE.UV(e,f));c.push(new THREE.UV(h,j));a.uvs.push(c)},uv4:function(a,b,d,e,f,h,j,c,k){var l=[];l.push(new THREE.UV(b,d));l.push(new THREE.UV(e,f));l.push(new THREE.UV(h,j));l.push(new THREE.UV(c,k));a.uvs.push(l)},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,f;if(a.map_diffuse&&b){f=document.createElement("canvas");e=new THREE.MeshLambertMaterial({map:new THREE.Texture(f)});f=new Image;f.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};f.src=b+"/"+a.map_diffuse}else if(a.col_diffuse){f=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;e=new THREE.MeshLambertMaterial({color:f,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("/")}};
|
||||
L+16+40)};L+=m.header_bytes;C=m.vertex_index_bytes;q=m.vertex_index_bytes*2;A=m.vertex_index_bytes*3;N=m.vertex_index_bytes*3+m.material_index_bytes;x=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes;D=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*2;G=m.vertex_index_bytes;E=m.vertex_index_bytes*2;z=m.vertex_index_bytes*3;I=m.vertex_index_bytes*4;F=m.vertex_index_bytes*4+m.material_index_bytes;T=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes;
|
||||
V=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*2;P=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*3;da=m.uv_index_bytes;X=m.uv_index_bytes*2;R=m.uv_index_bytes;U=m.uv_index_bytes*2;ba=m.uv_index_bytes*3;f=m.vertex_index_bytes*3+m.material_index_bytes;ha=m.vertex_index_bytes*4+m.material_index_bytes;Y=m.ntri_flat*f;H=m.ntri_smooth*(f+m.normal_index_bytes*3);S=m.ntri_flat_uv*(f+m.uv_index_bytes*3);W=m.ntri_smooth_uv*(f+m.normal_index_bytes*3+m.uv_index_bytes*
|
||||
3);ia=m.nquad_flat*ha;f=m.nquad_smooth*(ha+m.normal_index_bytes*4);ha=m.nquad_flat_uv*(ha+m.uv_index_bytes*4);L+=function(y){var M,J,Z,ca=m.vertex_coordinate_bytes*3,ga=y+m.nvertices*ca;for(y=y;y<ga;y+=ca){M=j(a,y);J=j(a,y+m.vertex_coordinate_bytes);Z=j(a,y+m.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(t,M,J,Z)}return m.nvertices*ca}(L);L+=function(y){var M,J,Z,ca=m.normal_coordinate_bytes*3,ga=y+m.nnormals*ca;for(y=y;y<ga;y+=ca){M=l(a,y);J=l(a,y+m.normal_coordinate_bytes);Z=l(a,y+m.normal_coordinate_bytes*
|
||||
2);h.push(M/127,J/127,Z/127)}return m.nnormals*ca}(L);L+=function(y){var M,J,Z=m.uv_coordinate_bytes*2,ca=y+m.nuvs*Z;for(y=y;y<ca;y+=Z){M=j(a,y);J=j(a,y+m.uv_coordinate_bytes);p.push(M,J)}return m.nuvs*Z}(L);L=L;Y=L+Y;H=Y+H;S=H+S;W=S+W;ia=W+ia;f=ia+f;ha=f+ha;(function(y){var M,J=m.vertex_index_bytes*3+m.material_index_bytes,Z=J+m.uv_index_bytes*3,ca=y+m.ntri_flat_uv*Z;for(M=y;M<ca;M+=Z){B(M);w(M+J)}return ca-y})(H);(function(y){var M,J=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*
|
||||
3,Z=J+m.uv_index_bytes*3,ca=y+m.ntri_smooth_uv*Z;for(M=y;M<ca;M+=Z){o(M);w(M+J)}return ca-y})(S);(function(y){var M,J=m.vertex_index_bytes*4+m.material_index_bytes,Z=J+m.uv_index_bytes*4,ca=y+m.nquad_flat_uv*Z;for(M=y;M<ca;M+=Z){u(M);K(M+J)}return ca-y})(f);(function(y){var M,J=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,Z=J+m.uv_index_bytes*4,ca=y+m.nquad_smooth_uv*Z;for(M=y;M<ca;M+=Z){v(M);K(M+J)}return ca-y})(ha);(function(y){var M,J=m.vertex_index_bytes*3+m.material_index_bytes,
|
||||
Z=y+m.ntri_flat*J;for(M=y;M<Z;M+=J)B(M);return Z-y})(L);(function(y){var M,J=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*3,Z=y+m.ntri_smooth*J;for(M=y;M<Z;M+=J)o(M);return Z-y})(Y);(function(y){var M,J=m.vertex_index_bytes*4+m.material_index_bytes,Z=y+m.nquad_flat*J;for(M=y;M<Z;M+=J)u(M);return Z-y})(W);(function(y){var M,J=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,Z=y+m.nquad_smooth*J;for(M=y;M<Z;M+=J)v(M);return Z-y})(ia);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 f=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,a.materials,g);(function(){var j,c,k,l,n;j=0;for(c=a.vertices.length;j<c;j+=3){k=a.vertices[j];l=a.vertices[j+1];n=a.vertices[j+2];THREE.Loader.prototype.v(f,k,l,n)}})();(function(){function j(v,w){THREE.Loader.prototype.f3(f,v[w],v[w+1],v[w+2],v[w+3])}function c(v,
|
||||
w){THREE.Loader.prototype.f3n(f,a.normals,v[w],v[w+1],v[w+2],v[w+3],v[w+4],v[w+5],v[w+6])}function k(v,w){THREE.Loader.prototype.f4(f,v[w],v[w+1],v[w+2],v[w+3],v[w+4])}function l(v,w){THREE.Loader.prototype.f4n(f,a.normals,v[w],v[w+1],v[w+2],v[w+3],v[w+4],v[w+5],v[w+6],v[w+7],v[w+8])}function n(v,w){var K,t,L;K=v[w];t=v[w+1];L=v[w+2];THREE.Loader.prototype.uv3(f,a.uvs[K*2],a.uvs[K*2+1],a.uvs[t*2],a.uvs[t*2+1],a.uvs[L*2],a.uvs[L*2+1])}function B(v,w){var K,t,L,m;K=v[w];t=v[w+1];L=v[w+2];m=v[w+3];THREE.Loader.prototype.uv4(f,
|
||||
a.uvs[K*2],a.uvs[K*2+1],a.uvs[t*2],a.uvs[t*2+1],a.uvs[L*2],a.uvs[L*2+1],a.uvs[m*2],a.uvs[m*2+1])}var o,u;o=0;for(u=a.triangles_uv.length;o<u;o+=7){j(a.triangles_uv,o);n(a.triangles_uv,o+4)}o=0;for(u=a.triangles_n_uv.length;o<u;o+=10){c(a.triangles_n_uv,o);n(a.triangles_n_uv,o+7)}o=0;for(u=a.quads_uv.length;o<u;o+=9){k(a.quads_uv,o);B(a.quads_uv,o+5)}o=0;for(u=a.quads_n_uv.length;o<u;o+=13){l(a.quads_n_uv,o);B(a.quads_n_uv,o+9)}o=0;for(u=a.triangles.length;o<u;o+=4)j(a.triangles,o);o=0;for(u=a.triangles_n.length;o<
|
||||
u;o+=7)c(a.triangles_n,o);o=0;for(u=a.quads.length;o<u;o+=5)k(a.quads,o);o=0;for(u=a.quads_n.length;o<u;o+=9)l(a.quads_n,o)})();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,f){a.faces.push(new THREE.Face4(b,d,e,g,null,
|
||||
a.materials[f]))},f3n:function(a,b,d,e,g,f,j,c,k){f=a.materials[f];var l=b[c*3],n=b[c*3+1];c=b[c*3+2];var B=b[k*3],o=b[k*3+1];k=b[k*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(l,n,c),new THREE.Vector3(B,o,k)],f))},f4n:function(a,b,d,e,g,f,j,c,k,l,n){j=a.materials[j];var B=b[k*3],o=b[k*3+1];k=b[k*3+2];var u=b[l*3],v=b[l*3+1];l=b[l*3+2];var w=b[n*3],K=b[n*3+1];n=b[n*3+2];a.faces.push(new THREE.Face4(d,e,g,f,[new THREE.Vector3(b[c*3],b[c*3+1],
|
||||
b[c*3+2]),new THREE.Vector3(B,o,k),new THREE.Vector3(u,v,l),new THREE.Vector3(w,K,n)],j))},uv3:function(a,b,d,e,g,f,j){var c=[];c.push(new THREE.UV(b,d));c.push(new THREE.UV(e,g));c.push(new THREE.UV(f,j));a.uvs.push(c)},uv4:function(a,b,d,e,g,f,j,c,k){var l=[];l.push(new THREE.UV(b,d));l.push(new THREE.UV(e,g));l.push(new THREE.UV(f,j));l.push(new THREE.UV(c,k));a.uvs.push(l)},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(f){f=Math.log(f)/Math.LN2;return Math.floor(f)==f}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 f=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=f;e.map.image.height=j;e.map.image.getContext("2d").drawImage(this,0,0,f,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("/")}};
|
||||
|
||||
@@ -29,10 +29,20 @@ var scene = {
|
||||
"visible" : true
|
||||
},
|
||||
|
||||
"icosahedron" : {
|
||||
"geometry" : "icosahedron",
|
||||
"materials": [ "faceted_white" ],
|
||||
"position" : [ 20, 10, -60 ],
|
||||
"rotation" : [ 0, 0, 0 ],
|
||||
"scale" : [ 20, 20, 20 ],
|
||||
"visible" : true
|
||||
},
|
||||
|
||||
|
||||
"torus" : {
|
||||
"geometry" : "torus",
|
||||
"materials": [ "phong_orange" ],
|
||||
"position" : [ 0, 5, -50 ],
|
||||
"position" : [ -20, 5, -50 ],
|
||||
"rotation" : [ 0, 0, 0 ],
|
||||
"scale" : [ 2, 2, 2 ],
|
||||
"visible" : true
|
||||
@@ -112,7 +122,12 @@ var scene = {
|
||||
"segments_width" : 32,
|
||||
"segments_height" : 16
|
||||
},
|
||||
|
||||
|
||||
"icosahedron": {
|
||||
"type" : "icosahedron",
|
||||
"subdivisions" : 2
|
||||
},
|
||||
|
||||
"torus": {
|
||||
"type" : "torus",
|
||||
"radius" : 5,
|
||||
@@ -180,6 +195,11 @@ var scene = {
|
||||
"type": "MeshBasicMaterial",
|
||||
"parameters": { color: 0xffffff, wireframe: true }
|
||||
},
|
||||
|
||||
"faceted_white": {
|
||||
"type": "MeshLambertMaterial",
|
||||
"parameters": { color: 0xffffff, shading: "flat" }
|
||||
},
|
||||
|
||||
"basic_blue": {
|
||||
"type": "MeshBasicMaterial",
|
||||
|
||||
@@ -137,6 +137,11 @@ var SceneUtils = {
|
||||
|
||||
geometry = new Torus( g.radius, g.tube, g.segmentsR, g.segmentsT );
|
||||
result.geometries[ dg ] = geometry;
|
||||
|
||||
} else if ( g.type == "icosahedron" ) {
|
||||
|
||||
geometry = new Icosahedron( g.subdivisions );
|
||||
result.geometries[ dg ] = geometry;
|
||||
|
||||
} else if ( g.type == "bin_mesh" ) {
|
||||
|
||||
@@ -188,6 +193,10 @@ var SceneUtils = {
|
||||
|
||||
m.parameters[ pp ] = result.textures[ m.parameters[ pp ] ];
|
||||
|
||||
} else if ( pp == "shading" ) {
|
||||
|
||||
m.parameters[ pp ] = ( m.parameters[ pp ] == "flat" ) ? THREE.FlatShading : THREE.SmoothShading;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* so it draws the entire texture on the seam-faces, I think...
|
||||
*/
|
||||
|
||||
var Icosahedron = function (subdivisions) {
|
||||
var Icosahedron = function ( subdivisions ) {
|
||||
|
||||
var scope = this;
|
||||
var tempScope = new THREE.Geometry();
|
||||
|
||||
@@ -82,6 +82,7 @@ EXTRAS_FILES = [
|
||||
'extras/primitives/Plane.js',
|
||||
'extras/primitives/Sphere.js',
|
||||
'extras/primitives/Torus.js',
|
||||
'extras/primitives/Icosahedron.js',
|
||||
'extras/primitives/LathedObject.js',
|
||||
'extras/io/Loader.js'
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user