Browse Source

Code clean up and minor optimisations.

Mr.doob 14 years ago
parent
commit
b913baa6f0

+ 167 - 167
build/Three.js

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

+ 167 - 167
build/ThreeDebug.js

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

+ 41 - 31
examples/camera_free.html

@@ -1,7 +1,7 @@
 <!DOCTYPE HTML>
 <html lang="en">
 	<head>
-		<title>three.js - geometry - cube</title>
+		<title>three.js - geometry - sphere</title>
 		<meta charset="utf-8">
 		<style type="text/css">
 			body {
@@ -60,23 +60,16 @@
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script>
 
 		<script type="text/javascript" src="../src/extras/primitives/Sphere.js"></script>
-		<script type="text/javascript" src="../src/extras/primitives/Plane.js"></script>
 
 		<script type="text/javascript" src="js/Stats.js"></script>
 
 		<script type="text/javascript">
 
-			var SCREEN_WIDTH = window.innerWidth;
-			var SCREEN_HEIGHT = window.innerHeight;
+			var container, stats;
 
-			var container;
-			var stats;
+			var camera, scene, renderer, objects;
 
-			var camera;
-			var scene;
-			var renderer;
-
-			var cube, plane;
+			var sphere;
 
 			var targetRotation = 0;
 			var targetRotationOnMouseDown = 0;
@@ -111,43 +104,59 @@
 				container = document.createElement('div');
 				document.body.appendChild(container);
 
-				camera = new THREE.Camera( 45, SCREEN_WIDTH / SCREEN_HEIGHT, 1, 10000 );
+				camera = new THREE.Camera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
 				camera.position.y = 150;
 				camera.position.z = 400;
 				camera.target.position.y = 150;
 
 				scene = new THREE.Scene();
 
-				// Plane
+				// Grid
+
+				var geometry = new THREE.Geometry();
+				geometry.vertices.push( new THREE.Vertex( new THREE.Vector3( - 500, 0, 0 ) ) );
+				geometry.vertices.push( new THREE.Vertex( new THREE.Vector3( 500, 0, 0 ) ) );
+
+				var material = new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.5 } );
 
-				var material = new THREE.MeshBasicMaterial( { color: 0x000000, opacity: 0.5, wireframe: true, wireframe_size: 1 } );
+				for ( var i = 0; i <= 10; i ++ ) {
 
-				plane = new THREE.Mesh( new Plane( 1000, 1000, 10, 10 ), material );
-				plane.rotation.x = - 90 * ( Math.PI / 180 );
-				plane.doubleSided = true;
-				scene.addObject( plane );
+					var line = new THREE.Line( geometry, material );
+					line.position.z = ( i * 100 ) - 500;
+					scene.addObject( line );
+
+					var line = new THREE.Line( geometry, material );
+					line.position.x = ( i * 100 ) - 500;
+					line.rotation.y = 90 * Math.PI / 180;
+					scene.addObject( line );
+
+				}
 
 				// Spheres
 
+				objects = [];
+
 				geometry = new Sphere( 100, 16, 8 );
 				material = new THREE.MeshLambertMaterial( { color: 0xffffff, opacity: 1 } );
 
 				for ( var i = 0; i < 10; i ++ ) {
 
-					cube = new THREE.Mesh( geometry, material );
-					cube.overdraw = true;
+					sphere = new THREE.Mesh( geometry, material );
+					sphere.overdraw = true;
 
-					cube.position.x = Math.random() * 1000 - 500;
-					cube.position.y = Math.random() * 1000 - 500;
-					cube.position.z = Math.random() * 1000 - 500;
+					sphere.position.x = Math.random() * 1000 - 500;
+					sphere.position.y = Math.random() * 1000 - 500;
+					sphere.position.z = Math.random() * 1000 - 500;
 
-					cube.rotation.x = Math.random() * 200 - 100;
-					cube.rotation.y = Math.random() * 200 - 100;
-					cube.rotation.z = Math.random() * 200 - 100;
+					sphere.rotation.x = Math.random() * 200 - 100;
+					sphere.rotation.y = Math.random() * 200 - 100;
+					sphere.rotation.z = Math.random() * 200 - 100;
 
-					cube.scale.x = cube.scale.y = cube.scale.z = Math.random() + 0.5;
+					sphere.scale.x = sphere.scale.y = sphere.scale.z = Math.random() + 0.5;
 
-					scene.addObject(cube);
+					objects.push( sphere );
+
+					scene.addObject( sphere );
 
 				}
 
@@ -168,7 +177,7 @@
 
 
 				renderer = new THREE.CanvasRenderer();
-				renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
+				renderer.setSize( window.innerWidth, window.innerHeight );
 
 				container.appendChild( renderer.domElement );
 
@@ -272,9 +281,10 @@
 				debugContext.rect( camera.target.position.x * 0.1 - 5, camera.target.position.z * 0.1 - 5, 10, 10 );
 				debugContext.rect( - 50, - 50, 100, 100 );
 
