|
@@ -13,50 +13,50 @@ THREE.Vector4=function(a,b,c,e){this.x=a||0;this.y=b||0;this.z=c||0;this.w=e||1}
|
|
THREE.Vector4.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;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;
|
|
THREE.Vector4.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;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+")"}};
|
|
return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
|
|
THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
|
|
THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
|
|
-THREE.Ray.prototype={intersectScene:function(a){var b,c,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){c=e[a];if(c instanceof THREE.Mesh)g=g.concat(this.intersectObject(c))}g.sort(function(f,h){return f.distance-h.distance});return g},intersectObject:function(a){function b(H,w,E,o){o=o.clone().subSelf(w);E=E.clone().subSelf(w);var d=H.clone().subSelf(w);H=o.dot(o);w=o.dot(E);o=o.dot(d);var P=E.dot(E);E=E.dot(d);d=1/(H*P-w*w);P=(P*o-w*E)*d;H=(H*E-w*o)*d;return P>0&&H>0&&P+H<1}var c,e,g,f,h,k,j,m,p,x,
|
|
|
|
-t,q=a.geometry,y=q.vertices,z=[];c=0;for(e=q.faces.length;c<e;c++){g=q.faces[c];x=this.origin.clone();t=this.direction.clone();f=a.matrix.multiplyVector3(y[g.a].position.clone());h=a.matrix.multiplyVector3(y[g.b].position.clone());k=a.matrix.multiplyVector3(y[g.c].position.clone());j=g instanceof THREE.Face4?a.matrix.multiplyVector3(y[g.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(g.normal.clone());p=t.dot(m);if(p<0){m=m.dot((new THREE.Vector3).sub(f,x))/p;x=x.addSelf(t.multiplyScalar(m));
|
|
|
|
-if(g instanceof THREE.Face3){if(b(x,f,h,k)){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};z.push(g)}}else if(g instanceof THREE.Face4)if(b(x,f,h,j)||b(x,h,k,j)){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};z.push(g)}}}return z}};
|
|
|
|
-THREE.Rectangle=function(){function a(){f=e-b;h=g-c}var b,c,e,g,f,h,k=true;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(j,m,p,x){k=false;b=j;c=m;e=p;g=x;a()};this.addPoint=function(j,m){if(k){k=false;b=j;c=m;e=j;g=m}else{b=b<j?b:j;c=c<m?c:m;e=e>j?e:j;g=g>m?
|
|
|
|
-g:m}a()};this.add3Points=function(j,m,p,x,t,q){if(k){k=false;b=j<p?j<t?j:t:p<t?p:t;c=m<x?m<q?m:q:x<q?x:q;e=j>p?j>t?j:t:p>t?p:t;g=m>x?m>q?m:q:x>q?x:q}else{b=j<p?j<t?j<b?j:b:t<b?t:b:p<t?p<b?p:b:t<b?t:b;c=m<x?m<q?m<c?m:c:q<c?q:c:x<q?x<c?x:c:q<c?q:c;e=j>p?j>t?j>e?j:e:t>e?t:e:p>t?p>e?p:e:t>e?t:e;g=m>x?m>q?m>g?m:g:q>g?q:g:x>q?x>g?x:g:q>g?q:g}a()};this.addRectangle=function(j){if(k){k=false;b=j.getLeft();c=j.getTop();e=j.getRight();g=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();c=c<j.getTop()?c:j.getTop();
|
|
|
|
|
|
+THREE.Ray.prototype={intersectScene:function(a){var b,c,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){c=e[a];if(c instanceof THREE.Mesh)g=g.concat(this.intersectObject(c))}g.sort(function(f,h){return f.distance-h.distance});return g},intersectObject:function(a){function b(E,v,F,p){p=p.clone().subSelf(v);F=F.clone().subSelf(v);var M=E.clone().subSelf(v);E=p.dot(p);v=p.dot(F);p=p.dot(M);var d=F.dot(F);F=F.dot(M);M=1/(E*d-v*v);d=(d*p-v*F)*M;E=(E*F-v*p)*M;return d>0&&E>0&&d+E<1}var c,e,g,f,h,k,j,m,q,w,
|
|
|
|
+u,t=a.geometry,x=t.vertices,A=[];c=0;for(e=t.faces.length;c<e;c++){g=t.faces[c];w=this.origin.clone();u=this.direction.clone();f=a.matrix.multiplyVector3(x[g.a].position.clone());h=a.matrix.multiplyVector3(x[g.b].position.clone());k=a.matrix.multiplyVector3(x[g.c].position.clone());j=g instanceof THREE.Face4?a.matrix.multiplyVector3(x[g.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(g.normal.clone());q=u.dot(m);if(q<0){m=m.dot((new THREE.Vector3).sub(f,w))/q;w=w.addSelf(u.multiplyScalar(m));
|
|
|
|
+if(g instanceof THREE.Face3){if(b(w,f,h,k)){g={distance:this.origin.distanceTo(w),point:w,face:g,object:a};A.push(g)}}else if(g instanceof THREE.Face4)if(b(w,f,h,j)||b(w,h,k,j)){g={distance:this.origin.distanceTo(w),point:w,face:g,object:a};A.push(g)}}}return A}};
|
|
|
|
+THREE.Rectangle=function(){function a(){f=e-b;h=g-c}var b,c,e,g,f,h,k=true;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(j,m,q,w){k=false;b=j;c=m;e=q;g=w;a()};this.addPoint=function(j,m){if(k){k=false;b=j;c=m;e=j;g=m}else{b=b<j?b:j;c=c<m?c:m;e=e>j?e:j;g=g>m?
|
|
|
|
+g:m}a()};this.add3Points=function(j,m,q,w,u,t){if(k){k=false;b=j<q?j<u?j:u:q<u?q:u;c=m<w?m<t?m:t:w<t?w:t;e=j>q?j>u?j:u:q>u?q:u;g=m>w?m>t?m:t:w>t?w:t}else{b=j<q?j<u?j<b?j:b:u<b?u:b:q<u?q<b?q:b:u<b?u:b;c=m<w?m<t?m<c?m:c:t<c?t:c:w<t?w<c?w:c:t<c?t:c;e=j>q?j>u?j>e?j:e:u>e?u:e:q>u?q>e?q:e:u>e?u:e;g=m>w?m>t?m>g?m:g:t>g?t:g:w>t?w>g?w:g:t>g?t:g}a()};this.addRectangle=function(j){if(k){k=false;b=j.getLeft();c=j.getTop();e=j.getRight();g=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();c=c<j.getTop()?c:j.getTop();
|
|
e=e>j.getRight()?e:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){b-=j;c-=j;e+=j;g+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();c=c>j.getTop()?c:j.getTop();e=e<j.getRight()?e:j.getRight();g=g<j.getBottom()?g:j.getBottom();a()};this.instersects=function(j){return Math.min(e,j.getRight())-Math.max(b,j.getLeft())>=0&&Math.min(g,j.getBottom())-Math.max(c,j.getTop())>=0};this.empty=function(){k=true;g=e=c=b=0;a()};this.isEmpty=function(){return k};this.toString=
|
|
e=e>j.getRight()?e:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){b-=j;c-=j;e+=j;g+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();c=c>j.getTop()?c:j.getTop();e=e<j.getRight()?e:j.getRight();g=g<j.getBottom()?g:j.getBottom();a()};this.instersects=function(j){return Math.min(e,j.getRight())-Math.max(b,j.getLeft())>=0&&Math.min(g,j.getBottom())-Math.max(c,j.getTop())>=0};this.empty=function(){k=true;g=e=c=b=0;a()};this.isEmpty=function(){return k};this.toString=
|
|
function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+c+", bottom: "+g+", width: "+f+", height: "+h+" )"}};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},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
|
|
function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+c+", bottom: "+g+", width: "+f+", height: "+h+" )"}};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},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
|
|
-THREE.Matrix4=function(a,b,c,e,g,f,h,k,j,m,p,x,t,q,y,z){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=e||0;this.n21=g||0;this.n22=f||1;this.n23=h||0;this.n24=k||0;this.n31=j||0;this.n32=m||0;this.n33=p||1;this.n34=x||0;this.n41=t||0;this.n42=q||0;this.n43=y||0;this.n44=z||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,c,e,g,f,h,k,j,m,p,x,t,q,y,z){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=g;this.n22=f;this.n23=h;this.n24=k;this.n31=j;this.n32=m;this.n33=p;this.n34=x;this.n41=t;this.n42=q;this.n43=y;this.n44=z;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
|
|
|
|
|
|
+THREE.Matrix4=function(a,b,c,e,g,f,h,k,j,m,q,w,u,t,x,A){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=e||0;this.n21=g||0;this.n22=f||1;this.n23=h||0;this.n24=k||0;this.n31=j||0;this.n32=m||0;this.n33=q||1;this.n34=w||0;this.n41=u||0;this.n42=t||0;this.n43=x||0;this.n44=A||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,c,e,g,f,h,k,j,m,q,w,u,t,x,A){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=g;this.n22=f;this.n23=h;this.n24=k;this.n31=j;this.n32=m;this.n33=q;this.n34=w;this.n41=u;this.n42=t;this.n43=x;this.n44=A;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,c){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();e.cross(c,f).normalize();g.cross(f,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);
|
|
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,c){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();e.cross(c,f).normalize();g.cross(f,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);
|
|
this.n31=f.x;this.n32=f.y;this.n33=f.z;this.n34=-f.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,e=a.z,g=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*c+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*c+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*c+this.n23*
|
|
this.n31=f.x;this.n32=f.y;this.n33=f.z;this.n34=-f.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,e=a.z,g=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*c+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*c+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*c+this.n23*
|
|
-e+this.n24*g;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*c+this.n43*e+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,e=a.n12,g=a.n13,f=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,p=a.n31,
|
|
|
|
-x=a.n32,t=a.n33,q=a.n34,y=a.n41,z=a.n42,H=a.n43,w=a.n44,E=b.n11,o=b.n12,d=b.n13,P=b.n14,aa=b.n21,N=b.n22,M=b.n23,U=b.n24,O=b.n31,Y=b.n32,W=b.n33,J=b.n34,X=b.n41,ha=b.n42,Z=b.n43,ea=b.n44;this.n11=c*E+e*aa+g*O+f*X;this.n12=c*o+e*N+g*Y+f*ha;this.n13=c*d+e*M+g*W+f*Z;this.n14=c*P+e*U+g*J+f*ea;this.n21=h*E+k*aa+j*O+m*X;this.n22=h*o+k*N+j*Y+m*ha;this.n23=h*d+k*M+j*W+m*Z;this.n24=h*P+k*U+j*J+m*ea;this.n31=p*E+x*aa+t*O+q*X;this.n32=p*o+x*N+t*Y+q*ha;this.n33=p*d+x*M+t*W+q*Z;this.n34=p*P+x*U+t*J+q*ea;this.n41=
|
|
|
|
-y*E+z*aa+H*O+w*X;this.n42=y*o+z*N+H*Y+w*ha;this.n43=y*d+z*M+H*W+w*Z;this.n44=y*P+z*U+H*J+w*ea;return this},multiplyToArray:function(a,b,c){var e=a.n11,g=a.n12,f=a.n13,h=a.n14,k=a.n21,j=a.n22,m=a.n23,p=a.n24,x=a.n31,t=a.n32,q=a.n33,y=a.n34,z=a.n41,H=a.n42,w=a.n43;a=a.n44;var E=b.n11,o=b.n12,d=b.n13,P=b.n14,aa=b.n21,N=b.n22,M=b.n23,U=b.n24,O=b.n31,Y=b.n32,W=b.n33,J=b.n34,X=b.n41,ha=b.n42,Z=b.n43;b=b.n44;this.n11=e*E+g*aa+f*O+h*X;this.n12=e*o+g*N+f*Y+h*ha;this.n13=e*d+g*M+f*W+h*Z;this.n14=e*P+g*U+f*
|
|
|
|
-J+h*b;this.n21=k*E+j*aa+m*O+p*X;this.n22=k*o+j*N+m*Y+p*ha;this.n23=k*d+j*M+m*W+p*Z;this.n24=k*P+j*U+m*J+p*b;this.n31=x*E+t*aa+q*O+y*X;this.n32=x*o+t*N+q*Y+y*ha;this.n33=x*d+t*M+q*W+y*Z;this.n34=x*P+t*U+q*J+y*b;this.n41=z*E+H*aa+w*O+a*X;this.n42=z*o+H*N+w*Y+a*ha;this.n43=z*d+H*M+w*W+a*Z;this.n44=z*P+H*U+w*J+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=
|
|
|
|
-this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,e=this.n13,g=this.n14,f=this.n21,h=this.n22,k=this.n23,j=this.n24,m=this.n31,p=this.n32,x=this.n33,t=this.n34,q=this.n41,y=this.n42,z=this.n43,H=this.n44,w=a.n11,E=a.n21,o=a.n31,d=a.n41,P=a.n12,aa=a.n22,N=a.n32,M=a.n42,U=a.n13,O=a.n23,Y=a.n33,W=a.n43,J=a.n14,X=a.n24,ha=a.n34;a=a.n44;this.n11=b*w+c*E+e*o+g*d;this.n12=b*P+c*aa+e*N+g*M;this.n13=b*U+c*O+e*Y+g*W;this.n14=b*J+c*X+e*ha+g*a;this.n21=f*w+
|
|
|
|
-h*E+k*o+j*d;this.n22=f*P+h*aa+k*N+j*M;this.n23=f*U+h*O+k*Y+j*W;this.n24=f*J+h*X+k*ha+j*a;this.n31=m*w+p*E+x*o+t*d;this.n32=m*P+p*aa+x*N+t*M;this.n33=m*U+p*O+x*Y+t*W;this.n34=m*J+p*X+x*ha+t*a;this.n41=q*w+y*E+z*o+H*d;this.n42=q*P+y*aa+z*N+H*M;this.n43=q*U+y*O+z*Y+H*W;this.n44=q*J+y*X+z*ha+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,c=this.n13,e=this.n14,g=this.n21,f=this.n22,h=this.n23,k=this.n24,j=this.n31,m=this.n32,p=this.n33,x=this.n34,t=this.n41,q=this.n42,y=this.n43,z=this.n44;return e*h*m*t-c*k*m*t-e*f*p*t+b*k*p*t+c*f*x*t-b*h*x*t-e*h*j*q+c*k*j*q+e*g*p*q-a*k*p*q-c*g*x*q+a*h*x*q+e*f*j*y-b*k*j*y-e*g*m*y+a*k*m*y+b*g*x*y-a*f*x*y-c*f*j*z+b*h*j*z+c*g*m*z-a*h*m*z-b*g*p*z+a*f*p*z},transpose:function(){function a(b,c,e){var g=b[c];b[c]=b[e];b[e]=
|
|
|
|
|
|
+e+this.n24*g;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*c+this.n43*e+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,e=a.n12,g=a.n13,f=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,q=a.n31,
|
|
|
|
+w=a.n32,u=a.n33,t=a.n34,x=a.n41,A=a.n42,E=a.n43,v=a.n44,F=b.n11,p=b.n12,M=b.n13,d=b.n14,aa=b.n21,O=b.n22,K=b.n23,X=b.n24,Q=b.n31,U=b.n32,V=b.n33,H=b.n34,Y=b.n41,ea=b.n42,Z=b.n43,fa=b.n44;this.n11=c*F+e*aa+g*Q+f*Y;this.n12=c*p+e*O+g*U+f*ea;this.n13=c*M+e*K+g*V+f*Z;this.n14=c*d+e*X+g*H+f*fa;this.n21=h*F+k*aa+j*Q+m*Y;this.n22=h*p+k*O+j*U+m*ea;this.n23=h*M+k*K+j*V+m*Z;this.n24=h*d+k*X+j*H+m*fa;this.n31=q*F+w*aa+u*Q+t*Y;this.n32=q*p+w*O+u*U+t*ea;this.n33=q*M+w*K+u*V+t*Z;this.n34=q*d+w*X+u*H+t*fa;this.n41=
|
|
|
|
+x*F+A*aa+E*Q+v*Y;this.n42=x*p+A*O+E*U+v*ea;this.n43=x*M+A*K+E*V+v*Z;this.n44=x*d+A*X+E*H+v*fa;return this},multiplyToArray:function(a,b,c){var e=a.n11,g=a.n12,f=a.n13,h=a.n14,k=a.n21,j=a.n22,m=a.n23,q=a.n24,w=a.n31,u=a.n32,t=a.n33,x=a.n34,A=a.n41,E=a.n42,v=a.n43;a=a.n44;var F=b.n11,p=b.n12,M=b.n13,d=b.n14,aa=b.n21,O=b.n22,K=b.n23,X=b.n24,Q=b.n31,U=b.n32,V=b.n33,H=b.n34,Y=b.n41,ea=b.n42,Z=b.n43;b=b.n44;this.n11=e*F+g*aa+f*Q+h*Y;this.n12=e*p+g*O+f*U+h*ea;this.n13=e*M+g*K+f*V+h*Z;this.n14=e*d+g*X+f*
|
|
|
|
+H+h*b;this.n21=k*F+j*aa+m*Q+q*Y;this.n22=k*p+j*O+m*U+q*ea;this.n23=k*M+j*K+m*V+q*Z;this.n24=k*d+j*X+m*H+q*b;this.n31=w*F+u*aa+t*Q+x*Y;this.n32=w*p+u*O+t*U+x*ea;this.n33=w*M+u*K+t*V+x*Z;this.n34=w*d+u*X+t*H+x*b;this.n41=A*F+E*aa+v*Q+a*Y;this.n42=A*p+E*O+v*U+a*ea;this.n43=A*M+E*K+v*V+a*Z;this.n44=A*d+E*X+v*H+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=
|
|
|
|
+this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,e=this.n13,g=this.n14,f=this.n21,h=this.n22,k=this.n23,j=this.n24,m=this.n31,q=this.n32,w=this.n33,u=this.n34,t=this.n41,x=this.n42,A=this.n43,E=this.n44,v=a.n11,F=a.n21,p=a.n31,M=a.n41,d=a.n12,aa=a.n22,O=a.n32,K=a.n42,X=a.n13,Q=a.n23,U=a.n33,V=a.n43,H=a.n14,Y=a.n24,ea=a.n34;a=a.n44;this.n11=b*v+c*F+e*p+g*M;this.n12=b*d+c*aa+e*O+g*K;this.n13=b*X+c*Q+e*U+g*V;this.n14=b*H+c*Y+e*ea+g*a;this.n21=f*v+
|
|
|
|
+h*F+k*p+j*M;this.n22=f*d+h*aa+k*O+j*K;this.n23=f*X+h*Q+k*U+j*V;this.n24=f*H+h*Y+k*ea+j*a;this.n31=m*v+q*F+w*p+u*M;this.n32=m*d+q*aa+w*O+u*K;this.n33=m*X+q*Q+w*U+u*V;this.n34=m*H+q*Y+w*ea+u*a;this.n41=t*v+x*F+A*p+E*M;this.n42=t*d+x*aa+A*O+E*K;this.n43=t*X+x*Q+A*U+E*V;this.n44=t*H+x*Y+A*ea+E*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,c=this.n13,e=this.n14,g=this.n21,f=this.n22,h=this.n23,k=this.n24,j=this.n31,m=this.n32,q=this.n33,w=this.n34,u=this.n41,t=this.n42,x=this.n43,A=this.n44;return e*h*m*u-c*k*m*u-e*f*q*u+b*k*q*u+c*f*w*u-b*h*w*u-e*h*j*t+c*k*j*t+e*g*q*t-a*k*q*t-c*g*w*t+a*h*w*t+e*f*j*x-b*k*j*x-e*g*m*x+a*k*m*x+b*g*w*x-a*f*w*x-c*f*j*A+b*h*j*A+c*g*m*A-a*h*m*A-b*g*q*A+a*f*q*A},transpose:function(){function a(b,c,e){var g=b[c];b[c]=b[e];b[e]=
|
|
g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;
|
|
g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;
|
|
a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){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,c){this.set(1,
|
|
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},flattenToArray:function(a){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,c){this.set(1,
|
|
0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,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 c=Math.cos(b),e=Math.sin(b),
|
|
0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,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 c=Math.cos(b),e=Math.sin(b),
|
|
g=1-c,f=a.x,h=a.y,k=a.z,j=g*f,m=g*h;this.set(j*f+c,j*h-e*k,j*k+e*h,0,j*h+e*k,m*h+c,m*k-e*f,0,j*k-e*h,m*k+e*f,g*k*k+c,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,c){var e=new THREE.Matrix4;e.setTranslation(a,b,c);return e};
|
|
g=1-c,f=a.x,h=a.y,k=a.z,j=g*f,m=g*h;this.set(j*f+c,j*h-e*k,j*k+e*h,0,j*h+e*k,m*h+c,m*k-e*f,0,j*k-e*h,m*k+e*f,g*k*k+c,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,c){var e=new THREE.Matrix4;e.setTranslation(a,b,c);return e};
|
|
THREE.Matrix4.scaleMatrix=function(a,b,c){var e=new THREE.Matrix4;e.setScale(a,b,c);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 c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
|
|
THREE.Matrix4.scaleMatrix=function(a,b,c){var e=new THREE.Matrix4;e.setScale(a,b,c);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 c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
|
|
-THREE.Matrix4.makeInvert=function(a){var b=a.n11,c=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,k=a.n23,j=a.n24,m=a.n31,p=a.n32,x=a.n33,t=a.n34,q=a.n41,y=a.n42,z=a.n43,H=a.n44,w=new THREE.Matrix4;w.n11=k*t*y-j*x*y+j*p*z-h*t*z-k*p*H+h*x*H;w.n12=g*x*y-e*t*y-g*p*z+c*t*z+e*p*H-c*x*H;w.n13=e*j*y-g*k*y+g*h*z-c*j*z-e*h*H+c*k*H;w.n14=g*k*p-e*j*p-g*h*x+c*j*x+e*h*t-c*k*t;w.n21=j*x*q-k*t*q-j*m*z+f*t*z+k*m*H-f*x*H;w.n22=e*t*q-g*x*q+g*m*z-b*t*z-e*m*H+b*x*H;w.n23=g*k*q-e*j*q-g*f*z+b*j*z+e*f*H-b*k*H;w.n24=e*j*m-g*k*m+
|
|
|
|
-g*f*x-b*j*x-e*f*t+b*k*t;w.n31=h*t*q-j*p*q+j*m*y-f*t*y-h*m*H+f*p*H;w.n32=g*p*q-c*t*q-g*m*y+b*t*y+c*m*H-b*p*H;w.n33=e*j*q-g*h*q+g*f*y-b*j*y-c*f*H+b*h*H;w.n34=g*h*m-c*j*m-g*f*p+b*j*p+c*f*t-b*h*t;w.n41=k*p*q-h*x*q-k*m*y+f*x*y+h*m*z-f*p*z;w.n42=c*x*q-e*p*q+e*m*y-b*x*y-c*m*z+b*p*z;w.n43=e*h*q-c*k*q-e*f*y+b*k*y+c*f*z-b*h*z;w.n44=c*k*m-e*h*m+e*f*p-b*k*p-c*f*x+b*h*x;w.multiplyScalar(1/a.determinant());return w};
|
|
|
|
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,p=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*g;c[2]=a*f;c[3]=a*h;c[4]=a*k;c[5]=a*j;c[6]=a*m;c[7]=a*p;c[8]=a*x;return b};
|
|
|
|
|
|
+THREE.Matrix4.makeInvert=function(a){var b=a.n11,c=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,k=a.n23,j=a.n24,m=a.n31,q=a.n32,w=a.n33,u=a.n34,t=a.n41,x=a.n42,A=a.n43,E=a.n44,v=new THREE.Matrix4;v.n11=k*u*x-j*w*x+j*q*A-h*u*A-k*q*E+h*w*E;v.n12=g*w*x-e*u*x-g*q*A+c*u*A+e*q*E-c*w*E;v.n13=e*j*x-g*k*x+g*h*A-c*j*A-e*h*E+c*k*E;v.n14=g*k*q-e*j*q-g*h*w+c*j*w+e*h*u-c*k*u;v.n21=j*w*t-k*u*t-j*m*A+f*u*A+k*m*E-f*w*E;v.n22=e*u*t-g*w*t+g*m*A-b*u*A-e*m*E+b*w*E;v.n23=g*k*t-e*j*t-g*f*A+b*j*A+e*f*E-b*k*E;v.n24=e*j*m-g*k*m+
|
|
|
|
+g*f*w-b*j*w-e*f*u+b*k*u;v.n31=h*u*t-j*q*t+j*m*x-f*u*x-h*m*E+f*q*E;v.n32=g*q*t-c*u*t-g*m*x+b*u*x+c*m*E-b*q*E;v.n33=e*j*t-g*h*t+g*f*x-b*j*x-c*f*E+b*h*E;v.n34=g*h*m-c*j*m-g*f*q+b*j*q+c*f*u-b*h*u;v.n41=k*q*t-h*w*t-k*m*x+f*w*x+h*m*A-f*q*A;v.n42=c*w*t-e*q*t+e*m*x-b*w*x-c*m*A+b*q*A;v.n43=e*h*t-c*k*t-e*f*x+b*k*x+c*f*A-b*h*A;v.n44=c*k*m-e*h*m+e*f*q-b*k*q-c*f*w+b*h*w;v.multiplyScalar(1/a.determinant());return v};
|
|
|
|
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,q=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*g;c[2]=a*f;c[3]=a*h;c[4]=a*k;c[5]=a*j;c[6]=a*m;c[7]=a*q;c[8]=a*w;return b};
|
|
THREE.Matrix4.makeFrustum=function(a,b,c,e,g,f){var h,k,j;h=new THREE.Matrix4;k=2*g/(b-a);j=2*g/(e-c);a=(b+a)/(b-a);c=(e+c)/(e-c);e=-(f+g)/(f-g);g=-2*f*g/(f-g);h.n11=k;h.n12=0;h.n13=a;h.n14=0;h.n21=0;h.n22=j;h.n23=c;h.n24=0;h.n31=0;h.n32=0;h.n33=e;h.n34=g;h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,e){var g;a=c*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,c,e)};
|
|
THREE.Matrix4.makeFrustum=function(a,b,c,e,g,f){var h,k,j;h=new THREE.Matrix4;k=2*g/(b-a);j=2*g/(e-c);a=(b+a)/(b-a);c=(e+c)/(e-c);e=-(f+g)/(f-g);g=-2*f*g/(f-g);h.n11=k;h.n12=0;h.n13=a;h.n14=0;h.n21=0;h.n22=j;h.n23=c;h.n24=0;h.n31=0;h.n32=0;h.n33=e;h.n34=g;h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,e){var g;a=c*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,c,e)};
|
|
THREE.Matrix4.makeOrtho=function(a,b,c,e,g,f){var h,k,j,m;h=new THREE.Matrix4;k=b-a;j=c-e;m=f-g;a=(b+a)/k;c=(c+e)/j;g=(f+g)/m;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-a;h.n21=0;h.n22=2/j;h.n23=0;h.n24=-c;h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-g;h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
|
|
THREE.Matrix4.makeOrtho=function(a,b,c,e,g,f){var h,k,j,m;h=new THREE.Matrix4;k=b-a;j=c-e;m=f-g;a=(b+a)/k;c=(c+e)/j;g=(f+g)/m;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-a;h.n21=0;h.n22=2/j;h.n23=0;h.n24=-c;h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-g;h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};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.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,c,e,g){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
|
|
THREE.Face3=function(a,b,c,e,g){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
|
|
THREE.Face4=function(a,b,c,e,g,f){this.a=a;this.b=b;this.c=c;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=f instanceof Array?f:[f]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
|
|
THREE.Face4=function(a,b,c,e,g,f){this.a=a;this.b=b;this.c=c;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=f instanceof Array?f:[f]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
|
|
-THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
|
|
|
|
|
|
+THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
|
|
THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);
|
|
THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);
|
|
c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,e,g,f,h,k=new THREE.Vector3,j=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){f=this.vertices[e];f.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];if(a&&f.vertexNormals.length){k.set(0,0,0);b=0;for(c=f.normal.length;b<c;b++)k.addSelf(f.vertexNormals[b]);k.divideScalar(3)}else{b=this.vertices[f.a];c=this.vertices[f.b];h=this.vertices[f.c];k.sub(h.position,
|
|
c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,e,g,f,h,k=new THREE.Vector3,j=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){f=this.vertices[e];f.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];if(a&&f.vertexNormals.length){k.set(0,0,0);b=0;for(c=f.normal.length;b<c;b++)k.addSelf(f.vertexNormals[b]);k.divideScalar(3)}else{b=this.vertices[f.a];c=this.vertices[f.b];h=this.vertices[f.c];k.sub(h.position,
|
|
c.position);j.sub(b.position,c.position);k.crossSelf(j)}k.isZero()||k.normalize();f.normal.copy(k)}},computeVertexNormals:function(){var a,b,c,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++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,
|
|
c.position);j.sub(b.position,c.position);k.crossSelf(j)}k.isZero()||k.normalize();f.normal.copy(k)}},computeVertexNormals:function(){var a,b,c,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++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.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++){c=this.faces[a];if(c instanceof THREE.Face3){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal);e[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)e[a].normalize();a=0;for(b=this.faces.length;a<
|
|
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++){c=this.faces[a];if(c instanceof THREE.Face3){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal);e[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)e[a].normalize();a=0;for(b=this.faces.length;a<
|
|
-b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c]);c.vertexNormals[3].copy(e[c.d])}}},computeTangents:function(){function a(J,X,ha,Z,ea,l,v){f=J.vertices[X].position;h=J.vertices[ha].position;k=J.vertices[Z].position;j=g[ea];m=g[l];p=g[v];x=h.x-f.x;t=k.x-f.x;q=h.y-f.y;y=k.y-
|
|
|
|
-f.y;z=h.z-f.z;H=k.z-f.z;w=m.u-j.u;E=p.u-j.u;o=m.v-j.v;d=p.v-j.v;P=1/(w*d-E*o);M.set((d*x-o*t)*P,(d*q-o*y)*P,(d*z-o*H)*P);U.set((w*t-E*x)*P,(w*y-E*q)*P,(w*H-E*z)*P);aa[X].addSelf(M);aa[ha].addSelf(M);aa[Z].addSelf(M);N[X].addSelf(U);N[ha].addSelf(U);N[Z].addSelf(U)}var b,c,e,g,f,h,k,j,m,p,x,t,q,y,z,H,w,E,o,d,P,aa=[],N=[],M=new THREE.Vector3,U=new THREE.Vector3,O=new THREE.Vector3,Y=new THREE.Vector3,W=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){aa[b]=new THREE.Vector3;N[b]=new THREE.Vector3}b=
|
|
|
|
|
|
+b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c]);c.vertexNormals[3].copy(e[c.d])}}},computeTangents:function(){function a(H,Y,ea,Z,fa,ia,l){f=H.vertices[Y].position;h=H.vertices[ea].position;k=H.vertices[Z].position;j=g[fa];m=g[ia];q=g[l];w=h.x-f.x;u=k.x-f.x;t=h.y-f.y;x=k.y-
|
|
|
|
+f.y;A=h.z-f.z;E=k.z-f.z;v=m.u-j.u;F=q.u-j.u;p=m.v-j.v;M=q.v-j.v;d=1/(v*M-F*p);K.set((M*w-p*u)*d,(M*t-p*x)*d,(M*A-p*E)*d);X.set((v*u-F*w)*d,(v*x-F*t)*d,(v*E-F*A)*d);aa[Y].addSelf(K);aa[ea].addSelf(K);aa[Z].addSelf(K);O[Y].addSelf(X);O[ea].addSelf(X);O[Z].addSelf(X)}var b,c,e,g,f,h,k,j,m,q,w,u,t,x,A,E,v,F,p,M,d,aa=[],O=[],K=new THREE.Vector3,X=new THREE.Vector3,Q=new THREE.Vector3,U=new THREE.Vector3,V=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){aa[b]=new THREE.Vector3;O[b]=new THREE.Vector3}b=
|
|
0;for(c=this.faces.length;b<c;b++){e=this.faces[b];g=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
|
|
0;for(c=this.faces.length;b<c;b++){e=this.faces[b];g=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
|
|
-this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){W.copy(this.vertices[b].normal);e=aa[b];O.copy(e);O.subSelf(W.multiplyScalar(W.dot(e))).normalize();Y.cross(this.vertices[b].normal,e);e=Y.dot(N[b]);e=e<0?-1:1;this.vertices[b].tangent.set(O.x,O.y,O.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(c=this.vertices.length;b<c;b++){V.copy(this.vertices[b].normal);e=aa[b];Q.copy(e);Q.subSelf(V.multiplyScalar(V.dot(e))).normalize();U.cross(this.vertices[b].normal,e);e=U.dot(O[b]);e=e<0?-1:1;this.vertices[b].tangent.set(Q.x,Q.y,Q.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],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,c=this.vertices.length;b<c;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>
|
|
z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;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,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(p){var x=[];b=0;for(c=p.length;b<c;b++)p[b]==undefined?x.push("undefined"):x.push(p[b].toString());return x.join("_")}var b,c,e,g,f,h,k,j,m={};e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];
|
|
|
|
|
|
+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,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(q){var w=[];b=0;for(c=q.length;b<c;b++)q[b]==undefined?w.push("undefined"):w.push(q[b].toString());return w.join("_")}var b,c,e,g,f,h,k,j,m={};e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];
|
|
h=f.materials;k=a(h);if(m[k]==undefined)m[k]={hash:k,counter:0};j=m[k].hash+"_"+m[k].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:h,vertices:0};f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+f>65535){m[k].counter+=1;j=m[k].hash+"_"+m[k].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:h,vertices:0}}this.geometryChunks[j].faces.push(e);this.geometryChunks[j].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+
|
|
h=f.materials;k=a(h);if(m[k]==undefined)m[k]={hash:k,counter:0};j=m[k].hash+"_"+m[k].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:h,vertices:0};f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+f>65535){m[k].counter+=1;j=m[k].hash+"_"+m[k].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:h,vertices:0}}this.geometryChunks[j].faces.push(e);this.geometryChunks[j].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+
|
|
-this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
|
|
|
|
|
|
+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0;
|
|
THREE.Camera=function(a,b,c,e){this.fov=a;this.aspect=b;this.near=c;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
|
|
THREE.Camera=function(a,b,c,e){this.fov=a;this.aspect=b;this.near=c;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
|
|
this.translateZ=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
|
|
this.translateZ=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
|
|
THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;
|
|
THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;
|
|
@@ -104,108 +104,108 @@ var Uniforms={clone:function(a){var b,c,e,g={};for(b in a){g[b]={};for(c in a[b]
|
|
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
|
|
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
|
|
THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
|
|
THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
|
|
THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b||1;this.far=c||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
|
|
THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b||1;this.far=c||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
|
|
-THREE.Projector=function(){function a(N,M){return M.z-N.z}function b(N,M){var U=0,O=1,Y=N.z+N.w,W=M.z+M.w,J=-N.z+N.w,X=-M.z+M.w;if(Y>=0&&W>=0&&J>=0&&X>=0)return true;else if(Y<0&&W<0||J<0&&X<0)return false;else{if(Y<0)U=Math.max(U,Y/(Y-W));else if(W<0)O=Math.min(O,Y/(Y-W));if(J<0)U=Math.max(U,J/(J-X));else if(X<0)O=Math.min(O,J/(J-X));if(O<U)return false;else{N.lerpSelf(M,U);M.lerpSelf(N,1-O);return true}}}var c,e,g=[],f,h,k,j=[],m,p,x=[],t,q,y=[],z=new THREE.Vector4,H=new THREE.Vector4,w=new THREE.Matrix4,
|
|
|
|
-E=new THREE.Matrix4,o=[],d=new THREE.Vector4,P=new THREE.Vector4,aa;this.projectObjects=function(N,M,U){var O=[],Y,W;e=0;w.multiply(M.projectionMatrix,M.matrix);o[0]=new THREE.Vector4(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);o[1]=new THREE.Vector4(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);o[2]=new THREE.Vector4(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);o[3]=new THREE.Vector4(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);o[4]=new THREE.Vector4(w.n41-w.n31,w.n42-w.n32,w.n43-
|
|
|
|
-w.n33,w.n44-w.n34);o[5]=new THREE.Vector4(w.n41+w.n31,w.n42+w.n32,w.n43+w.n33,w.n44+w.n34);M=0;for(Y=o.length;M<Y;M++){W=o[M];W.divideScalar(Math.sqrt(W.x*W.x+W.y*W.y+W.z*W.z))}Y=N.objects;N=0;for(M=Y.length;N<M;N++){W=Y[N];var J;if(!(J=!W.visible)){if(J=W instanceof THREE.Mesh){a:{J=void 0;for(var X=W.position,ha=-W.geometry.boundingSphere.radius*Math.max(W.scale.x,Math.max(W.scale.y,W.scale.z)),Z=0;Z<6;Z++){J=o[Z].x*X.x+o[Z].y*X.y+o[Z].z*X.z+o[Z].w;if(J<=ha){J=false;break a}}J=true}J=!J}J=J}if(!J){c=
|
|
|
|
-g[e]=g[e]||new THREE.RenderableObject;z.copy(W.position);w.multiplyVector3(z);c.object=W;c.z=z.z;O.push(c);e++}}U&&O.sort(a);return O};this.projectScene=function(N,M,U){var O=[],Y=M.near,W=M.far,J,X,ha,Z,ea,l,v,A,u,n,F,L,G,D,C,R;k=p=q=0;M.autoUpdateMatrix&&M.updateMatrix();w.multiply(M.projectionMatrix,M.matrix);l=this.projectObjects(N,M,true);N=0;for(J=l.length;N<J;N++){v=l[N].object;if(v.visible){v.autoUpdateMatrix&&v.updateMatrix();A=v.matrix;u=v.rotationMatrix;n=v.materials;F=v.overdraw;if(v instanceof
|
|
|
|
-THREE.Mesh){L=v.geometry;G=L.vertices;X=0;for(ha=G.length;X<ha;X++){D=G[X];D.positionWorld.copy(D.position);A.multiplyVector3(D.positionWorld);Z=D.positionScreen;Z.copy(D.positionWorld);w.multiplyVector4(Z);Z.x/=Z.w;Z.y/=Z.w;D.__visible=Z.z>Y&&Z.z<W}L=L.faces;X=0;for(ha=L.length;X<ha;X++){D=L[X];if(D instanceof THREE.Face3){Z=G[D.a];ea=G[D.b];C=G[D.c];if(Z.__visible&&ea.__visible&&C.__visible)if(v.doubleSided||v.flipSided!=(C.positionScreen.x-Z.positionScreen.x)*(ea.positionScreen.y-Z.positionScreen.y)-
|
|
|
|
-(C.positionScreen.y-Z.positionScreen.y)*(ea.positionScreen.x-Z.positionScreen.x)<0){f=j[k]=j[k]||new THREE.RenderableFace3;f.v1.positionWorld.copy(Z.positionWorld);f.v2.positionWorld.copy(ea.positionWorld);f.v3.positionWorld.copy(C.positionWorld);f.v1.positionScreen.copy(Z.positionScreen);f.v2.positionScreen.copy(ea.positionScreen);f.v3.positionScreen.copy(C.positionScreen);f.normalWorld.copy(D.normal);u.multiplyVector3(f.normalWorld);f.centroidWorld.copy(D.centroid);A.multiplyVector3(f.centroidWorld);
|
|
|
|
-f.centroidScreen.copy(f.centroidWorld);w.multiplyVector3(f.centroidScreen);C=D.vertexNormals;aa=f.vertexNormalsWorld;Z=0;for(ea=C.length;Z<ea;Z++){R=aa[Z]=aa[Z]||new THREE.Vector3;R.copy(C[Z]);u.multiplyVector3(R)}f.z=f.centroidScreen.z;f.meshMaterials=n;f.faceMaterials=D.materials;f.overdraw=F;if(v.geometry.uvs[X]){f.uvs[0]=v.geometry.uvs[X][0];f.uvs[1]=v.geometry.uvs[X][1];f.uvs[2]=v.geometry.uvs[X][2]}O.push(f);k++}}else if(D instanceof THREE.Face4){Z=G[D.a];ea=G[D.b];C=G[D.c];R=G[D.d];if(Z.__visible&&
|
|
|
|
-ea.__visible&&C.__visible&&R.__visible)if(v.doubleSided||v.flipSided!=((R.positionScreen.x-Z.positionScreen.x)*(ea.positionScreen.y-Z.positionScreen.y)-(R.positionScreen.y-Z.positionScreen.y)*(ea.positionScreen.x-Z.positionScreen.x)<0||(ea.positionScreen.x-C.positionScreen.x)*(R.positionScreen.y-C.positionScreen.y)-(ea.positionScreen.y-C.positionScreen.y)*(R.positionScreen.x-C.positionScreen.x)<0)){f=j[k]=j[k]||new THREE.RenderableFace3;f.v1.positionWorld.copy(Z.positionWorld);f.v2.positionWorld.copy(ea.positionWorld);
|
|
|
|
-f.v3.positionWorld.copy(R.positionWorld);f.v1.positionScreen.copy(Z.positionScreen);f.v2.positionScreen.copy(ea.positionScreen);f.v3.positionScreen.copy(R.positionScreen);f.normalWorld.copy(D.normal);u.multiplyVector3(f.normalWorld);f.centroidWorld.copy(D.centroid);A.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);w.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=n;f.faceMaterials=D.materials;f.overdraw=F;if(v.geometry.uvs[X]){f.uvs[0]=v.geometry.uvs[X][0];
|
|
|
|
-f.uvs[1]=v.geometry.uvs[X][1];f.uvs[2]=v.geometry.uvs[X][3]}O.push(f);k++;h=j[k]=j[k]||new THREE.RenderableFace3;h.v1.positionWorld.copy(ea.positionWorld);h.v2.positionWorld.copy(C.positionWorld);h.v3.positionWorld.copy(R.positionWorld);h.v1.positionScreen.copy(ea.positionScreen);h.v2.positionScreen.copy(C.positionScreen);h.v3.positionScreen.copy(R.positionScreen);h.normalWorld.copy(f.normalWorld);h.centroidWorld.copy(f.centroidWorld);h.centroidScreen.copy(f.centroidScreen);h.z=h.centroidScreen.z;
|
|
|
|
-h.meshMaterials=n;h.faceMaterials=D.materials;h.overdraw=F;if(v.geometry.uvs[X]){h.uvs[0]=v.geometry.uvs[X][1];h.uvs[1]=v.geometry.uvs[X][2];h.uvs[2]=v.geometry.uvs[X][3]}O.push(h);k++}}}}else if(v instanceof THREE.Line){E.multiply(w,A);G=v.geometry.vertices;D=G[0];D.positionScreen.copy(D.position);E.multiplyVector4(D.positionScreen);X=1;for(ha=G.length;X<ha;X++){Z=G[X];Z.positionScreen.copy(Z.position);E.multiplyVector4(Z.positionScreen);ea=G[X-1];d.copy(Z.positionScreen);P.copy(ea.positionScreen);
|
|
|
|
-if(b(d,P)){d.multiplyScalar(1/d.w);P.multiplyScalar(1/P.w);m=x[p]=x[p]||new THREE.RenderableLine;m.v1.positionScreen.copy(d);m.v2.positionScreen.copy(P);m.z=Math.max(d.z,P.z);m.materials=v.materials;O.push(m);p++}}}else if(v instanceof THREE.Particle){H.set(v.position.x,v.position.y,v.position.z,1);w.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){t=y[q]=y[q]||new THREE.RenderableParticle;t.x=H.x/H.w;t.y=H.y/H.w;t.z=H.z;t.rotation=v.rotation.z;t.scale.x=v.scale.x*Math.abs(t.x-(H.x+M.projectionMatrix.n11)/
|
|
|
|
-(H.w+M.projectionMatrix.n14));t.scale.y=v.scale.y*Math.abs(t.y-(H.y+M.projectionMatrix.n22)/(H.w+M.projectionMatrix.n24));t.materials=v.materials;O.push(t);q++}}}}U&&O.sort(a);return O};this.unprojectVector=function(N,M){var U=THREE.Matrix4.makeInvert(M.matrix);U.multiplySelf(THREE.Matrix4.makeInvert(M.projectionMatrix));U.multiplyVector3(N);return N}};
|
|
|
|
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,g,f;this.domElement=document.createElement("div");this.setSize=function(h,k){c=h;e=k;g=c/2;f=e/2};this.render=function(h,k){var j,m,p,x,t,q,y,z;a=b.projectScene(h,k);j=0;for(m=a.length;j<m;j++){t=a[j];if(t instanceof THREE.RenderableParticle){y=t.x*g+g;z=t.y*f+f;p=0;for(x=t.material.length;p<x;p++){q=t.material[p];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=y+"px";q.style.top=z+"px"}}}}}};
|
|
|
|
-THREE.CanvasRenderer=function(){function a(fa){if(t!=fa)m.globalAlpha=t=fa}function b(fa){if(q!=fa){switch(fa){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}q=fa}}var c=null,e=new THREE.Projector,g=document.createElement("canvas"),f,h,k,j,m=g.getContext("2d"),p=new THREE.Color(0),x=0,t=1,q=0,y=null,z=null,H=1,w,E,o,d,P,aa,N,M,U,O=new THREE.Color,
|
|
|
|
-Y=new THREE.Color,W=new THREE.Color,J=new THREE.Color,X=new THREE.Color,ha,Z,ea,l,v,A,u,n,F,L=new THREE.Rectangle,G=new THREE.Rectangle,D=new THREE.Rectangle,C=false,R=new THREE.Color,ba=new THREE.Color,ga=new THREE.Color,B=new THREE.Color,K=Math.PI*2,I=new THREE.Vector3,Q,da,V,ka,pa,ua,la=16;Q=document.createElement("canvas");Q.width=Q.height=2;da=Q.getContext("2d");da.fillStyle="rgba(0,0,0,1)";da.fillRect(0,0,2,2);V=da.getImageData(0,0,2,2);ka=V.data;pa=document.createElement("canvas");pa.width=
|
|
|
|
-pa.height=la;ua=pa.getContext("2d");ua.translate(-la/2,-la/2);ua.scale(la,la);la--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(fa,ja){f=fa;h=ja;k=f/2;j=h/2;g.width=f;g.height=h;L.set(-k,-j,k,j);t=1;q=0;z=y=null;H=1};this.setClearColor=function(fa,ja){p=fa;x=ja;G.set(-k,-j,k,j);m.setTransform(1,0,0,-1,k,j);this.clear()};this.setClearColorHex=function(fa,ja){p.setHex(fa);x=ja;G.set(-k,-j,k,j);m.setTransform(1,0,0,-1,k,j);this.clear()};this.clear=function(){m.setTransform(1,
|
|
|
|
-0,0,-1,k,j);if(!G.isEmpty()){G.inflate(1);G.minSelf(L);if(p.hex==0&&x==0)m.clearRect(G.getX(),G.getY(),G.getWidth(),G.getHeight());else{b(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*255)+","+x+")";m.fillRect(G.getX(),G.getY(),G.getWidth(),G.getHeight())}G.empty()}};this.render=function(fa,ja){function Fa(S){var ia,ca,T,$=S.lights;ba.setRGB(0,0,0);ga.setRGB(0,0,0);B.setRGB(0,0,0);S=0;for(ia=$.length;S<ia;S++){ca=$[S];T=ca.color;if(ca instanceof
|
|
|
|
-THREE.AmbientLight){ba.r+=T.r;ba.g+=T.g;ba.b+=T.b}else if(ca instanceof THREE.DirectionalLight){ga.r+=T.r;ga.g+=T.g;ga.b+=T.b}else if(ca instanceof THREE.PointLight){B.r+=T.r;B.g+=T.g;B.b+=T.b}}}function ta(S,ia,ca,T){var $,na,va,Aa,Ca=S.lights;S=0;for($=Ca.length;S<$;S++){na=Ca[S];va=na.color;Aa=na.intensity;if(na instanceof THREE.DirectionalLight){na=ca.dot(na.position)*Aa;if(na>0){T.r+=va.r*na;T.g+=va.g*na;T.b+=va.b*na}}else if(na instanceof THREE.PointLight){I.sub(na.position,ia);I.normalize();
|
|
|
|
-na=ca.dot(I)*Aa;if(na>0){T.r+=va.r*na;T.g+=va.g*na;T.b+=va.b*na}}}}function qa(S,ia,ca){if(ca.opacity!=0){a(ca.opacity);b(ca.blending);var T,$,na,va,Aa,Ca;if(ca instanceof THREE.ParticleBasicMaterial){if(ca.map&&ca.map.image.loaded){va=ca.map.image;Aa=va.width>>1;Ca=va.height>>1;$=ia.scale.x*k;na=ia.scale.y*j;ca=$*Aa;T=na*Ca;D.set(S.x-ca,S.y-T,S.x+ca,S.y+T);if(L.instersects(D)){m.save();m.translate(S.x,S.y);m.rotate(-ia.rotation);m.scale($,-na);m.translate(-Aa,-Ca);m.drawImage(va,0,0);m.restore()}}}else if(ca instanceof
|
|
|
|
-THREE.ParticleCircleMaterial){if(C){R.r=ba.r+ga.r+B.r;R.g=ba.g+ga.g+B.g;R.b=ba.b+ga.b+B.b;O.r=ca.color.r*R.r;O.g=ca.color.g*R.g;O.b=ca.color.b*R.b;O.updateStyleString()}else O.__styleString=ca.color.__styleString;ca=ia.scale.x*k;T=ia.scale.y*j;D.set(S.x-ca,S.y-T,S.x+ca,S.y+T);if(L.instersects(D)){$=O.__styleString;if(z!=$)m.fillStyle=z=$;m.save();m.translate(S.x,S.y);m.rotate(-ia.rotation);m.scale(ca,T);m.beginPath();m.arc(0,0,1,0,K,true);m.closePath();m.fill();m.restore()}}}}function sa(S,ia,ca,
|
|
|
|
-T){if(T.opacity!=0){a(T.opacity);b(T.blending);m.beginPath();m.moveTo(S.positionScreen.x,S.positionScreen.y);m.lineTo(ia.positionScreen.x,ia.positionScreen.y);m.closePath();if(T instanceof THREE.LineBasicMaterial){O.__styleString=T.color.__styleString;S=T.linewidth;if(H!=S)m.lineWidth=H=S;S=O.__styleString;if(y!=S)m.strokeStyle=y=S;m.stroke();D.inflate(T.linewidth*2)}}}function Ma(S,ia,ca,T,$,na){if($.opacity!=0){a($.opacity);b($.blending);d=S.positionScreen.x;P=S.positionScreen.y;aa=ia.positionScreen.x;
|
|
|
|
-N=ia.positionScreen.y;M=ca.positionScreen.x;U=ca.positionScreen.y;m.beginPath();m.moveTo(d,P);m.lineTo(aa,N);m.lineTo(M,U);m.lineTo(d,P);m.closePath();if($ instanceof THREE.MeshBasicMaterial)if($.map)$.map.image.loaded&&$.map.mapping instanceof THREE.UVMapping&&ma(d,P,aa,N,M,U,$.map.image,T.uvs[0].u,T.uvs[0].v,T.uvs[1].u,T.uvs[1].v,T.uvs[2].u,T.uvs[2].v);else if($.env_map){if($.env_map.image.loaded)if($.env_map.mapping instanceof THREE.SphericalReflectionMapping){S=ja.matrix;I.copy(T.vertexNormalsWorld[0]);
|
|
|
|
-l=(I.x*S.n11+I.y*S.n12+I.z*S.n13)*0.5+0.5;v=-(I.x*S.n21+I.y*S.n22+I.z*S.n23)*0.5+0.5;I.copy(T.vertexNormalsWorld[1]);A=(I.x*S.n11+I.y*S.n12+I.z*S.n13)*0.5+0.5;u=-(I.x*S.n21+I.y*S.n22+I.z*S.n23)*0.5+0.5;I.copy(T.vertexNormalsWorld[2]);n=(I.x*S.n11+I.y*S.n12+I.z*S.n13)*0.5+0.5;F=-(I.x*S.n21+I.y*S.n22+I.z*S.n23)*0.5+0.5;ma(d,P,aa,N,M,U,$.env_map.image,l,v,A,u,n,F)}}else $.wireframe?Ga($.color.__styleString,$.wireframe_linewidth):za($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&
|
|
|
|
-!$.wireframe){$.map.mapping instanceof THREE.UVMapping&&ma(d,P,aa,N,M,U,$.map.image,T.uvs[0].u,T.uvs[0].v,T.uvs[1].u,T.uvs[1].v,T.uvs[2].u,T.uvs[2].v);b(THREE.SubtractiveBlending)}if(C)if(!$.wireframe&&$.shading==THREE.SmoothShading&&T.vertexNormalsWorld.length==3){Y.r=W.r=J.r=ba.r;Y.g=W.g=J.g=ba.g;Y.b=W.b=J.b=ba.b;ta(na,T.v1.positionWorld,T.vertexNormalsWorld[0],Y);ta(na,T.v2.positionWorld,T.vertexNormalsWorld[1],W);ta(na,T.v3.positionWorld,T.vertexNormalsWorld[2],J);X.r=(W.r+J.r)*0.5;X.g=(W.g+J.g)*
|
|
|
|
-0.5;X.b=(W.b+J.b)*0.5;ea=ra(Y,W,J,X);ma(d,P,aa,N,M,U,ea,0,0,1,0,0,1)}else{R.r=ba.r;R.g=ba.g;R.b=ba.b;ta(na,T.centroidWorld,T.normalWorld,R);O.r=$.color.r*R.r;O.g=$.color.g*R.g;O.b=$.color.b*R.b;O.updateStyleString();$.wireframe?Ga(O.__styleString,$.wireframe_linewidth):za(O.__styleString)}else $.wireframe?Ga($.color.__styleString,$.wireframe_linewidth):za($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){ha=ja.near;Z=ja.far;Y.r=Y.g=Y.b=1-Da(S.positionScreen.z,ha,Z);W.r=W.g=W.b=
|
|
|
|
-1-Da(ia.positionScreen.z,ha,Z);J.r=J.g=J.b=1-Da(ca.positionScreen.z,ha,Z);X.r=(W.r+J.r)*0.5;X.g=(W.g+J.g)*0.5;X.b=(W.b+J.b)*0.5;ea=ra(Y,W,J,X);ma(d,P,aa,N,M,U,ea,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){O.r=xa(T.normalWorld.x);O.g=xa(T.normalWorld.y);O.b=xa(T.normalWorld.z);O.updateStyleString();$.wireframe?Ga(O.__styleString,$.wireframe_linewidth):za(O.__styleString)}}}function Ga(S,ia){if(y!=S)m.strokeStyle=y=S;if(H!=ia)m.lineWidth=H=ia;m.stroke();D.inflate(ia*2)}function za(S){if(z!=
|
|
|
|
-S)m.fillStyle=z=S;m.fill()}function ma(S,ia,ca,T,$,na,va,Aa,Ca,Ja,Ea,Ka,Ra){var Ha,La;Ha=va.width-1;La=va.height-1;Aa*=Ha;Ca*=La;Ja*=Ha;Ea*=La;Ka*=Ha;Ra*=La;ca-=S;T-=ia;$-=S;na-=ia;Ja-=Aa;Ea-=Ca;Ka-=Aa;Ra-=Ca;Ha=Ja*Ra-Ka*Ea;if(Ha!=0){La=1/Ha;Ha=(Ra*ca-Ea*$)*La;Ea=(Ra*T-Ea*na)*La;ca=(Ja*$-Ka*ca)*La;T=(Ja*na-Ka*T)*La;S=S-Ha*Aa-ca*Ca;ia=ia-Ea*Aa-T*Ca;m.save();m.transform(Ha,Ea,ca,T,S,ia);m.clip();m.drawImage(va,0,0);m.restore()}}function ra(S,ia,ca,T){var $=~~(S.r*255),na=~~(S.g*255);S=~~(S.b*255);var va=
|
|
|
|
-~~(ia.r*255),Aa=~~(ia.g*255);ia=~~(ia.b*255);var Ca=~~(ca.r*255),Ja=~~(ca.g*255);ca=~~(ca.b*255);var Ea=~~(T.r*255),Ka=~~(T.g*255);T=~~(T.b*255);ka[0]=$<0?0:$>255?255:$;ka[1]=na<0?0:na>255?255:na;ka[2]=S<0?0:S>255?255:S;ka[4]=va<0?0:va>255?255:va;ka[5]=Aa<0?0:Aa>255?255:Aa;ka[6]=ia<0?0:ia>255?255:ia;ka[8]=Ca<0?0:Ca>255?255:Ca;ka[9]=Ja<0?0:Ja>255?255:Ja;ka[10]=ca<0?0:ca>255?255:ca;ka[12]=Ea<0?0:Ea>255?255:Ea;ka[13]=Ka<0?0:Ka>255?255:Ka;ka[14]=T<0?0:T>255?255:T;da.putImageData(V,0,0);ua.drawImage(Q,
|
|
|
|
-0,0);return pa}function Da(S,ia,ca){S=(S-ia)/(ca-ia);return S*S*(3-2*S)}function xa(S){S=(S+1)*0.5;return S<0?0:S>1?1:S}function Oa(S,ia){var ca=ia.x-S.x,T=ia.y-S.y,$=1/Math.sqrt(ca*ca+T*T);ca*=$;T*=$;ia.x+=ca;ia.y+=T;S.x-=ca;S.y-=T}var ya,Pa,oa,Ba,Ia,Na,Qa,wa;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,j);c=e.projectScene(fa,ja,this.sortElements);(C=fa.lights.length>0)&&Fa(fa);ya=0;for(Pa=c.length;ya<Pa;ya++){oa=c[ya];D.empty();if(oa instanceof THREE.RenderableParticle){w=oa;w.x*=k;w.y*=
|
|
|
|
-j;Ba=0;for(Ia=oa.materials.length;Ba<Ia;Ba++)qa(w,oa,oa.materials[Ba],fa)}else if(oa instanceof THREE.RenderableLine){w=oa.v1;E=oa.v2;w.positionScreen.x*=k;w.positionScreen.y*=j;E.positionScreen.x*=k;E.positionScreen.y*=j;D.addPoint(w.positionScreen.x,w.positionScreen.y);D.addPoint(E.positionScreen.x,E.positionScreen.y);if(L.instersects(D)){Ba=0;for(Ia=oa.materials.length;Ba<Ia;)sa(w,E,oa,oa.materials[Ba++],fa)}}else if(oa instanceof THREE.RenderableFace3){w=oa.v1;E=oa.v2;o=oa.v3;w.positionScreen.x*=
|
|
|
|
-k;w.positionScreen.y*=j;E.positionScreen.x*=k;E.positionScreen.y*=j;o.positionScreen.x*=k;o.positionScreen.y*=j;if(oa.overdraw){Oa(w.positionScreen,E.positionScreen);Oa(E.positionScreen,o.positionScreen);Oa(o.positionScreen,w.positionScreen)}D.add3Points(w.positionScreen.x,w.positionScreen.y,E.positionScreen.x,E.positionScreen.y,o.positionScreen.x,o.positionScreen.y);if(L.instersects(D)){Ba=0;for(Ia=oa.meshMaterials.length;Ba<Ia;){wa=oa.meshMaterials[Ba++];if(wa instanceof THREE.MeshFaceMaterial){Na=
|
|
|
|
-0;for(Qa=oa.faceMaterials.length;Na<Qa;)(wa=oa.faceMaterials[Na++])&&Ma(w,E,o,oa,wa,fa)}else Ma(w,E,o,oa,wa,fa)}}}G.addRectangle(D)}m.setTransform(1,0,0,1,0,0)}};
|
|
|
|
-THREE.SVGRenderer=function(){function a(l,v,A){var u,n,F,L;u=0;for(n=l.lights.length;u<n;u++){F=l.lights[u];if(F instanceof THREE.DirectionalLight){L=v.normalWorld.dot(F.position)*F.intensity;if(L>0){A.r+=F.color.r*L;A.g+=F.color.g*L;A.b+=F.color.b*L}}else if(F instanceof THREE.PointLight){U.sub(F.position,v.centroidWorld);U.normalize();L=v.normalWorld.dot(U)*F.intensity;if(L>0){A.r+=F.color.r*L;A.g+=F.color.g*L;A.b+=F.color.b*L}}}}function b(l,v,A,u,n,F){J=e(X++);J.setAttribute("d","M "+l.positionScreen.x+
|
|
|
|
-" "+l.positionScreen.y+" L "+v.positionScreen.x+" "+v.positionScreen.y+" L "+A.positionScreen.x+","+A.positionScreen.y+"z");if(n instanceof THREE.MeshBasicMaterial)o.__styleString=n.color.__styleString;else if(n instanceof THREE.MeshLambertMaterial)if(E){d.r=P.r;d.g=P.g;d.b=P.b;a(F,u,d);o.r=n.color.r*d.r;o.g=n.color.g*d.g;o.b=n.color.b*d.b;o.updateStyleString()}else o.__styleString=n.color.__styleString;else if(n instanceof THREE.MeshDepthMaterial){M=1-n.__2near/(n.__farPlusNear-u.z*n.__farMinusNear);
|
|
|
|
-o.setRGB(M,M,M)}else n instanceof THREE.MeshNormalMaterial&&o.setRGB(g(u.normalWorld.x),g(u.normalWorld.y),g(u.normalWorld.z));n.wireframe?J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+n.wireframe_linewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframe_linecap+"; stroke-linejoin: "+n.wireframe_linejoin):J.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+n.opacity);k.appendChild(J)}function c(l,v,A,u,n,F,L){J=e(X++);J.setAttribute("d",
|
|
|
|
-"M "+l.positionScreen.x+" "+l.positionScreen.y+" L "+v.positionScreen.x+" "+v.positionScreen.y+" L "+A.positionScreen.x+","+A.positionScreen.y+" L "+u.positionScreen.x+","+u.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)o.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(E){d.r=P.r;d.g=P.g;d.b=P.b;a(L,n,d);o.r=F.color.r*d.r;o.g=F.color.g*d.g;o.b=F.color.b*d.b;o.updateStyleString()}else o.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){M=
|
|
|
|
-1-F.__2near/(F.__farPlusNear-n.z*F.__farMinusNear);o.setRGB(M,M,M)}else F instanceof THREE.MeshNormalMaterial&&o.setRGB(g(n.normalWorld.x),g(n.normalWorld.y),g(n.normalWorld.z));F.wireframe?J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):J.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+F.opacity);k.appendChild(J)}
|
|
|
|
-function e(l){if(O[l]==null){O[l]=document.createElementNS("http://www.w3.org/2000/svg","path");ea==0&&O[l].setAttribute("shape-rendering","crispEdges");return O[l]}return O[l]}function g(l){return l<0?Math.min((1+l)*0.5,0.5):0.5+Math.min(l*0.5,0.5)}var f=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,p,x,t,q,y,z,H=new THREE.Rectangle,w=new THREE.Rectangle,E=false,o=new THREE.Color(16777215),d=new THREE.Color(16777215),P=new THREE.Color(0),aa=new THREE.Color(0),
|
|
|
|
-N=new THREE.Color(0),M,U=new THREE.Vector3,O=[],Y=[],W=[],J,X,ha,Z,ea=1;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(l){switch(l){case "high":ea=1;break;case "low":ea=0}};this.setSize=function(l,v){j=l;m=v;p=j/2;x=m/2;k.setAttribute("viewBox",-p+" "+-x+" "+j+" "+m);k.setAttribute("width",j);k.setAttribute("height",m);H.set(-p,-x,p,x)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(l,v){var A,
|
|
|
|
-u,n,F,L,G,D,C;this.autoClear&&this.clear();f=h.projectScene(l,v,this.sortElements);Z=ha=X=0;if(E=l.lights.length>0){D=l.lights;P.setRGB(0,0,0);aa.setRGB(0,0,0);N.setRGB(0,0,0);A=0;for(u=D.length;A<u;A++){n=D[A];F=n.color;if(n instanceof THREE.AmbientLight){P.r+=F.r;P.g+=F.g;P.b+=F.b}else if(n instanceof THREE.DirectionalLight){aa.r+=F.r;aa.g+=F.g;aa.b+=F.b}else if(n instanceof THREE.PointLight){N.r+=F.r;N.g+=F.g;N.b+=F.b}}}A=0;for(u=f.length;A<u;A++){D=f[A];w.empty();if(D instanceof THREE.RenderableParticle){t=
|
|
|
|
-D;t.x*=p;t.y*=-x;n=0;for(F=D.materials.length;n<F;n++)if(C=D.materials[n]){L=t;G=D;C=C;var R=ha++;if(Y[R]==null){Y[R]=document.createElementNS("http://www.w3.org/2000/svg","circle");ea==0&&Y[R].setAttribute("shape-rendering","crispEdges")}J=Y[R];J.setAttribute("cx",L.x);J.setAttribute("cy",L.y);J.setAttribute("r",G.scale.x*p);if(C instanceof THREE.ParticleCircleMaterial){if(E){d.r=P.r+aa.r+N.r;d.g=P.g+aa.g+N.g;d.b=P.b+aa.b+N.b;o.r=C.color.r*d.r;o.g=C.color.g*d.g;o.b=C.color.b*d.b;o.updateStyleString()}else o=
|
|
|
|
-C.color;J.setAttribute("style","fill: "+o.__styleString)}k.appendChild(J)}}else if(D instanceof THREE.RenderableLine){t=D.v1;q=D.v2;t.positionScreen.x*=p;t.positionScreen.y*=-x;q.positionScreen.x*=p;q.positionScreen.y*=-x;w.addPoint(t.positionScreen.x,t.positionScreen.y);w.addPoint(q.positionScreen.x,q.positionScreen.y);if(H.instersects(w)){n=0;for(F=D.materials.length;n<F;)if(C=D.materials[n++]){L=t;G=q;C=C;R=Z++;if(W[R]==null){W[R]=document.createElementNS("http://www.w3.org/2000/svg","line");ea==
|
|
|
|
-0&&W[R].setAttribute("shape-rendering","crispEdges")}J=W[R];J.setAttribute("x1",L.positionScreen.x);J.setAttribute("y1",L.positionScreen.y);J.setAttribute("x2",G.positionScreen.x);J.setAttribute("y2",G.positionScreen.y);if(C instanceof THREE.LineBasicMaterial){o.__styleString=C.color.__styleString;J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+C.linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.linecap+"; stroke-linejoin: "+C.linejoin);k.appendChild(J)}}}}else if(D instanceof
|
|
|
|
-THREE.RenderableFace3){t=D.v1;q=D.v2;y=D.v3;t.positionScreen.x*=p;t.positionScreen.y*=-x;q.positionScreen.x*=p;q.positionScreen.y*=-x;y.positionScreen.x*=p;y.positionScreen.y*=-x;w.addPoint(t.positionScreen.x,t.positionScreen.y);w.addPoint(q.positionScreen.x,q.positionScreen.y);w.addPoint(y.positionScreen.x,y.positionScreen.y);if(H.instersects(w)){n=0;for(F=D.meshMaterials.length;n<F;){C=D.meshMaterials[n++];if(C instanceof THREE.MeshFaceMaterial){L=0;for(G=D.faceMaterials.length;L<G;)(C=D.faceMaterials[L++])&&
|
|
|
|
-b(t,q,y,D,C,l)}else C&&b(t,q,y,D,C,l)}}}else if(D instanceof THREE.RenderableFace4){t=D.v1;q=D.v2;y=D.v3;z=D.v4;t.positionScreen.x*=p;t.positionScreen.y*=-x;q.positionScreen.x*=p;q.positionScreen.y*=-x;y.positionScreen.x*=p;y.positionScreen.y*=-x;z.positionScreen.x*=p;z.positionScreen.y*=-x;w.addPoint(t.positionScreen.x,t.positionScreen.y);w.addPoint(q.positionScreen.x,q.positionScreen.y);w.addPoint(y.positionScreen.x,y.positionScreen.y);w.addPoint(z.positionScreen.x,z.positionScreen.y);if(H.instersects(w)){n=
|
|
|
|
-0;for(F=D.meshMaterials.length;n<F;){C=D.meshMaterials[n++];if(C instanceof THREE.MeshFaceMaterial){L=0;for(G=D.faceMaterials.length;L<G;)(C=D.faceMaterials[L++])&&c(t,q,y,z,D,C,l)}else C&&c(t,q,y,z,D,C,l)}}}}}};
|
|
|
|
-THREE.WebGLRenderer=function(a){function b(l,v,A){var u,n,F,L=l.vertices,G=L.length,D=l.colors,C=D.length,R=l.__vertexArray,ba=l.__colorArray,ga=l.__sortArray,B=l.__dirtyVertices,K=l.__dirtyColors;if(A.sortParticles){Y.multiplySelf(A.matrixWorld);for(u=0;u<G;u++){n=L[u].position;X.copy(n);Y.multiplyVector3(X);ga[u]=[X.z,u]}ga.sort(function(I,Q){return Q[0]-I[0]});for(u=0;u<G;u++){n=L[ga[u][1]].position;F=u*3;R[F]=n.x;R[F+1]=n.y;R[F+2]=n.z}for(u=0;u<C;u++){F=u*3;color=D[ga[u][1]];ba[F]=color.r;ba[F+
|
|
|
|
-1]=color.g;ba[F+2]=color.b}}else{if(B)for(u=0;u<G;u++){n=L[u].position;F=u*3;R[F]=n.x;R[F+1]=n.y;R[F+2]=n.z}if(K)for(u=0;u<C;u++){color=D[u];F=u*3;ba[F]=color.r;ba[F+1]=color.g;ba[F+2]=color.b}}if(B||A.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,R,v)}if(K||A.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,ba,v)}}function c(l,v){l.fragment_shader=v.fragment_shader;l.vertex_shader=v.vertex_shader;l.uniforms=
|
|
|
|
-Uniforms.clone(v.uniforms)}function e(l,v){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=d.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=d.createBuffer();if(l.hasPos){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,l.positionArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(v.attributes.position);d.vertexAttribPointer(v.attributes.position,3,d.FLOAT,false,0,0)}if(l.hasNormal){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,
|
|
|
|
-l.normalArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(v.attributes.normal);d.vertexAttribPointer(v.attributes.normal,3,d.FLOAT,false,0,0)}d.drawArrays(d.TRIANGLES,0,l.count);l.count=0}function g(l){if(N!=l.doubleSided){l.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE);N=l.doubleSided}if(M!=l.flipSided){l.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW);M=l.flipSided}}function f(l){O[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,l.n44-l.n14);O[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+
|
|
|
|
-l.n14);O[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);O[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);O[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);O[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var v;for(l=0;l<5;l++){v=O[l];v.divideScalar(Math.sqrt(v.x*v.x+v.y*v.y+v.z*v.z))}}function h(l){for(var v=l.matrix,A=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),u=0;u<6;u++){l=O[u].x*v.n14+O[u].y*v.n24+O[u].z*v.n34+O[u].w;
|
|
|
|
-if(l<=A)return false}return true}function k(l,v){l.list[l.count]=v;l.count+=1}function j(l){var v,A,u=l.object,n=l.opaque,F=l.transparent;F.count=0;l=n.count=0;for(v=u.materials.length;l<v;l++){A=u.materials[l];A.opacity&&A.opacity<1||A.blending!=THREE.NormalBlending?k(F,A):k(n,A)}}function m(l){var v,A,u,n,F=l.object,L=l.buffer,G=l.opaque,D=l.transparent;D.count=0;l=G.count=0;for(u=F.materials.length;l<u;l++){v=F.materials[l];if(v instanceof THREE.MeshFaceMaterial){v=0;for(A=L.materials.length;v<
|
|
|
|
-A;v++)if(n=L.materials[v])n.opacity&&n.opacity<1||n.blending!=THREE.NormalBlending?k(D,n):k(G,n)}else{n=v;n.opacity&&n.opacity<1||n.blending!=THREE.NormalBlending?k(D,n):k(G,n)}}}function p(l){var v,A,u,n=l.children;v=0;for(A=n.length;v<A;v++){u=n[v];u.autoUpdateMatrix&&u.updateMatrix();u.matrixWorld.multiply(l.matrixWorld,u.matrix);p(u)}}function x(l,v){var A,u,n=v.children;A=0;for(u=n.length;A<u;A++){child=n[A];t(l,child,false);x(l,child)}}function t(l,v,A){var u,n,F;n=v.geometry;if(l.__webGLObjectsMap[v.id]==
|
|
|
|
-undefined){l.__webGLObjectsMap[v.id]={};v._modelViewMatrix=new THREE.Matrix4;v._normalMatrixArray=new Float32Array(9);v._modelViewMatrixArray=new Float32Array(16);v._objectMatrixArray=new Float32Array(16);v.matrix.flattenToArray(v._objectMatrixArray)}F=l.__webGLObjectsMap[v.id];objlist=l.__webGLObjects;if(v instanceof THREE.Mesh){for(u in n.geometryChunks){l=n.geometryChunks[u];if(!l.__webGLVertexBuffer){var L=l;L.__webGLVertexBuffer=d.createBuffer();L.__webGLNormalBuffer=d.createBuffer();L.__webGLTangentBuffer=
|
|
|
|
-d.createBuffer();L.__webGLColorBuffer=d.createBuffer();L.__webGLUVBuffer=d.createBuffer();L.__webGLUV2Buffer=d.createBuffer();L.__webGLFaceBuffer=d.createBuffer();L.__webGLLineBuffer=d.createBuffer();L=l;var G=v,D=void 0,C=void 0,R=0,ba=0,ga=0,B=G.geometry.faces,K=L.faces;D=0;for(C=K.length;D<C;D++){fi=K[D];face=B[fi];if(face instanceof THREE.Face3){R+=3;ba+=1;ga+=3}else if(face instanceof THREE.Face4){R+=4;ba+=2;ga+=4}}L.__vertexArray=new Float32Array(R*3);L.__normalArray=new Float32Array(R*3);L.__tangentArray=
|
|
|
|
-new Float32Array(R*4);L.__colorArray=new Float32Array(R*3);L.__uvArray=new Float32Array(R*2);L.__uv2Array=new Float32Array(R*2);L.__faceArray=new Uint16Array(ba*3);L.__lineArray=new Uint16Array(ga*2);C=D=L;G=G;R=void 0;B=void 0;var I=void 0,Q=void 0;I=void 0;K=false;R=0;for(B=G.materials.length;R<B;R++){I=G.materials[R];if(I instanceof THREE.MeshFaceMaterial){I=0;for(Q=C.materials.length;I<Q;I++)if(C.materials[I]&&C.materials[I].shading!=undefined&&C.materials[I].shading==THREE.SmoothShading){K=true;
|
|
|
|
-break}}else if(I&&I.shading!=undefined&&I.shading==THREE.SmoothShading){K=true;break}if(K)break}D.__needsSmoothNormals=K;L.__webGLFaceCount=ba*3;L.__webGLLineCount=ga*2;n.__dirtyVertices=true;n.__dirtyElements=true;n.__dirtyUvs=true;n.__dirtyNormals=true;n.__dirtyTangents=true;n.__dirtyColors=true}if(n.__dirtyVertices||n.__dirtyElements||n.__dirtyUvs||n.__dirtyNormals||n.__dirtyColors||n.__dirtyTangents){L=l;ba=d.DYNAMIC_DRAW;ga=void 0;D=void 0;var da=void 0,V=void 0,ka=void 0,pa=void 0,ua=void 0;
|
|
|
|
-da=void 0;var la=void 0,fa=void 0,ja=void 0,Fa=void 0;la=void 0;fa=void 0;ja=void 0;V=void 0;la=void 0;fa=void 0;ja=void 0;Fa=void 0;V=void 0;pa=void 0;ka=void 0;ua=void 0;var ta=Q=I=K=B=R=G=C=0,qa=0,sa=L.__vertexArray,Ma=L.__uvArray,Ga=L.__uv2Array,za=L.__normalArray,ma=L.__tangentArray,ra=L.__colorArray,Da=L.__faceArray,xa=L.__lineArray,Oa=L.__needsSmoothNormals,ya=v.geometry,Pa=ya.__dirtyVertices,oa=ya.__dirtyElements,Ba=ya.__dirtyUvs,Ia=ya.__dirtyNormals,Na=ya.__dirtyTangents,Qa=ya.__dirtyColors,
|
|
|
|
-wa=ya.vertices,S=L.faces,ia=ya.faces,ca=ya.uvs,T=ya.uvs2,$=ya.colors;ga=0;for(D=S.length;ga<D;ga++){da=S[ga];V=ia[da];ua=ca[da];da=T[da];ka=V.vertexNormals;pa=V.normal;if(V instanceof THREE.Face3){if(Pa){la=wa[V.a].position;fa=wa[V.b].position;ja=wa[V.c].position;sa[G]=la.x;sa[G+1]=la.y;sa[G+2]=la.z;sa[G+3]=fa.x;sa[G+4]=fa.y;sa[G+5]=fa.z;sa[G+6]=ja.x;sa[G+7]=ja.y;sa[G+8]=ja.z;G+=9}if(Qa&&$.length){la=$[V.a];fa=$[V.b];ja=$[V.c];ra[qa]=la.r;ra[qa+1]=la.g;ra[qa+2]=la.b;ra[qa+3]=fa.r;ra[qa+4]=fa.g;ra[qa+
|
|
|
|
-5]=fa.b;ra[qa+6]=ja.r;ra[qa+7]=ja.g;ra[qa+8]=ja.b;qa+=9}if(Na&&ya.hasTangents){la=wa[V.a].tangent;fa=wa[V.b].tangent;ja=wa[V.c].tangent;ma[Q]=la.x;ma[Q+1]=la.y;ma[Q+2]=la.z;ma[Q+3]=la.w;ma[Q+4]=fa.x;ma[Q+5]=fa.y;ma[Q+6]=fa.z;ma[Q+7]=fa.w;ma[Q+8]=ja.x;ma[Q+9]=ja.y;ma[Q+10]=ja.z;ma[Q+11]=ja.w;Q+=12}if(Ia)if(ka.length==3&&Oa)for(V=0;V<3;V++){pa=ka[V];za[I]=pa.x;za[I+1]=pa.y;za[I+2]=pa.z;I+=3}else for(V=0;V<3;V++){za[I]=pa.x;za[I+1]=pa.y;za[I+2]=pa.z;I+=3}if(Ba&&ua)for(V=0;V<3;V++){ka=ua[V];Ma[R]=ka.u;
|
|
|
|
-Ma[R+1]=ka.v;R+=2}if(Ba&&da)for(V=0;V<3;V++){ua=da[V];Ga[B]=ua.u;Ga[B+1]=ua.v;B+=2}if(oa){Da[K]=C;Da[K+1]=C+1;Da[K+2]=C+2;K+=3;xa[ta]=C;xa[ta+1]=C+1;xa[ta+2]=C;xa[ta+3]=C+2;xa[ta+4]=C+1;xa[ta+5]=C+2;ta+=6;C+=3}}else if(V instanceof THREE.Face4){if(Pa){la=wa[V.a].position;fa=wa[V.b].position;ja=wa[V.c].position;Fa=wa[V.d].position;sa[G]=la.x;sa[G+1]=la.y;sa[G+2]=la.z;sa[G+3]=fa.x;sa[G+4]=fa.y;sa[G+5]=fa.z;sa[G+6]=ja.x;sa[G+7]=ja.y;sa[G+8]=ja.z;sa[G+9]=Fa.x;sa[G+10]=Fa.y;sa[G+11]=Fa.z;G+=12}if(Qa&&
|
|
|
|
-$.length){la=$[V.a];fa=$[V.b];ja=$[V.c];Fa=$[V.d];ra[qa]=la.r;ra[qa+1]=la.g;ra[qa+2]=la.b;ra[qa+3]=fa.r;ra[qa+4]=fa.g;ra[qa+5]=fa.b;ra[qa+6]=ja.r;ra[qa+7]=ja.g;ra[qa+8]=ja.b;ra[qa+9]=Fa.r;ra[qa+10]=Fa.g;ra[qa+11]=Fa.b;qa+=12}if(Na&&ya.hasTangents){la=wa[V.a].tangent;fa=wa[V.b].tangent;ja=wa[V.c].tangent;V=wa[V.d].tangent;ma[Q]=la.x;ma[Q+1]=la.y;ma[Q+2]=la.z;ma[Q+3]=la.w;ma[Q+4]=fa.x;ma[Q+5]=fa.y;ma[Q+6]=fa.z;ma[Q+7]=fa.w;ma[Q+8]=ja.x;ma[Q+9]=ja.y;ma[Q+10]=ja.z;ma[Q+11]=ja.w;ma[Q+12]=V.x;ma[Q+13]=
|
|
|
|
-V.y;ma[Q+14]=V.z;ma[Q+15]=V.w;Q+=16}if(Ia)if(ka.length==4&&Oa)for(V=0;V<4;V++){pa=ka[V];za[I]=pa.x;za[I+1]=pa.y;za[I+2]=pa.z;I+=3}else for(V=0;V<4;V++){za[I]=pa.x;za[I+1]=pa.y;za[I+2]=pa.z;I+=3}if(Ba&&ua)for(V=0;V<4;V++){ka=ua[V];Ma[R]=ka.u;Ma[R+1]=ka.v;R+=2}if(Ba&&da)for(V=0;V<4;V++){ua=da[V];Ga[B]=ua.u;Ga[B+1]=ua.v;B+=2}if(oa){Da[K]=C;Da[K+1]=C+1;Da[K+2]=C+2;Da[K+3]=C;Da[K+4]=C+2;Da[K+5]=C+3;K+=6;xa[ta]=C;xa[ta+1]=C+1;xa[ta+2]=C;xa[ta+3]=C+3;xa[ta+4]=C+1;xa[ta+5]=C+2;xa[ta+6]=C+2;xa[ta+7]=C+3;ta+=
|
|
|
|
-8;C+=4}}}if(Pa){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,sa,ba)}if(Qa&&$.length){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,ra,ba)}if(Ia){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,za,ba)}if(Na&&ya.hasTangents){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLTangentBuffer);d.bufferData(d.ARRAY_BUFFER,ma,ba)}if(Ba&&R>0){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLUVBuffer);d.bufferData(d.ARRAY_BUFFER,Ma,ba)}if(Ba&&
|
|
|
|
-B>0){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Ga,ba)}if(oa){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,L.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,Da,ba);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,L.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,xa,ba)}}q(objlist,F,u,l,v,A)}n.__dirtyVertices=false;n.__dirtyElements=false;n.__dirtyUvs=false;n.__dirtyNormals=false;n.__dirtyTangents=false;n.__dirtyColors=false}else if(v instanceof THREE.Line){if(!n.__webGLVertexBuffer){n.__webGLVertexBuffer=
|
|
|
|
-d.createBuffer();n.__webGLColorBuffer=d.createBuffer();u=n.vertices.length;n.__vertexArray=new Float32Array(u*3);n.__colorArray=new Float32Array(u*3);n.__webGLLineCount=u;n.__dirtyVertices=true;n.__dirtyColors=true}if(n.__dirtyVertices||n.__dirtyColors){u=d.DYNAMIC_DRAW;G=n.vertices;L=n.colors;R=G.length;ba=L.length;B=n.__vertexArray;ga=n.__colorArray;K=n.__dirtyColors;if(n.__dirtyVertices){for(D=0;D<R;D++){C=G[D].position;l=D*3;B[l]=C.x;B[l+1]=C.y;B[l+2]=C.z}d.bindBuffer(d.ARRAY_BUFFER,n.__webGLVertexBuffer);
|
|
|
|
-d.bufferData(d.ARRAY_BUFFER,B,u)}if(K){for(D=0;D<ba;D++){color=L[D];l=D*3;ga[l]=color.r;ga[l+1]=color.g;ga[l+2]=color.b}d.bindBuffer(d.ARRAY_BUFFER,n.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,ga,u)}}q(objlist,F,0,n,v,A);n.__dirtyVertices=false;n.__dirtyColors=false}else if(v instanceof THREE.ParticleSystem){if(!n.__webGLVertexBuffer){n.__webGLVertexBuffer=d.createBuffer();n.__webGLColorBuffer=d.createBuffer();u=n.vertices.length;n.__vertexArray=new Float32Array(u*3);n.__colorArray=new Float32Array(u*
|
|
|
|
-3);n.__sortArray=[];n.__webGLParticleCount=u;n.__dirtyVertices=true;n.__dirtyColors=true}if(n.__dirtyVertices||n.__dirtyColors||v.sortParticles)b(n,d.DYNAMIC_DRAW,v,camera);q(objlist,F,0,n,v,A);n.__dirtyVertices=false;n.__dirtyColors=false}else if(v instanceof THREE.MarchingCubes)if(F[0]==undefined){l.__webGLObjectsImmediate.push({object:v,opaque:{list:[],count:0},transparent:{list:[],count:0},root:A});F[0]=1}}function q(l,v,A,u,n,F){if(v[A]==undefined){l.push({buffer:u,object:n,opaque:{list:[],count:0},
|
|
|
|
-transparent:{list:[],count:0},root:F});v[A]=1}}function y(l,v){l._modelViewMatrix.multiplyToArray(v.matrix,l.matrixWorld,l._modelViewMatrixArray);l._normalMatrix=THREE.Matrix4.makeInvert3x3(l._modelViewMatrix).transposeIntoArray(l._normalMatrixArray)}function z(l){if(l!=U){switch(l){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE);break;case THREE.SubtractiveBlending:d.blendFunc(d.DST_COLOR,d.ZERO);break;case THREE.BillboardBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA,
|
|
|
|
-d.ONE_MINUS_SRC_ALPHA);break;default:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA)}U=l}}function H(l,v){if(l&&!l.__webGLFramebuffer){l.__webGLFramebuffer=d.createFramebuffer();l.__webGLRenderbuffer=d.createRenderbuffer();l.__webGLTexture=d.createTexture();d.bindRenderbuffer(d.RENDERBUFFER,l.__webGLRenderbuffer);d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,l.width,l.height);d.bindTexture(d.TEXTURE_2D,l.__webGLTexture);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,
|
|
|
|
-E(l.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,E(l.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,E(l.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,E(l.min_filter));d.texImage2D(d.TEXTURE_2D,0,E(l.format),l.width,l.height,0,E(l.format),E(l.type),null);d.bindFramebuffer(d.FRAMEBUFFER,l.__webGLFramebuffer);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,l.__webGLTexture,0);d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.RENDERBUFFER,
|
|
|
|
-l.__webGLRenderbuffer);d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,null)}var A,u,n;if(l){A=l.__webGLFramebuffer;u=l.width;n=l.height}else{A=null;u=o.width;n=o.height}if(A!=aa){d.bindFramebuffer(d.FRAMEBUFFER,A);d.viewport(0,0,u,n);v&&d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT);aa=A}}function w(l,v){var A;if(l=="fragment")A=d.createShader(d.FRAGMENT_SHADER);else if(l=="vertex")A=d.createShader(d.VERTEX_SHADER);d.shaderSource(A,v);d.compileShader(A);
|
|
|
|
-if(!d.getShaderParameter(A,d.COMPILE_STATUS)){alert(d.getShaderInfoLog(A));return null}return A}function E(l){switch(l){case THREE.RepeatWrapping:return d.REPEAT;case THREE.ClampToEdgeWrapping:return d.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return d.MIRRORED_REPEAT;case THREE.NearestFilter:return d.NEAREST;case THREE.NearestMipMapNearestFilter:return d.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return d.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return d.LINEAR;case THREE.LinearMipMapNearestFilter:return d.LINEAR_MIPMAP_NEAREST;
|
|
|
|
-case THREE.LinearMipMapLinearFilter:return d.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return d.BYTE;case THREE.UnsignedByteType:return d.UNSIGNED_BYTE;case THREE.ShortType:return d.SHORT;case THREE.UnsignedShortType:return d.UNSIGNED_SHORT;case THREE.IntType:return d.INT;case THREE.UnsignedShortType:return d.UNSIGNED_INT;case THREE.FloatType:return d.FLOAT;case THREE.AlphaFormat:return d.ALPHA;case THREE.RGBFormat:return d.RGB;case THREE.RGBAFormat:return d.RGBA;case THREE.LuminanceFormat:return d.LUMINANCE;
|
|
|
|
-case THREE.LuminanceAlphaFormat:return d.LUMINANCE_ALPHA}return 0}var o=document.createElement("canvas"),d,P=null,aa=null,N=null,M=null,U=null,O=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Y=new THREE.Matrix4,W=new Float32Array(16),J=new Float32Array(16),X=new THREE.Vector4,ha=true,Z=new THREE.Color(0),ea=0;if(a){if(a.antialias!==undefined)ha=a.antialias;a.clearColor!==undefined&&Z.setHex(a.clearColor);if(a.clearAlpha!==undefined)ea=
|
|
|
|
-a.clearAlpha}this.domElement=o;this.autoClear=true;(function(l,v,A){try{d=o.getContext("experimental-webgl",{antialias:l})}catch(u){console.log(u)}if(!d){alert("WebGL not supported");throw"cannot create webgl context";}d.clearColor(0,0,0,1);d.clearDepth(1);d.enable(d.DEPTH_TEST);d.depthFunc(d.LEQUAL);d.frontFace(d.CCW);d.cullFace(d.BACK);d.enable(d.CULL_FACE);d.enable(d.BLEND);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA);d.clearColor(v.r,v.g,v.b,A);_cullEnabled=true})(ha,Z,ea);this.context=d;this.lights=
|
|
|
|
-{ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,v){o.width=l;o.height=v;d.viewport(0,0,o.width,o.height)};this.setClearColorHex=function(l,v){var A=new THREE.Color(l);d.clearColor(A.r,A.g,A.b,v)};this.setClearColor=function(l,v){d.clearColor(l.r,l.g,l.b,v)};this.clear=function(){d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT)};this.setupLights=function(l,v){var A,u,n,F=0,L=0,G=0,D,C,R,ba=this.lights,ga=ba.directional.colors,
|
|
|
|
-B=ba.directional.positions,K=ba.point.colors,I=ba.point.positions,Q=0,da=0;A=n=n=0;for(u=v.length;A<u;A++){n=v[A];D=n.color;C=n.position;R=n.intensity;if(n instanceof THREE.AmbientLight){F+=D.r;L+=D.g;G+=D.b}else if(n instanceof THREE.DirectionalLight){n=Q*3;ga[n]=D.r*R;ga[n+1]=D.g*R;ga[n+2]=D.b*R;B[n]=C.x;B[n+1]=C.y;B[n+2]=C.z;Q+=1}else if(n instanceof THREE.PointLight){n=da*3;K[n]=D.r*R;K[n+1]=D.g*R;K[n+2]=D.b*R;I[n]=C.x;I[n+1]=C.y;I[n+2]=C.z;da+=1}}for(A=Q*3;A<ga.length;A++)ga[A]=0;for(A=da*3;A<
|
|
|
|
-K.length;A++)K[A]=0;ba.point.length=da;ba.directional.length=Q;ba.ambient[0]=F;ba.ambient[1]=L;ba.ambient[2]=G};this.initMaterial=function(l,v,A){var u,n;if(l instanceof THREE.MeshDepthMaterial)c(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)c(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)c(l,THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)c(l,THREE.ShaderLib.phong);
|
|
|
|
-else if(l instanceof THREE.LineBasicMaterial)c(l,THREE.ShaderLib.basic);else l instanceof THREE.ParticleBasicMaterial&&c(l,THREE.ShaderLib.particle_basic);var F,L,G,D;n=G=D=0;for(F=v.length;n<F;n++){L=v[n];L instanceof THREE.DirectionalLight&&G++;L instanceof THREE.PointLight&&D++}if(D+G<=4){v=G;D=D}else{v=Math.ceil(4*G/(D+G));D=4-v}n={directional:v,point:D};D=l.fragment_shader;v=l.vertex_shader;F={fog:A,map:l.map,env_map:l.env_map,light_map:l.light_map,vertex_colors:l.vertex_colors,maxDirLights:n.directional,
|
|
|
|
-maxPointLights:n.point};A=d.createProgram();n=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+F.maxDirLights,"#define MAX_POINT_LIGHTS "+F.maxPointLights,F.fog?"#define USE_FOG":"",F.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",F.map?"#define USE_MAP":"",F.env_map?"#define USE_ENVMAP":"",F.light_map?"#define USE_LIGHTMAP":"",F.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");F=[d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
|
|
|
|
-0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+F.maxDirLights,"#define MAX_POINT_LIGHTS "+F.maxPointLights,F.map?"#define USE_MAP":"",F.env_map?"#define USE_ENVMAP":"",F.light_map?"#define USE_LIGHTMAP":"",F.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");
|
|
|
|
-d.attachShader(A,w("fragment",n+D));d.attachShader(A,w("vertex",F+v));d.linkProgram(A);d.getProgramParameter(A,d.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+d.getProgramParameter(A,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");A.uniforms={};A.attributes={};l.program=A;A=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(u in l.uniforms)A.push(u);u=l.program;D=0;for(v=A.length;D<v;D++){n=A[D];u.uniforms[n]=d.getUniformLocation(u,
|
|
|
|
-n)}l=l.program;u=["position","normal","uv","uv2","tangent","color"];A=0;for(D=u.length;A<D;A++){v=u[A];l.attributes[v]=d.getAttribLocation(l,v)}};this.setProgram=function(l,v,A,u,n){u.program||this.initMaterial(u,v,A);var F=u.program,L=F.uniforms,G=u.uniforms;if(F!=P){d.useProgram(F);P=F;d.uniformMatrix4fv(L.projectionMatrix,false,W)}if(A&&(u instanceof THREE.MeshBasicMaterial||u instanceof THREE.MeshLambertMaterial||u instanceof THREE.MeshPhongMaterial||u instanceof THREE.LineBasicMaterial||u instanceof
|
|
|
|
-THREE.ParticleBasicMaterial)){G.fogColor.value.setHex(A.color.hex);if(A instanceof THREE.Fog){G.fogNear.value=A.near;G.fogFar.value=A.far}else if(A instanceof THREE.FogExp2)G.fogDensity.value=A.density}if(u instanceof THREE.MeshPhongMaterial||u instanceof THREE.MeshLambertMaterial){this.setupLights(F,v);v=this.lights;G.enableLighting.value=v.directional.length+v.point.length;G.ambientLightColor.value=v.ambient;G.directionalLightColor.value=v.directional.colors;G.directionalLightDirection.value=v.directional.positions;
|
|
|
|
-G.pointLightColor.value=v.point.colors;G.pointLightPosition.value=v.point.positions}if(u instanceof THREE.MeshBasicMaterial||u instanceof THREE.MeshLambertMaterial||u instanceof THREE.MeshPhongMaterial){G.diffuse.value.setRGB(u.color.r*u.opacity,u.color.g*u.opacity,u.color.b*u.opacity);G.opacity.value=u.opacity;G.map.texture=u.map;G.light_map.texture=u.light_map;G.env_map.texture=u.env_map;G.reflectivity.value=u.reflectivity;G.refraction_ratio.value=u.refraction_ratio;G.combine.value=u.combine;G.useRefract.value=
|
|
|
|
-u.env_map&&u.env_map.mapping instanceof THREE.CubeRefractionMapping}if(u instanceof THREE.LineBasicMaterial){G.diffuse.value.setRGB(u.color.r*u.opacity,u.color.g*u.opacity,u.color.b*u.opacity);G.opacity.value=u.opacity}else if(u instanceof THREE.ParticleBasicMaterial){G.psColor.value.setRGB(u.color.r*u.opacity,u.color.g*u.opacity,u.color.b*u.opacity);G.opacity.value=u.opacity;G.size.value=u.size;G.map.texture=u.map}else if(u instanceof THREE.MeshPhongMaterial){G.ambient.value.setRGB(u.ambient.r,u.ambient.g,
|
|
|
|
-u.ambient.b);G.specular.value.setRGB(u.specular.r,u.specular.g,u.specular.b);G.shininess.value=u.shininess}else if(u instanceof THREE.MeshDepthMaterial){G.mNear.value=l.near;G.mFar.value=l.far;G.opacity.value=u.opacity}else if(u instanceof THREE.MeshNormalMaterial)G.opacity.value=u.opacity;var D,C,R;for(D in G)if(R=F.uniforms[D]){A=G[D];C=A.type;v=A.value;if(C=="i")d.uniform1i(R,v);else if(C=="f")d.uniform1f(R,v);else if(C=="fv1")d.uniform1fv(R,v);else if(C=="fv")d.uniform3fv(R,v);else if(C=="v2")d.uniform2f(R,
|
|
|
|
-v.x,v.y);else if(C=="v3")d.uniform3f(R,v.x,v.y,v.z);else if(C=="c")d.uniform3f(R,v.r,v.g,v.b);else if(C=="t"){d.uniform1i(R,v);if(A=A.texture)if(A.image instanceof Array&&A.image.length==6){A=A;v=v;if(A.image.length==6){if(!A.image.__webGLTextureCube&&!A.image.__cubeMapInitialized&&A.image.loadCount==6){A.image.__webGLTextureCube=d.createTexture();d.bindTexture(d.TEXTURE_CUBE_MAP,A.image.__webGLTextureCube);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_CUBE_MAP,
|
|
|
|
-d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MAG_FILTER,d.LINEAR);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MIN_FILTER,d.LINEAR_MIPMAP_LINEAR);for(C=0;C<6;++C)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+C,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,A.image[C]);d.generateMipmap(d.TEXTURE_CUBE_MAP);d.bindTexture(d.TEXTURE_CUBE_MAP,null);A.image.__cubeMapInitialized=true}d.activeTexture(d.TEXTURE0+v);d.bindTexture(d.TEXTURE_CUBE_MAP,A.image.__webGLTextureCube)}}else{A=A;v=v;if(!A.__webGLTexture&&
|
|
|
|
-A.image.loaded){A.__webGLTexture=d.createTexture();d.bindTexture(d.TEXTURE_2D,A.__webGLTexture);d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,A.image);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,E(A.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,E(A.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,E(A.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,E(A.min_filter));d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}d.activeTexture(d.TEXTURE0+
|
|
|
|
-v);d.bindTexture(d.TEXTURE_2D,A.__webGLTexture)}}}d.uniformMatrix4fv(L.modelViewMatrix,false,n._modelViewMatrixArray);d.uniformMatrix3fv(L.normalMatrix,false,n._normalMatrixArray);if(u instanceof THREE.MeshShaderMaterial||u instanceof THREE.MeshPhongMaterial||u.env_map)d.uniform3f(L.cameraPosition,l.position.x,l.position.y,l.position.z);if(u instanceof THREE.MeshShaderMaterial||u.env_map)d.uniformMatrix4fv(L.objectMatrix,false,n._objectMatrixArray);if(u instanceof THREE.MeshPhongMaterial||u instanceof
|
|
|
|
-THREE.MeshLambertMaterial||u instanceof THREE.MeshShaderMaterial)d.uniformMatrix4fv(L.viewMatrix,false,J);return F};this.renderBuffer=function(l,v,A,u,n,F){l=this.setProgram(l,v,A,u,F).attributes;d.bindBuffer(d.ARRAY_BUFFER,n.__webGLVertexBuffer);d.vertexAttribPointer(l.position,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.position);if(l.color>=0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLColorBuffer);d.vertexAttribPointer(l.color,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.color)}if(l.normal>=
|
|
|
|
|
|
+THREE.Projector=function(){function a(O,K){return K.z-O.z}function b(O,K){var X=0,Q=1,U=O.z+O.w,V=K.z+K.w,H=-O.z+O.w,Y=-K.z+K.w;if(U>=0&&V>=0&&H>=0&&Y>=0)return true;else if(U<0&&V<0||H<0&&Y<0)return false;else{if(U<0)X=Math.max(X,U/(U-V));else if(V<0)Q=Math.min(Q,U/(U-V));if(H<0)X=Math.max(X,H/(H-Y));else if(Y<0)Q=Math.min(Q,H/(H-Y));if(Q<X)return false;else{O.lerpSelf(K,X);K.lerpSelf(O,1-Q);return true}}}var c,e,g=[],f,h,k,j=[],m,q,w=[],u,t,x=[],A=new THREE.Vector4,E=new THREE.Vector4,v=new THREE.Matrix4,
|
|
|
|
+F=new THREE.Matrix4,p=[],M=new THREE.Vector4,d=new THREE.Vector4,aa;this.projectObjects=function(O,K,X){var Q=[],U,V;e=0;v.multiply(K.projectionMatrix,K.matrix);p[0]=new THREE.Vector4(v.n41-v.n11,v.n42-v.n12,v.n43-v.n13,v.n44-v.n14);p[1]=new THREE.Vector4(v.n41+v.n11,v.n42+v.n12,v.n43+v.n13,v.n44+v.n14);p[2]=new THREE.Vector4(v.n41+v.n21,v.n42+v.n22,v.n43+v.n23,v.n44+v.n24);p[3]=new THREE.Vector4(v.n41-v.n21,v.n42-v.n22,v.n43-v.n23,v.n44-v.n24);p[4]=new THREE.Vector4(v.n41-v.n31,v.n42-v.n32,v.n43-
|
|
|
|
+v.n33,v.n44-v.n34);p[5]=new THREE.Vector4(v.n41+v.n31,v.n42+v.n32,v.n43+v.n33,v.n44+v.n34);K=0;for(U=p.length;K<U;K++){V=p[K];V.divideScalar(Math.sqrt(V.x*V.x+V.y*V.y+V.z*V.z))}U=O.objects;O=0;for(K=U.length;O<K;O++){V=U[O];var H;if(!(H=!V.visible)){if(H=V instanceof THREE.Mesh){a:{H=void 0;for(var Y=V.position,ea=-V.geometry.boundingSphere.radius*Math.max(V.scale.x,Math.max(V.scale.y,V.scale.z)),Z=0;Z<6;Z++){H=p[Z].x*Y.x+p[Z].y*Y.y+p[Z].z*Y.z+p[Z].w;if(H<=ea){H=false;break a}}H=true}H=!H}H=H}if(!H){c=
|
|
|
|
+g[e]=g[e]||new THREE.RenderableObject;A.copy(V.position);v.multiplyVector3(A);c.object=V;c.z=A.z;Q.push(c);e++}}X&&Q.sort(a);return Q};this.projectScene=function(O,K,X){var Q=[],U=K.near,V=K.far,H,Y,ea,Z,fa,ia,l,y,B,o,n,N,G,z,I,D;k=q=t=0;K.autoUpdateMatrix&&K.updateMatrix();v.multiply(K.projectionMatrix,K.matrix);ia=this.projectObjects(O,K,true);O=0;for(H=ia.length;O<H;O++){l=ia[O].object;if(l.visible){l.autoUpdateMatrix&&l.updateMatrix();y=l.matrix;B=l.rotationMatrix;o=l.materials;n=l.overdraw;if(l instanceof
|
|
|
|
+THREE.Mesh){N=l.geometry;G=N.vertices;Y=0;for(ea=G.length;Y<ea;Y++){z=G[Y];z.positionWorld.copy(z.position);y.multiplyVector3(z.positionWorld);Z=z.positionScreen;Z.copy(z.positionWorld);v.multiplyVector4(Z);Z.x/=Z.w;Z.y/=Z.w;z.__visible=Z.z>U&&Z.z<V}N=N.faces;Y=0;for(ea=N.length;Y<ea;Y++){z=N[Y];if(z instanceof THREE.Face3){Z=G[z.a];fa=G[z.b];I=G[z.c];if(Z.__visible&&fa.__visible&&I.__visible)if(l.doubleSided||l.flipSided!=(I.positionScreen.x-Z.positionScreen.x)*(fa.positionScreen.y-Z.positionScreen.y)-
|
|
|
|
+(I.positionScreen.y-Z.positionScreen.y)*(fa.positionScreen.x-Z.positionScreen.x)<0){f=j[k]=j[k]||new THREE.RenderableFace3;f.v1.positionWorld.copy(Z.positionWorld);f.v2.positionWorld.copy(fa.positionWorld);f.v3.positionWorld.copy(I.positionWorld);f.v1.positionScreen.copy(Z.positionScreen);f.v2.positionScreen.copy(fa.positionScreen);f.v3.positionScreen.copy(I.positionScreen);f.normalWorld.copy(z.normal);B.multiplyVector3(f.normalWorld);f.centroidWorld.copy(z.centroid);y.multiplyVector3(f.centroidWorld);
|
|
|
|
+f.centroidScreen.copy(f.centroidWorld);v.multiplyVector3(f.centroidScreen);I=z.vertexNormals;aa=f.vertexNormalsWorld;Z=0;for(fa=I.length;Z<fa;Z++){D=aa[Z]=aa[Z]||new THREE.Vector3;D.copy(I[Z]);B.multiplyVector3(D)}f.z=f.centroidScreen.z;f.meshMaterials=o;f.faceMaterials=z.materials;f.overdraw=n;if(l.geometry.uvs[Y]){f.uvs[0]=l.geometry.uvs[Y][0];f.uvs[1]=l.geometry.uvs[Y][1];f.uvs[2]=l.geometry.uvs[Y][2]}Q.push(f);k++}}else if(z instanceof THREE.Face4){Z=G[z.a];fa=G[z.b];I=G[z.c];D=G[z.d];if(Z.__visible&&
|
|
|
|
+fa.__visible&&I.__visible&&D.__visible)if(l.doubleSided||l.flipSided!=((D.positionScreen.x-Z.positionScreen.x)*(fa.positionScreen.y-Z.positionScreen.y)-(D.positionScreen.y-Z.positionScreen.y)*(fa.positionScreen.x-Z.positionScreen.x)<0||(fa.positionScreen.x-I.positionScreen.x)*(D.positionScreen.y-I.positionScreen.y)-(fa.positionScreen.y-I.positionScreen.y)*(D.positionScreen.x-I.positionScreen.x)<0)){f=j[k]=j[k]||new THREE.RenderableFace3;f.v1.positionWorld.copy(Z.positionWorld);f.v2.positionWorld.copy(fa.positionWorld);
|
|
|
|
+f.v3.positionWorld.copy(D.positionWorld);f.v1.positionScreen.copy(Z.positionScreen);f.v2.positionScreen.copy(fa.positionScreen);f.v3.positionScreen.copy(D.positionScreen);f.normalWorld.copy(z.normal);B.multiplyVector3(f.normalWorld);f.centroidWorld.copy(z.centroid);y.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);v.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=o;f.faceMaterials=z.materials;f.overdraw=n;if(l.geometry.uvs[Y]){f.uvs[0]=l.geometry.uvs[Y][0];
|
|
|
|
+f.uvs[1]=l.geometry.uvs[Y][1];f.uvs[2]=l.geometry.uvs[Y][3]}Q.push(f);k++;h=j[k]=j[k]||new THREE.RenderableFace3;h.v1.positionWorld.copy(fa.positionWorld);h.v2.positionWorld.copy(I.positionWorld);h.v3.positionWorld.copy(D.positionWorld);h.v1.positionScreen.copy(fa.positionScreen);h.v2.positionScreen.copy(I.positionScreen);h.v3.positionScreen.copy(D.positionScreen);h.normalWorld.copy(f.normalWorld);h.centroidWorld.copy(f.centroidWorld);h.centroidScreen.copy(f.centroidScreen);h.z=h.centroidScreen.z;
|
|
|
|
+h.meshMaterials=o;h.faceMaterials=z.materials;h.overdraw=n;if(l.geometry.uvs[Y]){h.uvs[0]=l.geometry.uvs[Y][1];h.uvs[1]=l.geometry.uvs[Y][2];h.uvs[2]=l.geometry.uvs[Y][3]}Q.push(h);k++}}}}else if(l instanceof THREE.Line){F.multiply(v,y);G=l.geometry.vertices;z=G[0];z.positionScreen.copy(z.position);F.multiplyVector4(z.positionScreen);Y=1;for(ea=G.length;Y<ea;Y++){Z=G[Y];Z.positionScreen.copy(Z.position);F.multiplyVector4(Z.positionScreen);fa=G[Y-1];M.copy(Z.positionScreen);d.copy(fa.positionScreen);
|
|
|
|
+if(b(M,d)){M.multiplyScalar(1/M.w);d.multiplyScalar(1/d.w);m=w[q]=w[q]||new THREE.RenderableLine;m.v1.positionScreen.copy(M);m.v2.positionScreen.copy(d);m.z=Math.max(M.z,d.z);m.materials=l.materials;Q.push(m);q++}}}else if(l instanceof THREE.Particle){E.set(l.position.x,l.position.y,l.position.z,1);v.multiplyVector4(E);E.z/=E.w;if(E.z>0&&E.z<1){u=x[t]=x[t]||new THREE.RenderableParticle;u.x=E.x/E.w;u.y=E.y/E.w;u.z=E.z;u.rotation=l.rotation.z;u.scale.x=l.scale.x*Math.abs(u.x-(E.x+K.projectionMatrix.n11)/
|
|
|
|
+(E.w+K.projectionMatrix.n14));u.scale.y=l.scale.y*Math.abs(u.y-(E.y+K.projectionMatrix.n22)/(E.w+K.projectionMatrix.n24));u.materials=l.materials;Q.push(u);t++}}}}X&&Q.sort(a);return Q};this.unprojectVector=function(O,K){var X=THREE.Matrix4.makeInvert(K.matrix);X.multiplySelf(THREE.Matrix4.makeInvert(K.projectionMatrix));X.multiplyVector3(O);return O}};
|
|
|
|
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,g,f;this.domElement=document.createElement("div");this.setSize=function(h,k){c=h;e=k;g=c/2;f=e/2};this.render=function(h,k){var j,m,q,w,u,t,x,A;a=b.projectScene(h,k);j=0;for(m=a.length;j<m;j++){u=a[j];if(u instanceof THREE.RenderableParticle){x=u.x*g+g;A=u.y*f+f;q=0;for(w=u.material.length;q<w;q++){t=u.material[q];if(t instanceof THREE.ParticleDOMMaterial){t=t.domElement;t.style.left=x+"px";t.style.top=A+"px"}}}}}};
|
|
|
|
+THREE.CanvasRenderer=function(){function a(ga){if(u!=ga)m.globalAlpha=u=ga}function b(ga){if(t!=ga){switch(ga){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}t=ga}}var c=null,e=new THREE.Projector,g=document.createElement("canvas"),f,h,k,j,m=g.getContext("2d"),q=new THREE.Color(0),w=0,u=1,t=0,x=null,A=null,E=1,v,F,p,M,d,aa,O,K,X,Q=new THREE.Color,
|
|
|
|
+U=new THREE.Color,V=new THREE.Color,H=new THREE.Color,Y=new THREE.Color,ea,Z,fa,ia,l,y,B,o,n,N=new THREE.Rectangle,G=new THREE.Rectangle,z=new THREE.Rectangle,I=false,D=new THREE.Color,$=new THREE.Color,da=new THREE.Color,C=new THREE.Color,L=Math.PI*2,J=new THREE.Vector3,R,W,la,S,ta,sa,va=16;R=document.createElement("canvas");R.width=R.height=2;W=R.getContext("2d");W.fillStyle="rgba(0,0,0,1)";W.fillRect(0,0,2,2);la=W.getImageData(0,0,2,2);S=la.data;ta=document.createElement("canvas");ta.width=ta.height=
|
|
|
|
+va;sa=ta.getContext("2d");sa.translate(-va/2,-va/2);sa.scale(va,va);va--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ga,ka){f=ga;h=ka;k=f/2;j=h/2;g.width=f;g.height=h;N.set(-k,-j,k,j);u=1;t=0;A=x=null;E=1};this.setClearColor=function(ga,ka){q=ga;w=ka;G.set(-k,-j,k,j);m.setTransform(1,0,0,-1,k,j);this.clear()};this.setClearColorHex=function(ga,ka){q.setHex(ga);w=ka;G.set(-k,-j,k,j);m.setTransform(1,0,0,-1,k,j);this.clear()};this.clear=function(){m.setTransform(1,
|
|
|
|
+0,0,-1,k,j);if(!G.isEmpty()){G.inflate(1);G.minSelf(N);if(q.hex==0&&w==0)m.clearRect(G.getX(),G.getY(),G.getWidth(),G.getHeight());else{b(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(q.r*255)+","+Math.floor(q.g*255)+","+Math.floor(q.b*255)+","+w+")";m.fillRect(G.getX(),G.getY(),G.getWidth(),G.getHeight())}G.empty()}};this.render=function(ga,ka){function na(P){var ha,ca,T,ba=P.lights;$.setRGB(0,0,0);da.setRGB(0,0,0);C.setRGB(0,0,0);P=0;for(ha=ba.length;P<ha;P++){ca=ba[P];T=ca.color;if(ca instanceof
|
|
|
|
+THREE.AmbientLight){$.r+=T.r;$.g+=T.g;$.b+=T.b}else if(ca instanceof THREE.DirectionalLight){da.r+=T.r;da.g+=T.g;da.b+=T.b}else if(ca instanceof THREE.PointLight){C.r+=T.r;C.g+=T.g;C.b+=T.b}}}function Ca(P,ha,ca,T){var ba,ja,ua,za,Ba=P.lights;P=0;for(ba=Ba.length;P<ba;P++){ja=Ba[P];ua=ja.color;za=ja.intensity;if(ja instanceof THREE.DirectionalLight){ja=ca.dot(ja.position)*za;if(ja>0){T.r+=ua.r*ja;T.g+=ua.g*ja;T.b+=ua.b*ja}}else if(ja instanceof THREE.PointLight){J.sub(ja.position,ha);J.normalize();
|
|
|
|
+ja=ca.dot(J)*za;if(ja>0){T.r+=ua.r*ja;T.g+=ua.g*ja;T.b+=ua.b*ja}}}}function ya(P,ha,ca){if(ca.opacity!=0){a(ca.opacity);b(ca.blending);var T,ba,ja,ua,za,Ba;if(ca instanceof THREE.ParticleBasicMaterial){if(ca.map&&ca.map.image.loaded){ua=ca.map.image;za=ua.width>>1;Ba=ua.height>>1;ba=ha.scale.x*k;ja=ha.scale.y*j;ca=ba*za;T=ja*Ba;z.set(P.x-ca,P.y-T,P.x+ca,P.y+T);if(N.instersects(z)){m.save();m.translate(P.x,P.y);m.rotate(-ha.rotation);m.scale(ba,-ja);m.translate(-za,-Ba);m.drawImage(ua,0,0);m.restore()}}}else if(ca instanceof
|
|
|
|
+THREE.ParticleCircleMaterial){if(I){D.r=$.r+da.r+C.r;D.g=$.g+da.g+C.g;D.b=$.b+da.b+C.b;Q.r=ca.color.r*D.r;Q.g=ca.color.g*D.g;Q.b=ca.color.b*D.b;Q.updateStyleString()}else Q.__styleString=ca.color.__styleString;ca=ha.scale.x*k;T=ha.scale.y*j;z.set(P.x-ca,P.y-T,P.x+ca,P.y+T);if(N.instersects(z)){ba=Q.__styleString;if(A!=ba)m.fillStyle=A=ba;m.save();m.translate(P.x,P.y);m.rotate(-ha.rotation);m.scale(ca,T);m.beginPath();m.arc(0,0,1,0,L,true);m.closePath();m.fill();m.restore()}}}}function qa(P,ha,ca,
|
|
|
|
+T){if(T.opacity!=0){a(T.opacity);b(T.blending);m.beginPath();m.moveTo(P.positionScreen.x,P.positionScreen.y);m.lineTo(ha.positionScreen.x,ha.positionScreen.y);m.closePath();if(T instanceof THREE.LineBasicMaterial){Q.__styleString=T.color.__styleString;P=T.linewidth;if(E!=P)m.lineWidth=E=P;P=Q.__styleString;if(x!=P)m.strokeStyle=x=P;m.stroke();z.inflate(T.linewidth*2)}}}function ra(P,ha,ca,T,ba,ja){if(ba.opacity!=0){a(ba.opacity);b(ba.blending);M=P.positionScreen.x;d=P.positionScreen.y;aa=ha.positionScreen.x;
|
|
|
|
+O=ha.positionScreen.y;K=ca.positionScreen.x;X=ca.positionScreen.y;m.beginPath();m.moveTo(M,d);m.lineTo(aa,O);m.lineTo(K,X);m.lineTo(M,d);m.closePath();if(ba instanceof THREE.MeshBasicMaterial)if(ba.map)ba.map.image.loaded&&ba.map.mapping instanceof THREE.UVMapping&&wa(M,d,aa,O,K,X,ba.map.image,T.uvs[0].u,T.uvs[0].v,T.uvs[1].u,T.uvs[1].v,T.uvs[2].u,T.uvs[2].v);else if(ba.env_map){if(ba.env_map.image.loaded)if(ba.env_map.mapping instanceof THREE.SphericalReflectionMapping){P=ka.matrix;J.copy(T.vertexNormalsWorld[0]);
|
|
|
|
+ia=(J.x*P.n11+J.y*P.n12+J.z*P.n13)*0.5+0.5;l=-(J.x*P.n21+J.y*P.n22+J.z*P.n23)*0.5+0.5;J.copy(T.vertexNormalsWorld[1]);y=(J.x*P.n11+J.y*P.n12+J.z*P.n13)*0.5+0.5;B=-(J.x*P.n21+J.y*P.n22+J.z*P.n23)*0.5+0.5;J.copy(T.vertexNormalsWorld[2]);o=(J.x*P.n11+J.y*P.n12+J.z*P.n13)*0.5+0.5;n=-(J.x*P.n21+J.y*P.n22+J.z*P.n23)*0.5+0.5;wa(M,d,aa,O,K,X,ba.env_map.image,ia,l,y,B,o,n)}}else ba.wireframe?Ha(ba.color.__styleString,ba.wireframe_linewidth):Ia(ba.color.__styleString);else if(ba instanceof THREE.MeshLambertMaterial){if(ba.map&&
|
|
|
|
+!ba.wireframe){ba.map.mapping instanceof THREE.UVMapping&&wa(M,d,aa,O,K,X,ba.map.image,T.uvs[0].u,T.uvs[0].v,T.uvs[1].u,T.uvs[1].v,T.uvs[2].u,T.uvs[2].v);b(THREE.SubtractiveBlending)}if(I)if(!ba.wireframe&&ba.shading==THREE.SmoothShading&&T.vertexNormalsWorld.length==3){U.r=V.r=H.r=$.r;U.g=V.g=H.g=$.g;U.b=V.b=H.b=$.b;Ca(ja,T.v1.positionWorld,T.vertexNormalsWorld[0],U);Ca(ja,T.v2.positionWorld,T.vertexNormalsWorld[1],V);Ca(ja,T.v3.positionWorld,T.vertexNormalsWorld[2],H);Y.r=(V.r+H.r)*0.5;Y.g=(V.g+
|
|
|
|
+H.g)*0.5;Y.b=(V.b+H.b)*0.5;fa=ma(U,V,H,Y);wa(M,d,aa,O,K,X,fa,0,0,1,0,0,1)}else{D.r=$.r;D.g=$.g;D.b=$.b;Ca(ja,T.centroidWorld,T.normalWorld,D);Q.r=ba.color.r*D.r;Q.g=ba.color.g*D.g;Q.b=ba.color.b*D.b;Q.updateStyleString();ba.wireframe?Ha(Q.__styleString,ba.wireframe_linewidth):Ia(Q.__styleString)}else ba.wireframe?Ha(ba.color.__styleString,ba.wireframe_linewidth):Ia(ba.color.__styleString)}else if(ba instanceof THREE.MeshDepthMaterial){ea=ka.near;Z=ka.far;U.r=U.g=U.b=1-pa(P.positionScreen.z,ea,Z);
|
|
|
|
+V.r=V.g=V.b=1-pa(ha.positionScreen.z,ea,Z);H.r=H.g=H.b=1-pa(ca.positionScreen.z,ea,Z);Y.r=(V.r+H.r)*0.5;Y.g=(V.g+H.g)*0.5;Y.b=(V.b+H.b)*0.5;fa=ma(U,V,H,Y);wa(M,d,aa,O,K,X,fa,0,0,1,0,0,1)}else if(ba instanceof THREE.MeshNormalMaterial){Q.r=Da(T.normalWorld.x);Q.g=Da(T.normalWorld.y);Q.b=Da(T.normalWorld.z);Q.updateStyleString();ba.wireframe?Ha(Q.__styleString,ba.wireframe_linewidth):Ia(Q.__styleString)}}}function Ha(P,ha){if(x!=P)m.strokeStyle=x=P;if(E!=ha)m.lineWidth=E=ha;m.stroke();z.inflate(ha*
|
|
|
|
+2)}function Ia(P){if(A!=P)m.fillStyle=A=P;m.fill()}function wa(P,ha,ca,T,ba,ja,ua,za,Ba,Ka,Ga,La,Ra){var Ja,Ma;Ja=ua.width-1;Ma=ua.height-1;za*=Ja;Ba*=Ma;Ka*=Ja;Ga*=Ma;La*=Ja;Ra*=Ma;ca-=P;T-=ha;ba-=P;ja-=ha;Ka-=za;Ga-=Ba;La-=za;Ra-=Ba;Ja=Ka*Ra-La*Ga;if(Ja!=0){Ma=1/Ja;Ja=(Ra*ca-Ga*ba)*Ma;Ga=(Ra*T-Ga*ja)*Ma;ca=(Ka*ba-La*ca)*Ma;T=(Ka*ja-La*T)*Ma;P=P-Ja*za-ca*Ba;ha=ha-Ga*za-T*Ba;m.save();m.transform(Ja,Ga,ca,T,P,ha);m.clip();m.drawImage(ua,0,0);m.restore()}}function ma(P,ha,ca,T){var ba=~~(P.r*255),ja=
|
|
|
|
+~~(P.g*255);P=~~(P.b*255);var ua=~~(ha.r*255),za=~~(ha.g*255);ha=~~(ha.b*255);var Ba=~~(ca.r*255),Ka=~~(ca.g*255);ca=~~(ca.b*255);var Ga=~~(T.r*255),La=~~(T.g*255);T=~~(T.b*255);S[0]=ba<0?0:ba>255?255:ba;S[1]=ja<0?0:ja>255?255:ja;S[2]=P<0?0:P>255?255:P;S[4]=ua<0?0:ua>255?255:ua;S[5]=za<0?0:za>255?255:za;S[6]=ha<0?0:ha>255?255:ha;S[8]=Ba<0?0:Ba>255?255:Ba;S[9]=Ka<0?0:Ka>255?255:Ka;S[10]=ca<0?0:ca>255?255:ca;S[12]=Ga<0?0:Ga>255?255:Ga;S[13]=La<0?0:La>255?255:La;S[14]=T<0?0:T>255?255:T;W.putImageData(la,
|
|
|
|
+0,0);sa.drawImage(R,0,0);return ta}function pa(P,ha,ca){P=(P-ha)/(ca-ha);return P*P*(3-2*P)}function Da(P){P=(P+1)*0.5;return P<0?0:P>1?1:P}function xa(P,ha){var ca=ha.x-P.x,T=ha.y-P.y,ba=1/Math.sqrt(ca*ca+T*T);ca*=ba;T*=ba;ha.x+=ca;ha.y+=T;P.x-=ca;P.y-=T}var Oa,Aa,oa,Ea,Fa,Pa,Qa,Na;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,j);c=e.projectScene(ga,ka,this.sortElements);(I=ga.lights.length>0)&&na(ga);Oa=0;for(Aa=c.length;Oa<Aa;Oa++){oa=c[Oa];z.empty();if(oa instanceof THREE.RenderableParticle){v=
|
|
|
|
+oa;v.x*=k;v.y*=j;Ea=0;for(Fa=oa.materials.length;Ea<Fa;Ea++)ya(v,oa,oa.materials[Ea],ga)}else if(oa instanceof THREE.RenderableLine){v=oa.v1;F=oa.v2;v.positionScreen.x*=k;v.positionScreen.y*=j;F.positionScreen.x*=k;F.positionScreen.y*=j;z.addPoint(v.positionScreen.x,v.positionScreen.y);z.addPoint(F.positionScreen.x,F.positionScreen.y);if(N.instersects(z)){Ea=0;for(Fa=oa.materials.length;Ea<Fa;)qa(v,F,oa,oa.materials[Ea++],ga)}}else if(oa instanceof THREE.RenderableFace3){v=oa.v1;F=oa.v2;p=oa.v3;v.positionScreen.x*=
|
|
|
|
+k;v.positionScreen.y*=j;F.positionScreen.x*=k;F.positionScreen.y*=j;p.positionScreen.x*=k;p.positionScreen.y*=j;if(oa.overdraw){xa(v.positionScreen,F.positionScreen);xa(F.positionScreen,p.positionScreen);xa(p.positionScreen,v.positionScreen)}z.add3Points(v.positionScreen.x,v.positionScreen.y,F.positionScreen.x,F.positionScreen.y,p.positionScreen.x,p.positionScreen.y);if(N.instersects(z)){Ea=0;for(Fa=oa.meshMaterials.length;Ea<Fa;){Na=oa.meshMaterials[Ea++];if(Na instanceof THREE.MeshFaceMaterial){Pa=
|
|
|
|
+0;for(Qa=oa.faceMaterials.length;Pa<Qa;)(Na=oa.faceMaterials[Pa++])&&ra(v,F,p,oa,Na,ga)}else ra(v,F,p,oa,Na,ga)}}}G.addRectangle(z)}m.setTransform(1,0,0,1,0,0)}};
|
|
|
|
+THREE.SVGRenderer=function(){function a(ia,l,y){var B,o,n,N;B=0;for(o=ia.lights.length;B<o;B++){n=ia.lights[B];if(n instanceof THREE.DirectionalLight){N=l.normalWorld.dot(n.position)*n.intensity;if(N>0){y.r+=n.color.r*N;y.g+=n.color.g*N;y.b+=n.color.b*N}}else if(n instanceof THREE.PointLight){X.sub(n.position,l.centroidWorld);X.normalize();N=l.normalWorld.dot(X)*n.intensity;if(N>0){y.r+=n.color.r*N;y.g+=n.color.g*N;y.b+=n.color.b*N}}}}function b(ia,l,y,B,o,n){H=e(Y++);H.setAttribute("d","M "+ia.positionScreen.x+
|
|
|
|
+" "+ia.positionScreen.y+" L "+l.positionScreen.x+" "+l.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+"z");if(o instanceof THREE.MeshBasicMaterial)p.__styleString=o.color.__styleString;else if(o instanceof THREE.MeshLambertMaterial)if(F){M.r=d.r;M.g=d.g;M.b=d.b;a(n,B,M);p.r=o.color.r*M.r;p.g=o.color.g*M.g;p.b=o.color.b*M.b;p.updateStyleString()}else p.__styleString=o.color.__styleString;else if(o instanceof THREE.MeshDepthMaterial){K=1-o.__2near/(o.__farPlusNear-B.z*o.__farMinusNear);
|
|
|
|
+p.setRGB(K,K,K)}else o instanceof THREE.MeshNormalMaterial&&p.setRGB(g(B.normalWorld.x),g(B.normalWorld.y),g(B.normalWorld.z));o.wireframe?H.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+o.wireframe_linewidth+"; stroke-opacity: "+o.opacity+"; stroke-linecap: "+o.wireframe_linecap+"; stroke-linejoin: "+o.wireframe_linejoin):H.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+o.opacity);k.appendChild(H)}function c(ia,l,y,B,o,n,N){H=e(Y++);H.setAttribute("d",
|
|
|
|
+"M "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+l.positionScreen.x+" "+l.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+" L "+B.positionScreen.x+","+B.positionScreen.y+"z");if(n instanceof THREE.MeshBasicMaterial)p.__styleString=n.color.__styleString;else if(n instanceof THREE.MeshLambertMaterial)if(F){M.r=d.r;M.g=d.g;M.b=d.b;a(N,o,M);p.r=n.color.r*M.r;p.g=n.color.g*M.g;p.b=n.color.b*M.b;p.updateStyleString()}else p.__styleString=n.color.__styleString;else if(n instanceof
|
|
|
|
+THREE.MeshDepthMaterial){K=1-n.__2near/(n.__farPlusNear-o.z*n.__farMinusNear);p.setRGB(K,K,K)}else n instanceof THREE.MeshNormalMaterial&&p.setRGB(g(o.normalWorld.x),g(o.normalWorld.y),g(o.normalWorld.z));n.wireframe?H.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+n.wireframe_linewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframe_linecap+"; stroke-linejoin: "+n.wireframe_linejoin):H.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+
|
|
|
|
+n.opacity);k.appendChild(H)}function e(ia){if(Q[ia]==null){Q[ia]=document.createElementNS("http://www.w3.org/2000/svg","path");fa==0&&Q[ia].setAttribute("shape-rendering","crispEdges");return Q[ia]}return Q[ia]}function g(ia){return ia<0?Math.min((1+ia)*0.5,0.5):0.5+Math.min(ia*0.5,0.5)}var f=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,q,w,u,t,x,A,E=new THREE.Rectangle,v=new THREE.Rectangle,F=false,p=new THREE.Color(16777215),M=new THREE.Color(16777215),
|
|
|
|
+d=new THREE.Color(0),aa=new THREE.Color(0),O=new THREE.Color(0),K,X=new THREE.Vector3,Q=[],U=[],V=[],H,Y,ea,Z,fa=1;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(ia){switch(ia){case "high":fa=1;break;case "low":fa=0}};this.setSize=function(ia,l){j=ia;m=l;q=j/2;w=m/2;k.setAttribute("viewBox",-q+" "+-w+" "+j+" "+m);k.setAttribute("width",j);k.setAttribute("height",m);E.set(-q,-w,q,w)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};
|
|
|
|
+this.render=function(ia,l){var y,B,o,n,N,G,z,I;this.autoClear&&this.clear();f=h.projectScene(ia,l,this.sortElements);Z=ea=Y=0;if(F=ia.lights.length>0){z=ia.lights;d.setRGB(0,0,0);aa.setRGB(0,0,0);O.setRGB(0,0,0);y=0;for(B=z.length;y<B;y++){o=z[y];n=o.color;if(o instanceof THREE.AmbientLight){d.r+=n.r;d.g+=n.g;d.b+=n.b}else if(o instanceof THREE.DirectionalLight){aa.r+=n.r;aa.g+=n.g;aa.b+=n.b}else if(o instanceof THREE.PointLight){O.r+=n.r;O.g+=n.g;O.b+=n.b}}}y=0;for(B=f.length;y<B;y++){z=f[y];v.empty();
|
|
|
|
+if(z instanceof THREE.RenderableParticle){u=z;u.x*=q;u.y*=-w;o=0;for(n=z.materials.length;o<n;o++)if(I=z.materials[o]){N=u;G=z;I=I;var D=ea++;if(U[D]==null){U[D]=document.createElementNS("http://www.w3.org/2000/svg","circle");fa==0&&U[D].setAttribute("shape-rendering","crispEdges")}H=U[D];H.setAttribute("cx",N.x);H.setAttribute("cy",N.y);H.setAttribute("r",G.scale.x*q);if(I instanceof THREE.ParticleCircleMaterial){if(F){M.r=d.r+aa.r+O.r;M.g=d.g+aa.g+O.g;M.b=d.b+aa.b+O.b;p.r=I.color.r*M.r;p.g=I.color.g*
|
|
|
|
+M.g;p.b=I.color.b*M.b;p.updateStyleString()}else p=I.color;H.setAttribute("style","fill: "+p.__styleString)}k.appendChild(H)}}else if(z instanceof THREE.RenderableLine){u=z.v1;t=z.v2;u.positionScreen.x*=q;u.positionScreen.y*=-w;t.positionScreen.x*=q;t.positionScreen.y*=-w;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(t.positionScreen.x,t.positionScreen.y);if(E.instersects(v)){o=0;for(n=z.materials.length;o<n;)if(I=z.materials[o++]){N=u;G=t;I=I;D=Z++;if(V[D]==null){V[D]=document.createElementNS("http://www.w3.org/2000/svg",
|
|
|
|
+"line");fa==0&&V[D].setAttribute("shape-rendering","crispEdges")}H=V[D];H.setAttribute("x1",N.positionScreen.x);H.setAttribute("y1",N.positionScreen.y);H.setAttribute("x2",G.positionScreen.x);H.setAttribute("y2",G.positionScreen.y);if(I instanceof THREE.LineBasicMaterial){p.__styleString=I.color.__styleString;H.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+I.linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: "+I.linecap+"; stroke-linejoin: "+I.linejoin);k.appendChild(H)}}}}else if(z instanceof
|
|
|
|
+THREE.RenderableFace3){u=z.v1;t=z.v2;x=z.v3;u.positionScreen.x*=q;u.positionScreen.y*=-w;t.positionScreen.x*=q;t.positionScreen.y*=-w;x.positionScreen.x*=q;x.positionScreen.y*=-w;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(t.positionScreen.x,t.positionScreen.y);v.addPoint(x.positionScreen.x,x.positionScreen.y);if(E.instersects(v)){o=0;for(n=z.meshMaterials.length;o<n;){I=z.meshMaterials[o++];if(I instanceof THREE.MeshFaceMaterial){N=0;for(G=z.faceMaterials.length;N<G;)(I=z.faceMaterials[N++])&&
|
|
|
|
+b(u,t,x,z,I,ia)}else I&&b(u,t,x,z,I,ia)}}}else if(z instanceof THREE.RenderableFace4){u=z.v1;t=z.v2;x=z.v3;A=z.v4;u.positionScreen.x*=q;u.positionScreen.y*=-w;t.positionScreen.x*=q;t.positionScreen.y*=-w;x.positionScreen.x*=q;x.positionScreen.y*=-w;A.positionScreen.x*=q;A.positionScreen.y*=-w;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(t.positionScreen.x,t.positionScreen.y);v.addPoint(x.positionScreen.x,x.positionScreen.y);v.addPoint(A.positionScreen.x,A.positionScreen.y);if(E.instersects(v)){o=
|
|
|
|
+0;for(n=z.meshMaterials.length;o<n;){I=z.meshMaterials[o++];if(I instanceof THREE.MeshFaceMaterial){N=0;for(G=z.faceMaterials.length;N<G;)(I=z.faceMaterials[N++])&&c(u,t,x,A,z,I,ia)}else I&&c(u,t,x,A,z,I,ia)}}}}}};
|
|
|
|
+THREE.WebGLRenderer=function(a){function b(l,y,B){var o,n,N,G=l.vertices,z=G.length,I=l.colors,D=I.length,$=l.__vertexArray,da=l.__colorArray,C=l.__sortArray,L=l.__dirtyVertices,J=l.__dirtyColors;if(B.sortParticles){V.multiplySelf(B.matrixWorld);for(o=0;o<z;o++){n=G[o].position;ea.copy(n);V.multiplyVector3(ea);C[o]=[ea.z,o]}C.sort(function(R,W){return W[0]-R[0]});for(o=0;o<z;o++){n=G[C[o][1]].position;N=o*3;$[N]=n.x;$[N+1]=n.y;$[N+2]=n.z}for(o=0;o<D;o++){N=o*3;color=I[C[o][1]];da[N]=color.r;da[N+
|
|
|
|
+1]=color.g;da[N+2]=color.b}}else{if(L)for(o=0;o<z;o++){n=G[o].position;N=o*3;$[N]=n.x;$[N+1]=n.y;$[N+2]=n.z}if(J)for(o=0;o<D;o++){color=I[o];N=o*3;da[N]=color.r;da[N+1]=color.g;da[N+2]=color.b}}if(L||B.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,$,y)}if(J||B.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,da,y)}}function c(l,y){l.fragment_shader=y.fragment_shader;l.vertex_shader=y.vertex_shader;l.uniforms=
|
|
|
|
+Uniforms.clone(y.uniforms)}function e(l,y){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=d.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=d.createBuffer();if(l.hasPos){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,l.positionArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(y.attributes.position);d.vertexAttribPointer(y.attributes.position,3,d.FLOAT,false,0,0)}if(l.hasNormal){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,
|
|
|
|
+l.normalArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(y.attributes.normal);d.vertexAttribPointer(y.attributes.normal,3,d.FLOAT,false,0,0)}d.drawArrays(d.TRIANGLES,0,l.count);l.count=0}function g(l){if(K!=l.doubleSided){l.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE);K=l.doubleSided}if(X!=l.flipSided){l.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW);X=l.flipSided}}function f(l){U[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,l.n44-l.n14);U[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+
|
|
|
|
+l.n14);U[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);U[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);U[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);U[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var y;for(l=0;l<5;l++){y=U[l];y.divideScalar(Math.sqrt(y.x*y.x+y.y*y.y+y.z*y.z))}}function h(l){for(var y=l.matrix,B=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),o=0;o<6;o++){l=U[o].x*y.n14+U[o].y*y.n24+U[o].z*y.n34+U[o].w;
|
|
|
|
+if(l<=B)return false}return true}function k(l,y){l.list[l.count]=y;l.count+=1}function j(l){var y,B,o=l.object,n=l.opaque,N=l.transparent;N.count=0;l=n.count=0;for(y=o.materials.length;l<y;l++){B=o.materials[l];B.opacity&&B.opacity<1||B.blending!=THREE.NormalBlending?k(N,B):k(n,B)}}function m(l){var y,B,o,n,N=l.object,G=l.buffer,z=l.opaque,I=l.transparent;I.count=0;l=z.count=0;for(o=N.materials.length;l<o;l++){y=N.materials[l];if(y instanceof THREE.MeshFaceMaterial){y=0;for(B=G.materials.length;y<
|
|
|
|
+B;y++)if(n=G.materials[y])n.opacity&&n.opacity<1||n.blending!=THREE.NormalBlending?k(I,n):k(z,n)}else{n=y;n.opacity&&n.opacity<1||n.blending!=THREE.NormalBlending?k(I,n):k(z,n)}}}function q(l){var y,B,o,n=l.children;y=0;for(B=n.length;y<B;y++){o=n[y];o.autoUpdateMatrix&&o.updateMatrix();o.matrixWorld.multiply(l.matrixWorld,o.matrix);q(o)}}function w(l,y){return y.z-l.z}function u(l,y){var B,o,n=y.children;B=0;for(o=n.length;B<o;B++){child=n[B];t(l,child,false);u(l,child)}}function t(l,y,B){var o,
|
|
|
|
+n,N;n=y.geometry;if(l.__webGLObjectsMap[y.id]==undefined){l.__webGLObjectsMap[y.id]={};y._modelViewMatrix=new THREE.Matrix4;y._normalMatrixArray=new Float32Array(9);y._modelViewMatrixArray=new Float32Array(16);y._objectMatrixArray=new Float32Array(16);y.matrix.flattenToArray(y._objectMatrixArray)}N=l.__webGLObjectsMap[y.id];objlist=l.__webGLObjects;if(y instanceof THREE.Mesh){for(o in n.geometryChunks){l=n.geometryChunks[o];if(!l.__webGLVertexBuffer){var G=l;G.__webGLVertexBuffer=d.createBuffer();
|
|
|
|
+G.__webGLNormalBuffer=d.createBuffer();G.__webGLTangentBuffer=d.createBuffer();G.__webGLColorBuffer=d.createBuffer();G.__webGLUVBuffer=d.createBuffer();G.__webGLUV2Buffer=d.createBuffer();G.__webGLFaceBuffer=d.createBuffer();G.__webGLLineBuffer=d.createBuffer();G=l;var z=y,I=void 0,D=void 0,$=0,da=0,C=0,L=z.geometry.faces,J=G.faces;I=0;for(D=J.length;I<D;I++){fi=J[I];face=L[fi];if(face instanceof THREE.Face3){$+=3;da+=1;C+=3}else if(face instanceof THREE.Face4){$+=4;da+=2;C+=4}}G.__vertexArray=new Float32Array($*
|
|
|
|
+3);G.__normalArray=new Float32Array($*3);G.__tangentArray=new Float32Array($*4);G.__colorArray=new Float32Array($*3);G.__uvArray=new Float32Array($*2);G.__uv2Array=new Float32Array($*2);G.__faceArray=new Uint16Array(da*3);G.__lineArray=new Uint16Array(C*2);D=I=G;z=z;$=void 0;L=void 0;var R=void 0,W=void 0;R=void 0;J=false;$=0;for(L=z.materials.length;$<L;$++){R=z.materials[$];if(R instanceof THREE.MeshFaceMaterial){R=0;for(W=D.materials.length;R<W;R++)if(D.materials[R]&&D.materials[R].shading!=undefined&&
|
|
|
|
+D.materials[R].shading==THREE.SmoothShading){J=true;break}}else if(R&&R.shading!=undefined&&R.shading==THREE.SmoothShading){J=true;break}if(J)break}I.__needsSmoothNormals=J;G.__webGLFaceCount=da*3;G.__webGLLineCount=C*2;n.__dirtyVertices=true;n.__dirtyElements=true;n.__dirtyUvs=true;n.__dirtyNormals=true;n.__dirtyTangents=true;n.__dirtyColors=true}if(n.__dirtyVertices||n.__dirtyElements||n.__dirtyUvs||n.__dirtyNormals||n.__dirtyColors||n.__dirtyTangents){G=l;da=d.DYNAMIC_DRAW;C=void 0;I=void 0;var la=
|
|
|
|
+void 0,S=void 0,ta=void 0,sa=void 0,va=void 0;la=void 0;var ga=void 0,ka=void 0,na=void 0,Ca=void 0;ga=void 0;ka=void 0;na=void 0;S=void 0;ga=void 0;ka=void 0;na=void 0;Ca=void 0;S=void 0;sa=void 0;ta=void 0;va=void 0;var ya=W=R=J=L=$=z=D=0,qa=0,ra=G.__vertexArray,Ha=G.__uvArray,Ia=G.__uv2Array,wa=G.__normalArray,ma=G.__tangentArray,pa=G.__colorArray,Da=G.__faceArray,xa=G.__lineArray,Oa=G.__needsSmoothNormals,Aa=y.geometry,oa=Aa.__dirtyVertices,Ea=Aa.__dirtyElements,Fa=Aa.__dirtyUvs,Pa=Aa.__dirtyNormals,
|
|
|
|
+Qa=Aa.__dirtyTangents,Na=Aa.__dirtyColors,P=Aa.vertices,ha=G.faces,ca=Aa.faces,T=Aa.uvs,ba=Aa.uvs2,ja=Aa.colors;C=0;for(I=ha.length;C<I;C++){la=ha[C];S=ca[la];va=T[la];la=ba[la];ta=S.vertexNormals;sa=S.normal;if(S instanceof THREE.Face3){if(oa){ga=P[S.a].position;ka=P[S.b].position;na=P[S.c].position;ra[z]=ga.x;ra[z+1]=ga.y;ra[z+2]=ga.z;ra[z+3]=ka.x;ra[z+4]=ka.y;ra[z+5]=ka.z;ra[z+6]=na.x;ra[z+7]=na.y;ra[z+8]=na.z;z+=9}if(Na&&ja.length){ga=ja[S.a];ka=ja[S.b];na=ja[S.c];pa[qa]=ga.r;pa[qa+1]=ga.g;pa[qa+
|
|
|
|
+2]=ga.b;pa[qa+3]=ka.r;pa[qa+4]=ka.g;pa[qa+5]=ka.b;pa[qa+6]=na.r;pa[qa+7]=na.g;pa[qa+8]=na.b;qa+=9}if(Qa&&Aa.hasTangents){ga=P[S.a].tangent;ka=P[S.b].tangent;na=P[S.c].tangent;ma[W]=ga.x;ma[W+1]=ga.y;ma[W+2]=ga.z;ma[W+3]=ga.w;ma[W+4]=ka.x;ma[W+5]=ka.y;ma[W+6]=ka.z;ma[W+7]=ka.w;ma[W+8]=na.x;ma[W+9]=na.y;ma[W+10]=na.z;ma[W+11]=na.w;W+=12}if(Pa)if(ta.length==3&&Oa)for(S=0;S<3;S++){sa=ta[S];wa[R]=sa.x;wa[R+1]=sa.y;wa[R+2]=sa.z;R+=3}else for(S=0;S<3;S++){wa[R]=sa.x;wa[R+1]=sa.y;wa[R+2]=sa.z;R+=3}if(Fa&&
|
|
|
|
+va)for(S=0;S<3;S++){ta=va[S];Ha[$]=ta.u;Ha[$+1]=ta.v;$+=2}if(Fa&&la)for(S=0;S<3;S++){va=la[S];Ia[L]=va.u;Ia[L+1]=va.v;L+=2}if(Ea){Da[J]=D;Da[J+1]=D+1;Da[J+2]=D+2;J+=3;xa[ya]=D;xa[ya+1]=D+1;xa[ya+2]=D;xa[ya+3]=D+2;xa[ya+4]=D+1;xa[ya+5]=D+2;ya+=6;D+=3}}else if(S instanceof THREE.Face4){if(oa){ga=P[S.a].position;ka=P[S.b].position;na=P[S.c].position;Ca=P[S.d].position;ra[z]=ga.x;ra[z+1]=ga.y;ra[z+2]=ga.z;ra[z+3]=ka.x;ra[z+4]=ka.y;ra[z+5]=ka.z;ra[z+6]=na.x;ra[z+7]=na.y;ra[z+8]=na.z;ra[z+9]=Ca.x;ra[z+
|
|
|
|
+10]=Ca.y;ra[z+11]=Ca.z;z+=12}if(Na&&ja.length){ga=ja[S.a];ka=ja[S.b];na=ja[S.c];Ca=ja[S.d];pa[qa]=ga.r;pa[qa+1]=ga.g;pa[qa+2]=ga.b;pa[qa+3]=ka.r;pa[qa+4]=ka.g;pa[qa+5]=ka.b;pa[qa+6]=na.r;pa[qa+7]=na.g;pa[qa+8]=na.b;pa[qa+9]=Ca.r;pa[qa+10]=Ca.g;pa[qa+11]=Ca.b;qa+=12}if(Qa&&Aa.hasTangents){ga=P[S.a].tangent;ka=P[S.b].tangent;na=P[S.c].tangent;S=P[S.d].tangent;ma[W]=ga.x;ma[W+1]=ga.y;ma[W+2]=ga.z;ma[W+3]=ga.w;ma[W+4]=ka.x;ma[W+5]=ka.y;ma[W+6]=ka.z;ma[W+7]=ka.w;ma[W+8]=na.x;ma[W+9]=na.y;ma[W+10]=na.z;
|
|
|
|
+ma[W+11]=na.w;ma[W+12]=S.x;ma[W+13]=S.y;ma[W+14]=S.z;ma[W+15]=S.w;W+=16}if(Pa)if(ta.length==4&&Oa)for(S=0;S<4;S++){sa=ta[S];wa[R]=sa.x;wa[R+1]=sa.y;wa[R+2]=sa.z;R+=3}else for(S=0;S<4;S++){wa[R]=sa.x;wa[R+1]=sa.y;wa[R+2]=sa.z;R+=3}if(Fa&&va)for(S=0;S<4;S++){ta=va[S];Ha[$]=ta.u;Ha[$+1]=ta.v;$+=2}if(Fa&&la)for(S=0;S<4;S++){va=la[S];Ia[L]=va.u;Ia[L+1]=va.v;L+=2}if(Ea){Da[J]=D;Da[J+1]=D+1;Da[J+2]=D+2;Da[J+3]=D;Da[J+4]=D+2;Da[J+5]=D+3;J+=6;xa[ya]=D;xa[ya+1]=D+1;xa[ya+2]=D;xa[ya+3]=D+3;xa[ya+4]=D+1;xa[ya+
|
|
|
|
+5]=D+2;xa[ya+6]=D+2;xa[ya+7]=D+3;ya+=8;D+=4}}}if(oa){d.bindBuffer(d.ARRAY_BUFFER,G.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,ra,da)}if(Na&&ja.length){d.bindBuffer(d.ARRAY_BUFFER,G.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,pa,da)}if(Pa){d.bindBuffer(d.ARRAY_BUFFER,G.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,wa,da)}if(Qa&&Aa.hasTangents){d.bindBuffer(d.ARRAY_BUFFER,G.__webGLTangentBuffer);d.bufferData(d.ARRAY_BUFFER,ma,da)}if(Fa&&$>0){d.bindBuffer(d.ARRAY_BUFFER,G.__webGLUVBuffer);
|
|
|
|
+d.bufferData(d.ARRAY_BUFFER,Ha,da)}if(Fa&&L>0){d.bindBuffer(d.ARRAY_BUFFER,G.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Ia,da)}if(Ea){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,G.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,Da,da);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,G.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,xa,da)}}x(objlist,N,o,l,y,B)}n.__dirtyVertices=false;n.__dirtyElements=false;n.__dirtyUvs=false;n.__dirtyNormals=false;n.__dirtyTangents=false;n.__dirtyColors=false}else if(y instanceof
|
|
|
|
+THREE.Line){if(!n.__webGLVertexBuffer){n.__webGLVertexBuffer=d.createBuffer();n.__webGLColorBuffer=d.createBuffer();o=n.vertices.length;n.__vertexArray=new Float32Array(o*3);n.__colorArray=new Float32Array(o*3);n.__webGLLineCount=o;n.__dirtyVertices=true;n.__dirtyColors=true}if(n.__dirtyVertices||n.__dirtyColors){o=d.DYNAMIC_DRAW;z=n.vertices;G=n.colors;$=z.length;da=G.length;L=n.__vertexArray;C=n.__colorArray;J=n.__dirtyColors;if(n.__dirtyVertices){for(I=0;I<$;I++){D=z[I].position;l=I*3;L[l]=D.x;
|
|
|
|
+L[l+1]=D.y;L[l+2]=D.z}d.bindBuffer(d.ARRAY_BUFFER,n.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,L,o)}if(J){for(I=0;I<da;I++){color=G[I];l=I*3;C[l]=color.r;C[l+1]=color.g;C[l+2]=color.b}d.bindBuffer(d.ARRAY_BUFFER,n.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,C,o)}}x(objlist,N,0,n,y,B);n.__dirtyVertices=false;n.__dirtyColors=false}else if(y instanceof THREE.ParticleSystem){if(!n.__webGLVertexBuffer){n.__webGLVertexBuffer=d.createBuffer();n.__webGLColorBuffer=d.createBuffer();o=n.vertices.length;
|
|
|
|
+n.__vertexArray=new Float32Array(o*3);n.__colorArray=new Float32Array(o*3);n.__sortArray=[];n.__webGLParticleCount=o;n.__dirtyVertices=true;n.__dirtyColors=true}if(n.__dirtyVertices||n.__dirtyColors||y.sortParticles)b(n,d.DYNAMIC_DRAW,y,camera);x(objlist,N,0,n,y,B);n.__dirtyVertices=false;n.__dirtyColors=false}else if(y instanceof THREE.MarchingCubes)if(N[0]==undefined){l.__webGLObjectsImmediate.push({object:y,opaque:{list:[],count:0},transparent:{list:[],count:0},root:B});N[0]=1}}function x(l,y,
|
|
|
|
+B,o,n,N){if(y[B]==undefined){l.push({buffer:o,object:n,opaque:{list:[],count:0},transparent:{list:[],count:0},root:N});y[B]=1}}function A(l,y){l._modelViewMatrix.multiplyToArray(y.matrix,l.matrixWorld,l._modelViewMatrixArray);l._normalMatrix=THREE.Matrix4.makeInvert3x3(l._modelViewMatrix).transposeIntoArray(l._normalMatrixArray)}function E(l){if(l!=Q){switch(l){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE);break;case THREE.SubtractiveBlending:d.blendFunc(d.DST_COLOR,
|
|
|
|
+d.ZERO);break;case THREE.BillboardBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA);break;default:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA)}Q=l}}function v(l,y){if(l&&!l.__webGLFramebuffer){l.__webGLFramebuffer=d.createFramebuffer();l.__webGLRenderbuffer=d.createRenderbuffer();l.__webGLTexture=d.createTexture();d.bindRenderbuffer(d.RENDERBUFFER,l.__webGLRenderbuffer);d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,l.width,l.height);
|
|
|
|
+d.bindTexture(d.TEXTURE_2D,l.__webGLTexture);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,p(l.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,p(l.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,p(l.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,p(l.min_filter));d.texImage2D(d.TEXTURE_2D,0,p(l.format),l.width,l.height,0,p(l.format),p(l.type),null);d.bindFramebuffer(d.FRAMEBUFFER,l.__webGLFramebuffer);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,
|
|
|
|
+l.__webGLTexture,0);d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.RENDERBUFFER,l.__webGLRenderbuffer);d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,null)}var B,o,n;if(l){B=l.__webGLFramebuffer;o=l.width;n=l.height}else{B=null;o=M.width;n=M.height}if(B!=O){d.bindFramebuffer(d.FRAMEBUFFER,B);d.viewport(0,0,o,n);y&&d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT);O=B}}function F(l,y){var B;if(l=="fragment")B=d.createShader(d.FRAGMENT_SHADER);
|
|
|
|
+else if(l=="vertex")B=d.createShader(d.VERTEX_SHADER);d.shaderSource(B,y);d.compileShader(B);if(!d.getShaderParameter(B,d.COMPILE_STATUS)){alert(d.getShaderInfoLog(B));return null}return B}function p(l){switch(l){case THREE.RepeatWrapping:return d.REPEAT;case THREE.ClampToEdgeWrapping:return d.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return d.MIRRORED_REPEAT;case THREE.NearestFilter:return d.NEAREST;case THREE.NearestMipMapNearestFilter:return d.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return d.NEAREST_MIPMAP_LINEAR;
|
|
|
|
+case THREE.LinearFilter:return d.LINEAR;case THREE.LinearMipMapNearestFilter:return d.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return d.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return d.BYTE;case THREE.UnsignedByteType:return d.UNSIGNED_BYTE;case THREE.ShortType:return d.SHORT;case THREE.UnsignedShortType:return d.UNSIGNED_SHORT;case THREE.IntType:return d.INT;case THREE.UnsignedShortType:return d.UNSIGNED_INT;case THREE.FloatType:return d.FLOAT;case THREE.AlphaFormat:return d.ALPHA;
|
|
|
|
+case THREE.RGBFormat:return d.RGB;case THREE.RGBAFormat:return d.RGBA;case THREE.LuminanceFormat:return d.LUMINANCE;case THREE.LuminanceAlphaFormat:return d.LUMINANCE_ALPHA}return 0}var M=document.createElement("canvas"),d,aa=null,O=null,K=null,X=null,Q=null,U=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],V=new THREE.Matrix4,H=new Float32Array(16),Y=new Float32Array(16),ea=new THREE.Vector4,Z=true,fa=new THREE.Color(0),ia=0;if(a){if(a.antialias!==
|
|
|
|
+undefined)Z=a.antialias;a.clearColor!==undefined&&fa.setHex(a.clearColor);if(a.clearAlpha!==undefined)ia=a.clearAlpha}this.domElement=M;this.autoClear=true;(function(l,y,B){try{d=M.getContext("experimental-webgl",{antialias:l})}catch(o){console.log(o)}if(!d){alert("WebGL not supported");throw"cannot create webgl context";}d.clearColor(0,0,0,1);d.clearDepth(1);d.enable(d.DEPTH_TEST);d.depthFunc(d.LEQUAL);d.frontFace(d.CCW);d.cullFace(d.BACK);d.enable(d.CULL_FACE);d.enable(d.BLEND);d.blendFunc(d.ONE,
|
|
|
|
+d.ONE_MINUS_SRC_ALPHA);d.clearColor(y.r,y.g,y.b,B);_cullEnabled=true})(Z,fa,ia);this.context=d;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,y){M.width=l;M.height=y;d.viewport(0,0,M.width,M.height)};this.setClearColorHex=function(l,y){var B=new THREE.Color(l);d.clearColor(B.r,B.g,B.b,y)};this.setClearColor=function(l,y){d.clearColor(l.r,l.g,l.b,y)};this.clear=function(){d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT)};
|
|
|
|
+this.setupLights=function(l,y){var B,o,n,N=0,G=0,z=0,I,D,$,da=this.lights,C=da.directional.colors,L=da.directional.positions,J=da.point.colors,R=da.point.positions,W=0,la=0;B=n=n=0;for(o=y.length;B<o;B++){n=y[B];I=n.color;D=n.position;$=n.intensity;if(n instanceof THREE.AmbientLight){N+=I.r;G+=I.g;z+=I.b}else if(n instanceof THREE.DirectionalLight){n=W*3;C[n]=I.r*$;C[n+1]=I.g*$;C[n+2]=I.b*$;L[n]=D.x;L[n+1]=D.y;L[n+2]=D.z;W+=1}else if(n instanceof THREE.PointLight){n=la*3;J[n]=I.r*$;J[n+1]=I.g*$;J[n+
|
|
|
|
+2]=I.b*$;R[n]=D.x;R[n+1]=D.y;R[n+2]=D.z;la+=1}}for(B=W*3;B<C.length;B++)C[B]=0;for(B=la*3;B<J.length;B++)J[B]=0;da.point.length=la;da.directional.length=W;da.ambient[0]=N;da.ambient[1]=G;da.ambient[2]=z};this.initMaterial=function(l,y,B){var o,n;if(l instanceof THREE.MeshDepthMaterial)c(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)c(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)c(l,
|
|
|
|
+THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)c(l,THREE.ShaderLib.phong);else if(l instanceof THREE.LineBasicMaterial)c(l,THREE.ShaderLib.basic);else l instanceof THREE.ParticleBasicMaterial&&c(l,THREE.ShaderLib.particle_basic);var N,G,z,I;n=z=I=0;for(N=y.length;n<N;n++){G=y[n];G instanceof THREE.DirectionalLight&&z++;G instanceof THREE.PointLight&&I++}if(I+z<=4){y=z;I=I}else{y=Math.ceil(4*z/(I+z));I=4-y}n={directional:y,point:I};I=l.fragment_shader;y=l.vertex_shader;N={fog:B,
|
|
|
|
+map:l.map,env_map:l.env_map,light_map:l.light_map,vertex_colors:l.vertex_colors,maxDirLights:n.directional,maxPointLights:n.point};B=d.createProgram();n=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+N.maxDirLights,"#define MAX_POINT_LIGHTS "+N.maxPointLights,N.fog?"#define USE_FOG":"",N.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",N.map?"#define USE_MAP":"",N.env_map?"#define USE_ENVMAP":"",N.light_map?"#define USE_LIGHTMAP":"",N.vertex_colors?"#define USE_COLOR":
|
|
|
|
+"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");N=[d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+N.maxDirLights,"#define MAX_POINT_LIGHTS "+N.maxPointLights,N.map?"#define USE_MAP":"",N.env_map?"#define USE_ENVMAP":"",N.light_map?"#define USE_LIGHTMAP":"",N.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");
|
|
|
|
+d.attachShader(B,F("fragment",n+I));d.attachShader(B,F("vertex",N+y));d.linkProgram(B);d.getProgramParameter(B,d.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+d.getProgramParameter(B,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");B.uniforms={};B.attributes={};l.program=B;B=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(o in l.uniforms)B.push(o);o=l.program;I=0;for(y=B.length;I<y;I++){n=B[I];o.uniforms[n]=d.getUniformLocation(o,
|
|
|
|
+n)}l=l.program;o=["position","normal","uv","uv2","tangent","color"];B=0;for(I=o.length;B<I;B++){y=o[B];l.attributes[y]=d.getAttribLocation(l,y)}};this.setProgram=function(l,y,B,o,n){o.program||this.initMaterial(o,y,B);var N=o.program,G=N.uniforms,z=o.uniforms;if(N!=aa){d.useProgram(N);aa=N;d.uniformMatrix4fv(G.projectionMatrix,false,H)}if(B&&(o instanceof THREE.MeshBasicMaterial||o instanceof THREE.MeshLambertMaterial||o instanceof THREE.MeshPhongMaterial||o instanceof THREE.LineBasicMaterial||o instanceof
|
|
|
|
+THREE.ParticleBasicMaterial)){z.fogColor.value.setHex(B.color.hex);if(B instanceof THREE.Fog){z.fogNear.value=B.near;z.fogFar.value=B.far}else if(B instanceof THREE.FogExp2)z.fogDensity.value=B.density}if(o instanceof THREE.MeshPhongMaterial||o instanceof THREE.MeshLambertMaterial){this.setupLights(N,y);y=this.lights;z.enableLighting.value=y.directional.length+y.point.length;z.ambientLightColor.value=y.ambient;z.directionalLightColor.value=y.directional.colors;z.directionalLightDirection.value=y.directional.positions;
|
|
|
|
+z.pointLightColor.value=y.point.colors;z.pointLightPosition.value=y.point.positions}if(o instanceof THREE.MeshBasicMaterial||o instanceof THREE.MeshLambertMaterial||o instanceof THREE.MeshPhongMaterial){z.diffuse.value.setRGB(o.color.r*o.opacity,o.color.g*o.opacity,o.color.b*o.opacity);z.opacity.value=o.opacity;z.map.texture=o.map;z.light_map.texture=o.light_map;z.env_map.texture=o.env_map;z.reflectivity.value=o.reflectivity;z.refraction_ratio.value=o.refraction_ratio;z.combine.value=o.combine;z.useRefract.value=
|
|
|
|
+o.env_map&&o.env_map.mapping instanceof THREE.CubeRefractionMapping}if(o instanceof THREE.LineBasicMaterial){z.diffuse.value.setRGB(o.color.r*o.opacity,o.color.g*o.opacity,o.color.b*o.opacity);z.opacity.value=o.opacity}else if(o instanceof THREE.ParticleBasicMaterial){z.psColor.value.setRGB(o.color.r*o.opacity,o.color.g*o.opacity,o.color.b*o.opacity);z.opacity.value=o.opacity;z.size.value=o.size;z.map.texture=o.map}else if(o instanceof THREE.MeshPhongMaterial){z.ambient.value.setRGB(o.ambient.r,o.ambient.g,
|
|
|
|
+o.ambient.b);z.specular.value.setRGB(o.specular.r,o.specular.g,o.specular.b);z.shininess.value=o.shininess}else if(o instanceof THREE.MeshDepthMaterial){z.mNear.value=l.near;z.mFar.value=l.far;z.opacity.value=o.opacity}else if(o instanceof THREE.MeshNormalMaterial)z.opacity.value=o.opacity;var I,D,$;for(I in z)if($=N.uniforms[I]){B=z[I];D=B.type;y=B.value;if(D=="i")d.uniform1i($,y);else if(D=="f")d.uniform1f($,y);else if(D=="fv1")d.uniform1fv($,y);else if(D=="fv")d.uniform3fv($,y);else if(D=="v2")d.uniform2f($,
|
|
|
|
+y.x,y.y);else if(D=="v3")d.uniform3f($,y.x,y.y,y.z);else if(D=="c")d.uniform3f($,y.r,y.g,y.b);else if(D=="t"){d.uniform1i($,y);if(B=B.texture)if(B.image instanceof Array&&B.image.length==6){B=B;y=y;if(B.image.length==6){if(!B.image.__webGLTextureCube&&!B.image.__cubeMapInitialized&&B.image.loadCount==6){B.image.__webGLTextureCube=d.createTexture();d.bindTexture(d.TEXTURE_CUBE_MAP,B.image.__webGLTextureCube);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_CUBE_MAP,
|
|
|
|
+d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MAG_FILTER,d.LINEAR);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MIN_FILTER,d.LINEAR_MIPMAP_LINEAR);for(D=0;D<6;++D)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,B.image[D]);d.generateMipmap(d.TEXTURE_CUBE_MAP);d.bindTexture(d.TEXTURE_CUBE_MAP,null);B.image.__cubeMapInitialized=true}d.activeTexture(d.TEXTURE0+y);d.bindTexture(d.TEXTURE_CUBE_MAP,B.image.__webGLTextureCube)}}else{B=B;y=y;if(!B.__webGLTexture&&
|
|
|
|
+B.image.loaded){B.__webGLTexture=d.createTexture();d.bindTexture(d.TEXTURE_2D,B.__webGLTexture);d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,B.image);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,p(B.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,p(B.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,p(B.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,p(B.min_filter));d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}d.activeTexture(d.TEXTURE0+
|
|
|
|
+y);d.bindTexture(d.TEXTURE_2D,B.__webGLTexture)}}}d.uniformMatrix4fv(G.modelViewMatrix,false,n._modelViewMatrixArray);d.uniformMatrix3fv(G.normalMatrix,false,n._normalMatrixArray);if(o instanceof THREE.MeshShaderMaterial||o instanceof THREE.MeshPhongMaterial||o.env_map)d.uniform3f(G.cameraPosition,l.position.x,l.position.y,l.position.z);if(o instanceof THREE.MeshShaderMaterial||o.env_map)d.uniformMatrix4fv(G.objectMatrix,false,n._objectMatrixArray);if(o instanceof THREE.MeshPhongMaterial||o instanceof
|
|
|
|
+THREE.MeshLambertMaterial||o instanceof THREE.MeshShaderMaterial)d.uniformMatrix4fv(G.viewMatrix,false,Y);return N};this.renderBuffer=function(l,y,B,o,n,N){l=this.setProgram(l,y,B,o,N).attributes;d.bindBuffer(d.ARRAY_BUFFER,n.__webGLVertexBuffer);d.vertexAttribPointer(l.position,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.position);if(l.color>=0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLColorBuffer);d.vertexAttribPointer(l.color,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.color)}if(l.normal>=
|
|
0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLNormalBuffer);d.vertexAttribPointer(l.normal,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.normal)}if(l.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLTangentBuffer);d.vertexAttribPointer(l.tangent,4,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.tangent)}if(l.uv>=0)if(n.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLUVBuffer);d.vertexAttribPointer(l.uv,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.uv)}else d.disableVertexAttribArray(l.uv);if(l.uv2>=
|
|
0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLNormalBuffer);d.vertexAttribPointer(l.normal,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.normal)}if(l.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLTangentBuffer);d.vertexAttribPointer(l.tangent,4,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.tangent)}if(l.uv>=0)if(n.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLUVBuffer);d.vertexAttribPointer(l.uv,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.uv)}else d.disableVertexAttribArray(l.uv);if(l.uv2>=
|
|
-0)if(n.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLUV2Buffer);d.vertexAttribPointer(l.uv2,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.uv2)}else d.disableVertexAttribArray(l.uv2);if(F instanceof THREE.Mesh)if(u.wireframe){d.lineWidth(u.wireframe_linewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);d.drawElements(d.LINES,n.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,n.__webGLFaceCount,d.UNSIGNED_SHORT,
|
|
|
|
-0)}else if(F instanceof THREE.Line){F=F.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(u.linewidth);d.drawArrays(F,0,n.__webGLLineCount)}else F instanceof THREE.ParticleSystem&&d.drawArrays(d.POINTS,0,n.__webGLParticleCount)};this.render=function(l,v,A,u){var n,F,L,G,D,C,R,ba=l.lights,ga=l.fog;v.autoUpdateMatrix&&v.updateMatrix();v.matrix.flattenToArray(J);v.projectionMatrix.flattenToArray(W);Y.multiply(v.projectionMatrix,v.matrix);f(Y);this.initWebGLObjects(l,v);H(A,u!==undefined?u:true);
|
|
|
|
-this.autoClear&&this.clear();G=l.__webGLObjects.length;for(u=0;u<G;u++){n=l.__webGLObjects[u];C=n.object;if(C.visible){if(n.root){C.autoUpdateMatrix&&C.updateMatrix();C.matrixWorld.copy(C.matrix);p(C)}if(!(C instanceof THREE.Mesh)||h(C)){C.matrixWorld.flattenToArray(C._objectMatrixArray);y(C,v);m(n);n.render=true}else n.render=false}else n.render=false}D=l.__webGLObjectsImmediate.length;for(u=0;u<D;u++){n=l.__webGLObjectsImmediate[u];C=n.object;if(C.visible){if(C.autoUpdateMatrix){C.updateMatrix();
|
|
|
|
-C.matrixWorld.copy(C.matrix);C.matrixWorld.flattenToArray(C._objectMatrixArray)}y(C,v);j(n)}}z(THREE.NormalBlending);for(u=0;u<G;u++){n=l.__webGLObjects[u];if(n.render){C=n.object;R=n.buffer;L=n.opaque;g(C);for(n=0;n<L.count;n++){material=L.list[n];this.setDepthTest(material.depth_test);this.renderBuffer(v,ba,ga,material,R,C)}}}for(u=0;u<D;u++){n=l.__webGLObjectsImmediate[u];C=n.object;if(C.visible){L=n.opaque;g(C);for(n=0;n<L.count;n++){material=L.list[n];this.setDepthTest(material.depth_test);F=
|
|
|
|
-this.setProgram(v,ba,ga,material,C);C.render(function(B){e(B,F)})}}}for(u=0;u<G;u++){n=l.__webGLObjects[u];if(n.render){C=n.object;R=n.buffer;L=n.transparent;g(C);for(n=0;n<L.count;n++){material=L.list[n];z(material.blending);this.setDepthTest(material.depth_test);this.renderBuffer(v,ba,ga,material,R,C)}}}for(u=0;u<D;u++){n=l.__webGLObjectsImmediate[u];C=n.object;if(C.visible){L=n.transparent;g(C);for(n=0;n<L.count;n++){material=L.list[n];z(material.blending);this.setDepthTest(material.depth_test);
|
|
|
|
-F=this.setProgram(v,ba,ga,material,C);C.render(function(B){e(B,F)})}}}if(A&&A.min_filter!==THREE.NearestFilter&&A.min_filter!==THREE.LinearFilter){d.bindTexture(d.TEXTURE_2D,A.__webGLTexture);d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}};this.initWebGLObjects=function(l){var v,A,u;if(!l.__webGLObjects){l.__webGLObjects=[];l.__webGLObjectsMap={};l.__webGLObjectsImmediate=[]}v=0;for(A=l.objects.length;v<A;v++){u=l.objects[v];t(l,u,true);x(l,u)}};this.removeObject=function(l,v){var A,
|
|
|
|
-u;for(A=l.__webGLObjects.length-1;A>=0;A--){u=l.__webGLObjects[A].object;v==u&&l.__webGLObjects.splice(A,1)}};this.setDepthTest=function(l){l?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST)};this.setFaceCulling=function(l,v){if(l){!v||v=="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW);if(l=="back")d.cullFace(d.BACK);else l=="front"?d.cullFace(d.FRONT):d.cullFace(d.FRONT_AND_BACK);d.enable(d.CULL_FACE)}else d.disable(d.CULL_FACE)};this.supportsVertexTextures=function(){return d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
|
|
|
|
|
|
+0)if(n.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLUV2Buffer);d.vertexAttribPointer(l.uv2,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.uv2)}else d.disableVertexAttribArray(l.uv2);if(N instanceof THREE.Mesh)if(o.wireframe){d.lineWidth(o.wireframe_linewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);d.drawElements(d.LINES,n.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,n.__webGLFaceCount,d.UNSIGNED_SHORT,
|
|
|
|
+0)}else if(N instanceof THREE.Line){N=N.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(o.linewidth);d.drawArrays(N,0,n.__webGLLineCount)}else N instanceof THREE.ParticleSystem&&d.drawArrays(d.POINTS,0,n.__webGLParticleCount)};this.render=function(l,y,B,o){var n,N,G,z,I,D,$,da=l.lights,C=l.fog;y.autoUpdateMatrix&&y.updateMatrix();y.matrix.flattenToArray(Y);y.projectionMatrix.flattenToArray(H);V.multiply(y.projectionMatrix,y.matrix);f(V);this.initWebGLObjects(l,y);v(B,o!==undefined?o:true);
|
|
|
|
+this.autoClear&&this.clear();z=l.__webGLObjects.length;for(o=0;o<z;o++){n=l.__webGLObjects[o];D=n.object;if(D.visible){if(n.root){D.autoUpdateMatrix&&D.updateMatrix();D.matrixWorld.copy(D.matrix);q(D)}if(!(D instanceof THREE.Mesh)||h(D)){D.matrixWorld.flattenToArray(D._objectMatrixArray);A(D,y);m(n);n.render=true;ea.copy(D.position);V.multiplyVector3(ea);n.z=ea.z}else n.render=false}else n.render=false}l.__webGLObjects.sort(w);I=l.__webGLObjectsImmediate.length;for(o=0;o<I;o++){n=l.__webGLObjectsImmediate[o];
|
|
|
|
+D=n.object;if(D.visible){if(D.autoUpdateMatrix){D.updateMatrix();D.matrixWorld.copy(D.matrix);D.matrixWorld.flattenToArray(D._objectMatrixArray)}A(D,y);j(n)}}E(THREE.NormalBlending);for(o=0;o<z;o++){n=l.__webGLObjects[o];if(n.render){D=n.object;$=n.buffer;G=n.opaque;g(D);for(n=0;n<G.count;n++){material=G.list[n];this.setDepthTest(material.depth_test);this.renderBuffer(y,da,C,material,$,D)}}}for(o=0;o<I;o++){n=l.__webGLObjectsImmediate[o];D=n.object;if(D.visible){G=n.opaque;g(D);for(n=0;n<G.count;n++){material=
|
|
|
|
+G.list[n];this.setDepthTest(material.depth_test);N=this.setProgram(y,da,C,material,D);D.render(function(L){e(L,N)})}}}for(o=0;o<z;o++){n=l.__webGLObjects[o];if(n.render){D=n.object;$=n.buffer;G=n.transparent;g(D);for(n=0;n<G.count;n++){material=G.list[n];E(material.blending);this.setDepthTest(material.depth_test);this.renderBuffer(y,da,C,material,$,D)}}}for(o=0;o<I;o++){n=l.__webGLObjectsImmediate[o];D=n.object;if(D.visible){G=n.transparent;g(D);for(n=0;n<G.count;n++){material=G.list[n];E(material.blending);
|
|
|
|
+this.setDepthTest(material.depth_test);N=this.setProgram(y,da,C,material,D);D.render(function(L){e(L,N)})}}}if(B&&B.min_filter!==THREE.NearestFilter&&B.min_filter!==THREE.LinearFilter){d.bindTexture(d.TEXTURE_2D,B.__webGLTexture);d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}};this.initWebGLObjects=function(l){var y,B,o;if(!l.__webGLObjects){l.__webGLObjects=[];l.__webGLObjectsMap={};l.__webGLObjectsImmediate=[]}y=0;for(B=l.objects.length;y<B;y++){o=l.objects[y];t(l,o,true);u(l,
|
|
|
|
+o)}};this.removeObject=function(l,y){var B,o;for(B=l.__webGLObjects.length-1;B>=0;B--){o=l.__webGLObjects[B].object;y==o&&l.__webGLObjects.splice(B,1)}};this.setDepthTest=function(l){l?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST)};this.setFaceCulling=function(l,y){if(l){!y||y=="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW);if(l=="back")d.cullFace(d.BACK);else l=="front"?d.cullFace(d.FRONT):d.cullFace(d.FRONT_AND_BACK);d.enable(d.CULL_FACE)}else d.disable(d.CULL_FACE)};this.supportsVertexTextures=function(){return d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
|
|
0}};
|
|
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, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
|
|
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, gl_FragColor.w ), 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\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\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",
|
|
envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\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",
|
|
@@ -231,17 +231,17 @@ THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=ne
|
|
THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
|
|
THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
|
|
THREE.Detector={canvas:!!document.createElement("canvas").getContext,webgl:window.Uint8Array!=undefined,workers:!!window.Worker,addGetWebGLMessage:function(a){var b=document.body,c="oldie";if(a){if(a.parent!==undefined)b=a.parent;if(a.id!==undefined)c=a.id}a=document.createElement("center");var e=document.createElement("div");e.innerHTML='Sorry, your browser doesn\'t support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a><br/>\n<br/>\nPlease try in\n<a href="http://www.google.com/chrome">Chrome 9+</a> /\n<a href="http://www.mozilla.com/en-US/firefox/all-beta.html">Firefox 4+</a> /\n<a href="http://nightly.webkit.org/">Safari OSX 10.6+</a>';e.id=
|
|
THREE.Detector={canvas:!!document.createElement("canvas").getContext,webgl:window.Uint8Array!=undefined,workers:!!window.Worker,addGetWebGLMessage:function(a){var b=document.body,c="oldie";if(a){if(a.parent!==undefined)b=a.parent;if(a.id!==undefined)c=a.id}a=document.createElement("center");var e=document.createElement("div");e.innerHTML='Sorry, your browser doesn\'t support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a><br/>\n<br/>\nPlease try in\n<a href="http://www.google.com/chrome">Chrome 9+</a> /\n<a href="http://www.mozilla.com/en-US/firefox/all-beta.html">Firefox 4+</a> /\n<a href="http://nightly.webkit.org/">Safari OSX 10.6+</a>';e.id=
|
|
c;c=e.style;c.fontFamily="monospace";c.fontSize="13px";c.textAlign="center";c.background="#eee";c.color="#000";c.padding="1em";c.width="475px";c.margin="5em auto 0";a.appendChild(e);b.appendChild(a);return e}};
|
|
c;c=e.style;c.fontFamily="monospace";c.fontSize="13px";c.textAlign="center";c.background="#eee";c.color="#000";c.padding="1em";c.width="475px";c.margin="5em auto 0";a.appendChild(e);b.appendChild(a);return e}};
|
|
-var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,e=a.vertices.length,g=c?b.geometry:b,f=a.vertices,h=g.vertices,k=a.faces,j=g.faces,m=a.uvs;g=g.uvs;c&&b.autoUpdateMatrix&&b.updateMatrix();for(var p=0,x=h.length;p<x;p++){var t=new THREE.Vertex(h[p].position.clone());c&&b.matrix.multiplyVector3(t.position);f.push(t)}p=0;for(x=j.length;p<x;p++){h=j[p];var q,y=h.vertexNormals;if(h instanceof THREE.Face3)q=new THREE.Face3(h.a+e,h.b+e,h.c+e);else if(h instanceof THREE.Face4)q=new THREE.Face4(h.a+
|
|
|
|
-e,h.b+e,h.c+e,h.d+e);q.centroid.copy(h.centroid);q.normal.copy(h.normal);c=0;for(f=y.length;c<f;c++){t=y[c];q.vertexNormals.push(t.clone())}q.materials=h.materials.slice();k.push(q)}p=0;for(x=g.length;p<x;p++){e=g[p];k=[];c=0;for(f=e.length;c<f;c++)k.push(new THREE.UV(e[c].u,e[c].v));m.push(k)}}},ImageUtils={loadTexture:function(a,b,c){var e=new Image;e.onload=function(){this.loaded=true;c&&c(this)};e.src=a;return new THREE.Texture(e,b)},loadArray:function(a,b){var c,e,g=[];c=g.loadCount=0;for(e=
|
|
|
|
-a.length;c<e;++c){g[c]=new Image;g[c].loaded=0;g[c].onload=function(){g.loadCount+=1;this.loaded=true;b&&b(this)};g[c].src=a[c]}return g}},SceneUtils={loadScene:function(a,b,c,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(g){function f(){for(p in N.objects)if(!J.objects[p]){z=N.objects[p];if(o=J.geometries[z.geometry]){aa=[];for(i=0;i<z.materials.length;i++)aa[i]=J.materials[z.materials[i]];H=z.position;r=z.rotation;s=z.scale;object=new THREE.Mesh(o,aa);object.position.set(H[0],H[1],H[2]);
|
|
|
|
-object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=z.visible;J.scene.addObject(object);J.objects[p]=object}}}function h(X){return function(ha){J.geometries[X]=ha;f();U-=1;k()}}function k(){e({total_models:Y,total_textures:W,loaded_models:Y-U,loaded_textures:W-O},J);U==0&&O==0&&c(J)}var j,m,p,x,t,q,y,z,H,w,E,o,d,P,aa,N,M,U,O,Y,W,J;N=g.data;M=new THREE.Loader;O=U=0;J={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
|
|
|
|
-g=function(){O-=1;k()};for(t in N.cameras){w=N.cameras[t];if(w.type=="perspective")d=new THREE.Camera(w.fov,w.aspect,w.near,w.far);else if(w.type=="ortho"){d=new THREE.Camera;d.projectionMatrix=THREE.Matrix4.makeOrtho(w.left,w.right,w.top,w.bottom,w.near,w.far)}H=w.position;w=w.target;d.position.set(H[0],H[1],H[2]);d.target.position.set(w[0],w[1],w[2]);J.cameras[t]=d}for(x in N.lights){t=N.lights[x];if(t.type=="directional"){H=t.direction;light=new THREE.DirectionalLight;light.position.set(H[0],H[1],
|
|
|
|
-H[2]);light.position.normalize()}else if(t.type=="point"){H=t.position;light=new THREE.PointLight;light.position.set(H[0],H[1],H[2])}w=t.color;i=t.intensity||1;light.color.setRGB(w[0]*i,w[1]*i,w[2]*i);J.scene.addLight(light);J.lights[x]=light}for(q in N.fogs){x=N.fogs[q];if(x.type=="linear")P=new THREE.Fog(0,x.near,x.far);else if(x.type=="exp2")P=new THREE.FogExp2(0,x.density);w=x.color;P.color.setRGB(w[0],w[1],w[2]);J.fogs[q]=P}if(J.cameras&&N.defaults.camera)J.currentCamera=J.cameras[N.defaults.camera];
|
|
|
|
-if(J.fogs&&N.defaults.fog)J.scene.fog=J.fogs[N.defaults.fog];w=N.defaults.bgcolor;J.bgColor=new THREE.Color;J.bgColor.setRGB(w[0],w[1],w[2]);J.bgColorAlpha=N.defaults.bgalpha;for(j in N.geometries){q=N.geometries[j];if(q.type=="bin_mesh"||q.type=="ascii_mesh")U+=1}Y=U;for(j in N.geometries){q=N.geometries[j];if(q.type=="cube"){o=new Cube(q.width,q.height,q.depth,q.segments_width,q.segments_height,null,q.flipped,q.sides);J.geometries[j]=o}else if(q.type=="plane"){o=new Plane(q.width,q.height,q.segments_width,
|
|
|
|
-q.segments_height);J.geometries[j]=o}else if(q.type=="sphere"){o=new Sphere(q.radius,q.segments_width,q.segments_height);J.geometries[j]=o}else if(q.type=="cylinder"){o=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);J.geometries[j]=o}else if(q.type=="torus"){o=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);J.geometries[j]=o}else if(q.type=="icosahedron"){o=new Icosahedron(q.subdivisions);J.geometries[j]=o}else if(q.type=="bin_mesh")M.loadBinary({model:q.url,callback:h(j)});
|
|
|
|
-else q.type=="ascii_mesh"&&M.loadAscii({model:q.url,callback:h(j)})}for(y in N.textures){j=N.textures[y];O+=j.url instanceof Array?j.url.length:1}W=O;for(y in N.textures){j=N.textures[y];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array){q=ImageUtils.loadArray(j.url,g);q=new THREE.Texture(q,j.mapping)}else{q=ImageUtils.loadTexture(j.url,j.mapping,g);if(THREE[j.min_filter]!=undefined)q.min_filter=THREE[j.min_filter];if(THREE[j.mag_filter]!=
|
|
|
|
-undefined)q.mag_filter=THREE[j.mag_filter]}J.textures[y]=q}for(m in N.materials){y=N.materials[m];for(E in y.parameters)if(E=="env_map"||E=="map"||E=="light_map")y.parameters[E]=J.textures[y.parameters[E]];else if(E=="shading")y.parameters[E]=y.parameters[E]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(E=="blending")y.parameters[E]=THREE[y.parameters[E]]?THREE[y.parameters[E]]:THREE.NormalBlending;else if(E=="combine")y.parameters[E]=y.parameters[E]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
|
|
|
|
-y=new THREE[y.type](y.parameters);J.materials[m]=y}f();b(J)}},addMesh:function(a,b,c,e,g,f,h,k,j,m){b=new THREE.Mesh(b,m);b.scale.x=b.scale.y=b.scale.z=c;b.position.x=e;b.position.y=g;b.position.z=f;b.rotation.x=h;b.rotation.y=k;b.rotation.z=j;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,c){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=c;c=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,uniforms:e.uniforms});b=new THREE.Mesh(new Cube(b,
|
|
|
|
|
|
+var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,e=a.vertices.length,g=c?b.geometry:b,f=a.vertices,h=g.vertices,k=a.faces,j=g.faces,m=a.uvs;g=g.uvs;c&&b.autoUpdateMatrix&&b.updateMatrix();for(var q=0,w=h.length;q<w;q++){var u=new THREE.Vertex(h[q].position.clone());c&&b.matrix.multiplyVector3(u.position);f.push(u)}q=0;for(w=j.length;q<w;q++){h=j[q];var t,x=h.vertexNormals;if(h instanceof THREE.Face3)t=new THREE.Face3(h.a+e,h.b+e,h.c+e);else if(h instanceof THREE.Face4)t=new THREE.Face4(h.a+
|
|
|
|
+e,h.b+e,h.c+e,h.d+e);t.centroid.copy(h.centroid);t.normal.copy(h.normal);c=0;for(f=x.length;c<f;c++){u=x[c];t.vertexNormals.push(u.clone())}t.materials=h.materials.slice();k.push(t)}q=0;for(w=g.length;q<w;q++){e=g[q];k=[];c=0;for(f=e.length;c<f;c++)k.push(new THREE.UV(e[c].u,e[c].v));m.push(k)}}},ImageUtils={loadTexture:function(a,b,c){var e=new Image;e.onload=function(){this.loaded=true;c&&c(this)};e.src=a;return new THREE.Texture(e,b)},loadArray:function(a,b){var c,e,g=[];c=g.loadCount=0;for(e=
|
|
|
|
+a.length;c<e;++c){g[c]=new Image;g[c].loaded=0;g[c].onload=function(){g.loadCount+=1;this.loaded=true;b&&b(this)};g[c].src=a[c]}return g}},SceneUtils={loadScene:function(a,b,c,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(g){function f(){for(q in O.objects)if(!H.objects[q]){A=O.objects[q];if(p=H.geometries[A.geometry]){aa=[];for(i=0;i<A.materials.length;i++)aa[i]=H.materials[A.materials[i]];E=A.position;r=A.rotation;s=A.scale;object=new THREE.Mesh(p,aa);object.position.set(E[0],E[1],E[2]);
|
|
|
|
+object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=A.visible;H.scene.addObject(object);H.objects[q]=object}}}function h(Y){return function(ea){H.geometries[Y]=ea;f();X-=1;k()}}function k(){e({total_models:U,total_textures:V,loaded_models:U-X,loaded_textures:V-Q},H);X==0&&Q==0&&c(H)}var j,m,q,w,u,t,x,A,E,v,F,p,M,d,aa,O,K,X,Q,U,V,H;O=g.data;K=new THREE.Loader;Q=X=0;H={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
|
|
|
|
+g=function(){Q-=1;k()};for(u in O.cameras){v=O.cameras[u];if(v.type=="perspective")M=new THREE.Camera(v.fov,v.aspect,v.near,v.far);else if(v.type=="ortho"){M=new THREE.Camera;M.projectionMatrix=THREE.Matrix4.makeOrtho(v.left,v.right,v.top,v.bottom,v.near,v.far)}E=v.position;v=v.target;M.position.set(E[0],E[1],E[2]);M.target.position.set(v[0],v[1],v[2]);H.cameras[u]=M}for(w in O.lights){u=O.lights[w];if(u.type=="directional"){E=u.direction;light=new THREE.DirectionalLight;light.position.set(E[0],E[1],
|
|
|
|
+E[2]);light.position.normalize()}else if(u.type=="point"){E=u.position;light=new THREE.PointLight;light.position.set(E[0],E[1],E[2])}v=u.color;i=u.intensity||1;light.color.setRGB(v[0]*i,v[1]*i,v[2]*i);H.scene.addLight(light);H.lights[w]=light}for(t in O.fogs){w=O.fogs[t];if(w.type=="linear")d=new THREE.Fog(0,w.near,w.far);else if(w.type=="exp2")d=new THREE.FogExp2(0,w.density);v=w.color;d.color.setRGB(v[0],v[1],v[2]);H.fogs[t]=d}if(H.cameras&&O.defaults.camera)H.currentCamera=H.cameras[O.defaults.camera];
|
|
|
|
+if(H.fogs&&O.defaults.fog)H.scene.fog=H.fogs[O.defaults.fog];v=O.defaults.bgcolor;H.bgColor=new THREE.Color;H.bgColor.setRGB(v[0],v[1],v[2]);H.bgColorAlpha=O.defaults.bgalpha;for(j in O.geometries){t=O.geometries[j];if(t.type=="bin_mesh"||t.type=="ascii_mesh")X+=1}U=X;for(j in O.geometries){t=O.geometries[j];if(t.type=="cube"){p=new Cube(t.width,t.height,t.depth,t.segments_width,t.segments_height,null,t.flipped,t.sides);H.geometries[j]=p}else if(t.type=="plane"){p=new Plane(t.width,t.height,t.segments_width,
|
|
|
|
+t.segments_height);H.geometries[j]=p}else if(t.type=="sphere"){p=new Sphere(t.radius,t.segments_width,t.segments_height);H.geometries[j]=p}else if(t.type=="cylinder"){p=new Cylinder(t.numSegs,t.topRad,t.botRad,t.height,t.topOffset,t.botOffset);H.geometries[j]=p}else if(t.type=="torus"){p=new Torus(t.radius,t.tube,t.segmentsR,t.segmentsT);H.geometries[j]=p}else if(t.type=="icosahedron"){p=new Icosahedron(t.subdivisions);H.geometries[j]=p}else if(t.type=="bin_mesh")K.loadBinary({model:t.url,callback:h(j)});
|
|
|
|
+else t.type=="ascii_mesh"&&K.loadAscii({model:t.url,callback:h(j)})}for(x in O.textures){j=O.textures[x];Q+=j.url instanceof Array?j.url.length:1}V=Q;for(x in O.textures){j=O.textures[x];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array){t=ImageUtils.loadArray(j.url,g);t=new THREE.Texture(t,j.mapping)}else{t=ImageUtils.loadTexture(j.url,j.mapping,g);if(THREE[j.min_filter]!=undefined)t.min_filter=THREE[j.min_filter];if(THREE[j.mag_filter]!=
|
|
|
|
+undefined)t.mag_filter=THREE[j.mag_filter]}H.textures[x]=t}for(m in O.materials){x=O.materials[m];for(F in x.parameters)if(F=="env_map"||F=="map"||F=="light_map")x.parameters[F]=H.textures[x.parameters[F]];else if(F=="shading")x.parameters[F]=x.parameters[F]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(F=="blending")x.parameters[F]=THREE[x.parameters[F]]?THREE[x.parameters[F]]:THREE.NormalBlending;else if(F=="combine")x.parameters[F]=x.parameters[F]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
|
|
|
|
+x=new THREE[x.type](x.parameters);H.materials[m]=x}f();b(H)}},addMesh:function(a,b,c,e,g,f,h,k,j,m){b=new THREE.Mesh(b,m);b.scale.x=b.scale.y=b.scale.z=c;b.position.x=e;b.position.y=g;b.position.z=f;b.rotation.x=h;b.rotation.y=k;b.rotation.z=j;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,c){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=c;c=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),c);a.addObject(b);return b},addPanoramaCube:function(a,b,c){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));b=new THREE.Mesh(new Cube(b,
|
|
b,b,1,1,null,true),c);a.addObject(b);return b},addPanoramaCube:function(a,b,c){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[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,c){var e=b/2;b=new Plane(b,b);var g=Math.PI/2,f=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));SceneUtils.addMesh(a,b,1,-e,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));SceneUtils.addMesh(a,b,1,e,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));SceneUtils.addMesh(a,b,1,0,e,0,g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));
|
|
b,b,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(b);return b},addPanoramaCubePlanes:function(a,b,c){var e=b/2;b=new Plane(b,b);var g=Math.PI/2,f=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));SceneUtils.addMesh(a,b,1,-e,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));SceneUtils.addMesh(a,b,1,e,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));SceneUtils.addMesh(a,b,1,0,e,0,g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));
|
|
SceneUtils.addMesh(a,b,1,0,-e,0,-g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[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}",
|
|
SceneUtils.addMesh(a,b,1,0,-e,0,-g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[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}",
|
|
@@ -253,38 +253,38 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying ve
|
|
value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertex_shader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
|
|
value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertex_shader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
|
|
film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},grayscale:{type:"i",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nconst float fNintensity = 0.35;\nconst float fSintensity = 0.35;\nconst float fScount = 4096.0;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time * 1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin(vUv.y * fScount), cos(vUv.y * fScount) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * fSintensity;\ncResult = cTextureScreen.rgb + clamp( fNintensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor = vec4( cResult, cTextureScreen.a );\n}"},
|
|
film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},grayscale:{type:"i",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nconst float fNintensity = 0.35;\nconst float fSintensity = 0.35;\nconst float fScount = 4096.0;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time * 1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin(vUv.y * fScount), cos(vUv.y * fScount) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * fSintensity;\ncResult = cTextureScreen.rgb + clamp( fNintensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor = vec4( cResult, cTextureScreen.a );\n}"},
|
|
screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
|
|
screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\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}"}},buildKernel:function(a){var b,c,e,g,f=2*Math.ceil(a*3)+1;if(f>25)f=25;g=(f-1)*0.5;c=Array(f);for(b=e=0;b<f;++b){c[b]=Math.exp(-((b-g)*(b-g))/(2*a*a));e+=c[b]}for(b=0;b<f;++b)c[b]/=e;return c}},Cube=function(a,b,c,e,g,f,h,k){function j(z,H,w,E,o,d,P,aa){var N,M,U=e||1,O=g||1,Y=U+1,W=O+1,J=o/2,X=d/2;o=o/U;var ha=d/O,Z=m.vertices.length;if(z=="x"&&H=="y"||z=="y"&&H=="x")N="z";else if(z=="x"&&H=="z"||z=="z"&&H=="x")N="y";
|
|
|
|
-else if(z=="z"&&H=="y"||z=="y"&&H=="z")N="x";for(M=0;M<W;M++)for(d=0;d<Y;d++){var ea=new THREE.Vector3;ea[z]=(d*o-J)*w;ea[H]=(M*ha-X)*E;ea[N]=P;m.vertices.push(new THREE.Vertex(ea))}for(M=0;M<O;M++)for(d=0;d<U;d++){m.faces.push(new THREE.Face4(d+Y*M+Z,d+Y*(M+1)+Z,d+1+Y*(M+1)+Z,d+1+Y*M+Z,null,aa));m.uvs.push([new THREE.UV(d/U,M/O),new THREE.UV(d/U,(M+1)/O),new THREE.UV((d+1)/U,(M+1)/O),new THREE.UV((d+1)/U,M/O)])}}THREE.Geometry.call(this);var m=this,p=a/2,x=b/2,t=c/2;h=h?-1:1;if(f!==undefined)if(f instanceof
|
|
|
|
-Array)this.materials=f;else{this.materials=[];for(var q=0;q<6;q++)this.materials.push([f])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(k!=undefined)for(var y in k)if(this.sides[y]!=undefined)this.sides[y]=k[y];this.sides.px&&j("z","y",1*h,-1,c,b,-p,this.materials[0]);this.sides.nx&&j("z","y",-1*h,-1,c,b,p,this.materials[1]);this.sides.py&&j("x","z",1*h,1,a,c,x,this.materials[2]);this.sides.ny&&j("x","z",1*h,-1,a,c,-x,this.materials[3]);this.sides.pz&&j("x",
|
|
|
|
-"y",1*h,-1,a,b,t,this.materials[4]);this.sides.nz&&j("x","y",-1*h,-1,a,b,-t,this.materials[5]);(function(){for(var z=[],H=[],w=0,E=m.vertices.length;w<E;w++){for(var o=m.vertices[w],d=false,P=0,aa=z.length;P<aa;P++){var N=z[P];if(o.position.x==N.position.x&&o.position.y==N.position.y&&o.position.z==N.position.z){H[w]=P;d=true;break}}if(!d){H[w]=z.length;z.push(new THREE.Vertex(o.position.clone()))}}w=0;for(E=m.faces.length;w<E;w++){o=m.faces[w];o.a=H[o.a];o.b=H[o.b];o.c=H[o.c];o.d=H[o.d]}m.vertices=
|
|
|
|
-z})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
|
|
|
|
-var Cylinder=function(a,b,c,e,g){function f(m,p,x){h.vertices.push(new THREE.Vertex(new THREE.Vector3(m,p,x)))}THREE.Geometry.call(this);var h=this,k=Math.PI,j;for(j=0;j<a;j++)f(Math.sin(2*k*j/a)*b,Math.cos(2*k*j/a)*b,0);for(j=0;j<a;j++)f(Math.sin(2*k*j/a)*c,Math.cos(2*k*j/a)*c,e);for(j=0;j<a;j++)h.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(c!=0){f(0,0,-g);for(j=a;j<a+a/2;j++)h.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){f(0,0,e+g);for(j=a+a/2;j<
|
|
|
|
|
|
+fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var b,c,e,g,f=2*Math.ceil(a*3)+1;if(f>25)f=25;g=(f-1)*0.5;c=Array(f);for(b=e=0;b<f;++b){c[b]=Math.exp(-((b-g)*(b-g))/(2*a*a));e+=c[b]}for(b=0;b<f;++b)c[b]/=e;return c}},Cube=function(a,b,c,e,g,f,h,k){function j(A,E,v,F,p,M,d,aa){var O,K,X=e||1,Q=g||1,U=X+1,V=Q+1,H=p/2,Y=M/2;p=p/X;var ea=M/Q,Z=m.vertices.length;if(A=="x"&&E=="y"||A=="y"&&E=="x")O="z";else if(A=="x"&&E=="z"||A=="z"&&E=="x")O="y";
|
|
|
|
+else if(A=="z"&&E=="y"||A=="y"&&E=="z")O="x";for(K=0;K<V;K++)for(M=0;M<U;M++){var fa=new THREE.Vector3;fa[A]=(M*p-H)*v;fa[E]=(K*ea-Y)*F;fa[O]=d;m.vertices.push(new THREE.Vertex(fa))}for(K=0;K<Q;K++)for(M=0;M<X;M++){m.faces.push(new THREE.Face4(M+U*K+Z,M+U*(K+1)+Z,M+1+U*(K+1)+Z,M+1+U*K+Z,null,aa));m.uvs.push([new THREE.UV(M/X,K/Q),new THREE.UV(M/X,(K+1)/Q),new THREE.UV((M+1)/X,(K+1)/Q),new THREE.UV((M+1)/X,K/Q)])}}THREE.Geometry.call(this);var m=this,q=a/2,w=b/2,u=c/2;h=h?-1:1;if(f!==undefined)if(f instanceof
|
|
|
|
+Array)this.materials=f;else{this.materials=[];for(var t=0;t<6;t++)this.materials.push([f])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(k!=undefined)for(var x in k)if(this.sides[x]!=undefined)this.sides[x]=k[x];this.sides.px&&j("z","y",1*h,-1,c,b,-q,this.materials[0]);this.sides.nx&&j("z","y",-1*h,-1,c,b,q,this.materials[1]);this.sides.py&&j("x","z",1*h,1,a,c,w,this.materials[2]);this.sides.ny&&j("x","z",1*h,-1,a,c,-w,this.materials[3]);this.sides.pz&&j("x",
|
|
|
|
+"y",1*h,-1,a,b,u,this.materials[4]);this.sides.nz&&j("x","y",-1*h,-1,a,b,-u,this.materials[5]);(function(){for(var A=[],E=[],v=0,F=m.vertices.length;v<F;v++){for(var p=m.vertices[v],M=false,d=0,aa=A.length;d<aa;d++){var O=A[d];if(p.position.x==O.position.x&&p.position.y==O.position.y&&p.position.z==O.position.z){E[v]=d;M=true;break}}if(!M){E[v]=A.length;A.push(new THREE.Vertex(p.position.clone()))}}v=0;for(F=m.faces.length;v<F;v++){p=m.faces[v];p.a=E[p.a];p.b=E[p.b];p.c=E[p.c];p.d=E[p.d]}m.vertices=
|
|
|
|
+A})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
|
|
|
|
+var Cylinder=function(a,b,c,e,g){function f(m,q,w){h.vertices.push(new THREE.Vertex(new THREE.Vector3(m,q,w)))}THREE.Geometry.call(this);var h=this,k=Math.PI,j;for(j=0;j<a;j++)f(Math.sin(2*k*j/a)*b,Math.cos(2*k*j/a)*b,0);for(j=0;j<a;j++)f(Math.sin(2*k*j/a)*c,Math.cos(2*k*j/a)*c,e);for(j=0;j<a;j++)h.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(c!=0){f(0,0,-g);for(j=a;j<a+a/2;j++)h.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){f(0,0,e+g);for(j=a+a/2;j<
|
|
2*a;j++)h.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;
|
|
2*a;j++)h.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,c,e){THREE.Geometry.call(this);var g,f=a/2,h=b/2;c=c||1;e=e||1;var k=c+1,j=e+1;a=a/c;var m=b/e;for(g=0;g<j;g++)for(b=0;b<k;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-f,-(g*m-h),0)));for(g=0;g<e;g++)for(b=0;b<c;b++){this.faces.push(new THREE.Face4(b+k*g,b+k*(g+1),b+1+k*(g+1),b+1+k*g));this.uvs.push([new THREE.UV(b/c,g/e),new THREE.UV(b/c,(g+1)/e),new THREE.UV((b+1)/c,(g+1)/e),new THREE.UV((b+1)/c,g/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
|
|
var Plane=function(a,b,c,e){THREE.Geometry.call(this);var g,f=a/2,h=b/2;c=c||1;e=e||1;var k=c+1,j=e+1;a=a/c;var m=b/e;for(g=0;g<j;g++)for(b=0;b<k;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-f,-(g*m-h),0)));for(g=0;g<e;g++)for(b=0;b<c;b++){this.faces.push(new THREE.Face4(b+k*g,b+k*(g+1),b+1+k*(g+1),b+1+k*g));this.uvs.push([new THREE.UV(b/c,g/e),new THREE.UV(b/c,(g+1)/e),new THREE.UV((b+1)/c,(g+1)/e),new THREE.UV((b+1)/c,g/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
|
|
Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
|
|
Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
|
|
-var Sphere=function(a,b,c){THREE.Geometry.call(this);var e,g=Math.PI,f=Math.max(3,b||8),h=Math.max(2,c||6);b=[];for(c=0;c<h+1;c++){e=c/h;var k=a*Math.cos(e*g),j=a*Math.sin(e*g),m=[],p=0;for(e=0;e<f;e++){var x=2*e/f,t=j*Math.sin(x*g);x=j*Math.cos(x*g);(c==0||c==h)&&e>0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,t)))-1);m.push(p)}b.push(m)}var q,y,z;g=b.length;for(c=0;c<g;c++){f=b[c].length;if(c>0)for(e=0;e<f;e++){m=e==f-1;h=b[c][m?0:e+1];k=b[c][m?f-1:e];j=b[c-1][m?f-1:e];m=b[c-1][m?
|
|
|
|
-0:e+1];t=c/(g-1);q=(c-1)/(g-1);y=(e+1)/f;x=e/f;p=new THREE.UV(1-y,t);t=new THREE.UV(1-x,t);x=new THREE.UV(1-x,q);var H=new THREE.UV(1-y,q);if(c<b.length-1){q=this.vertices[h].position.clone();y=this.vertices[k].position.clone();z=this.vertices[j].position.clone();q.normalize();y.normalize();z.normalize();this.faces.push(new THREE.Face3(h,k,j,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(z.x,z.y,z.z)]));this.uvs.push([p,t,x])}if(c>1){q=this.vertices[h].position.clone();
|
|
|
|
-y=this.vertices[j].position.clone();z=this.vertices[m].position.clone();q.normalize();y.normalize();z.normalize();this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(z.x,z.y,z.z)]));this.uvs.push([p,x,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
|
|
|
|
|
|
+var Sphere=function(a,b,c){THREE.Geometry.call(this);var e,g=Math.PI,f=Math.max(3,b||8),h=Math.max(2,c||6);b=[];for(c=0;c<h+1;c++){e=c/h;var k=a*Math.cos(e*g),j=a*Math.sin(e*g),m=[],q=0;for(e=0;e<f;e++){var w=2*e/f,u=j*Math.sin(w*g);w=j*Math.cos(w*g);(c==0||c==h)&&e>0||(q=this.vertices.push(new THREE.Vertex(new THREE.Vector3(w,k,u)))-1);m.push(q)}b.push(m)}var t,x,A;g=b.length;for(c=0;c<g;c++){f=b[c].length;if(c>0)for(e=0;e<f;e++){m=e==f-1;h=b[c][m?0:e+1];k=b[c][m?f-1:e];j=b[c-1][m?f-1:e];m=b[c-1][m?
|
|
|
|
+0:e+1];u=c/(g-1);t=(c-1)/(g-1);x=(e+1)/f;w=e/f;q=new THREE.UV(1-x,u);u=new THREE.UV(1-w,u);w=new THREE.UV(1-w,t);var E=new THREE.UV(1-x,t);if(c<b.length-1){t=this.vertices[h].position.clone();x=this.vertices[k].position.clone();A=this.vertices[j].position.clone();t.normalize();x.normalize();A.normalize();this.faces.push(new THREE.Face3(h,k,j,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([q,u,w])}if(c>1){t=this.vertices[h].position.clone();
|
|
|
|
+x=this.vertices[j].position.clone();A=this.vertices[m].position.clone();t.normalize();x.normalize();A.normalize();this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([q,w,E])}}}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,c,e){this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){e=c/this.segmentsT*2*Math.PI;var g=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(e),(this.radius+this.tube*Math.cos(g))*Math.sin(e),this.tube*Math.sin(g))));a.push([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c=
|
|
var Torus=function(a,b,c,e){this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){e=c/this.segmentsT*2*Math.PI;var g=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(e),(this.radius+this.tube*Math.cos(g))*Math.sin(e),this.tube*Math.sin(g))));a.push([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c=
|
|
1;c<=this.segmentsT;++c){e=(this.segmentsT+1)*b+c;g=(this.segmentsT+1)*b+c-1;var f=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(e,g,f,h));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
|
|
1;c<=this.segmentsT;++c){e=(this.segmentsT+1)*b+c;g=(this.segmentsT+1)*b+c-1;var f=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(e,g,f,h));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
|
|
-var Icosahedron=function(a){function b(x,t,q){var y=Math.sqrt(x*x+t*t+q*q);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(x/y,t/y,q/y)))-1}function c(x,t,q,y){y.faces.push(new THREE.Face3(x,t,q))}function e(x,t){var q=g.vertices[x].position,y=g.vertices[t].position;return b((q.x+y.x)/2,(q.y+y.y)/2,(q.z+y.z)/2)}var g=this,f=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0,
|
|
|
|
-1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,f);c(0,5,1,f);c(0,1,7,f);c(0,7,10,f);c(0,10,11,f);c(1,5,9,f);c(5,11,4,f);c(11,10,2,f);c(10,7,6,f);c(7,1,8,f);c(3,9,4,f);c(3,4,2,f);c(3,2,6,f);c(3,6,8,f);c(3,8,9,f);c(4,9,5,f);c(2,4,11,f);c(6,2,10,f);c(8,6,7,f);c(9,8,1,f);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var k in f.faces){var j=e(f.faces[k].a,f.faces[k].b),m=e(f.faces[k].b,f.faces[k].c),p=e(f.faces[k].c,f.faces[k].a);c(f.faces[k].a,j,p,h);c(f.faces[k].b,m,j,h);c(f.faces[k].c,
|
|
|
|
-p,m,h);c(j,m,p,h)}f.faces=h.faces}g.faces=f.faces;delete f;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
|
|
|
|
|
|
+var Icosahedron=function(a){function b(w,u,t){var x=Math.sqrt(w*w+u*u+t*t);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(w/x,u/x,t/x)))-1}function c(w,u,t,x){x.faces.push(new THREE.Face3(w,u,t))}function e(w,u){var t=g.vertices[w].position,x=g.vertices[u].position;return b((t.x+x.x)/2,(t.y+x.y)/2,(t.z+x.z)/2)}var g=this,f=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0,
|
|
|
|
+1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,f);c(0,5,1,f);c(0,1,7,f);c(0,7,10,f);c(0,10,11,f);c(1,5,9,f);c(5,11,4,f);c(11,10,2,f);c(10,7,6,f);c(7,1,8,f);c(3,9,4,f);c(3,4,2,f);c(3,2,6,f);c(3,6,8,f);c(3,8,9,f);c(4,9,5,f);c(2,4,11,f);c(6,2,10,f);c(8,6,7,f);c(9,8,1,f);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var k in f.faces){var j=e(f.faces[k].a,f.faces[k].b),m=e(f.faces[k].b,f.faces[k].c),q=e(f.faces[k].c,f.faces[k].a);c(f.faces[k].a,j,q,h);c(f.faces[k].b,m,j,h);c(f.faces[k].c,
|
|
|
|
+q,m,h);c(j,m,q,h)}f.faces=h.faces}g.faces=f.faces;delete f;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
|
|
function LathedObject(a,b,c){THREE.Geometry.call(this);b=b||12;c=c||2*Math.PI;b=c/b;for(var e=[],g=[],f=[],h=[],k=0;k<a.length;k++){this.vertices.push(new THREE.Vertex(a[k]));g[k]=this.vertices.length-1;e[k]=new THREE.Vector3(a[k].x,a[k].y,a[k].z)}for(var j=THREE.Matrix4.rotationZMatrix(b),m=0;m<=c+0.0010;m+=b){for(k=0;k<e.length;k++)if(m<c){e[k]=j.multiplyVector3(e[k].clone());this.vertices.push(new THREE.Vertex(e[k]));f[k]=this.vertices.length-1}else f=h;if(m==0)h=g;for(k=0;k<g.length-1;k++){this.faces.push(new THREE.Face4(f[k],
|
|
function LathedObject(a,b,c){THREE.Geometry.call(this);b=b||12;c=c||2*Math.PI;b=c/b;for(var e=[],g=[],f=[],h=[],k=0;k<a.length;k++){this.vertices.push(new THREE.Vertex(a[k]));g[k]=this.vertices.length-1;e[k]=new THREE.Vector3(a[k].x,a[k].y,a[k].z)}for(var j=THREE.Matrix4.rotationZMatrix(b),m=0;m<=c+0.0010;m+=b){for(k=0;k<e.length;k++)if(m<c){e[k]=j.multiplyVector3(e[k].clone());this.vertices.push(new THREE.Vertex(e[k]));f[k]=this.vertices.length-1}else f=h;if(m==0)h=g;for(k=0;k<g.length-1;k++){this.faces.push(new THREE.Face4(f[k],
|
|
f[k+1],g[k+1],g[k]));this.uvs.push([new THREE.UV(m/c,k/a.length),new THREE.UV(m/c,(k+1)/a.length),new THREE.UV((m-b)/c,(k+1)/a.length),new THREE.UV((m-b)/c,k/a.length)])}g=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
|
|
f[k+1],g[k+1],g[k]));this.uvs.push([new THREE.UV(m/c,k/a.length),new THREE.UV(m/c,(k+1)/a.length),new THREE.UV((m-b)/c,(k+1)/a.length),new THREE.UV((m-b)/c,k/a.length)])}g=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
|
|
THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b];this.init=function(c){this.isolation=80;this.size=c;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=true;this.maxCount=4096;this.count=
|
|
THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b];this.init=function(c){this.isolation=80;this.size=c;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=true;this.maxCount=4096;this.count=
|
|
-0;this.hasNormal=this.hasPos=false;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(c,e,g){return c+(e-c)*g};this.VIntX=function(c,e,g,f,h,k,j,m,p,x){h=(h-p)/(x-p);p=this.normal_cache;e[f]=k+h*this.delta;e[f+1]=j;e[f+2]=m;g[f]=this.lerp(p[c],p[c+3],h);g[f+1]=this.lerp(p[c+1],p[c+4],h);g[f+2]=this.lerp(p[c+2],p[c+5],h)};this.VIntY=function(c,e,g,f,h,k,j,m,p,x){h=(h-p)/(x-p);p=this.normal_cache;e[f]=k;e[f+1]=j+h*this.delta;e[f+
|
|
|
|
-2]=m;e=c+this.yd*3;g[f]=this.lerp(p[c],p[e],h);g[f+1]=this.lerp(p[c+1],p[e+1],h);g[f+2]=this.lerp(p[c+2],p[e+2],h)};this.VIntZ=function(c,e,g,f,h,k,j,m,p,x){h=(h-p)/(x-p);p=this.normal_cache;e[f]=k;e[f+1]=j;e[f+2]=m+h*this.delta;e=c+this.zd*3;g[f]=this.lerp(p[c],p[e],h);g[f+1]=this.lerp(p[c+1],p[e+1],h);g[f+2]=this.lerp(p[c+2],p[e+2],h)};this.compNorm=function(c){var e=c*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[c-1]-this.field[c+1];this.normal_cache[e+1]=this.field[c-this.yd]-
|
|
|
|
-this.field[c+this.yd];this.normal_cache[e+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,e,g,f,h,k){var j=f+1,m=f+this.yd,p=f+this.zd,x=j+this.yd,t=j+this.zd,q=f+this.yd+this.zd,y=j+this.yd+this.zd,z=0,H=this.field[f],w=this.field[j],E=this.field[m],o=this.field[x],d=this.field[p],P=this.field[t],aa=this.field[q],N=this.field[y];if(H<h)z|=1;if(w<h)z|=2;if(E<h)z|=8;if(o<h)z|=4;if(d<h)z|=16;if(P<h)z|=32;if(aa<h)z|=128;if(N<h)z|=64;var M=THREE.edgeTable[z];if(M==0)return 0;
|
|
|
|
-var U=this.delta,O=c+U,Y=e+U;U=g+U;if(M&1){this.compNorm(f);this.compNorm(j);this.VIntX(f*3,this.vlist,this.nlist,0,h,c,e,g,H,w)}if(M&2){this.compNorm(j);this.compNorm(x);this.VIntY(j*3,this.vlist,this.nlist,3,h,O,e,g,w,o)}if(M&4){this.compNorm(m);this.compNorm(x);this.VIntX(m*3,this.vlist,this.nlist,6,h,c,Y,g,E,o)}if(M&8){this.compNorm(f);this.compNorm(m);this.VIntY(f*3,this.vlist,this.nlist,9,h,c,e,g,H,E)}if(M&16){this.compNorm(p);this.compNorm(t);this.VIntX(p*3,this.vlist,this.nlist,12,h,c,e,U,
|
|
|
|
-d,P)}if(M&32){this.compNorm(t);this.compNorm(y);this.VIntY(t*3,this.vlist,this.nlist,15,h,O,e,U,P,N)}if(M&64){this.compNorm(q);this.compNorm(y);this.VIntX(q*3,this.vlist,this.nlist,18,h,c,Y,U,aa,N)}if(M&128){this.compNorm(p);this.compNorm(q);this.VIntY(p*3,this.vlist,this.nlist,21,h,c,e,U,d,aa)}if(M&256){this.compNorm(f);this.compNorm(p);this.VIntZ(f*3,this.vlist,this.nlist,24,h,c,e,g,H,d)}if(M&512){this.compNorm(j);this.compNorm(t);this.VIntZ(j*3,this.vlist,this.nlist,27,h,O,e,g,w,P)}if(M&1024){this.compNorm(x);
|
|
|
|
-this.compNorm(y);this.VIntZ(x*3,this.vlist,this.nlist,30,h,O,Y,g,o,N)}if(M&2048){this.compNorm(m);this.compNorm(q);this.VIntZ(m*3,this.vlist,this.nlist,33,h,c,Y,g,E,aa)}z<<=4;for(h=f=0;THREE.triTable[z+h]!=-1;){c=z+h;e=c+1;g=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[e],3*THREE.triTable[g],k);h+=3;f++}return f};this.posnormtriv=function(c,e,g,f,h,k){var j=this.count*3;this.positionArray[j]=c[g];this.positionArray[j+1]=c[g+1];this.positionArray[j+2]=c[g+2];this.positionArray[j+
|
|
|
|
|
|
+0;this.hasNormal=this.hasPos=false;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(c,e,g){return c+(e-c)*g};this.VIntX=function(c,e,g,f,h,k,j,m,q,w){h=(h-q)/(w-q);q=this.normal_cache;e[f]=k+h*this.delta;e[f+1]=j;e[f+2]=m;g[f]=this.lerp(q[c],q[c+3],h);g[f+1]=this.lerp(q[c+1],q[c+4],h);g[f+2]=this.lerp(q[c+2],q[c+5],h)};this.VIntY=function(c,e,g,f,h,k,j,m,q,w){h=(h-q)/(w-q);q=this.normal_cache;e[f]=k;e[f+1]=j+h*this.delta;e[f+
|
|
|
|
+2]=m;e=c+this.yd*3;g[f]=this.lerp(q[c],q[e],h);g[f+1]=this.lerp(q[c+1],q[e+1],h);g[f+2]=this.lerp(q[c+2],q[e+2],h)};this.VIntZ=function(c,e,g,f,h,k,j,m,q,w){h=(h-q)/(w-q);q=this.normal_cache;e[f]=k;e[f+1]=j;e[f+2]=m+h*this.delta;e=c+this.zd*3;g[f]=this.lerp(q[c],q[e],h);g[f+1]=this.lerp(q[c+1],q[e+1],h);g[f+2]=this.lerp(q[c+2],q[e+2],h)};this.compNorm=function(c){var e=c*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[c-1]-this.field[c+1];this.normal_cache[e+1]=this.field[c-this.yd]-
|
|
|
|
+this.field[c+this.yd];this.normal_cache[e+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,e,g,f,h,k){var j=f+1,m=f+this.yd,q=f+this.zd,w=j+this.yd,u=j+this.zd,t=f+this.yd+this.zd,x=j+this.yd+this.zd,A=0,E=this.field[f],v=this.field[j],F=this.field[m],p=this.field[w],M=this.field[q],d=this.field[u],aa=this.field[t],O=this.field[x];if(E<h)A|=1;if(v<h)A|=2;if(F<h)A|=8;if(p<h)A|=4;if(M<h)A|=16;if(d<h)A|=32;if(aa<h)A|=128;if(O<h)A|=64;var K=THREE.edgeTable[A];if(K==0)return 0;
|
|
|
|
+var X=this.delta,Q=c+X,U=e+X;X=g+X;if(K&1){this.compNorm(f);this.compNorm(j);this.VIntX(f*3,this.vlist,this.nlist,0,h,c,e,g,E,v)}if(K&2){this.compNorm(j);this.compNorm(w);this.VIntY(j*3,this.vlist,this.nlist,3,h,Q,e,g,v,p)}if(K&4){this.compNorm(m);this.compNorm(w);this.VIntX(m*3,this.vlist,this.nlist,6,h,c,U,g,F,p)}if(K&8){this.compNorm(f);this.compNorm(m);this.VIntY(f*3,this.vlist,this.nlist,9,h,c,e,g,E,F)}if(K&16){this.compNorm(q);this.compNorm(u);this.VIntX(q*3,this.vlist,this.nlist,12,h,c,e,X,
|
|
|
|
+M,d)}if(K&32){this.compNorm(u);this.compNorm(x);this.VIntY(u*3,this.vlist,this.nlist,15,h,Q,e,X,d,O)}if(K&64){this.compNorm(t);this.compNorm(x);this.VIntX(t*3,this.vlist,this.nlist,18,h,c,U,X,aa,O)}if(K&128){this.compNorm(q);this.compNorm(t);this.VIntY(q*3,this.vlist,this.nlist,21,h,c,e,X,M,aa)}if(K&256){this.compNorm(f);this.compNorm(q);this.VIntZ(f*3,this.vlist,this.nlist,24,h,c,e,g,E,M)}if(K&512){this.compNorm(j);this.compNorm(u);this.VIntZ(j*3,this.vlist,this.nlist,27,h,Q,e,g,v,d)}if(K&1024){this.compNorm(w);
|
|
|
|
+this.compNorm(x);this.VIntZ(w*3,this.vlist,this.nlist,30,h,Q,U,g,p,O)}if(K&2048){this.compNorm(m);this.compNorm(t);this.VIntZ(m*3,this.vlist,this.nlist,33,h,c,U,g,F,aa)}A<<=4;for(h=f=0;THREE.triTable[A+h]!=-1;){c=A+h;e=c+1;g=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[e],3*THREE.triTable[g],k);h+=3;f++}return f};this.posnormtriv=function(c,e,g,f,h,k){var j=this.count*3;this.positionArray[j]=c[g];this.positionArray[j+1]=c[g+1];this.positionArray[j+2]=c[g+2];this.positionArray[j+
|
|
3]=c[f];this.positionArray[j+4]=c[f+1];this.positionArray[j+5]=c[f+2];this.positionArray[j+6]=c[h];this.positionArray[j+7]=c[h+1];this.positionArray[j+8]=c[h+2];this.normalArray[j]=e[g];this.normalArray[j+1]=e[g+1];this.normalArray[j+2]=e[g+2];this.normalArray[j+3]=e[f];this.normalArray[j+4]=e[f+1];this.normalArray[j+5]=e[f+2];this.normalArray[j+6]=e[h];this.normalArray[j+7]=e[h+1];this.normalArray[j+8]=e[h+2];this.hasNormal=this.hasPos=true;this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=
|
|
3]=c[f];this.positionArray[j+4]=c[f+1];this.positionArray[j+5]=c[f+2];this.positionArray[j+6]=c[h];this.positionArray[j+7]=c[h+1];this.positionArray[j+8]=c[h+2];this.normalArray[j]=e[g];this.normalArray[j+1]=e[g+1];this.normalArray[j+2]=e[g+2];this.normalArray[j+3]=e[f];this.normalArray[j+4]=e[f+1];this.normalArray[j+5]=e[f+2];this.normalArray[j+6]=e[h];this.normalArray[j+7]=e[h+1];this.normalArray[j+8]=e[h+2];this.hasNormal=this.hasPos=true;this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=
|
|
-function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(c){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;c(this)}};this.addBall=function(c,e,g,f,h){var k=this.size*Math.sqrt(f/h),j=g*this.size,m=e*this.size,p=c*this.size,x=Math.floor(j-k);if(x<1)x=1;j=Math.floor(j+k);if(j>this.size-1)j=this.size-1;var t=Math.floor(m-k);if(t<1)t=1;m=Math.floor(m+k);if(m>this.size-1)m=this.size-1;var q=Math.floor(p-k);if(q<1)q=1;k=Math.floor(p+k);
|
|
|
|
-if(k>this.size-1)k=this.size-1;var y,z,H,w,E,o;for(x=x;x<j;x++){p=this.size2*x;z=x/this.size-g;E=z*z;for(z=t;z<m;z++){H=p+this.size*z;y=z/this.size-e;o=y*y;for(y=q;y<k;y++){w=y/this.size-c;w=f/(1.0E-6+w*w+o+E)-h;if(w>0)this.field[H+y]+=w}}}};this.addPlaneX=function(c,e){var g,f,h,k,j,m=this.size,p=this.yd,x=this.zd,t=this.field,q=m*Math.sqrt(c/e);if(q>m)q=m;for(g=0;g<q;g++){f=g/m;f=f*f;k=c/(1.0E-4+f)-e;if(k>0)for(f=0;f<m;f++){j=g+f*p;for(h=0;h<m;h++)t[x*h+j]+=k}}};this.addPlaneY=function(c,e){var g,
|
|
|
|
-f,h,k,j,m,p=this.size,x=this.yd,t=this.zd,q=this.field,y=p*Math.sqrt(c/e);if(y>p)y=p;for(f=0;f<y;f++){g=f/p;g=g*g;k=c/(1.0E-4+g)-e;if(k>0){j=f*x;for(g=0;g<p;g++){m=j+g;for(h=0;h<p;h++)q[t*h+m]+=k}}}};this.addPlaneZ=function(c,e){var g,f,h,k,j,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/e);if(dist>size)dist=size;for(h=0;h<dist;h++){g=h/size;g=g*g;k=c/(1.0E-4+g)-e;if(k>0){j=zd*h;for(f=0;f<size;f++){m=j+f*yd;for(g=0;g<size;g++)field[m+g]+=k}}}};this.reset=function(){var c;
|
|
|
|
-for(c=0;c<this.size3;c++){this.normal_cache[c*3]=0;this.field[c]=0}};this.render=function(c){this.begin();var e,g,f,h,k,j,m,p,x,t=this.size-2;for(h=1;h<t;h++){x=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(f=1;f<t;f++){p=x+this.size*f;j=(f-this.halfsize)/this.halfsize;for(g=1;g<t;g++){k=(g-this.halfsize)/this.halfsize;e=p+g;this.polygonize(k,j,m,e,this.isolation,c)}}}this.end(c)};this.generateGeometry=function(){var c=0,e=new THREE.Geometry;this.render(function(g){var f,h,k,j,m,p,x,t;for(f=
|
|
|
|
-0;f<g.count;f++){m=f*3;x=m+1;t=m+2;h=g.positionArray[m];k=g.positionArray[x];j=g.positionArray[t];p=new THREE.Vector3(h,k,j);h=g.normalArray[m];k=g.normalArray[x];j=g.normalArray[t];m=new THREE.Vector3(h,k,j);m.normalize();m=new THREE.Vertex(p,m);e.vertices.push(m)}nfaces=g.count/3;for(f=0;f<nfaces;f++){m=(c+f)*3;x=m+1;t=m+2;p=e.vertices[m].normal;h=e.vertices[x].normal;k=e.vertices[t].normal;m=new THREE.Face3(m,x,t,[p,h,k]);e.faces.push(m)}c+=nfaces;g.count=0});e.sortFacesByMaterial();return e};
|
|
|
|
|
|
+function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(c){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;c(this)}};this.addBall=function(c,e,g,f,h){var k=this.size*Math.sqrt(f/h),j=g*this.size,m=e*this.size,q=c*this.size,w=Math.floor(j-k);if(w<1)w=1;j=Math.floor(j+k);if(j>this.size-1)j=this.size-1;var u=Math.floor(m-k);if(u<1)u=1;m=Math.floor(m+k);if(m>this.size-1)m=this.size-1;var t=Math.floor(q-k);if(t<1)t=1;k=Math.floor(q+k);
|
|
|
|
+if(k>this.size-1)k=this.size-1;var x,A,E,v,F,p;for(w=w;w<j;w++){q=this.size2*w;A=w/this.size-g;F=A*A;for(A=u;A<m;A++){E=q+this.size*A;x=A/this.size-e;p=x*x;for(x=t;x<k;x++){v=x/this.size-c;v=f/(1.0E-6+v*v+p+F)-h;if(v>0)this.field[E+x]+=v}}}};this.addPlaneX=function(c,e){var g,f,h,k,j,m=this.size,q=this.yd,w=this.zd,u=this.field,t=m*Math.sqrt(c/e);if(t>m)t=m;for(g=0;g<t;g++){f=g/m;f=f*f;k=c/(1.0E-4+f)-e;if(k>0)for(f=0;f<m;f++){j=g+f*q;for(h=0;h<m;h++)u[w*h+j]+=k}}};this.addPlaneY=function(c,e){var g,
|
|
|
|
+f,h,k,j,m,q=this.size,w=this.yd,u=this.zd,t=this.field,x=q*Math.sqrt(c/e);if(x>q)x=q;for(f=0;f<x;f++){g=f/q;g=g*g;k=c/(1.0E-4+g)-e;if(k>0){j=f*w;for(g=0;g<q;g++){m=j+g;for(h=0;h<q;h++)t[u*h+m]+=k}}}};this.addPlaneZ=function(c,e){var g,f,h,k,j,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/e);if(dist>size)dist=size;for(h=0;h<dist;h++){g=h/size;g=g*g;k=c/(1.0E-4+g)-e;if(k>0){j=zd*h;for(f=0;f<size;f++){m=j+f*yd;for(g=0;g<size;g++)field[m+g]+=k}}}};this.reset=function(){var c;
|
|
|
|
+for(c=0;c<this.size3;c++){this.normal_cache[c*3]=0;this.field[c]=0}};this.render=function(c){this.begin();var e,g,f,h,k,j,m,q,w,u=this.size-2;for(h=1;h<u;h++){w=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(f=1;f<u;f++){q=w+this.size*f;j=(f-this.halfsize)/this.halfsize;for(g=1;g<u;g++){k=(g-this.halfsize)/this.halfsize;e=q+g;this.polygonize(k,j,m,e,this.isolation,c)}}}this.end(c)};this.generateGeometry=function(){var c=0,e=new THREE.Geometry;this.render(function(g){var f,h,k,j,m,q,w,u;for(f=
|
|
|
|
+0;f<g.count;f++){m=f*3;w=m+1;u=m+2;h=g.positionArray[m];k=g.positionArray[w];j=g.positionArray[u];q=new THREE.Vector3(h,k,j);h=g.normalArray[m];k=g.normalArray[w];j=g.normalArray[u];m=new THREE.Vector3(h,k,j);m.normalize();m=new THREE.Vertex(q,m);e.vertices.push(m)}nfaces=g.count/3;for(f=0;f<nfaces;f++){m=(c+f)*3;w=m+1;u=m+2;q=e.vertices[m].normal;h=e.vertices[w].normal;k=e.vertices[u].normal;m=new THREE.Face3(m,w,u,[q,h,k]);e.faces.push(m)}c+=nfaces;g.count=0});e.sortFacesByMaterial();return e};
|
|
this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
|
|
this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
|
|
THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
|
|
THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
|
|
1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
|
|
1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
|
|
@@ -314,23 +314,23 @@ THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement
|
|
b},loadAsciiOld:function(a,b){var c=document.createElement("script");c.type="text/javascript";c.onload=b;c.src=a;document.getElementsByTagName("head")[0].appendChild(c)},loadAscii:function(a){var b=a.model,c=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);b.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,c,e)};b.postMessage(a)},loadBinary:function(a){var b=a.model,c=a.callback,e=a.texture_path?a.texture_path:
|
|
b},loadAsciiOld:function(a,b){var c=document.createElement("script");c.type="text/javascript";c.onload=b;c.src=a;document.getElementsByTagName("head")[0].appendChild(c)},loadAscii:function(a){var b=a.model,c=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);b.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,c,e)};b.postMessage(a)},loadBinary:function(a){var b=a.model,c=a.callback,e=a.texture_path?a.texture_path:
|
|
THREE.Loader.prototype.extractUrlbase(b),g=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,c,g,e,f)};b.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,c,e,g,f){var h=new XMLHttpRequest,k=e+"/"+a,j=0;
|
|
THREE.Loader.prototype.extractUrlbase(b),g=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,c,g,e,f)};b.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,c,e,g,f){var h=new XMLHttpRequest,k=e+"/"+a,j=0;
|
|
h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,c,g,b):alert("Couldn't load ["+k+"] ["+h.status+"]");else if(h.readyState==3){if(f){if(j==0)j=h.getResponseHeader("Content-Length");f({total:j,loaded:h.responseText.length})}}else if(h.readyState==2)j=h.getResponseHeader("Content-Length")};h.open("GET",k,true);h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)},
|
|
h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,c,g,b):alert("Couldn't load ["+k+"] ["+h.status+"]");else if(h.readyState==3){if(f){if(j==0)j=h.getResponseHeader("Content-Length");f({total:j,loaded:h.responseText.length})}}else if(h.readyState==2)j=h.getResponseHeader("Content-Length")};h.open("GET",k,true);h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)},
|
|
-createBinModel:function(a,b,c,e){var g=function(f){function h(B,K){var I=p(B,K),Q=p(B,K+1),da=p(B,K+2),V=p(B,K+3),ka=(V<<1&255|da>>7)-127;I=(da&127)<<16|Q<<8|I;if(I==0&&ka==-127)return 0;return(1-2*(V>>7))*(1+I*Math.pow(2,-23))*Math.pow(2,ka)}function k(B,K){var I=p(B,K),Q=p(B,K+1),da=p(B,K+2);return(p(B,K+3)<<24)+(da<<16)+(Q<<8)+I}function j(B,K){var I=p(B,K);return(p(B,K+1)<<8)+I}function m(B,K){var I=p(B,K);return I>127?I-256:I}function p(B,K){return B.charCodeAt(K)&255}function x(B){var K,I,Q;
|
|
|
|
-K=k(a,B);I=k(a,B+aa);Q=k(a,B+N);B=j(a,B+M);THREE.Loader.prototype.f3(w,K,I,Q,B)}function t(B){var K,I,Q,da,V,ka;K=k(a,B);I=k(a,B+aa);Q=k(a,B+N);da=j(a,B+M);V=k(a,B+U);ka=k(a,B+O);B=k(a,B+Y);THREE.Loader.prototype.f3n(w,d,K,I,Q,da,V,ka,B)}function q(B){var K,I,Q,da;K=k(a,B);I=k(a,B+W);Q=k(a,B+J);da=k(a,B+X);B=j(a,B+ha);THREE.Loader.prototype.f4(w,K,I,Q,da,B)}function y(B){var K,I,Q,da,V,ka,pa,ua;K=k(a,B);I=k(a,B+W);Q=k(a,B+J);da=k(a,B+X);V=j(a,B+ha);ka=k(a,B+Z);pa=k(a,B+ea);ua=k(a,B+l);B=k(a,B+v);
|
|
|
|
-THREE.Loader.prototype.f4n(w,d,K,I,Q,da,V,ka,pa,ua,B)}function z(B){var K,I;K=k(a,B);I=k(a,B+A);B=k(a,B+u);THREE.Loader.prototype.uv3(w.uvs,P[K*2],P[K*2+1],P[I*2],P[I*2+1],P[B*2],P[B*2+1])}function H(B){var K,I,Q;K=k(a,B);I=k(a,B+n);Q=k(a,B+F);B=k(a,B+L);THREE.Loader.prototype.uv4(w.uvs,P[K*2],P[K*2+1],P[I*2],P[I*2+1],P[Q*2],P[Q*2+1],P[B*2],P[B*2+1])}var w=this,E=0,o,d=[],P=[],aa,N,M,U,O,Y,W,J,X,ha,Z,ea,l,v,A,u,n,F,L,G,D,C,R,ba,ga;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,
|
|
|
|
-e,f);o={signature:a.substr(E,8),header_bytes:p(a,E+8),vertex_coordinate_bytes:p(a,E+9),normal_coordinate_bytes:p(a,E+10),uv_coordinate_bytes:p(a,E+11),vertex_index_bytes:p(a,E+12),normal_index_bytes:p(a,E+13),uv_index_bytes:p(a,E+14),material_index_bytes:p(a,E+15),nvertices:k(a,E+16),nnormals:k(a,E+16+4),nuvs:k(a,E+16+8),ntri_flat:k(a,E+16+12),ntri_smooth:k(a,E+16+16),ntri_flat_uv:k(a,E+16+20),ntri_smooth_uv:k(a,E+16+24),nquad_flat:k(a,E+16+28),nquad_smooth:k(a,E+16+32),nquad_flat_uv:k(a,E+16+36),
|
|
|
|
-nquad_smooth_uv:k(a,E+16+40)};E+=o.header_bytes;aa=o.vertex_index_bytes;N=o.vertex_index_bytes*2;M=o.vertex_index_bytes*3;U=o.vertex_index_bytes*3+o.material_index_bytes;O=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;Y=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;W=o.vertex_index_bytes;J=o.vertex_index_bytes*2;X=o.vertex_index_bytes*3;ha=o.vertex_index_bytes*4;Z=o.vertex_index_bytes*4+o.material_index_bytes;ea=o.vertex_index_bytes*4+o.material_index_bytes+
|
|
|
|
-o.normal_index_bytes;l=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*2;v=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*3;A=o.uv_index_bytes;u=o.uv_index_bytes*2;n=o.uv_index_bytes;F=o.uv_index_bytes*2;L=o.uv_index_bytes*3;f=o.vertex_index_bytes*3+o.material_index_bytes;ga=o.vertex_index_bytes*4+o.material_index_bytes;G=o.ntri_flat*f;D=o.ntri_smooth*(f+o.normal_index_bytes*3);C=o.ntri_flat_uv*(f+o.uv_index_bytes*3);R=o.ntri_smooth_uv*(f+o.normal_index_bytes*
|
|
|
|
-3+o.uv_index_bytes*3);ba=o.nquad_flat*ga;f=o.nquad_smooth*(ga+o.normal_index_bytes*4);ga=o.nquad_flat_uv*(ga+o.uv_index_bytes*4);E+=function(B){var K,I,Q,da=o.vertex_coordinate_bytes*3,V=B+o.nvertices*da;for(B=B;B<V;B+=da){K=h(a,B);I=h(a,B+o.vertex_coordinate_bytes);Q=h(a,B+o.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(w,K,I,Q)}return o.nvertices*da}(E);E+=function(B){var K,I,Q,da=o.normal_coordinate_bytes*3,V=B+o.nnormals*da;for(B=B;B<V;B+=da){K=m(a,B);I=m(a,B+o.normal_coordinate_bytes);
|
|
|
|
-Q=m(a,B+o.normal_coordinate_bytes*2);d.push(K/127,I/127,Q/127)}return o.nnormals*da}(E);E+=function(B){var K,I,Q=o.uv_coordinate_bytes*2,da=B+o.nuvs*Q;for(B=B;B<da;B+=Q){K=h(a,B);I=h(a,B+o.uv_coordinate_bytes);P.push(K,I)}return o.nuvs*Q}(E);E=E;G=E+G;D=G+D;C=D+C;R=C+R;ba=R+ba;f=ba+f;ga=f+ga;(function(B){var K,I=o.vertex_index_bytes*3+o.material_index_bytes,Q=I+o.uv_index_bytes*3,da=B+o.ntri_flat_uv*Q;for(K=B;K<da;K+=Q){x(K);z(K+I)}return da-B})(D);(function(B){var K,I=o.vertex_index_bytes*3+o.material_index_bytes+
|
|
|
|
-o.normal_index_bytes*3,Q=I+o.uv_index_bytes*3,da=B+o.ntri_smooth_uv*Q;for(K=B;K<da;K+=Q){t(K);z(K+I)}return da-B})(C);(function(B){var K,I=o.vertex_index_bytes*4+o.material_index_bytes,Q=I+o.uv_index_bytes*4,da=B+o.nquad_flat_uv*Q;for(K=B;K<da;K+=Q){q(K);H(K+I)}return da-B})(f);(function(B){var K,I=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,Q=I+o.uv_index_bytes*4,da=B+o.nquad_smooth_uv*Q;for(K=B;K<da;K+=Q){y(K);H(K+I)}return da-B})(ga);(function(B){var K,I=o.vertex_index_bytes*
|
|
|
|
-3+o.material_index_bytes,Q=B+o.ntri_flat*I;for(K=B;K<Q;K+=I)x(K);return Q-B})(E);(function(B){var K,I=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*3,Q=B+o.ntri_smooth*I;for(K=B;K<Q;K+=I)t(K);return Q-B})(G);(function(B){var K,I=o.vertex_index_bytes*4+o.material_index_bytes,Q=B+o.nquad_flat*I;for(K=B;K<Q;K+=I)q(K);return Q-B})(R);(function(B){var K,I=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,Q=B+o.nquad_smooth*I;for(K=B;K<Q;K+=I)y(K);return Q-B})(ba);
|
|
|
|
-this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g(c))},createModel:function(a,b,c){var e=function(g){var f=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,a.materials,g);(function(){var h,k,j,m,p;h=0;for(k=a.vertices.length;h<k;h+=3){j=a.vertices[h];m=a.vertices[h+1];p=a.vertices[h+2];THREE.Loader.prototype.v(f,j,m,p)}if(a.colors){h=0;for(k=a.colors.length;h<k;h+=3){j=a.colors[h];m=
|
|
|
|
-a.colors[h+1];p=a.colors[h+2];THREE.Loader.prototype.vc(f,j,m,p)}}})();(function(){function h(y,z){THREE.Loader.prototype.f3(f,y[z],y[z+1],y[z+2],y[z+3])}function k(y,z){THREE.Loader.prototype.f3n(f,a.normals,y[z],y[z+1],y[z+2],y[z+3],y[z+4],y[z+5],y[z+6])}function j(y,z){THREE.Loader.prototype.f4(f,y[z],y[z+1],y[z+2],y[z+3],y[z+4])}function m(y,z){THREE.Loader.prototype.f4n(f,a.normals,y[z],y[z+1],y[z+2],y[z+3],y[z+4],y[z+5],y[z+6],y[z+7],y[z+8])}function p(y,z){var H,w,E,o,d,P,aa,N,M;H=y[z];w=y[z+
|
|
|
|
-1];E=y[z+2];o=a.uvs[H*2];aa=a.uvs[H*2+1];d=a.uvs[w*2];N=a.uvs[w*2+1];P=a.uvs[E*2];M=a.uvs[E*2+1];THREE.Loader.prototype.uv3(f.uvs,o,aa,d,N,P,M);if(a.uvs2){o=a.uvs2[H*2];aa=a.uvs2[H*2+1];d=a.uvs2[w*2];N=a.uvs2[w*2+1];P=a.uvs2[E*2];M=a.uvs2[E*2+1];THREE.Loader.prototype.uv3(f.uvs2,o,1-aa,d,1-N,P,1-M)}}function x(y,z){var H,w,E,o,d,P,aa,N,M,U,O,Y;H=y[z];w=y[z+1];E=y[z+2];o=y[z+3];d=a.uvs[H*2];M=a.uvs[H*2+1];P=a.uvs[w*2];U=a.uvs[w*2+1];aa=a.uvs[E*2];O=a.uvs[E*2+1];N=a.uvs[o*2];Y=a.uvs[o*2+1];THREE.Loader.prototype.uv4(f.uvs,
|
|
|
|
-d,M,P,U,aa,O,N,Y);if(a.uvs2){d=a.uvs2[H*2];M=a.uvs2[H*2+1];P=a.uvs2[w*2];U=a.uvs2[w*2+1];aa=a.uvs2[E*2];O=a.uvs2[E*2+1];N=a.uvs2[o*2];Y=a.uvs2[o*2+1];THREE.Loader.prototype.uv4(f.uvs2,d,1-M,P,1-U,aa,1-O,N,1-Y)}}var t,q;t=0;for(q=a.triangles_uv.length;t<q;t+=7){h(a.triangles_uv,t);p(a.triangles_uv,t+4)}t=0;for(q=a.triangles_n_uv.length;t<q;t+=10){k(a.triangles_n_uv,t);p(a.triangles_n_uv,t+7)}t=0;for(q=a.quads_uv.length;t<q;t+=9){j(a.quads_uv,t);x(a.quads_uv,t+5)}t=0;for(q=a.quads_n_uv.length;t<q;t+=
|
|
|
|
-13){m(a.quads_n_uv,t);x(a.quads_n_uv,t+9)}t=0;for(q=a.triangles.length;t<q;t+=4)h(a.triangles,t);t=0;for(q=a.triangles_n.length;t<q;t+=7)k(a.triangles_n,t);t=0;for(q=a.quads.length;t<q;t+=5)j(a.quads,t);t=0;for(q=a.quads_n.length;t<q;t+=9)m(a.quads_n,t)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(c))},v:function(a,b,c,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))},vc:function(a,
|
|
|
|
-b,c,e){var g=new THREE.Color(16777215);g.setRGB(b,c,e);a.colors.push(g)},f3:function(a,b,c,e,g){a.faces.push(new THREE.Face3(b,c,e,null,a.materials[g]))},f4:function(a,b,c,e,g,f){a.faces.push(new THREE.Face4(b,c,e,g,null,a.materials[f]))},f3n:function(a,b,c,e,g,f,h,k,j){f=a.materials[f];var m=b[k*3],p=b[k*3+1];k=b[k*3+2];var x=b[j*3],t=b[j*3+1];j=b[j*3+2];a.faces.push(new THREE.Face3(c,e,g,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(m,p,k),new THREE.Vector3(x,t,j)],f))},f4n:function(a,
|
|
|
|
-b,c,e,g,f,h,k,j,m,p){h=a.materials[h];var x=b[j*3],t=b[j*3+1];j=b[j*3+2];var q=b[m*3],y=b[m*3+1];m=b[m*3+2];var z=b[p*3],H=b[p*3+1];p=b[p*3+2];a.faces.push(new THREE.Face4(c,e,g,f,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(x,t,j),new THREE.Vector3(q,y,m),new THREE.Vector3(z,H,p)],h))},uv3:function(a,b,c,e,g,f,h){var k=[];k.push(new THREE.UV(b,c));k.push(new THREE.UV(e,g));k.push(new THREE.UV(f,h));a.push(k)},uv4:function(a,b,c,e,g,f,h,k,j){var m=[];m.push(new THREE.UV(b,c));m.push(new THREE.UV(e,
|
|
|
|
-g));m.push(new THREE.UV(f,h));m.push(new THREE.UV(k,j));a.push(m)},init_materials:function(a,b,c){a.materials=[];for(var e=0;e<b.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(b[e],c)]},createMaterial:function(a,b){function c(k){k=Math.log(k)/Math.LN2;return Math.floor(k)==k}function e(k,j){var m=new Image;m.onload=function(){if(!c(this.width)||!c(this.height)){var p=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),x=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));k.image.width=
|
|
|
|
-p;k.image.height=x;k.image.getContext("2d").drawImage(this,0,0,p,x)}else k.image=this;k.image.loaded=1};m.src=j}var g,f,h;g="MeshLambertMaterial";f={color:15658734,opacity:1,map:null,light_map:null,vertex_colors:a.vertex_colors};if(a.shading)if(a.shading=="Phong")g="MeshPhongMaterial";if(a.map_diffuse&&b){h=document.createElement("canvas");f.map=new THREE.Texture(h);e(f.map,b+"/"+a.map_diffuse)}else if(a.col_diffuse){h=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;f.color=
|
|
|
|
-h;f.opacity=a.transparency}else if(a.a_dbg_color)f.color=a.a_dbg_color;if(a.map_lightmap&&b){h=document.createElement("canvas");f.light_map=new THREE.Texture(h);e(f.light_map,b+"/"+a.map_lightmap)}return new THREE[g](f)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
|
|
|
|
|
|
+createBinModel:function(a,b,c,e){var g=function(f){function h(C,L){var J=q(C,L),R=q(C,L+1),W=q(C,L+2),la=q(C,L+3),S=(la<<1&255|W>>7)-127;J=(W&127)<<16|R<<8|J;if(J==0&&S==-127)return 0;return(1-2*(la>>7))*(1+J*Math.pow(2,-23))*Math.pow(2,S)}function k(C,L){var J=q(C,L),R=q(C,L+1),W=q(C,L+2);return(q(C,L+3)<<24)+(W<<16)+(R<<8)+J}function j(C,L){var J=q(C,L);return(q(C,L+1)<<8)+J}function m(C,L){var J=q(C,L);return J>127?J-256:J}function q(C,L){return C.charCodeAt(L)&255}function w(C){var L,J,R;L=k(a,
|
|
|
|
+C);J=k(a,C+aa);R=k(a,C+O);C=j(a,C+K);THREE.Loader.prototype.f3(v,L,J,R,C)}function u(C){var L,J,R,W,la,S;L=k(a,C);J=k(a,C+aa);R=k(a,C+O);W=j(a,C+K);la=k(a,C+X);S=k(a,C+Q);C=k(a,C+U);THREE.Loader.prototype.f3n(v,M,L,J,R,W,la,S,C)}function t(C){var L,J,R,W;L=k(a,C);J=k(a,C+V);R=k(a,C+H);W=k(a,C+Y);C=j(a,C+ea);THREE.Loader.prototype.f4(v,L,J,R,W,C)}function x(C){var L,J,R,W,la,S,ta,sa;L=k(a,C);J=k(a,C+V);R=k(a,C+H);W=k(a,C+Y);la=j(a,C+ea);S=k(a,C+Z);ta=k(a,C+fa);sa=k(a,C+ia);C=k(a,C+l);THREE.Loader.prototype.f4n(v,
|
|
|
|
+M,L,J,R,W,la,S,ta,sa,C)}function A(C){var L,J;L=k(a,C);J=k(a,C+y);C=k(a,C+B);THREE.Loader.prototype.uv3(v.uvs,d[L*2],d[L*2+1],d[J*2],d[J*2+1],d[C*2],d[C*2+1])}function E(C){var L,J,R;L=k(a,C);J=k(a,C+o);R=k(a,C+n);C=k(a,C+N);THREE.Loader.prototype.uv4(v.uvs,d[L*2],d[L*2+1],d[J*2],d[J*2+1],d[R*2],d[R*2+1],d[C*2],d[C*2+1])}var v=this,F=0,p,M=[],d=[],aa,O,K,X,Q,U,V,H,Y,ea,Z,fa,ia,l,y,B,o,n,N,G,z,I,D,$,da;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,e,f);p={signature:a.substr(F,8),
|
|
|
|
+header_bytes:q(a,F+8),vertex_coordinate_bytes:q(a,F+9),normal_coordinate_bytes:q(a,F+10),uv_coordinate_bytes:q(a,F+11),vertex_index_bytes:q(a,F+12),normal_index_bytes:q(a,F+13),uv_index_bytes:q(a,F+14),material_index_bytes:q(a,F+15),nvertices:k(a,F+16),nnormals:k(a,F+16+4),nuvs:k(a,F+16+8),ntri_flat:k(a,F+16+12),ntri_smooth:k(a,F+16+16),ntri_flat_uv:k(a,F+16+20),ntri_smooth_uv:k(a,F+16+24),nquad_flat:k(a,F+16+28),nquad_smooth:k(a,F+16+32),nquad_flat_uv:k(a,F+16+36),nquad_smooth_uv:k(a,F+16+40)};F+=
|
|
|
|
+p.header_bytes;aa=p.vertex_index_bytes;O=p.vertex_index_bytes*2;K=p.vertex_index_bytes*3;X=p.vertex_index_bytes*3+p.material_index_bytes;Q=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes;U=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*2;V=p.vertex_index_bytes;H=p.vertex_index_bytes*2;Y=p.vertex_index_bytes*3;ea=p.vertex_index_bytes*4;Z=p.vertex_index_bytes*4+p.material_index_bytes;fa=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes;ia=p.vertex_index_bytes*
|
|
|
|
+4+p.material_index_bytes+p.normal_index_bytes*2;l=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*3;y=p.uv_index_bytes;B=p.uv_index_bytes*2;o=p.uv_index_bytes;n=p.uv_index_bytes*2;N=p.uv_index_bytes*3;f=p.vertex_index_bytes*3+p.material_index_bytes;da=p.vertex_index_bytes*4+p.material_index_bytes;G=p.ntri_flat*f;z=p.ntri_smooth*(f+p.normal_index_bytes*3);I=p.ntri_flat_uv*(f+p.uv_index_bytes*3);D=p.ntri_smooth_uv*(f+p.normal_index_bytes*3+p.uv_index_bytes*3);$=p.nquad_flat*da;f=
|
|
|
|
+p.nquad_smooth*(da+p.normal_index_bytes*4);da=p.nquad_flat_uv*(da+p.uv_index_bytes*4);F+=function(C){var L,J,R,W=p.vertex_coordinate_bytes*3,la=C+p.nvertices*W;for(C=C;C<la;C+=W){L=h(a,C);J=h(a,C+p.vertex_coordinate_bytes);R=h(a,C+p.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(v,L,J,R)}return p.nvertices*W}(F);F+=function(C){var L,J,R,W=p.normal_coordinate_bytes*3,la=C+p.nnormals*W;for(C=C;C<la;C+=W){L=m(a,C);J=m(a,C+p.normal_coordinate_bytes);R=m(a,C+p.normal_coordinate_bytes*2);M.push(L/
|
|
|
|
+127,J/127,R/127)}return p.nnormals*W}(F);F+=function(C){var L,J,R=p.uv_coordinate_bytes*2,W=C+p.nuvs*R;for(C=C;C<W;C+=R){L=h(a,C);J=h(a,C+p.uv_coordinate_bytes);d.push(L,J)}return p.nuvs*R}(F);F=F;G=F+G;z=G+z;I=z+I;D=I+D;$=D+$;f=$+f;da=f+da;(function(C){var L,J=p.vertex_index_bytes*3+p.material_index_bytes,R=J+p.uv_index_bytes*3,W=C+p.ntri_flat_uv*R;for(L=C;L<W;L+=R){w(L);A(L+J)}return W-C})(z);(function(C){var L,J=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*3,R=J+p.uv_index_bytes*
|
|
|
|
+3,W=C+p.ntri_smooth_uv*R;for(L=C;L<W;L+=R){u(L);A(L+J)}return W-C})(I);(function(C){var L,J=p.vertex_index_bytes*4+p.material_index_bytes,R=J+p.uv_index_bytes*4,W=C+p.nquad_flat_uv*R;for(L=C;L<W;L+=R){t(L);E(L+J)}return W-C})(f);(function(C){var L,J=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*4,R=J+p.uv_index_bytes*4,W=C+p.nquad_smooth_uv*R;for(L=C;L<W;L+=R){x(L);E(L+J)}return W-C})(da);(function(C){var L,J=p.vertex_index_bytes*3+p.material_index_bytes,R=C+p.ntri_flat*J;for(L=
|
|
|
|
+C;L<R;L+=J)w(L);return R-C})(F);(function(C){var L,J=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*3,R=C+p.ntri_smooth*J;for(L=C;L<R;L+=J)u(L);return R-C})(G);(function(C){var L,J=p.vertex_index_bytes*4+p.material_index_bytes,R=C+p.nquad_flat*J;for(L=C;L<R;L+=J)t(L);return R-C})(D);(function(C){var L,J=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*4,R=C+p.nquad_smooth*J;for(L=C;L<R;L+=J)x(L);return R-C})($);this.computeCentroids();this.computeFaceNormals();
|
|
|
|
+this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g(c))},createModel:function(a,b,c){var e=function(g){var f=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,a.materials,g);(function(){var h,k,j,m,q;h=0;for(k=a.vertices.length;h<k;h+=3){j=a.vertices[h];m=a.vertices[h+1];q=a.vertices[h+2];THREE.Loader.prototype.v(f,j,m,q)}if(a.colors){h=0;for(k=a.colors.length;h<k;h+=3){j=a.colors[h];m=a.colors[h+1];q=a.colors[h+2];THREE.Loader.prototype.vc(f,
|
|
|
|
+j,m,q)}}})();(function(){function h(x,A){THREE.Loader.prototype.f3(f,x[A],x[A+1],x[A+2],x[A+3])}function k(x,A){THREE.Loader.prototype.f3n(f,a.normals,x[A],x[A+1],x[A+2],x[A+3],x[A+4],x[A+5],x[A+6])}function j(x,A){THREE.Loader.prototype.f4(f,x[A],x[A+1],x[A+2],x[A+3],x[A+4])}function m(x,A){THREE.Loader.prototype.f4n(f,a.normals,x[A],x[A+1],x[A+2],x[A+3],x[A+4],x[A+5],x[A+6],x[A+7],x[A+8])}function q(x,A){var E,v,F,p,M,d,aa,O,K;E=x[A];v=x[A+1];F=x[A+2];p=a.uvs[E*2];aa=a.uvs[E*2+1];M=a.uvs[v*2];O=
|
|
|
|
+a.uvs[v*2+1];d=a.uvs[F*2];K=a.uvs[F*2+1];THREE.Loader.prototype.uv3(f.uvs,p,aa,M,O,d,K);if(a.uvs2){p=a.uvs2[E*2];aa=a.uvs2[E*2+1];M=a.uvs2[v*2];O=a.uvs2[v*2+1];d=a.uvs2[F*2];K=a.uvs2[F*2+1];THREE.Loader.prototype.uv3(f.uvs2,p,1-aa,M,1-O,d,1-K)}}function w(x,A){var E,v,F,p,M,d,aa,O,K,X,Q,U;E=x[A];v=x[A+1];F=x[A+2];p=x[A+3];M=a.uvs[E*2];K=a.uvs[E*2+1];d=a.uvs[v*2];X=a.uvs[v*2+1];aa=a.uvs[F*2];Q=a.uvs[F*2+1];O=a.uvs[p*2];U=a.uvs[p*2+1];THREE.Loader.prototype.uv4(f.uvs,M,K,d,X,aa,Q,O,U);if(a.uvs2){M=
|
|
|
|
+a.uvs2[E*2];K=a.uvs2[E*2+1];d=a.uvs2[v*2];X=a.uvs2[v*2+1];aa=a.uvs2[F*2];Q=a.uvs2[F*2+1];O=a.uvs2[p*2];U=a.uvs2[p*2+1];THREE.Loader.prototype.uv4(f.uvs2,M,1-K,d,1-X,aa,1-Q,O,1-U)}}var u,t;u=0;for(t=a.triangles_uv.length;u<t;u+=7){h(a.triangles_uv,u);q(a.triangles_uv,u+4)}u=0;for(t=a.triangles_n_uv.length;u<t;u+=10){k(a.triangles_n_uv,u);q(a.triangles_n_uv,u+7)}u=0;for(t=a.quads_uv.length;u<t;u+=9){j(a.quads_uv,u);w(a.quads_uv,u+5)}u=0;for(t=a.quads_n_uv.length;u<t;u+=13){m(a.quads_n_uv,u);w(a.quads_n_uv,
|
|
|
|
+u+9)}u=0;for(t=a.triangles.length;u<t;u+=4)h(a.triangles,u);u=0;for(t=a.triangles_n.length;u<t;u+=7)k(a.triangles_n,u);u=0;for(t=a.quads.length;u<t;u+=5)j(a.quads,u);u=0;for(t=a.quads_n.length;u<t;u+=9)m(a.quads_n,u)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(c))},v:function(a,b,c,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))},vc:function(a,b,c,e){var g=new THREE.Color(16777215);
|
|
|
|
+g.setRGB(b,c,e);a.colors.push(g)},f3:function(a,b,c,e,g){a.faces.push(new THREE.Face3(b,c,e,null,a.materials[g]))},f4:function(a,b,c,e,g,f){a.faces.push(new THREE.Face4(b,c,e,g,null,a.materials[f]))},f3n:function(a,b,c,e,g,f,h,k,j){f=a.materials[f];var m=b[k*3],q=b[k*3+1];k=b[k*3+2];var w=b[j*3],u=b[j*3+1];j=b[j*3+2];a.faces.push(new THREE.Face3(c,e,g,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(m,q,k),new THREE.Vector3(w,u,j)],f))},f4n:function(a,b,c,e,g,f,h,k,j,m,q){h=a.materials[h];
|
|
|
|
+var w=b[j*3],u=b[j*3+1];j=b[j*3+2];var t=b[m*3],x=b[m*3+1];m=b[m*3+2];var A=b[q*3],E=b[q*3+1];q=b[q*3+2];a.faces.push(new THREE.Face4(c,e,g,f,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(w,u,j),new THREE.Vector3(t,x,m),new THREE.Vector3(A,E,q)],h))},uv3:function(a,b,c,e,g,f,h){var k=[];k.push(new THREE.UV(b,c));k.push(new THREE.UV(e,g));k.push(new THREE.UV(f,h));a.push(k)},uv4:function(a,b,c,e,g,f,h,k,j){var m=[];m.push(new THREE.UV(b,c));m.push(new THREE.UV(e,g));m.push(new THREE.UV(f,
|
|
|
|
+h));m.push(new THREE.UV(k,j));a.push(m)},init_materials:function(a,b,c){a.materials=[];for(var e=0;e<b.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(b[e],c)]},createMaterial:function(a,b){function c(k){k=Math.log(k)/Math.LN2;return Math.floor(k)==k}function e(k,j){var m=new Image;m.onload=function(){if(!c(this.width)||!c(this.height)){var q=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),w=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));k.image.width=q;k.image.height=
|
|
|
|
+w;k.image.getContext("2d").drawImage(this,0,0,q,w)}else k.image=this;k.image.loaded=1};m.src=j}var g,f,h;g="MeshLambertMaterial";f={color:15658734,opacity:1,map:null,light_map:null,vertex_colors:a.vertex_colors};if(a.shading)if(a.shading=="Phong")g="MeshPhongMaterial";if(a.map_diffuse&&b){h=document.createElement("canvas");f.map=new THREE.Texture(h);e(f.map,b+"/"+a.map_diffuse)}else if(a.col_diffuse){h=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;f.color=h;f.opacity=a.transparency}else if(a.a_dbg_color)f.color=
|
|
|
|
+a.a_dbg_color;if(a.map_lightmap&&b){h=document.createElement("canvas");f.light_map=new THREE.Texture(h);e(f.light_map,b+"/"+a.map_lightmap)}return new THREE[g](f)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
|