|
@@ -1,159 +1,159 @@
|
|
-// ThreeDebug.js r29 - http://github.com/mrdoob/three.js
|
|
|
|
-var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
|
|
|
|
-THREE.Color.prototype={setRGB:function(a,c,f){this.r=a;this.g=c;this.b=f;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+
|
|
|
|
-","+~~(this.g*255)+","+~~(this.b*255)+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0};
|
|
|
|
-THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
|
|
|
|
-this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,f){this.x=a||0;this.y=c||0;this.z=f||0};
|
|
|
|
-THREE.Vector3.prototype={set:function(a,c,f){this.x=a;this.y=c;this.z=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
|
|
|
|
-cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,f=this.y,b=this.z;this.x=f*a.z-b*a.y;this.y=b*a.x-c*a.z;this.z=c*a.y-f*a.x;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},
|
|
|
|
-distanceToSquared:function(a){var c=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return c*c+f*f+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){this.length()>0?this.multiplyScalar(1/this.length()):this.multiplyScalar(0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<
|
|
|
|
-1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,c,f,b){this.x=a||0;this.y=c||0;this.z=f||0;this.w=b||1};
|
|
|
|
-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;a<c;a++){f=b[a];if(f instanceof THREE.Mesh)d=d.concat(this.intersectObject(f))}d.sort(function(j,n){return j.distance-n.distance});return d},intersectObject:function(a){function c(x,h,B,q){q=q.clone().subSelf(h);B=B.clone().subSelf(h);var D=x.clone().subSelf(h);x=q.dot(q);h=q.dot(B);q=q.dot(D);var u=B.dot(B);B=B.dot(D);D=1/(x*u-h*h);u=(u*q-h*B)*D;x=(x*B-h*q)*D;return u>0&&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<b;f++){d=r.faces[f];i=this.origin.clone();l=this.direction.clone();j=a.matrix.transform(o[d.a].position.clone());n=a.matrix.transform(o[d.b].position.clone());t=a.matrix.transform(o[d.c].position.clone());e=d instanceof THREE.Face4?a.matrix.transform(o[d.d].position.clone()):null;g=a.matrixRotation.transform(d.normal.clone());m=l.dot(g);if(m<0){g=g.dot((new THREE.Vector3).sub(j,i))/m;i=i.addSelf(l.multiplyScalar(g));if(d instanceof THREE.Face3){if(c(i,
|
|
|
|
-j,n,t)){d={distance:this.origin.distanceTo(i),point:i,face:d,object:a};p.push(d)}}else if(d instanceof THREE.Face4)if(c(i,j,n,e)||c(i,n,t,e)){d={distance:this.origin.distanceTo(i),point:i,face:d,object:a};p.push(d)}}}return p}};
|
|
|
|
-THREE.Rectangle=function(){function a(){j=b-c;n=d-f}var c,f,b,d,j,n,t=true;this.getX=function(){return c};this.getY=function(){return f};this.getWidth=function(){return j};this.getHeight=function(){return n};this.getLeft=function(){return c};this.getTop=function(){return f};this.getRight=function(){return b};this.getBottom=function(){return d};this.set=function(e,g,m,i){t=false;c=e;f=g;b=m;d=i;a()};this.addPoint=function(e,g){if(t){t=false;c=e;f=g;b=e;d=g}else{c=Math.min(c,e);f=Math.min(f,g);b=Math.max(b,
|
|
|
|
-e);d=Math.max(d,g)}a()};this.addRectangle=function(e){if(t){t=false;c=e.getLeft();f=e.getTop();b=e.getRight();d=e.getBottom()}else{c=Math.min(c,e.getLeft());f=Math.min(f,e.getTop());b=Math.max(b,e.getRight());d=Math.max(d,e.getBottom())}a()};this.inflate=function(e){c-=e;f-=e;b+=e;d+=e;a()};this.minSelf=function(e){c=Math.max(c,e.getLeft());f=Math.max(f,e.getTop());b=Math.min(b,e.getRight());d=Math.min(d,e.getBottom());a()};this.instersects=function(e){return Math.min(b,e.getRight())-Math.max(c,e.getLeft())>=
|
|
|
|
-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.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*
|
|
|
|
-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.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.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;a<c;a++){f=this.faces[a];f.centroid.set(0,0,0);if(f instanceof THREE.Face3){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);f.centroid.divideScalar(3)}else if(f instanceof THREE.Face4){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);
|
|
|
|
-f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeNormals:function(a){var c,f,b,d,j,n,t=new THREE.Vector3,e=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++){j=this.vertices[b];j.normal.set(0,0,0)}b=0;for(d=this.faces.length;b<d;b++){j=this.faces[b];if(a&&j.vertexNormals.length){t.set(0,0,0);c=0;for(f=j.normal.length;c<f;c++)t.addSelf(j.vertexNormals[c]);t.divideScalar(3)}else{c=this.vertices[j.a];f=this.vertices[j.b];n=this.vertices[j.c];t.sub(n.position,
|
|
|
|
-f.position);e.sub(c.position,f.position);t.crossSelf(e)}t.isZero()||t.normalize();j.normal.copy(t)}},computeBoundingBox:function(){if(this.vertices.length>0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var a=1,c=this.vertices.length;a<c;a++){vertex=this.vertices[a];if(vertex.position.x<this.bbox.x[0])this.bbox.x[0]=vertex.position.x;else if(vertex.position.x>
|
|
|
|
-this.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.y<this.bbox.y[0])this.bbox.y[0]=vertex.position.y;else if(vertex.position.y>this.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.z<this.bbox.z[0])this.bbox.z[0]=vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},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;
|
|
|
|
-THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
|
|
|
|
-THREE.Object3D=function(){this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixTranslation=new THREE.Matrix4;this.matrixRotation=new THREE.Matrix4;this.matrixScale=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.matrixRotation=THREE.Matrix4.rotationXMatrix(this.rotation.x);
|
|
|
|
-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;c<f;c++)m[c]==undefined?i.push("undefined"):i.push(m[c].toString());return i.join("_")}var c,f,b,d,j,n,t,e,g={};b=0;for(d=this.geometry.faces.length;b<d;b++){j=this.geometry.faces[b];n=j.material;t=a(n);if(g[t]==undefined)g[t]={hash:t,counter:0};e=g[t].hash+"_"+g[t].counter;if(this.materialFaceGroup[e]==undefined)this.materialFaceGroup[e]={faces:[],material:n,vertices:0};j=j instanceof THREE.Face3?3:4;if(this.materialFaceGroup[e].vertices+
|
|
|
|
-j>65535){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;a<c;a++){d=this.geometry.uvs[a];f=0;for(b=d.length;f<b;f++){if(d[f].u!=1)d[f].u-=Math.floor(d[f].u);if(d[f].v!=1)d[f].v-=Math.floor(d[f].v)}}};THREE.FlatShading=0;
|
|
|
|
-THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
|
|
|
|
-THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth}this.toString=function(){return"THREE.LineBasicMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+
|
|
|
|
-this.linewidth+"<br/>)"}};
|
|
|
|
-THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(15658734);this.env_map=this.map=null;this.opacity=this.reflectivity=1;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.opacity!==undefined)this.opacity=
|
|
|
|
-a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth}this.toString=function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>reflectivity: "+this.reflectivity+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+
|
|
|
|
-this.wireframe_linewidth+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
|
|
|
|
-THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(15658734);this.env_map=this.map=null;this.opacity=this.reflectivity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;
|
|
|
|
-if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth}this.toString=function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>reflectivity: "+this.reflectivity+"<br/>opacity: "+this.opacity+
|
|
|
|
-"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_size: "+this.wireframe_linewidth+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
|
|
|
|
-THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(15658734);this.map=null;this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.env_map=this.specular_map=null;this.shininess=30;this.opacity=this.reflectivity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.map!==undefined)this.map=
|
|
|
|
-a.map;if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.specular_map!==undefined)this.specular_map=a.specular_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.shininess!==undefined)this.shininess=a.shininess;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=
|
|
|
|
-a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth}this.toString=function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>specular_map: "+this.specular_map+"<br/>shininess: "+this.shininess+"<br/>reflectivity: "+this.reflectivity+"<br/>opacity: "+this.opacity+
|
|
|
|
-"<br/>shading: "+this.shading+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>"+ +")"}};THREE.MeshPhongMaterialCounter={value:0};
|
|
|
|
-THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1E3;this.opacity=1;this.blending=THREE.NormalBlending;if(a){if(a.near!==undefined)this.near=a.near;if(a.far!==undefined)this.far=a.far;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=this.far-this.near;this.toString=function(){return"THREE.MeshDepthMaterial"}};
|
|
|
|
-THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){this.toString=function(){return"THREE.MeshFaceMaterial"}};
|
|
|
|
-THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+
|
|
|
|
-this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
|
|
|
|
-THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c){this.image=a;this.mapping=c?c:THREE.UVMapping;this.toString=function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>mapping: "+this.mapping+"<br/>)"}};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 (<br/>image: "+this.image+"<br/>mapping: "+this.mapping+"<br/>)"}};
|
|
|
|
-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(D<q)q=false;else{h.lerpSelf(B,q);B.lerpSelf(h,1-D);q=true}}return q}var c=null,f,b,d=[],j,n,t=[],e,g,m=[],i,l,r=[],o=new THREE.Vector4,p=new THREE.Matrix4,x=new THREE.Matrix4;this.projectScene=function(h,
|
|
|
|
-B){var q,D,u,L,v,s,y,M,X,F,Y=new THREE.Vector4,Z=new THREE.Vector4,Q,z,N,K;c=[];l=g=n=b=0;B.autoUpdateMatrix&&B.updateMatrix();p.multiply(B.projectionMatrix,B.matrix);v=h.objects;q=0;for(D=v.length;q<D;q++){s=v[q];y=s.matrix;s.autoUpdateMatrix&&s.updateMatrix();if(s instanceof THREE.Mesh){x.multiply(p,y);M=s.geometry.vertices;u=0;for(L=M.length;u<L;u++){X=M[u];F=X.positionScreen;F.copy(X.position);x.transform(F);F.multiplyScalar(1/F.w);X.__visible=F.z>0&&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;u<L;u++){X=M[u];X.positionScreen.copy(X.position);x.transform(X.positionScreen)}u=
|
|
|
|
-1;for(L=M.length;u<L;u++){y=M[u];X=M[u-1];Y.copy(y.positionScreen);Z.copy(X.positionScreen);if(a(Y,Z)){Y.multiplyScalar(1/Y.w);Z.multiplyScalar(1/Z.w);e=m[g]=m[g]||new THREE.RenderableLine;e.v1.positionScreen.copy(Y);e.v2.positionScreen.copy(Z);e.z=Math.max(Y.z,Z.z);e.material=s.material;c.push(e);g++}}}else if(s instanceof THREE.Particle){o.set(s.position.x,s.position.y,s.position.z,1);p.transform(o);o.z/=o.w;if(o.z>0&&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;e<g;e++){l=a[e];if(l instanceof THREE.RenderableParticle){o=l.x*d+d;p=l.y*j+j;m=0;for(i=l.material.length;m<i;m++){r=l.material[m];if(r instanceof THREE.ParticleDOMMaterial){r=r.domElement;r.style.left=o+"px";r.style.top=p+"px"}}}}}};
|
|
|
|
-THREE.CanvasRenderer=function(){function a(G,O,I){var J,k,H;lights=G.lights;G=0;for(J=lights.length;G<J;G++){k=lights[G];H=k.color;if(k instanceof THREE.DirectionalLight){k=O.normalWorld.dot(k.position)*k.intensity;if(k>0){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;I<J;I++){k=
|
|
|
|
-S[I];H=k.color;if(k instanceof THREE.AmbientLight){ga.r+=H.r;ga.g+=H.g;ga.b+=H.b}else if(k instanceof THREE.DirectionalLight){xa.r+=H.r;xa.g+=H.g;xa.b+=H.b}else if(k instanceof THREE.PointLight){ya.r+=H.r;ya.g+=H.g;ya.b+=H.b}}}I=0;for(J=m.length;I<J;I++){k=m[I];aa.empty();if(k instanceof THREE.RenderableParticle){v=k;v.x*=p;v.y*=x;H=0;for(S=k.material.length;H<S;H++)if(E=k.material[H]){w=v;T=k;E=E;var ca=void 0,ma=void 0,va=void 0,wa=void 0,za=void 0,Ja=void 0,Ga=void 0,Ka=void 0,La=void 0;if(E.opacity!=
|
|
|
|
-B)h.globalAlpha=B=E.opacity;E.blending!=q&&n(E.blending);if(E instanceof THREE.ParticleBasicMaterial){Ga=E.bitmap;Ka=Ga.width/2;La=Ga.height/2;va=T.scale.x*p;wa=T.scale.y*x;ca=va*Ka;ma=wa*La;za=E.offset.x*va;Ja=E.offset.y*wa;aa.set(w.x+za-ca,w.y+Ja-ma,w.x+za+ca,w.y+Ja+ma);if(oa.instersects(aa)){h.save();h.translate(w.x,w.y);h.rotate(-T.rotation);h.scale(va,-wa);h.translate(-Ka+E.offset.x,-La-E.offset.y);h.drawImage(Ga,0,0);h.restore();h.beginPath();h.moveTo(w.x-10,w.y);h.lineTo(w.x+10,w.y);h.moveTo(w.x,
|
|
|
|
-w.y-10);h.lineTo(w.x,w.y+10);h.closePath();h.strokeStyle="rgb(255,255,0)";h.stroke()}}else if(E instanceof THREE.ParticleCircleMaterial){if(Da){ba.r=ga.r+xa.r+ya.r;ba.g=ga.g+xa.g+ya.g;ba.b=ga.b+xa.b+ya.b;R.r=E.color.r*ba.r;R.g=E.color.g*ba.g;R.b=E.color.b*ba.b;R.updateStyleString()}else R.__styleString=E.color.__styleString;ca=T.scale.x*p;ma=T.scale.y*x;aa.set(w.x-ca,w.y-ma,w.x+ca,w.y+ma);if(oa.instersects(aa)){if(u!==R.__styleString)h.fillStyle=u=R.__styleString;h.save();h.translate(w.x,w.y);h.rotate(-T.rotation);
|
|
|
|
-h.scale(ca,ma);h.beginPath();h.arc(0,0,1,0,Ma,true);h.closePath();h.fill();h.restore()}}}}else if(k instanceof THREE.RenderableLine){v=k.v1;s=k.v2;v.positionScreen.x*=p;v.positionScreen.y*=x;s.positionScreen.x*=p;s.positionScreen.y*=x;aa.addPoint(v.positionScreen.x,v.positionScreen.y);aa.addPoint(s.positionScreen.x,s.positionScreen.y);if(!oa.instersects(aa))continue;H=0;for(S=k.material.length;H<S;)if(E=k.material[H++]){w=v;T=s;E=E;if(E.opacity!=B)h.globalAlpha=B=E.opacity;E.blending!=q&&n(E.blending);
|
|
|
|
-h.beginPath();h.moveTo(w.positionScreen.x,w.positionScreen.y);h.lineTo(T.positionScreen.x,T.positionScreen.y);h.closePath();if(E instanceof THREE.LineBasicMaterial){R.__styleString=E.color.__styleString;if(L!=E.linewidth)h.lineWidth=L=E.linewidth;if(D!=R.__styleString)h.strokeStyle=D=R.__styleString;h.stroke();aa.inflate(E.linewidth*2)}}}else if(k instanceof THREE.RenderableFace3){v=k.v1;s=k.v2;y=k.v3;v.positionScreen.x*=p;v.positionScreen.y*=x;s.positionScreen.x*=p;s.positionScreen.y*=x;y.positionScreen.x*=
|
|
|
|
-p;y.positionScreen.y*=x;if(k.overdraw){g(v.positionScreen,s.positionScreen);g(s.positionScreen,y.positionScreen);g(y.positionScreen,v.positionScreen)}aa.addPoint(v.positionScreen.x,v.positionScreen.y);aa.addPoint(s.positionScreen.x,s.positionScreen.y);aa.addPoint(y.positionScreen.x,y.positionScreen.y);if(!oa.instersects(aa))continue;H=0;for(S=k.meshMaterial.length;H<S;){E=k.meshMaterial[H++];if(E instanceof THREE.MeshFaceMaterial){w=0;for(T=k.faceMaterial.length;w<T;)(E=k.faceMaterial[w++])&&c(v,
|
|
|
|
-s,y,k,E,G)}else E&&c(v,s,y,k,E,G)}}else if(k instanceof THREE.RenderableFace4){v=k.v1;s=k.v2;y=k.v3;M=k.v4;v.positionScreen.x*=p;v.positionScreen.y*=x;s.positionScreen.x*=p;s.positionScreen.y*=x;y.positionScreen.x*=p;y.positionScreen.y*=x;M.positionScreen.x*=p;M.positionScreen.y*=x;X.positionScreen.copy(s.positionScreen);F.positionScreen.copy(M.positionScreen);if(k.overdraw){g(v.positionScreen,s.positionScreen);g(s.positionScreen,M.positionScreen);g(M.positionScreen,v.positionScreen)}if(k.overdraw){g(y.positionScreen,
|
|
|
|
-X.positionScreen);g(y.positionScreen,F.positionScreen)}aa.addPoint(v.positionScreen.x,v.positionScreen.y);aa.addPoint(s.positionScreen.x,s.positionScreen.y);aa.addPoint(y.positionScreen.x,y.positionScreen.y);aa.addPoint(M.positionScreen.x,M.positionScreen.y);if(!oa.instersects(aa))continue;H=0;for(S=k.meshMaterial.length;H<S;){E=k.meshMaterial[H++];if(E instanceof THREE.MeshFaceMaterial){w=0;for(T=k.faceMaterial.length;w<T;)(E=k.faceMaterial[w++])&&f(v,s,y,M,X,F,k,E,G)}else E&&f(v,s,y,M,X,F,k,E,G)}}ka.addRectangle(aa)}h.lineWidth=
|
|
|
|
-1;h.strokeStyle="rgba( 255, 0, 0, 0.5 )";h.strokeRect(ka.getX(),ka.getY(),ka.getWidth(),ka.getHeight());h.setTransform(1,0,0,1,0,0)}};
|
|
|
|
-THREE.SVGRenderer=function(){function a(z,N,K){var V,C,A,W;V=0;for(C=z.lights.length;V<C;V++){A=z.lights[V];if(A instanceof THREE.DirectionalLight){W=N.normalWorld.dot(A.position)*A.intensity;if(W>0){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<V;K++){C=P[K];A=C.color;if(C instanceof THREE.AmbientLight){u.r+=A.r;u.g+=A.g;u.b+=A.b}else if(C instanceof THREE.DirectionalLight){L.r+=A.r;L.g+=A.g;L.b+=A.b}else if(C instanceof THREE.PointLight){v.r+=A.r;v.g+=A.g;v.b+=A.b}}}K=0;for(V=j.length;K<V;K++){P=j[K];h.empty();if(P instanceof THREE.RenderableParticle){l=P;l.x*=m;l.y*=-i;C=0;for(A=P.material.length;C<A;C++)if(U=
|
|
|
|
-P.material[C]){W=l;pa=P;U=U;var ha=Z++;if(X[ha]==null){X[ha]=document.createElementNS("http://www.w3.org/2000/svg","circle");Q==0&&X[ha].setAttribute("shape-rendering","crispEdges")}F=X[ha];F.setAttribute("cx",W.x);F.setAttribute("cy",W.y);F.setAttribute("r",pa.scale.x*m);if(U instanceof THREE.ParticleCircleMaterial){if(B){D.r=u.r+L.r+v.r;D.g=u.g+L.g+v.g;D.b=u.b+L.b+v.b;q.r=U.color.r*D.r;q.g=U.color.g*D.g;q.b=U.color.b*D.b;q.updateStyleString()}else q=U.color;F.setAttribute("style","fill: "+q.__styleString)}t.appendChild(F)}}else if(P instanceof
|
|
|
|
-THREE.RenderableFace3){l=P.v1;r=P.v2;o=P.v3;l.positionScreen.x*=m;l.positionScreen.y*=-i;r.positionScreen.x*=m;r.positionScreen.y*=-i;o.positionScreen.x*=m;o.positionScreen.y*=-i;h.addPoint(l.positionScreen.x,l.positionScreen.y);h.addPoint(r.positionScreen.x,r.positionScreen.y);h.addPoint(o.positionScreen.x,o.positionScreen.y);if(x.instersects(h)){C=0;for(A=P.meshMaterial.length;C<A;){U=P.meshMaterial[C++];if(U instanceof THREE.MeshFaceMaterial){W=0;for(pa=P.faceMaterial.length;W<pa;)(U=P.faceMaterial[W++])&&
|
|
|
|
-c(l,r,o,P,U,z)}else U&&c(l,r,o,P,U,z)}}}else if(P instanceof THREE.RenderableFace4){l=P.v1;r=P.v2;o=P.v3;p=P.v4;l.positionScreen.x*=m;l.positionScreen.y*=-i;r.positionScreen.x*=m;r.positionScreen.y*=-i;o.positionScreen.x*=m;o.positionScreen.y*=-i;p.positionScreen.x*=m;p.positionScreen.y*=-i;h.addPoint(l.positionScreen.x,l.positionScreen.y);h.addPoint(r.positionScreen.x,r.positionScreen.y);h.addPoint(o.positionScreen.x,o.positionScreen.y);h.addPoint(p.positionScreen.x,p.positionScreen.y);if(x.instersects(h)){C=
|
|
|
|
-0;for(A=P.meshMaterial.length;C<A;){U=P.meshMaterial[C++];if(U instanceof THREE.MeshFaceMaterial){W=0;for(pa=P.faceMaterial.length;W<pa;)(U=P.faceMaterial[W++])&&f(l,r,o,p,P,U,z)}else U&&f(l,r,o,p,P,U,z)}}}}}};
|
|
|
|
-THREE.WebGLRenderer=function(a){function c(e,g){var m;if(e=="fragment")m=b.createShader(b.FRAGMENT_SHADER);else if(e=="vertex")m=b.createShader(b.VERTEX_SHADER);b.shaderSource(m,g);b.compileShader(m);if(!b.getShaderParameter(m,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(m));return null}return m}var f=document.createElement("canvas"),b,d,j=new THREE.Matrix4,n;a=function(e,g){if(e){var m,i,l,r=pointLights=maxDirLights=maxPointLights=0;m=0;for(i=e.lights.length;m<i;m++){l=e.lights[m];l instanceof THREE.DirectionalLight&&
|
|
|
|
-r++;l instanceof THREE.PointLight&&pointLights++}if(pointLights+r<=g){maxDirLights=r;maxPointLights=pointLights}else{maxDirLights=Math.ceil(g*r/(pointLights+r));maxPointLights=g-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:g-1}}(a,5);this.domElement=f;this.autoClear=true;try{b=f.getContext("experimental-webgl",{antialias:true})}catch(t){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);
|
|
|
|
-b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(0,0,0,0);(function(e,g){d=b.createProgram();b.attachShader(d,c("fragment",["#ifdef GL_ES\nprecision highp float;\n#endif",e?"#define MAX_DIR_LIGHTS "+e:"",g?"#define MAX_POINT_LIGHTS "+g:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\nuniform float m2Near;\nuniform float mFarPlusNear;\nuniform float mFarMinusNear;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
|
|
|
|
-e?"uniform mat4 viewMatrix;":"",e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",g?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = mReflectivity * textureCube( tCube, vReflect );\n}\nif ( material == 4 ) { \ngl_FragColor = vec4( 0.5*normalize( vNormal ) + vec3(0.5, 0.5, 0.5), mOpacity );\n} else if ( material == 3 ) { \nfloat w = 0.5;\ngl_FragColor = vec4( w, w, w, mOpacity );\n} else if ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
|
|
|
|
-g?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",g?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",g?"for( int i = 0; i < pointLightNumber; i++ ) {":"",g?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",g?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",g?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",g?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",g?"float pointSpecularWeight = 0.0;":"",g?"if ( pointDotNormalHalf >= 0.0 )":
|
|
|
|
-"",g?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",g?"pointDiffuse += mColor * pointDiffuseWeight;":"",g?"pointSpecular += mSpecular * pointSpecularWeight;":"",g?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
|
|
|
|
-"",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",g?"totalLight += pointDiffuse + pointSpecular;":
|
|
|
|
-"","gl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n} else if ( material == 1 ) {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}"].join("\n")));b.attachShader(d,c("vertex",[e?"#define MAX_DIR_LIGHTS "+e:"",g?"#define MAX_POINT_LIGHTS "+g:"","attribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nuniform vec3 cameraPosition;\nuniform bool enableLighting;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",
|
|
|
|
-e?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",g?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",g?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","uniform mat4 objMatrix;\nuniform mat4 viewMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat3 normalMatrix;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",g?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":
|
|
|
|
-"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nvoid main(void) {\nvec4 mPosition = objMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objMatrix[0].xyz, objMatrix[1].xyz, objMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
|
|
|
|
-e?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",e?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",e?"}":"",g?"for( int i = 0; i < pointLightNumber; i++ ) {":"",g?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",g?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
|
|
|
|
-"",g?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",g?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",g?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")));b.linkProgram(d);b.getProgramParameter(d,b.LINK_STATUS)||alert("Could not initialise shaders");b.useProgram(d);d.viewMatrix=b.getUniformLocation(d,
|
|
|
|
-"viewMatrix");d.modelViewMatrix=b.getUniformLocation(d,"modelViewMatrix");d.projectionMatrix=b.getUniformLocation(d,"projectionMatrix");d.normalMatrix=b.getUniformLocation(d,"normalMatrix");d.objMatrix=b.getUniformLocation(d,"objMatrix");d.cameraPosition=b.getUniformLocation(d,"cameraPosition");d.enableLighting=b.getUniformLocation(d,"enableLighting");d.ambientLightColor=b.getUniformLocation(d,"ambientLightColor");if(e){d.directionalLightNumber=b.getUniformLocation(d,"directionalLightNumber");d.directionalLightColor=
|
|
|
|
-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<m;g++){i=e.lights[g];if(i instanceof THREE.AmbientLight)r.push(i);else if(i instanceof THREE.DirectionalLight)p.push(i);else i instanceof THREE.PointLight&&o.push(i)}g=e=i=l=0;for(m=r.length;g<m;g++){e+=r[g].color.r;i+=r[g].color.g;l+=r[g].color.b}b.uniform3f(d.ambientLightColor,
|
|
|
|
-e,i,l);l=[];x=[];g=0;for(m=p.length;g<m;g++){i=p[g];l.push(i.color.r*i.intensity);l.push(i.color.g*i.intensity);l.push(i.color.b*i.intensity);x.push(i.position.x);x.push(i.position.y);x.push(i.position.z)}if(p.length){b.uniform1i(d.directionalLightNumber,p.length);b.uniform3fv(d.directionalLightDirection,x);b.uniform3fv(d.directionalLightColor,l)}l=[];x=[];g=0;for(m=o.length;g<m;g++){i=o[g];l.push(i.color.r*i.intensity);l.push(i.color.g*i.intensity);l.push(i.color.b*i.intensity);x.push(i.position.x);
|
|
|
|
-x.push(i.position.y);x.push(i.position.z)}if(o.length){b.uniform1i(d.pointLightNumber,o.length);b.uniform3fv(d.pointLightPosition,x);b.uniform3fv(d.pointLightColor,l)}};this.createBuffers=function(e,g){var m,i,l,r,o,p,x,h,B,q=e.materialFaceGroup[g],D=[],u=[],L=[],v=[],s=[],y=0,M=false;m=0;for(i=e.material.length;m<i;m++){meshMaterial=e.material[m];if(meshMaterial instanceof THREE.MeshFaceMaterial){o=0;for(p=q.material.length;o<p;o++)if(q.material[o]&&q.material[o].shading!=undefined&&q.material[o].shading==
|
|
|
|
-THREE.SmoothShading){M=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){M=true;break}if(M)break}m=0;for(i=q.faces.length;m<i;m++){l=q.faces[m];r=e.geometry.faces[l];o=r.vertexNormals;p=r.normal;l=e.geometry.uvs[l];if(r instanceof THREE.Face3){x=e.geometry.vertices[r.a].position;h=e.geometry.vertices[r.b].position;B=e.geometry.vertices[r.c].position;L.push(x.x,x.y,x.z);L.push(h.x,h.y,h.z);L.push(B.x,B.y,B.z);if(o.length==3&&M){v.push(o[0].x,
|
|
|
|
-o[0].y,o[0].z);v.push(o[1].x,o[1].y,o[1].z);v.push(o[2].x,o[2].y,o[2].z)}else{v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z)}if(l){s.push(l[0].u,l[0].v);s.push(l[1].u,l[1].v);s.push(l[2].u,l[2].v)}D.push(y,y+1,y+2);u.push(y,y+1);u.push(y,y+2);u.push(y+1,y+2);y+=3}else if(r instanceof THREE.Face4){x=e.geometry.vertices[r.a].position;h=e.geometry.vertices[r.b].position;B=e.geometry.vertices[r.c].position;r=e.geometry.vertices[r.d].position;L.push(x.x,x.y,x.z);L.push(h.x,h.y,h.z);L.push(B.x,
|
|
|
|
-B.y,B.z);L.push(r.x,r.y,r.z);if(o.length==4&&M){v.push(o[0].x,o[0].y,o[0].z);v.push(o[1].x,o[1].y,o[1].z);v.push(o[2].x,o[2].y,o[2].z);v.push(o[3].x,o[3].y,o[3].z)}else{v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z)}if(l){s.push(l[0].u,l[0].v);s.push(l[1].u,l[1].v);s.push(l[2].u,l[2].v);s.push(l[3].u,l[3].v)}D.push(y,y+1,y+2);D.push(y,y+2,y+3);u.push(y,y+1);u.push(y,y+2);u.push(y,y+3);u.push(y+1,y+2);u.push(y+2,y+3);y+=4}}if(L.length){q.__webGLVertexBuffer=b.createBuffer();
|
|
|
|
-b.bindBuffer(b.ARRAY_BUFFER,q.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,new Float32Array(L),b.STATIC_DRAW);q.__webGLNormalBuffer=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,q.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,new Float32Array(v),b.STATIC_DRAW);q.__webGLUVBuffer=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,q.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,new Float32Array(s),b.STATIC_DRAW);q.__webGLFaceBuffer=b.createBuffer();b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);
|
|
|
|
-b.bufferData(b.ELEMENT_ARRAY_BUFFER,new Uint16Array(D),b.STATIC_DRAW);q.__webGLLineBuffer=b.createBuffer();b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,new Uint16Array(u),b.STATIC_DRAW);q.__webGLFaceCount=D.length;q.__webGLLineCount=u.length}};this.renderBuffer=function(e,g){var m,i,l,r,o,p,x,h;if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshBasicMaterial){m=e.color;i=e.opacity;l=e.reflectivity;
|
|
|
|
-r=e.wireframe;o=e.wireframe_linewidth;x=e.map;h=e.env_map;b.uniform4f(d.mColor,m.r*i,m.g*i,m.b*i,i);b.uniform1f(d.mReflectivity,l)}if(e instanceof THREE.MeshNormalMaterial){i=e.opacity;b.uniform1f(d.mOpacity,i);b.uniform1i(d.material,4)}else if(e instanceof THREE.MeshDepthMaterial){i=e.opacity;r=e.wireframe;o=e.wireframe_linewidth;b.uniform1f(d.mOpacity,i);b.uniform1f(d.m2Near,e.__2near);b.uniform1f(d.mFarPlusNear,e.__farPlusNear);b.uniform1f(d.mFarMinusNear,e.__farMinusNear);b.uniform1i(d.material,
|
|
|
|
-3)}else if(e instanceof THREE.MeshPhongMaterial){m=e.ambient;l=e.specular;p=e.shininess;b.uniform4f(d.mAmbient,m.r,m.g,m.b,i);b.uniform4f(d.mSpecular,l.r,l.g,l.b,i);b.uniform1f(d.mShininess,p);b.uniform1i(d.material,2)}else if(e instanceof THREE.MeshLambertMaterial)b.uniform1i(d.material,1);else e instanceof THREE.MeshBasicMaterial&&b.uniform1i(d.material,0);if(x){if(!e.__webGLTexture&&e.map.image.loaded){e.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.texImage2D(b.TEXTURE_2D,
|
|
|
|
-0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.map.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.uniform1i(d.tMap,0);b.uniform1i(d.enableMap,1)}else b.uniform1i(d.enableMap,0);if(h){if(e.env_map&&e.env_map instanceof THREE.TextureCube&&e.env_map.image.length==6){if(!e.__webGLTextureCube&&
|
|
|
|
-!e.__cubeMapInitialized&&e.env_map.image.loadCount==6){e.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,e.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,
|
|
|
|
-e.env_map.image[0]);b.texImage2D(b.TEXTURE_CUBE_MAP_NEGATIVE_X,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[1]);b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_Y,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[2]);b.texImage2D(b.TEXTURE_CUBE_MAP_NEGATIVE_Y,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[3]);b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_Z,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[4]);b.texImage2D(b.TEXTURE_CUBE_MAP_NEGATIVE_Z,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[5]);b.generateMipmap(b.TEXTURE_CUBE_MAP);
|
|
|
|
-b.bindTexture(b.TEXTURE_CUBE_MAP,null);e.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_CUBE_MAP,e.__webGLTextureCube);b.uniform1i(d.tCube,1)}b.uniform1i(d.enableCubeMap,1)}else b.uniform1i(d.enableCubeMap,0);b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.vertexAttribPointer(d.position,3,b.FLOAT,false,0,0);b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.vertexAttribPointer(d.normal,3,b.FLOAT,false,0,0);if(x){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);
|
|
|
|
-b.enableVertexAttribArray(d.uv);b.vertexAttribPointer(d.uv,2,b.FLOAT,false,0,0)}else b.disableVertexAttribArray(d.uv);if(r){b.lineWidth(o);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.drawElements(b.LINES,g.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,g.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(e,g,m){var i,l,r,o,p;r=0;for(o=e.material.length;r<o;r++){i=e.material[r];if(i instanceof
|
|
|
|
-THREE.MeshFaceMaterial){i=0;for(l=g.material.length;i<l;i++)if((p=g.material[i])&&p.blending==m){this.setBlending(p.blending);this.renderBuffer(p,g)}}else if((p=i)&&p.blending==m){this.setBlending(p.blending);this.renderBuffer(p,g)}}};this.render=function(e,g){var m,i;this.initWebGLObjects(e);this.autoClear&&this.clear();g.autoUpdateMatrix&&g.updateMatrix();b.uniform3f(d.cameraPosition,g.position.x,g.position.y,g.position.z);this.setupLights(e);m=0;for(i=e.__webGLObjects.length;m<i;m++){webGLObject=
|
|
|
|
-e.__webGLObjects[m];this.setupMatrices(webGLObject.__object,g);this.renderPass(webGLObject.__object,webGLObject,THREE.NormalBlending)}m=0;for(i=e.__webGLObjects.length;m<i;m++){webGLObject=e.__webGLObjects[m];this.setupMatrices(webGLObject.__object,g);this.renderPass(webGLObject.__object,webGLObject,THREE.AdditiveBlending);this.renderPass(webGLObject.__object,webGLObject,THREE.SubtractiveBlending)}};this.initWebGLObjects=function(e){var g,m,i,l,r;if(!e.__webGLObjects)e.__webGLObjects=[];g=0;for(m=
|
|
|
|
-e.objects.length;g<m;g++){i=e.objects[g];if(i instanceof THREE.Mesh)for(l in i.materialFaceGroup){r=i.materialFaceGroup[l];if(!r.__webGLVertexBuffer){this.createBuffers(i,l);r.__object=i;e.__webGLObjects.push(r)}}}};this.setupMatrices=function(e,g){e.autoUpdateMatrix&&e.updateMatrix();j.multiply(g.matrix,e.matrix);d.viewMatrixArray=new Float32Array(g.matrix.flatten());d.modelViewMatrixArray=new Float32Array(j.flatten());d.projectionMatrixArray=new Float32Array(g.projectionMatrix.flatten());n=THREE.Matrix4.makeInvert3x3(j).transpose();
|
|
|
|
-d.normalMatrixArray=new Float32Array(n.m);b.uniformMatrix4fv(d.viewMatrix,false,d.viewMatrixArray);b.uniformMatrix4fv(d.modelViewMatrix,false,d.modelViewMatrixArray);b.uniformMatrix4fv(d.projectionMatrix,false,d.projectionMatrixArray);b.uniformMatrix3fv(d.normalMatrix,false,d.normalMatrixArray);b.uniformMatrix4fv(d.objMatrix,false,new Float32Array(e.matrix.flatten()))};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,
|
|
|
|
-b.ZERO);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,g){if(e){!g||g=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(e=="back")b.cullFace(b.BACK);else e=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)}};
|
|
|
|
-THREE.RenderableFace3=function(){this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.material=this.color=this.z=null};
|
|
|
|
-THREE.RenderableFace4=function(){this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.v4=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.material=this.color=this.z=null};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=this.color=null};
|
|
|
|
-THREE.RenderableLine=function(){this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=this.color=this.z=null};
|
|
|
|
|
|
+// ThreeDebug.js r29 - http://github.com/mrdoob/three.js
|
|
|
|
+var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
|
|
|
|
+THREE.Color.prototype={setRGB:function(a,c,f){this.r=a;this.g=c;this.b=f;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+
|
|
|
|
+","+~~(this.g*255)+","+~~(this.b*255)+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0};
|
|
|
|
+THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
|
|
|
|
+this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,f){this.x=a||0;this.y=c||0;this.z=f||0};
|
|
|
|
+THREE.Vector3.prototype={set:function(a,c,f){this.x=a;this.y=c;this.z=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
|
|
|
|
+cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,f=this.y,b=this.z;this.x=f*a.z-b*a.y;this.y=b*a.x-c*a.z;this.z=c*a.y-f*a.x;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},
|
|
|
|
+distanceToSquared:function(a){var c=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return c*c+f*f+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){this.length()>0?this.multiplyScalar(1/this.length()):this.multiplyScalar(0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<
|
|
|
|
+1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,c,f,b){this.x=a||0;this.y=c||0;this.z=f||0;this.w=b||1};
|
|
|
|
+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;a<c;a++){f=b[a];if(f instanceof THREE.Mesh)d=d.concat(this.intersectObject(f))}d.sort(function(j,n){return j.distance-n.distance});return d},intersectObject:function(a){function c(x,h,B,q){q=q.clone().subSelf(h);B=B.clone().subSelf(h);var D=x.clone().subSelf(h);x=q.dot(q);h=q.dot(B);q=q.dot(D);var u=B.dot(B);B=B.dot(D);D=1/(x*u-h*h);u=(u*q-h*B)*D;x=(x*B-h*q)*D;return u>0&&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<b;f++){d=r.faces[f];i=this.origin.clone();l=this.direction.clone();j=a.matrix.transform(o[d.a].position.clone());n=a.matrix.transform(o[d.b].position.clone());t=a.matrix.transform(o[d.c].position.clone());e=d instanceof THREE.Face4?a.matrix.transform(o[d.d].position.clone()):null;g=a.matrixRotation.transform(d.normal.clone());m=l.dot(g);if(m<0){g=g.dot((new THREE.Vector3).sub(j,i))/m;i=i.addSelf(l.multiplyScalar(g));if(d instanceof THREE.Face3){if(c(i,
|
|
|
|
+j,n,t)){d={distance:this.origin.distanceTo(i),point:i,face:d,object:a};p.push(d)}}else if(d instanceof THREE.Face4)if(c(i,j,n,e)||c(i,n,t,e)){d={distance:this.origin.distanceTo(i),point:i,face:d,object:a};p.push(d)}}}return p}};
|
|
|
|
+THREE.Rectangle=function(){function a(){j=b-c;n=d-f}var c,f,b,d,j,n,t=true;this.getX=function(){return c};this.getY=function(){return f};this.getWidth=function(){return j};this.getHeight=function(){return n};this.getLeft=function(){return c};this.getTop=function(){return f};this.getRight=function(){return b};this.getBottom=function(){return d};this.set=function(e,g,m,i){t=false;c=e;f=g;b=m;d=i;a()};this.addPoint=function(e,g){if(t){t=false;c=e;f=g;b=e;d=g}else{c=Math.min(c,e);f=Math.min(f,g);b=Math.max(b,
|
|
|
|
+e);d=Math.max(d,g)}a()};this.addRectangle=function(e){if(t){t=false;c=e.getLeft();f=e.getTop();b=e.getRight();d=e.getBottom()}else{c=Math.min(c,e.getLeft());f=Math.min(f,e.getTop());b=Math.max(b,e.getRight());d=Math.max(d,e.getBottom())}a()};this.inflate=function(e){c-=e;f-=e;b+=e;d+=e;a()};this.minSelf=function(e){c=Math.max(c,e.getLeft());f=Math.max(f,e.getTop());b=Math.min(b,e.getRight());d=Math.min(d,e.getBottom());a()};this.instersects=function(e){return Math.min(b,e.getRight())-Math.max(c,e.getLeft())>=
|
|
|
|
+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.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*
|
|
|
|
+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.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.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;a<c;a++){f=this.faces[a];f.centroid.set(0,0,0);if(f instanceof THREE.Face3){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);f.centroid.divideScalar(3)}else if(f instanceof THREE.Face4){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);
|
|
|
|
+f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeNormals:function(a){var c,f,b,d,j,n,t=new THREE.Vector3,e=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++){j=this.vertices[b];j.normal.set(0,0,0)}b=0;for(d=this.faces.length;b<d;b++){j=this.faces[b];if(a&&j.vertexNormals.length){t.set(0,0,0);c=0;for(f=j.normal.length;c<f;c++)t.addSelf(j.vertexNormals[c]);t.divideScalar(3)}else{c=this.vertices[j.a];f=this.vertices[j.b];n=this.vertices[j.c];t.sub(n.position,
|
|
|
|
+f.position);e.sub(c.position,f.position);t.crossSelf(e)}t.isZero()||t.normalize();j.normal.copy(t)}},computeBoundingBox:function(){if(this.vertices.length>0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var a=1,c=this.vertices.length;a<c;a++){vertex=this.vertices[a];if(vertex.position.x<this.bbox.x[0])this.bbox.x[0]=vertex.position.x;else if(vertex.position.x>
|
|
|
|
+this.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.y<this.bbox.y[0])this.bbox.y[0]=vertex.position.y;else if(vertex.position.y>this.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.z<this.bbox.z[0])this.bbox.z[0]=vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},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;
|
|
|
|
+THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
|
|
|
|
+THREE.Object3D=function(){this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixTranslation=new THREE.Matrix4;this.matrixRotation=new THREE.Matrix4;this.matrixScale=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.matrixRotation=THREE.Matrix4.rotationXMatrix(this.rotation.x);
|
|
|
|
+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;c<f;c++)m[c]==undefined?i.push("undefined"):i.push(m[c].toString());return i.join("_")}var c,f,b,d,j,n,t,e,g={};b=0;for(d=this.geometry.faces.length;b<d;b++){j=this.geometry.faces[b];n=j.material;t=a(n);if(g[t]==undefined)g[t]={hash:t,counter:0};e=g[t].hash+"_"+g[t].counter;if(this.materialFaceGroup[e]==undefined)this.materialFaceGroup[e]={faces:[],material:n,vertices:0};j=j instanceof THREE.Face3?3:4;if(this.materialFaceGroup[e].vertices+
|
|
|
|
+j>65535){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;a<c;a++){d=this.geometry.uvs[a];f=0;for(b=d.length;f<b;f++){if(d[f].u!=1)d[f].u-=Math.floor(d[f].u);if(d[f].v!=1)d[f].v-=Math.floor(d[f].v)}}};THREE.FlatShading=0;
|
|
|
|
+THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
|
|
|
|
+THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth}this.toString=function(){return"THREE.LineBasicMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+
|
|
|
|
+this.linewidth+"<br/>)"}};
|
|
|
|
+THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(15658734);this.env_map=this.map=null;this.opacity=this.reflectivity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.opacity!==
|
|
|
|
+undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth}this.toString=function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>reflectivity: "+this.reflectivity+"<br/>opacity: "+this.opacity+"<br/>blending: "+
|
|
|
|
+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
|
|
|
|
+THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(15658734);this.env_map=this.map=null;this.opacity=this.reflectivity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;
|
|
|
|
+if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth}this.toString=function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>reflectivity: "+this.reflectivity+"<br/>opacity: "+this.opacity+
|
|
|
|
+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_size: "+this.wireframe_linewidth+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
|
|
|
|
+THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(15658734);this.map=null;this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.env_map=this.specular_map=null;this.shininess=30;this.opacity=this.reflectivity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.map!==undefined)this.map=
|
|
|
|
+a.map;if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.specular_map!==undefined)this.specular_map=a.specular_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.shininess!==undefined)this.shininess=a.shininess;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=
|
|
|
|
+a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth}this.toString=function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>specular_map: "+this.specular_map+"<br/>shininess: "+this.shininess+"<br/>reflectivity: "+this.reflectivity+"<br/>opacity: "+this.opacity+
|
|
|
|
+"<br/>shading: "+this.shading+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>"+ +")"}};THREE.MeshPhongMaterialCounter={value:0};
|
|
|
|
+THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1E3;this.opacity=1;this.blending=THREE.NormalBlending;if(a){if(a.near!==undefined)this.near=a.near;if(a.far!==undefined)this.far=a.far;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=this.far-this.near;this.toString=function(){return"THREE.MeshDepthMaterial"}};
|
|
|
|
+THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){this.toString=function(){return"THREE.MeshFaceMaterial"}};
|
|
|
|
+THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+
|
|
|
|
+this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
|
|
|
|
+THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c){this.image=a;this.mapping=c?c:THREE.UVMapping;this.toString=function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>mapping: "+this.mapping+"<br/>)"}};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 (<br/>image: "+this.image+"<br/>mapping: "+this.mapping+"<br/>)"}};
|
|
|
|
+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(D<q)q=false;else{h.lerpSelf(B,q);B.lerpSelf(h,1-D);q=true}}return q}var c=null,f,b,d=[],j,n,t=[],e,g,m=[],i,l,r=[],o=new THREE.Vector4,p=new THREE.Matrix4,x=new THREE.Matrix4;this.projectScene=function(h,
|
|
|
|
+B){var q,D,u,L,v,s,y,M,X,F,Y=new THREE.Vector4,Z=new THREE.Vector4,Q,z,N,K;c=[];l=g=n=b=0;B.autoUpdateMatrix&&B.updateMatrix();p.multiply(B.projectionMatrix,B.matrix);v=h.objects;q=0;for(D=v.length;q<D;q++){s=v[q];y=s.matrix;s.autoUpdateMatrix&&s.updateMatrix();if(s instanceof THREE.Mesh){x.multiply(p,y);M=s.geometry.vertices;u=0;for(L=M.length;u<L;u++){X=M[u];F=X.positionScreen;F.copy(X.position);x.transform(F);F.multiplyScalar(1/F.w);X.__visible=F.z>0&&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;u<L;u++){X=M[u];X.positionScreen.copy(X.position);x.transform(X.positionScreen)}u=
|
|
|
|
+1;for(L=M.length;u<L;u++){y=M[u];X=M[u-1];Y.copy(y.positionScreen);Z.copy(X.positionScreen);if(a(Y,Z)){Y.multiplyScalar(1/Y.w);Z.multiplyScalar(1/Z.w);e=m[g]=m[g]||new THREE.RenderableLine;e.v1.positionScreen.copy(Y);e.v2.positionScreen.copy(Z);e.z=Math.max(Y.z,Z.z);e.material=s.material;c.push(e);g++}}}else if(s instanceof THREE.Particle){o.set(s.position.x,s.position.y,s.position.z,1);p.transform(o);o.z/=o.w;if(o.z>0&&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;e<g;e++){l=a[e];if(l instanceof THREE.RenderableParticle){o=l.x*d+d;p=l.y*j+j;m=0;for(i=l.material.length;m<i;m++){r=l.material[m];if(r instanceof THREE.ParticleDOMMaterial){r=r.domElement;r.style.left=o+"px";r.style.top=p+"px"}}}}}};
|
|
|
|
+THREE.CanvasRenderer=function(){function a(G,O,I){var J,k,H;lights=G.lights;G=0;for(J=lights.length;G<J;G++){k=lights[G];H=k.color;if(k instanceof THREE.DirectionalLight){k=O.normalWorld.dot(k.position)*k.intensity;if(k>0){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;I<J;I++){k=
|
|
|
|
+S[I];H=k.color;if(k instanceof THREE.AmbientLight){ga.r+=H.r;ga.g+=H.g;ga.b+=H.b}else if(k instanceof THREE.DirectionalLight){xa.r+=H.r;xa.g+=H.g;xa.b+=H.b}else if(k instanceof THREE.PointLight){ya.r+=H.r;ya.g+=H.g;ya.b+=H.b}}}I=0;for(J=m.length;I<J;I++){k=m[I];aa.empty();if(k instanceof THREE.RenderableParticle){v=k;v.x*=p;v.y*=x;H=0;for(S=k.material.length;H<S;H++)if(E=k.material[H]){w=v;T=k;E=E;var ca=void 0,ma=void 0,va=void 0,wa=void 0,za=void 0,Ja=void 0,Ga=void 0,Ka=void 0,La=void 0;if(E.opacity!=
|
|
|
|
+B)h.globalAlpha=B=E.opacity;E.blending!=q&&n(E.blending);if(E instanceof THREE.ParticleBasicMaterial){Ga=E.bitmap;Ka=Ga.width/2;La=Ga.height/2;va=T.scale.x*p;wa=T.scale.y*x;ca=va*Ka;ma=wa*La;za=E.offset.x*va;Ja=E.offset.y*wa;aa.set(w.x+za-ca,w.y+Ja-ma,w.x+za+ca,w.y+Ja+ma);if(oa.instersects(aa)){h.save();h.translate(w.x,w.y);h.rotate(-T.rotation);h.scale(va,-wa);h.translate(-Ka+E.offset.x,-La-E.offset.y);h.drawImage(Ga,0,0);h.restore();h.beginPath();h.moveTo(w.x-10,w.y);h.lineTo(w.x+10,w.y);h.moveTo(w.x,
|
|
|
|
+w.y-10);h.lineTo(w.x,w.y+10);h.closePath();h.strokeStyle="rgb(255,255,0)";h.stroke()}}else if(E instanceof THREE.ParticleCircleMaterial){if(Da){ba.r=ga.r+xa.r+ya.r;ba.g=ga.g+xa.g+ya.g;ba.b=ga.b+xa.b+ya.b;R.r=E.color.r*ba.r;R.g=E.color.g*ba.g;R.b=E.color.b*ba.b;R.updateStyleString()}else R.__styleString=E.color.__styleString;ca=T.scale.x*p;ma=T.scale.y*x;aa.set(w.x-ca,w.y-ma,w.x+ca,w.y+ma);if(oa.instersects(aa)){if(u!==R.__styleString)h.fillStyle=u=R.__styleString;h.save();h.translate(w.x,w.y);h.rotate(-T.rotation);
|
|
|
|
+h.scale(ca,ma);h.beginPath();h.arc(0,0,1,0,Ma,true);h.closePath();h.fill();h.restore()}}}}else if(k instanceof THREE.RenderableLine){v=k.v1;s=k.v2;v.positionScreen.x*=p;v.positionScreen.y*=x;s.positionScreen.x*=p;s.positionScreen.y*=x;aa.addPoint(v.positionScreen.x,v.positionScreen.y);aa.addPoint(s.positionScreen.x,s.positionScreen.y);if(!oa.instersects(aa))continue;H=0;for(S=k.material.length;H<S;)if(E=k.material[H++]){w=v;T=s;E=E;if(E.opacity!=B)h.globalAlpha=B=E.opacity;E.blending!=q&&n(E.blending);
|
|
|
|
+h.beginPath();h.moveTo(w.positionScreen.x,w.positionScreen.y);h.lineTo(T.positionScreen.x,T.positionScreen.y);h.closePath();if(E instanceof THREE.LineBasicMaterial){R.__styleString=E.color.__styleString;if(L!=E.linewidth)h.lineWidth=L=E.linewidth;if(D!=R.__styleString)h.strokeStyle=D=R.__styleString;h.stroke();aa.inflate(E.linewidth*2)}}}else if(k instanceof THREE.RenderableFace3){v=k.v1;s=k.v2;y=k.v3;v.positionScreen.x*=p;v.positionScreen.y*=x;s.positionScreen.x*=p;s.positionScreen.y*=x;y.positionScreen.x*=
|
|
|
|
+p;y.positionScreen.y*=x;if(k.overdraw){g(v.positionScreen,s.positionScreen);g(s.positionScreen,y.positionScreen);g(y.positionScreen,v.positionScreen)}aa.addPoint(v.positionScreen.x,v.positionScreen.y);aa.addPoint(s.positionScreen.x,s.positionScreen.y);aa.addPoint(y.positionScreen.x,y.positionScreen.y);if(!oa.instersects(aa))continue;H=0;for(S=k.meshMaterial.length;H<S;){E=k.meshMaterial[H++];if(E instanceof THREE.MeshFaceMaterial){w=0;for(T=k.faceMaterial.length;w<T;)(E=k.faceMaterial[w++])&&c(v,
|
|
|
|
+s,y,k,E,G)}else E&&c(v,s,y,k,E,G)}}else if(k instanceof THREE.RenderableFace4){v=k.v1;s=k.v2;y=k.v3;M=k.v4;v.positionScreen.x*=p;v.positionScreen.y*=x;s.positionScreen.x*=p;s.positionScreen.y*=x;y.positionScreen.x*=p;y.positionScreen.y*=x;M.positionScreen.x*=p;M.positionScreen.y*=x;X.positionScreen.copy(s.positionScreen);F.positionScreen.copy(M.positionScreen);if(k.overdraw){g(v.positionScreen,s.positionScreen);g(s.positionScreen,M.positionScreen);g(M.positionScreen,v.positionScreen)}if(k.overdraw){g(y.positionScreen,
|
|
|
|
+X.positionScreen);g(y.positionScreen,F.positionScreen)}aa.addPoint(v.positionScreen.x,v.positionScreen.y);aa.addPoint(s.positionScreen.x,s.positionScreen.y);aa.addPoint(y.positionScreen.x,y.positionScreen.y);aa.addPoint(M.positionScreen.x,M.positionScreen.y);if(!oa.instersects(aa))continue;H=0;for(S=k.meshMaterial.length;H<S;){E=k.meshMaterial[H++];if(E instanceof THREE.MeshFaceMaterial){w=0;for(T=k.faceMaterial.length;w<T;)(E=k.faceMaterial[w++])&&f(v,s,y,M,X,F,k,E,G)}else E&&f(v,s,y,M,X,F,k,E,G)}}ka.addRectangle(aa)}h.lineWidth=
|
|
|
|
+1;h.strokeStyle="rgba( 255, 0, 0, 0.5 )";h.strokeRect(ka.getX(),ka.getY(),ka.getWidth(),ka.getHeight());h.setTransform(1,0,0,1,0,0)}};
|
|
|
|
+THREE.SVGRenderer=function(){function a(z,N,K){var V,C,A,W;V=0;for(C=z.lights.length;V<C;V++){A=z.lights[V];if(A instanceof THREE.DirectionalLight){W=N.normalWorld.dot(A.position)*A.intensity;if(W>0){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<V;K++){C=P[K];A=C.color;if(C instanceof THREE.AmbientLight){u.r+=A.r;u.g+=A.g;u.b+=A.b}else if(C instanceof THREE.DirectionalLight){L.r+=A.r;L.g+=A.g;L.b+=A.b}else if(C instanceof THREE.PointLight){v.r+=A.r;v.g+=A.g;v.b+=A.b}}}K=0;for(V=j.length;K<V;K++){P=j[K];h.empty();if(P instanceof THREE.RenderableParticle){l=P;l.x*=m;l.y*=-i;C=0;for(A=P.material.length;C<A;C++)if(U=
|
|
|
|
+P.material[C]){W=l;pa=P;U=U;var ha=Z++;if(X[ha]==null){X[ha]=document.createElementNS("http://www.w3.org/2000/svg","circle");Q==0&&X[ha].setAttribute("shape-rendering","crispEdges")}F=X[ha];F.setAttribute("cx",W.x);F.setAttribute("cy",W.y);F.setAttribute("r",pa.scale.x*m);if(U instanceof THREE.ParticleCircleMaterial){if(B){D.r=u.r+L.r+v.r;D.g=u.g+L.g+v.g;D.b=u.b+L.b+v.b;q.r=U.color.r*D.r;q.g=U.color.g*D.g;q.b=U.color.b*D.b;q.updateStyleString()}else q=U.color;F.setAttribute("style","fill: "+q.__styleString)}t.appendChild(F)}}else if(P instanceof
|
|
|
|
+THREE.RenderableFace3){l=P.v1;r=P.v2;o=P.v3;l.positionScreen.x*=m;l.positionScreen.y*=-i;r.positionScreen.x*=m;r.positionScreen.y*=-i;o.positionScreen.x*=m;o.positionScreen.y*=-i;h.addPoint(l.positionScreen.x,l.positionScreen.y);h.addPoint(r.positionScreen.x,r.positionScreen.y);h.addPoint(o.positionScreen.x,o.positionScreen.y);if(x.instersects(h)){C=0;for(A=P.meshMaterial.length;C<A;){U=P.meshMaterial[C++];if(U instanceof THREE.MeshFaceMaterial){W=0;for(pa=P.faceMaterial.length;W<pa;)(U=P.faceMaterial[W++])&&
|
|
|
|
+c(l,r,o,P,U,z)}else U&&c(l,r,o,P,U,z)}}}else if(P instanceof THREE.RenderableFace4){l=P.v1;r=P.v2;o=P.v3;p=P.v4;l.positionScreen.x*=m;l.positionScreen.y*=-i;r.positionScreen.x*=m;r.positionScreen.y*=-i;o.positionScreen.x*=m;o.positionScreen.y*=-i;p.positionScreen.x*=m;p.positionScreen.y*=-i;h.addPoint(l.positionScreen.x,l.positionScreen.y);h.addPoint(r.positionScreen.x,r.positionScreen.y);h.addPoint(o.positionScreen.x,o.positionScreen.y);h.addPoint(p.positionScreen.x,p.positionScreen.y);if(x.instersects(h)){C=
|
|
|
|
+0;for(A=P.meshMaterial.length;C<A;){U=P.meshMaterial[C++];if(U instanceof THREE.MeshFaceMaterial){W=0;for(pa=P.faceMaterial.length;W<pa;)(U=P.faceMaterial[W++])&&f(l,r,o,p,P,U,z)}else U&&f(l,r,o,p,P,U,z)}}}}}};
|
|
|
|
+THREE.WebGLRenderer=function(a){function c(e,g){var m;if(e=="fragment")m=b.createShader(b.FRAGMENT_SHADER);else if(e=="vertex")m=b.createShader(b.VERTEX_SHADER);b.shaderSource(m,g);b.compileShader(m);if(!b.getShaderParameter(m,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(m));return null}return m}var f=document.createElement("canvas"),b,d,j=new THREE.Matrix4,n;a=function(e,g){if(e){var m,i,l,r=pointLights=maxDirLights=maxPointLights=0;m=0;for(i=e.lights.length;m<i;m++){l=e.lights[m];l instanceof THREE.DirectionalLight&&
|
|
|
|
+r++;l instanceof THREE.PointLight&&pointLights++}if(pointLights+r<=g){maxDirLights=r;maxPointLights=pointLights}else{maxDirLights=Math.ceil(g*r/(pointLights+r));maxPointLights=g-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:g-1}}(a,5);this.domElement=f;this.autoClear=true;try{b=f.getContext("experimental-webgl",{antialias:true})}catch(t){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);
|
|
|
|
+b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(0,0,0,0);(function(e,g){d=b.createProgram();b.attachShader(d,c("fragment",["#ifdef GL_ES\nprecision highp float;\n#endif",e?"#define MAX_DIR_LIGHTS "+e:"",g?"#define MAX_POINT_LIGHTS "+g:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\nuniform float m2Near;\nuniform float mFarPlusNear;\nuniform float mFarMinusNear;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
|
|
|
|
+e?"uniform mat4 viewMatrix;":"",e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",g?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = mReflectivity * textureCube( tCube, vReflect );\n}\nif ( material == 4 ) { \ngl_FragColor = vec4( 0.5*normalize( vNormal ) + vec3(0.5, 0.5, 0.5), mOpacity );\n} else if ( material == 3 ) { \nfloat w = 0.5;\ngl_FragColor = vec4( w, w, w, mOpacity );\n} else if ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
|
|
|
|
+g?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",g?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",g?"for( int i = 0; i < pointLightNumber; i++ ) {":"",g?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",g?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",g?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",g?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",g?"float pointSpecularWeight = 0.0;":"",g?"if ( pointDotNormalHalf >= 0.0 )":
|
|
|
|
+"",g?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",g?"pointDiffuse += mColor * pointDiffuseWeight;":"",g?"pointSpecular += mSpecular * pointSpecularWeight;":"",g?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
|
|
|
|
+"",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",g?"totalLight += pointDiffuse + pointSpecular;":
|
|
|
|
+"","gl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n} else if ( material == 1 ) {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}"].join("\n")));b.attachShader(d,c("vertex",[e?"#define MAX_DIR_LIGHTS "+e:"",g?"#define MAX_POINT_LIGHTS "+g:"","attribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nuniform vec3 cameraPosition;\nuniform bool enableLighting;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",
|
|
|
|
+e?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",g?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",g?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","uniform mat4 objMatrix;\nuniform mat4 viewMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat3 normalMatrix;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",g?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":
|
|
|
|
+"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nvoid main(void) {\nvec4 mPosition = objMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objMatrix[0].xyz, objMatrix[1].xyz, objMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
|
|
|
|
+e?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",e?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",e?"}":"",g?"for( int i = 0; i < pointLightNumber; i++ ) {":"",g?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",g?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
|
|
|
|
+"",g?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",g?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",g?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")));b.linkProgram(d);b.getProgramParameter(d,b.LINK_STATUS)||alert("Could not initialise shaders");b.useProgram(d);d.viewMatrix=b.getUniformLocation(d,
|
|
|
|
+"viewMatrix");d.modelViewMatrix=b.getUniformLocation(d,"modelViewMatrix");d.projectionMatrix=b.getUniformLocation(d,"projectionMatrix");d.normalMatrix=b.getUniformLocation(d,"normalMatrix");d.objMatrix=b.getUniformLocation(d,"objMatrix");d.cameraPosition=b.getUniformLocation(d,"cameraPosition");d.enableLighting=b.getUniformLocation(d,"enableLighting");d.ambientLightColor=b.getUniformLocation(d,"ambientLightColor");if(e){d.directionalLightNumber=b.getUniformLocation(d,"directionalLightNumber");d.directionalLightColor=
|
|
|
|
+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<m;g++){i=e.lights[g];if(i instanceof THREE.AmbientLight)r.push(i);else if(i instanceof THREE.DirectionalLight)p.push(i);else i instanceof THREE.PointLight&&o.push(i)}g=e=i=l=0;for(m=r.length;g<m;g++){e+=r[g].color.r;i+=r[g].color.g;l+=r[g].color.b}b.uniform3f(d.ambientLightColor,
|
|
|
|
+e,i,l);l=[];x=[];g=0;for(m=p.length;g<m;g++){i=p[g];l.push(i.color.r*i.intensity);l.push(i.color.g*i.intensity);l.push(i.color.b*i.intensity);x.push(i.position.x);x.push(i.position.y);x.push(i.position.z)}if(p.length){b.uniform1i(d.directionalLightNumber,p.length);b.uniform3fv(d.directionalLightDirection,x);b.uniform3fv(d.directionalLightColor,l)}l=[];x=[];g=0;for(m=o.length;g<m;g++){i=o[g];l.push(i.color.r*i.intensity);l.push(i.color.g*i.intensity);l.push(i.color.b*i.intensity);x.push(i.position.x);
|
|
|
|
+x.push(i.position.y);x.push(i.position.z)}if(o.length){b.uniform1i(d.pointLightNumber,o.length);b.uniform3fv(d.pointLightPosition,x);b.uniform3fv(d.pointLightColor,l)}};this.createBuffers=function(e,g){var m,i,l,r,o,p,x,h,B,q=e.materialFaceGroup[g],D=[],u=[],L=[],v=[],s=[],y=0,M=false;m=0;for(i=e.material.length;m<i;m++){meshMaterial=e.material[m];if(meshMaterial instanceof THREE.MeshFaceMaterial){o=0;for(p=q.material.length;o<p;o++)if(q.material[o]&&q.material[o].shading!=undefined&&q.material[o].shading==
|
|
|
|
+THREE.SmoothShading){M=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){M=true;break}if(M)break}m=0;for(i=q.faces.length;m<i;m++){l=q.faces[m];r=e.geometry.faces[l];o=r.vertexNormals;p=r.normal;l=e.geometry.uvs[l];if(r instanceof THREE.Face3){x=e.geometry.vertices[r.a].position;h=e.geometry.vertices[r.b].position;B=e.geometry.vertices[r.c].position;L.push(x.x,x.y,x.z);L.push(h.x,h.y,h.z);L.push(B.x,B.y,B.z);if(o.length==3&&M){v.push(o[0].x,
|
|
|
|
+o[0].y,o[0].z);v.push(o[1].x,o[1].y,o[1].z);v.push(o[2].x,o[2].y,o[2].z)}else{v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z)}if(l){s.push(l[0].u,l[0].v);s.push(l[1].u,l[1].v);s.push(l[2].u,l[2].v)}D.push(y,y+1,y+2);u.push(y,y+1);u.push(y,y+2);u.push(y+1,y+2);y+=3}else if(r instanceof THREE.Face4){x=e.geometry.vertices[r.a].position;h=e.geometry.vertices[r.b].position;B=e.geometry.vertices[r.c].position;r=e.geometry.vertices[r.d].position;L.push(x.x,x.y,x.z);L.push(h.x,h.y,h.z);L.push(B.x,
|
|
|
|
+B.y,B.z);L.push(r.x,r.y,r.z);if(o.length==4&&M){v.push(o[0].x,o[0].y,o[0].z);v.push(o[1].x,o[1].y,o[1].z);v.push(o[2].x,o[2].y,o[2].z);v.push(o[3].x,o[3].y,o[3].z)}else{v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z);v.push(p.x,p.y,p.z)}if(l){s.push(l[0].u,l[0].v);s.push(l[1].u,l[1].v);s.push(l[2].u,l[2].v);s.push(l[3].u,l[3].v)}D.push(y,y+1,y+2);D.push(y,y+2,y+3);u.push(y,y+1);u.push(y,y+2);u.push(y,y+3);u.push(y+1,y+2);u.push(y+2,y+3);y+=4}}if(L.length){q.__webGLVertexBuffer=b.createBuffer();
|
|
|
|
+b.bindBuffer(b.ARRAY_BUFFER,q.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,new Float32Array(L),b.STATIC_DRAW);q.__webGLNormalBuffer=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,q.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,new Float32Array(v),b.STATIC_DRAW);q.__webGLUVBuffer=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,q.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,new Float32Array(s),b.STATIC_DRAW);q.__webGLFaceBuffer=b.createBuffer();b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);
|
|
|
|
+b.bufferData(b.ELEMENT_ARRAY_BUFFER,new Uint16Array(D),b.STATIC_DRAW);q.__webGLLineBuffer=b.createBuffer();b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,new Uint16Array(u),b.STATIC_DRAW);q.__webGLFaceCount=D.length;q.__webGLLineCount=u.length}};this.renderBuffer=function(e,g){var m,i,l,r,o,p,x,h;if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshBasicMaterial){m=e.color;i=e.opacity;l=e.reflectivity;
|
|
|
|
+r=e.wireframe;o=e.wireframe_linewidth;x=e.map;h=e.env_map;b.uniform4f(d.mColor,m.r*i,m.g*i,m.b*i,i);b.uniform1f(d.mReflectivity,l)}if(e instanceof THREE.MeshNormalMaterial){i=e.opacity;b.uniform1f(d.mOpacity,i);b.uniform1i(d.material,4)}else if(e instanceof THREE.MeshDepthMaterial){i=e.opacity;r=e.wireframe;o=e.wireframe_linewidth;b.uniform1f(d.mOpacity,i);b.uniform1f(d.m2Near,e.__2near);b.uniform1f(d.mFarPlusNear,e.__farPlusNear);b.uniform1f(d.mFarMinusNear,e.__farMinusNear);b.uniform1i(d.material,
|
|
|
|
+3)}else if(e instanceof THREE.MeshPhongMaterial){m=e.ambient;l=e.specular;p=e.shininess;b.uniform4f(d.mAmbient,m.r,m.g,m.b,i);b.uniform4f(d.mSpecular,l.r,l.g,l.b,i);b.uniform1f(d.mShininess,p);b.uniform1i(d.material,2)}else if(e instanceof THREE.MeshLambertMaterial)b.uniform1i(d.material,1);else e instanceof THREE.MeshBasicMaterial&&b.uniform1i(d.material,0);if(x){if(!e.__webGLTexture&&e.map.image.loaded){e.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.texImage2D(b.TEXTURE_2D,
|
|
|
|
+0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.map.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.uniform1i(d.tMap,0);b.uniform1i(d.enableMap,1)}else b.uniform1i(d.enableMap,0);if(h){if(e.env_map&&e.env_map instanceof THREE.TextureCube&&e.env_map.image.length==6){if(!e.__webGLTextureCube&&
|
|
|
|
+!e.__cubeMapInitialized&&e.env_map.image.loadCount==6){e.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,e.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,
|
|
|
|
+e.env_map.image[0]);b.texImage2D(b.TEXTURE_CUBE_MAP_NEGATIVE_X,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[1]);b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_Y,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[2]);b.texImage2D(b.TEXTURE_CUBE_MAP_NEGATIVE_Y,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[3]);b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_Z,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[4]);b.texImage2D(b.TEXTURE_CUBE_MAP_NEGATIVE_Z,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[5]);b.generateMipmap(b.TEXTURE_CUBE_MAP);
|
|
|
|
+b.bindTexture(b.TEXTURE_CUBE_MAP,null);e.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_CUBE_MAP,e.__webGLTextureCube);b.uniform1i(d.tCube,1)}b.uniform1i(d.enableCubeMap,1)}else b.uniform1i(d.enableCubeMap,0);b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.vertexAttribPointer(d.position,3,b.FLOAT,false,0,0);b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.vertexAttribPointer(d.normal,3,b.FLOAT,false,0,0);if(x){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);
|
|
|
|
+b.enableVertexAttribArray(d.uv);b.vertexAttribPointer(d.uv,2,b.FLOAT,false,0,0)}else b.disableVertexAttribArray(d.uv);if(r){b.lineWidth(o);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.drawElements(b.LINES,g.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,g.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(e,g,m){var i,l,r,o,p;r=0;for(o=e.material.length;r<o;r++){i=e.material[r];if(i instanceof
|
|
|
|
+THREE.MeshFaceMaterial){i=0;for(l=g.material.length;i<l;i++)if((p=g.material[i])&&p.blending==m){this.setBlending(p.blending);this.renderBuffer(p,g)}}else if((p=i)&&p.blending==m){this.setBlending(p.blending);this.renderBuffer(p,g)}}};this.render=function(e,g){var m,i;this.initWebGLObjects(e);this.autoClear&&this.clear();g.autoUpdateMatrix&&g.updateMatrix();b.uniform3f(d.cameraPosition,g.position.x,g.position.y,g.position.z);this.setupLights(e);m=0;for(i=e.__webGLObjects.length;m<i;m++){webGLObject=
|
|
|
|
+e.__webGLObjects[m];this.setupMatrices(webGLObject.__object,g);this.renderPass(webGLObject.__object,webGLObject,THREE.NormalBlending)}m=0;for(i=e.__webGLObjects.length;m<i;m++){webGLObject=e.__webGLObjects[m];this.setupMatrices(webGLObject.__object,g);this.renderPass(webGLObject.__object,webGLObject,THREE.AdditiveBlending);this.renderPass(webGLObject.__object,webGLObject,THREE.SubtractiveBlending)}};this.initWebGLObjects=function(e){var g,m,i,l,r;if(!e.__webGLObjects)e.__webGLObjects=[];g=0;for(m=
|
|
|
|
+e.objects.length;g<m;g++){i=e.objects[g];if(i instanceof THREE.Mesh)for(l in i.materialFaceGroup){r=i.materialFaceGroup[l];if(!r.__webGLVertexBuffer){this.createBuffers(i,l);r.__object=i;e.__webGLObjects.push(r)}}}};this.setupMatrices=function(e,g){e.autoUpdateMatrix&&e.updateMatrix();j.multiply(g.matrix,e.matrix);d.viewMatrixArray=new Float32Array(g.matrix.flatten());d.modelViewMatrixArray=new Float32Array(j.flatten());d.projectionMatrixArray=new Float32Array(g.projectionMatrix.flatten());n=THREE.Matrix4.makeInvert3x3(j).transpose();
|
|
|
|
+d.normalMatrixArray=new Float32Array(n.m);b.uniformMatrix4fv(d.viewMatrix,false,d.viewMatrixArray);b.uniformMatrix4fv(d.modelViewMatrix,false,d.modelViewMatrixArray);b.uniformMatrix4fv(d.projectionMatrix,false,d.projectionMatrixArray);b.uniformMatrix3fv(d.normalMatrix,false,d.normalMatrixArray);b.uniformMatrix4fv(d.objMatrix,false,new Float32Array(e.matrix.flatten()))};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,
|
|
|
|
+b.ZERO);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,g){if(e){!g||g=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(e=="back")b.cullFace(b.BACK);else e=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)}};
|
|
|
|
+THREE.RenderableFace3=function(){this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.material=this.color=this.z=null};
|
|
|
|
+THREE.RenderableFace4=function(){this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.v4=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.material=this.color=this.z=null};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=this.color=null};
|
|
|
|
+THREE.RenderableLine=function(){this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=this.color=this.z=null};
|