Browse Source

Added MeshShaderMaterial (and Fresnel shader as its first example).

MeshShaderMaterial is still work in progress, expect changes.

Nice side effect of WebGLRenderer refactoring: optimized one significant bottleneck (with noticeable effect on framerate in some demos), typed arrays corresponding to matrix uniforms are now set (instead of being created anew in each frame).

Also created fully full build, with all extras included. This helps with deployment, especially when multiple versions of Three have to coexist in the same folder structure (got burned on this few times already).
alteredq 14 years ago
parent
commit
45b3ceb7df

+ 171 - 167
build/Three.js

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

+ 172 - 167
build/ThreeDebug.js

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

+ 208 - 0
build/ThreeExtras.js

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

+ 176 - 0
examples/materials_shaders_fresnel.html

@@ -0,0 +1,176 @@
+<!DOCTYPE HTML>
+<html lang="en">
+	<head>
+		<title>three.js - webgl fresnel</title>
+		<meta charset="utf-8">
+		<style type="text/css">
+			body {
+				background:#fff;
+				padding:0;
+				margin:0;
+				font-weight: bold;
+				overflow:hidden;
+			}
+
+			#info {
+				position: absolute;
+				top: 0px; width: 100%;
+				color: #ffffff;
+				padding: 5px;
+				font-family:Monospace;
+				font-size:13px;
+				text-align:center;
+				z-index:1000; 
+			}
+
+			a {
+				color: #ffffff;
+			}
+			#log { position:absolute; top:50px; text-align:left; display:block; z-index:100 }
+		</style>
+	</head>
+
+	<body>
+		<pre id="log"></pre>
+		
+		<div id="info"><a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - webgl cube Fresnel shader demo. texture by <a href="http://www.humus.name/index.php?page=Textures" target="_blank">Humus</a> </div>
+
+		<script type="text/javascript" src="../build/ThreeExtras.js"></script> 
+
+		<!--
+		<script type="text/javascript" src="js/Stats.js"></script>
+		-->
+		
+		<script type="text/javascript">
+
+			var statsEnabled = false;
+
+			var container, stats;
+
+			var camera, scene, webglRenderer;
+			var cameraCube, sceneCube;
+
+			var mesh, zmesh, lightMesh, geometry;
+
+			var directionalLight, pointLight;
+
+			var mouseX = 0;
+			var mouseY = 0;
+
+			var windowHalfX = window.innerWidth / 2;
+			var windowHalfY = window.innerHeight / 2;
+
+			document.addEventListener( 'mousemove', onDocumentMouseMove, false );
+
+			init();
+			setInterval( loop, 1000 / 60 );
+
+			function init() {
+
+				container = document.createElement('div');
+				document.body.appendChild(container);
+
+				camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 100000 );
+				camera.position.z = 3200;
+
+				cameraCube = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 100000 );
+
+				scene = new THREE.Scene();
+				sceneCube = new THREE.Scene();
+
+				var geometry = new THREE.Geometry();
+				var sphere = new THREE.Mesh( new Sphere( 100, 32, 16 ) );
+
+				for ( var i = 0; i < 200; i ++ ) {
+
+					sphere.position.x = Math.random() * 10000 - 5000;
+					sphere.position.y = Math.random() * 10000 - 5000;
+					sphere.position.z = Math.random() * 10000 - 5000;
+					sphere.scale.x = sphere.scale.y = sphere.scale.z = Math.random() * 4 + 1;
+
+					// Merging spheres in a single geometry
+					GeometryUtils.merge( geometry, sphere );
+					
+				}
+
+				var path = "textures/cube/Park2/";
+				var format = '.jpg';
+				var urls = [
+						path + 'posx' + format, path + 'negx' + format,
+						path + 'posy' + format, path + 'negy' + format,
+						path + 'posz' + format, path + 'negz' + format
+					];
+
+
+				var images = ImageUtils.loadArray( urls );
+				var textureCube = new THREE.TextureCube( images );
+				
+				var fragment_shader = ShaderUtils.lib["fresnel"].fragment_shader;
+				var vertex_shader = ShaderUtils.lib["fresnel"].vertex_shader;
+				var uniforms = ShaderUtils.lib["fresnel"].uniforms;
+				
+				uniforms["tCube"][2] = textureCube;
+				
+				var material = new THREE.MeshShaderMaterial( { fragment_shader: fragment_shader, 
+															   vertex_shader: vertex_shader, 
+															   uniforms: uniforms
+															} );
+
+				var mesh = new THREE.Mesh( geometry, material );
+				mesh.position.x = 100;
+				scene.addObject( mesh );
+
+				SceneUtils.addPanoramaCubeWebGL( sceneCube, 100000, textureCube );
+
+				webglRenderer = new THREE.WebGLRenderer( scene );
+				webglRenderer.setSize( window.innerWidth, window.innerHeight );
+				webglRenderer.autoClear = false;
+				container.appendChild( webglRenderer.domElement );
+
+				if ( statsEnabled ) {
+
+					stats = new Stats();
+					stats.domElement.style.position = 'absolute';
+					stats.domElement.style.top = '0px';
+					stats.domElement.style.zIndex = 100;
+					container.appendChild( stats.domElement );
+
+				}
+
+			}
+
+			function onDocumentMouseMove(event) {
+
+				mouseX = ( event.clientX - windowHalfX ) * 10;
+				mouseY = ( event.clientY - windowHalfY ) * 10;
+
+			}
+
+			function loop() {
+
+				camera.position.x += ( mouseX - camera.position.x ) * .05;
+				camera.position.y += ( - mouseY - camera.position.y ) * .05;
+
+				cameraCube.target.position.x = - camera.position.x;
+				cameraCube.target.position.y = - camera.position.y;
+				cameraCube.target.position.z = - camera.position.z;
+
+				webglRenderer.clear();
+				webglRenderer.render( sceneCube, cameraCube );
+				webglRenderer.render( scene, camera );
+
+				if ( statsEnabled ) stats.update();
+
+			}
+
+			function log( text ) {
+
+				var e = document.getElementById("log");
+				e.innerHTML = text + "<br/>" + e.innerHTML;
+
+			}
+
+		</script>
+
+	</body>
+</html>

