mirror of
https://github.com/wahyd4/three.js.git
synced 2026-08-11 05:55:56 +10:00
Added simple scene format loader.
This is very much work in progress - expect things to change and to be broken.
This commit is contained in:
+161
-153
@@ -12,47 +12,47 @@ 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(H,p,I,l){l=l.clone().subSelf(p);I=I.clone().subSelf(p);var g=H.clone().subSelf(p);H=l.dot(l);p=l.dot(I);l=l.dot(g);var m=I.dot(I);I=I.dot(g);g=1/(H*m-p*p);m=(m*l-p*I)*g;H=(H*I-p*l)*g;return m>0&&H>0&&m+H<1}var d,e,f,h,j,c,i,k,r,z,
|
||||
n,u=a.geometry,x=u.vertices,y=[];d=0;for(e=u.faces.length;d<e;d++){f=u.faces[d];z=this.origin.clone();n=this.direction.clone();h=a.matrix.multiplyVector3(x[f.a].position.clone());j=a.matrix.multiplyVector3(x[f.b].position.clone());c=a.matrix.multiplyVector3(x[f.c].position.clone());i=f instanceof THREE.Face4?a.matrix.multiplyVector3(x[f.d].position.clone()):null;k=a.rotationMatrix.multiplyVector3(f.normal.clone());r=n.dot(k);if(r<0){k=k.dot((new THREE.Vector3).sub(h,z))/r;z=z.addSelf(n.multiplyScalar(k));
|
||||
if(f instanceof THREE.Face3){if(b(z,h,j,c)){f={distance:this.origin.distanceTo(z),point:z,face:f,object:a};y.push(f)}}else if(f instanceof THREE.Face4)if(b(z,h,j,i)||b(z,j,c,i)){f={distance:this.origin.distanceTo(z),point:z,face:f,object:a};y.push(f)}}}return y}};
|
||||
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(i,k,r,z){c=false;b=i;d=k;e=r;f=z;a()};this.addPoint=function(i,k){if(c){c=false;b=i;d=k;e=i;f=k}else{b=b<i?b:i;d=d<k?d:k;e=e>i?e:i;f=f>k?
|
||||
f:k}a()};this.add3Points=function(i,k,r,z,n,u){if(c){c=false;b=i<r?i<n?i:n:r<n?r:n;d=k<z?k<u?k:u:z<u?z:u;e=i>r?i>n?i:n:r>n?r:n;f=k>z?k>u?k:u:z>u?z:u}else{b=i<r?i<n?i<b?i:b:n<b?n:b:r<n?r<b?r:b:n<b?n:b;d=k<z?k<u?k<d?k:d:u<d?u:d:z<u?z<d?z:d:u<d?u:d;e=i>r?i>n?i>e?i:e:n>e?n:e:r>n?r>e?r:e:n>e?n:e;f=k>z?k>u?k>f?k:f:u>f?u:f:z>u?z>f?z:f:u>f?u:f}a()};this.addRectangle=function(i){if(c){c=false;b=i.getLeft();d=i.getTop();e=i.getRight();f=i.getBottom()}else{b=b<i.getLeft()?b:i.getLeft();d=d<i.getTop()?d:i.getTop();
|
||||
e=e>i.getRight()?e:i.getRight();f=f>i.getBottom()?f:i.getBottom()}a()};this.inflate=function(i){b-=i;d-=i;e+=i;f+=i;a()};this.minSelf=function(i){b=b>i.getLeft()?b:i.getLeft();d=d>i.getTop()?d:i.getTop();e=e<i.getRight()?e:i.getRight();f=f<i.getBottom()?f:i.getBottom();a()};this.instersects=function(i){return Math.min(e,i.getRight())-Math.max(b,i.getLeft())>=0&&Math.min(f,i.getBottom())-Math.max(d,i.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,i,k,r,z,n,u,x,y){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=i||0;this.n32=k||0;this.n33=r||1;this.n34=z||0;this.n41=n||0;this.n42=u||0;this.n43=x||0;this.n44=y||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,i,k,r,z,n,u,x,y){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=i;this.n32=k;this.n33=r;this.n34=z;this.n41=n;this.n42=u;this.n43=x;this.n44=y;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,i=a.n23,k=a.n24,r=a.n31,
|
||||
z=a.n32,n=a.n33,u=a.n34,x=a.n41,y=a.n42,H=a.n43,p=a.n44,I=b.n11,l=b.n12,g=b.n13,m=b.n14,w=b.n21,o=b.n22,v=b.n23,J=b.n24,s=b.n31,A=b.n32,C=b.n33,B=b.n34,t=b.n41,L=b.n42,F=b.n43,R=b.n44;this.n11=d*I+e*w+f*s+h*t;this.n12=d*l+e*o+f*A+h*L;this.n13=d*g+e*v+f*C+h*F;this.n14=d*m+e*J+f*B+h*R;this.n21=j*I+c*w+i*s+k*t;this.n22=j*l+c*o+i*A+k*L;this.n23=j*g+c*v+i*C+k*F;this.n24=j*m+c*J+i*B+k*R;this.n31=r*I+z*w+n*s+u*t;this.n32=r*l+z*o+n*A+u*L;this.n33=r*g+z*v+n*C+u*F;this.n34=r*m+z*J+n*B+u*R;this.n41=x*I+y*w+
|
||||
H*s+p*t;this.n42=x*l+y*o+H*A+p*L;this.n43=x*g+y*v+H*C+p*F;this.n44=x*m+y*J+H*B+p*R;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,i=this.n24,k=this.n31,r=this.n32,z=this.n33,n=this.n34,u=this.n41,x=this.n42,y=this.n43,H=this.n44,p=a.n11,I=a.n21,l=a.n31,g=a.n41,m=a.n12,w=a.n22,o=a.n32,v=a.n42,J=a.n13,s=a.n23,A=a.n33,C=a.n43,B=a.n14,t=a.n24,L=a.n34;a=a.n44;this.n11=b*p+d*I+e*l+f*g;this.n12=b*m+d*w+e*o+f*v;this.n13=b*J+d*s+e*A+f*
|
||||
C;this.n14=b*B+d*t+e*L+f*a;this.n21=h*p+j*I+c*l+i*g;this.n22=h*m+j*w+c*o+i*v;this.n23=h*J+j*s+c*A+i*C;this.n24=h*B+j*t+c*L+i*a;this.n31=k*p+r*I+z*l+n*g;this.n32=k*m+r*w+z*o+n*v;this.n33=k*J+r*s+z*A+n*C;this.n34=k*B+r*t+z*L+n*a;this.n41=u*p+x*I+y*l+H*g;this.n42=u*m+x*w+y*o+H*v;this.n43=u*J+x*s+y*A+H*C;this.n44=u*B+x*t+y*L+H*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=
|
||||
a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,d=this.n13,e=this.n14,f=this.n21,h=this.n22,j=this.n23,c=this.n24,i=this.n31,k=this.n32,r=this.n33,z=this.n34,n=this.n41,u=this.n42,x=this.n43,y=this.n44;return e*j*k*n-d*c*k*n-e*h*r*n+b*c*r*n+d*h*z*n-b*j*z*n-e*j*i*u+d*c*i*u+e*f*r*u-a*c*r*u-d*f*z*u+a*j*z*u+e*h*i*x-b*c*i*x-e*f*k*x+a*c*k*x+b*f*z*x-a*h*z*x-d*h*i*y+b*j*i*y+d*f*k*y-a*j*k*y-b*f*r*y+a*h*r*y},transpose:function(){function a(b,d,
|
||||
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(g,k){return g.distance-k.distance});return f},intersectObject:function(a){function b(H,v,I,m){m=m.clone().subSelf(v);I=I.clone().subSelf(v);var h=H.clone().subSelf(v);H=m.dot(m);v=m.dot(I);m=m.dot(h);var n=I.dot(I);I=I.dot(h);h=1/(H*n-v*v);n=(n*m-v*I)*h;H=(H*I-v*m)*h;return n>0&&H>0&&n+H<1}var d,e,f,g,k,c,j,l,t,D,
|
||||
o,u=a.geometry,w=u.vertices,C=[];d=0;for(e=u.faces.length;d<e;d++){f=u.faces[d];D=this.origin.clone();o=this.direction.clone();g=a.matrix.multiplyVector3(w[f.a].position.clone());k=a.matrix.multiplyVector3(w[f.b].position.clone());c=a.matrix.multiplyVector3(w[f.c].position.clone());j=f instanceof THREE.Face4?a.matrix.multiplyVector3(w[f.d].position.clone()):null;l=a.rotationMatrix.multiplyVector3(f.normal.clone());t=o.dot(l);if(t<0){l=l.dot((new THREE.Vector3).sub(g,D))/t;D=D.addSelf(o.multiplyScalar(l));
|
||||
if(f instanceof THREE.Face3){if(b(D,g,k,c)){f={distance:this.origin.distanceTo(D),point:D,face:f,object:a};C.push(f)}}else if(f instanceof THREE.Face4)if(b(D,g,k,j)||b(D,k,c,j)){f={distance:this.origin.distanceTo(D),point:D,face:f,object:a};C.push(f)}}}return C}};
|
||||
THREE.Rectangle=function(){function a(){g=e-b;k=f-d}var b,d,e,f,g,k,c=true;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return g};this.getHeight=function(){return k};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(j,l,t,D){c=false;b=j;d=l;e=t;f=D;a()};this.addPoint=function(j,l){if(c){c=false;b=j;d=l;e=j;f=l}else{b=b<j?b:j;d=d<l?d:l;e=e>j?e:j;f=f>l?
|
||||
f:l}a()};this.add3Points=function(j,l,t,D,o,u){if(c){c=false;b=j<t?j<o?j:o:t<o?t:o;d=l<D?l<u?l:u:D<u?D:u;e=j>t?j>o?j:o:t>o?t:o;f=l>D?l>u?l:u:D>u?D:u}else{b=j<t?j<o?j<b?j:b:o<b?o:b:t<o?t<b?t:b:o<b?o:b;d=l<D?l<u?l<d?l:d:u<d?u:d:D<u?D<d?D:d:u<d?u:d;e=j>t?j>o?j>e?j:e:o>e?o:e:t>o?t>e?t:e:o>e?o:e;f=l>D?l>u?l>f?l:f:u>f?u:f:D>u?D>f?D:f:u>f?u:f}a()};this.addRectangle=function(j){if(c){c=false;b=j.getLeft();d=j.getTop();e=j.getRight();f=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();d=d<j.getTop()?d:j.getTop();
|
||||
e=e>j.getRight()?e:j.getRight();f=f>j.getBottom()?f:j.getBottom()}a()};this.inflate=function(j){b-=j;d-=j;e+=j;f+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();d=d>j.getTop()?d:j.getTop();e=e<j.getRight()?e:j.getRight();f=f<j.getBottom()?f:j.getBottom();a()};this.instersects=function(j){return Math.min(e,j.getRight())-Math.max(b,j.getLeft())>=0&&Math.min(f,j.getBottom())-Math.max(d,j.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: "+g+", height: "+k+" )"}};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,g,k,c,j,l,t,D,o,u,w,C){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=f||0;this.n22=g||1;this.n23=k||0;this.n24=c||0;this.n31=j||0;this.n32=l||0;this.n33=t||1;this.n34=D||0;this.n41=o||0;this.n42=u||0;this.n43=w||0;this.n44=C||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,g,k,c,j,l,t,D,o,u,w,C){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=f;this.n22=g;this.n23=k;this.n24=c;this.n31=j;this.n32=l;this.n33=t;this.n34=D;this.n41=o;this.n42=u;this.n43=w;this.n44=C;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
|
||||
a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,d){var e=THREE.Matrix4.__tmpVec1,f=THREE.Matrix4.__tmpVec2,g=THREE.Matrix4.__tmpVec3;g.sub(a,b).normalize();e.cross(d,g).normalize();f.cross(g,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=g.x;this.n32=g.y;this.n33=g.z;this.n34=-g.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,g=a.n14,k=a.n21,c=a.n22,j=a.n23,l=a.n24,t=a.n31,
|
||||
D=a.n32,o=a.n33,u=a.n34,w=a.n41,C=a.n42,H=a.n43,v=a.n44,I=b.n11,m=b.n12,h=b.n13,n=b.n14,B=b.n21,q=b.n22,z=b.n23,M=b.n24,p=b.n31,A=b.n32,F=b.n33,E=b.n34,y=b.n41,O=b.n42,K=b.n43,U=b.n44;this.n11=d*I+e*B+f*p+g*y;this.n12=d*m+e*q+f*A+g*O;this.n13=d*h+e*z+f*F+g*K;this.n14=d*n+e*M+f*E+g*U;this.n21=k*I+c*B+j*p+l*y;this.n22=k*m+c*q+j*A+l*O;this.n23=k*h+c*z+j*F+l*K;this.n24=k*n+c*M+j*E+l*U;this.n31=t*I+D*B+o*p+u*y;this.n32=t*m+D*q+o*A+u*O;this.n33=t*h+D*z+o*F+u*K;this.n34=t*n+D*M+o*E+u*U;this.n41=w*I+C*B+
|
||||
H*p+v*y;this.n42=w*m+C*q+H*A+v*O;this.n43=w*h+C*z+H*F+v*K;this.n44=w*n+C*M+H*E+v*U;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,f=this.n14,g=this.n21,k=this.n22,c=this.n23,j=this.n24,l=this.n31,t=this.n32,D=this.n33,o=this.n34,u=this.n41,w=this.n42,C=this.n43,H=this.n44,v=a.n11,I=a.n21,m=a.n31,h=a.n41,n=a.n12,B=a.n22,q=a.n32,z=a.n42,M=a.n13,p=a.n23,A=a.n33,F=a.n43,E=a.n14,y=a.n24,O=a.n34;a=a.n44;this.n11=b*v+d*I+e*m+f*h;this.n12=b*n+d*B+e*q+f*z;this.n13=b*M+d*p+e*A+f*
|
||||
F;this.n14=b*E+d*y+e*O+f*a;this.n21=g*v+k*I+c*m+j*h;this.n22=g*n+k*B+c*q+j*z;this.n23=g*M+k*p+c*A+j*F;this.n24=g*E+k*y+c*O+j*a;this.n31=l*v+t*I+D*m+o*h;this.n32=l*n+t*B+D*q+o*z;this.n33=l*M+t*p+D*A+o*F;this.n34=l*E+t*y+D*O+o*a;this.n41=u*v+w*I+C*m+H*h;this.n42=u*n+w*B+C*q+H*z;this.n43=u*M+w*p+C*A+H*F;this.n44=u*E+w*y+C*O+H*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=
|
||||
a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,d=this.n13,e=this.n14,f=this.n21,g=this.n22,k=this.n23,c=this.n24,j=this.n31,l=this.n32,t=this.n33,D=this.n34,o=this.n41,u=this.n42,w=this.n43,C=this.n44;return e*k*l*o-d*c*l*o-e*g*t*o+b*c*t*o+d*g*D*o-b*k*D*o-e*k*j*u+d*c*j*u+e*f*t*u-a*c*t*u-d*f*D*u+a*k*D*u+e*g*j*w-b*c*j*w-e*f*l*w+a*c*l*w+b*f*D*w-a*g*D*w-d*g*j*C+b*k*j*C+d*f*l*C-a*k*l*C-b*f*t*C+a*g*t*C},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;
|
||||
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,i=f*h,k=f*j;this.set(i*h+d,i*j-e*c,i*c+e*j,0,i*j+e*c,k*j+d,k*c-e*h,0,i*c-e*j,k*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),f=1-d,g=a.x,k=a.y,c=a.z,j=f*g,l=f*k;this.set(j*g+d,j*k-e*c,j*c+e*k,0,j*k+e*c,l*k+d,l*c-e*g,0,j*c-e*k,l*c+e*g,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+" "+
|
||||
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,i=a.n24,k=a.n31,r=a.n32,z=a.n33,n=a.n34,u=a.n41,x=a.n42,y=a.n43,H=a.n44,p=new THREE.Matrix4;p.n11=c*n*x-i*z*x+i*r*y-j*n*y-c*r*H+j*z*H;p.n12=f*z*x-e*n*x-f*r*y+d*n*y+e*r*H-d*z*H;p.n13=e*i*x-f*c*x+f*j*y-d*i*y-e*j*H+d*c*H;p.n14=f*c*r-e*i*r-f*j*z+d*i*z+e*j*n-d*c*n;p.n21=i*z*u-c*n*u-i*k*y+h*n*y+c*k*H-h*z*H;p.n22=e*n*u-f*z*u+f*k*y-b*n*y-e*k*H+b*z*H;p.n23=f*c*u-e*i*u-f*h*y+b*i*y+e*h*H-b*c*H;p.n24=e*i*k-f*c*k+
|
||||
f*h*z-b*i*z-e*h*n+b*c*n;p.n31=j*n*u-i*r*u+i*k*x-h*n*x-j*k*H+h*r*H;p.n32=f*r*u-d*n*u-f*k*x+b*n*x+d*k*H-b*r*H;p.n33=e*i*u-f*j*u+f*h*x-b*i*x-d*h*H+b*j*H;p.n34=f*j*k-d*i*k-f*h*r+b*i*r+d*h*n-b*j*n;p.n41=c*r*u-j*z*u-c*k*x+h*z*x+j*k*y-h*r*y;p.n42=d*z*u-e*r*u+e*k*x-b*z*x-d*k*y+b*r*y;p.n43=e*j*u-d*c*u-e*h*x+b*c*x+d*h*y-b*j*y;p.n44=d*c*k-e*j*k+e*h*r-b*c*r-d*h*z+b*j*z;p.multiplyScalar(1/a.determinant());return p};
|
||||
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],i=-b[6]*b[0]+b[2]*b[4],k=b[9]*b[4]-b[5]*b[8],r=-b[9]*b[0]+b[1]*b[8],z=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*j+b[2]*k;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*i;d[6]=b*k;d[7]=b*r;d[8]=b*z;return a};
|
||||
THREE.Matrix4.makeFrustum=function(a,b,d,e,f,h){var j,c,i;j=new THREE.Matrix4;c=2*f/(b-a);i=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=i;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,i,k;j=new THREE.Matrix4;c=b-a;i=d-e;k=h-f;a=(b+a)/c;d=(d+e)/i;f=(h+f)/k;j.n11=2/c;j.n12=0;j.n13=0;j.n14=-a;j.n21=0;j.n22=2/i;j.n23=0;j.n24=-d;j.n31=0;j.n32=0;j.n33=-2/k;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,f=a.n14,g=a.n21,k=a.n22,c=a.n23,j=a.n24,l=a.n31,t=a.n32,D=a.n33,o=a.n34,u=a.n41,w=a.n42,C=a.n43,H=a.n44,v=new THREE.Matrix4;v.n11=c*o*w-j*D*w+j*t*C-k*o*C-c*t*H+k*D*H;v.n12=f*D*w-e*o*w-f*t*C+d*o*C+e*t*H-d*D*H;v.n13=e*j*w-f*c*w+f*k*C-d*j*C-e*k*H+d*c*H;v.n14=f*c*t-e*j*t-f*k*D+d*j*D+e*k*o-d*c*o;v.n21=j*D*u-c*o*u-j*l*C+g*o*C+c*l*H-g*D*H;v.n22=e*o*u-f*D*u+f*l*C-b*o*C-e*l*H+b*D*H;v.n23=f*c*u-e*j*u-f*g*C+b*j*C+e*g*H-b*c*H;v.n24=e*j*l-f*c*l+
|
||||
f*g*D-b*j*D-e*g*o+b*c*o;v.n31=k*o*u-j*t*u+j*l*w-g*o*w-k*l*H+g*t*H;v.n32=f*t*u-d*o*u-f*l*w+b*o*w+d*l*H-b*t*H;v.n33=e*j*u-f*k*u+f*g*w-b*j*w-d*g*H+b*k*H;v.n34=f*k*l-d*j*l-f*g*t+b*j*t+d*g*o-b*k*o;v.n41=c*t*u-k*D*u-c*l*w+g*D*w+k*l*C-g*t*C;v.n42=d*D*u-e*t*u+e*l*w-b*D*w-d*l*C+b*t*C;v.n43=e*k*u-d*c*u-e*g*w+b*c*w+d*g*C-b*k*C;v.n44=d*c*l-e*k*l+e*g*t-b*c*t-d*g*D+b*k*D;v.multiplyScalar(1/a.determinant());return v};
|
||||
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],g=b[6]*b[1]-b[2]*b[5],k=-b[10]*b[4]+b[6]*b[8],c=b[10]*b[0]-b[2]*b[8],j=-b[6]*b[0]+b[2]*b[4],l=b[9]*b[4]-b[5]*b[8],t=-b[9]*b[0]+b[1]*b[8],D=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*k+b[2]*l;if(b==0)throw"matrix not invertible";b=1/b;d[0]=b*e;d[1]=b*f;d[2]=b*g;d[3]=b*k;d[4]=b*c;d[5]=b*j;d[6]=b*l;d[7]=b*t;d[8]=b*D;return a};
|
||||
THREE.Matrix4.makeFrustum=function(a,b,d,e,f,g){var k,c,j;k=new THREE.Matrix4;c=2*f/(b-a);j=2*f/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(g+f)/(g-f);f=-2*g*f/(g-f);k.n11=c;k.n12=0;k.n13=a;k.n14=0;k.n21=0;k.n22=j;k.n23=d;k.n24=0;k.n31=0;k.n32=0;k.n33=e;k.n34=f;k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};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,g){var k,c,j,l;k=new THREE.Matrix4;c=b-a;j=d-e;l=g-f;a=(b+a)/c;d=(d+e)/j;f=(g+f)/l;k.n11=2/c;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/j;k.n23=0;k.n24=-d;k.n31=0;k.n32=0;k.n33=-2/l;k.n34=-f;k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};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.Face4=function(a,b,d,e,f,g){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=g instanceof Array?g:[g]};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,i=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);i.sub(b.position,d.position);c.crossSelf(i)}c.isZero()||c.normalize();h.normal.copy(c)}},computeVertexNormals:function(){var a,b,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)e[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
|
||||
d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,f,g,k,c=new THREE.Vector3,j=new THREE.Vector3;e=0;for(f=this.vertices.length;e<f;e++){g=this.vertices[e];g.normal.set(0,0,0)}e=0;for(f=this.faces.length;e<f;e++){g=this.faces[e];if(a&&g.vertexNormals.length){c.set(0,0,0);b=0;for(d=g.normal.length;b<d;b++)c.addSelf(g.vertexNormals[b]);c.divideScalar(3)}else{b=this.vertices[g.a];d=this.vertices[g.b];k=this.vertices[g.c];c.sub(k.position,
|
||||
d.position);j.sub(b.position,d.position);c.crossSelf(j)}c.isZero()||c.normalize();g.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(B,t,L,F,R,T,M){h=B.vertices[t].position;j=B.vertices[L].position;c=B.vertices[F].position;i=f[R];k=f[T];r=f[M];z=j.x-h.x;n=c.x-h.x;u=j.y-h.y;x=c.y-h.y;
|
||||
y=j.z-h.z;H=c.z-h.z;p=k.u-i.u;I=r.u-i.u;l=k.v-i.v;g=r.v-i.v;m=1/(p*g-I*l);v.set((g*z-l*n)*m,(g*u-l*x)*m,(g*y-l*H)*m);J.set((p*n-I*z)*m,(p*x-I*u)*m,(p*H-I*y)*m);w[t].addSelf(v);w[L].addSelf(v);w[F].addSelf(v);o[t].addSelf(J);o[L].addSelf(J);o[F].addSelf(J)}var b,d,e,f,h,j,c,i,k,r,z,n,u,x,y,H,p,I,l,g,m,w=[],o=[],v=new THREE.Vector3,J=new THREE.Vector3,s=new THREE.Vector3,A=new THREE.Vector3,C=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++){w[b]=new THREE.Vector3;o[b]=new THREE.Vector3}b=0;
|
||||
b;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(E,y,O,K,U,W,P){g=E.vertices[y].position;k=E.vertices[O].position;c=E.vertices[K].position;j=f[U];l=f[W];t=f[P];D=k.x-g.x;o=c.x-g.x;u=k.y-g.y;w=c.y-g.y;
|
||||
C=k.z-g.z;H=c.z-g.z;v=l.u-j.u;I=t.u-j.u;m=l.v-j.v;h=t.v-j.v;n=1/(v*h-I*m);z.set((h*D-m*o)*n,(h*u-m*w)*n,(h*C-m*H)*n);M.set((v*o-I*D)*n,(v*w-I*u)*n,(v*H-I*C)*n);B[y].addSelf(z);B[O].addSelf(z);B[K].addSelf(z);q[y].addSelf(M);q[O].addSelf(M);q[K].addSelf(M)}var b,d,e,f,g,k,c,j,l,t,D,o,u,w,C,H,v,I,m,h,n,B=[],q=[],z=new THREE.Vector3,M=new THREE.Vector3,p=new THREE.Vector3,A=new THREE.Vector3,F=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++){C.copy(this.vertices[b].normal);e=w[b];s.copy(e);s.subSelf(C.multiplyScalar(C.dot(e))).normalize();A.cross(this.vertices[b].normal,e);e=A.dot(o[b]);e=e<0?-1:1;this.vertices[b].tangent.set(s.x,s.y,s.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
|
||||
this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(d=this.vertices.length;b<d;b++){F.copy(this.vertices[b].normal);e=B[b];p.copy(e);p.subSelf(F.multiplyScalar(F.dot(e))).normalize();A.cross(this.vertices[b].normal,e);e=A.dot(q[b]);e=e<0?-1:1;this.vertices[b].tangent.set(p.x,p.y,p.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
|
||||
z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,d=this.vertices.length;b<d;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
|
||||
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(r){var z=[];b=0;for(d=r.length;b<d;b++)r[b]==undefined?z.push("undefined"):z.push(r[b].toString());return z.join("_")}var b,d,e,f,h,j,c,i,k={};e=0;for(f=this.faces.length;e<f;e++){h=this.faces[e];
|
||||
j=h.materials;c=a(j);if(k[c]==undefined)k[c]={hash:c,counter:0};i=k[c].hash+"_"+k[c].counter;if(this.geometryChunks[i]==undefined)this.geometryChunks[i]={faces:[],materials:j,vertices:0};h=h instanceof THREE.Face3?3:4;if(this.geometryChunks[i].vertices+h>65535){k[c].counter+=1;i=k[c].hash+"_"+k[c].counter;if(this.geometryChunks[i]==undefined)this.geometryChunks[i]={faces:[],materials:j,vertices:0}}this.geometryChunks[i].faces.push(e);this.geometryChunks[i].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(t){var D=[];b=0;for(d=t.length;b<d;b++)t[b]==undefined?D.push("undefined"):D.push(t[b].toString());return D.join("_")}var b,d,e,f,g,k,c,j,l={};e=0;for(f=this.faces.length;e<f;e++){g=this.faces[e];
|
||||
k=g.materials;c=a(k);if(l[c]==undefined)l[c]={hash:c,counter:0};j=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:k,vertices:0};g=g instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+g>65535){l[c].counter+=1;j=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:k,vertices:0}}this.geometryChunks[j].faces.push(e);this.geometryChunks[j].vertices+=g}},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()};
|
||||
@@ -89,7 +89,7 @@ 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,f,g){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=g!==undefined?g: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};
|
||||
@@ -97,93 +97,94 @@ var Uniforms={clone:function(a){var b,d,e,f={};for(b in a){f[b]={};for(d in a[b]
|
||||
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
|
||||
THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
|
||||
THREE.Fog=function(a,b,d){this.color=new THREE.Color(a);this.near=b||1;this.far=d||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
|
||||
THREE.Projector=function(){function a(o,v){return v.z-o.z}function b(o,v){var J=0,s=1,A=o.z+o.w,C=v.z+v.w,B=-o.z+o.w,t=-v.z+v.w;if(A>=0&&C>=0&&B>=0&&t>=0)return true;else if(A<0&&C<0||B<0&&t<0)return false;else{if(A<0)J=Math.max(J,A/(A-C));else if(C<0)s=Math.min(s,A/(A-C));if(B<0)J=Math.max(J,B/(B-t));else if(t<0)s=Math.min(s,B/(B-t));if(s<J)return false;else{o.lerpSelf(v,J);v.lerpSelf(o,1-s);return true}}}var d,e,f=[],h,j,c,i=[],k,r,z=[],n,u,x=[],y=new THREE.Vector4,H=new THREE.Vector4,p=new THREE.Matrix4,
|
||||
I=new THREE.Matrix4,l=[],g=new THREE.Vector4,m=new THREE.Vector4,w;this.projectObjects=function(o,v,J){var s=[],A,C;e=0;p.multiply(v.projectionMatrix,v.matrix);l[0]=new THREE.Vector4(p.n41-p.n11,p.n42-p.n12,p.n43-p.n13,p.n44-p.n14);l[1]=new THREE.Vector4(p.n41+p.n11,p.n42+p.n12,p.n43+p.n13,p.n44+p.n14);l[2]=new THREE.Vector4(p.n41+p.n21,p.n42+p.n22,p.n43+p.n23,p.n44+p.n24);l[3]=new THREE.Vector4(p.n41-p.n21,p.n42-p.n22,p.n43-p.n23,p.n44-p.n24);l[4]=new THREE.Vector4(p.n41-p.n31,p.n42-p.n32,p.n43-
|
||||
p.n33,p.n44-p.n34);l[5]=new THREE.Vector4(p.n41+p.n31,p.n42+p.n32,p.n43+p.n33,p.n44+p.n34);v=0;for(A=l.length;v<A;v++){C=l[v];C.divideScalar(Math.sqrt(C.x*C.x+C.y*C.y+C.z*C.z))}A=o.objects;o=0;for(v=A.length;o<v;o++){C=A[o];var B;if(!(B=!C.visible)){if(B=C instanceof THREE.Mesh){a:{B=void 0;for(var t=C.position,L=-C.geometry.boundingSphere.radius*Math.max(C.scale.x,Math.max(C.scale.y,C.scale.z)),F=0;F<6;F++){B=l[F].x*t.x+l[F].y*t.y+l[F].z*t.z+l[F].w;if(B<=L){B=false;break a}}B=true}B=!B}B=B}if(!B){d=
|
||||
f[e]=f[e]||new THREE.RenderableObject;y.copy(C.position);p.multiplyVector3(y);d.object=C;d.z=y.z;s.push(d);e++}}J&&s.sort(a);return s};this.projectScene=function(o,v,J){var s=[],A=v.near,C=v.far,B,t,L,F,R,T,M,aa,U,O,Q,Z,V,D,P,S;c=r=u=0;v.autoUpdateMatrix&&v.updateMatrix();p.multiply(v.projectionMatrix,v.matrix);T=this.projectObjects(o,v,true);o=0;for(B=T.length;o<B;o++){M=T[o].object;if(M.visible){M.autoUpdateMatrix&&M.updateMatrix();aa=M.matrix;U=M.rotationMatrix;O=M.materials;Q=M.overdraw;if(M instanceof
|
||||
THREE.Mesh){Z=M.geometry;V=Z.vertices;t=0;for(L=V.length;t<L;t++){D=V[t];D.positionWorld.copy(D.position);aa.multiplyVector3(D.positionWorld);F=D.positionScreen;F.copy(D.positionWorld);p.multiplyVector4(F);F.x/=F.w;F.y/=F.w;D.__visible=F.z>A&&F.z<C}Z=Z.faces;t=0;for(L=Z.length;t<L;t++){D=Z[t];if(D instanceof THREE.Face3){F=V[D.a];R=V[D.b];P=V[D.c];if(F.__visible&&R.__visible&&P.__visible)if(M.doubleSided||M.flipSided!=(P.positionScreen.x-F.positionScreen.x)*(R.positionScreen.y-F.positionScreen.y)-
|
||||
(P.positionScreen.y-F.positionScreen.y)*(R.positionScreen.x-F.positionScreen.x)<0){h=i[c]=i[c]||new THREE.RenderableFace3;h.v1.positionWorld.copy(F.positionWorld);h.v2.positionWorld.copy(R.positionWorld);h.v3.positionWorld.copy(P.positionWorld);h.v1.positionScreen.copy(F.positionScreen);h.v2.positionScreen.copy(R.positionScreen);h.v3.positionScreen.copy(P.positionScreen);h.normalWorld.copy(D.normal);U.multiplyVector3(h.normalWorld);h.centroidWorld.copy(D.centroid);aa.multiplyVector3(h.centroidWorld);
|
||||
h.centroidScreen.copy(h.centroidWorld);p.multiplyVector3(h.centroidScreen);P=D.vertexNormals;w=h.vertexNormalsWorld;F=0;for(R=P.length;F<R;F++){S=w[F]=w[F]||new THREE.Vector3;S.copy(P[F]);U.multiplyVector3(S)}h.z=h.centroidScreen.z;h.meshMaterials=O;h.faceMaterials=D.materials;h.overdraw=Q;if(M.geometry.uvs[t]){h.uvs[0]=M.geometry.uvs[t][0];h.uvs[1]=M.geometry.uvs[t][1];h.uvs[2]=M.geometry.uvs[t][2]}s.push(h);c++}}else if(D instanceof THREE.Face4){F=V[D.a];R=V[D.b];P=V[D.c];S=V[D.d];if(F.__visible&&
|
||||
R.__visible&&P.__visible&&S.__visible)if(M.doubleSided||M.flipSided!=((S.positionScreen.x-F.positionScreen.x)*(R.positionScreen.y-F.positionScreen.y)-(S.positionScreen.y-F.positionScreen.y)*(R.positionScreen.x-F.positionScreen.x)<0||(R.positionScreen.x-P.positionScreen.x)*(S.positionScreen.y-P.positionScreen.y)-(R.positionScreen.y-P.positionScreen.y)*(S.positionScreen.x-P.positionScreen.x)<0)){h=i[c]=i[c]||new THREE.RenderableFace3;h.v1.positionWorld.copy(F.positionWorld);h.v2.positionWorld.copy(R.positionWorld);
|
||||
h.v3.positionWorld.copy(S.positionWorld);h.v1.positionScreen.copy(F.positionScreen);h.v2.positionScreen.copy(R.positionScreen);h.v3.positionScreen.copy(S.positionScreen);h.normalWorld.copy(D.normal);U.multiplyVector3(h.normalWorld);h.centroidWorld.copy(D.centroid);aa.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);p.multiplyVector3(h.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=O;h.faceMaterials=D.materials;h.overdraw=Q;if(M.geometry.uvs[t]){h.uvs[0]=M.geometry.uvs[t][0];
|
||||
h.uvs[1]=M.geometry.uvs[t][1];h.uvs[2]=M.geometry.uvs[t][3]}s.push(h);c++;j=i[c]=i[c]||new THREE.RenderableFace3;j.v1.positionWorld.copy(R.positionWorld);j.v2.positionWorld.copy(P.positionWorld);j.v3.positionWorld.copy(S.positionWorld);j.v1.positionScreen.copy(R.positionScreen);j.v2.positionScreen.copy(P.positionScreen);j.v3.positionScreen.copy(S.positionScreen);j.normalWorld.copy(h.normalWorld);j.centroidWorld.copy(h.centroidWorld);j.centroidScreen.copy(h.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=
|
||||
O;j.faceMaterials=D.materials;j.overdraw=Q;if(M.geometry.uvs[t]){j.uvs[0]=M.geometry.uvs[t][1];j.uvs[1]=M.geometry.uvs[t][2];j.uvs[2]=M.geometry.uvs[t][3]}s.push(j);c++}}}}else if(M instanceof THREE.Line){I.multiply(p,aa);V=M.geometry.vertices;D=V[0];D.positionScreen.copy(D.position);I.multiplyVector4(D.positionScreen);t=1;for(L=V.length;t<L;t++){F=V[t];F.positionScreen.copy(F.position);I.multiplyVector4(F.positionScreen);R=V[t-1];g.copy(F.positionScreen);m.copy(R.positionScreen);if(b(g,m)){g.multiplyScalar(1/
|
||||
g.w);m.multiplyScalar(1/m.w);k=z[r]=z[r]||new THREE.RenderableLine;k.v1.positionScreen.copy(g);k.v2.positionScreen.copy(m);k.z=Math.max(g.z,m.z);k.materials=M.materials;s.push(k);r++}}}else if(M instanceof THREE.Particle){H.set(M.position.x,M.position.y,M.position.z,1);p.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){n=x[u]=x[u]||new THREE.RenderableParticle;n.x=H.x/H.w;n.y=H.y/H.w;n.z=H.z;n.rotation=M.rotation.z;n.scale.x=M.scale.x*Math.abs(n.x-(H.x+v.projectionMatrix.n11)/(H.w+v.projectionMatrix.n14));
|
||||
n.scale.y=M.scale.y*Math.abs(n.y-(H.y+v.projectionMatrix.n22)/(H.w+v.projectionMatrix.n24));n.materials=M.materials;s.push(n);u++}}}}J&&s.sort(a);return s};this.unprojectVector=function(o,v){var J=THREE.Matrix4.makeInvert(v.matrix);J.multiplySelf(THREE.Matrix4.makeInvert(v.projectionMatrix));J.multiplyVector3(o);return o}};
|
||||
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 i,k,r,z,n,u,x,y;a=b.projectScene(j,c);i=0;for(k=a.length;i<k;i++){n=a[i];if(n instanceof THREE.RenderableParticle){x=n.x*f+f;y=n.y*h+h;r=0;for(z=n.material.length;r<z;r++){u=n.material[r];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=x+"px";u.style.top=y+"px"}}}}}};
|
||||
THREE.CanvasRenderer=function(){function a(ja){if(n!=ja)k.globalAlpha=n=ja}function b(ja){if(u!=ja){switch(ja){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}u=ja}}var d=null,e=new THREE.Projector,f=document.createElement("canvas"),h,j,c,i,k=f.getContext("2d"),r=null,z=null,n=1,u=0,x=null,y=null,H=1,p,I,l,g,m,w,o,v,J,s=new THREE.Color,
|
||||
A=new THREE.Color,C=new THREE.Color,B=new THREE.Color,t=new THREE.Color,L,F,R,T,M,aa,U,O,Q,Z=new THREE.Rectangle,V=new THREE.Rectangle,D=new THREE.Rectangle,P=false,S=new THREE.Color,fa=new THREE.Color,ea=new THREE.Color,q=new THREE.Color,G=Math.PI*2,E=new THREE.Vector3,W,$,da,ga,na,pa,va=16;W=document.createElement("canvas");W.width=W.height=2;$=W.getContext("2d");$.fillStyle="rgba(0,0,0,1)";$.fillRect(0,0,2,2);da=$.getImageData(0,0,2,2);ga=da.data;na=document.createElement("canvas");na.width=na.height=
|
||||
va;pa=na.getContext("2d");pa.translate(-va/2,-va/2);pa.scale(va,va);va--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ja,ta){h=ja;j=ta;c=h/2;i=j/2;f.width=h;f.height=j;Z.set(-c,-i,c,i);n=1;u=0;y=x=null;H=1};this.setClearColor=function(ja,ta){r=ja!==null?new THREE.Color(ja):null;z=ta;V.set(-c,-i,c,i);k.setTransform(1,0,0,-1,c,i);this.clear()};this.clear=function(){if(!V.isEmpty()){V.inflate(1);V.minSelf(Z);if(r!==null){b(THREE.NormalBlending);a(1);
|
||||
k.fillStyle="rgba("+Math.floor(r.r*255)+","+Math.floor(r.g*255)+","+Math.floor(r.b*255)+","+z+")";k.fillRect(V.getX(),V.getY(),V.getWidth(),V.getHeight())}else k.clearRect(V.getX(),V.getY(),V.getWidth(),V.getHeight());V.empty()}};this.render=function(ja,ta){function Ma(K){var ba,Y,N,X=K.lights;fa.setRGB(0,0,0);ea.setRGB(0,0,0);q.setRGB(0,0,0);K=0;for(ba=X.length;K<ba;K++){Y=X[K];N=Y.color;if(Y instanceof THREE.AmbientLight){fa.r+=N.r;fa.g+=N.g;fa.b+=N.b}else if(Y instanceof THREE.DirectionalLight){ea.r+=
|
||||
N.r;ea.g+=N.g;ea.b+=N.b}else if(Y instanceof THREE.PointLight){q.r+=N.r;q.g+=N.g;q.b+=N.b}}}function Aa(K,ba,Y,N){var X,ca,ia,ka,la=K.lights;K=0;for(X=la.length;K<X;K++){ca=la[K];ia=ca.color;ka=ca.intensity;if(ca instanceof THREE.DirectionalLight){ca=Y.dot(ca.position)*ka;if(ca>0){N.r+=ia.r*ca;N.g+=ia.g*ca;N.b+=ia.b*ca}}else if(ca instanceof THREE.PointLight){E.sub(ca.position,ba);E.normalize();ca=Y.dot(E)*ka;if(ca>0){N.r+=ia.r*ca;N.g+=ia.g*ca;N.b+=ia.b*ca}}}}function Na(K,ba,Y){if(Y.opacity!=0){a(Y.opacity);
|
||||
b(Y.blending);var N,X,ca,ia,ka,la;if(Y instanceof THREE.ParticleBasicMaterial){if(Y.map){ia=Y.map;ka=ia.width>>1;la=ia.height>>1;X=ba.scale.x*c;ca=ba.scale.y*i;Y=X*ka;N=ca*la;D.set(K.x-Y,K.y-N,K.x+Y,K.y+N);if(Z.instersects(D)){k.save();k.translate(K.x,K.y);k.rotate(-ba.rotation);k.scale(X,-ca);k.translate(-ka,-la);k.drawImage(ia,0,0);k.restore()}}}else if(Y instanceof THREE.ParticleCircleMaterial){if(P){S.r=fa.r+ea.r+q.r;S.g=fa.g+ea.g+q.g;S.b=fa.b+ea.b+q.b;s.r=Y.color.r*S.r;s.g=Y.color.g*S.g;s.b=
|
||||
Y.color.b*S.b;s.updateStyleString()}else s.__styleString=Y.color.__styleString;Y=ba.scale.x*c;N=ba.scale.y*i;D.set(K.x-Y,K.y-N,K.x+Y,K.y+N);if(Z.instersects(D)){X=s.__styleString;if(y!=X)k.fillStyle=y=X;k.save();k.translate(K.x,K.y);k.rotate(-ba.rotation);k.scale(Y,N);k.beginPath();k.arc(0,0,1,0,G,true);k.closePath();k.fill();k.restore()}}}}function Oa(K,ba,Y,N){if(N.opacity!=0){a(N.opacity);b(N.blending);k.beginPath();k.moveTo(K.positionScreen.x,K.positionScreen.y);k.lineTo(ba.positionScreen.x,ba.positionScreen.y);
|
||||
k.closePath();if(N instanceof THREE.LineBasicMaterial){s.__styleString=N.color.__styleString;K=N.linewidth;if(H!=K)k.lineWidth=H=K;K=s.__styleString;if(x!=K)k.strokeStyle=x=K;k.stroke();D.inflate(N.linewidth*2)}}}function Ia(K,ba,Y,N,X,ca){if(X.opacity!=0){a(X.opacity);b(X.blending);g=K.positionScreen.x;m=K.positionScreen.y;w=ba.positionScreen.x;o=ba.positionScreen.y;v=Y.positionScreen.x;J=Y.positionScreen.y;k.beginPath();k.moveTo(g,m);k.lineTo(w,o);k.lineTo(v,J);k.lineTo(g,m);k.closePath();if(X instanceof
|
||||
THREE.MeshBasicMaterial)if(X.map)X.map.image.loaded&&X.map.mapping instanceof THREE.UVMapping&&xa(g,m,w,o,v,J,X.map.image,N.uvs[0].u,N.uvs[0].v,N.uvs[1].u,N.uvs[1].v,N.uvs[2].u,N.uvs[2].v);else if(X.env_map){if(X.env_map.image.loaded)if(X.env_map.mapping instanceof THREE.SphericalReflectionMapping){K=ta.matrix;E.copy(N.vertexNormalsWorld[0]);T=(E.x*K.n11+E.y*K.n12+E.z*K.n13)*0.5+0.5;M=-(E.x*K.n21+E.y*K.n22+E.z*K.n23)*0.5+0.5;E.copy(N.vertexNormalsWorld[1]);aa=(E.x*K.n11+E.y*K.n12+E.z*K.n13)*0.5+0.5;
|
||||
U=-(E.x*K.n21+E.y*K.n22+E.z*K.n23)*0.5+0.5;E.copy(N.vertexNormalsWorld[2]);O=(E.x*K.n11+E.y*K.n12+E.z*K.n13)*0.5+0.5;Q=-(E.x*K.n21+E.y*K.n22+E.z*K.n23)*0.5+0.5;xa(g,m,w,o,v,J,X.env_map.image,T,M,aa,U,O,Q)}}else X.wireframe?Ba(X.color.__styleString,X.wireframe_linewidth):Ca(X.color.__styleString);else if(X instanceof THREE.MeshLambertMaterial){if(X.map&&!X.wireframe){X.map.mapping instanceof THREE.UVMapping&&xa(g,m,w,o,v,J,X.map.image,N.uvs[0].u,N.uvs[0].v,N.uvs[1].u,N.uvs[1].v,N.uvs[2].u,N.uvs[2].v);
|
||||
b(THREE.SubtractiveBlending)}if(P)if(!X.wireframe&&X.shading==THREE.SmoothShading&&N.vertexNormalsWorld.length==3){A.r=C.r=B.r=fa.r;A.g=C.g=B.g=fa.g;A.b=C.b=B.b=fa.b;Aa(ca,N.v1.positionWorld,N.vertexNormalsWorld[0],A);Aa(ca,N.v2.positionWorld,N.vertexNormalsWorld[1],C);Aa(ca,N.v3.positionWorld,N.vertexNormalsWorld[2],B);t.r=(C.r+B.r)*0.5;t.g=(C.g+B.g)*0.5;t.b=(C.b+B.b)*0.5;R=Ja(A,C,B,t);xa(g,m,w,o,v,J,R,0,0,1,0,0,1)}else{S.r=fa.r;S.g=fa.g;S.b=fa.b;Aa(ca,N.centroidWorld,N.normalWorld,S);s.r=X.color.r*
|
||||
S.r;s.g=X.color.g*S.g;s.b=X.color.b*S.b;s.updateStyleString();X.wireframe?Ba(s.__styleString,X.wireframe_linewidth):Ca(s.__styleString)}else X.wireframe?Ba(X.color.__styleString,X.wireframe_linewidth):Ca(X.color.__styleString)}else if(X instanceof THREE.MeshDepthMaterial){L=ta.near;F=ta.far;A.r=A.g=A.b=1-Ea(K.positionScreen.z,L,F);C.r=C.g=C.b=1-Ea(ba.positionScreen.z,L,F);B.r=B.g=B.b=1-Ea(Y.positionScreen.z,L,F);t.r=(C.r+B.r)*0.5;t.g=(C.g+B.g)*0.5;t.b=(C.b+B.b)*0.5;R=Ja(A,C,B,t);xa(g,m,w,o,v,J,R,
|
||||
0,0,1,0,0,1)}else if(X instanceof THREE.MeshNormalMaterial){s.r=Fa(N.normalWorld.x);s.g=Fa(N.normalWorld.y);s.b=Fa(N.normalWorld.z);s.updateStyleString();X.wireframe?Ba(s.__styleString,X.wireframe_linewidth):Ca(s.__styleString)}}}function Ba(K,ba){if(x!=K)k.strokeStyle=x=K;if(H!=ba)k.lineWidth=H=ba;k.stroke();D.inflate(ba*2)}function Ca(K){if(y!=K)k.fillStyle=y=K;k.fill()}function xa(K,ba,Y,N,X,ca,ia,ka,la,qa,ma,ra,ya){var ua,sa;ua=ia.width-1;sa=ia.height-1;ka*=ua;la*=sa;qa*=ua;ma*=sa;ra*=ua;ya*=
|
||||
sa;Y-=K;N-=ba;X-=K;ca-=ba;qa-=ka;ma-=la;ra-=ka;ya-=la;sa=1/(qa*ya-ra*ma);ua=(ya*Y-ma*X)*sa;ma=(ya*N-ma*ca)*sa;Y=(qa*X-ra*Y)*sa;N=(qa*ca-ra*N)*sa;K=K-ua*ka-Y*la;ba=ba-ma*ka-N*la;k.save();k.transform(ua,ma,Y,N,K,ba);k.clip();k.drawImage(ia,0,0);k.restore()}function Ja(K,ba,Y,N){var X=~~(K.r*255),ca=~~(K.g*255);K=~~(K.b*255);var ia=~~(ba.r*255),ka=~~(ba.g*255);ba=~~(ba.b*255);var la=~~(Y.r*255),qa=~~(Y.g*255);Y=~~(Y.b*255);var ma=~~(N.r*255),ra=~~(N.g*255);N=~~(N.b*255);ga[0]=X<0?0:X>255?255:X;ga[1]=
|
||||
ca<0?0:ca>255?255:ca;ga[2]=K<0?0:K>255?255:K;ga[4]=ia<0?0:ia>255?255:ia;ga[5]=ka<0?0:ka>255?255:ka;ga[6]=ba<0?0:ba>255?255:ba;ga[8]=la<0?0:la>255?255:la;ga[9]=qa<0?0:qa>255?255:qa;ga[10]=Y<0?0:Y>255?255:Y;ga[12]=ma<0?0:ma>255?255:ma;ga[13]=ra<0?0:ra>255?255:ra;ga[14]=N<0?0:N>255?255:N;$.putImageData(da,0,0);pa.drawImage(W,0,0);return na}function Ea(K,ba,Y){K=(K-ba)/(Y-ba);return K*K*(3-2*K)}function Fa(K){K=(K+1)*0.5;return K<0?0:K>1?1:K}function Ga(K,ba){var Y=ba.x-K.x,N=ba.y-K.y,X=1/Math.sqrt(Y*
|
||||
Y+N*N);Y*=X;N*=X;ba.x+=Y;ba.y+=N;K.x-=Y;K.y-=N}var Da,Ka,ha,oa,wa,Ha,La,za;k.setTransform(1,0,0,-1,c,i);this.autoClear&&this.clear();d=e.projectScene(ja,ta,this.sortElements);(P=ja.lights.length>0)&&Ma(ja);Da=0;for(Ka=d.length;Da<Ka;Da++){ha=d[Da];D.empty();if(ha instanceof THREE.RenderableParticle){p=ha;p.x*=c;p.y*=i;oa=0;for(wa=ha.materials.length;oa<wa;oa++)Na(p,ha,ha.materials[oa],ja)}else if(ha instanceof THREE.RenderableLine){p=ha.v1;I=ha.v2;p.positionScreen.x*=c;p.positionScreen.y*=i;I.positionScreen.x*=
|
||||
c;I.positionScreen.y*=i;D.addPoint(p.positionScreen.x,p.positionScreen.y);D.addPoint(I.positionScreen.x,I.positionScreen.y);if(Z.instersects(D)){oa=0;for(wa=ha.materials.length;oa<wa;)Oa(p,I,ha,ha.materials[oa++],ja)}}else if(ha instanceof THREE.RenderableFace3){p=ha.v1;I=ha.v2;l=ha.v3;p.positionScreen.x*=c;p.positionScreen.y*=i;I.positionScreen.x*=c;I.positionScreen.y*=i;l.positionScreen.x*=c;l.positionScreen.y*=i;if(ha.overdraw){Ga(p.positionScreen,I.positionScreen);Ga(I.positionScreen,l.positionScreen);
|
||||
Ga(l.positionScreen,p.positionScreen)}D.add3Points(p.positionScreen.x,p.positionScreen.y,I.positionScreen.x,I.positionScreen.y,l.positionScreen.x,l.positionScreen.y);if(Z.instersects(D)){oa=0;for(wa=ha.meshMaterials.length;oa<wa;){za=ha.meshMaterials[oa++];if(za instanceof THREE.MeshFaceMaterial){Ha=0;for(La=ha.faceMaterials.length;Ha<La;)(za=ha.faceMaterials[Ha++])&&Ia(p,I,l,ha,za,ja)}else Ia(p,I,l,ha,za,ja)}}}V.addRectangle(D)}k.setTransform(1,0,0,1,0,0)}};
|
||||
THREE.SVGRenderer=function(){function a(T,M,aa){var U,O,Q,Z;U=0;for(O=T.lights.length;U<O;U++){Q=T.lights[U];if(Q instanceof THREE.DirectionalLight){Z=M.normalWorld.dot(Q.position)*Q.intensity;if(Z>0){aa.r+=Q.color.r*Z;aa.g+=Q.color.g*Z;aa.b+=Q.color.b*Z}}else if(Q instanceof THREE.PointLight){J.sub(Q.position,M.centroidWorld);J.normalize();Z=M.normalWorld.dot(J)*Q.intensity;if(Z>0){aa.r+=Q.color.r*Z;aa.g+=Q.color.g*Z;aa.b+=Q.color.b*Z}}}}function b(T,M,aa,U,O,Q){B=e(t++);B.setAttribute("d","M "+
|
||||
T.positionScreen.x+" "+T.positionScreen.y+" L "+M.positionScreen.x+" "+M.positionScreen.y+" L "+aa.positionScreen.x+","+aa.positionScreen.y+"z");if(O instanceof THREE.MeshBasicMaterial)l.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshLambertMaterial)if(I){g.r=m.r;g.g=m.g;g.b=m.b;a(Q,U,g);l.r=O.color.r*g.r;l.g=O.color.g*g.g;l.b=O.color.b*g.b;l.updateStyleString()}else l.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshDepthMaterial){v=1-O.__2near/(O.__farPlusNear-
|
||||
U.z*O.__farMinusNear);l.setRGB(v,v,v)}else O instanceof THREE.MeshNormalMaterial&&l.setRGB(f(U.normalWorld.x),f(U.normalWorld.y),f(U.normalWorld.z));O.wireframe?B.setAttribute("style","fill: none; stroke: "+l.__styleString+"; stroke-width: "+O.wireframe_linewidth+"; stroke-opacity: "+O.opacity+"; stroke-linecap: "+O.wireframe_linecap+"; stroke-linejoin: "+O.wireframe_linejoin):B.setAttribute("style","fill: "+l.__styleString+"; fill-opacity: "+O.opacity);c.appendChild(B)}function d(T,M,aa,U,O,Q,Z){B=
|
||||
e(t++);B.setAttribute("d","M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+M.positionScreen.x+" "+M.positionScreen.y+" L "+aa.positionScreen.x+","+aa.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(Q instanceof THREE.MeshBasicMaterial)l.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshLambertMaterial)if(I){g.r=m.r;g.g=m.g;g.b=m.b;a(Z,O,g);l.r=Q.color.r*g.r;l.g=Q.color.g*g.g;l.b=Q.color.b*g.b;l.updateStyleString()}else l.__styleString=Q.color.__styleString;
|
||||
else if(Q instanceof THREE.MeshDepthMaterial){v=1-Q.__2near/(Q.__farPlusNear-O.z*Q.__farMinusNear);l.setRGB(v,v,v)}else Q instanceof THREE.MeshNormalMaterial&&l.setRGB(f(O.normalWorld.x),f(O.normalWorld.y),f(O.normalWorld.z));Q.wireframe?B.setAttribute("style","fill: none; stroke: "+l.__styleString+"; stroke-width: "+Q.wireframe_linewidth+"; stroke-opacity: "+Q.opacity+"; stroke-linecap: "+Q.wireframe_linecap+"; stroke-linejoin: "+Q.wireframe_linejoin):B.setAttribute("style","fill: "+l.__styleString+
|
||||
"; fill-opacity: "+Q.opacity);c.appendChild(B)}function e(T){if(s[T]==null){s[T]=document.createElementNS("http://www.w3.org/2000/svg","path");R==0&&s[T].setAttribute("shape-rendering","crispEdges");return s[T]}return s[T]}function f(T){return T<0?Math.min((1+T)*0.5,0.5):0.5+Math.min(T*0.5,0.5)}var h=null,j=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),i,k,r,z,n,u,x,y,H=new THREE.Rectangle,p=new THREE.Rectangle,I=false,l=new THREE.Color(16777215),g=new THREE.Color(16777215),
|
||||
m=new THREE.Color(0),w=new THREE.Color(0),o=new THREE.Color(0),v,J=new THREE.Vector3,s=[],A=[],C=[],B,t,L,F,R=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(T){switch(T){case "high":R=1;break;case "low":R=0}};this.setSize=function(T,M){i=T;k=M;r=i/2;z=k/2;c.setAttribute("viewBox",-r+" "+-z+" "+i+" "+k);c.setAttribute("width",i);c.setAttribute("height",k);H.set(-r,-z,r,z)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};
|
||||
this.render=function(T,M){var aa,U,O,Q,Z,V,D,P;this.autoClear&&this.clear();h=j.projectScene(T,M,this.sortElements);F=L=t=0;if(I=T.lights.length>0){D=T.lights;m.setRGB(0,0,0);w.setRGB(0,0,0);o.setRGB(0,0,0);aa=0;for(U=D.length;aa<U;aa++){O=D[aa];Q=O.color;if(O instanceof THREE.AmbientLight){m.r+=Q.r;m.g+=Q.g;m.b+=Q.b}else if(O instanceof THREE.DirectionalLight){w.r+=Q.r;w.g+=Q.g;w.b+=Q.b}else if(O instanceof THREE.PointLight){o.r+=Q.r;o.g+=Q.g;o.b+=Q.b}}}aa=0;for(U=h.length;aa<U;aa++){D=h[aa];p.empty();
|
||||
if(D instanceof THREE.RenderableParticle){n=D;n.x*=r;n.y*=-z;O=0;for(Q=D.materials.length;O<Q;O++)if(P=D.materials[O]){Z=n;V=D;P=P;var S=L++;if(A[S]==null){A[S]=document.createElementNS("http://www.w3.org/2000/svg","circle");R==0&&A[S].setAttribute("shape-rendering","crispEdges")}B=A[S];B.setAttribute("cx",Z.x);B.setAttribute("cy",Z.y);B.setAttribute("r",V.scale.x*r);if(P instanceof THREE.ParticleCircleMaterial){if(I){g.r=m.r+w.r+o.r;g.g=m.g+w.g+o.g;g.b=m.b+w.b+o.b;l.r=P.color.r*g.r;l.g=P.color.g*
|
||||
g.g;l.b=P.color.b*g.b;l.updateStyleString()}else l=P.color;B.setAttribute("style","fill: "+l.__styleString)}c.appendChild(B)}}else if(D instanceof THREE.RenderableLine){n=D.v1;u=D.v2;n.positionScreen.x*=r;n.positionScreen.y*=-z;u.positionScreen.x*=r;u.positionScreen.y*=-z;p.addPoint(n.positionScreen.x,n.positionScreen.y);p.addPoint(u.positionScreen.x,u.positionScreen.y);if(H.instersects(p)){O=0;for(Q=D.materials.length;O<Q;)if(P=D.materials[O++]){Z=n;V=u;P=P;S=F++;if(C[S]==null){C[S]=document.createElementNS("http://www.w3.org/2000/svg",
|
||||
"line");R==0&&C[S].setAttribute("shape-rendering","crispEdges")}B=C[S];B.setAttribute("x1",Z.positionScreen.x);B.setAttribute("y1",Z.positionScreen.y);B.setAttribute("x2",V.positionScreen.x);B.setAttribute("y2",V.positionScreen.y);if(P instanceof THREE.LineBasicMaterial){l.__styleString=P.color.__styleString;B.setAttribute("style","fill: none; stroke: "+l.__styleString+"; stroke-width: "+P.linewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.linecap+"; stroke-linejoin: "+P.linejoin);c.appendChild(B)}}}}else if(D instanceof
|
||||
THREE.RenderableFace3){n=D.v1;u=D.v2;x=D.v3;n.positionScreen.x*=r;n.positionScreen.y*=-z;u.positionScreen.x*=r;u.positionScreen.y*=-z;x.positionScreen.x*=r;x.positionScreen.y*=-z;p.addPoint(n.positionScreen.x,n.positionScreen.y);p.addPoint(u.positionScreen.x,u.positionScreen.y);p.addPoint(x.positionScreen.x,x.positionScreen.y);if(H.instersects(p)){O=0;for(Q=D.meshMaterials.length;O<Q;){P=D.meshMaterials[O++];if(P instanceof THREE.MeshFaceMaterial){Z=0;for(V=D.faceMaterials.length;Z<V;)(P=D.faceMaterials[Z++])&&
|
||||
b(n,u,x,D,P,T)}else P&&b(n,u,x,D,P,T)}}}else if(D instanceof THREE.RenderableFace4){n=D.v1;u=D.v2;x=D.v3;y=D.v4;n.positionScreen.x*=r;n.positionScreen.y*=-z;u.positionScreen.x*=r;u.positionScreen.y*=-z;x.positionScreen.x*=r;x.positionScreen.y*=-z;y.positionScreen.x*=r;y.positionScreen.y*=-z;p.addPoint(n.positionScreen.x,n.positionScreen.y);p.addPoint(u.positionScreen.x,u.positionScreen.y);p.addPoint(x.positionScreen.x,x.positionScreen.y);p.addPoint(y.positionScreen.x,y.positionScreen.y);if(H.instersects(p)){O=
|
||||
0;for(Q=D.meshMaterials.length;O<Q;){P=D.meshMaterials[O++];if(P instanceof THREE.MeshFaceMaterial){Z=0;for(V=D.faceMaterials.length;Z<V;)(P=D.faceMaterials[Z++])&&d(n,u,x,y,D,P,T)}else P&&d(n,u,x,y,D,P,T)}}}}}};
|
||||
THREE.WebGLRenderer=function(a){function b(g,m){g.fragment_shader=m.fragment_shader;g.vertex_shader=m.vertex_shader;g.uniforms=Uniforms.clone(m.uniforms)}function d(g,m){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(m){g.uniforms.fogColor.value.setHex(m.color.hex);if(m instanceof THREE.Fog){g.uniforms.fogNear.value=m.near;g.uniforms.fogFar.value=m.far}else if(m instanceof THREE.FogExp2)g.uniforms.fogDensity.value=m.density}}function e(g,m){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(m){g.uniforms.fogColor.value.setHex(m.color.hex);if(m instanceof THREE.Fog){g.uniforms.fogNear.value=
|
||||
m.near;g.uniforms.fogFar.value=m.far}else if(m instanceof THREE.FogExp2)g.uniforms.fogDensity.value=m.density}}function f(g,m){var w;if(g=="fragment")w=c.createShader(c.FRAGMENT_SHADER);else if(g=="vertex")w=c.createShader(c.VERTEX_SHADER);c.shaderSource(w,m);c.compileShader(w);if(!c.getShaderParameter(w,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(w));return null}return w}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;
|
||||
THREE.Projector=function(){function a(q,z){return z.z-q.z}function b(q,z){var M=0,p=1,A=q.z+q.w,F=z.z+z.w,E=-q.z+q.w,y=-z.z+z.w;if(A>=0&&F>=0&&E>=0&&y>=0)return true;else if(A<0&&F<0||E<0&&y<0)return false;else{if(A<0)M=Math.max(M,A/(A-F));else if(F<0)p=Math.min(p,A/(A-F));if(E<0)M=Math.max(M,E/(E-y));else if(y<0)p=Math.min(p,E/(E-y));if(p<M)return false;else{q.lerpSelf(z,M);z.lerpSelf(q,1-p);return true}}}var d,e,f=[],g,k,c,j=[],l,t,D=[],o,u,w=[],C=new THREE.Vector4,H=new THREE.Vector4,v=new THREE.Matrix4,
|
||||
I=new THREE.Matrix4,m=[],h=new THREE.Vector4,n=new THREE.Vector4,B;this.projectObjects=function(q,z,M){var p=[],A,F;e=0;v.multiply(z.projectionMatrix,z.matrix);m[0]=new THREE.Vector4(v.n41-v.n11,v.n42-v.n12,v.n43-v.n13,v.n44-v.n14);m[1]=new THREE.Vector4(v.n41+v.n11,v.n42+v.n12,v.n43+v.n13,v.n44+v.n14);m[2]=new THREE.Vector4(v.n41+v.n21,v.n42+v.n22,v.n43+v.n23,v.n44+v.n24);m[3]=new THREE.Vector4(v.n41-v.n21,v.n42-v.n22,v.n43-v.n23,v.n44-v.n24);m[4]=new THREE.Vector4(v.n41-v.n31,v.n42-v.n32,v.n43-
|
||||
v.n33,v.n44-v.n34);m[5]=new THREE.Vector4(v.n41+v.n31,v.n42+v.n32,v.n43+v.n33,v.n44+v.n34);z=0;for(A=m.length;z<A;z++){F=m[z];F.divideScalar(Math.sqrt(F.x*F.x+F.y*F.y+F.z*F.z))}A=q.objects;q=0;for(z=A.length;q<z;q++){F=A[q];var E;if(!(E=!F.visible)){if(E=F instanceof THREE.Mesh){a:{E=void 0;for(var y=F.position,O=-F.geometry.boundingSphere.radius*Math.max(F.scale.x,Math.max(F.scale.y,F.scale.z)),K=0;K<6;K++){E=m[K].x*y.x+m[K].y*y.y+m[K].z*y.z+m[K].w;if(E<=O){E=false;break a}}E=true}E=!E}E=E}if(!E){d=
|
||||
f[e]=f[e]||new THREE.RenderableObject;C.copy(F.position);v.multiplyVector3(C);d.object=F;d.z=C.z;p.push(d);e++}}M&&p.sort(a);return p};this.projectScene=function(q,z,M){var p=[],A=z.near,F=z.far,E,y,O,K,U,W,P,da,X,R,T,ba,Y,G,S,V;c=t=u=0;z.autoUpdateMatrix&&z.updateMatrix();v.multiply(z.projectionMatrix,z.matrix);W=this.projectObjects(q,z,true);q=0;for(E=W.length;q<E;q++){P=W[q].object;if(P.visible){P.autoUpdateMatrix&&P.updateMatrix();da=P.matrix;X=P.rotationMatrix;R=P.materials;T=P.overdraw;if(P instanceof
|
||||
THREE.Mesh){ba=P.geometry;Y=ba.vertices;y=0;for(O=Y.length;y<O;y++){G=Y[y];G.positionWorld.copy(G.position);da.multiplyVector3(G.positionWorld);K=G.positionScreen;K.copy(G.positionWorld);v.multiplyVector4(K);K.x/=K.w;K.y/=K.w;G.__visible=K.z>A&&K.z<F}ba=ba.faces;y=0;for(O=ba.length;y<O;y++){G=ba[y];if(G instanceof THREE.Face3){K=Y[G.a];U=Y[G.b];S=Y[G.c];if(K.__visible&&U.__visible&&S.__visible)if(P.doubleSided||P.flipSided!=(S.positionScreen.x-K.positionScreen.x)*(U.positionScreen.y-K.positionScreen.y)-
|
||||
(S.positionScreen.y-K.positionScreen.y)*(U.positionScreen.x-K.positionScreen.x)<0){g=j[c]=j[c]||new THREE.RenderableFace3;g.v1.positionWorld.copy(K.positionWorld);g.v2.positionWorld.copy(U.positionWorld);g.v3.positionWorld.copy(S.positionWorld);g.v1.positionScreen.copy(K.positionScreen);g.v2.positionScreen.copy(U.positionScreen);g.v3.positionScreen.copy(S.positionScreen);g.normalWorld.copy(G.normal);X.multiplyVector3(g.normalWorld);g.centroidWorld.copy(G.centroid);da.multiplyVector3(g.centroidWorld);
|
||||
g.centroidScreen.copy(g.centroidWorld);v.multiplyVector3(g.centroidScreen);S=G.vertexNormals;B=g.vertexNormalsWorld;K=0;for(U=S.length;K<U;K++){V=B[K]=B[K]||new THREE.Vector3;V.copy(S[K]);X.multiplyVector3(V)}g.z=g.centroidScreen.z;g.meshMaterials=R;g.faceMaterials=G.materials;g.overdraw=T;if(P.geometry.uvs[y]){g.uvs[0]=P.geometry.uvs[y][0];g.uvs[1]=P.geometry.uvs[y][1];g.uvs[2]=P.geometry.uvs[y][2]}p.push(g);c++}}else if(G instanceof THREE.Face4){K=Y[G.a];U=Y[G.b];S=Y[G.c];V=Y[G.d];if(K.__visible&&
|
||||
U.__visible&&S.__visible&&V.__visible)if(P.doubleSided||P.flipSided!=((V.positionScreen.x-K.positionScreen.x)*(U.positionScreen.y-K.positionScreen.y)-(V.positionScreen.y-K.positionScreen.y)*(U.positionScreen.x-K.positionScreen.x)<0||(U.positionScreen.x-S.positionScreen.x)*(V.positionScreen.y-S.positionScreen.y)-(U.positionScreen.y-S.positionScreen.y)*(V.positionScreen.x-S.positionScreen.x)<0)){g=j[c]=j[c]||new THREE.RenderableFace3;g.v1.positionWorld.copy(K.positionWorld);g.v2.positionWorld.copy(U.positionWorld);
|
||||
g.v3.positionWorld.copy(V.positionWorld);g.v1.positionScreen.copy(K.positionScreen);g.v2.positionScreen.copy(U.positionScreen);g.v3.positionScreen.copy(V.positionScreen);g.normalWorld.copy(G.normal);X.multiplyVector3(g.normalWorld);g.centroidWorld.copy(G.centroid);da.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);v.multiplyVector3(g.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=R;g.faceMaterials=G.materials;g.overdraw=T;if(P.geometry.uvs[y]){g.uvs[0]=P.geometry.uvs[y][0];
|
||||
g.uvs[1]=P.geometry.uvs[y][1];g.uvs[2]=P.geometry.uvs[y][3]}p.push(g);c++;k=j[c]=j[c]||new THREE.RenderableFace3;k.v1.positionWorld.copy(U.positionWorld);k.v2.positionWorld.copy(S.positionWorld);k.v3.positionWorld.copy(V.positionWorld);k.v1.positionScreen.copy(U.positionScreen);k.v2.positionScreen.copy(S.positionScreen);k.v3.positionScreen.copy(V.positionScreen);k.normalWorld.copy(g.normalWorld);k.centroidWorld.copy(g.centroidWorld);k.centroidScreen.copy(g.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterials=
|
||||
R;k.faceMaterials=G.materials;k.overdraw=T;if(P.geometry.uvs[y]){k.uvs[0]=P.geometry.uvs[y][1];k.uvs[1]=P.geometry.uvs[y][2];k.uvs[2]=P.geometry.uvs[y][3]}p.push(k);c++}}}}else if(P instanceof THREE.Line){I.multiply(v,da);Y=P.geometry.vertices;G=Y[0];G.positionScreen.copy(G.position);I.multiplyVector4(G.positionScreen);y=1;for(O=Y.length;y<O;y++){K=Y[y];K.positionScreen.copy(K.position);I.multiplyVector4(K.positionScreen);U=Y[y-1];h.copy(K.positionScreen);n.copy(U.positionScreen);if(b(h,n)){h.multiplyScalar(1/
|
||||
h.w);n.multiplyScalar(1/n.w);l=D[t]=D[t]||new THREE.RenderableLine;l.v1.positionScreen.copy(h);l.v2.positionScreen.copy(n);l.z=Math.max(h.z,n.z);l.materials=P.materials;p.push(l);t++}}}else if(P instanceof THREE.Particle){H.set(P.position.x,P.position.y,P.position.z,1);v.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){o=w[u]=w[u]||new THREE.RenderableParticle;o.x=H.x/H.w;o.y=H.y/H.w;o.z=H.z;o.rotation=P.rotation.z;o.scale.x=P.scale.x*Math.abs(o.x-(H.x+z.projectionMatrix.n11)/(H.w+z.projectionMatrix.n14));
|
||||
o.scale.y=P.scale.y*Math.abs(o.y-(H.y+z.projectionMatrix.n22)/(H.w+z.projectionMatrix.n24));o.materials=P.materials;p.push(o);u++}}}}M&&p.sort(a);return p};this.unprojectVector=function(q,z){var M=THREE.Matrix4.makeInvert(z.matrix);M.multiplySelf(THREE.Matrix4.makeInvert(z.projectionMatrix));M.multiplyVector3(q);return q}};
|
||||
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,f,g;this.domElement=document.createElement("div");this.setSize=function(k,c){d=k;e=c;f=d/2;g=e/2};this.render=function(k,c){var j,l,t,D,o,u,w,C;a=b.projectScene(k,c);j=0;for(l=a.length;j<l;j++){o=a[j];if(o instanceof THREE.RenderableParticle){w=o.x*f+f;C=o.y*g+g;t=0;for(D=o.material.length;t<D;t++){u=o.material[t];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=w+"px";u.style.top=C+"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,f=document.createElement("canvas"),g,k,c,j,l=f.getContext("2d"),t=null,D=null,o=1,u=0,w=null,C=null,H=1,v,I,m,h,n,B,q,z,M,p=new THREE.Color,
|
||||
A=new THREE.Color,F=new THREE.Color,E=new THREE.Color,y=new THREE.Color,O,K,U,W,P,da,X,R,T,ba=new THREE.Rectangle,Y=new THREE.Rectangle,G=new THREE.Rectangle,S=false,V=new THREE.Color,ia=new THREE.Color,ha=new THREE.Color,x=new THREE.Color,L=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){g=ma;k=wa;c=g/2;j=k/2;f.width=g;f.height=k;ba.set(-c,-j,c,j);o=1;u=0;C=w=null;H=1};this.setClearColor=function(ma,wa){t=ma!==null?new THREE.Color(ma):null;D=wa;Y.set(-c,-j,c,j);l.setTransform(1,0,0,-1,c,j);this.clear()};this.clear=function(){if(!Y.isEmpty()){Y.inflate(1);Y.minSelf(ba);if(t!==null){b(THREE.NormalBlending);
|
||||
a(1);l.fillStyle="rgba("+Math.floor(t.r*255)+","+Math.floor(t.g*255)+","+Math.floor(t.b*255)+","+D+")";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(N){var ea,aa,Q,$=N.lights;ia.setRGB(0,0,0);ha.setRGB(0,0,0);x.setRGB(0,0,0);N=0;for(ea=$.length;N<ea;N++){aa=$[N];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){x.r+=Q.r;x.g+=Q.g;x.b+=Q.b}}}function Da(N,ea,aa,Q){var $,fa,la,na,oa=N.lights;N=0;for($=oa.length;N<$;N++){fa=oa[N];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(N,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*j;aa=$*na;Q=fa*oa;G.set(N.x-aa,N.y-Q,N.x+aa,N.y+Q);if(ba.instersects(G)){l.save();l.translate(N.x,N.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){V.r=ia.r+ha.r+x.r;V.g=ia.g+ha.g+x.g;V.b=ia.b+ha.b+x.b;p.r=aa.color.r*
|
||||
V.r;p.g=aa.color.g*V.g;p.b=aa.color.b*V.b;p.updateStyleString()}else p.__styleString=aa.color.__styleString;aa=ea.scale.x*c;Q=ea.scale.y*j;G.set(N.x-aa,N.y-Q,N.x+aa,N.y+Q);if(ba.instersects(G)){$=p.__styleString;if(C!=$)l.fillStyle=C=$;l.save();l.translate(N.x,N.y);l.rotate(-ea.rotation);l.scale(aa,Q);l.beginPath();l.arc(0,0,1,0,L,true);l.closePath();l.fill();l.restore()}}}}function Ra(N,ea,aa,Q){if(Q.opacity!=0){a(Q.opacity);b(Q.blending);l.beginPath();l.moveTo(N.positionScreen.x,N.positionScreen.y);
|
||||
l.lineTo(ea.positionScreen.x,ea.positionScreen.y);l.closePath();if(Q instanceof THREE.LineBasicMaterial){p.__styleString=Q.color.__styleString;N=Q.linewidth;if(H!=N)l.lineWidth=H=N;N=p.__styleString;if(w!=N)l.strokeStyle=w=N;l.stroke();G.inflate(Q.linewidth*2)}}}function La(N,ea,aa,Q,$,fa){if($.opacity!=0){a($.opacity);b($.blending);h=N.positionScreen.x;n=N.positionScreen.y;B=ea.positionScreen.x;q=ea.positionScreen.y;z=aa.positionScreen.x;M=aa.positionScreen.y;l.beginPath();l.moveTo(h,n);l.lineTo(B,
|
||||
q);l.lineTo(z,M);l.lineTo(h,n);l.closePath();if($ instanceof THREE.MeshBasicMaterial)if($.map)$.map.image.loaded&&$.map.mapping instanceof THREE.UVMapping&&Aa(h,n,B,q,z,M,$.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){N=wa.matrix;J.copy(Q.vertexNormalsWorld[0]);W=(J.x*N.n11+J.y*N.n12+J.z*N.n13)*0.5+0.5;P=-(J.x*N.n21+J.y*N.n22+J.z*N.n23)*0.5+0.5;J.copy(Q.vertexNormalsWorld[1]);
|
||||
da=(J.x*N.n11+J.y*N.n12+J.z*N.n13)*0.5+0.5;X=-(J.x*N.n21+J.y*N.n22+J.z*N.n23)*0.5+0.5;J.copy(Q.vertexNormalsWorld[2]);R=(J.x*N.n11+J.y*N.n12+J.z*N.n13)*0.5+0.5;T=-(J.x*N.n21+J.y*N.n22+J.z*N.n23)*0.5+0.5;Aa(h,n,B,q,z,M,$.env_map.image,W,P,da,X,R,T)}}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,n,B,q,z,M,$.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){A.r=F.r=E.r=ia.r;A.g=F.g=E.g=ia.g;A.b=F.b=E.b=ia.b;Da(fa,Q.v1.positionWorld,Q.vertexNormalsWorld[0],A);Da(fa,Q.v2.positionWorld,Q.vertexNormalsWorld[1],F);Da(fa,Q.v3.positionWorld,Q.vertexNormalsWorld[2],E);y.r=(F.r+E.r)*0.5;y.g=(F.g+E.g)*0.5;y.b=(F.b+E.b)*0.5;U=Ma(A,F,E,y);Aa(h,n,B,q,z,M,U,0,0,1,0,0,1)}else{V.r=ia.r;V.g=ia.g;V.b=ia.b;Da(fa,
|
||||
Q.centroidWorld,Q.normalWorld,V);p.r=$.color.r*V.r;p.g=$.color.g*V.g;p.b=$.color.b*V.b;p.updateStyleString();$.wireframe?Ea(p.__styleString,$.wireframe_linewidth):Fa(p.__styleString)}else $.wireframe?Ea($.color.__styleString,$.wireframe_linewidth):Fa($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){O=wa.near;K=wa.far;A.r=A.g=A.b=1-Ha(N.positionScreen.z,O,K);F.r=F.g=F.b=1-Ha(ea.positionScreen.z,O,K);E.r=E.g=E.b=1-Ha(aa.positionScreen.z,O,K);y.r=(F.r+E.r)*0.5;y.g=(F.g+E.g)*0.5;y.b=
|
||||
(F.b+E.b)*0.5;U=Ma(A,F,E,y);Aa(h,n,B,q,z,M,U,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){p.r=Ia(Q.normalWorld.x);p.g=Ia(Q.normalWorld.y);p.b=Ia(Q.normalWorld.z);p.updateStyleString();$.wireframe?Ea(p.__styleString,$.wireframe_linewidth):Fa(p.__styleString)}}}function Ea(N,ea){if(w!=N)l.strokeStyle=w=N;if(H!=ea)l.lineWidth=H=ea;l.stroke();G.inflate(ea*2)}function Fa(N){if(C!=N)l.fillStyle=C=N;l.fill()}function Aa(N,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-=N;Q-=ea;$-=N;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;N=N-xa*na-aa*oa;ea=ea-pa*na-Q*oa;l.save();l.transform(xa,pa,aa,Q,N,ea);l.clip();l.drawImage(la,0,0);l.restore()}function Ma(N,ea,aa,Q){var $=~~(N.r*255),fa=~~(N.g*255);N=~~(N.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]=N<0?0:N>255?255:N;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(N,ea,aa){N=(N-ea)/(aa-ea);return N*N*(3-2*N)}function Ia(N){N=(N+1)*0.5;return N<0?0:N>1?1:N}function Ja(N,
|
||||
ea){var aa=ea.x-N.x,Q=ea.y-N.y,$=1/Math.sqrt(aa*aa+Q*Q);aa*=$;Q*=$;ea.x+=aa;ea.y+=Q;N.x-=aa;N.y-=Q}var Ga,Na,ka,ra,za,Ka,Oa,Ca;l.setTransform(1,0,0,-1,c,j);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];G.empty();if(ka instanceof THREE.RenderableParticle){v=ka;v.x*=c;v.y*=j;ra=0;for(za=ka.materials.length;ra<za;ra++)Qa(v,ka,ka.materials[ra],ma)}else if(ka instanceof THREE.RenderableLine){v=ka.v1;I=ka.v2;
|
||||
v.positionScreen.x*=c;v.positionScreen.y*=j;I.positionScreen.x*=c;I.positionScreen.y*=j;G.addPoint(v.positionScreen.x,v.positionScreen.y);G.addPoint(I.positionScreen.x,I.positionScreen.y);if(ba.instersects(G)){ra=0;for(za=ka.materials.length;ra<za;)Ra(v,I,ka,ka.materials[ra++],ma)}}else if(ka instanceof THREE.RenderableFace3){v=ka.v1;I=ka.v2;m=ka.v3;v.positionScreen.x*=c;v.positionScreen.y*=j;I.positionScreen.x*=c;I.positionScreen.y*=j;m.positionScreen.x*=c;m.positionScreen.y*=j;if(ka.overdraw){Ja(v.positionScreen,
|
||||
I.positionScreen);Ja(I.positionScreen,m.positionScreen);Ja(m.positionScreen,v.positionScreen)}G.add3Points(v.positionScreen.x,v.positionScreen.y,I.positionScreen.x,I.positionScreen.y,m.positionScreen.x,m.positionScreen.y);if(ba.instersects(G)){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(v,I,m,ka,Ca,ma)}else La(v,I,m,ka,Ca,ma)}}}Y.addRectangle(G)}l.setTransform(1,
|
||||
0,0,1,0,0)}};
|
||||
THREE.SVGRenderer=function(){function a(W,P,da){var X,R,T,ba;X=0;for(R=W.lights.length;X<R;X++){T=W.lights[X];if(T instanceof THREE.DirectionalLight){ba=P.normalWorld.dot(T.position)*T.intensity;if(ba>0){da.r+=T.color.r*ba;da.g+=T.color.g*ba;da.b+=T.color.b*ba}}else if(T instanceof THREE.PointLight){M.sub(T.position,P.centroidWorld);M.normalize();ba=P.normalWorld.dot(M)*T.intensity;if(ba>0){da.r+=T.color.r*ba;da.g+=T.color.g*ba;da.b+=T.color.b*ba}}}}function b(W,P,da,X,R,T){E=e(y++);E.setAttribute("d",
|
||||
"M "+W.positionScreen.x+" "+W.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(I){h.r=n.r;h.g=n.g;h.b=n.b;a(T,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){z=1-R.__2near/(R.__farPlusNear-
|
||||
X.z*R.__farMinusNear);m.setRGB(z,z,z)}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(W,P,da,X,R,T,ba){E=
|
||||
e(y++);E.setAttribute("d","M "+W.positionScreen.x+" "+W.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(T instanceof THREE.MeshBasicMaterial)m.__styleString=T.color.__styleString;else if(T instanceof THREE.MeshLambertMaterial)if(I){h.r=n.r;h.g=n.g;h.b=n.b;a(ba,R,h);m.r=T.color.r*h.r;m.g=T.color.g*h.g;m.b=T.color.b*h.b;m.updateStyleString()}else m.__styleString=T.color.__styleString;
|
||||
else if(T instanceof THREE.MeshDepthMaterial){z=1-T.__2near/(T.__farPlusNear-R.z*T.__farMinusNear);m.setRGB(z,z,z)}else T instanceof THREE.MeshNormalMaterial&&m.setRGB(f(R.normalWorld.x),f(R.normalWorld.y),f(R.normalWorld.z));T.wireframe?E.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+T.wireframe_linewidth+"; stroke-opacity: "+T.opacity+"; stroke-linecap: "+T.wireframe_linecap+"; stroke-linejoin: "+T.wireframe_linejoin):E.setAttribute("style","fill: "+m.__styleString+
|
||||
"; fill-opacity: "+T.opacity);c.appendChild(E)}function e(W){if(p[W]==null){p[W]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&p[W].setAttribute("shape-rendering","crispEdges");return p[W]}return p[W]}function f(W){return W<0?Math.min((1+W)*0.5,0.5):0.5+Math.min(W*0.5,0.5)}var g=null,k=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,l,t,D,o,u,w,C,H=new THREE.Rectangle,v=new THREE.Rectangle,I=false,m=new THREE.Color(16777215),h=new THREE.Color(16777215),
|
||||
n=new THREE.Color(0),B=new THREE.Color(0),q=new THREE.Color(0),z,M=new THREE.Vector3,p=[],A=[],F=[],E,y,O,K,U=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(W){switch(W){case "high":U=1;break;case "low":U=0}};this.setSize=function(W,P){j=W;l=P;t=j/2;D=l/2;c.setAttribute("viewBox",-t+" "+-D+" "+j+" "+l);c.setAttribute("width",j);c.setAttribute("height",l);H.set(-t,-D,t,D)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};
|
||||
this.render=function(W,P){var da,X,R,T,ba,Y,G,S;this.autoClear&&this.clear();g=k.projectScene(W,P,this.sortElements);K=O=y=0;if(I=W.lights.length>0){G=W.lights;n.setRGB(0,0,0);B.setRGB(0,0,0);q.setRGB(0,0,0);da=0;for(X=G.length;da<X;da++){R=G[da];T=R.color;if(R instanceof THREE.AmbientLight){n.r+=T.r;n.g+=T.g;n.b+=T.b}else if(R instanceof THREE.DirectionalLight){B.r+=T.r;B.g+=T.g;B.b+=T.b}else if(R instanceof THREE.PointLight){q.r+=T.r;q.g+=T.g;q.b+=T.b}}}da=0;for(X=g.length;da<X;da++){G=g[da];v.empty();
|
||||
if(G instanceof THREE.RenderableParticle){o=G;o.x*=t;o.y*=-D;R=0;for(T=G.materials.length;R<T;R++)if(S=G.materials[R]){ba=o;Y=G;S=S;var V=O++;if(A[V]==null){A[V]=document.createElementNS("http://www.w3.org/2000/svg","circle");U==0&&A[V].setAttribute("shape-rendering","crispEdges")}E=A[V];E.setAttribute("cx",ba.x);E.setAttribute("cy",ba.y);E.setAttribute("r",Y.scale.x*t);if(S instanceof THREE.ParticleCircleMaterial){if(I){h.r=n.r+B.r+q.r;h.g=n.g+B.g+q.g;h.b=n.b+B.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(G instanceof THREE.RenderableLine){o=G.v1;u=G.v2;o.positionScreen.x*=t;o.positionScreen.y*=-D;u.positionScreen.x*=t;u.positionScreen.y*=-D;v.addPoint(o.positionScreen.x,o.positionScreen.y);v.addPoint(u.positionScreen.x,u.positionScreen.y);if(H.instersects(v)){R=0;for(T=G.materials.length;R<T;)if(S=G.materials[R++]){ba=o;Y=u;S=S;V=K++;if(F[V]==null){F[V]=document.createElementNS("http://www.w3.org/2000/svg",
|
||||
"line");U==0&&F[V].setAttribute("shape-rendering","crispEdges")}E=F[V];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(G instanceof THREE.RenderableFace3){o=G.v1;u=G.v2;w=G.v3;o.positionScreen.x*=t;o.positionScreen.y*=-D;u.positionScreen.x*=t;u.positionScreen.y*=-D;w.positionScreen.x*=t;w.positionScreen.y*=-D;v.addPoint(o.positionScreen.x,o.positionScreen.y);v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(w.positionScreen.x,w.positionScreen.y);if(H.instersects(v)){R=0;for(T=G.meshMaterials.length;R<T;){S=G.meshMaterials[R++];if(S instanceof THREE.MeshFaceMaterial){ba=0;for(Y=
|
||||
G.faceMaterials.length;ba<Y;)(S=G.faceMaterials[ba++])&&b(o,u,w,G,S,W)}else S&&b(o,u,w,G,S,W)}}}else if(G instanceof THREE.RenderableFace4){o=G.v1;u=G.v2;w=G.v3;C=G.v4;o.positionScreen.x*=t;o.positionScreen.y*=-D;u.positionScreen.x*=t;u.positionScreen.y*=-D;w.positionScreen.x*=t;w.positionScreen.y*=-D;C.positionScreen.x*=t;C.positionScreen.y*=-D;v.addPoint(o.positionScreen.x,o.positionScreen.y);v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(w.positionScreen.x,w.positionScreen.y);v.addPoint(C.positionScreen.x,
|
||||
C.positionScreen.y);if(H.instersects(v)){R=0;for(T=G.meshMaterials.length;R<T;){S=G.meshMaterials[R++];if(S instanceof THREE.MeshFaceMaterial){ba=0;for(Y=G.faceMaterials.length;ba<Y;)(S=G.faceMaterials[ba++])&&d(o,u,w,C,G,S,W)}else S&&d(o,u,w,C,G,S,W)}}}}}};
|
||||
THREE.WebGLRenderer=function(a){function b(h,n){h.fragment_shader=n.fragment_shader;h.vertex_shader=n.vertex_shader;h.uniforms=Uniforms.clone(n.uniforms)}function d(h,n){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(n){h.uniforms.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){h.uniforms.fogNear.value=n.near;h.uniforms.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)h.uniforms.fogDensity.value=n.density}}function e(h,n){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(n){h.uniforms.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){h.uniforms.fogNear.value=
|
||||
n.near;h.uniforms.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)h.uniforms.fogDensity.value=n.density}}function f(h,n){var B;if(h=="fragment")B=c.createShader(c.FRAGMENT_SHADER);else if(h=="vertex")B=c.createShader(c.VERTEX_SHADER);c.shaderSource(B,n);c.compileShader(B);if(!c.getShaderParameter(B,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(B));return null}return B}function g(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,i=null,k=null,r=new THREE.Matrix4,z,n=new Float32Array(16),u=new Float32Array(16),x=new Float32Array(16),y=new Float32Array(9),
|
||||
H=new Float32Array(16),p=true,I=new THREE.Color(0),l=0;if(a){if(a.antialias!==undefined)p=a.antialias;a.clearColor!==undefined&&I.setHex(a.clearColor);if(a.clearAlpha!==undefined)l=a.clearAlpha}this.domElement=j;this.autoClear=true;(function(g,m,w){try{c=j.getContext("experimental-webgl",{antialias:g})}catch(o){}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(m.r,m.g,m.b,w)})(p,I,l);this.context=c;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(g,m){j.width=g;j.height=m;c.viewport(0,0,j.width,j.height)};this.setClearColor=function(g,m){var w=new THREE.Color(g);c.clearColor(w.r,w.g,w.b,m)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=
|
||||
function(g,m){var w,o,v,J=0,s=0,A=0,C,B,t,L=this.lights,F=L.directional.colors,R=L.directional.positions,T=L.point.colors,M=L.point.positions,aa=0,U=0;w=0;for(o=m.length;w<o;w++){v=m[w];C=v.color;B=v.position;t=v.intensity;if(v instanceof THREE.AmbientLight){J+=C.r;s+=C.g;A+=C.b}else if(v instanceof THREE.DirectionalLight){F[aa*3]=C.r*t;F[aa*3+1]=C.g*t;F[aa*3+2]=C.b*t;R[aa*3]=B.x;R[aa*3+1]=B.y;R[aa*3+2]=B.z;aa+=1}else if(v instanceof THREE.PointLight){T[U*3]=C.r*t;T[U*3+1]=C.g*t;T[U*3+2]=C.b*t;M[U*
|
||||
3]=B.x;M[U*3+1]=B.y;M[U*3+2]=B.z;U+=1}}L.point.length=U;L.directional.length=aa;L.ambient[0]=J;L.ambient[1]=s;L.ambient[2]=A};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 m=g.vertices.length;g.__vertexArray=new Float32Array(m*3);g.__lineArray=new Uint16Array(m);g.__webGLLineCount=m};this.initMeshBuffers=function(g,m){var w,o,v=0,J=0,s=0,A=m.geometry.faces,C=g.faces;w=0;for(o=C.length;w<o;w++){fi=C[w];face=A[fi];if(face instanceof THREE.Face3){v+=3;J+=1;s+=3}else if(face instanceof THREE.Face4){v+=4;J+=2;s+=4}}g.__vertexArray=
|
||||
new Float32Array(v*3);g.__normalArray=new Float32Array(v*3);g.__tangentArray=new Float32Array(v*4);g.__uvArray=new Float32Array(v*2);g.__faceArray=new Uint16Array(J*3);g.__lineArray=new Uint16Array(s*2);v=false;w=0;for(o=m.materials.length;w<o;w++){A=m.materials[w];if(A instanceof THREE.MeshFaceMaterial){A=0;for(C=g.materials.length;A<C;A++)if(g.materials[A]&&g.materials[A].shading!=undefined&&g.materials[A].shading==THREE.SmoothShading){v=true;break}}else if(A&&A.shading!=undefined&&A.shading==THREE.SmoothShading){v=
|
||||
true;break}if(v)break}g.__needsSmoothNormals=v;g.__webGLFaceCount=J*3;g.__webGLLineCount=s*2};this.setMeshBuffers=function(g,m,w,o,v,J,s,A){var C,B,t,L,F,R,T,M,aa,U=0,O=0,Q=0,Z=0,V=0,D=0,P=0,S=g.__vertexArray,fa=g.__uvArray,ea=g.__normalArray,q=g.__tangentArray,G=g.__faceArray,E=g.__lineArray,W=g.__needsSmoothNormals,$=m.geometry,da=$.vertices,ga=g.faces,na=$.faces,pa=$.uvs;m=0;for(C=ga.length;m<C;m++){B=ga[m];t=na[B];B=pa[B];L=t.vertexNormals;F=t.normal;if(t instanceof THREE.Face3){if(o){R=da[t.a].position;
|
||||
T=da[t.b].position;M=da[t.c].position;S[O]=R.x;S[O+1]=R.y;S[O+2]=R.z;S[O+3]=T.x;S[O+4]=T.y;S[O+5]=T.z;S[O+6]=M.x;S[O+7]=M.y;S[O+8]=M.z;O+=9}if(A&&$.hasTangents){R=da[t.a].tangent;T=da[t.b].tangent;M=da[t.c].tangent;q[D]=R.x;q[D+1]=R.y;q[D+2]=R.z;q[D+3]=R.w;q[D+4]=T.x;q[D+5]=T.y;q[D+6]=T.z;q[D+7]=T.w;q[D+8]=M.x;q[D+9]=M.y;q[D+10]=M.z;q[D+11]=M.w;D+=12}if(s)if(L.length==3&&W)for(t=0;t<3;t++){F=L[t];ea[V]=F.x;ea[V+1]=F.y;ea[V+2]=F.z;V+=3}else for(t=0;t<3;t++){ea[V]=F.x;ea[V+1]=F.y;ea[V+2]=F.z;V+=3}if(J&&
|
||||
B)for(t=0;t<3;t++){L=B[t];fa[Q]=L.u;fa[Q+1]=L.v;Q+=2}if(v){G[Z]=U;G[Z+1]=U+1;G[Z+2]=U+2;Z+=3;E[P]=U;E[P+1]=U+1;E[P+2]=U;E[P+3]=U+2;E[P+4]=U+1;E[P+5]=U+2;P+=6;U+=3}}else if(t instanceof THREE.Face4){if(o){R=da[t.a].position;T=da[t.b].position;M=da[t.c].position;aa=da[t.d].position;S[O]=R.x;S[O+1]=R.y;S[O+2]=R.z;S[O+3]=T.x;S[O+4]=T.y;S[O+5]=T.z;S[O+6]=M.x;S[O+7]=M.y;S[O+8]=M.z;S[O+9]=aa.x;S[O+10]=aa.y;S[O+11]=aa.z;O+=12}if(A&&$.hasTangents){R=da[t.a].tangent;T=da[t.b].tangent;M=da[t.c].tangent;t=da[t.d].tangent;
|
||||
q[D]=R.x;q[D+1]=R.y;q[D+2]=R.z;q[D+3]=R.w;q[D+4]=T.x;q[D+5]=T.y;q[D+6]=T.z;q[D+7]=T.w;q[D+8]=M.x;q[D+9]=M.y;q[D+10]=M.z;q[D+11]=M.w;q[D+12]=t.x;q[D+13]=t.y;q[D+14]=t.z;q[D+15]=t.w;D+=16}if(s)if(L.length==4&&W)for(t=0;t<4;t++){F=L[t];ea[V]=F.x;ea[V+1]=F.y;ea[V+2]=F.z;V+=3}else for(t=0;t<4;t++){ea[V]=F.x;ea[V+1]=F.y;ea[V+2]=F.z;V+=3}if(J&&B)for(t=0;t<4;t++){L=B[t];fa[Q]=L.u;fa[Q+1]=L.v;Q+=2}if(v){G[Z]=U;G[Z+1]=U+1;G[Z+2]=U+2;G[Z+3]=U;G[Z+4]=U+2;G[Z+5]=U+3;Z+=6;E[P]=U;E[P+1]=U+1;E[P+2]=U;E[P+3]=U+3;
|
||||
E[P+4]=U+1;E[P+5]=U+2;E[P+6]=U+2;E[P+7]=U+3;P+=8;U+=4}}}if(o){c.bindBuffer(c.ARRAY_BUFFER,g.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,S,w)}if(s){c.bindBuffer(c.ARRAY_BUFFER,g.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,ea,w)}if(A&&$.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,g.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,q,w)}if(J&&Q>0){c.bindBuffer(c.ARRAY_BUFFER,g.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,fa,w)}if(v){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,
|
||||
G,w);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,E,w)}};this.setLineBuffers=function(g,m,w,o){var v,J,s=g.vertices,A=s.length,C=g.__vertexArray,B=g.__lineArray;if(w)for(w=0;w<A;w++){v=s[w].position;J=w*3;C[J]=v.x;C[J+1]=v.y;C[J+2]=v.z}if(o)for(w=0;w<A;w++)B[w]=w;c.bindBuffer(c.ARRAY_BUFFER,g.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,C,m);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,B,m)};this.setParticleBuffers=
|
||||
function(){};this.renderBuffer=function(g,m,w,o,v,J){var s,A,C,B;if(!o.program){if(o instanceof THREE.MeshDepthMaterial){b(o,THREE.ShaderLib.depth);o.uniforms.mNear.value=g.near;o.uniforms.mFar.value=g.far}else if(o instanceof THREE.MeshNormalMaterial)b(o,THREE.ShaderLib.normal);else if(o instanceof THREE.MeshBasicMaterial){b(o,THREE.ShaderLib.basic);d(o,w)}else if(o instanceof THREE.MeshLambertMaterial){b(o,THREE.ShaderLib.lambert);d(o,w)}else if(o instanceof THREE.MeshPhongMaterial){b(o,THREE.ShaderLib.phong);
|
||||
d(o,w)}else if(o instanceof THREE.LineBasicMaterial){b(o,THREE.ShaderLib.basic);e(o,w)}var t,L,F;t=B=A=0;for(L=m.length;t<L;t++){F=m[t];F instanceof THREE.DirectionalLight&&B++;F instanceof THREE.PointLight&&A++}if(A+B<=4){t=B;A=A}else{t=Math.ceil(4*B/(A+B));A=4-t}A={directional:t,point:A};B={fog:w,map:o.map,env_map:o.env_map,maxDirLights:A.directional,maxPointLights:A.point};A=o.fragment_shader;t=o.vertex_shader;L=c.createProgram();F=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+
|
||||
B.maxDirLights,"#define MAX_POINT_LIGHTS "+B.maxPointLights,B.fog?"#define USE_FOG":"",B.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",B.map?"#define USE_MAP":"",B.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");B=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+B.maxDirLights,"#define MAX_POINT_LIGHTS "+B.maxPointLights,B.map?"#define USE_MAP":"",B.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(L,f("fragment",F+A));c.attachShader(L,f("vertex",B+t));c.linkProgram(L);c.getProgramParameter(L,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(L,c.VALIDATE_STATUS)+", gl error ["+
|
||||
c.getError()+"]");L.uniforms={};L.attributes={};o.program=L;A=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(s in o.uniforms)A.push(s);s=o.program;t=0;for(L=A.length;t<L;t++){F=A[t];s.uniforms[F]=c.getUniformLocation(s,F)}s=o.program;A=["position","normal","uv","tangent"];t=0;for(L=A.length;t<L;t++){F=A[t];s.attributes[F]=c.getAttribLocation(s,F)}}s=o.program;if(s!=i){c.useProgram(s);i=s}this.loadCamera(s,g);this.loadMatrices(s);if(o instanceof
|
||||
THREE.MeshPhongMaterial||o instanceof THREE.MeshLambertMaterial){this.setupLights(s,m);g=this.lights;o.uniforms.enableLighting.value=g.directional.length+g.point.length;o.uniforms.ambientLightColor.value=g.ambient;o.uniforms.directionalLightColor.value=g.directional.colors;o.uniforms.directionalLightDirection.value=g.directional.positions;o.uniforms.pointLightColor.value=g.point.colors;o.uniforms.pointLightPosition.value=g.point.positions}if(o instanceof THREE.MeshBasicMaterial||o instanceof THREE.MeshLambertMaterial||
|
||||
o instanceof THREE.MeshPhongMaterial)d(o,w);o instanceof THREE.LineBasicMaterial&&e(o,w);if(o instanceof THREE.MeshPhongMaterial){o.uniforms.ambient.value.setRGB(o.ambient.r,o.ambient.g,o.ambient.b);o.uniforms.specular.value.setRGB(o.specular.r,o.specular.g,o.specular.b);o.uniforms.shininess.value=o.shininess}w=o.uniforms;for(C in w)if(t=s.uniforms[C]){m=w[C];A=m.type;g=m.value;if(A=="i")c.uniform1i(t,g);else if(A=="f")c.uniform1f(t,g);else if(A=="fv1")c.uniform1fv(t,g);else if(A=="fv")c.uniform3fv(t,
|
||||
g);else if(A=="v2")c.uniform2f(t,g.x,g.y);else if(A=="v3")c.uniform3f(t,g.x,g.y,g.z);else if(A=="c")c.uniform3f(t,g.r,g.g,g.b);else if(A=="t"){c.uniform1i(t,g);if(m=m.texture)if(m.image instanceof Array&&m.image.length==6){m=m;g=g;if(m.image.length==6){if(!m.image.__webGLTextureCube&&!m.image.__cubeMapInitialized&&m.image.loadCount==6){m.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,m.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(A=0;A<6;++A)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+A,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,m.image[A]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);m.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+g);c.bindTexture(c.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube)}}else{m=
|
||||
m;g=g;if(!m.__webGLTexture&&m.image.loaded){m.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,m.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,m.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,h(m.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,h(m.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(m.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,h(m.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,
|
||||
null)}c.activeTexture(c.TEXTURE0+g);c.bindTexture(c.TEXTURE_2D,m.__webGLTexture)}}}C=s.attributes;c.bindBuffer(c.ARRAY_BUFFER,v.__webGLVertexBuffer);c.vertexAttribPointer(C.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(C.position);if(C.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,v.__webGLNormalBuffer);c.vertexAttribPointer(C.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(C.normal)}if(C.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,v.__webGLTangentBuffer);c.vertexAttribPointer(C.tangent,4,c.FLOAT,
|
||||
false,0,0);c.enableVertexAttribArray(C.tangent)}if(C.uv>=0)if(v.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,v.__webGLUVBuffer);c.vertexAttribPointer(C.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(C.uv)}else c.disableVertexAttribArray(C.uv);if(o.wireframe||o instanceof THREE.LineBasicMaterial){C=o.wireframe_linewidth!==undefined?o.wireframe_linewidth:o.linewidth!==undefined?o.linewidth:1;o=o instanceof THREE.LineBasicMaterial&&J.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(C);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
|
||||
v.__webGLLineBuffer);c.drawElements(o,v.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,v.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(g,m,w,o,v,J,s){var A,C,B,t,L;B=0;for(t=o.materials.length;B<t;B++){A=o.materials[B];if(A instanceof THREE.MeshFaceMaterial){A=0;for(C=v.materials.length;A<C;A++)if((L=v.materials[A])&&L.blending==J&&L.opacity<1==s){this.setBlending(L.blending);this.renderBuffer(g,m,w,L,
|
||||
v,o)}}else if((L=A)&&L.blending==J&&L.opacity<1==s){this.setBlending(L.blending);this.renderBuffer(g,m,w,L,v,o)}}};this.render=function(g,m,w,o){var v,J,s,A=g.lights,C=g.fog;this.initWebGLObjects(g);o=o!==undefined?o:true;if(w&&!w.__webGLFramebuffer){w.__webGLFramebuffer=c.createFramebuffer();w.__webGLRenderbuffer=c.createRenderbuffer();w.__webGLTexture=c.createTexture();c.bindRenderbuffer(c.RENDERBUFFER,w.__webGLRenderbuffer);c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,w.width,w.height);
|
||||
c.bindTexture(c.TEXTURE_2D,w.__webGLTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,h(w.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,h(w.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(w.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,h(w.min_filter));c.texImage2D(c.TEXTURE_2D,0,h(w.format),w.width,w.height,0,h(w.format),h(w.type),null);c.bindFramebuffer(c.FRAMEBUFFER,w.__webGLFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,
|
||||
w.__webGLTexture,0);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,w.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}if(w){v=w.__webGLFramebuffer;s=w.width;J=w.height}else{v=null;s=j.width;J=j.height}if(v!=k){c.bindFramebuffer(c.FRAMEBUFFER,v);c.viewport(0,0,s,J);o&&c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT);k=v}this.autoClear&&this.clear();m.autoUpdateMatrix&&m.updateMatrix();n.set(m.matrix.flatten());
|
||||
x.set(m.projectionMatrix.flatten());o=0;for(v=g.__webGLObjects.length;o<v;o++){J=g.__webGLObjects[o];s=J.object;J=J.buffer;if(s.visible){this.setupMatrices(s,m);this.renderPass(m,A,C,s,J,THREE.NormalBlending,false)}}o=0;for(v=g.__webGLObjects.length;o<v;o++){J=g.__webGLObjects[o];s=J.object;J=J.buffer;if(s.visible){this.setupMatrices(s,m);if(s.doubleSided)c.disable(c.CULL_FACE);else{c.enable(c.CULL_FACE);s.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW)}this.renderPass(m,A,C,s,J,THREE.AdditiveBlending,
|
||||
false);this.renderPass(m,A,C,s,J,THREE.SubtractiveBlending,false);this.renderPass(m,A,C,s,J,THREE.AdditiveBlending,true);this.renderPass(m,A,C,s,J,THREE.SubtractiveBlending,true);this.renderPass(m,A,C,s,J,THREE.NormalBlending,true)}}if(w&&w.min_filter!==THREE.NearestFilter&&w.min_filter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,w.__webGLTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}};this.initWebGLObjects=function(g){function m(B,t,L,F){if(B[t]==undefined){g.__webGLObjects.push({buffer:L,
|
||||
object:F});B[t]=1}}var w,o,v,J,s,A,C;if(!g.__webGLObjects){g.__webGLObjects=[];g.__webGLObjectsMap={}}w=0;for(o=g.objects.length;w<o;w++){v=g.objects[w];s=v.geometry;if(g.__webGLObjectsMap[v.id]==undefined)g.__webGLObjectsMap[v.id]={};C=g.__webGLObjectsMap[v.id];if(v instanceof THREE.Mesh){for(J in s.geometryChunks){A=s.geometryChunks[J];if(!A.__webGLVertexBuffer){this.createMeshBuffers(A);this.initMeshBuffers(A,v);s.__dirtyVertices=true;s.__dirtyElements=true;s.__dirtyUvs=true;s.__dirtyNormals=true;
|
||||
s.__dirtyTangents=true}if(s.__dirtyVertices||s.__dirtyElements||s.__dirtyUvs)this.setMeshBuffers(A,v,c.DYNAMIC_DRAW,s.__dirtyVertices,s.__dirtyElements,s.__dirtyUvs,s.__dirtyNormals,s.__dirtyTangents);m(C,J,A,v)}s.__dirtyVertices=false;s.__dirtyElements=false;s.__dirtyUvs=false;s.__dirtyNormals=false;s.__dirtyTangents=false}else if(v instanceof THREE.Line){if(!s.__webGLVertexBuffer){this.createLineBuffers(s);this.initLineBuffers(s);s.__dirtyVertices=true;s.__dirtyElements=true}s.__dirtyVertices&&
|
||||
this.setLineBuffers(s,c.DYNAMIC_DRAW,s.__dirtyVertices,s.__dirtyElements);m(C,0,s,v);s.__dirtyVertices=false;s.__dirtyElements=false}else if(v instanceof THREE.ParticleSystem){s.__webGLVertexBuffer||this.createParticleBuffers(s);m(C,0,s,v)}}};this.removeObject=function(g,m){var w,o;for(w=g.__webGLObjects.length-1;w>=0;w--){o=g.__webGLObjects[w].object;m==o&&g.__webGLObjects.splice(w,1)}};this.setupMatrices=function(g,m){g.autoUpdateMatrix&&g.updateMatrix();r.multiply(m.matrix,g.matrix);u.set(r.flatten());
|
||||
z=THREE.Matrix4.makeInvert3x3(r).transpose();y.set(z.m);H.set(g.matrix.flatten())};this.loadMatrices=function(g){c.uniformMatrix4fv(g.uniforms.viewMatrix,false,n);c.uniformMatrix4fv(g.uniforms.modelViewMatrix,false,u);c.uniformMatrix4fv(g.uniforms.projectionMatrix,false,x);c.uniformMatrix3fv(g.uniforms.normalMatrix,false,y);c.uniformMatrix4fv(g.uniforms.objectMatrix,false,H)};this.loadCamera=function(g,m){c.uniform3f(g.uniforms.cameraPosition,m.position.x,m.position.y,m.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,m){if(g){!m||m=="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.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=
|
||||
function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
|
||||
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 k=document.createElement("canvas"),c,j=null,l=null,t=new THREE.Matrix4,D,o=new Float32Array(16),u=new Float32Array(16),w=new Float32Array(16),C=new Float32Array(9),
|
||||
H=new Float32Array(16),v=true,I=new THREE.Color(0),m=0;if(a){if(a.antialias!==undefined)v=a.antialias;a.clearColor!==undefined&&I.setHex(a.clearColor);if(a.clearAlpha!==undefined)m=a.clearAlpha}this.domElement=k;this.autoClear=true;(function(h,n,B){try{c=k.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(n.r,n.g,n.b,B)})(v,I,m);this.context=c;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(h,n){k.width=h;k.height=n;c.viewport(0,0,k.width,k.height)};this.setClearColor=function(h,n){var B=new THREE.Color(h);c.clearColor(B.r,B.g,B.b,n)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=
|
||||
function(h,n){var B,q,z,M=0,p=0,A=0,F,E,y,O=this.lights,K=O.directional.colors,U=O.directional.positions,W=O.point.colors,P=O.point.positions,da=0,X=0;B=0;for(q=n.length;B<q;B++){z=n[B];F=z.color;E=z.position;y=z.intensity;if(z instanceof THREE.AmbientLight){M+=F.r;p+=F.g;A+=F.b}else if(z instanceof THREE.DirectionalLight){K[da*3]=F.r*y;K[da*3+1]=F.g*y;K[da*3+2]=F.b*y;U[da*3]=E.x;U[da*3+1]=E.y;U[da*3+2]=E.z;da+=1}else if(z instanceof THREE.PointLight){W[X*3]=F.r*y;W[X*3+1]=F.g*y;W[X*3+2]=F.b*y;P[X*
|
||||
3]=E.x;P[X*3+1]=E.y;P[X*3+2]=E.z;X+=1}}O.point.length=X;O.directional.length=da;O.ambient[0]=M;O.ambient[1]=p;O.ambient[2]=A};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 n=h.vertices.length;h.__vertexArray=new Float32Array(n*3);h.__lineArray=new Uint16Array(n);h.__webGLLineCount=n};this.initMeshBuffers=function(h,n){var B,q,z=0,M=0,p=0,A=n.geometry.faces,F=h.faces;B=0;for(q=F.length;B<q;B++){fi=F[B];face=A[fi];if(face instanceof THREE.Face3){z+=3;M+=1;p+=3}else if(face instanceof THREE.Face4){z+=4;M+=2;p+=4}}h.__vertexArray=
|
||||
new Float32Array(z*3);h.__normalArray=new Float32Array(z*3);h.__tangentArray=new Float32Array(z*4);h.__uvArray=new Float32Array(z*2);h.__faceArray=new Uint16Array(M*3);h.__lineArray=new Uint16Array(p*2);z=false;B=0;for(q=n.materials.length;B<q;B++){A=n.materials[B];if(A instanceof THREE.MeshFaceMaterial){A=0;for(F=h.materials.length;A<F;A++)if(h.materials[A]&&h.materials[A].shading!=undefined&&h.materials[A].shading==THREE.SmoothShading){z=true;break}}else if(A&&A.shading!=undefined&&A.shading==THREE.SmoothShading){z=
|
||||
true;break}if(z)break}h.__needsSmoothNormals=z;h.__webGLFaceCount=M*3;h.__webGLLineCount=p*2};this.setMeshBuffers=function(h,n,B,q,z,M,p,A){var F,E,y,O,K,U,W,P,da,X=0,R=0,T=0,ba=0,Y=0,G=0,S=0,V=h.__vertexArray,ia=h.__uvArray,ha=h.__normalArray,x=h.__tangentArray,L=h.__faceArray,J=h.__lineArray,Z=h.__needsSmoothNormals,ca=n.geometry,ga=ca.vertices,ja=h.faces,qa=ca.faces,sa=ca.uvs;n=0;for(F=ja.length;n<F;n++){E=ja[n];y=qa[E];E=sa[E];O=y.vertexNormals;K=y.normal;if(y instanceof THREE.Face3){if(q){U=
|
||||
ga[y.a].position;W=ga[y.b].position;P=ga[y.c].position;V[R]=U.x;V[R+1]=U.y;V[R+2]=U.z;V[R+3]=W.x;V[R+4]=W.y;V[R+5]=W.z;V[R+6]=P.x;V[R+7]=P.y;V[R+8]=P.z;R+=9}if(A&&ca.hasTangents){U=ga[y.a].tangent;W=ga[y.b].tangent;P=ga[y.c].tangent;x[G]=U.x;x[G+1]=U.y;x[G+2]=U.z;x[G+3]=U.w;x[G+4]=W.x;x[G+5]=W.y;x[G+6]=W.z;x[G+7]=W.w;x[G+8]=P.x;x[G+9]=P.y;x[G+10]=P.z;x[G+11]=P.w;G+=12}if(p)if(O.length==3&&Z)for(y=0;y<3;y++){K=O[y];ha[Y]=K.x;ha[Y+1]=K.y;ha[Y+2]=K.z;Y+=3}else for(y=0;y<3;y++){ha[Y]=K.x;ha[Y+1]=K.y;
|
||||
ha[Y+2]=K.z;Y+=3}if(M&&E)for(y=0;y<3;y++){O=E[y];ia[T]=O.u;ia[T+1]=O.v;T+=2}if(z){L[ba]=X;L[ba+1]=X+1;L[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){U=ga[y.a].position;W=ga[y.b].position;P=ga[y.c].position;da=ga[y.d].position;V[R]=U.x;V[R+1]=U.y;V[R+2]=U.z;V[R+3]=W.x;V[R+4]=W.y;V[R+5]=W.z;V[R+6]=P.x;V[R+7]=P.y;V[R+8]=P.z;V[R+9]=da.x;V[R+10]=da.y;V[R+11]=da.z;R+=12}if(A&&ca.hasTangents){U=ga[y.a].tangent;W=ga[y.b].tangent;
|
||||
P=ga[y.c].tangent;y=ga[y.d].tangent;x[G]=U.x;x[G+1]=U.y;x[G+2]=U.z;x[G+3]=U.w;x[G+4]=W.x;x[G+5]=W.y;x[G+6]=W.z;x[G+7]=W.w;x[G+8]=P.x;x[G+9]=P.y;x[G+10]=P.z;x[G+11]=P.w;x[G+12]=y.x;x[G+13]=y.y;x[G+14]=y.z;x[G+15]=y.w;G+=16}if(p)if(O.length==4&&Z)for(y=0;y<4;y++){K=O[y];ha[Y]=K.x;ha[Y+1]=K.y;ha[Y+2]=K.z;Y+=3}else for(y=0;y<4;y++){ha[Y]=K.x;ha[Y+1]=K.y;ha[Y+2]=K.z;Y+=3}if(M&&E)for(y=0;y<4;y++){O=E[y];ia[T]=O.u;ia[T+1]=O.v;T+=2}if(z){L[ba]=X;L[ba+1]=X+1;L[ba+2]=X+2;L[ba+3]=X;L[ba+4]=X+2;L[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,V,B)}if(p){c.bindBuffer(c.ARRAY_BUFFER,h.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,ha,B)}if(A&&ca.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,h.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,x,B)}if(M&&T>0){c.bindBuffer(c.ARRAY_BUFFER,h.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,ia,B)}if(z){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
|
||||
h.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,L,B);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,J,B)}};this.setLineBuffers=function(h,n,B,q){var z,M,p=h.vertices,A=p.length,F=h.__vertexArray,E=h.__lineArray;if(B)for(B=0;B<A;B++){z=p[B].position;M=B*3;F[M]=z.x;F[M+1]=z.y;F[M+2]=z.z}if(q)for(B=0;B<A;B++)E[B]=B;c.bindBuffer(c.ARRAY_BUFFER,h.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,F,n);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webGLLineBuffer);
|
||||
c.bufferData(c.ELEMENT_ARRAY_BUFFER,E,n)};this.setParticleBuffers=function(){};this.renderBuffer=function(h,n,B,q,z,M){var p,A,F,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,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,O,K;y=E=A=0;for(O=n.length;y<O;y++){K=n[y];K instanceof THREE.DirectionalLight&&E++;K instanceof THREE.PointLight&&A++}if(A+E<=4){y=E;A=A}else{y=Math.ceil(4*E/(A+E));A=4-y}A={directional:y,point:A};E={fog:B,map:q.map,env_map:q.env_map,maxDirLights:A.directional,maxPointLights:A.point};A=q.fragment_shader;y=q.vertex_shader;O=c.createProgram();
|
||||
K=["#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(O,f("fragment",K+A));c.attachShader(O,f("vertex",E+y));c.linkProgram(O);c.getProgramParameter(O,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+
|
||||
c.getProgramParameter(O,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");O.uniforms={};O.attributes={};q.program=O;A=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(p in q.uniforms)A.push(p);p=q.program;y=0;for(O=A.length;y<O;y++){K=A[y];p.uniforms[K]=c.getUniformLocation(p,K)}p=q.program;A=["position","normal","uv","tangent"];y=0;for(O=A.length;y<O;y++){K=A[y];p.attributes[K]=c.getAttribLocation(p,K)}}p=q.program;if(p!=j){c.useProgram(p);
|
||||
j=p}this.loadCamera(p,h);this.loadMatrices(p);if(q instanceof THREE.MeshPhongMaterial||q instanceof THREE.MeshLambertMaterial){this.setupLights(p,n);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,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(F in B)if(y=p.uniforms[F]){n=B[F];A=n.type;h=n.value;if(A=="i")c.uniform1i(y,h);else if(A=="f")c.uniform1f(y,
|
||||
h);else if(A=="fv1")c.uniform1fv(y,h);else if(A=="fv")c.uniform3fv(y,h);else if(A=="v2")c.uniform2f(y,h.x,h.y);else if(A=="v3")c.uniform3f(y,h.x,h.y,h.z);else if(A=="c")c.uniform3f(y,h.r,h.g,h.b);else if(A=="t"){c.uniform1i(y,h);if(n=n.texture)if(n.image instanceof Array&&n.image.length==6){n=n;h=h;if(n.image.length==6){if(!n.image.__webGLTextureCube&&!n.image.__cubeMapInitialized&&n.image.loadCount==6){n.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,n.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(A=0;A<6;++A)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+A,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,n.image[A]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);n.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+
|
||||
h);c.bindTexture(c.TEXTURE_CUBE_MAP,n.image.__webGLTextureCube)}}else{n=n;h=h;if(!n.__webGLTexture&&n.image.loaded){n.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,n.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,n.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,g(n.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,g(n.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,g(n.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,g(n.min_filter));
|
||||
c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+h);c.bindTexture(c.TEXTURE_2D,n.__webGLTexture)}}}F=p.attributes;c.bindBuffer(c.ARRAY_BUFFER,z.__webGLVertexBuffer);c.vertexAttribPointer(F.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(F.position);if(F.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,z.__webGLNormalBuffer);c.vertexAttribPointer(F.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(F.normal)}if(F.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,z.__webGLTangentBuffer);
|
||||
c.vertexAttribPointer(F.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(F.tangent)}if(F.uv>=0)if(z.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,z.__webGLUVBuffer);c.vertexAttribPointer(F.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(F.uv)}else c.disableVertexAttribArray(F.uv);if(q.wireframe||q instanceof THREE.LineBasicMaterial){F=q.wireframe_linewidth!==undefined?q.wireframe_linewidth:q.linewidth!==undefined?q.linewidth:1;q=q instanceof THREE.LineBasicMaterial&&M.type==THREE.LineStrip?
|
||||
c.LINE_STRIP:c.LINES;c.lineWidth(F);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,z.__webGLLineBuffer);c.drawElements(q,z.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,z.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,z.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(h,n,B,q,z,M,p){var A,F,E,y,O;E=0;for(y=q.materials.length;E<y;E++){A=q.materials[E];if(A instanceof THREE.MeshFaceMaterial){A=0;for(F=z.materials.length;A<F;A++)if((O=z.materials[A])&&O.blending==M&&
|
||||
O.opacity<1==p){this.setBlending(O.blending);this.renderBuffer(h,n,B,O,z,q)}}else if((O=A)&&O.blending==M&&O.opacity<1==p){this.setBlending(O.blending);this.renderBuffer(h,n,B,O,z,q)}}};this.render=function(h,n,B,q){var z,M,p,A=h.lights,F=h.fog;this.initWebGLObjects(h);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,g(B.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,g(B.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,g(B.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,g(B.min_filter));c.texImage2D(c.TEXTURE_2D,0,g(B.format),B.width,B.height,0,g(B.format),g(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){z=B.__webGLFramebuffer;p=B.width;M=B.height}else{z=null;p=k.width;M=k.height}if(z!=l){c.bindFramebuffer(c.FRAMEBUFFER,z);c.viewport(0,0,p,M);q&&c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT);l=z}this.autoClear&&
|
||||
this.clear();n.autoUpdateMatrix&&n.updateMatrix();o.set(n.matrix.flatten());w.set(n.projectionMatrix.flatten());q=0;for(z=h.__webGLObjects.length;q<z;q++){M=h.__webGLObjects[q];p=M.object;M=M.buffer;if(p.visible){this.setupMatrices(p,n);this.renderPass(n,A,F,p,M,THREE.NormalBlending,false)}}q=0;for(z=h.__webGLObjects.length;q<z;q++){M=h.__webGLObjects[q];p=M.object;M=M.buffer;if(p.visible){this.setupMatrices(p,n);if(p.doubleSided)c.disable(c.CULL_FACE);else{c.enable(c.CULL_FACE);p.flipSided?c.frontFace(c.CW):
|
||||
c.frontFace(c.CCW)}this.renderPass(n,A,F,p,M,THREE.AdditiveBlending,false);this.renderPass(n,A,F,p,M,THREE.SubtractiveBlending,false);this.renderPass(n,A,F,p,M,THREE.AdditiveBlending,true);this.renderPass(n,A,F,p,M,THREE.SubtractiveBlending,true);this.renderPass(n,A,F,p,M,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(h){function n(E,y,O,K){if(E[y]==undefined){h.__webGLObjects.push({buffer:O,object:K});E[y]=1}}var B,q,z,M,p,A,F;if(!h.__webGLObjects){h.__webGLObjects=[];h.__webGLObjectsMap={}}B=0;for(q=h.objects.length;B<q;B++){z=h.objects[B];p=z.geometry;if(h.__webGLObjectsMap[z.id]==undefined)h.__webGLObjectsMap[z.id]={};F=h.__webGLObjectsMap[z.id];if(z instanceof THREE.Mesh){for(M in p.geometryChunks){A=p.geometryChunks[M];if(!A.__webGLVertexBuffer){this.createMeshBuffers(A);this.initMeshBuffers(A,z);
|
||||
p.__dirtyVertices=true;p.__dirtyElements=true;p.__dirtyUvs=true;p.__dirtyNormals=true;p.__dirtyTangents=true}if(p.__dirtyVertices||p.__dirtyElements||p.__dirtyUvs)this.setMeshBuffers(A,z,c.DYNAMIC_DRAW,p.__dirtyVertices,p.__dirtyElements,p.__dirtyUvs,p.__dirtyNormals,p.__dirtyTangents);n(F,M,A,z)}p.__dirtyVertices=false;p.__dirtyElements=false;p.__dirtyUvs=false;p.__dirtyNormals=false;p.__dirtyTangents=false}else if(z instanceof THREE.Line){if(!p.__webGLVertexBuffer){this.createLineBuffers(p);this.initLineBuffers(p);
|
||||
p.__dirtyVertices=true;p.__dirtyElements=true}p.__dirtyVertices&&this.setLineBuffers(p,c.DYNAMIC_DRAW,p.__dirtyVertices,p.__dirtyElements);n(F,0,p,z);p.__dirtyVertices=false;p.__dirtyElements=false}else if(z instanceof THREE.ParticleSystem){p.__webGLVertexBuffer||this.createParticleBuffers(p);n(F,0,p,z)}}};this.removeObject=function(h,n){var B,q;for(B=h.__webGLObjects.length-1;B>=0;B--){q=h.__webGLObjects[B].object;n==q&&h.__webGLObjects.splice(B,1)}};this.setupMatrices=function(h,n){h.autoUpdateMatrix&&
|
||||
h.updateMatrix();t.multiply(n.matrix,h.matrix);u.set(t.flatten());D=THREE.Matrix4.makeInvert3x3(t).transpose();C.set(D.m);H.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,w);c.uniformMatrix3fv(h.uniforms.normalMatrix,false,C);c.uniformMatrix4fv(h.uniforms.objectMatrix,false,H)};this.loadCamera=function(h,n){c.uniform3f(h.uniforms.cameraPosition,
|
||||
n.position.x,n.position.y,n.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,n){if(h){!n||n=="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",
|
||||
map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
|
||||
@@ -200,50 +201,57 @@ 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,i=f.faces,k=a.uvs;f=f.uvs;d&&b.autoUpdateMatrix&&b.updateMatrix();for(var r=0,z=j.length;r<z;r++){var n=new THREE.Vertex(j[r].position.clone());d&&b.matrix.multiplyVector3(n.position);h.push(n)}r=0;for(z=i.length;r<z;r++){j=i[r];var u,x=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(h=x.length;d<h;d++){n=x[d];u.vertexNormals.push(n.clone())}u.materials=j.materials.slice();c.push(u)}r=0;for(z=f.length;r<z;r++){e=f[r];c=[];d=0;for(h=e.length;d<h;d++)c.push(new THREE.UV(e[d].u,e[d].v));k.push(c)}}},ImageUtils={loadTexture:function(a,b){var d=new Image;d.onload=function(){this.loaded=true};d.src=a;return new THREE.Texture(d,b)},loadArray:function(a){var b,d,e=[];b=e.loadCount=0;for(d=a.length;b<d;++b){e[b]=
|
||||
new Image;e[b].loaded=0;e[b].onload=function(){e.loadCount+=1;this.loaded=true};e[b].src=a[b]}return e}},SceneUtils={addMesh:function(a,b,d,e,f,h,j,c,i,k){b=new THREE.Mesh(b,k);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=i;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,d){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=d;d=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,
|
||||
var GeometryUtils={merge:function(a,b){var d=b instanceof THREE.Mesh,e=a.vertices.length,f=d?b.geometry:b,g=a.vertices,k=f.vertices,c=a.faces,j=f.faces,l=a.uvs;f=f.uvs;d&&b.autoUpdateMatrix&&b.updateMatrix();for(var t=0,D=k.length;t<D;t++){var o=new THREE.Vertex(k[t].position.clone());d&&b.matrix.multiplyVector3(o.position);g.push(o)}t=0;for(D=j.length;t<D;t++){k=j[t];var u,w=k.vertexNormals;if(k instanceof THREE.Face3)u=new THREE.Face3(k.a+e,k.b+e,k.c+e);else if(k instanceof THREE.Face4)u=new THREE.Face4(k.a+
|
||||
e,k.b+e,k.c+e,k.d+e);u.centroid.copy(k.centroid);u.normal.copy(k.normal);d=0;for(g=w.length;d<g;d++){o=w[d];u.vertexNormals.push(o.clone())}u.materials=k.materials.slice();c.push(u)}t=0;for(D=f.length;t<D;t++){e=f[t];c=[];d=0;for(g=e.length;d<g;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){var d,e,f,g,k,c,j,l,t,D,o,u,w,C,H,v,I,m,h,n,B=new Worker(a);B.onmessage=function(q){function z(){for(f in p.objects)if(!A.objects[f]){t=p.objects[f];if(H=A.geometries[t.geometry]){h=[];for(i=0;i<t.materials.length;i++)h[i]=A.materials[t.materials[i]];u=t.position;r=t.rotation;s=t.scale;object=new THREE.Mesh(H,h);object.position.set(u[0],u[1],u[2]);object.rotation.set(r[0],
|
||||
r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=t.visible;A.scene.addObject(object);A.objects[f]=object}}}function M(F){return function(E){A.geometries[F]=E;z()}}var p=q.data,A={scene:new THREE.Scene,geometries:{},materials:{},objects:{},cameras:{},lights:{},fogs:{}};n=new THREE.Loader;for(d in p.geometries){l=p.geometries[d];if(l.type=="cube"){H=new Cube(l.width,l.height,l.depth,l.segments_width,l.segments_height,null,l.flipped,l.sides);A.geometries[d]=H}else if(l.type=="plane"){H=new Plane(l.width,
|
||||
l.height,l.segments_width,l.segments_height);A.geometries[d]=H}else if(l.type=="sphere"){H=new Sphere(l.radius,l.segments_width,l.segments_height);A.geometries[d]=H}else if(l.type=="cylinder"){H=new Cylinder(l.numSegs,l.topRad,l.botRad,l.height,l.topOffset,l.botOffset);A.geometries[d]=H}else if(l.type=="torus"){H=new Torus(l.radius,l.tube,l.segmentsR,l.segmentsT);A.geometries[d]=H}else if(l.type=="bin_mesh")n.loadBinary({model:l.url,callback:M(d)});else l.type=="ascii_mesh"&&n.loadAscii({model:l.url,
|
||||
callback:M(d)})}for(e in p.materials){D=p.materials[e];v=new THREE[D.type](D.parameters);A.materials[e]=v}z();for(g in p.lights){o=p.lights[g];if(o.type=="directional"){u=o.direction;light=new THREE.DirectionalLight;light.position.set(u[0],u[1],u[2]);light.position.normalize()}else if(o.type=="point"){u=o.position;light=new THREE.PointLight;light.position.set(u[0],u[1],u[2])}w=o.color;light.color.setRGB(w[0],w[1],w[2]);A.scene.addLight(light);A.lights[g]=light}for(k in p.cameras){w=p.cameras[k];if(w.type==
|
||||
"perspective")I=new THREE.Camera(w.fov,w.aspect,w.near,w.far);else if(w.type=="ortho"){I=new THREE.Camera;I.projectionMatrix=THREE.Matrix4.makeOrtho(w.left,w.right,w.top,w.bottom,w.near,w.far)}u=w.position;C=w.target;I.position.set(u[0],u[1],u[2]);I.target.position.set(C[0],C[1],C[2]);A.cameras[k]=I}for(c in p.fogs){j=p.fogs[c];if(j.type=="linear")m=new THREE.Fog(0,j.near,j.far);else if(j.type=="exp2")m=new THREE.FogExp2(0,j.density);w=j.color;m.color.setRGB(w[0],w[1],w[2]);A.fogs[c]=m}A.currentCamera=
|
||||
A.cameras[p.defaults.camera];if(A.fogs&&p.defaults.fog)A.scene.fog=A.fogs[p.defaults.fog];b(A)};B.postMessage(0)},addMesh:function(a,b,d,e,f,g,k,c,j,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=g;b.rotation.x=k;b.rotation.y=c;b.rotation.z=j;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}",
|
||||
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,g=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,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));SceneUtils.addMesh(a,b,1,0,-e,0,-f,0,g,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 i(y,H,p,I,l,g,m,w){var o,v,J=e||1,s=f||1,A=J+1,C=s+1,B=l/2,t=g/2;l=l/J;var L=g/s,F=k.vertices.length;if(y=="x"&&H=="y"||y=="y"&&H=="x")o="z";else if(y=="x"&&H=="z"||y=="z"&&H=="x")o="y";else if(y=="z"&&H=="y"||y=="y"&&H=="z")o="x";for(v=0;v<C;v++)for(g=0;g<A;g++){var R=new THREE.Vector3;
|
||||
R[y]=(g*l-B)*p;R[H]=(v*L-t)*I;R[o]=m;k.vertices.push(new THREE.Vertex(R))}for(v=0;v<s;v++)for(g=0;g<J;g++){k.faces.push(new THREE.Face4(g+A*v+F,g+A*(v+1)+F,g+1+A*(v+1)+F,g+1+A*v+F,null,w));k.uvs.push([new THREE.UV(g/J,v/s),new THREE.UV(g/J,(v+1)/s),new THREE.UV((g+1)/J,(v+1)/s),new THREE.UV((g+1)/J,v/s)])}}THREE.Geometry.call(this);var k=this,r=a/2,z=b/2,n=d/2;j=j?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var u=0;u<6;u++)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 x in c)if(this.sides[x]!=undefined)this.sides[x]=c[x];this.sides.px&&i("z","y",1*j,-1,d,b,-r,this.materials[0]);this.sides.nx&&i("z","y",-1*j,-1,d,b,r,this.materials[1]);this.sides.py&&i("x","z",1*j,1,a,d,z,this.materials[2]);this.sides.ny&&i("x","z",1*j,-1,a,d,-z,this.materials[3]);this.sides.pz&&i("x","y",1*j,-1,a,b,n,this.materials[4]);this.sides.nz&&i("x","y",-1*j,-1,a,b,-n,this.materials[5]);(function(){for(var y=
|
||||
[],H=[],p=0,I=k.vertices.length;p<I;p++){for(var l=k.vertices[p],g=false,m=0,w=y.length;m<w;m++){var o=y[m];if(l.position.x==o.position.x&&l.position.y==o.position.y&&l.position.z==o.position.z){H[p]=m;g=true;break}}if(!g){H[p]=y.length;y.push(new THREE.Vertex(l.position.clone()))}}p=0;for(I=k.faces.length;p<I;p++){l=k.faces[p];l.a=H[l.a];l.b=H[l.b];l.c=H[l.c];l.d=H[l.d]}k.vertices=y})();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,f,g,k,c){function j(C,H,v,I,m,h,n,B){var q,z,M=e||1,p=f||1,A=M+1,F=p+1,E=m/2,y=h/2;m=m/M;var O=h/p,K=l.vertices.length;if(C=="x"&&H=="y"||C=="y"&&H=="x")q="z";else if(C=="x"&&H=="z"||C=="z"&&H=="x")q="y";else if(C=="z"&&H=="y"||C=="y"&&H=="z")q="x";for(z=0;z<F;z++)for(h=0;h<A;h++){var U=new THREE.Vector3;
|
||||
U[C]=(h*m-E)*v;U[H]=(z*O-y)*I;U[q]=n;l.vertices.push(new THREE.Vertex(U))}for(z=0;z<p;z++)for(h=0;h<M;h++){l.faces.push(new THREE.Face4(h+A*z+K,h+A*(z+1)+K,h+1+A*(z+1)+K,h+1+A*z+K,null,B));l.uvs.push([new THREE.UV(h/M,z/p),new THREE.UV(h/M,(z+1)/p),new THREE.UV((h+1)/M,(z+1)/p),new THREE.UV((h+1)/M,z/p)])}}THREE.Geometry.call(this);var l=this,t=a/2,D=b/2,o=d/2;k=k?-1:1;if(g!==undefined)if(g instanceof Array)this.materials=g;else{this.materials=[];for(var u=0;u<6;u++)this.materials.push([g])}else this.materials=
|
||||
[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(c!=undefined)for(var w in c)if(this.sides[w]!=undefined)this.sides[w]=c[w];this.sides.px&&j("z","y",1*k,-1,d,b,-t,this.materials[0]);this.sides.nx&&j("z","y",-1*k,-1,d,b,t,this.materials[1]);this.sides.py&&j("x","z",1*k,1,a,d,D,this.materials[2]);this.sides.ny&&j("x","z",1*k,-1,a,d,-D,this.materials[3]);this.sides.pz&&j("x","y",1*k,-1,a,b,o,this.materials[4]);this.sides.nz&&j("x","y",-1*k,-1,a,b,-o,this.materials[5]);(function(){for(var C=
|
||||
[],H=[],v=0,I=l.vertices.length;v<I;v++){for(var m=l.vertices[v],h=false,n=0,B=C.length;n<B;n++){var q=C[n];if(m.position.x==q.position.x&&m.position.y==q.position.y&&m.position.z==q.position.z){H[v]=n;h=true;break}}if(!h){H[v]=C.length;C.push(new THREE.Vertex(m.position.clone()))}}v=0;for(I=l.faces.length;v<I;v++){m=l.faces[v];m.a=H[m.a];m.b=H[m.b];m.c=H[m.c];m.d=H[m.d]}l.vertices=C})();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(k,r,z){j.vertices.push(new THREE.Vertex(new THREE.Vector3(k,r,z)))}THREE.Geometry.call(this);var j=this,c=Math.PI,i;for(i=0;i<a;i++)h(Math.sin(2*c*i/a)*b,Math.cos(2*c*i/a)*b,0);for(i=0;i<a;i++)h(Math.sin(2*c*i/a)*d,Math.cos(2*c*i/a)*d,e);for(i=0;i<a;i++)j.faces.push(new THREE.Face4(i,i+a,a+(i+1)%a,(i+1)%a));if(d!=0){h(0,0,-f);for(i=a;i<a+a/2;i++)j.faces.push(new THREE.Face4(2*a,(2*i-2*a)%a,(2*i-2*a+1)%a,(2*i-2*a+2)%a))}if(b!=0){h(0,0,e+f);for(i=a+a/2;i<
|
||||
2*a;i++)j.faces.push(new THREE.Face4((2*i-2*a+2)%a+a,(2*i-2*a+1)%a+a,(2*i-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
|
||||
var Plane=function(a,b,d,e){THREE.Geometry.call(this);var f,h=a/2,j=b/2;d=d||1;e=e||1;var c=d+1,i=e+1;a=a/d;var k=b/e;for(f=0;f<i;f++)for(b=0;b<c;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-h,-(f*k-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 Cylinder=function(a,b,d,e,f){function g(l,t,D){k.vertices.push(new THREE.Vertex(new THREE.Vector3(l,t,D)))}THREE.Geometry.call(this);var k=this,c=Math.PI,j;for(j=0;j<a;j++)g(Math.sin(2*c*j/a)*b,Math.cos(2*c*j/a)*b,0);for(j=0;j<a;j++)g(Math.sin(2*c*j/a)*d,Math.cos(2*c*j/a)*d,e);for(j=0;j<a;j++)k.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(d!=0){g(0,0,-f);for(j=a;j<a+a/2;j++)k.faces.push(new THREE.Face4(2*a,(2*j-2*a)%a,(2*j-2*a+1)%a,(2*j-2*a+2)%a))}if(b!=0){g(0,0,e+f);for(j=a+a/2;j<
|
||||
2*a;j++)k.faces.push(new THREE.Face4((2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-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,g=a/2,k=b/2;d=d||1;e=e||1;var c=d+1,j=e+1;a=a/d;var l=b/e;for(f=0;f<j;f++)for(b=0;b<c;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-g,-(f*l-k),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()};
|
||||
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),i=a*Math.sin(e*f),k=[],r=0;for(e=0;e<h;e++){var z=2*e/h,n=i*Math.sin(z*f);z=i*Math.cos(z*f);(d==0||d==j)&&e>0||(r=this.vertices.push(new THREE.Vertex(new THREE.Vector3(z,c,n)))-1);k.push(r)}b.push(k)}var u,x,y;f=b.length;for(d=0;d<f;d++){h=b[d].length;if(d>0)for(e=0;e<h;e++){k=e==h-1;j=b[d][k?0:e+1];c=b[d][k?h-1:e];i=b[d-1][k?h-1:e];k=b[d-1][k?
|
||||
0:e+1];n=d/(f-1);u=(d-1)/(f-1);x=(e+1)/h;z=e/h;r=new THREE.UV(1-x,n);n=new THREE.UV(1-z,n);z=new THREE.UV(1-z,u);var H=new THREE.UV(1-x,u);if(d<b.length-1){u=this.vertices[j].position.clone();x=this.vertices[c].position.clone();y=this.vertices[i].position.clone();u.normalize();x.normalize();y.normalize();this.faces.push(new THREE.Face3(j,c,i,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(y.x,y.y,y.z)]));this.uvs.push([r,n,z])}if(d>1){u=this.vertices[j].position.clone();
|
||||
x=this.vertices[i].position.clone();y=this.vertices[k].position.clone();u.normalize();x.normalize();y.normalize();this.faces.push(new THREE.Face3(j,i,k,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(y.x,y.y,y.z)]));this.uvs.push([r,z,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
|
||||
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 i=THREE.Matrix4.rotationZMatrix(b),k=0;k<=d+0.0010;k+=b){for(c=0;c<e.length;c++)if(k<d){e[c]=i.multiplyVector3(e[c].clone());this.vertices.push(new THREE.Vertex(e[c]));h[c]=this.vertices.length-1}else h=j;if(k==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(k/d,c/a.length),new THREE.UV(k/d,(c+1)/a.length),new THREE.UV((k-b)/d,(c+1)/a.length),new THREE.UV((k-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,f=Math.PI,g=Math.max(3,b||8),k=Math.max(2,d||6);b=[];for(d=0;d<k+1;d++){e=d/k;var c=a*Math.cos(e*f),j=a*Math.sin(e*f),l=[],t=0;for(e=0;e<g;e++){var D=2*e/g,o=j*Math.sin(D*f);D=j*Math.cos(D*f);(d==0||d==k)&&e>0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(D,c,o)))-1);l.push(t)}b.push(l)}var u,w,C;f=b.length;for(d=0;d<f;d++){g=b[d].length;if(d>0)for(e=0;e<g;e++){l=e==g-1;k=b[d][l?0:e+1];c=b[d][l?g-1:e];j=b[d-1][l?g-1:e];l=b[d-1][l?
|
||||
0:e+1];o=d/(f-1);u=(d-1)/(f-1);w=(e+1)/g;D=e/g;t=new THREE.UV(1-w,o);o=new THREE.UV(1-D,o);D=new THREE.UV(1-D,u);var H=new THREE.UV(1-w,u);if(d<b.length-1){u=this.vertices[k].position.clone();w=this.vertices[c].position.clone();C=this.vertices[j].position.clone();u.normalize();w.normalize();C.normalize();this.faces.push(new THREE.Face3(k,c,j,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([t,o,D])}if(d>1){u=this.vertices[k].position.clone();
|
||||
w=this.vertices[j].position.clone();C=this.vertices[l].position.clone();u.normalize();w.normalize();C.normalize();this.faces.push(new THREE.Face3(k,j,l,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([t,D,H])}}}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 g=(this.segmentsT+1)*(b-1)+d-1,k=(this.segmentsT+1)*(b-1)+d;this.faces.push(new THREE.Face4(e,f,g,k));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[g][0],a[g][1]),new THREE.UV(a[k][0],a[k][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=[],g=[],k=[],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 j=THREE.Matrix4.rotationZMatrix(b),l=0;l<=d+0.0010;l+=b){for(c=0;c<e.length;c++)if(l<d){e[c]=j.multiplyVector3(e[c].clone());this.vertices.push(new THREE.Vertex(e[c]));g[c]=this.vertices.length-1}else g=k;if(l==0)k=f;for(c=0;c<f.length-1;c++){this.faces.push(new THREE.Face4(g[c],
|
||||
g[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=g;g=[]}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,i=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(i==0)i=j.getResponseHeader("Content-Length");h({total:i,loaded:j.responseText.length})}}else if(j.readyState==2)i=j.getResponseHeader("Content-Length")};j.open("GET",c,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)},
|
||||
createBinModel:function(a,b,d,e){var f=function(h){function j(q,G){var E=r(q,G),W=r(q,G+1),$=r(q,G+2),da=r(q,G+3),ga=(da<<1&255|$>>7)-127;E=($&127)<<16|W<<8|E;if(E==0&&ga==-127)return 0;return(1-2*(da>>7))*(1+E*Math.pow(2,-23))*Math.pow(2,ga)}function c(q,G){var E=r(q,G),W=r(q,G+1),$=r(q,G+2);return(r(q,G+3)<<24)+($<<16)+(W<<8)+E}function i(q,G){var E=r(q,G);return(r(q,G+1)<<8)+E}function k(q,G){var E=r(q,G);return E>127?E-256:E}function r(q,G){return q.charCodeAt(G)&255}function z(q){var G,E,W;G=
|
||||
c(a,q);E=c(a,q+w);W=c(a,q+o);q=i(a,q+v);THREE.Loader.prototype.f3(p,G,E,W,q)}function n(q){var G,E,W,$,da,ga;G=c(a,q);E=c(a,q+w);W=c(a,q+o);$=i(a,q+v);da=c(a,q+J);ga=c(a,q+s);q=c(a,q+A);THREE.Loader.prototype.f3n(p,g,G,E,W,$,da,ga,q)}function u(q){var G,E,W,$;G=c(a,q);E=c(a,q+C);W=c(a,q+B);$=c(a,q+t);q=i(a,q+L);THREE.Loader.prototype.f4(p,G,E,W,$,q)}function x(q){var G,E,W,$,da,ga,na,pa;G=c(a,q);E=c(a,q+C);W=c(a,q+B);$=c(a,q+t);da=i(a,q+L);ga=c(a,q+F);na=c(a,q+R);pa=c(a,q+T);q=c(a,q+M);THREE.Loader.prototype.f4n(p,
|
||||
g,G,E,W,$,da,ga,na,pa,q)}function y(q){var G,E;G=c(a,q);E=c(a,q+aa);q=c(a,q+U);THREE.Loader.prototype.uv3(p,m[G*2],m[G*2+1],m[E*2],m[E*2+1],m[q*2],m[q*2+1])}function H(q){var G,E,W;G=c(a,q);E=c(a,q+O);W=c(a,q+Q);q=c(a,q+Z);THREE.Loader.prototype.uv4(p,m[G*2],m[G*2+1],m[E*2],m[E*2+1],m[W*2],m[W*2+1],m[q*2],m[q*2+1])}var p=this,I=0,l,g=[],m=[],w,o,v,J,s,A,C,B,t,L,F,R,T,M,aa,U,O,Q,Z,V,D,P,S,fa,ea;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(p,e,h);l={signature:a.substr(I,8),header_bytes:r(a,
|
||||
I+8),vertex_coordinate_bytes:r(a,I+9),normal_coordinate_bytes:r(a,I+10),uv_coordinate_bytes:r(a,I+11),vertex_index_bytes:r(a,I+12),normal_index_bytes:r(a,I+13),uv_index_bytes:r(a,I+14),material_index_bytes:r(a,I+15),nvertices:c(a,I+16),nnormals:c(a,I+16+4),nuvs:c(a,I+16+8),ntri_flat:c(a,I+16+12),ntri_smooth:c(a,I+16+16),ntri_flat_uv:c(a,I+16+20),ntri_smooth_uv:c(a,I+16+24),nquad_flat:c(a,I+16+28),nquad_smooth:c(a,I+16+32),nquad_flat_uv:c(a,I+16+36),nquad_smooth_uv:c(a,I+16+40)};I+=l.header_bytes;
|
||||
w=l.vertex_index_bytes;o=l.vertex_index_bytes*2;v=l.vertex_index_bytes*3;J=l.vertex_index_bytes*3+l.material_index_bytes;s=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes;A=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*2;C=l.vertex_index_bytes;B=l.vertex_index_bytes*2;t=l.vertex_index_bytes*3;L=l.vertex_index_bytes*4;F=l.vertex_index_bytes*4+l.material_index_bytes;R=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes;T=l.vertex_index_bytes*4+
|
||||
l.material_index_bytes+l.normal_index_bytes*2;M=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*3;aa=l.uv_index_bytes;U=l.uv_index_bytes*2;O=l.uv_index_bytes;Q=l.uv_index_bytes*2;Z=l.uv_index_bytes*3;h=l.vertex_index_bytes*3+l.material_index_bytes;ea=l.vertex_index_bytes*4+l.material_index_bytes;V=l.ntri_flat*h;D=l.ntri_smooth*(h+l.normal_index_bytes*3);P=l.ntri_flat_uv*(h+l.uv_index_bytes*3);S=l.ntri_smooth_uv*(h+l.normal_index_bytes*3+l.uv_index_bytes*3);fa=l.nquad_flat*ea;h=
|
||||
l.nquad_smooth*(ea+l.normal_index_bytes*4);ea=l.nquad_flat_uv*(ea+l.uv_index_bytes*4);I+=function(q){var G,E,W,$=l.vertex_coordinate_bytes*3,da=q+l.nvertices*$;for(q=q;q<da;q+=$){G=j(a,q);E=j(a,q+l.vertex_coordinate_bytes);W=j(a,q+l.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(p,G,E,W)}return l.nvertices*$}(I);I+=function(q){var G,E,W,$=l.normal_coordinate_bytes*3,da=q+l.nnormals*$;for(q=q;q<da;q+=$){G=k(a,q);E=k(a,q+l.normal_coordinate_bytes);W=k(a,q+l.normal_coordinate_bytes*2);g.push(G/
|
||||
127,E/127,W/127)}return l.nnormals*$}(I);I+=function(q){var G,E,W=l.uv_coordinate_bytes*2,$=q+l.nuvs*W;for(q=q;q<$;q+=W){G=j(a,q);E=j(a,q+l.uv_coordinate_bytes);m.push(G,E)}return l.nuvs*W}(I);I=I;V=I+V;D=V+D;P=D+P;S=P+S;fa=S+fa;h=fa+h;ea=h+ea;(function(q){var G,E=l.vertex_index_bytes*3+l.material_index_bytes,W=E+l.uv_index_bytes*3,$=q+l.ntri_flat_uv*W;for(G=q;G<$;G+=W){z(G);y(G+E)}return $-q})(D);(function(q){var G,E=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*3,W=E+l.uv_index_bytes*
|
||||
3,$=q+l.ntri_smooth_uv*W;for(G=q;G<$;G+=W){n(G);y(G+E)}return $-q})(P);(function(q){var G,E=l.vertex_index_bytes*4+l.material_index_bytes,W=E+l.uv_index_bytes*4,$=q+l.nquad_flat_uv*W;for(G=q;G<$;G+=W){u(G);H(G+E)}return $-q})(h);(function(q){var G,E=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*4,W=E+l.uv_index_bytes*4,$=q+l.nquad_smooth_uv*W;for(G=q;G<$;G+=W){x(G);H(G+E)}return $-q})(ea);(function(q){var G,E=l.vertex_index_bytes*3+l.material_index_bytes,W=q+l.ntri_flat*E;for(G=
|
||||
q;G<W;G+=E)z(G);return W-q})(I);(function(q){var G,E=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*3,W=q+l.ntri_smooth*E;for(G=q;G<W;G+=E)n(G);return W-q})(V);(function(q){var G,E=l.vertex_index_bytes*4+l.material_index_bytes,W=q+l.nquad_flat*E;for(G=q;G<W;G+=E)u(G);return W-q})(S);(function(q){var G,E=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*4,W=q+l.nquad_smooth*E;for(G=q;G<W;G+=E)x(G);return W-q})(fa);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,i,k,r;j=0;for(c=a.vertices.length;j<c;j+=3){i=a.vertices[j];k=a.vertices[j+1];r=a.vertices[j+2];THREE.Loader.prototype.v(h,i,k,r)}})();(function(){function j(x,y){THREE.Loader.prototype.f3(h,x[y],x[y+1],x[y+2],x[y+3])}function c(x,y){THREE.Loader.prototype.f3n(h,
|
||||
a.normals,x[y],x[y+1],x[y+2],x[y+3],x[y+4],x[y+5],x[y+6])}function i(x,y){THREE.Loader.prototype.f4(h,x[y],x[y+1],x[y+2],x[y+3],x[y+4])}function k(x,y){THREE.Loader.prototype.f4n(h,a.normals,x[y],x[y+1],x[y+2],x[y+3],x[y+4],x[y+5],x[y+6],x[y+7],x[y+8])}function r(x,y){var H,p,I;H=x[y];p=x[y+1];I=x[y+2];THREE.Loader.prototype.uv3(h,a.uvs[H*2],a.uvs[H*2+1],a.uvs[p*2],a.uvs[p*2+1],a.uvs[I*2],a.uvs[I*2+1])}function z(x,y){var H,p,I,l;H=x[y];p=x[y+1];I=x[y+2];l=x[y+3];THREE.Loader.prototype.uv4(h,a.uvs[H*
|
||||
2],a.uvs[H*2+1],a.uvs[p*2],a.uvs[p*2+1],a.uvs[I*2],a.uvs[I*2+1],a.uvs[l*2],a.uvs[l*2+1])}var n,u;n=0;for(u=a.triangles_uv.length;n<u;n+=7){j(a.triangles_uv,n);r(a.triangles_uv,n+4)}n=0;for(u=a.triangles_n_uv.length;n<u;n+=10){c(a.triangles_n_uv,n);r(a.triangles_n_uv,n+7)}n=0;for(u=a.quads_uv.length;n<u;n+=9){i(a.quads_uv,n);z(a.quads_uv,n+5)}n=0;for(u=a.quads_n_uv.length;n<u;n+=13){k(a.quads_n_uv,n);z(a.quads_n_uv,n+9)}n=0;for(u=a.triangles.length;n<u;n+=4)j(a.triangles,n);n=0;for(u=a.triangles_n.length;n<
|
||||
u;n+=7)c(a.triangles_n,n);n=0;for(u=a.quads.length;n<u;n+=5)i(a.quads,n);n=0;for(u=a.quads_n.length;n<u;n+=9)k(a.quads_n,n)})();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,i){h=a.materials[h];var k=b[c*3],r=b[c*3+1];c=b[c*3+2];var z=b[i*3],n=b[i*3+1];i=b[i*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(k,r,c),new THREE.Vector3(z,n,i)],h))},f4n:function(a,b,d,e,f,h,j,c,i,k,r){j=a.materials[j];var z=b[i*3],n=b[i*3+1];i=b[i*3+2];var u=b[k*3],x=b[k*3+1];k=b[k*3+2];var y=b[r*3],H=b[r*3+1];r=b[r*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(z,n,i),new THREE.Vector3(u,x,k),new THREE.Vector3(y,H,r)],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,i){var k=[];k.push(new THREE.UV(b,d));k.push(new THREE.UV(e,f));k.push(new THREE.UV(h,j));k.push(new THREE.UV(c,i));a.uvs.push(k)},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=
|
||||
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 g=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(k){THREE.Loader.prototype.loadAjaxBuffers(k.data.buffers,k.data.materials,d,f,e,g)};b.onerror=function(k){alert("worker.onerror: "+k.message+"\n"+k.data);k.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,d,e,f,g){var k=new XMLHttpRequest,c=e+"/"+a,j=0;
|
||||
k.onreadystatechange=function(){if(k.readyState==4)k.status==200||k.status==0?THREE.Loader.prototype.createBinModel(k.responseText,d,f,b):alert("Couldn't load ["+c+"] ["+k.status+"]");else if(k.readyState==3){if(g){if(j==0)j=k.getResponseHeader("Content-Length");g({total:j,loaded:k.responseText.length})}}else if(k.readyState==2)j=k.getResponseHeader("Content-Length")};k.open("GET",c,true);k.overrideMimeType("text/plain; charset=x-user-defined");k.setRequestHeader("Content-Type","text/plain");k.send(null)},
|
||||
createBinModel:function(a,b,d,e){var f=function(g){function k(x,L){var J=t(x,L),Z=t(x,L+1),ca=t(x,L+2),ga=t(x,L+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(x,L){var J=t(x,L),Z=t(x,L+1),ca=t(x,L+2);return(t(x,L+3)<<24)+(ca<<16)+(Z<<8)+J}function j(x,L){var J=t(x,L);return(t(x,L+1)<<8)+J}function l(x,L){var J=t(x,L);return J>127?J-256:J}function t(x,L){return x.charCodeAt(L)&255}function D(x){var L,
|
||||
J,Z;L=c(a,x);J=c(a,x+B);Z=c(a,x+q);x=j(a,x+z);THREE.Loader.prototype.f3(v,L,J,Z,x)}function o(x){var L,J,Z,ca,ga,ja;L=c(a,x);J=c(a,x+B);Z=c(a,x+q);ca=j(a,x+z);ga=c(a,x+M);ja=c(a,x+p);x=c(a,x+A);THREE.Loader.prototype.f3n(v,h,L,J,Z,ca,ga,ja,x)}function u(x){var L,J,Z,ca;L=c(a,x);J=c(a,x+F);Z=c(a,x+E);ca=c(a,x+y);x=j(a,x+O);THREE.Loader.prototype.f4(v,L,J,Z,ca,x)}function w(x){var L,J,Z,ca,ga,ja,qa,sa;L=c(a,x);J=c(a,x+F);Z=c(a,x+E);ca=c(a,x+y);ga=j(a,x+O);ja=c(a,x+K);qa=c(a,x+U);sa=c(a,x+W);x=c(a,x+
|
||||
P);THREE.Loader.prototype.f4n(v,h,L,J,Z,ca,ga,ja,qa,sa,x)}function C(x){var L,J;L=c(a,x);J=c(a,x+da);x=c(a,x+X);THREE.Loader.prototype.uv3(v,n[L*2],n[L*2+1],n[J*2],n[J*2+1],n[x*2],n[x*2+1])}function H(x){var L,J,Z;L=c(a,x);J=c(a,x+R);Z=c(a,x+T);x=c(a,x+ba);THREE.Loader.prototype.uv4(v,n[L*2],n[L*2+1],n[J*2],n[J*2+1],n[Z*2],n[Z*2+1],n[x*2],n[x*2+1])}var v=this,I=0,m,h=[],n=[],B,q,z,M,p,A,F,E,y,O,K,U,W,P,da,X,R,T,ba,Y,G,S,V,ia,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,e,g);
|
||||
m={signature:a.substr(I,8),header_bytes:t(a,I+8),vertex_coordinate_bytes:t(a,I+9),normal_coordinate_bytes:t(a,I+10),uv_coordinate_bytes:t(a,I+11),vertex_index_bytes:t(a,I+12),normal_index_bytes:t(a,I+13),uv_index_bytes:t(a,I+14),material_index_bytes:t(a,I+15),nvertices:c(a,I+16),nnormals:c(a,I+16+4),nuvs:c(a,I+16+8),ntri_flat:c(a,I+16+12),ntri_smooth:c(a,I+16+16),ntri_flat_uv:c(a,I+16+20),ntri_smooth_uv:c(a,I+16+24),nquad_flat:c(a,I+16+28),nquad_smooth:c(a,I+16+32),nquad_flat_uv:c(a,I+16+36),nquad_smooth_uv:c(a,
|
||||
I+16+40)};I+=m.header_bytes;B=m.vertex_index_bytes;q=m.vertex_index_bytes*2;z=m.vertex_index_bytes*3;M=m.vertex_index_bytes*3+m.material_index_bytes;p=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes;A=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*2;F=m.vertex_index_bytes;E=m.vertex_index_bytes*2;y=m.vertex_index_bytes*3;O=m.vertex_index_bytes*4;K=m.vertex_index_bytes*4+m.material_index_bytes;U=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes;
|
||||
W=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;T=m.uv_index_bytes*2;ba=m.uv_index_bytes*3;g=m.vertex_index_bytes*3+m.material_index_bytes;ha=m.vertex_index_bytes*4+m.material_index_bytes;Y=m.ntri_flat*g;G=m.ntri_smooth*(g+m.normal_index_bytes*3);S=m.ntri_flat_uv*(g+m.uv_index_bytes*3);V=m.ntri_smooth_uv*(g+m.normal_index_bytes*3+m.uv_index_bytes*
|
||||
3);ia=m.nquad_flat*ha;g=m.nquad_smooth*(ha+m.normal_index_bytes*4);ha=m.nquad_flat_uv*(ha+m.uv_index_bytes*4);I+=function(x){var L,J,Z,ca=m.vertex_coordinate_bytes*3,ga=x+m.nvertices*ca;for(x=x;x<ga;x+=ca){L=k(a,x);J=k(a,x+m.vertex_coordinate_bytes);Z=k(a,x+m.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(v,L,J,Z)}return m.nvertices*ca}(I);I+=function(x){var L,J,Z,ca=m.normal_coordinate_bytes*3,ga=x+m.nnormals*ca;for(x=x;x<ga;x+=ca){L=l(a,x);J=l(a,x+m.normal_coordinate_bytes);Z=l(a,x+m.normal_coordinate_bytes*
|
||||
2);h.push(L/127,J/127,Z/127)}return m.nnormals*ca}(I);I+=function(x){var L,J,Z=m.uv_coordinate_bytes*2,ca=x+m.nuvs*Z;for(x=x;x<ca;x+=Z){L=k(a,x);J=k(a,x+m.uv_coordinate_bytes);n.push(L,J)}return m.nuvs*Z}(I);I=I;Y=I+Y;G=Y+G;S=G+S;V=S+V;ia=V+ia;g=ia+g;ha=g+ha;(function(x){var L,J=m.vertex_index_bytes*3+m.material_index_bytes,Z=J+m.uv_index_bytes*3,ca=x+m.ntri_flat_uv*Z;for(L=x;L<ca;L+=Z){D(L);C(L+J)}return ca-x})(G);(function(x){var L,J=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*
|
||||
3,Z=J+m.uv_index_bytes*3,ca=x+m.ntri_smooth_uv*Z;for(L=x;L<ca;L+=Z){o(L);C(L+J)}return ca-x})(S);(function(x){var L,J=m.vertex_index_bytes*4+m.material_index_bytes,Z=J+m.uv_index_bytes*4,ca=x+m.nquad_flat_uv*Z;for(L=x;L<ca;L+=Z){u(L);H(L+J)}return ca-x})(g);(function(x){var L,J=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,Z=J+m.uv_index_bytes*4,ca=x+m.nquad_smooth_uv*Z;for(L=x;L<ca;L+=Z){w(L);H(L+J)}return ca-x})(ha);(function(x){var L,J=m.vertex_index_bytes*3+m.material_index_bytes,
|
||||
Z=x+m.ntri_flat*J;for(L=x;L<Z;L+=J)D(L);return Z-x})(I);(function(x){var L,J=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*3,Z=x+m.ntri_smooth*J;for(L=x;L<Z;L+=J)o(L);return Z-x})(Y);(function(x){var L,J=m.vertex_index_bytes*4+m.material_index_bytes,Z=x+m.nquad_flat*J;for(L=x;L<Z;L+=J)u(L);return Z-x})(V);(function(x){var L,J=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,Z=x+m.nquad_smooth*J;for(L=x;L<Z;L+=J)w(L);return Z-x})(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 g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,a.materials,f);(function(){var k,c,j,l,t;k=0;for(c=a.vertices.length;k<c;k+=3){j=a.vertices[k];l=a.vertices[k+1];t=a.vertices[k+2];THREE.Loader.prototype.v(g,j,l,t)}})();(function(){function k(w,C){THREE.Loader.prototype.f3(g,w[C],w[C+1],w[C+2],w[C+3])}function c(w,
|
||||
C){THREE.Loader.prototype.f3n(g,a.normals,w[C],w[C+1],w[C+2],w[C+3],w[C+4],w[C+5],w[C+6])}function j(w,C){THREE.Loader.prototype.f4(g,w[C],w[C+1],w[C+2],w[C+3],w[C+4])}function l(w,C){THREE.Loader.prototype.f4n(g,a.normals,w[C],w[C+1],w[C+2],w[C+3],w[C+4],w[C+5],w[C+6],w[C+7],w[C+8])}function t(w,C){var H,v,I;H=w[C];v=w[C+1];I=w[C+2];THREE.Loader.prototype.uv3(g,a.uvs[H*2],a.uvs[H*2+1],a.uvs[v*2],a.uvs[v*2+1],a.uvs[I*2],a.uvs[I*2+1])}function D(w,C){var H,v,I,m;H=w[C];v=w[C+1];I=w[C+2];m=w[C+3];THREE.Loader.prototype.uv4(g,
|
||||
a.uvs[H*2],a.uvs[H*2+1],a.uvs[v*2],a.uvs[v*2+1],a.uvs[I*2],a.uvs[I*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){k(a.triangles_uv,o);t(a.triangles_uv,o+4)}o=0;for(u=a.triangles_n_uv.length;o<u;o+=10){c(a.triangles_n_uv,o);t(a.triangles_n_uv,o+7)}o=0;for(u=a.quads_uv.length;o<u;o+=9){j(a.quads_uv,o);D(a.quads_uv,o+5)}o=0;for(u=a.quads_n_uv.length;o<u;o+=13){l(a.quads_n_uv,o);D(a.quads_n_uv,o+9)}o=0;for(u=a.triangles.length;o<u;o+=4)k(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)j(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,f){a.faces.push(new THREE.Face3(b,d,e,null,a.materials[f]))},f4:function(a,b,d,e,f,g){a.faces.push(new THREE.Face4(b,d,e,f,null,
|
||||
a.materials[g]))},f3n:function(a,b,d,e,f,g,k,c,j){g=a.materials[g];var l=b[c*3],t=b[c*3+1];c=b[c*3+2];var D=b[j*3],o=b[j*3+1];j=b[j*3+2];a.faces.push(new THREE.Face3(d,e,f,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(l,t,c),new THREE.Vector3(D,o,j)],g))},f4n:function(a,b,d,e,f,g,k,c,j,l,t){k=a.materials[k];var D=b[j*3],o=b[j*3+1];j=b[j*3+2];var u=b[l*3],w=b[l*3+1];l=b[l*3+2];var C=b[t*3],H=b[t*3+1];t=b[t*3+2];a.faces.push(new THREE.Face4(d,e,f,g,[new THREE.Vector3(b[c*3],b[c*3+1],
|
||||
b[c*3+2]),new THREE.Vector3(D,o,j),new THREE.Vector3(u,w,l),new THREE.Vector3(C,H,t)],k))},uv3:function(a,b,d,e,f,g,k){var c=[];c.push(new THREE.UV(b,d));c.push(new THREE.UV(e,f));c.push(new THREE.UV(g,k));a.uvs.push(c)},uv4:function(a,b,d,e,f,g,k,c,j){var l=[];l.push(new THREE.UV(b,d));l.push(new THREE.UV(e,f));l.push(new THREE.UV(g,k));l.push(new THREE.UV(c,j));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(g){g=Math.log(g)/Math.LN2;return Math.floor(g)==g}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 g=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),k=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));e.map.image.width=g;e.map.image.height=k;e.map.image.getContext("2d").drawImage(this,0,0,g,k)}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("/")}};
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>three.js - scene loader test</title>
|
||||
<meta charset="utf-8">
|
||||
<style type="text/css">
|
||||
body {
|
||||
background:#fff;
|
||||
padding:0;
|
||||
margin:0;
|
||||
overflow:hidden;
|
||||
font-family:georgia;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
#info {
|
||||
position: absolute;
|
||||
top: 0px; width: 100%;
|
||||
color: #000;
|
||||
padding: 5px;
|
||||
font-family: Monospace;
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
a { color:skyblue }
|
||||
canvas { pointer-events:none; z-index:10; }
|
||||
#log { position:absolute; top:0; display:block; text-align:left; z-index:1000; pointer-events:none; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="info">
|
||||
<a href="http://github.com/mrdoob/three.js">three.js</a> - scene loader test
|
||||
</div>
|
||||
|
||||
<pre id="log"></pre>
|
||||
|
||||
<script type="text/javascript" src="../build/ThreeExtras.js"></script>
|
||||
<script type="text/javascript" src="js/Stats.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var SCREEN_WIDTH = window.innerWidth;
|
||||
var SCREEN_HEIGHT = window.innerHeight;
|
||||
|
||||
var container,stats;
|
||||
|
||||
var camera, scene;
|
||||
var renderer;
|
||||
|
||||
var mesh, zmesh, geometry;
|
||||
|
||||
var mouseX = 0, mouseY = 0;
|
||||
|
||||
var windowHalfX = window.innerWidth / 2;
|
||||
var windowHalfY = window.innerHeight / 2;
|
||||
|
||||
document.addEventListener('mousemove', onDocumentMouseMove, false);
|
||||
|
||||
init();
|
||||
|
||||
|
||||
function init() {
|
||||
|
||||
container = document.createElement('div');
|
||||
document.body.appendChild(container);
|
||||
|
||||
var callback = function( result ) {
|
||||
|
||||
scene = result.scene;
|
||||
camera = result.currentCamera;
|
||||
|
||||
camera.aspect = window.innerWidth / window.innerHeight;
|
||||
camera.updateProjectionMatrix();
|
||||
|
||||
setInterval(loop, 1000/60);
|
||||
|
||||
}
|
||||
|
||||
SceneUtils.loadScene( "scenes/test_scene.js", callback );
|
||||
|
||||
renderer = new THREE.WebGLRenderer();
|
||||
renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
|
||||
renderer.domElement.style.position = "relative";
|
||||
container.appendChild( renderer.domElement );
|
||||
|
||||
stats = new Stats();
|
||||
stats.domElement.style.position = 'absolute';
|
||||
stats.domElement.style.top = '0px';
|
||||
stats.domElement.style.zIndex = 100;
|
||||
container.appendChild( stats.domElement );
|
||||
|
||||
}
|
||||
|
||||
function onDocumentMouseMove(event) {
|
||||
|
||||
mouseX = ( event.clientX - windowHalfX );
|
||||
mouseY = ( event.clientY - windowHalfY );
|
||||
|
||||
}
|
||||
|
||||
function loop() {
|
||||
|
||||
camera.position.x += ( mouseX - camera.position.x ) * .001;
|
||||
camera.position.y += ( - mouseY - camera.position.y ) * .001;
|
||||
|
||||
renderer.render( scene, camera );
|
||||
|
||||
stats.update();
|
||||
|
||||
}
|
||||
|
||||
function log( text ) {
|
||||
|
||||
var e = document.getElementById("log");
|
||||
e.innerHTML = text + "<br/>" + e.innerHTML;
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,287 @@
|
||||
var scene = {
|
||||
|
||||
"objects":
|
||||
{
|
||||
"cube1" : {
|
||||
"geometry" : "cube",
|
||||
"materials": [ "lambert_red" ],
|
||||
"position" : [ 0, 0, 0 ],
|
||||
"rotation" : [ 0, -0.3, 0 ],
|
||||
"scale" : [ 1, 1, 1 ],
|
||||
"visible" : true
|
||||
},
|
||||
|
||||
"cube2" : {
|
||||
"geometry" : "cube",
|
||||
"materials": [ "basic_black" ],
|
||||
"position" : [ 0, 0, 0 ],
|
||||
"rotation" : [ 0, -0.3, 0 ],
|
||||
"scale" : [ 2, 2, 2 ],
|
||||
"visible" : true
|
||||
},
|
||||
|
||||
"sphere" : {
|
||||
"geometry" : "sphere",
|
||||
"materials": [ "lambert_green" ],
|
||||
"position" : [ -20, -5, 15 ],
|
||||
"rotation" : [ 0, 0, 0 ],
|
||||
"scale" : [ 1, 1, 1 ],
|
||||
"visible" : true
|
||||
},
|
||||
|
||||
"torus" : {
|
||||
"geometry" : "torus",
|
||||
"materials": [ "phong_orange" ],
|
||||
"position" : [ 0, 5, -50 ],
|
||||
"rotation" : [ 0, 0, 0 ],
|
||||
"scale" : [ 2, 2, 2 ],
|
||||
"visible" : true
|
||||
},
|
||||
|
||||
"cone" : {
|
||||
"geometry" : "cone",
|
||||
"materials": [ "lambert_blue" ],
|
||||
"position" : [ -50, 40, -50 ],
|
||||
"rotation" : [ 1.57, 0, 0 ],
|
||||
"scale" : [ 1, 1, 1 ],
|
||||
"visible" : true
|
||||
},
|
||||
|
||||
"cylinder" : {
|
||||
"geometry" : "cylinder",
|
||||
"materials": [ "lambert_blue" ],
|
||||
"position" : [ 50, 40, -50 ],
|
||||
"rotation" : [ 1.57, 0, 0 ],
|
||||
"scale" : [ 1, 1, 1 ],
|
||||
"visible" : true
|
||||
},
|
||||
|
||||
"veyron" : {
|
||||
"geometry" : "veyron",
|
||||
"materials": [ "face" ],
|
||||
"position" : [ 40, -1, 0 ],
|
||||
"rotation" : [ 0, 0.3, 0 ],
|
||||
"scale" : [ 0.25, 0.25, 0.25 ],
|
||||
"visible" : true
|
||||
},
|
||||
|
||||
"walt" : {
|
||||
"geometry" : "WaltHead",
|
||||
"materials": [ "phong_white" ],
|
||||
"position" : [ -45, 10, 0 ],
|
||||
"rotation" : [ 0, 0, 0 ],
|
||||
"scale" : [ 0.5, 0.5, 0.5 ],
|
||||
"visible" : true
|
||||
},
|
||||
|
||||
"ground" : {
|
||||
"geometry" : "plane",
|
||||
"materials": [ "basic_gray" ],
|
||||
"position" : [ 0, -10, 0 ],
|
||||
"rotation" : [ 1.57, 0, 0 ],
|
||||
"scale" : [ 100, 100, 100 ],
|
||||
"visible" : true
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
"geometries":
|
||||
{
|
||||
"cube": {
|
||||
"type" : "cube",
|
||||
"width" : 10,
|
||||
"height": 10,
|
||||
"depth" : 10,
|
||||
"segments_width" : 1,
|
||||
"segments_height" : 1,
|
||||
"flipped" : false,
|
||||
"sides" : { "px": true, "nx": true, "py": true, "ny": true, "pz": true, "nz": true }
|
||||
},
|
||||
|
||||
"plane": {
|
||||
"type" : "plane",
|
||||
"width" : 10,
|
||||
"height" : 10,
|
||||
"segments_width" : 50,
|
||||
"segments_height" : 50
|
||||
},
|
||||
|
||||
"sphere": {
|
||||
"type" : "sphere",
|
||||
"radius" : 5,
|
||||
"segments_width" : 32,
|
||||
"segments_height" : 16
|
||||
},
|
||||
|
||||
"torus": {
|
||||
"type" : "torus",
|
||||
"radius" : 5,
|
||||
"tube" : 2,
|
||||
"segmentsR" : 16,
|
||||
"segmentsT" : 32
|
||||
},
|
||||
|
||||
"cylinder": {
|
||||
"type" : "cylinder",
|
||||
"numSegs" : 32,
|
||||
"topRad" : 5,
|
||||
"botRad" : 5,
|
||||
"height" : 50,
|
||||
"topOffset": 0,
|
||||
"botOffset": 0
|
||||
},
|
||||
|
||||
"cone": {
|
||||
"type" : "cylinder",
|
||||
"numSegs" : 32,
|
||||
"topRad" : 0,
|
||||
"botRad" : 5,
|
||||
"height" : 50,
|
||||
"topOffset": 0,
|
||||
"botOffset": 0
|
||||
},
|
||||
|
||||
"WaltHead": {
|
||||
"type": "bin_mesh",
|
||||
"url" : "obj/walt/WaltHead_bin.js"
|
||||
},
|
||||
|
||||
"veyron": {
|
||||
"type": "bin_mesh",
|
||||
"url" : "obj/veyron/VeyronNoUv_bin.js"
|
||||
},
|
||||
|
||||
"TextureCube": {
|
||||
"type": "ascii_mesh",
|
||||
"url" : "obj/textureTest/textureTest_baked.js"
|
||||
},
|
||||
|
||||
|
||||
},
|
||||
|
||||
"materials":
|
||||
{
|
||||
"basic_red": {
|
||||
"type": "MeshBasicMaterial",
|
||||
"parameters": { color: 0xff0000, wireframe: true }
|
||||
},
|
||||
|
||||
"basic_green": {
|
||||
"type": "MeshBasicMaterial",
|
||||
"parameters": { color: 0x007711, wireframe: true }
|
||||
},
|
||||
|
||||
"basic_gray": {
|
||||
"type": "MeshBasicMaterial",
|
||||
"parameters": { color: 0x666666, wireframe: true }
|
||||
},
|
||||
|
||||
"basic_black": {
|
||||
"type": "MeshBasicMaterial",
|
||||
"parameters": { color: 0x000000, wireframe: true }
|
||||
},
|
||||
|
||||
"basic_blue": {
|
||||
"type": "MeshBasicMaterial",
|
||||
"parameters": { color: 0x0000ff, wireframe: true }
|
||||
},
|
||||
|
||||
"lambert_red": {
|
||||
"type": "MeshLambertMaterial",
|
||||
"parameters": { color: 0xff0000 }
|
||||
},
|
||||
|
||||
"lambert_green": {
|
||||
"type": "MeshLambertMaterial",
|
||||
"parameters": { color: 0x007711 }
|
||||
},
|
||||
|
||||
"lambert_blue": {
|
||||
"type": "MeshLambertMaterial",
|
||||
"parameters": { color: 0x0055aa }
|
||||
},
|
||||
|
||||
"phong_white": {
|
||||
"type": "MeshPhongMaterial",
|
||||
"parameters": { color: 0xaaaaaa }
|
||||
},
|
||||
|
||||
"phong_orange": {
|
||||
"type": "MeshPhongMaterial",
|
||||
"parameters": { color:0x000000, specular: 0xaa5500 }
|
||||
},
|
||||
|
||||
"face": {
|
||||
"type": "MeshFaceMaterial",
|
||||
"parameters": {}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
"cameras":
|
||||
{
|
||||
"cam1": {
|
||||
"type" : "perspective",
|
||||
"fov" : 50,
|
||||
"aspect": 1.33333,
|
||||
"near" : 1,
|
||||
"far" : 1000,
|
||||
"position": [0,0,100],
|
||||
"target" : [0,0,0]
|
||||
},
|
||||
|
||||
"cam2": {
|
||||
"type" : "ortho",
|
||||
"left" : 0,
|
||||
"right" : 1024,
|
||||
"top" : 0,
|
||||
"bottom": 1024,
|
||||
"near" : 1,
|
||||
"far" : 1000,
|
||||
"position": [0,0,0],
|
||||
"target" : [0,0,0]
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
"lights":
|
||||
{
|
||||
"light1": {
|
||||
"type" : "directional",
|
||||
"direction" : [0,1,1],
|
||||
"color" : [1,1,1]
|
||||
},
|
||||
|
||||
"light2": {
|
||||
"type" : "point",
|
||||
"position": [0,0,0],
|
||||
"color" : [1,1,1]
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
"fogs":
|
||||
{
|
||||
"basic": {
|
||||
"type" : "linear",
|
||||
"color": [1,0,0],
|
||||
"near" : 1,
|
||||
"far" : 1000
|
||||
},
|
||||
|
||||
"exponential": {
|
||||
"type" : "exp2",
|
||||
"color" : [1,1,1],
|
||||
"density" : 0.005,
|
||||
}
|
||||
},
|
||||
|
||||
"defaults" :
|
||||
{
|
||||
"camera": "cam1",
|
||||
"fog" : "exponential"
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
postMessage( scene );
|
||||
@@ -1,4 +1,243 @@
|
||||
var SceneUtils = {
|
||||
|
||||
loadScene : function( url, callback ) {
|
||||
|
||||
var dg, dm, dd, dl, dc, df, f,
|
||||
g, o, m, l, p, c, t,
|
||||
geometry, material, camera, fog, materials,
|
||||
loader, callback_model,
|
||||
worker = new Worker( url );
|
||||
|
||||
worker.onmessage = function( event ) {
|
||||
|
||||
function handle_objects() {
|
||||
|
||||
for( dd in data.objects ) {
|
||||
|
||||
if ( !result.objects[ dd ] ) {
|
||||
|
||||
o = data.objects[ dd ];
|
||||
|
||||
geometry = result.geometries[ o.geometry ];
|
||||
|
||||
if ( geometry ) {
|
||||
|
||||
materials = [];
|
||||
for( i = 0; i < o.materials.length; i++ ) {
|
||||
|
||||
materials[ i ] = result.materials[ o.materials[i] ];
|
||||
|
||||
}
|
||||
|
||||
p = o.position;
|
||||
r = o.rotation;
|
||||
s = o.scale;
|
||||
|
||||
object = new THREE.Mesh( geometry, materials );
|
||||
object.position.set( p[0], p[1], p[2] );
|
||||
object.rotation.set( r[0], r[1], r[2] );
|
||||
object.scale.set( s[0], s[1], s[2] );
|
||||
object.visible = o.visible;
|
||||
|
||||
result.scene.addObject( object );
|
||||
|
||||
result.objects[ dd ] = object;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function handle_mesh( geo, id ) {
|
||||
|
||||
result.geometries[ id ] = geo;
|
||||
handle_objects();
|
||||
|
||||
};
|
||||
|
||||
function create_callback( id ) {
|
||||
|
||||
return function( geo ) { handle_mesh( geo, id ); }
|
||||
|
||||
}
|
||||
|
||||
var data = event.data;
|
||||
|
||||
var result = {
|
||||
|
||||
scene: new THREE.Scene(),
|
||||
geometries: {},
|
||||
materials: {},
|
||||
objects: {},
|
||||
cameras: {},
|
||||
lights: {},
|
||||
fogs: {}
|
||||
|
||||
};
|
||||
|
||||
loader = new THREE.Loader();
|
||||
|
||||
// geometries
|
||||
|
||||
for( dg in data.geometries ) {
|
||||
|
||||
g = data.geometries[ dg ];
|
||||
|
||||
if ( g.type == "cube" ) {
|
||||
|
||||
geometry = new Cube( g.width, g.height, g.depth, g.segments_width, g.segments_height, null, g.flipped, g.sides );
|
||||
result.geometries[ dg ] = geometry;
|
||||
|
||||
} else if ( g.type == "plane" ) {
|
||||
|
||||
geometry = new Plane( g.width, g.height, g.segments_width, g.segments_height );
|
||||
result.geometries[ dg ] = geometry;
|
||||
|
||||
} else if ( g.type == "sphere" ) {
|
||||
|
||||
geometry = new Sphere( g.radius, g.segments_width, g.segments_height );
|
||||
result.geometries[ dg ] = geometry;
|
||||
|
||||
} else if ( g.type == "cylinder" ) {
|
||||
|
||||
geometry = new Cylinder( g.numSegs, g.topRad, g.botRad, g.height, g.topOffset, g.botOffset );
|
||||
result.geometries[ dg ] = geometry;
|
||||
|
||||
} else if ( g.type == "torus" ) {
|
||||
|
||||
geometry = new Torus( g.radius, g.tube, g.segmentsR, g.segmentsT );
|
||||
result.geometries[ dg ] = geometry;
|
||||
|
||||
} else if ( g.type == "bin_mesh" ) {
|
||||
|
||||
loader.loadBinary( { model: g.url,
|
||||
callback: create_callback( dg )
|
||||
} );
|
||||
|
||||
} else if ( g.type == "ascii_mesh" ) {
|
||||
|
||||
loader.loadAscii( { model: g.url,
|
||||
callback: create_callback( dg )
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// materials
|
||||
|
||||
for( dm in data.materials ) {
|
||||
|
||||
m = data.materials[ dm ];
|
||||
|
||||
material = new THREE[ m.type ]( m.parameters );
|
||||
result.materials[ dm ] = material;
|
||||
|
||||
}
|
||||
|
||||
// objects
|
||||
|
||||
handle_objects();
|
||||
|
||||
|
||||
// lights
|
||||
|
||||
for( dl in data.lights ) {
|
||||
|
||||
l = data.lights[ dl ];
|
||||
|
||||
if ( l.type == "directional" ) {
|
||||
|
||||
p = l.direction;
|
||||
|
||||
light = new THREE.DirectionalLight();
|
||||
light.position.set( p[0], p[1], p[2] );
|
||||
light.position.normalize();
|
||||
|
||||
} else if ( l.type == "point" ) {
|
||||
|
||||
p = l.position;
|
||||
|
||||
light = new THREE.PointLight();
|
||||
light.position.set( p[0], p[1], p[2] );
|
||||
|
||||
}
|
||||
|
||||
c = l.color;
|
||||
light.color.setRGB( c[0], c[1], c[2] );
|
||||
|
||||
result.scene.addLight( light );
|
||||
|
||||
result.lights[ dl ] = light;
|
||||
|
||||
}
|
||||
|
||||
// cameras
|
||||
|
||||
for( dc in data.cameras ) {
|
||||
|
||||
c = data.cameras[ dc ];
|
||||
|
||||
if ( c.type == "perspective" ) {
|
||||
|
||||
camera = new THREE.Camera( c.fov, c.aspect, c.near, c.far );
|
||||
|
||||
} else if ( c.type == "ortho" ) {
|
||||
|
||||
camera = new THREE.Camera();
|
||||
camera.projectionMatrix = THREE.Matrix4.makeOrtho( c.left, c.right, c.top, c.bottom, c.near, c.far );
|
||||
|
||||
}
|
||||
|
||||
p = c.position;
|
||||
t = c.target;
|
||||
camera.position.set( p[0], p[1], p[2] );
|
||||
camera.target.position.set( t[0], t[1], t[2] );
|
||||
|
||||
result.cameras[ dc ] = camera;
|
||||
|
||||
}
|
||||
|
||||
// fogs
|
||||
|
||||
for( df in data.fogs ) {
|
||||
|
||||
f = data.fogs[ df ];
|
||||
|
||||
if ( f.type == "linear" ) {
|
||||
|
||||
fog = new THREE.Fog( 0x000000, f.near, f.far );
|
||||
|
||||
} else if ( f.type == "exp2" ) {
|
||||
|
||||
fog = new THREE.FogExp2( 0x000000, f.density );
|
||||
|
||||
}
|
||||
|
||||
c = f.color;
|
||||
fog.color.setRGB( c[0], c[1], c[2] );
|
||||
|
||||
result.fogs[ df ] = fog;
|
||||
|
||||
}
|
||||
|
||||
result.currentCamera = result.cameras[ data.defaults.camera ];
|
||||
|
||||
if ( result.fogs && data.defaults.fog ) {
|
||||
|
||||
result.scene.fog = result.fogs[ data.defaults.fog ];
|
||||
|
||||
}
|
||||
|
||||
callback( result );
|
||||
|
||||
};
|
||||
|
||||
worker.postMessage( 0 );
|
||||
|
||||
},
|
||||
|
||||
addMesh: function ( scene, geometry, scale, x, y, z, rx, ry, rz, material ) {
|
||||
|
||||
|
||||
+3
-1
@@ -80,7 +80,9 @@ EXTRAS_FILES = [
|
||||
'extras/primitives/Cube.js',
|
||||
'extras/primitives/Cylinder.js',
|
||||
'extras/primitives/Plane.js',
|
||||
'extras/primitives/Sphere.js','extras/primitives/LathedObject.js',
|
||||
'extras/primitives/Sphere.js',
|
||||
'extras/primitives/Torus.js',
|
||||
'extras/primitives/LathedObject.js',
|
||||
'extras/io/Loader.js'
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user