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