+ 1 - 0
examples/test.html

@@ -46,6 +46,7 @@
 		<script type="text/javascript" src="../src/materials/MeshDepthMaterial.js"></script>
 		<script type="text/javascript" src="../src/materials/MeshNormalMaterial.js"></script>
 		<script type="text/javascript" src="../src/materials/MeshFaceMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshShaderMaterial.js"></script>
 		<script type="text/javascript" src="../src/materials/ParticleBasicMaterial.js"></script>
 		<script type="text/javascript" src="../src/materials/ParticleCircleMaterial.js"></script>
 		<script type="text/javascript" src="../src/materials/textures/Texture.js"></script>

BIN
examples/textures/cube/Park2/negx.jpg


BIN
examples/textures/cube/Park2/negy.jpg


BIN
examples/textures/cube/Park2/negz.jpg


BIN
examples/textures/cube/Park2/posx.jpg


BIN
examples/textures/cube/Park2/posy.jpg


BIN
examples/textures/cube/Park2/posz.jpg


+ 20 - 0
examples/textures/cube/Park2/readme.txt

@@ -0,0 +1,20 @@
+Author
+======
+
+This is the work of Emil Persson, aka Humus.
+http://www.humus.name
[email protected]
+
+
+
+Legal stuff
+===========
+
+This work is free and may be used by anyone for any purpose
+and may be distributed freely to anyone using any distribution
+media or distribution method as long as this file is included.
+Distribution without this file is allowed if it's distributed
+with free non-commercial software; however, fair credit of the
+original author is expected.
+Any commercial distribution of this software requires the written
+approval of Emil Persson.

+ 1 - 1
src/extras/SceneUtils.js

@@ -57,4 +57,4 @@ var SceneUtils = {
 		
 	}
 	
-}
+}

+ 78 - 0
src/extras/ShaderUtils.js

@@ -0,0 +1,78 @@
+var ShaderUtils = {
+
+	lib: { 'fresnel': {
+		
+			uniforms: { 
+			
+			"mRefractionRatio": { type: "f", value: 1.02 },
+			"mFresnelBias": 	{ type: "f", value: 0.1 },
+			"mFresnelPower":    { type: "f", value: 2.0 },
+			"mFresnelScale":    { type: "f", value: 1.0 },
+			"tCube":			{ type: "t", value: 1, texture: null }
+			
+			},
+			
+			fragment_shader: [
+			
+			"uniform samplerCube tCube;",
+			
+			"varying vec3 vReflect;",
+			"varying vec3 vRefract[3];",
+			"varying float vReflectionFactor;",
+			
+			"void main() {",
+				"vec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );",
+				"vec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );",
+				
+				"refractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;",
+				"refractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;",
+				"refractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;",
+				"refractedColor.a = 1.0;",
+				
+				"gl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );",
+			"}"	
+			].join("\n"),
+				
+			vertex_shader: [
+			
+			"attribute vec3 position;",
+			"attribute vec3 normal;",
+			"attribute vec3 uv;",
+			
+			"uniform mat4 objMatrix;",
+			"uniform mat4 modelViewMatrix;",
+			"uniform mat4 projectionMatrix;",
+			
+			"uniform vec3 cameraPosition;",
+			
+			"uniform float mRefractionRatio;",
+			"uniform float mFresnelBias;",
+			"uniform float mFresnelScale;",
+			"uniform float mFresnelPower;",
+
+			"varying vec3 vReflect;",
+			"varying vec3 vRefract[3];",
+			"varying float vReflectionFactor;",
+
+			"void main(void) {",
+				"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
+				"vec4 mPosition = objMatrix * vec4( position, 1.0 );",
+				
+				"vec3 nWorld = normalize ( mat3( objMatrix[0].xyz, objMatrix[1].xyz, objMatrix[2].xyz ) * normal );",
+				
+				"vec3 I = mPosition.xyz - cameraPosition;",
+				
+				"vReflect = reflect( I, nWorld );",
+				"vRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );",
+				"vRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );",
+				"vRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );",
+				"vReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );",
+				
+				"gl_Position = projectionMatrix * mvPosition;",
+			"}"	
+			].join("\n")
+			
+		}
+	}
+
+};

+ 267 - 153
src/renderers/WebGLRenderer.js

