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