diff --git a/build/Three.js b/build/Three.js index b4bea877..8cac5e75 100644 --- a/build/Three.js +++ b/build/Three.js @@ -11,40 +11,40 @@ distanceToSquared:function(a){var c=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return THREE.Vector4.prototype={set:function(a,c,f,b){this.x=a;this.y=c;this.z=f;this.w=b;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.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,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},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,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var c,f,b=a.objects,d=[];a=0;for(c=b.length;a0&&w>0&&u+w<1}var f,b,d,j,n,t,e,g,m,h, -l,r=a.geometry,o=r.vertices,p=[];f=0;for(b=r.faces.length;f= -0&&Math.min(d,e.getBottom())-Math.max(f,e.getTop())>=0};this.empty=function(){t=true;d=b=f=c=0;a()};this.isEmpty=function(){return t};this.toString=function(){return"THREE.Rectangle ( left: "+c+", right: "+b+", top: "+f+", bottom: "+d+", width: "+j+", height: "+n+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; +THREE.Ray.prototype={intersectScene:function(a){var c,f,b=a.objects,d=[];a=0;for(c=b.length;a0&&A>0&&i+A<1}var f,b,d,j,o,r,e,g,m,h, +k,q=a.geometry,p=q.vertices,s=[];f=0;for(b=q.faces.length;f= +0&&Math.min(d,e.getBottom())-Math.max(f,e.getTop())>=0};this.empty=function(){r=true;d=b=f=c=0;a()};this.isEmpty=function(){return r};this.toString=function(){return"THREE.Rectangle ( left: "+c+", right: "+b+", top: "+f+", bottom: "+d+", width: "+j+", height: "+o+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; THREE.Matrix4=function(){this._x=new THREE.Vector3;this._y=new THREE.Vector3;this._z=new THREE.Vector3}; 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,c,f){var b=this._x,d=this._y,j=this._z;j.sub(a,c);j.normalize();b.cross(f,j);b.normalize();d.cross(j,b);d.normalize();this.n11=b.x;this.n12=b.y;this.n13=b.z;this.n14=-b.dot(a);this.n21=d.x;this.n22=d.y;this.n23=d.z;this.n24=-d.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},transform:function(a){var c=a.x,f=a.y,b=a.z,d=a.w?a.w:1;a.x=this.n11*c+this.n12*f+this.n13*b+this.n14* d;a.y=this.n21*c+this.n22*f+this.n23*b+this.n24*d;a.z=this.n31*c+this.n32*f+this.n33*b+this.n34*d;d=this.n41*c+this.n42*f+this.n43*b+this.n44*d;if(a.w)a.w=d;else{a.x/=d;a.y/=d;a.z/=d}return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a, c){this.n11=a.n11*c.n11+a.n12*c.n21+a.n13*c.n31+a.n14*c.n41;this.n12=a.n11*c.n12+a.n12*c.n22+a.n13*c.n32+a.n14*c.n42;this.n13=a.n11*c.n13+a.n12*c.n23+a.n13*c.n33+a.n14*c.n43;this.n14=a.n11*c.n14+a.n12*c.n24+a.n13*c.n34+a.n14*c.n44;this.n21=a.n21*c.n11+a.n22*c.n21+a.n23*c.n31+a.n24*c.n41;this.n22=a.n21*c.n12+a.n22*c.n22+a.n23*c.n32+a.n24*c.n42;this.n23=a.n21*c.n13+a.n22*c.n23+a.n23*c.n33+a.n24*c.n43;this.n24=a.n21*c.n14+a.n22*c.n24+a.n23*c.n34+a.n24*c.n44;this.n31=a.n31*c.n11+a.n32*c.n21+a.n33*c.n31+ -a.n34*c.n41;this.n32=a.n31*c.n12+a.n32*c.n22+a.n33*c.n32+a.n34*c.n42;this.n33=a.n31*c.n13+a.n32*c.n23+a.n33*c.n33+a.n34*c.n43;this.n34=a.n31*c.n14+a.n32*c.n24+a.n33*c.n34+a.n34*c.n44;this.n41=a.n41*c.n11+a.n42*c.n21+a.n43*c.n31+a.n44*c.n41;this.n42=a.n41*c.n12+a.n42*c.n22+a.n43*c.n32+a.n44*c.n42;this.n43=a.n41*c.n13+a.n42*c.n23+a.n43*c.n33+a.n44*c.n43;this.n44=a.n41*c.n14+a.n42*c.n24+a.n43*c.n34+a.n44*c.n44},multiplySelf:function(a){var c=this.n11,f=this.n12,b=this.n13,d=this.n14,j=this.n21,n=this.n22, -t=this.n23,e=this.n24,g=this.n31,m=this.n32,h=this.n33,l=this.n34,r=this.n41,o=this.n42,p=this.n43,w=this.n44;this.n11=c*a.n11+f*a.n21+b*a.n31+d*a.n41;this.n12=c*a.n12+f*a.n22+b*a.n32+d*a.n42;this.n13=c*a.n13+f*a.n23+b*a.n33+d*a.n43;this.n14=c*a.n14+f*a.n24+b*a.n34+d*a.n44;this.n21=j*a.n11+n*a.n21+t*a.n31+e*a.n41;this.n22=j*a.n12+n*a.n22+t*a.n32+e*a.n42;this.n23=j*a.n13+n*a.n23+t*a.n33+e*a.n43;this.n24=j*a.n14+n*a.n24+t*a.n34+e*a.n44;this.n31=g*a.n11+m*a.n21+h*a.n31+l*a.n41;this.n32=g*a.n12+m*a.n22+ -h*a.n32+l*a.n42;this.n33=g*a.n13+m*a.n23+h*a.n33+l*a.n43;this.n34=g*a.n14+m*a.n24+h*a.n34+l*a.n44;this.n41=r*a.n11+o*a.n21+p*a.n31+w*a.n41;this.n42=r*a.n12+o*a.n22+p*a.n32+w*a.n42;this.n43=r*a.n13+o*a.n23+p*a.n33+w*a.n43;this.n44=r*a.n14+o*a.n24+p*a.n34+w*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* +a.n34*c.n41;this.n32=a.n31*c.n12+a.n32*c.n22+a.n33*c.n32+a.n34*c.n42;this.n33=a.n31*c.n13+a.n32*c.n23+a.n33*c.n33+a.n34*c.n43;this.n34=a.n31*c.n14+a.n32*c.n24+a.n33*c.n34+a.n34*c.n44;this.n41=a.n41*c.n11+a.n42*c.n21+a.n43*c.n31+a.n44*c.n41;this.n42=a.n41*c.n12+a.n42*c.n22+a.n43*c.n32+a.n44*c.n42;this.n43=a.n41*c.n13+a.n42*c.n23+a.n43*c.n33+a.n44*c.n43;this.n44=a.n41*c.n14+a.n42*c.n24+a.n43*c.n34+a.n44*c.n44},multiplySelf:function(a){var c=this.n11,f=this.n12,b=this.n13,d=this.n14,j=this.n21,o=this.n22, +r=this.n23,e=this.n24,g=this.n31,m=this.n32,h=this.n33,k=this.n34,q=this.n41,p=this.n42,s=this.n43,A=this.n44;this.n11=c*a.n11+f*a.n21+b*a.n31+d*a.n41;this.n12=c*a.n12+f*a.n22+b*a.n32+d*a.n42;this.n13=c*a.n13+f*a.n23+b*a.n33+d*a.n43;this.n14=c*a.n14+f*a.n24+b*a.n34+d*a.n44;this.n21=j*a.n11+o*a.n21+r*a.n31+e*a.n41;this.n22=j*a.n12+o*a.n22+r*a.n32+e*a.n42;this.n23=j*a.n13+o*a.n23+r*a.n33+e*a.n43;this.n24=j*a.n14+o*a.n24+r*a.n34+e*a.n44;this.n31=g*a.n11+m*a.n21+h*a.n31+k*a.n41;this.n32=g*a.n12+m*a.n22+ +h*a.n32+k*a.n42;this.n33=g*a.n13+m*a.n23+h*a.n33+k*a.n43;this.n34=g*a.n14+m*a.n24+h*a.n34+k*a.n44;this.n41=q*a.n11+p*a.n21+s*a.n31+A*a.n41;this.n42=q*a.n12+p*a.n22+s*a.n32+A*a.n42;this.n43=q*a.n13+p*a.n23+s*a.n33+A*a.n43;this.n44=q*a.n14+p*a.n24+s*a.n34+A*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(c,f,b){var d=c[f];c[f]=c[b];c[b]=d}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,c,f){var b=new THREE.Matrix4;b.n14=a;b.n24=c;b.n34=f;return b};THREE.Matrix4.scaleMatrix=function(a,c,f){var b=new THREE.Matrix4;b.n11=a;b.n22=c;b.n33=f;return b}; THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.n22=c.n33=Math.cos(a);c.n32=Math.sin(a);c.n23=-c.n32;return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.n11=c.n33=Math.cos(a);c.n13=Math.sin(a);c.n31=-c.n13;return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.n11=c.n22=Math.cos(a);c.n21=Math.sin(a);c.n12=-c.n21;return c}; -THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var f=new THREE.Matrix4,b=Math.cos(c),d=Math.sin(c),j=1-b,n=a.x,t=a.y,e=a.z;f.n11=j*n*n+b;f.n12=j*n*t-d*e;f.n13=j*n*e+d*t;f.n21=j*n*t+d*e;f.n22=j*t*t+b;f.n23=j*t*e-d*n;f.n31=j*n*e-d*t;f.n32=j*t*e+d*n;f.n33=j*e*e+b;return f}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var f=new THREE.Matrix4,b=Math.cos(c),d=Math.sin(c),j=1-b,o=a.x,r=a.y,e=a.z;f.n11=j*o*o+b;f.n12=j*o*r-d*e;f.n13=j*o*e+d*r;f.n21=j*o*r+d*e;f.n22=j*r*r+b;f.n23=j*r*e-d*o;f.n31=j*o*e-d*r;f.n32=j*r*e+d*o;f.n33=j*e*e+b;return f}; THREE.Matrix4.makeInvert=function(a){var c=new THREE.Matrix4;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.multiplyScalar(1/a.determinant());return c}; -THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=new THREE.Matrix3;var f=c[10]*c[5]-c[6]*c[9],b=-c[10]*c[1]+c[2]*c[9],d=c[6]*c[1]-c[2]*c[5],j=-c[10]*c[4]+c[6]*c[8],n=c[10]*c[0]-c[2]*c[8],t=-c[6]*c[0]+c[2]*c[4],e=c[9]*c[4]-c[5]*c[8],g=-c[9]*c[0]+c[1]*c[8],m=c[5]*c[0]-c[1]*c[4];c=c[0]*f+c[1]*j+c[2]*e;if(c==0)throw"matrix not invertible";c=1/c;a.m[0]=c*f;a.m[1]=c*b;a.m[2]=c*d;a.m[3]=c*j;a.m[4]=c*n;a.m[5]=c*t;a.m[6]=c*e;a.m[7]=c*g;a.m[8]=c*m;return a}; -THREE.Matrix4.makeFrustum=function(a,c,f,b,d,j){var n,t,e;n=new THREE.Matrix4;t=2*d/(c-a);e=2*d/(b-f);a=(c+a)/(c-a);f=(b+f)/(b-f);b=-(j+d)/(j-d);d=-2*j*d/(j-d);n.n11=t;n.n12=0;n.n13=a;n.n14=0;n.n21=0;n.n22=e;n.n23=f;n.n24=0;n.n31=0;n.n32=0;n.n33=b;n.n34=d;n.n41=0;n.n42=0;n.n43=-1;n.n44=0;return n};THREE.Matrix4.makePerspective=function(a,c,f,b){var d;a=f*Math.tan(a*Math.PI/360);d=-a;return THREE.Matrix4.makeFrustum(d*c,a*c,d,a,f,b)}; -THREE.Matrix4.makeOrtho=function(a,c,f,b,d,j){var n,t,e,g;n=new THREE.Matrix4;t=c-a;e=f-b;g=j-d;a=(c+a)/t;f=(f+b)/e;d=(j+d)/g;n.n11=2/t;n.n12=0;n.n13=0;n.n14=-a;n.n21=0;n.n22=2/e;n.n23=0;n.n24=-f;n.n31=0;n.n32=0;n.n33=-2/g;n.n34=-d;n.n41=0;n.n42=0;n.n43=0;n.n44=1;return n}; +THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=new THREE.Matrix3;var f=c[10]*c[5]-c[6]*c[9],b=-c[10]*c[1]+c[2]*c[9],d=c[6]*c[1]-c[2]*c[5],j=-c[10]*c[4]+c[6]*c[8],o=c[10]*c[0]-c[2]*c[8],r=-c[6]*c[0]+c[2]*c[4],e=c[9]*c[4]-c[5]*c[8],g=-c[9]*c[0]+c[1]*c[8],m=c[5]*c[0]-c[1]*c[4];c=c[0]*f+c[1]*j+c[2]*e;if(c==0)throw"matrix not invertible";c=1/c;a.m[0]=c*f;a.m[1]=c*b;a.m[2]=c*d;a.m[3]=c*j;a.m[4]=c*o;a.m[5]=c*r;a.m[6]=c*e;a.m[7]=c*g;a.m[8]=c*m;return a}; +THREE.Matrix4.makeFrustum=function(a,c,f,b,d,j){var o,r,e;o=new THREE.Matrix4;r=2*d/(c-a);e=2*d/(b-f);a=(c+a)/(c-a);f=(b+f)/(b-f);b=-(j+d)/(j-d);d=-2*j*d/(j-d);o.n11=r;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=e;o.n23=f;o.n24=0;o.n31=0;o.n32=0;o.n33=b;o.n34=d;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,c,f,b){var d;a=f*Math.tan(a*Math.PI/360);d=-a;return THREE.Matrix4.makeFrustum(d*c,a*c,d,a,f,b)}; +THREE.Matrix4.makeOrtho=function(a,c,f,b,d,j){var o,r,e,g;o=new THREE.Matrix4;r=c-a;e=f-b;g=j-d;a=(c+a)/r;f=(f+b)/e;d=(j+d)/g;o.n11=2/r;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/e;o.n23=0;o.n24=-f;o.n31=0;o.n32=0;o.n33=-2/g;o.n34=-d;o.n41=0;o.n42=0;o.n43=0;o.n44=1;return o}; THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||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,c,f,b,d){this.a=a;this.b=c;this.c=f;this.centroid=new THREE.Vector3;this.normal=b instanceof THREE.Vector3?b:new THREE.Vector3;this.vertexNormals=b instanceof Array?b:[];this.material=d instanceof Array?d:[d]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; THREE.Face4=function(a,c,f,b,d,j){this.a=a;this.b=c;this.c=f;this.d=b;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.material=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||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=[]}; THREE.Geometry.prototype={computeCentroids:function(){var a,c,f;a=0;for(c=this.faces.length;a0){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,c=this.vertices.length;a +f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeNormals:function(a){var c,f,b,d,j,o,r=new THREE.Vector3,e=new THREE.Vector3;b=0;for(d=this.vertices.length;b0){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,c=this.vertices.length;a this.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.ythis.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+" )"}}; THREE.Camera=function(a,c,f,b){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,c,f,b);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(-16777216|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,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight; @@ -53,8 +53,8 @@ THREE.Object3D=function(){this.position=new THREE.Vector3;this.rotation=new THRE this.matrixRotation.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.matrixRotation.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.matrixScale=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.matrixRotation);this.matrix.multiplySelf(this.matrixScale)}};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,c){THREE.Object3D.call(this);this.geometry=a;this.material=c instanceof Array?c:[c]};THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; THREE.Mesh=function(a,c,f){THREE.Object3D.call(this);this.geometry=a;this.material=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.materialFaceGroup={};this.sortFacesByMaterial();f&&this.normalizeUVs();this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh; -THREE.Mesh.prototype.sortFacesByMaterial=function(){function a(m){var h=[];c=0;for(f=m.length;c65535){g[t].counter+=1;e=g[t].hash+"_"+g[t].counter;if(this.materialFaceGroup[e]==undefined)this.materialFaceGroup[e]={faces:[],material:n,vertices:0}}this.materialFaceGroup[e].faces.push(b);this.materialFaceGroup[e].vertices+=j}};THREE.Mesh.prototype.normalizeUVs=function(){var a,c,f,b,d;a=0;for(c=this.geometry.uvs.length;a65535){g[r].counter+=1;e=g[r].hash+"_"+g[r].counter;if(this.materialFaceGroup[e]==undefined)this.materialFaceGroup[e]={faces:[],material:o,vertices:0}}this.materialFaceGroup[e].faces.push(b);this.materialFaceGroup[e].vertices+=j}};THREE.Mesh.prototype.normalizeUVs=function(){var a,c,f,b,d;a=0;for(c=this.geometry.uvs.length;acolor: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+ this.linewidth+"
)"}}; @@ -75,50 +75,50 @@ this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c){this.image=a;this.mapping=c?c:THREE.UVMapping;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
mapping: "+this.mapping+"
)"}};THREE.UVMapping=0;THREE.ReflectionMap=1;THREE.RefractionMap=2; THREE.TextureCube=function(a,c){this.image=a;this.mapping=c?c:THREE.ReflectionMap;this.toString=function(){return"THREE.TextureCube (
image: "+this.image+"
mapping: "+this.mapping+"
)"}}; 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(i,B){var q;q=0;var D=1,u=i.z+i.w,L=B.z+B.w,v=-i.z+i.w,s=-B.z+B.w;if(u>=0&&L>=0&&v>=0&&s>=0)q=true;else if(u<0&&L<0||v<0&&s<0)q=false;else{if(u<0)q=Math.max(q,u/(u-L));else if(L<0)D=Math.min(D,u/(u-L));if(v<0)q=Math.max(q,v/(v-s));else if(s<0)D=Math.min(D,v/(v-s));if(D0&&F.z<1}X=s.geometry.faces;u=0;for(L=X.length;u< -L;u++){F=X[u];if(F instanceof THREE.Face3){Q=M[F.a];y=M[F.b];N=M[F.c];if(Q.__visible&&y.__visible&&N.__visible)if(s.doubleSided||s.flipSided!=(N.positionScreen.x-Q.positionScreen.x)*(y.positionScreen.y-Q.positionScreen.y)-(N.positionScreen.y-Q.positionScreen.y)*(y.positionScreen.x-Q.positionScreen.x)<0){f=d[b]=d[b]||new THREE.RenderableFace3;f.v1.positionScreen.copy(Q.positionScreen);f.v2.positionScreen.copy(y.positionScreen);f.v3.positionScreen.copy(N.positionScreen);f.normalWorld.copy(F.normal); -s.matrixRotation.transform(f.normalWorld);f.centroidWorld.copy(F.centroid);x.transform(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);p.transform(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterial=s.material;f.faceMaterial=F.material;f.overdraw=s.overdraw;f.uvs=s.geometry.uvs[u];f.color=F.color;c.push(f);b++}}else if(F instanceof THREE.Face4){Q=M[F.a];y=M[F.b];N=M[F.c];K=M[F.d];if(Q.__visible&&y.__visible&&N.__visible&&K.__visible)if(s.doubleSided||s.flipSided!=((K.positionScreen.x- -Q.positionScreen.x)*(y.positionScreen.y-Q.positionScreen.y)-(K.positionScreen.y-Q.positionScreen.y)*(y.positionScreen.x-Q.positionScreen.x)<0||(y.positionScreen.x-N.positionScreen.x)*(K.positionScreen.y-N.positionScreen.y)-(y.positionScreen.y-N.positionScreen.y)*(K.positionScreen.x-N.positionScreen.x)<0)){j=t[n]=t[n]||new THREE.RenderableFace4;j.v1.positionScreen.copy(Q.positionScreen);j.v2.positionScreen.copy(y.positionScreen);j.v3.positionScreen.copy(N.positionScreen);j.v4.positionScreen.copy(K.positionScreen); -j.normalWorld.copy(F.normal);s.matrixRotation.transform(j.normalWorld);j.centroidWorld.copy(F.centroid);x.transform(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);p.transform(j.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterial=s.material;j.faceMaterial=F.material;j.overdraw=s.overdraw;j.uvs=s.geometry.uvs[u];j.color=F.color;c.push(j);n++}}}}else if(s instanceof THREE.Line){w.multiply(p,x);M=s.geometry.vertices;u=0;for(L=M.length;u0&&o.z<1){h=r[l]=r[l]||new THREE.RenderableParticle;h.x=o.x/o.w;h.y=o.y/o.w;h.z= -o.z;h.rotation=s.rotation.z;h.scale.x=s.scale.x*Math.abs(h.x-(o.x+B.projectionMatrix.n11)/(o.w+B.projectionMatrix.n14));h.scale.y=s.scale.y*Math.abs(h.y-(o.y+B.projectionMatrix.n22)/(o.w+B.projectionMatrix.n24));h.material=s.material;c.push(h);l++}}}c.sort(function(V,C){return C.z-V.z});return c};this.unprojectVector=function(i,B){var q=new THREE.Matrix4;q.multiply(THREE.Matrix4.makeInvert(B.matrix),THREE.Matrix4.makeInvert(B.projectionMatrix));q.transform(i);return i}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,f,b,d,j;this.domElement=document.createElement("div");this.setSize=function(n,t){f=n;b=t;d=f/2;j=b/2};this.render=function(n,t){var e,g,m,h,l,r,o,p;a=c.projectScene(n,t);e=0;for(g=a.length;e0){I.r+=H.r*k;I.g+=H.g*k;I.b+=H.b*k}}else if(k instanceof THREE.PointLight){Ha.sub(k.position,O.centroidWorld);Ha.normalize();k=O.normalWorld.dot(Ha)*k.intensity;if(k>0){I.r+=H.r*k;I.g+=H.g*k;I.b+=H.b*k}}}}function c(G,O,I,J,k,H){Y=G.positionScreen.x;Z=G.positionScreen.y;Q=O.positionScreen.x; -y=O.positionScreen.y;N=I.positionScreen.x;K=I.positionScreen.y;if(k.opacity!=B)i.globalAlpha=B=k.opacity;k.blending!=q&&n(k.blending);if(k.map){fa=k.map.image;oa=fa.width-1;pa=fa.height-1;da.u=J.uvs[0].u*oa;da.v=J.uvs[0].v*pa;$.u=J.uvs[1].u*oa;$.v=J.uvs[1].v*pa;ea.u=J.uvs[2].u*oa;ea.v=J.uvs[2].v*pa;j(fa,Y,Z,Q,y,N,K,da.u,da.v,$.u,$.v,ea.u,ea.v)}else if(k instanceof THREE.MeshBasicMaterial)b(Y,Z,Q,y,N,K,k.color,k.wireframe,k.wireframe_linewidth);else if(k instanceof THREE.MeshLambertMaterial){if(Da){ba.r= -ga.r;ba.g=ga.g;ba.b=ga.b;a(H,J,ba);R.r=k.color.r*ba.r;R.g=k.color.g*ba.g;R.b=k.color.b*ba.b;R.updateStyleString()}else R.__styleString=k.color.__styleString;b(Y,Z,Q,y,N,K,R,k.wireframe,k.wireframe_linewidth)}else if(k instanceof THREE.MeshDepthMaterial){qa=k.__2near;ra=k.__farPlusNear;sa=k.__farMinusNear;U=~~((1-qa/(ra-G.positionScreen.z*sa))*255);ha=~~((1-qa/(ra-O.positionScreen.z*sa))*255);ma=~~((1-qa/(ra-I.positionScreen.z*sa))*255);fa=t([U,U,U],[ha,ha,ha],[ma,ma,ma],[ma,ma,ma]);da.u=0;da.v=0; -$.u=ka;$.v=0;ea.u=0;ea.v=ka;j(fa,Y,Z,Q,y,N,K,da.u,da.v,$.u,$.v,ea.u,ea.v)}else if(k instanceof THREE.MeshNormalMaterial){R.r=e(J.normalWorld.x);R.g=e(J.normalWorld.y);R.b=e(J.normalWorld.z);R.updateStyleString();b(Y,Z,Q,y,N,K,R,k.wireframe,k.wireframe_linewidth)}}function f(G,O,I,J,k,H,S,z,T){Y=G.positionScreen.x;Z=G.positionScreen.y;Q=O.positionScreen.x;y=O.positionScreen.y;N=I.positionScreen.x;K=I.positionScreen.y;V=J.positionScreen.x;C=J.positionScreen.y;A=k.positionScreen.x;W=k.positionScreen.y; -na=H.positionScreen.x;P=H.positionScreen.y;if(z.opacity!=B)i.globalAlpha=B=z.opacity;z.blending!=q&&n(z.blending);if(z.map){fa=z.map.image;oa=fa.width-1;pa=fa.height-1;da.copy(S.uvs[0]);$.copy(S.uvs[1]);ea.copy(S.uvs[2]);ia.copy(S.uvs[3]);da.u*=oa;da.v*=pa;$.u*=oa;$.v*=pa;ea.u*=oa;ea.v*=pa;ia.u*=oa;ia.v*=pa;j(fa,Y,Z,Q,y,V,C,da.u,da.v,$.u,$.v,ia.u,ia.v);j(fa,A,W,N,K,na,P,$.u,$.v,ea.u,ea.v,ia.u,ia.v)}else if(z instanceof THREE.MeshBasicMaterial)d(Y,Z,Q,y,N,K,V,C,z.color,z.wireframe,z.wireframe_linewidth); -else if(z instanceof THREE.MeshLambertMaterial){if(Da){ba.r=ga.r;ba.g=ga.g;ba.b=ga.b;a(T,S,ba);R.r=z.color.r*ba.r;R.g=z.color.g*ba.g;R.b=z.color.b*ba.b;R.updateStyleString()}else R.__styleString=z.color.__styleString;d(Y,Z,Q,y,N,K,V,C,R,z.wireframe,z.wireframe_linewidth)}else if(z instanceof THREE.MeshDepthMaterial){qa=z.__2near;ra=z.__farPlusNear;sa=z.__farMinusNear;U=~~((1-qa/(ra-G.positionScreen.z*sa))*255);ha=~~((1-qa/(ra-O.positionScreen.z*sa))*255);ma=~~((1-qa/(ra-I.positionScreen.z*sa))*255); -Ea=~~((1-qa/(ra-J.positionScreen.z*sa))*255);fa=t([U,U,U],[ha,ha,ha],[Ea,Ea,Ea],[ma,ma,ma]);da.u=0;da.v=0;$.u=ka;$.v=0;ea.u=ka;ea.v=ka;ia.u=0;ia.v=ka;j(fa,Y,Z,Q,y,V,C,da.u,da.v,$.u,$.v,ia.u,ia.v);j(fa,A,W,N,K,na,P,$.u,$.v,ea.u,ea.v,ia.u,ia.v)}else if(z instanceof THREE.MeshNormalMaterial){R.r=e(S.normalWorld.x);R.g=e(S.normalWorld.y);R.b=e(S.normalWorld.z);R.updateStyleString();d(Y,Z,Q,y,N,K,V,C,R,z.wireframe,z.wireframe_linewidth)}}function b(G,O,I,J,k,H,S,z,T){i.beginPath();i.moveTo(G,O);i.lineTo(I, -J);i.lineTo(k,H);i.lineTo(G,O);i.closePath();if(z){if(L!=T)i.lineWidth=L=T;if(D!=S.__styleString)i.strokeStyle=D=S.__styleString;i.stroke();aa.inflate(T*2)}else{if(u!=S.__styleString)i.fillStyle=u=S.__styleString;i.fill()}}function d(G,O,I,J,k,H,S,z,T,E,ca){i.beginPath();i.moveTo(G,O);i.lineTo(I,J);i.lineTo(k,H);i.lineTo(S,z);i.lineTo(G,O);i.closePath();if(E){if(L!=ca)i.lineWidth=L=ca;if(D!=T.__styleString)i.strokeStyle=D=T.__styleString;i.stroke();aa.inflate(ca*2)}else{if(u!=T.__styleString)i.fillStyle= -u=T.__styleString;i.fill()}}function j(G,O,I,J,k,H,S,z,T,E,ca,la,ta){i.beginPath();i.moveTo(O,I);i.lineTo(J,k);i.lineTo(H,S);i.closePath();J-=O;k-=I;H-=O;S-=I;E-=z;ca-=T;la-=z;ta-=T;var ua=1/(E*ta-la*ca),za=(ta*J-ca*H)*ua;ca=(ta*k-ca*S)*ua;J=(E*H-la*J)*ua;k=(E*S-la*k)*ua;O=O-za*z-J*T;I=I-ca*z-k*T;i.save();i.transform(za,ca,J,k,O,I);i.clip();i.drawImage(G,0,0);i.restore()}function n(G){switch(G){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation= -"lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}q=G}function t(G,O,I,J){ja[0]=G[0];ja[1]=G[1];ja[2]=G[2];ja[4]=O[0];ja[5]=O[1];ja[6]=O[2];ja[8]=I[0];ja[9]=I[1];ja[10]=I[2];ja[12]=J[0];ja[13]=J[1];ja[14]=J[2];Aa.putImageData(Ia,0,0);Fa.drawImage(Ba,0,0);return Ca}function e(G){return G<0?Math.min((1+G)*0.5,0.5):0.5+Math.min(G*0.5,0.5)}function g(G,O){var I=O.x-G.x,J=O.y-G.y,k=1/Math.sqrt(I*I+J*J);I*=k;J*=k;O.x+=I;O.y+=J;G.x-=I;G.y-=J}var m=null,h=new THREE.Projector, -l=document.createElement("canvas"),r,o,p,w,i=l.getContext("2d"),B=1,q=0,D=null,u=null,L=1,v,s,x,M,X=new THREE.Vertex,F=new THREE.Vertex,Y,Z,Q,y,N,K,V,C,A,W,na,P,U,ha,ma,Ea,qa,ra,sa,fa,oa,pa,wa=new THREE.Rectangle,va=new THREE.Rectangle,aa=new THREE.Rectangle,Da=false,R=new THREE.Color(4294967295),ba=new THREE.Color(4294967295),ga=new THREE.Color(4278190080),xa=new THREE.Color(4278190080),ya=new THREE.Color(4278190080),Ma=Math.PI*2,Ha=new THREE.Vector3,da=new THREE.UV,$=new THREE.UV,ea=new THREE.UV, -ia=new THREE.UV,Ba,Aa,Ia,ja,Ca,Fa,ka=16;Ba=document.createElement("canvas");Ba.width=Ba.height=2;Aa=Ba.getContext("2d");Aa.fillStyle="rgba(0,0,0,1)";Aa.fillRect(0,0,2,2);Ia=Aa.getImageData(0,0,2,2);ja=Ia.data;Ca=document.createElement("canvas");Ca.width=Ca.height=ka;Fa=Ca.getContext("2d");Fa.translate(-ka/2,-ka/2);Fa.scale(ka,ka);ka--;this.domElement=l;this.autoClear=true;this.setSize=function(G,O){r=G;o=O;p=r/2;w=o/2;l.width=r;l.height=o;i.lineJoin="round";i.lineCap="round";wa.set(-p,-w,p,w)};this.clear= -function(){if(!va.isEmpty()){va.inflate(1);va.minSelf(wa);i.setTransform(1,0,0,-1,p,w);i.clearRect(va.getX(),va.getY(),va.getWidth(),va.getHeight());va.empty()}};this.render=function(G,O){var I,J,k,H,S,z,T,E;this.autoClear&&this.clear();m=h.projectScene(G,O);i.setTransform(1,0,0,-1,p,w);if(Da=G.lights.length>0){S=G.lights;ga.setRGB(0,0,0);xa.setRGB(0,0,0);ya.setRGB(0,0,0);I=0;for(J=S.length;I0){K.r+=A.color.r*W;K.g+=A.color.g*W;K.b+=A.color.b*W}}else if(A instanceof THREE.PointLight){x.sub(A.position,N.centroidWorld);x.normalize();W=N.normalWorld.dot(x)*A.intensity;if(W>0){K.r+=A.color.r*W;K.g+=A.color.g*W;K.b+=A.color.b*W}}}}function c(y,N,K,V,C,A){F=b(Y++);F.setAttribute("d","M "+y.positionScreen.x+ -" "+y.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)q.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(B){D.r=u.r;D.g=u.g;D.b=u.b;a(A,V,D);q.r=C.color.r*D.r;q.g=C.color.g*D.g;q.b=C.color.b*D.b;q.updateStyleString()}else q.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){s=1-C.__2near/(C.__farPlusNear-V.z*C.__farMinusNear); -q.setRGB(s,s,s)}else C instanceof THREE.MeshNormalMaterial&&q.setRGB(d(V.normalWorld.x),d(V.normalWorld.y),d(V.normalWorld.z));C.wireframe?F.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: round; stroke-linejoin: round"):F.setAttribute("style","fill: "+q.__styleString+"; fill-opacity: "+C.opacity);t.appendChild(F)}function f(y,N,K,V,C,A,W){F=b(Y++);F.setAttribute("d","M "+y.positionScreen.x+" "+ -y.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(A instanceof THREE.MeshBasicMaterial)q.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshLambertMaterial)if(B){D.r=u.r;D.g=u.g;D.b=u.b;a(W,C,D);q.r=A.color.r*D.r;q.g=A.color.g*D.g;q.b=A.color.b*D.b;q.updateStyleString()}else q.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshDepthMaterial){s=1- -A.__2near/(A.__farPlusNear-C.z*A.__farMinusNear);q.setRGB(s,s,s)}else A instanceof THREE.MeshNormalMaterial&&q.setRGB(d(C.normalWorld.x),d(C.normalWorld.y),d(C.normalWorld.z));A.wireframe?F.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+A.wireframe_linewidth+"; stroke-opacity: "+A.opacity+"; stroke-linecap: round; stroke-linejoin: round"):F.setAttribute("style","fill: "+q.__styleString+"; fill-opacity: "+A.opacity);t.appendChild(F)}function b(y){if(M[y]==null){M[y]= -document.createElementNS("http://www.w3.org/2000/svg","path");Q==0&&M[y].setAttribute("shape-rendering","crispEdges");return M[y]}return M[y]}function d(y){return y<0?Math.min((1+y)*0.5,0.5):0.5+Math.min(y*0.5,0.5)}var j=null,n=new THREE.Projector,t=document.createElementNS("http://www.w3.org/2000/svg","svg"),e,g,m,h,l,r,o,p,w=new THREE.Rectangle,i=new THREE.Rectangle,B=false,q=new THREE.Color(4294967295),D=new THREE.Color(4294967295),u=new THREE.Color(4278190080),L=new THREE.Color(4278190080),v= -new THREE.Color(4278190080),s,x=new THREE.Vector3,M=[],X=[],F,Y,Z,Q=1;this.domElement=t;this.autoClear=true;this.setQuality=function(y){switch(y){case "high":Q=1;break;case "low":Q=0}};this.setSize=function(y,N){e=y;g=N;m=e/2;h=g/2;t.setAttribute("viewBox",-m+" "+-h+" "+e+" "+g);t.setAttribute("width",e);t.setAttribute("height",g);w.set(-m,-h,m,h)};this.clear=function(){for(;t.childNodes.length>0;)t.removeChild(t.childNodes[0])};this.render=function(y,N){var K,V,C,A,W,na,P,U;this.autoClear&&this.clear(); -j=n.projectScene(y,N);Z=Y=0;if(B=y.lights.length>0){P=y.lights;u.setRGB(0,0,0);L.setRGB(0,0,0);v.setRGB(0,0,0);K=0;for(V=P.length;K=0&&P>=0&&M>=0&&x>=0)n=true;else if(i<0&&P<0||M<0&&x<0)n=false;else{if(i<0)n=Math.max(n,i/(i-P));else if(P<0)v=Math.min(v,i/(i-P));if(M<0)n=Math.max(n,M/(M-x));else if(x<0)v=Math.min(v,M/(M-x));if(v0&&t.z<1}D=x.geometry.faces;i=0;for(P=D.length;i< +P;i++){t=D[i];if(t instanceof THREE.Face3){X=S[t.a];B=S[t.b];L=S[t.c];if(X.__visible&&B.__visible&&L.__visible)if(x.doubleSided||x.flipSided!=(L.positionScreen.x-X.positionScreen.x)*(B.positionScreen.y-X.positionScreen.y)-(L.positionScreen.y-X.positionScreen.y)*(B.positionScreen.x-X.positionScreen.x)<0){f=d[b]=d[b]||new THREE.RenderableFace3;f.v1.positionScreen.copy(X.positionScreen);f.v2.positionScreen.copy(B.positionScreen);f.v3.positionScreen.copy(L.positionScreen);f.normalWorld.copy(t.normal); +x.matrixRotation.transform(f.normalWorld);f.centroidWorld.copy(t.centroid);J.transform(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);s.transform(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterial=x.material;f.faceMaterial=t.material;f.overdraw=x.overdraw;f.uvs=x.geometry.uvs[i];f.color=t.color;c.push(f);b++}}else if(t instanceof THREE.Face4){X=S[t.a];B=S[t.b];L=S[t.c];K=S[t.d];if(X.__visible&&B.__visible&&L.__visible&&K.__visible)if(x.doubleSided||x.flipSided!=((K.positionScreen.x- +X.positionScreen.x)*(B.positionScreen.y-X.positionScreen.y)-(K.positionScreen.y-X.positionScreen.y)*(B.positionScreen.x-X.positionScreen.x)<0||(B.positionScreen.x-L.positionScreen.x)*(K.positionScreen.y-L.positionScreen.y)-(B.positionScreen.y-L.positionScreen.y)*(K.positionScreen.x-L.positionScreen.x)<0)){j=r[o]=r[o]||new THREE.RenderableFace4;j.v1.positionScreen.copy(X.positionScreen);j.v2.positionScreen.copy(B.positionScreen);j.v3.positionScreen.copy(L.positionScreen);j.v4.positionScreen.copy(K.positionScreen); +j.normalWorld.copy(t.normal);x.matrixRotation.transform(j.normalWorld);j.centroidWorld.copy(t.centroid);J.transform(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);s.transform(j.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterial=x.material;j.faceMaterial=t.material;j.overdraw=x.overdraw;j.uvs=x.geometry.uvs[i];j.color=t.color;c.push(j);o++}}}}else if(x instanceof THREE.Line){A.multiply(s,J);S=x.geometry.vertices;i=0;for(P=S.length;i0&&p.z<1){h=q[k]=q[k]||new THREE.RenderableParticle;h.x=p.x/p.w;h.y=p.y/p.w; +h.z=p.z;h.rotation=x.rotation.z;h.scale.x=x.scale.x*Math.abs(h.x-(p.x+E.projectionMatrix.n11)/(p.w+E.projectionMatrix.n14));h.scale.y=x.scale.y*Math.abs(h.y-(p.y+E.projectionMatrix.n22)/(p.w+E.projectionMatrix.n24));h.material=x.material;c.push(h);k++}}}c.sort(function(R,y){return y.z-R.z});return c};this.unprojectVector=function(C,E){var n=new THREE.Matrix4;n.multiply(THREE.Matrix4.makeInvert(E.matrix),THREE.Matrix4.makeInvert(E.projectionMatrix));n.transform(C);return C}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,f,b,d,j;this.domElement=document.createElement("div");this.setSize=function(o,r){f=o;b=r;d=f/2;j=b/2};this.render=function(o,r){var e,g,m,h,k,q,p,s;a=c.projectScene(o,r);e=0;for(g=a.length;e0){G.r+=F.r*l;G.g+=F.g*l;G.b+=F.b*l}}else if(l instanceof THREE.PointLight){Ja.sub(l.position,N.centroidWorld);Ja.normalize();l=N.normalWorld.dot(Ja)*l.intensity;if(l>0){G.r+=F.r*l;G.g+=F.g*l;G.b+=F.b*l}}}}function c(w,N,G,H,l,F){L=w.positionScreen.x;K=w.positionScreen.y;R=N.positionScreen.x; +y=N.positionScreen.y;u=G.positionScreen.x;Q=G.positionScreen.y;o(l.opacity);r(l.blending);if(l.map){fa=l.map.image;na=fa.width-1;oa=fa.height-1;da.u=H.uvs[0].u*na;da.v=H.uvs[0].v*oa;Z.u=H.uvs[1].u*na;Z.v=H.uvs[1].v*oa;ea.u=H.uvs[2].u*na;ea.v=H.uvs[2].v*oa;j(fa,L,K,R,y,u,Q,da.u,da.v,Z.u,Z.v,ea.u,ea.v)}else if(l instanceof THREE.MeshBasicMaterial)b(L,K,R,y,u,Q,l.color,l.wireframe,l.wireframe_linewidth);else if(l instanceof THREE.MeshLambertMaterial){if(Fa){ba.r=ga.r;ba.g=ga.g;ba.b=ga.b;a(F,H,ba);T.r= +l.color.r*ba.r;T.g=l.color.g*ba.g;T.b=l.color.b*ba.b;T.updateStyleString()}else T.__styleString=l.color.__styleString;b(L,K,R,y,u,Q,T,l.wireframe,l.wireframe_linewidth)}else if(l instanceof THREE.MeshDepthMaterial){pa=l.__2near;qa=l.__farPlusNear;ra=l.__farMinusNear;va=~~((1-pa/(qa-w.positionScreen.z*ra))*255);wa=~~((1-pa/(qa-N.positionScreen.z*ra))*255);ma=~~((1-pa/(qa-G.positionScreen.z*ra))*255);fa=h([va,va,va],[wa,wa,wa],[ma,ma,ma],[ma,ma,ma]);da.u=0;da.v=0;Z.u=ka;Z.v=0;ea.u=0;ea.v=ka;j(fa,L, +K,R,y,u,Q,da.u,da.v,Z.u,Z.v,ea.u,ea.v)}else if(l instanceof THREE.MeshNormalMaterial){T.r=k(H.normalWorld.x);T.g=k(H.normalWorld.y);T.b=k(H.normalWorld.z);T.updateStyleString();b(L,K,R,y,u,Q,T,l.wireframe,l.wireframe_linewidth)}}function f(w,N,G,H,l,F,U,z,W){L=w.positionScreen.x;K=w.positionScreen.y;R=N.positionScreen.x;y=N.positionScreen.y;u=G.positionScreen.x;Q=G.positionScreen.y;ha=H.positionScreen.x;O=H.positionScreen.y;Y=l.positionScreen.x;xa=l.positionScreen.y;Ka=F.positionScreen.x;La=F.positionScreen.y; +o(z.opacity);r(z.blending);if(z.map){fa=z.map.image;na=fa.width-1;oa=fa.height-1;da.copy(U.uvs[0]);Z.copy(U.uvs[1]);ea.copy(U.uvs[2]);ia.copy(U.uvs[3]);da.u*=na;da.v*=oa;Z.u*=na;Z.v*=oa;ea.u*=na;ea.v*=oa;ia.u*=na;ia.v*=oa;j(fa,L,K,R,y,ha,O,da.u,da.v,Z.u,Z.v,ia.u,ia.v);j(fa,Y,xa,u,Q,Ka,La,Z.u,Z.v,ea.u,ea.v,ia.u,ia.v)}else if(z instanceof THREE.MeshBasicMaterial)d(L,K,R,y,u,Q,ha,O,z.color,z.wireframe,z.wireframe_linewidth);else if(z instanceof THREE.MeshLambertMaterial){if(Fa){ba.r=ga.r;ba.g=ga.g;ba.b= +ga.b;a(W,U,ba);T.r=z.color.r*ba.r;T.g=z.color.g*ba.g;T.b=z.color.b*ba.b;T.updateStyleString()}else T.__styleString=z.color.__styleString;d(L,K,R,y,u,Q,ha,O,T,z.wireframe,z.wireframe_linewidth)}else if(z instanceof THREE.MeshDepthMaterial){pa=z.__2near;qa=z.__farPlusNear;ra=z.__farMinusNear;va=~~((1-pa/(qa-w.positionScreen.z*ra))*255);wa=~~((1-pa/(qa-N.positionScreen.z*ra))*255);ma=~~((1-pa/(qa-G.positionScreen.z*ra))*255);Ga=~~((1-pa/(qa-H.positionScreen.z*ra))*255);fa=h([va,va,va],[wa,wa,wa],[Ga, +Ga,Ga],[ma,ma,ma]);da.u=0;da.v=0;Z.u=ka;Z.v=0;ea.u=ka;ea.v=ka;ia.u=0;ia.v=ka;j(fa,L,K,R,y,ha,O,da.u,da.v,Z.u,Z.v,ia.u,ia.v);j(fa,Y,xa,u,Q,Ka,La,Z.u,Z.v,ea.u,ea.v,ia.u,ia.v)}else if(z instanceof THREE.MeshNormalMaterial){T.r=k(U.normalWorld.x);T.g=k(U.normalWorld.y);T.b=k(U.normalWorld.z);T.updateStyleString();d(L,K,R,y,u,Q,ha,O,T,z.wireframe,z.wireframe_linewidth)}}function b(w,N,G,H,l,F,U,z,W){i.beginPath();i.moveTo(w,N);i.lineTo(G,H);i.lineTo(l,F);i.lineTo(w,N);i.closePath();if(z){e(W);g(U.__styleString); +i.stroke();$.inflate(W*2)}else{m(U.__styleString);i.fill()}}function d(w,N,G,H,l,F,U,z,W,I,ca){i.beginPath();i.moveTo(w,N);i.lineTo(G,H);i.lineTo(l,F);i.lineTo(U,z);i.lineTo(w,N);i.closePath();if(I){e(ca);g(W.__styleString);i.stroke();$.inflate(ca*2)}else{m(W.__styleString);i.fill()}}function j(w,N,G,H,l,F,U,z,W,I,ca,la,sa){i.beginPath();i.moveTo(N,G);i.lineTo(H,l);i.lineTo(F,U);i.closePath();H-=N;l-=G;F-=N;U-=G;I-=z;ca-=W;la-=z;sa-=W;var ta=1/(I*sa-la*ca),Ba=(sa*H-ca*F)*ta;ca=(sa*l-ca*U)*ta;H=(I* +F-la*H)*ta;l=(I*U-la*l)*ta;N=N-Ba*z-H*W;G=G-ca*z-l*W;i.save();i.transform(Ba,ca,H,l,N,G);i.clip();i.drawImage(w,0,0);i.restore()}function o(w){if(P!=w)i.globalAlpha=P=w}function r(w){if(M!=w){switch(w){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}M=w}}function e(w){if(S!=w)i.lineWidth=S=w}function g(w){if(x!=w)i.strokeStyle=x=w}function m(w){if(J!= +w)i.fillStyle=J=w}function h(w,N,G,H){ja[0]=w[0];ja[1]=w[1];ja[2]=w[2];ja[4]=N[0];ja[5]=N[1];ja[6]=N[2];ja[8]=G[0];ja[9]=G[1];ja[10]=G[2];ja[12]=H[0];ja[13]=H[1];ja[14]=H[2];Ca.putImageData(Ma,0,0);Ha.drawImage(Da,0,0);return Ea}function k(w){return w<0?Math.min((1+w)*0.5,0.5):0.5+Math.min(w*0.5,0.5)}function q(w,N){var G=N.x-w.x,H=N.y-w.y,l=1/Math.sqrt(G*G+H*H);G*=l;H*=l;N.x+=G;N.y+=H;w.x-=G;w.y-=H}var p=null,s=new THREE.Projector,A=document.createElement("canvas"),C,E,n,v,i=A.getContext("2d"),P= +1,M=0,x=null,J=null,S=1,D,t,V,aa,X=new THREE.Vertex,B=new THREE.Vertex,L,K,R,y,u,Q,ha,O,Y,xa,Ka,La,va,wa,ma,Ga,pa,qa,ra,fa,na,oa,ya=new THREE.Rectangle,ua=new THREE.Rectangle,$=new THREE.Rectangle,Fa=false,T=new THREE.Color(4294967295),ba=new THREE.Color(4294967295),ga=new THREE.Color(4278190080),za=new THREE.Color(4278190080),Aa=new THREE.Color(4278190080),Qa=Math.PI*2,Ja=new THREE.Vector3,da=new THREE.UV,Z=new THREE.UV,ea=new THREE.UV,ia=new THREE.UV,Da,Ca,Ma,ja,Ea,Ha,ka=16;Da=document.createElement("canvas"); +Da.width=Da.height=2;Ca=Da.getContext("2d");Ca.fillStyle="rgba(0,0,0,1)";Ca.fillRect(0,0,2,2);Ma=Ca.getImageData(0,0,2,2);ja=Ma.data;Ea=document.createElement("canvas");Ea.width=Ea.height=ka;Ha=Ea.getContext("2d");Ha.translate(-ka/2,-ka/2);Ha.scale(ka,ka);ka--;this.domElement=A;this.autoClear=true;this.setSize=function(w,N){C=w;E=N;n=C/2;v=E/2;A.width=C;A.height=E;i.lineJoin="round";i.lineCap="round";ya.set(-n,-v,n,v)};this.clear=function(){if(!ua.isEmpty()){ua.inflate(1);ua.minSelf(ya);i.setTransform(1, +0,0,-1,n,v);i.clearRect(ua.getX(),ua.getY(),ua.getWidth(),ua.getHeight());ua.empty()}};this.render=function(w,N){var G,H,l,F,U,z,W,I;this.autoClear&&this.clear();p=s.projectScene(w,N);i.setTransform(1,0,0,-1,n,v);if(Fa=w.lights.length>0){U=w.lights;ga.setRGB(0,0,0);za.setRGB(0,0,0);Aa.setRGB(0,0,0);G=0;for(H=U.length;G0){K.r+=u.color.r*Q;K.g+=u.color.g*Q;K.b+=u.color.b*Q}}else if(u instanceof THREE.PointLight){J.sub(u.position,L.centroidWorld);J.normalize();Q=L.normalWorld.dot(J)*u.intensity;if(Q>0){K.r+=u.color.r*Q;K.g+=u.color.g*Q;K.b+=u.color.b*Q}}}}function c(B,L,K,R,y,u){t=b(V++);t.setAttribute("d","M "+B.positionScreen.x+ +" "+B.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(y instanceof THREE.MeshBasicMaterial)n.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshLambertMaterial)if(E){v.r=i.r;v.g=i.g;v.b=i.b;a(u,R,v);n.r=y.color.r*v.r;n.g=y.color.g*v.g;n.b=y.color.b*v.b;n.updateStyleString()}else n.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshDepthMaterial){x=1-y.__2near/(y.__farPlusNear-R.z*y.__farMinusNear); +n.setRGB(x,x,x)}else y instanceof THREE.MeshNormalMaterial&&n.setRGB(d(R.normalWorld.x),d(R.normalWorld.y),d(R.normalWorld.z));y.wireframe?t.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+y.wireframe_linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: round; stroke-linejoin: round"):t.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+y.opacity);r.appendChild(t)}function f(B,L,K,R,y,u,Q){t=b(V++);t.setAttribute("d","M "+B.positionScreen.x+" "+ +B.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+" L "+R.positionScreen.x+","+R.positionScreen.y+"z");if(u instanceof THREE.MeshBasicMaterial)n.__styleString=u.color.__styleString;else if(u instanceof THREE.MeshLambertMaterial)if(E){v.r=i.r;v.g=i.g;v.b=i.b;a(Q,y,v);n.r=u.color.r*v.r;n.g=u.color.g*v.g;n.b=u.color.b*v.b;n.updateStyleString()}else n.__styleString=u.color.__styleString;else if(u instanceof THREE.MeshDepthMaterial){x=1- +u.__2near/(u.__farPlusNear-y.z*u.__farMinusNear);n.setRGB(x,x,x)}else u instanceof THREE.MeshNormalMaterial&&n.setRGB(d(y.normalWorld.x),d(y.normalWorld.y),d(y.normalWorld.z));u.wireframe?t.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+u.wireframe_linewidth+"; stroke-opacity: "+u.opacity+"; stroke-linecap: round; stroke-linejoin: round"):t.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+u.opacity);r.appendChild(t)}function b(B){if(S[B]==null){S[B]= +document.createElementNS("http://www.w3.org/2000/svg","path");X==0&&S[B].setAttribute("shape-rendering","crispEdges");return S[B]}return S[B]}function d(B){return B<0?Math.min((1+B)*0.5,0.5):0.5+Math.min(B*0.5,0.5)}var j=null,o=new THREE.Projector,r=document.createElementNS("http://www.w3.org/2000/svg","svg"),e,g,m,h,k,q,p,s,A=new THREE.Rectangle,C=new THREE.Rectangle,E=false,n=new THREE.Color(4294967295),v=new THREE.Color(4294967295),i=new THREE.Color(4278190080),P=new THREE.Color(4278190080),M= +new THREE.Color(4278190080),x,J=new THREE.Vector3,S=[],D=[],t,V,aa,X=1;this.domElement=r;this.autoClear=true;this.setQuality=function(B){switch(B){case "high":X=1;break;case "low":X=0}};this.setSize=function(B,L){e=B;g=L;m=e/2;h=g/2;r.setAttribute("viewBox",-m+" "+-h+" "+e+" "+g);r.setAttribute("width",e);r.setAttribute("height",g);A.set(-m,-h,m,h)};this.clear=function(){for(;r.childNodes.length>0;)r.removeChild(r.childNodes[0])};this.render=function(B,L){var K,R,y,u,Q,ha,O,Y;this.autoClear&&this.clear(); +j=o.projectScene(B,L);aa=V=0;if(E=B.lights.length>0){O=B.lights;i.setRGB(0,0,0);P.setRGB(0,0,0);M.setRGB(0,0,0);K=0;for(R=O.length;K= 0.0 )": @@ -133,25 +133,25 @@ e?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",e?"vec4 lDirection = b.getUniformLocation(d,"directionalLightColor");d.directionalLightDirection=b.getUniformLocation(d,"directionalLightDirection")}if(g){d.pointLightNumber=b.getUniformLocation(d,"pointLightNumber");d.pointLightColor=b.getUniformLocation(d,"pointLightColor");d.pointLightPosition=b.getUniformLocation(d,"pointLightPosition")}d.material=b.getUniformLocation(d,"material");d.mColor=b.getUniformLocation(d,"mColor");d.mOpacity=b.getUniformLocation(d,"mOpacity");d.mReflectivity=b.getUniformLocation(d,"mReflectivity"); d.mAmbient=b.getUniformLocation(d,"mAmbient");d.mSpecular=b.getUniformLocation(d,"mSpecular");d.mShininess=b.getUniformLocation(d,"mShininess");d.enableMap=b.getUniformLocation(d,"enableMap");b.uniform1i(d.enableMap,0);d.tMap=b.getUniformLocation(d,"tMap");b.uniform1i(d.tMap,0);d.enableCubeMap=b.getUniformLocation(d,"enableCubeMap");b.uniform1i(d.enableCubeMap,0);d.tCube=b.getUniformLocation(d,"tCube");b.uniform1i(d.tCube,1);d.m2Near=b.getUniformLocation(d,"m2Near");d.mFarPlusNear=b.getUniformLocation(d, "mFarPlusNear");d.mFarMinusNear=b.getUniformLocation(d,"mFarMinusNear");d.position=b.getAttribLocation(d,"position");b.enableVertexAttribArray(d.position);d.normal=b.getAttribLocation(d,"normal");b.enableVertexAttribArray(d.normal);d.uv=b.getAttribLocation(d,"uv");b.enableVertexAttribArray(d.uv);d.viewMatrixArray=new Float32Array(16);d.modelViewMatrixArray=new Float32Array(16);d.projectionMatrixArray=new Float32Array(16)})(a.directional,a.point);this.setSize=function(e,g){f.width=e;f.height=g;b.viewport(0, -0,f.width,f.height)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(e){var g,m,h,l,r=[],o=[],p=[];l=[];var w=[];b.uniform1i(d.enableLighting,e.lights.length);g=0;for(m=e.lights.length;g0&&x>0&&u+x<1}var f,b,d,j,n,t,e,g,m,i, -l,r=a.geometry,o=r.vertices,p=[];f=0;for(b=r.faces.length;f= -0&&Math.min(d,e.getBottom())-Math.max(f,e.getTop())>=0};this.empty=function(){t=true;d=b=f=c=0;a()};this.isEmpty=function(){return t};this.toString=function(){return"THREE.Rectangle ( left: "+c+", right: "+b+", top: "+f+", bottom: "+d+", width: "+j+", height: "+n+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; +THREE.Ray.prototype={intersectScene:function(a){var c,f,b=a.objects,d=[];a=0;for(c=b.length;a0&&A>0&&h+A<1}var f,b,d,j,o,r,e,g,m,i, +k,q=a.geometry,p=q.vertices,s=[];f=0;for(b=q.faces.length;f= +0&&Math.min(d,e.getBottom())-Math.max(f,e.getTop())>=0};this.empty=function(){r=true;d=b=f=c=0;a()};this.isEmpty=function(){return r};this.toString=function(){return"THREE.Rectangle ( left: "+c+", right: "+b+", top: "+f+", bottom: "+d+", width: "+j+", height: "+o+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; THREE.Matrix4=function(){this._x=new THREE.Vector3;this._y=new THREE.Vector3;this._z=new THREE.Vector3}; 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,c,f){var b=this._x,d=this._y,j=this._z;j.sub(a,c);j.normalize();b.cross(f,j);b.normalize();d.cross(j,b);d.normalize();this.n11=b.x;this.n12=b.y;this.n13=b.z;this.n14=-b.dot(a);this.n21=d.x;this.n22=d.y;this.n23=d.z;this.n24=-d.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},transform:function(a){var c=a.x,f=a.y,b=a.z,d=a.w?a.w:1;a.x=this.n11*c+this.n12*f+this.n13*b+this.n14* d;a.y=this.n21*c+this.n22*f+this.n23*b+this.n24*d;a.z=this.n31*c+this.n32*f+this.n33*b+this.n34*d;d=this.n41*c+this.n42*f+this.n43*b+this.n44*d;if(a.w)a.w=d;else{a.x/=d;a.y/=d;a.z/=d}return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a, c){this.n11=a.n11*c.n11+a.n12*c.n21+a.n13*c.n31+a.n14*c.n41;this.n12=a.n11*c.n12+a.n12*c.n22+a.n13*c.n32+a.n14*c.n42;this.n13=a.n11*c.n13+a.n12*c.n23+a.n13*c.n33+a.n14*c.n43;this.n14=a.n11*c.n14+a.n12*c.n24+a.n13*c.n34+a.n14*c.n44;this.n21=a.n21*c.n11+a.n22*c.n21+a.n23*c.n31+a.n24*c.n41;this.n22=a.n21*c.n12+a.n22*c.n22+a.n23*c.n32+a.n24*c.n42;this.n23=a.n21*c.n13+a.n22*c.n23+a.n23*c.n33+a.n24*c.n43;this.n24=a.n21*c.n14+a.n22*c.n24+a.n23*c.n34+a.n24*c.n44;this.n31=a.n31*c.n11+a.n32*c.n21+a.n33*c.n31+ -a.n34*c.n41;this.n32=a.n31*c.n12+a.n32*c.n22+a.n33*c.n32+a.n34*c.n42;this.n33=a.n31*c.n13+a.n32*c.n23+a.n33*c.n33+a.n34*c.n43;this.n34=a.n31*c.n14+a.n32*c.n24+a.n33*c.n34+a.n34*c.n44;this.n41=a.n41*c.n11+a.n42*c.n21+a.n43*c.n31+a.n44*c.n41;this.n42=a.n41*c.n12+a.n42*c.n22+a.n43*c.n32+a.n44*c.n42;this.n43=a.n41*c.n13+a.n42*c.n23+a.n43*c.n33+a.n44*c.n43;this.n44=a.n41*c.n14+a.n42*c.n24+a.n43*c.n34+a.n44*c.n44},multiplySelf:function(a){var c=this.n11,f=this.n12,b=this.n13,d=this.n14,j=this.n21,n=this.n22, -t=this.n23,e=this.n24,g=this.n31,m=this.n32,i=this.n33,l=this.n34,r=this.n41,o=this.n42,p=this.n43,x=this.n44;this.n11=c*a.n11+f*a.n21+b*a.n31+d*a.n41;this.n12=c*a.n12+f*a.n22+b*a.n32+d*a.n42;this.n13=c*a.n13+f*a.n23+b*a.n33+d*a.n43;this.n14=c*a.n14+f*a.n24+b*a.n34+d*a.n44;this.n21=j*a.n11+n*a.n21+t*a.n31+e*a.n41;this.n22=j*a.n12+n*a.n22+t*a.n32+e*a.n42;this.n23=j*a.n13+n*a.n23+t*a.n33+e*a.n43;this.n24=j*a.n14+n*a.n24+t*a.n34+e*a.n44;this.n31=g*a.n11+m*a.n21+i*a.n31+l*a.n41;this.n32=g*a.n12+m*a.n22+ -i*a.n32+l*a.n42;this.n33=g*a.n13+m*a.n23+i*a.n33+l*a.n43;this.n34=g*a.n14+m*a.n24+i*a.n34+l*a.n44;this.n41=r*a.n11+o*a.n21+p*a.n31+x*a.n41;this.n42=r*a.n12+o*a.n22+p*a.n32+x*a.n42;this.n43=r*a.n13+o*a.n23+p*a.n33+x*a.n43;this.n44=r*a.n14+o*a.n24+p*a.n34+x*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* +a.n34*c.n41;this.n32=a.n31*c.n12+a.n32*c.n22+a.n33*c.n32+a.n34*c.n42;this.n33=a.n31*c.n13+a.n32*c.n23+a.n33*c.n33+a.n34*c.n43;this.n34=a.n31*c.n14+a.n32*c.n24+a.n33*c.n34+a.n34*c.n44;this.n41=a.n41*c.n11+a.n42*c.n21+a.n43*c.n31+a.n44*c.n41;this.n42=a.n41*c.n12+a.n42*c.n22+a.n43*c.n32+a.n44*c.n42;this.n43=a.n41*c.n13+a.n42*c.n23+a.n43*c.n33+a.n44*c.n43;this.n44=a.n41*c.n14+a.n42*c.n24+a.n43*c.n34+a.n44*c.n44},multiplySelf:function(a){var c=this.n11,f=this.n12,b=this.n13,d=this.n14,j=this.n21,o=this.n22, +r=this.n23,e=this.n24,g=this.n31,m=this.n32,i=this.n33,k=this.n34,q=this.n41,p=this.n42,s=this.n43,A=this.n44;this.n11=c*a.n11+f*a.n21+b*a.n31+d*a.n41;this.n12=c*a.n12+f*a.n22+b*a.n32+d*a.n42;this.n13=c*a.n13+f*a.n23+b*a.n33+d*a.n43;this.n14=c*a.n14+f*a.n24+b*a.n34+d*a.n44;this.n21=j*a.n11+o*a.n21+r*a.n31+e*a.n41;this.n22=j*a.n12+o*a.n22+r*a.n32+e*a.n42;this.n23=j*a.n13+o*a.n23+r*a.n33+e*a.n43;this.n24=j*a.n14+o*a.n24+r*a.n34+e*a.n44;this.n31=g*a.n11+m*a.n21+i*a.n31+k*a.n41;this.n32=g*a.n12+m*a.n22+ +i*a.n32+k*a.n42;this.n33=g*a.n13+m*a.n23+i*a.n33+k*a.n43;this.n34=g*a.n14+m*a.n24+i*a.n34+k*a.n44;this.n41=q*a.n11+p*a.n21+s*a.n31+A*a.n41;this.n42=q*a.n12+p*a.n22+s*a.n32+A*a.n42;this.n43=q*a.n13+p*a.n23+s*a.n33+A*a.n43;this.n44=q*a.n14+p*a.n24+s*a.n34+A*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(c,f,b){var d=c[f];c[f]=c[b];c[b]=d}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,c,f){var b=new THREE.Matrix4;b.n14=a;b.n24=c;b.n34=f;return b};THREE.Matrix4.scaleMatrix=function(a,c,f){var b=new THREE.Matrix4;b.n11=a;b.n22=c;b.n33=f;return b}; THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.n22=c.n33=Math.cos(a);c.n32=Math.sin(a);c.n23=-c.n32;return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.n11=c.n33=Math.cos(a);c.n13=Math.sin(a);c.n31=-c.n13;return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.n11=c.n22=Math.cos(a);c.n21=Math.sin(a);c.n12=-c.n21;return c}; -THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var f=new THREE.Matrix4,b=Math.cos(c),d=Math.sin(c),j=1-b,n=a.x,t=a.y,e=a.z;f.n11=j*n*n+b;f.n12=j*n*t-d*e;f.n13=j*n*e+d*t;f.n21=j*n*t+d*e;f.n22=j*t*t+b;f.n23=j*t*e-d*n;f.n31=j*n*e-d*t;f.n32=j*t*e+d*n;f.n33=j*e*e+b;return f}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var f=new THREE.Matrix4,b=Math.cos(c),d=Math.sin(c),j=1-b,o=a.x,r=a.y,e=a.z;f.n11=j*o*o+b;f.n12=j*o*r-d*e;f.n13=j*o*e+d*r;f.n21=j*o*r+d*e;f.n22=j*r*r+b;f.n23=j*r*e-d*o;f.n31=j*o*e-d*r;f.n32=j*r*e+d*o;f.n33=j*e*e+b;return f}; THREE.Matrix4.makeInvert=function(a){var c=new THREE.Matrix4;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.multiplyScalar(1/a.determinant());return c}; -THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=new THREE.Matrix3;var f=c[10]*c[5]-c[6]*c[9],b=-c[10]*c[1]+c[2]*c[9],d=c[6]*c[1]-c[2]*c[5],j=-c[10]*c[4]+c[6]*c[8],n=c[10]*c[0]-c[2]*c[8],t=-c[6]*c[0]+c[2]*c[4],e=c[9]*c[4]-c[5]*c[8],g=-c[9]*c[0]+c[1]*c[8],m=c[5]*c[0]-c[1]*c[4];c=c[0]*f+c[1]*j+c[2]*e;if(c==0)throw"matrix not invertible";c=1/c;a.m[0]=c*f;a.m[1]=c*b;a.m[2]=c*d;a.m[3]=c*j;a.m[4]=c*n;a.m[5]=c*t;a.m[6]=c*e;a.m[7]=c*g;a.m[8]=c*m;return a}; -THREE.Matrix4.makeFrustum=function(a,c,f,b,d,j){var n,t,e;n=new THREE.Matrix4;t=2*d/(c-a);e=2*d/(b-f);a=(c+a)/(c-a);f=(b+f)/(b-f);b=-(j+d)/(j-d);d=-2*j*d/(j-d);n.n11=t;n.n12=0;n.n13=a;n.n14=0;n.n21=0;n.n22=e;n.n23=f;n.n24=0;n.n31=0;n.n32=0;n.n33=b;n.n34=d;n.n41=0;n.n42=0;n.n43=-1;n.n44=0;return n};THREE.Matrix4.makePerspective=function(a,c,f,b){var d;a=f*Math.tan(a*Math.PI/360);d=-a;return THREE.Matrix4.makeFrustum(d*c,a*c,d,a,f,b)}; -THREE.Matrix4.makeOrtho=function(a,c,f,b,d,j){var n,t,e,g;n=new THREE.Matrix4;t=c-a;e=f-b;g=j-d;a=(c+a)/t;f=(f+b)/e;d=(j+d)/g;n.n11=2/t;n.n12=0;n.n13=0;n.n14=-a;n.n21=0;n.n22=2/e;n.n23=0;n.n24=-f;n.n31=0;n.n32=0;n.n33=-2/g;n.n34=-d;n.n41=0;n.n42=0;n.n43=0;n.n44=1;return n}; +THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=new THREE.Matrix3;var f=c[10]*c[5]-c[6]*c[9],b=-c[10]*c[1]+c[2]*c[9],d=c[6]*c[1]-c[2]*c[5],j=-c[10]*c[4]+c[6]*c[8],o=c[10]*c[0]-c[2]*c[8],r=-c[6]*c[0]+c[2]*c[4],e=c[9]*c[4]-c[5]*c[8],g=-c[9]*c[0]+c[1]*c[8],m=c[5]*c[0]-c[1]*c[4];c=c[0]*f+c[1]*j+c[2]*e;if(c==0)throw"matrix not invertible";c=1/c;a.m[0]=c*f;a.m[1]=c*b;a.m[2]=c*d;a.m[3]=c*j;a.m[4]=c*o;a.m[5]=c*r;a.m[6]=c*e;a.m[7]=c*g;a.m[8]=c*m;return a}; +THREE.Matrix4.makeFrustum=function(a,c,f,b,d,j){var o,r,e;o=new THREE.Matrix4;r=2*d/(c-a);e=2*d/(b-f);a=(c+a)/(c-a);f=(b+f)/(b-f);b=-(j+d)/(j-d);d=-2*j*d/(j-d);o.n11=r;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=e;o.n23=f;o.n24=0;o.n31=0;o.n32=0;o.n33=b;o.n34=d;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,c,f,b){var d;a=f*Math.tan(a*Math.PI/360);d=-a;return THREE.Matrix4.makeFrustum(d*c,a*c,d,a,f,b)}; +THREE.Matrix4.makeOrtho=function(a,c,f,b,d,j){var o,r,e,g;o=new THREE.Matrix4;r=c-a;e=f-b;g=j-d;a=(c+a)/r;f=(f+b)/e;d=(j+d)/g;o.n11=2/r;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/e;o.n23=0;o.n24=-f;o.n31=0;o.n32=0;o.n33=-2/g;o.n34=-d;o.n41=0;o.n42=0;o.n43=0;o.n44=1;return o}; THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||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,c,f,b,d){this.a=a;this.b=c;this.c=f;this.centroid=new THREE.Vector3;this.normal=b instanceof THREE.Vector3?b:new THREE.Vector3;this.vertexNormals=b instanceof Array?b:[];this.material=d instanceof Array?d:[d]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; THREE.Face4=function(a,c,f,b,d,j){this.a=a;this.b=c;this.c=f;this.d=b;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.material=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||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=[]}; THREE.Geometry.prototype={computeCentroids:function(){var a,c,f;a=0;for(c=this.faces.length;a0){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,c=this.vertices.length;a +f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeNormals:function(a){var c,f,b,d,j,o,r=new THREE.Vector3,e=new THREE.Vector3;b=0;for(d=this.vertices.length;b0){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,c=this.vertices.length;a this.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.ythis.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+" )"}}; THREE.Camera=function(a,c,f,b){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,c,f,b);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(-16777216|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,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight; @@ -53,8 +53,8 @@ THREE.Object3D=function(){this.position=new THREE.Vector3;this.rotation=new THRE this.matrixRotation.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.matrixRotation.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.matrixScale=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.matrixRotation);this.matrix.multiplySelf(this.matrixScale)}};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,c){THREE.Object3D.call(this);this.geometry=a;this.material=c instanceof Array?c:[c]};THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; THREE.Mesh=function(a,c,f){THREE.Object3D.call(this);this.geometry=a;this.material=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.materialFaceGroup={};this.sortFacesByMaterial();f&&this.normalizeUVs();this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh; -THREE.Mesh.prototype.sortFacesByMaterial=function(){function a(m){var i=[];c=0;for(f=m.length;c65535){g[t].counter+=1;e=g[t].hash+"_"+g[t].counter;if(this.materialFaceGroup[e]==undefined)this.materialFaceGroup[e]={faces:[],material:n,vertices:0}}this.materialFaceGroup[e].faces.push(b);this.materialFaceGroup[e].vertices+=j}};THREE.Mesh.prototype.normalizeUVs=function(){var a,c,f,b,d;a=0;for(c=this.geometry.uvs.length;a65535){g[r].counter+=1;e=g[r].hash+"_"+g[r].counter;if(this.materialFaceGroup[e]==undefined)this.materialFaceGroup[e]={faces:[],material:o,vertices:0}}this.materialFaceGroup[e].faces.push(b);this.materialFaceGroup[e].vertices+=j}};THREE.Mesh.prototype.normalizeUVs=function(){var a,c,f,b,d;a=0;for(c=this.geometry.uvs.length;acolor: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+ this.linewidth+"
)"}}; @@ -75,51 +75,50 @@ this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c){this.image=a;this.mapping=c?c:THREE.UVMapping;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
mapping: "+this.mapping+"
)"}};THREE.UVMapping=0;THREE.ReflectionMap=1;THREE.RefractionMap=2; THREE.TextureCube=function(a,c){this.image=a;this.mapping=c?c:THREE.ReflectionMap;this.toString=function(){return"THREE.TextureCube (
image: "+this.image+"
mapping: "+this.mapping+"
)"}}; 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(h,B){var q;q=0;var D=1,u=h.z+h.w,L=B.z+B.w,v=-h.z+h.w,s=-B.z+B.w;if(u>=0&&L>=0&&v>=0&&s>=0)q=true;else if(u<0&&L<0||v<0&&s<0)q=false;else{if(u<0)q=Math.max(q,u/(u-L));else if(L<0)D=Math.min(D,u/(u-L));if(v<0)q=Math.max(q,v/(v-s));else if(s<0)D=Math.min(D,v/(v-s));if(D0&&F.z<1}X=s.geometry.faces;u=0;for(L=X.length;u< -L;u++){F=X[u];if(F instanceof THREE.Face3){Q=M[F.a];z=M[F.b];N=M[F.c];if(Q.__visible&&z.__visible&&N.__visible)if(s.doubleSided||s.flipSided!=(N.positionScreen.x-Q.positionScreen.x)*(z.positionScreen.y-Q.positionScreen.y)-(N.positionScreen.y-Q.positionScreen.y)*(z.positionScreen.x-Q.positionScreen.x)<0){f=d[b]=d[b]||new THREE.RenderableFace3;f.v1.positionScreen.copy(Q.positionScreen);f.v2.positionScreen.copy(z.positionScreen);f.v3.positionScreen.copy(N.positionScreen);f.normalWorld.copy(F.normal); -s.matrixRotation.transform(f.normalWorld);f.centroidWorld.copy(F.centroid);y.transform(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);p.transform(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterial=s.material;f.faceMaterial=F.material;f.overdraw=s.overdraw;f.uvs=s.geometry.uvs[u];f.color=F.color;c.push(f);b++}}else if(F instanceof THREE.Face4){Q=M[F.a];z=M[F.b];N=M[F.c];K=M[F.d];if(Q.__visible&&z.__visible&&N.__visible&&K.__visible)if(s.doubleSided||s.flipSided!=((K.positionScreen.x- -Q.positionScreen.x)*(z.positionScreen.y-Q.positionScreen.y)-(K.positionScreen.y-Q.positionScreen.y)*(z.positionScreen.x-Q.positionScreen.x)<0||(z.positionScreen.x-N.positionScreen.x)*(K.positionScreen.y-N.positionScreen.y)-(z.positionScreen.y-N.positionScreen.y)*(K.positionScreen.x-N.positionScreen.x)<0)){j=t[n]=t[n]||new THREE.RenderableFace4;j.v1.positionScreen.copy(Q.positionScreen);j.v2.positionScreen.copy(z.positionScreen);j.v3.positionScreen.copy(N.positionScreen);j.v4.positionScreen.copy(K.positionScreen); -j.normalWorld.copy(F.normal);s.matrixRotation.transform(j.normalWorld);j.centroidWorld.copy(F.centroid);y.transform(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);p.transform(j.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterial=s.material;j.faceMaterial=F.material;j.overdraw=s.overdraw;j.uvs=s.geometry.uvs[u];j.color=F.color;c.push(j);n++}}}}else if(s instanceof THREE.Line){x.multiply(p,y);M=s.geometry.vertices;u=0;for(L=M.length;u0&&o.z<1){i=r[l]=r[l]||new THREE.RenderableParticle;i.x=o.x/o.w;i.y=o.y/o.w;i.z= -o.z;i.rotation=s.rotation.z;i.scale.x=s.scale.x*Math.abs(i.x-(o.x+B.projectionMatrix.n11)/(o.w+B.projectionMatrix.n14));i.scale.y=s.scale.y*Math.abs(i.y-(o.y+B.projectionMatrix.n22)/(o.w+B.projectionMatrix.n24));i.material=s.material;c.push(i);l++}}}c.sort(function(V,C){return C.z-V.z});return c};this.unprojectVector=function(h,B){var q=new THREE.Matrix4;q.multiply(THREE.Matrix4.makeInvert(B.matrix),THREE.Matrix4.makeInvert(B.projectionMatrix));q.transform(h);return h}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,f,b,d,j;this.domElement=document.createElement("div");this.setSize=function(n,t){f=n;b=t;d=f/2;j=b/2};this.render=function(n,t){var e,g,m,i,l,r,o,p;a=c.projectScene(n,t);e=0;for(g=a.length;e0){I.r+=H.r*k;I.g+=H.g*k;I.b+=H.b*k}}else if(k instanceof THREE.PointLight){Ha.sub(k.position,O.centroidWorld);Ha.normalize();k=O.normalWorld.dot(Ha)*k.intensity;if(k>0){I.r+=H.r*k;I.g+=H.g*k;I.b+=H.b*k}}}}function c(G,O,I,J,k,H){Y=G.positionScreen.x;Z=G.positionScreen.y;Q=O.positionScreen.x; -z=O.positionScreen.y;N=I.positionScreen.x;K=I.positionScreen.y;if(k.opacity!=B)h.globalAlpha=B=k.opacity;k.blending!=q&&n(k.blending);if(k.map){fa=k.map.image;qa=fa.width-1;ra=fa.height-1;da.u=J.uvs[0].u*qa;da.v=J.uvs[0].v*ra;$.u=J.uvs[1].u*qa;$.v=J.uvs[1].v*ra;ea.u=J.uvs[2].u*qa;ea.v=J.uvs[2].v*ra;j(fa,Y,Z,Q,z,N,K,da.u,da.v,$.u,$.v,ea.u,ea.v)}else if(k instanceof THREE.MeshBasicMaterial)b(Y,Z,Q,z,N,K,k.color,k.wireframe,k.wireframe_linewidth);else if(k instanceof THREE.MeshLambertMaterial){if(Da){ba.r= -ga.r;ba.g=ga.g;ba.b=ga.b;a(H,J,ba);R.r=k.color.r*ba.r;R.g=k.color.g*ba.g;R.b=k.color.b*ba.b;R.updateStyleString()}else R.__styleString=k.color.__styleString;b(Y,Z,Q,z,N,K,R,k.wireframe,k.wireframe_linewidth)}else if(k instanceof THREE.MeshDepthMaterial){sa=k.__2near;ta=k.__farPlusNear;ua=k.__farMinusNear;U=~~((1-sa/(ta-G.positionScreen.z*ua))*255);ha=~~((1-sa/(ta-O.positionScreen.z*ua))*255);na=~~((1-sa/(ta-I.positionScreen.z*ua))*255);fa=t([U,U,U],[ha,ha,ha],[na,na,na],[na,na,na]);da.u=0;da.v=0; -$.u=la;$.v=0;ea.u=0;ea.v=la;j(fa,Y,Z,Q,z,N,K,da.u,da.v,$.u,$.v,ea.u,ea.v)}else if(k instanceof THREE.MeshNormalMaterial){R.r=e(J.normalWorld.x);R.g=e(J.normalWorld.y);R.b=e(J.normalWorld.z);R.updateStyleString();b(Y,Z,Q,z,N,K,R,k.wireframe,k.wireframe_linewidth)}}function f(G,O,I,J,k,H,S,w,T){Y=G.positionScreen.x;Z=G.positionScreen.y;Q=O.positionScreen.x;z=O.positionScreen.y;N=I.positionScreen.x;K=I.positionScreen.y;V=J.positionScreen.x;C=J.positionScreen.y;A=k.positionScreen.x;W=k.positionScreen.y; -pa=H.positionScreen.x;P=H.positionScreen.y;if(w.opacity!=B)h.globalAlpha=B=w.opacity;w.blending!=q&&n(w.blending);if(w.map){fa=w.map.image;qa=fa.width-1;ra=fa.height-1;da.copy(S.uvs[0]);$.copy(S.uvs[1]);ea.copy(S.uvs[2]);ia.copy(S.uvs[3]);da.u*=qa;da.v*=ra;$.u*=qa;$.v*=ra;ea.u*=qa;ea.v*=ra;ia.u*=qa;ia.v*=ra;j(fa,Y,Z,Q,z,V,C,da.u,da.v,$.u,$.v,ia.u,ia.v);j(fa,A,W,N,K,pa,P,$.u,$.v,ea.u,ea.v,ia.u,ia.v)}else if(w instanceof THREE.MeshBasicMaterial)d(Y,Z,Q,z,N,K,V,C,w.color,w.wireframe,w.wireframe_linewidth); -else if(w instanceof THREE.MeshLambertMaterial){if(Da){ba.r=ga.r;ba.g=ga.g;ba.b=ga.b;a(T,S,ba);R.r=w.color.r*ba.r;R.g=w.color.g*ba.g;R.b=w.color.b*ba.b;R.updateStyleString()}else R.__styleString=w.color.__styleString;d(Y,Z,Q,z,N,K,V,C,R,w.wireframe,w.wireframe_linewidth)}else if(w instanceof THREE.MeshDepthMaterial){sa=w.__2near;ta=w.__farPlusNear;ua=w.__farMinusNear;U=~~((1-sa/(ta-G.positionScreen.z*ua))*255);ha=~~((1-sa/(ta-O.positionScreen.z*ua))*255);na=~~((1-sa/(ta-I.positionScreen.z*ua))*255); -Ea=~~((1-sa/(ta-J.positionScreen.z*ua))*255);fa=t([U,U,U],[ha,ha,ha],[Ea,Ea,Ea],[na,na,na]);da.u=0;da.v=0;$.u=la;$.v=0;ea.u=la;ea.v=la;ia.u=0;ia.v=la;j(fa,Y,Z,Q,z,V,C,da.u,da.v,$.u,$.v,ia.u,ia.v);j(fa,A,W,N,K,pa,P,$.u,$.v,ea.u,ea.v,ia.u,ia.v)}else if(w instanceof THREE.MeshNormalMaterial){R.r=e(S.normalWorld.x);R.g=e(S.normalWorld.y);R.b=e(S.normalWorld.z);R.updateStyleString();d(Y,Z,Q,z,N,K,V,C,R,w.wireframe,w.wireframe_linewidth)}}function b(G,O,I,J,k,H,S,w,T){h.beginPath();h.moveTo(G,O);h.lineTo(I, -J);h.lineTo(k,H);h.lineTo(G,O);h.closePath();if(w){if(L!=T)h.lineWidth=L=T;if(D!=S.__styleString)h.strokeStyle=D=S.__styleString;h.stroke();aa.inflate(T*2)}else{if(u!=S.__styleString)h.fillStyle=u=S.__styleString;h.fill()}}function d(G,O,I,J,k,H,S,w,T,E,ca){h.beginPath();h.moveTo(G,O);h.lineTo(I,J);h.lineTo(k,H);h.lineTo(S,w);h.lineTo(G,O);h.closePath();if(E){if(L!=ca)h.lineWidth=L=ca;if(D!=T.__styleString)h.strokeStyle=D=T.__styleString;h.stroke();aa.inflate(ca*2)}else{if(u!=T.__styleString)h.fillStyle= -u=T.__styleString;h.fill()}}function j(G,O,I,J,k,H,S,w,T,E,ca,ma,va){h.beginPath();h.moveTo(O,I);h.lineTo(J,k);h.lineTo(H,S);h.closePath();J-=O;k-=I;H-=O;S-=I;E-=w;ca-=T;ma-=w;va-=T;var wa=1/(E*va-ma*ca),za=(va*J-ca*H)*wa;ca=(va*k-ca*S)*wa;J=(E*H-ma*J)*wa;k=(E*S-ma*k)*wa;O=O-za*w-J*T;I=I-ca*w-k*T;h.save();h.transform(za,ca,J,k,O,I);h.clip();h.drawImage(G,0,0);h.restore()}function n(G){switch(G){case THREE.NormalBlending:h.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:h.globalCompositeOperation= -"lighter";break;case THREE.SubtractiveBlending:h.globalCompositeOperation="darker"}q=G}function t(G,O,I,J){ja[0]=G[0];ja[1]=G[1];ja[2]=G[2];ja[4]=O[0];ja[5]=O[1];ja[6]=O[2];ja[8]=I[0];ja[9]=I[1];ja[10]=I[2];ja[12]=J[0];ja[13]=J[1];ja[14]=J[2];Aa.putImageData(Ia,0,0);Fa.drawImage(Ba,0,0);return Ca}function e(G){return G<0?Math.min((1+G)*0.5,0.5):0.5+Math.min(G*0.5,0.5)}function g(G,O){var I=O.x-G.x,J=O.y-G.y,k=1/Math.sqrt(I*I+J*J);I*=k;J*=k;O.x+=I;O.y+=J;G.x-=I;G.y-=J}var m=null,i=new THREE.Projector, -l=document.createElement("canvas"),r,o,p,x,h=l.getContext("2d"),B=1,q=0,D=null,u=null,L=1,v,s,y,M,X=new THREE.Vertex,F=new THREE.Vertex,Y,Z,Q,z,N,K,V,C,A,W,pa,P,U,ha,na,Ea,sa,ta,ua,fa,qa,ra,oa=new THREE.Rectangle,ka=new THREE.Rectangle,aa=new THREE.Rectangle,Da=false,R=new THREE.Color(4294967295),ba=new THREE.Color(4294967295),ga=new THREE.Color(4278190080),xa=new THREE.Color(4278190080),ya=new THREE.Color(4278190080),Ma=Math.PI*2,Ha=new THREE.Vector3,da=new THREE.UV,$=new THREE.UV,ea=new THREE.UV, -ia=new THREE.UV,Ba,Aa,Ia,ja,Ca,Fa,la=16;Ba=document.createElement("canvas");Ba.width=Ba.height=2;Aa=Ba.getContext("2d");Aa.fillStyle="rgba(0,0,0,1)";Aa.fillRect(0,0,2,2);Ia=Aa.getImageData(0,0,2,2);ja=Ia.data;Ca=document.createElement("canvas");Ca.width=Ca.height=la;Fa=Ca.getContext("2d");Fa.translate(-la/2,-la/2);Fa.scale(la,la);la--;this.domElement=l;this.autoClear=true;this.setSize=function(G,O){r=G;o=O;p=r/2;x=o/2;l.width=r;l.height=o;h.lineJoin="round";h.lineCap="round";oa.set(-p,-x,p,x)};this.clear= -function(){if(!ka.isEmpty()){ka.inflate(1);ka.minSelf(oa);h.setTransform(1,0,0,-1,p,x);h.clearRect(ka.getX(),ka.getY(),ka.getWidth(),ka.getHeight());ka.empty()}};this.render=function(G,O){var I,J,k,H,S,w,T,E;this.autoClear&&this.clear();m=i.projectScene(G,O);h.setTransform(1,0,0,-1,p,x);h.fillStyle="rgba(0, 255, 255, 0.5)";h.fillRect(oa.getX(),oa.getY(),oa.getWidth(),oa.getHeight());if(Da=G.lights.length>0){S=G.lights;ga.setRGB(0,0,0);xa.setRGB(0,0,0);ya.setRGB(0,0,0);I=0;for(J=S.length;I0){K.r+=A.color.r*W;K.g+=A.color.g*W;K.b+=A.color.b*W}}else if(A instanceof THREE.PointLight){y.sub(A.position,N.centroidWorld);y.normalize();W=N.normalWorld.dot(y)*A.intensity;if(W>0){K.r+=A.color.r*W;K.g+=A.color.g*W;K.b+=A.color.b*W}}}}function c(z,N,K,V,C,A){F=b(Y++);F.setAttribute("d","M "+z.positionScreen.x+ -" "+z.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)q.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(B){D.r=u.r;D.g=u.g;D.b=u.b;a(A,V,D);q.r=C.color.r*D.r;q.g=C.color.g*D.g;q.b=C.color.b*D.b;q.updateStyleString()}else q.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){s=1-C.__2near/(C.__farPlusNear-V.z*C.__farMinusNear); -q.setRGB(s,s,s)}else C instanceof THREE.MeshNormalMaterial&&q.setRGB(d(V.normalWorld.x),d(V.normalWorld.y),d(V.normalWorld.z));C.wireframe?F.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: round; stroke-linejoin: round"):F.setAttribute("style","fill: "+q.__styleString+"; fill-opacity: "+C.opacity);t.appendChild(F)}function f(z,N,K,V,C,A,W){F=b(Y++);F.setAttribute("d","M "+z.positionScreen.x+" "+ -z.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(A instanceof THREE.MeshBasicMaterial)q.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshLambertMaterial)if(B){D.r=u.r;D.g=u.g;D.b=u.b;a(W,C,D);q.r=A.color.r*D.r;q.g=A.color.g*D.g;q.b=A.color.b*D.b;q.updateStyleString()}else q.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshDepthMaterial){s=1- -A.__2near/(A.__farPlusNear-C.z*A.__farMinusNear);q.setRGB(s,s,s)}else A instanceof THREE.MeshNormalMaterial&&q.setRGB(d(C.normalWorld.x),d(C.normalWorld.y),d(C.normalWorld.z));A.wireframe?F.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+A.wireframe_linewidth+"; stroke-opacity: "+A.opacity+"; stroke-linecap: round; stroke-linejoin: round"):F.setAttribute("style","fill: "+q.__styleString+"; fill-opacity: "+A.opacity);t.appendChild(F)}function b(z){if(M[z]==null){M[z]= -document.createElementNS("http://www.w3.org/2000/svg","path");Q==0&&M[z].setAttribute("shape-rendering","crispEdges");return M[z]}return M[z]}function d(z){return z<0?Math.min((1+z)*0.5,0.5):0.5+Math.min(z*0.5,0.5)}var j=null,n=new THREE.Projector,t=document.createElementNS("http://www.w3.org/2000/svg","svg"),e,g,m,i,l,r,o,p,x=new THREE.Rectangle,h=new THREE.Rectangle,B=false,q=new THREE.Color(4294967295),D=new THREE.Color(4294967295),u=new THREE.Color(4278190080),L=new THREE.Color(4278190080),v= -new THREE.Color(4278190080),s,y=new THREE.Vector3,M=[],X=[],F,Y,Z,Q=1;this.domElement=t;this.autoClear=true;this.setQuality=function(z){switch(z){case "high":Q=1;break;case "low":Q=0}};this.setSize=function(z,N){e=z;g=N;m=e/2;i=g/2;t.setAttribute("viewBox",-m+" "+-i+" "+e+" "+g);t.setAttribute("width",e);t.setAttribute("height",g);x.set(-m,-i,m,i)};this.clear=function(){for(;t.childNodes.length>0;)t.removeChild(t.childNodes[0])};this.render=function(z,N){var K,V,C,A,W,pa,P,U;this.autoClear&&this.clear(); -j=n.projectScene(z,N);Z=Y=0;if(B=z.lights.length>0){P=z.lights;u.setRGB(0,0,0);L.setRGB(0,0,0);v.setRGB(0,0,0);K=0;for(V=P.length;K=0&&P>=0&&M>=0&&y>=0)n=true;else if(h<0&&P<0||M<0&&y<0)n=false;else{if(h<0)n=Math.max(n,h/(h-P));else if(P<0)w=Math.min(w,h/(h-P));if(M<0)n=Math.max(n,M/(M-y));else if(y<0)w=Math.min(w,M/(M-y));if(w0&&t.z<1}D=y.geometry.faces;h=0;for(P=D.length;h< +P;h++){t=D[h];if(t instanceof THREE.Face3){X=S[t.a];B=S[t.b];L=S[t.c];if(X.__visible&&B.__visible&&L.__visible)if(y.doubleSided||y.flipSided!=(L.positionScreen.x-X.positionScreen.x)*(B.positionScreen.y-X.positionScreen.y)-(L.positionScreen.y-X.positionScreen.y)*(B.positionScreen.x-X.positionScreen.x)<0){f=d[b]=d[b]||new THREE.RenderableFace3;f.v1.positionScreen.copy(X.positionScreen);f.v2.positionScreen.copy(B.positionScreen);f.v3.positionScreen.copy(L.positionScreen);f.normalWorld.copy(t.normal); +y.matrixRotation.transform(f.normalWorld);f.centroidWorld.copy(t.centroid);J.transform(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);s.transform(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterial=y.material;f.faceMaterial=t.material;f.overdraw=y.overdraw;f.uvs=y.geometry.uvs[h];f.color=t.color;c.push(f);b++}}else if(t instanceof THREE.Face4){X=S[t.a];B=S[t.b];L=S[t.c];K=S[t.d];if(X.__visible&&B.__visible&&L.__visible&&K.__visible)if(y.doubleSided||y.flipSided!=((K.positionScreen.x- +X.positionScreen.x)*(B.positionScreen.y-X.positionScreen.y)-(K.positionScreen.y-X.positionScreen.y)*(B.positionScreen.x-X.positionScreen.x)<0||(B.positionScreen.x-L.positionScreen.x)*(K.positionScreen.y-L.positionScreen.y)-(B.positionScreen.y-L.positionScreen.y)*(K.positionScreen.x-L.positionScreen.x)<0)){j=r[o]=r[o]||new THREE.RenderableFace4;j.v1.positionScreen.copy(X.positionScreen);j.v2.positionScreen.copy(B.positionScreen);j.v3.positionScreen.copy(L.positionScreen);j.v4.positionScreen.copy(K.positionScreen); +j.normalWorld.copy(t.normal);y.matrixRotation.transform(j.normalWorld);j.centroidWorld.copy(t.centroid);J.transform(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);s.transform(j.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterial=y.material;j.faceMaterial=t.material;j.overdraw=y.overdraw;j.uvs=y.geometry.uvs[h];j.color=t.color;c.push(j);o++}}}}else if(y instanceof THREE.Line){A.multiply(s,J);S=y.geometry.vertices;h=0;for(P=S.length;h0&&p.z<1){i=q[k]=q[k]||new THREE.RenderableParticle;i.x=p.x/p.w;i.y=p.y/p.w; +i.z=p.z;i.rotation=y.rotation.z;i.scale.x=y.scale.x*Math.abs(i.x-(p.x+E.projectionMatrix.n11)/(p.w+E.projectionMatrix.n14));i.scale.y=y.scale.y*Math.abs(i.y-(p.y+E.projectionMatrix.n22)/(p.w+E.projectionMatrix.n24));i.material=y.material;c.push(i);k++}}}c.sort(function(R,z){return z.z-R.z});return c};this.unprojectVector=function(C,E){var n=new THREE.Matrix4;n.multiply(THREE.Matrix4.makeInvert(E.matrix),THREE.Matrix4.makeInvert(E.projectionMatrix));n.transform(C);return C}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,f,b,d,j;this.domElement=document.createElement("div");this.setSize=function(o,r){f=o;b=r;d=f/2;j=b/2};this.render=function(o,r){var e,g,m,i,k,q,p,s;a=c.projectScene(o,r);e=0;for(g=a.length;e0){G.r+=F.r*l;G.g+=F.g*l;G.b+=F.b*l}}else if(l instanceof THREE.PointLight){Ja.sub(l.position,N.centroidWorld);Ja.normalize();l=N.normalWorld.dot(Ja)*l.intensity;if(l>0){G.r+=F.r*l;G.g+=F.g*l;G.b+=F.b*l}}}}function c(x,N,G,H,l,F){L=x.positionScreen.x;K=x.positionScreen.y;R=N.positionScreen.x; +z=N.positionScreen.y;u=G.positionScreen.x;Q=G.positionScreen.y;o(l.opacity);r(l.blending);if(l.map){fa=l.map.image;pa=fa.width-1;qa=fa.height-1;da.u=H.uvs[0].u*pa;da.v=H.uvs[0].v*qa;Z.u=H.uvs[1].u*pa;Z.v=H.uvs[1].v*qa;ea.u=H.uvs[2].u*pa;ea.v=H.uvs[2].v*qa;j(fa,L,K,R,z,u,Q,da.u,da.v,Z.u,Z.v,ea.u,ea.v)}else if(l instanceof THREE.MeshBasicMaterial)b(L,K,R,z,u,Q,l.color,l.wireframe,l.wireframe_linewidth);else if(l instanceof THREE.MeshLambertMaterial){if(Fa){ba.r=ga.r;ba.g=ga.g;ba.b=ga.b;a(F,H,ba);T.r= +l.color.r*ba.r;T.g=l.color.g*ba.g;T.b=l.color.b*ba.b;T.updateStyleString()}else T.__styleString=l.color.__styleString;b(L,K,R,z,u,Q,T,l.wireframe,l.wireframe_linewidth)}else if(l instanceof THREE.MeshDepthMaterial){ra=l.__2near;sa=l.__farPlusNear;ta=l.__farMinusNear;wa=~~((1-ra/(sa-x.positionScreen.z*ta))*255);xa=~~((1-ra/(sa-N.positionScreen.z*ta))*255);na=~~((1-ra/(sa-G.positionScreen.z*ta))*255);fa=i([wa,wa,wa],[xa,xa,xa],[na,na,na],[na,na,na]);da.u=0;da.v=0;Z.u=la;Z.v=0;ea.u=0;ea.v=la;j(fa,L, +K,R,z,u,Q,da.u,da.v,Z.u,Z.v,ea.u,ea.v)}else if(l instanceof THREE.MeshNormalMaterial){T.r=k(H.normalWorld.x);T.g=k(H.normalWorld.y);T.b=k(H.normalWorld.z);T.updateStyleString();b(L,K,R,z,u,Q,T,l.wireframe,l.wireframe_linewidth)}}function f(x,N,G,H,l,F,U,v,W){L=x.positionScreen.x;K=x.positionScreen.y;R=N.positionScreen.x;z=N.positionScreen.y;u=G.positionScreen.x;Q=G.positionScreen.y;ha=H.positionScreen.x;O=H.positionScreen.y;Y=l.positionScreen.x;ya=l.positionScreen.y;Ka=F.positionScreen.x;La=F.positionScreen.y; +o(v.opacity);r(v.blending);if(v.map){fa=v.map.image;pa=fa.width-1;qa=fa.height-1;da.copy(U.uvs[0]);Z.copy(U.uvs[1]);ea.copy(U.uvs[2]);ia.copy(U.uvs[3]);da.u*=pa;da.v*=qa;Z.u*=pa;Z.v*=qa;ea.u*=pa;ea.v*=qa;ia.u*=pa;ia.v*=qa;j(fa,L,K,R,z,ha,O,da.u,da.v,Z.u,Z.v,ia.u,ia.v);j(fa,Y,ya,u,Q,Ka,La,Z.u,Z.v,ea.u,ea.v,ia.u,ia.v)}else if(v instanceof THREE.MeshBasicMaterial)d(L,K,R,z,u,Q,ha,O,v.color,v.wireframe,v.wireframe_linewidth);else if(v instanceof THREE.MeshLambertMaterial){if(Fa){ba.r=ga.r;ba.g=ga.g;ba.b= +ga.b;a(W,U,ba);T.r=v.color.r*ba.r;T.g=v.color.g*ba.g;T.b=v.color.b*ba.b;T.updateStyleString()}else T.__styleString=v.color.__styleString;d(L,K,R,z,u,Q,ha,O,T,v.wireframe,v.wireframe_linewidth)}else if(v instanceof THREE.MeshDepthMaterial){ra=v.__2near;sa=v.__farPlusNear;ta=v.__farMinusNear;wa=~~((1-ra/(sa-x.positionScreen.z*ta))*255);xa=~~((1-ra/(sa-N.positionScreen.z*ta))*255);na=~~((1-ra/(sa-G.positionScreen.z*ta))*255);Ga=~~((1-ra/(sa-H.positionScreen.z*ta))*255);fa=i([wa,wa,wa],[xa,xa,xa],[Ga, +Ga,Ga],[na,na,na]);da.u=0;da.v=0;Z.u=la;Z.v=0;ea.u=la;ea.v=la;ia.u=0;ia.v=la;j(fa,L,K,R,z,ha,O,da.u,da.v,Z.u,Z.v,ia.u,ia.v);j(fa,Y,ya,u,Q,Ka,La,Z.u,Z.v,ea.u,ea.v,ia.u,ia.v)}else if(v instanceof THREE.MeshNormalMaterial){T.r=k(U.normalWorld.x);T.g=k(U.normalWorld.y);T.b=k(U.normalWorld.z);T.updateStyleString();d(L,K,R,z,u,Q,ha,O,T,v.wireframe,v.wireframe_linewidth)}}function b(x,N,G,H,l,F,U,v,W){h.beginPath();h.moveTo(x,N);h.lineTo(G,H);h.lineTo(l,F);h.lineTo(x,N);h.closePath();if(v){e(W);g(U.__styleString); +h.stroke();$.inflate(W*2)}else{m(U.__styleString);h.fill()}}function d(x,N,G,H,l,F,U,v,W,I,ca){h.beginPath();h.moveTo(x,N);h.lineTo(G,H);h.lineTo(l,F);h.lineTo(U,v);h.lineTo(x,N);h.closePath();if(I){e(ca);g(W.__styleString);h.stroke();$.inflate(ca*2)}else{m(W.__styleString);h.fill()}}function j(x,N,G,H,l,F,U,v,W,I,ca,ma,ua){h.beginPath();h.moveTo(N,G);h.lineTo(H,l);h.lineTo(F,U);h.closePath();H-=N;l-=G;F-=N;U-=G;I-=v;ca-=W;ma-=v;ua-=W;var va=1/(I*ua-ma*ca),Ba=(ua*H-ca*F)*va;ca=(ua*l-ca*U)*va;H=(I* +F-ma*H)*va;l=(I*U-ma*l)*va;N=N-Ba*v-H*W;G=G-ca*v-l*W;h.save();h.transform(Ba,ca,H,l,N,G);h.clip();h.drawImage(x,0,0);h.restore()}function o(x){if(P!=x)h.globalAlpha=P=x}function r(x){if(M!=x){switch(x){case THREE.NormalBlending:h.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:h.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:h.globalCompositeOperation="darker"}M=x}}function e(x){if(S!=x)h.lineWidth=S=x}function g(x){if(y!=x)h.strokeStyle=y=x}function m(x){if(J!= +x)h.fillStyle=J=x}function i(x,N,G,H){ja[0]=x[0];ja[1]=x[1];ja[2]=x[2];ja[4]=N[0];ja[5]=N[1];ja[6]=N[2];ja[8]=G[0];ja[9]=G[1];ja[10]=G[2];ja[12]=H[0];ja[13]=H[1];ja[14]=H[2];Ca.putImageData(Ma,0,0);Ha.drawImage(Da,0,0);return Ea}function k(x){return x<0?Math.min((1+x)*0.5,0.5):0.5+Math.min(x*0.5,0.5)}function q(x,N){var G=N.x-x.x,H=N.y-x.y,l=1/Math.sqrt(G*G+H*H);G*=l;H*=l;N.x+=G;N.y+=H;x.x-=G;x.y-=H}var p=null,s=new THREE.Projector,A=document.createElement("canvas"),C,E,n,w,h=A.getContext("2d"),P= +1,M=0,y=null,J=null,S=1,D,t,V,aa,X=new THREE.Vertex,B=new THREE.Vertex,L,K,R,z,u,Q,ha,O,Y,ya,Ka,La,wa,xa,na,Ga,ra,sa,ta,fa,pa,qa,oa=new THREE.Rectangle,ka=new THREE.Rectangle,$=new THREE.Rectangle,Fa=false,T=new THREE.Color(4294967295),ba=new THREE.Color(4294967295),ga=new THREE.Color(4278190080),za=new THREE.Color(4278190080),Aa=new THREE.Color(4278190080),Qa=Math.PI*2,Ja=new THREE.Vector3,da=new THREE.UV,Z=new THREE.UV,ea=new THREE.UV,ia=new THREE.UV,Da,Ca,Ma,ja,Ea,Ha,la=16;Da=document.createElement("canvas"); +Da.width=Da.height=2;Ca=Da.getContext("2d");Ca.fillStyle="rgba(0,0,0,1)";Ca.fillRect(0,0,2,2);Ma=Ca.getImageData(0,0,2,2);ja=Ma.data;Ea=document.createElement("canvas");Ea.width=Ea.height=la;Ha=Ea.getContext("2d");Ha.translate(-la/2,-la/2);Ha.scale(la,la);la--;this.domElement=A;this.autoClear=true;this.setSize=function(x,N){C=x;E=N;n=C/2;w=E/2;A.width=C;A.height=E;h.lineJoin="round";h.lineCap="round";oa.set(-n,-w,n,w)};this.clear=function(){if(!ka.isEmpty()){ka.inflate(1);ka.minSelf(oa);h.setTransform(1, +0,0,-1,n,w);h.clearRect(ka.getX(),ka.getY(),ka.getWidth(),ka.getHeight());ka.empty()}};this.render=function(x,N){var G,H,l,F,U,v,W,I;this.autoClear&&this.clear();p=s.projectScene(x,N);h.setTransform(1,0,0,-1,n,w);h.fillStyle="rgba(0, 255, 255, 0.5)";h.fillRect(oa.getX(),oa.getY(),oa.getWidth(),oa.getHeight());if(Fa=x.lights.length>0){U=x.lights;ga.setRGB(0,0,0);za.setRGB(0,0,0);Aa.setRGB(0,0,0);G=0;for(H=U.length;G0){K.r+=u.color.r*Q;K.g+=u.color.g*Q;K.b+=u.color.b*Q}}else if(u instanceof THREE.PointLight){J.sub(u.position,L.centroidWorld);J.normalize();Q=L.normalWorld.dot(J)*u.intensity;if(Q>0){K.r+=u.color.r*Q;K.g+=u.color.g*Q;K.b+=u.color.b*Q}}}}function c(B,L,K,R,z,u){t=b(V++);t.setAttribute("d","M "+B.positionScreen.x+ +" "+B.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(z instanceof THREE.MeshBasicMaterial)n.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshLambertMaterial)if(E){w.r=h.r;w.g=h.g;w.b=h.b;a(u,R,w);n.r=z.color.r*w.r;n.g=z.color.g*w.g;n.b=z.color.b*w.b;n.updateStyleString()}else n.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshDepthMaterial){y=1-z.__2near/(z.__farPlusNear-R.z*z.__farMinusNear); +n.setRGB(y,y,y)}else z instanceof THREE.MeshNormalMaterial&&n.setRGB(d(R.normalWorld.x),d(R.normalWorld.y),d(R.normalWorld.z));z.wireframe?t.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+z.wireframe_linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: round; stroke-linejoin: round"):t.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+z.opacity);r.appendChild(t)}function f(B,L,K,R,z,u,Q){t=b(V++);t.setAttribute("d","M "+B.positionScreen.x+" "+ +B.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+" L "+R.positionScreen.x+","+R.positionScreen.y+"z");if(u instanceof THREE.MeshBasicMaterial)n.__styleString=u.color.__styleString;else if(u instanceof THREE.MeshLambertMaterial)if(E){w.r=h.r;w.g=h.g;w.b=h.b;a(Q,z,w);n.r=u.color.r*w.r;n.g=u.color.g*w.g;n.b=u.color.b*w.b;n.updateStyleString()}else n.__styleString=u.color.__styleString;else if(u instanceof THREE.MeshDepthMaterial){y=1- +u.__2near/(u.__farPlusNear-z.z*u.__farMinusNear);n.setRGB(y,y,y)}else u instanceof THREE.MeshNormalMaterial&&n.setRGB(d(z.normalWorld.x),d(z.normalWorld.y),d(z.normalWorld.z));u.wireframe?t.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+u.wireframe_linewidth+"; stroke-opacity: "+u.opacity+"; stroke-linecap: round; stroke-linejoin: round"):t.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+u.opacity);r.appendChild(t)}function b(B){if(S[B]==null){S[B]= +document.createElementNS("http://www.w3.org/2000/svg","path");X==0&&S[B].setAttribute("shape-rendering","crispEdges");return S[B]}return S[B]}function d(B){return B<0?Math.min((1+B)*0.5,0.5):0.5+Math.min(B*0.5,0.5)}var j=null,o=new THREE.Projector,r=document.createElementNS("http://www.w3.org/2000/svg","svg"),e,g,m,i,k,q,p,s,A=new THREE.Rectangle,C=new THREE.Rectangle,E=false,n=new THREE.Color(4294967295),w=new THREE.Color(4294967295),h=new THREE.Color(4278190080),P=new THREE.Color(4278190080),M= +new THREE.Color(4278190080),y,J=new THREE.Vector3,S=[],D=[],t,V,aa,X=1;this.domElement=r;this.autoClear=true;this.setQuality=function(B){switch(B){case "high":X=1;break;case "low":X=0}};this.setSize=function(B,L){e=B;g=L;m=e/2;i=g/2;r.setAttribute("viewBox",-m+" "+-i+" "+e+" "+g);r.setAttribute("width",e);r.setAttribute("height",g);A.set(-m,-i,m,i)};this.clear=function(){for(;r.childNodes.length>0;)r.removeChild(r.childNodes[0])};this.render=function(B,L){var K,R,z,u,Q,ha,O,Y;this.autoClear&&this.clear(); +j=o.projectScene(B,L);aa=V=0;if(E=B.lights.length>0){O=B.lights;h.setRGB(0,0,0);P.setRGB(0,0,0);M.setRGB(0,0,0);K=0;for(R=O.length;K= 0.0 )": @@ -134,25 +133,25 @@ e?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",e?"vec4 lDirection = b.getUniformLocation(d,"directionalLightColor");d.directionalLightDirection=b.getUniformLocation(d,"directionalLightDirection")}if(g){d.pointLightNumber=b.getUniformLocation(d,"pointLightNumber");d.pointLightColor=b.getUniformLocation(d,"pointLightColor");d.pointLightPosition=b.getUniformLocation(d,"pointLightPosition")}d.material=b.getUniformLocation(d,"material");d.mColor=b.getUniformLocation(d,"mColor");d.mOpacity=b.getUniformLocation(d,"mOpacity");d.mReflectivity=b.getUniformLocation(d,"mReflectivity"); d.mAmbient=b.getUniformLocation(d,"mAmbient");d.mSpecular=b.getUniformLocation(d,"mSpecular");d.mShininess=b.getUniformLocation(d,"mShininess");d.enableMap=b.getUniformLocation(d,"enableMap");b.uniform1i(d.enableMap,0);d.tMap=b.getUniformLocation(d,"tMap");b.uniform1i(d.tMap,0);d.enableCubeMap=b.getUniformLocation(d,"enableCubeMap");b.uniform1i(d.enableCubeMap,0);d.tCube=b.getUniformLocation(d,"tCube");b.uniform1i(d.tCube,1);d.m2Near=b.getUniformLocation(d,"m2Near");d.mFarPlusNear=b.getUniformLocation(d, "mFarPlusNear");d.mFarMinusNear=b.getUniformLocation(d,"mFarMinusNear");d.position=b.getAttribLocation(d,"position");b.enableVertexAttribArray(d.position);d.normal=b.getAttribLocation(d,"normal");b.enableVertexAttribArray(d.normal);d.uv=b.getAttribLocation(d,"uv");b.enableVertexAttribArray(d.uv);d.viewMatrixArray=new Float32Array(16);d.modelViewMatrixArray=new Float32Array(16);d.projectionMatrixArray=new Float32Array(16)})(a.directional,a.point);this.setSize=function(e,g){f.width=e;f.height=g;b.viewport(0, -0,f.width,f.height)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(e){var g,m,i,l,r=[],o=[],p=[];l=[];var x=[];b.uniform1i(d.enableLighting,e.lights.length);g=0;for(m=e.lights.length;g - +

