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