@@ -12,17 +12,24 @@ THREE.WebGLRenderer = function ( scene ) {
 	// The problem comes from shader using too many varying vectors.
 
 	// This is not GPU limitation as the same shader works ok in Firefox
-	// or Chrome with "--use-gl=desktop" flag.
+	// and Chrome with "--use-gl=desktop" flag.
 	
-	// This difference comes from Chrome on Windows using by default ANGLE,
+	// Difference comes from Chrome on Windows using by default ANGLE,
 	// thus going DirectX9 route (while FF uses OpenGL).
 	
 	// See http://code.google.com/p/chromium/issues/detail?id=63491
 
-	var _canvas = document.createElement( 'canvas' ), _gl, _program,
+	var _canvas = document.createElement( 'canvas' ), _gl, 
+	_program, _oldProgram,
 	_modelViewMatrix = new THREE.Matrix4(), _normalMatrix,
+	
+	_viewMatrixArray = new Float32Array(16), 
+	_modelViewMatrixArray = new Float32Array(16), 
+	_projectionMatrixArray = new Float32Array(16), 
+	_normalMatrixArray = new Float32Array(9),
+	_objMatrixArray = new Float32Array(16),
 
-	// material constants used in shader
+	// ubershader material constants
 	
 	BASIC = 0, LAMBERT = 1, PHONG = 2, DEPTH = 3, NORMAL = 4, CUBE = 5, 
 
@@ -35,7 +42,7 @@ THREE.WebGLRenderer = function ( scene ) {
 	this.autoClear = true;
 
 	initGL();
-	initProgram( maxLightCount.directional, maxLightCount.point );
+	initUbershader( maxLightCount.directional, maxLightCount.point );
 
 	//alert( dumpObject( getGLParams() ) );
 
@@ -53,13 +60,13 @@ THREE.WebGLRenderer = function ( scene ) {
 
 	};
 
-	this.setupLights = function ( scene ) {
+	this.setupLights = function ( program, scene ) {
 
 		var l, ll, light, r, g, b,
 			ambientLights = [], pointLights = [], directionalLights = [],
 			colors = [], positions = [];
 
-		_gl.uniform1i( _program.enableLighting, scene.lights.length );
+		_gl.uniform1i( program.uniforms.enableLighting, scene.lights.length );
 
 		for ( l = 0, ll = scene.lights.length; l < ll; l++ ) {
 
@@ -92,7 +99,7 @@ THREE.WebGLRenderer = function ( scene ) {
 
 		}
 
-		_gl.uniform3f( _program.ambientLightColor, r, g, b );
+		_gl.uniform3f( program.uniforms.ambientLightColor, r, g, b );
 
 		// pass directional lights as float arrays
 
@@ -114,9 +121,9 @@ THREE.WebGLRenderer = function ( scene ) {
 
 		if ( directionalLights.length ) {
 
-			_gl.uniform1i(  _program.directionalLightNumber, directionalLights.length );
-			_gl.uniform3fv( _program.directionalLightDirection, positions );
-			_gl.uniform3fv( _program.directionalLightColor, colors );
+			_gl.uniform1i(  program.uniforms.directionalLightNumber, directionalLights.length );
+			_gl.uniform3fv( program.uniforms.directionalLightDirection, positions );
+			_gl.uniform3fv( program.uniforms.directionalLightColor, colors );
 
 		}
 
@@ -140,9 +147,9 @@ THREE.WebGLRenderer = function ( scene ) {
 
 		if ( pointLights.length ) {
 
-			_gl.uniform1i(  _program.pointLightNumber, pointLights.length );
-			_gl.uniform3fv( _program.pointLightPosition, positions );
-			_gl.uniform3fv( _program.pointLightColor, colors );
+			_gl.uniform1i(  program.uniforms.pointLightNumber, pointLights.length );
+			_gl.uniform3fv( program.uniforms.pointLightPosition, positions );
+			_gl.uniform3fv( program.uniforms.pointLightColor, colors );
 
 		}
 
@@ -309,16 +316,51 @@ THREE.WebGLRenderer = function ( scene ) {
 
 	};
 
-	this.renderBuffer = function ( material, materialFaceGroup ) {
+	this.renderBuffer = function ( camera, material, materialFaceGroup ) {
 
 		var mColor, mOpacity, mReflectivity,
 			mWireframe, mLineWidth, mBlending,
 			mAmbient, mSpecular, mShininess,
 			mMap, envMap, mixEnvMap,
-			mRefractionRatio, useRefract;
+			mRefractionRatio, useRefract,
+			program, u, identifiers;
 		
 
-		if ( material instanceof THREE.MeshPhongMaterial ||
+		if ( material instanceof THREE.MeshShaderMaterial ) {
+			
+			if ( !material.program ) {
+				
+				material.program = buildProgram( material.fragment_shader, material.vertex_shader );
+				
+				identifiers = [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objMatrix', 'cameraPosition' ];
+				for( u in material.uniforms ) identifiers.push(u);
+				cacheUniformLocations( material.program, identifiers );
+				cacheAttributeLocations( material.program );
+				
+			}
+			
+			program = material.program;
+			
+		} else {
+			
+			program = _program;
+			
+		}
+		
+		if( program != _oldProgram ) {
+			
+			_gl.useProgram( program );
+			_oldProgram = program;
+			
+		}
+			
+		if ( material instanceof THREE.MeshShaderMaterial ) {
+			
+			setUniforms( program, material.uniforms );
+			this.loadCamera( program, camera );
+			this.loadMatrices( program );
+			
+		} else if ( material instanceof THREE.MeshPhongMaterial ||
 			 material instanceof THREE.MeshLambertMaterial ||
 			 material instanceof THREE.MeshBasicMaterial ) {
 
@@ -339,13 +381,13 @@ THREE.WebGLRenderer = function ( scene ) {
 			useRefract = material.env_map && material.env_map.mapping == THREE.RefractionMap;
 			mRefractionRatio = material.refraction_ratio;
 
-			_gl.uniform4f( _program.mColor,  mColor.r * mOpacity, mColor.g * mOpacity, mColor.b * mOpacity, mOpacity );
+			_gl.uniform4f( program.uniforms.mColor,  mColor.r * mOpacity, mColor.g * mOpacity, mColor.b * mOpacity, mOpacity );
 
-			_gl.uniform1i( _program.mixEnvMap, mixEnvMap );
-			_gl.uniform1f( _program.mReflectivity, mReflectivity );
+			_gl.uniform1i( program.uniforms.mixEnvMap, mixEnvMap );
+			_gl.uniform1f( program.uniforms.mReflectivity, mReflectivity );
 
-			_gl.uniform1i( _program.useRefract, useRefract );
-			_gl.uniform1f( _program.mRefractionRatio, mRefractionRatio );
+			_gl.uniform1i( program.uniforms.useRefract, useRefract );
+			_gl.uniform1f( program.uniforms.mRefractionRatio, mRefractionRatio );
 
 		}
 
@@ -354,9 +396,9 @@ THREE.WebGLRenderer = function ( scene ) {
 			mOpacity = material.opacity;
 			mBlending = material.blending;
 
-			_gl.uniform1f( _program.mOpacity, mOpacity );
+			_gl.uniform1f( program.uniforms.mOpacity, mOpacity );
 
-			_gl.uniform1i( _program.material, NORMAL );
+			_gl.uniform1i( program.uniforms.material, NORMAL );
 
 		} else if ( material instanceof THREE.MeshDepthMaterial ) {
 
@@ -365,13 +407,13 @@ THREE.WebGLRenderer = function ( scene ) {
 			mWireframe = material.wireframe;
 			mLineWidth = material.wireframe_linewidth;
 
-			_gl.uniform1f( _program.mOpacity, mOpacity );
+			_gl.uniform1f( program.uniforms.mOpacity, mOpacity );
 
-			_gl.uniform1f( _program.m2Near, material.__2near );
-			_gl.uniform1f( _program.mFarPlusNear, material.__farPlusNear );
-			_gl.uniform1f( _program.mFarMinusNear, material.__farMinusNear );
+			_gl.uniform1f( program.uniforms.m2Near, material.__2near );
+			_gl.uniform1f( program.uniforms.mFarPlusNear, material.__farPlusNear );
+			_gl.uniform1f( program.uniforms.mFarMinusNear, material.__farMinusNear );
 
-			_gl.uniform1i( _program.material, DEPTH );
+			_gl.uniform1i( program.uniforms.material, DEPTH );
 
 		} else if ( material instanceof THREE.MeshPhongMaterial ) {
 
@@ -379,23 +421,23 @@ THREE.WebGLRenderer = function ( scene ) {
 			mSpecular = material.specular;
 			mShininess = material.shininess;
 
-			_gl.uniform4f( _program.mAmbient,  mAmbient.r,  mAmbient.g,  mAmbient.b,  mOpacity );
-			_gl.uniform4f( _program.mSpecular, mSpecular.r, mSpecular.g, mSpecular.b, mOpacity );
-			_gl.uniform1f( _program.mShininess, mShininess );
+			_gl.uniform4f( program.uniforms.mAmbient,  mAmbient.r,  mAmbient.g,  mAmbient.b,  mOpacity );
+			_gl.uniform4f( program.uniforms.mSpecular, mSpecular.r, mSpecular.g, mSpecular.b, mOpacity );
+			_gl.uniform1f( program.uniforms.mShininess, mShininess );
 
-			_gl.uniform1i( _program.material, PHONG );
+			_gl.uniform1i( program.uniforms.material, PHONG );
 
 		} else if ( material instanceof THREE.MeshLambertMaterial ) {
 
-			_gl.uniform1i( _program.material, LAMBERT );
+			_gl.uniform1i( program.uniforms.material, LAMBERT );
 
 		} else if ( material instanceof THREE.MeshBasicMaterial ) {
 
-			_gl.uniform1i( _program.material, BASIC );
+			_gl.uniform1i( program.uniforms.material, BASIC );
 
 		} else if ( material instanceof THREE.MeshCubeMaterial ) {
 
-			_gl.uniform1i( _program.material, CUBE );
+			_gl.uniform1i( program.uniforms.material, CUBE );
 
 			envMap = material.env_map;
 
@@ -421,13 +463,13 @@ THREE.WebGLRenderer = function ( scene ) {
 
 			_gl.activeTexture( _gl.TEXTURE0 );
 			_gl.bindTexture( _gl.TEXTURE_2D, material.map.__webGLTexture );
-			_gl.uniform1i( _program.tMap,  0 );
+			_gl.uniform1i( program.uniforms.tMap,  0 );
 
-			_gl.uniform1i( _program.enableMap, 1 );
+			_gl.uniform1i( program.uniforms.enableMap, 1 );
 
 		} else {
 
-			_gl.uniform1i( _program.enableMap, 0 );
+			_gl.uniform1i( program.uniforms.enableMap, 0 );
 
 		}
 
@@ -465,27 +507,27 @@ THREE.WebGLRenderer = function ( scene ) {
 
 				_gl.activeTexture( _gl.TEXTURE1 );
 				_gl.bindTexture( _gl.TEXTURE_CUBE_MAP, material.env_map.image.__webGLTextureCube );
-				_gl.uniform1i( _program.tCube,  1 );
+				_gl.uniform1i( program.uniforms.tCube,  1 );
 
 			}
 
-			_gl.uniform1i( _program.enableCubeMap, 1 );
+			_gl.uniform1i( program.uniforms.enableCubeMap, 1 );
 
 		} else {
 
-			_gl.uniform1i( _program.enableCubeMap, 0 );
+			_gl.uniform1i( program.uniforms.enableCubeMap, 0 );
 
 		}
 
 		// vertices
 
 		_gl.bindBuffer( _gl.ARRAY_BUFFER, materialFaceGroup.__webGLVertexBuffer );
-		_gl.vertexAttribPointer( _program.position, 3, _gl.FLOAT, false, 0, 0 );
+		_gl.vertexAttribPointer( program.position, 3, _gl.FLOAT, false, 0, 0 );
 
 		// normals
 
 		_gl.bindBuffer( _gl.ARRAY_BUFFER, materialFaceGroup.__webGLNormalBuffer );
-		_gl.vertexAttribPointer( _program.normal, 3, _gl.FLOAT, false, 0, 0 );
+		_gl.vertexAttribPointer( program.normal, 3, _gl.FLOAT, false, 0, 0 );
 
 		// uvs
 
@@ -493,12 +535,12 @@ THREE.WebGLRenderer = function ( scene ) {
 
 			_gl.bindBuffer( _gl.ARRAY_BUFFER, materialFaceGroup.__webGLUVBuffer );
 
-			_gl.enableVertexAttribArray( _program.uv );
-			_gl.vertexAttribPointer( _program.uv, 2, _gl.FLOAT, false, 0, 0 );
+			_gl.enableVertexAttribArray( program.uv );
+			_gl.vertexAttribPointer( program.uv, 2, _gl.FLOAT, false, 0, 0 );
 
 		} else {
 
-			_gl.disableVertexAttribArray( _program.uv );
+			_gl.disableVertexAttribArray( program.uv );
 
 		}
 
@@ -521,7 +563,7 @@ THREE.WebGLRenderer = function ( scene ) {
 
 	};
 
-	this.renderPass = function ( object, materialFaceGroup, blending, transparent ) {
+	this.renderPass = function ( camera, object, materialFaceGroup, blending, transparent ) {
 
 		var i, l, m, ml, material, meshMaterial;
 
@@ -537,7 +579,7 @@ THREE.WebGLRenderer = function ( scene ) {
 					if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) {
 
 						this.setBlending( material.blending );
-						this.renderBuffer( material, materialFaceGroup );
+						this.renderBuffer( camera, material, materialFaceGroup );
 
 					}
 
@@ -549,7 +591,8 @@ THREE.WebGLRenderer = function ( scene ) {
 				if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) {
 
 					this.setBlending( material.blending );
-					this.renderBuffer( material, materialFaceGroup );
+					this.renderBuffer( camera, material, materialFaceGroup );
+					
 				}
 
 			}
@@ -557,7 +600,7 @@ THREE.WebGLRenderer = function ( scene ) {
 		}
 
 	};
-
+	
 	this.render = function( scene, camera ) {
 
 		var o, ol;
@@ -571,9 +614,9 @@ THREE.WebGLRenderer = function ( scene ) {
 		}
 
 		camera.autoUpdateMatrix && camera.updateMatrix();
-		_gl.uniform3f( _program.cameraPosition, camera.position.x, camera.position.y, camera.position.z );
+		this.loadCamera( _program, camera );
 
-		this.setupLights( scene );
+		this.setupLights( _program, scene );
 
 		// opaque pass
 
@@ -584,7 +627,8 @@ THREE.WebGLRenderer = function ( scene ) {
 			if ( webGLObject.__object.visible ) {
 
 				this.setupMatrices( webGLObject.__object, camera );
-				this.renderPass( webGLObject.__object, webGLObject, THREE.NormalBlending, false );
+				this.loadMatrices( _program );
+				this.renderPass( camera, webGLObject.__object, webGLObject, THREE.NormalBlending, false );
 				
 			}
 
@@ -599,20 +643,21 @@ THREE.WebGLRenderer = function ( scene ) {
 			if ( webGLObject.__object.visible ) {
 				
 				this.setupMatrices( webGLObject.__object, camera );
+				this.loadMatrices( _program );
 
 				// opaque blended materials
 				
-				this.renderPass( webGLObject.__object, webGLObject, THREE.AdditiveBlending, false );
-				this.renderPass( webGLObject.__object, webGLObject, THREE.SubtractiveBlending, false );
+				this.renderPass( camera, webGLObject.__object, webGLObject, THREE.AdditiveBlending, false );
+				this.renderPass( camera, webGLObject.__object, webGLObject, THREE.SubtractiveBlending, false );
 				
 				// transparent blended materials
 				
-				this.renderPass( webGLObject.__object, webGLObject, THREE.AdditiveBlending, true );
-				this.renderPass( webGLObject.__object, webGLObject, THREE.SubtractiveBlending, true );
+				this.renderPass( camera, webGLObject.__object, webGLObject, THREE.AdditiveBlending, true );
+				this.renderPass( camera, webGLObject.__object, webGLObject, THREE.SubtractiveBlending, true );
 
 				// transparent normal materials
 				
-				this.renderPass( webGLObject.__object, webGLObject, THREE.NormalBlending, true );
+				this.renderPass( camera, webGLObject.__object, webGLObject, THREE.NormalBlending, true );
 				
 			}
 
@@ -688,21 +733,32 @@ THREE.WebGLRenderer = function ( scene ) {
 
 		_modelViewMatrix.multiply( camera.matrix, object.matrix );
 
-		_program.viewMatrixArray = new Float32Array( camera.matrix.flatten() );
-		_program.modelViewMatrixArray = new Float32Array( _modelViewMatrix.flatten() );
-		_program.projectionMatrixArray = new Float32Array( camera.projectionMatrix.flatten() );
+		_viewMatrixArray.set( camera.matrix.flatten() );
+		_modelViewMatrixArray.set( _modelViewMatrix.flatten() );
+		_projectionMatrixArray.set( camera.projectionMatrix.flatten() );
 
 		_normalMatrix = THREE.Matrix4.makeInvert3x3( _modelViewMatrix ).transpose();
-		_program.normalMatrixArray = new Float32Array( _normalMatrix.m );
-
-		_gl.uniformMatrix4fv( _program.viewMatrix, false, _program.viewMatrixArray );
-		_gl.uniformMatrix4fv( _program.modelViewMatrix, false, _program.modelViewMatrixArray );
-		_gl.uniformMatrix4fv( _program.projectionMatrix, false, _program.projectionMatrixArray );
-		_gl.uniformMatrix3fv( _program.normalMatrix, false, _program.normalMatrixArray );
-		_gl.uniformMatrix4fv( _program.objMatrix, false, new Float32Array( object.matrix.flatten() ) );
+		_normalMatrixArray.set( _normalMatrix.m );
 
+		_objMatrixArray.set( object.matrix.flatten() );
+	
+	};
+	
+	this.loadMatrices = function ( program ) {
+		
+		_gl.uniformMatrix4fv( program.uniforms.viewMatrix, false, _viewMatrixArray );
+		_gl.uniformMatrix4fv( program.uniforms.modelViewMatrix, false, _modelViewMatrixArray );
+		_gl.uniformMatrix4fv( program.uniforms.projectionMatrix, false, _projectionMatrixArray );
+		_gl.uniformMatrix3fv( program.uniforms.normalMatrix, false, _normalMatrixArray );
+		_gl.uniformMatrix4fv( program.uniforms.objMatrix, false, _objMatrixArray );
+		
 	};
 
+	this.loadCamera = function( program, camera ) {
+		
+		_gl.uniform3f( program.uniforms.cameraPosition, camera.position.x, camera.position.y, camera.position.z );
+		
+	};
 
 	this.setBlending = function( blending ) {
 
@@ -732,7 +788,7 @@ THREE.WebGLRenderer = function ( scene ) {
 
 	};
 
-	this.setFaceCulling = function( cullFace, frontFace ) {
+	this.setFaceCulling = function ( cullFace, frontFace ) {
 
 		if ( cullFace ) {
 
@@ -743,6 +799,7 @@ THREE.WebGLRenderer = function ( scene ) {
 			} else {
 
 				_gl.frontFace( _gl.CW );
+				
 			}
 
 			if( cullFace == "back" ) {
@@ -756,6 +813,7 @@ THREE.WebGLRenderer = function ( scene ) {
 			} else {
 
 				_gl.cullFace( _gl.FRONT_AND_BACK );
+				
 			}
 
 			_gl.enable( _gl.CULL_FACE );
@@ -763,6 +821,7 @@ THREE.WebGLRenderer = function ( scene ) {
 		} else {
 
 			_gl.disable( _gl.CULL_FACE );
+		
 		}
 
 	};
@@ -804,10 +863,6 @@ THREE.WebGLRenderer = function ( scene ) {
 
 		var chunks = [
 
-			"#ifdef GL_ES",
-			"precision highp float;",
-			"#endif",
-
 			maxDirLights   ? "#define MAX_DIR_LIGHTS " + maxDirLights     : "",
 			maxPointLights ? "#define MAX_POINT_LIGHTS " + maxPointLights : "",
 
@@ -1129,125 +1184,184 @@ THREE.WebGLRenderer = function ( scene ) {
 
 	};
 
-	function initProgram( maxDirLights, maxPointLights ) {
-
-		_program = _gl.createProgram();
-
-		//log ( generateVertexShader( maxDirLights, maxPointLights ) );
-		//log ( generateFragmentShader( maxDirLights, maxPointLights ) );
-
-		_gl.attachShader( _program, getShader( "fragment", generateFragmentShader( maxDirLights, maxPointLights ) ) );
-		_gl.attachShader( _program, getShader( "vertex",   generateVertexShader( maxDirLights, maxPointLights ) ) );
-
-		_gl.linkProgram( _program );
+	function buildProgram( fragment_shader, vertex_shader ) {
+		
+		var program = _gl.createProgram(),
+		
+		prefix = [ "#ifdef GL_ES",
+				   "precision highp float;",
+				   "#endif",
+				   ""
+			     ].join("\n");
+
+		_gl.attachShader( program, getShader( "fragment", prefix + fragment_shader ) );
+		_gl.attachShader( program, getShader( "vertex", vertex_shader ) );
+		
+		_gl.linkProgram( program );
 
-		if ( !_gl.getProgramParameter( _program, _gl.LINK_STATUS ) ) {
+		if ( !_gl.getProgramParameter( program, _gl.LINK_STATUS ) ) {
 
 			alert( "Could not initialise shaders" );
 
-			alert( "VALIDATE_STATUS: " + _gl.getProgramParameter( _program, _gl.VALIDATE_STATUS ) );
+			alert( "VALIDATE_STATUS: " + _gl.getProgramParameter( program, _gl.VALIDATE_STATUS ) );
 			alert( _gl.getError() );
 			
 		}
+		
+		program.uniforms = {};
+		
+		return program;
+		
+	};
+	
+	function setUniforms( program, uniforms ) {
+		
+		var u, value, type, location, texture;
+		
+		for( u in uniforms ) {
+			
+			type = uniforms[u].type;
+			value = uniforms[u].value;
+			location = program.uniforms[u];
+			
+			if( type == "i" ) {
+				
+				_gl.uniform1i( location, value );
+				
+			} else if( type == "f" ) {
+				
+				_gl.uniform1f( location, value );
+				
+			} else if( type == "t" ) {
+			
+				_gl.uniform1i( location, value );
+				
+				texture = uniforms[u].texture;
+				
+				if ( texture instanceof THREE.TextureCube &&
+					 texture.image.length == 6 ) {
 
+					if ( !texture.image.__webGLTextureCube &&
+						 !texture.image.__cubeMapInitialized && texture.image.loadCount == 6 ) {
 
-		_gl.useProgram( _program );
-
-		// matrices
+						texture.image.__webGLTextureCube = _gl.createTexture();
 
-		_program.viewMatrix = _gl.getUniformLocation( _program, "viewMatrix" );
-		_program.modelViewMatrix = _gl.getUniformLocation( _program, "modelViewMatrix" );
-		_program.projectionMatrix = _gl.getUniformLocation( _program, "projectionMatrix" );
-		_program.normalMatrix = _gl.getUniformLocation( _program, "normalMatrix" );
-		_program.objMatrix = _gl.getUniformLocation( _program, "objMatrix" );
+						_gl.bindTexture( _gl.TEXTURE_CUBE_MAP, texture.image.__webGLTextureCube );
 
-		_program.cameraPosition = _gl.getUniformLocation( _program, 'cameraPosition' );
+						_gl.texParameteri( _gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE );
+						_gl.texParameteri( _gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE );
 
-		// lights
+						_gl.texParameteri( _gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_MAG_FILTER, _gl.LINEAR );
+						_gl.texParameteri( _gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_MIN_FILTER, _gl.LINEAR_MIPMAP_LINEAR );
 
-		_program.enableLighting = _gl.getUniformLocation( _program, 'enableLighting' );
+						for ( var i = 0; i < 6; ++i ) {
 
-		_program.ambientLightColor = _gl.getUniformLocation( _program, 'ambientLightColor' );
+							_gl.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, _gl.RGBA, _gl.RGBA, _gl.UNSIGNED_BYTE, texture.image[ i ] );
 
-		if ( maxDirLights ) {
+						}
 
-			_program.directionalLightNumber = _gl.getUniformLocation( _program, 'directionalLightNumber' );
-			_program.directionalLightColor = _gl.getUniformLocation( _program, 'directionalLightColor' );
-			_program.directionalLightDirection = _gl.getUniformLocation( _program, 'directionalLightDirection' );
+						_gl.generateMipmap( _gl.TEXTURE_CUBE_MAP );
 
-		}
+						_gl.bindTexture( _gl.TEXTURE_CUBE_MAP, null );
 
-		if ( maxPointLights ) {
+						texture.image.__cubeMapInitialized = true;
 
-			_program.pointLightNumber = _gl.getUniformLocation( _program, 'pointLightNumber' );
-			_program.pointLightColor = _gl.getUniformLocation( _program, 'pointLightColor' );
-			_program.pointLightPosition = _gl.getUniformLocation( _program, 'pointLightPosition' );
+					}
 
+					_gl.activeTexture( _gl.TEXTURE1 );
+					_gl.bindTexture( _gl.TEXTURE_CUBE_MAP, texture.image.__webGLTextureCube );
+				
+				}
+			
+			}
+			
 		}
+		
+	};
 
-		// material
-
-		_program.material = _gl.getUniformLocation( _program, 'material' );
+	function cacheUniformLocations( program, identifiers ) {
+		
+		var i, l, id;
+		
+		for( i = 0, l = identifiers.length; i < l; i++ ) {
+			
+			id = identifiers[i];
+			program.uniforms[id] = _gl.getUniformLocation( program, id );
+			
+		}
+		
+	};
+	
+	function cacheAttributeLocations( program ) {
+		
+		program.position = _gl.getAttribLocation( program, "position" );
+		_gl.enableVertexAttribArray( program.position );
 
-		// material properties (Basic / Lambert / Blinn-Phong shader)
+		program.normal = _gl.getAttribLocation( program, "normal" );
+		_gl.enableVertexAttribArray( program.normal );
 
-		_program.mColor = _gl.getUniformLocation( _program, 'mColor' );
-		_program.mOpacity = _gl.getUniformLocation( _program, 'mOpacity' );
-		_program.mReflectivity = _gl.getUniformLocation( _program, 'mReflectivity' );
+		program.uv = _gl.getAttribLocation( program, "uv" );
+		_gl.enableVertexAttribArray( program.uv );
 
-		// material properties (Blinn-Phong shader)
+	};
+	
+	function initUbershader( maxDirLights, maxPointLights ) {
 
-		_program.mAmbient = _gl.getUniformLocation( _program, 'mAmbient' );
-		_program.mSpecular = _gl.getUniformLocation( _program, 'mSpecular' );
-		_program.mShininess = _gl.getUniformLocation( _program, 'mShininess' );
+		var vertex_shader = generateVertexShader( maxDirLights, maxPointLights ),
+		    fragment_shader = generateFragmentShader( maxDirLights, maxPointLights );
 
-		// texture (diffuse map)
+		//log ( vertex_shader );
+		//log ( fragment_shader );
+		
+		_program = buildProgram( fragment_shader, vertex_shader );
+		
+		_gl.useProgram( _program );
 
-		_program.enableMap = _gl.getUniformLocation( _program, "enableMap" );
-		_gl.uniform1i( _program.enableMap, 0 );
+		// matrices
+		// lights
+		// material properties (Basic / Lambert / Blinn-Phong shader)
+		// material properties (Depth)
 
-		_program.tMap = _gl.getUniformLocation( _program, "tMap" );
-		_gl.uniform1i( _program.tMap, 0 );
+		cacheUniformLocations( _program, [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objMatrix', 'cameraPosition',
+										   'enableLighting', 'ambientLightColor',
+										   'material', 'mColor', 'mAmbient', 'mSpecular', 'mShininess', 'mOpacity',
+										   'enableMap', 'tMap',
+										   'enableCubeMap', 'tCube', 'mixEnvMap', 'mReflectivity',
+										   'mRefractionRatio', 'useRefract',
+										   'm2Near', 'mFarPlusNear', 'mFarMinusNear'
+		] );		
 
-		// cube texture
 
-		_program.enableCubeMap = _gl.getUniformLocation( _program, "enableCubeMap" );
-		_gl.uniform1i( _program.enableCubeMap, 0 );
+		if ( maxDirLights ) {
+			
+			cacheUniformLocations( _program, [ 'directionalLightNumber', 'directionalLightColor', 'directionalLightDirection' ] );			
 
-		_program.tCube = _gl.getUniformLocation( _program, "tCube" );
-		_gl.uniform1i( _program.tCube, 1 ); // it's important to use non-zero texture unit, otherwise it doesn't work
+		}
 
-		_program.mixEnvMap = _gl.getUniformLocation( _program, "mixEnvMap" );
-		_gl.uniform1i( _program.mixEnvMap, 0 );
+		if ( maxPointLights ) {
 
-		// refraction
+			cacheUniformLocations( _program, [ 'pointLightNumber', 'pointLightColor', 'pointLightPosition' ] );			
 
-		_program.mRefractionRatio = _gl.getUniformLocation( _program, 'mRefractionRatio' );
+		}
 
-		_program.useRefract = _gl.getUniformLocation( _program, "useRefract" );
-		_gl.uniform1i( _program.useRefract, 0 );
+		// texture (diffuse map)
+		
+		_gl.uniform1i( _program.uniforms.enableMap, 0 );
+		_gl.uniform1i( _program.uniforms.tMap, 0 );
 
-		// material properties (Depth)
+		// cube texture
 
-		_program.m2Near = _gl.getUniformLocation( _program, 'm2Near' );
-		_program.mFarPlusNear = _gl.getUniformLocation( _program, 'mFarPlusNear' );
-		_program.mFarMinusNear = _gl.getUniformLocation( _program, 'mFarMinusNear' );
+		_gl.uniform1i( _program.uniforms.enableCubeMap, 0 );
+		_gl.uniform1i( _program.uniforms.tCube, 1 ); // it's important to use non-zero texture unit, otherwise it doesn't work
+		_gl.uniform1i( _program.uniforms.mixEnvMap, 0 );
 
+		// refraction
+		
+		_gl.uniform1i( _program.uniforms.useRefract, 0 );
+		
 		// vertex arrays
 
-		_program.position = _gl.getAttribLocation( _program, "position" );
-		_gl.enableVertexAttribArray( _program.position );
-
-		_program.normal = _gl.getAttribLocation( _program, "normal" );
-		_gl.enableVertexAttribArray( _program.normal );
-
-		_program.uv = _gl.getAttribLocation( _program, "uv" );
-		_gl.enableVertexAttribArray( _program.uv );
-
-
-		_program.viewMatrixArray = new Float32Array(16);
-		_program.modelViewMatrixArray = new Float32Array(16);
-		_program.projectionMatrixArray = new Float32Array(16);
+		cacheAttributeLocations( _program );	
 
 	};
 
@@ -1299,7 +1413,7 @@ THREE.WebGLRenderer = function ( scene ) {
 
 	};
 	
-	function bufferNeedsSmoothNormals ( materialFaceGroup, object ) {
+	function bufferNeedsSmoothNormals( materialFaceGroup, object ) {
 		
 		var m, ml, i, l, needsSmoothNormals = false;
 		

+ 1 - 0
utils/build.bat

@@ -1,2 +1,3 @@
 python build.py
+python build.py --extras
 python build.py --debug

+ 69 - 0
utils/build.py

@@ -83,6 +83,69 @@ def build(files, debug, outputFilename):
 	output(addHeader(compress(text), outputFilename), outputFilename)
 
 
+def buildExtras(debug):
+	files = [
+		'Three.js',
+		'core/Color.js',
+		'core/Vector2.js',
+		'core/Vector3.js',
+		'core/Vector4.js',
+		'core/Ray.js',
+		'core/Rectangle.js',
+		'core/Matrix3.js',
+		'core/Matrix4.js',
+		'core/Vertex.js',
+		'core/Face3.js',
+		'core/Face4.js',
+		'core/UV.js',
+		'core/Geometry.js',
+		'cameras/Camera.js',
+		'lights/Light.js',
+		'lights/AmbientLight.js',
+		'lights/DirectionalLight.js',
+		'lights/PointLight.js',
+		'objects/Object3D.js',
+		'objects/Particle.js',
+		'objects/Line.js',
+		'objects/Mesh.js',
+		'materials/Material.js',
+		'materials/LineBasicMaterial.js',
+		'materials/MeshBasicMaterial.js',
+		'materials/MeshLambertMaterial.js',
+		'materials/MeshPhongMaterial.js',
+		'materials/MeshDepthMaterial.js',
+		'materials/MeshNormalMaterial.js',
+		'materials/MeshFaceMaterial.js',
+		'materials/MeshCubeMaterial.js',
+		'materials/MeshShaderMaterial.js',
+		'materials/ParticleBasicMaterial.js',
+		'materials/ParticleCircleMaterial.js',
+		'materials/ParticleDOMMaterial.js',
+		'materials/textures/Texture.js',
+		'materials/textures/TextureCube.js',
+		'scenes/Scene.js',
+		'renderers/Projector.js',
+		'renderers/DOMRenderer.js',
+		'renderers/CanvasRenderer.js',
+		'renderers/SVGRenderer.js',
+		'renderers/WebGLRenderer.js',
+		'renderers/renderables/RenderableFace3.js',
+		'renderers/renderables/RenderableFace4.js',
+		'renderers/renderables/RenderableParticle.js',
+		'renderers/renderables/RenderableLine.js',
+		'extras/GeometryUtils.js',
+		'extras/ImageUtils.js',
+		'extras/SceneUtils.js',
+		'extras/ShaderUtils.js',
+		'extras/primitives/Cube.js',
+		'extras/primitives/Cylinder.js',
+		'extras/primitives/Plane.js',
+		'extras/primitives/Sphere.js',
+		'extras/io/Loader.js'
+	]
+
+	build(files, debug, 'ThreeExtras')
+	
 def buildFull(debug):
 	files = [
 		'Three.js',
@@ -117,6 +180,7 @@ def buildFull(debug):
 		'materials/MeshNormalMaterial.js',
 		'materials/MeshFaceMaterial.js',
 		'materials/MeshCubeMaterial.js',
+		'materials/MeshShaderMaterial.js',
 		'materials/ParticleBasicMaterial.js',
 		'materials/ParticleCircleMaterial.js',
 		'materials/ParticleDOMMaterial.js',
@@ -221,6 +285,7 @@ def buildWebGL(debug):
 		'materials/MeshNormalMaterial.js',
 		'materials/MeshFaceMaterial.js',
 		'materials/MeshCubeMaterial.js',
+		'materials/MeshShaderMaterial.js',
 		'materials/ParticleBasicMaterial.js',
 		'materials/ParticleCircleMaterial.js',
 		'materials/textures/Texture.js',
@@ -313,6 +378,7 @@ def parse_args():
 
 	if ap:
 		parser = argparse.ArgumentParser(description='Build and compress Three.js')
+		parser.add_argument('--extras', help='Build ThreeExtras.js', action='store_const', const=True)
 		parser.add_argument('--full', help='Build Three.js', action='store_const', const=True, default=True)
 		parser.add_argument('--canvas', help='Build ThreeCanvas.js', action='store_true')
 		parser.add_argument('--webgl', help='Build ThreeWebGL.js', action='store_true')
@@ -325,6 +391,7 @@ def parse_args():
 
 	else:
 		parser = optparse.OptionParser(description='Build and compress Three.js')
+		parser.add_option('--extras', dest='extras', help='Build ThreeExtras.js', action='store_const', const=True)
 		parser.add_option('--full', dest='full', help='Build Three.js', action='store_const', const=True, default=True)
 		parser.add_option('--canvas', dest='canvas', help='Build ThreeCanvas.js', action='store_true')
 		parser.add_option('--webgl', dest='webgl', help='Build ThreeWebGL.js', action='store_true')
@@ -344,6 +411,8 @@ def main(argv=None):
 
 	debug = args.debug
 
+	if args.extras:
+		buildExtras(debug)
 
 	if args.full or args.all:
 		buildFull(debug)

+ 1 - 0
utils/build.sh

@@ -2,5 +2,6 @@
 
 python build.py
 python build.py --debug
+python build.py --extras
 
 # python build.py --help