|
@@ -1,212 +1,212 @@
|
|
|
-// ThreeExtras.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,e=this.z;this.x=d*a.z-e*a.y;this.y=e*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,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1};
|
|
|
-THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
|
|
|
-return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
|
|
|
-THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
|
|
|
-THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){d=e[a];if(d instanceof THREE.Mesh)g=g.concat(this.intersectObject(d))}g.sort(function(j,l){return j.distance-l.distance});return g},intersectObject:function(a){function b(H,I,z,m){m=m.clone().subSelf(I);z=z.clone().subSelf(I);var h=H.clone().subSelf(I);H=m.dot(m);I=m.dot(z);m=m.dot(h);var n=z.dot(z);z=z.dot(h);h=1/(H*n-I*I);n=(n*m-I*z)*h;H=(H*z-I*m)*h;return n>0&&H>0&&n+H<1}var d,e,g,j,l,f,q,c,t,D,
|
|
|
-r,u=a.geometry,v=u.vertices,w=[];d=0;for(e=u.faces.length;d<e;d++){g=u.faces[d];D=this.origin.clone();r=this.direction.clone();j=a.matrix.multiplyVector3(v[g.a].position.clone());l=a.matrix.multiplyVector3(v[g.b].position.clone());f=a.matrix.multiplyVector3(v[g.c].position.clone());q=g instanceof THREE.Face4?a.matrix.multiplyVector3(v[g.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(g.normal.clone());t=r.dot(c);if(t<0){c=c.dot((new THREE.Vector3).sub(j,D))/t;D=D.addSelf(r.multiplyScalar(c));
|
|
|
-if(g instanceof THREE.Face3){if(b(D,j,l,f)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};w.push(g)}}else if(g instanceof THREE.Face4)if(b(D,j,l,q)||b(D,l,f,q)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};w.push(g)}}}return w}};
|
|
|
-THREE.Rectangle=function(){function a(){j=e-b;l=g-d}var b,d,e,g,j,l,f=true;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return j};this.getHeight=function(){return l};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(q,c,t,D){f=false;b=q;d=c;e=t;g=D;a()};this.addPoint=function(q,c){if(f){f=false;b=q;d=c;e=q;g=c}else{b=Math.min(b,q);d=Math.min(d,c);e=Math.max(e,
|
|
|
-q);g=Math.max(g,c)}a()};this.addRectangle=function(q){if(f){f=false;b=q.getLeft();d=q.getTop();e=q.getRight();g=q.getBottom()}else{b=Math.min(b,q.getLeft());d=Math.min(d,q.getTop());e=Math.max(e,q.getRight());g=Math.max(g,q.getBottom())}a()};this.inflate=function(q){b-=q;d-=q;e+=q;g+=q;a()};this.minSelf=function(q){b=Math.max(b,q.getLeft());d=Math.max(d,q.getTop());e=Math.min(e,q.getRight());g=Math.min(g,q.getBottom());a()};this.instersects=function(q){return Math.min(e,q.getRight())-Math.max(b,q.getLeft())>=
|
|
|
-0&&Math.min(g,q.getBottom())-Math.max(d,q.getTop())>=0};this.empty=function(){f=true;g=e=d=b=0;a()};this.isEmpty=function(){return f};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+g+", width: "+j+", height: "+l+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
|
|
|
-THREE.Matrix4=function(){};
|
|
|
-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 e=new THREE.Vector3,g=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(d,j).normalize();g.cross(j,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=j.x;this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,g=1/(this.n41*b+this.n42*
|
|
|
-d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*g;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*
|
|
|
-a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,g=a.n13,j=a.n14,l=a.n21,f=a.n22,q=a.n23,c=a.n24,t=a.n31,D=a.n32,r=a.n33,u=a.n34,v=a.n41,w=a.n42,H=a.n43,I=a.n44,z=b.n11,m=b.n12,h=b.n13,n=b.n14,i=b.n21,y=b.n22,k=b.n23,o=b.n24,B=b.n31,A=b.n32,P=b.n33,J=b.n34,R=b.n41,T=b.n42,E=b.n43,
|
|
|
-V=b.n44;this.n11=d*z+e*i+g*B+j*R;this.n12=d*m+e*y+g*A+j*T;this.n13=d*h+e*k+g*P+j*E;this.n14=d*n+e*o+g*J+j*V;this.n21=l*z+f*i+q*B+c*R;this.n22=l*m+f*y+q*A+c*T;this.n23=l*h+f*k+q*P+c*E;this.n24=l*n+f*o+q*J+c*V;this.n31=t*z+D*i+r*B+u*R;this.n32=t*m+D*y+r*A+u*T;this.n33=t*h+D*k+r*P+u*E;this.n34=t*n+D*o+r*J+u*V;this.n41=v*z+w*i+H*B+I*R;this.n42=v*m+w*y+H*A+I*T;this.n43=v*h+w*k+H*P+I*E;this.n44=v*n+w*o+H*J+I*V},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,g=this.n14,j=this.n21,l=this.n22,
|
|
|
-f=this.n23,q=this.n24,c=this.n31,t=this.n32,D=this.n33,r=this.n34,u=this.n41,v=this.n42,w=this.n43,H=this.n44;this.n11=b*a.n11+d*a.n21+e*a.n31+g*a.n41;this.n12=b*a.n12+d*a.n22+e*a.n32+g*a.n42;this.n13=b*a.n13+d*a.n23+e*a.n33+g*a.n43;this.n14=b*a.n14+d*a.n24+e*a.n34+g*a.n44;this.n21=j*a.n11+l*a.n21+f*a.n31+q*a.n41;this.n22=j*a.n12+l*a.n22+f*a.n32+q*a.n42;this.n23=j*a.n13+l*a.n23+f*a.n33+q*a.n43;this.n24=j*a.n14+l*a.n24+f*a.n34+q*a.n44;this.n31=c*a.n11+t*a.n21+D*a.n31+r*a.n41;this.n32=c*a.n12+t*a.n22+
|
|
|
-D*a.n32+r*a.n42;this.n33=c*a.n13+t*a.n23+D*a.n33+r*a.n43;this.n34=c*a.n14+t*a.n24+D*a.n34+r*a.n44;this.n41=u*a.n11+v*a.n21+w*a.n31+H*a.n41;this.n42=u*a.n12+v*a.n22+w*a.n32+H*a.n42;this.n43=u*a.n13+v*a.n23+w*a.n33+H*a.n43;this.n44=u*a.n14+v*a.n24+w*a.n34+H*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,e){var g=b[d];b[d]=b[e];b[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,
|
|
|
-"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){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 e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=d;return e};THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=d;return e};
|
|
|
-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,e=Math.cos(b),g=Math.sin(b),j=1-e,l=a.x,f=a.y,q=a.z;d.n11=j*l*l+e;d.n12=j*l*f-g*q;d.n13=j*l*q+g*f;d.n21=j*l*f+g*q;d.n22=j*f*f+e;d.n23=j*f*q-g*l;d.n31=j*l*q-g*f;d.n32=j*f*q+g*l;d.n33=j*q*q+e;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],e=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],l=b[10]*b[0]-b[2]*b[8],f=-b[6]*b[0]+b[2]*b[4],q=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],t=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*j+b[2]*q;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*g;a.m[3]=b*j;a.m[4]=b*l;a.m[5]=b*f;a.m[6]=b*q;a.m[7]=b*c;a.m[8]=b*t;return a};
|
|
|
-THREE.Matrix4.makeFrustum=function(a,b,d,e,g,j){var l,f,q;l=new THREE.Matrix4;f=2*g/(b-a);q=2*g/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(j+g)/(j-g);g=-2*j*g/(j-g);l.n11=f;l.n12=0;l.n13=a;l.n14=0;l.n21=0;l.n22=q;l.n23=d;l.n24=0;l.n31=0;l.n32=0;l.n33=e;l.n34=g;l.n41=0;l.n42=0;l.n43=-1;l.n44=0;return l};THREE.Matrix4.makePerspective=function(a,b,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,d,e)};
|
|
|
-THREE.Matrix4.makeOrtho=function(a,b,d,e,g,j){var l,f,q,c;l=new THREE.Matrix4;f=b-a;q=d-e;c=j-g;a=(b+a)/f;d=(d+e)/q;g=(j+g)/c;l.n11=2/f;l.n12=0;l.n13=0;l.n14=-a;l.n21=0;l.n22=2/q;l.n23=0;l.n24=-d;l.n31=0;l.n32=0;l.n33=-2/c;l.n34=-g;l.n41=0;l.n42=0;l.n43=0;l.n44=1;return l};
|
|
|
-THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
|
|
|
-THREE.Face3=function(a,b,d,e,g){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.material=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
|
|
|
-THREE.Face4=function(a,b,d,e,g,j){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.material=j instanceof Array?j:[j]};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)}}},computeNormals:function(a){var b,d,e,g,j,l,f=new THREE.Vector3,q=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){j=this.vertices[e];j.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){j=this.faces[e];if(a&&j.vertexNormals.length){f.set(0,0,0);b=0;for(d=j.normal.length;b<d;b++)f.addSelf(j.vertexNormals[b]);f.divideScalar(3)}else{b=this.vertices[j.a];d=this.vertices[j.b];l=this.vertices[j.c];f.sub(l.position,
|
|
|
-d.position);q.sub(b.position,d.position);f.crossSelf(q)}f.isZero()||f.normalize();j.normal.copy(f)}},computeVertexNormals:function(){var a,b=[],d,e;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++){e=this.faces[a];if(e instanceof THREE.Face3){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal);b[e.d].addSelf(e.normal)}}a=
|
|
|
-0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone()}else if(e instanceof THREE.Face4){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone();e.vertexNormals[3]=b[e.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(t){var D=[];b=0;for(d=t.length;b<d;b++)t[b]==undefined?D.push("undefined"):D.push(t[b].toString());return D.join("_")}var b,d,e,g,j,l,f,q,c={};e=0;for(g=this.faces.length;e<g;e++){j=this.faces[e];l=j.material;f=a(l);if(c[f]==undefined)c[f]={hash:f,counter:0};q=c[f].hash+"_"+c[f].counter;if(this.geometryChunks[q]==
|
|
|
-undefined)this.geometryChunks[q]={faces:[],material:l,vertices:0};j=j instanceof THREE.Face3?3:4;if(this.geometryChunks[q].vertices+j>65535){c[f].counter+=1;q=c[f].hash+"_"+c[f].counter;if(this.geometryChunks[q]==undefined)this.geometryChunks[q]={faces:[],material:l,vertices:0}}this.geometryChunks[q].faces.push(e);this.geometryChunks[q].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
|
|
|
-THREE.Camera=function(a,b,d,e){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,e);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,e,g;a=0;for(b=this.geometry.uvs.length;a<b;a++){g=this.geometry.uvs[a];d=0;for(e=g.length;d<e;d++){if(g[d].u!=1)g[d].u-=Math.floor(g[d].u);if(g[d].v!=1)g[d].v-=Math.floor(g[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,e,g,j){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=j!==undefined?j: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(z,m){var h=0,n=1,i=z.z+z.w,y=m.z+m.w,k=-z.z+z.w,o=-m.z+m.w;if(i>=0&&y>=0&&k>=0&&o>=0)return true;else if(i<0&&y<0||k<0&&o<0)return false;else{if(i<0)h=Math.max(h,i/(i-y));else if(y<0)n=Math.min(n,i/(i-y));if(k<0)h=Math.max(h,k/(k-o));else if(o<0)n=Math.min(n,k/(k-o));if(n<h)return false;else{z.lerpSelf(m,h);m.lerpSelf(z,1-n);return true}}}var b=null,d,e,g,j=[],l,f,q=[],c,t,D=[],r=new THREE.Vector4,u=new THREE.Matrix4,v=new THREE.Matrix4,w=new THREE.Vector4,H=
|
|
|
-new THREE.Vector4,I;this.projectScene=function(z,m){var h,n,i,y,k,o,B,A,P,J,R,T,E,V,K,L,N;b=[];g=f=t=0;m.autoUpdateMatrix&&m.updateMatrix();u.multiply(m.projectionMatrix,m.matrix);B=z.objects;h=0;for(n=B.length;h<n;h++){A=B[h];A.autoUpdateMatrix&&A.updateMatrix();P=A.matrix;J=A.rotationMatrix;R=A.material;T=A.overdraw;if(A instanceof THREE.Mesh){E=A.geometry.vertices;i=0;for(y=E.length;i<y;i++){V=E[i];V.positionWorld.copy(V.position);P.multiplyVector3(V.positionWorld);K=V.positionScreen;K.copy(V.positionWorld);
|
|
|
-u.multiplyVector4(K);K.multiplyScalar(1/K.w);V.__visible=K.z>0&&K.z<1}V=A.geometry.faces;i=0;for(y=V.length;i<y;i++){K=V[i];if(K instanceof THREE.Face3){k=E[K.a];o=E[K.b];L=E[K.c];if(k.__visible&&o.__visible&&L.__visible)if(A.doubleSided||A.flipSided!=(L.positionScreen.x-k.positionScreen.x)*(o.positionScreen.y-k.positionScreen.y)-(L.positionScreen.y-k.positionScreen.y)*(o.positionScreen.x-k.positionScreen.x)<0){d=j[g]=j[g]||new THREE.RenderableFace3;d.v1.positionWorld.copy(k.positionWorld);d.v2.positionWorld.copy(o.positionWorld);
|
|
|
-d.v3.positionWorld.copy(L.positionWorld);d.v1.positionScreen.copy(k.positionScreen);d.v2.positionScreen.copy(o.positionScreen);d.v3.positionScreen.copy(L.positionScreen);d.normalWorld.copy(K.normal);J.multiplyVector3(d.normalWorld);d.centroidWorld.copy(K.centroid);P.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);u.multiplyVector3(d.centroidScreen);L=K.vertexNormals;I=d.vertexNormalsWorld;k=0;for(o=L.length;k<o;k++){N=I[k]=I[k]||new THREE.Vector3;N.copy(L[k]);J.multiplyVector3(N)}d.z=
|
|
|
-d.centroidScreen.z;d.meshMaterial=R;d.faceMaterial=K.material;d.overdraw=T;if(A.geometry.uvs[i]){d.uvs[0]=A.geometry.uvs[i][0];d.uvs[1]=A.geometry.uvs[i][1];d.uvs[2]=A.geometry.uvs[i][2]}b.push(d);g++}}else if(K instanceof THREE.Face4){k=E[K.a];o=E[K.b];L=E[K.c];N=E[K.d];if(k.__visible&&o.__visible&&L.__visible&&N.__visible)if(A.doubleSided||A.flipSided!=((N.positionScreen.x-k.positionScreen.x)*(o.positionScreen.y-k.positionScreen.y)-(N.positionScreen.y-k.positionScreen.y)*(o.positionScreen.x-k.positionScreen.x)<
|
|
|
-0||(o.positionScreen.x-L.positionScreen.x)*(N.positionScreen.y-L.positionScreen.y)-(o.positionScreen.y-L.positionScreen.y)*(N.positionScreen.x-L.positionScreen.x)<0)){d=j[g]=j[g]||new THREE.RenderableFace3;d.v1.positionWorld.copy(k.positionWorld);d.v2.positionWorld.copy(o.positionWorld);d.v3.positionWorld.copy(N.positionWorld);d.v1.positionScreen.copy(k.positionScreen);d.v2.positionScreen.copy(o.positionScreen);d.v3.positionScreen.copy(N.positionScreen);d.normalWorld.copy(K.normal);J.multiplyVector3(d.normalWorld);
|
|
|
-d.centroidWorld.copy(K.centroid);P.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);u.multiplyVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=R;d.faceMaterial=K.material;d.overdraw=T;if(A.geometry.uvs[i]){d.uvs[0]=A.geometry.uvs[i][0];d.uvs[1]=A.geometry.uvs[i][1];d.uvs[2]=A.geometry.uvs[i][3]}b.push(d);g++;e=j[g]=j[g]||new THREE.RenderableFace3;e.v1.positionWorld.copy(o.positionWorld);e.v2.positionWorld.copy(L.positionWorld);e.v3.positionWorld.copy(N.positionWorld);
|
|
|
-e.v1.positionScreen.copy(o.positionScreen);e.v2.positionScreen.copy(L.positionScreen);e.v3.positionScreen.copy(N.positionScreen);e.normalWorld.copy(d.normalWorld);e.centroidWorld.copy(d.centroidWorld);e.centroidScreen.copy(d.centroidScreen);e.z=e.centroidScreen.z;e.meshMaterial=R;e.faceMaterial=K.material;e.overdraw=T;if(A.geometry.uvs[i]){e.uvs[0]=A.geometry.uvs[i][1];e.uvs[1]=A.geometry.uvs[i][2];e.uvs[2]=A.geometry.uvs[i][3]}b.push(e);g++}}}}else if(A instanceof THREE.Line){v.multiply(u,P);E=A.geometry.vertices;
|
|
|
-V=E[0];V.positionScreen.copy(V.position);v.multiplyVector4(V.positionScreen);i=1;for(y=E.length;i<y;i++){k=E[i];k.positionScreen.copy(k.position);v.multiplyVector4(k.positionScreen);o=E[i-1];w.copy(k.positionScreen);H.copy(o.positionScreen);if(a(w,H)){w.multiplyScalar(1/w.w);H.multiplyScalar(1/H.w);l=q[f]=q[f]||new THREE.RenderableLine;l.v1.positionScreen.copy(w);l.v2.positionScreen.copy(H);l.z=Math.max(w.z,H.z);l.material=A.material;b.push(l);f++}}}else if(A instanceof THREE.Particle){r.set(A.position.x,
|
|
|
-A.position.y,A.position.z,1);u.multiplyVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){c=D[t]=D[t]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=A.rotation.z;c.scale.x=A.scale.x*Math.abs(c.x-(r.x+m.projectionMatrix.n11)/(r.w+m.projectionMatrix.n14));c.scale.y=A.scale.y*Math.abs(c.y-(r.y+m.projectionMatrix.n22)/(r.w+m.projectionMatrix.n24));c.material=A.material;b.push(c);t++}}}b.sort(function(Y,Q){return Q.z-Y.z});return b};this.unprojectVector=function(z,m){var h=new THREE.Matrix4;
|
|
|
-h.multiply(THREE.Matrix4.makeInvert(m.matrix),THREE.Matrix4.makeInvert(m.projectionMatrix));h.multiplyVector3(z);return z}};
|
|
|
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,g,j;this.domElement=document.createElement("div");this.setSize=function(l,f){d=l;e=f;g=d/2;j=e/2};this.render=function(l,f){var q,c,t,D,r,u,v,w;a=b.projectScene(l,f);q=0;for(c=a.length;q<c;q++){r=a[q];if(r instanceof THREE.RenderableParticle){v=r.x*g+g;w=r.y*j+j;t=0;for(D=r.material.length;t<D;t++){u=r.material[t];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=v+"px";u.style.top=w+"px"}}}}}};
|
|
|
-THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,d=document.createElement("canvas"),e,g,j,l,f=d.getContext("2d"),q=1,c=0,t=null,D=null,r=1,u=Math.min,v=Math.max,w,H,I,z,m,h,n,i,y,k=new THREE.Color,o=new THREE.Color,B=new THREE.Color,A=new THREE.Color,P=new THREE.Color,J,R,T,E,V,K,L,N,Y,Q,M=new THREE.Rectangle,W=new THREE.Rectangle,p=new THREE.Rectangle,s=false,x=new THREE.Color,G=new THREE.Color,U=new THREE.Color,ba=new THREE.Color,ga=Math.PI*2,$=new THREE.Vector3,ka,pa,Da,da,qa,wa,
|
|
|
-na=16;ka=document.createElement("canvas");ka.width=ka.height=2;pa=ka.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);Da=pa.getImageData(0,0,2,2);da=Da.data;qa=document.createElement("canvas");qa.width=qa.height=na;wa=qa.getContext("2d");wa.translate(-na/2,-na/2);wa.scale(na,na);na--;this.domElement=d;this.autoClear=true;this.setSize=function(ia,xa){e=ia;g=xa;j=e/2;l=g/2;d.width=e;d.height=g;M.set(-j,-l,j,l)};this.clear=function(){if(!W.isEmpty()){W.inflate(1);W.minSelf(M);f.clearRect(W.getX(),
|
|
|
-W.getY(),W.getWidth(),W.getHeight());W.empty()}};this.render=function(ia,xa){function Ma(C){var X,S,F,O=C.lights;G.setRGB(0,0,0);U.setRGB(0,0,0);ba.setRGB(0,0,0);C=0;for(X=O.length;C<X;C++){S=O[C];F=S.color;if(S instanceof THREE.AmbientLight){G.r+=F.r;G.g+=F.g;G.b+=F.b}else if(S instanceof THREE.DirectionalLight){U.r+=F.r;U.g+=F.g;U.b+=F.b}else if(S instanceof THREE.PointLight){ba.r+=F.r;ba.g+=F.g;ba.b+=F.b}}}function ya(C,X,S,F){var O,Z,ca,ea,fa=C.lights;C=0;for(O=fa.length;C<O;C++){Z=fa[C];ca=Z.color;
|
|
|
-ea=Z.intensity;if(Z instanceof THREE.DirectionalLight){Z=S.dot(Z.position)*ea;if(Z>0){F.r+=ca.r*Z;F.g+=ca.g*Z;F.b+=ca.b*Z}}else if(Z instanceof THREE.PointLight){$.sub(Z.position,X);$.normalize();Z=S.dot($)*ea;if(Z>0){F.r+=ca.r*Z;F.g+=ca.g*Z;F.b+=ca.b*Z}}}}function Na(C,X,S){if(S.opacity!=0){Ea(S.opacity);za(S.blending);var F,O,Z,ca,ea,fa;if(S instanceof THREE.ParticleBasicMaterial){if(S.map){ca=S.map;ea=ca.width>>1;fa=ca.height>>1;O=X.scale.x*j;Z=X.scale.y*l;S=O*ea;F=Z*fa;p.set(C.x-S,C.y-F,C.x+S,
|
|
|
-C.y+F);if(M.instersects(p)){f.save();f.translate(C.x,C.y);f.rotate(-X.rotation);f.scale(O,-Z);f.translate(-ea,-fa);f.drawImage(ca,0,0);f.restore()}}}else if(S instanceof THREE.ParticleCircleMaterial){if(s){x.r=G.r+U.r+ba.r;x.g=G.g+U.g+ba.g;x.b=G.b+U.b+ba.b;k.r=S.color.r*x.r;k.g=S.color.g*x.g;k.b=S.color.b*x.b;k.updateStyleString()}else k.__styleString=S.color.__styleString;S=X.scale.x*j;F=X.scale.y*l;p.set(C.x-S,C.y-F,C.x+S,C.y+F);if(M.instersects(p)){O=k.__styleString;if(D!=O)f.fillStyle=D=O;f.save();
|
|
|
-f.translate(C.x,C.y);f.rotate(-X.rotation);f.scale(S,F);f.beginPath();f.arc(0,0,1,0,ga,true);f.closePath();f.fill();f.restore()}}}}function Oa(C,X,S,F){if(F.opacity!=0){Ea(F.opacity);za(F.blending);f.beginPath();f.moveTo(C.positionScreen.x,C.positionScreen.y);f.lineTo(X.positionScreen.x,X.positionScreen.y);f.closePath();if(F instanceof THREE.LineBasicMaterial){k.__styleString=F.color.__styleString;C=F.linewidth;if(r!=C)f.lineWidth=r=C;C=k.__styleString;if(t!=C)f.strokeStyle=t=C;f.stroke();p.inflate(F.linewidth*
|
|
|
-2)}}}function Ia(C,X,S,F,O,Z){if(O.opacity!=0){Ea(O.opacity);za(O.blending);z=C.positionScreen.x;m=C.positionScreen.y;h=X.positionScreen.x;n=X.positionScreen.y;i=S.positionScreen.x;y=S.positionScreen.y;f.beginPath();f.moveTo(z,m);f.lineTo(h,n);f.lineTo(i,y);f.lineTo(z,m);f.closePath();if(O instanceof THREE.MeshBasicMaterial)if(O.map)O.map.image.loaded&&O.map.mapping instanceof THREE.UVMapping&&ra(z,m,h,n,i,y,O.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);else if(O.env_map){if(O.env_map.image.loaded)if(O.env_map.mapping instanceof
|
|
|
-THREE.SphericalReflectionMapping){C=xa.matrix;$.copy(F.vertexNormalsWorld[0]);V=($.x*C.n11+$.y*C.n12+$.z*C.n13)*0.5+0.5;K=-($.x*C.n21+$.y*C.n22+$.z*C.n23)*0.5+0.5;$.copy(F.vertexNormalsWorld[1]);L=($.x*C.n11+$.y*C.n12+$.z*C.n13)*0.5+0.5;N=-($.x*C.n21+$.y*C.n22+$.z*C.n23)*0.5+0.5;$.copy(F.vertexNormalsWorld[2]);Y=($.x*C.n11+$.y*C.n12+$.z*C.n13)*0.5+0.5;Q=-($.x*C.n21+$.y*C.n22+$.z*C.n23)*0.5+0.5;ra(z,m,h,n,i,y,O.env_map.image,V,K,L,N,Y,Q)}}else O.wireframe?Aa(O.color.__styleString,O.wireframe_linewidth):
|
|
|
-Ba(O.color.__styleString);else if(O instanceof THREE.MeshLambertMaterial){if(O.map&&!O.wireframe){O.map.mapping instanceof THREE.UVMapping&&ra(z,m,h,n,i,y,O.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);za(THREE.SubtractiveBlending)}if(s)if(!O.wireframe&&O.shading==THREE.SmoothShading&&F.vertexNormalsWorld.length==3){o.r=B.r=A.r=G.r;o.g=B.g=A.g=G.g;o.b=B.b=A.b=G.b;ya(Z,F.v1.positionWorld,F.vertexNormalsWorld[0],o);ya(Z,F.v2.positionWorld,F.vertexNormalsWorld[1],B);ya(Z,
|
|
|
-F.v3.positionWorld,F.vertexNormalsWorld[2],A);P.r=(B.r+A.r)*0.5;P.g=(B.g+A.g)*0.5;P.b=(B.b+A.b)*0.5;E=Ja(o,B,A,P);ra(z,m,h,n,i,y,E,0,0,1,0,0,1)}else{x.r=G.r;x.g=G.g;x.b=G.b;ya(Z,F.centroidWorld,F.normalWorld,x);k.r=O.color.r*x.r;k.g=O.color.g*x.g;k.b=O.color.b*x.b;k.updateStyleString();O.wireframe?Aa(k.__styleString,O.wireframe_linewidth):Ba(k.__styleString)}else O.wireframe?Aa(O.color.__styleString,O.wireframe_linewidth):Ba(O.color.__styleString)}else if(O instanceof THREE.MeshDepthMaterial){J=O.__2near;
|
|
|
-R=O.__farPlusNear;T=O.__farMinusNear;o.r=o.g=o.b=1-J/(R-C.positionScreen.z*T);B.r=B.g=B.b=1-J/(R-X.positionScreen.z*T);A.r=A.g=A.b=1-J/(R-S.positionScreen.z*T);P.r=(B.r+A.r)*0.5;P.g=(B.g+A.g)*0.5;P.b=(B.b+A.b)*0.5;E=Ja(o,B,A,P);ra(z,m,h,n,i,y,E,0,0,1,0,0,1)}else if(O instanceof THREE.MeshNormalMaterial){k.r=Fa(F.normalWorld.x);k.g=Fa(F.normalWorld.y);k.b=Fa(F.normalWorld.z);k.updateStyleString();O.wireframe?Aa(k.__styleString,O.wireframe_linewidth):Ba(k.__styleString)}}}function Aa(C,X){if(t!=C)f.strokeStyle=
|
|
|
-t=C;if(r!=X)f.lineWidth=r=X;f.stroke();p.inflate(X*2)}function Ba(C){if(D!=C)f.fillStyle=D=C;f.fill()}function ra(C,X,S,F,O,Z,ca,ea,fa,sa,la,ta,ua){var ma,ja;ma=ca.width-1;ja=ca.height-1;ea*=ma;fa*=ja;sa*=ma;la*=ja;ta*=ma;ua*=ja;S-=C;F-=X;O-=C;Z-=X;sa-=ea;la-=fa;ta-=ea;ua-=fa;ja=1/(sa*ua-ta*la);ma=(ua*S-la*O)*ja;la=(ua*F-la*Z)*ja;S=(sa*O-ta*S)*ja;F=(sa*Z-ta*F)*ja;C=C-ma*ea-S*fa;X=X-la*ea-F*fa;f.save();f.transform(ma,la,S,F,C,X);f.clip();f.drawImage(ca,0,0);f.restore()}function Ea(C){if(q!=C)f.globalAlpha=
|
|
|
-q=C}function za(C){if(c!=C){switch(C){case THREE.NormalBlending:f.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:f.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:f.globalCompositeOperation="darker"}c=C}}function Ja(C,X,S,F){da[0]=v(0,u(255,~~(C.r*255)));da[1]=v(0,u(255,~~(C.g*255)));da[2]=v(0,u(255,~~(C.b*255)));da[4]=v(0,u(255,~~(X.r*255)));da[5]=v(0,u(255,~~(X.g*255)));da[6]=v(0,u(255,~~(X.b*255)));da[8]=v(0,u(255,~~(S.r*255)));da[9]=v(0,u(255,
|
|
|
-~~(S.g*255)));da[10]=v(0,u(255,~~(S.b*255)));da[12]=v(0,u(255,~~(F.r*255)));da[13]=v(0,u(255,~~(F.g*255)));da[14]=v(0,u(255,~~(F.b*255)));pa.putImageData(Da,0,0);wa.drawImage(ka,0,0);return qa}function Fa(C){return C<0?u((1+C)*0.5,0.5):0.5+u(C*0.5,0.5)}function Ga(C,X){var S=X.x-C.x,F=X.y-C.y,O=1/Math.sqrt(S*S+F*F);S*=O;F*=O;X.x+=S;X.y+=F;C.x-=S;C.y-=F}var Ca,Ka,aa,ha,oa,Ha,La,va;f.setTransform(1,0,0,-1,j,l);this.autoClear&&this.clear();a=b.projectScene(ia,xa);(s=ia.lights.length>0)&&Ma(ia);Ca=0;
|
|
|
-for(Ka=a.length;Ca<Ka;Ca++){aa=a[Ca];p.empty();if(aa instanceof THREE.RenderableParticle){w=aa;w.x*=j;w.y*=l;ha=0;for(oa=aa.material.length;ha<oa;ha++)Na(w,aa,aa.material[ha],ia)}else if(aa instanceof THREE.RenderableLine){w=aa.v1;H=aa.v2;w.positionScreen.x*=j;w.positionScreen.y*=l;H.positionScreen.x*=j;H.positionScreen.y*=l;p.addPoint(w.positionScreen.x,w.positionScreen.y);p.addPoint(H.positionScreen.x,H.positionScreen.y);if(M.instersects(p)){ha=0;for(oa=aa.material.length;ha<oa;)Oa(w,H,aa,aa.material[ha++],
|
|
|
-ia)}}else if(aa instanceof THREE.RenderableFace3){w=aa.v1;H=aa.v2;I=aa.v3;w.positionScreen.x*=j;w.positionScreen.y*=l;H.positionScreen.x*=j;H.positionScreen.y*=l;I.positionScreen.x*=j;I.positionScreen.y*=l;if(aa.overdraw){Ga(w.positionScreen,H.positionScreen);Ga(H.positionScreen,I.positionScreen);Ga(I.positionScreen,w.positionScreen)}p.addPoint(w.positionScreen.x,w.positionScreen.y);p.addPoint(H.positionScreen.x,H.positionScreen.y);p.addPoint(I.positionScreen.x,I.positionScreen.y);if(M.instersects(p)){ha=
|
|
|
-0;for(oa=aa.meshMaterial.length;ha<oa;){va=aa.meshMaterial[ha++];if(va instanceof THREE.MeshFaceMaterial){Ha=0;for(La=aa.faceMaterial.length;Ha<La;)(va=aa.faceMaterial[Ha++])&&Ia(w,H,I,aa,va,ia)}else Ia(w,H,I,aa,va,ia)}}}W.addRectangle(p)}f.setTransform(1,0,0,1,0,0)}};
|
|
|
-THREE.SVGRenderer=function(){function a(K,L,N){var Y,Q,M,W;Y=0;for(Q=K.lights.length;Y<Q;Y++){M=K.lights[Y];if(M instanceof THREE.DirectionalLight){W=L.normalWorld.dot(M.position)*M.intensity;if(W>0){N.r+=M.color.r*W;N.g+=M.color.g*W;N.b+=M.color.b*W}}else if(M instanceof THREE.PointLight){o.sub(M.position,L.centroidWorld);o.normalize();W=L.normalWorld.dot(o)*M.intensity;if(W>0){N.r+=M.color.r*W;N.g+=M.color.g*W;N.b+=M.color.b*W}}}}function b(K,L,N,Y,Q,M){J=e(R++);J.setAttribute("d","M "+K.positionScreen.x+
|
|
|
-" "+K.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+"z");if(Q instanceof THREE.MeshBasicMaterial)m.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshLambertMaterial)if(z){h.r=n.r;h.g=n.g;h.b=n.b;a(M,Y,h);m.r=Q.color.r*h.r;m.g=Q.color.g*h.g;m.b=Q.color.b*h.b;m.updateStyleString()}else m.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshDepthMaterial){k=1-Q.__2near/(Q.__farPlusNear-Y.z*Q.__farMinusNear);
|
|
|
-m.setRGB(k,k,k)}else Q instanceof THREE.MeshNormalMaterial&&m.setRGB(g(Y.normalWorld.x),g(Y.normalWorld.y),g(Y.normalWorld.z));Q.wireframe?J.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+Q.wireframe_linewidth+"; stroke-opacity: "+Q.opacity+"; stroke-linecap: "+Q.wireframe_linecap+"; stroke-linejoin: "+Q.wireframe_linejoin):J.setAttribute("style","fill: "+m.__styleString+"; fill-opacity: "+Q.opacity);f.appendChild(J)}function d(K,L,N,Y,Q,M,W){J=e(R++);J.setAttribute("d",
|
|
|
-"M "+K.positionScreen.x+" "+K.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+" L "+Y.positionScreen.x+","+Y.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)m.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(z){h.r=n.r;h.g=n.g;h.b=n.b;a(W,Q,h);m.r=M.color.r*h.r;m.g=M.color.g*h.g;m.b=M.color.b*h.b;m.updateStyleString()}else m.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){k=
|
|
|
-1-M.__2near/(M.__farPlusNear-Q.z*M.__farMinusNear);m.setRGB(k,k,k)}else M instanceof THREE.MeshNormalMaterial&&m.setRGB(g(Q.normalWorld.x),g(Q.normalWorld.y),g(Q.normalWorld.z));M.wireframe?J.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+M.wireframe_linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframe_linecap+"; stroke-linejoin: "+M.wireframe_linejoin):J.setAttribute("style","fill: "+m.__styleString+"; fill-opacity: "+M.opacity);f.appendChild(J)}
|
|
|
-function e(K){if(B[K]==null){B[K]=document.createElementNS("http://www.w3.org/2000/svg","path");V==0&&B[K].setAttribute("shape-rendering","crispEdges");return B[K]}return B[K]}function g(K){return K<0?Math.min((1+K)*0.5,0.5):0.5+Math.min(K*0.5,0.5)}var j=null,l=new THREE.Projector,f=document.createElementNS("http://www.w3.org/2000/svg","svg"),q,c,t,D,r,u,v,w,H=new THREE.Rectangle,I=new THREE.Rectangle,z=false,m=new THREE.Color(16777215),h=new THREE.Color(16777215),n=new THREE.Color(0),i=new THREE.Color(0),
|
|
|
-y=new THREE.Color(0),k,o=new THREE.Vector3,B=[],A=[],P=[],J,R,T,E,V=1;this.domElement=f;this.autoClear=true;this.setQuality=function(K){switch(K){case "high":V=1;break;case "low":V=0}};this.setSize=function(K,L){q=K;c=L;t=q/2;D=c/2;f.setAttribute("viewBox",-t+" "+-D+" "+q+" "+c);f.setAttribute("width",q);f.setAttribute("height",c);H.set(-t,-D,t,D)};this.clear=function(){for(;f.childNodes.length>0;)f.removeChild(f.childNodes[0])};this.render=function(K,L){var N,Y,Q,M,W,p,s,x;this.autoClear&&this.clear();
|
|
|
-j=l.projectScene(K,L);E=T=R=0;if(z=K.lights.length>0){s=K.lights;n.setRGB(0,0,0);i.setRGB(0,0,0);y.setRGB(0,0,0);N=0;for(Y=s.length;N<Y;N++){Q=s[N];M=Q.color;if(Q instanceof THREE.AmbientLight){n.r+=M.r;n.g+=M.g;n.b+=M.b}else if(Q instanceof THREE.DirectionalLight){i.r+=M.r;i.g+=M.g;i.b+=M.b}else if(Q instanceof THREE.PointLight){y.r+=M.r;y.g+=M.g;y.b+=M.b}}}N=0;for(Y=j.length;N<Y;N++){s=j[N];I.empty();if(s instanceof THREE.RenderableParticle){r=s;r.x*=t;r.y*=-D;Q=0;for(M=s.material.length;Q<M;Q++)if(x=
|
|
|
-s.material[Q]){W=r;p=s;x=x;var G=T++;if(A[G]==null){A[G]=document.createElementNS("http://www.w3.org/2000/svg","circle");V==0&&A[G].setAttribute("shape-rendering","crispEdges")}J=A[G];J.setAttribute("cx",W.x);J.setAttribute("cy",W.y);J.setAttribute("r",p.scale.x*t);if(x instanceof THREE.ParticleCircleMaterial){if(z){h.r=n.r+i.r+y.r;h.g=n.g+i.g+y.g;h.b=n.b+i.b+y.b;m.r=x.color.r*h.r;m.g=x.color.g*h.g;m.b=x.color.b*h.b;m.updateStyleString()}else m=x.color;J.setAttribute("style","fill: "+m.__styleString)}f.appendChild(J)}}else if(s instanceof
|
|
|
-THREE.RenderableLine){r=s.v1;u=s.v2;r.positionScreen.x*=t;r.positionScreen.y*=-D;u.positionScreen.x*=t;u.positionScreen.y*=-D;I.addPoint(r.positionScreen.x,r.positionScreen.y);I.addPoint(u.positionScreen.x,u.positionScreen.y);if(H.instersects(I)){Q=0;for(M=s.material.length;Q<M;)if(x=s.material[Q++]){W=r;p=u;x=x;G=E++;if(P[G]==null){P[G]=document.createElementNS("http://www.w3.org/2000/svg","line");V==0&&P[G].setAttribute("shape-rendering","crispEdges")}J=P[G];J.setAttribute("x1",W.positionScreen.x);
|
|
|
-J.setAttribute("y1",W.positionScreen.y);J.setAttribute("x2",p.positionScreen.x);J.setAttribute("y2",p.positionScreen.y);if(x instanceof THREE.LineBasicMaterial){m.__styleString=x.color.__styleString;J.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+x.linewidth+"; stroke-opacity: "+x.opacity+"; stroke-linecap: "+x.linecap+"; stroke-linejoin: "+x.linejoin);f.appendChild(J)}}}}else if(s instanceof THREE.RenderableFace3){r=s.v1;u=s.v2;v=s.v3;r.positionScreen.x*=t;r.positionScreen.y*=
|
|
|
--D;u.positionScreen.x*=t;u.positionScreen.y*=-D;v.positionScreen.x*=t;v.positionScreen.y*=-D;I.addPoint(r.positionScreen.x,r.positionScreen.y);I.addPoint(u.positionScreen.x,u.positionScreen.y);I.addPoint(v.positionScreen.x,v.positionScreen.y);if(H.instersects(I)){Q=0;for(M=s.meshMaterial.length;Q<M;){x=s.meshMaterial[Q++];if(x instanceof THREE.MeshFaceMaterial){W=0;for(p=s.faceMaterial.length;W<p;)(x=s.faceMaterial[W++])&&b(r,u,v,s,x,K)}else x&&b(r,u,v,s,x,K)}}}else if(s instanceof THREE.RenderableFace4){r=
|
|
|
-s.v1;u=s.v2;v=s.v3;w=s.v4;r.positionScreen.x*=t;r.positionScreen.y*=-D;u.positionScreen.x*=t;u.positionScreen.y*=-D;v.positionScreen.x*=t;v.positionScreen.y*=-D;w.positionScreen.x*=t;w.positionScreen.y*=-D;I.addPoint(r.positionScreen.x,r.positionScreen.y);I.addPoint(u.positionScreen.x,u.positionScreen.y);I.addPoint(v.positionScreen.x,v.positionScreen.y);I.addPoint(w.positionScreen.x,w.positionScreen.y);if(H.instersects(I)){Q=0;for(M=s.meshMaterial.length;Q<M;){x=s.meshMaterial[Q++];if(x instanceof
|
|
|
-THREE.MeshFaceMaterial){W=0;for(p=s.faceMaterial.length;W<p;)(x=s.faceMaterial[W++])&&d(r,u,v,w,s,x,K)}else x&&d(r,u,v,w,s,x,K)}}}}}};
|
|
|
-THREE.WebGLRenderer=function(a){function b(h,n){var i=c.createProgram();c.attachShader(i,l("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\n"+h));c.attachShader(i,l("vertex","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"+n));c.linkProgram(i);c.getProgramParameter(i,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(i,
|
|
|
-c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");i.uniforms={};i.attributes={};return i}function d(h,n){if(h.image.length==6){if(!h.image.__webGLTextureCube&&!h.image.__cubeMapInitialized&&h.image.loadCount==6){h.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,h.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 i=0;i<6;++i)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,h.image[i]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);h.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+n);c.bindTexture(c.TEXTURE_CUBE_MAP,h.image.__webGLTextureCube)}}function e(h,n){if(!h.__webGLTexture&&h.image.loaded){h.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,
|
|
|
-h.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,h.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,f(h.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,f(h.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,f(h.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,f(h.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+n);c.bindTexture(c.TEXTURE_2D,h.__webGLTexture)}function g(h,n){var i,y,k;
|
|
|
-i=0;for(y=n.length;i<y;i++){k=n[i];h.uniforms[k]=c.getUniformLocation(h,k)}}function j(h,n){var i,y,k;i=0;for(y=n.length;i<y;i++){k=n[i];h.attributes[k]=c.getAttribLocation(h,k);h.attributes[k]>=0&&c.enableVertexAttribArray(h.attributes[k])}}function l(h,n){var i;if(h=="fragment")i=c.createShader(c.FRAGMENT_SHADER);else if(h=="vertex")i=c.createShader(c.VERTEX_SHADER);c.shaderSource(i,n);c.compileShader(i);if(!c.getShaderParameter(i,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(i));return null}return i}
|
|
|
-function f(h){switch(h){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}
|
|
|
-var q=document.createElement("canvas"),c,t,D,r=new THREE.Matrix4,u,v=new Float32Array(16),w=new Float32Array(16),H=new Float32Array(16),I=new Float32Array(9),z=new Float32Array(16);a=function(h,n){if(h){var i,y,k,o=pointLights=maxDirLights=maxPointLights=0;i=0;for(y=h.lights.length;i<y;i++){k=h.lights[i];k instanceof THREE.DirectionalLight&&o++;k instanceof THREE.PointLight&&pointLights++}if(pointLights+o<=n){maxDirLights=o;maxPointLights=pointLights}else{maxDirLights=Math.ceil(n*o/(pointLights+o));
|
|
|
-maxPointLights=n-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:n-1}}(a,4);this.domElement=q;this.autoClear=true;try{c=q.getContext("experimental-webgl",{antialias:true})}catch(m){}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);t=D=function(h,n){var i=[h?"#define MAX_DIR_LIGHTS "+h:"",n?"#define MAX_POINT_LIGHTS "+n:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",h?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",h?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",n?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",n?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":
|
|
|
-"","uniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",n?"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;",
|
|
|
-h?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",h?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",h?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",h?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",h?"}":"",n?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",n?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",n?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
|
|
|
-"",n?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",n?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",n?"}":"","}\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"),
|
|
|
-y=[h?"#define MAX_DIR_LIGHTS "+h:"",n?"#define MAX_POINT_LIGHTS "+n:"","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;",
|
|
|
-h?"uniform mat4 viewMatrix;":"",h?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",n?"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 );",
|
|
|
-n?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",n?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",n?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",n?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",n?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",n?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",n?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",n?"float pointSpecularWeight = 0.0;":"",n?"if ( pointDotNormalHalf >= 0.0 )":
|
|
|
-"",n?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",n?"pointDiffuse += mColor * pointDiffuseWeight;":"",n?"pointSpecular += mSpecular * pointSpecularWeight;":"",n?"}":"",h?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",h?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",h?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",h?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",h?"vec3 dirVector = normalize( lDirection.xyz );":"",h?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
|
|
|
-"",h?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",h?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",h?"float dirSpecularWeight = 0.0;":"",h?"if ( dirDotNormalHalf >= 0.0 )":"",h?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",h?"dirDiffuse += mColor * dirDiffuseWeight;":"",h?"dirSpecular += mSpecular * dirSpecularWeight;":"",h?"}":"","vec4 totalLight = mAmbient;",h?"totalLight += dirDiffuse + dirSpecular;":"",n?"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");
|
|
|
-i=b(y,i);c.useProgram(i);g(i,["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"]);h&&g(i,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);n&&g(i,["pointLightNumber","pointLightColor",
|
|
|
-"pointLightPosition"]);c.uniform1i(i.uniforms.enableMap,0);c.uniform1i(i.uniforms.tMap,0);c.uniform1i(i.uniforms.enableCubeMap,0);c.uniform1i(i.uniforms.tCube,1);c.uniform1i(i.uniforms.mixEnvMap,0);c.uniform1i(i.uniforms.useRefract,0);j(i,["position","normal","uv"]);return i}(a.directional,a.point);this.setSize=function(h,n){q.width=h;q.height=n;c.viewport(0,0,q.width,q.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(h,n){var i,y,k,o,B,A=[],
|
|
|
-P=[],J=[];o=[];B=[];c.uniform1i(h.uniforms.enableLighting,n.length);i=0;for(y=n.length;i<y;i++){k=n[i];if(k instanceof THREE.AmbientLight)A.push(k);else if(k instanceof THREE.DirectionalLight)J.push(k);else k instanceof THREE.PointLight&&P.push(k)}i=k=o=B=0;for(y=A.length;i<y;i++){k+=A[i].color.r;o+=A[i].color.g;B+=A[i].color.b}c.uniform3f(h.uniforms.ambientLightColor,k,o,B);o=[];B=[];i=0;for(y=J.length;i<y;i++){k=J[i];o.push(k.color.r*k.intensity);o.push(k.color.g*k.intensity);o.push(k.color.b*k.intensity);
|
|
|
-B.push(k.position.x);B.push(k.position.y);B.push(k.position.z)}if(J.length){c.uniform1i(h.uniforms.directionalLightNumber,J.length);c.uniform3fv(h.uniforms.directionalLightDirection,B);c.uniform3fv(h.uniforms.directionalLightColor,o)}o=[];B=[];i=0;for(y=P.length;i<y;i++){k=P[i];o.push(k.color.r*k.intensity);o.push(k.color.g*k.intensity);o.push(k.color.b*k.intensity);B.push(k.position.x);B.push(k.position.y);B.push(k.position.z)}if(P.length){c.uniform1i(h.uniforms.pointLightNumber,P.length);c.uniform3fv(h.uniforms.pointLightPosition,
|
|
|
-B);c.uniform3fv(h.uniforms.pointLightColor,o)}};this.createBuffers=function(h,n){var i,y,k,o,B,A,P,J,R=[],T=[],E=[],V=[],K=[],L=0,N=h.geometry.geometryChunks[n],Y;k=false;i=0;for(y=h.material.length;i<y;i++){meshMaterial=h.material[i];if(meshMaterial instanceof THREE.MeshFaceMaterial){B=0;for(Y=N.material.length;B<Y;B++)if(N.material[B]&&N.material[B].shading!=undefined&&N.material[B].shading==THREE.SmoothShading){k=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
|
|
|
-THREE.SmoothShading){k=true;break}if(k)break}Y=k;i=0;for(y=N.faces.length;i<y;i++){k=N.faces[i];o=h.geometry.faces[k];B=o.vertexNormals;faceNormal=o.normal;k=h.geometry.uvs[k];if(o instanceof THREE.Face3){A=h.geometry.vertices[o.a].position;P=h.geometry.vertices[o.b].position;J=h.geometry.vertices[o.c].position;E.push(A.x,A.y,A.z);E.push(P.x,P.y,P.z);E.push(J.x,J.y,J.z);if(B.length==3&&Y)for(o=0;o<3;o++)V.push(B[o].x,B[o].y,B[o].z);else for(o=0;o<3;o++)V.push(faceNormal.x,faceNormal.y,faceNormal.z);
|
|
|
-if(k)for(o=0;o<3;o++)K.push(k[o].u,k[o].v);R.push(L,L+1,L+2);T.push(L,L+1);T.push(L,L+2);T.push(L+1,L+2);L+=3}else if(o instanceof THREE.Face4){A=h.geometry.vertices[o.a].position;P=h.geometry.vertices[o.b].position;J=h.geometry.vertices[o.c].position;o=h.geometry.vertices[o.d].position;E.push(A.x,A.y,A.z);E.push(P.x,P.y,P.z);E.push(J.x,J.y,J.z);E.push(o.x,o.y,o.z);if(B.length==4&&Y)for(o=0;o<4;o++)V.push(B[o].x,B[o].y,B[o].z);else for(o=0;o<4;o++)V.push(faceNormal.x,faceNormal.y,faceNormal.z);if(k)for(o=
|
|
|
-0;o<4;o++)K.push(k[o].u,k[o].v);R.push(L,L+1,L+2);R.push(L,L+2,L+3);T.push(L,L+1);T.push(L,L+2);T.push(L,L+3);T.push(L+1,L+2);T.push(L+2,L+3);L+=4}}if(E.length){N.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,N.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(E),c.STATIC_DRAW);N.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,N.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW);if(K.length>0){N.__webGLUVBuffer=c.createBuffer();
|
|
|
-c.bindBuffer(c.ARRAY_BUFFER,N.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(K),c.STATIC_DRAW)}N.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,N.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(R),c.STATIC_DRAW);N.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,N.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(T),c.STATIC_DRAW);N.__webGLFaceCount=R.length;N.__webGLLineCount=T.length}};this.renderBuffer=
|
|
|
-function(h,n,i,y){var k,o,B,A,P,J,R,T,E;if(i instanceof THREE.MeshShaderMaterial){if(!i.program){i.program=b(i.fragment_shader,i.vertex_shader);R=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(E in i.uniforms)R.push(E);g(i.program,R);j(i.program,["position","normal","uv"])}E=i.program}else E=D;if(E!=t){c.useProgram(E);t=E}E==D&&this.setupLights(E,n);this.loadCamera(E,h);this.loadMatrices(E);if(i instanceof THREE.MeshShaderMaterial){B=i.wireframe;
|
|
|
-A=i.wireframe_linewidth;h=E;n=i.uniforms;var V;for(k in n){T=n[k].type;R=n[k].value;V=h.uniforms[k];if(T=="i")c.uniform1i(V,R);else if(T=="f")c.uniform1f(V,R);else if(T=="t"){c.uniform1i(V,R);if(T=n[k].texture)T.image instanceof Array&&T.image.length==6?d(T,R):e(T,R)}}}if(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshBasicMaterial){k=i.color;o=i.opacity;B=i.wireframe;A=i.wireframe_linewidth;P=i.map;J=i.env_map;n=i.combine==THREE.MixOperation;
|
|
|
-h=i.reflectivity;T=i.env_map&&i.env_map.mapping instanceof THREE.CubeRefractionMapping;R=i.refraction_ratio;c.uniform4f(E.uniforms.mColor,k.r*o,k.g*o,k.b*o,o);c.uniform1i(E.uniforms.mixEnvMap,n);c.uniform1f(E.uniforms.mReflectivity,h);c.uniform1i(E.uniforms.useRefract,T);c.uniform1f(E.uniforms.mRefractionRatio,R)}if(i instanceof THREE.MeshNormalMaterial){o=i.opacity;c.uniform1f(E.uniforms.mOpacity,o);c.uniform1i(E.uniforms.material,4)}else if(i instanceof THREE.MeshDepthMaterial){o=i.opacity;B=i.wireframe;
|
|
|
-A=i.wireframe_linewidth;c.uniform1f(E.uniforms.mOpacity,o);c.uniform1f(E.uniforms.m2Near,i.__2near);c.uniform1f(E.uniforms.mFarPlusNear,i.__farPlusNear);c.uniform1f(E.uniforms.mFarMinusNear,i.__farMinusNear);c.uniform1i(E.uniforms.material,3)}else if(i instanceof THREE.MeshPhongMaterial){k=i.ambient;h=i.specular;i=i.shininess;c.uniform4f(E.uniforms.mAmbient,k.r,k.g,k.b,o);c.uniform4f(E.uniforms.mSpecular,h.r,h.g,h.b,o);c.uniform1f(E.uniforms.mShininess,i);c.uniform1i(E.uniforms.material,2)}else if(i instanceof
|
|
|
-THREE.MeshLambertMaterial)c.uniform1i(E.uniforms.material,1);else if(i instanceof THREE.MeshBasicMaterial)c.uniform1i(E.uniforms.material,0);else if(i instanceof THREE.MeshCubeMaterial){c.uniform1i(E.uniforms.material,5);J=i.env_map}if(P){e(P,0);c.uniform1i(E.uniforms.tMap,0);c.uniform1i(E.uniforms.enableMap,1)}else c.uniform1i(E.uniforms.enableMap,0);if(J){d(J,1);c.uniform1i(E.uniforms.tCube,1);c.uniform1i(E.uniforms.enableCubeMap,1)}else c.uniform1i(E.uniforms.enableCubeMap,0);o=E.attributes;c.bindBuffer(c.ARRAY_BUFFER,
|
|
|
-y.__webGLVertexBuffer);c.vertexAttribPointer(o.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,y.__webGLNormalBuffer);c.vertexAttribPointer(o.normal,3,c.FLOAT,false,0,0);if(o.uv>=0)if(y.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,y.__webGLUVBuffer);c.enableVertexAttribArray(o.uv);c.vertexAttribPointer(o.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(o.uv);if(B){c.lineWidth(A);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y.__webGLLineBuffer);c.drawElements(c.LINES,y.__webGLLineCount,c.UNSIGNED_SHORT,
|
|
|
-0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,y.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(h,n,i,y,k,o){var B,A,P,J,R;P=0;for(J=i.material.length;P<J;P++){B=i.material[P];if(B instanceof THREE.MeshFaceMaterial){B=0;for(A=y.material.length;B<A;B++)if((R=y.material[B])&&R.blending==k&&R.opacity<1==o){this.setBlending(R.blending);this.renderBuffer(h,n,R,y)}}else if((R=B)&&R.blending==k&&R.opacity<1==o){this.setBlending(R.blending);this.renderBuffer(h,
|
|
|
-n,R,y)}}};this.render=function(h,n){var i,y,k,o,B=h.lights;this.initWebGLObjects(h);this.autoClear&&this.clear();n.autoUpdateMatrix&&n.updateMatrix();i=0;for(y=h.__webGLObjects.length;i<y;i++){k=h.__webGLObjects[i];o=k.object;k=k.buffer;if(o.visible){this.setupMatrices(o,n);this.renderPass(n,B,o,k,THREE.NormalBlending,false)}}i=0;for(y=h.__webGLObjects.length;i<y;i++){k=h.__webGLObjects[i];o=k.object;k=k.buffer;if(o.visible){this.setupMatrices(o,n);this.renderPass(n,B,o,k,THREE.AdditiveBlending,false);
|
|
|
-this.renderPass(n,B,o,k,THREE.SubtractiveBlending,false);this.renderPass(n,B,o,k,THREE.AdditiveBlending,true);this.renderPass(n,B,o,k,THREE.SubtractiveBlending,true);this.renderPass(n,B,o,k,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(h){var n,i,y,k,o,B;if(!h.__webGLObjects){h.__webGLObjects=[];h.__webGLObjectsMap={}}n=0;for(i=h.objects.length;n<i;n++){y=h.objects[n];if(h.__webGLObjectsMap[y.id]==undefined)h.__webGLObjectsMap[y.id]={};B=h.__webGLObjectsMap[y.id];if(y instanceof THREE.Mesh)for(o in y.geometry.geometryChunks){k=
|
|
|
-y.geometry.geometryChunks[o];k.__webGLVertexBuffer||this.createBuffers(y,o);if(B[o]==undefined){k={buffer:k,object:y};h.__webGLObjects.push(k);B[o]=1}}}};this.removeObject=function(h,n){var i,y;for(i=h.__webGLObjects.length-1;i>=0;i--){y=h.__webGLObjects[i].object;n==y&&h.__webGLObjects.splice(i,1)}};this.setupMatrices=function(h,n){h.autoUpdateMatrix&&h.updateMatrix();r.multiply(n.matrix,h.matrix);v.set(n.matrix.flatten());w.set(r.flatten());H.set(n.projectionMatrix.flatten());u=THREE.Matrix4.makeInvert3x3(r).transpose();
|
|
|
-I.set(u.m);z.set(h.matrix.flatten())};this.loadMatrices=function(h){c.uniformMatrix4fv(h.uniforms.viewMatrix,false,v);c.uniformMatrix4fv(h.uniforms.modelViewMatrix,false,w);c.uniformMatrix4fv(h.uniforms.projectionMatrix,false,H);c.uniformMatrix3fv(h.uniforms.normalMatrix,false,I);c.uniformMatrix4fv(h.uniforms.objectMatrix,false,z)};this.loadCamera=function(h,n){c.uniform3f(h.uniforms.cameraPosition,n.position.x,n.position.y,n.position.z)};this.setBlending=function(h){switch(h){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);
|
|
|
-c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(h,n){if(h){!n||n=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(h=="back")c.cullFace(c.BACK);else h=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)}};
|
|
|
-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};
|
|
|
-var GeometryUtils={merge:function(a,b){var d=b instanceof THREE.Mesh,e=a.vertices.length,g=d?b.geometry:b,j=a.vertices,l=g.vertices,f=a.faces,q=g.faces,c=a.uvs;g=g.uvs;d&&b.updateMatrix();for(var t=0,D=l.length;t<D;t++){var r=new THREE.Vertex(l[t].position.clone());d&&b.matrix.multiplyVector3(r.position);j.push(r)}t=0;for(D=q.length;t<D;t++){l=q[t];var u,v=l.vertexNormals;if(l instanceof THREE.Face3)u=new THREE.Face3(l.a+e,l.b+e,l.c+e);else if(l instanceof THREE.Face4)u=new THREE.Face4(l.a+e,l.b+
|
|
|
-e,l.c+e,l.d+e);u.centroid.copy(l.centroid);u.normal.copy(l.normal);d=0;for(j=v.length;d<j;d++){r=v[d];u.vertexNormals.push(r.clone())}u.material=l.material.slice();f.push(u)}t=0;for(D=g.length;t<D;t++){e=g[t];f=[];d=0;for(j=e.length;d<j;d++)f.push(new THREE.UV(e[d].u,e[d].v));c.push(f)}}},ImageUtils={loadTexture:function(a,b){var d=new Image;d.onload=function(){this.loaded=true};d.src=a;return new THREE.Texture(d,b)},loadArray:function(a){var b,d,e=[];b=e.loadCount=0;for(d=a.length;b<d;++b){e[b]=
|
|
|
-new Image;e[b].loaded=0;e[b].onload=function(){e.loadCount+=1;this.loaded=true};e[b].src=a[b]}return e}},SceneUtils={addMesh:function(a,b,d,e,g,j,l,f,q,c){b=new THREE.Mesh(b,c);b.scale.x=b.scale.y=b.scale.z=d;b.position.x=e;b.position.y=g;b.position.z=j;b.rotation.x=l;b.rotation.y=f;b.rotation.z=q;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,d){d=new THREE.MeshCubeMaterial({env_map:d});b=new THREE.Mesh(new Cube(b,b,b,1,1,null,true),d);a.addObject(b);return b},addPanoramaCube:function(a,
|
|
|
-b,d){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));mesh=new THREE.Mesh(new Cube(b,b,b,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(mesh);
|
|
|
-return mesh},addPanoramaCubePlanes:function(a,b,d){var e=b/2;b=new Plane(b,b);var g=Math.PI/2,j=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));SceneUtils.addMesh(a,b,1,-e,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,b,1,e,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,b,1,0,e,0,g,0,j,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));SceneUtils.addMesh(a,
|
|
|
-b,1,0,-e,0,-g,0,j,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
|
|
|
-vertex_shader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main(void) {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"}}},
|
|
|
-Cube=function(a,b,d,e,g,j,l,f){function q(w,H,I,z,m,h,n,i){var y=e||1,k=g||1,o=y+1,B=k+1;m=m/y;h=h/k;var A=c.vertices.length,P;if(w=="x"&&H=="y"||w=="y"&&H=="x")P="z";else if(w=="x"&&H=="z"||w=="z"&&H=="x")P="y";else if(w=="z"&&H=="y"||w=="y"&&H=="z")P="x";for(iy=0;iy<B;iy++)for(ix=0;ix<o;ix++){var J=new THREE.Vector3;J[w]=(ix*m-t)*I;J[H]=(iy*h-D)*z;J[P]=n;c.vertices.push(new THREE.Vertex(J))}for(iy=0;iy<k;iy++)for(ix=0;ix<y;ix++){c.faces.push(new THREE.Face4(ix+o*iy+A,ix+o*(iy+1)+A,ix+1+o*(iy+1)+
|
|
|
-A,ix+1+o*iy+A,null,i));c.uvs.push([new THREE.UV(ix/y,iy/k),new THREE.UV(ix/y,(iy+1)/k),new THREE.UV((ix+1)/y,(iy+1)/k),new THREE.UV((ix+1)/y,iy/k)])}}THREE.Geometry.call(this);var c=this,t=a/2,D=b/2,r=d/2;l=l?-1:1;if(j!==undefined)if(j instanceof Array)this.materials=j;else{this.materials=[];for(var u=0;u<6;u++)this.materials.push([j])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(f!=undefined)for(var v in f)if(this.sides[v]!=undefined)this.sides[v]=f[v];this.sides.px&&
|
|
|
-q("z","y",1*l,-1,d,b,-t,this.materials[0]);this.sides.nx&&q("z","y",-1*l,-1,d,b,t,this.materials[1]);this.sides.py&&q("x","z",1*l,1,a,d,D,this.materials[2]);this.sides.ny&&q("x","z",1*l,-1,a,d,-D,this.materials[3]);this.sides.pz&&q("x","y",1*l,-1,a,b,r,this.materials[4]);this.sides.nz&&q("x","y",-1*l,-1,a,b,-r,this.materials[5]);(function(){for(var w=[],H=[],I=0,z=c.vertices.length;I<z;I++){for(var m=c.vertices[I],h=false,n=0,i=w.length;n<i;n++){var y=w[n];if(m.position.x==y.position.x&&m.position.y==
|
|
|
-y.position.y&&m.position.z==y.position.z){H[I]=n;h=true;break}}if(!h){H[I]=w.length;w.push(new THREE.Vertex(m.position.clone()))}}I=0;for(z=c.faces.length;I<z;I++){m=c.faces[I];m.a=H[m.a];m.b=H[m.b];m.c=H[m.c];m.d=H[m.d]}c.vertices=w})();this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
|
|
|
-var Cylinder=function(a,b,d,e,g){function j(q,c,t){l.vertices.push(new THREE.Vertex(new THREE.Vector3(q,c,t)))}THREE.Geometry.call(this);var l=this,f;for(f=0;f<a;f++)j(Math.sin(6.283*f/a)*b,Math.cos(6.283*f/a)*b,0);for(f=0;f<a;f++)j(Math.sin(6.283*f/a)*d,Math.cos(6.283*f/a)*d,e);for(f=0;f<a;f++)l.faces.push(new THREE.Face4(f,f+a,a+(f+1)%a,(f+1)%a));if(d!=0){j(0,0,-g);for(f=a;f<a+a/2;f++)l.faces.push(new THREE.Face4(2*a,(2*f-2*a)%a,(2*f-2*a+1)%a,(2*f-2*a+2)%a))}if(b!=0){j(0,0,e+g);for(f=a+a/2;f<2*
|
|
|
-a;f++)l.faces.push(new THREE.Face4((2*f-2*a+2)%a+a,(2*f-2*a+1)%a+a,(2*f-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
|
|
|
-var Plane=function(a,b,d,e){THREE.Geometry.call(this);var g,j=a/2,l=b/2;d=d||1;e=e||1;var f=d+1,q=e+1;a=a/d;var c=b/e;for(g=0;g<q;g++)for(b=0;b<f;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-j,-(g*c-l),0)));for(g=0;g<e;g++)for(b=0;b<d;b++){this.faces.push(new THREE.Face4(b+f*g,b+f*(g+1),b+1+f*(g+1),b+1+f*g));this.uvs.push([new THREE.UV(b/d,g/e),new THREE.UV(b/d,(g+1)/e),new THREE.UV((b+1)/d,(g+1)/e),new THREE.UV((b+1)/d,g/e)])}this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};
|
|
|
-Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
|
|
|
-var Sphere=function(a,b,d){THREE.Geometry.call(this);var e,g=Math.max(3,b||8),j=Math.max(2,d||6);b=[];for(d=0;d<j+1;d++){e=d/j;var l=a*Math.cos(e*Math.PI),f=a*Math.sin(e*Math.PI),q=[],c=0;for(e=0;e<g;e++){var t=2*e/g,D=f*Math.sin(t*Math.PI);t=f*Math.cos(t*Math.PI);(d==0||d==j)&&e>0||(c=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,l,D)))-1);q.push(c)}b.push(q)}var r,u,v;a=b.length;for(d=0;d<a;d++){g=b[d].length;if(d>0)for(e=0;e<g;e++){q=e==g-1;j=b[d][q?0:e+1];l=b[d][q?g-1:e];f=b[d-1][q?
|
|
|
-g-1:e];q=b[d-1][q?0:e+1];D=d/(a-1);r=(d-1)/(a-1);u=(e+1)/g;t=e/g;c=new THREE.UV(1-u,D);D=new THREE.UV(1-t,D);t=new THREE.UV(1-t,r);var w=new THREE.UV(1-u,r);if(d<b.length-1){r=this.vertices[j].position.clone();u=this.vertices[l].position.clone();v=this.vertices[f].position.clone();r.normalize();u.normalize();v.normalize();this.faces.push(new THREE.Face3(j,l,f,[new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z)]));this.uvs.push([c,D,t])}if(d>1){r=this.vertices[j].position.clone();
|
|
|
-u=this.vertices[f].position.clone();v=this.vertices[q].position.clone();r.normalize();u.normalize();v.normalize();this.faces.push(new THREE.Face3(j,f,q,[new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z)]));this.uvs.push([c,t,w])}}}this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
|
|
|
-THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
|
|
|
-THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
|
|
|
-b},loadAsciiOld:function(a,b){var d=document.createElement("script");d.type="text/javascript";d.onload=b;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);a.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,b,d)};a.postMessage(e)},loadBinary:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers,
|
|
|
-j.data.materials,b,d,g)};a.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};a.postMessage(e)},loadAjaxBuffers:function(a,b,d,e,g){var j=new XMLHttpRequest,l=e+"/"+a,f=0;j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.Loader.prototype.createBinModel(j.responseText,d,e,b):alert("Couldn't load ["+l+"] ["+j.status+"]");else if(j.readyState==3){if(g){if(f==0)f=j.getResponseHeader("Content-Length");g({total:f,loaded:j.responseText.length})}}else if(j.readyState==
|
|
|
-2)f=j.getResponseHeader("Content-Length")};j.open("GET",l,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)},createBinModel:function(a,b,d,e){var g=function(j){function l(p,s){var x=t(p,s),G=t(p,s+1),U=t(p,s+2),ba=t(p,s+3),ga=(ba<<1&255|U>>7)-127;x=(U&127)<<16|G<<8|x;if(x==0&&ga==-127)return 0;return(1-2*(ba>>7))*(1+x*Math.pow(2,-23))*Math.pow(2,ga)}function f(p,s){var x=t(p,s),G=t(p,s+1),U=t(p,s+2);return(t(p,s+3)<<24)+(U<<
|
|
|
-16)+(G<<8)+x}function q(p,s){var x=t(p,s);return(t(p,s+1)<<8)+x}function c(p,s){var x=t(p,s);return x>127?x-256:x}function t(p,s){return p.charCodeAt(s)&255}function D(p){var s,x,G;s=f(a,p);x=f(a,p+i);G=f(a,p+y);p=q(a,p+k);THREE.Loader.prototype.f3(I,s,x,G,p)}function r(p){var s,x,G,U,ba,ga;s=f(a,p);x=f(a,p+i);G=f(a,p+y);U=q(a,p+k);ba=f(a,p+o);ga=f(a,p+B);p=f(a,p+A);THREE.Loader.prototype.f3n(I,h,s,x,G,U,ba,ga,p)}function u(p){var s,x,G,U;s=f(a,p);x=f(a,p+P);G=f(a,p+J);U=f(a,p+R);p=q(a,p+T);THREE.Loader.prototype.f4(I,
|
|
|
-s,x,G,U,p)}function v(p){var s,x,G,U,ba,ga,$,ka;s=f(a,p);x=f(a,p+P);G=f(a,p+J);U=f(a,p+R);ba=q(a,p+T);ga=f(a,p+E);$=f(a,p+V);ka=f(a,p+K);p=f(a,p+L);THREE.Loader.prototype.f4n(I,h,s,x,G,U,ba,ga,$,ka,p)}function w(p){var s,x;s=f(a,p);x=f(a,p+N);p=f(a,p+Y);THREE.Loader.prototype.uv3(I,n[s*2],n[s*2+1],n[x*2],n[x*2+1],n[p*2],n[p*2+1])}function H(p){var s,x,G;s=f(a,p);x=f(a,p+Q);G=f(a,p+M);p=f(a,p+W);THREE.Loader.prototype.uv4(I,n[s*2],n[s*2+1],n[x*2],n[x*2+1],n[G*2],n[G*2+1],n[p*2],n[p*2+1])}var I=this,
|
|
|
-z=0,m,h=[],n=[],i,y,k,o,B,A,P,J,R,T,E,V,K,L,N,Y,Q,M,W;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(I,e,j);m={signature:a.substr(z,8),header_bytes:t(a,z+8),vertex_coordinate_bytes:t(a,z+9),normal_coordinate_bytes:t(a,z+10),uv_coordinate_bytes:t(a,z+11),vertex_index_bytes:t(a,z+12),normal_index_bytes:t(a,z+13),uv_index_bytes:t(a,z+14),material_index_bytes:t(a,z+15),nvertices:f(a,z+16),nnormals:f(a,z+16+4),nuvs:f(a,z+16+8),ntri_flat:f(a,z+16+12),ntri_smooth:f(a,z+16+16),ntri_flat_uv:f(a,
|
|
|
-z+16+20),ntri_smooth_uv:f(a,z+16+24),nquad_flat:f(a,z+16+28),nquad_smooth:f(a,z+16+32),nquad_flat_uv:f(a,z+16+36),nquad_smooth_uv:f(a,z+16+40)};z+=m.header_bytes;i=m.vertex_index_bytes;y=m.vertex_index_bytes*2;k=m.vertex_index_bytes*3;o=m.vertex_index_bytes*3+m.material_index_bytes;B=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes;A=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*2;P=m.vertex_index_bytes;J=m.vertex_index_bytes*2;R=m.vertex_index_bytes*3;T=m.vertex_index_bytes*
|
|
|
-4;E=m.vertex_index_bytes*4+m.material_index_bytes;V=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes;K=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*2;L=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*3;N=m.uv_index_bytes;Y=m.uv_index_bytes*2;Q=m.uv_index_bytes;M=m.uv_index_bytes*2;W=m.uv_index_bytes*3;z+=function(p){var s,x,G,U=m.vertex_coordinate_bytes*3,ba=p+m.nvertices*U;for(p=p;p<ba;p+=U){s=l(a,p);x=l(a,p+m.vertex_coordinate_bytes);G=
|
|
|
-l(a,p+m.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(I,s,x,G)}return m.nvertices*U}(z);z+=function(p){var s,x,G,U=m.normal_coordinate_bytes*3,ba=p+m.nnormals*U;for(p=p;p<ba;p+=U){s=c(a,p);x=c(a,p+m.normal_coordinate_bytes);G=c(a,p+m.normal_coordinate_bytes*2);h.push(s/127,x/127,G/127)}return m.nnormals*U}(z);z+=function(p){var s,x,G=m.uv_coordinate_bytes*2,U=p+m.nuvs*G;for(p=p;p<U;p+=G){s=l(a,p);x=l(a,p+m.uv_coordinate_bytes);n.push(s,x)}return m.nuvs*G}(z);z+=function(p){var s,x=m.vertex_index_bytes*
|
|
|
-3+m.material_index_bytes,G=p+m.ntri_flat*x;for(s=p;s<G;s+=x)D(s);return G-p}(z);z+=function(p){var s,x=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*3,G=p+m.ntri_smooth*x;for(s=p;s<G;s+=x)r(s);return G-p}(z);z+=function(p){var s,x=m.vertex_index_bytes*3+m.material_index_bytes,G=x+m.uv_index_bytes*3,U=p+m.ntri_flat_uv*G;for(s=p;s<U;s+=G){D(s);w(s+x)}return U-p}(z);z+=function(p){var s,x=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*3,G=x+m.uv_index_bytes*3,
|
|
|
-U=p+m.ntri_smooth_uv*G;for(s=p;s<U;s+=G){r(s);w(s+x)}return U-p}(z);z+=function(p){var s,x=m.vertex_index_bytes*4+m.material_index_bytes,G=p+m.nquad_flat*x;for(s=p;s<G;s+=x)u(s);return G-p}(z);z+=function(p){var s,x=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,G=p+m.nquad_smooth*x;for(s=p;s<G;s+=x)v(s);return G-p}(z);z+=function(p){var s,x=m.vertex_index_bytes*4+m.material_index_bytes,G=x+m.uv_index_bytes*4,U=p+m.nquad_flat_uv*G;for(s=p;s<U;s+=G){u(s);H(s+x)}return U-p}(z);
|
|
|
-z+=function(p){var s,x=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,G=x+m.uv_index_bytes*4,U=p+m.nquad_smooth_uv*G;for(s=p;s<U;s+=G){v(s);H(s+x)}return U-p}(z);this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g(d))},createModel:function(a,b,d){var e=function(g){var j=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(j,a.materials,g);(function(){var l,f,q,c,t;l=0;for(f=
|
|
|
-a.vertices.length;l<f;l+=3){q=a.vertices[l];c=a.vertices[l+1];t=a.vertices[l+2];THREE.Loader.prototype.v(j,q,c,t)}})();(function(){function l(v,w){THREE.Loader.prototype.f3(j,v[w],v[w+1],v[w+2],v[w+3])}function f(v,w){THREE.Loader.prototype.f3n(j,a.normals,v[w],v[w+1],v[w+2],v[w+3],v[w+4],v[w+5],v[w+6])}function q(v,w){THREE.Loader.prototype.f4(j,v[w],v[w+1],v[w+2],v[w+3],v[w+4])}function c(v,w){THREE.Loader.prototype.f4n(j,a.normals,v[w],v[w+1],v[w+2],v[w+3],v[w+4],v[w+5],v[w+6],v[w+7],v[w+8])}function t(v,
|
|
|
-w){var H,I,z;H=v[w];I=v[w+1];z=v[w+2];THREE.Loader.prototype.uv3(j,a.uvs[H*2],a.uvs[H*2+1],a.uvs[I*2],a.uvs[I*2+1],a.uvs[z*2],a.uvs[z*2+1])}function D(v,w){var H,I,z,m;H=v[w];I=v[w+1];z=v[w+2];m=v[w+3];THREE.Loader.prototype.uv4(j,a.uvs[H*2],a.uvs[H*2+1],a.uvs[I*2],a.uvs[I*2+1],a.uvs[z*2],a.uvs[z*2+1],a.uvs[m*2],a.uvs[m*2+1])}var r,u;r=0;for(u=a.triangles.length;r<u;r+=4)l(a.triangles,r);r=0;for(u=a.triangles_uv.length;r<u;r+=7){l(a.triangles_uv,r);t(a.triangles_uv,r+4)}r=0;for(u=a.triangles_n.length;r<
|
|
|
-u;r+=7)f(a.triangles_n,r);r=0;for(u=a.triangles_n_uv.length;r<u;r+=10){f(a.triangles_n_uv,r);t(a.triangles_n_uv,r+7)}r=0;for(u=a.quads.length;r<u;r+=5)q(a.quads,r);r=0;for(u=a.quads_uv.length;r<u;r+=9){q(a.quads_uv,r);D(a.quads_uv,r+5)}r=0;for(u=a.quads_n.length;r<u;r+=9)c(a.quads_n,r);r=0;for(u=a.quads_n_uv.length;r<u;r+=13){c(a.quads_n_uv,r);D(a.quads_n_uv,r+9)}})();this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;
|
|
|
-b(new e(d))},v:function(a,b,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,d,e)))},f3:function(a,b,d,e,g){a.faces.push(new THREE.Face3(b,d,e,null,a.materials[g]))},f4:function(a,b,d,e,g,j){a.faces.push(new THREE.Face4(b,d,e,g,null,a.materials[j]))},f3n:function(a,b,d,e,g,j,l,f,q){j=a.materials[j];var c=b[f*3],t=b[f*3+1];f=b[f*3+2];var D=b[q*3],r=b[q*3+1];q=b[q*3+2];a.faces.push(new THREE.Face3(d,e,g,[new THREE.Vector3(b[l*3],b[l*3+1],b[l*3+2]),new THREE.Vector3(c,t,f),new THREE.Vector3(D,
|
|
|
-r,q)],j))},f4n:function(a,b,d,e,g,j,l,f,q,c,t){l=a.materials[l];var D=b[q*3],r=b[q*3+1];q=b[q*3+2];var u=b[c*3],v=b[c*3+1];c=b[c*3+2];var w=b[t*3],H=b[t*3+1];t=b[t*3+2];a.faces.push(new THREE.Face4(d,e,g,j,[new THREE.Vector3(b[f*3],b[f*3+1],b[f*3+2]),new THREE.Vector3(D,r,q),new THREE.Vector3(u,v,c),new THREE.Vector3(w,H,t)],l))},uv3:function(a,b,d,e,g,j,l){var f=[];f.push(new THREE.UV(b,d));f.push(new THREE.UV(e,g));f.push(new THREE.UV(j,l));a.uvs.push(f)},uv4:function(a,b,d,e,g,j,l,f,q){var c=[];
|
|
|
-c.push(new THREE.UV(b,d));c.push(new THREE.UV(e,g));c.push(new THREE.UV(j,l));c.push(new THREE.UV(f,q));a.uvs.push(c)},init_materials:function(a,b,d){a.materials=[];for(var e=0;e<b.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(b[e],d)]},createMaterial:function(a,b){function d(j){j=Math.log(j)/Math.LN2;return Math.floor(j)==j}var e,g;if(a.map_diffuse&&b){g=document.createElement("canvas");e=new THREE.MeshLambertMaterial({map:new THREE.Texture(g)});g=new Image;g.onload=function(){if(!d(this.width)||
|
|
|
-!d(this.height)){var j=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),l=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));e.map.image.width=j;e.map.image.height=l;e.map.image.getContext("2d").drawImage(this,0,0,j,l)}else e.map.image=this;e.map.image.loaded=1};g.src=b+"/"+a.map_diffuse}else if(a.col_diffuse){g=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;e=new THREE.MeshLambertMaterial({color:g,opacity:a.transparency})}else e=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):
|
|
|
-new THREE.MeshLambertMaterial({color:15658734});return e}};
|
|
|
+// ThreeExtras.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,e=this.z;this.x=d*a.z-e*a.y;this.y=e*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,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1};
|
|
|
+THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
|
|
|
+return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
|
|
|
+THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
|
|
|
+THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,f=[];a=0;for(b=e.length;a<b;a++){d=e[a];if(d instanceof THREE.Mesh)f=f.concat(this.intersectObject(d))}f.sort(function(j,k){return j.distance-k.distance});return f},intersectObject:function(a){function b(H,I,z,n){n=n.clone().subSelf(I);z=z.clone().subSelf(I);var h=H.clone().subSelf(I);H=n.dot(n);I=n.dot(z);n=n.dot(h);var o=z.dot(z);z=z.dot(h);h=1/(H*o-I*I);o=(o*n-I*z)*h;H=(H*z-I*n)*h;return o>0&&H>0&&o+H<1}var d,e,f,j,k,g,m,c,t,A,
|
|
|
+r,u=a.geometry,v=u.vertices,w=[];d=0;for(e=u.faces.length;d<e;d++){f=u.faces[d];A=this.origin.clone();r=this.direction.clone();j=a.matrix.multiplyVector3(v[f.a].position.clone());k=a.matrix.multiplyVector3(v[f.b].position.clone());g=a.matrix.multiplyVector3(v[f.c].position.clone());m=f instanceof THREE.Face4?a.matrix.multiplyVector3(v[f.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(f.normal.clone());t=r.dot(c);if(t<0){c=c.dot((new THREE.Vector3).sub(j,A))/t;A=A.addSelf(r.multiplyScalar(c));
|
|
|
+if(f instanceof THREE.Face3){if(b(A,j,k,g)){f={distance:this.origin.distanceTo(A),point:A,face:f,object:a};w.push(f)}}else if(f instanceof THREE.Face4)if(b(A,j,k,m)||b(A,k,g,m)){f={distance:this.origin.distanceTo(A),point:A,face:f,object:a};w.push(f)}}}return w}};
|
|
|
+THREE.Rectangle=function(){function a(){j=e-b;k=f-d}var b,d,e,f,j,k,g=true;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return j};this.getHeight=function(){return k};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(m,c,t,A){g=false;b=m;d=c;e=t;f=A;a()};this.addPoint=function(m,c){if(g){g=false;b=m;d=c;e=m;f=c}else{b=Math.min(b,m);d=Math.min(d,c);e=Math.max(e,
|
|
|
+m);f=Math.max(f,c)}a()};this.addRectangle=function(m){if(g){g=false;b=m.getLeft();d=m.getTop();e=m.getRight();f=m.getBottom()}else{b=Math.min(b,m.getLeft());d=Math.min(d,m.getTop());e=Math.max(e,m.getRight());f=Math.max(f,m.getBottom())}a()};this.inflate=function(m){b-=m;d-=m;e+=m;f+=m;a()};this.minSelf=function(m){b=Math.max(b,m.getLeft());d=Math.max(d,m.getTop());e=Math.min(e,m.getRight());f=Math.min(f,m.getBottom());a()};this.instersects=function(m){return Math.min(e,m.getRight())-Math.max(b,m.getLeft())>=
|
|
|
+0&&Math.min(f,m.getBottom())-Math.max(d,m.getTop())>=0};this.empty=function(){g=true;f=e=d=b=0;a()};this.isEmpty=function(){return g};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+f+", width: "+j+", height: "+k+" )"}};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 e=new THREE.Vector3,f=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(d,j).normalize();f.cross(j,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);this.n31=j.x;this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,f=1/(this.n41*b+this.n42*
|
|
|
+d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*f;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*f;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*f;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*
|
|
|
+a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,f=a.n13,j=a.n14,k=a.n21,g=a.n22,m=a.n23,c=a.n24,t=a.n31,A=a.n32,r=a.n33,u=a.n34,v=a.n41,w=a.n42,H=a.n43,I=a.n44,z=b.n11,n=b.n12,h=b.n13,o=b.n14,i=b.n21,y=b.n22,l=b.n23,p=b.n24,C=b.n31,B=b.n32,P=b.n33,J=b.n34,R=b.n41,T=b.n42,E=b.n43,
|
|
|
+V=b.n44;this.n11=d*z+e*i+f*C+j*R;this.n12=d*n+e*y+f*B+j*T;this.n13=d*h+e*l+f*P+j*E;this.n14=d*o+e*p+f*J+j*V;this.n21=k*z+g*i+m*C+c*R;this.n22=k*n+g*y+m*B+c*T;this.n23=k*h+g*l+m*P+c*E;this.n24=k*o+g*p+m*J+c*V;this.n31=t*z+A*i+r*C+u*R;this.n32=t*n+A*y+r*B+u*T;this.n33=t*h+A*l+r*P+u*E;this.n34=t*o+A*p+r*J+u*V;this.n41=v*z+w*i+H*C+I*R;this.n42=v*n+w*y+H*B+I*T;this.n43=v*h+w*l+H*P+I*E;this.n44=v*o+w*p+H*J+I*V},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,f=this.n14,j=this.n21,k=this.n22,
|
|
|
+g=this.n23,m=this.n24,c=this.n31,t=this.n32,A=this.n33,r=this.n34,u=this.n41,v=this.n42,w=this.n43,H=this.n44;this.n11=b*a.n11+d*a.n21+e*a.n31+f*a.n41;this.n12=b*a.n12+d*a.n22+e*a.n32+f*a.n42;this.n13=b*a.n13+d*a.n23+e*a.n33+f*a.n43;this.n14=b*a.n14+d*a.n24+e*a.n34+f*a.n44;this.n21=j*a.n11+k*a.n21+g*a.n31+m*a.n41;this.n22=j*a.n12+k*a.n22+g*a.n32+m*a.n42;this.n23=j*a.n13+k*a.n23+g*a.n33+m*a.n43;this.n24=j*a.n14+k*a.n24+g*a.n34+m*a.n44;this.n31=c*a.n11+t*a.n21+A*a.n31+r*a.n41;this.n32=c*a.n12+t*a.n22+
|
|
|
+A*a.n32+r*a.n42;this.n33=c*a.n13+t*a.n23+A*a.n33+r*a.n43;this.n34=c*a.n14+t*a.n24+A*a.n34+r*a.n44;this.n41=u*a.n11+v*a.n21+w*a.n31+H*a.n41;this.n42=u*a.n12+v*a.n22+w*a.n32+H*a.n42;this.n43=u*a.n13+v*a.n23+w*a.n33+H*a.n43;this.n44=u*a.n14+v*a.n24+w*a.n34+H*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,e){var f=b[d];b[d]=b[e];b[e]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,
|
|
|
+"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){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 e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=d;return e};THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=d;return e};
|
|
|
+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,e=Math.cos(b),f=Math.sin(b),j=1-e,k=a.x,g=a.y,m=a.z;d.n11=j*k*k+e;d.n12=j*k*g-f*m;d.n13=j*k*m+f*g;d.n21=j*k*g+f*m;d.n22=j*g*g+e;d.n23=j*g*m-f*k;d.n31=j*k*m-f*g;d.n32=j*g*m+f*k;d.n33=j*m*m+e;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],e=-b[10]*b[1]+b[2]*b[9],f=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],k=b[10]*b[0]-b[2]*b[8],g=-b[6]*b[0]+b[2]*b[4],m=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],t=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*j+b[2]*m;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*f;a.m[3]=b*j;a.m[4]=b*k;a.m[5]=b*g;a.m[6]=b*m;a.m[7]=b*c;a.m[8]=b*t;return a};
|
|
|
+THREE.Matrix4.makeFrustum=function(a,b,d,e,f,j){var k,g,m;k=new THREE.Matrix4;g=2*f/(b-a);m=2*f/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(j+f)/(j-f);f=-2*j*f/(j-f);k.n11=g;k.n12=0;k.n13=a;k.n14=0;k.n21=0;k.n22=m;k.n23=d;k.n24=0;k.n31=0;k.n32=0;k.n33=e;k.n34=f;k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,b,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,d,e)};
|
|
|
+THREE.Matrix4.makeOrtho=function(a,b,d,e,f,j){var k,g,m,c;k=new THREE.Matrix4;g=b-a;m=d-e;c=j-f;a=(b+a)/g;d=(d+e)/m;f=(j+f)/c;k.n11=2/g;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/m;k.n23=0;k.n24=-d;k.n31=0;k.n32=0;k.n33=-2/c;k.n34=-f;k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};
|
|
|
+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,e,f){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.material=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
|
|
|
+THREE.Face4=function(a,b,d,e,f,j){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.material=j instanceof Array?j:[j]};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,e,f,j,k,g=new THREE.Vector3,m=new THREE.Vector3;e=0;for(f=this.vertices.length;e<f;e++){j=this.vertices[e];j.normal.set(0,0,0)}e=0;for(f=this.faces.length;e<f;e++){j=this.faces[e];if(a&&j.vertexNormals.length){g.set(0,0,0);b=0;for(d=j.normal.length;b<d;b++)g.addSelf(j.vertexNormals[b]);g.divideScalar(3)}else{b=this.vertices[j.a];d=this.vertices[j.b];k=this.vertices[j.c];g.sub(k.position,
|
|
|
+d.position);m.sub(b.position,d.position);g.crossSelf(m)}g.isZero()||g.normalize();j.normal.copy(g)}},computeVertexNormals:function(){var a,b=[],d,e;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++){e=this.faces[a];if(e instanceof THREE.Face3){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal);b[e.d].addSelf(e.normal)}}a=
|
|
|
+0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone()}else if(e instanceof THREE.Face4){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone();e.vertexNormals[3]=b[e.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(t){var A=[];b=0;for(d=t.length;b<d;b++)t[b]==undefined?A.push("undefined"):A.push(t[b].toString());return A.join("_")}var b,d,e,f,j,k,g,m,c={};e=0;for(f=this.faces.length;e<f;e++){j=this.faces[e];k=j.material;g=a(k);if(c[g]==undefined)c[g]={hash:g,counter:0};m=c[g].hash+"_"+c[g].counter;if(this.geometryChunks[m]==
|
|
|
+undefined)this.geometryChunks[m]={faces:[],material:k,vertices:0};j=j instanceof THREE.Face3?3:4;if(this.geometryChunks[m].vertices+j>65535){c[g].counter+=1;m=c[g].hash+"_"+c[g].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],material:k,vertices:0}}this.geometryChunks[m].faces.push(e);this.geometryChunks[m].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
|
|
|
+THREE.Camera=function(a,b,d,e){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,e);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,e,f;a=0;for(b=this.geometry.uvs.length;a<b;a++){f=this.geometry.uvs[a];d=0;for(e=f.length;d<e;d++){if(f[d].u!=1)f[d].u-=Math.floor(f[d].u);if(f[d].v!=1)f[d].v-=Math.floor(f[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,e,f,j){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=f!==undefined?f:THREE.LinearFilter;this.min_filter=j!==undefined?j: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(z,n){var h=0,o=1,i=z.z+z.w,y=n.z+n.w,l=-z.z+z.w,p=-n.z+n.w;if(i>=0&&y>=0&&l>=0&&p>=0)return true;else if(i<0&&y<0||l<0&&p<0)return false;else{if(i<0)h=Math.max(h,i/(i-y));else if(y<0)o=Math.min(o,i/(i-y));if(l<0)h=Math.max(h,l/(l-p));else if(p<0)o=Math.min(o,l/(l-p));if(o<h)return false;else{z.lerpSelf(n,h);n.lerpSelf(z,1-o);return true}}}var b=null,d,e,f,j=[],k,g,m=[],c,t,A=[],r=new THREE.Vector4,u=new THREE.Matrix4,v=new THREE.Matrix4,w=new THREE.Vector4,H=
|
|
|
+new THREE.Vector4,I;this.projectScene=function(z,n){var h,o,i,y,l,p,C,B,P,J,R,T,E,V,K,L,N;b=[];f=g=t=0;n.autoUpdateMatrix&&n.updateMatrix();u.multiply(n.projectionMatrix,n.matrix);C=z.objects;h=0;for(o=C.length;h<o;h++){B=C[h];B.autoUpdateMatrix&&B.updateMatrix();P=B.matrix;J=B.rotationMatrix;R=B.material;T=B.overdraw;if(B instanceof THREE.Mesh){E=B.geometry.vertices;i=0;for(y=E.length;i<y;i++){V=E[i];V.positionWorld.copy(V.position);P.multiplyVector3(V.positionWorld);K=V.positionScreen;K.copy(V.positionWorld);
|
|
|
+u.multiplyVector4(K);K.multiplyScalar(1/K.w);V.__visible=K.z>0&&K.z<1}V=B.geometry.faces;i=0;for(y=V.length;i<y;i++){K=V[i];if(K instanceof THREE.Face3){l=E[K.a];p=E[K.b];L=E[K.c];if(l.__visible&&p.__visible&&L.__visible)if(B.doubleSided||B.flipSided!=(L.positionScreen.x-l.positionScreen.x)*(p.positionScreen.y-l.positionScreen.y)-(L.positionScreen.y-l.positionScreen.y)*(p.positionScreen.x-l.positionScreen.x)<0){d=j[f]=j[f]||new THREE.RenderableFace3;d.v1.positionWorld.copy(l.positionWorld);d.v2.positionWorld.copy(p.positionWorld);
|
|
|
+d.v3.positionWorld.copy(L.positionWorld);d.v1.positionScreen.copy(l.positionScreen);d.v2.positionScreen.copy(p.positionScreen);d.v3.positionScreen.copy(L.positionScreen);d.normalWorld.copy(K.normal);J.multiplyVector3(d.normalWorld);d.centroidWorld.copy(K.centroid);P.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);u.multiplyVector3(d.centroidScreen);L=K.vertexNormals;I=d.vertexNormalsWorld;l=0;for(p=L.length;l<p;l++){N=I[l]=I[l]||new THREE.Vector3;N.copy(L[l]);J.multiplyVector3(N)}d.z=
|
|
|
+d.centroidScreen.z;d.meshMaterial=R;d.faceMaterial=K.material;d.overdraw=T;if(B.geometry.uvs[i]){d.uvs[0]=B.geometry.uvs[i][0];d.uvs[1]=B.geometry.uvs[i][1];d.uvs[2]=B.geometry.uvs[i][2]}b.push(d);f++}}else if(K instanceof THREE.Face4){l=E[K.a];p=E[K.b];L=E[K.c];N=E[K.d];if(l.__visible&&p.__visible&&L.__visible&&N.__visible)if(B.doubleSided||B.flipSided!=((N.positionScreen.x-l.positionScreen.x)*(p.positionScreen.y-l.positionScreen.y)-(N.positionScreen.y-l.positionScreen.y)*(p.positionScreen.x-l.positionScreen.x)<
|
|
|
+0||(p.positionScreen.x-L.positionScreen.x)*(N.positionScreen.y-L.positionScreen.y)-(p.positionScreen.y-L.positionScreen.y)*(N.positionScreen.x-L.positionScreen.x)<0)){d=j[f]=j[f]||new THREE.RenderableFace3;d.v1.positionWorld.copy(l.positionWorld);d.v2.positionWorld.copy(p.positionWorld);d.v3.positionWorld.copy(N.positionWorld);d.v1.positionScreen.copy(l.positionScreen);d.v2.positionScreen.copy(p.positionScreen);d.v3.positionScreen.copy(N.positionScreen);d.normalWorld.copy(K.normal);J.multiplyVector3(d.normalWorld);
|
|
|
+d.centroidWorld.copy(K.centroid);P.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);u.multiplyVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=R;d.faceMaterial=K.material;d.overdraw=T;if(B.geometry.uvs[i]){d.uvs[0]=B.geometry.uvs[i][0];d.uvs[1]=B.geometry.uvs[i][1];d.uvs[2]=B.geometry.uvs[i][3]}b.push(d);f++;e=j[f]=j[f]||new THREE.RenderableFace3;e.v1.positionWorld.copy(p.positionWorld);e.v2.positionWorld.copy(L.positionWorld);e.v3.positionWorld.copy(N.positionWorld);
|
|
|
+e.v1.positionScreen.copy(p.positionScreen);e.v2.positionScreen.copy(L.positionScreen);e.v3.positionScreen.copy(N.positionScreen);e.normalWorld.copy(d.normalWorld);e.centroidWorld.copy(d.centroidWorld);e.centroidScreen.copy(d.centroidScreen);e.z=e.centroidScreen.z;e.meshMaterial=R;e.faceMaterial=K.material;e.overdraw=T;if(B.geometry.uvs[i]){e.uvs[0]=B.geometry.uvs[i][1];e.uvs[1]=B.geometry.uvs[i][2];e.uvs[2]=B.geometry.uvs[i][3]}b.push(e);f++}}}}else if(B instanceof THREE.Line){v.multiply(u,P);E=B.geometry.vertices;
|
|
|
+V=E[0];V.positionScreen.copy(V.position);v.multiplyVector4(V.positionScreen);i=1;for(y=E.length;i<y;i++){l=E[i];l.positionScreen.copy(l.position);v.multiplyVector4(l.positionScreen);p=E[i-1];w.copy(l.positionScreen);H.copy(p.positionScreen);if(a(w,H)){w.multiplyScalar(1/w.w);H.multiplyScalar(1/H.w);k=m[g]=m[g]||new THREE.RenderableLine;k.v1.positionScreen.copy(w);k.v2.positionScreen.copy(H);k.z=Math.max(w.z,H.z);k.material=B.material;b.push(k);g++}}}else if(B instanceof THREE.Particle){r.set(B.position.x,
|
|
|
+B.position.y,B.position.z,1);u.multiplyVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){c=A[t]=A[t]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=B.rotation.z;c.scale.x=B.scale.x*Math.abs(c.x-(r.x+n.projectionMatrix.n11)/(r.w+n.projectionMatrix.n14));c.scale.y=B.scale.y*Math.abs(c.y-(r.y+n.projectionMatrix.n22)/(r.w+n.projectionMatrix.n24));c.material=B.material;b.push(c);t++}}}b.sort(function(Y,Q){return Q.z-Y.z});return b};this.unprojectVector=function(z,n){var h=new THREE.Matrix4;
|
|
|
+h.multiply(THREE.Matrix4.makeInvert(n.matrix),THREE.Matrix4.makeInvert(n.projectionMatrix));h.multiplyVector3(z);return z}};
|
|
|
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,f,j;this.domElement=document.createElement("div");this.setSize=function(k,g){d=k;e=g;f=d/2;j=e/2};this.render=function(k,g){var m,c,t,A,r,u,v,w;a=b.projectScene(k,g);m=0;for(c=a.length;m<c;m++){r=a[m];if(r instanceof THREE.RenderableParticle){v=r.x*f+f;w=r.y*j+j;t=0;for(A=r.material.length;t<A;t++){u=r.material[t];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=v+"px";u.style.top=w+"px"}}}}}};
|
|
|
+THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,d=document.createElement("canvas"),e,f,j,k,g=d.getContext("2d"),m=1,c=0,t=null,A=null,r=1,u=Math.min,v=Math.max,w,H,I,z,n,h,o,i,y,l=new THREE.Color,p=new THREE.Color,C=new THREE.Color,B=new THREE.Color,P=new THREE.Color,J,R,T,E,V,K,L,N,Y,Q,M=new THREE.Rectangle,W=new THREE.Rectangle,q=new THREE.Rectangle,s=false,x=new THREE.Color,G=new THREE.Color,U=new THREE.Color,ba=new THREE.Color,ga=Math.PI*2,$=new THREE.Vector3,ka,pa,Da,da,qa,wa,
|
|
|
+na=16;ka=document.createElement("canvas");ka.width=ka.height=2;pa=ka.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);Da=pa.getImageData(0,0,2,2);da=Da.data;qa=document.createElement("canvas");qa.width=qa.height=na;wa=qa.getContext("2d");wa.translate(-na/2,-na/2);wa.scale(na,na);na--;this.domElement=d;this.autoClear=true;this.setSize=function(ia,xa){e=ia;f=xa;j=e/2;k=f/2;d.width=e;d.height=f;M.set(-j,-k,j,k)};this.clear=function(){if(!W.isEmpty()){W.inflate(1);W.minSelf(M);g.clearRect(W.getX(),
|
|
|
+W.getY(),W.getWidth(),W.getHeight());W.empty()}};this.render=function(ia,xa){function Ma(D){var X,S,F,O=D.lights;G.setRGB(0,0,0);U.setRGB(0,0,0);ba.setRGB(0,0,0);D=0;for(X=O.length;D<X;D++){S=O[D];F=S.color;if(S instanceof THREE.AmbientLight){G.r+=F.r;G.g+=F.g;G.b+=F.b}else if(S instanceof THREE.DirectionalLight){U.r+=F.r;U.g+=F.g;U.b+=F.b}else if(S instanceof THREE.PointLight){ba.r+=F.r;ba.g+=F.g;ba.b+=F.b}}}function ya(D,X,S,F){var O,Z,ca,ea,fa=D.lights;D=0;for(O=fa.length;D<O;D++){Z=fa[D];ca=Z.color;
|
|
|
+ea=Z.intensity;if(Z instanceof THREE.DirectionalLight){Z=S.dot(Z.position)*ea;if(Z>0){F.r+=ca.r*Z;F.g+=ca.g*Z;F.b+=ca.b*Z}}else if(Z instanceof THREE.PointLight){$.sub(Z.position,X);$.normalize();Z=S.dot($)*ea;if(Z>0){F.r+=ca.r*Z;F.g+=ca.g*Z;F.b+=ca.b*Z}}}}function Na(D,X,S){if(S.opacity!=0){Ea(S.opacity);za(S.blending);var F,O,Z,ca,ea,fa;if(S instanceof THREE.ParticleBasicMaterial){if(S.map){ca=S.map;ea=ca.width>>1;fa=ca.height>>1;O=X.scale.x*j;Z=X.scale.y*k;S=O*ea;F=Z*fa;q.set(D.x-S,D.y-F,D.x+S,
|
|
|
+D.y+F);if(M.instersects(q)){g.save();g.translate(D.x,D.y);g.rotate(-X.rotation);g.scale(O,-Z);g.translate(-ea,-fa);g.drawImage(ca,0,0);g.restore()}}}else if(S instanceof THREE.ParticleCircleMaterial){if(s){x.r=G.r+U.r+ba.r;x.g=G.g+U.g+ba.g;x.b=G.b+U.b+ba.b;l.r=S.color.r*x.r;l.g=S.color.g*x.g;l.b=S.color.b*x.b;l.updateStyleString()}else l.__styleString=S.color.__styleString;S=X.scale.x*j;F=X.scale.y*k;q.set(D.x-S,D.y-F,D.x+S,D.y+F);if(M.instersects(q)){O=l.__styleString;if(A!=O)g.fillStyle=A=O;g.save();
|
|
|
+g.translate(D.x,D.y);g.rotate(-X.rotation);g.scale(S,F);g.beginPath();g.arc(0,0,1,0,ga,true);g.closePath();g.fill();g.restore()}}}}function Oa(D,X,S,F){if(F.opacity!=0){Ea(F.opacity);za(F.blending);g.beginPath();g.moveTo(D.positionScreen.x,D.positionScreen.y);g.lineTo(X.positionScreen.x,X.positionScreen.y);g.closePath();if(F instanceof THREE.LineBasicMaterial){l.__styleString=F.color.__styleString;D=F.linewidth;if(r!=D)g.lineWidth=r=D;D=l.__styleString;if(t!=D)g.strokeStyle=t=D;g.stroke();q.inflate(F.linewidth*
|
|
|
+2)}}}function Ia(D,X,S,F,O,Z){if(O.opacity!=0){Ea(O.opacity);za(O.blending);z=D.positionScreen.x;n=D.positionScreen.y;h=X.positionScreen.x;o=X.positionScreen.y;i=S.positionScreen.x;y=S.positionScreen.y;g.beginPath();g.moveTo(z,n);g.lineTo(h,o);g.lineTo(i,y);g.lineTo(z,n);g.closePath();if(O instanceof THREE.MeshBasicMaterial)if(O.map)O.map.image.loaded&&O.map.mapping instanceof THREE.UVMapping&&ra(z,n,h,o,i,y,O.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);else if(O.env_map){if(O.env_map.image.loaded)if(O.env_map.mapping instanceof
|
|
|
+THREE.SphericalReflectionMapping){D=xa.matrix;$.copy(F.vertexNormalsWorld[0]);V=($.x*D.n11+$.y*D.n12+$.z*D.n13)*0.5+0.5;K=-($.x*D.n21+$.y*D.n22+$.z*D.n23)*0.5+0.5;$.copy(F.vertexNormalsWorld[1]);L=($.x*D.n11+$.y*D.n12+$.z*D.n13)*0.5+0.5;N=-($.x*D.n21+$.y*D.n22+$.z*D.n23)*0.5+0.5;$.copy(F.vertexNormalsWorld[2]);Y=($.x*D.n11+$.y*D.n12+$.z*D.n13)*0.5+0.5;Q=-($.x*D.n21+$.y*D.n22+$.z*D.n23)*0.5+0.5;ra(z,n,h,o,i,y,O.env_map.image,V,K,L,N,Y,Q)}}else O.wireframe?Aa(O.color.__styleString,O.wireframe_linewidth):
|
|
|
+Ba(O.color.__styleString);else if(O instanceof THREE.MeshLambertMaterial){if(O.map&&!O.wireframe){O.map.mapping instanceof THREE.UVMapping&&ra(z,n,h,o,i,y,O.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);za(THREE.SubtractiveBlending)}if(s)if(!O.wireframe&&O.shading==THREE.SmoothShading&&F.vertexNormalsWorld.length==3){p.r=C.r=B.r=G.r;p.g=C.g=B.g=G.g;p.b=C.b=B.b=G.b;ya(Z,F.v1.positionWorld,F.vertexNormalsWorld[0],p);ya(Z,F.v2.positionWorld,F.vertexNormalsWorld[1],C);ya(Z,
|
|
|
+F.v3.positionWorld,F.vertexNormalsWorld[2],B);P.r=(C.r+B.r)*0.5;P.g=(C.g+B.g)*0.5;P.b=(C.b+B.b)*0.5;E=Ja(p,C,B,P);ra(z,n,h,o,i,y,E,0,0,1,0,0,1)}else{x.r=G.r;x.g=G.g;x.b=G.b;ya(Z,F.centroidWorld,F.normalWorld,x);l.r=O.color.r*x.r;l.g=O.color.g*x.g;l.b=O.color.b*x.b;l.updateStyleString();O.wireframe?Aa(l.__styleString,O.wireframe_linewidth):Ba(l.__styleString)}else O.wireframe?Aa(O.color.__styleString,O.wireframe_linewidth):Ba(O.color.__styleString)}else if(O instanceof THREE.MeshDepthMaterial){J=O.__2near;
|
|
|
+R=O.__farPlusNear;T=O.__farMinusNear;p.r=p.g=p.b=1-J/(R-D.positionScreen.z*T);C.r=C.g=C.b=1-J/(R-X.positionScreen.z*T);B.r=B.g=B.b=1-J/(R-S.positionScreen.z*T);P.r=(C.r+B.r)*0.5;P.g=(C.g+B.g)*0.5;P.b=(C.b+B.b)*0.5;E=Ja(p,C,B,P);ra(z,n,h,o,i,y,E,0,0,1,0,0,1)}else if(O instanceof THREE.MeshNormalMaterial){l.r=Fa(F.normalWorld.x);l.g=Fa(F.normalWorld.y);l.b=Fa(F.normalWorld.z);l.updateStyleString();O.wireframe?Aa(l.__styleString,O.wireframe_linewidth):Ba(l.__styleString)}}}function Aa(D,X){if(t!=D)g.strokeStyle=
|
|
|
+t=D;if(r!=X)g.lineWidth=r=X;g.stroke();q.inflate(X*2)}function Ba(D){if(A!=D)g.fillStyle=A=D;g.fill()}function ra(D,X,S,F,O,Z,ca,ea,fa,sa,la,ta,ua){var ma,ja;ma=ca.width-1;ja=ca.height-1;ea*=ma;fa*=ja;sa*=ma;la*=ja;ta*=ma;ua*=ja;S-=D;F-=X;O-=D;Z-=X;sa-=ea;la-=fa;ta-=ea;ua-=fa;ja=1/(sa*ua-ta*la);ma=(ua*S-la*O)*ja;la=(ua*F-la*Z)*ja;S=(sa*O-ta*S)*ja;F=(sa*Z-ta*F)*ja;D=D-ma*ea-S*fa;X=X-la*ea-F*fa;g.save();g.transform(ma,la,S,F,D,X);g.clip();g.drawImage(ca,0,0);g.restore()}function Ea(D){if(m!=D)g.globalAlpha=
|
|
|
+m=D}function za(D){if(c!=D){switch(D){case THREE.NormalBlending:g.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:g.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:g.globalCompositeOperation="darker"}c=D}}function Ja(D,X,S,F){da[0]=v(0,u(255,~~(D.r*255)));da[1]=v(0,u(255,~~(D.g*255)));da[2]=v(0,u(255,~~(D.b*255)));da[4]=v(0,u(255,~~(X.r*255)));da[5]=v(0,u(255,~~(X.g*255)));da[6]=v(0,u(255,~~(X.b*255)));da[8]=v(0,u(255,~~(S.r*255)));da[9]=v(0,u(255,
|
|
|
+~~(S.g*255)));da[10]=v(0,u(255,~~(S.b*255)));da[12]=v(0,u(255,~~(F.r*255)));da[13]=v(0,u(255,~~(F.g*255)));da[14]=v(0,u(255,~~(F.b*255)));pa.putImageData(Da,0,0);wa.drawImage(ka,0,0);return qa}function Fa(D){return D<0?u((1+D)*0.5,0.5):0.5+u(D*0.5,0.5)}function Ga(D,X){var S=X.x-D.x,F=X.y-D.y,O=1/Math.sqrt(S*S+F*F);S*=O;F*=O;X.x+=S;X.y+=F;D.x-=S;D.y-=F}var Ca,Ka,aa,ha,oa,Ha,La,va;g.setTransform(1,0,0,-1,j,k);this.autoClear&&this.clear();a=b.projectScene(ia,xa);(s=ia.lights.length>0)&&Ma(ia);Ca=0;
|
|
|
+for(Ka=a.length;Ca<Ka;Ca++){aa=a[Ca];q.empty();if(aa instanceof THREE.RenderableParticle){w=aa;w.x*=j;w.y*=k;ha=0;for(oa=aa.material.length;ha<oa;ha++)Na(w,aa,aa.material[ha],ia)}else if(aa instanceof THREE.RenderableLine){w=aa.v1;H=aa.v2;w.positionScreen.x*=j;w.positionScreen.y*=k;H.positionScreen.x*=j;H.positionScreen.y*=k;q.addPoint(w.positionScreen.x,w.positionScreen.y);q.addPoint(H.positionScreen.x,H.positionScreen.y);if(M.instersects(q)){ha=0;for(oa=aa.material.length;ha<oa;)Oa(w,H,aa,aa.material[ha++],
|
|
|
+ia)}}else if(aa instanceof THREE.RenderableFace3){w=aa.v1;H=aa.v2;I=aa.v3;w.positionScreen.x*=j;w.positionScreen.y*=k;H.positionScreen.x*=j;H.positionScreen.y*=k;I.positionScreen.x*=j;I.positionScreen.y*=k;if(aa.overdraw){Ga(w.positionScreen,H.positionScreen);Ga(H.positionScreen,I.positionScreen);Ga(I.positionScreen,w.positionScreen)}q.addPoint(w.positionScreen.x,w.positionScreen.y);q.addPoint(H.positionScreen.x,H.positionScreen.y);q.addPoint(I.positionScreen.x,I.positionScreen.y);if(M.instersects(q)){ha=
|
|
|
+0;for(oa=aa.meshMaterial.length;ha<oa;){va=aa.meshMaterial[ha++];if(va instanceof THREE.MeshFaceMaterial){Ha=0;for(La=aa.faceMaterial.length;Ha<La;)(va=aa.faceMaterial[Ha++])&&Ia(w,H,I,aa,va,ia)}else Ia(w,H,I,aa,va,ia)}}}W.addRectangle(q)}g.setTransform(1,0,0,1,0,0)}};
|
|
|
+THREE.SVGRenderer=function(){function a(K,L,N){var Y,Q,M,W;Y=0;for(Q=K.lights.length;Y<Q;Y++){M=K.lights[Y];if(M instanceof THREE.DirectionalLight){W=L.normalWorld.dot(M.position)*M.intensity;if(W>0){N.r+=M.color.r*W;N.g+=M.color.g*W;N.b+=M.color.b*W}}else if(M instanceof THREE.PointLight){p.sub(M.position,L.centroidWorld);p.normalize();W=L.normalWorld.dot(p)*M.intensity;if(W>0){N.r+=M.color.r*W;N.g+=M.color.g*W;N.b+=M.color.b*W}}}}function b(K,L,N,Y,Q,M){J=e(R++);J.setAttribute("d","M "+K.positionScreen.x+
|
|
|
+" "+K.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+"z");if(Q instanceof THREE.MeshBasicMaterial)n.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshLambertMaterial)if(z){h.r=o.r;h.g=o.g;h.b=o.b;a(M,Y,h);n.r=Q.color.r*h.r;n.g=Q.color.g*h.g;n.b=Q.color.b*h.b;n.updateStyleString()}else n.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshDepthMaterial){l=1-Q.__2near/(Q.__farPlusNear-Y.z*Q.__farMinusNear);
|
|
|
+n.setRGB(l,l,l)}else Q instanceof THREE.MeshNormalMaterial&&n.setRGB(f(Y.normalWorld.x),f(Y.normalWorld.y),f(Y.normalWorld.z));Q.wireframe?J.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+Q.wireframe_linewidth+"; stroke-opacity: "+Q.opacity+"; stroke-linecap: "+Q.wireframe_linecap+"; stroke-linejoin: "+Q.wireframe_linejoin):J.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+Q.opacity);g.appendChild(J)}function d(K,L,N,Y,Q,M,W){J=e(R++);J.setAttribute("d",
|
|
|
+"M "+K.positionScreen.x+" "+K.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+" L "+Y.positionScreen.x+","+Y.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(z){h.r=o.r;h.g=o.g;h.b=o.b;a(W,Q,h);n.r=M.color.r*h.r;n.g=M.color.g*h.g;n.b=M.color.b*h.b;n.updateStyleString()}else n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){l=
|
|
|
+1-M.__2near/(M.__farPlusNear-Q.z*M.__farMinusNear);n.setRGB(l,l,l)}else M instanceof THREE.MeshNormalMaterial&&n.setRGB(f(Q.normalWorld.x),f(Q.normalWorld.y),f(Q.normalWorld.z));M.wireframe?J.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+M.wireframe_linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframe_linecap+"; stroke-linejoin: "+M.wireframe_linejoin):J.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+M.opacity);g.appendChild(J)}
|
|
|
+function e(K){if(C[K]==null){C[K]=document.createElementNS("http://www.w3.org/2000/svg","path");V==0&&C[K].setAttribute("shape-rendering","crispEdges");return C[K]}return C[K]}function f(K){return K<0?Math.min((1+K)*0.5,0.5):0.5+Math.min(K*0.5,0.5)}var j=null,k=new THREE.Projector,g=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,c,t,A,r,u,v,w,H=new THREE.Rectangle,I=new THREE.Rectangle,z=false,n=new THREE.Color(16777215),h=new THREE.Color(16777215),o=new THREE.Color(0),i=new THREE.Color(0),
|
|
|
+y=new THREE.Color(0),l,p=new THREE.Vector3,C=[],B=[],P=[],J,R,T,E,V=1;this.domElement=g;this.autoClear=true;this.setQuality=function(K){switch(K){case "high":V=1;break;case "low":V=0}};this.setSize=function(K,L){m=K;c=L;t=m/2;A=c/2;g.setAttribute("viewBox",-t+" "+-A+" "+m+" "+c);g.setAttribute("width",m);g.setAttribute("height",c);H.set(-t,-A,t,A)};this.clear=function(){for(;g.childNodes.length>0;)g.removeChild(g.childNodes[0])};this.render=function(K,L){var N,Y,Q,M,W,q,s,x;this.autoClear&&this.clear();
|
|
|
+j=k.projectScene(K,L);E=T=R=0;if(z=K.lights.length>0){s=K.lights;o.setRGB(0,0,0);i.setRGB(0,0,0);y.setRGB(0,0,0);N=0;for(Y=s.length;N<Y;N++){Q=s[N];M=Q.color;if(Q instanceof THREE.AmbientLight){o.r+=M.r;o.g+=M.g;o.b+=M.b}else if(Q instanceof THREE.DirectionalLight){i.r+=M.r;i.g+=M.g;i.b+=M.b}else if(Q instanceof THREE.PointLight){y.r+=M.r;y.g+=M.g;y.b+=M.b}}}N=0;for(Y=j.length;N<Y;N++){s=j[N];I.empty();if(s instanceof THREE.RenderableParticle){r=s;r.x*=t;r.y*=-A;Q=0;for(M=s.material.length;Q<M;Q++)if(x=
|
|
|
+s.material[Q]){W=r;q=s;x=x;var G=T++;if(B[G]==null){B[G]=document.createElementNS("http://www.w3.org/2000/svg","circle");V==0&&B[G].setAttribute("shape-rendering","crispEdges")}J=B[G];J.setAttribute("cx",W.x);J.setAttribute("cy",W.y);J.setAttribute("r",q.scale.x*t);if(x instanceof THREE.ParticleCircleMaterial){if(z){h.r=o.r+i.r+y.r;h.g=o.g+i.g+y.g;h.b=o.b+i.b+y.b;n.r=x.color.r*h.r;n.g=x.color.g*h.g;n.b=x.color.b*h.b;n.updateStyleString()}else n=x.color;J.setAttribute("style","fill: "+n.__styleString)}g.appendChild(J)}}else if(s instanceof
|
|
|
+THREE.RenderableLine){r=s.v1;u=s.v2;r.positionScreen.x*=t;r.positionScreen.y*=-A;u.positionScreen.x*=t;u.positionScreen.y*=-A;I.addPoint(r.positionScreen.x,r.positionScreen.y);I.addPoint(u.positionScreen.x,u.positionScreen.y);if(H.instersects(I)){Q=0;for(M=s.material.length;Q<M;)if(x=s.material[Q++]){W=r;q=u;x=x;G=E++;if(P[G]==null){P[G]=document.createElementNS("http://www.w3.org/2000/svg","line");V==0&&P[G].setAttribute("shape-rendering","crispEdges")}J=P[G];J.setAttribute("x1",W.positionScreen.x);
|
|
|
+J.setAttribute("y1",W.positionScreen.y);J.setAttribute("x2",q.positionScreen.x);J.setAttribute("y2",q.positionScreen.y);if(x instanceof THREE.LineBasicMaterial){n.__styleString=x.color.__styleString;J.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+x.linewidth+"; stroke-opacity: "+x.opacity+"; stroke-linecap: "+x.linecap+"; stroke-linejoin: "+x.linejoin);g.appendChild(J)}}}}else if(s instanceof THREE.RenderableFace3){r=s.v1;u=s.v2;v=s.v3;r.positionScreen.x*=t;r.positionScreen.y*=
|
|
|
+-A;u.positionScreen.x*=t;u.positionScreen.y*=-A;v.positionScreen.x*=t;v.positionScreen.y*=-A;I.addPoint(r.positionScreen.x,r.positionScreen.y);I.addPoint(u.positionScreen.x,u.positionScreen.y);I.addPoint(v.positionScreen.x,v.positionScreen.y);if(H.instersects(I)){Q=0;for(M=s.meshMaterial.length;Q<M;){x=s.meshMaterial[Q++];if(x instanceof THREE.MeshFaceMaterial){W=0;for(q=s.faceMaterial.length;W<q;)(x=s.faceMaterial[W++])&&b(r,u,v,s,x,K)}else x&&b(r,u,v,s,x,K)}}}else if(s instanceof THREE.RenderableFace4){r=
|
|
|
+s.v1;u=s.v2;v=s.v3;w=s.v4;r.positionScreen.x*=t;r.positionScreen.y*=-A;u.positionScreen.x*=t;u.positionScreen.y*=-A;v.positionScreen.x*=t;v.positionScreen.y*=-A;w.positionScreen.x*=t;w.positionScreen.y*=-A;I.addPoint(r.positionScreen.x,r.positionScreen.y);I.addPoint(u.positionScreen.x,u.positionScreen.y);I.addPoint(v.positionScreen.x,v.positionScreen.y);I.addPoint(w.positionScreen.x,w.positionScreen.y);if(H.instersects(I)){Q=0;for(M=s.meshMaterial.length;Q<M;){x=s.meshMaterial[Q++];if(x instanceof
|
|
|
+THREE.MeshFaceMaterial){W=0;for(q=s.faceMaterial.length;W<q;)(x=s.faceMaterial[W++])&&d(r,u,v,w,s,x,K)}else x&&d(r,u,v,w,s,x,K)}}}}}};
|
|
|
+THREE.WebGLRenderer=function(a){function b(h,o){var i=c.createProgram();c.attachShader(i,k("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\n"+h));c.attachShader(i,k("vertex","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"+o));c.linkProgram(i);c.getProgramParameter(i,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(i,
|
|
|
+c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");i.uniforms={};i.attributes={};return i}function d(h,o){if(h.image.length==6){if(!h.image.__webGLTextureCube&&!h.image.__cubeMapInitialized&&h.image.loadCount==6){h.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,h.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 i=0;i<6;++i)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,h.image[i]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);h.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+o);c.bindTexture(c.TEXTURE_CUBE_MAP,h.image.__webGLTextureCube)}}function e(h,o){if(!h.__webGLTexture&&h.image.loaded){h.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,
|
|
|
+h.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,h.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,g(h.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,g(h.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,g(h.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,g(h.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+o);c.bindTexture(c.TEXTURE_2D,h.__webGLTexture)}function f(h,o){var i,y,l;
|
|
|
+i=0;for(y=o.length;i<y;i++){l=o[i];h.uniforms[l]=c.getUniformLocation(h,l)}}function j(h,o){var i,y,l;i=0;for(y=o.length;i<y;i++){l=o[i];h.attributes[l]=c.getAttribLocation(h,l);h.attributes[l]>=0&&c.enableVertexAttribArray(h.attributes[l])}}function k(h,o){var i;if(h=="fragment")i=c.createShader(c.FRAGMENT_SHADER);else if(h=="vertex")i=c.createShader(c.VERTEX_SHADER);c.shaderSource(i,o);c.compileShader(i);if(!c.getShaderParameter(i,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(i));return null}return i}
|
|
|
+function g(h){switch(h){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}
|
|
|
+var m=document.createElement("canvas"),c,t,A,r=new THREE.Matrix4,u,v=new Float32Array(16),w=new Float32Array(16),H=new Float32Array(16),I=new Float32Array(9),z=new Float32Array(16);a=function(h,o){if(h){var i,y,l,p=pointLights=maxDirLights=maxPointLights=0;i=0;for(y=h.lights.length;i<y;i++){l=h.lights[i];l instanceof THREE.DirectionalLight&&p++;l instanceof THREE.PointLight&&pointLights++}if(pointLights+p<=o){maxDirLights=p;maxPointLights=pointLights}else{maxDirLights=Math.ceil(o*p/(pointLights+p));
|
|
|
+maxPointLights=o-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:o-1}}(a,4);this.domElement=m;this.autoClear=true;try{c=m.getContext("experimental-webgl",{antialias:true})}catch(n){}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);t=A=function(h,o){var i=[h?"#define MAX_DIR_LIGHTS "+h:"",o?"#define MAX_POINT_LIGHTS "+o:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",h?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",h?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",o?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",o?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":
|
|
|
+"","uniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",o?"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;",
|
|
|
+h?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",h?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",h?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",h?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",h?"}":"",o?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",o?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",o?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
|
|
|
+"",o?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",o?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",o?"}":"","}\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"),
|
|
|
+y=[h?"#define MAX_DIR_LIGHTS "+h:"",o?"#define MAX_POINT_LIGHTS "+o:"","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;",
|
|
|
+h?"uniform mat4 viewMatrix;":"",h?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",o?"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 );",
|
|
|
+o?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",o?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",o?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",o?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",o?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",o?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",o?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",o?"float pointSpecularWeight = 0.0;":"",o?"if ( pointDotNormalHalf >= 0.0 )":
|
|
|
+"",o?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",o?"pointDiffuse += mColor * pointDiffuseWeight;":"",o?"pointSpecular += mSpecular * pointSpecularWeight;":"",o?"}":"",h?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",h?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",h?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",h?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",h?"vec3 dirVector = normalize( lDirection.xyz );":"",h?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
|
|
|
+"",h?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",h?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",h?"float dirSpecularWeight = 0.0;":"",h?"if ( dirDotNormalHalf >= 0.0 )":"",h?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",h?"dirDiffuse += mColor * dirDiffuseWeight;":"",h?"dirSpecular += mSpecular * dirSpecularWeight;":"",h?"}":"","vec4 totalLight = mAmbient;",h?"totalLight += dirDiffuse + dirSpecular;":"",o?"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");
|
|
|
+i=b(y,i);c.useProgram(i);f(i,["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"]);h&&f(i,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);o&&f(i,["pointLightNumber","pointLightColor",
|
|
|
+"pointLightPosition"]);c.uniform1i(i.uniforms.enableMap,0);c.uniform1i(i.uniforms.tMap,0);c.uniform1i(i.uniforms.enableCubeMap,0);c.uniform1i(i.uniforms.tCube,1);c.uniform1i(i.uniforms.mixEnvMap,0);c.uniform1i(i.uniforms.useRefract,0);j(i,["position","normal","uv"]);return i}(a.directional,a.point);this.setSize=function(h,o){m.width=h;m.height=o;c.viewport(0,0,m.width,m.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(h,o){var i,y,l,p,C,B=[],
|
|
|
+P=[],J=[];p=[];C=[];c.uniform1i(h.uniforms.enableLighting,o.length);i=0;for(y=o.length;i<y;i++){l=o[i];if(l instanceof THREE.AmbientLight)B.push(l);else if(l instanceof THREE.DirectionalLight)J.push(l);else l instanceof THREE.PointLight&&P.push(l)}i=l=p=C=0;for(y=B.length;i<y;i++){l+=B[i].color.r;p+=B[i].color.g;C+=B[i].color.b}c.uniform3f(h.uniforms.ambientLightColor,l,p,C);p=[];C=[];i=0;for(y=J.length;i<y;i++){l=J[i];p.push(l.color.r*l.intensity);p.push(l.color.g*l.intensity);p.push(l.color.b*l.intensity);
|
|
|
+C.push(l.position.x);C.push(l.position.y);C.push(l.position.z)}if(J.length){c.uniform1i(h.uniforms.directionalLightNumber,J.length);c.uniform3fv(h.uniforms.directionalLightDirection,C);c.uniform3fv(h.uniforms.directionalLightColor,p)}p=[];C=[];i=0;for(y=P.length;i<y;i++){l=P[i];p.push(l.color.r*l.intensity);p.push(l.color.g*l.intensity);p.push(l.color.b*l.intensity);C.push(l.position.x);C.push(l.position.y);C.push(l.position.z)}if(P.length){c.uniform1i(h.uniforms.pointLightNumber,P.length);c.uniform3fv(h.uniforms.pointLightPosition,
|
|
|
+C);c.uniform3fv(h.uniforms.pointLightColor,p)}};this.createBuffers=function(h,o){var i,y,l,p,C,B,P,J,R=[],T=[],E=[],V=[],K=[],L=0,N=h.geometry.geometryChunks[o],Y;l=false;i=0;for(y=h.material.length;i<y;i++){meshMaterial=h.material[i];if(meshMaterial instanceof THREE.MeshFaceMaterial){C=0;for(Y=N.material.length;C<Y;C++)if(N.material[C]&&N.material[C].shading!=undefined&&N.material[C].shading==THREE.SmoothShading){l=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
|
|
|
+THREE.SmoothShading){l=true;break}if(l)break}Y=l;i=0;for(y=N.faces.length;i<y;i++){l=N.faces[i];p=h.geometry.faces[l];C=p.vertexNormals;faceNormal=p.normal;l=h.geometry.uvs[l];if(p instanceof THREE.Face3){B=h.geometry.vertices[p.a].position;P=h.geometry.vertices[p.b].position;J=h.geometry.vertices[p.c].position;E.push(B.x,B.y,B.z);E.push(P.x,P.y,P.z);E.push(J.x,J.y,J.z);if(C.length==3&&Y)for(p=0;p<3;p++)V.push(C[p].x,C[p].y,C[p].z);else for(p=0;p<3;p++)V.push(faceNormal.x,faceNormal.y,faceNormal.z);
|
|
|
+if(l)for(p=0;p<3;p++)K.push(l[p].u,l[p].v);R.push(L,L+1,L+2);T.push(L,L+1);T.push(L,L+2);T.push(L+1,L+2);L+=3}else if(p instanceof THREE.Face4){B=h.geometry.vertices[p.a].position;P=h.geometry.vertices[p.b].position;J=h.geometry.vertices[p.c].position;p=h.geometry.vertices[p.d].position;E.push(B.x,B.y,B.z);E.push(P.x,P.y,P.z);E.push(J.x,J.y,J.z);E.push(p.x,p.y,p.z);if(C.length==4&&Y)for(p=0;p<4;p++)V.push(C[p].x,C[p].y,C[p].z);else for(p=0;p<4;p++)V.push(faceNormal.x,faceNormal.y,faceNormal.z);if(l)for(p=
|
|
|
+0;p<4;p++)K.push(l[p].u,l[p].v);R.push(L,L+1,L+2);R.push(L,L+2,L+3);T.push(L,L+1);T.push(L,L+2);T.push(L,L+3);T.push(L+1,L+2);T.push(L+2,L+3);L+=4}}if(E.length){N.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,N.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(E),c.STATIC_DRAW);N.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,N.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW);if(K.length>0){N.__webGLUVBuffer=c.createBuffer();
|
|
|
+c.bindBuffer(c.ARRAY_BUFFER,N.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(K),c.STATIC_DRAW)}N.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,N.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(R),c.STATIC_DRAW);N.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,N.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(T),c.STATIC_DRAW);N.__webGLFaceCount=R.length;N.__webGLLineCount=T.length}};this.renderBuffer=
|
|
|
+function(h,o,i,y){var l,p,C,B,P,J,R,T,E;if(i instanceof THREE.MeshShaderMaterial){if(!i.program){i.program=b(i.fragment_shader,i.vertex_shader);R=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(E in i.uniforms)R.push(E);f(i.program,R);j(i.program,["position","normal","uv"])}E=i.program}else E=A;if(E!=t){c.useProgram(E);t=E}E==A&&this.setupLights(E,o);this.loadCamera(E,h);this.loadMatrices(E);if(i instanceof THREE.MeshShaderMaterial){C=i.wireframe;
|
|
|
+B=i.wireframe_linewidth;h=E;o=i.uniforms;var V;for(l in o){T=o[l].type;R=o[l].value;V=h.uniforms[l];if(T=="i")c.uniform1i(V,R);else if(T=="f")c.uniform1f(V,R);else if(T=="t"){c.uniform1i(V,R);if(T=o[l].texture)T.image instanceof Array&&T.image.length==6?d(T,R):e(T,R)}}}if(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshBasicMaterial){l=i.color;p=i.opacity;C=i.wireframe;B=i.wireframe_linewidth;P=i.map;J=i.env_map;o=i.combine==THREE.MixOperation;
|
|
|
+h=i.reflectivity;T=i.env_map&&i.env_map.mapping instanceof THREE.CubeRefractionMapping;R=i.refraction_ratio;c.uniform4f(E.uniforms.mColor,l.r*p,l.g*p,l.b*p,p);c.uniform1i(E.uniforms.mixEnvMap,o);c.uniform1f(E.uniforms.mReflectivity,h);c.uniform1i(E.uniforms.useRefract,T);c.uniform1f(E.uniforms.mRefractionRatio,R)}if(i instanceof THREE.MeshNormalMaterial){p=i.opacity;c.uniform1f(E.uniforms.mOpacity,p);c.uniform1i(E.uniforms.material,4)}else if(i instanceof THREE.MeshDepthMaterial){p=i.opacity;C=i.wireframe;
|
|
|
+B=i.wireframe_linewidth;c.uniform1f(E.uniforms.mOpacity,p);c.uniform1f(E.uniforms.m2Near,i.__2near);c.uniform1f(E.uniforms.mFarPlusNear,i.__farPlusNear);c.uniform1f(E.uniforms.mFarMinusNear,i.__farMinusNear);c.uniform1i(E.uniforms.material,3)}else if(i instanceof THREE.MeshPhongMaterial){l=i.ambient;h=i.specular;i=i.shininess;c.uniform4f(E.uniforms.mAmbient,l.r,l.g,l.b,p);c.uniform4f(E.uniforms.mSpecular,h.r,h.g,h.b,p);c.uniform1f(E.uniforms.mShininess,i);c.uniform1i(E.uniforms.material,2)}else if(i instanceof
|
|
|
+THREE.MeshLambertMaterial)c.uniform1i(E.uniforms.material,1);else if(i instanceof THREE.MeshBasicMaterial)c.uniform1i(E.uniforms.material,0);else if(i instanceof THREE.MeshCubeMaterial){c.uniform1i(E.uniforms.material,5);J=i.env_map}if(P){e(P,0);c.uniform1i(E.uniforms.tMap,0);c.uniform1i(E.uniforms.enableMap,1)}else c.uniform1i(E.uniforms.enableMap,0);if(J){d(J,1);c.uniform1i(E.uniforms.tCube,1);c.uniform1i(E.uniforms.enableCubeMap,1)}else c.uniform1i(E.uniforms.enableCubeMap,0);p=E.attributes;c.bindBuffer(c.ARRAY_BUFFER,
|
|
|
+y.__webGLVertexBuffer);c.vertexAttribPointer(p.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,y.__webGLNormalBuffer);c.vertexAttribPointer(p.normal,3,c.FLOAT,false,0,0);if(p.uv>=0)if(y.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,y.__webGLUVBuffer);c.enableVertexAttribArray(p.uv);c.vertexAttribPointer(p.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(p.uv);if(C){c.lineWidth(B);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y.__webGLLineBuffer);c.drawElements(c.LINES,y.__webGLLineCount,c.UNSIGNED_SHORT,
|
|
|
+0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,y.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(h,o,i,y,l,p){var C,B,P,J,R;P=0;for(J=i.material.length;P<J;P++){C=i.material[P];if(C instanceof THREE.MeshFaceMaterial){C=0;for(B=y.material.length;C<B;C++)if((R=y.material[C])&&R.blending==l&&R.opacity<1==p){this.setBlending(R.blending);this.renderBuffer(h,o,R,y)}}else if((R=C)&&R.blending==l&&R.opacity<1==p){this.setBlending(R.blending);this.renderBuffer(h,
|
|
|
+o,R,y)}}};this.render=function(h,o){var i,y,l,p,C=h.lights;this.initWebGLObjects(h);this.autoClear&&this.clear();o.autoUpdateMatrix&&o.updateMatrix();i=0;for(y=h.__webGLObjects.length;i<y;i++){l=h.__webGLObjects[i];p=l.object;l=l.buffer;if(p.visible){this.setupMatrices(p,o);this.renderPass(o,C,p,l,THREE.NormalBlending,false)}}i=0;for(y=h.__webGLObjects.length;i<y;i++){l=h.__webGLObjects[i];p=l.object;l=l.buffer;if(p.visible){this.setupMatrices(p,o);this.renderPass(o,C,p,l,THREE.AdditiveBlending,false);
|
|
|
+this.renderPass(o,C,p,l,THREE.SubtractiveBlending,false);this.renderPass(o,C,p,l,THREE.AdditiveBlending,true);this.renderPass(o,C,p,l,THREE.SubtractiveBlending,true);this.renderPass(o,C,p,l,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(h){var o,i,y,l,p,C;if(!h.__webGLObjects){h.__webGLObjects=[];h.__webGLObjectsMap={}}o=0;for(i=h.objects.length;o<i;o++){y=h.objects[o];if(h.__webGLObjectsMap[y.id]==undefined)h.__webGLObjectsMap[y.id]={};C=h.__webGLObjectsMap[y.id];if(y instanceof THREE.Mesh)for(p in y.geometry.geometryChunks){l=
|
|
|
+y.geometry.geometryChunks[p];l.__webGLVertexBuffer||this.createBuffers(y,p);if(C[p]==undefined){l={buffer:l,object:y};h.__webGLObjects.push(l);C[p]=1}}}};this.removeObject=function(h,o){var i,y;for(i=h.__webGLObjects.length-1;i>=0;i--){y=h.__webGLObjects[i].object;o==y&&h.__webGLObjects.splice(i,1)}};this.setupMatrices=function(h,o){h.autoUpdateMatrix&&h.updateMatrix();r.multiply(o.matrix,h.matrix);v.set(o.matrix.flatten());w.set(r.flatten());H.set(o.projectionMatrix.flatten());u=THREE.Matrix4.makeInvert3x3(r).transpose();
|
|
|
+I.set(u.m);z.set(h.matrix.flatten())};this.loadMatrices=function(h){c.uniformMatrix4fv(h.uniforms.viewMatrix,false,v);c.uniformMatrix4fv(h.uniforms.modelViewMatrix,false,w);c.uniformMatrix4fv(h.uniforms.projectionMatrix,false,H);c.uniformMatrix3fv(h.uniforms.normalMatrix,false,I);c.uniformMatrix4fv(h.uniforms.objectMatrix,false,z)};this.loadCamera=function(h,o){c.uniform3f(h.uniforms.cameraPosition,o.position.x,o.position.y,o.position.z)};this.setBlending=function(h){switch(h){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);
|
|
|
+c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(h,o){if(h){!o||o=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(h=="back")c.cullFace(c.BACK);else h=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)}};
|
|
|
+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};
|
|
|
+var GeometryUtils={merge:function(a,b){var d=b instanceof THREE.Mesh,e=a.vertices.length,f=d?b.geometry:b,j=a.vertices,k=f.vertices,g=a.faces,m=f.faces,c=a.uvs;f=f.uvs;d&&b.updateMatrix();for(var t=0,A=k.length;t<A;t++){var r=new THREE.Vertex(k[t].position.clone());d&&b.matrix.multiplyVector3(r.position);j.push(r)}t=0;for(A=m.length;t<A;t++){k=m[t];var u,v=k.vertexNormals;if(k instanceof THREE.Face3)u=new THREE.Face3(k.a+e,k.b+e,k.c+e);else if(k instanceof THREE.Face4)u=new THREE.Face4(k.a+e,k.b+
|
|
|
+e,k.c+e,k.d+e);u.centroid.copy(k.centroid);u.normal.copy(k.normal);d=0;for(j=v.length;d<j;d++){r=v[d];u.vertexNormals.push(r.clone())}u.material=k.material.slice();g.push(u)}t=0;for(A=f.length;t<A;t++){e=f[t];g=[];d=0;for(j=e.length;d<j;d++)g.push(new THREE.UV(e[d].u,e[d].v));c.push(g)}}},ImageUtils={loadTexture:function(a,b){var d=new Image;d.onload=function(){this.loaded=true};d.src=a;return new THREE.Texture(d,b)},loadArray:function(a){var b,d,e=[];b=e.loadCount=0;for(d=a.length;b<d;++b){e[b]=
|
|
|
+new Image;e[b].loaded=0;e[b].onload=function(){e.loadCount+=1;this.loaded=true};e[b].src=a[b]}return e}},SceneUtils={addMesh:function(a,b,d,e,f,j,k,g,m,c){b=new THREE.Mesh(b,c);b.scale.x=b.scale.y=b.scale.z=d;b.position.x=e;b.position.y=f;b.position.z=j;b.rotation.x=k;b.rotation.y=g;b.rotation.z=m;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,d){d=new THREE.MeshCubeMaterial({env_map:d});b=new THREE.Mesh(new Cube(b,b,b,1,1,null,true),d);a.addObject(b);return b},addPanoramaCube:function(a,
|
|
|
+b,d){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));mesh=new THREE.Mesh(new Cube(b,b,b,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(mesh);
|
|
|
+return mesh},addPanoramaCubePlanes:function(a,b,d){var e=b/2;b=new Plane(b,b);var f=Math.PI/2,j=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));SceneUtils.addMesh(a,b,1,-e,0,0,0,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,b,1,e,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,b,1,0,e,0,f,0,j,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));SceneUtils.addMesh(a,
|
|
|
+b,1,0,-e,0,-f,0,j,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
|
|
|
+vertex_shader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main(void) {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"}}},
|
|
|
+Cube=function(a,b,d,e,f,j,k,g){function m(w,H,I,z,n,h,o,i){var y=e||1,l=f||1,p=y+1,C=l+1;n=n/y;h=h/l;var B=c.vertices.length,P;if(w=="x"&&H=="y"||w=="y"&&H=="x")P="z";else if(w=="x"&&H=="z"||w=="z"&&H=="x")P="y";else if(w=="z"&&H=="y"||w=="y"&&H=="z")P="x";for(iy=0;iy<C;iy++)for(ix=0;ix<p;ix++){var J=new THREE.Vector3;J[w]=(ix*n-t)*I;J[H]=(iy*h-A)*z;J[P]=o;c.vertices.push(new THREE.Vertex(J))}for(iy=0;iy<l;iy++)for(ix=0;ix<y;ix++){c.faces.push(new THREE.Face4(ix+p*iy+B,ix+p*(iy+1)+B,ix+1+p*(iy+1)+
|
|
|
+B,ix+1+p*iy+B,null,i));c.uvs.push([new THREE.UV(ix/y,iy/l),new THREE.UV(ix/y,(iy+1)/l),new THREE.UV((ix+1)/y,(iy+1)/l),new THREE.UV((ix+1)/y,iy/l)])}}THREE.Geometry.call(this);var c=this,t=a/2,A=b/2,r=d/2;k=k?-1:1;if(j!==undefined)if(j instanceof Array)this.materials=j;else{this.materials=[];for(var u=0;u<6;u++)this.materials.push([j])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(g!=undefined)for(var v in g)if(this.sides[v]!=undefined)this.sides[v]=g[v];this.sides.px&&
|
|
|
+m("z","y",1*k,-1,d,b,-t,this.materials[0]);this.sides.nx&&m("z","y",-1*k,-1,d,b,t,this.materials[1]);this.sides.py&&m("x","z",1*k,1,a,d,A,this.materials[2]);this.sides.ny&&m("x","z",1*k,-1,a,d,-A,this.materials[3]);this.sides.pz&&m("x","y",1*k,-1,a,b,r,this.materials[4]);this.sides.nz&&m("x","y",-1*k,-1,a,b,-r,this.materials[5]);(function(){for(var w=[],H=[],I=0,z=c.vertices.length;I<z;I++){for(var n=c.vertices[I],h=false,o=0,i=w.length;o<i;o++){var y=w[o];if(n.position.x==y.position.x&&n.position.y==
|
|
|
+y.position.y&&n.position.z==y.position.z){H[I]=o;h=true;break}}if(!h){H[I]=w.length;w.push(new THREE.Vertex(n.position.clone()))}}I=0;for(z=c.faces.length;I<z;I++){n=c.faces[I];n.a=H[n.a];n.b=H[n.b];n.c=H[n.c];n.d=H[n.d]}c.vertices=w})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
|
|
|
+var Cylinder=function(a,b,d,e,f){function j(c,t,A){k.vertices.push(new THREE.Vertex(new THREE.Vector3(c,t,A)))}THREE.Geometry.call(this);var k=this,g=Math.PI,m;for(m=0;m<a;m++)j(Math.sin(2*g*m/a)*b,Math.cos(2*g*m/a)*b,0);for(m=0;m<a;m++)j(Math.sin(2*g*m/a)*d,Math.cos(2*g*m/a)*d,e);for(m=0;m<a;m++)k.faces.push(new THREE.Face4(m,m+a,a+(m+1)%a,(m+1)%a));if(d!=0){j(0,0,-f);for(m=a;m<a+a/2;m++)k.faces.push(new THREE.Face4(2*a,(2*m-2*a)%a,(2*m-2*a+1)%a,(2*m-2*a+2)%a))}if(b!=0){j(0,0,e+f);for(m=a+a/2;m<
|
|
|
+2*a;m++)k.faces.push(new THREE.Face4((2*m-2*a+2)%a+a,(2*m-2*a+1)%a+a,(2*m-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
|
|
|
+var Plane=function(a,b,d,e){THREE.Geometry.call(this);var f,j=a/2,k=b/2;d=d||1;e=e||1;var g=d+1,m=e+1;a=a/d;var c=b/e;for(f=0;f<m;f++)for(b=0;b<g;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-j,-(f*c-k),0)));for(f=0;f<e;f++)for(b=0;b<d;b++){this.faces.push(new THREE.Face4(b+g*f,b+g*(f+1),b+1+g*(f+1),b+1+g*f));this.uvs.push([new THREE.UV(b/d,f/e),new THREE.UV(b/d,(f+1)/e),new THREE.UV((b+1)/d,(f+1)/e),new THREE.UV((b+1)/d,f/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
|
|
|
+Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
|
|
|
+var Sphere=function(a,b,d){THREE.Geometry.call(this);var e,f=Math.PI,j=Math.max(3,b||8),k=Math.max(2,d||6);b=[];for(d=0;d<k+1;d++){e=d/k;var g=a*Math.cos(e*f),m=a*Math.sin(e*f),c=[],t=0;for(e=0;e<j;e++){var A=2*e/j,r=m*Math.sin(A*f);A=m*Math.cos(A*f);(d==0||d==k)&&e>0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(A,g,r)))-1);c.push(t)}b.push(c)}var u,v;a=b.length;for(d=0;d<a;d++){f=b[d].length;if(d>0)for(e=0;e<f;e++){m=e==f-1;j=b[d][m?0:e+1];k=b[d][m?f-1:e];g=b[d-1][m?f-1:e];m=b[d-1][m?
|
|
|
+0:e+1];t=d/(a-1);A=(d-1)/(a-1);u=(e+1)/f;r=e/f;c=new THREE.UV(1-u,t);t=new THREE.UV(1-r,t);r=new THREE.UV(1-r,A);var w=new THREE.UV(1-u,A);if(d<b.length-1){A=this.vertices[j].position.clone();u=this.vertices[k].position.clone();v=this.vertices[g].position.clone();A.normalize();u.normalize();v.normalize();this.faces.push(new THREE.Face3(j,k,g,[new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z)]));this.uvs.push([c,t,r])}if(d>1){A=this.vertices[j].position.clone();
|
|
|
+u=this.vertices[g].position.clone();v=this.vertices[m].position.clone();A.normalize();u.normalize();v.normalize();this.faces.push(new THREE.Face3(j,g,m,[new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z)]));this.uvs.push([c,r,w])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
|
|
|
+THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
|
|
|
+THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
|
|
|
+b},loadAsciiOld:function(a,b){var d=document.createElement("script");d.type="text/javascript";d.onload=b;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);a.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,b,d)};a.postMessage(e)},loadBinary:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers,
|
|
|
+j.data.materials,b,d,f)};a.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};a.postMessage(e)},loadAjaxBuffers:function(a,b,d,e,f){var j=new XMLHttpRequest,k=e+"/"+a,g=0;j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.Loader.prototype.createBinModel(j.responseText,d,e,b):alert("Couldn't load ["+k+"] ["+j.status+"]");else if(j.readyState==3){if(f){if(g==0)g=j.getResponseHeader("Content-Length");f({total:g,loaded:j.responseText.length})}}else if(j.readyState==
|
|
|
+2)g=j.getResponseHeader("Content-Length")};j.open("GET",k,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)},createBinModel:function(a,b,d,e){var f=function(j){function k(q,s){var x=t(q,s),G=t(q,s+1),U=t(q,s+2),ba=t(q,s+3),ga=(ba<<1&255|U>>7)-127;x=(U&127)<<16|G<<8|x;if(x==0&&ga==-127)return 0;return(1-2*(ba>>7))*(1+x*Math.pow(2,-23))*Math.pow(2,ga)}function g(q,s){var x=t(q,s),G=t(q,s+1),U=t(q,s+2);return(t(q,s+3)<<24)+(U<<
|
|
|
+16)+(G<<8)+x}function m(q,s){var x=t(q,s);return(t(q,s+1)<<8)+x}function c(q,s){var x=t(q,s);return x>127?x-256:x}function t(q,s){return q.charCodeAt(s)&255}function A(q){var s,x,G;s=g(a,q);x=g(a,q+i);G=g(a,q+y);q=m(a,q+l);THREE.Loader.prototype.f3(I,s,x,G,q)}function r(q){var s,x,G,U,ba,ga;s=g(a,q);x=g(a,q+i);G=g(a,q+y);U=m(a,q+l);ba=g(a,q+p);ga=g(a,q+C);q=g(a,q+B);THREE.Loader.prototype.f3n(I,h,s,x,G,U,ba,ga,q)}function u(q){var s,x,G,U;s=g(a,q);x=g(a,q+P);G=g(a,q+J);U=g(a,q+R);q=m(a,q+T);THREE.Loader.prototype.f4(I,
|
|
|
+s,x,G,U,q)}function v(q){var s,x,G,U,ba,ga,$,ka;s=g(a,q);x=g(a,q+P);G=g(a,q+J);U=g(a,q+R);ba=m(a,q+T);ga=g(a,q+E);$=g(a,q+V);ka=g(a,q+K);q=g(a,q+L);THREE.Loader.prototype.f4n(I,h,s,x,G,U,ba,ga,$,ka,q)}function w(q){var s,x;s=g(a,q);x=g(a,q+N);q=g(a,q+Y);THREE.Loader.prototype.uv3(I,o[s*2],o[s*2+1],o[x*2],o[x*2+1],o[q*2],o[q*2+1])}function H(q){var s,x,G;s=g(a,q);x=g(a,q+Q);G=g(a,q+M);q=g(a,q+W);THREE.Loader.prototype.uv4(I,o[s*2],o[s*2+1],o[x*2],o[x*2+1],o[G*2],o[G*2+1],o[q*2],o[q*2+1])}var I=this,
|
|
|
+z=0,n,h=[],o=[],i,y,l,p,C,B,P,J,R,T,E,V,K,L,N,Y,Q,M,W;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(I,e,j);n={signature:a.substr(z,8),header_bytes:t(a,z+8),vertex_coordinate_bytes:t(a,z+9),normal_coordinate_bytes:t(a,z+10),uv_coordinate_bytes:t(a,z+11),vertex_index_bytes:t(a,z+12),normal_index_bytes:t(a,z+13),uv_index_bytes:t(a,z+14),material_index_bytes:t(a,z+15),nvertices:g(a,z+16),nnormals:g(a,z+16+4),nuvs:g(a,z+16+8),ntri_flat:g(a,z+16+12),ntri_smooth:g(a,z+16+16),ntri_flat_uv:g(a,
|
|
|
+z+16+20),ntri_smooth_uv:g(a,z+16+24),nquad_flat:g(a,z+16+28),nquad_smooth:g(a,z+16+32),nquad_flat_uv:g(a,z+16+36),nquad_smooth_uv:g(a,z+16+40)};z+=n.header_bytes;i=n.vertex_index_bytes;y=n.vertex_index_bytes*2;l=n.vertex_index_bytes*3;p=n.vertex_index_bytes*3+n.material_index_bytes;C=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;B=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;P=n.vertex_index_bytes;J=n.vertex_index_bytes*2;R=n.vertex_index_bytes*3;T=n.vertex_index_bytes*
|
|
|
+4;E=n.vertex_index_bytes*4+n.material_index_bytes;V=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;K=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;L=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;N=n.uv_index_bytes;Y=n.uv_index_bytes*2;Q=n.uv_index_bytes;M=n.uv_index_bytes*2;W=n.uv_index_bytes*3;z+=function(q){var s,x,G,U=n.vertex_coordinate_bytes*3,ba=q+n.nvertices*U;for(q=q;q<ba;q+=U){s=k(a,q);x=k(a,q+n.vertex_coordinate_bytes);G=
|
|
|
+k(a,q+n.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(I,s,x,G)}return n.nvertices*U}(z);z+=function(q){var s,x,G,U=n.normal_coordinate_bytes*3,ba=q+n.nnormals*U;for(q=q;q<ba;q+=U){s=c(a,q);x=c(a,q+n.normal_coordinate_bytes);G=c(a,q+n.normal_coordinate_bytes*2);h.push(s/127,x/127,G/127)}return n.nnormals*U}(z);z+=function(q){var s,x,G=n.uv_coordinate_bytes*2,U=q+n.nuvs*G;for(q=q;q<U;q+=G){s=k(a,q);x=k(a,q+n.uv_coordinate_bytes);o.push(s,x)}return n.nuvs*G}(z);z+=function(q){var s,x=n.vertex_index_bytes*
|
|
|
+3+n.material_index_bytes,G=q+n.ntri_flat*x;for(s=q;s<G;s+=x)A(s);return G-q}(z);z+=function(q){var s,x=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,G=q+n.ntri_smooth*x;for(s=q;s<G;s+=x)r(s);return G-q}(z);z+=function(q){var s,x=n.vertex_index_bytes*3+n.material_index_bytes,G=x+n.uv_index_bytes*3,U=q+n.ntri_flat_uv*G;for(s=q;s<U;s+=G){A(s);w(s+x)}return U-q}(z);z+=function(q){var s,x=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,G=x+n.uv_index_bytes*3,
|
|
|
+U=q+n.ntri_smooth_uv*G;for(s=q;s<U;s+=G){r(s);w(s+x)}return U-q}(z);z+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes,G=q+n.nquad_flat*x;for(s=q;s<G;s+=x)u(s);return G-q}(z);z+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,G=q+n.nquad_smooth*x;for(s=q;s<G;s+=x)v(s);return G-q}(z);z+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes,G=x+n.uv_index_bytes*4,U=q+n.nquad_flat_uv*G;for(s=q;s<U;s+=G){u(s);H(s+x)}return U-q}(z);
|
|
|
+z+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,G=x+n.uv_index_bytes*4,U=q+n.nquad_smooth_uv*G;for(s=q;s<U;s+=G){v(s);H(s+x)}return U-q}(z);this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(d))},createModel:function(a,b,d){var e=function(f){var j=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(j,a.materials,f);(function(){var k,g,m,c,t;k=0;for(g=
|
|
|
+a.vertices.length;k<g;k+=3){m=a.vertices[k];c=a.vertices[k+1];t=a.vertices[k+2];THREE.Loader.prototype.v(j,m,c,t)}})();(function(){function k(v,w){THREE.Loader.prototype.f3(j,v[w],v[w+1],v[w+2],v[w+3])}function g(v,w){THREE.Loader.prototype.f3n(j,a.normals,v[w],v[w+1],v[w+2],v[w+3],v[w+4],v[w+5],v[w+6])}function m(v,w){THREE.Loader.prototype.f4(j,v[w],v[w+1],v[w+2],v[w+3],v[w+4])}function c(v,w){THREE.Loader.prototype.f4n(j,a.normals,v[w],v[w+1],v[w+2],v[w+3],v[w+4],v[w+5],v[w+6],v[w+7],v[w+8])}function t(v,
|
|
|
+w){var H,I,z;H=v[w];I=v[w+1];z=v[w+2];THREE.Loader.prototype.uv3(j,a.uvs[H*2],a.uvs[H*2+1],a.uvs[I*2],a.uvs[I*2+1],a.uvs[z*2],a.uvs[z*2+1])}function A(v,w){var H,I,z,n;H=v[w];I=v[w+1];z=v[w+2];n=v[w+3];THREE.Loader.prototype.uv4(j,a.uvs[H*2],a.uvs[H*2+1],a.uvs[I*2],a.uvs[I*2+1],a.uvs[z*2],a.uvs[z*2+1],a.uvs[n*2],a.uvs[n*2+1])}var r,u;r=0;for(u=a.triangles.length;r<u;r+=4)k(a.triangles,r);r=0;for(u=a.triangles_uv.length;r<u;r+=7){k(a.triangles_uv,r);t(a.triangles_uv,r+4)}r=0;for(u=a.triangles_n.length;r<
|
|
|
+u;r+=7)g(a.triangles_n,r);r=0;for(u=a.triangles_n_uv.length;r<u;r+=10){g(a.triangles_n_uv,r);t(a.triangles_n_uv,r+7)}r=0;for(u=a.quads.length;r<u;r+=5)m(a.quads,r);r=0;for(u=a.quads_uv.length;r<u;r+=9){m(a.quads_uv,r);A(a.quads_uv,r+5)}r=0;for(u=a.quads_n.length;r<u;r+=9)c(a.quads_n,r);r=0;for(u=a.quads_n_uv.length;r<u;r+=13){c(a.quads_n_uv,r);A(a.quads_n_uv,r+9)}})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=
|
|
|
+e;b(new e(d))},v:function(a,b,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,d,e)))},f3:function(a,b,d,e,f){a.faces.push(new THREE.Face3(b,d,e,null,a.materials[f]))},f4:function(a,b,d,e,f,j){a.faces.push(new THREE.Face4(b,d,e,f,null,a.materials[j]))},f3n:function(a,b,d,e,f,j,k,g,m){j=a.materials[j];var c=b[g*3],t=b[g*3+1];g=b[g*3+2];var A=b[m*3],r=b[m*3+1];m=b[m*3+2];a.faces.push(new THREE.Face3(d,e,f,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(c,t,g),new THREE.Vector3(A,
|
|
|
+r,m)],j))},f4n:function(a,b,d,e,f,j,k,g,m,c,t){k=a.materials[k];var A=b[m*3],r=b[m*3+1];m=b[m*3+2];var u=b[c*3],v=b[c*3+1];c=b[c*3+2];var w=b[t*3],H=b[t*3+1];t=b[t*3+2];a.faces.push(new THREE.Face4(d,e,f,j,[new THREE.Vector3(b[g*3],b[g*3+1],b[g*3+2]),new THREE.Vector3(A,r,m),new THREE.Vector3(u,v,c),new THREE.Vector3(w,H,t)],k))},uv3:function(a,b,d,e,f,j,k){var g=[];g.push(new THREE.UV(b,d));g.push(new THREE.UV(e,f));g.push(new THREE.UV(j,k));a.uvs.push(g)},uv4:function(a,b,d,e,f,j,k,g,m){var c=[];
|
|
|
+c.push(new THREE.UV(b,d));c.push(new THREE.UV(e,f));c.push(new THREE.UV(j,k));c.push(new THREE.UV(g,m));a.uvs.push(c)},init_materials:function(a,b,d){a.materials=[];for(var e=0;e<b.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(b[e],d)]},createMaterial:function(a,b){function d(j){j=Math.log(j)/Math.LN2;return Math.floor(j)==j}var e,f;if(a.map_diffuse&&b){f=document.createElement("canvas");e=new THREE.MeshLambertMaterial({map:new THREE.Texture(f)});f=new Image;f.onload=function(){if(!d(this.width)||
|
|
|
+!d(this.height)){var j=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),k=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));e.map.image.width=j;e.map.image.height=k;e.map.image.getContext("2d").drawImage(this,0,0,j,k)}else e.map.image=this;e.map.image.loaded=1};f.src=b+"/"+a.map_diffuse}else if(a.col_diffuse){f=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;e=new THREE.MeshLambertMaterial({color:f,opacity:a.transparency})}else e=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):
|
|
|
+new THREE.MeshLambertMaterial({color:15658734});return e}};
|