-				for ( var i = 1; i < scene.objects.length; i++ ) {
+				for ( var i = 0, l = objects.length; i < l; i++ ) {
+
+					var object = objects[ i ];
 
-					var object = scene.objects[i];
 					object.rotation.x += 0.01;
 					object.rotation.y += 0.005;
 					object.position.y = Math.sin( object.rotation.x ) * 200;

+ 2 - 2
examples/geometry/Qrcode.js

@@ -3,8 +3,8 @@ var Qrcode = function () {
 	THREE.Geometry.call( this );
 
 	var scope = this,
-	m1 = new THREE.MeshLambertMaterial( { color: 0x000000 } ),
-	m2 = new THREE.MeshLambertMaterial( { color: 0xc0c0c0 } );
+	m1 = new THREE.MeshLambertMaterial( { color: 0x000000, shading: THREE.FlatShading } ),
+	m2 = new THREE.MeshLambertMaterial( { color: 0xc0c0c0, shading: THREE.FlatShading } );
 
 	v(-54,134,58);
 	v(-54,146,58);

+ 1 - 1
examples/interactive_voxelpainter.html

@@ -145,7 +145,7 @@
 
 					} else {
 
-						var position = new THREE.Vector3().add( intersects[ 0 ].point, intersects[ 0 ].object.matrixRotation.transform( intersects[ 0 ].face.normal.clone() ) );
+						var position = new THREE.Vector3().add( intersects[ 0 ].point, intersects[ 0 ].object.rotationMatrix.transform( intersects[ 0 ].face.normal.clone() ) );
 
 						var voxel = new THREE.Mesh( new Cube( 50, 50, 50 ), [ new THREE.MeshLambertMaterial( { color: 0x00ff80, opacity: 1 } ), new THREE.MeshFaceMaterial() ] );
 						voxel.position.x = Math.floor( position.x / 50 ) * 50 + 25;

+ 1 - 1
examples/lights_pointlights.html

@@ -60,7 +60,7 @@
 
 				scene = new THREE.Scene();
 
-				object = new THREE.Mesh( new WaltHead(), new THREE.MeshLambertMaterial( { color: 0xffffff } ) );
+				object = new THREE.Mesh( new WaltHead(), new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading } ) );
 				object.overdraw = true;
 				scene.addObject( object );
 

+ 36 - 26
examples/lights_test.html

@@ -42,7 +42,6 @@
 
 		<script type="text/javascript" src="../src/extras/io/Loader.js"></script>
 		<script type="text/javascript" src="../src/extras/primitives/Sphere.js"></script>
-		<script type="text/javascript" src="../src/extras/primitives/Plane.js"></script>
 
 		<script type="text/javascript" src="js/Stats.js"></script>
 
@@ -94,23 +93,25 @@
 
 				scene = new THREE.Scene();
 
+				// Spheres
 
-				// SPHERES
+				var geometry = new Sphere( 100, 16, 8 );
+				var material = new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading } );
 
-				sphere = new Sphere( 100, 16, 8 );
-				for (var i=0; i<30; i++) {
-					mesh = new THREE.Mesh( sphere, new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading } ) );
-					mesh.position.x = 500 * (Math.random() - 0.5);
-					mesh.position.y = 500 * (Math.random() - 0.5);
-					mesh.position.z = 500 * (Math.random() - 0.5);
-					mesh.scale.x = mesh.scale.y = mesh.scale.z = 0.25 * (Math.random() + 0.5);
+				for ( var i = 0; i < 30; i ++ ) {
+
+					mesh = new THREE.Mesh( geometry, material );
+					mesh.position.x = 500 * ( Math.random() - 0.5 );
+					mesh.position.y = 500 * ( Math.random() - 0.5 );
+					mesh.position.z = 500 * ( Math.random() - 0.5 );
+					mesh.scale.x = mesh.scale.y = mesh.scale.z = 0.25 * ( Math.random() + 0.5 );
 					mesh.overdraw = true;
 					mesh.updateMatrix();
 					scene.addObject(mesh);
-				}
 
+				}
 
-				// LIGHTS
+				// Lights
 
 				var ambient = new THREE.AmbientLight( 0x101010 );
 				scene.addLight( ambient );
@@ -127,9 +128,7 @@
 				pointLight.position.z = 0;
 				scene.addLight( pointLight );
 
-
-				sphere = new Sphere( 100, 16, 8 );
-				lightMesh = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: 0xffaa00 } ) );
+				lightMesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { color: 0xffaa00 } ) );
 				lightMesh.scale.x = lightMesh.scale.y = lightMesh.scale.z = 0.05;
 				lightMesh.position = pointLight.position;
 				lightMesh.overdraw = true;
@@ -137,21 +136,28 @@
 				scene.addObject(lightMesh);
 
 
