Browse Source

Added handling of 2d textures in MeshShaderMaterial.

alteredq 14 years ago
parent
commit
c1cb8e9067
4 changed files with 423 additions and 413 deletions
  1. 122 122
      build/Three.js
  2. 123 123
      build/ThreeDebug.js
  3. 140 140
      build/ThreeExtras.js
  4. 38 28
      src/renderers/WebGLRenderer.js

+ 122 - 122
build/Three.js

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

+ 123 - 123
build/ThreeDebug.js

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

+ 140 - 140
build/ThreeExtras.js

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

+ 38 - 28
src/renderers/WebGLRenderer.js

@@ -445,26 +445,9 @@ THREE.WebGLRenderer = function ( scene ) {
 		
 		if ( mMap ) {
 
-			if ( !material.map.__webGLTexture && material.map.image.loaded ) {
-
-				material.map.__webGLTexture = _gl.createTexture();
-				_gl.bindTexture( _gl.TEXTURE_2D, material.map.__webGLTexture );
-				_gl.texImage2D( _gl.TEXTURE_2D, 0, _gl.RGBA, _gl.RGBA, _gl.UNSIGNED_BYTE, material.map.image );
-				
-				_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_S, paramThreeToGL( material.map.wrap_s ) );
-				_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_T, paramThreeToGL( material.map.wrap_t ) );
-				
-				_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MAG_FILTER, _gl.LINEAR );
-				_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, _gl.LINEAR_MIPMAP_LINEAR );
-				_gl.generateMipmap( _gl.TEXTURE_2D );
-				_gl.bindTexture( _gl.TEXTURE_2D, null );
-
-			}
-
-			_gl.activeTexture( _gl.TEXTURE0 );
-			_gl.bindTexture( _gl.TEXTURE_2D, material.map.__webGLTexture );
+			setTexture( mMap, 0 );
+			
 			_gl.uniform1i( program.uniforms.tMap,  0 );
-
 			_gl.uniform1i( program.uniforms.enableMap, 1 );
 
 		} else {
@@ -475,14 +458,9 @@ THREE.WebGLRenderer = function ( scene ) {
 
 		if ( envMap ) {
 
-			if ( material.env_map ) {
-
-				setCubeTexture( material.env_map, 1 );
-				
-				_gl.uniform1i( program.uniforms.tCube, 1 );
-
-			}
-
+			setCubeTexture( envMap, 1 );
+			
+			_gl.uniform1i( program.uniforms.tCube, 1 );
 			_gl.uniform1i( program.uniforms.enableCubeMap, 1 );
 
 		} else {
@@ -1212,7 +1190,16 @@ THREE.WebGLRenderer = function ( scene ) {
 				_gl.uniform1i( location, value );
 				
 				texture = uniforms[u].texture;
-				setCubeTexture( texture, value );
+				
+				if ( texture instanceof THREE.TextureCube ) {
+					
+					setCubeTexture( texture, value );
+					
+				} else if ( texture instanceof THREE.Texture ) {
+					
+					setTexture( texture, value );
+					
+				}
 			
 			}
 			
@@ -1259,6 +1246,29 @@ THREE.WebGLRenderer = function ( scene ) {
 		
 	};
 	
+	function setTexture( texture, slot ) {
+		
+		if ( !texture.__webGLTexture && texture.image.loaded ) {
+
+			texture.__webGLTexture = _gl.createTexture();
+			_gl.bindTexture( _gl.TEXTURE_2D, texture.__webGLTexture );
+			_gl.texImage2D( _gl.TEXTURE_2D, 0, _gl.RGBA, _gl.RGBA, _gl.UNSIGNED_BYTE, texture.image );
+			
+			_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_S, paramThreeToGL( texture.wrap_s ) );
+			_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_T, paramThreeToGL( texture.wrap_t ) );
+			
+			_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MAG_FILTER, _gl.LINEAR );
+			_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, _gl.LINEAR_MIPMAP_LINEAR );
+			_gl.generateMipmap( _gl.TEXTURE_2D );
+			_gl.bindTexture( _gl.TEXTURE_2D, null );
+
+		}
+
+		_gl.activeTexture( _gl.TEXTURE0 + slot );
+		_gl.bindTexture( _gl.TEXTURE_2D, texture.__webGLTexture );
+		
+	};
+	
 	function cacheUniformLocations( program, identifiers ) {
 		
 		var i, l, id;