Three.js cube mapping demo @@ -31,11 +31,11 @@

Walt Disney head by David OReilly

Texture by Humus

- +

 
 		 
-		
+
 		
 		
 		
@@ -44,37 +44,90 @@
 
 		
 
diff --git a/examples/materials_cubemap_sky.html b/examples/materials_cubemap_sky.html
index 9a4896cd..eab25827 100644
--- a/examples/materials_cubemap_sky.html
+++ b/examples/materials_cubemap_sky.html
@@ -46,6 +46,7 @@
 			var container, stats;
 
 			var camera, scene, webglRenderer;
+			var cameraCube, sceneCube;
 
 			var mesh, zmesh, lightMesh, geometry;
 
@@ -70,8 +71,10 @@
 				camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 100000 );
 				camera.position.z = 3200;
 
-				scene = new THREE.Scene();
+				cameraCube = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 100000 );
 
+				scene = new THREE.Scene();
+				sceneCube = new THREE.Scene();
 
 				var r = "textures/skymap_";
 
@@ -99,6 +102,7 @@
 
 				webglRenderer = new THREE.WebGLRenderer( scene );
 				webglRenderer.setSize( window.innerWidth, window.innerHeight );
+				webglRenderer.autoClear = false;
 				container.appendChild( webglRenderer.domElement );
 
 				if ( statsEnabled ) {
@@ -123,9 +127,7 @@
 				mesh.rotation.x = rx;
 				mesh.rotation.y = ry;
 				mesh.rotation.z = rz;
-				mesh.overdraw = true;
-				mesh.updateMatrix();
-				scene.addObject(mesh);
+				sceneCube.addObject(mesh);
 
 			}
 