-				if( render_canvas ) {
+				if ( render_canvas ) {
+
 					canvasRenderer = new THREE.CanvasRenderer();
 					canvasRenderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
 					container.appendChild( canvasRenderer.domElement );
+
 				}
 
 				if ( render_gl ) {
+
 					try {
+
 						webglRenderer = new THREE.WebGLRenderer( scene );
 						webglRenderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
 						container.appendChild( webglRenderer.domElement );
+
 						has_gl = 1;
+
+					} catch (e) {
+
 					}
-					catch (e) {
-					}
+
 				}
 
 				stats = new Stats();
@@ -165,26 +171,24 @@
 
 
 				var loader = new THREE.Loader();
-				//loader.loadAscii( "obj/torus/Torus_slim.js", function( geometry ) { createScene( geometry ) } );
-                loader.loadBinary( "obj/torus/Torus_bin.js", function( geometry ) { createScene( geometry ) }, "obj/torus" );
+				//loader.loadAscii( "obj/torus/Torus_slim.js", function( geometry ) { createMesh( geometry ) } );
+				loader.loadBinary( "obj/torus/Torus_bin.js", function( geometry ) { createMesh( geometry ) }, "obj/torus" );
 
 			}
 
-			function createScene( geometry ) {
+			function createMesh( geometry ) {
 
 				zmesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: 0xffffff } ) );
-				zmesh.position.x = 0;
-				zmesh.position.z = 0;
-				zmesh.position.y = 0;
+				zmesh.position.x = zmesh.position.y = zmesh.position.z = 0;
 				zmesh.scale.x = zmesh.scale.y = zmesh.scale.z = 100;
 				zmesh.overdraw = true;
 				zmesh.updateMatrix();
-				scene.addObject(zmesh);
+				scene.addObject( zmesh );
 
 			}
 
 
