From 98dc841aaba570cab4996e0d79bfb6a2bef3f0be Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Mon, 15 Nov 2010 01:17:41 +0000 Subject: [PATCH] Added MeshDepthMaterial. Optimised Particles projection in CanvasRenderer. --- build/Three.js | 2 +- build/ThreeDebug.js | 2 +- examples/camera_free.html | 3 +- examples/camera_orthographic.html | 2 +- examples/interactive_voxelpainter.html | 44 +--- examples/materials_depth.html | 263 ++++++++++++++++++++++++ examples/test.html | 3 +- src/core/Matrix4.js | 8 +- src/materials/Material.js | 4 - src/materials/{ => textures}/Texture.js | 4 + src/renderers/CanvasRenderer.js | 59 ++++-- src/renderers/Projector.js | 21 +- src/renderers/Renderer.js | 155 -------------- src/renderers/SVGRenderer.js | 6 + utils/build.py | 10 +- 15 files changed, 339 insertions(+), 247 deletions(-) create mode 100644 examples/materials_depth.html rename src/materials/{ => textures}/Texture.js (83%) delete mode 100755 src/renderers/Renderer.js diff --git a/build/Three.js b/build/Three.js index 96211cd4..3a5bed27 100644 --- a/build/Three.js +++ b/build/Three.js @@ -1,2 +1,2 @@ // Three.js r28 - http://github.com/mrdoob/three.js -var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};THREE.Color.prototype={setRGBA:function(f,e,c,d){this.r=f;this.g=e;this.b=c;this.a=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=(~~a).toString(16).length<8?255<<24^a:a;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},copyRGB:function(a){this.r=a.r;this.g=a.g;this.b=a.b},copyRGBA:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.a=a.a},multiplySelfRGB:function(a){this.r*=a.r;this.g*=a.g;this.b*=a.b},updateHex:function(){this.hex=~~(this.a*255)<<24^~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.a=(this.hex>>24&255)/255;this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgba("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+","+this.a+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", a: "+this.a+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(b,a){this.x=b.x-a.x;this.y=b.y-a.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,b){this.x=a||0;this.y=c||0;this.z=b||0};THREE.Vector3.prototype={set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;this.z=b.z+a.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(b,a){this.x=b.x-a.x;this.y=b.y-a.y;this.z=b.z-a.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},cross:function(b,a){this.x=b.y*a.z-b.z*a.y;this.y=b.z*a.x-b.x*a.z;this.z=b.x*a.y-b.y*a.x;return this},crossSelf:function(c){var b=this.x,a=this.y,d=this.z;this.x=a*c.z-d*c.y;this.y=d*c.x-b*c.z;this.z=b*c.y-a*c.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(d){var c=this.x-d.x,b=this.y-d.y,a=this.z-d.z;return c*c+b*b+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(){if(this.length()>0){this.multiplyScalar(1/this.length())}else{this.multiplyScalar(0)}return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){var a=0.0001;return(Math.abs(this.x)0)&&(I>0)&&(K+I<1)}}};THREE.Rectangle=function(){var e,g,h,d,a,c,f=true;function b(){a=h-e;c=d-g}this.getX=function(){return e};this.getY=function(){return g};this.getWidth=function(){return a};this.getHeight=function(){return c};this.getLeft=function(){return e};this.getTop=function(){return g};this.getRight=function(){return h};this.getBottom=function(){return d};this.set=function(l,k,j,i){f=false;e=l;g=k;h=j;d=i;b()};this.addPoint=function(i,j){if(f){f=false;e=i;g=j;h=i;d=j}else{e=Math.min(e,i);g=Math.min(g,j);h=Math.max(h,i);d=Math.max(d,j)}b()};this.addRectangle=function(i){if(f){f=false;e=i.getLeft();g=i.getTop();h=i.getRight();d=i.getBottom()}else{e=Math.min(e,i.getLeft());g=Math.min(g,i.getTop());h=Math.max(h,i.getRight());d=Math.max(d,i.getBottom())}b()};this.inflate=function(i){e-=i;g-=i;h+=i;d+=i;b()};this.minSelf=function(i){e=Math.max(e,i.getLeft());g=Math.max(g,i.getTop());h=Math.min(h,i.getRight());d=Math.min(d,i.getBottom());b()};this.instersects=function(i){return Math.min(h,i.getRight())-Math.max(e,i.getLeft())>=0&&Math.min(d,i.getBottom())-Math.max(g,i.getTop())>=0};this.empty=function(){f=true;e=0;g=0;h=0;d=0;b()};this.isEmpty=function(){return f};this.toString=function(){return"THREE.Rectangle ( left: "+e+", right: "+h+", top: "+g+", bottom: "+d+", width: "+a+", height: "+c+" )"}};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.n12=0;this.n13=0;this.n14=0;this.n21=0;this.n22=1;this.n23=0;this.n24=0;this.n31=0;this.n32=0;this.n33=1;this.n34=0;this.n41=0;this.n42=0;this.n43=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(d,c,b){var a=this._x,f=this._y,e=this._z;e.sub(d,c);e.normalize();a.cross(b,e);a.normalize();f.cross(e,a);f.normalize();this.n11=a.x;this.n12=a.y;this.n13=a.z;this.n14=-a.dot(d);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(d);this.n31=e.x;this.n32=e.y;this.n33=e.z;this.n34=-e.dot(d);this.n41=0;this.n42=0;this.n43=0;this.n44=1},transform:function(a){var d=a.x,c=a.y,b=a.z,e=a.w?a.w:1;a.x=this.n11*d+this.n12*c+this.n13*b+this.n14*e;a.y=this.n21*d+this.n22*c+this.n23*b+this.n24*e;a.z=this.n31*d+this.n32*c+this.n33*b+this.n34*e;e=this.n41*d+this.n42*c+this.n43*b+this.n44*e;if(a.w){a.w=e}else{a.x=a.x/e;a.y=a.y/e;a.z=a.z/e}return a},crossVector:function(b){var c=new THREE.Vector4();c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=(b.w)?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(d,c){this.n11=d.n11*c.n11+d.n12*c.n21+d.n13*c.n31+d.n14*c.n41;this.n12=d.n11*c.n12+d.n12*c.n22+d.n13*c.n32+d.n14*c.n42;this.n13=d.n11*c.n13+d.n12*c.n23+d.n13*c.n33+d.n14*c.n43;this.n14=d.n11*c.n14+d.n12*c.n24+d.n13*c.n34+d.n14*c.n44;this.n21=d.n21*c.n11+d.n22*c.n21+d.n23*c.n31+d.n24*c.n41;this.n22=d.n21*c.n12+d.n22*c.n22+d.n23*c.n32+d.n24*c.n42;this.n23=d.n21*c.n13+d.n22*c.n23+d.n23*c.n33+d.n24*c.n43;this.n24=d.n21*c.n14+d.n22*c.n24+d.n23*c.n34+d.n24*c.n44;this.n31=d.n31*c.n11+d.n32*c.n21+d.n33*c.n31+d.n34*c.n41;this.n32=d.n31*c.n12+d.n32*c.n22+d.n33*c.n32+d.n34*c.n42;this.n33=d.n31*c.n13+d.n32*c.n23+d.n33*c.n33+d.n34*c.n43;this.n34=d.n31*c.n14+d.n32*c.n24+d.n33*c.n34+d.n34*c.n44;this.n41=d.n41*c.n11+d.n42*c.n21+d.n43*c.n31+d.n44*c.n41;this.n42=d.n41*c.n12+d.n42*c.n22+d.n43*c.n32+d.n44*c.n42;this.n43=d.n41*c.n13+d.n42*c.n23+d.n43*c.n33+d.n44*c.n43;this.n44=d.n41*c.n14+d.n42*c.n24+d.n43*c.n34+d.n44*c.n44},multiplySelf:function(c){var o=this.n11,n=this.n12,k=this.n13,i=this.n14,f=this.n21,e=this.n22,d=this.n23,b=this.n24,a=this.n31,r=this.n32,q=this.n33,p=this.n34,l=this.n41,j=this.n42,h=this.n43,g=this.n44;this.n11=o*c.n11+n*c.n21+k*c.n31+i*c.n41;this.n12=o*c.n12+n*c.n22+k*c.n32+i*c.n42;this.n13=o*c.n13+n*c.n23+k*c.n33+i*c.n43;this.n14=o*c.n14+n*c.n24+k*c.n34+i*c.n44;this.n21=f*c.n11+e*c.n21+d*c.n31+b*c.n41;this.n22=f*c.n12+e*c.n22+d*c.n32+b*c.n42;this.n23=f*c.n13+e*c.n23+d*c.n33+b*c.n43;this.n24=f*c.n14+e*c.n24+d*c.n34+b*c.n44;this.n31=a*c.n11+r*c.n21+q*c.n31+p*c.n41;this.n32=a*c.n12+r*c.n22+q*c.n32+p*c.n42;this.n33=a*c.n13+r*c.n23+q*c.n33+p*c.n43;this.n34=a*c.n14+r*c.n24+q*c.n34+p*c.n44;this.n41=l*c.n11+j*c.n21+h*c.n31+g*c.n41;this.n42=l*c.n12+j*c.n22+h*c.n32+g*c.n42;this.n43=l*c.n13+j*c.n23+h*c.n33+g*c.n43;this.n44=l*c.n14+j*c.n24+h*c.n34+g*c.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(d,e,c){var b=d[e];d[e]=d[c];d[c]=b}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(b,d,c){var a=new THREE.Matrix4();a.n14=b;a.n24=d;a.n34=c;return a};THREE.Matrix4.scaleMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n11=b;a.n22=d;a.n33=c;return a};THREE.Matrix4.rotationXMatrix=function(b){var a=new THREE.Matrix4();a.n22=a.n33=Math.cos(b);a.n32=Math.sin(b);a.n23=-a.n32;return a};THREE.Matrix4.rotationYMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n33=Math.cos(b);a.n13=Math.sin(b);a.n31=-a.n13;return a};THREE.Matrix4.rotationZMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n22=Math.cos(b);a.n21=Math.sin(b);a.n12=-a.n21;return a};THREE.Matrix4.rotationAxisAngleMatrix=function(b,d){var a=new THREE.Matrix4(),f=Math.cos(d),j=Math.sin(d),i=1-f,h=b.x,g=b.y,e=b.z;a.n11=i*h*h+f;a.n12=i*h*g-j*e;a.n13=i*h*e+j*g;a.n21=i*h*g+j*e;a.n22=i*g*g+f;a.n23=i*g*e-j*h;a.n31=i*h*e-j*g;a.n32=i*g*e+j*h;a.n33=i*e*e+f;return a};THREE.Matrix4.makeInvert=function(b){var a=new THREE.Matrix4();a.n11=b.n23*b.n34*b.n42-b.n24*b.n33*b.n42+b.n24*b.n32*b.n43-b.n22*b.n34*b.n43-b.n23*b.n32*b.n44+b.n22*b.n33*b.n44;a.n12=b.n14*b.n33*b.n42-b.n13*b.n34*b.n42-b.n14*b.n32*b.n43+b.n12*b.n34*b.n43+b.n13*b.n32*b.n44-b.n12*b.n33*b.n44;a.n13=b.n13*b.n24*b.n42-b.n14*b.n23*b.n42+b.n14*b.n22*b.n43-b.n12*b.n24*b.n43-b.n13*b.n22*b.n44+b.n12*b.n23*b.n44;a.n14=b.n14*b.n23*b.n32-b.n13*b.n24*b.n32-b.n14*b.n22*b.n33+b.n12*b.n24*b.n33+b.n13*b.n22*b.n34-b.n12*b.n23*b.n34;a.n21=b.n24*b.n33*b.n41-b.n23*b.n34*b.n41-b.n24*b.n31*b.n43+b.n21*b.n34*b.n43+b.n23*b.n31*b.n44-b.n21*b.n33*b.n44;a.n22=b.n13*b.n34*b.n41-b.n14*b.n33*b.n41+b.n14*b.n31*b.n43-b.n11*b.n34*b.n43-b.n13*b.n31*b.n44+b.n11*b.n33*b.n44;a.n23=b.n14*b.n23*b.n41-b.n13*b.n24*b.n41-b.n14*b.n21*b.n43+b.n11*b.n24*b.n43+b.n13*b.n21*b.n44-b.n11*b.n23*b.n44;a.n24=b.n13*b.n24*b.n31-b.n14*b.n23*b.n31+b.n14*b.n21*b.n33-b.n11*b.n24*b.n33-b.n13*b.n21*b.n34+b.n11*b.n23*b.n34;a.n31=b.n22*b.n34*b.n41-b.n24*b.n32*b.n41+b.n24*b.n31*b.n42-b.n21*b.n34*b.n42-b.n22*b.n31*b.n44+b.n21*b.n32*b.n44;a.n32=b.n14*b.n32*b.n41-b.n12*b.n34*b.n41-b.n14*b.n31*b.n42+b.n11*b.n34*b.n42+b.n12*b.n31*b.n44-b.n11*b.n32*b.n44;a.n33=b.n13*b.n24*b.n41-b.n14*b.n22*b.n41+b.n14*b.n21*b.n42-b.n11*b.n24*b.n42-b.n12*b.n21*b.n44+b.n11*b.n22*b.n44;a.n34=b.n14*b.n22*b.n31-b.n12*b.n24*b.n31-b.n14*b.n21*b.n32+b.n11*b.n24*b.n32+b.n12*b.n21*b.n34-b.n11*b.n22*b.n34;a.n41=b.n23*b.n32*b.n41-b.n22*b.n33*b.n41-b.n23*b.n31*b.n42+b.n21*b.n33*b.n42+b.n22*b.n31*b.n43-b.n21*b.n32*b.n43;a.n42=b.n12*b.n33*b.n41-b.n13*b.n32*b.n41+b.n13*b.n31*b.n42-b.n11*b.n33*b.n42-b.n12*b.n31*b.n43+b.n11*b.n32*b.n43;a.n43=b.n13*b.n22*b.n41-b.n12*b.n23*b.n41-b.n13*b.n21*b.n42+b.n11*b.n23*b.n42+b.n12*b.n21*b.n43-b.n11*b.n22*b.n43;a.n44=b.n12*b.n23*b.n31-b.n13*b.n22*b.n31+b.n13*b.n21*b.n32-b.n11*b.n23*b.n32-b.n12*b.n21*b.n33+b.n11*b.n22*b.n33;a.multiplyScalar(1/b.determinant());return a};THREE.Matrix4.makeInvert3x3=function(o){var e=o.flatten(),l=new THREE.Matrix3(),n=e[10]*e[5]-e[6]*e[9],i=-e[10]*e[1]+e[2]*e[9],d=e[6]*e[1]-e[2]*e[5],k=-e[10]*e[4]+e[6]*e[8],g=e[10]*e[0]-e[2]*e[8],c=-e[6]*e[0]+e[2]*e[4],j=e[9]*e[4]-e[5]*e[8],f=-e[9]*e[0]+e[1]*e[8],a=e[5]*e[0]-e[1]*e[4],h=e[0]*(n)+e[1]*(k)+e[2]*(j),b;if(h==0){throw"matrix not invertible"}b=1/h;l.m[0]=b*n;l.m[1]=b*i;l.m[2]=b*d;l.m[3]=b*k;l.m[4]=b*g;l.m[5]=b*c;l.m[6]=b*j;l.m[7]=b*f;l.m[8]=b*a;return l};THREE.Matrix4.makeFrustum=function(f,r,e,o,i,h){var g,q,n,p,l,k,j;g=new THREE.Matrix4();q=2*i/(r-f);n=2*i/(o-e);p=(r+f)/(r-f);l=(o+e)/(o-e);k=-(h+i)/(h-i);j=-2*h*i/(h-i);g.n11=q;g.n12=0;g.n13=p;g.n14=0;g.n21=0;g.n22=n;g.n23=l;g.n24=0;g.n31=0;g.n32=0;g.n33=k;g.n34=j;g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(e,c,g,b){var a,f,h,d;a=g*Math.tan(e*Math.PI/360);f=-a;h=f*c;d=a*c;return THREE.Matrix4.makeFrustum(h,d,f,a,g,b)};THREE.Matrix4.makeOrtho=function(c,o,k,a,g,f){var d,l,j,i,n,e,b;d=new THREE.Matrix4();n=o-c;e=k-a;b=f-g;l=(o+c)/n;j=(k+a)/e;i=(f+g)/b;d.n11=2/n;d.n12=0;d.n13=0;d.n14=-l;d.n21=0;d.n22=2/e;d.n23=0;d.n24=-j;d.n31=0;d.n32=0;d.n33=-2/b;d.n34=-i;d.n41=0;d.n42=0;d.n43=0;d.n44=1;return d};THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3();this.positionWorld=new THREE.Vector3();this.positionScreen=new THREE.Vector3();this.normal=b||new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.normalScreen=new THREE.Vector3();this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};THREE.Face3=function(e,d,h,g,f){this.a=e;this.b=d;this.c=h;this.centroid=new THREE.Vector3();this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3();this.vertexNormals=g instanceof Array?g:[];this.material=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};THREE.Face4=function(f,e,j,i,h,g){this.a=f;this.b=e;this.c=j;this.d=i;this.centroid=new THREE.Vector3();this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3();this.vertexNormals=h instanceof Array?h:[];this.material=g instanceof Array?g:[g]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(b,a){this.u=b||0;this.v=a||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 c,b,a;for(c=0,b=this.faces.length;c0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var a=1,b=this.vertices.length;athis.bbox.x[1]){this.bbox.x[1]=vertex.position.x}}if(vertex.position.ythis.bbox.y[1]){this.bbox.y[1]=vertex.position.y}}if(vertex.position.zthis.bbox.z[1]){this.bbox.z[1]=vertex.position.z}}}}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+" )"}};THREE.Camera=function(c,b,d,a){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(c,b,d,a);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.Loader=function(){};THREE.Loader.prototype={loadAsciiOld:function(a,c){var b=document.createElement("script");b.type="text/javascript";b.onload=c;b.src=a;document.getElementsByTagName("head")[0].appendChild(b)},loadAscii:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,e,b)};d.postMessage(c)},loadBinary:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(h){var g=h.data.materials,f=h.data.buffers;THREE.Loader.prototype.loadAjaxBuffers(f,g,e,b)};d.onerror=function(f){alert("worker.onerror: "+f.message+"\n"+f.data);f.preventDefault()};d.postMessage(c)},loadAjaxBuffers:function(b,a,f,d){var e=new XMLHttpRequest(),c=d+"/"+b;e.onreadystatechange=function(){if(e.readyState==4){if(e.status==200||e.status==0){THREE.Loader.prototype.createBinModel(e.responseText,f,d,a)}else{alert("Couldn't load ["+c+"] ["+e.status+"]")}}};e.open("GET",c,true);e.overrideMimeType("text/plain; charset=x-user-defined");e.setRequestHeader("Content-Type","text/plain");e.send(null)},createBinModel:function(c,e,b,a){var d=function(aa){var I=this,h=0,x,A=[],L=[],V,T,O,U,R,P,D,C,B,y,r,q,p,o,u,t,N,K,J;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(I,a,aa);x=W(c,h);h+=x.header_bytes;V=x.vertex_index_bytes,T=x.vertex_index_bytes*2,O=x.vertex_index_bytes*3,U=x.vertex_index_bytes*3+x.material_index_bytes,R=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes,P=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*2,D=x.vertex_index_bytes,C=x.vertex_index_bytes*2,B=x.vertex_index_bytes*3,y=x.vertex_index_bytes*4,r=x.vertex_index_bytes*4+x.material_index_bytes,q=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes,p=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*2,o=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*3,u=x.uv_index_bytes,t=x.uv_index_bytes*2,N=x.uv_index_bytes,K=x.uv_index_bytes*2,J=x.uv_index_bytes*3;h+=w(h);h+=H(h);h+=G(h);h+=Q(h);h+=S(h);h+=ab(h);h+=n(h);h+=g(h);h+=k(h);h+=s(h);h+=z(h);this.computeCentroids();this.computeNormals();function W(ad,ae){var ac={signature:F(ad,ae,8),header_bytes:j(ad,ae+8),vertex_coordinate_bytes:j(ad,ae+9),normal_coordinate_bytes:j(ad,ae+10),uv_coordinate_bytes:j(ad,ae+11),vertex_index_bytes:j(ad,ae+12),normal_index_bytes:j(ad,ae+13),uv_index_bytes:j(ad,ae+14),material_index_bytes:j(ad,ae+15),nvertices:v(ad,ae+16),nnormals:v(ad,ae+16+4*1),nuvs:v(ad,ae+16+4*2),ntri_flat:v(ad,ae+16+4*3),ntri_smooth:v(ad,ae+16+4*4),ntri_flat_uv:v(ad,ae+16+4*5),ntri_smooth_uv:v(ad,ae+16+4*6),nquad_flat:v(ad,ae+16+4*7),nquad_smooth:v(ad,ae+16+4*8),nquad_flat_uv:v(ad,ae+16+4*9),nquad_smooth_uv:v(ad,ae+16+4*10)};return ac}function F(ad,ae,ac){return ad.substr(ae,ac)}function f(af,ae){var ag=j(af,ae),ai=j(af,ae+1),aj=j(af,ae+2),ak=j(af,ae+3),ad=1-(2*(ak>>7)),ah=(((ak<<1)&255)|(aj>>7))-127,ac=((aj&127)<<16)|(ai<<8)|ag;if(ac==0&&ah==-127){return 0}return ad*(1+ac*Math.pow(2,-23))*Math.pow(2,ah)}function v(ag,ah){var af=j(ag,ah),ae=j(ag,ah+1),ad=j(ag,ah+2),ac=j(ag,ah+3);return(ac<<24)+(ad<<16)+(ae<<8)+af}function Z(ae,af){var ad=j(ae,af),ac=j(ae,af+1);return(ac<<8)+ad}function i(ad,ae){var ac=j(ad,ae);return ac>127?ac-256:ac}function j(ac,ad){return ac.charCodeAt(ad)&255}function w(ai){var ae,ac,ah,ag,af=x.vertex_coordinate_bytes*3,ad=ai+x.nvertices*af;for(ae=ai;ae65535){g[n].counter+=1;d=g[n].hash+"_"+g[n].counter;if(this.materialFaceGroup[d]==undefined){this.materialFaceGroup[d]={faces:[],material:h,vertices:0}}}this.materialFaceGroup[d].faces.push(e);this.materialFaceGroup[d].vertices+=j}};THREE.Mesh.prototype.normalizeUVs=function(){var e,a,b,d,c;for(e=0,a=this.geometry.uvs.length;ecolor: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+this.linewidth+"
)"}};THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16711680);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(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}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 (
id: "+this.id+"
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+this.blending+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
)"}};THREE.MeshBasicMaterialCounter={value:0};THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16711680);this.map=null;this.opacity=1;this.shading=THREE.GouraudShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(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.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 (
id: "+this.id+"
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
shading: "+this.shading+"
blending: "+this.blending+"
wireframe: "+this.wireframe+"
wireframe_size: "+this.wireframe_linewidth+"
)"}};THREE.MeshLambertMaterialCounter={value:0};THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16711680);this.map=null;this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.specular_map=null;this.shininess=30;this.opacity=1;this.shading=THREE.GouraudShading;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_color=new THREE.Color(a.specular)}if(a.specular_map!==undefined){this.specular_map=a.specular_map}if(a.shininess!==undefined){this.shininess=a.shininess}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 (
id: "+this.id+"
color: "+this.color+"
map: "+this.map+"
ambient: "+this.ambient+"
specular: "+this.specular+"
specular_map: "+this.specular_map+"
shininess: "+this.shininess+"
alpha: "+this.opacity+"
shading: "+this.shading+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
"+ +")"}};THREE.MeshPhongMaterialCounter={value:0};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){if(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 (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;if(a){if(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 (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(b,a){this.image=b;this.mapping=a?a:THREE.UVMapping;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
mapping: "+this.mapping+"
)"}};THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(a){var b=this.objects.indexOf(a);if(b!==-1){this.objects.splice(b,1)}};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(a){var b=this.lights.indexOf(a);if(b!==-1){this.lights.splice(b,1)}};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};THREE.Projector=function(){var e=null,c,p,n=[],b,f,l=[],k,m,i=[],j,h,a=[],g=new THREE.Vector4(),d=new THREE.Matrix4(),o=new THREE.Matrix4();this.projectScene=function(J,G){var F,E,D,K,I,B,r,L,q,z,H,u,C,w,A,y,x,t,s;e=[];p=0,f=0,m=0,h=0;if(G.autoUpdateMatrix){G.updateMatrix()}d.multiply(G.projectionMatrix,G.matrix);r=J.objects;for(F=0,E=r.length;F0&&u.z<1}w=L.geometry.faces;for(I=0,B=w.length;I0&&u.z<1;if(D>0){C=L.geometry.vertices[D-1];if(H.__visible&&C.__visible){k=i[m]=i[m]||new THREE.RenderableLine();k.v1.copy(H.positionScreen);k.v2.copy(C.positionScreen);k.z=Math.max(H.positionScreen.z,C.positionScreen.z);k.material=L.material;e.push(k);m++}}}}else{if(L instanceof THREE.Particle){g.set(L.position.x,L.position.y,L.position.z,1);G.matrix.transform(g);G.projectionMatrix.transform(g);L.screen.set(g.x/g.w,g.y/g.w,g.z/g.w);if(L.screen.z>0&&L.screen.z<1){j=a[h]=a[h]||new THREE.RenderableParticle();j.x=L.screen.x;j.y=L.screen.y;j.z=L.screen.z;j.rotation=L.rotation.z;j.scale.x=L.scale.x*Math.abs(g.x/g.w-(g.x+G.projectionMatrix.n11)/(g.w+G.projectionMatrix.n14));j.scale.y=L.scale.y*Math.abs(g.y/g.w-(g.y+G.projectionMatrix.n22)/(g.w+G.projectionMatrix.n24));j.material=L.material;j.color=L.color;e.push(j);h++}}}}}e.sort(function(M,v){return v.z-M.z});return e};this.unprojectVector=function(q,s){var r=new THREE.Matrix4();r.multiply(THREE.Matrix4.makeInvert(s.matrix),THREE.Matrix4.makeInvert(s.projectionMatrix));r.transform(q);return q}};THREE.DOMRenderer=function(){THREE.Renderer.call(this);var e=null,g=new THREE.Projector(),b=document.createElement("div"),a,c,f,d;this.domElement=b;this.setSize=function(i,h){a=i;c=h;f=a/2;d=c/2};this.render=function(p,r){var q,h,i,n,o,s,l,k,j;e=g.projectScene(p,r);for(q=0,h=e.length;q0;if(C){e(ag,G)}for(af=0,O=n.length;af0){O.r+=L.r*P;O.g+=L.g*P;O.b+=L.b*P}}else{if(M instanceof THREE.PointLight){D.sub(M.position,Q.centroidWorld);D.normalize();P=Q.normalWorld.dot(D)*M.intensity;if(P>0){O.r+=L.r*P;O.g+=L.g*P;O.b+=L.b*P}}}}}function o(N,M,Q,T,S){var L,Y,W,V,R,P,U,X,O;if(B!=T.opacity){r.globalAlpha=B=T.opacity}if(T instanceof THREE.ParticleBasicMaterial){U=T.bitmap;X=U.width/2;O=U.height/2;W=Q.scale.x*v;V=Q.scale.y*h;L=W*X;Y=V*O;R=T.offset.x*W;P=T.offset.y*V;m.set(N+R-L,M+P-Y,N+R+L,M+P+Y);if(!w.instersects(m)){return}r.save();r.translate(N,M);r.rotate(-Q.rotation);r.scale(W,-V);r.translate(-X+T.offset.x,-O-T.offset.y);r.drawImage(U,0,0);r.restore()}else{if(T instanceof THREE.ParticleCircleMaterial){if(C){y.copyRGB(G);g(S,Q,y);A.copyRGBA(T.color);A.multiplySelfRGB(y);A.updateStyleString()}else{A.__styleString=T.color.__styleString}L=Q.scale.x*v;Y=Q.scale.y*h;m.set(N-L,M-Y,N+L,M+Y);if(!w.instersects(m)){return}r.save();r.translate(N,M);r.rotate(-Q.rotation);r.scale(L,Y);r.beginPath();r.arc(0,0,1,0,j,true);r.closePath();r.fillStyle=A.__styleString;r.fill();r.restore()}}}function z(L,R,N,M,O,P,Q){if(B!=P.opacity){r.globalAlpha=B=P.opacity}if(P instanceof THREE.LineBasicMaterial){r.beginPath();r.moveTo(L,R);r.lineTo(N,M);r.closePath();A.__styleString=P.color.__styleString;if(f!=P.linewidth){r.lineWidth=f=P.linewidth}if(i!=A.__styleString){r.strokeStyle=i=A.__styleString}r.stroke();m.inflate(P.linewidth*2)}}function l(N,M,L,W,T,S,P,R,Q){var U,V,O;if(B!=R.opacity){r.globalAlpha=B=R.opacity}if(R.map){U=R.map.image;V=U.width-1;O=U.height-1;u.copy(P.uvs[0]);t.copy(P.uvs[1]);q.copy(P.uvs[2]);u.u*=V;u.v*=O;t.u*=V;t.v*=O;q.u*=V;q.v*=O;c(U,N,M,L,W,T,S,u.u,u.v,t.u,t.v,q.u,q.v);return}r.beginPath();r.moveTo(N,M);r.lineTo(L,W);r.lineTo(T,S);r.lineTo(N,M);r.closePath();if(R instanceof THREE.MeshBasicMaterial){A.__styleString=R.color.__styleString}else{if(R instanceof THREE.MeshLambertMaterial){if(C){y.copyRGB(G);d(Q,P,y);A.copyRGBA(R.color);A.multiplySelfRGB(y);A.updateStyleString()}else{A.__styleString=R.color.__styleString}}}if(R.wireframe){if(f!=R.wireframe_linewidth){r.lineWidth=f=R.wireframe_linewidth}if(i!=A.__styleString){r.strokeStyle=i=A.__styleString}r.stroke();m.inflate(R.wireframe_linewidth*2)}else{if(K!=A.__styleString){r.fillStyle=K=A.__styleString}r.fill()}}function k(R,Q,Z,X,M,L,T,S,aa,Y,O,N,P,V,ab){var ac,U,W;if(B!=V.opacity){r.globalAlpha=B=V.opacity}if(V.map){ac=V.map.image;U=ac.width-1;W=ac.height-1;u.copy(P.uvs[0]);t.copy(P.uvs[1]);q.copy(P.uvs[2]);p.copy(P.uvs[3]);u.u*=U;u.v*=W;t.u*=U;t.v*=W;q.u*=U;q.v*=W;p.u*=U;p.v*=W;c(ac,R,Q,Z,X,T,S,u.u,u.v,t.u,t.v,p.u,p.v);c(ac,aa,Y,M,L,O,N,t.u,t.v,q.u,q.v,p.u,p.v);return}r.beginPath();r.moveTo(R,Q);r.lineTo(Z,X);r.lineTo(M,L);r.lineTo(T,S);r.lineTo(R,Q);r.closePath();if(V instanceof THREE.MeshBasicMaterial){A.__styleString=V.color.__styleString}else{if(V instanceof THREE.MeshLambertMaterial){if(C){y.copyRGB(G);d(ab,P,y);A.copyRGBA(V.color);A.multiplySelfRGB(y);A.updateStyleString()}else{A.__styleString=V.color.__styleString}}}if(V.wireframe){if(f!=V.wireframe_linewidth){r.lineWidth=f=V.wireframe_linewidth}if(i!=A.__styleString){r.strokeStyle=i=A.__styleString}r.stroke();m.inflate(V.wireframe_linewidth*2)}else{if(K!=A.__styleString){r.fillStyle=K=A.__styleString}r.fill()}}function c(ae,T,S,Z,Y,N,L,X,W,ab,aa,P,O){var M,ad,ac,R,Q,V,U;r.beginPath();r.moveTo(T,S);r.lineTo(Z,Y);r.lineTo(N,L);r.lineTo(T,S);r.closePath();r.save();r.clip();M=X*(O-aa)-ab*O+P*aa+(ab-P)*W;ad=-(W*(N-Z)-aa*N+O*Z+(aa-O)*T)/M;ac=(aa*L+W*(Y-L)-O*Y+(O-aa)*S)/M;R=(X*(N-Z)-ab*N+P*Z+(ab-P)*T)/M;Q=-(ab*L+X*(Y-L)-P*Y+(P-ab)*S)/M;V=(X*(O*Z-aa*N)+W*(ab*N-P*Z)+(P*aa-ab*O)*T)/M;U=(X*(O*Y-aa*L)+W*(ab*L-P*Y)+(P*aa-ab*O)*S)/M;r.transform(ad,ac,R,Q,V,U);r.drawImage(ae,0,0);r.restore()}function b(M,L){F.sub(L,M);F.unit();F.multiplyScalar(0.75);L.addSelf(F);M.subSelf(F)}};THREE.SVGRenderer=function(){var x=null,r=new THREE.Projector(),t=document.createElementNS("http://www.w3.org/2000/svg","svg"),b,o,p,s,z=new THREE.Rectangle(),w=new THREE.Rectangle(),i=false,k=new THREE.Color(4294967295),v=new THREE.Color(4294967295),c=new THREE.Color(4294967295),g=new THREE.Vector3(),d=[],l=[],B,n,f,A=1;this.domElement=t;this.autoClear=true;this.setQuality=function(C){switch(C){case"high":A=1;break;case"low":A=0;break}};this.setSize=function(D,C){b=D;o=C;p=b/2;s=o/2;t.setAttribute("viewBox",(-p)+" "+(-s)+" "+b+" "+o);t.setAttribute("width",b);t.setAttribute("height",o);z.set(-p,-s,p,s)};this.clear=function(){while(t.childNodes.length>0){t.removeChild(t.childNodes[0])}};this.render=function(T,Q){var S,E,N,R,J,G,F,M,K,H,P,O,D,C,L,I;if(this.autoClear){this.clear()}x=r.projectScene(T,Q);n=0;f=0;i=T.lights.length>0;if(i){y(T,c)}for(S=0,E=x.length;S0){E.r+=C.color.r*F;E.g+=C.color.g*F;E.b+=C.color.b*F}}else{if(C instanceof THREE.PointLight){g.sub(C.position,G.centroidWorld);g.normalize();F=G.normalWorld.dot(g)*C.intensity;if(F>0){E.r+=C.color.r*F;E.g+=C.color.g*F;E.b+=C.color.b*F}}}}}function j(C,G,D,E,F){B=u(f++);B.setAttribute("cx",C);B.setAttribute("cy",G);B.setAttribute("r",D.scale.x*p);if(E instanceof THREE.ParticleCircleMaterial){if(i){v.copyRGB(c);q(F,D,v);k.copyRGBA(E.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=E.color}B.setAttribute("style","fill: "+k.__styleString)}t.appendChild(B)}function h(E,D,C,K,J,I,F,H,G){B=m(n++);B.setAttribute("d","M "+E+" "+D+" L "+C+" "+K+" L "+J+","+I+"z");if(H instanceof THREE.MeshBasicMaterial){k.__styleString=H.color.__styleString}else{if(H instanceof THREE.MeshLambertMaterial){if(i){v.copyRGB(c);a(G,F,v);k.copyRGBA(H.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k.__styleString=H.color.__styleString}}}if(H.wireframe){B.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+H.wireframe_linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: round; stroke-linejoin: round")}else{B.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+H.opacity)}t.appendChild(B)}function e(G,E,C,M,L,K,F,D,H,J,I){B=m(n++);B.setAttribute("d","M "+G+" "+E+" L "+C+" "+M+" L "+L+","+K+" L "+F+","+D+"z");if(J instanceof THREE.MeshBasicMaterial){k.__styleString=J.color.__styleString}else{if(J instanceof THREE.MeshLambertMaterial){if(i){v.copyRGB(c);a(I,H,v);k.copyRGBA(J.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k.__styleString=J.color.__styleString}}}if(J.wireframe){B.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: round; stroke-linejoin: round")}else{B.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+J.opacity)}t.appendChild(B)}function m(C){if(d[C]==null){d[C]=document.createElementNS("http://www.w3.org/2000/svg","path");if(A==0){d[C].setAttribute("shape-rendering","crispEdges")}return d[C]}return d[C]}function u(C){if(l[C]==null){l[C]=document.createElementNS("http://www.w3.org/2000/svg","circle");if(A==0){l[C].setAttribute("shape-rendering","crispEdges")}return l[C]}return l[C]}};THREE.WebGLRenderer=function(k){var n=document.createElement("canvas"),c,f,q=new THREE.Matrix4(),m,a=0,p=1,j=2,d=3,e=l(k,5);this.domElement=n;this.autoClear=true;i();h(e.directional,e.point);function l(v,w){if(v){var s,u,r,t=pointLights=maxDirLights=maxPointLights=0;for(s=0,u=v.lights.length;s= 0.0 )":"",s?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",s?"pointDiffuse += mDiffuse * pointDiffuseWeight;":"",s?"pointSpecular += mSpecular * pointSpecularWeight;":"",s?"}":"",r?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",r?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",r?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",r?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",r?"vec3 dirVector = normalize( lDirection.xyz );":"",r?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":"",r?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",r?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",r?"float dirSpecularWeight = 0.0;":"",r?"if ( dirDotNormalHalf >= 0.0 )":"",r?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",r?"dirDiffuse += mDiffuse * dirDiffuseWeight;":"",r?"dirSpecular += mSpecular * dirSpecularWeight;":"",r?"}":"","vec4 totalLight = mAmbient;",r?"totalLight += dirDiffuse + dirSpecular;":"",s?"totalLight += pointDiffuse + pointSpecular;":"","gl_FragColor = vec4( totalLight.xyz * vLightWeighting, 1.0 );","} else if ( material == 2 ) {","vec4 texelColor = texture2D( tDiffuse, vUv );","gl_FragColor = vec4( texelColor.rgb * vLightWeighting, texelColor.a );","} else if ( material == 1 ) {","gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );","} else {","gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );","}","}"];return t.join("\n")}function g(r,s){var t=[r?"#define MAX_DIR_LIGHTS "+r:"",s?"#define MAX_POINT_LIGHTS "+s:"","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","uniform vec3 cameraPosition;","uniform bool enableLighting;","uniform int pointLightNumber;","uniform int directionalLightNumber;","uniform vec3 ambientLightColor;",r?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",r?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",s?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",s?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","uniform mat4 objMatrix;","uniform mat4 viewMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat3 normalMatrix;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vLightWeighting;",s?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;","void main(void) {","vec4 mPosition = objMatrix * vec4( position, 1.0 );","vViewPosition = cameraPosition - mPosition.xyz;","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec3 transformedNormal = normalize( normalMatrix * normal );","if ( !enableLighting ) {","vLightWeighting = vec3( 1.0, 1.0, 1.0 );","} else {","vLightWeighting = ambientLightColor;",r?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",r?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",r?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",r?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",r?"}":"",s?"for( int i = 0; i < pointLightNumber; i++ ) {":"",s?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",s?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":"",s?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",s?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",s?"}":"","}","vNormal = transformedNormal;","vUv = uv;","gl_Position = projectionMatrix * mvPosition;","}"];return t.join("\n")}function h(r,s){f=c.createProgram();c.attachShader(f,b("fragment",o(r,s)));c.attachShader(f,b("vertex",g(r,s)));c.linkProgram(f);if(!c.getProgramParameter(f,c.LINK_STATUS)){alert("Could not initialise shaders")}c.useProgram(f);f.viewMatrix=c.getUniformLocation(f,"viewMatrix");f.modelViewMatrix=c.getUniformLocation(f,"modelViewMatrix");f.projectionMatrix=c.getUniformLocation(f,"projectionMatrix");f.normalMatrix=c.getUniformLocation(f,"normalMatrix");f.objMatrix=c.getUniformLocation(f,"objMatrix");f.cameraPosition=c.getUniformLocation(f,"cameraPosition");f.enableLighting=c.getUniformLocation(f,"enableLighting");f.ambientLightColor=c.getUniformLocation(f,"ambientLightColor");if(r){f.directionalLightNumber=c.getUniformLocation(f,"directionalLightNumber");f.directionalLightColor=c.getUniformLocation(f,"directionalLightColor");f.directionalLightDirection=c.getUniformLocation(f,"directionalLightDirection")}if(s){f.pointLightNumber=c.getUniformLocation(f,"pointLightNumber");f.pointLightColor=c.getUniformLocation(f,"pointLightColor");f.pointLightPosition=c.getUniformLocation(f,"pointLightPosition")}f.material=c.getUniformLocation(f,"material");f.mColor=c.getUniformLocation(f,"mColor");f.mAmbient=c.getUniformLocation(f,"mAmbient");f.mDiffuse=c.getUniformLocation(f,"mDiffuse");f.mSpecular=c.getUniformLocation(f,"mSpecular");f.mShininess=c.getUniformLocation(f,"mShininess");f.tDiffuse=c.getUniformLocation(f,"tDiffuse");c.uniform1i(f.tDiffuse,0);f.position=c.getAttribLocation(f,"position");c.enableVertexAttribArray(f.position);f.normal=c.getAttribLocation(f,"normal");c.enableVertexAttribArray(f.normal);f.uv=c.getAttribLocation(f,"uv");c.enableVertexAttribArray(f.uv);f.viewMatrixArray=new Float32Array(16);f.modelViewMatrixArray=new Float32Array(16);f.projectionMatrixArray=new Float32Array(16)}function b(s,r){var t;if(s=="fragment"){t=c.createShader(c.FRAGMENT_SHADER)}else{if(s=="vertex"){t=c.createShader(c.VERTEX_SHADER)}}c.shaderSource(t,r);c.compileShader(t);if(!c.getShaderParameter(t,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(t));return null}return t}};THREE.RenderableFace3=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.centroidScreen=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableFace4=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.v4=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.centroidScreen=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableParticle=function(){this.x=null;this.y=null;this.z=null;this.rotation=null;this.scale=new THREE.Vector2();this.color=null;this.material=null};THREE.RenderableLine=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.z=null;this.color=null;this.material=null}; \ No newline at end of file +var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};THREE.Color.prototype={setRGBA:function(f,e,c,d){this.r=f;this.g=e;this.b=c;this.a=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=(~~a).toString(16).length<8?255<<24^a:a;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},copyRGB:function(a){this.r=a.r;this.g=a.g;this.b=a.b},copyRGBA:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.a=a.a},multiplySelfRGB:function(a){this.r*=a.r;this.g*=a.g;this.b*=a.b},updateHex:function(){this.hex=~~(this.a*255)<<24^~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.a=(this.hex>>24&255)/255;this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgba("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+","+this.a+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", a: "+this.a+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(b,a){this.x=b.x-a.x;this.y=b.y-a.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,b){this.x=a||0;this.y=c||0;this.z=b||0};THREE.Vector3.prototype={set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;this.z=b.z+a.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(b,a){this.x=b.x-a.x;this.y=b.y-a.y;this.z=b.z-a.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},cross:function(b,a){this.x=b.y*a.z-b.z*a.y;this.y=b.z*a.x-b.x*a.z;this.z=b.x*a.y-b.y*a.x;return this},crossSelf:function(c){var b=this.x,a=this.y,d=this.z;this.x=a*c.z-d*c.y;this.y=d*c.x-b*c.z;this.z=b*c.y-a*c.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(d){var c=this.x-d.x,b=this.y-d.y,a=this.z-d.z;return c*c+b*b+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(){if(this.length()>0){this.multiplyScalar(1/this.length())}else{this.multiplyScalar(0)}return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){var a=0.0001;return(Math.abs(this.x)0)&&(I>0)&&(K+I<1)}}};THREE.Rectangle=function(){var e,g,h,d,a,c,f=true;function b(){a=h-e;c=d-g}this.getX=function(){return e};this.getY=function(){return g};this.getWidth=function(){return a};this.getHeight=function(){return c};this.getLeft=function(){return e};this.getTop=function(){return g};this.getRight=function(){return h};this.getBottom=function(){return d};this.set=function(l,k,j,i){f=false;e=l;g=k;h=j;d=i;b()};this.addPoint=function(i,j){if(f){f=false;e=i;g=j;h=i;d=j}else{e=Math.min(e,i);g=Math.min(g,j);h=Math.max(h,i);d=Math.max(d,j)}b()};this.addRectangle=function(i){if(f){f=false;e=i.getLeft();g=i.getTop();h=i.getRight();d=i.getBottom()}else{e=Math.min(e,i.getLeft());g=Math.min(g,i.getTop());h=Math.max(h,i.getRight());d=Math.max(d,i.getBottom())}b()};this.inflate=function(i){e-=i;g-=i;h+=i;d+=i;b()};this.minSelf=function(i){e=Math.max(e,i.getLeft());g=Math.max(g,i.getTop());h=Math.min(h,i.getRight());d=Math.min(d,i.getBottom());b()};this.instersects=function(i){return Math.min(h,i.getRight())-Math.max(e,i.getLeft())>=0&&Math.min(d,i.getBottom())-Math.max(g,i.getTop())>=0};this.empty=function(){f=true;e=0;g=0;h=0;d=0;b()};this.isEmpty=function(){return f};this.toString=function(){return"THREE.Rectangle ( left: "+e+", right: "+h+", top: "+g+", bottom: "+d+", width: "+a+", height: "+c+" )"}};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.n12=0;this.n13=0;this.n14=0;this.n21=0;this.n22=1;this.n23=0;this.n24=0;this.n31=0;this.n32=0;this.n33=1;this.n34=0;this.n41=0;this.n42=0;this.n43=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(d,c,b){var a=this._x,f=this._y,e=this._z;e.sub(d,c);e.normalize();a.cross(b,e);a.normalize();f.cross(e,a);f.normalize();this.n11=a.x;this.n12=a.y;this.n13=a.z;this.n14=-a.dot(d);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(d);this.n31=e.x;this.n32=e.y;this.n33=e.z;this.n34=-e.dot(d);this.n41=0;this.n42=0;this.n43=0;this.n44=1},transform:function(a){var d=a.x,c=a.y,b=a.z,e=a.w?a.w:1;a.x=this.n11*d+this.n12*c+this.n13*b+this.n14*e;a.y=this.n21*d+this.n22*c+this.n23*b+this.n24*e;a.z=this.n31*d+this.n32*c+this.n33*b+this.n34*e;e=this.n41*d+this.n42*c+this.n43*b+this.n44*e;if(a.w){a.w=e}else{a.x=a.x/e;a.y=a.y/e;a.z=a.z/e}return a},crossVector:function(b){var c=new THREE.Vector4();c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=(b.w)?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(d,c){this.n11=d.n11*c.n11+d.n12*c.n21+d.n13*c.n31+d.n14*c.n41;this.n12=d.n11*c.n12+d.n12*c.n22+d.n13*c.n32+d.n14*c.n42;this.n13=d.n11*c.n13+d.n12*c.n23+d.n13*c.n33+d.n14*c.n43;this.n14=d.n11*c.n14+d.n12*c.n24+d.n13*c.n34+d.n14*c.n44;this.n21=d.n21*c.n11+d.n22*c.n21+d.n23*c.n31+d.n24*c.n41;this.n22=d.n21*c.n12+d.n22*c.n22+d.n23*c.n32+d.n24*c.n42;this.n23=d.n21*c.n13+d.n22*c.n23+d.n23*c.n33+d.n24*c.n43;this.n24=d.n21*c.n14+d.n22*c.n24+d.n23*c.n34+d.n24*c.n44;this.n31=d.n31*c.n11+d.n32*c.n21+d.n33*c.n31+d.n34*c.n41;this.n32=d.n31*c.n12+d.n32*c.n22+d.n33*c.n32+d.n34*c.n42;this.n33=d.n31*c.n13+d.n32*c.n23+d.n33*c.n33+d.n34*c.n43;this.n34=d.n31*c.n14+d.n32*c.n24+d.n33*c.n34+d.n34*c.n44;this.n41=d.n41*c.n11+d.n42*c.n21+d.n43*c.n31+d.n44*c.n41;this.n42=d.n41*c.n12+d.n42*c.n22+d.n43*c.n32+d.n44*c.n42;this.n43=d.n41*c.n13+d.n42*c.n23+d.n43*c.n33+d.n44*c.n43;this.n44=d.n41*c.n14+d.n42*c.n24+d.n43*c.n34+d.n44*c.n44},multiplySelf:function(c){var o=this.n11,n=this.n12,k=this.n13,i=this.n14,f=this.n21,e=this.n22,d=this.n23,b=this.n24,a=this.n31,r=this.n32,q=this.n33,p=this.n34,l=this.n41,j=this.n42,h=this.n43,g=this.n44;this.n11=o*c.n11+n*c.n21+k*c.n31+i*c.n41;this.n12=o*c.n12+n*c.n22+k*c.n32+i*c.n42;this.n13=o*c.n13+n*c.n23+k*c.n33+i*c.n43;this.n14=o*c.n14+n*c.n24+k*c.n34+i*c.n44;this.n21=f*c.n11+e*c.n21+d*c.n31+b*c.n41;this.n22=f*c.n12+e*c.n22+d*c.n32+b*c.n42;this.n23=f*c.n13+e*c.n23+d*c.n33+b*c.n43;this.n24=f*c.n14+e*c.n24+d*c.n34+b*c.n44;this.n31=a*c.n11+r*c.n21+q*c.n31+p*c.n41;this.n32=a*c.n12+r*c.n22+q*c.n32+p*c.n42;this.n33=a*c.n13+r*c.n23+q*c.n33+p*c.n43;this.n34=a*c.n14+r*c.n24+q*c.n34+p*c.n44;this.n41=l*c.n11+j*c.n21+h*c.n31+g*c.n41;this.n42=l*c.n12+j*c.n22+h*c.n32+g*c.n42;this.n43=l*c.n13+j*c.n23+h*c.n33+g*c.n43;this.n44=l*c.n14+j*c.n24+h*c.n34+g*c.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(d,e,c){var b=d[e];d[e]=d[c];d[c]=b}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(b,d,c){var a=new THREE.Matrix4();a.n14=b;a.n24=d;a.n34=c;return a};THREE.Matrix4.scaleMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n11=b;a.n22=d;a.n33=c;return a};THREE.Matrix4.rotationXMatrix=function(b){var a=new THREE.Matrix4();a.n22=a.n33=Math.cos(b);a.n32=Math.sin(b);a.n23=-a.n32;return a};THREE.Matrix4.rotationYMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n33=Math.cos(b);a.n13=Math.sin(b);a.n31=-a.n13;return a};THREE.Matrix4.rotationZMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n22=Math.cos(b);a.n21=Math.sin(b);a.n12=-a.n21;return a};THREE.Matrix4.rotationAxisAngleMatrix=function(b,d){var a=new THREE.Matrix4(),f=Math.cos(d),j=Math.sin(d),i=1-f,h=b.x,g=b.y,e=b.z;a.n11=i*h*h+f;a.n12=i*h*g-j*e;a.n13=i*h*e+j*g;a.n21=i*h*g+j*e;a.n22=i*g*g+f;a.n23=i*g*e-j*h;a.n31=i*h*e-j*g;a.n32=i*g*e+j*h;a.n33=i*e*e+f;return a};THREE.Matrix4.makeInvert=function(b){var a=new THREE.Matrix4();a.n11=b.n23*b.n34*b.n42-b.n24*b.n33*b.n42+b.n24*b.n32*b.n43-b.n22*b.n34*b.n43-b.n23*b.n32*b.n44+b.n22*b.n33*b.n44;a.n12=b.n14*b.n33*b.n42-b.n13*b.n34*b.n42-b.n14*b.n32*b.n43+b.n12*b.n34*b.n43+b.n13*b.n32*b.n44-b.n12*b.n33*b.n44;a.n13=b.n13*b.n24*b.n42-b.n14*b.n23*b.n42+b.n14*b.n22*b.n43-b.n12*b.n24*b.n43-b.n13*b.n22*b.n44+b.n12*b.n23*b.n44;a.n14=b.n14*b.n23*b.n32-b.n13*b.n24*b.n32-b.n14*b.n22*b.n33+b.n12*b.n24*b.n33+b.n13*b.n22*b.n34-b.n12*b.n23*b.n34;a.n21=b.n24*b.n33*b.n41-b.n23*b.n34*b.n41-b.n24*b.n31*b.n43+b.n21*b.n34*b.n43+b.n23*b.n31*b.n44-b.n21*b.n33*b.n44;a.n22=b.n13*b.n34*b.n41-b.n14*b.n33*b.n41+b.n14*b.n31*b.n43-b.n11*b.n34*b.n43-b.n13*b.n31*b.n44+b.n11*b.n33*b.n44;a.n23=b.n14*b.n23*b.n41-b.n13*b.n24*b.n41-b.n14*b.n21*b.n43+b.n11*b.n24*b.n43+b.n13*b.n21*b.n44-b.n11*b.n23*b.n44;a.n24=b.n13*b.n24*b.n31-b.n14*b.n23*b.n31+b.n14*b.n21*b.n33-b.n11*b.n24*b.n33-b.n13*b.n21*b.n34+b.n11*b.n23*b.n34;a.n31=b.n22*b.n34*b.n41-b.n24*b.n32*b.n41+b.n24*b.n31*b.n42-b.n21*b.n34*b.n42-b.n22*b.n31*b.n44+b.n21*b.n32*b.n44;a.n32=b.n14*b.n32*b.n41-b.n12*b.n34*b.n41-b.n14*b.n31*b.n42+b.n11*b.n34*b.n42+b.n12*b.n31*b.n44-b.n11*b.n32*b.n44;a.n33=b.n13*b.n24*b.n41-b.n14*b.n22*b.n41+b.n14*b.n21*b.n42-b.n11*b.n24*b.n42-b.n12*b.n21*b.n44+b.n11*b.n22*b.n44;a.n34=b.n14*b.n22*b.n31-b.n12*b.n24*b.n31-b.n14*b.n21*b.n32+b.n11*b.n24*b.n32+b.n12*b.n21*b.n34-b.n11*b.n22*b.n34;a.n41=b.n23*b.n32*b.n41-b.n22*b.n33*b.n41-b.n23*b.n31*b.n42+b.n21*b.n33*b.n42+b.n22*b.n31*b.n43-b.n21*b.n32*b.n43;a.n42=b.n12*b.n33*b.n41-b.n13*b.n32*b.n41+b.n13*b.n31*b.n42-b.n11*b.n33*b.n42-b.n12*b.n31*b.n43+b.n11*b.n32*b.n43;a.n43=b.n13*b.n22*b.n41-b.n12*b.n23*b.n41-b.n13*b.n21*b.n42+b.n11*b.n23*b.n42+b.n12*b.n21*b.n43-b.n11*b.n22*b.n43;a.n44=b.n12*b.n23*b.n31-b.n13*b.n22*b.n31+b.n13*b.n21*b.n32-b.n11*b.n23*b.n32-b.n12*b.n21*b.n33+b.n11*b.n22*b.n33;a.multiplyScalar(1/b.determinant());return a};THREE.Matrix4.makeInvert3x3=function(o){var e=o.flatten(),l=new THREE.Matrix3(),n=e[10]*e[5]-e[6]*e[9],i=-e[10]*e[1]+e[2]*e[9],d=e[6]*e[1]-e[2]*e[5],k=-e[10]*e[4]+e[6]*e[8],g=e[10]*e[0]-e[2]*e[8],c=-e[6]*e[0]+e[2]*e[4],j=e[9]*e[4]-e[5]*e[8],f=-e[9]*e[0]+e[1]*e[8],a=e[5]*e[0]-e[1]*e[4],h=e[0]*(n)+e[1]*(k)+e[2]*(j),b;if(h==0){throw"matrix not invertible"}b=1/h;l.m[0]=b*n;l.m[1]=b*i;l.m[2]=b*d;l.m[3]=b*k;l.m[4]=b*g;l.m[5]=b*c;l.m[6]=b*j;l.m[7]=b*f;l.m[8]=b*a;return l};THREE.Matrix4.makeFrustum=function(f,r,e,o,i,h){var g,q,n,p,l,k,j;g=new THREE.Matrix4();q=2*i/(r-f);n=2*i/(o-e);p=(r+f)/(r-f);l=(o+e)/(o-e);k=-(h+i)/(h-i);j=-2*h*i/(h-i);g.n11=q;g.n12=0;g.n13=p;g.n14=0;g.n21=0;g.n22=n;g.n23=l;g.n24=0;g.n31=0;g.n32=0;g.n33=k;g.n34=j;g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(e,c,g,b){var a,f,h,d;a=g*Math.tan(e*Math.PI/360);f=-a;h=f*c;d=a*c;return THREE.Matrix4.makeFrustum(h,d,f,a,g,b)};THREE.Matrix4.makeOrtho=function(c,o,k,a,g,f){var d,l,j,i,n,e,b;d=new THREE.Matrix4();n=o-c;e=k-a;b=f-g;l=(o+c)/n;j=(k+a)/e;i=(f+g)/b;d.n11=2/n;d.n12=0;d.n13=0;d.n14=-l;d.n21=0;d.n22=2/e;d.n23=0;d.n24=-j;d.n31=0;d.n32=0;d.n33=-2/b;d.n34=-i;d.n41=0;d.n42=0;d.n43=0;d.n44=1;return d};THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3();this.positionWorld=new THREE.Vector3();this.positionScreen=new THREE.Vector3();this.normal=b||new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.normalScreen=new THREE.Vector3();this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};THREE.Face3=function(e,d,h,g,f){this.a=e;this.b=d;this.c=h;this.centroid=new THREE.Vector3();this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3();this.vertexNormals=g instanceof Array?g:[];this.material=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};THREE.Face4=function(f,e,j,i,h,g){this.a=f;this.b=e;this.c=j;this.d=i;this.centroid=new THREE.Vector3();this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3();this.vertexNormals=h instanceof Array?h:[];this.material=g instanceof Array?g:[g]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(b,a){this.u=b||0;this.v=a||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 c,b,a;for(c=0,b=this.faces.length;c0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var a=1,b=this.vertices.length;athis.bbox.x[1]){this.bbox.x[1]=vertex.position.x}}if(vertex.position.ythis.bbox.y[1]){this.bbox.y[1]=vertex.position.y}}if(vertex.position.zthis.bbox.z[1]){this.bbox.z[1]=vertex.position.z}}}}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+" )"}};THREE.Camera=function(c,b,d,a){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(c,b,d,a);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.Loader=function(){};THREE.Loader.prototype={loadAsciiOld:function(a,c){var b=document.createElement("script");b.type="text/javascript";b.onload=c;b.src=a;document.getElementsByTagName("head")[0].appendChild(b)},loadAscii:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,e,b)};d.postMessage(c)},loadBinary:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(h){var g=h.data.materials,f=h.data.buffers;THREE.Loader.prototype.loadAjaxBuffers(f,g,e,b)};d.onerror=function(f){alert("worker.onerror: "+f.message+"\n"+f.data);f.preventDefault()};d.postMessage(c)},loadAjaxBuffers:function(b,a,f,d){var e=new XMLHttpRequest(),c=d+"/"+b;e.onreadystatechange=function(){if(e.readyState==4){if(e.status==200||e.status==0){THREE.Loader.prototype.createBinModel(e.responseText,f,d,a)}else{alert("Couldn't load ["+c+"] ["+e.status+"]")}}};e.open("GET",c,true);e.overrideMimeType("text/plain; charset=x-user-defined");e.setRequestHeader("Content-Type","text/plain");e.send(null)},createBinModel:function(c,e,b,a){var d=function(aa){var I=this,h=0,x,A=[],L=[],V,T,O,U,R,P,D,C,B,y,r,q,p,o,u,t,N,K,J;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(I,a,aa);x=W(c,h);h+=x.header_bytes;V=x.vertex_index_bytes,T=x.vertex_index_bytes*2,O=x.vertex_index_bytes*3,U=x.vertex_index_bytes*3+x.material_index_bytes,R=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes,P=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*2,D=x.vertex_index_bytes,C=x.vertex_index_bytes*2,B=x.vertex_index_bytes*3,y=x.vertex_index_bytes*4,r=x.vertex_index_bytes*4+x.material_index_bytes,q=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes,p=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*2,o=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*3,u=x.uv_index_bytes,t=x.uv_index_bytes*2,N=x.uv_index_bytes,K=x.uv_index_bytes*2,J=x.uv_index_bytes*3;h+=w(h);h+=H(h);h+=G(h);h+=Q(h);h+=S(h);h+=ab(h);h+=n(h);h+=g(h);h+=k(h);h+=s(h);h+=z(h);this.computeCentroids();this.computeNormals();function W(ad,ae){var ac={signature:F(ad,ae,8),header_bytes:j(ad,ae+8),vertex_coordinate_bytes:j(ad,ae+9),normal_coordinate_bytes:j(ad,ae+10),uv_coordinate_bytes:j(ad,ae+11),vertex_index_bytes:j(ad,ae+12),normal_index_bytes:j(ad,ae+13),uv_index_bytes:j(ad,ae+14),material_index_bytes:j(ad,ae+15),nvertices:v(ad,ae+16),nnormals:v(ad,ae+16+4*1),nuvs:v(ad,ae+16+4*2),ntri_flat:v(ad,ae+16+4*3),ntri_smooth:v(ad,ae+16+4*4),ntri_flat_uv:v(ad,ae+16+4*5),ntri_smooth_uv:v(ad,ae+16+4*6),nquad_flat:v(ad,ae+16+4*7),nquad_smooth:v(ad,ae+16+4*8),nquad_flat_uv:v(ad,ae+16+4*9),nquad_smooth_uv:v(ad,ae+16+4*10)};return ac}function F(ad,ae,ac){return ad.substr(ae,ac)}function f(af,ae){var ag=j(af,ae),ai=j(af,ae+1),aj=j(af,ae+2),ak=j(af,ae+3),ad=1-(2*(ak>>7)),ah=(((ak<<1)&255)|(aj>>7))-127,ac=((aj&127)<<16)|(ai<<8)|ag;if(ac==0&&ah==-127){return 0}return ad*(1+ac*Math.pow(2,-23))*Math.pow(2,ah)}function v(ag,ah){var af=j(ag,ah),ae=j(ag,ah+1),ad=j(ag,ah+2),ac=j(ag,ah+3);return(ac<<24)+(ad<<16)+(ae<<8)+af}function Z(ae,af){var ad=j(ae,af),ac=j(ae,af+1);return(ac<<8)+ad}function i(ad,ae){var ac=j(ad,ae);return ac>127?ac-256:ac}function j(ac,ad){return ac.charCodeAt(ad)&255}function w(ai){var ae,ac,ah,ag,af=x.vertex_coordinate_bytes*3,ad=ai+x.nvertices*af;for(ae=ai;ae65535){g[n].counter+=1;d=g[n].hash+"_"+g[n].counter;if(this.materialFaceGroup[d]==undefined){this.materialFaceGroup[d]={faces:[],material:h,vertices:0}}}this.materialFaceGroup[d].faces.push(e);this.materialFaceGroup[d].vertices+=j}};THREE.Mesh.prototype.normalizeUVs=function(){var e,a,b,d,c;for(e=0,a=this.geometry.uvs.length;ecolor: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+this.linewidth+"
)"}};THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16711680);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(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}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 (
id: "+this.id+"
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+this.blending+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
)"}};THREE.MeshBasicMaterialCounter={value:0};THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1000;this.opacity=1;this.wireframe=false;this.wireframe_linewidth=1;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.wireframe!==undefined){this.wireframe=a.wireframe}if(a.wireframe_linewidth!==undefined){this.wireframe_linewidth=a.wireframe_linewidth}}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=this.far-this.near;this.toString=function(){return"THREE.MeshDepthMaterial"}};THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16711680);this.map=null;this.opacity=1;this.shading=THREE.GouraudShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(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.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 (
id: "+this.id+"
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
shading: "+this.shading+"
blending: "+this.blending+"
wireframe: "+this.wireframe+"
wireframe_size: "+this.wireframe_linewidth+"
)"}};THREE.MeshLambertMaterialCounter={value:0};THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16711680);this.map=null;this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.specular_map=null;this.shininess=30;this.opacity=1;this.shading=THREE.GouraudShading;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_color=new THREE.Color(a.specular)}if(a.specular_map!==undefined){this.specular_map=a.specular_map}if(a.shininess!==undefined){this.shininess=a.shininess}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 (
id: "+this.id+"
color: "+this.color+"
map: "+this.map+"
ambient: "+this.ambient+"
specular: "+this.specular+"
specular_map: "+this.specular_map+"
shininess: "+this.shininess+"
alpha: "+this.opacity+"
shading: "+this.shading+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
"+ +")"}};THREE.MeshPhongMaterialCounter={value:0};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){if(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 (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;if(a){if(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 (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(b,a){this.image=b;this.mapping=a?a:THREE.UVMapping;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
mapping: "+this.mapping+"
)"}};THREE.UVMapping=0;THREE.ReflectionMap=1;THREE.CubeMap=2;THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(a){var b=this.objects.indexOf(a);if(b!==-1){this.objects.splice(b,1)}};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(a){var b=this.lights.indexOf(a);if(b!==-1){this.lights.splice(b,1)}};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};THREE.Projector=function(){var e=null,c,p,n=[],b,f,l=[],k,m,i=[],j,h,a=[],g=new THREE.Vector4(),d=new THREE.Matrix4(),o=new THREE.Matrix4();this.projectScene=function(J,G){var F,E,D,K,I,B,r,L,q,z,H,u,C,w,A,y,x,t,s;e=[];p=0,f=0,m=0,h=0;if(G.autoUpdateMatrix){G.updateMatrix()}d.multiply(G.projectionMatrix,G.matrix);r=J.objects;for(F=0,E=r.length;F0&&u.z<1}w=L.geometry.faces;for(I=0,B=w.length;I0&&u.z<1;if(D>0){C=L.geometry.vertices[D-1];if(H.__visible&&C.__visible){k=i[m]=i[m]||new THREE.RenderableLine();k.v1.copy(H.positionScreen);k.v2.copy(C.positionScreen);k.z=Math.max(H.positionScreen.z,C.positionScreen.z);k.material=L.material;e.push(k);m++}}}}else{if(L instanceof THREE.Particle){g.set(L.position.x,L.position.y,L.position.z,1);d.transform(g);g.z/=g.w;if(g.z>0&&g.z<1){j=a[h]=a[h]||new THREE.RenderableParticle();j.x=g.x/g.w;j.y=g.y/g.w;j.z=g.z;j.rotation=L.rotation.z;j.scale.x=L.scale.x*Math.abs(j.x-(g.x+G.projectionMatrix.n11)/(g.w+G.projectionMatrix.n14));j.scale.y=L.scale.y*Math.abs(j.y-(g.y+G.projectionMatrix.n22)/(g.w+G.projectionMatrix.n24));j.material=L.material;e.push(j);h++}}}}}e.sort(function(M,v){return v.z-M.z});return e};this.unprojectVector=function(q,s){var r=new THREE.Matrix4();r.multiply(THREE.Matrix4.makeInvert(s.matrix),THREE.Matrix4.makeInvert(s.projectionMatrix));r.transform(q);return q}};THREE.DOMRenderer=function(){THREE.Renderer.call(this);var e=null,g=new THREE.Projector(),b=document.createElement("div"),a,c,f,d;this.domElement=b;this.setSize=function(i,h){a=i;c=h;f=a/2;d=c/2};this.render=function(p,r){var q,h,i,n,o,s,l,k,j;e=g.projectScene(p,r);for(q=0,h=e.length;q0;if(D){e(ah,H)}for(ag=0,P=n.length;ag0){P.r+=M.r*Q;P.g+=M.g*Q;P.b+=M.b*Q}}else{if(N instanceof THREE.PointLight){E.sub(N.position,R.centroidWorld);E.normalize();Q=R.normalWorld.dot(E)*N.intensity;if(Q>0){P.r+=M.r*Q;P.g+=M.g*Q;P.b+=M.b*Q}}}}}function o(O,N,R,U,T){var M,Z,X,W,S,Q,V,Y,P;if(B!=U.opacity){r.globalAlpha=B=U.opacity}if(U instanceof THREE.ParticleBasicMaterial){V=U.bitmap;Y=V.width/2;P=V.height/2;X=R.scale.x*v;W=R.scale.y*h;M=X*Y;Z=W*P;S=U.offset.x*X;Q=U.offset.y*W;m.set(O+S-M,N+Q-Z,O+S+M,N+Q+Z);if(!w.instersects(m)){return}r.save();r.translate(O,N);r.rotate(-R.rotation);r.scale(X,-W);r.translate(-Y+U.offset.x,-P-U.offset.y);r.drawImage(V,0,0);r.restore()}else{if(U instanceof THREE.ParticleCircleMaterial){if(D){y.copyRGB(H);g(T,R,y);A.copyRGBA(U.color);A.multiplySelfRGB(y);A.updateStyleString()}else{A.__styleString=U.color.__styleString}M=R.scale.x*v;Z=R.scale.y*h;m.set(O-M,N-Z,O+M,N+Z);if(!w.instersects(m)){return}r.save();r.translate(O,N);r.rotate(-R.rotation);r.scale(M,Z);r.beginPath();r.arc(0,0,1,0,k,true);r.closePath();r.fillStyle=A.__styleString;r.fill();r.restore()}}}function z(M,S,O,N,P,Q,R){if(B!=Q.opacity){r.globalAlpha=B=Q.opacity}if(Q instanceof THREE.LineBasicMaterial){r.beginPath();r.moveTo(M,S);r.lineTo(O,N);r.closePath();A.__styleString=Q.color.__styleString;if(f!=Q.linewidth){r.lineWidth=f=Q.linewidth}if(i!=A.__styleString){r.strokeStyle=i=A.__styleString}r.stroke();m.inflate(Q.linewidth*2)}}function l(O,N,M,X,U,T,Q,S,R){var V,W,P;if(B!=S.opacity){r.globalAlpha=B=S.opacity}if(S.map){V=S.map.image;W=V.width-1;P=V.height-1;u.copy(Q.uvs[0]);t.copy(Q.uvs[1]);q.copy(Q.uvs[2]);u.u*=W;u.v*=P;t.u*=W;t.v*=P;q.u*=W;q.v*=P;c(V,O,N,M,X,U,T,u.u,u.v,t.u,t.v,q.u,q.v);return}r.beginPath();r.moveTo(O,N);r.lineTo(M,X);r.lineTo(U,T);r.lineTo(O,N);r.closePath();if(S instanceof THREE.MeshBasicMaterial){A.__styleString=S.color.__styleString}else{if(S instanceof THREE.MeshDepthMaterial){C=1-(S.__2near/(S.__farPlusNear-Q.z*S.__farMinusNear));A.setRGBA(C,C,C,1)}else{if(S instanceof THREE.MeshLambertMaterial){if(D){y.copyRGB(H);d(R,Q,y);A.copyRGBA(S.color);A.multiplySelfRGB(y);A.updateStyleString()}else{A.__styleString=S.color.__styleString}}}}if(S.wireframe){if(f!=S.wireframe_linewidth){r.lineWidth=f=S.wireframe_linewidth}if(i!=A.__styleString){r.strokeStyle=i=A.__styleString}r.stroke();m.inflate(S.wireframe_linewidth*2)}else{if(L!=A.__styleString){r.fillStyle=L=A.__styleString}r.fill()}}function j(S,R,aa,Y,N,M,U,T,ab,Z,P,O,Q,W,ac){var ad,V,X;if(B!=W.opacity){r.globalAlpha=B=W.opacity}if(W.map){ad=W.map.image;V=ad.width-1;X=ad.height-1;u.copy(Q.uvs[0]);t.copy(Q.uvs[1]);q.copy(Q.uvs[2]);p.copy(Q.uvs[3]);u.u*=V;u.v*=X;t.u*=V;t.v*=X;q.u*=V;q.v*=X;p.u*=V;p.v*=X;c(ad,S,R,aa,Y,U,T,u.u,u.v,t.u,t.v,p.u,p.v);c(ad,ab,Z,N,M,P,O,t.u,t.v,q.u,q.v,p.u,p.v);return}r.beginPath();r.moveTo(S,R);r.lineTo(aa,Y);r.lineTo(N,M);r.lineTo(U,T);r.lineTo(S,R);r.closePath();if(W instanceof THREE.MeshBasicMaterial){A.__styleString=W.color.__styleString}else{if(W instanceof THREE.MeshDepthMaterial){C=1-(W.__2near/(W.__farPlusNear-Q.z*W.__farMinusNear));A.setRGBA(C,C,C,1)}else{if(W instanceof THREE.MeshLambertMaterial){if(D){y.copyRGB(H);d(ac,Q,y);A.copyRGBA(W.color);A.multiplySelfRGB(y);A.updateStyleString()}else{A.__styleString=W.color.__styleString}}}}if(W.wireframe){if(f!=W.wireframe_linewidth){r.lineWidth=f=W.wireframe_linewidth}if(i!=A.__styleString){r.strokeStyle=i=A.__styleString}r.stroke();m.inflate(W.wireframe_linewidth*2)}else{if(L!=A.__styleString){r.fillStyle=L=A.__styleString}r.fill()}}function c(af,Z,R,X,Q,V,O,W,P,U,N,T,M){r.beginPath();r.moveTo(Z,R);r.lineTo(X,Q);r.lineTo(V,O);r.closePath();X-=Z;Q-=R;V-=Z;O-=R;U-=W;N-=P;T-=W;M-=P;var S=1/(U*M-T*N),ae=(M*X-N*V)*S,ad=(M*Q-N*O)*S,ac=(U*V-T*X)*S,ab=(U*O-T*Q)*S,aa=Z-ae*W-ac*P,Y=R-ad*W-ab*P;r.save();r.transform(ae,ad,ac,ab,aa,Y);r.clip();r.drawImage(af,0,0);r.restore()}function b(N,M){G.sub(M,N);G.unit();G.multiplyScalar(0.75);M.addSelf(G);N.subSelf(G)}};THREE.SVGRenderer=function(){var y=null,r=new THREE.Projector(),t=document.createElementNS("http://www.w3.org/2000/svg","svg"),b,o,p,s,A=new THREE.Rectangle(),w=new THREE.Rectangle(),i=false,k=new THREE.Color(4294967295),v=new THREE.Color(4294967295),c=new THREE.Color(4294967295),x,g=new THREE.Vector3(),d=[],l=[],C,n,f,B=1;this.domElement=t;this.autoClear=true;this.setQuality=function(D){switch(D){case"high":B=1;break;case"low":B=0;break}};this.setSize=function(E,D){b=E;o=D;p=b/2;s=o/2;t.setAttribute("viewBox",(-p)+" "+(-s)+" "+b+" "+o);t.setAttribute("width",b);t.setAttribute("height",o);A.set(-p,-s,p,s)};this.clear=function(){while(t.childNodes.length>0){t.removeChild(t.childNodes[0])}};this.render=function(U,R){var T,F,O,S,K,H,G,N,L,I,Q,P,E,D,M,J;if(this.autoClear){this.clear()}y=r.projectScene(U,R);n=0;f=0;i=U.lights.length>0;if(i){z(U,c)}for(T=0,F=y.length;T0){F.r+=D.color.r*G;F.g+=D.color.g*G;F.b+=D.color.b*G}}else{if(D instanceof THREE.PointLight){g.sub(D.position,H.centroidWorld);g.normalize();G=H.normalWorld.dot(g)*D.intensity;if(G>0){F.r+=D.color.r*G;F.g+=D.color.g*G;F.b+=D.color.b*G}}}}}function j(D,H,E,F,G){C=u(f++);C.setAttribute("cx",D);C.setAttribute("cy",H);C.setAttribute("r",E.scale.x*p);if(F instanceof THREE.ParticleCircleMaterial){if(i){v.copyRGB(c);q(G,E,v);k.copyRGBA(F.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=F.color}C.setAttribute("style","fill: "+k.__styleString)}t.appendChild(C)}function h(F,E,D,L,K,J,G,I,H){C=m(n++);C.setAttribute("d","M "+F+" "+E+" L "+D+" "+L+" L "+K+","+J+"z");if(I instanceof THREE.MeshBasicMaterial){k.__styleString=I.color.__styleString}else{if(I instanceof THREE.MeshDepthMaterial){x=1-(I.__2near/(I.__farPlusNear-G.z*I.__farMinusNear));k.setRGBA(x,x,x,1)}else{if(I instanceof THREE.MeshLambertMaterial){if(i){v.copyRGB(c);a(H,G,v);k.copyRGBA(I.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k.__styleString=I.color.__styleString}}}}if(I.wireframe){C.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+I.wireframe_linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: round; stroke-linejoin: round")}else{C.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+I.opacity)}t.appendChild(C)}function e(H,F,D,N,M,L,G,E,I,K,J){C=m(n++);C.setAttribute("d","M "+H+" "+F+" L "+D+" "+N+" L "+M+","+L+" L "+G+","+E+"z");if(K instanceof THREE.MeshBasicMaterial){k.__styleString=K.color.__styleString}else{if(K instanceof THREE.MeshLambertMaterial){if(i){v.copyRGB(c);a(J,I,v);k.copyRGBA(K.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k.__styleString=K.color.__styleString}}}if(K.wireframe){C.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+K.wireframe_linewidth+"; stroke-opacity: "+K.opacity+"; stroke-linecap: round; stroke-linejoin: round")}else{C.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+K.opacity)}t.appendChild(C)}function m(D){if(d[D]==null){d[D]=document.createElementNS("http://www.w3.org/2000/svg","path");if(B==0){d[D].setAttribute("shape-rendering","crispEdges")}return d[D]}return d[D]}function u(D){if(l[D]==null){l[D]=document.createElementNS("http://www.w3.org/2000/svg","circle");if(B==0){l[D].setAttribute("shape-rendering","crispEdges")}return l[D]}return l[D]}};THREE.WebGLRenderer=function(k){var n=document.createElement("canvas"),c,f,q=new THREE.Matrix4(),m,a=0,p=1,j=2,d=3,e=l(k,5);this.domElement=n;this.autoClear=true;i();h(e.directional,e.point);function l(v,w){if(v){var s,u,r,t=pointLights=maxDirLights=maxPointLights=0;for(s=0,u=v.lights.length;s= 0.0 )":"",s?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",s?"pointDiffuse += mDiffuse * pointDiffuseWeight;":"",s?"pointSpecular += mSpecular * pointSpecularWeight;":"",s?"}":"",r?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",r?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",r?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",r?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",r?"vec3 dirVector = normalize( lDirection.xyz );":"",r?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":"",r?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",r?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",r?"float dirSpecularWeight = 0.0;":"",r?"if ( dirDotNormalHalf >= 0.0 )":"",r?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",r?"dirDiffuse += mDiffuse * dirDiffuseWeight;":"",r?"dirSpecular += mSpecular * dirSpecularWeight;":"",r?"}":"","vec4 totalLight = mAmbient;",r?"totalLight += dirDiffuse + dirSpecular;":"",s?"totalLight += pointDiffuse + pointSpecular;":"","gl_FragColor = vec4( totalLight.xyz * vLightWeighting, 1.0 );","} else if ( material == 2 ) {","vec4 texelColor = texture2D( tDiffuse, vUv );","gl_FragColor = vec4( texelColor.rgb * vLightWeighting, texelColor.a );","} else if ( material == 1 ) {","gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );","} else {","gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );","}","}"];return t.join("\n")}function g(r,s){var t=[r?"#define MAX_DIR_LIGHTS "+r:"",s?"#define MAX_POINT_LIGHTS "+s:"","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","uniform vec3 cameraPosition;","uniform bool enableLighting;","uniform int pointLightNumber;","uniform int directionalLightNumber;","uniform vec3 ambientLightColor;",r?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",r?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",s?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",s?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","uniform mat4 objMatrix;","uniform mat4 viewMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat3 normalMatrix;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vLightWeighting;",s?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;","void main(void) {","vec4 mPosition = objMatrix * vec4( position, 1.0 );","vViewPosition = cameraPosition - mPosition.xyz;","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec3 transformedNormal = normalize( normalMatrix * normal );","if ( !enableLighting ) {","vLightWeighting = vec3( 1.0, 1.0, 1.0 );","} else {","vLightWeighting = ambientLightColor;",r?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",r?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",r?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",r?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",r?"}":"",s?"for( int i = 0; i < pointLightNumber; i++ ) {":"",s?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",s?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":"",s?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",s?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",s?"}":"","}","vNormal = transformedNormal;","vUv = uv;","gl_Position = projectionMatrix * mvPosition;","}"];return t.join("\n")}function h(r,s){f=c.createProgram();c.attachShader(f,b("fragment",o(r,s)));c.attachShader(f,b("vertex",g(r,s)));c.linkProgram(f);if(!c.getProgramParameter(f,c.LINK_STATUS)){alert("Could not initialise shaders")}c.useProgram(f);f.viewMatrix=c.getUniformLocation(f,"viewMatrix");f.modelViewMatrix=c.getUniformLocation(f,"modelViewMatrix");f.projectionMatrix=c.getUniformLocation(f,"projectionMatrix");f.normalMatrix=c.getUniformLocation(f,"normalMatrix");f.objMatrix=c.getUniformLocation(f,"objMatrix");f.cameraPosition=c.getUniformLocation(f,"cameraPosition");f.enableLighting=c.getUniformLocation(f,"enableLighting");f.ambientLightColor=c.getUniformLocation(f,"ambientLightColor");if(r){f.directionalLightNumber=c.getUniformLocation(f,"directionalLightNumber");f.directionalLightColor=c.getUniformLocation(f,"directionalLightColor");f.directionalLightDirection=c.getUniformLocation(f,"directionalLightDirection")}if(s){f.pointLightNumber=c.getUniformLocation(f,"pointLightNumber");f.pointLightColor=c.getUniformLocation(f,"pointLightColor");f.pointLightPosition=c.getUniformLocation(f,"pointLightPosition")}f.material=c.getUniformLocation(f,"material");f.mColor=c.getUniformLocation(f,"mColor");f.mAmbient=c.getUniformLocation(f,"mAmbient");f.mDiffuse=c.getUniformLocation(f,"mDiffuse");f.mSpecular=c.getUniformLocation(f,"mSpecular");f.mShininess=c.getUniformLocation(f,"mShininess");f.tDiffuse=c.getUniformLocation(f,"tDiffuse");c.uniform1i(f.tDiffuse,0);f.position=c.getAttribLocation(f,"position");c.enableVertexAttribArray(f.position);f.normal=c.getAttribLocation(f,"normal");c.enableVertexAttribArray(f.normal);f.uv=c.getAttribLocation(f,"uv");c.enableVertexAttribArray(f.uv);f.viewMatrixArray=new Float32Array(16);f.modelViewMatrixArray=new Float32Array(16);f.projectionMatrixArray=new Float32Array(16)}function b(s,r){var t;if(s=="fragment"){t=c.createShader(c.FRAGMENT_SHADER)}else{if(s=="vertex"){t=c.createShader(c.VERTEX_SHADER)}}c.shaderSource(t,r);c.compileShader(t);if(!c.getShaderParameter(t,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(t));return null}return t}};THREE.RenderableFace3=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.centroidScreen=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableFace4=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.v4=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.centroidScreen=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableParticle=function(){this.x=null;this.y=null;this.z=null;this.rotation=null;this.scale=new THREE.Vector2();this.color=null;this.material=null};THREE.RenderableLine=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.z=null;this.color=null;this.material=null}; \ No newline at end of file diff --git a/build/ThreeDebug.js b/build/ThreeDebug.js index 5305a77f..3fcc715e 100644 --- a/build/ThreeDebug.js +++ b/build/ThreeDebug.js @@ -1,2 +1,2 @@ // ThreeDebug.js r28 - http://github.com/mrdoob/three.js -var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};THREE.Color.prototype={setRGBA:function(f,e,c,d){this.r=f;this.g=e;this.b=c;this.a=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=(~~a).toString(16).length<8?255<<24^a:a;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},copyRGB:function(a){this.r=a.r;this.g=a.g;this.b=a.b},copyRGBA:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.a=a.a},multiplySelfRGB:function(a){this.r*=a.r;this.g*=a.g;this.b*=a.b},updateHex:function(){this.hex=~~(this.a*255)<<24^~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.a=(this.hex>>24&255)/255;this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgba("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+","+this.a+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", a: "+this.a+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(b,a){this.x=b.x-a.x;this.y=b.y-a.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,b){this.x=a||0;this.y=c||0;this.z=b||0};THREE.Vector3.prototype={set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;this.z=b.z+a.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(b,a){this.x=b.x-a.x;this.y=b.y-a.y;this.z=b.z-a.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},cross:function(b,a){this.x=b.y*a.z-b.z*a.y;this.y=b.z*a.x-b.x*a.z;this.z=b.x*a.y-b.y*a.x;return this},crossSelf:function(c){var b=this.x,a=this.y,d=this.z;this.x=a*c.z-d*c.y;this.y=d*c.x-b*c.z;this.z=b*c.y-a*c.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(d){var c=this.x-d.x,b=this.y-d.y,a=this.z-d.z;return c*c+b*b+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(){if(this.length()>0){this.multiplyScalar(1/this.length())}else{this.multiplyScalar(0)}return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){var a=0.0001;return(Math.abs(this.x)0)&&(I>0)&&(K+I<1)}}};THREE.Rectangle=function(){var e,g,h,d,a,c,f=true;function b(){a=h-e;c=d-g}this.getX=function(){return e};this.getY=function(){return g};this.getWidth=function(){return a};this.getHeight=function(){return c};this.getLeft=function(){return e};this.getTop=function(){return g};this.getRight=function(){return h};this.getBottom=function(){return d};this.set=function(l,k,j,i){f=false;e=l;g=k;h=j;d=i;b()};this.addPoint=function(i,j){if(f){f=false;e=i;g=j;h=i;d=j}else{e=Math.min(e,i);g=Math.min(g,j);h=Math.max(h,i);d=Math.max(d,j)}b()};this.addRectangle=function(i){if(f){f=false;e=i.getLeft();g=i.getTop();h=i.getRight();d=i.getBottom()}else{e=Math.min(e,i.getLeft());g=Math.min(g,i.getTop());h=Math.max(h,i.getRight());d=Math.max(d,i.getBottom())}b()};this.inflate=function(i){e-=i;g-=i;h+=i;d+=i;b()};this.minSelf=function(i){e=Math.max(e,i.getLeft());g=Math.max(g,i.getTop());h=Math.min(h,i.getRight());d=Math.min(d,i.getBottom());b()};this.instersects=function(i){return Math.min(h,i.getRight())-Math.max(e,i.getLeft())>=0&&Math.min(d,i.getBottom())-Math.max(g,i.getTop())>=0};this.empty=function(){f=true;e=0;g=0;h=0;d=0;b()};this.isEmpty=function(){return f};this.toString=function(){return"THREE.Rectangle ( left: "+e+", right: "+h+", top: "+g+", bottom: "+d+", width: "+a+", height: "+c+" )"}};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.n12=0;this.n13=0;this.n14=0;this.n21=0;this.n22=1;this.n23=0;this.n24=0;this.n31=0;this.n32=0;this.n33=1;this.n34=0;this.n41=0;this.n42=0;this.n43=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(d,c,b){var a=this._x,f=this._y,e=this._z;e.sub(d,c);e.normalize();a.cross(b,e);a.normalize();f.cross(e,a);f.normalize();this.n11=a.x;this.n12=a.y;this.n13=a.z;this.n14=-a.dot(d);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(d);this.n31=e.x;this.n32=e.y;this.n33=e.z;this.n34=-e.dot(d);this.n41=0;this.n42=0;this.n43=0;this.n44=1},transform:function(a){var d=a.x,c=a.y,b=a.z,e=a.w?a.w:1;a.x=this.n11*d+this.n12*c+this.n13*b+this.n14*e;a.y=this.n21*d+this.n22*c+this.n23*b+this.n24*e;a.z=this.n31*d+this.n32*c+this.n33*b+this.n34*e;e=this.n41*d+this.n42*c+this.n43*b+this.n44*e;if(a.w){a.w=e}else{a.x=a.x/e;a.y=a.y/e;a.z=a.z/e}return a},crossVector:function(b){var c=new THREE.Vector4();c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=(b.w)?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(d,c){this.n11=d.n11*c.n11+d.n12*c.n21+d.n13*c.n31+d.n14*c.n41;this.n12=d.n11*c.n12+d.n12*c.n22+d.n13*c.n32+d.n14*c.n42;this.n13=d.n11*c.n13+d.n12*c.n23+d.n13*c.n33+d.n14*c.n43;this.n14=d.n11*c.n14+d.n12*c.n24+d.n13*c.n34+d.n14*c.n44;this.n21=d.n21*c.n11+d.n22*c.n21+d.n23*c.n31+d.n24*c.n41;this.n22=d.n21*c.n12+d.n22*c.n22+d.n23*c.n32+d.n24*c.n42;this.n23=d.n21*c.n13+d.n22*c.n23+d.n23*c.n33+d.n24*c.n43;this.n24=d.n21*c.n14+d.n22*c.n24+d.n23*c.n34+d.n24*c.n44;this.n31=d.n31*c.n11+d.n32*c.n21+d.n33*c.n31+d.n34*c.n41;this.n32=d.n31*c.n12+d.n32*c.n22+d.n33*c.n32+d.n34*c.n42;this.n33=d.n31*c.n13+d.n32*c.n23+d.n33*c.n33+d.n34*c.n43;this.n34=d.n31*c.n14+d.n32*c.n24+d.n33*c.n34+d.n34*c.n44;this.n41=d.n41*c.n11+d.n42*c.n21+d.n43*c.n31+d.n44*c.n41;this.n42=d.n41*c.n12+d.n42*c.n22+d.n43*c.n32+d.n44*c.n42;this.n43=d.n41*c.n13+d.n42*c.n23+d.n43*c.n33+d.n44*c.n43;this.n44=d.n41*c.n14+d.n42*c.n24+d.n43*c.n34+d.n44*c.n44},multiplySelf:function(c){var o=this.n11,n=this.n12,k=this.n13,i=this.n14,f=this.n21,e=this.n22,d=this.n23,b=this.n24,a=this.n31,r=this.n32,q=this.n33,p=this.n34,l=this.n41,j=this.n42,h=this.n43,g=this.n44;this.n11=o*c.n11+n*c.n21+k*c.n31+i*c.n41;this.n12=o*c.n12+n*c.n22+k*c.n32+i*c.n42;this.n13=o*c.n13+n*c.n23+k*c.n33+i*c.n43;this.n14=o*c.n14+n*c.n24+k*c.n34+i*c.n44;this.n21=f*c.n11+e*c.n21+d*c.n31+b*c.n41;this.n22=f*c.n12+e*c.n22+d*c.n32+b*c.n42;this.n23=f*c.n13+e*c.n23+d*c.n33+b*c.n43;this.n24=f*c.n14+e*c.n24+d*c.n34+b*c.n44;this.n31=a*c.n11+r*c.n21+q*c.n31+p*c.n41;this.n32=a*c.n12+r*c.n22+q*c.n32+p*c.n42;this.n33=a*c.n13+r*c.n23+q*c.n33+p*c.n43;this.n34=a*c.n14+r*c.n24+q*c.n34+p*c.n44;this.n41=l*c.n11+j*c.n21+h*c.n31+g*c.n41;this.n42=l*c.n12+j*c.n22+h*c.n32+g*c.n42;this.n43=l*c.n13+j*c.n23+h*c.n33+g*c.n43;this.n44=l*c.n14+j*c.n24+h*c.n34+g*c.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(d,e,c){var b=d[e];d[e]=d[c];d[c]=b}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(b,d,c){var a=new THREE.Matrix4();a.n14=b;a.n24=d;a.n34=c;return a};THREE.Matrix4.scaleMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n11=b;a.n22=d;a.n33=c;return a};THREE.Matrix4.rotationXMatrix=function(b){var a=new THREE.Matrix4();a.n22=a.n33=Math.cos(b);a.n32=Math.sin(b);a.n23=-a.n32;return a};THREE.Matrix4.rotationYMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n33=Math.cos(b);a.n13=Math.sin(b);a.n31=-a.n13;return a};THREE.Matrix4.rotationZMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n22=Math.cos(b);a.n21=Math.sin(b);a.n12=-a.n21;return a};THREE.Matrix4.rotationAxisAngleMatrix=function(b,d){var a=new THREE.Matrix4(),f=Math.cos(d),j=Math.sin(d),i=1-f,h=b.x,g=b.y,e=b.z;a.n11=i*h*h+f;a.n12=i*h*g-j*e;a.n13=i*h*e+j*g;a.n21=i*h*g+j*e;a.n22=i*g*g+f;a.n23=i*g*e-j*h;a.n31=i*h*e-j*g;a.n32=i*g*e+j*h;a.n33=i*e*e+f;return a};THREE.Matrix4.makeInvert=function(b){var a=new THREE.Matrix4();a.n11=b.n23*b.n34*b.n42-b.n24*b.n33*b.n42+b.n24*b.n32*b.n43-b.n22*b.n34*b.n43-b.n23*b.n32*b.n44+b.n22*b.n33*b.n44;a.n12=b.n14*b.n33*b.n42-b.n13*b.n34*b.n42-b.n14*b.n32*b.n43+b.n12*b.n34*b.n43+b.n13*b.n32*b.n44-b.n12*b.n33*b.n44;a.n13=b.n13*b.n24*b.n42-b.n14*b.n23*b.n42+b.n14*b.n22*b.n43-b.n12*b.n24*b.n43-b.n13*b.n22*b.n44+b.n12*b.n23*b.n44;a.n14=b.n14*b.n23*b.n32-b.n13*b.n24*b.n32-b.n14*b.n22*b.n33+b.n12*b.n24*b.n33+b.n13*b.n22*b.n34-b.n12*b.n23*b.n34;a.n21=b.n24*b.n33*b.n41-b.n23*b.n34*b.n41-b.n24*b.n31*b.n43+b.n21*b.n34*b.n43+b.n23*b.n31*b.n44-b.n21*b.n33*b.n44;a.n22=b.n13*b.n34*b.n41-b.n14*b.n33*b.n41+b.n14*b.n31*b.n43-b.n11*b.n34*b.n43-b.n13*b.n31*b.n44+b.n11*b.n33*b.n44;a.n23=b.n14*b.n23*b.n41-b.n13*b.n24*b.n41-b.n14*b.n21*b.n43+b.n11*b.n24*b.n43+b.n13*b.n21*b.n44-b.n11*b.n23*b.n44;a.n24=b.n13*b.n24*b.n31-b.n14*b.n23*b.n31+b.n14*b.n21*b.n33-b.n11*b.n24*b.n33-b.n13*b.n21*b.n34+b.n11*b.n23*b.n34;a.n31=b.n22*b.n34*b.n41-b.n24*b.n32*b.n41+b.n24*b.n31*b.n42-b.n21*b.n34*b.n42-b.n22*b.n31*b.n44+b.n21*b.n32*b.n44;a.n32=b.n14*b.n32*b.n41-b.n12*b.n34*b.n41-b.n14*b.n31*b.n42+b.n11*b.n34*b.n42+b.n12*b.n31*b.n44-b.n11*b.n32*b.n44;a.n33=b.n13*b.n24*b.n41-b.n14*b.n22*b.n41+b.n14*b.n21*b.n42-b.n11*b.n24*b.n42-b.n12*b.n21*b.n44+b.n11*b.n22*b.n44;a.n34=b.n14*b.n22*b.n31-b.n12*b.n24*b.n31-b.n14*b.n21*b.n32+b.n11*b.n24*b.n32+b.n12*b.n21*b.n34-b.n11*b.n22*b.n34;a.n41=b.n23*b.n32*b.n41-b.n22*b.n33*b.n41-b.n23*b.n31*b.n42+b.n21*b.n33*b.n42+b.n22*b.n31*b.n43-b.n21*b.n32*b.n43;a.n42=b.n12*b.n33*b.n41-b.n13*b.n32*b.n41+b.n13*b.n31*b.n42-b.n11*b.n33*b.n42-b.n12*b.n31*b.n43+b.n11*b.n32*b.n43;a.n43=b.n13*b.n22*b.n41-b.n12*b.n23*b.n41-b.n13*b.n21*b.n42+b.n11*b.n23*b.n42+b.n12*b.n21*b.n43-b.n11*b.n22*b.n43;a.n44=b.n12*b.n23*b.n31-b.n13*b.n22*b.n31+b.n13*b.n21*b.n32-b.n11*b.n23*b.n32-b.n12*b.n21*b.n33+b.n11*b.n22*b.n33;a.multiplyScalar(1/b.determinant());return a};THREE.Matrix4.makeInvert3x3=function(o){var e=o.flatten(),l=new THREE.Matrix3(),n=e[10]*e[5]-e[6]*e[9],i=-e[10]*e[1]+e[2]*e[9],d=e[6]*e[1]-e[2]*e[5],k=-e[10]*e[4]+e[6]*e[8],g=e[10]*e[0]-e[2]*e[8],c=-e[6]*e[0]+e[2]*e[4],j=e[9]*e[4]-e[5]*e[8],f=-e[9]*e[0]+e[1]*e[8],a=e[5]*e[0]-e[1]*e[4],h=e[0]*(n)+e[1]*(k)+e[2]*(j),b;if(h==0){throw"matrix not invertible"}b=1/h;l.m[0]=b*n;l.m[1]=b*i;l.m[2]=b*d;l.m[3]=b*k;l.m[4]=b*g;l.m[5]=b*c;l.m[6]=b*j;l.m[7]=b*f;l.m[8]=b*a;return l};THREE.Matrix4.makeFrustum=function(f,r,e,o,i,h){var g,q,n,p,l,k,j;g=new THREE.Matrix4();q=2*i/(r-f);n=2*i/(o-e);p=(r+f)/(r-f);l=(o+e)/(o-e);k=-(h+i)/(h-i);j=-2*h*i/(h-i);g.n11=q;g.n12=0;g.n13=p;g.n14=0;g.n21=0;g.n22=n;g.n23=l;g.n24=0;g.n31=0;g.n32=0;g.n33=k;g.n34=j;g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(e,c,g,b){var a,f,h,d;a=g*Math.tan(e*Math.PI/360);f=-a;h=f*c;d=a*c;return THREE.Matrix4.makeFrustum(h,d,f,a,g,b)};THREE.Matrix4.makeOrtho=function(c,o,k,a,g,f){var d,l,j,i,n,e,b;d=new THREE.Matrix4();n=o-c;e=k-a;b=f-g;l=(o+c)/n;j=(k+a)/e;i=(f+g)/b;d.n11=2/n;d.n12=0;d.n13=0;d.n14=-l;d.n21=0;d.n22=2/e;d.n23=0;d.n24=-j;d.n31=0;d.n32=0;d.n33=-2/b;d.n34=-i;d.n41=0;d.n42=0;d.n43=0;d.n44=1;return d};THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3();this.positionWorld=new THREE.Vector3();this.positionScreen=new THREE.Vector3();this.normal=b||new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.normalScreen=new THREE.Vector3();this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};THREE.Face3=function(e,d,h,g,f){this.a=e;this.b=d;this.c=h;this.centroid=new THREE.Vector3();this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3();this.vertexNormals=g instanceof Array?g:[];this.material=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};THREE.Face4=function(f,e,j,i,h,g){this.a=f;this.b=e;this.c=j;this.d=i;this.centroid=new THREE.Vector3();this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3();this.vertexNormals=h instanceof Array?h:[];this.material=g instanceof Array?g:[g]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(b,a){this.u=b||0;this.v=a||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 c,b,a;for(c=0,b=this.faces.length;c0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var a=1,b=this.vertices.length;athis.bbox.x[1]){this.bbox.x[1]=vertex.position.x}}if(vertex.position.ythis.bbox.y[1]){this.bbox.y[1]=vertex.position.y}}if(vertex.position.zthis.bbox.z[1]){this.bbox.z[1]=vertex.position.z}}}}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+" )"}};THREE.Camera=function(c,b,d,a){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(c,b,d,a);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.Loader=function(){};THREE.Loader.prototype={loadAsciiOld:function(a,c){var b=document.createElement("script");b.type="text/javascript";b.onload=c;b.src=a;document.getElementsByTagName("head")[0].appendChild(b)},loadAscii:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,e,b)};d.postMessage(c)},loadBinary:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(h){var g=h.data.materials,f=h.data.buffers;THREE.Loader.prototype.loadAjaxBuffers(f,g,e,b)};d.onerror=function(f){alert("worker.onerror: "+f.message+"\n"+f.data);f.preventDefault()};d.postMessage(c)},loadAjaxBuffers:function(b,a,f,d){var e=new XMLHttpRequest(),c=d+"/"+b;e.onreadystatechange=function(){if(e.readyState==4){if(e.status==200||e.status==0){THREE.Loader.prototype.createBinModel(e.responseText,f,d,a)}else{alert("Couldn't load ["+c+"] ["+e.status+"]")}}};e.open("GET",c,true);e.overrideMimeType("text/plain; charset=x-user-defined");e.setRequestHeader("Content-Type","text/plain");e.send(null)},createBinModel:function(c,e,b,a){var d=function(aa){var I=this,h=0,x,A=[],L=[],V,T,O,U,R,P,D,C,B,y,r,q,p,o,u,t,N,K,J;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(I,a,aa);x=W(c,h);h+=x.header_bytes;V=x.vertex_index_bytes,T=x.vertex_index_bytes*2,O=x.vertex_index_bytes*3,U=x.vertex_index_bytes*3+x.material_index_bytes,R=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes,P=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*2,D=x.vertex_index_bytes,C=x.vertex_index_bytes*2,B=x.vertex_index_bytes*3,y=x.vertex_index_bytes*4,r=x.vertex_index_bytes*4+x.material_index_bytes,q=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes,p=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*2,o=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*3,u=x.uv_index_bytes,t=x.uv_index_bytes*2,N=x.uv_index_bytes,K=x.uv_index_bytes*2,J=x.uv_index_bytes*3;h+=w(h);h+=H(h);h+=G(h);h+=Q(h);h+=S(h);h+=ab(h);h+=n(h);h+=g(h);h+=k(h);h+=s(h);h+=z(h);this.computeCentroids();this.computeNormals();function W(ad,ae){var ac={signature:F(ad,ae,8),header_bytes:j(ad,ae+8),vertex_coordinate_bytes:j(ad,ae+9),normal_coordinate_bytes:j(ad,ae+10),uv_coordinate_bytes:j(ad,ae+11),vertex_index_bytes:j(ad,ae+12),normal_index_bytes:j(ad,ae+13),uv_index_bytes:j(ad,ae+14),material_index_bytes:j(ad,ae+15),nvertices:v(ad,ae+16),nnormals:v(ad,ae+16+4*1),nuvs:v(ad,ae+16+4*2),ntri_flat:v(ad,ae+16+4*3),ntri_smooth:v(ad,ae+16+4*4),ntri_flat_uv:v(ad,ae+16+4*5),ntri_smooth_uv:v(ad,ae+16+4*6),nquad_flat:v(ad,ae+16+4*7),nquad_smooth:v(ad,ae+16+4*8),nquad_flat_uv:v(ad,ae+16+4*9),nquad_smooth_uv:v(ad,ae+16+4*10)};return ac}function F(ad,ae,ac){return ad.substr(ae,ac)}function f(af,ae){var ag=j(af,ae),ai=j(af,ae+1),aj=j(af,ae+2),ak=j(af,ae+3),ad=1-(2*(ak>>7)),ah=(((ak<<1)&255)|(aj>>7))-127,ac=((aj&127)<<16)|(ai<<8)|ag;if(ac==0&&ah==-127){return 0}return ad*(1+ac*Math.pow(2,-23))*Math.pow(2,ah)}function v(ag,ah){var af=j(ag,ah),ae=j(ag,ah+1),ad=j(ag,ah+2),ac=j(ag,ah+3);return(ac<<24)+(ad<<16)+(ae<<8)+af}function Z(ae,af){var ad=j(ae,af),ac=j(ae,af+1);return(ac<<8)+ad}function i(ad,ae){var ac=j(ad,ae);return ac>127?ac-256:ac}function j(ac,ad){return ac.charCodeAt(ad)&255}function w(ai){var ae,ac,ah,ag,af=x.vertex_coordinate_bytes*3,ad=ai+x.nvertices*af;for(ae=ai;ae65535){g[n].counter+=1;d=g[n].hash+"_"+g[n].counter;if(this.materialFaceGroup[d]==undefined){this.materialFaceGroup[d]={faces:[],material:h,vertices:0}}}this.materialFaceGroup[d].faces.push(e);this.materialFaceGroup[d].vertices+=j}};THREE.Mesh.prototype.normalizeUVs=function(){var e,a,b,d,c;for(e=0,a=this.geometry.uvs.length;ecolor: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+this.linewidth+"
)"}};THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16711680);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(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}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 (
id: "+this.id+"
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+this.blending+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
)"}};THREE.MeshBasicMaterialCounter={value:0};THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16711680);this.map=null;this.opacity=1;this.shading=THREE.GouraudShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(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.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 (
id: "+this.id+"
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
shading: "+this.shading+"
blending: "+this.blending+"
wireframe: "+this.wireframe+"
wireframe_size: "+this.wireframe_linewidth+"
)"}};THREE.MeshLambertMaterialCounter={value:0};THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16711680);this.map=null;this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.specular_map=null;this.shininess=30;this.opacity=1;this.shading=THREE.GouraudShading;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_color=new THREE.Color(a.specular)}if(a.specular_map!==undefined){this.specular_map=a.specular_map}if(a.shininess!==undefined){this.shininess=a.shininess}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 (
id: "+this.id+"
color: "+this.color+"
map: "+this.map+"
ambient: "+this.ambient+"
specular: "+this.specular+"
specular_map: "+this.specular_map+"
shininess: "+this.shininess+"
alpha: "+this.opacity+"
shading: "+this.shading+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
"+ +")"}};THREE.MeshPhongMaterialCounter={value:0};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){if(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 (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;if(a){if(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 (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(b,a){this.image=b;this.mapping=a?a:THREE.UVMapping;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
mapping: "+this.mapping+"
)"}};THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(a){var b=this.objects.indexOf(a);if(b!==-1){this.objects.splice(b,1)}};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(a){var b=this.lights.indexOf(a);if(b!==-1){this.lights.splice(b,1)}};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};THREE.Projector=function(){var e=null,c,p,n=[],b,f,l=[],k,m,i=[],j,h,a=[],g=new THREE.Vector4(),d=new THREE.Matrix4(),o=new THREE.Matrix4();this.projectScene=function(J,G){var F,E,D,K,I,B,r,L,q,z,H,u,C,w,A,y,x,t,s;e=[];p=0,f=0,m=0,h=0;if(G.autoUpdateMatrix){G.updateMatrix()}d.multiply(G.projectionMatrix,G.matrix);r=J.objects;for(F=0,E=r.length;F0&&u.z<1}w=L.geometry.faces;for(I=0,B=w.length;I0&&u.z<1;if(D>0){C=L.geometry.vertices[D-1];if(H.__visible&&C.__visible){k=i[m]=i[m]||new THREE.RenderableLine();k.v1.copy(H.positionScreen);k.v2.copy(C.positionScreen);k.z=Math.max(H.positionScreen.z,C.positionScreen.z);k.material=L.material;e.push(k);m++}}}}else{if(L instanceof THREE.Particle){g.set(L.position.x,L.position.y,L.position.z,1);G.matrix.transform(g);G.projectionMatrix.transform(g);L.screen.set(g.x/g.w,g.y/g.w,g.z/g.w);if(L.screen.z>0&&L.screen.z<1){j=a[h]=a[h]||new THREE.RenderableParticle();j.x=L.screen.x;j.y=L.screen.y;j.z=L.screen.z;j.rotation=L.rotation.z;j.scale.x=L.scale.x*Math.abs(g.x/g.w-(g.x+G.projectionMatrix.n11)/(g.w+G.projectionMatrix.n14));j.scale.y=L.scale.y*Math.abs(g.y/g.w-(g.y+G.projectionMatrix.n22)/(g.w+G.projectionMatrix.n24));j.material=L.material;j.color=L.color;e.push(j);h++}}}}}e.sort(function(M,v){return v.z-M.z});return e};this.unprojectVector=function(q,s){var r=new THREE.Matrix4();r.multiply(THREE.Matrix4.makeInvert(s.matrix),THREE.Matrix4.makeInvert(s.projectionMatrix));r.transform(q);return q}};THREE.DOMRenderer=function(){THREE.Renderer.call(this);var e=null,g=new THREE.Projector(),b=document.createElement("div"),a,c,f,d;this.domElement=b;this.setSize=function(i,h){a=i;c=h;f=a/2;d=c/2};this.render=function(p,r){var q,h,i,n,o,s,l,k,j;e=g.projectScene(p,r);for(q=0,h=e.length;q0;if(C){e(ag,G)}for(af=0,O=n.length;af0){O.r+=L.r*P;O.g+=L.g*P;O.b+=L.b*P}}else{if(M instanceof THREE.PointLight){D.sub(M.position,Q.centroidWorld);D.normalize();P=Q.normalWorld.dot(D)*M.intensity;if(P>0){O.r+=L.r*P;O.g+=L.g*P;O.b+=L.b*P}}}}}function o(N,M,Q,T,S){var L,Y,W,V,R,P,U,X,O;if(B!=T.opacity){r.globalAlpha=B=T.opacity}if(T instanceof THREE.ParticleBasicMaterial){U=T.bitmap;X=U.width/2;O=U.height/2;W=Q.scale.x*v;V=Q.scale.y*h;L=W*X;Y=V*O;R=T.offset.x*W;P=T.offset.y*V;m.set(N+R-L,M+P-Y,N+R+L,M+P+Y);if(!w.instersects(m)){return}r.save();r.translate(N,M);r.rotate(-Q.rotation);r.scale(W,-V);r.translate(-X+T.offset.x,-O-T.offset.y);r.drawImage(U,0,0);r.restore();r.beginPath();r.moveTo(N-10,M);r.lineTo(N+10,M);r.moveTo(N,M-10);r.lineTo(N,M+10);r.closePath();r.strokeStyle="rgb(255,255,0)";r.stroke()}else{if(T instanceof THREE.ParticleCircleMaterial){if(C){y.copyRGB(G);g(S,Q,y);A.copyRGBA(T.color);A.multiplySelfRGB(y);A.updateStyleString()}else{A.__styleString=T.color.__styleString}L=Q.scale.x*v;Y=Q.scale.y*h;m.set(N-L,M-Y,N+L,M+Y);if(!w.instersects(m)){return}r.save();r.translate(N,M);r.rotate(-Q.rotation);r.scale(L,Y);r.beginPath();r.arc(0,0,1,0,j,true);r.closePath();r.fillStyle=A.__styleString;r.fill();r.restore()}}}function z(L,R,N,M,O,P,Q){if(B!=P.opacity){r.globalAlpha=B=P.opacity}if(P instanceof THREE.LineBasicMaterial){r.beginPath();r.moveTo(L,R);r.lineTo(N,M);r.closePath();A.__styleString=P.color.__styleString;if(f!=P.linewidth){r.lineWidth=f=P.linewidth}if(i!=A.__styleString){r.strokeStyle=i=A.__styleString}r.stroke();m.inflate(P.linewidth*2)}}function l(N,M,L,W,T,S,P,R,Q){var U,V,O;if(B!=R.opacity){r.globalAlpha=B=R.opacity}if(R.map){U=R.map.image;V=U.width-1;O=U.height-1;u.copy(P.uvs[0]);t.copy(P.uvs[1]);q.copy(P.uvs[2]);u.u*=V;u.v*=O;t.u*=V;t.v*=O;q.u*=V;q.v*=O;c(U,N,M,L,W,T,S,u.u,u.v,t.u,t.v,q.u,q.v);return}r.beginPath();r.moveTo(N,M);r.lineTo(L,W);r.lineTo(T,S);r.lineTo(N,M);r.closePath();if(R instanceof THREE.MeshBasicMaterial){A.__styleString=R.color.__styleString}else{if(R instanceof THREE.MeshLambertMaterial){if(C){y.copyRGB(G);d(Q,P,y);A.copyRGBA(R.color);A.multiplySelfRGB(y);A.updateStyleString()}else{A.__styleString=R.color.__styleString}}}if(R.wireframe){if(f!=R.wireframe_linewidth){r.lineWidth=f=R.wireframe_linewidth}if(i!=A.__styleString){r.strokeStyle=i=A.__styleString}r.stroke();m.inflate(R.wireframe_linewidth*2)}else{if(K!=A.__styleString){r.fillStyle=K=A.__styleString}r.fill()}}function k(R,Q,Z,X,M,L,T,S,aa,Y,O,N,P,V,ab){var ac,U,W;if(B!=V.opacity){r.globalAlpha=B=V.opacity}if(V.map){ac=V.map.image;U=ac.width-1;W=ac.height-1;u.copy(P.uvs[0]);t.copy(P.uvs[1]);q.copy(P.uvs[2]);p.copy(P.uvs[3]);u.u*=U;u.v*=W;t.u*=U;t.v*=W;q.u*=U;q.v*=W;p.u*=U;p.v*=W;c(ac,R,Q,Z,X,T,S,u.u,u.v,t.u,t.v,p.u,p.v);c(ac,aa,Y,M,L,O,N,t.u,t.v,q.u,q.v,p.u,p.v);return}r.beginPath();r.moveTo(R,Q);r.lineTo(Z,X);r.lineTo(M,L);r.lineTo(T,S);r.lineTo(R,Q);r.closePath();if(V instanceof THREE.MeshBasicMaterial){A.__styleString=V.color.__styleString}else{if(V instanceof THREE.MeshLambertMaterial){if(C){y.copyRGB(G);d(ab,P,y);A.copyRGBA(V.color);A.multiplySelfRGB(y);A.updateStyleString()}else{A.__styleString=V.color.__styleString}}}if(V.wireframe){if(f!=V.wireframe_linewidth){r.lineWidth=f=V.wireframe_linewidth}if(i!=A.__styleString){r.strokeStyle=i=A.__styleString}r.stroke();m.inflate(V.wireframe_linewidth*2)}else{if(K!=A.__styleString){r.fillStyle=K=A.__styleString}r.fill()}}function c(ae,T,S,Z,Y,N,L,X,W,ab,aa,P,O){var M,ad,ac,R,Q,V,U;r.beginPath();r.moveTo(T,S);r.lineTo(Z,Y);r.lineTo(N,L);r.lineTo(T,S);r.closePath();r.save();r.clip();M=X*(O-aa)-ab*O+P*aa+(ab-P)*W;ad=-(W*(N-Z)-aa*N+O*Z+(aa-O)*T)/M;ac=(aa*L+W*(Y-L)-O*Y+(O-aa)*S)/M;R=(X*(N-Z)-ab*N+P*Z+(ab-P)*T)/M;Q=-(ab*L+X*(Y-L)-P*Y+(P-ab)*S)/M;V=(X*(O*Z-aa*N)+W*(ab*N-P*Z)+(P*aa-ab*O)*T)/M;U=(X*(O*Y-aa*L)+W*(ab*L-P*Y)+(P*aa-ab*O)*S)/M;r.transform(ad,ac,R,Q,V,U);r.drawImage(ae,0,0);r.restore()}function b(M,L){F.sub(L,M);F.unit();F.multiplyScalar(0.75);L.addSelf(F);M.subSelf(F)}};THREE.SVGRenderer=function(){var x=null,r=new THREE.Projector(),t=document.createElementNS("http://www.w3.org/2000/svg","svg"),b,o,p,s,z=new THREE.Rectangle(),w=new THREE.Rectangle(),i=false,k=new THREE.Color(4294967295),v=new THREE.Color(4294967295),c=new THREE.Color(4294967295),g=new THREE.Vector3(),d=[],l=[],B,n,f,A=1;this.domElement=t;this.autoClear=true;this.setQuality=function(C){switch(C){case"high":A=1;break;case"low":A=0;break}};this.setSize=function(D,C){b=D;o=C;p=b/2;s=o/2;t.setAttribute("viewBox",(-p)+" "+(-s)+" "+b+" "+o);t.setAttribute("width",b);t.setAttribute("height",o);z.set(-p,-s,p,s)};this.clear=function(){while(t.childNodes.length>0){t.removeChild(t.childNodes[0])}};this.render=function(T,Q){var S,E,N,R,J,G,F,M,K,H,P,O,D,C,L,I;if(this.autoClear){this.clear()}x=r.projectScene(T,Q);n=0;f=0;i=T.lights.length>0;if(i){y(T,c)}for(S=0,E=x.length;S0){E.r+=C.color.r*F;E.g+=C.color.g*F;E.b+=C.color.b*F}}else{if(C instanceof THREE.PointLight){g.sub(C.position,G.centroidWorld);g.normalize();F=G.normalWorld.dot(g)*C.intensity;if(F>0){E.r+=C.color.r*F;E.g+=C.color.g*F;E.b+=C.color.b*F}}}}}function j(C,G,D,E,F){B=u(f++);B.setAttribute("cx",C);B.setAttribute("cy",G);B.setAttribute("r",D.scale.x*p);if(E instanceof THREE.ParticleCircleMaterial){if(i){v.copyRGB(c);q(F,D,v);k.copyRGBA(E.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=E.color}B.setAttribute("style","fill: "+k.__styleString)}t.appendChild(B)}function h(E,D,C,K,J,I,F,H,G){B=m(n++);B.setAttribute("d","M "+E+" "+D+" L "+C+" "+K+" L "+J+","+I+"z");if(H instanceof THREE.MeshBasicMaterial){k.__styleString=H.color.__styleString}else{if(H instanceof THREE.MeshLambertMaterial){if(i){v.copyRGB(c);a(G,F,v);k.copyRGBA(H.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k.__styleString=H.color.__styleString}}}if(H.wireframe){B.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+H.wireframe_linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: round; stroke-linejoin: round")}else{B.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+H.opacity)}t.appendChild(B)}function e(G,E,C,M,L,K,F,D,H,J,I){B=m(n++);B.setAttribute("d","M "+G+" "+E+" L "+C+" "+M+" L "+L+","+K+" L "+F+","+D+"z");if(J instanceof THREE.MeshBasicMaterial){k.__styleString=J.color.__styleString}else{if(J instanceof THREE.MeshLambertMaterial){if(i){v.copyRGB(c);a(I,H,v);k.copyRGBA(J.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k.__styleString=J.color.__styleString}}}if(J.wireframe){B.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: round; stroke-linejoin: round")}else{B.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+J.opacity)}t.appendChild(B)}function m(C){if(d[C]==null){d[C]=document.createElementNS("http://www.w3.org/2000/svg","path");if(A==0){d[C].setAttribute("shape-rendering","crispEdges")}return d[C]}return d[C]}function u(C){if(l[C]==null){l[C]=document.createElementNS("http://www.w3.org/2000/svg","circle");if(A==0){l[C].setAttribute("shape-rendering","crispEdges")}return l[C]}return l[C]}};THREE.WebGLRenderer=function(q){var h=document.createElement("canvas"),f,n,k=new THREE.Matrix4(),d,g=0,c=1,s=2,o=3,l=b(q,5);this.domElement=h;this.autoClear=true;a();i(l.directional,l.point);function b(x,y){if(x){var u,w,t,v=pointLights=maxDirLights=maxPointLights=0;for(u=0,w=x.lights.length;u= 0.0 )":"",u?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",u?"pointDiffuse += mDiffuse * pointDiffuseWeight;":"",u?"pointSpecular += mSpecular * pointSpecularWeight;":"",u?"}":"",t?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",t?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",t?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",t?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",t?"vec3 dirVector = normalize( lDirection.xyz );":"",t?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":"",t?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",t?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",t?"float dirSpecularWeight = 0.0;":"",t?"if ( dirDotNormalHalf >= 0.0 )":"",t?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",t?"dirDiffuse += mDiffuse * dirDiffuseWeight;":"",t?"dirSpecular += mSpecular * dirSpecularWeight;":"",t?"}":"","vec4 totalLight = mAmbient;",t?"totalLight += dirDiffuse + dirSpecular;":"",u?"totalLight += pointDiffuse + pointSpecular;":"","gl_FragColor = vec4( totalLight.xyz * vLightWeighting, 1.0 );","} else if ( material == 2 ) {","vec4 texelColor = texture2D( tDiffuse, vUv );","gl_FragColor = vec4( texelColor.rgb * vLightWeighting, texelColor.a );","} else if ( material == 1 ) {","gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );","} else {","gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );","}","}"];return v.join("\n")}function j(t,u){var v=[t?"#define MAX_DIR_LIGHTS "+t:"",u?"#define MAX_POINT_LIGHTS "+u:"","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","uniform vec3 cameraPosition;","uniform bool enableLighting;","uniform int pointLightNumber;","uniform int directionalLightNumber;","uniform vec3 ambientLightColor;",t?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",t?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",u?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",u?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","uniform mat4 objMatrix;","uniform mat4 viewMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat3 normalMatrix;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vLightWeighting;",u?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;","void main(void) {","vec4 mPosition = objMatrix * vec4( position, 1.0 );","vViewPosition = cameraPosition - mPosition.xyz;","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec3 transformedNormal = normalize( normalMatrix * normal );","if ( !enableLighting ) {","vLightWeighting = vec3( 1.0, 1.0, 1.0 );","} else {","vLightWeighting = ambientLightColor;",t?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",t?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",t?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",t?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",t?"}":"",u?"for( int i = 0; i < pointLightNumber; i++ ) {":"",u?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",u?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":"",u?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",u?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",u?"}":"","}","vNormal = transformedNormal;","vUv = uv;","gl_Position = projectionMatrix * mvPosition;","}"];return v.join("\n")}function i(t,u){n=f.createProgram();f.attachShader(n,r("fragment",p(t,u)));f.attachShader(n,r("vertex",j(t,u)));f.linkProgram(n);if(!f.getProgramParameter(n,f.LINK_STATUS)){alert("Could not initialise shaders")}f.useProgram(n);n.viewMatrix=f.getUniformLocation(n,"viewMatrix");n.modelViewMatrix=f.getUniformLocation(n,"modelViewMatrix");n.projectionMatrix=f.getUniformLocation(n,"projectionMatrix");n.normalMatrix=f.getUniformLocation(n,"normalMatrix");n.objMatrix=f.getUniformLocation(n,"objMatrix");n.cameraPosition=f.getUniformLocation(n,"cameraPosition");n.enableLighting=f.getUniformLocation(n,"enableLighting");n.ambientLightColor=f.getUniformLocation(n,"ambientLightColor");if(t){n.directionalLightNumber=f.getUniformLocation(n,"directionalLightNumber");n.directionalLightColor=f.getUniformLocation(n,"directionalLightColor");n.directionalLightDirection=f.getUniformLocation(n,"directionalLightDirection")}if(u){n.pointLightNumber=f.getUniformLocation(n,"pointLightNumber");n.pointLightColor=f.getUniformLocation(n,"pointLightColor");n.pointLightPosition=f.getUniformLocation(n,"pointLightPosition")}n.material=f.getUniformLocation(n,"material");n.mColor=f.getUniformLocation(n,"mColor");n.mAmbient=f.getUniformLocation(n,"mAmbient");n.mDiffuse=f.getUniformLocation(n,"mDiffuse");n.mSpecular=f.getUniformLocation(n,"mSpecular");n.mShininess=f.getUniformLocation(n,"mShininess");n.tDiffuse=f.getUniformLocation(n,"tDiffuse");f.uniform1i(n.tDiffuse,0);n.position=f.getAttribLocation(n,"position");f.enableVertexAttribArray(n.position);n.normal=f.getAttribLocation(n,"normal");f.enableVertexAttribArray(n.normal);n.uv=f.getAttribLocation(n,"uv");f.enableVertexAttribArray(n.uv);n.viewMatrixArray=new Float32Array(16);n.modelViewMatrixArray=new Float32Array(16);n.projectionMatrixArray=new Float32Array(16)}function r(u,t){var v;if(u=="fragment"){v=f.createShader(f.FRAGMENT_SHADER)}else{if(u=="vertex"){v=f.createShader(f.VERTEX_SHADER)}}f.shaderSource(v,t);f.compileShader(v);if(!f.getShaderParameter(v,f.COMPILE_STATUS)){alert(f.getShaderInfoLog(v));return null}return v}function e(){var t={MAX_VARYING_VECTORS:f.getParameter(f.MAX_VARYING_VECTORS),MAX_VERTEX_ATTRIBS:f.getParameter(f.MAX_VERTEX_ATTRIBS),MAX_TEXTURE_IMAGE_UNITS:f.getParameter(f.MAX_TEXTURE_IMAGE_UNITS),MAX_VERTEX_TEXTURE_IMAGE_UNITS:f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS),MAX_COMBINED_TEXTURE_IMAGE_UNITS:f.getParameter(f.MAX_COMBINED_TEXTURE_IMAGE_UNITS),MAX_VERTEX_UNIFORM_VECTORS:f.getParameter(f.MAX_VERTEX_UNIFORM_VECTORS),MAX_FRAGMENT_UNIFORM_VECTORS:f.getParameter(f.MAX_FRAGMENT_UNIFORM_VECTORS)};return t}function m(u){var t,v="";for(t in u){v+=t+": "+u[t]+"\n"}return v}};THREE.RenderableFace3=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.centroidScreen=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableFace4=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.v4=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.centroidScreen=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableParticle=function(){this.x=null;this.y=null;this.z=null;this.rotation=null;this.scale=new THREE.Vector2();this.color=null;this.material=null};THREE.RenderableLine=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.z=null;this.color=null;this.material=null}; \ No newline at end of file +var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};THREE.Color.prototype={setRGBA:function(f,e,c,d){this.r=f;this.g=e;this.b=c;this.a=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=(~~a).toString(16).length<8?255<<24^a:a;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},copyRGB:function(a){this.r=a.r;this.g=a.g;this.b=a.b},copyRGBA:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.a=a.a},multiplySelfRGB:function(a){this.r*=a.r;this.g*=a.g;this.b*=a.b},updateHex:function(){this.hex=~~(this.a*255)<<24^~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.a=(this.hex>>24&255)/255;this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgba("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+","+this.a+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", a: "+this.a+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(b,a){this.x=b.x-a.x;this.y=b.y-a.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,b){this.x=a||0;this.y=c||0;this.z=b||0};THREE.Vector3.prototype={set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;this.z=b.z+a.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(b,a){this.x=b.x-a.x;this.y=b.y-a.y;this.z=b.z-a.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},cross:function(b,a){this.x=b.y*a.z-b.z*a.y;this.y=b.z*a.x-b.x*a.z;this.z=b.x*a.y-b.y*a.x;return this},crossSelf:function(c){var b=this.x,a=this.y,d=this.z;this.x=a*c.z-d*c.y;this.y=d*c.x-b*c.z;this.z=b*c.y-a*c.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(d){var c=this.x-d.x,b=this.y-d.y,a=this.z-d.z;return c*c+b*b+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(){if(this.length()>0){this.multiplyScalar(1/this.length())}else{this.multiplyScalar(0)}return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){var a=0.0001;return(Math.abs(this.x)0)&&(I>0)&&(K+I<1)}}};THREE.Rectangle=function(){var e,g,h,d,a,c,f=true;function b(){a=h-e;c=d-g}this.getX=function(){return e};this.getY=function(){return g};this.getWidth=function(){return a};this.getHeight=function(){return c};this.getLeft=function(){return e};this.getTop=function(){return g};this.getRight=function(){return h};this.getBottom=function(){return d};this.set=function(l,k,j,i){f=false;e=l;g=k;h=j;d=i;b()};this.addPoint=function(i,j){if(f){f=false;e=i;g=j;h=i;d=j}else{e=Math.min(e,i);g=Math.min(g,j);h=Math.max(h,i);d=Math.max(d,j)}b()};this.addRectangle=function(i){if(f){f=false;e=i.getLeft();g=i.getTop();h=i.getRight();d=i.getBottom()}else{e=Math.min(e,i.getLeft());g=Math.min(g,i.getTop());h=Math.max(h,i.getRight());d=Math.max(d,i.getBottom())}b()};this.inflate=function(i){e-=i;g-=i;h+=i;d+=i;b()};this.minSelf=function(i){e=Math.max(e,i.getLeft());g=Math.max(g,i.getTop());h=Math.min(h,i.getRight());d=Math.min(d,i.getBottom());b()};this.instersects=function(i){return Math.min(h,i.getRight())-Math.max(e,i.getLeft())>=0&&Math.min(d,i.getBottom())-Math.max(g,i.getTop())>=0};this.empty=function(){f=true;e=0;g=0;h=0;d=0;b()};this.isEmpty=function(){return f};this.toString=function(){return"THREE.Rectangle ( left: "+e+", right: "+h+", top: "+g+", bottom: "+d+", width: "+a+", height: "+c+" )"}};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.n12=0;this.n13=0;this.n14=0;this.n21=0;this.n22=1;this.n23=0;this.n24=0;this.n31=0;this.n32=0;this.n33=1;this.n34=0;this.n41=0;this.n42=0;this.n43=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(d,c,b){var a=this._x,f=this._y,e=this._z;e.sub(d,c);e.normalize();a.cross(b,e);a.normalize();f.cross(e,a);f.normalize();this.n11=a.x;this.n12=a.y;this.n13=a.z;this.n14=-a.dot(d);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(d);this.n31=e.x;this.n32=e.y;this.n33=e.z;this.n34=-e.dot(d);this.n41=0;this.n42=0;this.n43=0;this.n44=1},transform:function(a){var d=a.x,c=a.y,b=a.z,e=a.w?a.w:1;a.x=this.n11*d+this.n12*c+this.n13*b+this.n14*e;a.y=this.n21*d+this.n22*c+this.n23*b+this.n24*e;a.z=this.n31*d+this.n32*c+this.n33*b+this.n34*e;e=this.n41*d+this.n42*c+this.n43*b+this.n44*e;if(a.w){a.w=e}else{a.x=a.x/e;a.y=a.y/e;a.z=a.z/e}return a},crossVector:function(b){var c=new THREE.Vector4();c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=(b.w)?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(d,c){this.n11=d.n11*c.n11+d.n12*c.n21+d.n13*c.n31+d.n14*c.n41;this.n12=d.n11*c.n12+d.n12*c.n22+d.n13*c.n32+d.n14*c.n42;this.n13=d.n11*c.n13+d.n12*c.n23+d.n13*c.n33+d.n14*c.n43;this.n14=d.n11*c.n14+d.n12*c.n24+d.n13*c.n34+d.n14*c.n44;this.n21=d.n21*c.n11+d.n22*c.n21+d.n23*c.n31+d.n24*c.n41;this.n22=d.n21*c.n12+d.n22*c.n22+d.n23*c.n32+d.n24*c.n42;this.n23=d.n21*c.n13+d.n22*c.n23+d.n23*c.n33+d.n24*c.n43;this.n24=d.n21*c.n14+d.n22*c.n24+d.n23*c.n34+d.n24*c.n44;this.n31=d.n31*c.n11+d.n32*c.n21+d.n33*c.n31+d.n34*c.n41;this.n32=d.n31*c.n12+d.n32*c.n22+d.n33*c.n32+d.n34*c.n42;this.n33=d.n31*c.n13+d.n32*c.n23+d.n33*c.n33+d.n34*c.n43;this.n34=d.n31*c.n14+d.n32*c.n24+d.n33*c.n34+d.n34*c.n44;this.n41=d.n41*c.n11+d.n42*c.n21+d.n43*c.n31+d.n44*c.n41;this.n42=d.n41*c.n12+d.n42*c.n22+d.n43*c.n32+d.n44*c.n42;this.n43=d.n41*c.n13+d.n42*c.n23+d.n43*c.n33+d.n44*c.n43;this.n44=d.n41*c.n14+d.n42*c.n24+d.n43*c.n34+d.n44*c.n44},multiplySelf:function(c){var o=this.n11,n=this.n12,k=this.n13,i=this.n14,f=this.n21,e=this.n22,d=this.n23,b=this.n24,a=this.n31,r=this.n32,q=this.n33,p=this.n34,l=this.n41,j=this.n42,h=this.n43,g=this.n44;this.n11=o*c.n11+n*c.n21+k*c.n31+i*c.n41;this.n12=o*c.n12+n*c.n22+k*c.n32+i*c.n42;this.n13=o*c.n13+n*c.n23+k*c.n33+i*c.n43;this.n14=o*c.n14+n*c.n24+k*c.n34+i*c.n44;this.n21=f*c.n11+e*c.n21+d*c.n31+b*c.n41;this.n22=f*c.n12+e*c.n22+d*c.n32+b*c.n42;this.n23=f*c.n13+e*c.n23+d*c.n33+b*c.n43;this.n24=f*c.n14+e*c.n24+d*c.n34+b*c.n44;this.n31=a*c.n11+r*c.n21+q*c.n31+p*c.n41;this.n32=a*c.n12+r*c.n22+q*c.n32+p*c.n42;this.n33=a*c.n13+r*c.n23+q*c.n33+p*c.n43;this.n34=a*c.n14+r*c.n24+q*c.n34+p*c.n44;this.n41=l*c.n11+j*c.n21+h*c.n31+g*c.n41;this.n42=l*c.n12+j*c.n22+h*c.n32+g*c.n42;this.n43=l*c.n13+j*c.n23+h*c.n33+g*c.n43;this.n44=l*c.n14+j*c.n24+h*c.n34+g*c.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(d,e,c){var b=d[e];d[e]=d[c];d[c]=b}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(b,d,c){var a=new THREE.Matrix4();a.n14=b;a.n24=d;a.n34=c;return a};THREE.Matrix4.scaleMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n11=b;a.n22=d;a.n33=c;return a};THREE.Matrix4.rotationXMatrix=function(b){var a=new THREE.Matrix4();a.n22=a.n33=Math.cos(b);a.n32=Math.sin(b);a.n23=-a.n32;return a};THREE.Matrix4.rotationYMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n33=Math.cos(b);a.n13=Math.sin(b);a.n31=-a.n13;return a};THREE.Matrix4.rotationZMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n22=Math.cos(b);a.n21=Math.sin(b);a.n12=-a.n21;return a};THREE.Matrix4.rotationAxisAngleMatrix=function(b,d){var a=new THREE.Matrix4(),f=Math.cos(d),j=Math.sin(d),i=1-f,h=b.x,g=b.y,e=b.z;a.n11=i*h*h+f;a.n12=i*h*g-j*e;a.n13=i*h*e+j*g;a.n21=i*h*g+j*e;a.n22=i*g*g+f;a.n23=i*g*e-j*h;a.n31=i*h*e-j*g;a.n32=i*g*e+j*h;a.n33=i*e*e+f;return a};THREE.Matrix4.makeInvert=function(b){var a=new THREE.Matrix4();a.n11=b.n23*b.n34*b.n42-b.n24*b.n33*b.n42+b.n24*b.n32*b.n43-b.n22*b.n34*b.n43-b.n23*b.n32*b.n44+b.n22*b.n33*b.n44;a.n12=b.n14*b.n33*b.n42-b.n13*b.n34*b.n42-b.n14*b.n32*b.n43+b.n12*b.n34*b.n43+b.n13*b.n32*b.n44-b.n12*b.n33*b.n44;a.n13=b.n13*b.n24*b.n42-b.n14*b.n23*b.n42+b.n14*b.n22*b.n43-b.n12*b.n24*b.n43-b.n13*b.n22*b.n44+b.n12*b.n23*b.n44;a.n14=b.n14*b.n23*b.n32-b.n13*b.n24*b.n32-b.n14*b.n22*b.n33+b.n12*b.n24*b.n33+b.n13*b.n22*b.n34-b.n12*b.n23*b.n34;a.n21=b.n24*b.n33*b.n41-b.n23*b.n34*b.n41-b.n24*b.n31*b.n43+b.n21*b.n34*b.n43+b.n23*b.n31*b.n44-b.n21*b.n33*b.n44;a.n22=b.n13*b.n34*b.n41-b.n14*b.n33*b.n41+b.n14*b.n31*b.n43-b.n11*b.n34*b.n43-b.n13*b.n31*b.n44+b.n11*b.n33*b.n44;a.n23=b.n14*b.n23*b.n41-b.n13*b.n24*b.n41-b.n14*b.n21*b.n43+b.n11*b.n24*b.n43+b.n13*b.n21*b.n44-b.n11*b.n23*b.n44;a.n24=b.n13*b.n24*b.n31-b.n14*b.n23*b.n31+b.n14*b.n21*b.n33-b.n11*b.n24*b.n33-b.n13*b.n21*b.n34+b.n11*b.n23*b.n34;a.n31=b.n22*b.n34*b.n41-b.n24*b.n32*b.n41+b.n24*b.n31*b.n42-b.n21*b.n34*b.n42-b.n22*b.n31*b.n44+b.n21*b.n32*b.n44;a.n32=b.n14*b.n32*b.n41-b.n12*b.n34*b.n41-b.n14*b.n31*b.n42+b.n11*b.n34*b.n42+b.n12*b.n31*b.n44-b.n11*b.n32*b.n44;a.n33=b.n13*b.n24*b.n41-b.n14*b.n22*b.n41+b.n14*b.n21*b.n42-b.n11*b.n24*b.n42-b.n12*b.n21*b.n44+b.n11*b.n22*b.n44;a.n34=b.n14*b.n22*b.n31-b.n12*b.n24*b.n31-b.n14*b.n21*b.n32+b.n11*b.n24*b.n32+b.n12*b.n21*b.n34-b.n11*b.n22*b.n34;a.n41=b.n23*b.n32*b.n41-b.n22*b.n33*b.n41-b.n23*b.n31*b.n42+b.n21*b.n33*b.n42+b.n22*b.n31*b.n43-b.n21*b.n32*b.n43;a.n42=b.n12*b.n33*b.n41-b.n13*b.n32*b.n41+b.n13*b.n31*b.n42-b.n11*b.n33*b.n42-b.n12*b.n31*b.n43+b.n11*b.n32*b.n43;a.n43=b.n13*b.n22*b.n41-b.n12*b.n23*b.n41-b.n13*b.n21*b.n42+b.n11*b.n23*b.n42+b.n12*b.n21*b.n43-b.n11*b.n22*b.n43;a.n44=b.n12*b.n23*b.n31-b.n13*b.n22*b.n31+b.n13*b.n21*b.n32-b.n11*b.n23*b.n32-b.n12*b.n21*b.n33+b.n11*b.n22*b.n33;a.multiplyScalar(1/b.determinant());return a};THREE.Matrix4.makeInvert3x3=function(o){var e=o.flatten(),l=new THREE.Matrix3(),n=e[10]*e[5]-e[6]*e[9],i=-e[10]*e[1]+e[2]*e[9],d=e[6]*e[1]-e[2]*e[5],k=-e[10]*e[4]+e[6]*e[8],g=e[10]*e[0]-e[2]*e[8],c=-e[6]*e[0]+e[2]*e[4],j=e[9]*e[4]-e[5]*e[8],f=-e[9]*e[0]+e[1]*e[8],a=e[5]*e[0]-e[1]*e[4],h=e[0]*(n)+e[1]*(k)+e[2]*(j),b;if(h==0){throw"matrix not invertible"}b=1/h;l.m[0]=b*n;l.m[1]=b*i;l.m[2]=b*d;l.m[3]=b*k;l.m[4]=b*g;l.m[5]=b*c;l.m[6]=b*j;l.m[7]=b*f;l.m[8]=b*a;return l};THREE.Matrix4.makeFrustum=function(f,r,e,o,i,h){var g,q,n,p,l,k,j;g=new THREE.Matrix4();q=2*i/(r-f);n=2*i/(o-e);p=(r+f)/(r-f);l=(o+e)/(o-e);k=-(h+i)/(h-i);j=-2*h*i/(h-i);g.n11=q;g.n12=0;g.n13=p;g.n14=0;g.n21=0;g.n22=n;g.n23=l;g.n24=0;g.n31=0;g.n32=0;g.n33=k;g.n34=j;g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(e,c,g,b){var a,f,h,d;a=g*Math.tan(e*Math.PI/360);f=-a;h=f*c;d=a*c;return THREE.Matrix4.makeFrustum(h,d,f,a,g,b)};THREE.Matrix4.makeOrtho=function(c,o,k,a,g,f){var d,l,j,i,n,e,b;d=new THREE.Matrix4();n=o-c;e=k-a;b=f-g;l=(o+c)/n;j=(k+a)/e;i=(f+g)/b;d.n11=2/n;d.n12=0;d.n13=0;d.n14=-l;d.n21=0;d.n22=2/e;d.n23=0;d.n24=-j;d.n31=0;d.n32=0;d.n33=-2/b;d.n34=-i;d.n41=0;d.n42=0;d.n43=0;d.n44=1;return d};THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3();this.positionWorld=new THREE.Vector3();this.positionScreen=new THREE.Vector3();this.normal=b||new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.normalScreen=new THREE.Vector3();this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};THREE.Face3=function(e,d,h,g,f){this.a=e;this.b=d;this.c=h;this.centroid=new THREE.Vector3();this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3();this.vertexNormals=g instanceof Array?g:[];this.material=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};THREE.Face4=function(f,e,j,i,h,g){this.a=f;this.b=e;this.c=j;this.d=i;this.centroid=new THREE.Vector3();this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3();this.vertexNormals=h instanceof Array?h:[];this.material=g instanceof Array?g:[g]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(b,a){this.u=b||0;this.v=a||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 c,b,a;for(c=0,b=this.faces.length;c0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var a=1,b=this.vertices.length;athis.bbox.x[1]){this.bbox.x[1]=vertex.position.x}}if(vertex.position.ythis.bbox.y[1]){this.bbox.y[1]=vertex.position.y}}if(vertex.position.zthis.bbox.z[1]){this.bbox.z[1]=vertex.position.z}}}}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+" )"}};THREE.Camera=function(c,b,d,a){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(c,b,d,a);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.Loader=function(){};THREE.Loader.prototype={loadAsciiOld:function(a,c){var b=document.createElement("script");b.type="text/javascript";b.onload=c;b.src=a;document.getElementsByTagName("head")[0].appendChild(b)},loadAscii:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,e,b)};d.postMessage(c)},loadBinary:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(h){var g=h.data.materials,f=h.data.buffers;THREE.Loader.prototype.loadAjaxBuffers(f,g,e,b)};d.onerror=function(f){alert("worker.onerror: "+f.message+"\n"+f.data);f.preventDefault()};d.postMessage(c)},loadAjaxBuffers:function(b,a,f,d){var e=new XMLHttpRequest(),c=d+"/"+b;e.onreadystatechange=function(){if(e.readyState==4){if(e.status==200||e.status==0){THREE.Loader.prototype.createBinModel(e.responseText,f,d,a)}else{alert("Couldn't load ["+c+"] ["+e.status+"]")}}};e.open("GET",c,true);e.overrideMimeType("text/plain; charset=x-user-defined");e.setRequestHeader("Content-Type","text/plain");e.send(null)},createBinModel:function(c,e,b,a){var d=function(aa){var I=this,h=0,x,A=[],L=[],V,T,O,U,R,P,D,C,B,y,r,q,p,o,u,t,N,K,J;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(I,a,aa);x=W(c,h);h+=x.header_bytes;V=x.vertex_index_bytes,T=x.vertex_index_bytes*2,O=x.vertex_index_bytes*3,U=x.vertex_index_bytes*3+x.material_index_bytes,R=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes,P=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*2,D=x.vertex_index_bytes,C=x.vertex_index_bytes*2,B=x.vertex_index_bytes*3,y=x.vertex_index_bytes*4,r=x.vertex_index_bytes*4+x.material_index_bytes,q=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes,p=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*2,o=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*3,u=x.uv_index_bytes,t=x.uv_index_bytes*2,N=x.uv_index_bytes,K=x.uv_index_bytes*2,J=x.uv_index_bytes*3;h+=w(h);h+=H(h);h+=G(h);h+=Q(h);h+=S(h);h+=ab(h);h+=n(h);h+=g(h);h+=k(h);h+=s(h);h+=z(h);this.computeCentroids();this.computeNormals();function W(ad,ae){var ac={signature:F(ad,ae,8),header_bytes:j(ad,ae+8),vertex_coordinate_bytes:j(ad,ae+9),normal_coordinate_bytes:j(ad,ae+10),uv_coordinate_bytes:j(ad,ae+11),vertex_index_bytes:j(ad,ae+12),normal_index_bytes:j(ad,ae+13),uv_index_bytes:j(ad,ae+14),material_index_bytes:j(ad,ae+15),nvertices:v(ad,ae+16),nnormals:v(ad,ae+16+4*1),nuvs:v(ad,ae+16+4*2),ntri_flat:v(ad,ae+16+4*3),ntri_smooth:v(ad,ae+16+4*4),ntri_flat_uv:v(ad,ae+16+4*5),ntri_smooth_uv:v(ad,ae+16+4*6),nquad_flat:v(ad,ae+16+4*7),nquad_smooth:v(ad,ae+16+4*8),nquad_flat_uv:v(ad,ae+16+4*9),nquad_smooth_uv:v(ad,ae+16+4*10)};return ac}function F(ad,ae,ac){return ad.substr(ae,ac)}function f(af,ae){var ag=j(af,ae),ai=j(af,ae+1),aj=j(af,ae+2),ak=j(af,ae+3),ad=1-(2*(ak>>7)),ah=(((ak<<1)&255)|(aj>>7))-127,ac=((aj&127)<<16)|(ai<<8)|ag;if(ac==0&&ah==-127){return 0}return ad*(1+ac*Math.pow(2,-23))*Math.pow(2,ah)}function v(ag,ah){var af=j(ag,ah),ae=j(ag,ah+1),ad=j(ag,ah+2),ac=j(ag,ah+3);return(ac<<24)+(ad<<16)+(ae<<8)+af}function Z(ae,af){var ad=j(ae,af),ac=j(ae,af+1);return(ac<<8)+ad}function i(ad,ae){var ac=j(ad,ae);return ac>127?ac-256:ac}function j(ac,ad){return ac.charCodeAt(ad)&255}function w(ai){var ae,ac,ah,ag,af=x.vertex_coordinate_bytes*3,ad=ai+x.nvertices*af;for(ae=ai;ae65535){g[n].counter+=1;d=g[n].hash+"_"+g[n].counter;if(this.materialFaceGroup[d]==undefined){this.materialFaceGroup[d]={faces:[],material:h,vertices:0}}}this.materialFaceGroup[d].faces.push(e);this.materialFaceGroup[d].vertices+=j}};THREE.Mesh.prototype.normalizeUVs=function(){var e,a,b,d,c;for(e=0,a=this.geometry.uvs.length;ecolor: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+this.linewidth+"
)"}};THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16711680);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(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}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 (
id: "+this.id+"
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+this.blending+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
)"}};THREE.MeshBasicMaterialCounter={value:0};THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1000;this.opacity=1;this.wireframe=false;this.wireframe_linewidth=1;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.wireframe!==undefined){this.wireframe=a.wireframe}if(a.wireframe_linewidth!==undefined){this.wireframe_linewidth=a.wireframe_linewidth}}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=this.far-this.near;this.toString=function(){return"THREE.MeshDepthMaterial"}};THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16711680);this.map=null;this.opacity=1;this.shading=THREE.GouraudShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(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.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 (
id: "+this.id+"
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
shading: "+this.shading+"
blending: "+this.blending+"
wireframe: "+this.wireframe+"
wireframe_size: "+this.wireframe_linewidth+"
)"}};THREE.MeshLambertMaterialCounter={value:0};THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16711680);this.map=null;this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.specular_map=null;this.shininess=30;this.opacity=1;this.shading=THREE.GouraudShading;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_color=new THREE.Color(a.specular)}if(a.specular_map!==undefined){this.specular_map=a.specular_map}if(a.shininess!==undefined){this.shininess=a.shininess}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 (
id: "+this.id+"
color: "+this.color+"
map: "+this.map+"
ambient: "+this.ambient+"
specular: "+this.specular+"
specular_map: "+this.specular_map+"
shininess: "+this.shininess+"
alpha: "+this.opacity+"
shading: "+this.shading+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
"+ +")"}};THREE.MeshPhongMaterialCounter={value:0};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){if(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 (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;if(a){if(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 (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(b,a){this.image=b;this.mapping=a?a:THREE.UVMapping;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
mapping: "+this.mapping+"
)"}};THREE.UVMapping=0;THREE.ReflectionMap=1;THREE.CubeMap=2;THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(a){var b=this.objects.indexOf(a);if(b!==-1){this.objects.splice(b,1)}};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(a){var b=this.lights.indexOf(a);if(b!==-1){this.lights.splice(b,1)}};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};THREE.Projector=function(){var e=null,c,p,n=[],b,f,l=[],k,m,i=[],j,h,a=[],g=new THREE.Vector4(),d=new THREE.Matrix4(),o=new THREE.Matrix4();this.projectScene=function(J,G){var F,E,D,K,I,B,r,L,q,z,H,u,C,w,A,y,x,t,s;e=[];p=0,f=0,m=0,h=0;if(G.autoUpdateMatrix){G.updateMatrix()}d.multiply(G.projectionMatrix,G.matrix);r=J.objects;for(F=0,E=r.length;F0&&u.z<1}w=L.geometry.faces;for(I=0,B=w.length;I0&&u.z<1;if(D>0){C=L.geometry.vertices[D-1];if(H.__visible&&C.__visible){k=i[m]=i[m]||new THREE.RenderableLine();k.v1.copy(H.positionScreen);k.v2.copy(C.positionScreen);k.z=Math.max(H.positionScreen.z,C.positionScreen.z);k.material=L.material;e.push(k);m++}}}}else{if(L instanceof THREE.Particle){g.set(L.position.x,L.position.y,L.position.z,1);d.transform(g);g.z/=g.w;if(g.z>0&&g.z<1){j=a[h]=a[h]||new THREE.RenderableParticle();j.x=g.x/g.w;j.y=g.y/g.w;j.z=g.z;j.rotation=L.rotation.z;j.scale.x=L.scale.x*Math.abs(j.x-(g.x+G.projectionMatrix.n11)/(g.w+G.projectionMatrix.n14));j.scale.y=L.scale.y*Math.abs(j.y-(g.y+G.projectionMatrix.n22)/(g.w+G.projectionMatrix.n24));j.material=L.material;e.push(j);h++}}}}}e.sort(function(M,v){return v.z-M.z});return e};this.unprojectVector=function(q,s){var r=new THREE.Matrix4();r.multiply(THREE.Matrix4.makeInvert(s.matrix),THREE.Matrix4.makeInvert(s.projectionMatrix));r.transform(q);return q}};THREE.DOMRenderer=function(){THREE.Renderer.call(this);var e=null,g=new THREE.Projector(),b=document.createElement("div"),a,c,f,d;this.domElement=b;this.setSize=function(i,h){a=i;c=h;f=a/2;d=c/2};this.render=function(p,r){var q,h,i,n,o,s,l,k,j;e=g.projectScene(p,r);for(q=0,h=e.length;q0;if(D){e(ah,H)}for(ag=0,P=n.length;ag0){P.r+=M.r*Q;P.g+=M.g*Q;P.b+=M.b*Q}}else{if(N instanceof THREE.PointLight){E.sub(N.position,R.centroidWorld);E.normalize();Q=R.normalWorld.dot(E)*N.intensity;if(Q>0){P.r+=M.r*Q;P.g+=M.g*Q;P.b+=M.b*Q}}}}}function o(O,N,R,U,T){var M,Z,X,W,S,Q,V,Y,P;if(B!=U.opacity){r.globalAlpha=B=U.opacity}if(U instanceof THREE.ParticleBasicMaterial){V=U.bitmap;Y=V.width/2;P=V.height/2;X=R.scale.x*v;W=R.scale.y*h;M=X*Y;Z=W*P;S=U.offset.x*X;Q=U.offset.y*W;m.set(O+S-M,N+Q-Z,O+S+M,N+Q+Z);if(!w.instersects(m)){return}r.save();r.translate(O,N);r.rotate(-R.rotation);r.scale(X,-W);r.translate(-Y+U.offset.x,-P-U.offset.y);r.drawImage(V,0,0);r.restore();r.beginPath();r.moveTo(O-10,N);r.lineTo(O+10,N);r.moveTo(O,N-10);r.lineTo(O,N+10);r.closePath();r.strokeStyle="rgb(255,255,0)";r.stroke()}else{if(U instanceof THREE.ParticleCircleMaterial){if(D){y.copyRGB(H);g(T,R,y);A.copyRGBA(U.color);A.multiplySelfRGB(y);A.updateStyleString()}else{A.__styleString=U.color.__styleString}M=R.scale.x*v;Z=R.scale.y*h;m.set(O-M,N-Z,O+M,N+Z);if(!w.instersects(m)){return}r.save();r.translate(O,N);r.rotate(-R.rotation);r.scale(M,Z);r.beginPath();r.arc(0,0,1,0,k,true);r.closePath();r.fillStyle=A.__styleString;r.fill();r.restore()}}}function z(M,S,O,N,P,Q,R){if(B!=Q.opacity){r.globalAlpha=B=Q.opacity}if(Q instanceof THREE.LineBasicMaterial){r.beginPath();r.moveTo(M,S);r.lineTo(O,N);r.closePath();A.__styleString=Q.color.__styleString;if(f!=Q.linewidth){r.lineWidth=f=Q.linewidth}if(i!=A.__styleString){r.strokeStyle=i=A.__styleString}r.stroke();m.inflate(Q.linewidth*2)}}function l(O,N,M,X,U,T,Q,S,R){var V,W,P;if(B!=S.opacity){r.globalAlpha=B=S.opacity}if(S.map){V=S.map.image;W=V.width-1;P=V.height-1;u.copy(Q.uvs[0]);t.copy(Q.uvs[1]);q.copy(Q.uvs[2]);u.u*=W;u.v*=P;t.u*=W;t.v*=P;q.u*=W;q.v*=P;c(V,O,N,M,X,U,T,u.u,u.v,t.u,t.v,q.u,q.v);return}r.beginPath();r.moveTo(O,N);r.lineTo(M,X);r.lineTo(U,T);r.lineTo(O,N);r.closePath();if(S instanceof THREE.MeshBasicMaterial){A.__styleString=S.color.__styleString}else{if(S instanceof THREE.MeshDepthMaterial){C=1-(S.__2near/(S.__farPlusNear-Q.z*S.__farMinusNear));A.setRGBA(C,C,C,1)}else{if(S instanceof THREE.MeshLambertMaterial){if(D){y.copyRGB(H);d(R,Q,y);A.copyRGBA(S.color);A.multiplySelfRGB(y);A.updateStyleString()}else{A.__styleString=S.color.__styleString}}}}if(S.wireframe){if(f!=S.wireframe_linewidth){r.lineWidth=f=S.wireframe_linewidth}if(i!=A.__styleString){r.strokeStyle=i=A.__styleString}r.stroke();m.inflate(S.wireframe_linewidth*2)}else{if(L!=A.__styleString){r.fillStyle=L=A.__styleString}r.fill()}}function j(S,R,aa,Y,N,M,U,T,ab,Z,P,O,Q,W,ac){var ad,V,X;if(B!=W.opacity){r.globalAlpha=B=W.opacity}if(W.map){ad=W.map.image;V=ad.width-1;X=ad.height-1;u.copy(Q.uvs[0]);t.copy(Q.uvs[1]);q.copy(Q.uvs[2]);p.copy(Q.uvs[3]);u.u*=V;u.v*=X;t.u*=V;t.v*=X;q.u*=V;q.v*=X;p.u*=V;p.v*=X;c(ad,S,R,aa,Y,U,T,u.u,u.v,t.u,t.v,p.u,p.v);c(ad,ab,Z,N,M,P,O,t.u,t.v,q.u,q.v,p.u,p.v);return}r.beginPath();r.moveTo(S,R);r.lineTo(aa,Y);r.lineTo(N,M);r.lineTo(U,T);r.lineTo(S,R);r.closePath();if(W instanceof THREE.MeshBasicMaterial){A.__styleString=W.color.__styleString}else{if(W instanceof THREE.MeshDepthMaterial){C=1-(W.__2near/(W.__farPlusNear-Q.z*W.__farMinusNear));A.setRGBA(C,C,C,1)}else{if(W instanceof THREE.MeshLambertMaterial){if(D){y.copyRGB(H);d(ac,Q,y);A.copyRGBA(W.color);A.multiplySelfRGB(y);A.updateStyleString()}else{A.__styleString=W.color.__styleString}}}}if(W.wireframe){if(f!=W.wireframe_linewidth){r.lineWidth=f=W.wireframe_linewidth}if(i!=A.__styleString){r.strokeStyle=i=A.__styleString}r.stroke();m.inflate(W.wireframe_linewidth*2)}else{if(L!=A.__styleString){r.fillStyle=L=A.__styleString}r.fill()}}function c(af,Z,R,X,Q,V,O,W,P,U,N,T,M){r.beginPath();r.moveTo(Z,R);r.lineTo(X,Q);r.lineTo(V,O);r.closePath();X-=Z;Q-=R;V-=Z;O-=R;U-=W;N-=P;T-=W;M-=P;var S=1/(U*M-T*N),ae=(M*X-N*V)*S,ad=(M*Q-N*O)*S,ac=(U*V-T*X)*S,ab=(U*O-T*Q)*S,aa=Z-ae*W-ac*P,Y=R-ad*W-ab*P;r.save();r.transform(ae,ad,ac,ab,aa,Y);r.clip();r.drawImage(af,0,0);r.restore()}function b(N,M){G.sub(M,N);G.unit();G.multiplyScalar(0.75);M.addSelf(G);N.subSelf(G)}};THREE.SVGRenderer=function(){var y=null,r=new THREE.Projector(),t=document.createElementNS("http://www.w3.org/2000/svg","svg"),b,o,p,s,A=new THREE.Rectangle(),w=new THREE.Rectangle(),i=false,k=new THREE.Color(4294967295),v=new THREE.Color(4294967295),c=new THREE.Color(4294967295),x,g=new THREE.Vector3(),d=[],l=[],C,n,f,B=1;this.domElement=t;this.autoClear=true;this.setQuality=function(D){switch(D){case"high":B=1;break;case"low":B=0;break}};this.setSize=function(E,D){b=E;o=D;p=b/2;s=o/2;t.setAttribute("viewBox",(-p)+" "+(-s)+" "+b+" "+o);t.setAttribute("width",b);t.setAttribute("height",o);A.set(-p,-s,p,s)};this.clear=function(){while(t.childNodes.length>0){t.removeChild(t.childNodes[0])}};this.render=function(U,R){var T,F,O,S,K,H,G,N,L,I,Q,P,E,D,M,J;if(this.autoClear){this.clear()}y=r.projectScene(U,R);n=0;f=0;i=U.lights.length>0;if(i){z(U,c)}for(T=0,F=y.length;T0){F.r+=D.color.r*G;F.g+=D.color.g*G;F.b+=D.color.b*G}}else{if(D instanceof THREE.PointLight){g.sub(D.position,H.centroidWorld);g.normalize();G=H.normalWorld.dot(g)*D.intensity;if(G>0){F.r+=D.color.r*G;F.g+=D.color.g*G;F.b+=D.color.b*G}}}}}function j(D,H,E,F,G){C=u(f++);C.setAttribute("cx",D);C.setAttribute("cy",H);C.setAttribute("r",E.scale.x*p);if(F instanceof THREE.ParticleCircleMaterial){if(i){v.copyRGB(c);q(G,E,v);k.copyRGBA(F.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=F.color}C.setAttribute("style","fill: "+k.__styleString)}t.appendChild(C)}function h(F,E,D,L,K,J,G,I,H){C=m(n++);C.setAttribute("d","M "+F+" "+E+" L "+D+" "+L+" L "+K+","+J+"z");if(I instanceof THREE.MeshBasicMaterial){k.__styleString=I.color.__styleString}else{if(I instanceof THREE.MeshDepthMaterial){x=1-(I.__2near/(I.__farPlusNear-G.z*I.__farMinusNear));k.setRGBA(x,x,x,1)}else{if(I instanceof THREE.MeshLambertMaterial){if(i){v.copyRGB(c);a(H,G,v);k.copyRGBA(I.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k.__styleString=I.color.__styleString}}}}if(I.wireframe){C.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+I.wireframe_linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: round; stroke-linejoin: round")}else{C.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+I.opacity)}t.appendChild(C)}function e(H,F,D,N,M,L,G,E,I,K,J){C=m(n++);C.setAttribute("d","M "+H+" "+F+" L "+D+" "+N+" L "+M+","+L+" L "+G+","+E+"z");if(K instanceof THREE.MeshBasicMaterial){k.__styleString=K.color.__styleString}else{if(K instanceof THREE.MeshLambertMaterial){if(i){v.copyRGB(c);a(J,I,v);k.copyRGBA(K.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k.__styleString=K.color.__styleString}}}if(K.wireframe){C.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+K.wireframe_linewidth+"; stroke-opacity: "+K.opacity+"; stroke-linecap: round; stroke-linejoin: round")}else{C.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+K.opacity)}t.appendChild(C)}function m(D){if(d[D]==null){d[D]=document.createElementNS("http://www.w3.org/2000/svg","path");if(B==0){d[D].setAttribute("shape-rendering","crispEdges")}return d[D]}return d[D]}function u(D){if(l[D]==null){l[D]=document.createElementNS("http://www.w3.org/2000/svg","circle");if(B==0){l[D].setAttribute("shape-rendering","crispEdges")}return l[D]}return l[D]}};THREE.WebGLRenderer=function(q){var h=document.createElement("canvas"),f,n,k=new THREE.Matrix4(),d,g=0,c=1,s=2,o=3,l=b(q,5);this.domElement=h;this.autoClear=true;a();i(l.directional,l.point);function b(x,y){if(x){var u,w,t,v=pointLights=maxDirLights=maxPointLights=0;for(u=0,w=x.lights.length;u= 0.0 )":"",u?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",u?"pointDiffuse += mDiffuse * pointDiffuseWeight;":"",u?"pointSpecular += mSpecular * pointSpecularWeight;":"",u?"}":"",t?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",t?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",t?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",t?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",t?"vec3 dirVector = normalize( lDirection.xyz );":"",t?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":"",t?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",t?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",t?"float dirSpecularWeight = 0.0;":"",t?"if ( dirDotNormalHalf >= 0.0 )":"",t?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",t?"dirDiffuse += mDiffuse * dirDiffuseWeight;":"",t?"dirSpecular += mSpecular * dirSpecularWeight;":"",t?"}":"","vec4 totalLight = mAmbient;",t?"totalLight += dirDiffuse + dirSpecular;":"",u?"totalLight += pointDiffuse + pointSpecular;":"","gl_FragColor = vec4( totalLight.xyz * vLightWeighting, 1.0 );","} else if ( material == 2 ) {","vec4 texelColor = texture2D( tDiffuse, vUv );","gl_FragColor = vec4( texelColor.rgb * vLightWeighting, texelColor.a );","} else if ( material == 1 ) {","gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );","} else {","gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );","}","}"];return v.join("\n")}function j(t,u){var v=[t?"#define MAX_DIR_LIGHTS "+t:"",u?"#define MAX_POINT_LIGHTS "+u:"","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","uniform vec3 cameraPosition;","uniform bool enableLighting;","uniform int pointLightNumber;","uniform int directionalLightNumber;","uniform vec3 ambientLightColor;",t?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",t?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",u?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",u?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","uniform mat4 objMatrix;","uniform mat4 viewMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat3 normalMatrix;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vLightWeighting;",u?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;","void main(void) {","vec4 mPosition = objMatrix * vec4( position, 1.0 );","vViewPosition = cameraPosition - mPosition.xyz;","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec3 transformedNormal = normalize( normalMatrix * normal );","if ( !enableLighting ) {","vLightWeighting = vec3( 1.0, 1.0, 1.0 );","} else {","vLightWeighting = ambientLightColor;",t?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",t?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",t?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",t?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",t?"}":"",u?"for( int i = 0; i < pointLightNumber; i++ ) {":"",u?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",u?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":"",u?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",u?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",u?"}":"","}","vNormal = transformedNormal;","vUv = uv;","gl_Position = projectionMatrix * mvPosition;","}"];return v.join("\n")}function i(t,u){n=f.createProgram();f.attachShader(n,r("fragment",p(t,u)));f.attachShader(n,r("vertex",j(t,u)));f.linkProgram(n);if(!f.getProgramParameter(n,f.LINK_STATUS)){alert("Could not initialise shaders")}f.useProgram(n);n.viewMatrix=f.getUniformLocation(n,"viewMatrix");n.modelViewMatrix=f.getUniformLocation(n,"modelViewMatrix");n.projectionMatrix=f.getUniformLocation(n,"projectionMatrix");n.normalMatrix=f.getUniformLocation(n,"normalMatrix");n.objMatrix=f.getUniformLocation(n,"objMatrix");n.cameraPosition=f.getUniformLocation(n,"cameraPosition");n.enableLighting=f.getUniformLocation(n,"enableLighting");n.ambientLightColor=f.getUniformLocation(n,"ambientLightColor");if(t){n.directionalLightNumber=f.getUniformLocation(n,"directionalLightNumber");n.directionalLightColor=f.getUniformLocation(n,"directionalLightColor");n.directionalLightDirection=f.getUniformLocation(n,"directionalLightDirection")}if(u){n.pointLightNumber=f.getUniformLocation(n,"pointLightNumber");n.pointLightColor=f.getUniformLocation(n,"pointLightColor");n.pointLightPosition=f.getUniformLocation(n,"pointLightPosition")}n.material=f.getUniformLocation(n,"material");n.mColor=f.getUniformLocation(n,"mColor");n.mAmbient=f.getUniformLocation(n,"mAmbient");n.mDiffuse=f.getUniformLocation(n,"mDiffuse");n.mSpecular=f.getUniformLocation(n,"mSpecular");n.mShininess=f.getUniformLocation(n,"mShininess");n.tDiffuse=f.getUniformLocation(n,"tDiffuse");f.uniform1i(n.tDiffuse,0);n.position=f.getAttribLocation(n,"position");f.enableVertexAttribArray(n.position);n.normal=f.getAttribLocation(n,"normal");f.enableVertexAttribArray(n.normal);n.uv=f.getAttribLocation(n,"uv");f.enableVertexAttribArray(n.uv);n.viewMatrixArray=new Float32Array(16);n.modelViewMatrixArray=new Float32Array(16);n.projectionMatrixArray=new Float32Array(16)}function r(u,t){var v;if(u=="fragment"){v=f.createShader(f.FRAGMENT_SHADER)}else{if(u=="vertex"){v=f.createShader(f.VERTEX_SHADER)}}f.shaderSource(v,t);f.compileShader(v);if(!f.getShaderParameter(v,f.COMPILE_STATUS)){alert(f.getShaderInfoLog(v));return null}return v}function e(){var t={MAX_VARYING_VECTORS:f.getParameter(f.MAX_VARYING_VECTORS),MAX_VERTEX_ATTRIBS:f.getParameter(f.MAX_VERTEX_ATTRIBS),MAX_TEXTURE_IMAGE_UNITS:f.getParameter(f.MAX_TEXTURE_IMAGE_UNITS),MAX_VERTEX_TEXTURE_IMAGE_UNITS:f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS),MAX_COMBINED_TEXTURE_IMAGE_UNITS:f.getParameter(f.MAX_COMBINED_TEXTURE_IMAGE_UNITS),MAX_VERTEX_UNIFORM_VECTORS:f.getParameter(f.MAX_VERTEX_UNIFORM_VECTORS),MAX_FRAGMENT_UNIFORM_VECTORS:f.getParameter(f.MAX_FRAGMENT_UNIFORM_VECTORS)};return t}function m(u){var t,v="";for(t in u){v+=t+": "+u[t]+"\n"}return v}};THREE.RenderableFace3=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.centroidScreen=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableFace4=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.v4=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.centroidScreen=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableParticle=function(){this.x=null;this.y=null;this.z=null;this.rotation=null;this.scale=new THREE.Vector2();this.color=null;this.material=null};THREE.RenderableLine=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.z=null;this.color=null;this.material=null}; \ No newline at end of file diff --git a/examples/camera_free.html b/examples/camera_free.html index 4fb24ef3..ec5d6f22 100644 --- a/examples/camera_free.html +++ b/examples/camera_free.html @@ -42,12 +42,13 @@ + - + diff --git a/examples/camera_orthographic.html b/examples/camera_orthographic.html index f478405f..2ad93535 100644 --- a/examples/camera_orthographic.html +++ b/examples/camera_orthographic.html @@ -42,7 +42,7 @@ container.appendChild( info ); camera = new THREE.Camera( 45, window.innerWidth / window.innerHeight, 1, 10000 ); - camera.projectionMatrix = THREE.Matrix4.makeOrtho( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, -2000, 1000 ); + camera.projectionMatrix = THREE.Matrix4.makeOrtho( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 2000, 1000 ); camera.position.x = 200; camera.position.y = 100; camera.position.z = 200; diff --git a/examples/interactive_voxelpainter.html b/examples/interactive_voxelpainter.html index 9edb89f5..3e886d08 100644 --- a/examples/interactive_voxelpainter.html +++ b/examples/interactive_voxelpainter.html @@ -14,49 +14,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/examples/materials_depth.html b/examples/materials_depth.html new file mode 100644 index 00000000..2de76576 --- /dev/null +++ b/examples/materials_depth.html @@ -0,0 +1,263 @@ + + + + three.js - depth material + + + + + + + + + + + + + + + + diff --git a/examples/test.html b/examples/test.html index 9f81aa78..ec118978 100644 --- a/examples/test.html +++ b/examples/test.html @@ -41,12 +41,13 @@ + - + diff --git a/src/core/Matrix4.js b/src/core/Matrix4.js index 52bfd513..99966975 100644 --- a/src/core/Matrix4.js +++ b/src/core/Matrix4.js @@ -55,13 +55,13 @@ THREE.Matrix4.prototype = { this.n11 = x.x; this.n12 = x.y; this.n13 = x.z; this.n14 = - x.dot( eye ); this.n21 = y.x; this.n22 = y.y; this.n23 = y.z; this.n24 = - y.dot( eye ); this.n31 = z.x; this.n32 = z.y; this.n33 = z.z; this.n34 = - z.dot( eye ); - this.n41 = 0; this.n42 = 0; this.n43 = 0; this. -n44 = 1; + this.n41 = 0; this.n42 = 0; this.n43 = 0; this.n44 = 1; + }, transform: function ( v ) { - var vx = v.x, vy = v.y, vz = v.z, vw = v.w ? v.w : 1.0; + var vx = v.x, vy = v.y, vz = v.z, vw = v.w ? v.w : 1; v.x = this.n11 * vx + this.n12 * vy + this.n13 * vz + this.n14 * vw; v.y = this.n21 * vx + this.n22 * vy + this.n23 * vz + this.n24 * vw; @@ -69,7 +69,7 @@ n44 = 1; vw = this.n41 * vx + this.n42 * vy + this.n43 * vz + this.n44 * vw; - if( v.w ) { + if ( v.w ) { v.w = vw; diff --git a/src/materials/Material.js b/src/materials/Material.js index 95c95b7a..839997e5 100644 --- a/src/materials/Material.js +++ b/src/materials/Material.js @@ -3,10 +3,6 @@ * } */ -THREE.UVMapping = 0; -THREE.ReflectionMap = 1; -THREE.CubeMap = 2; - THREE.FlatShading = 0; THREE.GouraudShading = 1; THREE.PhongShading = 2; diff --git a/src/materials/Texture.js b/src/materials/textures/Texture.js similarity index 83% rename from src/materials/Texture.js rename to src/materials/textures/Texture.js index 82c736f5..6a523e13 100644 --- a/src/materials/Texture.js +++ b/src/materials/textures/Texture.js @@ -18,3 +18,7 @@ THREE.Texture = function ( image, mapping ) { }; }; + +THREE.UVMapping = 0; +THREE.ReflectionMap = 1; +THREE.CubeMap = 2; diff --git a/src/renderers/CanvasRenderer.js b/src/renderers/CanvasRenderer.js index 6fb17247..d644be95 100644 --- a/src/renderers/CanvasRenderer.js +++ b/src/renderers/CanvasRenderer.js @@ -26,6 +26,7 @@ THREE.CanvasRenderer = function () { _ambientLight = new THREE.Color( 0xff000000 ), _pi2 = Math.PI * 2, + _w, // z-buffer to w-buffer _vector2 = new THREE.Vector2(), // Needed for expand _vector3 = new THREE.Vector3(), // Needed for PointLight _uv1 = new THREE.UV(), _uv2 = new THREE.UV(), _uv3 = new THREE.UV(), _uv4 = new THREE.UV(), @@ -556,6 +557,11 @@ THREE.CanvasRenderer = function () { _color.__styleString = material.color.__styleString; + } else if ( material instanceof THREE.MeshDepthMaterial ) { + + _w = 1 - ( material.__2near / (material.__farPlusNear - element.z * material.__farMinusNear ) ); + _color.setRGBA( _w, _w, _w, 1 ); + } else if ( material instanceof THREE.MeshLambertMaterial ) { if ( _enableLighting ) { @@ -652,6 +658,11 @@ THREE.CanvasRenderer = function () { _color.__styleString = material.color.__styleString; + } else if ( material instanceof THREE.MeshDepthMaterial ) { + + _w = 1 - ( material.__2near / (material.__farPlusNear - element.z * material.__farMinusNear ) ); + _color.setRGBA( _w, _w, _w, 1 ); + } else if ( material instanceof THREE.MeshLambertMaterial ) { if ( _enableLighting ) { @@ -703,37 +714,41 @@ THREE.CanvasRenderer = function () { } - function drawTexturedTriangle( bitmap, v1x, v1y, v2x, v2y, v3x, v3y, _uv1u, _uv1v, _uv2u, _uv2v, _uv3u, _uv3v ) { + function drawTexturedTriangle( bitmap, x0, y0, x1, y1, x2, y2, u0, v0, u1, v1, u2, v2 ) { - // Textured triangle drawing by Thatcher Ulrich. - // http://tulrich.com/geekstuff/canvas/jsgl.js - - var denom, m11, m12, m21, m22, dx, dy; + // http://extremelysatisfactorytotalitarianism.com/blog/?p=2120 _context.beginPath(); - _context.moveTo( v1x, v1y ); - _context.lineTo( v2x, v2y ); - _context.lineTo( v3x, v3y ); - _context.lineTo( v1x, v1y ); + _context.moveTo( x0, y0 ); + _context.lineTo( x1, y1 ); + _context.lineTo( x2, y2 ); _context.closePath(); + x1 -= x0; + y1 -= y0; + x2 -= x0; + y2 -= y0; + + u1 -= u0; + v1 -= v0; + u2 -= u0; + v2 -= v0; + + var det = 1 / ( u1 * v2 - u2 * v1 ), + + a = ( v2 * x1 - v1 * x2 ) * det, + b = ( v2 * y1 - v1 * y2 ) * det, + c = ( u1 * x2 - u2 * x1 ) * det, + d = ( u1 * y2 - u2 * y1 ) * det, + + e = x0 - a * u0 - c * v0, + f = y0 - b * u0 - d * v0; + _context.save(); + _context.transform( a, b, c, d, e, f ); _context.clip(); - - denom = _uv1u * ( _uv3v - _uv2v ) - _uv2u * _uv3v + _uv3u * _uv2v + ( _uv2u - _uv3u ) * _uv1v; - - m11 = - ( _uv1v * (v3x - v2x ) - _uv2v * v3x + _uv3v * v2x + ( _uv2v - _uv3v ) * v1x ) / denom; - m12 = ( _uv2v * v3y + _uv1v * ( v2y - v3y ) - _uv3v * v2y + ( _uv3v - _uv2v) * v1y ) / denom; - m21 = ( _uv1u * ( v3x - v2x ) - _uv2u * v3x + _uv3u * v2x + ( _uv2u - _uv3u ) * v1x ) / denom; - m22 = - ( _uv2u * v3y + _uv1u * ( v2y - v3y ) - _uv3u * v2y + ( _uv3u - _uv2u ) * v1y ) / denom; - dx = ( _uv1u * ( _uv3v * v2x - _uv2v * v3x ) + _uv1v * ( _uv2u * v3x - _uv3u * v2x ) + ( _uv3u * _uv2v - _uv2u * _uv3v ) * v1x ) / denom; - dy = ( _uv1u * ( _uv3v * v2y - _uv2v * v3y ) + _uv1v * ( _uv2u * v3y - _uv3u * v2y ) + ( _uv3u * _uv2v - _uv2u * _uv3v ) * v1y ) / denom; - - _context.transform( m11, m12, m21, m22, dx, dy ); - _context.drawImage( bitmap, 0, 0 ); _context.restore(); - } // Hide anti-alias gaps diff --git a/src/renderers/Projector.js b/src/renderers/Projector.js index d73397e0..4cbc8fdb 100644 --- a/src/renderers/Projector.js +++ b/src/renderers/Projector.js @@ -186,7 +186,7 @@ THREE.Projector = function() { _line.v1.copy( vertex.positionScreen ); _line.v2.copy( vertex2.positionScreen ); - // TODO: Use centriums here too. + // TODO: Use centroids here too. _line.z = Math.max( vertex.positionScreen.z, vertex2.positionScreen.z ); _line.material = object.material; @@ -203,24 +203,23 @@ THREE.Projector = function() { _vector4.set( object.position.x, object.position.y, object.position.z, 1 ); - camera.matrix.transform( _vector4 ); - camera.projectionMatrix.transform( _vector4 ); + _projScreenMatrix.transform( _vector4 ); - object.screen.set( _vector4.x / _vector4.w, _vector4.y / _vector4.w, _vector4.z / _vector4.w ); + _vector4.z /= _vector4.w; - if ( object.screen.z > 0 && object.screen.z < 1 ) { + if ( _vector4.z > 0 && _vector4.z < 1 ) { _particle = _particlePool[ _particleCount ] = _particlePool[ _particleCount ] || new THREE.RenderableParticle(); - _particle.x = object.screen.x; - _particle.y = object.screen.y; - _particle.z = object.screen.z; + _particle.x = _vector4.x / _vector4.w; + _particle.y = _vector4.y / _vector4.w; + _particle.z = _vector4.z; _particle.rotation = object.rotation.z; - _particle.scale.x = object.scale.x * Math.abs( _vector4.x / _vector4.w - ( _vector4.x + camera.projectionMatrix.n11 ) / ( _vector4.w + camera.projectionMatrix.n14 ) ); - _particle.scale.y = object.scale.y * Math.abs( _vector4.y / _vector4.w - ( _vector4.y + camera.projectionMatrix.n22 ) / ( _vector4.w + camera.projectionMatrix.n24 ) ); + _particle.scale.x = object.scale.x * Math.abs( _particle.x - ( _vector4.x + camera.projectionMatrix.n11 ) / ( _vector4.w + camera.projectionMatrix.n14 ) ); + _particle.scale.y = object.scale.y * Math.abs( _particle.y - ( _vector4.y + camera.projectionMatrix.n22 ) / ( _vector4.w + camera.projectionMatrix.n24 ) ); + _particle.material = object.material; - _particle.color = object.color; _renderList.push( _particle ); diff --git a/src/renderers/Renderer.js b/src/renderers/Renderer.js deleted file mode 100755 index 588a3524..00000000 --- a/src/renderers/Renderer.js +++ /dev/null @@ -1,155 +0,0 @@ -var Renderer = Class.extend -({ - matrix: null, - - viewport: null, - renderList: null, - - face3Pool: null, - face4Pool: null, - - width: null, - height: null, - widthHalf: null, - heightHalf: null, - - init: function() - { - this.matrix = new Matrix4(); - - this.face3Pool = new Array(); - this.face4Pool = new Array(); - }, - - setSize: function( width, height ) - { - this.width = width; - this.height = height; - - this.widthHalf = this.width / 2; - this.heightHalf = this.height / 2; - }, - - sort: function(a, b) - { - return a.screen.z - b.screen.z; - }, - - render: function( scene, camera ) - { - var vertex, face, object; - var face3count = 0, face4count = 0; - - var focuszoom = camera.focus * camera.zoom; - - var matrixMultiply = this.matrix.multiply; - var matrixTransform = this.matrix.transform; - - this.renderList = new Array(); - - for (var i = 0; i < scene.objects.length; i++) - { - object = scene.objects[i]; - - if (object instanceof Mesh) - { - matrixMultiply( camera.matrix, object.matrix ); - - // vertices - - for (var j = 0; j < object.geometry.vertices.length; j++) - { - vertex = object.geometry.vertices[j]; - - vertex.screen.copy( vertex ); - - matrixTransform( vertex.screen ); - - vertex.screen.z = focuszoom / (camera.focus + vertex.screen.z); - - vertex.visible = vertex.screen.z > 0; - - vertex.screen.x *= vertex.screen.z; - vertex.screen.y *= vertex.screen.z; - } - - // faces - - for (j = 0; j < object.geometry.faces.length; j++) - { - face = object.geometry.faces[j]; - - // TODO: Use normals for culling - - if (face instanceof Face3) - { - if (face.a.visible && face.b.visible && face.c.visible && (object.doubleSided || - (face.c.screen.x - face.a.screen.x) * (face.b.screen.y - face.a.screen.y) - - (face.c.screen.y - face.a.screen.y) * (face.b.screen.x - face.a.screen.x) > 0) ) - { - face.screen.z = (face.a.screen.z + face.b.screen.z + face.c.screen.z) * 0.3; - - if (this.face3Pool[face3count] == null) - this.face3Pool[face3count] = new Face3(new Vertex(), new Vertex(), new Vertex()); - - this.face3Pool[face3count].a.screen.copy(face.a.screen); - this.face3Pool[face3count].b.screen.copy(face.b.screen); - this.face3Pool[face3count].c.screen.copy(face.c.screen); - this.face3Pool[face3count].screen.z = face.screen.z; - this.face3Pool[face3count].color = face.color; - this.face3Pool[face3count].material = object.material; - - this.renderList.push( this.face3Pool[face3count] ); - - face3count++; - } - } - else if (face instanceof Face4) - { - if (face.a.visible && face.b.visible && face.c.visible && (object.doubleSided || - ((face.d.screen.x - face.a.screen.x) * (face.b.screen.y - face.a.screen.y) - - (face.d.screen.y - face.a.screen.y) * (face.b.screen.x - face.a.screen.x) > 0 || - (face.b.screen.x - face.c.screen.x) * (face.d.screen.y - face.c.screen.y) - - (face.b.screen.y - face.c.screen.y) * (face.d.screen.x - face.c.screen.x) > 0)) ) - { - face.screen.z = (face.a.screen.z + face.b.screen.z + face.c.screen.z + face.d.screen.z) * 0.25; - - if (this.face4Pool[face4count] == null) - this.face4Pool[face4count] = new Face4(new Vertex(), new Vertex(), new Vertex(), new Vertex()); - - this.face4Pool[face4count].a.screen.copy(face.a.screen); - this.face4Pool[face4count].b.screen.copy(face.b.screen); - this.face4Pool[face4count].c.screen.copy(face.c.screen); - this.face4Pool[face4count].d.screen.copy(face.d.screen); - this.face4Pool[face4count].screen.z = face.screen.z; - this.face4Pool[face4count].color = face.color; - this.face4Pool[face4count].material = object.material; - - this.renderList.push( this.face4Pool[face4count] ); - - face4count++; - } - } - } - } - else if (object instanceof Particle) - { - object.screen.copy(object.position); - - camera.matrix.transform( object.screen ); - - object.screen.z = focuszoom / (camera.focus + object.screen.z); - - if (object.screen.z < 0) - continue; - - object.screen.x *= object.screen.z; - object.screen.y *= object.screen.z; - - this.renderList.push( object ); - } - } - - this.renderList.sort(this.sort); - } -}); diff --git a/src/renderers/SVGRenderer.js b/src/renderers/SVGRenderer.js index db8dadb0..06329503 100644 --- a/src/renderers/SVGRenderer.js +++ b/src/renderers/SVGRenderer.js @@ -16,6 +16,7 @@ THREE.SVGRenderer = function () { _light = new THREE.Color( 0xffffffff ), _ambientLight = new THREE.Color( 0xffffffff ), + _w, // z-buffer to w-buffer _vector3 = new THREE.Vector3(), // Needed for PointLight _svgPathPool = [], _svgCirclePool = [], @@ -331,6 +332,11 @@ THREE.SVGRenderer = function () { _color.__styleString = material.color.__styleString; + } else if ( material instanceof THREE.MeshDepthMaterial ) { + + _w = 1 - ( material.__2near / (material.__farPlusNear - element.z * material.__farMinusNear) ); + _color.setRGBA( _w, _w, _w, 1 ); + } else if ( material instanceof THREE.MeshLambertMaterial ) { if ( _enableLighting ) { diff --git a/utils/build.py b/utils/build.py index af8c56d6..d6f84de2 100644 --- a/utils/build.py +++ b/utils/build.py @@ -111,13 +111,14 @@ def buildFull(debug): 'materials/Material.js', 'materials/LineBasicMaterial.js', 'materials/MeshBasicMaterial.js', + 'materials/MeshDepthMaterial.js', 'materials/MeshLambertMaterial.js', 'materials/MeshPhongMaterial.js', 'materials/MeshFaceMaterial.js', 'materials/ParticleBasicMaterial.js', 'materials/ParticleCircleMaterial.js', 'materials/ParticleDOMMaterial.js', - 'materials/Texture.js', + 'materials/textures/Texture.js', 'scenes/Scene.js', 'renderers/Projector.js', 'renderers/DOMRenderer.js', @@ -163,12 +164,13 @@ def buildCanvas(debug): 'materials/Material.js', 'materials/LineBasicMaterial.js', 'materials/MeshBasicMaterial.js', + 'materials/MeshDepthMaterial.js', 'materials/MeshLambertMaterial.js', 'materials/MeshPhongMaterial.js', 'materials/MeshFaceMaterial.js', 'materials/ParticleBasicMaterial.js', 'materials/ParticleCircleMaterial.js', - 'materials/Texture.js', + 'materials/textures/Texture.js', 'scenes/Scene.js', 'renderers/Projector.js', 'renderers/CanvasRenderer.js', @@ -211,12 +213,13 @@ def buildWebGL(debug): 'materials/Material.js', 'materials/LineBasicMaterial.js', 'materials/MeshBasicMaterial.js', + 'materials/MeshDepthMaterial.js', 'materials/MeshLambertMaterial.js', 'materials/MeshPhongMaterial.js', 'materials/MeshFaceMaterial.js', 'materials/ParticleBasicMaterial.js', 'materials/ParticleCircleMaterial.js', - 'materials/Texture.js', + 'materials/textures/Texture.js', 'scenes/Scene.js', 'renderers/WebGLRenderer.js', ] @@ -254,6 +257,7 @@ def buildSVG(debug): 'materials/Material.js', 'materials/LineBasicMaterial.js', 'materials/MeshBasicMaterial.js', + 'materials/MeshDepthMaterial.js', 'materials/MeshLambertMaterial.js', 'materials/MeshPhongMaterial.js', 'materials/MeshFaceMaterial.js',