@@ -172,6 +174,12 @@
 				camera.position.x += ( mouseX - camera.position.x ) * .05;
 				camera.position.y += ( - mouseY - camera.position.y ) * .05;
 
+				cameraCube.target.position.x = - camera.position.x;
+				cameraCube.target.position.y = - camera.position.y;
+				cameraCube.target.position.z = - camera.position.z;
+
+				webglRenderer.clear();
+				webglRenderer.render( sceneCube, cameraCube );
 				webglRenderer.render( scene, camera );
 
 				if ( statsEnabled ) stats.update();
diff --git a/examples/test.html b/examples/test.html
index e595a508..6853b0d5 100644
--- a/examples/test.html
+++ b/examples/test.html
@@ -213,7 +213,7 @@
 
 				webglRenderer = new THREE.WebGLRenderer();
 				webglRenderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
-                //webglRenderer.setFaceCulling( 0 );
+				// webglRenderer.setFaceCulling( 0 );
 				container.appendChild( webglRenderer.domElement );
 
 				stats = new Stats();
diff --git a/src/renderers/CanvasRenderer.js b/src/renderers/CanvasRenderer.js
index 36a7e8d5..63e97e3c 100644
--- a/src/renderers/CanvasRenderer.js
+++ b/src/renderers/CanvasRenderer.js
@@ -18,7 +18,7 @@ THREE.CanvasRenderer = function () {
 	_contextLineWidth = 1,
 
 	_v1, _v2, _v3, _v4,
-	_v5 = new THREE.Vertex(), _v6 = new THREE.Vertex(), // Needed for latter splitting tris to quads
+	_v5 = new THREE.Vertex(), _v6 = new THREE.Vertex(), // Needed for latter splitting quads to tris
 
 	_v1x, _v1y, _v2x, _v2y, _v3x, _v3y,
 	_v4x, _v4y, _v5x, _v5y, _v6x, _v6y,
@@ -119,9 +119,7 @@ THREE.CanvasRenderer = function () {
 		_context.fillRect( _clipRect.getX(), _clipRect.getY(), _clipRect.getWidth(), _clipRect.getHeight() );
 		*/
 
-		_enableLighting = scene.lights.length > 0;
-
-		if ( _enableLighting ) {
+		if ( _enableLighting = scene.lights.length > 0 ) {
 
 			calculateLights( scene );
 
@@ -393,17 +391,8 @@ THREE.CanvasRenderer = function () {
 		var width, height, scaleX, scaleY, offsetX, offsetY,
 		bitmap, bitmapWidth, bitmapHeight;
 
-		if ( material.opacity != _contextGlobalAlpha ) {
-
-			_context.globalAlpha = _contextGlobalAlpha = material.opacity;
-
-		}
-
-		if ( material.blending != _contextGlobalCompositeOperation ) {
-
-			setBlending( material.blending );
-
-		}
+		setOpacity( material.opacity );
+		setBlending( material.blending );
 
 		if ( material instanceof THREE.ParticleBasicMaterial ) {
 
@@ -482,11 +471,7 @@ THREE.CanvasRenderer = function () {
 
 			}
 
-			if ( _contextFillStyle !== _color.__styleString ) {
-
-				_context.fillStyle = _contextFillStyle = _color.__styleString;
-
-			}
+			setFillStyle( _color.__styleString );
 
 			_context.save();
 			_context.translate( v1.x, v1.y );
@@ -506,17 +491,8 @@ THREE.CanvasRenderer = function () {
 
 	function renderLine( v1, v2, element, material, scene ) {
 
-		if ( material.opacity != _contextGlobalAlpha ) {
-
-			_context.globalAlpha = _contextGlobalAlpha = material.opacity;
-
-		}
-
-		if ( material.blending != _contextGlobalCompositeOperation ) {
-
-			setBlending( material.blending );
-
-		}
+		setOpacity( material.opacity );
+		setBlending( material.blending );
 
 		_context.beginPath();
 		_context.moveTo( v1.positionScreen.x, v1.positionScreen.y );
@@ -527,17 +503,8 @@ THREE.CanvasRenderer = function () {
 
 			_color.__styleString = material.color.__styleString;
 
-			if ( _contextLineWidth != material.linewidth ) {
-
-				_context.lineWidth = _contextLineWidth = material.linewidth;
-
-			}
-
-			if ( _contextStrokeStyle != _color.__styleString ) {
-
-				_context.strokeStyle = _contextStrokeStyle  = _color.__styleString;
-
-			}
+			setLineWidth( material.linewidth );
+			setStrokeStyle( _color.__styleString );
 
 			_context.stroke();
 			_bboxRect.inflate( material.linewidth * 2 );
@@ -552,17 +519,8 @@ THREE.CanvasRenderer = function () {
 		_v2x = v2.positionScreen.x; _v2y = v2.positionScreen.y;
 		_v3x = v3.positionScreen.x; _v3y = v3.positionScreen.y;
 
-		if ( material.opacity != _contextGlobalAlpha ) {
-
-			_context.globalAlpha = _contextGlobalAlpha = material.opacity;
-
-		}
-
-		if ( material.blending != _contextGlobalCompositeOperation ) {
-
-			setBlending( material.blending );
-
-		}
+		setOpacity( material.opacity );
+		setBlending( material.blending );
 
 		if ( material.map ) {
 
@@ -654,17 +612,8 @@ THREE.CanvasRenderer = function () {
 		_v5x = v5.positionScreen.x; _v5y = v5.positionScreen.y;
 		_v6x = v6.positionScreen.x; _v6y = v6.positionScreen.y;
 
-		if ( material.opacity != _contextGlobalAlpha ) {
-
-			_context.globalAlpha = _contextGlobalAlpha = material.opacity;
-
-		}
-
-		if ( material.blending != _contextGlobalCompositeOperation ) {
-
-			setBlending( material.blending );
-
-		}
+		setOpacity( material.opacity );
+		setBlending( material.blending );
 
 		if ( material.map ) {
 
@@ -767,28 +716,15 @@ THREE.CanvasRenderer = function () {
 
 		if ( wireframe ) {
 
-			if ( _contextLineWidth != wireframe_linewidth ) {
-
-				_context.lineWidth = _contextLineWidth = wireframe_linewidth;
-
-			}
-
-			if ( _contextStrokeStyle != color.__styleString ) {
-
-				_context.strokeStyle = _contextStrokeStyle  = color.__styleString;
-
-			}
+			setLineWidth( wireframe_linewidth );
+			setStrokeStyle( color.__styleString );
 
 			_context.stroke();
 			_bboxRect.inflate( wireframe_linewidth * 2 );
 
 		} else {
 
-			if ( _contextFillStyle != color.__styleString ) {
-
-				_context.fillStyle = _contextFillStyle = color.__styleString;
-
-			}
+			setFillStyle( color.__styleString );
 
 			_context.fill();
 
@@ -808,28 +744,15 @@ THREE.CanvasRenderer = function () {
 
 		if ( wireframe ) {
 
-			if ( _contextLineWidth != wireframe_linewidth ) {
-
-				_context.lineWidth = _contextLineWidth = wireframe_linewidth;
-
-			}
-
-			if ( _contextStrokeStyle != color.__styleString ) {
-
-				_context.strokeStyle = _contextStrokeStyle  = color.__styleString;
-
-			}
+			setLineWidth( wireframe_linewidth );
+			setStrokeStyle( color.__styleString );
 
 			_context.stroke();
 			_bboxRect.inflate( wireframe_linewidth * 2 );
 
 		} else {
 
-			if ( _contextFillStyle != color.__styleString ) {
-
-				_context.fillStyle = _contextFillStyle = color.__styleString;
-
-			}
+			setFillStyle( color.__styleString );
 
 			_context.fill();
 
@@ -871,31 +794,77 @@ THREE.CanvasRenderer = function () {
 
 	}
 
-	function setBlending( blending ) {
+	//
 
-		switch ( blending ) {
+	function setOpacity( value ) {
 
-			case THREE.NormalBlending:
+		if ( _contextGlobalAlpha != value ) {
 
-				_context.globalCompositeOperation = 'source-over';
-
-				break;
-
-			case THREE.AdditiveBlending:
-
-				_context.globalCompositeOperation = 'lighter';
-
-				break;
-
-			case THREE.SubtractiveBlending:
-
-				_context.globalCompositeOperation = 'darker';
-
-				break;
+			_context.globalAlpha = _contextGlobalAlpha = value;
 
 		}
 
-		_contextGlobalCompositeOperation = blending;
+	}
+
+	function setBlending( value ) {
+
+		if ( _contextGlobalCompositeOperation != value ) {
+
+			switch ( value ) {
+
+				case THREE.NormalBlending:
+
+					_context.globalCompositeOperation = 'source-over';
+
+					break;
+
+				case THREE.AdditiveBlending:
+
+					_context.globalCompositeOperation = 'lighter';
+
+					break;
+
+				case THREE.SubtractiveBlending:
+
+					_context.globalCompositeOperation = 'darker';
+
+					break;
+
+			}
+
+			_contextGlobalCompositeOperation = value;
+
+		}
+
+	}
+
+	function setLineWidth( value ) {
+
+		if ( _contextLineWidth != value ) {
+
+			_context.lineWidth = _contextLineWidth = value;
+
+		}
+
+	}
+
+	function setStrokeStyle( value ) {
+
+		if ( _contextStrokeStyle != value ) {
+
+			_context.strokeStyle = _contextStrokeStyle  = value;
+
+		}
+
+	}
+
+	function setFillStyle( value ) {
+
+		if ( _contextFillStyle != value ) {
+
+			_context.fillStyle = _contextFillStyle = value;
+
+		}
 
 	}