-			function onDocumentMouseMove(event) {
+			function onDocumentMouseMove( event ) {
 
 				mouseX = ( event.clientX - windowHalfX );
 				mouseY = ( event.clientY - windowHalfY );
@@ -200,12 +204,18 @@
 				camera.updateMatrix();
 
 
-				for(var i=0; i<scene.objects.length; ++i) {
+				for ( var i = 0, l = scene.objects.length; i < l; i ++ ) {
+
 					if ( i%3 == 1 )
+
 						scene.objects[i].rotation.x += 0.05;
+
 					else if ( i%3 == 2 )
+
 						scene.objects[i].rotation.y += 0.05;
+
 					else if ( i%3 == 0 )
+
 						scene.objects[i].rotation.z += 0.05;
 
 					scene.objects[i].updateMatrix();

+ 13 - 13
examples/lines_test.html

@@ -60,7 +60,7 @@
 				material = new THREE.ParticleCircleMaterial( { color: 0xffffff } );
 				var geometry = new THREE.Geometry();
 
-				for (var i = 0; i < 100; i++) {
+				for ( var i = 0; i < 100; i ++ ) {
 
 					particle = new THREE.Particle( material );
 					particle.position.x = Math.random() * 2 - 1;
@@ -78,7 +78,7 @@
 				// lines
 
 				var line = new THREE.Line( geometry, new THREE.LineBasicMaterial( { color: 0xffffff, opacity: 0.5 } ) );
-				scene.addObject(line);
+				scene.addObject( line );
 
 				/*
 				stats = new Stats();
@@ -87,9 +87,9 @@
 				container.appendChild(stats.domElement);
 				*/
 
-				document.addEventListener('mousemove', onDocumentMouseMove, false);
-				document.addEventListener('touchstart', onDocumentTouchStart, false);
-				document.addEventListener('touchmove', onDocumentTouchMove, false);
+				document.addEventListener( 'mousemove', onDocumentMouseMove, false );
+				document.addEventListener( 'touchstart', onDocumentTouchStart, false );
+				document.addEventListener( 'touchmove', onDocumentTouchMove, false );
 			}
 
 			//
@@ -102,23 +102,23 @@
 
 			function onDocumentTouchStart( event ) {
 
-				if(event.touches.length > 1) {
+				if ( event.touches.length > 1 ) {
 
 					event.preventDefault();
 
-					mouseX = event.touches[0].pageX - windowHalfX;
-					mouseY = event.touches[0].pageY - windowHalfY;
+					mouseX = event.touches[ 0 ].pageX - windowHalfX;
+					mouseY = event.touches[ 0 ].pageY - windowHalfY;
 				}
 			}
 
 			function onDocumentTouchMove( event ) {
 
-				if(event.touches.length == 1) {
+				if ( event.touches.length == 1 ) {
 
 					event.preventDefault();
 
-					mouseX = event.touches[0].pageX - windowHalfX;
-					mouseY = event.touches[0].pageY - windowHalfY;
+					mouseX = event.touches[ 0 ].pageX - windowHalfX;
+					mouseY = event.touches[ 0 ].pageY - windowHalfY;
 				}
 			}
 
@@ -126,8 +126,8 @@
 
 			function loop() {
 
-				camera.position.x += (mouseX - camera.position.x) * .05;
-				camera.position.y += (-mouseY + 200 - camera.position.y) * .05;
+				camera.position.x += ( mouseX - camera.position.x ) * .05;
+				camera.position.y += ( - mouseY + 200 - camera.position.y ) * .05;
 				camera.updateMatrix();
 
 				renderer.render(scene, camera);

+ 6 - 5
examples/materials.html

@@ -17,7 +17,6 @@
 		<script type="text/javascript" src="../build/Three.js"></script>
 
 		<script type="text/javascript" src="../src/extras/primitives/Sphere.js"></script>
-		<script type="text/javascript" src="../src/extras/primitives/Plane.js"></script>
 
 		<script type="text/javascript" src="js/Stats.js"></script>
 
@@ -48,14 +47,16 @@
 				geometry.vertices.push( new THREE.Vertex( new THREE.Vector3( - 500, 0, 0 ) ) );
 				geometry.vertices.push( new THREE.Vertex( new THREE.Vector3( 500, 0, 0 ) ) );
 
+				var material = new THREE.LineBasicMaterial( { color: 0xffffff, opacity: 0.2 } );
+
 				for ( var i = 0; i <= 10; i ++ ) {
 
-					var line = new THREE.Line( geometry, new THREE.LineBasicMaterial( { color: 0xffffff, opacity: 0.2 } ) );
+					var line = new THREE.Line( geometry, material );
 					line.position.y = - 120;
 					line.position.z = ( i * 100 ) - 500;
 					scene.addObject( line );
 
-					var line = new THREE.Line( geometry, new THREE.LineBasicMaterial( { color: 0xffffff, opacity: 0.2 } ) );
+					var line = new THREE.Line( geometry, material );
 					line.position.x = ( i * 100 ) - 500;
 					line.position.y = - 120;
 					line.rotation.y = 90 * Math.PI / 180;
@@ -74,8 +75,8 @@
 				materials.push( { material: new THREE.MeshBasicMaterial( { color: 0x00ffff, wireframe: true } ), overdraw: false, doubleSided: true } );
 				//materials.push( { material: new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.SubtractiveBlending } ), overdraw: false, doubleSided: true } );
 				materials.push( { material: new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.AdditiveBlending } ), overdraw: false, doubleSided: true } );
-				materials.push( { material: new THREE.MeshLambertMaterial( { color: 0xffffff } ), overdraw: true, doubleSided: false } );
-				materials.push( { material: new THREE.MeshPhongMaterial( { ambient: 0x030383, color: 0xf55555, specular: 0x66f6f6, shininess: 10 } ), overdraw: true, doubleSided: false } );
+				materials.push( { material: new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading } ), overdraw: true, doubleSided: false } );
+				materials.push( { material: new THREE.MeshPhongMaterial( { ambient: 0x030383, color: 0xf55555, specular: 0x66f6f6, shininess: 10, shading: THREE.FlatShading } ), overdraw: true, doubleSided: false } );
 				materials.push( { material: new THREE.MeshDepthMaterial( { near: 1, far: 2000 } ), overdraw: true, doubleSided: false } );
 				materials.push( { material: new THREE.MeshNormalMaterial( ), overdraw: true, doubleSided: false } );
 				materials.push( { material: new THREE.MeshBasicMaterial( { map: generatedTexture } ), overdraw: true, doubleSided: false } );

+ 9 - 17
src/core/Matrix4.js

@@ -8,10 +8,6 @@
 
 THREE.Matrix4 = function () {
 
-	this._x = new THREE.Vector3();
-	this._y = new THREE.Vector3();
-	this._z = new THREE.Vector3();
-
 };
 
 THREE.Matrix4.prototype = {
@@ -41,16 +37,11 @@ THREE.Matrix4.prototype = {
 
 	lookAt: function ( eye, center, up ) {
 
-		var x = this._x, y = this._y, z = this._z;
-
-		z.sub( eye, center );
-		z.normalize();
-
-		x.cross( up, z );
-		x.normalize();
+		var x = new THREE.Vector3(), y = new THREE.Vector3(), z = new THREE.Vector3();
 
-		y.cross( z, x );
-		y.normalize();
+		z.sub( eye, center ).normalize();
+		x.cross( up, z ).normalize();
+		y.cross( z, x ).normalize();
 
 		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 );
@@ -61,7 +52,7 @@ THREE.Matrix4.prototype = {
 
 	transform: function ( v ) {
 
-		var vx = v.x, vy = v.y, vz = v.z, vw = v.w ? v.w : 1;
+		var vx = v.x, vy = v.y, vz = v.z, vw = v.w || 1, vwi;
 
 		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;
@@ -75,9 +66,10 @@ THREE.Matrix4.prototype = {
 
 		} else {
 
-			v.x = v.x / vw;
-			v.y = v.y / vw;
-			v.z = v.z / vw;
+			vwi = 1 / vw;
+			v.x *= vwi;
+			v.y *= vwi;
+			v.z *= vwi;
 
 		}
 

+ 1 - 1
src/core/Ray.js

@@ -57,7 +57,7 @@ THREE.Ray.prototype = {
 			c = object.matrix.transform( vertices[ face.c ].position.clone() );
 			d = face instanceof THREE.Face4 ? object.matrix.transform( vertices[ face.d ].position.clone() ) : null;
 
-			normal = object.matrixRotation.transform( face.normal.clone() );
+			normal = object.rotationMatrix.transform( face.normal.clone() );
 			dot = direction.dot( normal );
 
 			if ( dot < 0 ) { // Math.abs( dot ) > 0.0001

+ 5 - 10
src/core/Vector3.js

@@ -34,7 +34,7 @@ THREE.Vector3.prototype = {
 
 	},
 
-	add: function( v1, v2 ) {
+	add: function ( v1, v2 ) {
 
 		this.x = v1.x + v2.x;
 		this.y = v1.y + v2.y;
@@ -144,7 +144,8 @@ THREE.Vector3.prototype = {
 
 	distanceTo: function ( v ) {
 
-		return Math.sqrt( this.distanceToSquared( v ) );
+		var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
+		return Math.sqrt( dx * dx + dy * dy + dz * dz );
 
 	},
 
@@ -179,15 +180,9 @@ THREE.Vector3.prototype = {
 
 	normalize: function () {
 
-		if ( this.length() > 0 ) {
-
-			this.multiplyScalar( 1 / this.length() );
-
-		} else {
-
-			this.multiplyScalar( 0 );
+		var length = Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );
 
-		}
+		length > 0 ? this.multiplyScalar( 1 / length ) : this.set( 0, 0, 0 );
 
 		return this;
 

+ 9 - 10
src/objects/Object3D.js

@@ -9,29 +9,28 @@ THREE.Object3D = function ( material ) {
 	this.scale = new THREE.Vector3( 1, 1, 1 );
 
 	this.matrix = new THREE.Matrix4();
-	this.matrixTranslation = new THREE.Matrix4();
-	this.matrixRotation = new THREE.Matrix4();
-	this.matrixScale = new THREE.Matrix4();
+	this.translationMatrix = new THREE.Matrix4();
+	this.rotationMatrix = new THREE.Matrix4();
+	this.scaleMatrix = new THREE.Matrix4();
 
 	this.screen = new THREE.Vector3();
 
 	this.visible = true;
-	
 	this.autoUpdateMatrix = true;
 
 	this.updateMatrix = function () {
 
 		this.matrixPosition = THREE.Matrix4.translationMatrix( this.position.x, this.position.y, this.position.z );
 
-		this.matrixRotation = THREE.Matrix4.rotationXMatrix( this.rotation.x );
-		this.matrixRotation.multiplySelf( THREE.Matrix4.rotationYMatrix( this.rotation.y ) );
-		this.matrixRotation.multiplySelf( THREE.Matrix4.rotationZMatrix( this.rotation.z ) );
+		this.rotationMatrix = THREE.Matrix4.rotationXMatrix( this.rotation.x );
+		this.rotationMatrix.multiplySelf( THREE.Matrix4.rotationYMatrix( this.rotation.y ) );
+		this.rotationMatrix.multiplySelf( THREE.Matrix4.rotationZMatrix( this.rotation.z ) );
 
-		this.matrixScale = THREE.Matrix4.scaleMatrix( this.scale.x, this.scale.y, this.scale.z );
+		this.scaleMatrix = THREE.Matrix4.scaleMatrix( this.scale.x, this.scale.y, this.scale.z );
 
 		this.matrix.copy( this.matrixPosition );
-		this.matrix.multiplySelf( this.matrixRotation );
-		this.matrix.multiplySelf( this.matrixScale );
+		this.matrix.multiplySelf( this.rotationMatrix );
+		this.matrix.multiplySelf( this.scaleMatrix );
 
 	};
 

+ 69 - 71
src/renderers/CanvasRenderer.js

@@ -78,9 +78,6 @@ THREE.CanvasRenderer = function () {
 		_canvas.width = _canvasWidth;
 		_canvas.height = _canvasHeight;
 
-		_context.lineJoin = 'round';
-		_context.lineCap = 'round';
-
 		_clipRect.set( - _canvasWidthHalf, - _canvasHeightHalf, _canvasWidthHalf, _canvasHeightHalf );
 
 	};
@@ -92,7 +89,6 @@ THREE.CanvasRenderer = function () {
 			_clearRect.inflate( 1 );
 			_clearRect.minSelf( _clipRect );
 
-			_context.setTransform( 1, 0, 0, - 1, _canvasWidthHalf, _canvasHeightHalf );
 			_context.clearRect( _clearRect.getX(), _clearRect.getY(), _clearRect.getWidth(), _clearRect.getHeight() );
 
 			_clearRect.empty();
@@ -104,26 +100,18 @@ THREE.CanvasRenderer = function () {
 
 		var e, el, element, m, ml, fm, fml, material;
 
-		if ( this.autoClear ) {
-
-			this.clear();
+		_context.setTransform( 1, 0, 0, - 1, _canvasWidthHalf, _canvasHeightHalf );
 
-		}
+		this.autoClear && this.clear();
 
 		_renderList = _projector.projectScene( scene, camera );
 
-		_context.setTransform( 1, 0, 0, - 1, _canvasWidthHalf, _canvasHeightHalf );
-
 		/* DEBUG
 		_context.fillStyle = 'rgba(0, 255, 255, 0.5)';
 		_context.fillRect( _clipRect.getX(), _clipRect.getY(), _clipRect.getWidth(), _clipRect.getHeight() );
 		*/
 
-		if ( _enableLighting = scene.lights.length > 0 ) {
-
-			calculateLights( scene );
-
-		}
+		( _enableLighting = scene.lights.length > 0 ) && calculateLights( scene );
 
 		for ( e = 0, el = _renderList.length; e < el; e++ ) {
 
@@ -138,8 +126,7 @@ THREE.CanvasRenderer = function () {
 
 				for ( m = 0, ml = element.material.length; m < ml; m++ ) {
 
-					material = element.material[ m ];
-					renderParticle( _v1, element, material, scene );
+					renderParticle( _v1, element, element.material[ m ], scene );
 
 				}
 
@@ -153,21 +140,19 @@ THREE.CanvasRenderer = function () {
 				_bboxRect.addPoint( _v1.positionScreen.x, _v1.positionScreen.y );
 				_bboxRect.addPoint( _v2.positionScreen.x, _v2.positionScreen.y );
 
-				if ( !_clipRect.instersects( _bboxRect ) ) {
-
-					continue;
+				if ( _clipRect.instersects( _bboxRect ) ) {
 
-				}
+					m = 0; ml = element.material.length;
 
-				m = 0; ml = element.material.length;
+					while ( m < ml ) {
 
-				while ( m < ml ) {
+						renderLine( _v1, _v2, element, element.material[ m ++ ], scene );
 
-					material = element.material[ m ++ ];
-					renderLine( _v1, _v2, element, material, scene );
+					}
 
 				}
 
+
 			} else if ( element instanceof THREE.RenderableFace3 ) {
 
 				_v1 = element.v1; _v2 = element.v2; _v3 = element.v3;
@@ -188,35 +173,33 @@ THREE.CanvasRenderer = function () {
 				_bboxRect.addPoint( _v2.positionScreen.x, _v2.positionScreen.y );
 				_bboxRect.addPoint( _v3.positionScreen.x, _v3.positionScreen.y );
 
-				if ( !_clipRect.instersects( _bboxRect ) ) {
+				if ( _clipRect.instersects( _bboxRect ) ) {
 
-					continue;
+					m = 0; ml = element.meshMaterial.length;
 
-				}
+					while ( m < ml ) {
 
-				m = 0; ml = element.meshMaterial.length;
+						material = element.meshMaterial[ m ++ ];
 
-				while ( m < ml ) {
+						if ( material instanceof THREE.MeshFaceMaterial ) {
 
-					material = element.meshMaterial[ m ++ ];
+							fm = 0; fml = element.faceMaterial.length;
 
-					if ( material instanceof THREE.MeshFaceMaterial ) {
+							while ( fm < fml ) {
 
-						fm = 0; fml = element.faceMaterial.length;
+								material = element.faceMaterial[ fm ++ ];
+								material && renderFace3( _v1, _v2, _v3, element, material, scene );
 
-						while ( fm < fml ) {
+							}
 
-							material = element.faceMaterial[ fm ++ ];
-							material && renderFace3( _v1, _v2, _v3, element, material, scene );
+							continue;
 
 						}
 
-						continue;
+						renderFace3( _v1, _v2, _v3, element, material, scene );
 
 					}
 
-					renderFace3( _v1, _v2, _v3, element, material, scene );
-
 				}
 
 			} else if ( element instanceof THREE.RenderableFace4 ) {
@@ -237,10 +220,6 @@ THREE.CanvasRenderer = function () {
 					expand( _v2.positionScreen, _v4.positionScreen );
 					expand( _v4.positionScreen, _v1.positionScreen );
 
-				}
-
-				if ( element.overdraw ) {
-
 					expand( _v3.positionScreen, _v5.positionScreen );
 					expand( _v3.positionScreen, _v6.positionScreen );
 
@@ -251,35 +230,33 @@ THREE.CanvasRenderer = function () {
 				_bboxRect.addPoint( _v3.positionScreen.x, _v3.positionScreen.y );
 				_bboxRect.addPoint( _v4.positionScreen.x, _v4.positionScreen.y );
 
-				if ( !_clipRect.instersects( _bboxRect ) ) {
+				if ( _clipRect.instersects( _bboxRect ) ) {
 
-					continue;
+					m = 0; ml = element.meshMaterial.length;
 
-				}
+					while ( m < ml ) {
 
-				m = 0; ml = element.meshMaterial.length;
+						material = element.meshMaterial[ m ++ ];
 
-				while ( m < ml ) {
+						if ( material instanceof THREE.MeshFaceMaterial ) {
 
-					material = element.meshMaterial[ m ++ ];
+							fm = 0; fml = element.faceMaterial.length;
 
-					if ( material instanceof THREE.MeshFaceMaterial ) {
+							while ( fm < fml ) {
 
-						fm = 0; fml = element.faceMaterial.length;
+								material = element.faceMaterial[ fm ++ ];
+								material && renderFace4( _v1, _v2, _v3, _v4, _v5, _v6, element, material, scene );
 
-						while ( fm < fml ) {
+							}
 
-							material = element.faceMaterial[ fm ++ ];
-							material && renderFace4( _v1, _v2, _v3, _v4, _v5, _v6, element, material, scene );
+							continue;
 
 						}
 
-						continue;
+						renderFace4( _v1, _v2, _v3, _v4, _v5, _v6, element, material, scene );
 
 					}
 
-					renderFace4( _v1, _v2, _v3, _v4, _v5, _v6, element, material, scene );
-
 				}
 
 			}
@@ -314,7 +291,7 @@ THREE.CanvasRenderer = function () {
 		_directionalLights.setRGB( 0, 0, 0 );
 		_pointLights.setRGB( 0, 0, 0 );
 
-		for ( l = 0, ll = lights.length; l < ll; l++ ) {
+		for ( l = 0, ll = lights.length; l < ll; l ++ ) {
 
 			light = lights[ l ];
 			lightColor = light.color;
@@ -348,17 +325,18 @@ THREE.CanvasRenderer = function () {
 		var l, ll, light, lightColor, amount
 		lights = scene.lights;
 
-		for ( l = 0, ll = lights.length; l < ll; l++ ) {
+		for ( l = 0, ll = lights.length; l < ll; l ++ ) {
 
 			light = lights[ l ];
 			lightColor = light.color;
 
 			if ( light instanceof THREE.DirectionalLight ) {
 
-				amount = element.normalWorld.dot( light.position ) * light.intensity;
+				amount = element.normalWorld.dot( light.position );
 
 				if ( amount > 0 ) {
 
+					amount *= light.intensity;
 					color.r += lightColor.r * amount;
 					color.g += lightColor.g * amount;
 					color.b += lightColor.b * amount;
@@ -370,10 +348,11 @@ THREE.CanvasRenderer = function () {
 				_vector3.sub( light.position, element.centroidWorld );
 				_vector3.normalize();
 
-				amount = element.normalWorld.dot( _vector3 ) * light.intensity;
+				amount = element.normalWorld.dot( _vector3 );
 
 				if ( amount > 0 ) {
 
+					amount *= light.intensity;
 					color.r += lightColor.r * amount;
 					color.g += lightColor.g * amount;
 					color.b += lightColor.b * amount;
@@ -553,25 +532,44 @@ THREE.CanvasRenderer = function () {
 
 			if ( _enableLighting ) {
 
-				_light.r = _ambientLight.r;
-				_light.g = _ambientLight.g;
-				_light.b = _ambientLight.b;
+				if ( material.shading == THREE.FlatShading ) {
 
-				calculateFaceLight( scene, element, _light );
+					_light.r = _ambientLight.r;
+					_light.g = _ambientLight.g;
+					_light.b = _ambientLight.b;
 
-				_color.r = material.color.r * _light.r;
-				_color.g = material.color.g * _light.g;
-				_color.b = material.color.b * _light.b;
+					calculateFaceLight( scene, element, _light );
 
-				_color.updateStyleString();
+					_color.r = material.color.r * _light.r;
+					_color.g = material.color.g * _light.g;
+					_color.b = material.color.b * _light.b;
+
+					_color.updateStyleString();
+
+					drawTriangle( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _color, material.wireframe, material.wireframe_linewidth );
+
+				} else if ( material.shading == THREE.SmoothShading ) {
+
+					_light.r = _ambientLight.r;
+					_light.g = _ambientLight.g;
+					_light.b = _ambientLight.b;
+
+					calculateFaceLight( scene, element, _light );
+
+					_color.r = material.color.r * _light.r;
+					_color.g = material.color.g * _light.g;
+					_color.b = material.color.b * _light.b;
+
+					_color.updateStyleString();
+
+				}
 
 			} else {
 
-				_color.__styleString = material.color.__styleString;
+				drawTriangle( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, material.color.__styleString, material.wireframe, material.wireframe_linewidth );
 
 			}
 
-			drawTriangle( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _color, material.wireframe, material.wireframe_linewidth );
 
 		} else if ( material instanceof THREE.MeshDepthMaterial ) {
 

+ 16 - 23
src/renderers/Projector.js

@@ -21,21 +21,15 @@ THREE.Projector = function() {
 
 	this.projectScene = function ( scene, camera ) {
 
-		var o, ol, v, vl, f, fl, objects, object, objectMatrix,
+		var o, ol, v, vl, f, fl, objects, object,
+		objectMatrix, objectRotationMatrix, objectMaterial, objectOverdraw,
 		vertices, vertex, vertexPositionScreen,
 		faces, face, v1, v2, v3, v4;
 
 		_renderList = [];
-		_face3Count = 0;
-		_face4Count = 0;
-		_lineCount = 0;
-		_particleCount = 0;
+		_face3Count = _face4Count = _lineCount = _particleCount = 0;
 
-		if( camera.autoUpdateMatrix ) {
-
-			camera.updateMatrix();
-
-		}
+		camera.autoUpdateMatrix && camera.updateMatrix();
 
 		_projScreenMatrix.multiply( camera.projectionMatrix, camera.matrix );
 
@@ -45,12 +39,11 @@ THREE.Projector = function() {
 
 			object = objects[ o ];
 			objectMatrix = object.matrix;
+			objectRotationMatrix = object.rotationMatrix;
+			objectMaterial = object.material;
+			objectOverdraw = object.overdraw;
 
-			if( object.autoUpdateMatrix ) {
-
-				object.updateMatrix();
-
-			}
+			object.autoUpdateMatrix && object.updateMatrix();
 
 			if ( object instanceof THREE.Mesh ) {
 
@@ -96,12 +89,13 @@ THREE.Projector = function() {
 							   ( v3.positionScreen.y - v1.positionScreen.y ) * ( v2.positionScreen.x - v1.positionScreen.x ) < 0 ) ) ) {
 
 								_face3 = _face3Pool[ _face3Count ] = _face3Pool[ _face3Count ] || new THREE.RenderableFace3();
+
 								_face3.v1.positionScreen.copy( v1.positionScreen );
 								_face3.v2.positionScreen.copy( v2.positionScreen );
 								_face3.v3.positionScreen.copy( v3.positionScreen );
 
 								_face3.normalWorld.copy( face.normal );
-								object.matrixRotation.transform( _face3.normalWorld );
+								objectRotationMatrix.transform( _face3.normalWorld );
 
 								_face3.centroidWorld.copy( face.centroid );
 								objectMatrix.transform( _face3.centroidWorld );
@@ -111,11 +105,10 @@ THREE.Projector = function() {
 
 								_face3.z = _face3.centroidScreen.z;
 
-								_face3.meshMaterial = object.material;
+								_face3.meshMaterial = objectMaterial;
 								_face3.faceMaterial = face.material;
-								_face3.overdraw = object.overdraw;
+								_face3.overdraw = objectOverdraw;
 								_face3.uvs = object.geometry.uvs[ f ];
-								_face3.color = face.color;
 
 								_renderList.push( _face3 );
 
@@ -138,13 +131,14 @@ THREE.Projector = function() {
 							   ( v2.positionScreen.y - v3.positionScreen.y ) * ( v4.positionScreen.x - v3.positionScreen.x ) < 0 ) ) ) ) {
 
 								_face4 = _face4Pool[ _face4Count ] = _face4Pool[ _face4Count ] || new THREE.RenderableFace4();
+
 								_face4.v1.positionScreen.copy( v1.positionScreen );
 								_face4.v2.positionScreen.copy( v2.positionScreen );
 								_face4.v3.positionScreen.copy( v3.positionScreen );
 								_face4.v4.positionScreen.copy( v4.positionScreen );
 
 								_face4.normalWorld.copy( face.normal );
-								object.matrixRotation.transform( _face4.normalWorld );
+								objectRotationMatrix.transform( _face4.normalWorld );
 
 								_face4.centroidWorld.copy( face.centroid );
 								objectMatrix.transform( _face4.centroidWorld );
@@ -154,11 +148,10 @@ THREE.Projector = function() {
 
 								_face4.z = _face4.centroidScreen.z;
 
-								_face4.meshMaterial = object.material;
+								_face4.meshMaterial = objectMaterial;
 								_face4.faceMaterial = face.material;
-								_face4.overdraw = object.overdraw;
+								_face4.overdraw = objectOverdraw;
 								_face4.uvs = object.geometry.uvs[ f ];
-								_face4.color = face.color;
 
 								_renderList.push( _face4 );
 

+ 7 - 4
src/renderers/renderables/RenderableFace3.js

@@ -4,6 +4,8 @@
 
 THREE.RenderableFace3 = function () {
 
+	this.z = null;
+
 	this.v1 = new THREE.Vertex();
 	this.v2 = new THREE.Vertex();
 	this.v3 = new THREE.Vertex();
@@ -12,10 +14,11 @@ THREE.RenderableFace3 = function () {
 	this.centroidScreen = new THREE.Vector3();
 
 	this.normalWorld = new THREE.Vector3();
+	this.vertexNormalsWorld = [ new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3() ];
 
-	this.z = null;
-
-	this.color = null;
-	this.material = null;
+	this.meshMaterial = null;
+	this.faceMaterial = null;
+	this.overdraw = false;
+	this.uv = null;
 
 };

+ 7 - 4
src/renderers/renderables/RenderableFace4.js

@@ -4,6 +4,8 @@
 
 THREE.RenderableFace4 = function () {
 
+	this.z = null;
+
 	this.v1 = new THREE.Vertex();
 	this.v2 = new THREE.Vertex();
 	this.v3 = new THREE.Vertex();
@@ -13,10 +15,11 @@ THREE.RenderableFace4 = function () {
 	this.centroidScreen = new THREE.Vector3();
 
 	this.normalWorld = new THREE.Vector3();
+	this.vertexNormalsWorld = [ new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3() ];
 
-	this.z = null;
-
-	this.color = null;
-	this.material = null;
+	this.meshMaterial = null;
+	this.faceMaterial = null;
+	this.overdraw = false;
+	this.uv = null;
 
 };

+ 2 - 3
src/renderers/renderables/RenderableLine.js

@@ -4,12 +4,11 @@
 
 THREE.RenderableLine = function () {
 
+	this.z = null;
+
 	this.v1 = new THREE.Vertex();
 	this.v2 = new THREE.Vertex();
 
-	this.z = null;
-
-	this.color = null;
 	this.material = null;
 
 };

+ 0 - 1
src/renderers/renderables/RenderableParticle.js

@@ -11,7 +11,6 @@ THREE.RenderableParticle = function () {
 	this.rotation = null;
 	this.scale = new THREE.Vector2();
 
-	this.color = null;
 	this.material = null;
 
 };