Browse Source

First integration step: something appeared on the screen ;)

Otherwise things are very much work in progress, expect everything to be broken.
alteredq 14 years ago
parent
commit
cf37a8cc43

+ 165 - 165
build/Three.js

@@ -1,70 +1,70 @@
 // Three.js r32 - http://github.com/mrdoob/three.js
 // Three.js r32 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
 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()}},setHSV:function(a,c,d){var f,j,k,q,o,l;if(d==0)f=j=k=0;else{q=Math.floor(a*6);o=a*6-q;a=d*(1-c);l=d*(1-c*o);c=d*(1-c*(1-o));switch(q){case 1:f=l;j=d;k=a;break;case 2:f=a;j=d;k=c;break;case 3:f=a;j=l;k=d;break;case 4:f=c;j=a;k=d;break;case 5:f=d;j=a;k=l;break;case 6:case 0:f=d;j=c;k=a}}this.r=f;this.g=j;this.b=k;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
+THREE.Color.prototype={setRGB:function(a,c,e){this.r=a;this.g=c;this.b=e;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,e){var g,i,k,q,p,l;if(e==0)g=i=k=0;else{q=Math.floor(a*6);p=a*6-q;a=e*(1-c);l=e*(1-c*p);c=e*(1-c*(1-p));switch(q){case 1:g=l;i=e;k=a;break;case 2:g=a;i=e;k=c;break;case 3:g=a;i=l;k=e;break;case 4:g=c;i=a;k=e;break;case 5:g=e;i=a;k=l;break;case 6:case 0:g=e;i=c;k=a}}this.r=g;this.g=i;this.b=k;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)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+
 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)+")"},clone:function(){return new THREE.Color(this.hex)},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};
 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*
 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,f=this.z;this.x=d*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.z;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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
-a.z;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)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,e){this.x=a||0;this.y=c||0;this.z=e||0};
+THREE.Vector3.prototype={set:function(a,c,e){this.x=a;this.y=c;this.z=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
+cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,e=this.y,g=this.z;this.x=e*a.z-g*a.y;this.y=g*a.x-c*a.z;this.z=c*a.y-e*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.z;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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
+a.z;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var c=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+e*e+a*a)},distanceToSquared:function(a){var c=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return c*c+e*e+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=
 -this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};
 -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,f){this.x=a||0;this.y=c||0;this.z=d||0;this.w=f||1};
-THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;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,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;
+THREE.Vector4=function(a,c,e,g){this.x=a||0;this.y=c||0;this.z=e||0;this.w=g||1};
+THREE.Vector4.prototype={set:function(a,c,e,g){this.x=a;this.y=c;this.z=e;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+")"}};
 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=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var c,d,f=a.objects,j=[];a=0;for(c=f.length;a<c;a++){d=f[a];if(d instanceof THREE.Mesh)j=j.concat(this.intersectObject(d))}j.sort(function(k,q){return k.distance-q.distance});return j},intersectObject:function(a){function c(I,s,O,C){C=C.clone().subSelf(s);O=O.clone().subSelf(s);var b=I.clone().subSelf(s);I=C.dot(C);s=C.dot(O);C=C.dot(b);var R=O.dot(O);O=O.dot(b);b=1/(I*R-s*s);R=(R*C-s*O)*b;I=(I*O-s*C)*b;return R>0&&I>0&&R+I<1}var d,f,j,k,q,o,l,n,z,y,
-v,x=a.geometry,F=x.vertices,H=[];d=0;for(f=x.faces.length;d<f;d++){j=x.faces[d];y=this.origin.clone();v=this.direction.clone();k=a.matrix.multiplyVector3(F[j.a].position.clone());q=a.matrix.multiplyVector3(F[j.b].position.clone());o=a.matrix.multiplyVector3(F[j.c].position.clone());l=j instanceof THREE.Face4?a.matrix.multiplyVector3(F[j.d].position.clone()):null;n=a.rotationMatrix.multiplyVector3(j.normal.clone());z=v.dot(n);if(z<0){n=n.dot((new THREE.Vector3).sub(k,y))/z;y=y.addSelf(v.multiplyScalar(n));
-if(j instanceof THREE.Face3){if(c(y,k,q,o)){j={distance:this.origin.distanceTo(y),point:y,face:j,object:a};H.push(j)}}else if(j instanceof THREE.Face4)if(c(y,k,q,l)||c(y,q,o,l)){j={distance:this.origin.distanceTo(y),point:y,face:j,object:a};H.push(j)}}}return H}};
-THREE.Rectangle=function(){function a(){k=f-c;q=j-d}var c,d,f,j,k,q,o=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return k};this.getHeight=function(){return q};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return j};this.set=function(l,n,z,y){o=false;c=l;d=n;f=z;j=y;a()};this.addPoint=function(l,n){if(o){o=false;c=l;d=n;f=l;j=n}else{c=c<l?c:l;d=d<n?d:n;f=f>l?f:l;j=j>n?
-j:n}a()};this.add3Points=function(l,n,z,y,v,x){if(o){o=false;c=l<z?l<v?l:v:z<v?z:v;d=n<y?n<x?n:x:y<x?y:x;f=l>z?l>v?l:v:z>v?z:v;j=n>y?n>x?n:x:y>x?y:x}else{c=l<z?l<v?l<c?l:c:v<c?v:c:z<v?z<c?z:c:v<c?v:c;d=n<y?n<x?n<d?n:d:x<d?x:d:y<x?y<d?y:d:x<d?x:d;f=l>z?l>v?l>f?l:f:v>f?v:f:z>v?z>f?z:f:v>f?v:f;j=n>y?n>x?n>j?n:j:x>j?x:j:y>x?y>j?y:j:x>j?x:j}a()};this.addRectangle=function(l){if(o){o=false;c=l.getLeft();d=l.getTop();f=l.getRight();j=l.getBottom()}else{c=c<l.getLeft()?c:l.getLeft();d=d<l.getTop()?d:l.getTop();
-f=f>l.getRight()?f:l.getRight();j=j>l.getBottom()?j:l.getBottom()}a()};this.inflate=function(l){c-=l;d-=l;f+=l;j+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();d=d>l.getTop()?d:l.getTop();f=f<l.getRight()?f:l.getRight();j=j<l.getBottom()?j:l.getBottom();a()};this.instersects=function(l){return Math.min(f,l.getRight())-Math.max(c,l.getLeft())>=0&&Math.min(j,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){o=true;j=f=d=c=0;a()};this.isEmpty=function(){return o};this.toString=
-function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+j+", width: "+k+", height: "+q+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
-THREE.Matrix4=function(a,c,d,f,j,k,q,o,l,n,z,y,v,x,F,H){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=j||0;this.n22=k||1;this.n23=q||0;this.n24=o||0;this.n31=l||0;this.n32=n||0;this.n33=z||1;this.n34=y||0;this.n41=v||0;this.n42=x||0;this.n43=F||0;this.n44=H||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={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;return this},set:function(a,c,d,f,j,k,q,o,l,n,z,y,v,x,F,H){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=j;this.n22=k;this.n23=q;this.n24=o;this.n31=l;this.n32=n;this.n33=z;this.n34=y;this.n41=v;this.n42=x;this.n43=F;this.n44=H;return this},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;return this},lookAt:function(a,c,d){var f=THREE.Matrix4.__tmpVec1,j=THREE.Matrix4.__tmpVec2,k=THREE.Matrix4.__tmpVec3;k.sub(a,c).normalize();f.cross(d,k).normalize();j.cross(k,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);
-this.n31=k.x;this.n32=k.y;this.n33=k.z;this.n34=-k.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,j=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*j;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*j;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*j;return a},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,j=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*j;a.y=this.n21*c+this.n22*d+this.n23*
-f+this.n24*j;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*j;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*j;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,f=a.n12,j=a.n13,k=a.n14,q=a.n21,o=a.n22,l=a.n23,n=a.n24,z=a.n31,
-y=a.n32,v=a.n33,x=a.n34,F=a.n41,H=a.n42,I=a.n43,s=a.n44,O=c.n11,C=c.n12,b=c.n13,R=c.n14,$=c.n21,Q=c.n22,J=c.n23,X=c.n24,G=c.n31,U=c.n32,M=c.n33,D=c.n34,K=c.n41,ca=c.n42,N=c.n43,aa=c.n44;this.n11=d*O+f*$+j*G+k*K;this.n12=d*C+f*Q+j*U+k*ca;this.n13=d*b+f*J+j*M+k*N;this.n14=d*R+f*X+j*D+k*aa;this.n21=q*O+o*$+l*G+n*K;this.n22=q*C+o*Q+l*U+n*ca;this.n23=q*b+o*J+l*M+n*N;this.n24=q*R+o*X+l*D+n*aa;this.n31=z*O+y*$+v*G+x*K;this.n32=z*C+y*Q+v*U+x*ca;this.n33=z*b+y*J+v*M+x*N;this.n34=z*R+y*X+v*D+x*aa;this.n41=
-F*O+H*$+I*G+s*K;this.n42=F*C+H*Q+I*U+s*ca;this.n43=F*b+H*J+I*M+s*N;this.n44=F*R+H*X+I*D+s*aa;return this},multiplyToArray:function(a,c,d){var f=a.n11,j=a.n12,k=a.n13,q=a.n14,o=a.n21,l=a.n22,n=a.n23,z=a.n24,y=a.n31,v=a.n32,x=a.n33,F=a.n34,H=a.n41,I=a.n42,s=a.n43;a=a.n44;var O=c.n11,C=c.n12,b=c.n13,R=c.n14,$=c.n21,Q=c.n22,J=c.n23,X=c.n24,G=c.n31,U=c.n32,M=c.n33,D=c.n34,K=c.n41,ca=c.n42,N=c.n43;c=c.n44;this.n11=f*O+j*$+k*G+q*K;this.n12=f*C+j*Q+k*U+q*ca;this.n13=f*b+j*J+k*M+q*N;this.n14=f*R+j*X+k*D+q*
-c;this.n21=o*O+l*$+n*G+z*K;this.n22=o*C+l*Q+n*U+z*ca;this.n23=o*b+l*J+n*M+z*N;this.n24=o*R+l*X+n*D+z*c;this.n31=y*O+v*$+x*G+F*K;this.n32=y*C+v*Q+x*U+F*ca;this.n33=y*b+v*J+x*M+F*N;this.n34=y*R+v*X+x*D+F*c;this.n41=H*O+I*$+s*G+a*K;this.n42=H*C+I*Q+s*U+a*ca;this.n43=H*b+I*J+s*M+a*N;this.n44=H*R+I*X+s*D+a*c;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;
-d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,j=this.n14,k=this.n21,q=this.n22,o=this.n23,l=this.n24,n=this.n31,z=this.n32,y=this.n33,v=this.n34,x=this.n41,F=this.n42,H=this.n43,I=this.n44,s=a.n11,O=a.n21,C=a.n31,b=a.n41,R=a.n12,$=a.n22,Q=a.n32,J=a.n42,X=a.n13,G=a.n23,U=a.n33,M=a.n43,D=a.n14,K=a.n24,ca=a.n34;a=a.n44;this.n11=c*s+d*O+f*C+j*b;this.n12=c*R+d*$+f*Q+j*J;this.n13=c*X+d*G+f*U+j*M;this.n14=c*D+d*K+f*ca+j*a;this.n21=k*s+q*O+o*C+l*
-b;this.n22=k*R+q*$+o*Q+l*J;this.n23=k*X+q*G+o*U+l*M;this.n24=k*D+q*K+o*ca+l*a;this.n31=n*s+z*O+y*C+v*b;this.n32=n*R+z*$+y*Q+v*J;this.n33=n*X+z*G+y*U+v*M;this.n34=n*D+z*K+y*ca+v*a;this.n41=x*s+F*O+H*C+I*b;this.n42=x*R+F*$+H*Q+I*J;this.n43=x*X+F*G+H*U+I*M;this.n44=x*D+F*K+H*ca+I*a;return this},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;return this},determinant:function(){var a=this.n11,c=this.n12,d=this.n13,f=this.n14,j=this.n21,k=this.n22,q=this.n23,o=this.n24,l=this.n31,n=this.n32,z=this.n33,y=this.n34,v=this.n41,x=this.n42,F=this.n43,H=this.n44;return f*q*n*v-d*o*n*v-f*k*z*v+c*o*z*v+d*k*y*v-c*q*y*v-f*q*l*x+d*o*l*x+f*j*z*x-a*o*z*x-d*j*y*x+a*q*y*x+f*k*l*F-c*o*l*F-f*j*n*F+a*o*n*F+c*j*y*F-a*k*y*F-d*k*l*H+c*q*l*H+d*j*n*H-a*q*n*H-c*j*z*H+a*k*z*H},transpose:function(){function a(c,d,f){var j=c[d];c[d]=c[f];c[f]=j}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(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;
-a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,
-0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),f=Math.sin(c),j=1-d,k=a.x,q=a.y,
-o=a.z,l=j*k,n=j*q;this.set(l*k+d,l*q-f*o,l*o+f*q,0,l*q+f*o,n*q+d,n*o-f*k,0,l*o-f*q,n*o+f*k,j*o*o+d,0,0,0,0,1);return this},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 f=new THREE.Matrix4;f.setTranslation(a,c,d);return f};
-THREE.Matrix4.scaleMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setScale(a,c,d);return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
-THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,f=a.n13,j=a.n14,k=a.n21,q=a.n22,o=a.n23,l=a.n24,n=a.n31,z=a.n32,y=a.n33,v=a.n34,x=a.n41,F=a.n42,H=a.n43,I=a.n44,s=new THREE.Matrix4;s.n11=o*v*F-l*y*F+l*z*H-q*v*H-o*z*I+q*y*I;s.n12=j*y*F-f*v*F-j*z*H+d*v*H+f*z*I-d*y*I;s.n13=f*l*F-j*o*F+j*q*H-d*l*H-f*q*I+d*o*I;s.n14=j*o*z-f*l*z-j*q*y+d*l*y+f*q*v-d*o*v;s.n21=l*y*x-o*v*x-l*n*H+k*v*H+o*n*I-k*y*I;s.n22=f*v*x-j*y*x+j*n*H-c*v*H-f*n*I+c*y*I;s.n23=j*o*x-f*l*x-j*k*H+c*l*H+f*k*I-c*o*I;s.n24=f*l*n-j*o*n+
-j*k*y-c*l*y-f*k*v+c*o*v;s.n31=q*v*x-l*z*x+l*n*F-k*v*F-q*n*I+k*z*I;s.n32=j*z*x-d*v*x-j*n*F+c*v*F+d*n*I-c*z*I;s.n33=f*l*x-j*q*x+j*k*F-c*l*F-d*k*I+c*q*I;s.n34=j*q*n-d*l*n-j*k*z+c*l*z+d*k*v-c*q*v;s.n41=o*z*x-q*y*x-o*n*F+k*y*F+q*n*H-k*z*H;s.n42=d*y*x-f*z*x+f*n*F-c*y*F-d*n*H+c*z*H;s.n43=f*q*x-d*o*x-f*k*F+c*o*F+d*k*H-c*q*H;s.n44=d*o*n-f*q*n+f*k*z-c*o*z-d*k*y+c*q*y;s.multiplyScalar(1/a.determinant());return s};
-THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,d=c.m,f=a.n33*a.n22-a.n32*a.n23,j=-a.n33*a.n21+a.n31*a.n23,k=a.n32*a.n21-a.n31*a.n22,q=-a.n33*a.n12+a.n32*a.n13,o=a.n33*a.n11-a.n31*a.n13,l=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,z=-a.n23*a.n11+a.n21*a.n13,y=a.n22*a.n11-a.n21*a.n12;a=a.n11*f+a.n21*q+a.n31*n;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*f;d[1]=a*j;d[2]=a*k;d[3]=a*q;d[4]=a*o;d[5]=a*l;d[6]=a*n;d[7]=a*z;d[8]=a*y;return c};
-THREE.Matrix4.makeFrustum=function(a,c,d,f,j,k){var q,o,l;q=new THREE.Matrix4;o=2*j/(c-a);l=2*j/(f-d);a=(c+a)/(c-a);d=(f+d)/(f-d);f=-(k+j)/(k-j);j=-2*k*j/(k-j);q.n11=o;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=d;q.n24=0;q.n31=0;q.n32=0;q.n33=f;q.n34=j;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,d,f){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*c,a*c,j,a,d,f)};
-THREE.Matrix4.makeOrtho=function(a,c,d,f,j,k){var q,o,l,n;q=new THREE.Matrix4;o=c-a;l=d-f;n=k-j;a=(c+a)/o;d=(d+f)/l;j=(k+j)/n;q.n11=2/o;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-d;q.n31=0;q.n32=0;q.n33=-2/n;q.n34=-j;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
+THREE.Ray.prototype={intersectScene:function(a){var c,e,g=a.objects,i=[];a=0;for(c=g.length;a<c;a++){e=g[a];if(e instanceof THREE.Mesh)i=i.concat(this.intersectObject(e))}i.sort(function(k,q){return k.distance-q.distance});return i},intersectObject:function(a){function c(G,r,S,B){B=B.clone().subSelf(r);S=S.clone().subSelf(r);var I=G.clone().subSelf(r);G=B.dot(B);r=B.dot(S);B=B.dot(I);var b=S.dot(S);S=S.dot(I);I=1/(G*b-r*r);b=(b*B-r*S)*I;G=(G*S-r*B)*I;return b>0&&G>0&&b+G<1}var e,g,i,k,q,p,l,n,y,z,
+t,x=a.geometry,D=x.vertices,H=[];e=0;for(g=x.faces.length;e<g;e++){i=x.faces[e];z=this.origin.clone();t=this.direction.clone();k=a.matrix.multiplyVector3(D[i.a].position.clone());q=a.matrix.multiplyVector3(D[i.b].position.clone());p=a.matrix.multiplyVector3(D[i.c].position.clone());l=i instanceof THREE.Face4?a.matrix.multiplyVector3(D[i.d].position.clone()):null;n=a.rotationMatrix.multiplyVector3(i.normal.clone());y=t.dot(n);if(y<0){n=n.dot((new THREE.Vector3).sub(k,z))/y;z=z.addSelf(t.multiplyScalar(n));
+if(i instanceof THREE.Face3){if(c(z,k,q,p)){i={distance:this.origin.distanceTo(z),point:z,face:i,object:a};H.push(i)}}else if(i instanceof THREE.Face4)if(c(z,k,q,l)||c(z,q,p,l)){i={distance:this.origin.distanceTo(z),point:z,face:i,object:a};H.push(i)}}}return H}};
+THREE.Rectangle=function(){function a(){k=g-c;q=i-e}var c,e,g,i,k,q,p=true;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return k};this.getHeight=function(){return q};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return g};this.getBottom=function(){return i};this.set=function(l,n,y,z){p=false;c=l;e=n;g=y;i=z;a()};this.addPoint=function(l,n){if(p){p=false;c=l;e=n;g=l;i=n}else{c=c<l?c:l;e=e<n?e:n;g=g>l?g:l;i=i>n?
+i:n}a()};this.add3Points=function(l,n,y,z,t,x){if(p){p=false;c=l<y?l<t?l:t:y<t?y:t;e=n<z?n<x?n:x:z<x?z:x;g=l>y?l>t?l:t:y>t?y:t;i=n>z?n>x?n:x:z>x?z:x}else{c=l<y?l<t?l<c?l:c:t<c?t:c:y<t?y<c?y:c:t<c?t:c;e=n<z?n<x?n<e?n:e:x<e?x:e:z<x?z<e?z:e:x<e?x:e;g=l>y?l>t?l>g?l:g:t>g?t:g:y>t?y>g?y:g:t>g?t:g;i=n>z?n>x?n>i?n:i:x>i?x:i:z>x?z>i?z:i:x>i?x:i}a()};this.addRectangle=function(l){if(p){p=false;c=l.getLeft();e=l.getTop();g=l.getRight();i=l.getBottom()}else{c=c<l.getLeft()?c:l.getLeft();e=e<l.getTop()?e:l.getTop();
+g=g>l.getRight()?g:l.getRight();i=i>l.getBottom()?i:l.getBottom()}a()};this.inflate=function(l){c-=l;e-=l;g+=l;i+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();e=e>l.getTop()?e:l.getTop();g=g<l.getRight()?g:l.getRight();i=i<l.getBottom()?i:l.getBottom();a()};this.instersects=function(l){return Math.min(g,l.getRight())-Math.max(c,l.getLeft())>=0&&Math.min(i,l.getBottom())-Math.max(e,l.getTop())>=0};this.empty=function(){p=true;i=g=e=c=0;a()};this.isEmpty=function(){return p};this.toString=
+function(){return"THREE.Rectangle ( left: "+c+", right: "+g+", top: "+e+", bottom: "+i+", width: "+k+", height: "+q+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
+THREE.Matrix4=function(a,c,e,g,i,k,q,p,l,n,y,z,t,x,D,H){this.n11=a||1;this.n12=c||0;this.n13=e||0;this.n14=g||0;this.n21=i||0;this.n22=k||1;this.n23=q||0;this.n24=p||0;this.n31=l||0;this.n32=n||0;this.n33=y||1;this.n34=z||0;this.n41=t||0;this.n42=x||0;this.n43=D||0;this.n44=H||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={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;return this},set:function(a,c,e,g,i,k,q,p,l,n,y,z,t,x,D,H){this.n11=a;this.n12=c;this.n13=e;this.n14=g;this.n21=i;this.n22=k;this.n23=q;this.n24=p;this.n31=l;this.n32=n;this.n33=y;this.n34=z;this.n41=t;this.n42=x;this.n43=D;this.n44=H;return this},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;return this},lookAt:function(a,c,e){var g=THREE.Matrix4.__tmpVec1,i=THREE.Matrix4.__tmpVec2,k=THREE.Matrix4.__tmpVec3;k.sub(a,c).normalize();g.cross(e,k).normalize();i.cross(k,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=k.x;this.n32=k.y;this.n33=k.z;this.n34=-k.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,e=a.y,g=a.z,i=1/(this.n41*c+this.n42*e+this.n43*g+this.n44);a.x=(this.n11*c+this.n12*e+this.n13*g+this.n14)*i;a.y=(this.n21*c+this.n22*e+this.n23*g+this.n24)*i;a.z=(this.n31*c+this.n32*e+this.n33*g+this.n34)*i;return a},multiplyVector4:function(a){var c=a.x,e=a.y,g=a.z,i=a.w;a.x=this.n11*c+this.n12*e+this.n13*g+this.n14*i;a.y=this.n21*c+this.n22*e+this.n23*
+g+this.n24*i;a.z=this.n31*c+this.n32*e+this.n33*g+this.n34*i;a.w=this.n41*c+this.n42*e+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 e=a.n11,g=a.n12,i=a.n13,k=a.n14,q=a.n21,p=a.n22,l=a.n23,n=a.n24,y=a.n31,
+z=a.n32,t=a.n33,x=a.n34,D=a.n41,H=a.n42,G=a.n43,r=a.n44,S=c.n11,B=c.n12,I=c.n13,b=c.n14,aa=c.n21,P=c.n22,J=c.n23,W=c.n24,M=c.n31,R=c.n32,K=c.n33,C=c.n34,L=c.n41,ba=c.n42,N=c.n43,da=c.n44;this.n11=e*S+g*aa+i*M+k*L;this.n12=e*B+g*P+i*R+k*ba;this.n13=e*I+g*J+i*K+k*N;this.n14=e*b+g*W+i*C+k*da;this.n21=q*S+p*aa+l*M+n*L;this.n22=q*B+p*P+l*R+n*ba;this.n23=q*I+p*J+l*K+n*N;this.n24=q*b+p*W+l*C+n*da;this.n31=y*S+z*aa+t*M+x*L;this.n32=y*B+z*P+t*R+x*ba;this.n33=y*I+z*J+t*K+x*N;this.n34=y*b+z*W+t*C+x*da;this.n41=
+D*S+H*aa+G*M+r*L;this.n42=D*B+H*P+G*R+r*ba;this.n43=D*I+H*J+G*K+r*N;this.n44=D*b+H*W+G*C+r*da;return this},multiplyToArray:function(a,c,e){var g=a.n11,i=a.n12,k=a.n13,q=a.n14,p=a.n21,l=a.n22,n=a.n23,y=a.n24,z=a.n31,t=a.n32,x=a.n33,D=a.n34,H=a.n41,G=a.n42,r=a.n43;a=a.n44;var S=c.n11,B=c.n12,I=c.n13,b=c.n14,aa=c.n21,P=c.n22,J=c.n23,W=c.n24,M=c.n31,R=c.n32,K=c.n33,C=c.n34,L=c.n41,ba=c.n42,N=c.n43;c=c.n44;this.n11=g*S+i*aa+k*M+q*L;this.n12=g*B+i*P+k*R+q*ba;this.n13=g*I+i*J+k*K+q*N;this.n14=g*b+i*W+k*
+C+q*c;this.n21=p*S+l*aa+n*M+y*L;this.n22=p*B+l*P+n*R+y*ba;this.n23=p*I+l*J+n*K+y*N;this.n24=p*b+l*W+n*C+y*c;this.n31=z*S+t*aa+x*M+D*L;this.n32=z*B+t*P+x*R+D*ba;this.n33=z*I+t*J+x*K+D*N;this.n34=z*b+t*W+x*C+D*c;this.n41=H*S+G*aa+r*M+a*L;this.n42=H*B+G*P+r*R+a*ba;this.n43=H*I+G*J+r*K+a*N;this.n44=H*b+G*W+r*C+a*c;e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=
+this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,e=this.n12,g=this.n13,i=this.n14,k=this.n21,q=this.n22,p=this.n23,l=this.n24,n=this.n31,y=this.n32,z=this.n33,t=this.n34,x=this.n41,D=this.n42,H=this.n43,G=this.n44,r=a.n11,S=a.n21,B=a.n31,I=a.n41,b=a.n12,aa=a.n22,P=a.n32,J=a.n42,W=a.n13,M=a.n23,R=a.n33,K=a.n43,C=a.n14,L=a.n24,ba=a.n34;a=a.n44;this.n11=c*r+e*S+g*B+i*I;this.n12=c*b+e*aa+g*P+i*J;this.n13=c*W+e*M+g*R+i*K;this.n14=c*C+e*L+g*ba+i*a;this.n21=k*r+
+q*S+p*B+l*I;this.n22=k*b+q*aa+p*P+l*J;this.n23=k*W+q*M+p*R+l*K;this.n24=k*C+q*L+p*ba+l*a;this.n31=n*r+y*S+z*B+t*I;this.n32=n*b+y*aa+z*P+t*J;this.n33=n*W+y*M+z*R+t*K;this.n34=n*C+y*L+z*ba+t*a;this.n41=x*r+D*S+H*B+G*I;this.n42=x*b+D*aa+H*P+G*J;this.n43=x*W+D*M+H*R+G*K;this.n44=x*C+D*L+H*ba+G*a;return this},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;return this},determinant:function(){var a=this.n11,c=this.n12,e=this.n13,g=this.n14,i=this.n21,k=this.n22,q=this.n23,p=this.n24,l=this.n31,n=this.n32,y=this.n33,z=this.n34,t=this.n41,x=this.n42,D=this.n43,H=this.n44;return g*q*n*t-e*p*n*t-g*k*y*t+c*p*y*t+e*k*z*t-c*q*z*t-g*q*l*x+e*p*l*x+g*i*y*x-a*p*y*x-e*i*z*x+a*q*z*x+g*k*l*D-c*p*l*D-g*i*n*D+a*p*n*D+c*i*z*D-a*k*z*D-e*k*l*H+c*q*l*H+e*i*n*H-a*q*n*H-c*i*y*H+a*k*y*H},transpose:function(){function a(c,e,g){var i=c[e];c[e]=c[g];c[g]=
+i}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;
+a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,e){this.set(1,
+0,0,a,0,1,0,c,0,0,1,e,0,0,0,1);return this},setScale:function(a,c,e){this.set(a,0,0,0,0,c,0,0,0,0,e,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var e=Math.cos(c),g=Math.sin(c),
+i=1-e,k=a.x,q=a.y,p=a.z,l=i*k,n=i*q;this.set(l*k+e,l*q-g*p,l*p+g*q,0,l*q+g*p,n*q+e,n*p-g*k,0,l*p-g*q,n*p+g*k,i*p*p+e,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,e){var g=new THREE.Matrix4;g.setTranslation(a,c,e);return g};
+THREE.Matrix4.scaleMatrix=function(a,c,e){var g=new THREE.Matrix4;g.setScale(a,c,e);return g};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var e=new THREE.Matrix4;e.setRotAxis(a,c);return e};
+THREE.Matrix4.makeInvert=function(a){var c=a.n11,e=a.n12,g=a.n13,i=a.n14,k=a.n21,q=a.n22,p=a.n23,l=a.n24,n=a.n31,y=a.n32,z=a.n33,t=a.n34,x=a.n41,D=a.n42,H=a.n43,G=a.n44,r=new THREE.Matrix4;r.n11=p*t*D-l*z*D+l*y*H-q*t*H-p*y*G+q*z*G;r.n12=i*z*D-g*t*D-i*y*H+e*t*H+g*y*G-e*z*G;r.n13=g*l*D-i*p*D+i*q*H-e*l*H-g*q*G+e*p*G;r.n14=i*p*y-g*l*y-i*q*z+e*l*z+g*q*t-e*p*t;r.n21=l*z*x-p*t*x-l*n*H+k*t*H+p*n*G-k*z*G;r.n22=g*t*x-i*z*x+i*n*H-c*t*H-g*n*G+c*z*G;r.n23=i*p*x-g*l*x-i*k*H+c*l*H+g*k*G-c*p*G;r.n24=g*l*n-i*p*n+
+i*k*z-c*l*z-g*k*t+c*p*t;r.n31=q*t*x-l*y*x+l*n*D-k*t*D-q*n*G+k*y*G;r.n32=i*y*x-e*t*x-i*n*D+c*t*D+e*n*G-c*y*G;r.n33=g*l*x-i*q*x+i*k*D-c*l*D-e*k*G+c*q*G;r.n34=i*q*n-e*l*n-i*k*y+c*l*y+e*k*t-c*q*t;r.n41=p*y*x-q*z*x-p*n*D+k*z*D+q*n*H-k*y*H;r.n42=e*z*x-g*y*x+g*n*D-c*z*D-e*n*H+c*y*H;r.n43=g*q*x-e*p*x-g*k*D+c*p*D+e*k*H-c*q*H;r.n44=e*p*n-g*q*n+g*k*y-c*p*y-e*k*z+c*q*z;r.multiplyScalar(1/a.determinant());return r};
+THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,e=c.m,g=a.n33*a.n22-a.n32*a.n23,i=-a.n33*a.n21+a.n31*a.n23,k=a.n32*a.n21-a.n31*a.n22,q=-a.n33*a.n12+a.n32*a.n13,p=a.n33*a.n11-a.n31*a.n13,l=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,y=-a.n23*a.n11+a.n21*a.n13,z=a.n22*a.n11-a.n21*a.n12;a=a.n11*g+a.n21*q+a.n31*n;if(a==0)throw"matrix not invertible";a=1/a;e[0]=a*g;e[1]=a*i;e[2]=a*k;e[3]=a*q;e[4]=a*p;e[5]=a*l;e[6]=a*n;e[7]=a*y;e[8]=a*z;return c};
+THREE.Matrix4.makeFrustum=function(a,c,e,g,i,k){var q,p,l;q=new THREE.Matrix4;p=2*i/(c-a);l=2*i/(g-e);a=(c+a)/(c-a);e=(g+e)/(g-e);g=-(k+i)/(k-i);i=-2*k*i/(k-i);q.n11=p;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=e;q.n24=0;q.n31=0;q.n32=0;q.n33=g;q.n34=i;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,e,g){var i;a=e*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*c,a*c,i,a,e,g)};
+THREE.Matrix4.makeOrtho=function(a,c,e,g,i,k){var q,p,l,n;q=new THREE.Matrix4;p=c-a;l=e-g;n=k-i;a=(c+a)/p;e=(e+g)/l;i=(k+i)/n;q.n11=2/p;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-e;q.n31=0;q.n32=0;q.n33=-2/n;q.n34=-i;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 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.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
 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.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
-THREE.Face3=function(a,c,d,f,j){this.a=a;this.b=c;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.materials=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
-THREE.Face4=function(a,c,d,f,j,k){this.a=a;this.b=c;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.materials=k instanceof Array?k:[k]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
-THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
-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);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
-d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,f,j,k,q,o=new THREE.Vector3,l=new THREE.Vector3;f=0;for(j=this.vertices.length;f<j;f++){k=this.vertices[f];k.normal.set(0,0,0)}f=0;for(j=this.faces.length;f<j;f++){k=this.faces[f];if(a&&k.vertexNormals.length){o.set(0,0,0);c=0;for(d=k.normal.length;c<d;c++)o.addSelf(k.vertexNormals[c]);o.divideScalar(3)}else{c=this.vertices[k.a];d=this.vertices[k.b];q=this.vertices[k.c];o.sub(q.position,
-d.position);l.sub(c.position,d.position);o.crossSelf(l)}o.isZero()||o.normalize();k.normal.copy(o)}},computeVertexNormals:function(){var a,c,d,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
-new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal);f[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
-c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c]);d.vertexNormals[3].copy(f[d.d])}}},computeTangents:function(){function a(D,K,ca,N,aa,e,i){k=D.vertices[K].position;q=D.vertices[ca].position;o=D.vertices[N].position;l=j[aa];n=j[e];z=j[i];y=q.x-k.x;v=o.x-k.x;x=q.y-k.y;F=o.y-
-k.y;H=q.z-k.z;I=o.z-k.z;s=n.u-l.u;O=z.u-l.u;C=n.v-l.v;b=z.v-l.v;R=1/(s*b-O*C);J.set((b*y-C*v)*R,(b*x-C*F)*R,(b*H-C*I)*R);X.set((s*v-O*y)*R,(s*F-O*x)*R,(s*I-O*H)*R);$[K].addSelf(J);$[ca].addSelf(J);$[N].addSelf(J);Q[K].addSelf(X);Q[ca].addSelf(X);Q[N].addSelf(X)}var c,d,f,j,k,q,o,l,n,z,y,v,x,F,H,I,s,O,C,b,R,$=[],Q=[],J=new THREE.Vector3,X=new THREE.Vector3,G=new THREE.Vector3,U=new THREE.Vector3,M=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){$[c]=new THREE.Vector3;Q[c]=new THREE.Vector3}c=
-0;for(d=this.faces.length;c<d;c++){f=this.faces[c];j=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
-this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){M.copy(this.vertices[c].normal);f=$[c];G.copy(f);G.subSelf(M.multiplyScalar(M.dot(f))).normalize();U.cross(this.vertices[c].normal,f);f=U.dot(Q[c]);f=f<0?-1:1;this.vertices[c].tangent.set(G.x,G.y,G.z,f)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={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 c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
-this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(z){var y=[];c=0;for(d=z.length;c<d;c++)z[c]==undefined?y.push("undefined"):y.push(z[c].toString());return y.join("_")}var c,d,f,j,k,q,o,l,n={};f=0;for(j=this.faces.length;f<j;f++){k=this.faces[f];
-q=k.materials;o=a(q);if(n[o]==undefined)n[o]={hash:o,counter:0};l=n[o].hash+"_"+n[o].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0};k=k instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+k>65535){n[o].counter+=1;l=n[o].hash+"_"+n[o].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(f);this.geometryChunks[l].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+
-this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
-THREE.Camera=function(a,c,d,f){this.fov=a;this.aspect=c;this.near=d;this.far=f;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(j){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
-this.translateZ=function(j){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
+THREE.Face3=function(a,c,e,g,i){this.a=a;this.b=c;this.c=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=i instanceof Array?i:[i]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
+THREE.Face4=function(a,c,e,g,i,k){this.a=a;this.b=c;this.c=e;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.materials=k instanceof Array?k:[k]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
+THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
+THREE.Geometry.prototype={computeCentroids:function(){var a,c,e;a=0;for(c=this.faces.length;a<c;a++){e=this.faces[a];e.centroid.set(0,0,0);if(e instanceof THREE.Face3){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);e.centroid.divideScalar(3)}else if(e instanceof THREE.Face4){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);
+e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,e,g,i,k,q,p=new THREE.Vector3,l=new THREE.Vector3;g=0;for(i=this.vertices.length;g<i;g++){k=this.vertices[g];k.normal.set(0,0,0)}g=0;for(i=this.faces.length;g<i;g++){k=this.faces[g];if(a&&k.vertexNormals.length){p.set(0,0,0);c=0;for(e=k.normal.length;c<e;c++)p.addSelf(k.vertexNormals[c]);p.divideScalar(3)}else{c=this.vertices[k.a];e=this.vertices[k.b];q=this.vertices[k.c];p.sub(q.position,
+e.position);l.sub(c.position,e.position);p.crossSelf(l)}p.isZero()||p.normalize();k.normal.copy(p)}},computeVertexNormals:function(){var a,c,e,g;if(this.__tmpVertices==undefined){g=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)g[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){e=this.faces[a];if(e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,
+new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{g=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)g[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){e=this.faces[a];if(e instanceof THREE.Face3){g[e.a].addSelf(e.normal);g[e.b].addSelf(e.normal);g[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){g[e.a].addSelf(e.normal);g[e.b].addSelf(e.normal);g[e.c].addSelf(e.normal);g[e.d].addSelf(e.normal)}}a=0;for(c=this.vertices.length;a<c;a++)g[a].normalize();a=0;for(c=this.faces.length;a<
+c;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0].copy(g[e.a]);e.vertexNormals[1].copy(g[e.b]);e.vertexNormals[2].copy(g[e.c])}else if(e instanceof THREE.Face4){e.vertexNormals[0].copy(g[e.a]);e.vertexNormals[1].copy(g[e.b]);e.vertexNormals[2].copy(g[e.c]);e.vertexNormals[3].copy(g[e.d])}}},computeTangents:function(){function a(C,L,ba,N,da,ca,d){k=C.vertices[L].position;q=C.vertices[ba].position;p=C.vertices[N].position;l=i[da];n=i[ca];y=i[d];z=q.x-k.x;t=p.x-k.x;x=q.y-k.y;D=p.y-
+k.y;H=q.z-k.z;G=p.z-k.z;r=n.u-l.u;S=y.u-l.u;B=n.v-l.v;I=y.v-l.v;b=1/(r*I-S*B);J.set((I*z-B*t)*b,(I*x-B*D)*b,(I*H-B*G)*b);W.set((r*t-S*z)*b,(r*D-S*x)*b,(r*G-S*H)*b);aa[L].addSelf(J);aa[ba].addSelf(J);aa[N].addSelf(J);P[L].addSelf(W);P[ba].addSelf(W);P[N].addSelf(W)}var c,e,g,i,k,q,p,l,n,y,z,t,x,D,H,G,r,S,B,I,b,aa=[],P=[],J=new THREE.Vector3,W=new THREE.Vector3,M=new THREE.Vector3,R=new THREE.Vector3,K=new THREE.Vector3;c=0;for(e=this.vertices.length;c<e;c++){aa[c]=new THREE.Vector3;P[c]=new THREE.Vector3}c=
+0;for(e=this.faces.length;c<e;c++){g=this.faces[c];i=this.uvs[c];if(g instanceof THREE.Face3){a(this,g.a,g.b,g.c,0,1,2);this.vertices[g.a].normal.copy(g.vertexNormals[0]);this.vertices[g.b].normal.copy(g.vertexNormals[1]);this.vertices[g.c].normal.copy(g.vertexNormals[2])}else if(g instanceof THREE.Face4){a(this,g.a,g.b,g.c,0,1,2);a(this,g.a,g.b,g.d,0,1,3);this.vertices[g.a].normal.copy(g.vertexNormals[0]);this.vertices[g.b].normal.copy(g.vertexNormals[1]);this.vertices[g.c].normal.copy(g.vertexNormals[2]);
+this.vertices[g.d].normal.copy(g.vertexNormals[3])}}c=0;for(e=this.vertices.length;c<e;c++){K.copy(this.vertices[c].normal);g=aa[c];M.copy(g);M.subSelf(K.multiplyScalar(K.dot(g))).normalize();R.cross(this.vertices[c].normal,g);g=R.dot(P[c]);g=g<0?-1:1;this.vertices[c].tangent.set(M.x,M.y,M.z,g)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={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 c=1,e=this.vertices.length;c<e;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
+this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,e=this.vertices.length;c<e;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(y){var z=[];c=0;for(e=y.length;c<e;c++)y[c]==undefined?z.push("undefined"):z.push(y[c].toString());return z.join("_")}var c,e,g,i,k,q,p,l,n={};g=0;for(i=this.faces.length;g<i;g++){k=this.faces[g];
+q=k.materials;p=a(q);if(n[p]==undefined)n[p]={hash:p,counter:0};l=n[p].hash+"_"+n[p].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0};k=k instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+k>65535){n[p].counter+=1;l=n[p].hash+"_"+n[p].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(g);this.geometryChunks[l].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+
+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0;
+THREE.Camera=function(a,c,e,g){this.fov=a;this.aspect=c;this.near=e;this.far=g;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(i){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(i);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
+this.translateZ=function(i){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(i);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
 THREE.Camera.prototype={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.Camera.prototype={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.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
 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.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
 THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true;this.children=[]};
 THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true;this.children=[]};
-THREE.Object3D.prototype={addChild:function(a){this.children.indexOf(a)===-1&&this.children.push(a)},removeChild:function(a){a=this.children.indexOf(a);a!==-1&&this.children.splice(a,1)},updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,f=this.matrix,j=this.rotationMatrix,k=this.tmpMatrix;f.setTranslation(a.x,a.y,a.z);j.setRotX(c.x);c.y!=0&&j.multiplySelf(k.setRotY(c.y));c.z!=0&&j.multiplySelf(k.setRotZ(c.z));f.multiplySelf(j);if(d.x!=0||d.y!=0||d.z!=0)f.multiplySelf(k.setScale(d.x,
-d.y,d.z))}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
-THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
+THREE.Object3D.prototype={addChild:function(a){this.children.indexOf(a)===-1&&this.children.push(a)},removeChild:function(a){a=this.children.indexOf(a);a!==-1&&this.children.splice(a,1)},updateMatrix:function(){var a=this.position,c=this.rotation,e=this.scale,g=this.matrix,i=this.rotationMatrix,k=this.tmpMatrix;g.setTranslation(a.x,a.y,a.z);i.setRotX(c.x);c.y!=0&&i.multiplySelf(k.setRotY(c.y));c.z!=0&&i.multiplySelf(k.setRotZ(c.z));g.multiplySelf(i);if(e.x!=0||e.y!=0||e.z!=0)g.multiplySelf(k.setScale(e.x,
+e.y,e.z))}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
+THREE.Line=function(a,c,e){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=e!=undefined?e:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
 THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;
 THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;
 THREE.LineBasicMaterial=function(a){this.id=THREE.LineBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=false;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.depth_test!==undefined)this.depth_test=a.depth_test;if(a.linewidth!==undefined)this.linewidth=
 THREE.LineBasicMaterial=function(a){this.id=THREE.LineBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=false;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.depth_test!==undefined)this.depth_test=a.depth_test;if(a.linewidth!==undefined)this.linewidth=
 a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
 a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
@@ -96,121 +96,121 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM
 THREE.ParticleBasicMaterial=function(a){this.id=THREE.ParticleBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.offset=new THREE.Vector2;this.vertex_colors=false;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;
 THREE.ParticleBasicMaterial=function(a){this.id=THREE.ParticleBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.offset=new THREE.Vector2;this.vertex_colors=false;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;
 if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>size: "+this.size+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.ParticleBasicMaterialCounter={value:0};
 if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>size: "+this.size+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.ParticleBasicMaterialCounter={value:0};
 THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);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}};THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
 THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);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}};THREE.ParticleCircleMaterial.prototype={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};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,f,j,k){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=j!==undefined?j:THREE.LinearFilter;this.min_filter=k!==undefined?k:THREE.LinearMipMapLinearFilter};
+THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,e,g,i,k){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=g!==undefined?g:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=k!==undefined?k:THREE.LinearMipMapLinearFilter};
 THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},toString:function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;
 THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},toString:function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;
 THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
 THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
-THREE.RenderTarget=function(a,c,d){this.width=a;this.height=c;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType};
-var Uniforms={clone:function(a){var c,d,f,j={};for(c in a){j[c]={};for(d in a[c]){f=a[c][d];j[c][d]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return j},merge:function(a){var c,d,f,j={};for(c=0;c<a.length;c++){f=this.clone(a[c]);for(d in f)j[d]=f[d]}return j}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
+THREE.RenderTarget=function(a,c,e){this.width=a;this.height=c;e=e||{};this.wrap_s=e.wrap_s!==undefined?e.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=e.wrap_t!==undefined?e.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=e.mag_filter!==undefined?e.mag_filter:THREE.LinearFilter;this.min_filter=e.min_filter!==undefined?e.min_filter:THREE.LinearMipMapLinearFilter;this.format=e.format!==undefined?e.format:THREE.RGBFormat;this.type=e.type!==undefined?e.type:THREE.UnsignedByteType};
+var Uniforms={clone:function(a){var c,e,g,i={};for(c in a){i[c]={};for(e in a[c]){g=a[c][e];i[c][e]=g instanceof THREE.Color||g instanceof THREE.Vector3||g instanceof THREE.Texture?g.clone():g}}return i},merge:function(a){var c,e,g,i={};for(c=0;c<a.length;c++){g=this.clone(a[c]);for(e in g)i[e]=g[e]}return i}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&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.indexOf(a)===-1&&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.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&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.indexOf(a)===-1&&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.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
-THREE.Projector=function(){function a(Q,J){return J.z-Q.z}function c(Q,J){var X=0,G=1,U=Q.z+Q.w,M=J.z+J.w,D=-Q.z+Q.w,K=-J.z+J.w;if(U>=0&&M>=0&&D>=0&&K>=0)return true;else if(U<0&&M<0||D<0&&K<0)return false;else{if(U<0)X=Math.max(X,U/(U-M));else if(M<0)G=Math.min(G,U/(U-M));if(D<0)X=Math.max(X,D/(D-K));else if(K<0)G=Math.min(G,D/(D-K));if(G<X)return false;else{Q.lerpSelf(J,X);J.lerpSelf(Q,1-G);return true}}}var d,f,j=[],k,q,o,l=[],n,z,y=[],v,x,F=[],H=new THREE.Vector4,I=new THREE.Vector4,s=new THREE.Matrix4,
-O=new THREE.Matrix4,C=[],b=new THREE.Vector4,R=new THREE.Vector4,$;this.projectObjects=function(Q,J,X){var G=[],U,M;f=0;s.multiply(J.projectionMatrix,J.matrix);C[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);C[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);C[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);C[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);C[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
-s.n33,s.n44-s.n34);C[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);J=0;for(U=C.length;J<U;J++){M=C[J];M.divideScalar(Math.sqrt(M.x*M.x+M.y*M.y+M.z*M.z))}U=Q.objects;Q=0;for(J=U.length;Q<J;Q++){M=U[Q];var D;if(!(D=!M.visible)){if(D=M instanceof THREE.Mesh){a:{D=void 0;for(var K=M.position,ca=-M.geometry.boundingSphere.radius*Math.max(M.scale.x,Math.max(M.scale.y,M.scale.z)),N=0;N<6;N++){D=C[N].x*K.x+C[N].y*K.y+C[N].z*K.z+C[N].w;if(D<=ca){D=false;break a}}D=true}D=!D}D=D}if(!D){d=
-j[f]=j[f]||new THREE.RenderableObject;H.copy(M.position);s.multiplyVector3(H);d.object=M;d.z=H.z;G.push(d);f++}}X&&G.sort(a);return G};this.projectScene=function(Q,J,X){var G=[],U=J.near,M=J.far,D,K,ca,N,aa,e,i,m,h,g,t,w,u,r,p,B;o=z=x=0;J.autoUpdateMatrix&&J.updateMatrix();s.multiply(J.projectionMatrix,J.matrix);e=this.projectObjects(Q,J,true);Q=0;for(D=e.length;Q<D;Q++){i=e[Q].object;if(i.visible){i.autoUpdateMatrix&&i.updateMatrix();m=i.matrix;h=i.rotationMatrix;g=i.materials;t=i.overdraw;if(i instanceof
-THREE.Mesh){w=i.geometry;u=w.vertices;K=0;for(ca=u.length;K<ca;K++){r=u[K];r.positionWorld.copy(r.position);m.multiplyVector3(r.positionWorld);N=r.positionScreen;N.copy(r.positionWorld);s.multiplyVector4(N);N.x/=N.w;N.y/=N.w;r.__visible=N.z>U&&N.z<M}w=w.faces;K=0;for(ca=w.length;K<ca;K++){r=w[K];if(r instanceof THREE.Face3){N=u[r.a];aa=u[r.b];p=u[r.c];if(N.__visible&&aa.__visible&&p.__visible)if(i.doubleSided||i.flipSided!=(p.positionScreen.x-N.positionScreen.x)*(aa.positionScreen.y-N.positionScreen.y)-
-(p.positionScreen.y-N.positionScreen.y)*(aa.positionScreen.x-N.positionScreen.x)<0){k=l[o]=l[o]||new THREE.RenderableFace3;k.v1.positionWorld.copy(N.positionWorld);k.v2.positionWorld.copy(aa.positionWorld);k.v3.positionWorld.copy(p.positionWorld);k.v1.positionScreen.copy(N.positionScreen);k.v2.positionScreen.copy(aa.positionScreen);k.v3.positionScreen.copy(p.positionScreen);k.normalWorld.copy(r.normal);h.multiplyVector3(k.normalWorld);k.centroidWorld.copy(r.centroid);m.multiplyVector3(k.centroidWorld);
-k.centroidScreen.copy(k.centroidWorld);s.multiplyVector3(k.centroidScreen);p=r.vertexNormals;$=k.vertexNormalsWorld;N=0;for(aa=p.length;N<aa;N++){B=$[N]=$[N]||new THREE.Vector3;B.copy(p[N]);h.multiplyVector3(B)}k.z=k.centroidScreen.z;k.meshMaterials=g;k.faceMaterials=r.materials;k.overdraw=t;if(i.geometry.uvs[K]){k.uvs[0]=i.geometry.uvs[K][0];k.uvs[1]=i.geometry.uvs[K][1];k.uvs[2]=i.geometry.uvs[K][2]}G.push(k);o++}}else if(r instanceof THREE.Face4){N=u[r.a];aa=u[r.b];p=u[r.c];B=u[r.d];if(N.__visible&&
-aa.__visible&&p.__visible&&B.__visible)if(i.doubleSided||i.flipSided!=((B.positionScreen.x-N.positionScreen.x)*(aa.positionScreen.y-N.positionScreen.y)-(B.positionScreen.y-N.positionScreen.y)*(aa.positionScreen.x-N.positionScreen.x)<0||(aa.positionScreen.x-p.positionScreen.x)*(B.positionScreen.y-p.positionScreen.y)-(aa.positionScreen.y-p.positionScreen.y)*(B.positionScreen.x-p.positionScreen.x)<0)){k=l[o]=l[o]||new THREE.RenderableFace3;k.v1.positionWorld.copy(N.positionWorld);k.v2.positionWorld.copy(aa.positionWorld);
-k.v3.positionWorld.copy(B.positionWorld);k.v1.positionScreen.copy(N.positionScreen);k.v2.positionScreen.copy(aa.positionScreen);k.v3.positionScreen.copy(B.positionScreen);k.normalWorld.copy(r.normal);h.multiplyVector3(k.normalWorld);k.centroidWorld.copy(r.centroid);m.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);s.multiplyVector3(k.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterials=g;k.faceMaterials=r.materials;k.overdraw=t;if(i.geometry.uvs[K]){k.uvs[0]=i.geometry.uvs[K][0];
-k.uvs[1]=i.geometry.uvs[K][1];k.uvs[2]=i.geometry.uvs[K][3]}G.push(k);o++;q=l[o]=l[o]||new THREE.RenderableFace3;q.v1.positionWorld.copy(aa.positionWorld);q.v2.positionWorld.copy(p.positionWorld);q.v3.positionWorld.copy(B.positionWorld);q.v1.positionScreen.copy(aa.positionScreen);q.v2.positionScreen.copy(p.positionScreen);q.v3.positionScreen.copy(B.positionScreen);q.normalWorld.copy(k.normalWorld);q.centroidWorld.copy(k.centroidWorld);q.centroidScreen.copy(k.centroidScreen);q.z=q.centroidScreen.z;
-q.meshMaterials=g;q.faceMaterials=r.materials;q.overdraw=t;if(i.geometry.uvs[K]){q.uvs[0]=i.geometry.uvs[K][1];q.uvs[1]=i.geometry.uvs[K][2];q.uvs[2]=i.geometry.uvs[K][3]}G.push(q);o++}}}}else if(i instanceof THREE.Line){O.multiply(s,m);u=i.geometry.vertices;r=u[0];r.positionScreen.copy(r.position);O.multiplyVector4(r.positionScreen);K=1;for(ca=u.length;K<ca;K++){N=u[K];N.positionScreen.copy(N.position);O.multiplyVector4(N.positionScreen);aa=u[K-1];b.copy(N.positionScreen);R.copy(aa.positionScreen);
-if(c(b,R)){b.multiplyScalar(1/b.w);R.multiplyScalar(1/R.w);n=y[z]=y[z]||new THREE.RenderableLine;n.v1.positionScreen.copy(b);n.v2.positionScreen.copy(R);n.z=Math.max(b.z,R.z);n.materials=i.materials;G.push(n);z++}}}else if(i instanceof THREE.Particle){I.set(i.position.x,i.position.y,i.position.z,1);s.multiplyVector4(I);I.z/=I.w;if(I.z>0&&I.z<1){v=F[x]=F[x]||new THREE.RenderableParticle;v.x=I.x/I.w;v.y=I.y/I.w;v.z=I.z;v.rotation=i.rotation.z;v.scale.x=i.scale.x*Math.abs(v.x-(I.x+J.projectionMatrix.n11)/
-(I.w+J.projectionMatrix.n14));v.scale.y=i.scale.y*Math.abs(v.y-(I.y+J.projectionMatrix.n22)/(I.w+J.projectionMatrix.n24));v.materials=i.materials;G.push(v);x++}}}}X&&G.sort(a);return G};this.unprojectVector=function(Q,J){var X=THREE.Matrix4.makeInvert(J.matrix);X.multiplySelf(THREE.Matrix4.makeInvert(J.projectionMatrix));X.multiplyVector3(Q);return Q}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,j,k;this.domElement=document.createElement("div");this.setSize=function(q,o){d=q;f=o;j=d/2;k=f/2};this.render=function(q,o){var l,n,z,y,v,x,F,H;a=c.projectScene(q,o);l=0;for(n=a.length;l<n;l++){v=a[l];if(v instanceof THREE.RenderableParticle){F=v.x*j+j;H=v.y*k+k;z=0;for(y=v.material.length;z<y;z++){x=v.material[z];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=F+"px";x.style.top=H+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(W){if(v!=W)n.globalAlpha=v=W}function c(W){if(x!=W){switch(W){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}x=W}}var d=null,f=new THREE.Projector,j=document.createElement("canvas"),k,q,o,l,n=j.getContext("2d"),z=new THREE.Color(0),y=0,v=1,x=0,F=null,H=null,I=1,s,O,C,b,R,$,Q,J,X,G=new THREE.Color,
-U=new THREE.Color,M=new THREE.Color,D=new THREE.Color,K=new THREE.Color,ca,N,aa,e,i,m,h,g,t,w=new THREE.Rectangle,u=new THREE.Rectangle,r=new THREE.Rectangle,p=false,B=new THREE.Color,V=new THREE.Color,da=new THREE.Color,ea=new THREE.Color,ia=Math.PI*2,S=new THREE.Vector3,Y,pa,P,ka,oa,wa,fa=16;Y=document.createElement("canvas");Y.width=Y.height=2;pa=Y.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);P=pa.getImageData(0,0,2,2);ka=P.data;oa=document.createElement("canvas");oa.width=
-oa.height=fa;wa=oa.getContext("2d");wa.translate(-fa/2,-fa/2);wa.scale(fa,fa);fa--;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(W,ba){k=W;q=ba;o=k/2;l=q/2;j.width=k;j.height=q;w.set(-o,-l,o,l);v=1;x=0;H=F=null;I=1};this.setClearColor=function(W,ba){z=W;y=ba;u.set(-o,-l,o,l);n.setTransform(1,0,0,-1,o,l);this.clear()};this.setClearColorHex=function(W,ba){z.setHex(W);y=ba;u.set(-o,-l,o,l);n.setTransform(1,0,0,-1,o,l);this.clear()};this.clear=function(){n.setTransform(1,
-0,0,-1,o,l);if(!u.isEmpty()){u.inflate(1);u.minSelf(w);if(z.hex==0&&y==0)n.clearRect(u.getX(),u.getY(),u.getWidth(),u.getHeight());else{c(THREE.NormalBlending);a(1);n.fillStyle="rgba("+Math.floor(z.r*255)+","+Math.floor(z.g*255)+","+Math.floor(z.b*255)+","+y+")";n.fillRect(u.getX(),u.getY(),u.getWidth(),u.getHeight())}u.empty()}};this.render=function(W,ba){function Ca(A){var Z,T,E,L=A.lights;V.setRGB(0,0,0);da.setRGB(0,0,0);ea.setRGB(0,0,0);A=0;for(Z=L.length;A<Z;A++){T=L[A];E=T.color;if(T instanceof
-THREE.AmbientLight){V.r+=E.r;V.g+=E.g;V.b+=E.b}else if(T instanceof THREE.DirectionalLight){da.r+=E.r;da.g+=E.g;da.b+=E.b}else if(T instanceof THREE.PointLight){ea.r+=E.r;ea.g+=E.g;ea.b+=E.b}}}function qa(A,Z,T,E){var L,ha,ra,xa,za=A.lights;A=0;for(L=za.length;A<L;A++){ha=za[A];ra=ha.color;xa=ha.intensity;if(ha instanceof THREE.DirectionalLight){ha=T.dot(ha.position)*xa;if(ha>0){E.r+=ra.r*ha;E.g+=ra.g*ha;E.b+=ra.b*ha}}else if(ha instanceof THREE.PointLight){S.sub(ha.position,Z);S.normalize();ha=T.dot(S)*
-xa;if(ha>0){E.r+=ra.r*ha;E.g+=ra.g*ha;E.b+=ra.b*ha}}}}function la(A,Z,T){if(T.opacity!=0){a(T.opacity);c(T.blending);var E,L,ha,ra,xa,za;if(T instanceof THREE.ParticleBasicMaterial){if(T.map&&T.map.image.loaded){ra=T.map.image;xa=ra.width>>1;za=ra.height>>1;L=Z.scale.x*o;ha=Z.scale.y*l;T=L*xa;E=ha*za;r.set(A.x-T,A.y-E,A.x+T,A.y+E);if(w.instersects(r)){n.save();n.translate(A.x,A.y);n.rotate(-Z.rotation);n.scale(L,-ha);n.translate(-xa,-za);n.drawImage(ra,0,0);n.restore()}}}else if(T instanceof THREE.ParticleCircleMaterial){if(p){B.r=
-V.r+da.r+ea.r;B.g=V.g+da.g+ea.g;B.b=V.b+da.b+ea.b;G.r=T.color.r*B.r;G.g=T.color.g*B.g;G.b=T.color.b*B.b;G.updateStyleString()}else G.__styleString=T.color.__styleString;T=Z.scale.x*o;E=Z.scale.y*l;r.set(A.x-T,A.y-E,A.x+T,A.y+E);if(w.instersects(r)){L=G.__styleString;if(H!=L)n.fillStyle=H=L;n.save();n.translate(A.x,A.y);n.rotate(-Z.rotation);n.scale(T,E);n.beginPath();n.arc(0,0,1,0,ia,true);n.closePath();n.fill();n.restore()}}}}function na(A,Z,T,E){if(E.opacity!=0){a(E.opacity);c(E.blending);n.beginPath();
-n.moveTo(A.positionScreen.x,A.positionScreen.y);n.lineTo(Z.positionScreen.x,Z.positionScreen.y);n.closePath();if(E instanceof THREE.LineBasicMaterial){G.__styleString=E.color.__styleString;A=E.linewidth;if(I!=A)n.lineWidth=I=A;A=G.__styleString;if(F!=A)n.strokeStyle=F=A;n.stroke();r.inflate(E.linewidth*2)}}}function Ja(A,Z,T,E,L,ha){if(L.opacity!=0){a(L.opacity);c(L.blending);b=A.positionScreen.x;R=A.positionScreen.y;$=Z.positionScreen.x;Q=Z.positionScreen.y;J=T.positionScreen.x;X=T.positionScreen.y;
-n.beginPath();n.moveTo(b,R);n.lineTo($,Q);n.lineTo(J,X);n.lineTo(b,R);n.closePath();if(L instanceof THREE.MeshBasicMaterial)if(L.map)L.map.image.loaded&&L.map.mapping instanceof THREE.UVMapping&&ga(b,R,$,Q,J,X,L.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);else if(L.env_map){if(L.env_map.image.loaded)if(L.env_map.mapping instanceof THREE.SphericalReflectionMapping){A=ba.matrix;S.copy(E.vertexNormalsWorld[0]);e=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;i=-(S.x*A.n21+S.y*
-A.n22+S.z*A.n23)*0.5+0.5;S.copy(E.vertexNormalsWorld[1]);m=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;h=-(S.x*A.n21+S.y*A.n22+S.z*A.n23)*0.5+0.5;S.copy(E.vertexNormalsWorld[2]);g=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;t=-(S.x*A.n21+S.y*A.n22+S.z*A.n23)*0.5+0.5;ga(b,R,$,Q,J,X,L.env_map.image,e,i,m,h,g,t)}}else L.wireframe?Da(L.color.__styleString,L.wireframe_linewidth):va(L.color.__styleString);else if(L instanceof THREE.MeshLambertMaterial){if(L.map&&!L.wireframe){L.map.mapping instanceof THREE.UVMapping&&
-ga(b,R,$,Q,J,X,L.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);c(THREE.SubtractiveBlending)}if(p)if(!L.wireframe&&L.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){U.r=M.r=D.r=V.r;U.g=M.g=D.g=V.g;U.b=M.b=D.b=V.b;qa(ha,E.v1.positionWorld,E.vertexNormalsWorld[0],U);qa(ha,E.v2.positionWorld,E.vertexNormalsWorld[1],M);qa(ha,E.v3.positionWorld,E.vertexNormalsWorld[2],D);K.r=(M.r+D.r)*0.5;K.g=(M.g+D.g)*0.5;K.b=(M.b+D.b)*0.5;aa=ma(U,M,D,K);ga(b,R,$,Q,J,X,aa,0,
-0,1,0,0,1)}else{B.r=V.r;B.g=V.g;B.b=V.b;qa(ha,E.centroidWorld,E.normalWorld,B);G.r=L.color.r*B.r;G.g=L.color.g*B.g;G.b=L.color.b*B.b;G.updateStyleString();L.wireframe?Da(G.__styleString,L.wireframe_linewidth):va(G.__styleString)}else L.wireframe?Da(L.color.__styleString,L.wireframe_linewidth):va(L.color.__styleString)}else if(L instanceof THREE.MeshDepthMaterial){ca=ba.near;N=ba.far;U.r=U.g=U.b=1-Aa(A.positionScreen.z,ca,N);M.r=M.g=M.b=1-Aa(Z.positionScreen.z,ca,N);D.r=D.g=D.b=1-Aa(T.positionScreen.z,
-ca,N);K.r=(M.r+D.r)*0.5;K.g=(M.g+D.g)*0.5;K.b=(M.b+D.b)*0.5;aa=ma(U,M,D,K);ga(b,R,$,Q,J,X,aa,0,0,1,0,0,1)}else if(L instanceof THREE.MeshNormalMaterial){G.r=ta(E.normalWorld.x);G.g=ta(E.normalWorld.y);G.b=ta(E.normalWorld.z);G.updateStyleString();L.wireframe?Da(G.__styleString,L.wireframe_linewidth):va(G.__styleString)}}}function Da(A,Z){if(F!=A)n.strokeStyle=F=A;if(I!=Z)n.lineWidth=I=Z;n.stroke();r.inflate(Z*2)}function va(A){if(H!=A)n.fillStyle=H=A;n.fill()}function ga(A,Z,T,E,L,ha,ra,xa,za,Ga,
-Ba,Ha,Oa){var Ea,Ia;Ea=ra.width-1;Ia=ra.height-1;xa*=Ea;za*=Ia;Ga*=Ea;Ba*=Ia;Ha*=Ea;Oa*=Ia;T-=A;E-=Z;L-=A;ha-=Z;Ga-=xa;Ba-=za;Ha-=xa;Oa-=za;Ea=Ga*Oa-Ha*Ba;if(Ea!=0){Ia=1/Ea;Ea=(Oa*T-Ba*L)*Ia;Ba=(Oa*E-Ba*ha)*Ia;T=(Ga*L-Ha*T)*Ia;E=(Ga*ha-Ha*E)*Ia;A=A-Ea*xa-T*za;Z=Z-Ba*xa-E*za;n.save();n.transform(Ea,Ba,T,E,A,Z);n.clip();n.drawImage(ra,0,0);n.restore()}}function ma(A,Z,T,E){var L=~~(A.r*255),ha=~~(A.g*255);A=~~(A.b*255);var ra=~~(Z.r*255),xa=~~(Z.g*255);Z=~~(Z.b*255);var za=~~(T.r*255),Ga=~~(T.g*255);
-T=~~(T.b*255);var Ba=~~(E.r*255),Ha=~~(E.g*255);E=~~(E.b*255);ka[0]=L<0?0:L>255?255:L;ka[1]=ha<0?0:ha>255?255:ha;ka[2]=A<0?0:A>255?255:A;ka[4]=ra<0?0:ra>255?255:ra;ka[5]=xa<0?0:xa>255?255:xa;ka[6]=Z<0?0:Z>255?255:Z;ka[8]=za<0?0:za>255?255:za;ka[9]=Ga<0?0:Ga>255?255:Ga;ka[10]=T<0?0:T>255?255:T;ka[12]=Ba<0?0:Ba>255?255:Ba;ka[13]=Ha<0?0:Ha>255?255:Ha;ka[14]=E<0?0:E>255?255:E;pa.putImageData(P,0,0);wa.drawImage(Y,0,0);return oa}function Aa(A,Z,T){A=(A-Z)/(T-Z);return A*A*(3-2*A)}function ta(A){A=(A+1)*
-0.5;return A<0?0:A>1?1:A}function La(A,Z){var T=Z.x-A.x,E=Z.y-A.y,L=1/Math.sqrt(T*T+E*E);T*=L;E*=L;Z.x+=T;Z.y+=E;A.x-=T;A.y-=E}var ua,Ma,ja,ya,Fa,Ka,Na,sa;this.autoClear?this.clear():n.setTransform(1,0,0,-1,o,l);d=f.projectScene(W,ba,this.sortElements);(p=W.lights.length>0)&&Ca(W);ua=0;for(Ma=d.length;ua<Ma;ua++){ja=d[ua];r.empty();if(ja instanceof THREE.RenderableParticle){s=ja;s.x*=o;s.y*=l;ya=0;for(Fa=ja.materials.length;ya<Fa;ya++)la(s,ja,ja.materials[ya],W)}else if(ja instanceof THREE.RenderableLine){s=
-ja.v1;O=ja.v2;s.positionScreen.x*=o;s.positionScreen.y*=l;O.positionScreen.x*=o;O.positionScreen.y*=l;r.addPoint(s.positionScreen.x,s.positionScreen.y);r.addPoint(O.positionScreen.x,O.positionScreen.y);if(w.instersects(r)){ya=0;for(Fa=ja.materials.length;ya<Fa;)na(s,O,ja,ja.materials[ya++],W)}}else if(ja instanceof THREE.RenderableFace3){s=ja.v1;O=ja.v2;C=ja.v3;s.positionScreen.x*=o;s.positionScreen.y*=l;O.positionScreen.x*=o;O.positionScreen.y*=l;C.positionScreen.x*=o;C.positionScreen.y*=l;if(ja.overdraw){La(s.positionScreen,
-O.positionScreen);La(O.positionScreen,C.positionScreen);La(C.positionScreen,s.positionScreen)}r.add3Points(s.positionScreen.x,s.positionScreen.y,O.positionScreen.x,O.positionScreen.y,C.positionScreen.x,C.positionScreen.y);if(w.instersects(r)){ya=0;for(Fa=ja.meshMaterials.length;ya<Fa;){sa=ja.meshMaterials[ya++];if(sa instanceof THREE.MeshFaceMaterial){Ka=0;for(Na=ja.faceMaterials.length;Ka<Na;)(sa=ja.faceMaterials[Ka++])&&Ja(s,O,C,ja,sa,W)}else Ja(s,O,C,ja,sa,W)}}}u.addRectangle(r)}n.setTransform(1,
+THREE.Fog=function(a,c,e){this.color=new THREE.Color(a);this.near=c||1;this.far=e||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
+THREE.Projector=function(){function a(P,J){return J.z-P.z}function c(P,J){var W=0,M=1,R=P.z+P.w,K=J.z+J.w,C=-P.z+P.w,L=-J.z+J.w;if(R>=0&&K>=0&&C>=0&&L>=0)return true;else if(R<0&&K<0||C<0&&L<0)return false;else{if(R<0)W=Math.max(W,R/(R-K));else if(K<0)M=Math.min(M,R/(R-K));if(C<0)W=Math.max(W,C/(C-L));else if(L<0)M=Math.min(M,C/(C-L));if(M<W)return false;else{P.lerpSelf(J,W);J.lerpSelf(P,1-M);return true}}}var e,g,i=[],k,q,p,l=[],n,y,z=[],t,x,D=[],H=new THREE.Vector4,G=new THREE.Vector4,r=new THREE.Matrix4,
+S=new THREE.Matrix4,B=[],I=new THREE.Vector4,b=new THREE.Vector4,aa;this.projectObjects=function(P,J,W){var M=[],R,K;g=0;r.multiply(J.projectionMatrix,J.matrix);B[0]=new THREE.Vector4(r.n41-r.n11,r.n42-r.n12,r.n43-r.n13,r.n44-r.n14);B[1]=new THREE.Vector4(r.n41+r.n11,r.n42+r.n12,r.n43+r.n13,r.n44+r.n14);B[2]=new THREE.Vector4(r.n41+r.n21,r.n42+r.n22,r.n43+r.n23,r.n44+r.n24);B[3]=new THREE.Vector4(r.n41-r.n21,r.n42-r.n22,r.n43-r.n23,r.n44-r.n24);B[4]=new THREE.Vector4(r.n41-r.n31,r.n42-r.n32,r.n43-
+r.n33,r.n44-r.n34);B[5]=new THREE.Vector4(r.n41+r.n31,r.n42+r.n32,r.n43+r.n33,r.n44+r.n34);J=0;for(R=B.length;J<R;J++){K=B[J];K.divideScalar(Math.sqrt(K.x*K.x+K.y*K.y+K.z*K.z))}R=P.objects;P=0;for(J=R.length;P<J;P++){K=R[P];var C;if(!(C=!K.visible)){if(C=K instanceof THREE.Mesh){a:{C=void 0;for(var L=K.position,ba=-K.geometry.boundingSphere.radius*Math.max(K.scale.x,Math.max(K.scale.y,K.scale.z)),N=0;N<6;N++){C=B[N].x*L.x+B[N].y*L.y+B[N].z*L.z+B[N].w;if(C<=ba){C=false;break a}}C=true}C=!C}C=C}if(!C){e=
+i[g]=i[g]||new THREE.RenderableObject;H.copy(K.position);r.multiplyVector3(H);e.object=K;e.z=H.z;M.push(e);g++}}W&&M.sort(a);return M};this.projectScene=function(P,J,W){var M=[],R=J.near,K=J.far,C,L,ba,N,da,ca,d,j,o,h,f,w,u,m,v,s;p=y=x=0;J.autoUpdateMatrix&&J.updateMatrix();r.multiply(J.projectionMatrix,J.matrix);ca=this.projectObjects(P,J,true);P=0;for(C=ca.length;P<C;P++){d=ca[P].object;if(d.visible){d.autoUpdateMatrix&&d.updateMatrix();j=d.matrix;o=d.rotationMatrix;h=d.materials;f=d.overdraw;if(d instanceof
+THREE.Mesh){w=d.geometry;u=w.vertices;L=0;for(ba=u.length;L<ba;L++){m=u[L];m.positionWorld.copy(m.position);j.multiplyVector3(m.positionWorld);N=m.positionScreen;N.copy(m.positionWorld);r.multiplyVector4(N);N.x/=N.w;N.y/=N.w;m.__visible=N.z>R&&N.z<K}w=w.faces;L=0;for(ba=w.length;L<ba;L++){m=w[L];if(m instanceof THREE.Face3){N=u[m.a];da=u[m.b];v=u[m.c];if(N.__visible&&da.__visible&&v.__visible)if(d.doubleSided||d.flipSided!=(v.positionScreen.x-N.positionScreen.x)*(da.positionScreen.y-N.positionScreen.y)-
+(v.positionScreen.y-N.positionScreen.y)*(da.positionScreen.x-N.positionScreen.x)<0){k=l[p]=l[p]||new THREE.RenderableFace3;k.v1.positionWorld.copy(N.positionWorld);k.v2.positionWorld.copy(da.positionWorld);k.v3.positionWorld.copy(v.positionWorld);k.v1.positionScreen.copy(N.positionScreen);k.v2.positionScreen.copy(da.positionScreen);k.v3.positionScreen.copy(v.positionScreen);k.normalWorld.copy(m.normal);o.multiplyVector3(k.normalWorld);k.centroidWorld.copy(m.centroid);j.multiplyVector3(k.centroidWorld);
+k.centroidScreen.copy(k.centroidWorld);r.multiplyVector3(k.centroidScreen);v=m.vertexNormals;aa=k.vertexNormalsWorld;N=0;for(da=v.length;N<da;N++){s=aa[N]=aa[N]||new THREE.Vector3;s.copy(v[N]);o.multiplyVector3(s)}k.z=k.centroidScreen.z;k.meshMaterials=h;k.faceMaterials=m.materials;k.overdraw=f;if(d.geometry.uvs[L]){k.uvs[0]=d.geometry.uvs[L][0];k.uvs[1]=d.geometry.uvs[L][1];k.uvs[2]=d.geometry.uvs[L][2]}M.push(k);p++}}else if(m instanceof THREE.Face4){N=u[m.a];da=u[m.b];v=u[m.c];s=u[m.d];if(N.__visible&&
+da.__visible&&v.__visible&&s.__visible)if(d.doubleSided||d.flipSided!=((s.positionScreen.x-N.positionScreen.x)*(da.positionScreen.y-N.positionScreen.y)-(s.positionScreen.y-N.positionScreen.y)*(da.positionScreen.x-N.positionScreen.x)<0||(da.positionScreen.x-v.positionScreen.x)*(s.positionScreen.y-v.positionScreen.y)-(da.positionScreen.y-v.positionScreen.y)*(s.positionScreen.x-v.positionScreen.x)<0)){k=l[p]=l[p]||new THREE.RenderableFace3;k.v1.positionWorld.copy(N.positionWorld);k.v2.positionWorld.copy(da.positionWorld);
+k.v3.positionWorld.copy(s.positionWorld);k.v1.positionScreen.copy(N.positionScreen);k.v2.positionScreen.copy(da.positionScreen);k.v3.positionScreen.copy(s.positionScreen);k.normalWorld.copy(m.normal);o.multiplyVector3(k.normalWorld);k.centroidWorld.copy(m.centroid);j.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);r.multiplyVector3(k.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterials=h;k.faceMaterials=m.materials;k.overdraw=f;if(d.geometry.uvs[L]){k.uvs[0]=d.geometry.uvs[L][0];
+k.uvs[1]=d.geometry.uvs[L][1];k.uvs[2]=d.geometry.uvs[L][3]}M.push(k);p++;q=l[p]=l[p]||new THREE.RenderableFace3;q.v1.positionWorld.copy(da.positionWorld);q.v2.positionWorld.copy(v.positionWorld);q.v3.positionWorld.copy(s.positionWorld);q.v1.positionScreen.copy(da.positionScreen);q.v2.positionScreen.copy(v.positionScreen);q.v3.positionScreen.copy(s.positionScreen);q.normalWorld.copy(k.normalWorld);q.centroidWorld.copy(k.centroidWorld);q.centroidScreen.copy(k.centroidScreen);q.z=q.centroidScreen.z;
+q.meshMaterials=h;q.faceMaterials=m.materials;q.overdraw=f;if(d.geometry.uvs[L]){q.uvs[0]=d.geometry.uvs[L][1];q.uvs[1]=d.geometry.uvs[L][2];q.uvs[2]=d.geometry.uvs[L][3]}M.push(q);p++}}}}else if(d instanceof THREE.Line){S.multiply(r,j);u=d.geometry.vertices;m=u[0];m.positionScreen.copy(m.position);S.multiplyVector4(m.positionScreen);L=1;for(ba=u.length;L<ba;L++){N=u[L];N.positionScreen.copy(N.position);S.multiplyVector4(N.positionScreen);da=u[L-1];I.copy(N.positionScreen);b.copy(da.positionScreen);
+if(c(I,b)){I.multiplyScalar(1/I.w);b.multiplyScalar(1/b.w);n=z[y]=z[y]||new THREE.RenderableLine;n.v1.positionScreen.copy(I);n.v2.positionScreen.copy(b);n.z=Math.max(I.z,b.z);n.materials=d.materials;M.push(n);y++}}}else if(d instanceof THREE.Particle){G.set(d.position.x,d.position.y,d.position.z,1);r.multiplyVector4(G);G.z/=G.w;if(G.z>0&&G.z<1){t=D[x]=D[x]||new THREE.RenderableParticle;t.x=G.x/G.w;t.y=G.y/G.w;t.z=G.z;t.rotation=d.rotation.z;t.scale.x=d.scale.x*Math.abs(t.x-(G.x+J.projectionMatrix.n11)/
+(G.w+J.projectionMatrix.n14));t.scale.y=d.scale.y*Math.abs(t.y-(G.y+J.projectionMatrix.n22)/(G.w+J.projectionMatrix.n24));t.materials=d.materials;M.push(t);x++}}}}W&&M.sort(a);return M};this.unprojectVector=function(P,J){var W=THREE.Matrix4.makeInvert(J.matrix);W.multiplySelf(THREE.Matrix4.makeInvert(J.projectionMatrix));W.multiplyVector3(P);return P}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,e,g,i,k;this.domElement=document.createElement("div");this.setSize=function(q,p){e=q;g=p;i=e/2;k=g/2};this.render=function(q,p){var l,n,y,z,t,x,D,H;a=c.projectScene(q,p);l=0;for(n=a.length;l<n;l++){t=a[l];if(t instanceof THREE.RenderableParticle){D=t.x*i+i;H=t.y*k+k;y=0;for(z=t.material.length;y<z;y++){x=t.material[y];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=D+"px";x.style.top=H+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(V){if(t!=V)n.globalAlpha=t=V}function c(V){if(x!=V){switch(V){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}x=V}}var e=null,g=new THREE.Projector,i=document.createElement("canvas"),k,q,p,l,n=i.getContext("2d"),y=new THREE.Color(0),z=0,t=1,x=0,D=null,H=null,G=1,r,S,B,I,b,aa,P,J,W,M=new THREE.Color,
+R=new THREE.Color,K=new THREE.Color,C=new THREE.Color,L=new THREE.Color,ba,N,da,ca,d,j,o,h,f,w=new THREE.Rectangle,u=new THREE.Rectangle,m=new THREE.Rectangle,v=false,s=new THREE.Color,O=new THREE.Color,Y=new THREE.Color,ga=new THREE.Color,ia=Math.PI*2,U=new THREE.Vector3,ea,Z,qa,F,ua,oa,ra=16;ea=document.createElement("canvas");ea.width=ea.height=2;Z=ea.getContext("2d");Z.fillStyle="rgba(0,0,0,1)";Z.fillRect(0,0,2,2);qa=Z.getImageData(0,0,2,2);F=qa.data;ua=document.createElement("canvas");ua.width=
+ua.height=ra;oa=ua.getContext("2d");oa.translate(-ra/2,-ra/2);oa.scale(ra,ra);ra--;this.domElement=i;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(V,fa){k=V;q=fa;p=k/2;l=q/2;i.width=k;i.height=q;w.set(-p,-l,p,l);t=1;x=0;H=D=null;G=1};this.setClearColor=function(V,fa){y=V;z=fa;u.set(-p,-l,p,l);n.setTransform(1,0,0,-1,p,l);this.clear()};this.setClearColorHex=function(V,fa){y.setHex(V);z=fa;u.set(-p,-l,p,l);n.setTransform(1,0,0,-1,p,l);this.clear()};this.clear=function(){n.setTransform(1,
+0,0,-1,p,l);if(!u.isEmpty()){u.inflate(1);u.minSelf(w);if(y.hex==0&&z==0)n.clearRect(u.getX(),u.getY(),u.getWidth(),u.getHeight());else{c(THREE.NormalBlending);a(1);n.fillStyle="rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b*255)+","+z+")";n.fillRect(u.getX(),u.getY(),u.getWidth(),u.getHeight())}u.empty()}};this.render=function(V,fa){function ja(A){var X,T,E,Q=A.lights;O.setRGB(0,0,0);Y.setRGB(0,0,0);ga.setRGB(0,0,0);A=0;for(X=Q.length;A<X;A++){T=Q[A];E=T.color;if(T instanceof
+THREE.AmbientLight){O.r+=E.r;O.g+=E.g;O.b+=E.b}else if(T instanceof THREE.DirectionalLight){Y.r+=E.r;Y.g+=E.g;Y.b+=E.b}else if(T instanceof THREE.PointLight){ga.r+=E.r;ga.g+=E.g;ga.b+=E.b}}}function za(A,X,T,E){var Q,$,pa,wa,ya=A.lights;A=0;for(Q=ya.length;A<Q;A++){$=ya[A];pa=$.color;wa=$.intensity;if($ instanceof THREE.DirectionalLight){$=T.dot($.position)*wa;if($>0){E.r+=pa.r*$;E.g+=pa.g*$;E.b+=pa.b*$}}else if($ instanceof THREE.PointLight){U.sub($.position,X);U.normalize();$=T.dot(U)*wa;if($>0){E.r+=
+pa.r*$;E.g+=pa.g*$;E.b+=pa.b*$}}}}function va(A,X,T){if(T.opacity!=0){a(T.opacity);c(T.blending);var E,Q,$,pa,wa,ya;if(T instanceof THREE.ParticleBasicMaterial){if(T.map&&T.map.image.loaded){pa=T.map.image;wa=pa.width>>1;ya=pa.height>>1;Q=X.scale.x*p;$=X.scale.y*l;T=Q*wa;E=$*ya;m.set(A.x-T,A.y-E,A.x+T,A.y+E);if(w.instersects(m)){n.save();n.translate(A.x,A.y);n.rotate(-X.rotation);n.scale(Q,-$);n.translate(-wa,-ya);n.drawImage(pa,0,0);n.restore()}}}else if(T instanceof THREE.ParticleCircleMaterial){if(v){s.r=
+O.r+Y.r+ga.r;s.g=O.g+Y.g+ga.g;s.b=O.b+Y.b+ga.b;M.r=T.color.r*s.r;M.g=T.color.g*s.g;M.b=T.color.b*s.b;M.updateStyleString()}else M.__styleString=T.color.__styleString;T=X.scale.x*p;E=X.scale.y*l;m.set(A.x-T,A.y-E,A.x+T,A.y+E);if(w.instersects(m)){Q=M.__styleString;if(H!=Q)n.fillStyle=H=Q;n.save();n.translate(A.x,A.y);n.rotate(-X.rotation);n.scale(T,E);n.beginPath();n.arc(0,0,1,0,ia,true);n.closePath();n.fill();n.restore()}}}}function ma(A,X,T,E){if(E.opacity!=0){a(E.opacity);c(E.blending);n.beginPath();
+n.moveTo(A.positionScreen.x,A.positionScreen.y);n.lineTo(X.positionScreen.x,X.positionScreen.y);n.closePath();if(E instanceof THREE.LineBasicMaterial){M.__styleString=E.color.__styleString;A=E.linewidth;if(G!=A)n.lineWidth=G=A;A=M.__styleString;if(D!=A)n.strokeStyle=D=A;n.stroke();m.inflate(E.linewidth*2)}}}function na(A,X,T,E,Q,$){if(Q.opacity!=0){a(Q.opacity);c(Q.blending);I=A.positionScreen.x;b=A.positionScreen.y;aa=X.positionScreen.x;P=X.positionScreen.y;J=T.positionScreen.x;W=T.positionScreen.y;
+n.beginPath();n.moveTo(I,b);n.lineTo(aa,P);n.lineTo(J,W);n.lineTo(I,b);n.closePath();if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&sa(I,b,aa,P,J,W,Q.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);else if(Q.env_map){if(Q.env_map.image.loaded)if(Q.env_map.mapping instanceof THREE.SphericalReflectionMapping){A=fa.matrix;U.copy(E.vertexNormalsWorld[0]);ca=(U.x*A.n11+U.y*A.n12+U.z*A.n13)*0.5+0.5;d=-(U.x*A.n21+
+U.y*A.n22+U.z*A.n23)*0.5+0.5;U.copy(E.vertexNormalsWorld[1]);j=(U.x*A.n11+U.y*A.n12+U.z*A.n13)*0.5+0.5;o=-(U.x*A.n21+U.y*A.n22+U.z*A.n23)*0.5+0.5;U.copy(E.vertexNormalsWorld[2]);h=(U.x*A.n11+U.y*A.n12+U.z*A.n13)*0.5+0.5;f=-(U.x*A.n21+U.y*A.n22+U.z*A.n23)*0.5+0.5;sa(I,b,aa,P,J,W,Q.env_map.image,ca,d,j,o,h,f)}}else Q.wireframe?Ea(Q.color.__styleString,Q.wireframe_linewidth):Fa(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&!Q.wireframe){Q.map.mapping instanceof THREE.UVMapping&&
+sa(I,b,aa,P,J,W,Q.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);c(THREE.SubtractiveBlending)}if(v)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){R.r=K.r=C.r=O.r;R.g=K.g=C.g=O.g;R.b=K.b=C.b=O.b;za($,E.v1.positionWorld,E.vertexNormalsWorld[0],R);za($,E.v2.positionWorld,E.vertexNormalsWorld[1],K);za($,E.v3.positionWorld,E.vertexNormalsWorld[2],C);L.r=(K.r+C.r)*0.5;L.g=(K.g+C.g)*0.5;L.b=(K.b+C.b)*0.5;da=ha(R,K,C,L);sa(I,b,aa,P,J,W,da,0,
+0,1,0,0,1)}else{s.r=O.r;s.g=O.g;s.b=O.b;za($,E.centroidWorld,E.normalWorld,s);M.r=Q.color.r*s.r;M.g=Q.color.g*s.g;M.b=Q.color.b*s.b;M.updateStyleString();Q.wireframe?Ea(M.__styleString,Q.wireframe_linewidth):Fa(M.__styleString)}else Q.wireframe?Ea(Q.color.__styleString,Q.wireframe_linewidth):Fa(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){ba=fa.near;N=fa.far;R.r=R.g=R.b=1-la(A.positionScreen.z,ba,N);K.r=K.g=K.b=1-la(X.positionScreen.z,ba,N);C.r=C.g=C.b=1-la(T.positionScreen.z,
+ba,N);L.r=(K.r+C.r)*0.5;L.g=(K.g+C.g)*0.5;L.b=(K.b+C.b)*0.5;da=ha(R,K,C,L);sa(I,b,aa,P,J,W,da,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){M.r=Aa(E.normalWorld.x);M.g=Aa(E.normalWorld.y);M.b=Aa(E.normalWorld.z);M.updateStyleString();Q.wireframe?Ea(M.__styleString,Q.wireframe_linewidth):Fa(M.__styleString)}}}function Ea(A,X){if(D!=A)n.strokeStyle=D=A;if(G!=X)n.lineWidth=G=X;n.stroke();m.inflate(X*2)}function Fa(A){if(H!=A)n.fillStyle=H=A;n.fill()}function sa(A,X,T,E,Q,$,pa,wa,ya,Ha,
+Da,Ia,Oa){var Ga,Ja;Ga=pa.width-1;Ja=pa.height-1;wa*=Ga;ya*=Ja;Ha*=Ga;Da*=Ja;Ia*=Ga;Oa*=Ja;T-=A;E-=X;Q-=A;$-=X;Ha-=wa;Da-=ya;Ia-=wa;Oa-=ya;Ga=Ha*Oa-Ia*Da;if(Ga!=0){Ja=1/Ga;Ga=(Oa*T-Da*Q)*Ja;Da=(Oa*E-Da*$)*Ja;T=(Ha*Q-Ia*T)*Ja;E=(Ha*$-Ia*E)*Ja;A=A-Ga*wa-T*ya;X=X-Da*wa-E*ya;n.save();n.transform(Ga,Da,T,E,A,X);n.clip();n.drawImage(pa,0,0);n.restore()}}function ha(A,X,T,E){var Q=~~(A.r*255),$=~~(A.g*255);A=~~(A.b*255);var pa=~~(X.r*255),wa=~~(X.g*255);X=~~(X.b*255);var ya=~~(T.r*255),Ha=~~(T.g*255);T=
+~~(T.b*255);var Da=~~(E.r*255),Ia=~~(E.g*255);E=~~(E.b*255);F[0]=Q<0?0:Q>255?255:Q;F[1]=$<0?0:$>255?255:$;F[2]=A<0?0:A>255?255:A;F[4]=pa<0?0:pa>255?255:pa;F[5]=wa<0?0:wa>255?255:wa;F[6]=X<0?0:X>255?255:X;F[8]=ya<0?0:ya>255?255:ya;F[9]=Ha<0?0:Ha>255?255:Ha;F[10]=T<0?0:T>255?255:T;F[12]=Da<0?0:Da>255?255:Da;F[13]=Ia<0?0:Ia>255?255:Ia;F[14]=E<0?0:E>255?255:E;Z.putImageData(qa,0,0);oa.drawImage(ea,0,0);return ua}function la(A,X,T){A=(A-X)/(T-X);return A*A*(3-2*A)}function Aa(A){A=(A+1)*0.5;return A<0?
+0:A>1?1:A}function ta(A,X){var T=X.x-A.x,E=X.y-A.y,Q=1/Math.sqrt(T*T+E*E);T*=Q;E*=Q;X.x+=T;X.y+=E;A.x-=T;A.y-=E}var La,xa,ka,Ba,Ca,Ma,Na,Ka;this.autoClear?this.clear():n.setTransform(1,0,0,-1,p,l);e=g.projectScene(V,fa,this.sortElements);(v=V.lights.length>0)&&ja(V);La=0;for(xa=e.length;La<xa;La++){ka=e[La];m.empty();if(ka instanceof THREE.RenderableParticle){r=ka;r.x*=p;r.y*=l;Ba=0;for(Ca=ka.materials.length;Ba<Ca;Ba++)va(r,ka,ka.materials[Ba],V)}else if(ka instanceof THREE.RenderableLine){r=ka.v1;
+S=ka.v2;r.positionScreen.x*=p;r.positionScreen.y*=l;S.positionScreen.x*=p;S.positionScreen.y*=l;m.addPoint(r.positionScreen.x,r.positionScreen.y);m.addPoint(S.positionScreen.x,S.positionScreen.y);if(w.instersects(m)){Ba=0;for(Ca=ka.materials.length;Ba<Ca;)ma(r,S,ka,ka.materials[Ba++],V)}}else if(ka instanceof THREE.RenderableFace3){r=ka.v1;S=ka.v2;B=ka.v3;r.positionScreen.x*=p;r.positionScreen.y*=l;S.positionScreen.x*=p;S.positionScreen.y*=l;B.positionScreen.x*=p;B.positionScreen.y*=l;if(ka.overdraw){ta(r.positionScreen,
+S.positionScreen);ta(S.positionScreen,B.positionScreen);ta(B.positionScreen,r.positionScreen)}m.add3Points(r.positionScreen.x,r.positionScreen.y,S.positionScreen.x,S.positionScreen.y,B.positionScreen.x,B.positionScreen.y);if(w.instersects(m)){Ba=0;for(Ca=ka.meshMaterials.length;Ba<Ca;){Ka=ka.meshMaterials[Ba++];if(Ka instanceof THREE.MeshFaceMaterial){Ma=0;for(Na=ka.faceMaterials.length;Ma<Na;)(Ka=ka.faceMaterials[Ma++])&&na(r,S,B,ka,Ka,V)}else na(r,S,B,ka,Ka,V)}}}u.addRectangle(m)}n.setTransform(1,
 0,0,1,0,0)}};
 0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(e,i,m){var h,g,t,w;h=0;for(g=e.lights.length;h<g;h++){t=e.lights[h];if(t instanceof THREE.DirectionalLight){w=i.normalWorld.dot(t.position)*t.intensity;if(w>0){m.r+=t.color.r*w;m.g+=t.color.g*w;m.b+=t.color.b*w}}else if(t instanceof THREE.PointLight){X.sub(t.position,i.centroidWorld);X.normalize();w=i.normalWorld.dot(X)*t.intensity;if(w>0){m.r+=t.color.r*w;m.g+=t.color.g*w;m.b+=t.color.b*w}}}}function c(e,i,m,h,g,t){D=f(K++);D.setAttribute("d","M "+e.positionScreen.x+
-" "+e.positionScreen.y+" L "+i.positionScreen.x+" "+i.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");if(g instanceof THREE.MeshBasicMaterial)C.__styleString=g.color.__styleString;else if(g instanceof THREE.MeshLambertMaterial)if(O){b.r=R.r;b.g=R.g;b.b=R.b;a(t,h,b);C.r=g.color.r*b.r;C.g=g.color.g*b.g;C.b=g.color.b*b.b;C.updateStyleString()}else C.__styleString=g.color.__styleString;else if(g instanceof THREE.MeshDepthMaterial){J=1-g.__2near/(g.__farPlusNear-h.z*g.__farMinusNear);
-C.setRGB(J,J,J)}else g instanceof THREE.MeshNormalMaterial&&C.setRGB(j(h.normalWorld.x),j(h.normalWorld.y),j(h.normalWorld.z));g.wireframe?D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+g.wireframe_linewidth+"; stroke-opacity: "+g.opacity+"; stroke-linecap: "+g.wireframe_linecap+"; stroke-linejoin: "+g.wireframe_linejoin):D.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+g.opacity);o.appendChild(D)}function d(e,i,m,h,g,t,w){D=f(K++);D.setAttribute("d",
-"M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+i.positionScreen.x+" "+i.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");if(t instanceof THREE.MeshBasicMaterial)C.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshLambertMaterial)if(O){b.r=R.r;b.g=R.g;b.b=R.b;a(w,g,b);C.r=t.color.r*b.r;C.g=t.color.g*b.g;C.b=t.color.b*b.b;C.updateStyleString()}else C.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshDepthMaterial){J=
-1-t.__2near/(t.__farPlusNear-g.z*t.__farMinusNear);C.setRGB(J,J,J)}else t instanceof THREE.MeshNormalMaterial&&C.setRGB(j(g.normalWorld.x),j(g.normalWorld.y),j(g.normalWorld.z));t.wireframe?D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+t.wireframe_linewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframe_linecap+"; stroke-linejoin: "+t.wireframe_linejoin):D.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+t.opacity);o.appendChild(D)}
-function f(e){if(G[e]==null){G[e]=document.createElementNS("http://www.w3.org/2000/svg","path");aa==0&&G[e].setAttribute("shape-rendering","crispEdges");return G[e]}return G[e]}function j(e){return e<0?Math.min((1+e)*0.5,0.5):0.5+Math.min(e*0.5,0.5)}var k=null,q=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,n,z,y,v,x,F,H,I=new THREE.Rectangle,s=new THREE.Rectangle,O=false,C=new THREE.Color(16777215),b=new THREE.Color(16777215),R=new THREE.Color(0),$=new THREE.Color(0),
-Q=new THREE.Color(0),J,X=new THREE.Vector3,G=[],U=[],M=[],D,K,ca,N,aa=1;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(e){switch(e){case "high":aa=1;break;case "low":aa=0}};this.setSize=function(e,i){l=e;n=i;z=l/2;y=n/2;o.setAttribute("viewBox",-z+" "+-y+" "+l+" "+n);o.setAttribute("width",l);o.setAttribute("height",n);I.set(-z,-y,z,y)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=function(e,i){var m,
-h,g,t,w,u,r,p;this.autoClear&&this.clear();k=q.projectScene(e,i,this.sortElements);N=ca=K=0;if(O=e.lights.length>0){r=e.lights;R.setRGB(0,0,0);$.setRGB(0,0,0);Q.setRGB(0,0,0);m=0;for(h=r.length;m<h;m++){g=r[m];t=g.color;if(g instanceof THREE.AmbientLight){R.r+=t.r;R.g+=t.g;R.b+=t.b}else if(g instanceof THREE.DirectionalLight){$.r+=t.r;$.g+=t.g;$.b+=t.b}else if(g instanceof THREE.PointLight){Q.r+=t.r;Q.g+=t.g;Q.b+=t.b}}}m=0;for(h=k.length;m<h;m++){r=k[m];s.empty();if(r instanceof THREE.RenderableParticle){v=
-r;v.x*=z;v.y*=-y;g=0;for(t=r.materials.length;g<t;g++)if(p=r.materials[g]){w=v;u=r;p=p;var B=ca++;if(U[B]==null){U[B]=document.createElementNS("http://www.w3.org/2000/svg","circle");aa==0&&U[B].setAttribute("shape-rendering","crispEdges")}D=U[B];D.setAttribute("cx",w.x);D.setAttribute("cy",w.y);D.setAttribute("r",u.scale.x*z);if(p instanceof THREE.ParticleCircleMaterial){if(O){b.r=R.r+$.r+Q.r;b.g=R.g+$.g+Q.g;b.b=R.b+$.b+Q.b;C.r=p.color.r*b.r;C.g=p.color.g*b.g;C.b=p.color.b*b.b;C.updateStyleString()}else C=
-p.color;D.setAttribute("style","fill: "+C.__styleString)}o.appendChild(D)}}else if(r instanceof THREE.RenderableLine){v=r.v1;x=r.v2;v.positionScreen.x*=z;v.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);if(I.instersects(s)){g=0;for(t=r.materials.length;g<t;)if(p=r.materials[g++]){w=v;u=x;p=p;B=N++;if(M[B]==null){M[B]=document.createElementNS("http://www.w3.org/2000/svg","line");aa==
-0&&M[B].setAttribute("shape-rendering","crispEdges")}D=M[B];D.setAttribute("x1",w.positionScreen.x);D.setAttribute("y1",w.positionScreen.y);D.setAttribute("x2",u.positionScreen.x);D.setAttribute("y2",u.positionScreen.y);if(p instanceof THREE.LineBasicMaterial){C.__styleString=p.color.__styleString;D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+p.linewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.linecap+"; stroke-linejoin: "+p.linejoin);o.appendChild(D)}}}}else if(r instanceof
-THREE.RenderableFace3){v=r.v1;x=r.v2;F=r.v3;v.positionScreen.x*=z;v.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;F.positionScreen.x*=z;F.positionScreen.y*=-y;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(F.positionScreen.x,F.positionScreen.y);if(I.instersects(s)){g=0;for(t=r.meshMaterials.length;g<t;){p=r.meshMaterials[g++];if(p instanceof THREE.MeshFaceMaterial){w=0;for(u=r.faceMaterials.length;w<u;)(p=r.faceMaterials[w++])&&
-c(v,x,F,r,p,e)}else p&&c(v,x,F,r,p,e)}}}else if(r instanceof THREE.RenderableFace4){v=r.v1;x=r.v2;F=r.v3;H=r.v4;v.positionScreen.x*=z;v.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;F.positionScreen.x*=z;F.positionScreen.y*=-y;H.positionScreen.x*=z;H.positionScreen.y*=-y;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(F.positionScreen.x,F.positionScreen.y);s.addPoint(H.positionScreen.x,H.positionScreen.y);if(I.instersects(s)){g=
-0;for(t=r.meshMaterials.length;g<t;){p=r.meshMaterials[g++];if(p instanceof THREE.MeshFaceMaterial){w=0;for(u=r.faceMaterials.length;w<u;)(p=r.faceMaterials[w++])&&d(v,x,F,H,r,p,e)}else p&&d(v,x,F,H,r,p,e)}}}}}};
-THREE.WebGLRenderer=function(a){function c(e,i,m){var h,g,t,w=e.vertices,u=w.length,r=e.colors,p=r.length,B=e.__vertexArray,V=e.__colorArray,da=e.__sortArray,ea=e.__dirtyVertices,ia=e.__dirtyColors;if(m.sortParticles){U.multiplySelf(m.matrixWorld);for(h=0;h<u;h++){g=w[h].position;K.copy(g);U.multiplyVector3(K);da[h]=[K.z,h]}da.sort(function(S,Y){return Y[0]-S[0]});for(h=0;h<u;h++){g=w[da[h][1]].position;t=h*3;B[t]=g.x;B[t+1]=g.y;B[t+2]=g.z}for(h=0;h<p;h++){t=h*3;color=r[da[h][1]];V[t]=color.r;V[t+
-1]=color.g;V[t+2]=color.b}}else{if(ea)for(h=0;h<u;h++){g=w[h].position;t=h*3;B[t]=g.x;B[t+1]=g.y;B[t+2]=g.z}if(ia)for(h=0;h<p;h++){color=r[h];t=h*3;V[t]=color.r;V[t+1]=color.g;V[t+2]=color.b}}if(ea||m.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,B,i)}if(ia||m.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,V,i)}}function d(e,i){e.fragment_shader=i.fragment_shader;e.vertex_shader=i.vertex_shader;e.uniforms=
-Uniforms.clone(i.uniforms)}function f(e,i){if(!e.__webGLVertexBuffer)e.__webGLVertexBuffer=b.createBuffer();if(!e.__webGLNormalBuffer)e.__webGLNormalBuffer=b.createBuffer();if(e.hasPos){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,e.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(i.attributes.position);b.vertexAttribPointer(i.attributes.position,3,b.FLOAT,false,0,0)}if(e.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,
-e.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(i.attributes.normal);b.vertexAttribPointer(i.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,e.count);e.count=0}function j(e){if(Q!=e.doubleSided){e.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);Q=e.doubleSided}if(J!=e.flipSided){e.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);J=e.flipSided}}function k(e){G[0].set(e.n41-e.n11,e.n42-e.n12,e.n43-e.n13,e.n44-e.n14);G[1].set(e.n41+e.n11,e.n42+e.n12,e.n43+e.n13,e.n44+
-e.n14);G[2].set(e.n41+e.n21,e.n42+e.n22,e.n43+e.n23,e.n44+e.n24);G[3].set(e.n41-e.n21,e.n42-e.n22,e.n43-e.n23,e.n44-e.n24);G[4].set(e.n41-e.n31,e.n42-e.n32,e.n43-e.n33,e.n44-e.n34);G[5].set(e.n41+e.n31,e.n42+e.n32,e.n43+e.n33,e.n44+e.n34);var i;for(e=0;e<5;e++){i=G[e];i.divideScalar(Math.sqrt(i.x*i.x+i.y*i.y+i.z*i.z))}}function q(e){for(var i=e.matrix,m=-e.geometry.boundingSphere.radius*Math.max(e.scale.x,Math.max(e.scale.y,e.scale.z)),h=0;h<6;h++){e=G[h].x*i.n14+G[h].y*i.n24+G[h].z*i.n34+G[h].w;
-if(e<=m)return false}return true}function o(e,i){e.list[e.count]=i;e.count+=1}function l(e){var i,m,h=e.object,g=e.opaque,t=e.transparent;t.count=0;e=g.count=0;for(i=h.materials.length;e<i;e++){m=h.materials[e];m.opacity&&m.opacity<1||m.blending!=THREE.NormalBlending?o(t,m):o(g,m)}}function n(e){var i,m,h,g,t=e.object,w=e.buffer,u=e.opaque,r=e.transparent;r.count=0;e=u.count=0;for(h=t.materials.length;e<h;e++){i=t.materials[e];if(i instanceof THREE.MeshFaceMaterial){i=0;for(m=w.materials.length;i<
-m;i++)if(g=w.materials[i])g.opacity&&g.opacity<1||g.blending!=THREE.NormalBlending?o(r,g):o(u,g)}else{g=i;g.opacity&&g.opacity<1||g.blending!=THREE.NormalBlending?o(r,g):o(u,g)}}}function z(e){var i,m,h,g=e.children;i=0;for(m=g.length;i<m;i++){h=g[i];h.autoUpdateMatrix&&h.updateMatrix();h.matrixWorld.multiply(e.matrixWorld,h.matrix);z(h)}}function y(e,i){var m,h,g=i.children;m=0;for(h=g.length;m<h;m++){child=g[m];v(e,child,false);y(e,child)}}function v(e,i,m){var h,g,t;g=i.geometry;if(e.__webGLObjectsMap[i.id]==
-undefined){e.__webGLObjectsMap[i.id]={};i._modelViewMatrix=new THREE.Matrix4;i._normalMatrixArray=new Float32Array(9);i._modelViewMatrixArray=new Float32Array(16);i._objectMatrixArray=new Float32Array(16);i.matrix.flattenToArray(i._objectMatrixArray)}t=e.__webGLObjectsMap[i.id];objlist=e.__webGLObjects;if(i instanceof THREE.Mesh){for(h in g.geometryChunks){e=g.geometryChunks[h];if(!e.__webGLVertexBuffer){var w=e;w.__webGLVertexBuffer=b.createBuffer();w.__webGLNormalBuffer=b.createBuffer();w.__webGLTangentBuffer=
-b.createBuffer();w.__webGLColorBuffer=b.createBuffer();w.__webGLUVBuffer=b.createBuffer();w.__webGLUV2Buffer=b.createBuffer();w.__webGLFaceBuffer=b.createBuffer();w.__webGLLineBuffer=b.createBuffer();w=e;var u=i,r=void 0,p=void 0,B=0,V=0,da=0,ea=u.geometry.faces,ia=w.faces;r=0;for(p=ia.length;r<p;r++){fi=ia[r];face=ea[fi];if(face instanceof THREE.Face3){B+=3;V+=1;da+=3}else if(face instanceof THREE.Face4){B+=4;V+=2;da+=4}}w.__vertexArray=new Float32Array(B*3);w.__normalArray=new Float32Array(B*3);
-w.__tangentArray=new Float32Array(B*4);w.__colorArray=new Float32Array(B*3);w.__uvArray=new Float32Array(B*2);w.__uv2Array=new Float32Array(B*2);w.__faceArray=new Uint16Array(V*3);w.__lineArray=new Uint16Array(da*2);p=r=w;u=u;B=void 0;ea=void 0;var S=void 0,Y=void 0;S=void 0;ia=false;B=0;for(ea=u.materials.length;B<ea;B++){S=u.materials[B];if(S instanceof THREE.MeshFaceMaterial){S=0;for(Y=p.materials.length;S<Y;S++)if(p.materials[S]&&p.materials[S].shading!=undefined&&p.materials[S].shading==THREE.SmoothShading){ia=
-true;break}}else if(S&&S.shading!=undefined&&S.shading==THREE.SmoothShading){ia=true;break}if(ia)break}r.__needsSmoothNormals=ia;w.__webGLFaceCount=V*3;w.__webGLLineCount=da*2;g.__dirtyVertices=true;g.__dirtyElements=true;g.__dirtyUvs=true;g.__dirtyNormals=true;g.__dirtyTangents=true;g.__dirtyColors=true}if(g.__dirtyVertices||g.__dirtyElements||g.__dirtyUvs||g.__dirtyNormals||g.__dirtyColors||g.__dirtyTangents){w=e;V=b.DYNAMIC_DRAW;da=void 0;r=void 0;var pa=void 0,P=void 0,ka=void 0,oa=void 0,wa=
-void 0;pa=void 0;var fa=void 0,W=void 0,ba=void 0,Ca=void 0;fa=void 0;W=void 0;ba=void 0;P=void 0;fa=void 0;W=void 0;ba=void 0;Ca=void 0;P=void 0;oa=void 0;ka=void 0;wa=void 0;var qa=Y=S=ia=ea=B=u=p=0,la=0,na=w.__vertexArray,Ja=w.__uvArray,Da=w.__uv2Array,va=w.__normalArray,ga=w.__tangentArray,ma=w.__colorArray,Aa=w.__faceArray,ta=w.__lineArray,La=w.__needsSmoothNormals,ua=i.geometry,Ma=ua.__dirtyVertices,ja=ua.__dirtyElements,ya=ua.__dirtyUvs,Fa=ua.__dirtyNormals,Ka=ua.__dirtyTangents,Na=ua.__dirtyColors,
-sa=ua.vertices,A=w.faces,Z=ua.faces,T=ua.uvs,E=ua.uvs2,L=ua.colors;da=0;for(r=A.length;da<r;da++){pa=A[da];P=Z[pa];wa=T[pa];pa=E[pa];ka=P.vertexNormals;oa=P.normal;if(P instanceof THREE.Face3){if(Ma){fa=sa[P.a].position;W=sa[P.b].position;ba=sa[P.c].position;na[u]=fa.x;na[u+1]=fa.y;na[u+2]=fa.z;na[u+3]=W.x;na[u+4]=W.y;na[u+5]=W.z;na[u+6]=ba.x;na[u+7]=ba.y;na[u+8]=ba.z;u+=9}if(Na&&L.length){fa=L[P.a];W=L[P.b];ba=L[P.c];ma[la]=fa.r;ma[la+1]=fa.g;ma[la+2]=fa.b;ma[la+3]=W.r;ma[la+4]=W.g;ma[la+5]=W.b;
-ma[la+6]=ba.r;ma[la+7]=ba.g;ma[la+8]=ba.b;la+=9}if(Ka&&ua.hasTangents){fa=sa[P.a].tangent;W=sa[P.b].tangent;ba=sa[P.c].tangent;ga[Y]=fa.x;ga[Y+1]=fa.y;ga[Y+2]=fa.z;ga[Y+3]=fa.w;ga[Y+4]=W.x;ga[Y+5]=W.y;ga[Y+6]=W.z;ga[Y+7]=W.w;ga[Y+8]=ba.x;ga[Y+9]=ba.y;ga[Y+10]=ba.z;ga[Y+11]=ba.w;Y+=12}if(Fa)if(ka.length==3&&La)for(P=0;P<3;P++){oa=ka[P];va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}else for(P=0;P<3;P++){va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}if(ya&&wa)for(P=0;P<3;P++){ka=wa[P];Ja[B]=ka.u;Ja[B+1]=ka.v;
-B+=2}if(ya&&pa)for(P=0;P<3;P++){wa=pa[P];Da[ea]=wa.u;Da[ea+1]=wa.v;ea+=2}if(ja){Aa[ia]=p;Aa[ia+1]=p+1;Aa[ia+2]=p+2;ia+=3;ta[qa]=p;ta[qa+1]=p+1;ta[qa+2]=p;ta[qa+3]=p+2;ta[qa+4]=p+1;ta[qa+5]=p+2;qa+=6;p+=3}}else if(P instanceof THREE.Face4){if(Ma){fa=sa[P.a].position;W=sa[P.b].position;ba=sa[P.c].position;Ca=sa[P.d].position;na[u]=fa.x;na[u+1]=fa.y;na[u+2]=fa.z;na[u+3]=W.x;na[u+4]=W.y;na[u+5]=W.z;na[u+6]=ba.x;na[u+7]=ba.y;na[u+8]=ba.z;na[u+9]=Ca.x;na[u+10]=Ca.y;na[u+11]=Ca.z;u+=12}if(Na&&L.length){fa=
-L[P.a];W=L[P.b];ba=L[P.c];Ca=L[P.d];ma[la]=fa.r;ma[la+1]=fa.g;ma[la+2]=fa.b;ma[la+3]=W.r;ma[la+4]=W.g;ma[la+5]=W.b;ma[la+6]=ba.r;ma[la+7]=ba.g;ma[la+8]=ba.b;ma[la+9]=Ca.r;ma[la+10]=Ca.g;ma[la+11]=Ca.b;la+=12}if(Ka&&ua.hasTangents){fa=sa[P.a].tangent;W=sa[P.b].tangent;ba=sa[P.c].tangent;P=sa[P.d].tangent;ga[Y]=fa.x;ga[Y+1]=fa.y;ga[Y+2]=fa.z;ga[Y+3]=fa.w;ga[Y+4]=W.x;ga[Y+5]=W.y;ga[Y+6]=W.z;ga[Y+7]=W.w;ga[Y+8]=ba.x;ga[Y+9]=ba.y;ga[Y+10]=ba.z;ga[Y+11]=ba.w;ga[Y+12]=P.x;ga[Y+13]=P.y;ga[Y+14]=P.z;ga[Y+
-15]=P.w;Y+=16}if(Fa)if(ka.length==4&&La)for(P=0;P<4;P++){oa=ka[P];va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}else for(P=0;P<4;P++){va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}if(ya&&wa)for(P=0;P<4;P++){ka=wa[P];Ja[B]=ka.u;Ja[B+1]=ka.v;B+=2}if(ya&&pa)for(P=0;P<4;P++){wa=pa[P];Da[ea]=wa.u;Da[ea+1]=wa.v;ea+=2}if(ja){Aa[ia]=p;Aa[ia+1]=p+1;Aa[ia+2]=p+2;Aa[ia+3]=p;Aa[ia+4]=p+2;Aa[ia+5]=p+3;ia+=6;ta[qa]=p;ta[qa+1]=p+1;ta[qa+2]=p;ta[qa+3]=p+3;ta[qa+4]=p+1;ta[qa+5]=p+2;ta[qa+6]=p+2;ta[qa+7]=p+3;qa+=8;p+=4}}}if(Ma){b.bindBuffer(b.ARRAY_BUFFER,
-w.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,na,V)}if(Na&&L.length){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,ma,V)}if(Fa){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,va,V)}if(Ka&&ua.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,ga,V)}if(ya&&B>0){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,Ja,V)}if(ya&&ea>0){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLUV2Buffer);
-b.bufferData(b.ARRAY_BUFFER,Da,V)}if(ja){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Aa,V);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,w.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ta,V)}}x(objlist,t,h,e,i,m)}g.__dirtyVertices=false;g.__dirtyElements=false;g.__dirtyUvs=false;g.__dirtyNormals=false;g.__dirtyTangents=false;g.__dirtyColors=false}else if(i instanceof THREE.Line){if(!g.__webGLVertexBuffer){g.__webGLVertexBuffer=b.createBuffer();g.__webGLColorBuffer=
-b.createBuffer();h=g.vertices.length;g.__vertexArray=new Float32Array(h*3);g.__colorArray=new Float32Array(h*3);g.__webGLLineCount=h;g.__dirtyVertices=true;g.__dirtyColors=true}if(g.__dirtyVertices||g.__dirtyColors){h=b.DYNAMIC_DRAW;u=g.vertices;w=g.colors;B=u.length;V=w.length;ea=g.__vertexArray;da=g.__colorArray;ia=g.__dirtyColors;if(g.__dirtyVertices){for(r=0;r<B;r++){p=u[r].position;e=r*3;ea[e]=p.x;ea[e+1]=p.y;ea[e+2]=p.z}b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,
-ea,h)}if(ia){for(r=0;r<V;r++){color=w[r];e=r*3;da[e]=color.r;da[e+1]=color.g;da[e+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,da,h)}}x(objlist,t,0,g,i,m);g.__dirtyVertices=false;g.__dirtyColors=false}else if(i instanceof THREE.ParticleSystem){if(!g.__webGLVertexBuffer){g.__webGLVertexBuffer=b.createBuffer();g.__webGLColorBuffer=b.createBuffer();h=g.vertices.length;g.__vertexArray=new Float32Array(h*3);g.__colorArray=new Float32Array(h*3);g.__sortArray=
-[];g.__webGLParticleCount=h;g.__dirtyVertices=true;g.__dirtyColors=true}if(g.__dirtyVertices||g.__dirtyColors||i.sortParticles)c(g,b.DYNAMIC_DRAW,i,camera);x(objlist,t,0,g,i,m);g.__dirtyVertices=false;g.__dirtyColors=false}else if(i instanceof THREE.MarchingCubes)if(t[0]==undefined){e.__webGLObjectsImmediate.push({object:i,opaque:{list:[],count:0},transparent:{list:[],count:0},root:m});t[0]=1}}function x(e,i,m,h,g,t){if(i[m]==undefined){e.push({buffer:h,object:g,opaque:{list:[],count:0},transparent:{list:[],
-count:0},root:t});i[m]=1}}function F(e,i){e._modelViewMatrix.multiplyToArray(i.matrix,e.matrixWorld,e._modelViewMatrixArray);e._normalMatrix=THREE.Matrix4.makeInvert3x3(e._modelViewMatrix).transposeIntoArray(e._normalMatrixArray)}function H(e){if(e!=X){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;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);
-break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}X=e}}function I(e,i){if(e&&!e.__webGLFramebuffer){e.__webGLFramebuffer=b.createFramebuffer();e.__webGLRenderbuffer=b.createRenderbuffer();e.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,e.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,e.width,e.height);b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,O(e.wrap_s));b.texParameteri(b.TEXTURE_2D,
-b.TEXTURE_WRAP_T,O(e.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,O(e.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,O(e.min_filter));b.texImage2D(b.TEXTURE_2D,0,O(e.format),e.width,e.height,0,O(e.format),O(e.type),null);b.bindFramebuffer(b.FRAMEBUFFER,e.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,e.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,e.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,
-null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}var m,h,g;if(e){m=e.__webGLFramebuffer;h=e.width;g=e.height}else{m=null;h=C.width;g=C.height}if(m!=$){b.bindFramebuffer(b.FRAMEBUFFER,m);b.viewport(0,0,h,g);i&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);$=m}}function s(e,i){var m;if(e=="fragment")m=b.createShader(b.FRAGMENT_SHADER);else if(e=="vertex")m=b.createShader(b.VERTEX_SHADER);b.shaderSource(m,i);b.compileShader(m);if(!b.getShaderParameter(m,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(m));
-return null}return m}function O(e){switch(e){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;
-case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}
-var C=document.createElement("canvas"),b,R=null,$=null,Q=null,J=null,X=null,G=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],U=new THREE.Matrix4,M=new Float32Array(16),D=new Float32Array(16),K=new THREE.Vector4,ca=true,N=new THREE.Color(0),aa=0;if(a){if(a.antialias!==undefined)ca=a.antialias;a.clearColor!==undefined&&N.setHex(a.clearColor);if(a.clearAlpha!==undefined)aa=a.clearAlpha}this.domElement=C;this.autoClear=true;(function(e,i,
-m){try{b=C.getContext("experimental-webgl",{antialias:e})}catch(h){console.log(h)}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(i.r,i.g,i.b,m);_cullEnabled=true})(ca,N,aa);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},
-point:{length:0,colors:[],positions:[]}};this.setSize=function(e,i){C.width=e;C.height=i;b.viewport(0,0,C.width,C.height)};this.setClearColorHex=function(e,i){var m=new THREE.Color(e);b.clearColor(m.r,m.g,m.b,i)};this.setClearColor=function(e,i){b.clearColor(e.r,e.g,e.b,i)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(e,i){var m,h,g,t=0,w=0,u=0,r,p,B,V=this.lights,da=V.directional.colors,ea=V.directional.positions,ia=V.point.colors,S=V.point.positions,
-Y=0,pa=0;m=g=g=0;for(h=i.length;m<h;m++){g=i[m];r=g.color;p=g.position;B=g.intensity;if(g instanceof THREE.AmbientLight){t+=r.r;w+=r.g;u+=r.b}else if(g instanceof THREE.DirectionalLight){g=Y*3;da[g]=r.r*B;da[g+1]=r.g*B;da[g+2]=r.b*B;ea[g]=p.x;ea[g+1]=p.y;ea[g+2]=p.z;Y+=1}else if(g instanceof THREE.PointLight){g=pa*3;ia[g]=r.r*B;ia[g+1]=r.g*B;ia[g+2]=r.b*B;S[g]=p.x;S[g+1]=p.y;S[g+2]=p.z;pa+=1}}for(m=Y*3;m<da.length;m++)da[m]=0;for(m=pa*3;m<ia.length;m++)ia[m]=0;V.point.length=pa;V.directional.length=
-Y;V.ambient[0]=t;V.ambient[1]=w;V.ambient[2]=u};this.initMaterial=function(e,i,m){var h,g;if(e instanceof THREE.MeshDepthMaterial)d(e,THREE.ShaderLib.depth);else if(e instanceof THREE.MeshNormalMaterial)d(e,THREE.ShaderLib.normal);else if(e instanceof THREE.MeshBasicMaterial)d(e,THREE.ShaderLib.basic);else if(e instanceof THREE.MeshLambertMaterial)d(e,THREE.ShaderLib.lambert);else if(e instanceof THREE.MeshPhongMaterial)d(e,THREE.ShaderLib.phong);else if(e instanceof THREE.LineBasicMaterial)d(e,THREE.ShaderLib.basic);
-else e instanceof THREE.ParticleBasicMaterial&&d(e,THREE.ShaderLib.particle_basic);var t,w,u,r;g=u=r=0;for(t=i.length;g<t;g++){w=i[g];w instanceof THREE.DirectionalLight&&u++;w instanceof THREE.PointLight&&r++}if(r+u<=4){i=u;r=r}else{i=Math.ceil(4*u/(r+u));r=4-i}g={directional:i,point:r};r=e.fragment_shader;i=e.vertex_shader;t={fog:m,map:e.map,env_map:e.env_map,light_map:e.light_map,vertex_colors:e.vertex_colors,maxDirLights:g.directional,maxPointLights:g.point};m=b.createProgram();g=["#ifdef GL_ES\nprecision highp float;\n#endif",
-"#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+t.maxPointLights,t.fog?"#define USE_FOG":"",t.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.env_map?"#define USE_ENVMAP":"",t.light_map?"#define USE_LIGHTMAP":"",t.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");t=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+
-t.maxPointLights,t.map?"#define USE_MAP":"",t.env_map?"#define USE_ENVMAP":"",t.light_map?"#define USE_LIGHTMAP":"",t.vertex_colors?"#define USE_COLOR":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(m,s("fragment",g+r));b.attachShader(m,
-s("vertex",t+i));b.linkProgram(m);b.getProgramParameter(m,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(m,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");m.uniforms={};m.attributes={};e.program=m;m=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(h in e.uniforms)m.push(h);h=e.program;r=0;for(i=m.length;r<i;r++){g=m[r];h.uniforms[g]=b.getUniformLocation(h,g)}e=e.program;h=["position","normal",
-"uv","uv2","tangent","color"];m=0;for(r=h.length;m<r;m++){i=h[m];e.attributes[i]=b.getAttribLocation(e,i)}};this.setProgram=function(e,i,m,h,g){h.program||this.initMaterial(h,i,m);var t=h.program,w=t.uniforms,u=h.uniforms;if(t!=R){b.useProgram(t);R=t;b.uniformMatrix4fv(w.projectionMatrix,false,M)}if(m&&(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial||h instanceof THREE.LineBasicMaterial||h instanceof THREE.ParticleBasicMaterial)){u.fogColor.value.setHex(m.color.hex);
-if(m instanceof THREE.Fog){u.fogNear.value=m.near;u.fogFar.value=m.far}else if(m instanceof THREE.FogExp2)u.fogDensity.value=m.density}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial){this.setupLights(t,i);i=this.lights;u.enableLighting.value=i.directional.length+i.point.length;u.ambientLightColor.value=i.ambient;u.directionalLightColor.value=i.directional.colors;u.directionalLightDirection.value=i.directional.positions;u.pointLightColor.value=i.point.colors;u.pointLightPosition.value=
-i.point.positions}if(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial){u.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);u.opacity.value=h.opacity;u.map.texture=h.map;u.light_map.texture=h.light_map;u.env_map.texture=h.env_map;u.reflectivity.value=h.reflectivity;u.refraction_ratio.value=h.refraction_ratio;u.combine.value=h.combine;u.useRefract.value=h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping}if(h instanceof
-THREE.LineBasicMaterial){u.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);u.opacity.value=h.opacity}else if(h instanceof THREE.ParticleBasicMaterial){u.psColor.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);u.opacity.value=h.opacity;u.size.value=h.size;u.map.texture=h.map}else if(h instanceof THREE.MeshPhongMaterial){u.ambient.value.setRGB(h.ambient.r,h.ambient.g,h.ambient.b);u.specular.value.setRGB(h.specular.r,h.specular.g,h.specular.b);
-u.shininess.value=h.shininess}else if(h instanceof THREE.MeshDepthMaterial){u.mNear.value=e.near;u.mFar.value=e.far;u.opacity.value=h.opacity}else if(h instanceof THREE.MeshNormalMaterial)u.opacity.value=h.opacity;var r,p,B;for(r in u)if(B=t.uniforms[r]){m=u[r];p=m.type;i=m.value;if(p=="i")b.uniform1i(B,i);else if(p=="f")b.uniform1f(B,i);else if(p=="fv1")b.uniform1fv(B,i);else if(p=="fv")b.uniform3fv(B,i);else if(p=="v2")b.uniform2f(B,i.x,i.y);else if(p=="v3")b.uniform3f(B,i.x,i.y,i.z);else if(p==
-"c")b.uniform3f(B,i.r,i.g,i.b);else if(p=="t"){b.uniform1i(B,i);if(m=m.texture)if(m.image instanceof Array&&m.image.length==6){m=m;i=i;if(m.image.length==6){if(!m.image.__webGLTextureCube&&!m.image.__cubeMapInitialized&&m.image.loadCount==6){m.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,m.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(p=0;p<6;++p)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,m.image[p]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);m.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube)}}else{m=m;i=i;if(!m.__webGLTexture&&m.image.loaded){m.__webGLTexture=b.createTexture();
-b.bindTexture(b.TEXTURE_2D,m.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,m.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,O(m.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,O(m.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,O(m.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,O(m.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_2D,m.__webGLTexture)}}}b.uniformMatrix4fv(w.modelViewMatrix,
-false,g._modelViewMatrixArray);b.uniformMatrix3fv(w.normalMatrix,false,g._normalMatrixArray);if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshPhongMaterial||h.env_map)b.uniform3f(w.cameraPosition,e.position.x,e.position.y,e.position.z);if(h instanceof THREE.MeshShaderMaterial||h.env_map)b.uniformMatrix4fv(w.objectMatrix,false,g._objectMatrixArray);if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshShaderMaterial)b.uniformMatrix4fv(w.viewMatrix,
-false,D);return t};this.renderBuffer=function(e,i,m,h,g,t){e=this.setProgram(e,i,m,h,t).attributes;b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.vertexAttribPointer(e.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.position);if(e.color>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.vertexAttribPointer(e.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.color)}if(e.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.vertexAttribPointer(e.normal,3,b.FLOAT,
-false,0,0);b.enableVertexAttribArray(e.normal)}if(e.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLTangentBuffer);b.vertexAttribPointer(e.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.tangent)}if(e.uv>=0)if(g.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.vertexAttribPointer(e.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.uv)}else b.disableVertexAttribArray(e.uv);if(e.uv2>=0)if(g.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUV2Buffer);b.vertexAttribPointer(e.uv2,
-2,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.uv2)}else b.disableVertexAttribArray(e.uv2);if(t instanceof THREE.Mesh)if(h.wireframe){b.lineWidth(h.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.drawElements(b.LINES,g.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,g.__webGLFaceCount,b.UNSIGNED_SHORT,0)}else if(t instanceof THREE.Line){t=t.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(h.linewidth);
-b.drawArrays(t,0,g.__webGLLineCount)}else t instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,g.__webGLParticleCount)};this.render=function(e,i,m,h){var g,t,w,u,r,p,B,V=e.lights,da=e.fog;i.autoUpdateMatrix&&i.updateMatrix();i.matrix.flattenToArray(D);i.projectionMatrix.flattenToArray(M);U.multiply(i.projectionMatrix,i.matrix);k(U);this.initWebGLObjects(e,i);I(m,h!==undefined?h:true);this.autoClear&&this.clear();u=e.__webGLObjects.length;for(h=0;h<u;h++){g=e.__webGLObjects[h];p=g.object;if(p.visible){if(g.root){p.autoUpdateMatrix&&
-p.updateMatrix();p.matrixWorld.copy(p.matrix);z(p)}if(!(p instanceof THREE.Mesh)||q(p)){p.matrixWorld.flattenToArray(p._objectMatrixArray);F(p,i);n(g);g.render=true}else g.render=false}else g.render=false}r=e.__webGLObjectsImmediate.length;for(h=0;h<r;h++){g=e.__webGLObjectsImmediate[h];p=g.object;if(p.visible){if(p.autoUpdateMatrix){p.updateMatrix();p.matrixWorld.copy(p.matrix);p.matrixWorld.flattenToArray(p._objectMatrixArray)}F(p,i);l(g)}}H(THREE.NormalBlending);for(h=0;h<u;h++){g=e.__webGLObjects[h];
-if(g.render){p=g.object;B=g.buffer;w=g.opaque;j(p);for(g=0;g<w.count;g++){material=w.list[g];this.setDepthTest(material.depth_test);this.renderBuffer(i,V,da,material,B,p)}}}for(h=0;h<r;h++){g=e.__webGLObjectsImmediate[h];p=g.object;if(p.visible){w=g.opaque;j(p);for(g=0;g<w.count;g++){material=w.list[g];this.setDepthTest(material.depth_test);t=this.setProgram(i,V,da,material,p);p.render(function(ea){f(ea,t)})}}}for(h=0;h<u;h++){g=e.__webGLObjects[h];if(g.render){p=g.object;B=g.buffer;w=g.transparent;
-j(p);for(g=0;g<w.count;g++){material=w.list[g];H(material.blending);this.setDepthTest(material.depth_test);this.renderBuffer(i,V,da,material,B,p)}}}for(h=0;h<r;h++){g=e.__webGLObjectsImmediate[h];p=g.object;if(p.visible){w=g.transparent;j(p);for(g=0;g<w.count;g++){material=w.list[g];H(material.blending);this.setDepthTest(material.depth_test);t=this.setProgram(i,V,da,material,p);p.render(function(ea){f(ea,t)})}}}if(m&&m.min_filter!==THREE.NearestFilter&&m.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,
-m.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(e){var i,m,h;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={};e.__webGLObjectsImmediate=[]}i=0;for(m=e.objects.length;i<m;i++){h=e.objects[i];v(e,h,true);y(e,h)}};this.removeObject=function(e,i){var m,h;for(m=e.__webGLObjects.length-1;m>=0;m--){h=e.__webGLObjects[m].object;i==h&&e.__webGLObjects.splice(m,1)}};this.setDepthTest=function(e){e?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};
-this.setFaceCulling=function(e,i){if(e){!i||i=="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)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
-THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
-envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",
-envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
-map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",
-lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
+THREE.SVGRenderer=function(){function a(ca,d,j){var o,h,f,w;o=0;for(h=ca.lights.length;o<h;o++){f=ca.lights[o];if(f instanceof THREE.DirectionalLight){w=d.normalWorld.dot(f.position)*f.intensity;if(w>0){j.r+=f.color.r*w;j.g+=f.color.g*w;j.b+=f.color.b*w}}else if(f instanceof THREE.PointLight){W.sub(f.position,d.centroidWorld);W.normalize();w=d.normalWorld.dot(W)*f.intensity;if(w>0){j.r+=f.color.r*w;j.g+=f.color.g*w;j.b+=f.color.b*w}}}}function c(ca,d,j,o,h,f){C=g(L++);C.setAttribute("d","M "+ca.positionScreen.x+
+" "+ca.positionScreen.y+" L "+d.positionScreen.x+" "+d.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+"z");if(h instanceof THREE.MeshBasicMaterial)B.__styleString=h.color.__styleString;else if(h instanceof THREE.MeshLambertMaterial)if(S){I.r=b.r;I.g=b.g;I.b=b.b;a(f,o,I);B.r=h.color.r*I.r;B.g=h.color.g*I.g;B.b=h.color.b*I.b;B.updateStyleString()}else B.__styleString=h.color.__styleString;else if(h instanceof THREE.MeshDepthMaterial){J=1-h.__2near/(h.__farPlusNear-o.z*h.__farMinusNear);
+B.setRGB(J,J,J)}else h instanceof THREE.MeshNormalMaterial&&B.setRGB(i(o.normalWorld.x),i(o.normalWorld.y),i(o.normalWorld.z));h.wireframe?C.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+h.wireframe_linewidth+"; stroke-opacity: "+h.opacity+"; stroke-linecap: "+h.wireframe_linecap+"; stroke-linejoin: "+h.wireframe_linejoin):C.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+h.opacity);p.appendChild(C)}function e(ca,d,j,o,h,f,w){C=g(L++);C.setAttribute("d",
+"M "+ca.positionScreen.x+" "+ca.positionScreen.y+" L "+d.positionScreen.x+" "+d.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+" L "+o.positionScreen.x+","+o.positionScreen.y+"z");if(f instanceof THREE.MeshBasicMaterial)B.__styleString=f.color.__styleString;else if(f instanceof THREE.MeshLambertMaterial)if(S){I.r=b.r;I.g=b.g;I.b=b.b;a(w,h,I);B.r=f.color.r*I.r;B.g=f.color.g*I.g;B.b=f.color.b*I.b;B.updateStyleString()}else B.__styleString=f.color.__styleString;else if(f instanceof
+THREE.MeshDepthMaterial){J=1-f.__2near/(f.__farPlusNear-h.z*f.__farMinusNear);B.setRGB(J,J,J)}else f instanceof THREE.MeshNormalMaterial&&B.setRGB(i(h.normalWorld.x),i(h.normalWorld.y),i(h.normalWorld.z));f.wireframe?C.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+f.wireframe_linewidth+"; stroke-opacity: "+f.opacity+"; stroke-linecap: "+f.wireframe_linecap+"; stroke-linejoin: "+f.wireframe_linejoin):C.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+
+f.opacity);p.appendChild(C)}function g(ca){if(M[ca]==null){M[ca]=document.createElementNS("http://www.w3.org/2000/svg","path");da==0&&M[ca].setAttribute("shape-rendering","crispEdges");return M[ca]}return M[ca]}function i(ca){return ca<0?Math.min((1+ca)*0.5,0.5):0.5+Math.min(ca*0.5,0.5)}var k=null,q=new THREE.Projector,p=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,n,y,z,t,x,D,H,G=new THREE.Rectangle,r=new THREE.Rectangle,S=false,B=new THREE.Color(16777215),I=new THREE.Color(16777215),
+b=new THREE.Color(0),aa=new THREE.Color(0),P=new THREE.Color(0),J,W=new THREE.Vector3,M=[],R=[],K=[],C,L,ba,N,da=1;this.domElement=p;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(ca){switch(ca){case "high":da=1;break;case "low":da=0}};this.setSize=function(ca,d){l=ca;n=d;y=l/2;z=n/2;p.setAttribute("viewBox",-y+" "+-z+" "+l+" "+n);p.setAttribute("width",l);p.setAttribute("height",n);G.set(-y,-z,y,z)};this.clear=function(){for(;p.childNodes.length>0;)p.removeChild(p.childNodes[0])};
+this.render=function(ca,d){var j,o,h,f,w,u,m,v;this.autoClear&&this.clear();k=q.projectScene(ca,d,this.sortElements);N=ba=L=0;if(S=ca.lights.length>0){m=ca.lights;b.setRGB(0,0,0);aa.setRGB(0,0,0);P.setRGB(0,0,0);j=0;for(o=m.length;j<o;j++){h=m[j];f=h.color;if(h instanceof THREE.AmbientLight){b.r+=f.r;b.g+=f.g;b.b+=f.b}else if(h instanceof THREE.DirectionalLight){aa.r+=f.r;aa.g+=f.g;aa.b+=f.b}else if(h instanceof THREE.PointLight){P.r+=f.r;P.g+=f.g;P.b+=f.b}}}j=0;for(o=k.length;j<o;j++){m=k[j];r.empty();
+if(m instanceof THREE.RenderableParticle){t=m;t.x*=y;t.y*=-z;h=0;for(f=m.materials.length;h<f;h++)if(v=m.materials[h]){w=t;u=m;v=v;var s=ba++;if(R[s]==null){R[s]=document.createElementNS("http://www.w3.org/2000/svg","circle");da==0&&R[s].setAttribute("shape-rendering","crispEdges")}C=R[s];C.setAttribute("cx",w.x);C.setAttribute("cy",w.y);C.setAttribute("r",u.scale.x*y);if(v instanceof THREE.ParticleCircleMaterial){if(S){I.r=b.r+aa.r+P.r;I.g=b.g+aa.g+P.g;I.b=b.b+aa.b+P.b;B.r=v.color.r*I.r;B.g=v.color.g*
+I.g;B.b=v.color.b*I.b;B.updateStyleString()}else B=v.color;C.setAttribute("style","fill: "+B.__styleString)}p.appendChild(C)}}else if(m instanceof THREE.RenderableLine){t=m.v1;x=m.v2;t.positionScreen.x*=y;t.positionScreen.y*=-z;x.positionScreen.x*=y;x.positionScreen.y*=-z;r.addPoint(t.positionScreen.x,t.positionScreen.y);r.addPoint(x.positionScreen.x,x.positionScreen.y);if(G.instersects(r)){h=0;for(f=m.materials.length;h<f;)if(v=m.materials[h++]){w=t;u=x;v=v;s=N++;if(K[s]==null){K[s]=document.createElementNS("http://www.w3.org/2000/svg",
+"line");da==0&&K[s].setAttribute("shape-rendering","crispEdges")}C=K[s];C.setAttribute("x1",w.positionScreen.x);C.setAttribute("y1",w.positionScreen.y);C.setAttribute("x2",u.positionScreen.x);C.setAttribute("y2",u.positionScreen.y);if(v instanceof THREE.LineBasicMaterial){B.__styleString=v.color.__styleString;C.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+v.linewidth+"; stroke-opacity: "+v.opacity+"; stroke-linecap: "+v.linecap+"; stroke-linejoin: "+v.linejoin);p.appendChild(C)}}}}else if(m instanceof
+THREE.RenderableFace3){t=m.v1;x=m.v2;D=m.v3;t.positionScreen.x*=y;t.positionScreen.y*=-z;x.positionScreen.x*=y;x.positionScreen.y*=-z;D.positionScreen.x*=y;D.positionScreen.y*=-z;r.addPoint(t.positionScreen.x,t.positionScreen.y);r.addPoint(x.positionScreen.x,x.positionScreen.y);r.addPoint(D.positionScreen.x,D.positionScreen.y);if(G.instersects(r)){h=0;for(f=m.meshMaterials.length;h<f;){v=m.meshMaterials[h++];if(v instanceof THREE.MeshFaceMaterial){w=0;for(u=m.faceMaterials.length;w<u;)(v=m.faceMaterials[w++])&&
+c(t,x,D,m,v,ca)}else v&&c(t,x,D,m,v,ca)}}}else if(m instanceof THREE.RenderableFace4){t=m.v1;x=m.v2;D=m.v3;H=m.v4;t.positionScreen.x*=y;t.positionScreen.y*=-z;x.positionScreen.x*=y;x.positionScreen.y*=-z;D.positionScreen.x*=y;D.positionScreen.y*=-z;H.positionScreen.x*=y;H.positionScreen.y*=-z;r.addPoint(t.positionScreen.x,t.positionScreen.y);r.addPoint(x.positionScreen.x,x.positionScreen.y);r.addPoint(D.positionScreen.x,D.positionScreen.y);r.addPoint(H.positionScreen.x,H.positionScreen.y);if(G.instersects(r)){h=
+0;for(f=m.meshMaterials.length;h<f;){v=m.meshMaterials[h++];if(v instanceof THREE.MeshFaceMaterial){w=0;for(u=m.faceMaterials.length;w<u;)(v=m.faceMaterials[w++])&&e(t,x,D,H,m,v,ca)}else v&&e(t,x,D,H,m,v,ca)}}}}}};
+THREE.WebGLRenderer=function(a){function c(d,j,o){var h,f,w,u=d.vertices,m=u.length,v=d.colors,s=v.length,O=d.__vertexArray,Y=d.__colorArray,ga=d.__sortArray,ia=d.__dirtyVertices,U=d.__dirtyColors;if(o.sortParticles){K.multiplySelf(o.matrixWorld);for(h=0;h<m;h++){f=u[h].position;ba.copy(f);K.multiplyVector3(ba);ga[h]=[ba.z,h]}ga.sort(function(ea,Z){return Z[0]-ea[0]});for(h=0;h<m;h++){f=u[ga[h][1]].position;w=h*3;O[w]=f.x;O[w+1]=f.y;O[w+2]=f.z}for(h=0;h<s;h++){w=h*3;color=v[ga[h][1]];Y[w]=color.r;
+Y[w+1]=color.g;Y[w+2]=color.b}}else{if(ia)for(h=0;h<m;h++){f=u[h].position;w=h*3;O[w]=f.x;O[w+1]=f.y;O[w+2]=f.z}if(U)for(h=0;h<s;h++){color=v[h];w=h*3;Y[w]=color.r;Y[w+1]=color.g;Y[w+2]=color.b}}if(ia||o.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,O,j)}if(U||o.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,Y,j)}}function e(d,j){d.fragment_shader=j.fragment_shader;d.vertex_shader=j.vertex_shader;d.uniforms=
+Uniforms.clone(j.uniforms)}function g(d,j){if(!d.__webGLVertexBuffer)d.__webGLVertexBuffer=b.createBuffer();if(!d.__webGLNormalBuffer)d.__webGLNormalBuffer=b.createBuffer();if(d.hasPos){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,d.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(j.attributes.position);b.vertexAttribPointer(j.attributes.position,3,b.FLOAT,false,0,0)}if(d.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,
+d.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(j.attributes.normal);b.vertexAttribPointer(j.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,d.count);d.count=0}function i(d){if(J!=d.doubleSided){d.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);J=d.doubleSided}if(W!=d.flipSided){d.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);W=d.flipSided}}function k(d){R[0].set(d.n41-d.n11,d.n42-d.n12,d.n43-d.n13,d.n44-d.n14);R[1].set(d.n41+d.n11,d.n42+d.n12,d.n43+d.n13,d.n44+
+d.n14);R[2].set(d.n41+d.n21,d.n42+d.n22,d.n43+d.n23,d.n44+d.n24);R[3].set(d.n41-d.n21,d.n42-d.n22,d.n43-d.n23,d.n44-d.n24);R[4].set(d.n41-d.n31,d.n42-d.n32,d.n43-d.n33,d.n44-d.n34);R[5].set(d.n41+d.n31,d.n42+d.n32,d.n43+d.n33,d.n44+d.n34);var j;for(d=0;d<5;d++){j=R[d];j.divideScalar(Math.sqrt(j.x*j.x+j.y*j.y+j.z*j.z))}}function q(d){for(var j=d.matrix,o=-d.geometry.boundingSphere.radius*Math.max(d.scale.x,Math.max(d.scale.y,d.scale.z)),h=0;h<6;h++){d=R[h].x*j.n14+R[h].y*j.n24+R[h].z*j.n34+R[h].w;
+if(d<=o)return false}return true}function p(d,j){d.list[d.count]=j;d.count+=1}function l(d){var j,o,h=d.object,f=d.opaque,w=d.transparent;w.count=0;d=f.count=0;for(j=h.materials.length;d<j;d++){o=h.materials[d];o.opacity&&o.opacity<1||o.blending!=THREE.NormalBlending?p(w,o):p(f,o)}}function n(d){var j,o,h,f,w=d.object,u=d.buffer,m=d.opaque,v=d.transparent;v.count=0;d=m.count=0;for(h=w.materials.length;d<h;d++){j=w.materials[d];if(j instanceof THREE.MeshFaceMaterial){j=0;for(o=u.materials.length;j<
+o;j++)if(f=u.materials[j])f.opacity&&f.opacity<1||f.blending!=THREE.NormalBlending?p(v,f):p(m,f)}else{f=j;f.opacity&&f.opacity<1||f.blending!=THREE.NormalBlending?p(v,f):p(m,f)}}}function y(d){var j,o,h,f=d.children;j=0;for(o=f.length;j<o;j++){h=f[j];h.autoUpdateMatrix&&h.updateMatrix();h.matrixWorld.multiply(d.matrixWorld,h.matrix);y(h)}}function z(d,j){return j.z-d.z}function t(d,j){var o,h,f=j.children;o=0;for(h=f.length;o<h;o++){child=f[o];x(d,child,false);t(d,child)}}function x(d,j,o){var h,
+f,w;f=j.geometry;if(d.__webGLObjectsMap[j.id]==undefined){d.__webGLObjectsMap[j.id]={};j._modelViewMatrix=new THREE.Matrix4;j._normalMatrixArray=new Float32Array(9);j._modelViewMatrixArray=new Float32Array(16);j._objectMatrixArray=new Float32Array(16);j.matrix.flattenToArray(j._objectMatrixArray)}w=d.__webGLObjectsMap[j.id];objlist=d.__webGLObjects;if(j instanceof THREE.Mesh){for(h in f.geometryChunks){d=f.geometryChunks[h];if(!d.__webGLVertexBuffer){var u=d;u.__webGLVertexBuffer=b.createBuffer();
+u.__webGLNormalBuffer=b.createBuffer();u.__webGLTangentBuffer=b.createBuffer();u.__webGLColorBuffer=b.createBuffer();u.__webGLUVBuffer=b.createBuffer();u.__webGLUV2Buffer=b.createBuffer();u.__webGLFaceBuffer=b.createBuffer();u.__webGLLineBuffer=b.createBuffer();u=d;var m=j,v=void 0,s=void 0,O=0,Y=0,ga=0,ia=m.geometry.faces,U=u.faces;v=0;for(s=U.length;v<s;v++){fi=U[v];face=ia[fi];if(face instanceof THREE.Face3){O+=3;Y+=1;ga+=3}else if(face instanceof THREE.Face4){O+=4;Y+=2;ga+=4}}u.__vertexArray=
+new Float32Array(O*3);u.__normalArray=new Float32Array(O*3);u.__tangentArray=new Float32Array(O*4);u.__colorArray=new Float32Array(O*3);u.__uvArray=new Float32Array(O*2);u.__uv2Array=new Float32Array(O*2);u.__faceArray=new Uint16Array(Y*3);u.__lineArray=new Uint16Array(ga*2);s=v=u;m=m;O=void 0;ia=void 0;var ea=void 0,Z=void 0;ea=void 0;U=false;O=0;for(ia=m.materials.length;O<ia;O++){ea=m.materials[O];if(ea instanceof THREE.MeshFaceMaterial){ea=0;for(Z=s.materials.length;ea<Z;ea++)if(s.materials[ea]&&
+s.materials[ea].shading!=undefined&&s.materials[ea].shading==THREE.SmoothShading){U=true;break}}else if(ea&&ea.shading!=undefined&&ea.shading==THREE.SmoothShading){U=true;break}if(U)break}v.__needsSmoothNormals=U;u.__webGLFaceCount=Y*3;u.__webGLLineCount=ga*2;f.__dirtyVertices=true;f.__dirtyElements=true;f.__dirtyUvs=true;f.__dirtyNormals=true;f.__dirtyTangents=true;f.__dirtyColors=true}if(f.__dirtyVertices||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents){u=
+d;Y=b.DYNAMIC_DRAW;ga=void 0;v=void 0;var qa=void 0,F=void 0,ua=void 0,oa=void 0,ra=void 0;qa=void 0;var V=void 0,fa=void 0,ja=void 0,za=void 0;V=void 0;fa=void 0;ja=void 0;F=void 0;V=void 0;fa=void 0;ja=void 0;za=void 0;F=void 0;oa=void 0;ua=void 0;ra=void 0;var va=Z=ea=U=ia=O=m=s=0,ma=0,na=u.__vertexArray,Ea=u.__uvArray,Fa=u.__uv2Array,sa=u.__normalArray,ha=u.__tangentArray,la=u.__colorArray,Aa=u.__faceArray,ta=u.__lineArray,La=u.__needsSmoothNormals,xa=j.geometry,ka=xa.__dirtyVertices,Ba=xa.__dirtyElements,
+Ca=xa.__dirtyUvs,Ma=xa.__dirtyNormals,Na=xa.__dirtyTangents,Ka=xa.__dirtyColors,A=xa.vertices,X=u.faces,T=xa.faces,E=xa.uvs,Q=xa.uvs2,$=xa.colors;ga=0;for(v=X.length;ga<v;ga++){qa=X[ga];F=T[qa];ra=E[qa];qa=Q[qa];ua=F.vertexNormals;oa=F.normal;if(F instanceof THREE.Face3){if(ka){V=A[F.a].position;fa=A[F.b].position;ja=A[F.c].position;na[m]=V.x;na[m+1]=V.y;na[m+2]=V.z;na[m+3]=fa.x;na[m+4]=fa.y;na[m+5]=fa.z;na[m+6]=ja.x;na[m+7]=ja.y;na[m+8]=ja.z;m+=9}if(Ka&&$.length){V=$[F.a];fa=$[F.b];ja=$[F.c];la[ma]=
+V.r;la[ma+1]=V.g;la[ma+2]=V.b;la[ma+3]=fa.r;la[ma+4]=fa.g;la[ma+5]=fa.b;la[ma+6]=ja.r;la[ma+7]=ja.g;la[ma+8]=ja.b;ma+=9}if(Na&&xa.hasTangents){V=A[F.a].tangent;fa=A[F.b].tangent;ja=A[F.c].tangent;ha[Z]=V.x;ha[Z+1]=V.y;ha[Z+2]=V.z;ha[Z+3]=V.w;ha[Z+4]=fa.x;ha[Z+5]=fa.y;ha[Z+6]=fa.z;ha[Z+7]=fa.w;ha[Z+8]=ja.x;ha[Z+9]=ja.y;ha[Z+10]=ja.z;ha[Z+11]=ja.w;Z+=12}if(Ma)if(ua.length==3&&La)for(F=0;F<3;F++){oa=ua[F];sa[ea]=oa.x;sa[ea+1]=oa.y;sa[ea+2]=oa.z;ea+=3}else for(F=0;F<3;F++){sa[ea]=oa.x;sa[ea+1]=oa.y;sa[ea+
+2]=oa.z;ea+=3}if(Ca&&ra)for(F=0;F<3;F++){ua=ra[F];Ea[O]=ua.u;Ea[O+1]=ua.v;O+=2}if(Ca&&qa)for(F=0;F<3;F++){ra=qa[F];Fa[ia]=ra.u;Fa[ia+1]=ra.v;ia+=2}if(Ba){Aa[U]=s;Aa[U+1]=s+1;Aa[U+2]=s+2;U+=3;ta[va]=s;ta[va+1]=s+1;ta[va+2]=s;ta[va+3]=s+2;ta[va+4]=s+1;ta[va+5]=s+2;va+=6;s+=3}}else if(F instanceof THREE.Face4){if(ka){V=A[F.a].position;fa=A[F.b].position;ja=A[F.c].position;za=A[F.d].position;na[m]=V.x;na[m+1]=V.y;na[m+2]=V.z;na[m+3]=fa.x;na[m+4]=fa.y;na[m+5]=fa.z;na[m+6]=ja.x;na[m+7]=ja.y;na[m+8]=ja.z;
+na[m+9]=za.x;na[m+10]=za.y;na[m+11]=za.z;m+=12}if(Ka&&$.length){V=$[F.a];fa=$[F.b];ja=$[F.c];za=$[F.d];la[ma]=V.r;la[ma+1]=V.g;la[ma+2]=V.b;la[ma+3]=fa.r;la[ma+4]=fa.g;la[ma+5]=fa.b;la[ma+6]=ja.r;la[ma+7]=ja.g;la[ma+8]=ja.b;la[ma+9]=za.r;la[ma+10]=za.g;la[ma+11]=za.b;ma+=12}if(Na&&xa.hasTangents){V=A[F.a].tangent;fa=A[F.b].tangent;ja=A[F.c].tangent;F=A[F.d].tangent;ha[Z]=V.x;ha[Z+1]=V.y;ha[Z+2]=V.z;ha[Z+3]=V.w;ha[Z+4]=fa.x;ha[Z+5]=fa.y;ha[Z+6]=fa.z;ha[Z+7]=fa.w;ha[Z+8]=ja.x;ha[Z+9]=ja.y;ha[Z+10]=
+ja.z;ha[Z+11]=ja.w;ha[Z+12]=F.x;ha[Z+13]=F.y;ha[Z+14]=F.z;ha[Z+15]=F.w;Z+=16}if(Ma)if(ua.length==4&&La)for(F=0;F<4;F++){oa=ua[F];sa[ea]=oa.x;sa[ea+1]=oa.y;sa[ea+2]=oa.z;ea+=3}else for(F=0;F<4;F++){sa[ea]=oa.x;sa[ea+1]=oa.y;sa[ea+2]=oa.z;ea+=3}if(Ca&&ra)for(F=0;F<4;F++){ua=ra[F];Ea[O]=ua.u;Ea[O+1]=ua.v;O+=2}if(Ca&&qa)for(F=0;F<4;F++){ra=qa[F];Fa[ia]=ra.u;Fa[ia+1]=ra.v;ia+=2}if(Ba){Aa[U]=s;Aa[U+1]=s+1;Aa[U+2]=s+2;Aa[U+3]=s;Aa[U+4]=s+2;Aa[U+5]=s+3;U+=6;ta[va]=s;ta[va+1]=s+1;ta[va+2]=s;ta[va+3]=s+3;ta[va+
+4]=s+1;ta[va+5]=s+2;ta[va+6]=s+2;ta[va+7]=s+3;va+=8;s+=4}}}if(ka){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,na,Y)}if(Ka&&$.length){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,la,Y)}if(Ma){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,sa,Y)}if(Na&&xa.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,ha,Y)}if(Ca&&O>0){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLUVBuffer);
+b.bufferData(b.ARRAY_BUFFER,Ea,Y)}if(Ca&&ia>0){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,Fa,Y)}if(Ba){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,u.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Aa,Y);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,u.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ta,Y)}}D(objlist,w,h,d,j,o)}f.__dirtyVertices=false;f.__dirtyElements=false;f.__dirtyUvs=false;f.__dirtyNormals=false;f.__dirtyTangents=false;f.__dirtyColors=false}else if(j instanceof
+THREE.Line){if(!f.__webGLVertexBuffer){f.__webGLVertexBuffer=b.createBuffer();f.__webGLColorBuffer=b.createBuffer();h=f.vertices.length;f.__vertexArray=new Float32Array(h*3);f.__colorArray=new Float32Array(h*3);f.__webGLLineCount=h;f.__dirtyVertices=true;f.__dirtyColors=true}if(f.__dirtyVertices||f.__dirtyColors){h=b.DYNAMIC_DRAW;m=f.vertices;u=f.colors;O=m.length;Y=u.length;ia=f.__vertexArray;ga=f.__colorArray;U=f.__dirtyColors;if(f.__dirtyVertices){for(v=0;v<O;v++){s=m[v].position;d=v*3;ia[d]=s.x;
+ia[d+1]=s.y;ia[d+2]=s.z}b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,ia,h)}if(U){for(v=0;v<Y;v++){color=u[v];d=v*3;ga[d]=color.r;ga[d+1]=color.g;ga[d+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,ga,h)}}D(objlist,w,0,f,j,o);f.__dirtyVertices=false;f.__dirtyColors=false}else if(j instanceof THREE.ParticleSystem){if(!f.__webGLVertexBuffer){f.__webGLVertexBuffer=b.createBuffer();f.__webGLColorBuffer=b.createBuffer();h=f.vertices.length;
+f.__vertexArray=new Float32Array(h*3);f.__colorArray=new Float32Array(h*3);f.__sortArray=[];f.__webGLParticleCount=h;f.__dirtyVertices=true;f.__dirtyColors=true}if(f.__dirtyVertices||f.__dirtyColors||j.sortParticles)c(f,b.DYNAMIC_DRAW,j,camera);D(objlist,w,0,f,j,o);f.__dirtyVertices=false;f.__dirtyColors=false}else if(j instanceof THREE.MarchingCubes)if(w[0]==undefined){d.__webGLObjectsImmediate.push({object:j,opaque:{list:[],count:0},transparent:{list:[],count:0},root:o});w[0]=1}}function D(d,j,
+o,h,f,w){if(j[o]==undefined){d.push({buffer:h,object:f,opaque:{list:[],count:0},transparent:{list:[],count:0},root:w});j[o]=1}}function H(d,j){d._modelViewMatrix.multiplyToArray(j.matrix,d.matrixWorld,d._modelViewMatrixArray);d._normalMatrix=THREE.Matrix4.makeInvert3x3(d._modelViewMatrix).transposeIntoArray(d._normalMatrixArray)}function G(d){if(d!=M){switch(d){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;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}M=d}}function r(d,j){if(d&&!d.__webGLFramebuffer){d.__webGLFramebuffer=b.createFramebuffer();d.__webGLRenderbuffer=b.createRenderbuffer();d.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,d.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,d.width,d.height);
+b.bindTexture(b.TEXTURE_2D,d.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,B(d.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,B(d.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,B(d.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,B(d.min_filter));b.texImage2D(b.TEXTURE_2D,0,B(d.format),d.width,d.height,0,B(d.format),B(d.type),null);b.bindFramebuffer(b.FRAMEBUFFER,d.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,
+d.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,d.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}var o,h,f;if(d){o=d.__webGLFramebuffer;h=d.width;f=d.height}else{o=null;h=I.width;f=I.height}if(o!=P){b.bindFramebuffer(b.FRAMEBUFFER,o);b.viewport(0,0,h,f);j&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);P=o}}function S(d,j){var o;if(d=="fragment")o=b.createShader(b.FRAGMENT_SHADER);
+else if(d=="vertex")o=b.createShader(b.VERTEX_SHADER);b.shaderSource(o,j);b.compileShader(o);if(!b.getShaderParameter(o,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(o));return null}return o}function B(d){switch(d){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;
+case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;
+case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var I=document.createElement("canvas"),b,aa=null,P=null,J=null,W=null,M=null,R=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],K=new THREE.Matrix4,C=new Float32Array(16),L=new Float32Array(16),ba=new THREE.Vector4,N=true,da=new THREE.Color(0),ca=0;if(a){if(a.antialias!==
+undefined)N=a.antialias;a.clearColor!==undefined&&da.setHex(a.clearColor);if(a.clearAlpha!==undefined)ca=a.clearAlpha}this.domElement=I;this.autoClear=true;(function(d,j,o){try{b=I.getContext("experimental-webgl",{antialias:d})}catch(h){console.log(h)}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(j.r,j.g,j.b,o);_cullEnabled=true})(N,da,ca);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(d,j){I.width=d;I.height=j;b.viewport(0,0,I.width,I.height)};this.setClearColorHex=function(d,j){var o=new THREE.Color(d);b.clearColor(o.r,o.g,o.b,j)};this.setClearColor=function(d,j){b.clearColor(d.r,d.g,d.b,j)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};
+this.setupLights=function(d,j){var o,h,f,w=0,u=0,m=0,v,s,O,Y=this.lights,ga=Y.directional.colors,ia=Y.directional.positions,U=Y.point.colors,ea=Y.point.positions,Z=0,qa=0;o=f=f=0;for(h=j.length;o<h;o++){f=j[o];v=f.color;s=f.position;O=f.intensity;if(f instanceof THREE.AmbientLight){w+=v.r;u+=v.g;m+=v.b}else if(f instanceof THREE.DirectionalLight){f=Z*3;ga[f]=v.r*O;ga[f+1]=v.g*O;ga[f+2]=v.b*O;ia[f]=s.x;ia[f+1]=s.y;ia[f+2]=s.z;Z+=1}else if(f instanceof THREE.PointLight){f=qa*3;U[f]=v.r*O;U[f+1]=v.g*
+O;U[f+2]=v.b*O;ea[f]=s.x;ea[f+1]=s.y;ea[f+2]=s.z;qa+=1}}for(o=Z*3;o<ga.length;o++)ga[o]=0;for(o=qa*3;o<U.length;o++)U[o]=0;Y.point.length=qa;Y.directional.length=Z;Y.ambient[0]=w;Y.ambient[1]=u;Y.ambient[2]=m};this.initMaterial=function(d,j,o){var h,f;if(d instanceof THREE.MeshDepthMaterial)e(d,THREE.ShaderLib.depth);else if(d instanceof THREE.MeshNormalMaterial)e(d,THREE.ShaderLib.normal);else if(d instanceof THREE.MeshBasicMaterial)e(d,THREE.ShaderLib.basic);else if(d instanceof THREE.MeshLambertMaterial)e(d,
+THREE.ShaderLib.lambert);else if(d instanceof THREE.MeshPhongMaterial)e(d,THREE.ShaderLib.phong);else if(d instanceof THREE.LineBasicMaterial)e(d,THREE.ShaderLib.basic);else d instanceof THREE.ParticleBasicMaterial&&e(d,THREE.ShaderLib.particle_basic);var w,u,m,v;f=m=v=0;for(w=j.length;f<w;f++){u=j[f];u instanceof THREE.DirectionalLight&&m++;u instanceof THREE.PointLight&&v++}if(v+m<=4){j=m;v=v}else{j=Math.ceil(4*m/(v+m));v=4-j}f={directional:j,point:v};v=d.fragment_shader;j=d.vertex_shader;w={fog:o,
+map:d.map,env_map:d.env_map,light_map:d.light_map,vertex_colors:d.vertex_colors,maxDirLights:f.directional,maxPointLights:f.point};o=b.createProgram();f=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+w.maxPointLights,w.fog?"#define USE_FOG":"",w.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",w.map?"#define USE_MAP":"",w.env_map?"#define USE_ENVMAP":"",w.light_map?"#define USE_LIGHTMAP":"",w.vertex_colors?"#define USE_COLOR":
+"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");w=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+w.maxPointLights,w.map?"#define USE_MAP":"",w.env_map?"#define USE_ENVMAP":"",w.light_map?"#define USE_LIGHTMAP":"",w.vertex_colors?"#define USE_COLOR":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");
+b.attachShader(o,S("fragment",f+v));b.attachShader(o,S("vertex",w+j));b.linkProgram(o);b.getProgramParameter(o,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(o,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");o.uniforms={};o.attributes={};d.program=o;o=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(h in d.uniforms)o.push(h);h=d.program;v=0;for(j=o.length;v<j;v++){f=o[v];h.uniforms[f]=b.getUniformLocation(h,
+f)}d=d.program;h=["position","normal","uv","uv2","tangent","color"];o=0;for(v=h.length;o<v;o++){j=h[o];d.attributes[j]=b.getAttribLocation(d,j)}};this.setProgram=function(d,j,o,h,f){h.program||this.initMaterial(h,j,o);var w=h.program,u=w.uniforms,m=h.uniforms;if(w!=aa){b.useProgram(w);aa=w;b.uniformMatrix4fv(u.projectionMatrix,false,C)}if(o&&(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial||h instanceof THREE.LineBasicMaterial||h instanceof
+THREE.ParticleBasicMaterial)){m.fogColor.value.setHex(o.color.hex);if(o instanceof THREE.Fog){m.fogNear.value=o.near;m.fogFar.value=o.far}else if(o instanceof THREE.FogExp2)m.fogDensity.value=o.density}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial){this.setupLights(w,j);j=this.lights;m.enableLighting.value=j.directional.length+j.point.length;m.ambientLightColor.value=j.ambient;m.directionalLightColor.value=j.directional.colors;m.directionalLightDirection.value=j.directional.positions;
+m.pointLightColor.value=j.point.colors;m.pointLightPosition.value=j.point.positions}if(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial){m.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);m.opacity.value=h.opacity;m.map.texture=h.map;m.light_map.texture=h.light_map;m.env_map.texture=h.env_map;m.reflectivity.value=h.reflectivity;m.refraction_ratio.value=h.refraction_ratio;m.combine.value=h.combine;m.useRefract.value=
+h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping}if(h instanceof THREE.LineBasicMaterial){m.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);m.opacity.value=h.opacity}else if(h instanceof THREE.ParticleBasicMaterial){m.psColor.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);m.opacity.value=h.opacity;m.size.value=h.size;m.map.texture=h.map}else if(h instanceof THREE.MeshPhongMaterial){m.ambient.value.setRGB(h.ambient.r,h.ambient.g,
+h.ambient.b);m.specular.value.setRGB(h.specular.r,h.specular.g,h.specular.b);m.shininess.value=h.shininess}else if(h instanceof THREE.MeshDepthMaterial){m.mNear.value=d.near;m.mFar.value=d.far;m.opacity.value=h.opacity}else if(h instanceof THREE.MeshNormalMaterial)m.opacity.value=h.opacity;var v,s,O;for(v in m)if(O=w.uniforms[v]){o=m[v];s=o.type;j=o.value;if(s=="i")b.uniform1i(O,j);else if(s=="f")b.uniform1f(O,j);else if(s=="fv1")b.uniform1fv(O,j);else if(s=="fv")b.uniform3fv(O,j);else if(s=="v2")b.uniform2f(O,
+j.x,j.y);else if(s=="v3")b.uniform3f(O,j.x,j.y,j.z);else if(s=="c")b.uniform3f(O,j.r,j.g,j.b);else if(s=="t"){b.uniform1i(O,j);if(o=o.texture)if(o.image instanceof Array&&o.image.length==6){o=o;j=j;if(o.image.length==6){if(!o.image.__webGLTextureCube&&!o.image.__cubeMapInitialized&&o.image.loadCount==6){o.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,o.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(s=0;s<6;++s)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,o.image[s]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);o.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+j);b.bindTexture(b.TEXTURE_CUBE_MAP,o.image.__webGLTextureCube)}}else{o=o;j=j;if(!o.__webGLTexture&&
+o.image.loaded){o.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,o.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,o.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,B(o.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,B(o.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,B(o.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,B(o.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+
+j);b.bindTexture(b.TEXTURE_2D,o.__webGLTexture)}}}b.uniformMatrix4fv(u.modelViewMatrix,false,f._modelViewMatrixArray);b.uniformMatrix3fv(u.normalMatrix,false,f._normalMatrixArray);if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshPhongMaterial||h.env_map)b.uniform3f(u.cameraPosition,d.position.x,d.position.y,d.position.z);if(h instanceof THREE.MeshShaderMaterial||h.env_map)b.uniformMatrix4fv(u.objectMatrix,false,f._objectMatrixArray);if(h instanceof THREE.MeshPhongMaterial||h instanceof
+THREE.MeshLambertMaterial||h instanceof THREE.MeshShaderMaterial)b.uniformMatrix4fv(u.viewMatrix,false,L);return w};this.renderBuffer=function(d,j,o,h,f,w){d=this.setProgram(d,j,o,h,w).attributes;b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.vertexAttribPointer(d.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.position);if(d.color>=0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.vertexAttribPointer(d.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.color)}if(d.normal>=
+0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLNormalBuffer);b.vertexAttribPointer(d.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.normal)}if(d.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLTangentBuffer);b.vertexAttribPointer(d.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.tangent)}if(d.uv>=0)if(f.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUVBuffer);b.vertexAttribPointer(d.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv)}else b.disableVertexAttribArray(d.uv);if(d.uv2>=
+0)if(f.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUV2Buffer);b.vertexAttribPointer(d.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv2)}else b.disableVertexAttribArray(d.uv2);if(w instanceof THREE.Mesh)if(h.wireframe){b.lineWidth(h.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.drawElements(b.LINES,f.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,f.__webGLFaceCount,b.UNSIGNED_SHORT,
+0)}else if(w instanceof THREE.Line){w=w.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(h.linewidth);b.drawArrays(w,0,f.__webGLLineCount)}else w instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,f.__webGLParticleCount)};this.render=function(d,j,o,h){var f,w,u,m,v,s,O,Y=d.lights,ga=d.fog;j.autoUpdateMatrix&&j.updateMatrix();j.matrix.flattenToArray(L);j.projectionMatrix.flattenToArray(C);K.multiply(j.projectionMatrix,j.matrix);k(K);this.initWebGLObjects(d,j);r(o,h!==undefined?h:true);
+this.autoClear&&this.clear();m=d.__webGLObjects.length;for(h=0;h<m;h++){f=d.__webGLObjects[h];s=f.object;if(s.visible){if(f.root){s.autoUpdateMatrix&&s.updateMatrix();s.matrixWorld.copy(s.matrix);y(s)}if(!(s instanceof THREE.Mesh)||q(s)){s.matrixWorld.flattenToArray(s._objectMatrixArray);H(s,j);n(f);f.render=true;ba.copy(s.position);K.multiplyVector3(ba);f.z=ba.z}else f.render=false}else f.render=false}d.__webGLObjects.sort(z);v=d.__webGLObjectsImmediate.length;for(h=0;h<v;h++){f=d.__webGLObjectsImmediate[h];
+s=f.object;if(s.visible){if(s.autoUpdateMatrix){s.updateMatrix();s.matrixWorld.copy(s.matrix);s.matrixWorld.flattenToArray(s._objectMatrixArray)}H(s,j);l(f)}}G(THREE.NormalBlending);for(h=0;h<m;h++){f=d.__webGLObjects[h];if(f.render){s=f.object;O=f.buffer;u=f.opaque;i(s);for(f=0;f<u.count;f++){material=u.list[f];this.setDepthTest(material.depth_test);this.renderBuffer(j,Y,ga,material,O,s)}}}for(h=0;h<v;h++){f=d.__webGLObjectsImmediate[h];s=f.object;if(s.visible){u=f.opaque;i(s);for(f=0;f<u.count;f++){material=
+u.list[f];this.setDepthTest(material.depth_test);w=this.setProgram(j,Y,ga,material,s);s.render(function(ia){g(ia,w)})}}}for(h=0;h<m;h++){f=d.__webGLObjects[h];if(f.render){s=f.object;O=f.buffer;u=f.transparent;i(s);for(f=0;f<u.count;f++){material=u.list[f];G(material.blending);this.setDepthTest(material.depth_test);this.renderBuffer(j,Y,ga,material,O,s)}}}for(h=0;h<v;h++){f=d.__webGLObjectsImmediate[h];s=f.object;if(s.visible){u=f.transparent;i(s);for(f=0;f<u.count;f++){material=u.list[f];G(material.blending);
+this.setDepthTest(material.depth_test);w=this.setProgram(j,Y,ga,material,s);s.render(function(ia){g(ia,w)})}}}if(o&&o.min_filter!==THREE.NearestFilter&&o.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,o.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(d){var j,o,h;if(!d.__webGLObjects){d.__webGLObjects=[];d.__webGLObjectsMap={};d.__webGLObjectsImmediate=[]}j=0;for(o=d.objects.length;j<o;j++){h=d.objects[j];x(d,h,true);t(d,
+h)}};this.removeObject=function(d,j){var o,h;for(o=d.__webGLObjects.length-1;o>=0;o--){h=d.__webGLObjects[o].object;j==h&&d.__webGLObjects.splice(o,1)}};this.setDepthTest=function(d){d?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};this.setFaceCulling=function(d,j){if(d){!j||j=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(d=="back")b.cullFace(b.BACK);else d=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
+0}};
+THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
+envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
+map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",
+lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
 lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
 lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
 lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse  = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse  += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse  = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse  += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
 lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse  = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse  += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse  = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse  += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
 color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif"};
 color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif"};

+ 166 - 166
build/ThreeDebug.js

@@ -1,70 +1,70 @@
 // ThreeDebug.js r32 - http://github.com/mrdoob/three.js
 // ThreeDebug.js r32 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
 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()}},setHSV:function(a,c,d){var f,j,k,q,o,l;if(d==0)f=j=k=0;else{q=Math.floor(a*6);o=a*6-q;a=d*(1-c);l=d*(1-c*o);c=d*(1-c*(1-o));switch(q){case 1:f=l;j=d;k=a;break;case 2:f=a;j=d;k=c;break;case 3:f=a;j=l;k=d;break;case 4:f=c;j=a;k=d;break;case 5:f=d;j=a;k=l;break;case 6:case 0:f=d;j=c;k=a}}this.r=f;this.g=j;this.b=k;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
+THREE.Color.prototype={setRGB:function(a,c,e){this.r=a;this.g=c;this.b=e;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,e){var g,i,k,q,p,l;if(e==0)g=i=k=0;else{q=Math.floor(a*6);p=a*6-q;a=e*(1-c);l=e*(1-c*p);c=e*(1-c*(1-p));switch(q){case 1:g=l;i=e;k=a;break;case 2:g=a;i=e;k=c;break;case 3:g=a;i=l;k=e;break;case 4:g=c;i=a;k=e;break;case 5:g=e;i=a;k=l;break;case 6:case 0:g=e;i=c;k=a}}this.r=g;this.g=i;this.b=k;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)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+
 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)+")"},clone:function(){return new THREE.Color(this.hex)},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};
 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*
 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,f=this.z;this.x=d*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.z;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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
-a.z;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)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,e){this.x=a||0;this.y=c||0;this.z=e||0};
+THREE.Vector3.prototype={set:function(a,c,e){this.x=a;this.y=c;this.z=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
+cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,e=this.y,g=this.z;this.x=e*a.z-g*a.y;this.y=g*a.x-c*a.z;this.z=c*a.y-e*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.z;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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
+a.z;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var c=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+e*e+a*a)},distanceToSquared:function(a){var c=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return c*c+e*e+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=
 -this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};
 -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,f){this.x=a||0;this.y=c||0;this.z=d||0;this.w=f||1};
-THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;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,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;
+THREE.Vector4=function(a,c,e,g){this.x=a||0;this.y=c||0;this.z=e||0;this.w=g||1};
+THREE.Vector4.prototype={set:function(a,c,e,g){this.x=a;this.y=c;this.z=e;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+")"}};
 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=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var c,d,f=a.objects,j=[];a=0;for(c=f.length;a<c;a++){d=f[a];if(d instanceof THREE.Mesh)j=j.concat(this.intersectObject(d))}j.sort(function(k,q){return k.distance-q.distance});return j},intersectObject:function(a){function c(I,s,O,C){C=C.clone().subSelf(s);O=O.clone().subSelf(s);var b=I.clone().subSelf(s);I=C.dot(C);s=C.dot(O);C=C.dot(b);var R=O.dot(O);O=O.dot(b);b=1/(I*R-s*s);R=(R*C-s*O)*b;I=(I*O-s*C)*b;return R>0&&I>0&&R+I<1}var d,f,j,k,q,o,l,m,z,y,
-v,x=a.geometry,F=x.vertices,H=[];d=0;for(f=x.faces.length;d<f;d++){j=x.faces[d];y=this.origin.clone();v=this.direction.clone();k=a.matrix.multiplyVector3(F[j.a].position.clone());q=a.matrix.multiplyVector3(F[j.b].position.clone());o=a.matrix.multiplyVector3(F[j.c].position.clone());l=j instanceof THREE.Face4?a.matrix.multiplyVector3(F[j.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(j.normal.clone());z=v.dot(m);if(z<0){m=m.dot((new THREE.Vector3).sub(k,y))/z;y=y.addSelf(v.multiplyScalar(m));
-if(j instanceof THREE.Face3){if(c(y,k,q,o)){j={distance:this.origin.distanceTo(y),point:y,face:j,object:a};H.push(j)}}else if(j instanceof THREE.Face4)if(c(y,k,q,l)||c(y,q,o,l)){j={distance:this.origin.distanceTo(y),point:y,face:j,object:a};H.push(j)}}}return H}};
-THREE.Rectangle=function(){function a(){k=f-c;q=j-d}var c,d,f,j,k,q,o=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return k};this.getHeight=function(){return q};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return j};this.set=function(l,m,z,y){o=false;c=l;d=m;f=z;j=y;a()};this.addPoint=function(l,m){if(o){o=false;c=l;d=m;f=l;j=m}else{c=c<l?c:l;d=d<m?d:m;f=f>l?f:l;j=j>m?
-j:m}a()};this.add3Points=function(l,m,z,y,v,x){if(o){o=false;c=l<z?l<v?l:v:z<v?z:v;d=m<y?m<x?m:x:y<x?y:x;f=l>z?l>v?l:v:z>v?z:v;j=m>y?m>x?m:x:y>x?y:x}else{c=l<z?l<v?l<c?l:c:v<c?v:c:z<v?z<c?z:c:v<c?v:c;d=m<y?m<x?m<d?m:d:x<d?x:d:y<x?y<d?y:d:x<d?x:d;f=l>z?l>v?l>f?l:f:v>f?v:f:z>v?z>f?z:f:v>f?v:f;j=m>y?m>x?m>j?m:j:x>j?x:j:y>x?y>j?y:j:x>j?x:j}a()};this.addRectangle=function(l){if(o){o=false;c=l.getLeft();d=l.getTop();f=l.getRight();j=l.getBottom()}else{c=c<l.getLeft()?c:l.getLeft();d=d<l.getTop()?d:l.getTop();
-f=f>l.getRight()?f:l.getRight();j=j>l.getBottom()?j:l.getBottom()}a()};this.inflate=function(l){c-=l;d-=l;f+=l;j+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();d=d>l.getTop()?d:l.getTop();f=f<l.getRight()?f:l.getRight();j=j<l.getBottom()?j:l.getBottom();a()};this.instersects=function(l){return Math.min(f,l.getRight())-Math.max(c,l.getLeft())>=0&&Math.min(j,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){o=true;j=f=d=c=0;a()};this.isEmpty=function(){return o};this.toString=
-function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+j+", width: "+k+", height: "+q+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
-THREE.Matrix4=function(a,c,d,f,j,k,q,o,l,m,z,y,v,x,F,H){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=j||0;this.n22=k||1;this.n23=q||0;this.n24=o||0;this.n31=l||0;this.n32=m||0;this.n33=z||1;this.n34=y||0;this.n41=v||0;this.n42=x||0;this.n43=F||0;this.n44=H||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={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;return this},set:function(a,c,d,f,j,k,q,o,l,m,z,y,v,x,F,H){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=j;this.n22=k;this.n23=q;this.n24=o;this.n31=l;this.n32=m;this.n33=z;this.n34=y;this.n41=v;this.n42=x;this.n43=F;this.n44=H;return this},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;return this},lookAt:function(a,c,d){var f=THREE.Matrix4.__tmpVec1,j=THREE.Matrix4.__tmpVec2,k=THREE.Matrix4.__tmpVec3;k.sub(a,c).normalize();f.cross(d,k).normalize();j.cross(k,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);
-this.n31=k.x;this.n32=k.y;this.n33=k.z;this.n34=-k.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,j=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*j;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*j;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*j;return a},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,j=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*j;a.y=this.n21*c+this.n22*d+this.n23*
-f+this.n24*j;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*j;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*j;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,f=a.n12,j=a.n13,k=a.n14,q=a.n21,o=a.n22,l=a.n23,m=a.n24,z=a.n31,
-y=a.n32,v=a.n33,x=a.n34,F=a.n41,H=a.n42,I=a.n43,s=a.n44,O=c.n11,C=c.n12,b=c.n13,R=c.n14,$=c.n21,Q=c.n22,J=c.n23,X=c.n24,G=c.n31,U=c.n32,M=c.n33,D=c.n34,K=c.n41,ca=c.n42,N=c.n43,aa=c.n44;this.n11=d*O+f*$+j*G+k*K;this.n12=d*C+f*Q+j*U+k*ca;this.n13=d*b+f*J+j*M+k*N;this.n14=d*R+f*X+j*D+k*aa;this.n21=q*O+o*$+l*G+m*K;this.n22=q*C+o*Q+l*U+m*ca;this.n23=q*b+o*J+l*M+m*N;this.n24=q*R+o*X+l*D+m*aa;this.n31=z*O+y*$+v*G+x*K;this.n32=z*C+y*Q+v*U+x*ca;this.n33=z*b+y*J+v*M+x*N;this.n34=z*R+y*X+v*D+x*aa;this.n41=
-F*O+H*$+I*G+s*K;this.n42=F*C+H*Q+I*U+s*ca;this.n43=F*b+H*J+I*M+s*N;this.n44=F*R+H*X+I*D+s*aa;return this},multiplyToArray:function(a,c,d){var f=a.n11,j=a.n12,k=a.n13,q=a.n14,o=a.n21,l=a.n22,m=a.n23,z=a.n24,y=a.n31,v=a.n32,x=a.n33,F=a.n34,H=a.n41,I=a.n42,s=a.n43;a=a.n44;var O=c.n11,C=c.n12,b=c.n13,R=c.n14,$=c.n21,Q=c.n22,J=c.n23,X=c.n24,G=c.n31,U=c.n32,M=c.n33,D=c.n34,K=c.n41,ca=c.n42,N=c.n43;c=c.n44;this.n11=f*O+j*$+k*G+q*K;this.n12=f*C+j*Q+k*U+q*ca;this.n13=f*b+j*J+k*M+q*N;this.n14=f*R+j*X+k*D+q*
-c;this.n21=o*O+l*$+m*G+z*K;this.n22=o*C+l*Q+m*U+z*ca;this.n23=o*b+l*J+m*M+z*N;this.n24=o*R+l*X+m*D+z*c;this.n31=y*O+v*$+x*G+F*K;this.n32=y*C+v*Q+x*U+F*ca;this.n33=y*b+v*J+x*M+F*N;this.n34=y*R+v*X+x*D+F*c;this.n41=H*O+I*$+s*G+a*K;this.n42=H*C+I*Q+s*U+a*ca;this.n43=H*b+I*J+s*M+a*N;this.n44=H*R+I*X+s*D+a*c;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;
-d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,j=this.n14,k=this.n21,q=this.n22,o=this.n23,l=this.n24,m=this.n31,z=this.n32,y=this.n33,v=this.n34,x=this.n41,F=this.n42,H=this.n43,I=this.n44,s=a.n11,O=a.n21,C=a.n31,b=a.n41,R=a.n12,$=a.n22,Q=a.n32,J=a.n42,X=a.n13,G=a.n23,U=a.n33,M=a.n43,D=a.n14,K=a.n24,ca=a.n34;a=a.n44;this.n11=c*s+d*O+f*C+j*b;this.n12=c*R+d*$+f*Q+j*J;this.n13=c*X+d*G+f*U+j*M;this.n14=c*D+d*K+f*ca+j*a;this.n21=k*s+q*O+o*C+l*
-b;this.n22=k*R+q*$+o*Q+l*J;this.n23=k*X+q*G+o*U+l*M;this.n24=k*D+q*K+o*ca+l*a;this.n31=m*s+z*O+y*C+v*b;this.n32=m*R+z*$+y*Q+v*J;this.n33=m*X+z*G+y*U+v*M;this.n34=m*D+z*K+y*ca+v*a;this.n41=x*s+F*O+H*C+I*b;this.n42=x*R+F*$+H*Q+I*J;this.n43=x*X+F*G+H*U+I*M;this.n44=x*D+F*K+H*ca+I*a;return this},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;return this},determinant:function(){var a=this.n11,c=this.n12,d=this.n13,f=this.n14,j=this.n21,k=this.n22,q=this.n23,o=this.n24,l=this.n31,m=this.n32,z=this.n33,y=this.n34,v=this.n41,x=this.n42,F=this.n43,H=this.n44;return f*q*m*v-d*o*m*v-f*k*z*v+c*o*z*v+d*k*y*v-c*q*y*v-f*q*l*x+d*o*l*x+f*j*z*x-a*o*z*x-d*j*y*x+a*q*y*x+f*k*l*F-c*o*l*F-f*j*m*F+a*o*m*F+c*j*y*F-a*k*y*F-d*k*l*H+c*q*l*H+d*j*m*H-a*q*m*H-c*j*z*H+a*k*z*H},transpose:function(){function a(c,d,f){var j=c[d];c[d]=c[f];c[f]=j}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(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;
-a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,
-0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),f=Math.sin(c),j=1-d,k=a.x,q=a.y,
-o=a.z,l=j*k,m=j*q;this.set(l*k+d,l*q-f*o,l*o+f*q,0,l*q+f*o,m*q+d,m*o-f*k,0,l*o-f*q,m*o+f*k,j*o*o+d,0,0,0,0,1);return this},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 f=new THREE.Matrix4;f.setTranslation(a,c,d);return f};
-THREE.Matrix4.scaleMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setScale(a,c,d);return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
-THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,f=a.n13,j=a.n14,k=a.n21,q=a.n22,o=a.n23,l=a.n24,m=a.n31,z=a.n32,y=a.n33,v=a.n34,x=a.n41,F=a.n42,H=a.n43,I=a.n44,s=new THREE.Matrix4;s.n11=o*v*F-l*y*F+l*z*H-q*v*H-o*z*I+q*y*I;s.n12=j*y*F-f*v*F-j*z*H+d*v*H+f*z*I-d*y*I;s.n13=f*l*F-j*o*F+j*q*H-d*l*H-f*q*I+d*o*I;s.n14=j*o*z-f*l*z-j*q*y+d*l*y+f*q*v-d*o*v;s.n21=l*y*x-o*v*x-l*m*H+k*v*H+o*m*I-k*y*I;s.n22=f*v*x-j*y*x+j*m*H-c*v*H-f*m*I+c*y*I;s.n23=j*o*x-f*l*x-j*k*H+c*l*H+f*k*I-c*o*I;s.n24=f*l*m-j*o*m+
-j*k*y-c*l*y-f*k*v+c*o*v;s.n31=q*v*x-l*z*x+l*m*F-k*v*F-q*m*I+k*z*I;s.n32=j*z*x-d*v*x-j*m*F+c*v*F+d*m*I-c*z*I;s.n33=f*l*x-j*q*x+j*k*F-c*l*F-d*k*I+c*q*I;s.n34=j*q*m-d*l*m-j*k*z+c*l*z+d*k*v-c*q*v;s.n41=o*z*x-q*y*x-o*m*F+k*y*F+q*m*H-k*z*H;s.n42=d*y*x-f*z*x+f*m*F-c*y*F-d*m*H+c*z*H;s.n43=f*q*x-d*o*x-f*k*F+c*o*F+d*k*H-c*q*H;s.n44=d*o*m-f*q*m+f*k*z-c*o*z-d*k*y+c*q*y;s.multiplyScalar(1/a.determinant());return s};
-THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,d=c.m,f=a.n33*a.n22-a.n32*a.n23,j=-a.n33*a.n21+a.n31*a.n23,k=a.n32*a.n21-a.n31*a.n22,q=-a.n33*a.n12+a.n32*a.n13,o=a.n33*a.n11-a.n31*a.n13,l=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,z=-a.n23*a.n11+a.n21*a.n13,y=a.n22*a.n11-a.n21*a.n12;a=a.n11*f+a.n21*q+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*f;d[1]=a*j;d[2]=a*k;d[3]=a*q;d[4]=a*o;d[5]=a*l;d[6]=a*m;d[7]=a*z;d[8]=a*y;return c};
-THREE.Matrix4.makeFrustum=function(a,c,d,f,j,k){var q,o,l;q=new THREE.Matrix4;o=2*j/(c-a);l=2*j/(f-d);a=(c+a)/(c-a);d=(f+d)/(f-d);f=-(k+j)/(k-j);j=-2*k*j/(k-j);q.n11=o;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=d;q.n24=0;q.n31=0;q.n32=0;q.n33=f;q.n34=j;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,d,f){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*c,a*c,j,a,d,f)};
-THREE.Matrix4.makeOrtho=function(a,c,d,f,j,k){var q,o,l,m;q=new THREE.Matrix4;o=c-a;l=d-f;m=k-j;a=(c+a)/o;d=(d+f)/l;j=(k+j)/m;q.n11=2/o;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-d;q.n31=0;q.n32=0;q.n33=-2/m;q.n34=-j;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
+THREE.Ray.prototype={intersectScene:function(a){var c,e,g=a.objects,i=[];a=0;for(c=g.length;a<c;a++){e=g[a];if(e instanceof THREE.Mesh)i=i.concat(this.intersectObject(e))}i.sort(function(k,q){return k.distance-q.distance});return i},intersectObject:function(a){function c(G,r,S,B){B=B.clone().subSelf(r);S=S.clone().subSelf(r);var I=G.clone().subSelf(r);G=B.dot(B);r=B.dot(S);B=B.dot(I);var b=S.dot(S);S=S.dot(I);I=1/(G*b-r*r);b=(b*B-r*S)*I;G=(G*S-r*B)*I;return b>0&&G>0&&b+G<1}var e,g,i,k,q,p,l,m,z,A,
+t,y=a.geometry,D=y.vertices,H=[];e=0;for(g=y.faces.length;e<g;e++){i=y.faces[e];A=this.origin.clone();t=this.direction.clone();k=a.matrix.multiplyVector3(D[i.a].position.clone());q=a.matrix.multiplyVector3(D[i.b].position.clone());p=a.matrix.multiplyVector3(D[i.c].position.clone());l=i instanceof THREE.Face4?a.matrix.multiplyVector3(D[i.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(i.normal.clone());z=t.dot(m);if(z<0){m=m.dot((new THREE.Vector3).sub(k,A))/z;A=A.addSelf(t.multiplyScalar(m));
+if(i instanceof THREE.Face3){if(c(A,k,q,p)){i={distance:this.origin.distanceTo(A),point:A,face:i,object:a};H.push(i)}}else if(i instanceof THREE.Face4)if(c(A,k,q,l)||c(A,q,p,l)){i={distance:this.origin.distanceTo(A),point:A,face:i,object:a};H.push(i)}}}return H}};
+THREE.Rectangle=function(){function a(){k=g-c;q=i-e}var c,e,g,i,k,q,p=true;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return k};this.getHeight=function(){return q};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return g};this.getBottom=function(){return i};this.set=function(l,m,z,A){p=false;c=l;e=m;g=z;i=A;a()};this.addPoint=function(l,m){if(p){p=false;c=l;e=m;g=l;i=m}else{c=c<l?c:l;e=e<m?e:m;g=g>l?g:l;i=i>m?
+i:m}a()};this.add3Points=function(l,m,z,A,t,y){if(p){p=false;c=l<z?l<t?l:t:z<t?z:t;e=m<A?m<y?m:y:A<y?A:y;g=l>z?l>t?l:t:z>t?z:t;i=m>A?m>y?m:y:A>y?A:y}else{c=l<z?l<t?l<c?l:c:t<c?t:c:z<t?z<c?z:c:t<c?t:c;e=m<A?m<y?m<e?m:e:y<e?y:e:A<y?A<e?A:e:y<e?y:e;g=l>z?l>t?l>g?l:g:t>g?t:g:z>t?z>g?z:g:t>g?t:g;i=m>A?m>y?m>i?m:i:y>i?y:i:A>y?A>i?A:i:y>i?y:i}a()};this.addRectangle=function(l){if(p){p=false;c=l.getLeft();e=l.getTop();g=l.getRight();i=l.getBottom()}else{c=c<l.getLeft()?c:l.getLeft();e=e<l.getTop()?e:l.getTop();
+g=g>l.getRight()?g:l.getRight();i=i>l.getBottom()?i:l.getBottom()}a()};this.inflate=function(l){c-=l;e-=l;g+=l;i+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();e=e>l.getTop()?e:l.getTop();g=g<l.getRight()?g:l.getRight();i=i<l.getBottom()?i:l.getBottom();a()};this.instersects=function(l){return Math.min(g,l.getRight())-Math.max(c,l.getLeft())>=0&&Math.min(i,l.getBottom())-Math.max(e,l.getTop())>=0};this.empty=function(){p=true;i=g=e=c=0;a()};this.isEmpty=function(){return p};this.toString=
+function(){return"THREE.Rectangle ( left: "+c+", right: "+g+", top: "+e+", bottom: "+i+", width: "+k+", height: "+q+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
+THREE.Matrix4=function(a,c,e,g,i,k,q,p,l,m,z,A,t,y,D,H){this.n11=a||1;this.n12=c||0;this.n13=e||0;this.n14=g||0;this.n21=i||0;this.n22=k||1;this.n23=q||0;this.n24=p||0;this.n31=l||0;this.n32=m||0;this.n33=z||1;this.n34=A||0;this.n41=t||0;this.n42=y||0;this.n43=D||0;this.n44=H||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={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;return this},set:function(a,c,e,g,i,k,q,p,l,m,z,A,t,y,D,H){this.n11=a;this.n12=c;this.n13=e;this.n14=g;this.n21=i;this.n22=k;this.n23=q;this.n24=p;this.n31=l;this.n32=m;this.n33=z;this.n34=A;this.n41=t;this.n42=y;this.n43=D;this.n44=H;return this},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;return this},lookAt:function(a,c,e){var g=THREE.Matrix4.__tmpVec1,i=THREE.Matrix4.__tmpVec2,k=THREE.Matrix4.__tmpVec3;k.sub(a,c).normalize();g.cross(e,k).normalize();i.cross(k,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=k.x;this.n32=k.y;this.n33=k.z;this.n34=-k.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,e=a.y,g=a.z,i=1/(this.n41*c+this.n42*e+this.n43*g+this.n44);a.x=(this.n11*c+this.n12*e+this.n13*g+this.n14)*i;a.y=(this.n21*c+this.n22*e+this.n23*g+this.n24)*i;a.z=(this.n31*c+this.n32*e+this.n33*g+this.n34)*i;return a},multiplyVector4:function(a){var c=a.x,e=a.y,g=a.z,i=a.w;a.x=this.n11*c+this.n12*e+this.n13*g+this.n14*i;a.y=this.n21*c+this.n22*e+this.n23*
+g+this.n24*i;a.z=this.n31*c+this.n32*e+this.n33*g+this.n34*i;a.w=this.n41*c+this.n42*e+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 e=a.n11,g=a.n12,i=a.n13,k=a.n14,q=a.n21,p=a.n22,l=a.n23,m=a.n24,z=a.n31,
+A=a.n32,t=a.n33,y=a.n34,D=a.n41,H=a.n42,G=a.n43,r=a.n44,S=c.n11,B=c.n12,I=c.n13,b=c.n14,aa=c.n21,P=c.n22,J=c.n23,W=c.n24,M=c.n31,R=c.n32,K=c.n33,C=c.n34,L=c.n41,ba=c.n42,N=c.n43,da=c.n44;this.n11=e*S+g*aa+i*M+k*L;this.n12=e*B+g*P+i*R+k*ba;this.n13=e*I+g*J+i*K+k*N;this.n14=e*b+g*W+i*C+k*da;this.n21=q*S+p*aa+l*M+m*L;this.n22=q*B+p*P+l*R+m*ba;this.n23=q*I+p*J+l*K+m*N;this.n24=q*b+p*W+l*C+m*da;this.n31=z*S+A*aa+t*M+y*L;this.n32=z*B+A*P+t*R+y*ba;this.n33=z*I+A*J+t*K+y*N;this.n34=z*b+A*W+t*C+y*da;this.n41=
+D*S+H*aa+G*M+r*L;this.n42=D*B+H*P+G*R+r*ba;this.n43=D*I+H*J+G*K+r*N;this.n44=D*b+H*W+G*C+r*da;return this},multiplyToArray:function(a,c,e){var g=a.n11,i=a.n12,k=a.n13,q=a.n14,p=a.n21,l=a.n22,m=a.n23,z=a.n24,A=a.n31,t=a.n32,y=a.n33,D=a.n34,H=a.n41,G=a.n42,r=a.n43;a=a.n44;var S=c.n11,B=c.n12,I=c.n13,b=c.n14,aa=c.n21,P=c.n22,J=c.n23,W=c.n24,M=c.n31,R=c.n32,K=c.n33,C=c.n34,L=c.n41,ba=c.n42,N=c.n43;c=c.n44;this.n11=g*S+i*aa+k*M+q*L;this.n12=g*B+i*P+k*R+q*ba;this.n13=g*I+i*J+k*K+q*N;this.n14=g*b+i*W+k*
+C+q*c;this.n21=p*S+l*aa+m*M+z*L;this.n22=p*B+l*P+m*R+z*ba;this.n23=p*I+l*J+m*K+z*N;this.n24=p*b+l*W+m*C+z*c;this.n31=A*S+t*aa+y*M+D*L;this.n32=A*B+t*P+y*R+D*ba;this.n33=A*I+t*J+y*K+D*N;this.n34=A*b+t*W+y*C+D*c;this.n41=H*S+G*aa+r*M+a*L;this.n42=H*B+G*P+r*R+a*ba;this.n43=H*I+G*J+r*K+a*N;this.n44=H*b+G*W+r*C+a*c;e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=
+this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,e=this.n12,g=this.n13,i=this.n14,k=this.n21,q=this.n22,p=this.n23,l=this.n24,m=this.n31,z=this.n32,A=this.n33,t=this.n34,y=this.n41,D=this.n42,H=this.n43,G=this.n44,r=a.n11,S=a.n21,B=a.n31,I=a.n41,b=a.n12,aa=a.n22,P=a.n32,J=a.n42,W=a.n13,M=a.n23,R=a.n33,K=a.n43,C=a.n14,L=a.n24,ba=a.n34;a=a.n44;this.n11=c*r+e*S+g*B+i*I;this.n12=c*b+e*aa+g*P+i*J;this.n13=c*W+e*M+g*R+i*K;this.n14=c*C+e*L+g*ba+i*a;this.n21=k*r+
+q*S+p*B+l*I;this.n22=k*b+q*aa+p*P+l*J;this.n23=k*W+q*M+p*R+l*K;this.n24=k*C+q*L+p*ba+l*a;this.n31=m*r+z*S+A*B+t*I;this.n32=m*b+z*aa+A*P+t*J;this.n33=m*W+z*M+A*R+t*K;this.n34=m*C+z*L+A*ba+t*a;this.n41=y*r+D*S+H*B+G*I;this.n42=y*b+D*aa+H*P+G*J;this.n43=y*W+D*M+H*R+G*K;this.n44=y*C+D*L+H*ba+G*a;return this},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;return this},determinant:function(){var a=this.n11,c=this.n12,e=this.n13,g=this.n14,i=this.n21,k=this.n22,q=this.n23,p=this.n24,l=this.n31,m=this.n32,z=this.n33,A=this.n34,t=this.n41,y=this.n42,D=this.n43,H=this.n44;return g*q*m*t-e*p*m*t-g*k*z*t+c*p*z*t+e*k*A*t-c*q*A*t-g*q*l*y+e*p*l*y+g*i*z*y-a*p*z*y-e*i*A*y+a*q*A*y+g*k*l*D-c*p*l*D-g*i*m*D+a*p*m*D+c*i*A*D-a*k*A*D-e*k*l*H+c*q*l*H+e*i*m*H-a*q*m*H-c*i*z*H+a*k*z*H},transpose:function(){function a(c,e,g){var i=c[e];c[e]=c[g];c[g]=
+i}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;
+a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,e){this.set(1,
+0,0,a,0,1,0,c,0,0,1,e,0,0,0,1);return this},setScale:function(a,c,e){this.set(a,0,0,0,0,c,0,0,0,0,e,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var e=Math.cos(c),g=Math.sin(c),
+i=1-e,k=a.x,q=a.y,p=a.z,l=i*k,m=i*q;this.set(l*k+e,l*q-g*p,l*p+g*q,0,l*q+g*p,m*q+e,m*p-g*k,0,l*p-g*q,m*p+g*k,i*p*p+e,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,e){var g=new THREE.Matrix4;g.setTranslation(a,c,e);return g};
+THREE.Matrix4.scaleMatrix=function(a,c,e){var g=new THREE.Matrix4;g.setScale(a,c,e);return g};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var e=new THREE.Matrix4;e.setRotAxis(a,c);return e};
+THREE.Matrix4.makeInvert=function(a){var c=a.n11,e=a.n12,g=a.n13,i=a.n14,k=a.n21,q=a.n22,p=a.n23,l=a.n24,m=a.n31,z=a.n32,A=a.n33,t=a.n34,y=a.n41,D=a.n42,H=a.n43,G=a.n44,r=new THREE.Matrix4;r.n11=p*t*D-l*A*D+l*z*H-q*t*H-p*z*G+q*A*G;r.n12=i*A*D-g*t*D-i*z*H+e*t*H+g*z*G-e*A*G;r.n13=g*l*D-i*p*D+i*q*H-e*l*H-g*q*G+e*p*G;r.n14=i*p*z-g*l*z-i*q*A+e*l*A+g*q*t-e*p*t;r.n21=l*A*y-p*t*y-l*m*H+k*t*H+p*m*G-k*A*G;r.n22=g*t*y-i*A*y+i*m*H-c*t*H-g*m*G+c*A*G;r.n23=i*p*y-g*l*y-i*k*H+c*l*H+g*k*G-c*p*G;r.n24=g*l*m-i*p*m+
+i*k*A-c*l*A-g*k*t+c*p*t;r.n31=q*t*y-l*z*y+l*m*D-k*t*D-q*m*G+k*z*G;r.n32=i*z*y-e*t*y-i*m*D+c*t*D+e*m*G-c*z*G;r.n33=g*l*y-i*q*y+i*k*D-c*l*D-e*k*G+c*q*G;r.n34=i*q*m-e*l*m-i*k*z+c*l*z+e*k*t-c*q*t;r.n41=p*z*y-q*A*y-p*m*D+k*A*D+q*m*H-k*z*H;r.n42=e*A*y-g*z*y+g*m*D-c*A*D-e*m*H+c*z*H;r.n43=g*q*y-e*p*y-g*k*D+c*p*D+e*k*H-c*q*H;r.n44=e*p*m-g*q*m+g*k*z-c*p*z-e*k*A+c*q*A;r.multiplyScalar(1/a.determinant());return r};
+THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,e=c.m,g=a.n33*a.n22-a.n32*a.n23,i=-a.n33*a.n21+a.n31*a.n23,k=a.n32*a.n21-a.n31*a.n22,q=-a.n33*a.n12+a.n32*a.n13,p=a.n33*a.n11-a.n31*a.n13,l=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,z=-a.n23*a.n11+a.n21*a.n13,A=a.n22*a.n11-a.n21*a.n12;a=a.n11*g+a.n21*q+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;e[0]=a*g;e[1]=a*i;e[2]=a*k;e[3]=a*q;e[4]=a*p;e[5]=a*l;e[6]=a*m;e[7]=a*z;e[8]=a*A;return c};
+THREE.Matrix4.makeFrustum=function(a,c,e,g,i,k){var q,p,l;q=new THREE.Matrix4;p=2*i/(c-a);l=2*i/(g-e);a=(c+a)/(c-a);e=(g+e)/(g-e);g=-(k+i)/(k-i);i=-2*k*i/(k-i);q.n11=p;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=e;q.n24=0;q.n31=0;q.n32=0;q.n33=g;q.n34=i;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,e,g){var i;a=e*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*c,a*c,i,a,e,g)};
+THREE.Matrix4.makeOrtho=function(a,c,e,g,i,k){var q,p,l,m;q=new THREE.Matrix4;p=c-a;l=e-g;m=k-i;a=(c+a)/p;e=(e+g)/l;i=(k+i)/m;q.n11=2/p;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-e;q.n31=0;q.n32=0;q.n33=-2/m;q.n34=-i;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 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.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
 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.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
-THREE.Face3=function(a,c,d,f,j){this.a=a;this.b=c;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.materials=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
-THREE.Face4=function(a,c,d,f,j,k){this.a=a;this.b=c;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.materials=k instanceof Array?k:[k]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
-THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
-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);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
-d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,f,j,k,q,o=new THREE.Vector3,l=new THREE.Vector3;f=0;for(j=this.vertices.length;f<j;f++){k=this.vertices[f];k.normal.set(0,0,0)}f=0;for(j=this.faces.length;f<j;f++){k=this.faces[f];if(a&&k.vertexNormals.length){o.set(0,0,0);c=0;for(d=k.normal.length;c<d;c++)o.addSelf(k.vertexNormals[c]);o.divideScalar(3)}else{c=this.vertices[k.a];d=this.vertices[k.b];q=this.vertices[k.c];o.sub(q.position,
-d.position);l.sub(c.position,d.position);o.crossSelf(l)}o.isZero()||o.normalize();k.normal.copy(o)}},computeVertexNormals:function(){var a,c,d,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
-new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal);f[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
-c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c]);d.vertexNormals[3].copy(f[d.d])}}},computeTangents:function(){function a(D,K,ca,N,aa,e,i){k=D.vertices[K].position;q=D.vertices[ca].position;o=D.vertices[N].position;l=j[aa];m=j[e];z=j[i];y=q.x-k.x;v=o.x-k.x;x=q.y-k.y;F=o.y-
-k.y;H=q.z-k.z;I=o.z-k.z;s=m.u-l.u;O=z.u-l.u;C=m.v-l.v;b=z.v-l.v;R=1/(s*b-O*C);J.set((b*y-C*v)*R,(b*x-C*F)*R,(b*H-C*I)*R);X.set((s*v-O*y)*R,(s*F-O*x)*R,(s*I-O*H)*R);$[K].addSelf(J);$[ca].addSelf(J);$[N].addSelf(J);Q[K].addSelf(X);Q[ca].addSelf(X);Q[N].addSelf(X)}var c,d,f,j,k,q,o,l,m,z,y,v,x,F,H,I,s,O,C,b,R,$=[],Q=[],J=new THREE.Vector3,X=new THREE.Vector3,G=new THREE.Vector3,U=new THREE.Vector3,M=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){$[c]=new THREE.Vector3;Q[c]=new THREE.Vector3}c=
-0;for(d=this.faces.length;c<d;c++){f=this.faces[c];j=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
-this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){M.copy(this.vertices[c].normal);f=$[c];G.copy(f);G.subSelf(M.multiplyScalar(M.dot(f))).normalize();U.cross(this.vertices[c].normal,f);f=U.dot(Q[c]);f=f<0?-1:1;this.vertices[c].tangent.set(G.x,G.y,G.z,f)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={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 c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
-this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(z){var y=[];c=0;for(d=z.length;c<d;c++)z[c]==undefined?y.push("undefined"):y.push(z[c].toString());return y.join("_")}var c,d,f,j,k,q,o,l,m={};f=0;for(j=this.faces.length;f<j;f++){k=this.faces[f];
-q=k.materials;o=a(q);if(m[o]==undefined)m[o]={hash:o,counter:0};l=m[o].hash+"_"+m[o].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0};k=k instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+k>65535){m[o].counter+=1;l=m[o].hash+"_"+m[o].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(f);this.geometryChunks[l].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+
-this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
-THREE.Camera=function(a,c,d,f){this.fov=a;this.aspect=c;this.near=d;this.far=f;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(j){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
-this.translateZ=function(j){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
+THREE.Face3=function(a,c,e,g,i){this.a=a;this.b=c;this.c=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=i instanceof Array?i:[i]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
+THREE.Face4=function(a,c,e,g,i,k){this.a=a;this.b=c;this.c=e;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.materials=k instanceof Array?k:[k]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
+THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
+THREE.Geometry.prototype={computeCentroids:function(){var a,c,e;a=0;for(c=this.faces.length;a<c;a++){e=this.faces[a];e.centroid.set(0,0,0);if(e instanceof THREE.Face3){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);e.centroid.divideScalar(3)}else if(e instanceof THREE.Face4){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);
+e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,e,g,i,k,q,p=new THREE.Vector3,l=new THREE.Vector3;g=0;for(i=this.vertices.length;g<i;g++){k=this.vertices[g];k.normal.set(0,0,0)}g=0;for(i=this.faces.length;g<i;g++){k=this.faces[g];if(a&&k.vertexNormals.length){p.set(0,0,0);c=0;for(e=k.normal.length;c<e;c++)p.addSelf(k.vertexNormals[c]);p.divideScalar(3)}else{c=this.vertices[k.a];e=this.vertices[k.b];q=this.vertices[k.c];p.sub(q.position,
+e.position);l.sub(c.position,e.position);p.crossSelf(l)}p.isZero()||p.normalize();k.normal.copy(p)}},computeVertexNormals:function(){var a,c,e,g;if(this.__tmpVertices==undefined){g=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)g[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){e=this.faces[a];if(e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,
+new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{g=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)g[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){e=this.faces[a];if(e instanceof THREE.Face3){g[e.a].addSelf(e.normal);g[e.b].addSelf(e.normal);g[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){g[e.a].addSelf(e.normal);g[e.b].addSelf(e.normal);g[e.c].addSelf(e.normal);g[e.d].addSelf(e.normal)}}a=0;for(c=this.vertices.length;a<c;a++)g[a].normalize();a=0;for(c=this.faces.length;a<
+c;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0].copy(g[e.a]);e.vertexNormals[1].copy(g[e.b]);e.vertexNormals[2].copy(g[e.c])}else if(e instanceof THREE.Face4){e.vertexNormals[0].copy(g[e.a]);e.vertexNormals[1].copy(g[e.b]);e.vertexNormals[2].copy(g[e.c]);e.vertexNormals[3].copy(g[e.d])}}},computeTangents:function(){function a(C,L,ba,N,da,ca,d){k=C.vertices[L].position;q=C.vertices[ba].position;p=C.vertices[N].position;l=i[da];m=i[ca];z=i[d];A=q.x-k.x;t=p.x-k.x;y=q.y-k.y;D=p.y-
+k.y;H=q.z-k.z;G=p.z-k.z;r=m.u-l.u;S=z.u-l.u;B=m.v-l.v;I=z.v-l.v;b=1/(r*I-S*B);J.set((I*A-B*t)*b,(I*y-B*D)*b,(I*H-B*G)*b);W.set((r*t-S*A)*b,(r*D-S*y)*b,(r*G-S*H)*b);aa[L].addSelf(J);aa[ba].addSelf(J);aa[N].addSelf(J);P[L].addSelf(W);P[ba].addSelf(W);P[N].addSelf(W)}var c,e,g,i,k,q,p,l,m,z,A,t,y,D,H,G,r,S,B,I,b,aa=[],P=[],J=new THREE.Vector3,W=new THREE.Vector3,M=new THREE.Vector3,R=new THREE.Vector3,K=new THREE.Vector3;c=0;for(e=this.vertices.length;c<e;c++){aa[c]=new THREE.Vector3;P[c]=new THREE.Vector3}c=
+0;for(e=this.faces.length;c<e;c++){g=this.faces[c];i=this.uvs[c];if(g instanceof THREE.Face3){a(this,g.a,g.b,g.c,0,1,2);this.vertices[g.a].normal.copy(g.vertexNormals[0]);this.vertices[g.b].normal.copy(g.vertexNormals[1]);this.vertices[g.c].normal.copy(g.vertexNormals[2])}else if(g instanceof THREE.Face4){a(this,g.a,g.b,g.c,0,1,2);a(this,g.a,g.b,g.d,0,1,3);this.vertices[g.a].normal.copy(g.vertexNormals[0]);this.vertices[g.b].normal.copy(g.vertexNormals[1]);this.vertices[g.c].normal.copy(g.vertexNormals[2]);
+this.vertices[g.d].normal.copy(g.vertexNormals[3])}}c=0;for(e=this.vertices.length;c<e;c++){K.copy(this.vertices[c].normal);g=aa[c];M.copy(g);M.subSelf(K.multiplyScalar(K.dot(g))).normalize();R.cross(this.vertices[c].normal,g);g=R.dot(P[c]);g=g<0?-1:1;this.vertices[c].tangent.set(M.x,M.y,M.z,g)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={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 c=1,e=this.vertices.length;c<e;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
+this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,e=this.vertices.length;c<e;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(z){var A=[];c=0;for(e=z.length;c<e;c++)z[c]==undefined?A.push("undefined"):A.push(z[c].toString());return A.join("_")}var c,e,g,i,k,q,p,l,m={};g=0;for(i=this.faces.length;g<i;g++){k=this.faces[g];
+q=k.materials;p=a(q);if(m[p]==undefined)m[p]={hash:p,counter:0};l=m[p].hash+"_"+m[p].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0};k=k instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+k>65535){m[p].counter+=1;l=m[p].hash+"_"+m[p].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(g);this.geometryChunks[l].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+
+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0;
+THREE.Camera=function(a,c,e,g){this.fov=a;this.aspect=c;this.near=e;this.far=g;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(i){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(i);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
+this.translateZ=function(i){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(i);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
 THREE.Camera.prototype={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.Camera.prototype={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.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
 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.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
 THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true;this.children=[]};
 THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true;this.children=[]};
-THREE.Object3D.prototype={addChild:function(a){this.children.indexOf(a)===-1&&this.children.push(a)},removeChild:function(a){a=this.children.indexOf(a);a!==-1&&this.children.splice(a,1)},updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,f=this.matrix,j=this.rotationMatrix,k=this.tmpMatrix;f.setTranslation(a.x,a.y,a.z);j.setRotX(c.x);c.y!=0&&j.multiplySelf(k.setRotY(c.y));c.z!=0&&j.multiplySelf(k.setRotZ(c.z));f.multiplySelf(j);if(d.x!=0||d.y!=0||d.z!=0)f.multiplySelf(k.setScale(d.x,
-d.y,d.z))}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
-THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
+THREE.Object3D.prototype={addChild:function(a){this.children.indexOf(a)===-1&&this.children.push(a)},removeChild:function(a){a=this.children.indexOf(a);a!==-1&&this.children.splice(a,1)},updateMatrix:function(){var a=this.position,c=this.rotation,e=this.scale,g=this.matrix,i=this.rotationMatrix,k=this.tmpMatrix;g.setTranslation(a.x,a.y,a.z);i.setRotX(c.x);c.y!=0&&i.multiplySelf(k.setRotY(c.y));c.z!=0&&i.multiplySelf(k.setRotZ(c.z));g.multiplySelf(i);if(e.x!=0||e.y!=0||e.z!=0)g.multiplySelf(k.setScale(e.x,
+e.y,e.z))}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
+THREE.Line=function(a,c,e){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=e!=undefined?e:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
 THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;
 THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;
 THREE.LineBasicMaterial=function(a){this.id=THREE.LineBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=false;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.depth_test!==undefined)this.depth_test=a.depth_test;if(a.linewidth!==undefined)this.linewidth=
 THREE.LineBasicMaterial=function(a){this.id=THREE.LineBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=false;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.depth_test!==undefined)this.depth_test=a.depth_test;if(a.linewidth!==undefined)this.linewidth=
 a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
 a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
@@ -96,121 +96,121 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM
 THREE.ParticleBasicMaterial=function(a){this.id=THREE.ParticleBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.offset=new THREE.Vector2;this.vertex_colors=false;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;
 THREE.ParticleBasicMaterial=function(a){this.id=THREE.ParticleBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.offset=new THREE.Vector2;this.vertex_colors=false;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;
 if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>size: "+this.size+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.ParticleBasicMaterialCounter={value:0};
 if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>size: "+this.size+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.ParticleBasicMaterialCounter={value:0};
 THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);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}};THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
 THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);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}};THREE.ParticleCircleMaterial.prototype={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};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,f,j,k){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=j!==undefined?j:THREE.LinearFilter;this.min_filter=k!==undefined?k:THREE.LinearMipMapLinearFilter};
+THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,e,g,i,k){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=g!==undefined?g:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=k!==undefined?k:THREE.LinearMipMapLinearFilter};
 THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},toString:function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;
 THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},toString:function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;
 THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
 THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
-THREE.RenderTarget=function(a,c,d){this.width=a;this.height=c;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType};
-var Uniforms={clone:function(a){var c,d,f,j={};for(c in a){j[c]={};for(d in a[c]){f=a[c][d];j[c][d]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return j},merge:function(a){var c,d,f,j={};for(c=0;c<a.length;c++){f=this.clone(a[c]);for(d in f)j[d]=f[d]}return j}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
+THREE.RenderTarget=function(a,c,e){this.width=a;this.height=c;e=e||{};this.wrap_s=e.wrap_s!==undefined?e.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=e.wrap_t!==undefined?e.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=e.mag_filter!==undefined?e.mag_filter:THREE.LinearFilter;this.min_filter=e.min_filter!==undefined?e.min_filter:THREE.LinearMipMapLinearFilter;this.format=e.format!==undefined?e.format:THREE.RGBFormat;this.type=e.type!==undefined?e.type:THREE.UnsignedByteType};
+var Uniforms={clone:function(a){var c,e,g,i={};for(c in a){i[c]={};for(e in a[c]){g=a[c][e];i[c][e]=g instanceof THREE.Color||g instanceof THREE.Vector3||g instanceof THREE.Texture?g.clone():g}}return i},merge:function(a){var c,e,g,i={};for(c=0;c<a.length;c++){g=this.clone(a[c]);for(e in g)i[e]=g[e]}return i}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&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.indexOf(a)===-1&&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.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&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.indexOf(a)===-1&&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.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
-THREE.Projector=function(){function a(Q,J){return J.z-Q.z}function c(Q,J){var X=0,G=1,U=Q.z+Q.w,M=J.z+J.w,D=-Q.z+Q.w,K=-J.z+J.w;if(U>=0&&M>=0&&D>=0&&K>=0)return true;else if(U<0&&M<0||D<0&&K<0)return false;else{if(U<0)X=Math.max(X,U/(U-M));else if(M<0)G=Math.min(G,U/(U-M));if(D<0)X=Math.max(X,D/(D-K));else if(K<0)G=Math.min(G,D/(D-K));if(G<X)return false;else{Q.lerpSelf(J,X);J.lerpSelf(Q,1-G);return true}}}var d,f,j=[],k,q,o,l=[],m,z,y=[],v,x,F=[],H=new THREE.Vector4,I=new THREE.Vector4,s=new THREE.Matrix4,
-O=new THREE.Matrix4,C=[],b=new THREE.Vector4,R=new THREE.Vector4,$;this.projectObjects=function(Q,J,X){var G=[],U,M;f=0;s.multiply(J.projectionMatrix,J.matrix);C[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);C[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);C[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);C[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);C[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
-s.n33,s.n44-s.n34);C[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);J=0;for(U=C.length;J<U;J++){M=C[J];M.divideScalar(Math.sqrt(M.x*M.x+M.y*M.y+M.z*M.z))}U=Q.objects;Q=0;for(J=U.length;Q<J;Q++){M=U[Q];var D;if(!(D=!M.visible)){if(D=M instanceof THREE.Mesh){a:{D=void 0;for(var K=M.position,ca=-M.geometry.boundingSphere.radius*Math.max(M.scale.x,Math.max(M.scale.y,M.scale.z)),N=0;N<6;N++){D=C[N].x*K.x+C[N].y*K.y+C[N].z*K.z+C[N].w;if(D<=ca){D=false;break a}}D=true}D=!D}D=D}if(!D){d=
-j[f]=j[f]||new THREE.RenderableObject;H.copy(M.position);s.multiplyVector3(H);d.object=M;d.z=H.z;G.push(d);f++}}X&&G.sort(a);return G};this.projectScene=function(Q,J,X){var G=[],U=J.near,M=J.far,D,K,ca,N,aa,e,i,n,h,g,t,w,u,r,p,B;o=z=x=0;J.autoUpdateMatrix&&J.updateMatrix();s.multiply(J.projectionMatrix,J.matrix);e=this.projectObjects(Q,J,true);Q=0;for(D=e.length;Q<D;Q++){i=e[Q].object;if(i.visible){i.autoUpdateMatrix&&i.updateMatrix();n=i.matrix;h=i.rotationMatrix;g=i.materials;t=i.overdraw;if(i instanceof
-THREE.Mesh){w=i.geometry;u=w.vertices;K=0;for(ca=u.length;K<ca;K++){r=u[K];r.positionWorld.copy(r.position);n.multiplyVector3(r.positionWorld);N=r.positionScreen;N.copy(r.positionWorld);s.multiplyVector4(N);N.x/=N.w;N.y/=N.w;r.__visible=N.z>U&&N.z<M}w=w.faces;K=0;for(ca=w.length;K<ca;K++){r=w[K];if(r instanceof THREE.Face3){N=u[r.a];aa=u[r.b];p=u[r.c];if(N.__visible&&aa.__visible&&p.__visible)if(i.doubleSided||i.flipSided!=(p.positionScreen.x-N.positionScreen.x)*(aa.positionScreen.y-N.positionScreen.y)-
-(p.positionScreen.y-N.positionScreen.y)*(aa.positionScreen.x-N.positionScreen.x)<0){k=l[o]=l[o]||new THREE.RenderableFace3;k.v1.positionWorld.copy(N.positionWorld);k.v2.positionWorld.copy(aa.positionWorld);k.v3.positionWorld.copy(p.positionWorld);k.v1.positionScreen.copy(N.positionScreen);k.v2.positionScreen.copy(aa.positionScreen);k.v3.positionScreen.copy(p.positionScreen);k.normalWorld.copy(r.normal);h.multiplyVector3(k.normalWorld);k.centroidWorld.copy(r.centroid);n.multiplyVector3(k.centroidWorld);
-k.centroidScreen.copy(k.centroidWorld);s.multiplyVector3(k.centroidScreen);p=r.vertexNormals;$=k.vertexNormalsWorld;N=0;for(aa=p.length;N<aa;N++){B=$[N]=$[N]||new THREE.Vector3;B.copy(p[N]);h.multiplyVector3(B)}k.z=k.centroidScreen.z;k.meshMaterials=g;k.faceMaterials=r.materials;k.overdraw=t;if(i.geometry.uvs[K]){k.uvs[0]=i.geometry.uvs[K][0];k.uvs[1]=i.geometry.uvs[K][1];k.uvs[2]=i.geometry.uvs[K][2]}G.push(k);o++}}else if(r instanceof THREE.Face4){N=u[r.a];aa=u[r.b];p=u[r.c];B=u[r.d];if(N.__visible&&
-aa.__visible&&p.__visible&&B.__visible)if(i.doubleSided||i.flipSided!=((B.positionScreen.x-N.positionScreen.x)*(aa.positionScreen.y-N.positionScreen.y)-(B.positionScreen.y-N.positionScreen.y)*(aa.positionScreen.x-N.positionScreen.x)<0||(aa.positionScreen.x-p.positionScreen.x)*(B.positionScreen.y-p.positionScreen.y)-(aa.positionScreen.y-p.positionScreen.y)*(B.positionScreen.x-p.positionScreen.x)<0)){k=l[o]=l[o]||new THREE.RenderableFace3;k.v1.positionWorld.copy(N.positionWorld);k.v2.positionWorld.copy(aa.positionWorld);
-k.v3.positionWorld.copy(B.positionWorld);k.v1.positionScreen.copy(N.positionScreen);k.v2.positionScreen.copy(aa.positionScreen);k.v3.positionScreen.copy(B.positionScreen);k.normalWorld.copy(r.normal);h.multiplyVector3(k.normalWorld);k.centroidWorld.copy(r.centroid);n.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);s.multiplyVector3(k.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterials=g;k.faceMaterials=r.materials;k.overdraw=t;if(i.geometry.uvs[K]){k.uvs[0]=i.geometry.uvs[K][0];
-k.uvs[1]=i.geometry.uvs[K][1];k.uvs[2]=i.geometry.uvs[K][3]}G.push(k);o++;q=l[o]=l[o]||new THREE.RenderableFace3;q.v1.positionWorld.copy(aa.positionWorld);q.v2.positionWorld.copy(p.positionWorld);q.v3.positionWorld.copy(B.positionWorld);q.v1.positionScreen.copy(aa.positionScreen);q.v2.positionScreen.copy(p.positionScreen);q.v3.positionScreen.copy(B.positionScreen);q.normalWorld.copy(k.normalWorld);q.centroidWorld.copy(k.centroidWorld);q.centroidScreen.copy(k.centroidScreen);q.z=q.centroidScreen.z;
-q.meshMaterials=g;q.faceMaterials=r.materials;q.overdraw=t;if(i.geometry.uvs[K]){q.uvs[0]=i.geometry.uvs[K][1];q.uvs[1]=i.geometry.uvs[K][2];q.uvs[2]=i.geometry.uvs[K][3]}G.push(q);o++}}}}else if(i instanceof THREE.Line){O.multiply(s,n);u=i.geometry.vertices;r=u[0];r.positionScreen.copy(r.position);O.multiplyVector4(r.positionScreen);K=1;for(ca=u.length;K<ca;K++){N=u[K];N.positionScreen.copy(N.position);O.multiplyVector4(N.positionScreen);aa=u[K-1];b.copy(N.positionScreen);R.copy(aa.positionScreen);
-if(c(b,R)){b.multiplyScalar(1/b.w);R.multiplyScalar(1/R.w);m=y[z]=y[z]||new THREE.RenderableLine;m.v1.positionScreen.copy(b);m.v2.positionScreen.copy(R);m.z=Math.max(b.z,R.z);m.materials=i.materials;G.push(m);z++}}}else if(i instanceof THREE.Particle){I.set(i.position.x,i.position.y,i.position.z,1);s.multiplyVector4(I);I.z/=I.w;if(I.z>0&&I.z<1){v=F[x]=F[x]||new THREE.RenderableParticle;v.x=I.x/I.w;v.y=I.y/I.w;v.z=I.z;v.rotation=i.rotation.z;v.scale.x=i.scale.x*Math.abs(v.x-(I.x+J.projectionMatrix.n11)/
-(I.w+J.projectionMatrix.n14));v.scale.y=i.scale.y*Math.abs(v.y-(I.y+J.projectionMatrix.n22)/(I.w+J.projectionMatrix.n24));v.materials=i.materials;G.push(v);x++}}}}X&&G.sort(a);return G};this.unprojectVector=function(Q,J){var X=THREE.Matrix4.makeInvert(J.matrix);X.multiplySelf(THREE.Matrix4.makeInvert(J.projectionMatrix));X.multiplyVector3(Q);return Q}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,j,k;this.domElement=document.createElement("div");this.setSize=function(q,o){d=q;f=o;j=d/2;k=f/2};this.render=function(q,o){var l,m,z,y,v,x,F,H;a=c.projectScene(q,o);l=0;for(m=a.length;l<m;l++){v=a[l];if(v instanceof THREE.RenderableParticle){F=v.x*j+j;H=v.y*k+k;z=0;for(y=v.material.length;z<y;z++){x=v.material[z];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=F+"px";x.style.top=H+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(W){if(v!=W)m.globalAlpha=v=W}function c(W){if(x!=W){switch(W){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}x=W}}var d=null,f=new THREE.Projector,j=document.createElement("canvas"),k,q,o,l,m=j.getContext("2d"),z=new THREE.Color(0),y=0,v=1,x=0,F=null,H=null,I=1,s,O,C,b,R,$,Q,J,X,G=new THREE.Color,
-U=new THREE.Color,M=new THREE.Color,D=new THREE.Color,K=new THREE.Color,ca,N,aa,e,i,n,h,g,t,w=new THREE.Rectangle,u=new THREE.Rectangle,r=new THREE.Rectangle,p=false,B=new THREE.Color,V=new THREE.Color,da=new THREE.Color,ea=new THREE.Color,ia=Math.PI*2,S=new THREE.Vector3,Y,pa,P,ka,oa,wa,fa=16;Y=document.createElement("canvas");Y.width=Y.height=2;pa=Y.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);P=pa.getImageData(0,0,2,2);ka=P.data;oa=document.createElement("canvas");oa.width=
-oa.height=fa;wa=oa.getContext("2d");wa.translate(-fa/2,-fa/2);wa.scale(fa,fa);fa--;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(W,ba){k=W;q=ba;o=k/2;l=q/2;j.width=k;j.height=q;w.set(-o,-l,o,l);v=1;x=0;H=F=null;I=1};this.setClearColor=function(W,ba){z=W;y=ba;u.set(-o,-l,o,l);m.setTransform(1,0,0,-1,o,l);this.clear()};this.setClearColorHex=function(W,ba){z.setHex(W);y=ba;u.set(-o,-l,o,l);m.setTransform(1,0,0,-1,o,l);this.clear()};this.clear=function(){m.setTransform(1,
-0,0,-1,o,l);if(!u.isEmpty()){u.inflate(1);u.minSelf(w);if(z.hex==0&&y==0)m.clearRect(u.getX(),u.getY(),u.getWidth(),u.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(z.r*255)+","+Math.floor(z.g*255)+","+Math.floor(z.b*255)+","+y+")";m.fillRect(u.getX(),u.getY(),u.getWidth(),u.getHeight())}u.empty()}};this.render=function(W,ba){function Ca(A){var Z,T,E,L=A.lights;V.setRGB(0,0,0);da.setRGB(0,0,0);ea.setRGB(0,0,0);A=0;for(Z=L.length;A<Z;A++){T=L[A];E=T.color;if(T instanceof
-THREE.AmbientLight){V.r+=E.r;V.g+=E.g;V.b+=E.b}else if(T instanceof THREE.DirectionalLight){da.r+=E.r;da.g+=E.g;da.b+=E.b}else if(T instanceof THREE.PointLight){ea.r+=E.r;ea.g+=E.g;ea.b+=E.b}}}function qa(A,Z,T,E){var L,ha,ra,xa,za=A.lights;A=0;for(L=za.length;A<L;A++){ha=za[A];ra=ha.color;xa=ha.intensity;if(ha instanceof THREE.DirectionalLight){ha=T.dot(ha.position)*xa;if(ha>0){E.r+=ra.r*ha;E.g+=ra.g*ha;E.b+=ra.b*ha}}else if(ha instanceof THREE.PointLight){S.sub(ha.position,Z);S.normalize();ha=T.dot(S)*
-xa;if(ha>0){E.r+=ra.r*ha;E.g+=ra.g*ha;E.b+=ra.b*ha}}}}function la(A,Z,T){if(T.opacity!=0){a(T.opacity);c(T.blending);var E,L,ha,ra,xa,za;if(T instanceof THREE.ParticleBasicMaterial){if(T.map&&T.map.image.loaded){ra=T.map.image;xa=ra.width>>1;za=ra.height>>1;L=Z.scale.x*o;ha=Z.scale.y*l;T=L*xa;E=ha*za;r.set(A.x-T,A.y-E,A.x+T,A.y+E);if(!w.instersects(r))return;m.save();m.translate(A.x,A.y);m.rotate(-Z.rotation);m.scale(L,-ha);m.translate(-xa,-za);m.drawImage(ra,0,0);m.restore()}m.beginPath();m.moveTo(A.x-
-10,A.y);m.lineTo(A.x+10,A.y);m.moveTo(A.x,A.y-10);m.lineTo(A.x,A.y+10);m.closePath();m.strokeStyle="rgb(255,255,0)";m.stroke()}else if(T instanceof THREE.ParticleCircleMaterial){if(p){B.r=V.r+da.r+ea.r;B.g=V.g+da.g+ea.g;B.b=V.b+da.b+ea.b;G.r=T.color.r*B.r;G.g=T.color.g*B.g;G.b=T.color.b*B.b;G.updateStyleString()}else G.__styleString=T.color.__styleString;T=Z.scale.x*o;E=Z.scale.y*l;r.set(A.x-T,A.y-E,A.x+T,A.y+E);if(w.instersects(r)){L=G.__styleString;if(H!=L)m.fillStyle=H=L;m.save();m.translate(A.x,
-A.y);m.rotate(-Z.rotation);m.scale(T,E);m.beginPath();m.arc(0,0,1,0,ia,true);m.closePath();m.fill();m.restore()}}}}function na(A,Z,T,E){if(E.opacity!=0){a(E.opacity);c(E.blending);m.beginPath();m.moveTo(A.positionScreen.x,A.positionScreen.y);m.lineTo(Z.positionScreen.x,Z.positionScreen.y);m.closePath();if(E instanceof THREE.LineBasicMaterial){G.__styleString=E.color.__styleString;A=E.linewidth;if(I!=A)m.lineWidth=I=A;A=G.__styleString;if(F!=A)m.strokeStyle=F=A;m.stroke();r.inflate(E.linewidth*2)}}}
-function Ja(A,Z,T,E,L,ha){if(L.opacity!=0){a(L.opacity);c(L.blending);b=A.positionScreen.x;R=A.positionScreen.y;$=Z.positionScreen.x;Q=Z.positionScreen.y;J=T.positionScreen.x;X=T.positionScreen.y;m.beginPath();m.moveTo(b,R);m.lineTo($,Q);m.lineTo(J,X);m.lineTo(b,R);m.closePath();if(L instanceof THREE.MeshBasicMaterial)if(L.map)L.map.image.loaded&&L.map.mapping instanceof THREE.UVMapping&&ga(b,R,$,Q,J,X,L.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);else if(L.env_map){if(L.env_map.image.loaded)if(L.env_map.mapping instanceof
-THREE.SphericalReflectionMapping){A=ba.matrix;S.copy(E.vertexNormalsWorld[0]);e=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;i=-(S.x*A.n21+S.y*A.n22+S.z*A.n23)*0.5+0.5;S.copy(E.vertexNormalsWorld[1]);n=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;h=-(S.x*A.n21+S.y*A.n22+S.z*A.n23)*0.5+0.5;S.copy(E.vertexNormalsWorld[2]);g=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;t=-(S.x*A.n21+S.y*A.n22+S.z*A.n23)*0.5+0.5;ga(b,R,$,Q,J,X,L.env_map.image,e,i,n,h,g,t)}}else L.wireframe?Da(L.color.__styleString,L.wireframe_linewidth):
-va(L.color.__styleString);else if(L instanceof THREE.MeshLambertMaterial){if(L.map&&!L.wireframe){L.map.mapping instanceof THREE.UVMapping&&ga(b,R,$,Q,J,X,L.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);c(THREE.SubtractiveBlending)}if(p)if(!L.wireframe&&L.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){U.r=M.r=D.r=V.r;U.g=M.g=D.g=V.g;U.b=M.b=D.b=V.b;qa(ha,E.v1.positionWorld,E.vertexNormalsWorld[0],U);qa(ha,E.v2.positionWorld,E.vertexNormalsWorld[1],M);
-qa(ha,E.v3.positionWorld,E.vertexNormalsWorld[2],D);K.r=(M.r+D.r)*0.5;K.g=(M.g+D.g)*0.5;K.b=(M.b+D.b)*0.5;aa=ma(U,M,D,K);ga(b,R,$,Q,J,X,aa,0,0,1,0,0,1)}else{B.r=V.r;B.g=V.g;B.b=V.b;qa(ha,E.centroidWorld,E.normalWorld,B);G.r=L.color.r*B.r;G.g=L.color.g*B.g;G.b=L.color.b*B.b;G.updateStyleString();L.wireframe?Da(G.__styleString,L.wireframe_linewidth):va(G.__styleString)}else L.wireframe?Da(L.color.__styleString,L.wireframe_linewidth):va(L.color.__styleString)}else if(L instanceof THREE.MeshDepthMaterial){ca=
-ba.near;N=ba.far;U.r=U.g=U.b=1-Aa(A.positionScreen.z,ca,N);M.r=M.g=M.b=1-Aa(Z.positionScreen.z,ca,N);D.r=D.g=D.b=1-Aa(T.positionScreen.z,ca,N);K.r=(M.r+D.r)*0.5;K.g=(M.g+D.g)*0.5;K.b=(M.b+D.b)*0.5;aa=ma(U,M,D,K);ga(b,R,$,Q,J,X,aa,0,0,1,0,0,1)}else if(L instanceof THREE.MeshNormalMaterial){G.r=ta(E.normalWorld.x);G.g=ta(E.normalWorld.y);G.b=ta(E.normalWorld.z);G.updateStyleString();L.wireframe?Da(G.__styleString,L.wireframe_linewidth):va(G.__styleString)}}}function Da(A,Z){if(F!=A)m.strokeStyle=F=
-A;if(I!=Z)m.lineWidth=I=Z;m.stroke();r.inflate(Z*2)}function va(A){if(H!=A)m.fillStyle=H=A;m.fill()}function ga(A,Z,T,E,L,ha,ra,xa,za,Ga,Ba,Ha,Oa){var Ea,Ia;Ea=ra.width-1;Ia=ra.height-1;xa*=Ea;za*=Ia;Ga*=Ea;Ba*=Ia;Ha*=Ea;Oa*=Ia;T-=A;E-=Z;L-=A;ha-=Z;Ga-=xa;Ba-=za;Ha-=xa;Oa-=za;Ea=Ga*Oa-Ha*Ba;if(Ea!=0){Ia=1/Ea;Ea=(Oa*T-Ba*L)*Ia;Ba=(Oa*E-Ba*ha)*Ia;T=(Ga*L-Ha*T)*Ia;E=(Ga*ha-Ha*E)*Ia;A=A-Ea*xa-T*za;Z=Z-Ba*xa-E*za;m.save();m.transform(Ea,Ba,T,E,A,Z);m.clip();m.drawImage(ra,0,0);m.restore()}}function ma(A,
-Z,T,E){var L=~~(A.r*255),ha=~~(A.g*255);A=~~(A.b*255);var ra=~~(Z.r*255),xa=~~(Z.g*255);Z=~~(Z.b*255);var za=~~(T.r*255),Ga=~~(T.g*255);T=~~(T.b*255);var Ba=~~(E.r*255),Ha=~~(E.g*255);E=~~(E.b*255);ka[0]=L<0?0:L>255?255:L;ka[1]=ha<0?0:ha>255?255:ha;ka[2]=A<0?0:A>255?255:A;ka[4]=ra<0?0:ra>255?255:ra;ka[5]=xa<0?0:xa>255?255:xa;ka[6]=Z<0?0:Z>255?255:Z;ka[8]=za<0?0:za>255?255:za;ka[9]=Ga<0?0:Ga>255?255:Ga;ka[10]=T<0?0:T>255?255:T;ka[12]=Ba<0?0:Ba>255?255:Ba;ka[13]=Ha<0?0:Ha>255?255:Ha;ka[14]=E<0?0:E>
-255?255:E;pa.putImageData(P,0,0);wa.drawImage(Y,0,0);return oa}function Aa(A,Z,T){A=(A-Z)/(T-Z);return A*A*(3-2*A)}function ta(A){A=(A+1)*0.5;return A<0?0:A>1?1:A}function La(A,Z){var T=Z.x-A.x,E=Z.y-A.y,L=1/Math.sqrt(T*T+E*E);T*=L;E*=L;Z.x+=T;Z.y+=E;A.x-=T;A.y-=E}var ua,Ma,ja,ya,Fa,Ka,Na,sa;this.autoClear?this.clear():m.setTransform(1,0,0,-1,o,l);d=f.projectScene(W,ba,this.sortElements);m.fillStyle="rgba( 0, 255, 255, 0.5 )";m.fillRect(w.getX(),w.getY(),w.getWidth(),w.getHeight());(p=W.lights.length>
-0)&&Ca(W);ua=0;for(Ma=d.length;ua<Ma;ua++){ja=d[ua];r.empty();if(ja instanceof THREE.RenderableParticle){s=ja;s.x*=o;s.y*=l;ya=0;for(Fa=ja.materials.length;ya<Fa;ya++)la(s,ja,ja.materials[ya],W)}else if(ja instanceof THREE.RenderableLine){s=ja.v1;O=ja.v2;s.positionScreen.x*=o;s.positionScreen.y*=l;O.positionScreen.x*=o;O.positionScreen.y*=l;r.addPoint(s.positionScreen.x,s.positionScreen.y);r.addPoint(O.positionScreen.x,O.positionScreen.y);if(w.instersects(r)){ya=0;for(Fa=ja.materials.length;ya<Fa;)na(s,
-O,ja,ja.materials[ya++],W)}}else if(ja instanceof THREE.RenderableFace3){s=ja.v1;O=ja.v2;C=ja.v3;s.positionScreen.x*=o;s.positionScreen.y*=l;O.positionScreen.x*=o;O.positionScreen.y*=l;C.positionScreen.x*=o;C.positionScreen.y*=l;if(ja.overdraw){La(s.positionScreen,O.positionScreen);La(O.positionScreen,C.positionScreen);La(C.positionScreen,s.positionScreen)}r.add3Points(s.positionScreen.x,s.positionScreen.y,O.positionScreen.x,O.positionScreen.y,C.positionScreen.x,C.positionScreen.y);if(w.instersects(r)){ya=
-0;for(Fa=ja.meshMaterials.length;ya<Fa;){sa=ja.meshMaterials[ya++];if(sa instanceof THREE.MeshFaceMaterial){Ka=0;for(Na=ja.faceMaterials.length;Ka<Na;)(sa=ja.faceMaterials[Ka++])&&Ja(s,O,C,ja,sa,W)}else Ja(s,O,C,ja,sa,W)}}}u.addRectangle(r)}m.lineWidth=1;m.strokeStyle="rgba( 255, 0, 0, 0.5 )";m.strokeRect(u.getX(),u.getY(),u.getWidth(),u.getHeight());m.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(e,i,n){var h,g,t,w;h=0;for(g=e.lights.length;h<g;h++){t=e.lights[h];if(t instanceof THREE.DirectionalLight){w=i.normalWorld.dot(t.position)*t.intensity;if(w>0){n.r+=t.color.r*w;n.g+=t.color.g*w;n.b+=t.color.b*w}}else if(t instanceof THREE.PointLight){X.sub(t.position,i.centroidWorld);X.normalize();w=i.normalWorld.dot(X)*t.intensity;if(w>0){n.r+=t.color.r*w;n.g+=t.color.g*w;n.b+=t.color.b*w}}}}function c(e,i,n,h,g,t){D=f(K++);D.setAttribute("d","M "+e.positionScreen.x+
-" "+e.positionScreen.y+" L "+i.positionScreen.x+" "+i.positionScreen.y+" L "+n.positionScreen.x+","+n.positionScreen.y+"z");if(g instanceof THREE.MeshBasicMaterial)C.__styleString=g.color.__styleString;else if(g instanceof THREE.MeshLambertMaterial)if(O){b.r=R.r;b.g=R.g;b.b=R.b;a(t,h,b);C.r=g.color.r*b.r;C.g=g.color.g*b.g;C.b=g.color.b*b.b;C.updateStyleString()}else C.__styleString=g.color.__styleString;else if(g instanceof THREE.MeshDepthMaterial){J=1-g.__2near/(g.__farPlusNear-h.z*g.__farMinusNear);
-C.setRGB(J,J,J)}else g instanceof THREE.MeshNormalMaterial&&C.setRGB(j(h.normalWorld.x),j(h.normalWorld.y),j(h.normalWorld.z));g.wireframe?D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+g.wireframe_linewidth+"; stroke-opacity: "+g.opacity+"; stroke-linecap: "+g.wireframe_linecap+"; stroke-linejoin: "+g.wireframe_linejoin):D.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+g.opacity);o.appendChild(D)}function d(e,i,n,h,g,t,w){D=f(K++);D.setAttribute("d",
-"M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+i.positionScreen.x+" "+i.positionScreen.y+" L "+n.positionScreen.x+","+n.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");if(t instanceof THREE.MeshBasicMaterial)C.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshLambertMaterial)if(O){b.r=R.r;b.g=R.g;b.b=R.b;a(w,g,b);C.r=t.color.r*b.r;C.g=t.color.g*b.g;C.b=t.color.b*b.b;C.updateStyleString()}else C.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshDepthMaterial){J=
-1-t.__2near/(t.__farPlusNear-g.z*t.__farMinusNear);C.setRGB(J,J,J)}else t instanceof THREE.MeshNormalMaterial&&C.setRGB(j(g.normalWorld.x),j(g.normalWorld.y),j(g.normalWorld.z));t.wireframe?D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+t.wireframe_linewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframe_linecap+"; stroke-linejoin: "+t.wireframe_linejoin):D.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+t.opacity);o.appendChild(D)}
-function f(e){if(G[e]==null){G[e]=document.createElementNS("http://www.w3.org/2000/svg","path");aa==0&&G[e].setAttribute("shape-rendering","crispEdges");return G[e]}return G[e]}function j(e){return e<0?Math.min((1+e)*0.5,0.5):0.5+Math.min(e*0.5,0.5)}var k=null,q=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,m,z,y,v,x,F,H,I=new THREE.Rectangle,s=new THREE.Rectangle,O=false,C=new THREE.Color(16777215),b=new THREE.Color(16777215),R=new THREE.Color(0),$=new THREE.Color(0),
-Q=new THREE.Color(0),J,X=new THREE.Vector3,G=[],U=[],M=[],D,K,ca,N,aa=1;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(e){switch(e){case "high":aa=1;break;case "low":aa=0}};this.setSize=function(e,i){l=e;m=i;z=l/2;y=m/2;o.setAttribute("viewBox",-z+" "+-y+" "+l+" "+m);o.setAttribute("width",l);o.setAttribute("height",m);I.set(-z,-y,z,y)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=function(e,i){var n,
-h,g,t,w,u,r,p;this.autoClear&&this.clear();k=q.projectScene(e,i,this.sortElements);N=ca=K=0;if(O=e.lights.length>0){r=e.lights;R.setRGB(0,0,0);$.setRGB(0,0,0);Q.setRGB(0,0,0);n=0;for(h=r.length;n<h;n++){g=r[n];t=g.color;if(g instanceof THREE.AmbientLight){R.r+=t.r;R.g+=t.g;R.b+=t.b}else if(g instanceof THREE.DirectionalLight){$.r+=t.r;$.g+=t.g;$.b+=t.b}else if(g instanceof THREE.PointLight){Q.r+=t.r;Q.g+=t.g;Q.b+=t.b}}}n=0;for(h=k.length;n<h;n++){r=k[n];s.empty();if(r instanceof THREE.RenderableParticle){v=
-r;v.x*=z;v.y*=-y;g=0;for(t=r.materials.length;g<t;g++)if(p=r.materials[g]){w=v;u=r;p=p;var B=ca++;if(U[B]==null){U[B]=document.createElementNS("http://www.w3.org/2000/svg","circle");aa==0&&U[B].setAttribute("shape-rendering","crispEdges")}D=U[B];D.setAttribute("cx",w.x);D.setAttribute("cy",w.y);D.setAttribute("r",u.scale.x*z);if(p instanceof THREE.ParticleCircleMaterial){if(O){b.r=R.r+$.r+Q.r;b.g=R.g+$.g+Q.g;b.b=R.b+$.b+Q.b;C.r=p.color.r*b.r;C.g=p.color.g*b.g;C.b=p.color.b*b.b;C.updateStyleString()}else C=
-p.color;D.setAttribute("style","fill: "+C.__styleString)}o.appendChild(D)}}else if(r instanceof THREE.RenderableLine){v=r.v1;x=r.v2;v.positionScreen.x*=z;v.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);if(I.instersects(s)){g=0;for(t=r.materials.length;g<t;)if(p=r.materials[g++]){w=v;u=x;p=p;B=N++;if(M[B]==null){M[B]=document.createElementNS("http://www.w3.org/2000/svg","line");aa==
-0&&M[B].setAttribute("shape-rendering","crispEdges")}D=M[B];D.setAttribute("x1",w.positionScreen.x);D.setAttribute("y1",w.positionScreen.y);D.setAttribute("x2",u.positionScreen.x);D.setAttribute("y2",u.positionScreen.y);if(p instanceof THREE.LineBasicMaterial){C.__styleString=p.color.__styleString;D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+p.linewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.linecap+"; stroke-linejoin: "+p.linejoin);o.appendChild(D)}}}}else if(r instanceof
-THREE.RenderableFace3){v=r.v1;x=r.v2;F=r.v3;v.positionScreen.x*=z;v.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;F.positionScreen.x*=z;F.positionScreen.y*=-y;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(F.positionScreen.x,F.positionScreen.y);if(I.instersects(s)){g=0;for(t=r.meshMaterials.length;g<t;){p=r.meshMaterials[g++];if(p instanceof THREE.MeshFaceMaterial){w=0;for(u=r.faceMaterials.length;w<u;)(p=r.faceMaterials[w++])&&
-c(v,x,F,r,p,e)}else p&&c(v,x,F,r,p,e)}}}else if(r instanceof THREE.RenderableFace4){v=r.v1;x=r.v2;F=r.v3;H=r.v4;v.positionScreen.x*=z;v.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;F.positionScreen.x*=z;F.positionScreen.y*=-y;H.positionScreen.x*=z;H.positionScreen.y*=-y;s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(F.positionScreen.x,F.positionScreen.y);s.addPoint(H.positionScreen.x,H.positionScreen.y);if(I.instersects(s)){g=
-0;for(t=r.meshMaterials.length;g<t;){p=r.meshMaterials[g++];if(p instanceof THREE.MeshFaceMaterial){w=0;for(u=r.faceMaterials.length;w<u;)(p=r.faceMaterials[w++])&&d(v,x,F,H,r,p,e)}else p&&d(v,x,F,H,r,p,e)}}}}}};
-THREE.WebGLRenderer=function(a){function c(e,i,n){var h,g,t,w=e.vertices,u=w.length,r=e.colors,p=r.length,B=e.__vertexArray,V=e.__colorArray,da=e.__sortArray,ea=e.__dirtyVertices,ia=e.__dirtyColors;if(n.sortParticles){U.multiplySelf(n.matrixWorld);for(h=0;h<u;h++){g=w[h].position;K.copy(g);U.multiplyVector3(K);da[h]=[K.z,h]}da.sort(function(S,Y){return Y[0]-S[0]});for(h=0;h<u;h++){g=w[da[h][1]].position;t=h*3;B[t]=g.x;B[t+1]=g.y;B[t+2]=g.z}for(h=0;h<p;h++){t=h*3;color=r[da[h][1]];V[t]=color.r;V[t+
-1]=color.g;V[t+2]=color.b}}else{if(ea)for(h=0;h<u;h++){g=w[h].position;t=h*3;B[t]=g.x;B[t+1]=g.y;B[t+2]=g.z}if(ia)for(h=0;h<p;h++){color=r[h];t=h*3;V[t]=color.r;V[t+1]=color.g;V[t+2]=color.b}}if(ea||n.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,B,i)}if(ia||n.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,V,i)}}function d(e,i){e.fragment_shader=i.fragment_shader;e.vertex_shader=i.vertex_shader;e.uniforms=
-Uniforms.clone(i.uniforms)}function f(e,i){if(!e.__webGLVertexBuffer)e.__webGLVertexBuffer=b.createBuffer();if(!e.__webGLNormalBuffer)e.__webGLNormalBuffer=b.createBuffer();if(e.hasPos){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,e.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(i.attributes.position);b.vertexAttribPointer(i.attributes.position,3,b.FLOAT,false,0,0)}if(e.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,
-e.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(i.attributes.normal);b.vertexAttribPointer(i.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,e.count);e.count=0}function j(e){if(Q!=e.doubleSided){e.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);Q=e.doubleSided}if(J!=e.flipSided){e.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);J=e.flipSided}}function k(e){G[0].set(e.n41-e.n11,e.n42-e.n12,e.n43-e.n13,e.n44-e.n14);G[1].set(e.n41+e.n11,e.n42+e.n12,e.n43+e.n13,e.n44+
-e.n14);G[2].set(e.n41+e.n21,e.n42+e.n22,e.n43+e.n23,e.n44+e.n24);G[3].set(e.n41-e.n21,e.n42-e.n22,e.n43-e.n23,e.n44-e.n24);G[4].set(e.n41-e.n31,e.n42-e.n32,e.n43-e.n33,e.n44-e.n34);G[5].set(e.n41+e.n31,e.n42+e.n32,e.n43+e.n33,e.n44+e.n34);var i;for(e=0;e<5;e++){i=G[e];i.divideScalar(Math.sqrt(i.x*i.x+i.y*i.y+i.z*i.z))}}function q(e){for(var i=e.matrix,n=-e.geometry.boundingSphere.radius*Math.max(e.scale.x,Math.max(e.scale.y,e.scale.z)),h=0;h<6;h++){e=G[h].x*i.n14+G[h].y*i.n24+G[h].z*i.n34+G[h].w;
-if(e<=n)return false}return true}function o(e,i){e.list[e.count]=i;e.count+=1}function l(e){var i,n,h=e.object,g=e.opaque,t=e.transparent;t.count=0;e=g.count=0;for(i=h.materials.length;e<i;e++){n=h.materials[e];n.opacity&&n.opacity<1||n.blending!=THREE.NormalBlending?o(t,n):o(g,n)}}function m(e){var i,n,h,g,t=e.object,w=e.buffer,u=e.opaque,r=e.transparent;r.count=0;e=u.count=0;for(h=t.materials.length;e<h;e++){i=t.materials[e];if(i instanceof THREE.MeshFaceMaterial){i=0;for(n=w.materials.length;i<
-n;i++)if(g=w.materials[i])g.opacity&&g.opacity<1||g.blending!=THREE.NormalBlending?o(r,g):o(u,g)}else{g=i;g.opacity&&g.opacity<1||g.blending!=THREE.NormalBlending?o(r,g):o(u,g)}}}function z(e){var i,n,h,g=e.children;i=0;for(n=g.length;i<n;i++){h=g[i];h.autoUpdateMatrix&&h.updateMatrix();h.matrixWorld.multiply(e.matrixWorld,h.matrix);z(h)}}function y(e,i){var n,h,g=i.children;n=0;for(h=g.length;n<h;n++){child=g[n];v(e,child,false);y(e,child)}}function v(e,i,n){var h,g,t;g=i.geometry;if(e.__webGLObjectsMap[i.id]==
-undefined){e.__webGLObjectsMap[i.id]={};i._modelViewMatrix=new THREE.Matrix4;i._normalMatrixArray=new Float32Array(9);i._modelViewMatrixArray=new Float32Array(16);i._objectMatrixArray=new Float32Array(16);i.matrix.flattenToArray(i._objectMatrixArray)}t=e.__webGLObjectsMap[i.id];objlist=e.__webGLObjects;if(i instanceof THREE.Mesh){for(h in g.geometryChunks){e=g.geometryChunks[h];if(!e.__webGLVertexBuffer){var w=e;w.__webGLVertexBuffer=b.createBuffer();w.__webGLNormalBuffer=b.createBuffer();w.__webGLTangentBuffer=
-b.createBuffer();w.__webGLColorBuffer=b.createBuffer();w.__webGLUVBuffer=b.createBuffer();w.__webGLUV2Buffer=b.createBuffer();w.__webGLFaceBuffer=b.createBuffer();w.__webGLLineBuffer=b.createBuffer();w=e;var u=i,r=void 0,p=void 0,B=0,V=0,da=0,ea=u.geometry.faces,ia=w.faces;r=0;for(p=ia.length;r<p;r++){fi=ia[r];face=ea[fi];if(face instanceof THREE.Face3){B+=3;V+=1;da+=3}else if(face instanceof THREE.Face4){B+=4;V+=2;da+=4}}w.__vertexArray=new Float32Array(B*3);w.__normalArray=new Float32Array(B*3);
-w.__tangentArray=new Float32Array(B*4);w.__colorArray=new Float32Array(B*3);w.__uvArray=new Float32Array(B*2);w.__uv2Array=new Float32Array(B*2);w.__faceArray=new Uint16Array(V*3);w.__lineArray=new Uint16Array(da*2);p=r=w;u=u;B=void 0;ea=void 0;var S=void 0,Y=void 0;S=void 0;ia=false;B=0;for(ea=u.materials.length;B<ea;B++){S=u.materials[B];if(S instanceof THREE.MeshFaceMaterial){S=0;for(Y=p.materials.length;S<Y;S++)if(p.materials[S]&&p.materials[S].shading!=undefined&&p.materials[S].shading==THREE.SmoothShading){ia=
-true;break}}else if(S&&S.shading!=undefined&&S.shading==THREE.SmoothShading){ia=true;break}if(ia)break}r.__needsSmoothNormals=ia;w.__webGLFaceCount=V*3;w.__webGLLineCount=da*2;g.__dirtyVertices=true;g.__dirtyElements=true;g.__dirtyUvs=true;g.__dirtyNormals=true;g.__dirtyTangents=true;g.__dirtyColors=true}if(g.__dirtyVertices||g.__dirtyElements||g.__dirtyUvs||g.__dirtyNormals||g.__dirtyColors||g.__dirtyTangents){w=e;V=b.DYNAMIC_DRAW;da=void 0;r=void 0;var pa=void 0,P=void 0,ka=void 0,oa=void 0,wa=
-void 0;pa=void 0;var fa=void 0,W=void 0,ba=void 0,Ca=void 0;fa=void 0;W=void 0;ba=void 0;P=void 0;fa=void 0;W=void 0;ba=void 0;Ca=void 0;P=void 0;oa=void 0;ka=void 0;wa=void 0;var qa=Y=S=ia=ea=B=u=p=0,la=0,na=w.__vertexArray,Ja=w.__uvArray,Da=w.__uv2Array,va=w.__normalArray,ga=w.__tangentArray,ma=w.__colorArray,Aa=w.__faceArray,ta=w.__lineArray,La=w.__needsSmoothNormals,ua=i.geometry,Ma=ua.__dirtyVertices,ja=ua.__dirtyElements,ya=ua.__dirtyUvs,Fa=ua.__dirtyNormals,Ka=ua.__dirtyTangents,Na=ua.__dirtyColors,
-sa=ua.vertices,A=w.faces,Z=ua.faces,T=ua.uvs,E=ua.uvs2,L=ua.colors;da=0;for(r=A.length;da<r;da++){pa=A[da];P=Z[pa];wa=T[pa];pa=E[pa];ka=P.vertexNormals;oa=P.normal;if(P instanceof THREE.Face3){if(Ma){fa=sa[P.a].position;W=sa[P.b].position;ba=sa[P.c].position;na[u]=fa.x;na[u+1]=fa.y;na[u+2]=fa.z;na[u+3]=W.x;na[u+4]=W.y;na[u+5]=W.z;na[u+6]=ba.x;na[u+7]=ba.y;na[u+8]=ba.z;u+=9}if(Na&&L.length){fa=L[P.a];W=L[P.b];ba=L[P.c];ma[la]=fa.r;ma[la+1]=fa.g;ma[la+2]=fa.b;ma[la+3]=W.r;ma[la+4]=W.g;ma[la+5]=W.b;
-ma[la+6]=ba.r;ma[la+7]=ba.g;ma[la+8]=ba.b;la+=9}if(Ka&&ua.hasTangents){fa=sa[P.a].tangent;W=sa[P.b].tangent;ba=sa[P.c].tangent;ga[Y]=fa.x;ga[Y+1]=fa.y;ga[Y+2]=fa.z;ga[Y+3]=fa.w;ga[Y+4]=W.x;ga[Y+5]=W.y;ga[Y+6]=W.z;ga[Y+7]=W.w;ga[Y+8]=ba.x;ga[Y+9]=ba.y;ga[Y+10]=ba.z;ga[Y+11]=ba.w;Y+=12}if(Fa)if(ka.length==3&&La)for(P=0;P<3;P++){oa=ka[P];va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}else for(P=0;P<3;P++){va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}if(ya&&wa)for(P=0;P<3;P++){ka=wa[P];Ja[B]=ka.u;Ja[B+1]=ka.v;
-B+=2}if(ya&&pa)for(P=0;P<3;P++){wa=pa[P];Da[ea]=wa.u;Da[ea+1]=wa.v;ea+=2}if(ja){Aa[ia]=p;Aa[ia+1]=p+1;Aa[ia+2]=p+2;ia+=3;ta[qa]=p;ta[qa+1]=p+1;ta[qa+2]=p;ta[qa+3]=p+2;ta[qa+4]=p+1;ta[qa+5]=p+2;qa+=6;p+=3}}else if(P instanceof THREE.Face4){if(Ma){fa=sa[P.a].position;W=sa[P.b].position;ba=sa[P.c].position;Ca=sa[P.d].position;na[u]=fa.x;na[u+1]=fa.y;na[u+2]=fa.z;na[u+3]=W.x;na[u+4]=W.y;na[u+5]=W.z;na[u+6]=ba.x;na[u+7]=ba.y;na[u+8]=ba.z;na[u+9]=Ca.x;na[u+10]=Ca.y;na[u+11]=Ca.z;u+=12}if(Na&&L.length){fa=
-L[P.a];W=L[P.b];ba=L[P.c];Ca=L[P.d];ma[la]=fa.r;ma[la+1]=fa.g;ma[la+2]=fa.b;ma[la+3]=W.r;ma[la+4]=W.g;ma[la+5]=W.b;ma[la+6]=ba.r;ma[la+7]=ba.g;ma[la+8]=ba.b;ma[la+9]=Ca.r;ma[la+10]=Ca.g;ma[la+11]=Ca.b;la+=12}if(Ka&&ua.hasTangents){fa=sa[P.a].tangent;W=sa[P.b].tangent;ba=sa[P.c].tangent;P=sa[P.d].tangent;ga[Y]=fa.x;ga[Y+1]=fa.y;ga[Y+2]=fa.z;ga[Y+3]=fa.w;ga[Y+4]=W.x;ga[Y+5]=W.y;ga[Y+6]=W.z;ga[Y+7]=W.w;ga[Y+8]=ba.x;ga[Y+9]=ba.y;ga[Y+10]=ba.z;ga[Y+11]=ba.w;ga[Y+12]=P.x;ga[Y+13]=P.y;ga[Y+14]=P.z;ga[Y+
-15]=P.w;Y+=16}if(Fa)if(ka.length==4&&La)for(P=0;P<4;P++){oa=ka[P];va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}else for(P=0;P<4;P++){va[S]=oa.x;va[S+1]=oa.y;va[S+2]=oa.z;S+=3}if(ya&&wa)for(P=0;P<4;P++){ka=wa[P];Ja[B]=ka.u;Ja[B+1]=ka.v;B+=2}if(ya&&pa)for(P=0;P<4;P++){wa=pa[P];Da[ea]=wa.u;Da[ea+1]=wa.v;ea+=2}if(ja){Aa[ia]=p;Aa[ia+1]=p+1;Aa[ia+2]=p+2;Aa[ia+3]=p;Aa[ia+4]=p+2;Aa[ia+5]=p+3;ia+=6;ta[qa]=p;ta[qa+1]=p+1;ta[qa+2]=p;ta[qa+3]=p+3;ta[qa+4]=p+1;ta[qa+5]=p+2;ta[qa+6]=p+2;ta[qa+7]=p+3;qa+=8;p+=4}}}if(Ma){b.bindBuffer(b.ARRAY_BUFFER,
-w.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,na,V)}if(Na&&L.length){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,ma,V)}if(Fa){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,va,V)}if(Ka&&ua.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,ga,V)}if(ya&&B>0){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,Ja,V)}if(ya&&ea>0){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLUV2Buffer);
-b.bufferData(b.ARRAY_BUFFER,Da,V)}if(ja){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Aa,V);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,w.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ta,V)}}x(objlist,t,h,e,i,n)}g.__dirtyVertices=false;g.__dirtyElements=false;g.__dirtyUvs=false;g.__dirtyNormals=false;g.__dirtyTangents=false;g.__dirtyColors=false}else if(i instanceof THREE.Line){if(!g.__webGLVertexBuffer){g.__webGLVertexBuffer=b.createBuffer();g.__webGLColorBuffer=
-b.createBuffer();h=g.vertices.length;g.__vertexArray=new Float32Array(h*3);g.__colorArray=new Float32Array(h*3);g.__webGLLineCount=h;g.__dirtyVertices=true;g.__dirtyColors=true}if(g.__dirtyVertices||g.__dirtyColors){h=b.DYNAMIC_DRAW;u=g.vertices;w=g.colors;B=u.length;V=w.length;ea=g.__vertexArray;da=g.__colorArray;ia=g.__dirtyColors;if(g.__dirtyVertices){for(r=0;r<B;r++){p=u[r].position;e=r*3;ea[e]=p.x;ea[e+1]=p.y;ea[e+2]=p.z}b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,
-ea,h)}if(ia){for(r=0;r<V;r++){color=w[r];e=r*3;da[e]=color.r;da[e+1]=color.g;da[e+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,da,h)}}x(objlist,t,0,g,i,n);g.__dirtyVertices=false;g.__dirtyColors=false}else if(i instanceof THREE.ParticleSystem){if(!g.__webGLVertexBuffer){g.__webGLVertexBuffer=b.createBuffer();g.__webGLColorBuffer=b.createBuffer();h=g.vertices.length;g.__vertexArray=new Float32Array(h*3);g.__colorArray=new Float32Array(h*3);g.__sortArray=
-[];g.__webGLParticleCount=h;g.__dirtyVertices=true;g.__dirtyColors=true}if(g.__dirtyVertices||g.__dirtyColors||i.sortParticles)c(g,b.DYNAMIC_DRAW,i,camera);x(objlist,t,0,g,i,n);g.__dirtyVertices=false;g.__dirtyColors=false}else if(i instanceof THREE.MarchingCubes)if(t[0]==undefined){e.__webGLObjectsImmediate.push({object:i,opaque:{list:[],count:0},transparent:{list:[],count:0},root:n});t[0]=1}}function x(e,i,n,h,g,t){if(i[n]==undefined){e.push({buffer:h,object:g,opaque:{list:[],count:0},transparent:{list:[],
-count:0},root:t});i[n]=1}}function F(e,i){e._modelViewMatrix.multiplyToArray(i.matrix,e.matrixWorld,e._modelViewMatrixArray);e._normalMatrix=THREE.Matrix4.makeInvert3x3(e._modelViewMatrix).transposeIntoArray(e._normalMatrixArray)}function H(e){if(e!=X){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;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);
-break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}X=e}}function I(e,i){if(e&&!e.__webGLFramebuffer){e.__webGLFramebuffer=b.createFramebuffer();e.__webGLRenderbuffer=b.createRenderbuffer();e.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,e.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,e.width,e.height);b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,O(e.wrap_s));b.texParameteri(b.TEXTURE_2D,
-b.TEXTURE_WRAP_T,O(e.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,O(e.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,O(e.min_filter));b.texImage2D(b.TEXTURE_2D,0,O(e.format),e.width,e.height,0,O(e.format),O(e.type),null);b.bindFramebuffer(b.FRAMEBUFFER,e.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,e.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,e.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,
-null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}var n,h,g;if(e){n=e.__webGLFramebuffer;h=e.width;g=e.height}else{n=null;h=C.width;g=C.height}if(n!=$){b.bindFramebuffer(b.FRAMEBUFFER,n);b.viewport(0,0,h,g);i&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);$=n}}function s(e,i){var n;if(e=="fragment")n=b.createShader(b.FRAGMENT_SHADER);else if(e=="vertex")n=b.createShader(b.VERTEX_SHADER);b.shaderSource(n,i);b.compileShader(n);if(!b.getShaderParameter(n,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(n));
-return null}return n}function O(e){switch(e){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;
-case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}
-var C=document.createElement("canvas"),b,R=null,$=null,Q=null,J=null,X=null,G=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],U=new THREE.Matrix4,M=new Float32Array(16),D=new Float32Array(16),K=new THREE.Vector4,ca=true,N=new THREE.Color(0),aa=0;if(a){if(a.antialias!==undefined)ca=a.antialias;a.clearColor!==undefined&&N.setHex(a.clearColor);if(a.clearAlpha!==undefined)aa=a.clearAlpha}this.domElement=C;this.autoClear=true;(function(e,i,
-n){try{b=C.getContext("experimental-webgl",{antialias:e})}catch(h){console.log(h)}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(i.r,i.g,i.b,n);_cullEnabled=true})(ca,N,aa);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},
-point:{length:0,colors:[],positions:[]}};this.setSize=function(e,i){C.width=e;C.height=i;b.viewport(0,0,C.width,C.height)};this.setClearColorHex=function(e,i){var n=new THREE.Color(e);b.clearColor(n.r,n.g,n.b,i)};this.setClearColor=function(e,i){b.clearColor(e.r,e.g,e.b,i)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(e,i){var n,h,g,t=0,w=0,u=0,r,p,B,V=this.lights,da=V.directional.colors,ea=V.directional.positions,ia=V.point.colors,S=V.point.positions,
-Y=0,pa=0;n=g=g=0;for(h=i.length;n<h;n++){g=i[n];r=g.color;p=g.position;B=g.intensity;if(g instanceof THREE.AmbientLight){t+=r.r;w+=r.g;u+=r.b}else if(g instanceof THREE.DirectionalLight){g=Y*3;da[g]=r.r*B;da[g+1]=r.g*B;da[g+2]=r.b*B;ea[g]=p.x;ea[g+1]=p.y;ea[g+2]=p.z;Y+=1}else if(g instanceof THREE.PointLight){g=pa*3;ia[g]=r.r*B;ia[g+1]=r.g*B;ia[g+2]=r.b*B;S[g]=p.x;S[g+1]=p.y;S[g+2]=p.z;pa+=1}}for(n=Y*3;n<da.length;n++)da[n]=0;for(n=pa*3;n<ia.length;n++)ia[n]=0;V.point.length=pa;V.directional.length=
-Y;V.ambient[0]=t;V.ambient[1]=w;V.ambient[2]=u};this.initMaterial=function(e,i,n){var h,g;if(e instanceof THREE.MeshDepthMaterial)d(e,THREE.ShaderLib.depth);else if(e instanceof THREE.MeshNormalMaterial)d(e,THREE.ShaderLib.normal);else if(e instanceof THREE.MeshBasicMaterial)d(e,THREE.ShaderLib.basic);else if(e instanceof THREE.MeshLambertMaterial)d(e,THREE.ShaderLib.lambert);else if(e instanceof THREE.MeshPhongMaterial)d(e,THREE.ShaderLib.phong);else if(e instanceof THREE.LineBasicMaterial)d(e,THREE.ShaderLib.basic);
-else e instanceof THREE.ParticleBasicMaterial&&d(e,THREE.ShaderLib.particle_basic);var t,w,u,r;g=u=r=0;for(t=i.length;g<t;g++){w=i[g];w instanceof THREE.DirectionalLight&&u++;w instanceof THREE.PointLight&&r++}if(r+u<=4){i=u;r=r}else{i=Math.ceil(4*u/(r+u));r=4-i}g={directional:i,point:r};r=e.fragment_shader;i=e.vertex_shader;t={fog:n,map:e.map,env_map:e.env_map,light_map:e.light_map,vertex_colors:e.vertex_colors,maxDirLights:g.directional,maxPointLights:g.point};n=b.createProgram();g=["#ifdef GL_ES\nprecision highp float;\n#endif",
-"#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+t.maxPointLights,t.fog?"#define USE_FOG":"",t.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.env_map?"#define USE_ENVMAP":"",t.light_map?"#define USE_LIGHTMAP":"",t.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");t=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+
-t.maxPointLights,t.map?"#define USE_MAP":"",t.env_map?"#define USE_ENVMAP":"",t.light_map?"#define USE_LIGHTMAP":"",t.vertex_colors?"#define USE_COLOR":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(n,s("fragment",g+r));b.attachShader(n,
-s("vertex",t+i));b.linkProgram(n);b.getProgramParameter(n,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(n,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");n.uniforms={};n.attributes={};e.program=n;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(h in e.uniforms)n.push(h);h=e.program;r=0;for(i=n.length;r<i;r++){g=n[r];h.uniforms[g]=b.getUniformLocation(h,g)}e=e.program;h=["position","normal",
-"uv","uv2","tangent","color"];n=0;for(r=h.length;n<r;n++){i=h[n];e.attributes[i]=b.getAttribLocation(e,i)}};this.setProgram=function(e,i,n,h,g){h.program||this.initMaterial(h,i,n);var t=h.program,w=t.uniforms,u=h.uniforms;if(t!=R){b.useProgram(t);R=t;b.uniformMatrix4fv(w.projectionMatrix,false,M)}if(n&&(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial||h instanceof THREE.LineBasicMaterial||h instanceof THREE.ParticleBasicMaterial)){u.fogColor.value.setHex(n.color.hex);
-if(n instanceof THREE.Fog){u.fogNear.value=n.near;u.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)u.fogDensity.value=n.density}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial){this.setupLights(t,i);i=this.lights;u.enableLighting.value=i.directional.length+i.point.length;u.ambientLightColor.value=i.ambient;u.directionalLightColor.value=i.directional.colors;u.directionalLightDirection.value=i.directional.positions;u.pointLightColor.value=i.point.colors;u.pointLightPosition.value=
-i.point.positions}if(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial){u.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);u.opacity.value=h.opacity;u.map.texture=h.map;u.light_map.texture=h.light_map;u.env_map.texture=h.env_map;u.reflectivity.value=h.reflectivity;u.refraction_ratio.value=h.refraction_ratio;u.combine.value=h.combine;u.useRefract.value=h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping}if(h instanceof
-THREE.LineBasicMaterial){u.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);u.opacity.value=h.opacity}else if(h instanceof THREE.ParticleBasicMaterial){u.psColor.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);u.opacity.value=h.opacity;u.size.value=h.size;u.map.texture=h.map}else if(h instanceof THREE.MeshPhongMaterial){u.ambient.value.setRGB(h.ambient.r,h.ambient.g,h.ambient.b);u.specular.value.setRGB(h.specular.r,h.specular.g,h.specular.b);
-u.shininess.value=h.shininess}else if(h instanceof THREE.MeshDepthMaterial){u.mNear.value=e.near;u.mFar.value=e.far;u.opacity.value=h.opacity}else if(h instanceof THREE.MeshNormalMaterial)u.opacity.value=h.opacity;var r,p,B;for(r in u)if(B=t.uniforms[r]){n=u[r];p=n.type;i=n.value;if(p=="i")b.uniform1i(B,i);else if(p=="f")b.uniform1f(B,i);else if(p=="fv1")b.uniform1fv(B,i);else if(p=="fv")b.uniform3fv(B,i);else if(p=="v2")b.uniform2f(B,i.x,i.y);else if(p=="v3")b.uniform3f(B,i.x,i.y,i.z);else if(p==
-"c")b.uniform3f(B,i.r,i.g,i.b);else if(p=="t"){b.uniform1i(B,i);if(n=n.texture)if(n.image instanceof Array&&n.image.length==6){n=n;i=i;if(n.image.length==6){if(!n.image.__webGLTextureCube&&!n.image.__cubeMapInitialized&&n.image.loadCount==6){n.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,n.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(p=0;p<6;++p)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,n.image[p]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);n.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_CUBE_MAP,n.image.__webGLTextureCube)}}else{n=n;i=i;if(!n.__webGLTexture&&n.image.loaded){n.__webGLTexture=b.createTexture();
-b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,n.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,O(n.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,O(n.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,O(n.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,O(n.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_2D,n.__webGLTexture)}}}b.uniformMatrix4fv(w.modelViewMatrix,
-false,g._modelViewMatrixArray);b.uniformMatrix3fv(w.normalMatrix,false,g._normalMatrixArray);if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshPhongMaterial||h.env_map)b.uniform3f(w.cameraPosition,e.position.x,e.position.y,e.position.z);if(h instanceof THREE.MeshShaderMaterial||h.env_map)b.uniformMatrix4fv(w.objectMatrix,false,g._objectMatrixArray);if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshShaderMaterial)b.uniformMatrix4fv(w.viewMatrix,
-false,D);return t};this.renderBuffer=function(e,i,n,h,g,t){e=this.setProgram(e,i,n,h,t).attributes;b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.vertexAttribPointer(e.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.position);if(e.color>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.vertexAttribPointer(e.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.color)}if(e.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.vertexAttribPointer(e.normal,3,b.FLOAT,
-false,0,0);b.enableVertexAttribArray(e.normal)}if(e.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLTangentBuffer);b.vertexAttribPointer(e.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.tangent)}if(e.uv>=0)if(g.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.vertexAttribPointer(e.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.uv)}else b.disableVertexAttribArray(e.uv);if(e.uv2>=0)if(g.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUV2Buffer);b.vertexAttribPointer(e.uv2,
-2,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.uv2)}else b.disableVertexAttribArray(e.uv2);if(t instanceof THREE.Mesh)if(h.wireframe){b.lineWidth(h.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.drawElements(b.LINES,g.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,g.__webGLFaceCount,b.UNSIGNED_SHORT,0)}else if(t instanceof THREE.Line){t=t.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(h.linewidth);
-b.drawArrays(t,0,g.__webGLLineCount)}else t instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,g.__webGLParticleCount)};this.render=function(e,i,n,h){var g,t,w,u,r,p,B,V=e.lights,da=e.fog;i.autoUpdateMatrix&&i.updateMatrix();i.matrix.flattenToArray(D);i.projectionMatrix.flattenToArray(M);U.multiply(i.projectionMatrix,i.matrix);k(U);this.initWebGLObjects(e,i);I(n,h!==undefined?h:true);this.autoClear&&this.clear();u=e.__webGLObjects.length;for(h=0;h<u;h++){g=e.__webGLObjects[h];p=g.object;if(p.visible){if(g.root){p.autoUpdateMatrix&&
-p.updateMatrix();p.matrixWorld.copy(p.matrix);z(p)}if(!(p instanceof THREE.Mesh)||q(p)){p.matrixWorld.flattenToArray(p._objectMatrixArray);F(p,i);m(g);g.render=true}else g.render=false}else g.render=false}r=e.__webGLObjectsImmediate.length;for(h=0;h<r;h++){g=e.__webGLObjectsImmediate[h];p=g.object;if(p.visible){if(p.autoUpdateMatrix){p.updateMatrix();p.matrixWorld.copy(p.matrix);p.matrixWorld.flattenToArray(p._objectMatrixArray)}F(p,i);l(g)}}H(THREE.NormalBlending);for(h=0;h<u;h++){g=e.__webGLObjects[h];
-if(g.render){p=g.object;B=g.buffer;w=g.opaque;j(p);for(g=0;g<w.count;g++){material=w.list[g];this.setDepthTest(material.depth_test);this.renderBuffer(i,V,da,material,B,p)}}}for(h=0;h<r;h++){g=e.__webGLObjectsImmediate[h];p=g.object;if(p.visible){w=g.opaque;j(p);for(g=0;g<w.count;g++){material=w.list[g];this.setDepthTest(material.depth_test);t=this.setProgram(i,V,da,material,p);p.render(function(ea){f(ea,t)})}}}for(h=0;h<u;h++){g=e.__webGLObjects[h];if(g.render){p=g.object;B=g.buffer;w=g.transparent;
-j(p);for(g=0;g<w.count;g++){material=w.list[g];H(material.blending);this.setDepthTest(material.depth_test);this.renderBuffer(i,V,da,material,B,p)}}}for(h=0;h<r;h++){g=e.__webGLObjectsImmediate[h];p=g.object;if(p.visible){w=g.transparent;j(p);for(g=0;g<w.count;g++){material=w.list[g];H(material.blending);this.setDepthTest(material.depth_test);t=this.setProgram(i,V,da,material,p);p.render(function(ea){f(ea,t)})}}}if(n&&n.min_filter!==THREE.NearestFilter&&n.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,
-n.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(e){var i,n,h;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={};e.__webGLObjectsImmediate=[]}i=0;for(n=e.objects.length;i<n;i++){h=e.objects[i];v(e,h,true);y(e,h)}};this.removeObject=function(e,i){var n,h;for(n=e.__webGLObjects.length-1;n>=0;n--){h=e.__webGLObjects[n].object;i==h&&e.__webGLObjects.splice(n,1)}};this.setDepthTest=function(e){e?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};
-this.setFaceCulling=function(e,i){if(e){!i||i=="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)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
-THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
-envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",
-envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
-map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",
-lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
+THREE.Fog=function(a,c,e){this.color=new THREE.Color(a);this.near=c||1;this.far=e||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
+THREE.Projector=function(){function a(P,J){return J.z-P.z}function c(P,J){var W=0,M=1,R=P.z+P.w,K=J.z+J.w,C=-P.z+P.w,L=-J.z+J.w;if(R>=0&&K>=0&&C>=0&&L>=0)return true;else if(R<0&&K<0||C<0&&L<0)return false;else{if(R<0)W=Math.max(W,R/(R-K));else if(K<0)M=Math.min(M,R/(R-K));if(C<0)W=Math.max(W,C/(C-L));else if(L<0)M=Math.min(M,C/(C-L));if(M<W)return false;else{P.lerpSelf(J,W);J.lerpSelf(P,1-M);return true}}}var e,g,i=[],k,q,p,l=[],m,z,A=[],t,y,D=[],H=new THREE.Vector4,G=new THREE.Vector4,r=new THREE.Matrix4,
+S=new THREE.Matrix4,B=[],I=new THREE.Vector4,b=new THREE.Vector4,aa;this.projectObjects=function(P,J,W){var M=[],R,K;g=0;r.multiply(J.projectionMatrix,J.matrix);B[0]=new THREE.Vector4(r.n41-r.n11,r.n42-r.n12,r.n43-r.n13,r.n44-r.n14);B[1]=new THREE.Vector4(r.n41+r.n11,r.n42+r.n12,r.n43+r.n13,r.n44+r.n14);B[2]=new THREE.Vector4(r.n41+r.n21,r.n42+r.n22,r.n43+r.n23,r.n44+r.n24);B[3]=new THREE.Vector4(r.n41-r.n21,r.n42-r.n22,r.n43-r.n23,r.n44-r.n24);B[4]=new THREE.Vector4(r.n41-r.n31,r.n42-r.n32,r.n43-
+r.n33,r.n44-r.n34);B[5]=new THREE.Vector4(r.n41+r.n31,r.n42+r.n32,r.n43+r.n33,r.n44+r.n34);J=0;for(R=B.length;J<R;J++){K=B[J];K.divideScalar(Math.sqrt(K.x*K.x+K.y*K.y+K.z*K.z))}R=P.objects;P=0;for(J=R.length;P<J;P++){K=R[P];var C;if(!(C=!K.visible)){if(C=K instanceof THREE.Mesh){a:{C=void 0;for(var L=K.position,ba=-K.geometry.boundingSphere.radius*Math.max(K.scale.x,Math.max(K.scale.y,K.scale.z)),N=0;N<6;N++){C=B[N].x*L.x+B[N].y*L.y+B[N].z*L.z+B[N].w;if(C<=ba){C=false;break a}}C=true}C=!C}C=C}if(!C){e=
+i[g]=i[g]||new THREE.RenderableObject;H.copy(K.position);r.multiplyVector3(H);e.object=K;e.z=H.z;M.push(e);g++}}W&&M.sort(a);return M};this.projectScene=function(P,J,W){var M=[],R=J.near,K=J.far,C,L,ba,N,da,ca,d,j,o,h,f,v,u,n,w,s;p=z=y=0;J.autoUpdateMatrix&&J.updateMatrix();r.multiply(J.projectionMatrix,J.matrix);ca=this.projectObjects(P,J,true);P=0;for(C=ca.length;P<C;P++){d=ca[P].object;if(d.visible){d.autoUpdateMatrix&&d.updateMatrix();j=d.matrix;o=d.rotationMatrix;h=d.materials;f=d.overdraw;if(d instanceof
+THREE.Mesh){v=d.geometry;u=v.vertices;L=0;for(ba=u.length;L<ba;L++){n=u[L];n.positionWorld.copy(n.position);j.multiplyVector3(n.positionWorld);N=n.positionScreen;N.copy(n.positionWorld);r.multiplyVector4(N);N.x/=N.w;N.y/=N.w;n.__visible=N.z>R&&N.z<K}v=v.faces;L=0;for(ba=v.length;L<ba;L++){n=v[L];if(n instanceof THREE.Face3){N=u[n.a];da=u[n.b];w=u[n.c];if(N.__visible&&da.__visible&&w.__visible)if(d.doubleSided||d.flipSided!=(w.positionScreen.x-N.positionScreen.x)*(da.positionScreen.y-N.positionScreen.y)-
+(w.positionScreen.y-N.positionScreen.y)*(da.positionScreen.x-N.positionScreen.x)<0){k=l[p]=l[p]||new THREE.RenderableFace3;k.v1.positionWorld.copy(N.positionWorld);k.v2.positionWorld.copy(da.positionWorld);k.v3.positionWorld.copy(w.positionWorld);k.v1.positionScreen.copy(N.positionScreen);k.v2.positionScreen.copy(da.positionScreen);k.v3.positionScreen.copy(w.positionScreen);k.normalWorld.copy(n.normal);o.multiplyVector3(k.normalWorld);k.centroidWorld.copy(n.centroid);j.multiplyVector3(k.centroidWorld);
+k.centroidScreen.copy(k.centroidWorld);r.multiplyVector3(k.centroidScreen);w=n.vertexNormals;aa=k.vertexNormalsWorld;N=0;for(da=w.length;N<da;N++){s=aa[N]=aa[N]||new THREE.Vector3;s.copy(w[N]);o.multiplyVector3(s)}k.z=k.centroidScreen.z;k.meshMaterials=h;k.faceMaterials=n.materials;k.overdraw=f;if(d.geometry.uvs[L]){k.uvs[0]=d.geometry.uvs[L][0];k.uvs[1]=d.geometry.uvs[L][1];k.uvs[2]=d.geometry.uvs[L][2]}M.push(k);p++}}else if(n instanceof THREE.Face4){N=u[n.a];da=u[n.b];w=u[n.c];s=u[n.d];if(N.__visible&&
+da.__visible&&w.__visible&&s.__visible)if(d.doubleSided||d.flipSided!=((s.positionScreen.x-N.positionScreen.x)*(da.positionScreen.y-N.positionScreen.y)-(s.positionScreen.y-N.positionScreen.y)*(da.positionScreen.x-N.positionScreen.x)<0||(da.positionScreen.x-w.positionScreen.x)*(s.positionScreen.y-w.positionScreen.y)-(da.positionScreen.y-w.positionScreen.y)*(s.positionScreen.x-w.positionScreen.x)<0)){k=l[p]=l[p]||new THREE.RenderableFace3;k.v1.positionWorld.copy(N.positionWorld);k.v2.positionWorld.copy(da.positionWorld);
+k.v3.positionWorld.copy(s.positionWorld);k.v1.positionScreen.copy(N.positionScreen);k.v2.positionScreen.copy(da.positionScreen);k.v3.positionScreen.copy(s.positionScreen);k.normalWorld.copy(n.normal);o.multiplyVector3(k.normalWorld);k.centroidWorld.copy(n.centroid);j.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);r.multiplyVector3(k.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterials=h;k.faceMaterials=n.materials;k.overdraw=f;if(d.geometry.uvs[L]){k.uvs[0]=d.geometry.uvs[L][0];
+k.uvs[1]=d.geometry.uvs[L][1];k.uvs[2]=d.geometry.uvs[L][3]}M.push(k);p++;q=l[p]=l[p]||new THREE.RenderableFace3;q.v1.positionWorld.copy(da.positionWorld);q.v2.positionWorld.copy(w.positionWorld);q.v3.positionWorld.copy(s.positionWorld);q.v1.positionScreen.copy(da.positionScreen);q.v2.positionScreen.copy(w.positionScreen);q.v3.positionScreen.copy(s.positionScreen);q.normalWorld.copy(k.normalWorld);q.centroidWorld.copy(k.centroidWorld);q.centroidScreen.copy(k.centroidScreen);q.z=q.centroidScreen.z;
+q.meshMaterials=h;q.faceMaterials=n.materials;q.overdraw=f;if(d.geometry.uvs[L]){q.uvs[0]=d.geometry.uvs[L][1];q.uvs[1]=d.geometry.uvs[L][2];q.uvs[2]=d.geometry.uvs[L][3]}M.push(q);p++}}}}else if(d instanceof THREE.Line){S.multiply(r,j);u=d.geometry.vertices;n=u[0];n.positionScreen.copy(n.position);S.multiplyVector4(n.positionScreen);L=1;for(ba=u.length;L<ba;L++){N=u[L];N.positionScreen.copy(N.position);S.multiplyVector4(N.positionScreen);da=u[L-1];I.copy(N.positionScreen);b.copy(da.positionScreen);
+if(c(I,b)){I.multiplyScalar(1/I.w);b.multiplyScalar(1/b.w);m=A[z]=A[z]||new THREE.RenderableLine;m.v1.positionScreen.copy(I);m.v2.positionScreen.copy(b);m.z=Math.max(I.z,b.z);m.materials=d.materials;M.push(m);z++}}}else if(d instanceof THREE.Particle){G.set(d.position.x,d.position.y,d.position.z,1);r.multiplyVector4(G);G.z/=G.w;if(G.z>0&&G.z<1){t=D[y]=D[y]||new THREE.RenderableParticle;t.x=G.x/G.w;t.y=G.y/G.w;t.z=G.z;t.rotation=d.rotation.z;t.scale.x=d.scale.x*Math.abs(t.x-(G.x+J.projectionMatrix.n11)/
+(G.w+J.projectionMatrix.n14));t.scale.y=d.scale.y*Math.abs(t.y-(G.y+J.projectionMatrix.n22)/(G.w+J.projectionMatrix.n24));t.materials=d.materials;M.push(t);y++}}}}W&&M.sort(a);return M};this.unprojectVector=function(P,J){var W=THREE.Matrix4.makeInvert(J.matrix);W.multiplySelf(THREE.Matrix4.makeInvert(J.projectionMatrix));W.multiplyVector3(P);return P}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,e,g,i,k;this.domElement=document.createElement("div");this.setSize=function(q,p){e=q;g=p;i=e/2;k=g/2};this.render=function(q,p){var l,m,z,A,t,y,D,H;a=c.projectScene(q,p);l=0;for(m=a.length;l<m;l++){t=a[l];if(t instanceof THREE.RenderableParticle){D=t.x*i+i;H=t.y*k+k;z=0;for(A=t.material.length;z<A;z++){y=t.material[z];if(y instanceof THREE.ParticleDOMMaterial){y=y.domElement;y.style.left=D+"px";y.style.top=H+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(V){if(t!=V)m.globalAlpha=t=V}function c(V){if(y!=V){switch(V){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}y=V}}var e=null,g=new THREE.Projector,i=document.createElement("canvas"),k,q,p,l,m=i.getContext("2d"),z=new THREE.Color(0),A=0,t=1,y=0,D=null,H=null,G=1,r,S,B,I,b,aa,P,J,W,M=new THREE.Color,
+R=new THREE.Color,K=new THREE.Color,C=new THREE.Color,L=new THREE.Color,ba,N,da,ca,d,j,o,h,f,v=new THREE.Rectangle,u=new THREE.Rectangle,n=new THREE.Rectangle,w=false,s=new THREE.Color,O=new THREE.Color,Y=new THREE.Color,ga=new THREE.Color,ia=Math.PI*2,U=new THREE.Vector3,ea,Z,qa,F,ua,oa,ra=16;ea=document.createElement("canvas");ea.width=ea.height=2;Z=ea.getContext("2d");Z.fillStyle="rgba(0,0,0,1)";Z.fillRect(0,0,2,2);qa=Z.getImageData(0,0,2,2);F=qa.data;ua=document.createElement("canvas");ua.width=
+ua.height=ra;oa=ua.getContext("2d");oa.translate(-ra/2,-ra/2);oa.scale(ra,ra);ra--;this.domElement=i;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(V,fa){k=V;q=fa;p=k/2;l=q/2;i.width=k;i.height=q;v.set(-p,-l,p,l);t=1;y=0;H=D=null;G=1};this.setClearColor=function(V,fa){z=V;A=fa;u.set(-p,-l,p,l);m.setTransform(1,0,0,-1,p,l);this.clear()};this.setClearColorHex=function(V,fa){z.setHex(V);A=fa;u.set(-p,-l,p,l);m.setTransform(1,0,0,-1,p,l);this.clear()};this.clear=function(){m.setTransform(1,
+0,0,-1,p,l);if(!u.isEmpty()){u.inflate(1);u.minSelf(v);if(z.hex==0&&A==0)m.clearRect(u.getX(),u.getY(),u.getWidth(),u.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(z.r*255)+","+Math.floor(z.g*255)+","+Math.floor(z.b*255)+","+A+")";m.fillRect(u.getX(),u.getY(),u.getWidth(),u.getHeight())}u.empty()}};this.render=function(V,fa){function ja(x){var X,T,E,Q=x.lights;O.setRGB(0,0,0);Y.setRGB(0,0,0);ga.setRGB(0,0,0);x=0;for(X=Q.length;x<X;x++){T=Q[x];E=T.color;if(T instanceof
+THREE.AmbientLight){O.r+=E.r;O.g+=E.g;O.b+=E.b}else if(T instanceof THREE.DirectionalLight){Y.r+=E.r;Y.g+=E.g;Y.b+=E.b}else if(T instanceof THREE.PointLight){ga.r+=E.r;ga.g+=E.g;ga.b+=E.b}}}function za(x,X,T,E){var Q,$,pa,wa,ya=x.lights;x=0;for(Q=ya.length;x<Q;x++){$=ya[x];pa=$.color;wa=$.intensity;if($ instanceof THREE.DirectionalLight){$=T.dot($.position)*wa;if($>0){E.r+=pa.r*$;E.g+=pa.g*$;E.b+=pa.b*$}}else if($ instanceof THREE.PointLight){U.sub($.position,X);U.normalize();$=T.dot(U)*wa;if($>0){E.r+=
+pa.r*$;E.g+=pa.g*$;E.b+=pa.b*$}}}}function va(x,X,T){if(T.opacity!=0){a(T.opacity);c(T.blending);var E,Q,$,pa,wa,ya;if(T instanceof THREE.ParticleBasicMaterial){if(T.map&&T.map.image.loaded){pa=T.map.image;wa=pa.width>>1;ya=pa.height>>1;Q=X.scale.x*p;$=X.scale.y*l;T=Q*wa;E=$*ya;n.set(x.x-T,x.y-E,x.x+T,x.y+E);if(!v.instersects(n))return;m.save();m.translate(x.x,x.y);m.rotate(-X.rotation);m.scale(Q,-$);m.translate(-wa,-ya);m.drawImage(pa,0,0);m.restore()}m.beginPath();m.moveTo(x.x-10,x.y);m.lineTo(x.x+
+10,x.y);m.moveTo(x.x,x.y-10);m.lineTo(x.x,x.y+10);m.closePath();m.strokeStyle="rgb(255,255,0)";m.stroke()}else if(T instanceof THREE.ParticleCircleMaterial){if(w){s.r=O.r+Y.r+ga.r;s.g=O.g+Y.g+ga.g;s.b=O.b+Y.b+ga.b;M.r=T.color.r*s.r;M.g=T.color.g*s.g;M.b=T.color.b*s.b;M.updateStyleString()}else M.__styleString=T.color.__styleString;T=X.scale.x*p;E=X.scale.y*l;n.set(x.x-T,x.y-E,x.x+T,x.y+E);if(v.instersects(n)){Q=M.__styleString;if(H!=Q)m.fillStyle=H=Q;m.save();m.translate(x.x,x.y);m.rotate(-X.rotation);
+m.scale(T,E);m.beginPath();m.arc(0,0,1,0,ia,true);m.closePath();m.fill();m.restore()}}}}function ma(x,X,T,E){if(E.opacity!=0){a(E.opacity);c(E.blending);m.beginPath();m.moveTo(x.positionScreen.x,x.positionScreen.y);m.lineTo(X.positionScreen.x,X.positionScreen.y);m.closePath();if(E instanceof THREE.LineBasicMaterial){M.__styleString=E.color.__styleString;x=E.linewidth;if(G!=x)m.lineWidth=G=x;x=M.__styleString;if(D!=x)m.strokeStyle=D=x;m.stroke();n.inflate(E.linewidth*2)}}}function na(x,X,T,E,Q,$){if(Q.opacity!=
+0){a(Q.opacity);c(Q.blending);I=x.positionScreen.x;b=x.positionScreen.y;aa=X.positionScreen.x;P=X.positionScreen.y;J=T.positionScreen.x;W=T.positionScreen.y;m.beginPath();m.moveTo(I,b);m.lineTo(aa,P);m.lineTo(J,W);m.lineTo(I,b);m.closePath();if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&sa(I,b,aa,P,J,W,Q.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);else if(Q.env_map){if(Q.env_map.image.loaded)if(Q.env_map.mapping instanceof
+THREE.SphericalReflectionMapping){x=fa.matrix;U.copy(E.vertexNormalsWorld[0]);ca=(U.x*x.n11+U.y*x.n12+U.z*x.n13)*0.5+0.5;d=-(U.x*x.n21+U.y*x.n22+U.z*x.n23)*0.5+0.5;U.copy(E.vertexNormalsWorld[1]);j=(U.x*x.n11+U.y*x.n12+U.z*x.n13)*0.5+0.5;o=-(U.x*x.n21+U.y*x.n22+U.z*x.n23)*0.5+0.5;U.copy(E.vertexNormalsWorld[2]);h=(U.x*x.n11+U.y*x.n12+U.z*x.n13)*0.5+0.5;f=-(U.x*x.n21+U.y*x.n22+U.z*x.n23)*0.5+0.5;sa(I,b,aa,P,J,W,Q.env_map.image,ca,d,j,o,h,f)}}else Q.wireframe?Ea(Q.color.__styleString,Q.wireframe_linewidth):
+Fa(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&!Q.wireframe){Q.map.mapping instanceof THREE.UVMapping&&sa(I,b,aa,P,J,W,Q.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);c(THREE.SubtractiveBlending)}if(w)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){R.r=K.r=C.r=O.r;R.g=K.g=C.g=O.g;R.b=K.b=C.b=O.b;za($,E.v1.positionWorld,E.vertexNormalsWorld[0],R);za($,E.v2.positionWorld,E.vertexNormalsWorld[1],K);za($,
+E.v3.positionWorld,E.vertexNormalsWorld[2],C);L.r=(K.r+C.r)*0.5;L.g=(K.g+C.g)*0.5;L.b=(K.b+C.b)*0.5;da=ha(R,K,C,L);sa(I,b,aa,P,J,W,da,0,0,1,0,0,1)}else{s.r=O.r;s.g=O.g;s.b=O.b;za($,E.centroidWorld,E.normalWorld,s);M.r=Q.color.r*s.r;M.g=Q.color.g*s.g;M.b=Q.color.b*s.b;M.updateStyleString();Q.wireframe?Ea(M.__styleString,Q.wireframe_linewidth):Fa(M.__styleString)}else Q.wireframe?Ea(Q.color.__styleString,Q.wireframe_linewidth):Fa(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){ba=
+fa.near;N=fa.far;R.r=R.g=R.b=1-la(x.positionScreen.z,ba,N);K.r=K.g=K.b=1-la(X.positionScreen.z,ba,N);C.r=C.g=C.b=1-la(T.positionScreen.z,ba,N);L.r=(K.r+C.r)*0.5;L.g=(K.g+C.g)*0.5;L.b=(K.b+C.b)*0.5;da=ha(R,K,C,L);sa(I,b,aa,P,J,W,da,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){M.r=Aa(E.normalWorld.x);M.g=Aa(E.normalWorld.y);M.b=Aa(E.normalWorld.z);M.updateStyleString();Q.wireframe?Ea(M.__styleString,Q.wireframe_linewidth):Fa(M.__styleString)}}}function Ea(x,X){if(D!=x)m.strokeStyle=D=
+x;if(G!=X)m.lineWidth=G=X;m.stroke();n.inflate(X*2)}function Fa(x){if(H!=x)m.fillStyle=H=x;m.fill()}function sa(x,X,T,E,Q,$,pa,wa,ya,Ha,Da,Ia,Oa){var Ga,Ja;Ga=pa.width-1;Ja=pa.height-1;wa*=Ga;ya*=Ja;Ha*=Ga;Da*=Ja;Ia*=Ga;Oa*=Ja;T-=x;E-=X;Q-=x;$-=X;Ha-=wa;Da-=ya;Ia-=wa;Oa-=ya;Ga=Ha*Oa-Ia*Da;if(Ga!=0){Ja=1/Ga;Ga=(Oa*T-Da*Q)*Ja;Da=(Oa*E-Da*$)*Ja;T=(Ha*Q-Ia*T)*Ja;E=(Ha*$-Ia*E)*Ja;x=x-Ga*wa-T*ya;X=X-Da*wa-E*ya;m.save();m.transform(Ga,Da,T,E,x,X);m.clip();m.drawImage(pa,0,0);m.restore()}}function ha(x,X,
+T,E){var Q=~~(x.r*255),$=~~(x.g*255);x=~~(x.b*255);var pa=~~(X.r*255),wa=~~(X.g*255);X=~~(X.b*255);var ya=~~(T.r*255),Ha=~~(T.g*255);T=~~(T.b*255);var Da=~~(E.r*255),Ia=~~(E.g*255);E=~~(E.b*255);F[0]=Q<0?0:Q>255?255:Q;F[1]=$<0?0:$>255?255:$;F[2]=x<0?0:x>255?255:x;F[4]=pa<0?0:pa>255?255:pa;F[5]=wa<0?0:wa>255?255:wa;F[6]=X<0?0:X>255?255:X;F[8]=ya<0?0:ya>255?255:ya;F[9]=Ha<0?0:Ha>255?255:Ha;F[10]=T<0?0:T>255?255:T;F[12]=Da<0?0:Da>255?255:Da;F[13]=Ia<0?0:Ia>255?255:Ia;F[14]=E<0?0:E>255?255:E;Z.putImageData(qa,
+0,0);oa.drawImage(ea,0,0);return ua}function la(x,X,T){x=(x-X)/(T-X);return x*x*(3-2*x)}function Aa(x){x=(x+1)*0.5;return x<0?0:x>1?1:x}function ta(x,X){var T=X.x-x.x,E=X.y-x.y,Q=1/Math.sqrt(T*T+E*E);T*=Q;E*=Q;X.x+=T;X.y+=E;x.x-=T;x.y-=E}var La,xa,ka,Ba,Ca,Ma,Na,Ka;this.autoClear?this.clear():m.setTransform(1,0,0,-1,p,l);e=g.projectScene(V,fa,this.sortElements);m.fillStyle="rgba( 0, 255, 255, 0.5 )";m.fillRect(v.getX(),v.getY(),v.getWidth(),v.getHeight());(w=V.lights.length>0)&&ja(V);La=0;for(xa=
+e.length;La<xa;La++){ka=e[La];n.empty();if(ka instanceof THREE.RenderableParticle){r=ka;r.x*=p;r.y*=l;Ba=0;for(Ca=ka.materials.length;Ba<Ca;Ba++)va(r,ka,ka.materials[Ba],V)}else if(ka instanceof THREE.RenderableLine){r=ka.v1;S=ka.v2;r.positionScreen.x*=p;r.positionScreen.y*=l;S.positionScreen.x*=p;S.positionScreen.y*=l;n.addPoint(r.positionScreen.x,r.positionScreen.y);n.addPoint(S.positionScreen.x,S.positionScreen.y);if(v.instersects(n)){Ba=0;for(Ca=ka.materials.length;Ba<Ca;)ma(r,S,ka,ka.materials[Ba++],
+V)}}else if(ka instanceof THREE.RenderableFace3){r=ka.v1;S=ka.v2;B=ka.v3;r.positionScreen.x*=p;r.positionScreen.y*=l;S.positionScreen.x*=p;S.positionScreen.y*=l;B.positionScreen.x*=p;B.positionScreen.y*=l;if(ka.overdraw){ta(r.positionScreen,S.positionScreen);ta(S.positionScreen,B.positionScreen);ta(B.positionScreen,r.positionScreen)}n.add3Points(r.positionScreen.x,r.positionScreen.y,S.positionScreen.x,S.positionScreen.y,B.positionScreen.x,B.positionScreen.y);if(v.instersects(n)){Ba=0;for(Ca=ka.meshMaterials.length;Ba<
+Ca;){Ka=ka.meshMaterials[Ba++];if(Ka instanceof THREE.MeshFaceMaterial){Ma=0;for(Na=ka.faceMaterials.length;Ma<Na;)(Ka=ka.faceMaterials[Ma++])&&na(r,S,B,ka,Ka,V)}else na(r,S,B,ka,Ka,V)}}}u.addRectangle(n)}m.lineWidth=1;m.strokeStyle="rgba( 255, 0, 0, 0.5 )";m.strokeRect(u.getX(),u.getY(),u.getWidth(),u.getHeight());m.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(ca,d,j){var o,h,f,v;o=0;for(h=ca.lights.length;o<h;o++){f=ca.lights[o];if(f instanceof THREE.DirectionalLight){v=d.normalWorld.dot(f.position)*f.intensity;if(v>0){j.r+=f.color.r*v;j.g+=f.color.g*v;j.b+=f.color.b*v}}else if(f instanceof THREE.PointLight){W.sub(f.position,d.centroidWorld);W.normalize();v=d.normalWorld.dot(W)*f.intensity;if(v>0){j.r+=f.color.r*v;j.g+=f.color.g*v;j.b+=f.color.b*v}}}}function c(ca,d,j,o,h,f){C=g(L++);C.setAttribute("d","M "+ca.positionScreen.x+
+" "+ca.positionScreen.y+" L "+d.positionScreen.x+" "+d.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+"z");if(h instanceof THREE.MeshBasicMaterial)B.__styleString=h.color.__styleString;else if(h instanceof THREE.MeshLambertMaterial)if(S){I.r=b.r;I.g=b.g;I.b=b.b;a(f,o,I);B.r=h.color.r*I.r;B.g=h.color.g*I.g;B.b=h.color.b*I.b;B.updateStyleString()}else B.__styleString=h.color.__styleString;else if(h instanceof THREE.MeshDepthMaterial){J=1-h.__2near/(h.__farPlusNear-o.z*h.__farMinusNear);
+B.setRGB(J,J,J)}else h instanceof THREE.MeshNormalMaterial&&B.setRGB(i(o.normalWorld.x),i(o.normalWorld.y),i(o.normalWorld.z));h.wireframe?C.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+h.wireframe_linewidth+"; stroke-opacity: "+h.opacity+"; stroke-linecap: "+h.wireframe_linecap+"; stroke-linejoin: "+h.wireframe_linejoin):C.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+h.opacity);p.appendChild(C)}function e(ca,d,j,o,h,f,v){C=g(L++);C.setAttribute("d",
+"M "+ca.positionScreen.x+" "+ca.positionScreen.y+" L "+d.positionScreen.x+" "+d.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+" L "+o.positionScreen.x+","+o.positionScreen.y+"z");if(f instanceof THREE.MeshBasicMaterial)B.__styleString=f.color.__styleString;else if(f instanceof THREE.MeshLambertMaterial)if(S){I.r=b.r;I.g=b.g;I.b=b.b;a(v,h,I);B.r=f.color.r*I.r;B.g=f.color.g*I.g;B.b=f.color.b*I.b;B.updateStyleString()}else B.__styleString=f.color.__styleString;else if(f instanceof
+THREE.MeshDepthMaterial){J=1-f.__2near/(f.__farPlusNear-h.z*f.__farMinusNear);B.setRGB(J,J,J)}else f instanceof THREE.MeshNormalMaterial&&B.setRGB(i(h.normalWorld.x),i(h.normalWorld.y),i(h.normalWorld.z));f.wireframe?C.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+f.wireframe_linewidth+"; stroke-opacity: "+f.opacity+"; stroke-linecap: "+f.wireframe_linecap+"; stroke-linejoin: "+f.wireframe_linejoin):C.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+
+f.opacity);p.appendChild(C)}function g(ca){if(M[ca]==null){M[ca]=document.createElementNS("http://www.w3.org/2000/svg","path");da==0&&M[ca].setAttribute("shape-rendering","crispEdges");return M[ca]}return M[ca]}function i(ca){return ca<0?Math.min((1+ca)*0.5,0.5):0.5+Math.min(ca*0.5,0.5)}var k=null,q=new THREE.Projector,p=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,m,z,A,t,y,D,H,G=new THREE.Rectangle,r=new THREE.Rectangle,S=false,B=new THREE.Color(16777215),I=new THREE.Color(16777215),
+b=new THREE.Color(0),aa=new THREE.Color(0),P=new THREE.Color(0),J,W=new THREE.Vector3,M=[],R=[],K=[],C,L,ba,N,da=1;this.domElement=p;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(ca){switch(ca){case "high":da=1;break;case "low":da=0}};this.setSize=function(ca,d){l=ca;m=d;z=l/2;A=m/2;p.setAttribute("viewBox",-z+" "+-A+" "+l+" "+m);p.setAttribute("width",l);p.setAttribute("height",m);G.set(-z,-A,z,A)};this.clear=function(){for(;p.childNodes.length>0;)p.removeChild(p.childNodes[0])};
+this.render=function(ca,d){var j,o,h,f,v,u,n,w;this.autoClear&&this.clear();k=q.projectScene(ca,d,this.sortElements);N=ba=L=0;if(S=ca.lights.length>0){n=ca.lights;b.setRGB(0,0,0);aa.setRGB(0,0,0);P.setRGB(0,0,0);j=0;for(o=n.length;j<o;j++){h=n[j];f=h.color;if(h instanceof THREE.AmbientLight){b.r+=f.r;b.g+=f.g;b.b+=f.b}else if(h instanceof THREE.DirectionalLight){aa.r+=f.r;aa.g+=f.g;aa.b+=f.b}else if(h instanceof THREE.PointLight){P.r+=f.r;P.g+=f.g;P.b+=f.b}}}j=0;for(o=k.length;j<o;j++){n=k[j];r.empty();
+if(n instanceof THREE.RenderableParticle){t=n;t.x*=z;t.y*=-A;h=0;for(f=n.materials.length;h<f;h++)if(w=n.materials[h]){v=t;u=n;w=w;var s=ba++;if(R[s]==null){R[s]=document.createElementNS("http://www.w3.org/2000/svg","circle");da==0&&R[s].setAttribute("shape-rendering","crispEdges")}C=R[s];C.setAttribute("cx",v.x);C.setAttribute("cy",v.y);C.setAttribute("r",u.scale.x*z);if(w instanceof THREE.ParticleCircleMaterial){if(S){I.r=b.r+aa.r+P.r;I.g=b.g+aa.g+P.g;I.b=b.b+aa.b+P.b;B.r=w.color.r*I.r;B.g=w.color.g*
+I.g;B.b=w.color.b*I.b;B.updateStyleString()}else B=w.color;C.setAttribute("style","fill: "+B.__styleString)}p.appendChild(C)}}else if(n instanceof THREE.RenderableLine){t=n.v1;y=n.v2;t.positionScreen.x*=z;t.positionScreen.y*=-A;y.positionScreen.x*=z;y.positionScreen.y*=-A;r.addPoint(t.positionScreen.x,t.positionScreen.y);r.addPoint(y.positionScreen.x,y.positionScreen.y);if(G.instersects(r)){h=0;for(f=n.materials.length;h<f;)if(w=n.materials[h++]){v=t;u=y;w=w;s=N++;if(K[s]==null){K[s]=document.createElementNS("http://www.w3.org/2000/svg",
+"line");da==0&&K[s].setAttribute("shape-rendering","crispEdges")}C=K[s];C.setAttribute("x1",v.positionScreen.x);C.setAttribute("y1",v.positionScreen.y);C.setAttribute("x2",u.positionScreen.x);C.setAttribute("y2",u.positionScreen.y);if(w instanceof THREE.LineBasicMaterial){B.__styleString=w.color.__styleString;C.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+w.linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.linecap+"; stroke-linejoin: "+w.linejoin);p.appendChild(C)}}}}else if(n instanceof
+THREE.RenderableFace3){t=n.v1;y=n.v2;D=n.v3;t.positionScreen.x*=z;t.positionScreen.y*=-A;y.positionScreen.x*=z;y.positionScreen.y*=-A;D.positionScreen.x*=z;D.positionScreen.y*=-A;r.addPoint(t.positionScreen.x,t.positionScreen.y);r.addPoint(y.positionScreen.x,y.positionScreen.y);r.addPoint(D.positionScreen.x,D.positionScreen.y);if(G.instersects(r)){h=0;for(f=n.meshMaterials.length;h<f;){w=n.meshMaterials[h++];if(w instanceof THREE.MeshFaceMaterial){v=0;for(u=n.faceMaterials.length;v<u;)(w=n.faceMaterials[v++])&&
+c(t,y,D,n,w,ca)}else w&&c(t,y,D,n,w,ca)}}}else if(n instanceof THREE.RenderableFace4){t=n.v1;y=n.v2;D=n.v3;H=n.v4;t.positionScreen.x*=z;t.positionScreen.y*=-A;y.positionScreen.x*=z;y.positionScreen.y*=-A;D.positionScreen.x*=z;D.positionScreen.y*=-A;H.positionScreen.x*=z;H.positionScreen.y*=-A;r.addPoint(t.positionScreen.x,t.positionScreen.y);r.addPoint(y.positionScreen.x,y.positionScreen.y);r.addPoint(D.positionScreen.x,D.positionScreen.y);r.addPoint(H.positionScreen.x,H.positionScreen.y);if(G.instersects(r)){h=
+0;for(f=n.meshMaterials.length;h<f;){w=n.meshMaterials[h++];if(w instanceof THREE.MeshFaceMaterial){v=0;for(u=n.faceMaterials.length;v<u;)(w=n.faceMaterials[v++])&&e(t,y,D,H,n,w,ca)}else w&&e(t,y,D,H,n,w,ca)}}}}}};
+THREE.WebGLRenderer=function(a){function c(d,j,o){var h,f,v,u=d.vertices,n=u.length,w=d.colors,s=w.length,O=d.__vertexArray,Y=d.__colorArray,ga=d.__sortArray,ia=d.__dirtyVertices,U=d.__dirtyColors;if(o.sortParticles){K.multiplySelf(o.matrixWorld);for(h=0;h<n;h++){f=u[h].position;ba.copy(f);K.multiplyVector3(ba);ga[h]=[ba.z,h]}ga.sort(function(ea,Z){return Z[0]-ea[0]});for(h=0;h<n;h++){f=u[ga[h][1]].position;v=h*3;O[v]=f.x;O[v+1]=f.y;O[v+2]=f.z}for(h=0;h<s;h++){v=h*3;color=w[ga[h][1]];Y[v]=color.r;
+Y[v+1]=color.g;Y[v+2]=color.b}}else{if(ia)for(h=0;h<n;h++){f=u[h].position;v=h*3;O[v]=f.x;O[v+1]=f.y;O[v+2]=f.z}if(U)for(h=0;h<s;h++){color=w[h];v=h*3;Y[v]=color.r;Y[v+1]=color.g;Y[v+2]=color.b}}if(ia||o.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,O,j)}if(U||o.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,Y,j)}}function e(d,j){d.fragment_shader=j.fragment_shader;d.vertex_shader=j.vertex_shader;d.uniforms=
+Uniforms.clone(j.uniforms)}function g(d,j){if(!d.__webGLVertexBuffer)d.__webGLVertexBuffer=b.createBuffer();if(!d.__webGLNormalBuffer)d.__webGLNormalBuffer=b.createBuffer();if(d.hasPos){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,d.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(j.attributes.position);b.vertexAttribPointer(j.attributes.position,3,b.FLOAT,false,0,0)}if(d.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,
+d.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(j.attributes.normal);b.vertexAttribPointer(j.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,d.count);d.count=0}function i(d){if(J!=d.doubleSided){d.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);J=d.doubleSided}if(W!=d.flipSided){d.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);W=d.flipSided}}function k(d){R[0].set(d.n41-d.n11,d.n42-d.n12,d.n43-d.n13,d.n44-d.n14);R[1].set(d.n41+d.n11,d.n42+d.n12,d.n43+d.n13,d.n44+
+d.n14);R[2].set(d.n41+d.n21,d.n42+d.n22,d.n43+d.n23,d.n44+d.n24);R[3].set(d.n41-d.n21,d.n42-d.n22,d.n43-d.n23,d.n44-d.n24);R[4].set(d.n41-d.n31,d.n42-d.n32,d.n43-d.n33,d.n44-d.n34);R[5].set(d.n41+d.n31,d.n42+d.n32,d.n43+d.n33,d.n44+d.n34);var j;for(d=0;d<5;d++){j=R[d];j.divideScalar(Math.sqrt(j.x*j.x+j.y*j.y+j.z*j.z))}}function q(d){for(var j=d.matrix,o=-d.geometry.boundingSphere.radius*Math.max(d.scale.x,Math.max(d.scale.y,d.scale.z)),h=0;h<6;h++){d=R[h].x*j.n14+R[h].y*j.n24+R[h].z*j.n34+R[h].w;
+if(d<=o)return false}return true}function p(d,j){d.list[d.count]=j;d.count+=1}function l(d){var j,o,h=d.object,f=d.opaque,v=d.transparent;v.count=0;d=f.count=0;for(j=h.materials.length;d<j;d++){o=h.materials[d];o.opacity&&o.opacity<1||o.blending!=THREE.NormalBlending?p(v,o):p(f,o)}}function m(d){var j,o,h,f,v=d.object,u=d.buffer,n=d.opaque,w=d.transparent;w.count=0;d=n.count=0;for(h=v.materials.length;d<h;d++){j=v.materials[d];if(j instanceof THREE.MeshFaceMaterial){j=0;for(o=u.materials.length;j<
+o;j++)if(f=u.materials[j])f.opacity&&f.opacity<1||f.blending!=THREE.NormalBlending?p(w,f):p(n,f)}else{f=j;f.opacity&&f.opacity<1||f.blending!=THREE.NormalBlending?p(w,f):p(n,f)}}}function z(d){var j,o,h,f=d.children;j=0;for(o=f.length;j<o;j++){h=f[j];h.autoUpdateMatrix&&h.updateMatrix();h.matrixWorld.multiply(d.matrixWorld,h.matrix);z(h)}}function A(d,j){return j.z-d.z}function t(d,j){var o,h,f=j.children;o=0;for(h=f.length;o<h;o++){child=f[o];y(d,child,false);t(d,child)}}function y(d,j,o){var h,
+f,v;f=j.geometry;if(d.__webGLObjectsMap[j.id]==undefined){d.__webGLObjectsMap[j.id]={};j._modelViewMatrix=new THREE.Matrix4;j._normalMatrixArray=new Float32Array(9);j._modelViewMatrixArray=new Float32Array(16);j._objectMatrixArray=new Float32Array(16);j.matrix.flattenToArray(j._objectMatrixArray)}v=d.__webGLObjectsMap[j.id];objlist=d.__webGLObjects;if(j instanceof THREE.Mesh){for(h in f.geometryChunks){d=f.geometryChunks[h];if(!d.__webGLVertexBuffer){var u=d;u.__webGLVertexBuffer=b.createBuffer();
+u.__webGLNormalBuffer=b.createBuffer();u.__webGLTangentBuffer=b.createBuffer();u.__webGLColorBuffer=b.createBuffer();u.__webGLUVBuffer=b.createBuffer();u.__webGLUV2Buffer=b.createBuffer();u.__webGLFaceBuffer=b.createBuffer();u.__webGLLineBuffer=b.createBuffer();u=d;var n=j,w=void 0,s=void 0,O=0,Y=0,ga=0,ia=n.geometry.faces,U=u.faces;w=0;for(s=U.length;w<s;w++){fi=U[w];face=ia[fi];if(face instanceof THREE.Face3){O+=3;Y+=1;ga+=3}else if(face instanceof THREE.Face4){O+=4;Y+=2;ga+=4}}u.__vertexArray=
+new Float32Array(O*3);u.__normalArray=new Float32Array(O*3);u.__tangentArray=new Float32Array(O*4);u.__colorArray=new Float32Array(O*3);u.__uvArray=new Float32Array(O*2);u.__uv2Array=new Float32Array(O*2);u.__faceArray=new Uint16Array(Y*3);u.__lineArray=new Uint16Array(ga*2);s=w=u;n=n;O=void 0;ia=void 0;var ea=void 0,Z=void 0;ea=void 0;U=false;O=0;for(ia=n.materials.length;O<ia;O++){ea=n.materials[O];if(ea instanceof THREE.MeshFaceMaterial){ea=0;for(Z=s.materials.length;ea<Z;ea++)if(s.materials[ea]&&
+s.materials[ea].shading!=undefined&&s.materials[ea].shading==THREE.SmoothShading){U=true;break}}else if(ea&&ea.shading!=undefined&&ea.shading==THREE.SmoothShading){U=true;break}if(U)break}w.__needsSmoothNormals=U;u.__webGLFaceCount=Y*3;u.__webGLLineCount=ga*2;f.__dirtyVertices=true;f.__dirtyElements=true;f.__dirtyUvs=true;f.__dirtyNormals=true;f.__dirtyTangents=true;f.__dirtyColors=true}if(f.__dirtyVertices||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents){u=
+d;Y=b.DYNAMIC_DRAW;ga=void 0;w=void 0;var qa=void 0,F=void 0,ua=void 0,oa=void 0,ra=void 0;qa=void 0;var V=void 0,fa=void 0,ja=void 0,za=void 0;V=void 0;fa=void 0;ja=void 0;F=void 0;V=void 0;fa=void 0;ja=void 0;za=void 0;F=void 0;oa=void 0;ua=void 0;ra=void 0;var va=Z=ea=U=ia=O=n=s=0,ma=0,na=u.__vertexArray,Ea=u.__uvArray,Fa=u.__uv2Array,sa=u.__normalArray,ha=u.__tangentArray,la=u.__colorArray,Aa=u.__faceArray,ta=u.__lineArray,La=u.__needsSmoothNormals,xa=j.geometry,ka=xa.__dirtyVertices,Ba=xa.__dirtyElements,
+Ca=xa.__dirtyUvs,Ma=xa.__dirtyNormals,Na=xa.__dirtyTangents,Ka=xa.__dirtyColors,x=xa.vertices,X=u.faces,T=xa.faces,E=xa.uvs,Q=xa.uvs2,$=xa.colors;ga=0;for(w=X.length;ga<w;ga++){qa=X[ga];F=T[qa];ra=E[qa];qa=Q[qa];ua=F.vertexNormals;oa=F.normal;if(F instanceof THREE.Face3){if(ka){V=x[F.a].position;fa=x[F.b].position;ja=x[F.c].position;na[n]=V.x;na[n+1]=V.y;na[n+2]=V.z;na[n+3]=fa.x;na[n+4]=fa.y;na[n+5]=fa.z;na[n+6]=ja.x;na[n+7]=ja.y;na[n+8]=ja.z;n+=9}if(Ka&&$.length){V=$[F.a];fa=$[F.b];ja=$[F.c];la[ma]=
+V.r;la[ma+1]=V.g;la[ma+2]=V.b;la[ma+3]=fa.r;la[ma+4]=fa.g;la[ma+5]=fa.b;la[ma+6]=ja.r;la[ma+7]=ja.g;la[ma+8]=ja.b;ma+=9}if(Na&&xa.hasTangents){V=x[F.a].tangent;fa=x[F.b].tangent;ja=x[F.c].tangent;ha[Z]=V.x;ha[Z+1]=V.y;ha[Z+2]=V.z;ha[Z+3]=V.w;ha[Z+4]=fa.x;ha[Z+5]=fa.y;ha[Z+6]=fa.z;ha[Z+7]=fa.w;ha[Z+8]=ja.x;ha[Z+9]=ja.y;ha[Z+10]=ja.z;ha[Z+11]=ja.w;Z+=12}if(Ma)if(ua.length==3&&La)for(F=0;F<3;F++){oa=ua[F];sa[ea]=oa.x;sa[ea+1]=oa.y;sa[ea+2]=oa.z;ea+=3}else for(F=0;F<3;F++){sa[ea]=oa.x;sa[ea+1]=oa.y;sa[ea+
+2]=oa.z;ea+=3}if(Ca&&ra)for(F=0;F<3;F++){ua=ra[F];Ea[O]=ua.u;Ea[O+1]=ua.v;O+=2}if(Ca&&qa)for(F=0;F<3;F++){ra=qa[F];Fa[ia]=ra.u;Fa[ia+1]=ra.v;ia+=2}if(Ba){Aa[U]=s;Aa[U+1]=s+1;Aa[U+2]=s+2;U+=3;ta[va]=s;ta[va+1]=s+1;ta[va+2]=s;ta[va+3]=s+2;ta[va+4]=s+1;ta[va+5]=s+2;va+=6;s+=3}}else if(F instanceof THREE.Face4){if(ka){V=x[F.a].position;fa=x[F.b].position;ja=x[F.c].position;za=x[F.d].position;na[n]=V.x;na[n+1]=V.y;na[n+2]=V.z;na[n+3]=fa.x;na[n+4]=fa.y;na[n+5]=fa.z;na[n+6]=ja.x;na[n+7]=ja.y;na[n+8]=ja.z;
+na[n+9]=za.x;na[n+10]=za.y;na[n+11]=za.z;n+=12}if(Ka&&$.length){V=$[F.a];fa=$[F.b];ja=$[F.c];za=$[F.d];la[ma]=V.r;la[ma+1]=V.g;la[ma+2]=V.b;la[ma+3]=fa.r;la[ma+4]=fa.g;la[ma+5]=fa.b;la[ma+6]=ja.r;la[ma+7]=ja.g;la[ma+8]=ja.b;la[ma+9]=za.r;la[ma+10]=za.g;la[ma+11]=za.b;ma+=12}if(Na&&xa.hasTangents){V=x[F.a].tangent;fa=x[F.b].tangent;ja=x[F.c].tangent;F=x[F.d].tangent;ha[Z]=V.x;ha[Z+1]=V.y;ha[Z+2]=V.z;ha[Z+3]=V.w;ha[Z+4]=fa.x;ha[Z+5]=fa.y;ha[Z+6]=fa.z;ha[Z+7]=fa.w;ha[Z+8]=ja.x;ha[Z+9]=ja.y;ha[Z+10]=
+ja.z;ha[Z+11]=ja.w;ha[Z+12]=F.x;ha[Z+13]=F.y;ha[Z+14]=F.z;ha[Z+15]=F.w;Z+=16}if(Ma)if(ua.length==4&&La)for(F=0;F<4;F++){oa=ua[F];sa[ea]=oa.x;sa[ea+1]=oa.y;sa[ea+2]=oa.z;ea+=3}else for(F=0;F<4;F++){sa[ea]=oa.x;sa[ea+1]=oa.y;sa[ea+2]=oa.z;ea+=3}if(Ca&&ra)for(F=0;F<4;F++){ua=ra[F];Ea[O]=ua.u;Ea[O+1]=ua.v;O+=2}if(Ca&&qa)for(F=0;F<4;F++){ra=qa[F];Fa[ia]=ra.u;Fa[ia+1]=ra.v;ia+=2}if(Ba){Aa[U]=s;Aa[U+1]=s+1;Aa[U+2]=s+2;Aa[U+3]=s;Aa[U+4]=s+2;Aa[U+5]=s+3;U+=6;ta[va]=s;ta[va+1]=s+1;ta[va+2]=s;ta[va+3]=s+3;ta[va+
+4]=s+1;ta[va+5]=s+2;ta[va+6]=s+2;ta[va+7]=s+3;va+=8;s+=4}}}if(ka){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,na,Y)}if(Ka&&$.length){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,la,Y)}if(Ma){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,sa,Y)}if(Na&&xa.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,ha,Y)}if(Ca&&O>0){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLUVBuffer);
+b.bufferData(b.ARRAY_BUFFER,Ea,Y)}if(Ca&&ia>0){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,Fa,Y)}if(Ba){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,u.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Aa,Y);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,u.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ta,Y)}}D(objlist,v,h,d,j,o)}f.__dirtyVertices=false;f.__dirtyElements=false;f.__dirtyUvs=false;f.__dirtyNormals=false;f.__dirtyTangents=false;f.__dirtyColors=false}else if(j instanceof
+THREE.Line){if(!f.__webGLVertexBuffer){f.__webGLVertexBuffer=b.createBuffer();f.__webGLColorBuffer=b.createBuffer();h=f.vertices.length;f.__vertexArray=new Float32Array(h*3);f.__colorArray=new Float32Array(h*3);f.__webGLLineCount=h;f.__dirtyVertices=true;f.__dirtyColors=true}if(f.__dirtyVertices||f.__dirtyColors){h=b.DYNAMIC_DRAW;n=f.vertices;u=f.colors;O=n.length;Y=u.length;ia=f.__vertexArray;ga=f.__colorArray;U=f.__dirtyColors;if(f.__dirtyVertices){for(w=0;w<O;w++){s=n[w].position;d=w*3;ia[d]=s.x;
+ia[d+1]=s.y;ia[d+2]=s.z}b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,ia,h)}if(U){for(w=0;w<Y;w++){color=u[w];d=w*3;ga[d]=color.r;ga[d+1]=color.g;ga[d+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,ga,h)}}D(objlist,v,0,f,j,o);f.__dirtyVertices=false;f.__dirtyColors=false}else if(j instanceof THREE.ParticleSystem){if(!f.__webGLVertexBuffer){f.__webGLVertexBuffer=b.createBuffer();f.__webGLColorBuffer=b.createBuffer();h=f.vertices.length;
+f.__vertexArray=new Float32Array(h*3);f.__colorArray=new Float32Array(h*3);f.__sortArray=[];f.__webGLParticleCount=h;f.__dirtyVertices=true;f.__dirtyColors=true}if(f.__dirtyVertices||f.__dirtyColors||j.sortParticles)c(f,b.DYNAMIC_DRAW,j,camera);D(objlist,v,0,f,j,o);f.__dirtyVertices=false;f.__dirtyColors=false}else if(j instanceof THREE.MarchingCubes)if(v[0]==undefined){d.__webGLObjectsImmediate.push({object:j,opaque:{list:[],count:0},transparent:{list:[],count:0},root:o});v[0]=1}}function D(d,j,
+o,h,f,v){if(j[o]==undefined){d.push({buffer:h,object:f,opaque:{list:[],count:0},transparent:{list:[],count:0},root:v});j[o]=1}}function H(d,j){d._modelViewMatrix.multiplyToArray(j.matrix,d.matrixWorld,d._modelViewMatrixArray);d._normalMatrix=THREE.Matrix4.makeInvert3x3(d._modelViewMatrix).transposeIntoArray(d._normalMatrixArray)}function G(d){if(d!=M){switch(d){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;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}M=d}}function r(d,j){if(d&&!d.__webGLFramebuffer){d.__webGLFramebuffer=b.createFramebuffer();d.__webGLRenderbuffer=b.createRenderbuffer();d.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,d.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,d.width,d.height);
+b.bindTexture(b.TEXTURE_2D,d.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,B(d.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,B(d.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,B(d.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,B(d.min_filter));b.texImage2D(b.TEXTURE_2D,0,B(d.format),d.width,d.height,0,B(d.format),B(d.type),null);b.bindFramebuffer(b.FRAMEBUFFER,d.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,
+d.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,d.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}var o,h,f;if(d){o=d.__webGLFramebuffer;h=d.width;f=d.height}else{o=null;h=I.width;f=I.height}if(o!=P){b.bindFramebuffer(b.FRAMEBUFFER,o);b.viewport(0,0,h,f);j&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);P=o}}function S(d,j){var o;if(d=="fragment")o=b.createShader(b.FRAGMENT_SHADER);
+else if(d=="vertex")o=b.createShader(b.VERTEX_SHADER);b.shaderSource(o,j);b.compileShader(o);if(!b.getShaderParameter(o,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(o));return null}return o}function B(d){switch(d){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;
+case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;
+case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var I=document.createElement("canvas"),b,aa=null,P=null,J=null,W=null,M=null,R=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],K=new THREE.Matrix4,C=new Float32Array(16),L=new Float32Array(16),ba=new THREE.Vector4,N=true,da=new THREE.Color(0),ca=0;if(a){if(a.antialias!==
+undefined)N=a.antialias;a.clearColor!==undefined&&da.setHex(a.clearColor);if(a.clearAlpha!==undefined)ca=a.clearAlpha}this.domElement=I;this.autoClear=true;(function(d,j,o){try{b=I.getContext("experimental-webgl",{antialias:d})}catch(h){console.log(h)}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(j.r,j.g,j.b,o);_cullEnabled=true})(N,da,ca);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(d,j){I.width=d;I.height=j;b.viewport(0,0,I.width,I.height)};this.setClearColorHex=function(d,j){var o=new THREE.Color(d);b.clearColor(o.r,o.g,o.b,j)};this.setClearColor=function(d,j){b.clearColor(d.r,d.g,d.b,j)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};
+this.setupLights=function(d,j){var o,h,f,v=0,u=0,n=0,w,s,O,Y=this.lights,ga=Y.directional.colors,ia=Y.directional.positions,U=Y.point.colors,ea=Y.point.positions,Z=0,qa=0;o=f=f=0;for(h=j.length;o<h;o++){f=j[o];w=f.color;s=f.position;O=f.intensity;if(f instanceof THREE.AmbientLight){v+=w.r;u+=w.g;n+=w.b}else if(f instanceof THREE.DirectionalLight){f=Z*3;ga[f]=w.r*O;ga[f+1]=w.g*O;ga[f+2]=w.b*O;ia[f]=s.x;ia[f+1]=s.y;ia[f+2]=s.z;Z+=1}else if(f instanceof THREE.PointLight){f=qa*3;U[f]=w.r*O;U[f+1]=w.g*
+O;U[f+2]=w.b*O;ea[f]=s.x;ea[f+1]=s.y;ea[f+2]=s.z;qa+=1}}for(o=Z*3;o<ga.length;o++)ga[o]=0;for(o=qa*3;o<U.length;o++)U[o]=0;Y.point.length=qa;Y.directional.length=Z;Y.ambient[0]=v;Y.ambient[1]=u;Y.ambient[2]=n};this.initMaterial=function(d,j,o){var h,f;if(d instanceof THREE.MeshDepthMaterial)e(d,THREE.ShaderLib.depth);else if(d instanceof THREE.MeshNormalMaterial)e(d,THREE.ShaderLib.normal);else if(d instanceof THREE.MeshBasicMaterial)e(d,THREE.ShaderLib.basic);else if(d instanceof THREE.MeshLambertMaterial)e(d,
+THREE.ShaderLib.lambert);else if(d instanceof THREE.MeshPhongMaterial)e(d,THREE.ShaderLib.phong);else if(d instanceof THREE.LineBasicMaterial)e(d,THREE.ShaderLib.basic);else d instanceof THREE.ParticleBasicMaterial&&e(d,THREE.ShaderLib.particle_basic);var v,u,n,w;f=n=w=0;for(v=j.length;f<v;f++){u=j[f];u instanceof THREE.DirectionalLight&&n++;u instanceof THREE.PointLight&&w++}if(w+n<=4){j=n;w=w}else{j=Math.ceil(4*n/(w+n));w=4-j}f={directional:j,point:w};w=d.fragment_shader;j=d.vertex_shader;v={fog:o,
+map:d.map,env_map:d.env_map,light_map:d.light_map,vertex_colors:d.vertex_colors,maxDirLights:f.directional,maxPointLights:f.point};o=b.createProgram();f=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+v.maxDirLights,"#define MAX_POINT_LIGHTS "+v.maxPointLights,v.fog?"#define USE_FOG":"",v.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",v.map?"#define USE_MAP":"",v.env_map?"#define USE_ENVMAP":"",v.light_map?"#define USE_LIGHTMAP":"",v.vertex_colors?"#define USE_COLOR":
+"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");v=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+v.maxDirLights,"#define MAX_POINT_LIGHTS "+v.maxPointLights,v.map?"#define USE_MAP":"",v.env_map?"#define USE_ENVMAP":"",v.light_map?"#define USE_LIGHTMAP":"",v.vertex_colors?"#define USE_COLOR":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");
+b.attachShader(o,S("fragment",f+w));b.attachShader(o,S("vertex",v+j));b.linkProgram(o);b.getProgramParameter(o,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(o,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");o.uniforms={};o.attributes={};d.program=o;o=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(h in d.uniforms)o.push(h);h=d.program;w=0;for(j=o.length;w<j;w++){f=o[w];h.uniforms[f]=b.getUniformLocation(h,
+f)}d=d.program;h=["position","normal","uv","uv2","tangent","color"];o=0;for(w=h.length;o<w;o++){j=h[o];d.attributes[j]=b.getAttribLocation(d,j)}};this.setProgram=function(d,j,o,h,f){h.program||this.initMaterial(h,j,o);var v=h.program,u=v.uniforms,n=h.uniforms;if(v!=aa){b.useProgram(v);aa=v;b.uniformMatrix4fv(u.projectionMatrix,false,C)}if(o&&(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial||h instanceof THREE.LineBasicMaterial||h instanceof
+THREE.ParticleBasicMaterial)){n.fogColor.value.setHex(o.color.hex);if(o instanceof THREE.Fog){n.fogNear.value=o.near;n.fogFar.value=o.far}else if(o instanceof THREE.FogExp2)n.fogDensity.value=o.density}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial){this.setupLights(v,j);j=this.lights;n.enableLighting.value=j.directional.length+j.point.length;n.ambientLightColor.value=j.ambient;n.directionalLightColor.value=j.directional.colors;n.directionalLightDirection.value=j.directional.positions;
+n.pointLightColor.value=j.point.colors;n.pointLightPosition.value=j.point.positions}if(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial){n.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);n.opacity.value=h.opacity;n.map.texture=h.map;n.light_map.texture=h.light_map;n.env_map.texture=h.env_map;n.reflectivity.value=h.reflectivity;n.refraction_ratio.value=h.refraction_ratio;n.combine.value=h.combine;n.useRefract.value=
+h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping}if(h instanceof THREE.LineBasicMaterial){n.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);n.opacity.value=h.opacity}else if(h instanceof THREE.ParticleBasicMaterial){n.psColor.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);n.opacity.value=h.opacity;n.size.value=h.size;n.map.texture=h.map}else if(h instanceof THREE.MeshPhongMaterial){n.ambient.value.setRGB(h.ambient.r,h.ambient.g,
+h.ambient.b);n.specular.value.setRGB(h.specular.r,h.specular.g,h.specular.b);n.shininess.value=h.shininess}else if(h instanceof THREE.MeshDepthMaterial){n.mNear.value=d.near;n.mFar.value=d.far;n.opacity.value=h.opacity}else if(h instanceof THREE.MeshNormalMaterial)n.opacity.value=h.opacity;var w,s,O;for(w in n)if(O=v.uniforms[w]){o=n[w];s=o.type;j=o.value;if(s=="i")b.uniform1i(O,j);else if(s=="f")b.uniform1f(O,j);else if(s=="fv1")b.uniform1fv(O,j);else if(s=="fv")b.uniform3fv(O,j);else if(s=="v2")b.uniform2f(O,
+j.x,j.y);else if(s=="v3")b.uniform3f(O,j.x,j.y,j.z);else if(s=="c")b.uniform3f(O,j.r,j.g,j.b);else if(s=="t"){b.uniform1i(O,j);if(o=o.texture)if(o.image instanceof Array&&o.image.length==6){o=o;j=j;if(o.image.length==6){if(!o.image.__webGLTextureCube&&!o.image.__cubeMapInitialized&&o.image.loadCount==6){o.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,o.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(s=0;s<6;++s)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,o.image[s]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);o.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+j);b.bindTexture(b.TEXTURE_CUBE_MAP,o.image.__webGLTextureCube)}}else{o=o;j=j;if(!o.__webGLTexture&&
+o.image.loaded){o.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,o.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,o.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,B(o.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,B(o.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,B(o.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,B(o.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+
+j);b.bindTexture(b.TEXTURE_2D,o.__webGLTexture)}}}b.uniformMatrix4fv(u.modelViewMatrix,false,f._modelViewMatrixArray);b.uniformMatrix3fv(u.normalMatrix,false,f._normalMatrixArray);if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshPhongMaterial||h.env_map)b.uniform3f(u.cameraPosition,d.position.x,d.position.y,d.position.z);if(h instanceof THREE.MeshShaderMaterial||h.env_map)b.uniformMatrix4fv(u.objectMatrix,false,f._objectMatrixArray);if(h instanceof THREE.MeshPhongMaterial||h instanceof
+THREE.MeshLambertMaterial||h instanceof THREE.MeshShaderMaterial)b.uniformMatrix4fv(u.viewMatrix,false,L);return v};this.renderBuffer=function(d,j,o,h,f,v){d=this.setProgram(d,j,o,h,v).attributes;b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.vertexAttribPointer(d.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.position);if(d.color>=0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.vertexAttribPointer(d.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.color)}if(d.normal>=
+0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLNormalBuffer);b.vertexAttribPointer(d.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.normal)}if(d.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLTangentBuffer);b.vertexAttribPointer(d.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.tangent)}if(d.uv>=0)if(f.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUVBuffer);b.vertexAttribPointer(d.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv)}else b.disableVertexAttribArray(d.uv);if(d.uv2>=
+0)if(f.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUV2Buffer);b.vertexAttribPointer(d.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv2)}else b.disableVertexAttribArray(d.uv2);if(v instanceof THREE.Mesh)if(h.wireframe){b.lineWidth(h.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.drawElements(b.LINES,f.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,f.__webGLFaceCount,b.UNSIGNED_SHORT,
+0)}else if(v instanceof THREE.Line){v=v.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(h.linewidth);b.drawArrays(v,0,f.__webGLLineCount)}else v instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,f.__webGLParticleCount)};this.render=function(d,j,o,h){var f,v,u,n,w,s,O,Y=d.lights,ga=d.fog;j.autoUpdateMatrix&&j.updateMatrix();j.matrix.flattenToArray(L);j.projectionMatrix.flattenToArray(C);K.multiply(j.projectionMatrix,j.matrix);k(K);this.initWebGLObjects(d,j);r(o,h!==undefined?h:true);
+this.autoClear&&this.clear();n=d.__webGLObjects.length;for(h=0;h<n;h++){f=d.__webGLObjects[h];s=f.object;if(s.visible){if(f.root){s.autoUpdateMatrix&&s.updateMatrix();s.matrixWorld.copy(s.matrix);z(s)}if(!(s instanceof THREE.Mesh)||q(s)){s.matrixWorld.flattenToArray(s._objectMatrixArray);H(s,j);m(f);f.render=true;ba.copy(s.position);K.multiplyVector3(ba);f.z=ba.z}else f.render=false}else f.render=false}d.__webGLObjects.sort(A);w=d.__webGLObjectsImmediate.length;for(h=0;h<w;h++){f=d.__webGLObjectsImmediate[h];
+s=f.object;if(s.visible){if(s.autoUpdateMatrix){s.updateMatrix();s.matrixWorld.copy(s.matrix);s.matrixWorld.flattenToArray(s._objectMatrixArray)}H(s,j);l(f)}}G(THREE.NormalBlending);for(h=0;h<n;h++){f=d.__webGLObjects[h];if(f.render){s=f.object;O=f.buffer;u=f.opaque;i(s);for(f=0;f<u.count;f++){material=u.list[f];this.setDepthTest(material.depth_test);this.renderBuffer(j,Y,ga,material,O,s)}}}for(h=0;h<w;h++){f=d.__webGLObjectsImmediate[h];s=f.object;if(s.visible){u=f.opaque;i(s);for(f=0;f<u.count;f++){material=
+u.list[f];this.setDepthTest(material.depth_test);v=this.setProgram(j,Y,ga,material,s);s.render(function(ia){g(ia,v)})}}}for(h=0;h<n;h++){f=d.__webGLObjects[h];if(f.render){s=f.object;O=f.buffer;u=f.transparent;i(s);for(f=0;f<u.count;f++){material=u.list[f];G(material.blending);this.setDepthTest(material.depth_test);this.renderBuffer(j,Y,ga,material,O,s)}}}for(h=0;h<w;h++){f=d.__webGLObjectsImmediate[h];s=f.object;if(s.visible){u=f.transparent;i(s);for(f=0;f<u.count;f++){material=u.list[f];G(material.blending);
+this.setDepthTest(material.depth_test);v=this.setProgram(j,Y,ga,material,s);s.render(function(ia){g(ia,v)})}}}if(o&&o.min_filter!==THREE.NearestFilter&&o.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,o.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(d){var j,o,h;if(!d.__webGLObjects){d.__webGLObjects=[];d.__webGLObjectsMap={};d.__webGLObjectsImmediate=[]}j=0;for(o=d.objects.length;j<o;j++){h=d.objects[j];y(d,h,true);t(d,
+h)}};this.removeObject=function(d,j){var o,h;for(o=d.__webGLObjects.length-1;o>=0;o--){h=d.__webGLObjects[o].object;j==h&&d.__webGLObjects.splice(o,1)}};this.setDepthTest=function(d){d?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};this.setFaceCulling=function(d,j){if(d){!j||j=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(d=="back")b.cullFace(b.BACK);else d=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
+0}};
+THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
+envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
+map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",
+lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
 lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
 lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
 lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse  = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse  += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse  = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse  += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
 lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse  = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse  += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse  = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse  += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
 color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif"};
 color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif"};

+ 178 - 178
build/ThreeExtras.js

@@ -13,50 +13,50 @@ THREE.Vector4=function(a,b,c,e){this.x=a||0;this.y=b||0;this.z=c||0;this.w=e||1}
 THREE.Vector4.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;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;
 THREE.Vector4.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;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+")"}};
 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=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,c,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){c=e[a];if(c instanceof THREE.Mesh)g=g.concat(this.intersectObject(c))}g.sort(function(f,h){return f.distance-h.distance});return g},intersectObject:function(a){function b(H,w,E,o){o=o.clone().subSelf(w);E=E.clone().subSelf(w);var d=H.clone().subSelf(w);H=o.dot(o);w=o.dot(E);o=o.dot(d);var P=E.dot(E);E=E.dot(d);d=1/(H*P-w*w);P=(P*o-w*E)*d;H=(H*E-w*o)*d;return P>0&&H>0&&P+H<1}var c,e,g,f,h,k,j,m,p,x,
-t,q=a.geometry,y=q.vertices,z=[];c=0;for(e=q.faces.length;c<e;c++){g=q.faces[c];x=this.origin.clone();t=this.direction.clone();f=a.matrix.multiplyVector3(y[g.a].position.clone());h=a.matrix.multiplyVector3(y[g.b].position.clone());k=a.matrix.multiplyVector3(y[g.c].position.clone());j=g instanceof THREE.Face4?a.matrix.multiplyVector3(y[g.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(g.normal.clone());p=t.dot(m);if(p<0){m=m.dot((new THREE.Vector3).sub(f,x))/p;x=x.addSelf(t.multiplyScalar(m));
-if(g instanceof THREE.Face3){if(b(x,f,h,k)){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};z.push(g)}}else if(g instanceof THREE.Face4)if(b(x,f,h,j)||b(x,h,k,j)){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};z.push(g)}}}return z}};
-THREE.Rectangle=function(){function a(){f=e-b;h=g-c}var b,c,e,g,f,h,k=true;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(j,m,p,x){k=false;b=j;c=m;e=p;g=x;a()};this.addPoint=function(j,m){if(k){k=false;b=j;c=m;e=j;g=m}else{b=b<j?b:j;c=c<m?c:m;e=e>j?e:j;g=g>m?
-g:m}a()};this.add3Points=function(j,m,p,x,t,q){if(k){k=false;b=j<p?j<t?j:t:p<t?p:t;c=m<x?m<q?m:q:x<q?x:q;e=j>p?j>t?j:t:p>t?p:t;g=m>x?m>q?m:q:x>q?x:q}else{b=j<p?j<t?j<b?j:b:t<b?t:b:p<t?p<b?p:b:t<b?t:b;c=m<x?m<q?m<c?m:c:q<c?q:c:x<q?x<c?x:c:q<c?q:c;e=j>p?j>t?j>e?j:e:t>e?t:e:p>t?p>e?p:e:t>e?t:e;g=m>x?m>q?m>g?m:g:q>g?q:g:x>q?x>g?x:g:q>g?q:g}a()};this.addRectangle=function(j){if(k){k=false;b=j.getLeft();c=j.getTop();e=j.getRight();g=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();c=c<j.getTop()?c:j.getTop();
+THREE.Ray.prototype={intersectScene:function(a){var b,c,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){c=e[a];if(c instanceof THREE.Mesh)g=g.concat(this.intersectObject(c))}g.sort(function(f,h){return f.distance-h.distance});return g},intersectObject:function(a){function b(E,v,F,p){p=p.clone().subSelf(v);F=F.clone().subSelf(v);var M=E.clone().subSelf(v);E=p.dot(p);v=p.dot(F);p=p.dot(M);var d=F.dot(F);F=F.dot(M);M=1/(E*d-v*v);d=(d*p-v*F)*M;E=(E*F-v*p)*M;return d>0&&E>0&&d+E<1}var c,e,g,f,h,k,j,m,q,w,
+u,t=a.geometry,x=t.vertices,A=[];c=0;for(e=t.faces.length;c<e;c++){g=t.faces[c];w=this.origin.clone();u=this.direction.clone();f=a.matrix.multiplyVector3(x[g.a].position.clone());h=a.matrix.multiplyVector3(x[g.b].position.clone());k=a.matrix.multiplyVector3(x[g.c].position.clone());j=g instanceof THREE.Face4?a.matrix.multiplyVector3(x[g.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(g.normal.clone());q=u.dot(m);if(q<0){m=m.dot((new THREE.Vector3).sub(f,w))/q;w=w.addSelf(u.multiplyScalar(m));
+if(g instanceof THREE.Face3){if(b(w,f,h,k)){g={distance:this.origin.distanceTo(w),point:w,face:g,object:a};A.push(g)}}else if(g instanceof THREE.Face4)if(b(w,f,h,j)||b(w,h,k,j)){g={distance:this.origin.distanceTo(w),point:w,face:g,object:a};A.push(g)}}}return A}};
+THREE.Rectangle=function(){function a(){f=e-b;h=g-c}var b,c,e,g,f,h,k=true;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(j,m,q,w){k=false;b=j;c=m;e=q;g=w;a()};this.addPoint=function(j,m){if(k){k=false;b=j;c=m;e=j;g=m}else{b=b<j?b:j;c=c<m?c:m;e=e>j?e:j;g=g>m?
+g:m}a()};this.add3Points=function(j,m,q,w,u,t){if(k){k=false;b=j<q?j<u?j:u:q<u?q:u;c=m<w?m<t?m:t:w<t?w:t;e=j>q?j>u?j:u:q>u?q:u;g=m>w?m>t?m:t:w>t?w:t}else{b=j<q?j<u?j<b?j:b:u<b?u:b:q<u?q<b?q:b:u<b?u:b;c=m<w?m<t?m<c?m:c:t<c?t:c:w<t?w<c?w:c:t<c?t:c;e=j>q?j>u?j>e?j:e:u>e?u:e:q>u?q>e?q:e:u>e?u:e;g=m>w?m>t?m>g?m:g:t>g?t:g:w>t?w>g?w:g:t>g?t:g}a()};this.addRectangle=function(j){if(k){k=false;b=j.getLeft();c=j.getTop();e=j.getRight();g=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();c=c<j.getTop()?c:j.getTop();
 e=e>j.getRight()?e:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){b-=j;c-=j;e+=j;g+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();c=c>j.getTop()?c:j.getTop();e=e<j.getRight()?e:j.getRight();g=g<j.getBottom()?g:j.getBottom();a()};this.instersects=function(j){return Math.min(e,j.getRight())-Math.max(b,j.getLeft())>=0&&Math.min(g,j.getBottom())-Math.max(c,j.getTop())>=0};this.empty=function(){k=true;g=e=c=b=0;a()};this.isEmpty=function(){return k};this.toString=
 e=e>j.getRight()?e:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){b-=j;c-=j;e+=j;g+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();c=c>j.getTop()?c:j.getTop();e=e<j.getRight()?e:j.getRight();g=g<j.getBottom()?g:j.getBottom();a()};this.instersects=function(j){return Math.min(e,j.getRight())-Math.max(b,j.getLeft())>=0&&Math.min(g,j.getBottom())-Math.max(c,j.getTop())>=0};this.empty=function(){k=true;g=e=c=b=0;a()};this.isEmpty=function(){return k};this.toString=
 function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+c+", bottom: "+g+", width: "+f+", height: "+h+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
 function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+c+", bottom: "+g+", width: "+f+", height: "+h+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
-THREE.Matrix4=function(a,b,c,e,g,f,h,k,j,m,p,x,t,q,y,z){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=e||0;this.n21=g||0;this.n22=f||1;this.n23=h||0;this.n24=k||0;this.n31=j||0;this.n32=m||0;this.n33=p||1;this.n34=x||0;this.n41=t||0;this.n42=q||0;this.n43=y||0;this.n44=z||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={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;return this},set:function(a,b,c,e,g,f,h,k,j,m,p,x,t,q,y,z){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=g;this.n22=f;this.n23=h;this.n24=k;this.n31=j;this.n32=m;this.n33=p;this.n34=x;this.n41=t;this.n42=q;this.n43=y;this.n44=z;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
+THREE.Matrix4=function(a,b,c,e,g,f,h,k,j,m,q,w,u,t,x,A){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=e||0;this.n21=g||0;this.n22=f||1;this.n23=h||0;this.n24=k||0;this.n31=j||0;this.n32=m||0;this.n33=q||1;this.n34=w||0;this.n41=u||0;this.n42=t||0;this.n43=x||0;this.n44=A||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={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;return this},set:function(a,b,c,e,g,f,h,k,j,m,q,w,u,t,x,A){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=g;this.n22=f;this.n23=h;this.n24=k;this.n31=j;this.n32=m;this.n33=q;this.n34=w;this.n41=u;this.n42=t;this.n43=x;this.n44=A;return this},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;return this},lookAt:function(a,b,c){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();e.cross(c,f).normalize();g.cross(f,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);
 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;return this},lookAt:function(a,b,c){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();e.cross(c,f).normalize();g.cross(f,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);
 this.n31=f.x;this.n32=f.y;this.n33=f.z;this.n34=-f.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,e=a.z,g=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*c+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*c+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*c+this.n23*
 this.n31=f.x;this.n32=f.y;this.n33=f.z;this.n34=-f.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,e=a.z,g=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*c+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*c+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*c+this.n23*
-e+this.n24*g;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*c+this.n43*e+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 c=a.n11,e=a.n12,g=a.n13,f=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,p=a.n31,
-x=a.n32,t=a.n33,q=a.n34,y=a.n41,z=a.n42,H=a.n43,w=a.n44,E=b.n11,o=b.n12,d=b.n13,P=b.n14,aa=b.n21,N=b.n22,M=b.n23,U=b.n24,O=b.n31,Y=b.n32,W=b.n33,J=b.n34,X=b.n41,ha=b.n42,Z=b.n43,ea=b.n44;this.n11=c*E+e*aa+g*O+f*X;this.n12=c*o+e*N+g*Y+f*ha;this.n13=c*d+e*M+g*W+f*Z;this.n14=c*P+e*U+g*J+f*ea;this.n21=h*E+k*aa+j*O+m*X;this.n22=h*o+k*N+j*Y+m*ha;this.n23=h*d+k*M+j*W+m*Z;this.n24=h*P+k*U+j*J+m*ea;this.n31=p*E+x*aa+t*O+q*X;this.n32=p*o+x*N+t*Y+q*ha;this.n33=p*d+x*M+t*W+q*Z;this.n34=p*P+x*U+t*J+q*ea;this.n41=
-y*E+z*aa+H*O+w*X;this.n42=y*o+z*N+H*Y+w*ha;this.n43=y*d+z*M+H*W+w*Z;this.n44=y*P+z*U+H*J+w*ea;return this},multiplyToArray:function(a,b,c){var e=a.n11,g=a.n12,f=a.n13,h=a.n14,k=a.n21,j=a.n22,m=a.n23,p=a.n24,x=a.n31,t=a.n32,q=a.n33,y=a.n34,z=a.n41,H=a.n42,w=a.n43;a=a.n44;var E=b.n11,o=b.n12,d=b.n13,P=b.n14,aa=b.n21,N=b.n22,M=b.n23,U=b.n24,O=b.n31,Y=b.n32,W=b.n33,J=b.n34,X=b.n41,ha=b.n42,Z=b.n43;b=b.n44;this.n11=e*E+g*aa+f*O+h*X;this.n12=e*o+g*N+f*Y+h*ha;this.n13=e*d+g*M+f*W+h*Z;this.n14=e*P+g*U+f*
-J+h*b;this.n21=k*E+j*aa+m*O+p*X;this.n22=k*o+j*N+m*Y+p*ha;this.n23=k*d+j*M+m*W+p*Z;this.n24=k*P+j*U+m*J+p*b;this.n31=x*E+t*aa+q*O+y*X;this.n32=x*o+t*N+q*Y+y*ha;this.n33=x*d+t*M+q*W+y*Z;this.n34=x*P+t*U+q*J+y*b;this.n41=z*E+H*aa+w*O+a*X;this.n42=z*o+H*N+w*Y+a*ha;this.n43=z*d+H*M+w*W+a*Z;this.n44=z*P+H*U+w*J+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=
-this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,e=this.n13,g=this.n14,f=this.n21,h=this.n22,k=this.n23,j=this.n24,m=this.n31,p=this.n32,x=this.n33,t=this.n34,q=this.n41,y=this.n42,z=this.n43,H=this.n44,w=a.n11,E=a.n21,o=a.n31,d=a.n41,P=a.n12,aa=a.n22,N=a.n32,M=a.n42,U=a.n13,O=a.n23,Y=a.n33,W=a.n43,J=a.n14,X=a.n24,ha=a.n34;a=a.n44;this.n11=b*w+c*E+e*o+g*d;this.n12=b*P+c*aa+e*N+g*M;this.n13=b*U+c*O+e*Y+g*W;this.n14=b*J+c*X+e*ha+g*a;this.n21=f*w+
-h*E+k*o+j*d;this.n22=f*P+h*aa+k*N+j*M;this.n23=f*U+h*O+k*Y+j*W;this.n24=f*J+h*X+k*ha+j*a;this.n31=m*w+p*E+x*o+t*d;this.n32=m*P+p*aa+x*N+t*M;this.n33=m*U+p*O+x*Y+t*W;this.n34=m*J+p*X+x*ha+t*a;this.n41=q*w+y*E+z*o+H*d;this.n42=q*P+y*aa+z*N+H*M;this.n43=q*U+y*O+z*Y+H*W;this.n44=q*J+y*X+z*ha+H*a;return this},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;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,e=this.n14,g=this.n21,f=this.n22,h=this.n23,k=this.n24,j=this.n31,m=this.n32,p=this.n33,x=this.n34,t=this.n41,q=this.n42,y=this.n43,z=this.n44;return e*h*m*t-c*k*m*t-e*f*p*t+b*k*p*t+c*f*x*t-b*h*x*t-e*h*j*q+c*k*j*q+e*g*p*q-a*k*p*q-c*g*x*q+a*h*x*q+e*f*j*y-b*k*j*y-e*g*m*y+a*k*m*y+b*g*x*y-a*f*x*y-c*f*j*z+b*h*j*z+c*g*m*z-a*h*m*z-b*g*p*z+a*f*p*z},transpose:function(){function a(b,c,e){var g=b[c];b[c]=b[e];b[e]=
+e+this.n24*g;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*c+this.n43*e+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 c=a.n11,e=a.n12,g=a.n13,f=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,q=a.n31,
+w=a.n32,u=a.n33,t=a.n34,x=a.n41,A=a.n42,E=a.n43,v=a.n44,F=b.n11,p=b.n12,M=b.n13,d=b.n14,aa=b.n21,O=b.n22,K=b.n23,X=b.n24,Q=b.n31,U=b.n32,V=b.n33,H=b.n34,Y=b.n41,ea=b.n42,Z=b.n43,fa=b.n44;this.n11=c*F+e*aa+g*Q+f*Y;this.n12=c*p+e*O+g*U+f*ea;this.n13=c*M+e*K+g*V+f*Z;this.n14=c*d+e*X+g*H+f*fa;this.n21=h*F+k*aa+j*Q+m*Y;this.n22=h*p+k*O+j*U+m*ea;this.n23=h*M+k*K+j*V+m*Z;this.n24=h*d+k*X+j*H+m*fa;this.n31=q*F+w*aa+u*Q+t*Y;this.n32=q*p+w*O+u*U+t*ea;this.n33=q*M+w*K+u*V+t*Z;this.n34=q*d+w*X+u*H+t*fa;this.n41=
+x*F+A*aa+E*Q+v*Y;this.n42=x*p+A*O+E*U+v*ea;this.n43=x*M+A*K+E*V+v*Z;this.n44=x*d+A*X+E*H+v*fa;return this},multiplyToArray:function(a,b,c){var e=a.n11,g=a.n12,f=a.n13,h=a.n14,k=a.n21,j=a.n22,m=a.n23,q=a.n24,w=a.n31,u=a.n32,t=a.n33,x=a.n34,A=a.n41,E=a.n42,v=a.n43;a=a.n44;var F=b.n11,p=b.n12,M=b.n13,d=b.n14,aa=b.n21,O=b.n22,K=b.n23,X=b.n24,Q=b.n31,U=b.n32,V=b.n33,H=b.n34,Y=b.n41,ea=b.n42,Z=b.n43;b=b.n44;this.n11=e*F+g*aa+f*Q+h*Y;this.n12=e*p+g*O+f*U+h*ea;this.n13=e*M+g*K+f*V+h*Z;this.n14=e*d+g*X+f*
+H+h*b;this.n21=k*F+j*aa+m*Q+q*Y;this.n22=k*p+j*O+m*U+q*ea;this.n23=k*M+j*K+m*V+q*Z;this.n24=k*d+j*X+m*H+q*b;this.n31=w*F+u*aa+t*Q+x*Y;this.n32=w*p+u*O+t*U+x*ea;this.n33=w*M+u*K+t*V+x*Z;this.n34=w*d+u*X+t*H+x*b;this.n41=A*F+E*aa+v*Q+a*Y;this.n42=A*p+E*O+v*U+a*ea;this.n43=A*M+E*K+v*V+a*Z;this.n44=A*d+E*X+v*H+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=
+this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,e=this.n13,g=this.n14,f=this.n21,h=this.n22,k=this.n23,j=this.n24,m=this.n31,q=this.n32,w=this.n33,u=this.n34,t=this.n41,x=this.n42,A=this.n43,E=this.n44,v=a.n11,F=a.n21,p=a.n31,M=a.n41,d=a.n12,aa=a.n22,O=a.n32,K=a.n42,X=a.n13,Q=a.n23,U=a.n33,V=a.n43,H=a.n14,Y=a.n24,ea=a.n34;a=a.n44;this.n11=b*v+c*F+e*p+g*M;this.n12=b*d+c*aa+e*O+g*K;this.n13=b*X+c*Q+e*U+g*V;this.n14=b*H+c*Y+e*ea+g*a;this.n21=f*v+
+h*F+k*p+j*M;this.n22=f*d+h*aa+k*O+j*K;this.n23=f*X+h*Q+k*U+j*V;this.n24=f*H+h*Y+k*ea+j*a;this.n31=m*v+q*F+w*p+u*M;this.n32=m*d+q*aa+w*O+u*K;this.n33=m*X+q*Q+w*U+u*V;this.n34=m*H+q*Y+w*ea+u*a;this.n41=t*v+x*F+A*p+E*M;this.n42=t*d+x*aa+A*O+E*K;this.n43=t*X+x*Q+A*U+E*V;this.n44=t*H+x*Y+A*ea+E*a;return this},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;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,e=this.n14,g=this.n21,f=this.n22,h=this.n23,k=this.n24,j=this.n31,m=this.n32,q=this.n33,w=this.n34,u=this.n41,t=this.n42,x=this.n43,A=this.n44;return e*h*m*u-c*k*m*u-e*f*q*u+b*k*q*u+c*f*w*u-b*h*w*u-e*h*j*t+c*k*j*t+e*g*q*t-a*k*q*t-c*g*w*t+a*h*w*t+e*f*j*x-b*k*j*x-e*g*m*x+a*k*m*x+b*g*w*x-a*f*w*x-c*f*j*A+b*h*j*A+c*g*m*A-a*h*m*A-b*g*q*A+a*f*q*A},transpose:function(){function a(b,c,e){var g=b[c];b[c]=b[e];b[e]=
 g}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(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;
 g}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(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;
 a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,
 a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,
 0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),e=Math.sin(b),
 0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),e=Math.sin(b),
 g=1-c,f=a.x,h=a.y,k=a.z,j=g*f,m=g*h;this.set(j*f+c,j*h-e*k,j*k+e*h,0,j*h+e*k,m*h+c,m*k-e*f,0,j*k-e*h,m*k+e*f,g*k*k+c,0,0,0,0,1);return this},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,c){var e=new THREE.Matrix4;e.setTranslation(a,b,c);return e};
 g=1-c,f=a.x,h=a.y,k=a.z,j=g*f,m=g*h;this.set(j*f+c,j*h-e*k,j*k+e*h,0,j*h+e*k,m*h+c,m*k-e*f,0,j*k-e*h,m*k+e*f,g*k*k+c,0,0,0,0,1);return this},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,c){var e=new THREE.Matrix4;e.setTranslation(a,b,c);return e};
 THREE.Matrix4.scaleMatrix=function(a,b,c){var e=new THREE.Matrix4;e.setScale(a,b,c);return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
 THREE.Matrix4.scaleMatrix=function(a,b,c){var e=new THREE.Matrix4;e.setScale(a,b,c);return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
-THREE.Matrix4.makeInvert=function(a){var b=a.n11,c=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,k=a.n23,j=a.n24,m=a.n31,p=a.n32,x=a.n33,t=a.n34,q=a.n41,y=a.n42,z=a.n43,H=a.n44,w=new THREE.Matrix4;w.n11=k*t*y-j*x*y+j*p*z-h*t*z-k*p*H+h*x*H;w.n12=g*x*y-e*t*y-g*p*z+c*t*z+e*p*H-c*x*H;w.n13=e*j*y-g*k*y+g*h*z-c*j*z-e*h*H+c*k*H;w.n14=g*k*p-e*j*p-g*h*x+c*j*x+e*h*t-c*k*t;w.n21=j*x*q-k*t*q-j*m*z+f*t*z+k*m*H-f*x*H;w.n22=e*t*q-g*x*q+g*m*z-b*t*z-e*m*H+b*x*H;w.n23=g*k*q-e*j*q-g*f*z+b*j*z+e*f*H-b*k*H;w.n24=e*j*m-g*k*m+
-g*f*x-b*j*x-e*f*t+b*k*t;w.n31=h*t*q-j*p*q+j*m*y-f*t*y-h*m*H+f*p*H;w.n32=g*p*q-c*t*q-g*m*y+b*t*y+c*m*H-b*p*H;w.n33=e*j*q-g*h*q+g*f*y-b*j*y-c*f*H+b*h*H;w.n34=g*h*m-c*j*m-g*f*p+b*j*p+c*f*t-b*h*t;w.n41=k*p*q-h*x*q-k*m*y+f*x*y+h*m*z-f*p*z;w.n42=c*x*q-e*p*q+e*m*y-b*x*y-c*m*z+b*p*z;w.n43=e*h*q-c*k*q-e*f*y+b*k*y+c*f*z-b*h*z;w.n44=c*k*m-e*h*m+e*f*p-b*k*p-c*f*x+b*h*x;w.multiplyScalar(1/a.determinant());return w};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,p=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*g;c[2]=a*f;c[3]=a*h;c[4]=a*k;c[5]=a*j;c[6]=a*m;c[7]=a*p;c[8]=a*x;return b};
+THREE.Matrix4.makeInvert=function(a){var b=a.n11,c=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,k=a.n23,j=a.n24,m=a.n31,q=a.n32,w=a.n33,u=a.n34,t=a.n41,x=a.n42,A=a.n43,E=a.n44,v=new THREE.Matrix4;v.n11=k*u*x-j*w*x+j*q*A-h*u*A-k*q*E+h*w*E;v.n12=g*w*x-e*u*x-g*q*A+c*u*A+e*q*E-c*w*E;v.n13=e*j*x-g*k*x+g*h*A-c*j*A-e*h*E+c*k*E;v.n14=g*k*q-e*j*q-g*h*w+c*j*w+e*h*u-c*k*u;v.n21=j*w*t-k*u*t-j*m*A+f*u*A+k*m*E-f*w*E;v.n22=e*u*t-g*w*t+g*m*A-b*u*A-e*m*E+b*w*E;v.n23=g*k*t-e*j*t-g*f*A+b*j*A+e*f*E-b*k*E;v.n24=e*j*m-g*k*m+
+g*f*w-b*j*w-e*f*u+b*k*u;v.n31=h*u*t-j*q*t+j*m*x-f*u*x-h*m*E+f*q*E;v.n32=g*q*t-c*u*t-g*m*x+b*u*x+c*m*E-b*q*E;v.n33=e*j*t-g*h*t+g*f*x-b*j*x-c*f*E+b*h*E;v.n34=g*h*m-c*j*m-g*f*q+b*j*q+c*f*u-b*h*u;v.n41=k*q*t-h*w*t-k*m*x+f*w*x+h*m*A-f*q*A;v.n42=c*w*t-e*q*t+e*m*x-b*w*x-c*m*A+b*q*A;v.n43=e*h*t-c*k*t-e*f*x+b*k*x+c*f*A-b*h*A;v.n44=c*k*m-e*h*m+e*f*q-b*k*q-c*f*w+b*h*w;v.multiplyScalar(1/a.determinant());return v};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,q=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*g;c[2]=a*f;c[3]=a*h;c[4]=a*k;c[5]=a*j;c[6]=a*m;c[7]=a*q;c[8]=a*w;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,e,g,f){var h,k,j;h=new THREE.Matrix4;k=2*g/(b-a);j=2*g/(e-c);a=(b+a)/(b-a);c=(e+c)/(e-c);e=-(f+g)/(f-g);g=-2*f*g/(f-g);h.n11=k;h.n12=0;h.n13=a;h.n14=0;h.n21=0;h.n22=j;h.n23=c;h.n24=0;h.n31=0;h.n32=0;h.n33=e;h.n34=g;h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,e){var g;a=c*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,c,e)};
 THREE.Matrix4.makeFrustum=function(a,b,c,e,g,f){var h,k,j;h=new THREE.Matrix4;k=2*g/(b-a);j=2*g/(e-c);a=(b+a)/(b-a);c=(e+c)/(e-c);e=-(f+g)/(f-g);g=-2*f*g/(f-g);h.n11=k;h.n12=0;h.n13=a;h.n14=0;h.n21=0;h.n22=j;h.n23=c;h.n24=0;h.n31=0;h.n32=0;h.n33=e;h.n34=g;h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,e){var g;a=c*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,c,e)};
 THREE.Matrix4.makeOrtho=function(a,b,c,e,g,f){var h,k,j,m;h=new THREE.Matrix4;k=b-a;j=c-e;m=f-g;a=(b+a)/k;c=(c+e)/j;g=(f+g)/m;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-a;h.n21=0;h.n22=2/j;h.n23=0;h.n24=-c;h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-g;h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 THREE.Matrix4.makeOrtho=function(a,b,c,e,g,f){var h,k,j,m;h=new THREE.Matrix4;k=b-a;j=c-e;m=f-g;a=(b+a)/k;c=(c+e)/j;g=(f+g)/m;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-a;h.n21=0;h.n22=2/j;h.n23=0;h.n24=-c;h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-g;h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 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.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
 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.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
 THREE.Face3=function(a,b,c,e,g){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
 THREE.Face3=function(a,b,c,e,g){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
 THREE.Face4=function(a,b,c,e,g,f){this.a=a;this.b=b;this.c=c;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=f instanceof Array?f:[f]};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.Face4=function(a,b,c,e,g,f){this.a=a;this.b=b;this.c=c;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=f instanceof Array?f:[f]};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=[];this.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
+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.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);
 c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,e,g,f,h,k=new THREE.Vector3,j=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){f=this.vertices[e];f.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];if(a&&f.vertexNormals.length){k.set(0,0,0);b=0;for(c=f.normal.length;b<c;b++)k.addSelf(f.vertexNormals[b]);k.divideScalar(3)}else{b=this.vertices[f.a];c=this.vertices[f.b];h=this.vertices[f.c];k.sub(h.position,
 c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,e,g,f,h,k=new THREE.Vector3,j=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){f=this.vertices[e];f.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];if(a&&f.vertexNormals.length){k.set(0,0,0);b=0;for(c=f.normal.length;b<c;b++)k.addSelf(f.vertexNormals[b]);k.divideScalar(3)}else{b=this.vertices[f.a];c=this.vertices[f.b];h=this.vertices[f.c];k.sub(h.position,
 c.position);j.sub(b.position,c.position);k.crossSelf(j)}k.isZero()||k.normalize();f.normal.copy(k)}},computeVertexNormals:function(){var a,b,c,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)e[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,
 c.position);j.sub(b.position,c.position);k.crossSelf(j)}k.isZero()||k.normalize();f.normal.copy(k)}},computeVertexNormals:function(){var a,b,c,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)e[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,
 new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)e[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal);e[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)e[a].normalize();a=0;for(b=this.faces.length;a<
 new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)e[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal);e[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)e[a].normalize();a=0;for(b=this.faces.length;a<
-b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c]);c.vertexNormals[3].copy(e[c.d])}}},computeTangents:function(){function a(J,X,ha,Z,ea,l,v){f=J.vertices[X].position;h=J.vertices[ha].position;k=J.vertices[Z].position;j=g[ea];m=g[l];p=g[v];x=h.x-f.x;t=k.x-f.x;q=h.y-f.y;y=k.y-
-f.y;z=h.z-f.z;H=k.z-f.z;w=m.u-j.u;E=p.u-j.u;o=m.v-j.v;d=p.v-j.v;P=1/(w*d-E*o);M.set((d*x-o*t)*P,(d*q-o*y)*P,(d*z-o*H)*P);U.set((w*t-E*x)*P,(w*y-E*q)*P,(w*H-E*z)*P);aa[X].addSelf(M);aa[ha].addSelf(M);aa[Z].addSelf(M);N[X].addSelf(U);N[ha].addSelf(U);N[Z].addSelf(U)}var b,c,e,g,f,h,k,j,m,p,x,t,q,y,z,H,w,E,o,d,P,aa=[],N=[],M=new THREE.Vector3,U=new THREE.Vector3,O=new THREE.Vector3,Y=new THREE.Vector3,W=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){aa[b]=new THREE.Vector3;N[b]=new THREE.Vector3}b=
+b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c]);c.vertexNormals[3].copy(e[c.d])}}},computeTangents:function(){function a(H,Y,ea,Z,fa,ia,l){f=H.vertices[Y].position;h=H.vertices[ea].position;k=H.vertices[Z].position;j=g[fa];m=g[ia];q=g[l];w=h.x-f.x;u=k.x-f.x;t=h.y-f.y;x=k.y-
+f.y;A=h.z-f.z;E=k.z-f.z;v=m.u-j.u;F=q.u-j.u;p=m.v-j.v;M=q.v-j.v;d=1/(v*M-F*p);K.set((M*w-p*u)*d,(M*t-p*x)*d,(M*A-p*E)*d);X.set((v*u-F*w)*d,(v*x-F*t)*d,(v*E-F*A)*d);aa[Y].addSelf(K);aa[ea].addSelf(K);aa[Z].addSelf(K);O[Y].addSelf(X);O[ea].addSelf(X);O[Z].addSelf(X)}var b,c,e,g,f,h,k,j,m,q,w,u,t,x,A,E,v,F,p,M,d,aa=[],O=[],K=new THREE.Vector3,X=new THREE.Vector3,Q=new THREE.Vector3,U=new THREE.Vector3,V=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){aa[b]=new THREE.Vector3;O[b]=new THREE.Vector3}b=
 0;for(c=this.faces.length;b<c;b++){e=this.faces[b];g=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
 0;for(c=this.faces.length;b<c;b++){e=this.faces[b];g=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
-this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){W.copy(this.vertices[b].normal);e=aa[b];O.copy(e);O.subSelf(W.multiplyScalar(W.dot(e))).normalize();Y.cross(this.vertices[b].normal,e);e=Y.dot(N[b]);e=e<0?-1:1;this.vertices[b].tangent.set(O.x,O.y,O.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
+this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){V.copy(this.vertices[b].normal);e=aa[b];Q.copy(e);Q.subSelf(V.multiplyScalar(V.dot(e))).normalize();U.cross(this.vertices[b].normal,e);e=U.dot(O[b]);e=e<0?-1:1;this.vertices[b].tangent.set(Q.x,Q.y,Q.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={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 b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
 z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
-this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(p){var x=[];b=0;for(c=p.length;b<c;b++)p[b]==undefined?x.push("undefined"):x.push(p[b].toString());return x.join("_")}var b,c,e,g,f,h,k,j,m={};e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];
+this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(q){var w=[];b=0;for(c=q.length;b<c;b++)q[b]==undefined?w.push("undefined"):w.push(q[b].toString());return w.join("_")}var b,c,e,g,f,h,k,j,m={};e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];
 h=f.materials;k=a(h);if(m[k]==undefined)m[k]={hash:k,counter:0};j=m[k].hash+"_"+m[k].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:h,vertices:0};f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+f>65535){m[k].counter+=1;j=m[k].hash+"_"+m[k].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:h,vertices:0}}this.geometryChunks[j].faces.push(e);this.geometryChunks[j].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+
 h=f.materials;k=a(h);if(m[k]==undefined)m[k]={hash:k,counter:0};j=m[k].hash+"_"+m[k].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:h,vertices:0};f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+f>65535){m[k].counter+=1;j=m[k].hash+"_"+m[k].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:h,vertices:0}}this.geometryChunks[j].faces.push(e);this.geometryChunks[j].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+
-this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0;
 THREE.Camera=function(a,b,c,e){this.fov=a;this.aspect=b;this.near=c;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
 THREE.Camera=function(a,b,c,e){this.fov=a;this.aspect=b;this.near=c;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
 this.translateZ=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
 this.translateZ=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
 THREE.Camera.prototype={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.Camera.prototype={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;
@@ -104,108 +104,108 @@ var Uniforms={clone:function(a){var b,c,e,g={};for(b in a){g[b]={};for(c in a[b]
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&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.indexOf(a)===-1&&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.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&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.indexOf(a)===-1&&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.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b||1;this.far=c||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
 THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b||1;this.far=c||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
-THREE.Projector=function(){function a(N,M){return M.z-N.z}function b(N,M){var U=0,O=1,Y=N.z+N.w,W=M.z+M.w,J=-N.z+N.w,X=-M.z+M.w;if(Y>=0&&W>=0&&J>=0&&X>=0)return true;else if(Y<0&&W<0||J<0&&X<0)return false;else{if(Y<0)U=Math.max(U,Y/(Y-W));else if(W<0)O=Math.min(O,Y/(Y-W));if(J<0)U=Math.max(U,J/(J-X));else if(X<0)O=Math.min(O,J/(J-X));if(O<U)return false;else{N.lerpSelf(M,U);M.lerpSelf(N,1-O);return true}}}var c,e,g=[],f,h,k,j=[],m,p,x=[],t,q,y=[],z=new THREE.Vector4,H=new THREE.Vector4,w=new THREE.Matrix4,
-E=new THREE.Matrix4,o=[],d=new THREE.Vector4,P=new THREE.Vector4,aa;this.projectObjects=function(N,M,U){var O=[],Y,W;e=0;w.multiply(M.projectionMatrix,M.matrix);o[0]=new THREE.Vector4(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);o[1]=new THREE.Vector4(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);o[2]=new THREE.Vector4(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);o[3]=new THREE.Vector4(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);o[4]=new THREE.Vector4(w.n41-w.n31,w.n42-w.n32,w.n43-
-w.n33,w.n44-w.n34);o[5]=new THREE.Vector4(w.n41+w.n31,w.n42+w.n32,w.n43+w.n33,w.n44+w.n34);M=0;for(Y=o.length;M<Y;M++){W=o[M];W.divideScalar(Math.sqrt(W.x*W.x+W.y*W.y+W.z*W.z))}Y=N.objects;N=0;for(M=Y.length;N<M;N++){W=Y[N];var J;if(!(J=!W.visible)){if(J=W instanceof THREE.Mesh){a:{J=void 0;for(var X=W.position,ha=-W.geometry.boundingSphere.radius*Math.max(W.scale.x,Math.max(W.scale.y,W.scale.z)),Z=0;Z<6;Z++){J=o[Z].x*X.x+o[Z].y*X.y+o[Z].z*X.z+o[Z].w;if(J<=ha){J=false;break a}}J=true}J=!J}J=J}if(!J){c=
-g[e]=g[e]||new THREE.RenderableObject;z.copy(W.position);w.multiplyVector3(z);c.object=W;c.z=z.z;O.push(c);e++}}U&&O.sort(a);return O};this.projectScene=function(N,M,U){var O=[],Y=M.near,W=M.far,J,X,ha,Z,ea,l,v,A,u,n,F,L,G,D,C,R;k=p=q=0;M.autoUpdateMatrix&&M.updateMatrix();w.multiply(M.projectionMatrix,M.matrix);l=this.projectObjects(N,M,true);N=0;for(J=l.length;N<J;N++){v=l[N].object;if(v.visible){v.autoUpdateMatrix&&v.updateMatrix();A=v.matrix;u=v.rotationMatrix;n=v.materials;F=v.overdraw;if(v instanceof
-THREE.Mesh){L=v.geometry;G=L.vertices;X=0;for(ha=G.length;X<ha;X++){D=G[X];D.positionWorld.copy(D.position);A.multiplyVector3(D.positionWorld);Z=D.positionScreen;Z.copy(D.positionWorld);w.multiplyVector4(Z);Z.x/=Z.w;Z.y/=Z.w;D.__visible=Z.z>Y&&Z.z<W}L=L.faces;X=0;for(ha=L.length;X<ha;X++){D=L[X];if(D instanceof THREE.Face3){Z=G[D.a];ea=G[D.b];C=G[D.c];if(Z.__visible&&ea.__visible&&C.__visible)if(v.doubleSided||v.flipSided!=(C.positionScreen.x-Z.positionScreen.x)*(ea.positionScreen.y-Z.positionScreen.y)-
-(C.positionScreen.y-Z.positionScreen.y)*(ea.positionScreen.x-Z.positionScreen.x)<0){f=j[k]=j[k]||new THREE.RenderableFace3;f.v1.positionWorld.copy(Z.positionWorld);f.v2.positionWorld.copy(ea.positionWorld);f.v3.positionWorld.copy(C.positionWorld);f.v1.positionScreen.copy(Z.positionScreen);f.v2.positionScreen.copy(ea.positionScreen);f.v3.positionScreen.copy(C.positionScreen);f.normalWorld.copy(D.normal);u.multiplyVector3(f.normalWorld);f.centroidWorld.copy(D.centroid);A.multiplyVector3(f.centroidWorld);
-f.centroidScreen.copy(f.centroidWorld);w.multiplyVector3(f.centroidScreen);C=D.vertexNormals;aa=f.vertexNormalsWorld;Z=0;for(ea=C.length;Z<ea;Z++){R=aa[Z]=aa[Z]||new THREE.Vector3;R.copy(C[Z]);u.multiplyVector3(R)}f.z=f.centroidScreen.z;f.meshMaterials=n;f.faceMaterials=D.materials;f.overdraw=F;if(v.geometry.uvs[X]){f.uvs[0]=v.geometry.uvs[X][0];f.uvs[1]=v.geometry.uvs[X][1];f.uvs[2]=v.geometry.uvs[X][2]}O.push(f);k++}}else if(D instanceof THREE.Face4){Z=G[D.a];ea=G[D.b];C=G[D.c];R=G[D.d];if(Z.__visible&&
-ea.__visible&&C.__visible&&R.__visible)if(v.doubleSided||v.flipSided!=((R.positionScreen.x-Z.positionScreen.x)*(ea.positionScreen.y-Z.positionScreen.y)-(R.positionScreen.y-Z.positionScreen.y)*(ea.positionScreen.x-Z.positionScreen.x)<0||(ea.positionScreen.x-C.positionScreen.x)*(R.positionScreen.y-C.positionScreen.y)-(ea.positionScreen.y-C.positionScreen.y)*(R.positionScreen.x-C.positionScreen.x)<0)){f=j[k]=j[k]||new THREE.RenderableFace3;f.v1.positionWorld.copy(Z.positionWorld);f.v2.positionWorld.copy(ea.positionWorld);
-f.v3.positionWorld.copy(R.positionWorld);f.v1.positionScreen.copy(Z.positionScreen);f.v2.positionScreen.copy(ea.positionScreen);f.v3.positionScreen.copy(R.positionScreen);f.normalWorld.copy(D.normal);u.multiplyVector3(f.normalWorld);f.centroidWorld.copy(D.centroid);A.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);w.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=n;f.faceMaterials=D.materials;f.overdraw=F;if(v.geometry.uvs[X]){f.uvs[0]=v.geometry.uvs[X][0];
-f.uvs[1]=v.geometry.uvs[X][1];f.uvs[2]=v.geometry.uvs[X][3]}O.push(f);k++;h=j[k]=j[k]||new THREE.RenderableFace3;h.v1.positionWorld.copy(ea.positionWorld);h.v2.positionWorld.copy(C.positionWorld);h.v3.positionWorld.copy(R.positionWorld);h.v1.positionScreen.copy(ea.positionScreen);h.v2.positionScreen.copy(C.positionScreen);h.v3.positionScreen.copy(R.positionScreen);h.normalWorld.copy(f.normalWorld);h.centroidWorld.copy(f.centroidWorld);h.centroidScreen.copy(f.centroidScreen);h.z=h.centroidScreen.z;
-h.meshMaterials=n;h.faceMaterials=D.materials;h.overdraw=F;if(v.geometry.uvs[X]){h.uvs[0]=v.geometry.uvs[X][1];h.uvs[1]=v.geometry.uvs[X][2];h.uvs[2]=v.geometry.uvs[X][3]}O.push(h);k++}}}}else if(v instanceof THREE.Line){E.multiply(w,A);G=v.geometry.vertices;D=G[0];D.positionScreen.copy(D.position);E.multiplyVector4(D.positionScreen);X=1;for(ha=G.length;X<ha;X++){Z=G[X];Z.positionScreen.copy(Z.position);E.multiplyVector4(Z.positionScreen);ea=G[X-1];d.copy(Z.positionScreen);P.copy(ea.positionScreen);
-if(b(d,P)){d.multiplyScalar(1/d.w);P.multiplyScalar(1/P.w);m=x[p]=x[p]||new THREE.RenderableLine;m.v1.positionScreen.copy(d);m.v2.positionScreen.copy(P);m.z=Math.max(d.z,P.z);m.materials=v.materials;O.push(m);p++}}}else if(v instanceof THREE.Particle){H.set(v.position.x,v.position.y,v.position.z,1);w.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){t=y[q]=y[q]||new THREE.RenderableParticle;t.x=H.x/H.w;t.y=H.y/H.w;t.z=H.z;t.rotation=v.rotation.z;t.scale.x=v.scale.x*Math.abs(t.x-(H.x+M.projectionMatrix.n11)/
-(H.w+M.projectionMatrix.n14));t.scale.y=v.scale.y*Math.abs(t.y-(H.y+M.projectionMatrix.n22)/(H.w+M.projectionMatrix.n24));t.materials=v.materials;O.push(t);q++}}}}U&&O.sort(a);return O};this.unprojectVector=function(N,M){var U=THREE.Matrix4.makeInvert(M.matrix);U.multiplySelf(THREE.Matrix4.makeInvert(M.projectionMatrix));U.multiplyVector3(N);return N}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,g,f;this.domElement=document.createElement("div");this.setSize=function(h,k){c=h;e=k;g=c/2;f=e/2};this.render=function(h,k){var j,m,p,x,t,q,y,z;a=b.projectScene(h,k);j=0;for(m=a.length;j<m;j++){t=a[j];if(t instanceof THREE.RenderableParticle){y=t.x*g+g;z=t.y*f+f;p=0;for(x=t.material.length;p<x;p++){q=t.material[p];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=y+"px";q.style.top=z+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(fa){if(t!=fa)m.globalAlpha=t=fa}function b(fa){if(q!=fa){switch(fa){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}q=fa}}var c=null,e=new THREE.Projector,g=document.createElement("canvas"),f,h,k,j,m=g.getContext("2d"),p=new THREE.Color(0),x=0,t=1,q=0,y=null,z=null,H=1,w,E,o,d,P,aa,N,M,U,O=new THREE.Color,
-Y=new THREE.Color,W=new THREE.Color,J=new THREE.Color,X=new THREE.Color,ha,Z,ea,l,v,A,u,n,F,L=new THREE.Rectangle,G=new THREE.Rectangle,D=new THREE.Rectangle,C=false,R=new THREE.Color,ba=new THREE.Color,ga=new THREE.Color,B=new THREE.Color,K=Math.PI*2,I=new THREE.Vector3,Q,da,V,ka,pa,ua,la=16;Q=document.createElement("canvas");Q.width=Q.height=2;da=Q.getContext("2d");da.fillStyle="rgba(0,0,0,1)";da.fillRect(0,0,2,2);V=da.getImageData(0,0,2,2);ka=V.data;pa=document.createElement("canvas");pa.width=
-pa.height=la;ua=pa.getContext("2d");ua.translate(-la/2,-la/2);ua.scale(la,la);la--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(fa,ja){f=fa;h=ja;k=f/2;j=h/2;g.width=f;g.height=h;L.set(-k,-j,k,j);t=1;q=0;z=y=null;H=1};this.setClearColor=function(fa,ja){p=fa;x=ja;G.set(-k,-j,k,j);m.setTransform(1,0,0,-1,k,j);this.clear()};this.setClearColorHex=function(fa,ja){p.setHex(fa);x=ja;G.set(-k,-j,k,j);m.setTransform(1,0,0,-1,k,j);this.clear()};this.clear=function(){m.setTransform(1,
-0,0,-1,k,j);if(!G.isEmpty()){G.inflate(1);G.minSelf(L);if(p.hex==0&&x==0)m.clearRect(G.getX(),G.getY(),G.getWidth(),G.getHeight());else{b(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*255)+","+x+")";m.fillRect(G.getX(),G.getY(),G.getWidth(),G.getHeight())}G.empty()}};this.render=function(fa,ja){function Fa(S){var ia,ca,T,$=S.lights;ba.setRGB(0,0,0);ga.setRGB(0,0,0);B.setRGB(0,0,0);S=0;for(ia=$.length;S<ia;S++){ca=$[S];T=ca.color;if(ca instanceof
-THREE.AmbientLight){ba.r+=T.r;ba.g+=T.g;ba.b+=T.b}else if(ca instanceof THREE.DirectionalLight){ga.r+=T.r;ga.g+=T.g;ga.b+=T.b}else if(ca instanceof THREE.PointLight){B.r+=T.r;B.g+=T.g;B.b+=T.b}}}function ta(S,ia,ca,T){var $,na,va,Aa,Ca=S.lights;S=0;for($=Ca.length;S<$;S++){na=Ca[S];va=na.color;Aa=na.intensity;if(na instanceof THREE.DirectionalLight){na=ca.dot(na.position)*Aa;if(na>0){T.r+=va.r*na;T.g+=va.g*na;T.b+=va.b*na}}else if(na instanceof THREE.PointLight){I.sub(na.position,ia);I.normalize();
-na=ca.dot(I)*Aa;if(na>0){T.r+=va.r*na;T.g+=va.g*na;T.b+=va.b*na}}}}function qa(S,ia,ca){if(ca.opacity!=0){a(ca.opacity);b(ca.blending);var T,$,na,va,Aa,Ca;if(ca instanceof THREE.ParticleBasicMaterial){if(ca.map&&ca.map.image.loaded){va=ca.map.image;Aa=va.width>>1;Ca=va.height>>1;$=ia.scale.x*k;na=ia.scale.y*j;ca=$*Aa;T=na*Ca;D.set(S.x-ca,S.y-T,S.x+ca,S.y+T);if(L.instersects(D)){m.save();m.translate(S.x,S.y);m.rotate(-ia.rotation);m.scale($,-na);m.translate(-Aa,-Ca);m.drawImage(va,0,0);m.restore()}}}else if(ca instanceof
-THREE.ParticleCircleMaterial){if(C){R.r=ba.r+ga.r+B.r;R.g=ba.g+ga.g+B.g;R.b=ba.b+ga.b+B.b;O.r=ca.color.r*R.r;O.g=ca.color.g*R.g;O.b=ca.color.b*R.b;O.updateStyleString()}else O.__styleString=ca.color.__styleString;ca=ia.scale.x*k;T=ia.scale.y*j;D.set(S.x-ca,S.y-T,S.x+ca,S.y+T);if(L.instersects(D)){$=O.__styleString;if(z!=$)m.fillStyle=z=$;m.save();m.translate(S.x,S.y);m.rotate(-ia.rotation);m.scale(ca,T);m.beginPath();m.arc(0,0,1,0,K,true);m.closePath();m.fill();m.restore()}}}}function sa(S,ia,ca,
-T){if(T.opacity!=0){a(T.opacity);b(T.blending);m.beginPath();m.moveTo(S.positionScreen.x,S.positionScreen.y);m.lineTo(ia.positionScreen.x,ia.positionScreen.y);m.closePath();if(T instanceof THREE.LineBasicMaterial){O.__styleString=T.color.__styleString;S=T.linewidth;if(H!=S)m.lineWidth=H=S;S=O.__styleString;if(y!=S)m.strokeStyle=y=S;m.stroke();D.inflate(T.linewidth*2)}}}function Ma(S,ia,ca,T,$,na){if($.opacity!=0){a($.opacity);b($.blending);d=S.positionScreen.x;P=S.positionScreen.y;aa=ia.positionScreen.x;
-N=ia.positionScreen.y;M=ca.positionScreen.x;U=ca.positionScreen.y;m.beginPath();m.moveTo(d,P);m.lineTo(aa,N);m.lineTo(M,U);m.lineTo(d,P);m.closePath();if($ instanceof THREE.MeshBasicMaterial)if($.map)$.map.image.loaded&&$.map.mapping instanceof THREE.UVMapping&&ma(d,P,aa,N,M,U,$.map.image,T.uvs[0].u,T.uvs[0].v,T.uvs[1].u,T.uvs[1].v,T.uvs[2].u,T.uvs[2].v);else if($.env_map){if($.env_map.image.loaded)if($.env_map.mapping instanceof THREE.SphericalReflectionMapping){S=ja.matrix;I.copy(T.vertexNormalsWorld[0]);
-l=(I.x*S.n11+I.y*S.n12+I.z*S.n13)*0.5+0.5;v=-(I.x*S.n21+I.y*S.n22+I.z*S.n23)*0.5+0.5;I.copy(T.vertexNormalsWorld[1]);A=(I.x*S.n11+I.y*S.n12+I.z*S.n13)*0.5+0.5;u=-(I.x*S.n21+I.y*S.n22+I.z*S.n23)*0.5+0.5;I.copy(T.vertexNormalsWorld[2]);n=(I.x*S.n11+I.y*S.n12+I.z*S.n13)*0.5+0.5;F=-(I.x*S.n21+I.y*S.n22+I.z*S.n23)*0.5+0.5;ma(d,P,aa,N,M,U,$.env_map.image,l,v,A,u,n,F)}}else $.wireframe?Ga($.color.__styleString,$.wireframe_linewidth):za($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&
-!$.wireframe){$.map.mapping instanceof THREE.UVMapping&&ma(d,P,aa,N,M,U,$.map.image,T.uvs[0].u,T.uvs[0].v,T.uvs[1].u,T.uvs[1].v,T.uvs[2].u,T.uvs[2].v);b(THREE.SubtractiveBlending)}if(C)if(!$.wireframe&&$.shading==THREE.SmoothShading&&T.vertexNormalsWorld.length==3){Y.r=W.r=J.r=ba.r;Y.g=W.g=J.g=ba.g;Y.b=W.b=J.b=ba.b;ta(na,T.v1.positionWorld,T.vertexNormalsWorld[0],Y);ta(na,T.v2.positionWorld,T.vertexNormalsWorld[1],W);ta(na,T.v3.positionWorld,T.vertexNormalsWorld[2],J);X.r=(W.r+J.r)*0.5;X.g=(W.g+J.g)*
-0.5;X.b=(W.b+J.b)*0.5;ea=ra(Y,W,J,X);ma(d,P,aa,N,M,U,ea,0,0,1,0,0,1)}else{R.r=ba.r;R.g=ba.g;R.b=ba.b;ta(na,T.centroidWorld,T.normalWorld,R);O.r=$.color.r*R.r;O.g=$.color.g*R.g;O.b=$.color.b*R.b;O.updateStyleString();$.wireframe?Ga(O.__styleString,$.wireframe_linewidth):za(O.__styleString)}else $.wireframe?Ga($.color.__styleString,$.wireframe_linewidth):za($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){ha=ja.near;Z=ja.far;Y.r=Y.g=Y.b=1-Da(S.positionScreen.z,ha,Z);W.r=W.g=W.b=
-1-Da(ia.positionScreen.z,ha,Z);J.r=J.g=J.b=1-Da(ca.positionScreen.z,ha,Z);X.r=(W.r+J.r)*0.5;X.g=(W.g+J.g)*0.5;X.b=(W.b+J.b)*0.5;ea=ra(Y,W,J,X);ma(d,P,aa,N,M,U,ea,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){O.r=xa(T.normalWorld.x);O.g=xa(T.normalWorld.y);O.b=xa(T.normalWorld.z);O.updateStyleString();$.wireframe?Ga(O.__styleString,$.wireframe_linewidth):za(O.__styleString)}}}function Ga(S,ia){if(y!=S)m.strokeStyle=y=S;if(H!=ia)m.lineWidth=H=ia;m.stroke();D.inflate(ia*2)}function za(S){if(z!=
-S)m.fillStyle=z=S;m.fill()}function ma(S,ia,ca,T,$,na,va,Aa,Ca,Ja,Ea,Ka,Ra){var Ha,La;Ha=va.width-1;La=va.height-1;Aa*=Ha;Ca*=La;Ja*=Ha;Ea*=La;Ka*=Ha;Ra*=La;ca-=S;T-=ia;$-=S;na-=ia;Ja-=Aa;Ea-=Ca;Ka-=Aa;Ra-=Ca;Ha=Ja*Ra-Ka*Ea;if(Ha!=0){La=1/Ha;Ha=(Ra*ca-Ea*$)*La;Ea=(Ra*T-Ea*na)*La;ca=(Ja*$-Ka*ca)*La;T=(Ja*na-Ka*T)*La;S=S-Ha*Aa-ca*Ca;ia=ia-Ea*Aa-T*Ca;m.save();m.transform(Ha,Ea,ca,T,S,ia);m.clip();m.drawImage(va,0,0);m.restore()}}function ra(S,ia,ca,T){var $=~~(S.r*255),na=~~(S.g*255);S=~~(S.b*255);var va=
-~~(ia.r*255),Aa=~~(ia.g*255);ia=~~(ia.b*255);var Ca=~~(ca.r*255),Ja=~~(ca.g*255);ca=~~(ca.b*255);var Ea=~~(T.r*255),Ka=~~(T.g*255);T=~~(T.b*255);ka[0]=$<0?0:$>255?255:$;ka[1]=na<0?0:na>255?255:na;ka[2]=S<0?0:S>255?255:S;ka[4]=va<0?0:va>255?255:va;ka[5]=Aa<0?0:Aa>255?255:Aa;ka[6]=ia<0?0:ia>255?255:ia;ka[8]=Ca<0?0:Ca>255?255:Ca;ka[9]=Ja<0?0:Ja>255?255:Ja;ka[10]=ca<0?0:ca>255?255:ca;ka[12]=Ea<0?0:Ea>255?255:Ea;ka[13]=Ka<0?0:Ka>255?255:Ka;ka[14]=T<0?0:T>255?255:T;da.putImageData(V,0,0);ua.drawImage(Q,
-0,0);return pa}function Da(S,ia,ca){S=(S-ia)/(ca-ia);return S*S*(3-2*S)}function xa(S){S=(S+1)*0.5;return S<0?0:S>1?1:S}function Oa(S,ia){var ca=ia.x-S.x,T=ia.y-S.y,$=1/Math.sqrt(ca*ca+T*T);ca*=$;T*=$;ia.x+=ca;ia.y+=T;S.x-=ca;S.y-=T}var ya,Pa,oa,Ba,Ia,Na,Qa,wa;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,j);c=e.projectScene(fa,ja,this.sortElements);(C=fa.lights.length>0)&&Fa(fa);ya=0;for(Pa=c.length;ya<Pa;ya++){oa=c[ya];D.empty();if(oa instanceof THREE.RenderableParticle){w=oa;w.x*=k;w.y*=
-j;Ba=0;for(Ia=oa.materials.length;Ba<Ia;Ba++)qa(w,oa,oa.materials[Ba],fa)}else if(oa instanceof THREE.RenderableLine){w=oa.v1;E=oa.v2;w.positionScreen.x*=k;w.positionScreen.y*=j;E.positionScreen.x*=k;E.positionScreen.y*=j;D.addPoint(w.positionScreen.x,w.positionScreen.y);D.addPoint(E.positionScreen.x,E.positionScreen.y);if(L.instersects(D)){Ba=0;for(Ia=oa.materials.length;Ba<Ia;)sa(w,E,oa,oa.materials[Ba++],fa)}}else if(oa instanceof THREE.RenderableFace3){w=oa.v1;E=oa.v2;o=oa.v3;w.positionScreen.x*=
-k;w.positionScreen.y*=j;E.positionScreen.x*=k;E.positionScreen.y*=j;o.positionScreen.x*=k;o.positionScreen.y*=j;if(oa.overdraw){Oa(w.positionScreen,E.positionScreen);Oa(E.positionScreen,o.positionScreen);Oa(o.positionScreen,w.positionScreen)}D.add3Points(w.positionScreen.x,w.positionScreen.y,E.positionScreen.x,E.positionScreen.y,o.positionScreen.x,o.positionScreen.y);if(L.instersects(D)){Ba=0;for(Ia=oa.meshMaterials.length;Ba<Ia;){wa=oa.meshMaterials[Ba++];if(wa instanceof THREE.MeshFaceMaterial){Na=
-0;for(Qa=oa.faceMaterials.length;Na<Qa;)(wa=oa.faceMaterials[Na++])&&Ma(w,E,o,oa,wa,fa)}else Ma(w,E,o,oa,wa,fa)}}}G.addRectangle(D)}m.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(l,v,A){var u,n,F,L;u=0;for(n=l.lights.length;u<n;u++){F=l.lights[u];if(F instanceof THREE.DirectionalLight){L=v.normalWorld.dot(F.position)*F.intensity;if(L>0){A.r+=F.color.r*L;A.g+=F.color.g*L;A.b+=F.color.b*L}}else if(F instanceof THREE.PointLight){U.sub(F.position,v.centroidWorld);U.normalize();L=v.normalWorld.dot(U)*F.intensity;if(L>0){A.r+=F.color.r*L;A.g+=F.color.g*L;A.b+=F.color.b*L}}}}function b(l,v,A,u,n,F){J=e(X++);J.setAttribute("d","M "+l.positionScreen.x+
-" "+l.positionScreen.y+" L "+v.positionScreen.x+" "+v.positionScreen.y+" L "+A.positionScreen.x+","+A.positionScreen.y+"z");if(n instanceof THREE.MeshBasicMaterial)o.__styleString=n.color.__styleString;else if(n instanceof THREE.MeshLambertMaterial)if(E){d.r=P.r;d.g=P.g;d.b=P.b;a(F,u,d);o.r=n.color.r*d.r;o.g=n.color.g*d.g;o.b=n.color.b*d.b;o.updateStyleString()}else o.__styleString=n.color.__styleString;else if(n instanceof THREE.MeshDepthMaterial){M=1-n.__2near/(n.__farPlusNear-u.z*n.__farMinusNear);
-o.setRGB(M,M,M)}else n instanceof THREE.MeshNormalMaterial&&o.setRGB(g(u.normalWorld.x),g(u.normalWorld.y),g(u.normalWorld.z));n.wireframe?J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+n.wireframe_linewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframe_linecap+"; stroke-linejoin: "+n.wireframe_linejoin):J.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+n.opacity);k.appendChild(J)}function c(l,v,A,u,n,F,L){J=e(X++);J.setAttribute("d",
-"M "+l.positionScreen.x+" "+l.positionScreen.y+" L "+v.positionScreen.x+" "+v.positionScreen.y+" L "+A.positionScreen.x+","+A.positionScreen.y+" L "+u.positionScreen.x+","+u.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)o.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(E){d.r=P.r;d.g=P.g;d.b=P.b;a(L,n,d);o.r=F.color.r*d.r;o.g=F.color.g*d.g;o.b=F.color.b*d.b;o.updateStyleString()}else o.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){M=
-1-F.__2near/(F.__farPlusNear-n.z*F.__farMinusNear);o.setRGB(M,M,M)}else F instanceof THREE.MeshNormalMaterial&&o.setRGB(g(n.normalWorld.x),g(n.normalWorld.y),g(n.normalWorld.z));F.wireframe?J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):J.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+F.opacity);k.appendChild(J)}
-function e(l){if(O[l]==null){O[l]=document.createElementNS("http://www.w3.org/2000/svg","path");ea==0&&O[l].setAttribute("shape-rendering","crispEdges");return O[l]}return O[l]}function g(l){return l<0?Math.min((1+l)*0.5,0.5):0.5+Math.min(l*0.5,0.5)}var f=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,p,x,t,q,y,z,H=new THREE.Rectangle,w=new THREE.Rectangle,E=false,o=new THREE.Color(16777215),d=new THREE.Color(16777215),P=new THREE.Color(0),aa=new THREE.Color(0),
-N=new THREE.Color(0),M,U=new THREE.Vector3,O=[],Y=[],W=[],J,X,ha,Z,ea=1;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(l){switch(l){case "high":ea=1;break;case "low":ea=0}};this.setSize=function(l,v){j=l;m=v;p=j/2;x=m/2;k.setAttribute("viewBox",-p+" "+-x+" "+j+" "+m);k.setAttribute("width",j);k.setAttribute("height",m);H.set(-p,-x,p,x)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(l,v){var A,
-u,n,F,L,G,D,C;this.autoClear&&this.clear();f=h.projectScene(l,v,this.sortElements);Z=ha=X=0;if(E=l.lights.length>0){D=l.lights;P.setRGB(0,0,0);aa.setRGB(0,0,0);N.setRGB(0,0,0);A=0;for(u=D.length;A<u;A++){n=D[A];F=n.color;if(n instanceof THREE.AmbientLight){P.r+=F.r;P.g+=F.g;P.b+=F.b}else if(n instanceof THREE.DirectionalLight){aa.r+=F.r;aa.g+=F.g;aa.b+=F.b}else if(n instanceof THREE.PointLight){N.r+=F.r;N.g+=F.g;N.b+=F.b}}}A=0;for(u=f.length;A<u;A++){D=f[A];w.empty();if(D instanceof THREE.RenderableParticle){t=
-D;t.x*=p;t.y*=-x;n=0;for(F=D.materials.length;n<F;n++)if(C=D.materials[n]){L=t;G=D;C=C;var R=ha++;if(Y[R]==null){Y[R]=document.createElementNS("http://www.w3.org/2000/svg","circle");ea==0&&Y[R].setAttribute("shape-rendering","crispEdges")}J=Y[R];J.setAttribute("cx",L.x);J.setAttribute("cy",L.y);J.setAttribute("r",G.scale.x*p);if(C instanceof THREE.ParticleCircleMaterial){if(E){d.r=P.r+aa.r+N.r;d.g=P.g+aa.g+N.g;d.b=P.b+aa.b+N.b;o.r=C.color.r*d.r;o.g=C.color.g*d.g;o.b=C.color.b*d.b;o.updateStyleString()}else o=
-C.color;J.setAttribute("style","fill: "+o.__styleString)}k.appendChild(J)}}else if(D instanceof THREE.RenderableLine){t=D.v1;q=D.v2;t.positionScreen.x*=p;t.positionScreen.y*=-x;q.positionScreen.x*=p;q.positionScreen.y*=-x;w.addPoint(t.positionScreen.x,t.positionScreen.y);w.addPoint(q.positionScreen.x,q.positionScreen.y);if(H.instersects(w)){n=0;for(F=D.materials.length;n<F;)if(C=D.materials[n++]){L=t;G=q;C=C;R=Z++;if(W[R]==null){W[R]=document.createElementNS("http://www.w3.org/2000/svg","line");ea==
-0&&W[R].setAttribute("shape-rendering","crispEdges")}J=W[R];J.setAttribute("x1",L.positionScreen.x);J.setAttribute("y1",L.positionScreen.y);J.setAttribute("x2",G.positionScreen.x);J.setAttribute("y2",G.positionScreen.y);if(C instanceof THREE.LineBasicMaterial){o.__styleString=C.color.__styleString;J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+C.linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.linecap+"; stroke-linejoin: "+C.linejoin);k.appendChild(J)}}}}else if(D instanceof
-THREE.RenderableFace3){t=D.v1;q=D.v2;y=D.v3;t.positionScreen.x*=p;t.positionScreen.y*=-x;q.positionScreen.x*=p;q.positionScreen.y*=-x;y.positionScreen.x*=p;y.positionScreen.y*=-x;w.addPoint(t.positionScreen.x,t.positionScreen.y);w.addPoint(q.positionScreen.x,q.positionScreen.y);w.addPoint(y.positionScreen.x,y.positionScreen.y);if(H.instersects(w)){n=0;for(F=D.meshMaterials.length;n<F;){C=D.meshMaterials[n++];if(C instanceof THREE.MeshFaceMaterial){L=0;for(G=D.faceMaterials.length;L<G;)(C=D.faceMaterials[L++])&&
-b(t,q,y,D,C,l)}else C&&b(t,q,y,D,C,l)}}}else if(D instanceof THREE.RenderableFace4){t=D.v1;q=D.v2;y=D.v3;z=D.v4;t.positionScreen.x*=p;t.positionScreen.y*=-x;q.positionScreen.x*=p;q.positionScreen.y*=-x;y.positionScreen.x*=p;y.positionScreen.y*=-x;z.positionScreen.x*=p;z.positionScreen.y*=-x;w.addPoint(t.positionScreen.x,t.positionScreen.y);w.addPoint(q.positionScreen.x,q.positionScreen.y);w.addPoint(y.positionScreen.x,y.positionScreen.y);w.addPoint(z.positionScreen.x,z.positionScreen.y);if(H.instersects(w)){n=
-0;for(F=D.meshMaterials.length;n<F;){C=D.meshMaterials[n++];if(C instanceof THREE.MeshFaceMaterial){L=0;for(G=D.faceMaterials.length;L<G;)(C=D.faceMaterials[L++])&&c(t,q,y,z,D,C,l)}else C&&c(t,q,y,z,D,C,l)}}}}}};
-THREE.WebGLRenderer=function(a){function b(l,v,A){var u,n,F,L=l.vertices,G=L.length,D=l.colors,C=D.length,R=l.__vertexArray,ba=l.__colorArray,ga=l.__sortArray,B=l.__dirtyVertices,K=l.__dirtyColors;if(A.sortParticles){Y.multiplySelf(A.matrixWorld);for(u=0;u<G;u++){n=L[u].position;X.copy(n);Y.multiplyVector3(X);ga[u]=[X.z,u]}ga.sort(function(I,Q){return Q[0]-I[0]});for(u=0;u<G;u++){n=L[ga[u][1]].position;F=u*3;R[F]=n.x;R[F+1]=n.y;R[F+2]=n.z}for(u=0;u<C;u++){F=u*3;color=D[ga[u][1]];ba[F]=color.r;ba[F+
-1]=color.g;ba[F+2]=color.b}}else{if(B)for(u=0;u<G;u++){n=L[u].position;F=u*3;R[F]=n.x;R[F+1]=n.y;R[F+2]=n.z}if(K)for(u=0;u<C;u++){color=D[u];F=u*3;ba[F]=color.r;ba[F+1]=color.g;ba[F+2]=color.b}}if(B||A.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,R,v)}if(K||A.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,ba,v)}}function c(l,v){l.fragment_shader=v.fragment_shader;l.vertex_shader=v.vertex_shader;l.uniforms=
-Uniforms.clone(v.uniforms)}function e(l,v){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=d.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=d.createBuffer();if(l.hasPos){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,l.positionArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(v.attributes.position);d.vertexAttribPointer(v.attributes.position,3,d.FLOAT,false,0,0)}if(l.hasNormal){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,
-l.normalArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(v.attributes.normal);d.vertexAttribPointer(v.attributes.normal,3,d.FLOAT,false,0,0)}d.drawArrays(d.TRIANGLES,0,l.count);l.count=0}function g(l){if(N!=l.doubleSided){l.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE);N=l.doubleSided}if(M!=l.flipSided){l.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW);M=l.flipSided}}function f(l){O[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,l.n44-l.n14);O[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+
-l.n14);O[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);O[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);O[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);O[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var v;for(l=0;l<5;l++){v=O[l];v.divideScalar(Math.sqrt(v.x*v.x+v.y*v.y+v.z*v.z))}}function h(l){for(var v=l.matrix,A=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),u=0;u<6;u++){l=O[u].x*v.n14+O[u].y*v.n24+O[u].z*v.n34+O[u].w;
-if(l<=A)return false}return true}function k(l,v){l.list[l.count]=v;l.count+=1}function j(l){var v,A,u=l.object,n=l.opaque,F=l.transparent;F.count=0;l=n.count=0;for(v=u.materials.length;l<v;l++){A=u.materials[l];A.opacity&&A.opacity<1||A.blending!=THREE.NormalBlending?k(F,A):k(n,A)}}function m(l){var v,A,u,n,F=l.object,L=l.buffer,G=l.opaque,D=l.transparent;D.count=0;l=G.count=0;for(u=F.materials.length;l<u;l++){v=F.materials[l];if(v instanceof THREE.MeshFaceMaterial){v=0;for(A=L.materials.length;v<
-A;v++)if(n=L.materials[v])n.opacity&&n.opacity<1||n.blending!=THREE.NormalBlending?k(D,n):k(G,n)}else{n=v;n.opacity&&n.opacity<1||n.blending!=THREE.NormalBlending?k(D,n):k(G,n)}}}function p(l){var v,A,u,n=l.children;v=0;for(A=n.length;v<A;v++){u=n[v];u.autoUpdateMatrix&&u.updateMatrix();u.matrixWorld.multiply(l.matrixWorld,u.matrix);p(u)}}function x(l,v){var A,u,n=v.children;A=0;for(u=n.length;A<u;A++){child=n[A];t(l,child,false);x(l,child)}}function t(l,v,A){var u,n,F;n=v.geometry;if(l.__webGLObjectsMap[v.id]==
-undefined){l.__webGLObjectsMap[v.id]={};v._modelViewMatrix=new THREE.Matrix4;v._normalMatrixArray=new Float32Array(9);v._modelViewMatrixArray=new Float32Array(16);v._objectMatrixArray=new Float32Array(16);v.matrix.flattenToArray(v._objectMatrixArray)}F=l.__webGLObjectsMap[v.id];objlist=l.__webGLObjects;if(v instanceof THREE.Mesh){for(u in n.geometryChunks){l=n.geometryChunks[u];if(!l.__webGLVertexBuffer){var L=l;L.__webGLVertexBuffer=d.createBuffer();L.__webGLNormalBuffer=d.createBuffer();L.__webGLTangentBuffer=
-d.createBuffer();L.__webGLColorBuffer=d.createBuffer();L.__webGLUVBuffer=d.createBuffer();L.__webGLUV2Buffer=d.createBuffer();L.__webGLFaceBuffer=d.createBuffer();L.__webGLLineBuffer=d.createBuffer();L=l;var G=v,D=void 0,C=void 0,R=0,ba=0,ga=0,B=G.geometry.faces,K=L.faces;D=0;for(C=K.length;D<C;D++){fi=K[D];face=B[fi];if(face instanceof THREE.Face3){R+=3;ba+=1;ga+=3}else if(face instanceof THREE.Face4){R+=4;ba+=2;ga+=4}}L.__vertexArray=new Float32Array(R*3);L.__normalArray=new Float32Array(R*3);L.__tangentArray=
-new Float32Array(R*4);L.__colorArray=new Float32Array(R*3);L.__uvArray=new Float32Array(R*2);L.__uv2Array=new Float32Array(R*2);L.__faceArray=new Uint16Array(ba*3);L.__lineArray=new Uint16Array(ga*2);C=D=L;G=G;R=void 0;B=void 0;var I=void 0,Q=void 0;I=void 0;K=false;R=0;for(B=G.materials.length;R<B;R++){I=G.materials[R];if(I instanceof THREE.MeshFaceMaterial){I=0;for(Q=C.materials.length;I<Q;I++)if(C.materials[I]&&C.materials[I].shading!=undefined&&C.materials[I].shading==THREE.SmoothShading){K=true;
-break}}else if(I&&I.shading!=undefined&&I.shading==THREE.SmoothShading){K=true;break}if(K)break}D.__needsSmoothNormals=K;L.__webGLFaceCount=ba*3;L.__webGLLineCount=ga*2;n.__dirtyVertices=true;n.__dirtyElements=true;n.__dirtyUvs=true;n.__dirtyNormals=true;n.__dirtyTangents=true;n.__dirtyColors=true}if(n.__dirtyVertices||n.__dirtyElements||n.__dirtyUvs||n.__dirtyNormals||n.__dirtyColors||n.__dirtyTangents){L=l;ba=d.DYNAMIC_DRAW;ga=void 0;D=void 0;var da=void 0,V=void 0,ka=void 0,pa=void 0,ua=void 0;
-da=void 0;var la=void 0,fa=void 0,ja=void 0,Fa=void 0;la=void 0;fa=void 0;ja=void 0;V=void 0;la=void 0;fa=void 0;ja=void 0;Fa=void 0;V=void 0;pa=void 0;ka=void 0;ua=void 0;var ta=Q=I=K=B=R=G=C=0,qa=0,sa=L.__vertexArray,Ma=L.__uvArray,Ga=L.__uv2Array,za=L.__normalArray,ma=L.__tangentArray,ra=L.__colorArray,Da=L.__faceArray,xa=L.__lineArray,Oa=L.__needsSmoothNormals,ya=v.geometry,Pa=ya.__dirtyVertices,oa=ya.__dirtyElements,Ba=ya.__dirtyUvs,Ia=ya.__dirtyNormals,Na=ya.__dirtyTangents,Qa=ya.__dirtyColors,
-wa=ya.vertices,S=L.faces,ia=ya.faces,ca=ya.uvs,T=ya.uvs2,$=ya.colors;ga=0;for(D=S.length;ga<D;ga++){da=S[ga];V=ia[da];ua=ca[da];da=T[da];ka=V.vertexNormals;pa=V.normal;if(V instanceof THREE.Face3){if(Pa){la=wa[V.a].position;fa=wa[V.b].position;ja=wa[V.c].position;sa[G]=la.x;sa[G+1]=la.y;sa[G+2]=la.z;sa[G+3]=fa.x;sa[G+4]=fa.y;sa[G+5]=fa.z;sa[G+6]=ja.x;sa[G+7]=ja.y;sa[G+8]=ja.z;G+=9}if(Qa&&$.length){la=$[V.a];fa=$[V.b];ja=$[V.c];ra[qa]=la.r;ra[qa+1]=la.g;ra[qa+2]=la.b;ra[qa+3]=fa.r;ra[qa+4]=fa.g;ra[qa+
-5]=fa.b;ra[qa+6]=ja.r;ra[qa+7]=ja.g;ra[qa+8]=ja.b;qa+=9}if(Na&&ya.hasTangents){la=wa[V.a].tangent;fa=wa[V.b].tangent;ja=wa[V.c].tangent;ma[Q]=la.x;ma[Q+1]=la.y;ma[Q+2]=la.z;ma[Q+3]=la.w;ma[Q+4]=fa.x;ma[Q+5]=fa.y;ma[Q+6]=fa.z;ma[Q+7]=fa.w;ma[Q+8]=ja.x;ma[Q+9]=ja.y;ma[Q+10]=ja.z;ma[Q+11]=ja.w;Q+=12}if(Ia)if(ka.length==3&&Oa)for(V=0;V<3;V++){pa=ka[V];za[I]=pa.x;za[I+1]=pa.y;za[I+2]=pa.z;I+=3}else for(V=0;V<3;V++){za[I]=pa.x;za[I+1]=pa.y;za[I+2]=pa.z;I+=3}if(Ba&&ua)for(V=0;V<3;V++){ka=ua[V];Ma[R]=ka.u;
-Ma[R+1]=ka.v;R+=2}if(Ba&&da)for(V=0;V<3;V++){ua=da[V];Ga[B]=ua.u;Ga[B+1]=ua.v;B+=2}if(oa){Da[K]=C;Da[K+1]=C+1;Da[K+2]=C+2;K+=3;xa[ta]=C;xa[ta+1]=C+1;xa[ta+2]=C;xa[ta+3]=C+2;xa[ta+4]=C+1;xa[ta+5]=C+2;ta+=6;C+=3}}else if(V instanceof THREE.Face4){if(Pa){la=wa[V.a].position;fa=wa[V.b].position;ja=wa[V.c].position;Fa=wa[V.d].position;sa[G]=la.x;sa[G+1]=la.y;sa[G+2]=la.z;sa[G+3]=fa.x;sa[G+4]=fa.y;sa[G+5]=fa.z;sa[G+6]=ja.x;sa[G+7]=ja.y;sa[G+8]=ja.z;sa[G+9]=Fa.x;sa[G+10]=Fa.y;sa[G+11]=Fa.z;G+=12}if(Qa&&
-$.length){la=$[V.a];fa=$[V.b];ja=$[V.c];Fa=$[V.d];ra[qa]=la.r;ra[qa+1]=la.g;ra[qa+2]=la.b;ra[qa+3]=fa.r;ra[qa+4]=fa.g;ra[qa+5]=fa.b;ra[qa+6]=ja.r;ra[qa+7]=ja.g;ra[qa+8]=ja.b;ra[qa+9]=Fa.r;ra[qa+10]=Fa.g;ra[qa+11]=Fa.b;qa+=12}if(Na&&ya.hasTangents){la=wa[V.a].tangent;fa=wa[V.b].tangent;ja=wa[V.c].tangent;V=wa[V.d].tangent;ma[Q]=la.x;ma[Q+1]=la.y;ma[Q+2]=la.z;ma[Q+3]=la.w;ma[Q+4]=fa.x;ma[Q+5]=fa.y;ma[Q+6]=fa.z;ma[Q+7]=fa.w;ma[Q+8]=ja.x;ma[Q+9]=ja.y;ma[Q+10]=ja.z;ma[Q+11]=ja.w;ma[Q+12]=V.x;ma[Q+13]=
-V.y;ma[Q+14]=V.z;ma[Q+15]=V.w;Q+=16}if(Ia)if(ka.length==4&&Oa)for(V=0;V<4;V++){pa=ka[V];za[I]=pa.x;za[I+1]=pa.y;za[I+2]=pa.z;I+=3}else for(V=0;V<4;V++){za[I]=pa.x;za[I+1]=pa.y;za[I+2]=pa.z;I+=3}if(Ba&&ua)for(V=0;V<4;V++){ka=ua[V];Ma[R]=ka.u;Ma[R+1]=ka.v;R+=2}if(Ba&&da)for(V=0;V<4;V++){ua=da[V];Ga[B]=ua.u;Ga[B+1]=ua.v;B+=2}if(oa){Da[K]=C;Da[K+1]=C+1;Da[K+2]=C+2;Da[K+3]=C;Da[K+4]=C+2;Da[K+5]=C+3;K+=6;xa[ta]=C;xa[ta+1]=C+1;xa[ta+2]=C;xa[ta+3]=C+3;xa[ta+4]=C+1;xa[ta+5]=C+2;xa[ta+6]=C+2;xa[ta+7]=C+3;ta+=
-8;C+=4}}}if(Pa){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,sa,ba)}if(Qa&&$.length){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,ra,ba)}if(Ia){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,za,ba)}if(Na&&ya.hasTangents){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLTangentBuffer);d.bufferData(d.ARRAY_BUFFER,ma,ba)}if(Ba&&R>0){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLUVBuffer);d.bufferData(d.ARRAY_BUFFER,Ma,ba)}if(Ba&&
-B>0){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Ga,ba)}if(oa){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,L.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,Da,ba);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,L.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,xa,ba)}}q(objlist,F,u,l,v,A)}n.__dirtyVertices=false;n.__dirtyElements=false;n.__dirtyUvs=false;n.__dirtyNormals=false;n.__dirtyTangents=false;n.__dirtyColors=false}else if(v instanceof THREE.Line){if(!n.__webGLVertexBuffer){n.__webGLVertexBuffer=
-d.createBuffer();n.__webGLColorBuffer=d.createBuffer();u=n.vertices.length;n.__vertexArray=new Float32Array(u*3);n.__colorArray=new Float32Array(u*3);n.__webGLLineCount=u;n.__dirtyVertices=true;n.__dirtyColors=true}if(n.__dirtyVertices||n.__dirtyColors){u=d.DYNAMIC_DRAW;G=n.vertices;L=n.colors;R=G.length;ba=L.length;B=n.__vertexArray;ga=n.__colorArray;K=n.__dirtyColors;if(n.__dirtyVertices){for(D=0;D<R;D++){C=G[D].position;l=D*3;B[l]=C.x;B[l+1]=C.y;B[l+2]=C.z}d.bindBuffer(d.ARRAY_BUFFER,n.__webGLVertexBuffer);
-d.bufferData(d.ARRAY_BUFFER,B,u)}if(K){for(D=0;D<ba;D++){color=L[D];l=D*3;ga[l]=color.r;ga[l+1]=color.g;ga[l+2]=color.b}d.bindBuffer(d.ARRAY_BUFFER,n.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,ga,u)}}q(objlist,F,0,n,v,A);n.__dirtyVertices=false;n.__dirtyColors=false}else if(v instanceof THREE.ParticleSystem){if(!n.__webGLVertexBuffer){n.__webGLVertexBuffer=d.createBuffer();n.__webGLColorBuffer=d.createBuffer();u=n.vertices.length;n.__vertexArray=new Float32Array(u*3);n.__colorArray=new Float32Array(u*
-3);n.__sortArray=[];n.__webGLParticleCount=u;n.__dirtyVertices=true;n.__dirtyColors=true}if(n.__dirtyVertices||n.__dirtyColors||v.sortParticles)b(n,d.DYNAMIC_DRAW,v,camera);q(objlist,F,0,n,v,A);n.__dirtyVertices=false;n.__dirtyColors=false}else if(v instanceof THREE.MarchingCubes)if(F[0]==undefined){l.__webGLObjectsImmediate.push({object:v,opaque:{list:[],count:0},transparent:{list:[],count:0},root:A});F[0]=1}}function q(l,v,A,u,n,F){if(v[A]==undefined){l.push({buffer:u,object:n,opaque:{list:[],count:0},
-transparent:{list:[],count:0},root:F});v[A]=1}}function y(l,v){l._modelViewMatrix.multiplyToArray(v.matrix,l.matrixWorld,l._modelViewMatrixArray);l._normalMatrix=THREE.Matrix4.makeInvert3x3(l._modelViewMatrix).transposeIntoArray(l._normalMatrixArray)}function z(l){if(l!=U){switch(l){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE);break;case THREE.SubtractiveBlending:d.blendFunc(d.DST_COLOR,d.ZERO);break;case THREE.BillboardBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA,
-d.ONE_MINUS_SRC_ALPHA);break;default:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA)}U=l}}function H(l,v){if(l&&!l.__webGLFramebuffer){l.__webGLFramebuffer=d.createFramebuffer();l.__webGLRenderbuffer=d.createRenderbuffer();l.__webGLTexture=d.createTexture();d.bindRenderbuffer(d.RENDERBUFFER,l.__webGLRenderbuffer);d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,l.width,l.height);d.bindTexture(d.TEXTURE_2D,l.__webGLTexture);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,
-E(l.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,E(l.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,E(l.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,E(l.min_filter));d.texImage2D(d.TEXTURE_2D,0,E(l.format),l.width,l.height,0,E(l.format),E(l.type),null);d.bindFramebuffer(d.FRAMEBUFFER,l.__webGLFramebuffer);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,l.__webGLTexture,0);d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.RENDERBUFFER,
-l.__webGLRenderbuffer);d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,null)}var A,u,n;if(l){A=l.__webGLFramebuffer;u=l.width;n=l.height}else{A=null;u=o.width;n=o.height}if(A!=aa){d.bindFramebuffer(d.FRAMEBUFFER,A);d.viewport(0,0,u,n);v&&d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT);aa=A}}function w(l,v){var A;if(l=="fragment")A=d.createShader(d.FRAGMENT_SHADER);else if(l=="vertex")A=d.createShader(d.VERTEX_SHADER);d.shaderSource(A,v);d.compileShader(A);
-if(!d.getShaderParameter(A,d.COMPILE_STATUS)){alert(d.getShaderInfoLog(A));return null}return A}function E(l){switch(l){case THREE.RepeatWrapping:return d.REPEAT;case THREE.ClampToEdgeWrapping:return d.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return d.MIRRORED_REPEAT;case THREE.NearestFilter:return d.NEAREST;case THREE.NearestMipMapNearestFilter:return d.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return d.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return d.LINEAR;case THREE.LinearMipMapNearestFilter:return d.LINEAR_MIPMAP_NEAREST;
-case THREE.LinearMipMapLinearFilter:return d.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return d.BYTE;case THREE.UnsignedByteType:return d.UNSIGNED_BYTE;case THREE.ShortType:return d.SHORT;case THREE.UnsignedShortType:return d.UNSIGNED_SHORT;case THREE.IntType:return d.INT;case THREE.UnsignedShortType:return d.UNSIGNED_INT;case THREE.FloatType:return d.FLOAT;case THREE.AlphaFormat:return d.ALPHA;case THREE.RGBFormat:return d.RGB;case THREE.RGBAFormat:return d.RGBA;case THREE.LuminanceFormat:return d.LUMINANCE;
-case THREE.LuminanceAlphaFormat:return d.LUMINANCE_ALPHA}return 0}var o=document.createElement("canvas"),d,P=null,aa=null,N=null,M=null,U=null,O=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Y=new THREE.Matrix4,W=new Float32Array(16),J=new Float32Array(16),X=new THREE.Vector4,ha=true,Z=new THREE.Color(0),ea=0;if(a){if(a.antialias!==undefined)ha=a.antialias;a.clearColor!==undefined&&Z.setHex(a.clearColor);if(a.clearAlpha!==undefined)ea=
-a.clearAlpha}this.domElement=o;this.autoClear=true;(function(l,v,A){try{d=o.getContext("experimental-webgl",{antialias:l})}catch(u){console.log(u)}if(!d){alert("WebGL not supported");throw"cannot create webgl context";}d.clearColor(0,0,0,1);d.clearDepth(1);d.enable(d.DEPTH_TEST);d.depthFunc(d.LEQUAL);d.frontFace(d.CCW);d.cullFace(d.BACK);d.enable(d.CULL_FACE);d.enable(d.BLEND);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA);d.clearColor(v.r,v.g,v.b,A);_cullEnabled=true})(ha,Z,ea);this.context=d;this.lights=
-{ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,v){o.width=l;o.height=v;d.viewport(0,0,o.width,o.height)};this.setClearColorHex=function(l,v){var A=new THREE.Color(l);d.clearColor(A.r,A.g,A.b,v)};this.setClearColor=function(l,v){d.clearColor(l.r,l.g,l.b,v)};this.clear=function(){d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT)};this.setupLights=function(l,v){var A,u,n,F=0,L=0,G=0,D,C,R,ba=this.lights,ga=ba.directional.colors,
-B=ba.directional.positions,K=ba.point.colors,I=ba.point.positions,Q=0,da=0;A=n=n=0;for(u=v.length;A<u;A++){n=v[A];D=n.color;C=n.position;R=n.intensity;if(n instanceof THREE.AmbientLight){F+=D.r;L+=D.g;G+=D.b}else if(n instanceof THREE.DirectionalLight){n=Q*3;ga[n]=D.r*R;ga[n+1]=D.g*R;ga[n+2]=D.b*R;B[n]=C.x;B[n+1]=C.y;B[n+2]=C.z;Q+=1}else if(n instanceof THREE.PointLight){n=da*3;K[n]=D.r*R;K[n+1]=D.g*R;K[n+2]=D.b*R;I[n]=C.x;I[n+1]=C.y;I[n+2]=C.z;da+=1}}for(A=Q*3;A<ga.length;A++)ga[A]=0;for(A=da*3;A<
-K.length;A++)K[A]=0;ba.point.length=da;ba.directional.length=Q;ba.ambient[0]=F;ba.ambient[1]=L;ba.ambient[2]=G};this.initMaterial=function(l,v,A){var u,n;if(l instanceof THREE.MeshDepthMaterial)c(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)c(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)c(l,THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)c(l,THREE.ShaderLib.phong);
-else if(l instanceof THREE.LineBasicMaterial)c(l,THREE.ShaderLib.basic);else l instanceof THREE.ParticleBasicMaterial&&c(l,THREE.ShaderLib.particle_basic);var F,L,G,D;n=G=D=0;for(F=v.length;n<F;n++){L=v[n];L instanceof THREE.DirectionalLight&&G++;L instanceof THREE.PointLight&&D++}if(D+G<=4){v=G;D=D}else{v=Math.ceil(4*G/(D+G));D=4-v}n={directional:v,point:D};D=l.fragment_shader;v=l.vertex_shader;F={fog:A,map:l.map,env_map:l.env_map,light_map:l.light_map,vertex_colors:l.vertex_colors,maxDirLights:n.directional,
-maxPointLights:n.point};A=d.createProgram();n=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+F.maxDirLights,"#define MAX_POINT_LIGHTS "+F.maxPointLights,F.fog?"#define USE_FOG":"",F.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",F.map?"#define USE_MAP":"",F.env_map?"#define USE_ENVMAP":"",F.light_map?"#define USE_LIGHTMAP":"",F.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");F=[d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
-0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+F.maxDirLights,"#define MAX_POINT_LIGHTS "+F.maxPointLights,F.map?"#define USE_MAP":"",F.env_map?"#define USE_ENVMAP":"",F.light_map?"#define USE_LIGHTMAP":"",F.vertex_colors?"#define USE_COLOR":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");
-d.attachShader(A,w("fragment",n+D));d.attachShader(A,w("vertex",F+v));d.linkProgram(A);d.getProgramParameter(A,d.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+d.getProgramParameter(A,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");A.uniforms={};A.attributes={};l.program=A;A=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(u in l.uniforms)A.push(u);u=l.program;D=0;for(v=A.length;D<v;D++){n=A[D];u.uniforms[n]=d.getUniformLocation(u,
-n)}l=l.program;u=["position","normal","uv","uv2","tangent","color"];A=0;for(D=u.length;A<D;A++){v=u[A];l.attributes[v]=d.getAttribLocation(l,v)}};this.setProgram=function(l,v,A,u,n){u.program||this.initMaterial(u,v,A);var F=u.program,L=F.uniforms,G=u.uniforms;if(F!=P){d.useProgram(F);P=F;d.uniformMatrix4fv(L.projectionMatrix,false,W)}if(A&&(u instanceof THREE.MeshBasicMaterial||u instanceof THREE.MeshLambertMaterial||u instanceof THREE.MeshPhongMaterial||u instanceof THREE.LineBasicMaterial||u instanceof
-THREE.ParticleBasicMaterial)){G.fogColor.value.setHex(A.color.hex);if(A instanceof THREE.Fog){G.fogNear.value=A.near;G.fogFar.value=A.far}else if(A instanceof THREE.FogExp2)G.fogDensity.value=A.density}if(u instanceof THREE.MeshPhongMaterial||u instanceof THREE.MeshLambertMaterial){this.setupLights(F,v);v=this.lights;G.enableLighting.value=v.directional.length+v.point.length;G.ambientLightColor.value=v.ambient;G.directionalLightColor.value=v.directional.colors;G.directionalLightDirection.value=v.directional.positions;
-G.pointLightColor.value=v.point.colors;G.pointLightPosition.value=v.point.positions}if(u instanceof THREE.MeshBasicMaterial||u instanceof THREE.MeshLambertMaterial||u instanceof THREE.MeshPhongMaterial){G.diffuse.value.setRGB(u.color.r*u.opacity,u.color.g*u.opacity,u.color.b*u.opacity);G.opacity.value=u.opacity;G.map.texture=u.map;G.light_map.texture=u.light_map;G.env_map.texture=u.env_map;G.reflectivity.value=u.reflectivity;G.refraction_ratio.value=u.refraction_ratio;G.combine.value=u.combine;G.useRefract.value=
-u.env_map&&u.env_map.mapping instanceof THREE.CubeRefractionMapping}if(u instanceof THREE.LineBasicMaterial){G.diffuse.value.setRGB(u.color.r*u.opacity,u.color.g*u.opacity,u.color.b*u.opacity);G.opacity.value=u.opacity}else if(u instanceof THREE.ParticleBasicMaterial){G.psColor.value.setRGB(u.color.r*u.opacity,u.color.g*u.opacity,u.color.b*u.opacity);G.opacity.value=u.opacity;G.size.value=u.size;G.map.texture=u.map}else if(u instanceof THREE.MeshPhongMaterial){G.ambient.value.setRGB(u.ambient.r,u.ambient.g,
-u.ambient.b);G.specular.value.setRGB(u.specular.r,u.specular.g,u.specular.b);G.shininess.value=u.shininess}else if(u instanceof THREE.MeshDepthMaterial){G.mNear.value=l.near;G.mFar.value=l.far;G.opacity.value=u.opacity}else if(u instanceof THREE.MeshNormalMaterial)G.opacity.value=u.opacity;var D,C,R;for(D in G)if(R=F.uniforms[D]){A=G[D];C=A.type;v=A.value;if(C=="i")d.uniform1i(R,v);else if(C=="f")d.uniform1f(R,v);else if(C=="fv1")d.uniform1fv(R,v);else if(C=="fv")d.uniform3fv(R,v);else if(C=="v2")d.uniform2f(R,
-v.x,v.y);else if(C=="v3")d.uniform3f(R,v.x,v.y,v.z);else if(C=="c")d.uniform3f(R,v.r,v.g,v.b);else if(C=="t"){d.uniform1i(R,v);if(A=A.texture)if(A.image instanceof Array&&A.image.length==6){A=A;v=v;if(A.image.length==6){if(!A.image.__webGLTextureCube&&!A.image.__cubeMapInitialized&&A.image.loadCount==6){A.image.__webGLTextureCube=d.createTexture();d.bindTexture(d.TEXTURE_CUBE_MAP,A.image.__webGLTextureCube);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_CUBE_MAP,
-d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MAG_FILTER,d.LINEAR);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MIN_FILTER,d.LINEAR_MIPMAP_LINEAR);for(C=0;C<6;++C)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+C,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,A.image[C]);d.generateMipmap(d.TEXTURE_CUBE_MAP);d.bindTexture(d.TEXTURE_CUBE_MAP,null);A.image.__cubeMapInitialized=true}d.activeTexture(d.TEXTURE0+v);d.bindTexture(d.TEXTURE_CUBE_MAP,A.image.__webGLTextureCube)}}else{A=A;v=v;if(!A.__webGLTexture&&
-A.image.loaded){A.__webGLTexture=d.createTexture();d.bindTexture(d.TEXTURE_2D,A.__webGLTexture);d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,A.image);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,E(A.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,E(A.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,E(A.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,E(A.min_filter));d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}d.activeTexture(d.TEXTURE0+
-v);d.bindTexture(d.TEXTURE_2D,A.__webGLTexture)}}}d.uniformMatrix4fv(L.modelViewMatrix,false,n._modelViewMatrixArray);d.uniformMatrix3fv(L.normalMatrix,false,n._normalMatrixArray);if(u instanceof THREE.MeshShaderMaterial||u instanceof THREE.MeshPhongMaterial||u.env_map)d.uniform3f(L.cameraPosition,l.position.x,l.position.y,l.position.z);if(u instanceof THREE.MeshShaderMaterial||u.env_map)d.uniformMatrix4fv(L.objectMatrix,false,n._objectMatrixArray);if(u instanceof THREE.MeshPhongMaterial||u instanceof
-THREE.MeshLambertMaterial||u instanceof THREE.MeshShaderMaterial)d.uniformMatrix4fv(L.viewMatrix,false,J);return F};this.renderBuffer=function(l,v,A,u,n,F){l=this.setProgram(l,v,A,u,F).attributes;d.bindBuffer(d.ARRAY_BUFFER,n.__webGLVertexBuffer);d.vertexAttribPointer(l.position,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.position);if(l.color>=0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLColorBuffer);d.vertexAttribPointer(l.color,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.color)}if(l.normal>=
+THREE.Projector=function(){function a(O,K){return K.z-O.z}function b(O,K){var X=0,Q=1,U=O.z+O.w,V=K.z+K.w,H=-O.z+O.w,Y=-K.z+K.w;if(U>=0&&V>=0&&H>=0&&Y>=0)return true;else if(U<0&&V<0||H<0&&Y<0)return false;else{if(U<0)X=Math.max(X,U/(U-V));else if(V<0)Q=Math.min(Q,U/(U-V));if(H<0)X=Math.max(X,H/(H-Y));else if(Y<0)Q=Math.min(Q,H/(H-Y));if(Q<X)return false;else{O.lerpSelf(K,X);K.lerpSelf(O,1-Q);return true}}}var c,e,g=[],f,h,k,j=[],m,q,w=[],u,t,x=[],A=new THREE.Vector4,E=new THREE.Vector4,v=new THREE.Matrix4,
+F=new THREE.Matrix4,p=[],M=new THREE.Vector4,d=new THREE.Vector4,aa;this.projectObjects=function(O,K,X){var Q=[],U,V;e=0;v.multiply(K.projectionMatrix,K.matrix);p[0]=new THREE.Vector4(v.n41-v.n11,v.n42-v.n12,v.n43-v.n13,v.n44-v.n14);p[1]=new THREE.Vector4(v.n41+v.n11,v.n42+v.n12,v.n43+v.n13,v.n44+v.n14);p[2]=new THREE.Vector4(v.n41+v.n21,v.n42+v.n22,v.n43+v.n23,v.n44+v.n24);p[3]=new THREE.Vector4(v.n41-v.n21,v.n42-v.n22,v.n43-v.n23,v.n44-v.n24);p[4]=new THREE.Vector4(v.n41-v.n31,v.n42-v.n32,v.n43-
+v.n33,v.n44-v.n34);p[5]=new THREE.Vector4(v.n41+v.n31,v.n42+v.n32,v.n43+v.n33,v.n44+v.n34);K=0;for(U=p.length;K<U;K++){V=p[K];V.divideScalar(Math.sqrt(V.x*V.x+V.y*V.y+V.z*V.z))}U=O.objects;O=0;for(K=U.length;O<K;O++){V=U[O];var H;if(!(H=!V.visible)){if(H=V instanceof THREE.Mesh){a:{H=void 0;for(var Y=V.position,ea=-V.geometry.boundingSphere.radius*Math.max(V.scale.x,Math.max(V.scale.y,V.scale.z)),Z=0;Z<6;Z++){H=p[Z].x*Y.x+p[Z].y*Y.y+p[Z].z*Y.z+p[Z].w;if(H<=ea){H=false;break a}}H=true}H=!H}H=H}if(!H){c=
+g[e]=g[e]||new THREE.RenderableObject;A.copy(V.position);v.multiplyVector3(A);c.object=V;c.z=A.z;Q.push(c);e++}}X&&Q.sort(a);return Q};this.projectScene=function(O,K,X){var Q=[],U=K.near,V=K.far,H,Y,ea,Z,fa,ia,l,y,B,o,n,N,G,z,I,D;k=q=t=0;K.autoUpdateMatrix&&K.updateMatrix();v.multiply(K.projectionMatrix,K.matrix);ia=this.projectObjects(O,K,true);O=0;for(H=ia.length;O<H;O++){l=ia[O].object;if(l.visible){l.autoUpdateMatrix&&l.updateMatrix();y=l.matrix;B=l.rotationMatrix;o=l.materials;n=l.overdraw;if(l instanceof
+THREE.Mesh){N=l.geometry;G=N.vertices;Y=0;for(ea=G.length;Y<ea;Y++){z=G[Y];z.positionWorld.copy(z.position);y.multiplyVector3(z.positionWorld);Z=z.positionScreen;Z.copy(z.positionWorld);v.multiplyVector4(Z);Z.x/=Z.w;Z.y/=Z.w;z.__visible=Z.z>U&&Z.z<V}N=N.faces;Y=0;for(ea=N.length;Y<ea;Y++){z=N[Y];if(z instanceof THREE.Face3){Z=G[z.a];fa=G[z.b];I=G[z.c];if(Z.__visible&&fa.__visible&&I.__visible)if(l.doubleSided||l.flipSided!=(I.positionScreen.x-Z.positionScreen.x)*(fa.positionScreen.y-Z.positionScreen.y)-
+(I.positionScreen.y-Z.positionScreen.y)*(fa.positionScreen.x-Z.positionScreen.x)<0){f=j[k]=j[k]||new THREE.RenderableFace3;f.v1.positionWorld.copy(Z.positionWorld);f.v2.positionWorld.copy(fa.positionWorld);f.v3.positionWorld.copy(I.positionWorld);f.v1.positionScreen.copy(Z.positionScreen);f.v2.positionScreen.copy(fa.positionScreen);f.v3.positionScreen.copy(I.positionScreen);f.normalWorld.copy(z.normal);B.multiplyVector3(f.normalWorld);f.centroidWorld.copy(z.centroid);y.multiplyVector3(f.centroidWorld);
+f.centroidScreen.copy(f.centroidWorld);v.multiplyVector3(f.centroidScreen);I=z.vertexNormals;aa=f.vertexNormalsWorld;Z=0;for(fa=I.length;Z<fa;Z++){D=aa[Z]=aa[Z]||new THREE.Vector3;D.copy(I[Z]);B.multiplyVector3(D)}f.z=f.centroidScreen.z;f.meshMaterials=o;f.faceMaterials=z.materials;f.overdraw=n;if(l.geometry.uvs[Y]){f.uvs[0]=l.geometry.uvs[Y][0];f.uvs[1]=l.geometry.uvs[Y][1];f.uvs[2]=l.geometry.uvs[Y][2]}Q.push(f);k++}}else if(z instanceof THREE.Face4){Z=G[z.a];fa=G[z.b];I=G[z.c];D=G[z.d];if(Z.__visible&&
+fa.__visible&&I.__visible&&D.__visible)if(l.doubleSided||l.flipSided!=((D.positionScreen.x-Z.positionScreen.x)*(fa.positionScreen.y-Z.positionScreen.y)-(D.positionScreen.y-Z.positionScreen.y)*(fa.positionScreen.x-Z.positionScreen.x)<0||(fa.positionScreen.x-I.positionScreen.x)*(D.positionScreen.y-I.positionScreen.y)-(fa.positionScreen.y-I.positionScreen.y)*(D.positionScreen.x-I.positionScreen.x)<0)){f=j[k]=j[k]||new THREE.RenderableFace3;f.v1.positionWorld.copy(Z.positionWorld);f.v2.positionWorld.copy(fa.positionWorld);
+f.v3.positionWorld.copy(D.positionWorld);f.v1.positionScreen.copy(Z.positionScreen);f.v2.positionScreen.copy(fa.positionScreen);f.v3.positionScreen.copy(D.positionScreen);f.normalWorld.copy(z.normal);B.multiplyVector3(f.normalWorld);f.centroidWorld.copy(z.centroid);y.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);v.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=o;f.faceMaterials=z.materials;f.overdraw=n;if(l.geometry.uvs[Y]){f.uvs[0]=l.geometry.uvs[Y][0];
+f.uvs[1]=l.geometry.uvs[Y][1];f.uvs[2]=l.geometry.uvs[Y][3]}Q.push(f);k++;h=j[k]=j[k]||new THREE.RenderableFace3;h.v1.positionWorld.copy(fa.positionWorld);h.v2.positionWorld.copy(I.positionWorld);h.v3.positionWorld.copy(D.positionWorld);h.v1.positionScreen.copy(fa.positionScreen);h.v2.positionScreen.copy(I.positionScreen);h.v3.positionScreen.copy(D.positionScreen);h.normalWorld.copy(f.normalWorld);h.centroidWorld.copy(f.centroidWorld);h.centroidScreen.copy(f.centroidScreen);h.z=h.centroidScreen.z;
+h.meshMaterials=o;h.faceMaterials=z.materials;h.overdraw=n;if(l.geometry.uvs[Y]){h.uvs[0]=l.geometry.uvs[Y][1];h.uvs[1]=l.geometry.uvs[Y][2];h.uvs[2]=l.geometry.uvs[Y][3]}Q.push(h);k++}}}}else if(l instanceof THREE.Line){F.multiply(v,y);G=l.geometry.vertices;z=G[0];z.positionScreen.copy(z.position);F.multiplyVector4(z.positionScreen);Y=1;for(ea=G.length;Y<ea;Y++){Z=G[Y];Z.positionScreen.copy(Z.position);F.multiplyVector4(Z.positionScreen);fa=G[Y-1];M.copy(Z.positionScreen);d.copy(fa.positionScreen);
+if(b(M,d)){M.multiplyScalar(1/M.w);d.multiplyScalar(1/d.w);m=w[q]=w[q]||new THREE.RenderableLine;m.v1.positionScreen.copy(M);m.v2.positionScreen.copy(d);m.z=Math.max(M.z,d.z);m.materials=l.materials;Q.push(m);q++}}}else if(l instanceof THREE.Particle){E.set(l.position.x,l.position.y,l.position.z,1);v.multiplyVector4(E);E.z/=E.w;if(E.z>0&&E.z<1){u=x[t]=x[t]||new THREE.RenderableParticle;u.x=E.x/E.w;u.y=E.y/E.w;u.z=E.z;u.rotation=l.rotation.z;u.scale.x=l.scale.x*Math.abs(u.x-(E.x+K.projectionMatrix.n11)/
+(E.w+K.projectionMatrix.n14));u.scale.y=l.scale.y*Math.abs(u.y-(E.y+K.projectionMatrix.n22)/(E.w+K.projectionMatrix.n24));u.materials=l.materials;Q.push(u);t++}}}}X&&Q.sort(a);return Q};this.unprojectVector=function(O,K){var X=THREE.Matrix4.makeInvert(K.matrix);X.multiplySelf(THREE.Matrix4.makeInvert(K.projectionMatrix));X.multiplyVector3(O);return O}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,g,f;this.domElement=document.createElement("div");this.setSize=function(h,k){c=h;e=k;g=c/2;f=e/2};this.render=function(h,k){var j,m,q,w,u,t,x,A;a=b.projectScene(h,k);j=0;for(m=a.length;j<m;j++){u=a[j];if(u instanceof THREE.RenderableParticle){x=u.x*g+g;A=u.y*f+f;q=0;for(w=u.material.length;q<w;q++){t=u.material[q];if(t instanceof THREE.ParticleDOMMaterial){t=t.domElement;t.style.left=x+"px";t.style.top=A+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(ga){if(u!=ga)m.globalAlpha=u=ga}function b(ga){if(t!=ga){switch(ga){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}t=ga}}var c=null,e=new THREE.Projector,g=document.createElement("canvas"),f,h,k,j,m=g.getContext("2d"),q=new THREE.Color(0),w=0,u=1,t=0,x=null,A=null,E=1,v,F,p,M,d,aa,O,K,X,Q=new THREE.Color,
+U=new THREE.Color,V=new THREE.Color,H=new THREE.Color,Y=new THREE.Color,ea,Z,fa,ia,l,y,B,o,n,N=new THREE.Rectangle,G=new THREE.Rectangle,z=new THREE.Rectangle,I=false,D=new THREE.Color,$=new THREE.Color,da=new THREE.Color,C=new THREE.Color,L=Math.PI*2,J=new THREE.Vector3,R,W,la,S,ta,sa,va=16;R=document.createElement("canvas");R.width=R.height=2;W=R.getContext("2d");W.fillStyle="rgba(0,0,0,1)";W.fillRect(0,0,2,2);la=W.getImageData(0,0,2,2);S=la.data;ta=document.createElement("canvas");ta.width=ta.height=
+va;sa=ta.getContext("2d");sa.translate(-va/2,-va/2);sa.scale(va,va);va--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ga,ka){f=ga;h=ka;k=f/2;j=h/2;g.width=f;g.height=h;N.set(-k,-j,k,j);u=1;t=0;A=x=null;E=1};this.setClearColor=function(ga,ka){q=ga;w=ka;G.set(-k,-j,k,j);m.setTransform(1,0,0,-1,k,j);this.clear()};this.setClearColorHex=function(ga,ka){q.setHex(ga);w=ka;G.set(-k,-j,k,j);m.setTransform(1,0,0,-1,k,j);this.clear()};this.clear=function(){m.setTransform(1,
+0,0,-1,k,j);if(!G.isEmpty()){G.inflate(1);G.minSelf(N);if(q.hex==0&&w==0)m.clearRect(G.getX(),G.getY(),G.getWidth(),G.getHeight());else{b(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(q.r*255)+","+Math.floor(q.g*255)+","+Math.floor(q.b*255)+","+w+")";m.fillRect(G.getX(),G.getY(),G.getWidth(),G.getHeight())}G.empty()}};this.render=function(ga,ka){function na(P){var ha,ca,T,ba=P.lights;$.setRGB(0,0,0);da.setRGB(0,0,0);C.setRGB(0,0,0);P=0;for(ha=ba.length;P<ha;P++){ca=ba[P];T=ca.color;if(ca instanceof
+THREE.AmbientLight){$.r+=T.r;$.g+=T.g;$.b+=T.b}else if(ca instanceof THREE.DirectionalLight){da.r+=T.r;da.g+=T.g;da.b+=T.b}else if(ca instanceof THREE.PointLight){C.r+=T.r;C.g+=T.g;C.b+=T.b}}}function Ca(P,ha,ca,T){var ba,ja,ua,za,Ba=P.lights;P=0;for(ba=Ba.length;P<ba;P++){ja=Ba[P];ua=ja.color;za=ja.intensity;if(ja instanceof THREE.DirectionalLight){ja=ca.dot(ja.position)*za;if(ja>0){T.r+=ua.r*ja;T.g+=ua.g*ja;T.b+=ua.b*ja}}else if(ja instanceof THREE.PointLight){J.sub(ja.position,ha);J.normalize();
+ja=ca.dot(J)*za;if(ja>0){T.r+=ua.r*ja;T.g+=ua.g*ja;T.b+=ua.b*ja}}}}function ya(P,ha,ca){if(ca.opacity!=0){a(ca.opacity);b(ca.blending);var T,ba,ja,ua,za,Ba;if(ca instanceof THREE.ParticleBasicMaterial){if(ca.map&&ca.map.image.loaded){ua=ca.map.image;za=ua.width>>1;Ba=ua.height>>1;ba=ha.scale.x*k;ja=ha.scale.y*j;ca=ba*za;T=ja*Ba;z.set(P.x-ca,P.y-T,P.x+ca,P.y+T);if(N.instersects(z)){m.save();m.translate(P.x,P.y);m.rotate(-ha.rotation);m.scale(ba,-ja);m.translate(-za,-Ba);m.drawImage(ua,0,0);m.restore()}}}else if(ca instanceof
+THREE.ParticleCircleMaterial){if(I){D.r=$.r+da.r+C.r;D.g=$.g+da.g+C.g;D.b=$.b+da.b+C.b;Q.r=ca.color.r*D.r;Q.g=ca.color.g*D.g;Q.b=ca.color.b*D.b;Q.updateStyleString()}else Q.__styleString=ca.color.__styleString;ca=ha.scale.x*k;T=ha.scale.y*j;z.set(P.x-ca,P.y-T,P.x+ca,P.y+T);if(N.instersects(z)){ba=Q.__styleString;if(A!=ba)m.fillStyle=A=ba;m.save();m.translate(P.x,P.y);m.rotate(-ha.rotation);m.scale(ca,T);m.beginPath();m.arc(0,0,1,0,L,true);m.closePath();m.fill();m.restore()}}}}function qa(P,ha,ca,
+T){if(T.opacity!=0){a(T.opacity);b(T.blending);m.beginPath();m.moveTo(P.positionScreen.x,P.positionScreen.y);m.lineTo(ha.positionScreen.x,ha.positionScreen.y);m.closePath();if(T instanceof THREE.LineBasicMaterial){Q.__styleString=T.color.__styleString;P=T.linewidth;if(E!=P)m.lineWidth=E=P;P=Q.__styleString;if(x!=P)m.strokeStyle=x=P;m.stroke();z.inflate(T.linewidth*2)}}}function ra(P,ha,ca,T,ba,ja){if(ba.opacity!=0){a(ba.opacity);b(ba.blending);M=P.positionScreen.x;d=P.positionScreen.y;aa=ha.positionScreen.x;
+O=ha.positionScreen.y;K=ca.positionScreen.x;X=ca.positionScreen.y;m.beginPath();m.moveTo(M,d);m.lineTo(aa,O);m.lineTo(K,X);m.lineTo(M,d);m.closePath();if(ba instanceof THREE.MeshBasicMaterial)if(ba.map)ba.map.image.loaded&&ba.map.mapping instanceof THREE.UVMapping&&wa(M,d,aa,O,K,X,ba.map.image,T.uvs[0].u,T.uvs[0].v,T.uvs[1].u,T.uvs[1].v,T.uvs[2].u,T.uvs[2].v);else if(ba.env_map){if(ba.env_map.image.loaded)if(ba.env_map.mapping instanceof THREE.SphericalReflectionMapping){P=ka.matrix;J.copy(T.vertexNormalsWorld[0]);
+ia=(J.x*P.n11+J.y*P.n12+J.z*P.n13)*0.5+0.5;l=-(J.x*P.n21+J.y*P.n22+J.z*P.n23)*0.5+0.5;J.copy(T.vertexNormalsWorld[1]);y=(J.x*P.n11+J.y*P.n12+J.z*P.n13)*0.5+0.5;B=-(J.x*P.n21+J.y*P.n22+J.z*P.n23)*0.5+0.5;J.copy(T.vertexNormalsWorld[2]);o=(J.x*P.n11+J.y*P.n12+J.z*P.n13)*0.5+0.5;n=-(J.x*P.n21+J.y*P.n22+J.z*P.n23)*0.5+0.5;wa(M,d,aa,O,K,X,ba.env_map.image,ia,l,y,B,o,n)}}else ba.wireframe?Ha(ba.color.__styleString,ba.wireframe_linewidth):Ia(ba.color.__styleString);else if(ba instanceof THREE.MeshLambertMaterial){if(ba.map&&
+!ba.wireframe){ba.map.mapping instanceof THREE.UVMapping&&wa(M,d,aa,O,K,X,ba.map.image,T.uvs[0].u,T.uvs[0].v,T.uvs[1].u,T.uvs[1].v,T.uvs[2].u,T.uvs[2].v);b(THREE.SubtractiveBlending)}if(I)if(!ba.wireframe&&ba.shading==THREE.SmoothShading&&T.vertexNormalsWorld.length==3){U.r=V.r=H.r=$.r;U.g=V.g=H.g=$.g;U.b=V.b=H.b=$.b;Ca(ja,T.v1.positionWorld,T.vertexNormalsWorld[0],U);Ca(ja,T.v2.positionWorld,T.vertexNormalsWorld[1],V);Ca(ja,T.v3.positionWorld,T.vertexNormalsWorld[2],H);Y.r=(V.r+H.r)*0.5;Y.g=(V.g+
+H.g)*0.5;Y.b=(V.b+H.b)*0.5;fa=ma(U,V,H,Y);wa(M,d,aa,O,K,X,fa,0,0,1,0,0,1)}else{D.r=$.r;D.g=$.g;D.b=$.b;Ca(ja,T.centroidWorld,T.normalWorld,D);Q.r=ba.color.r*D.r;Q.g=ba.color.g*D.g;Q.b=ba.color.b*D.b;Q.updateStyleString();ba.wireframe?Ha(Q.__styleString,ba.wireframe_linewidth):Ia(Q.__styleString)}else ba.wireframe?Ha(ba.color.__styleString,ba.wireframe_linewidth):Ia(ba.color.__styleString)}else if(ba instanceof THREE.MeshDepthMaterial){ea=ka.near;Z=ka.far;U.r=U.g=U.b=1-pa(P.positionScreen.z,ea,Z);
+V.r=V.g=V.b=1-pa(ha.positionScreen.z,ea,Z);H.r=H.g=H.b=1-pa(ca.positionScreen.z,ea,Z);Y.r=(V.r+H.r)*0.5;Y.g=(V.g+H.g)*0.5;Y.b=(V.b+H.b)*0.5;fa=ma(U,V,H,Y);wa(M,d,aa,O,K,X,fa,0,0,1,0,0,1)}else if(ba instanceof THREE.MeshNormalMaterial){Q.r=Da(T.normalWorld.x);Q.g=Da(T.normalWorld.y);Q.b=Da(T.normalWorld.z);Q.updateStyleString();ba.wireframe?Ha(Q.__styleString,ba.wireframe_linewidth):Ia(Q.__styleString)}}}function Ha(P,ha){if(x!=P)m.strokeStyle=x=P;if(E!=ha)m.lineWidth=E=ha;m.stroke();z.inflate(ha*
+2)}function Ia(P){if(A!=P)m.fillStyle=A=P;m.fill()}function wa(P,ha,ca,T,ba,ja,ua,za,Ba,Ka,Ga,La,Ra){var Ja,Ma;Ja=ua.width-1;Ma=ua.height-1;za*=Ja;Ba*=Ma;Ka*=Ja;Ga*=Ma;La*=Ja;Ra*=Ma;ca-=P;T-=ha;ba-=P;ja-=ha;Ka-=za;Ga-=Ba;La-=za;Ra-=Ba;Ja=Ka*Ra-La*Ga;if(Ja!=0){Ma=1/Ja;Ja=(Ra*ca-Ga*ba)*Ma;Ga=(Ra*T-Ga*ja)*Ma;ca=(Ka*ba-La*ca)*Ma;T=(Ka*ja-La*T)*Ma;P=P-Ja*za-ca*Ba;ha=ha-Ga*za-T*Ba;m.save();m.transform(Ja,Ga,ca,T,P,ha);m.clip();m.drawImage(ua,0,0);m.restore()}}function ma(P,ha,ca,T){var ba=~~(P.r*255),ja=
+~~(P.g*255);P=~~(P.b*255);var ua=~~(ha.r*255),za=~~(ha.g*255);ha=~~(ha.b*255);var Ba=~~(ca.r*255),Ka=~~(ca.g*255);ca=~~(ca.b*255);var Ga=~~(T.r*255),La=~~(T.g*255);T=~~(T.b*255);S[0]=ba<0?0:ba>255?255:ba;S[1]=ja<0?0:ja>255?255:ja;S[2]=P<0?0:P>255?255:P;S[4]=ua<0?0:ua>255?255:ua;S[5]=za<0?0:za>255?255:za;S[6]=ha<0?0:ha>255?255:ha;S[8]=Ba<0?0:Ba>255?255:Ba;S[9]=Ka<0?0:Ka>255?255:Ka;S[10]=ca<0?0:ca>255?255:ca;S[12]=Ga<0?0:Ga>255?255:Ga;S[13]=La<0?0:La>255?255:La;S[14]=T<0?0:T>255?255:T;W.putImageData(la,
+0,0);sa.drawImage(R,0,0);return ta}function pa(P,ha,ca){P=(P-ha)/(ca-ha);return P*P*(3-2*P)}function Da(P){P=(P+1)*0.5;return P<0?0:P>1?1:P}function xa(P,ha){var ca=ha.x-P.x,T=ha.y-P.y,ba=1/Math.sqrt(ca*ca+T*T);ca*=ba;T*=ba;ha.x+=ca;ha.y+=T;P.x-=ca;P.y-=T}var Oa,Aa,oa,Ea,Fa,Pa,Qa,Na;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,j);c=e.projectScene(ga,ka,this.sortElements);(I=ga.lights.length>0)&&na(ga);Oa=0;for(Aa=c.length;Oa<Aa;Oa++){oa=c[Oa];z.empty();if(oa instanceof THREE.RenderableParticle){v=
+oa;v.x*=k;v.y*=j;Ea=0;for(Fa=oa.materials.length;Ea<Fa;Ea++)ya(v,oa,oa.materials[Ea],ga)}else if(oa instanceof THREE.RenderableLine){v=oa.v1;F=oa.v2;v.positionScreen.x*=k;v.positionScreen.y*=j;F.positionScreen.x*=k;F.positionScreen.y*=j;z.addPoint(v.positionScreen.x,v.positionScreen.y);z.addPoint(F.positionScreen.x,F.positionScreen.y);if(N.instersects(z)){Ea=0;for(Fa=oa.materials.length;Ea<Fa;)qa(v,F,oa,oa.materials[Ea++],ga)}}else if(oa instanceof THREE.RenderableFace3){v=oa.v1;F=oa.v2;p=oa.v3;v.positionScreen.x*=
+k;v.positionScreen.y*=j;F.positionScreen.x*=k;F.positionScreen.y*=j;p.positionScreen.x*=k;p.positionScreen.y*=j;if(oa.overdraw){xa(v.positionScreen,F.positionScreen);xa(F.positionScreen,p.positionScreen);xa(p.positionScreen,v.positionScreen)}z.add3Points(v.positionScreen.x,v.positionScreen.y,F.positionScreen.x,F.positionScreen.y,p.positionScreen.x,p.positionScreen.y);if(N.instersects(z)){Ea=0;for(Fa=oa.meshMaterials.length;Ea<Fa;){Na=oa.meshMaterials[Ea++];if(Na instanceof THREE.MeshFaceMaterial){Pa=
+0;for(Qa=oa.faceMaterials.length;Pa<Qa;)(Na=oa.faceMaterials[Pa++])&&ra(v,F,p,oa,Na,ga)}else ra(v,F,p,oa,Na,ga)}}}G.addRectangle(z)}m.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(ia,l,y){var B,o,n,N;B=0;for(o=ia.lights.length;B<o;B++){n=ia.lights[B];if(n instanceof THREE.DirectionalLight){N=l.normalWorld.dot(n.position)*n.intensity;if(N>0){y.r+=n.color.r*N;y.g+=n.color.g*N;y.b+=n.color.b*N}}else if(n instanceof THREE.PointLight){X.sub(n.position,l.centroidWorld);X.normalize();N=l.normalWorld.dot(X)*n.intensity;if(N>0){y.r+=n.color.r*N;y.g+=n.color.g*N;y.b+=n.color.b*N}}}}function b(ia,l,y,B,o,n){H=e(Y++);H.setAttribute("d","M "+ia.positionScreen.x+
+" "+ia.positionScreen.y+" L "+l.positionScreen.x+" "+l.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+"z");if(o instanceof THREE.MeshBasicMaterial)p.__styleString=o.color.__styleString;else if(o instanceof THREE.MeshLambertMaterial)if(F){M.r=d.r;M.g=d.g;M.b=d.b;a(n,B,M);p.r=o.color.r*M.r;p.g=o.color.g*M.g;p.b=o.color.b*M.b;p.updateStyleString()}else p.__styleString=o.color.__styleString;else if(o instanceof THREE.MeshDepthMaterial){K=1-o.__2near/(o.__farPlusNear-B.z*o.__farMinusNear);
+p.setRGB(K,K,K)}else o instanceof THREE.MeshNormalMaterial&&p.setRGB(g(B.normalWorld.x),g(B.normalWorld.y),g(B.normalWorld.z));o.wireframe?H.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+o.wireframe_linewidth+"; stroke-opacity: "+o.opacity+"; stroke-linecap: "+o.wireframe_linecap+"; stroke-linejoin: "+o.wireframe_linejoin):H.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+o.opacity);k.appendChild(H)}function c(ia,l,y,B,o,n,N){H=e(Y++);H.setAttribute("d",
+"M "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+l.positionScreen.x+" "+l.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+" L "+B.positionScreen.x+","+B.positionScreen.y+"z");if(n instanceof THREE.MeshBasicMaterial)p.__styleString=n.color.__styleString;else if(n instanceof THREE.MeshLambertMaterial)if(F){M.r=d.r;M.g=d.g;M.b=d.b;a(N,o,M);p.r=n.color.r*M.r;p.g=n.color.g*M.g;p.b=n.color.b*M.b;p.updateStyleString()}else p.__styleString=n.color.__styleString;else if(n instanceof
+THREE.MeshDepthMaterial){K=1-n.__2near/(n.__farPlusNear-o.z*n.__farMinusNear);p.setRGB(K,K,K)}else n instanceof THREE.MeshNormalMaterial&&p.setRGB(g(o.normalWorld.x),g(o.normalWorld.y),g(o.normalWorld.z));n.wireframe?H.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+n.wireframe_linewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframe_linecap+"; stroke-linejoin: "+n.wireframe_linejoin):H.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+
+n.opacity);k.appendChild(H)}function e(ia){if(Q[ia]==null){Q[ia]=document.createElementNS("http://www.w3.org/2000/svg","path");fa==0&&Q[ia].setAttribute("shape-rendering","crispEdges");return Q[ia]}return Q[ia]}function g(ia){return ia<0?Math.min((1+ia)*0.5,0.5):0.5+Math.min(ia*0.5,0.5)}var f=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,q,w,u,t,x,A,E=new THREE.Rectangle,v=new THREE.Rectangle,F=false,p=new THREE.Color(16777215),M=new THREE.Color(16777215),
+d=new THREE.Color(0),aa=new THREE.Color(0),O=new THREE.Color(0),K,X=new THREE.Vector3,Q=[],U=[],V=[],H,Y,ea,Z,fa=1;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(ia){switch(ia){case "high":fa=1;break;case "low":fa=0}};this.setSize=function(ia,l){j=ia;m=l;q=j/2;w=m/2;k.setAttribute("viewBox",-q+" "+-w+" "+j+" "+m);k.setAttribute("width",j);k.setAttribute("height",m);E.set(-q,-w,q,w)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};
+this.render=function(ia,l){var y,B,o,n,N,G,z,I;this.autoClear&&this.clear();f=h.projectScene(ia,l,this.sortElements);Z=ea=Y=0;if(F=ia.lights.length>0){z=ia.lights;d.setRGB(0,0,0);aa.setRGB(0,0,0);O.setRGB(0,0,0);y=0;for(B=z.length;y<B;y++){o=z[y];n=o.color;if(o instanceof THREE.AmbientLight){d.r+=n.r;d.g+=n.g;d.b+=n.b}else if(o instanceof THREE.DirectionalLight){aa.r+=n.r;aa.g+=n.g;aa.b+=n.b}else if(o instanceof THREE.PointLight){O.r+=n.r;O.g+=n.g;O.b+=n.b}}}y=0;for(B=f.length;y<B;y++){z=f[y];v.empty();
+if(z instanceof THREE.RenderableParticle){u=z;u.x*=q;u.y*=-w;o=0;for(n=z.materials.length;o<n;o++)if(I=z.materials[o]){N=u;G=z;I=I;var D=ea++;if(U[D]==null){U[D]=document.createElementNS("http://www.w3.org/2000/svg","circle");fa==0&&U[D].setAttribute("shape-rendering","crispEdges")}H=U[D];H.setAttribute("cx",N.x);H.setAttribute("cy",N.y);H.setAttribute("r",G.scale.x*q);if(I instanceof THREE.ParticleCircleMaterial){if(F){M.r=d.r+aa.r+O.r;M.g=d.g+aa.g+O.g;M.b=d.b+aa.b+O.b;p.r=I.color.r*M.r;p.g=I.color.g*
+M.g;p.b=I.color.b*M.b;p.updateStyleString()}else p=I.color;H.setAttribute("style","fill: "+p.__styleString)}k.appendChild(H)}}else if(z instanceof THREE.RenderableLine){u=z.v1;t=z.v2;u.positionScreen.x*=q;u.positionScreen.y*=-w;t.positionScreen.x*=q;t.positionScreen.y*=-w;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(t.positionScreen.x,t.positionScreen.y);if(E.instersects(v)){o=0;for(n=z.materials.length;o<n;)if(I=z.materials[o++]){N=u;G=t;I=I;D=Z++;if(V[D]==null){V[D]=document.createElementNS("http://www.w3.org/2000/svg",
+"line");fa==0&&V[D].setAttribute("shape-rendering","crispEdges")}H=V[D];H.setAttribute("x1",N.positionScreen.x);H.setAttribute("y1",N.positionScreen.y);H.setAttribute("x2",G.positionScreen.x);H.setAttribute("y2",G.positionScreen.y);if(I instanceof THREE.LineBasicMaterial){p.__styleString=I.color.__styleString;H.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+I.linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: "+I.linecap+"; stroke-linejoin: "+I.linejoin);k.appendChild(H)}}}}else if(z instanceof
+THREE.RenderableFace3){u=z.v1;t=z.v2;x=z.v3;u.positionScreen.x*=q;u.positionScreen.y*=-w;t.positionScreen.x*=q;t.positionScreen.y*=-w;x.positionScreen.x*=q;x.positionScreen.y*=-w;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(t.positionScreen.x,t.positionScreen.y);v.addPoint(x.positionScreen.x,x.positionScreen.y);if(E.instersects(v)){o=0;for(n=z.meshMaterials.length;o<n;){I=z.meshMaterials[o++];if(I instanceof THREE.MeshFaceMaterial){N=0;for(G=z.faceMaterials.length;N<G;)(I=z.faceMaterials[N++])&&
+b(u,t,x,z,I,ia)}else I&&b(u,t,x,z,I,ia)}}}else if(z instanceof THREE.RenderableFace4){u=z.v1;t=z.v2;x=z.v3;A=z.v4;u.positionScreen.x*=q;u.positionScreen.y*=-w;t.positionScreen.x*=q;t.positionScreen.y*=-w;x.positionScreen.x*=q;x.positionScreen.y*=-w;A.positionScreen.x*=q;A.positionScreen.y*=-w;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(t.positionScreen.x,t.positionScreen.y);v.addPoint(x.positionScreen.x,x.positionScreen.y);v.addPoint(A.positionScreen.x,A.positionScreen.y);if(E.instersects(v)){o=
+0;for(n=z.meshMaterials.length;o<n;){I=z.meshMaterials[o++];if(I instanceof THREE.MeshFaceMaterial){N=0;for(G=z.faceMaterials.length;N<G;)(I=z.faceMaterials[N++])&&c(u,t,x,A,z,I,ia)}else I&&c(u,t,x,A,z,I,ia)}}}}}};
+THREE.WebGLRenderer=function(a){function b(l,y,B){var o,n,N,G=l.vertices,z=G.length,I=l.colors,D=I.length,$=l.__vertexArray,da=l.__colorArray,C=l.__sortArray,L=l.__dirtyVertices,J=l.__dirtyColors;if(B.sortParticles){V.multiplySelf(B.matrixWorld);for(o=0;o<z;o++){n=G[o].position;ea.copy(n);V.multiplyVector3(ea);C[o]=[ea.z,o]}C.sort(function(R,W){return W[0]-R[0]});for(o=0;o<z;o++){n=G[C[o][1]].position;N=o*3;$[N]=n.x;$[N+1]=n.y;$[N+2]=n.z}for(o=0;o<D;o++){N=o*3;color=I[C[o][1]];da[N]=color.r;da[N+
+1]=color.g;da[N+2]=color.b}}else{if(L)for(o=0;o<z;o++){n=G[o].position;N=o*3;$[N]=n.x;$[N+1]=n.y;$[N+2]=n.z}if(J)for(o=0;o<D;o++){color=I[o];N=o*3;da[N]=color.r;da[N+1]=color.g;da[N+2]=color.b}}if(L||B.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,$,y)}if(J||B.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,da,y)}}function c(l,y){l.fragment_shader=y.fragment_shader;l.vertex_shader=y.vertex_shader;l.uniforms=
+Uniforms.clone(y.uniforms)}function e(l,y){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=d.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=d.createBuffer();if(l.hasPos){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,l.positionArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(y.attributes.position);d.vertexAttribPointer(y.attributes.position,3,d.FLOAT,false,0,0)}if(l.hasNormal){d.bindBuffer(d.ARRAY_BUFFER,l.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,
+l.normalArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(y.attributes.normal);d.vertexAttribPointer(y.attributes.normal,3,d.FLOAT,false,0,0)}d.drawArrays(d.TRIANGLES,0,l.count);l.count=0}function g(l){if(K!=l.doubleSided){l.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE);K=l.doubleSided}if(X!=l.flipSided){l.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW);X=l.flipSided}}function f(l){U[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,l.n44-l.n14);U[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+
+l.n14);U[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);U[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);U[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);U[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var y;for(l=0;l<5;l++){y=U[l];y.divideScalar(Math.sqrt(y.x*y.x+y.y*y.y+y.z*y.z))}}function h(l){for(var y=l.matrix,B=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),o=0;o<6;o++){l=U[o].x*y.n14+U[o].y*y.n24+U[o].z*y.n34+U[o].w;
+if(l<=B)return false}return true}function k(l,y){l.list[l.count]=y;l.count+=1}function j(l){var y,B,o=l.object,n=l.opaque,N=l.transparent;N.count=0;l=n.count=0;for(y=o.materials.length;l<y;l++){B=o.materials[l];B.opacity&&B.opacity<1||B.blending!=THREE.NormalBlending?k(N,B):k(n,B)}}function m(l){var y,B,o,n,N=l.object,G=l.buffer,z=l.opaque,I=l.transparent;I.count=0;l=z.count=0;for(o=N.materials.length;l<o;l++){y=N.materials[l];if(y instanceof THREE.MeshFaceMaterial){y=0;for(B=G.materials.length;y<
+B;y++)if(n=G.materials[y])n.opacity&&n.opacity<1||n.blending!=THREE.NormalBlending?k(I,n):k(z,n)}else{n=y;n.opacity&&n.opacity<1||n.blending!=THREE.NormalBlending?k(I,n):k(z,n)}}}function q(l){var y,B,o,n=l.children;y=0;for(B=n.length;y<B;y++){o=n[y];o.autoUpdateMatrix&&o.updateMatrix();o.matrixWorld.multiply(l.matrixWorld,o.matrix);q(o)}}function w(l,y){return y.z-l.z}function u(l,y){var B,o,n=y.children;B=0;for(o=n.length;B<o;B++){child=n[B];t(l,child,false);u(l,child)}}function t(l,y,B){var o,
+n,N;n=y.geometry;if(l.__webGLObjectsMap[y.id]==undefined){l.__webGLObjectsMap[y.id]={};y._modelViewMatrix=new THREE.Matrix4;y._normalMatrixArray=new Float32Array(9);y._modelViewMatrixArray=new Float32Array(16);y._objectMatrixArray=new Float32Array(16);y.matrix.flattenToArray(y._objectMatrixArray)}N=l.__webGLObjectsMap[y.id];objlist=l.__webGLObjects;if(y instanceof THREE.Mesh){for(o in n.geometryChunks){l=n.geometryChunks[o];if(!l.__webGLVertexBuffer){var G=l;G.__webGLVertexBuffer=d.createBuffer();
+G.__webGLNormalBuffer=d.createBuffer();G.__webGLTangentBuffer=d.createBuffer();G.__webGLColorBuffer=d.createBuffer();G.__webGLUVBuffer=d.createBuffer();G.__webGLUV2Buffer=d.createBuffer();G.__webGLFaceBuffer=d.createBuffer();G.__webGLLineBuffer=d.createBuffer();G=l;var z=y,I=void 0,D=void 0,$=0,da=0,C=0,L=z.geometry.faces,J=G.faces;I=0;for(D=J.length;I<D;I++){fi=J[I];face=L[fi];if(face instanceof THREE.Face3){$+=3;da+=1;C+=3}else if(face instanceof THREE.Face4){$+=4;da+=2;C+=4}}G.__vertexArray=new Float32Array($*
+3);G.__normalArray=new Float32Array($*3);G.__tangentArray=new Float32Array($*4);G.__colorArray=new Float32Array($*3);G.__uvArray=new Float32Array($*2);G.__uv2Array=new Float32Array($*2);G.__faceArray=new Uint16Array(da*3);G.__lineArray=new Uint16Array(C*2);D=I=G;z=z;$=void 0;L=void 0;var R=void 0,W=void 0;R=void 0;J=false;$=0;for(L=z.materials.length;$<L;$++){R=z.materials[$];if(R instanceof THREE.MeshFaceMaterial){R=0;for(W=D.materials.length;R<W;R++)if(D.materials[R]&&D.materials[R].shading!=undefined&&
+D.materials[R].shading==THREE.SmoothShading){J=true;break}}else if(R&&R.shading!=undefined&&R.shading==THREE.SmoothShading){J=true;break}if(J)break}I.__needsSmoothNormals=J;G.__webGLFaceCount=da*3;G.__webGLLineCount=C*2;n.__dirtyVertices=true;n.__dirtyElements=true;n.__dirtyUvs=true;n.__dirtyNormals=true;n.__dirtyTangents=true;n.__dirtyColors=true}if(n.__dirtyVertices||n.__dirtyElements||n.__dirtyUvs||n.__dirtyNormals||n.__dirtyColors||n.__dirtyTangents){G=l;da=d.DYNAMIC_DRAW;C=void 0;I=void 0;var la=
+void 0,S=void 0,ta=void 0,sa=void 0,va=void 0;la=void 0;var ga=void 0,ka=void 0,na=void 0,Ca=void 0;ga=void 0;ka=void 0;na=void 0;S=void 0;ga=void 0;ka=void 0;na=void 0;Ca=void 0;S=void 0;sa=void 0;ta=void 0;va=void 0;var ya=W=R=J=L=$=z=D=0,qa=0,ra=G.__vertexArray,Ha=G.__uvArray,Ia=G.__uv2Array,wa=G.__normalArray,ma=G.__tangentArray,pa=G.__colorArray,Da=G.__faceArray,xa=G.__lineArray,Oa=G.__needsSmoothNormals,Aa=y.geometry,oa=Aa.__dirtyVertices,Ea=Aa.__dirtyElements,Fa=Aa.__dirtyUvs,Pa=Aa.__dirtyNormals,
+Qa=Aa.__dirtyTangents,Na=Aa.__dirtyColors,P=Aa.vertices,ha=G.faces,ca=Aa.faces,T=Aa.uvs,ba=Aa.uvs2,ja=Aa.colors;C=0;for(I=ha.length;C<I;C++){la=ha[C];S=ca[la];va=T[la];la=ba[la];ta=S.vertexNormals;sa=S.normal;if(S instanceof THREE.Face3){if(oa){ga=P[S.a].position;ka=P[S.b].position;na=P[S.c].position;ra[z]=ga.x;ra[z+1]=ga.y;ra[z+2]=ga.z;ra[z+3]=ka.x;ra[z+4]=ka.y;ra[z+5]=ka.z;ra[z+6]=na.x;ra[z+7]=na.y;ra[z+8]=na.z;z+=9}if(Na&&ja.length){ga=ja[S.a];ka=ja[S.b];na=ja[S.c];pa[qa]=ga.r;pa[qa+1]=ga.g;pa[qa+
+2]=ga.b;pa[qa+3]=ka.r;pa[qa+4]=ka.g;pa[qa+5]=ka.b;pa[qa+6]=na.r;pa[qa+7]=na.g;pa[qa+8]=na.b;qa+=9}if(Qa&&Aa.hasTangents){ga=P[S.a].tangent;ka=P[S.b].tangent;na=P[S.c].tangent;ma[W]=ga.x;ma[W+1]=ga.y;ma[W+2]=ga.z;ma[W+3]=ga.w;ma[W+4]=ka.x;ma[W+5]=ka.y;ma[W+6]=ka.z;ma[W+7]=ka.w;ma[W+8]=na.x;ma[W+9]=na.y;ma[W+10]=na.z;ma[W+11]=na.w;W+=12}if(Pa)if(ta.length==3&&Oa)for(S=0;S<3;S++){sa=ta[S];wa[R]=sa.x;wa[R+1]=sa.y;wa[R+2]=sa.z;R+=3}else for(S=0;S<3;S++){wa[R]=sa.x;wa[R+1]=sa.y;wa[R+2]=sa.z;R+=3}if(Fa&&
+va)for(S=0;S<3;S++){ta=va[S];Ha[$]=ta.u;Ha[$+1]=ta.v;$+=2}if(Fa&&la)for(S=0;S<3;S++){va=la[S];Ia[L]=va.u;Ia[L+1]=va.v;L+=2}if(Ea){Da[J]=D;Da[J+1]=D+1;Da[J+2]=D+2;J+=3;xa[ya]=D;xa[ya+1]=D+1;xa[ya+2]=D;xa[ya+3]=D+2;xa[ya+4]=D+1;xa[ya+5]=D+2;ya+=6;D+=3}}else if(S instanceof THREE.Face4){if(oa){ga=P[S.a].position;ka=P[S.b].position;na=P[S.c].position;Ca=P[S.d].position;ra[z]=ga.x;ra[z+1]=ga.y;ra[z+2]=ga.z;ra[z+3]=ka.x;ra[z+4]=ka.y;ra[z+5]=ka.z;ra[z+6]=na.x;ra[z+7]=na.y;ra[z+8]=na.z;ra[z+9]=Ca.x;ra[z+
+10]=Ca.y;ra[z+11]=Ca.z;z+=12}if(Na&&ja.length){ga=ja[S.a];ka=ja[S.b];na=ja[S.c];Ca=ja[S.d];pa[qa]=ga.r;pa[qa+1]=ga.g;pa[qa+2]=ga.b;pa[qa+3]=ka.r;pa[qa+4]=ka.g;pa[qa+5]=ka.b;pa[qa+6]=na.r;pa[qa+7]=na.g;pa[qa+8]=na.b;pa[qa+9]=Ca.r;pa[qa+10]=Ca.g;pa[qa+11]=Ca.b;qa+=12}if(Qa&&Aa.hasTangents){ga=P[S.a].tangent;ka=P[S.b].tangent;na=P[S.c].tangent;S=P[S.d].tangent;ma[W]=ga.x;ma[W+1]=ga.y;ma[W+2]=ga.z;ma[W+3]=ga.w;ma[W+4]=ka.x;ma[W+5]=ka.y;ma[W+6]=ka.z;ma[W+7]=ka.w;ma[W+8]=na.x;ma[W+9]=na.y;ma[W+10]=na.z;
+ma[W+11]=na.w;ma[W+12]=S.x;ma[W+13]=S.y;ma[W+14]=S.z;ma[W+15]=S.w;W+=16}if(Pa)if(ta.length==4&&Oa)for(S=0;S<4;S++){sa=ta[S];wa[R]=sa.x;wa[R+1]=sa.y;wa[R+2]=sa.z;R+=3}else for(S=0;S<4;S++){wa[R]=sa.x;wa[R+1]=sa.y;wa[R+2]=sa.z;R+=3}if(Fa&&va)for(S=0;S<4;S++){ta=va[S];Ha[$]=ta.u;Ha[$+1]=ta.v;$+=2}if(Fa&&la)for(S=0;S<4;S++){va=la[S];Ia[L]=va.u;Ia[L+1]=va.v;L+=2}if(Ea){Da[J]=D;Da[J+1]=D+1;Da[J+2]=D+2;Da[J+3]=D;Da[J+4]=D+2;Da[J+5]=D+3;J+=6;xa[ya]=D;xa[ya+1]=D+1;xa[ya+2]=D;xa[ya+3]=D+3;xa[ya+4]=D+1;xa[ya+
+5]=D+2;xa[ya+6]=D+2;xa[ya+7]=D+3;ya+=8;D+=4}}}if(oa){d.bindBuffer(d.ARRAY_BUFFER,G.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,ra,da)}if(Na&&ja.length){d.bindBuffer(d.ARRAY_BUFFER,G.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,pa,da)}if(Pa){d.bindBuffer(d.ARRAY_BUFFER,G.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,wa,da)}if(Qa&&Aa.hasTangents){d.bindBuffer(d.ARRAY_BUFFER,G.__webGLTangentBuffer);d.bufferData(d.ARRAY_BUFFER,ma,da)}if(Fa&&$>0){d.bindBuffer(d.ARRAY_BUFFER,G.__webGLUVBuffer);
+d.bufferData(d.ARRAY_BUFFER,Ha,da)}if(Fa&&L>0){d.bindBuffer(d.ARRAY_BUFFER,G.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Ia,da)}if(Ea){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,G.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,Da,da);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,G.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,xa,da)}}x(objlist,N,o,l,y,B)}n.__dirtyVertices=false;n.__dirtyElements=false;n.__dirtyUvs=false;n.__dirtyNormals=false;n.__dirtyTangents=false;n.__dirtyColors=false}else if(y instanceof
+THREE.Line){if(!n.__webGLVertexBuffer){n.__webGLVertexBuffer=d.createBuffer();n.__webGLColorBuffer=d.createBuffer();o=n.vertices.length;n.__vertexArray=new Float32Array(o*3);n.__colorArray=new Float32Array(o*3);n.__webGLLineCount=o;n.__dirtyVertices=true;n.__dirtyColors=true}if(n.__dirtyVertices||n.__dirtyColors){o=d.DYNAMIC_DRAW;z=n.vertices;G=n.colors;$=z.length;da=G.length;L=n.__vertexArray;C=n.__colorArray;J=n.__dirtyColors;if(n.__dirtyVertices){for(I=0;I<$;I++){D=z[I].position;l=I*3;L[l]=D.x;
+L[l+1]=D.y;L[l+2]=D.z}d.bindBuffer(d.ARRAY_BUFFER,n.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,L,o)}if(J){for(I=0;I<da;I++){color=G[I];l=I*3;C[l]=color.r;C[l+1]=color.g;C[l+2]=color.b}d.bindBuffer(d.ARRAY_BUFFER,n.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,C,o)}}x(objlist,N,0,n,y,B);n.__dirtyVertices=false;n.__dirtyColors=false}else if(y instanceof THREE.ParticleSystem){if(!n.__webGLVertexBuffer){n.__webGLVertexBuffer=d.createBuffer();n.__webGLColorBuffer=d.createBuffer();o=n.vertices.length;
+n.__vertexArray=new Float32Array(o*3);n.__colorArray=new Float32Array(o*3);n.__sortArray=[];n.__webGLParticleCount=o;n.__dirtyVertices=true;n.__dirtyColors=true}if(n.__dirtyVertices||n.__dirtyColors||y.sortParticles)b(n,d.DYNAMIC_DRAW,y,camera);x(objlist,N,0,n,y,B);n.__dirtyVertices=false;n.__dirtyColors=false}else if(y instanceof THREE.MarchingCubes)if(N[0]==undefined){l.__webGLObjectsImmediate.push({object:y,opaque:{list:[],count:0},transparent:{list:[],count:0},root:B});N[0]=1}}function x(l,y,
+B,o,n,N){if(y[B]==undefined){l.push({buffer:o,object:n,opaque:{list:[],count:0},transparent:{list:[],count:0},root:N});y[B]=1}}function A(l,y){l._modelViewMatrix.multiplyToArray(y.matrix,l.matrixWorld,l._modelViewMatrixArray);l._normalMatrix=THREE.Matrix4.makeInvert3x3(l._modelViewMatrix).transposeIntoArray(l._normalMatrixArray)}function E(l){if(l!=Q){switch(l){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE);break;case THREE.SubtractiveBlending:d.blendFunc(d.DST_COLOR,
+d.ZERO);break;case THREE.BillboardBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA);break;default:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA)}Q=l}}function v(l,y){if(l&&!l.__webGLFramebuffer){l.__webGLFramebuffer=d.createFramebuffer();l.__webGLRenderbuffer=d.createRenderbuffer();l.__webGLTexture=d.createTexture();d.bindRenderbuffer(d.RENDERBUFFER,l.__webGLRenderbuffer);d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,l.width,l.height);
+d.bindTexture(d.TEXTURE_2D,l.__webGLTexture);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,p(l.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,p(l.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,p(l.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,p(l.min_filter));d.texImage2D(d.TEXTURE_2D,0,p(l.format),l.width,l.height,0,p(l.format),p(l.type),null);d.bindFramebuffer(d.FRAMEBUFFER,l.__webGLFramebuffer);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,
+l.__webGLTexture,0);d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.RENDERBUFFER,l.__webGLRenderbuffer);d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,null)}var B,o,n;if(l){B=l.__webGLFramebuffer;o=l.width;n=l.height}else{B=null;o=M.width;n=M.height}if(B!=O){d.bindFramebuffer(d.FRAMEBUFFER,B);d.viewport(0,0,o,n);y&&d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT);O=B}}function F(l,y){var B;if(l=="fragment")B=d.createShader(d.FRAGMENT_SHADER);
+else if(l=="vertex")B=d.createShader(d.VERTEX_SHADER);d.shaderSource(B,y);d.compileShader(B);if(!d.getShaderParameter(B,d.COMPILE_STATUS)){alert(d.getShaderInfoLog(B));return null}return B}function p(l){switch(l){case THREE.RepeatWrapping:return d.REPEAT;case THREE.ClampToEdgeWrapping:return d.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return d.MIRRORED_REPEAT;case THREE.NearestFilter:return d.NEAREST;case THREE.NearestMipMapNearestFilter:return d.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return d.NEAREST_MIPMAP_LINEAR;
+case THREE.LinearFilter:return d.LINEAR;case THREE.LinearMipMapNearestFilter:return d.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return d.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return d.BYTE;case THREE.UnsignedByteType:return d.UNSIGNED_BYTE;case THREE.ShortType:return d.SHORT;case THREE.UnsignedShortType:return d.UNSIGNED_SHORT;case THREE.IntType:return d.INT;case THREE.UnsignedShortType:return d.UNSIGNED_INT;case THREE.FloatType:return d.FLOAT;case THREE.AlphaFormat:return d.ALPHA;
+case THREE.RGBFormat:return d.RGB;case THREE.RGBAFormat:return d.RGBA;case THREE.LuminanceFormat:return d.LUMINANCE;case THREE.LuminanceAlphaFormat:return d.LUMINANCE_ALPHA}return 0}var M=document.createElement("canvas"),d,aa=null,O=null,K=null,X=null,Q=null,U=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],V=new THREE.Matrix4,H=new Float32Array(16),Y=new Float32Array(16),ea=new THREE.Vector4,Z=true,fa=new THREE.Color(0),ia=0;if(a){if(a.antialias!==
+undefined)Z=a.antialias;a.clearColor!==undefined&&fa.setHex(a.clearColor);if(a.clearAlpha!==undefined)ia=a.clearAlpha}this.domElement=M;this.autoClear=true;(function(l,y,B){try{d=M.getContext("experimental-webgl",{antialias:l})}catch(o){console.log(o)}if(!d){alert("WebGL not supported");throw"cannot create webgl context";}d.clearColor(0,0,0,1);d.clearDepth(1);d.enable(d.DEPTH_TEST);d.depthFunc(d.LEQUAL);d.frontFace(d.CCW);d.cullFace(d.BACK);d.enable(d.CULL_FACE);d.enable(d.BLEND);d.blendFunc(d.ONE,
+d.ONE_MINUS_SRC_ALPHA);d.clearColor(y.r,y.g,y.b,B);_cullEnabled=true})(Z,fa,ia);this.context=d;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,y){M.width=l;M.height=y;d.viewport(0,0,M.width,M.height)};this.setClearColorHex=function(l,y){var B=new THREE.Color(l);d.clearColor(B.r,B.g,B.b,y)};this.setClearColor=function(l,y){d.clearColor(l.r,l.g,l.b,y)};this.clear=function(){d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT)};
+this.setupLights=function(l,y){var B,o,n,N=0,G=0,z=0,I,D,$,da=this.lights,C=da.directional.colors,L=da.directional.positions,J=da.point.colors,R=da.point.positions,W=0,la=0;B=n=n=0;for(o=y.length;B<o;B++){n=y[B];I=n.color;D=n.position;$=n.intensity;if(n instanceof THREE.AmbientLight){N+=I.r;G+=I.g;z+=I.b}else if(n instanceof THREE.DirectionalLight){n=W*3;C[n]=I.r*$;C[n+1]=I.g*$;C[n+2]=I.b*$;L[n]=D.x;L[n+1]=D.y;L[n+2]=D.z;W+=1}else if(n instanceof THREE.PointLight){n=la*3;J[n]=I.r*$;J[n+1]=I.g*$;J[n+
+2]=I.b*$;R[n]=D.x;R[n+1]=D.y;R[n+2]=D.z;la+=1}}for(B=W*3;B<C.length;B++)C[B]=0;for(B=la*3;B<J.length;B++)J[B]=0;da.point.length=la;da.directional.length=W;da.ambient[0]=N;da.ambient[1]=G;da.ambient[2]=z};this.initMaterial=function(l,y,B){var o,n;if(l instanceof THREE.MeshDepthMaterial)c(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)c(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)c(l,
+THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)c(l,THREE.ShaderLib.phong);else if(l instanceof THREE.LineBasicMaterial)c(l,THREE.ShaderLib.basic);else l instanceof THREE.ParticleBasicMaterial&&c(l,THREE.ShaderLib.particle_basic);var N,G,z,I;n=z=I=0;for(N=y.length;n<N;n++){G=y[n];G instanceof THREE.DirectionalLight&&z++;G instanceof THREE.PointLight&&I++}if(I+z<=4){y=z;I=I}else{y=Math.ceil(4*z/(I+z));I=4-y}n={directional:y,point:I};I=l.fragment_shader;y=l.vertex_shader;N={fog:B,
+map:l.map,env_map:l.env_map,light_map:l.light_map,vertex_colors:l.vertex_colors,maxDirLights:n.directional,maxPointLights:n.point};B=d.createProgram();n=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+N.maxDirLights,"#define MAX_POINT_LIGHTS "+N.maxPointLights,N.fog?"#define USE_FOG":"",N.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",N.map?"#define USE_MAP":"",N.env_map?"#define USE_ENVMAP":"",N.light_map?"#define USE_LIGHTMAP":"",N.vertex_colors?"#define USE_COLOR":
+"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");N=[d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+N.maxDirLights,"#define MAX_POINT_LIGHTS "+N.maxPointLights,N.map?"#define USE_MAP":"",N.env_map?"#define USE_ENVMAP":"",N.light_map?"#define USE_LIGHTMAP":"",N.vertex_colors?"#define USE_COLOR":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");
+d.attachShader(B,F("fragment",n+I));d.attachShader(B,F("vertex",N+y));d.linkProgram(B);d.getProgramParameter(B,d.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+d.getProgramParameter(B,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");B.uniforms={};B.attributes={};l.program=B;B=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(o in l.uniforms)B.push(o);o=l.program;I=0;for(y=B.length;I<y;I++){n=B[I];o.uniforms[n]=d.getUniformLocation(o,
+n)}l=l.program;o=["position","normal","uv","uv2","tangent","color"];B=0;for(I=o.length;B<I;B++){y=o[B];l.attributes[y]=d.getAttribLocation(l,y)}};this.setProgram=function(l,y,B,o,n){o.program||this.initMaterial(o,y,B);var N=o.program,G=N.uniforms,z=o.uniforms;if(N!=aa){d.useProgram(N);aa=N;d.uniformMatrix4fv(G.projectionMatrix,false,H)}if(B&&(o instanceof THREE.MeshBasicMaterial||o instanceof THREE.MeshLambertMaterial||o instanceof THREE.MeshPhongMaterial||o instanceof THREE.LineBasicMaterial||o instanceof
+THREE.ParticleBasicMaterial)){z.fogColor.value.setHex(B.color.hex);if(B instanceof THREE.Fog){z.fogNear.value=B.near;z.fogFar.value=B.far}else if(B instanceof THREE.FogExp2)z.fogDensity.value=B.density}if(o instanceof THREE.MeshPhongMaterial||o instanceof THREE.MeshLambertMaterial){this.setupLights(N,y);y=this.lights;z.enableLighting.value=y.directional.length+y.point.length;z.ambientLightColor.value=y.ambient;z.directionalLightColor.value=y.directional.colors;z.directionalLightDirection.value=y.directional.positions;
+z.pointLightColor.value=y.point.colors;z.pointLightPosition.value=y.point.positions}if(o instanceof THREE.MeshBasicMaterial||o instanceof THREE.MeshLambertMaterial||o instanceof THREE.MeshPhongMaterial){z.diffuse.value.setRGB(o.color.r*o.opacity,o.color.g*o.opacity,o.color.b*o.opacity);z.opacity.value=o.opacity;z.map.texture=o.map;z.light_map.texture=o.light_map;z.env_map.texture=o.env_map;z.reflectivity.value=o.reflectivity;z.refraction_ratio.value=o.refraction_ratio;z.combine.value=o.combine;z.useRefract.value=
+o.env_map&&o.env_map.mapping instanceof THREE.CubeRefractionMapping}if(o instanceof THREE.LineBasicMaterial){z.diffuse.value.setRGB(o.color.r*o.opacity,o.color.g*o.opacity,o.color.b*o.opacity);z.opacity.value=o.opacity}else if(o instanceof THREE.ParticleBasicMaterial){z.psColor.value.setRGB(o.color.r*o.opacity,o.color.g*o.opacity,o.color.b*o.opacity);z.opacity.value=o.opacity;z.size.value=o.size;z.map.texture=o.map}else if(o instanceof THREE.MeshPhongMaterial){z.ambient.value.setRGB(o.ambient.r,o.ambient.g,
+o.ambient.b);z.specular.value.setRGB(o.specular.r,o.specular.g,o.specular.b);z.shininess.value=o.shininess}else if(o instanceof THREE.MeshDepthMaterial){z.mNear.value=l.near;z.mFar.value=l.far;z.opacity.value=o.opacity}else if(o instanceof THREE.MeshNormalMaterial)z.opacity.value=o.opacity;var I,D,$;for(I in z)if($=N.uniforms[I]){B=z[I];D=B.type;y=B.value;if(D=="i")d.uniform1i($,y);else if(D=="f")d.uniform1f($,y);else if(D=="fv1")d.uniform1fv($,y);else if(D=="fv")d.uniform3fv($,y);else if(D=="v2")d.uniform2f($,
+y.x,y.y);else if(D=="v3")d.uniform3f($,y.x,y.y,y.z);else if(D=="c")d.uniform3f($,y.r,y.g,y.b);else if(D=="t"){d.uniform1i($,y);if(B=B.texture)if(B.image instanceof Array&&B.image.length==6){B=B;y=y;if(B.image.length==6){if(!B.image.__webGLTextureCube&&!B.image.__cubeMapInitialized&&B.image.loadCount==6){B.image.__webGLTextureCube=d.createTexture();d.bindTexture(d.TEXTURE_CUBE_MAP,B.image.__webGLTextureCube);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_CUBE_MAP,
+d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MAG_FILTER,d.LINEAR);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MIN_FILTER,d.LINEAR_MIPMAP_LINEAR);for(D=0;D<6;++D)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,B.image[D]);d.generateMipmap(d.TEXTURE_CUBE_MAP);d.bindTexture(d.TEXTURE_CUBE_MAP,null);B.image.__cubeMapInitialized=true}d.activeTexture(d.TEXTURE0+y);d.bindTexture(d.TEXTURE_CUBE_MAP,B.image.__webGLTextureCube)}}else{B=B;y=y;if(!B.__webGLTexture&&
+B.image.loaded){B.__webGLTexture=d.createTexture();d.bindTexture(d.TEXTURE_2D,B.__webGLTexture);d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,B.image);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,p(B.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,p(B.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,p(B.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,p(B.min_filter));d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}d.activeTexture(d.TEXTURE0+
+y);d.bindTexture(d.TEXTURE_2D,B.__webGLTexture)}}}d.uniformMatrix4fv(G.modelViewMatrix,false,n._modelViewMatrixArray);d.uniformMatrix3fv(G.normalMatrix,false,n._normalMatrixArray);if(o instanceof THREE.MeshShaderMaterial||o instanceof THREE.MeshPhongMaterial||o.env_map)d.uniform3f(G.cameraPosition,l.position.x,l.position.y,l.position.z);if(o instanceof THREE.MeshShaderMaterial||o.env_map)d.uniformMatrix4fv(G.objectMatrix,false,n._objectMatrixArray);if(o instanceof THREE.MeshPhongMaterial||o instanceof
+THREE.MeshLambertMaterial||o instanceof THREE.MeshShaderMaterial)d.uniformMatrix4fv(G.viewMatrix,false,Y);return N};this.renderBuffer=function(l,y,B,o,n,N){l=this.setProgram(l,y,B,o,N).attributes;d.bindBuffer(d.ARRAY_BUFFER,n.__webGLVertexBuffer);d.vertexAttribPointer(l.position,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.position);if(l.color>=0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLColorBuffer);d.vertexAttribPointer(l.color,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.color)}if(l.normal>=
 0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLNormalBuffer);d.vertexAttribPointer(l.normal,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.normal)}if(l.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLTangentBuffer);d.vertexAttribPointer(l.tangent,4,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.tangent)}if(l.uv>=0)if(n.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLUVBuffer);d.vertexAttribPointer(l.uv,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.uv)}else d.disableVertexAttribArray(l.uv);if(l.uv2>=
 0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLNormalBuffer);d.vertexAttribPointer(l.normal,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.normal)}if(l.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLTangentBuffer);d.vertexAttribPointer(l.tangent,4,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.tangent)}if(l.uv>=0)if(n.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLUVBuffer);d.vertexAttribPointer(l.uv,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.uv)}else d.disableVertexAttribArray(l.uv);if(l.uv2>=
-0)if(n.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLUV2Buffer);d.vertexAttribPointer(l.uv2,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.uv2)}else d.disableVertexAttribArray(l.uv2);if(F instanceof THREE.Mesh)if(u.wireframe){d.lineWidth(u.wireframe_linewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);d.drawElements(d.LINES,n.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,n.__webGLFaceCount,d.UNSIGNED_SHORT,
-0)}else if(F instanceof THREE.Line){F=F.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(u.linewidth);d.drawArrays(F,0,n.__webGLLineCount)}else F instanceof THREE.ParticleSystem&&d.drawArrays(d.POINTS,0,n.__webGLParticleCount)};this.render=function(l,v,A,u){var n,F,L,G,D,C,R,ba=l.lights,ga=l.fog;v.autoUpdateMatrix&&v.updateMatrix();v.matrix.flattenToArray(J);v.projectionMatrix.flattenToArray(W);Y.multiply(v.projectionMatrix,v.matrix);f(Y);this.initWebGLObjects(l,v);H(A,u!==undefined?u:true);
-this.autoClear&&this.clear();G=l.__webGLObjects.length;for(u=0;u<G;u++){n=l.__webGLObjects[u];C=n.object;if(C.visible){if(n.root){C.autoUpdateMatrix&&C.updateMatrix();C.matrixWorld.copy(C.matrix);p(C)}if(!(C instanceof THREE.Mesh)||h(C)){C.matrixWorld.flattenToArray(C._objectMatrixArray);y(C,v);m(n);n.render=true}else n.render=false}else n.render=false}D=l.__webGLObjectsImmediate.length;for(u=0;u<D;u++){n=l.__webGLObjectsImmediate[u];C=n.object;if(C.visible){if(C.autoUpdateMatrix){C.updateMatrix();
-C.matrixWorld.copy(C.matrix);C.matrixWorld.flattenToArray(C._objectMatrixArray)}y(C,v);j(n)}}z(THREE.NormalBlending);for(u=0;u<G;u++){n=l.__webGLObjects[u];if(n.render){C=n.object;R=n.buffer;L=n.opaque;g(C);for(n=0;n<L.count;n++){material=L.list[n];this.setDepthTest(material.depth_test);this.renderBuffer(v,ba,ga,material,R,C)}}}for(u=0;u<D;u++){n=l.__webGLObjectsImmediate[u];C=n.object;if(C.visible){L=n.opaque;g(C);for(n=0;n<L.count;n++){material=L.list[n];this.setDepthTest(material.depth_test);F=
-this.setProgram(v,ba,ga,material,C);C.render(function(B){e(B,F)})}}}for(u=0;u<G;u++){n=l.__webGLObjects[u];if(n.render){C=n.object;R=n.buffer;L=n.transparent;g(C);for(n=0;n<L.count;n++){material=L.list[n];z(material.blending);this.setDepthTest(material.depth_test);this.renderBuffer(v,ba,ga,material,R,C)}}}for(u=0;u<D;u++){n=l.__webGLObjectsImmediate[u];C=n.object;if(C.visible){L=n.transparent;g(C);for(n=0;n<L.count;n++){material=L.list[n];z(material.blending);this.setDepthTest(material.depth_test);
-F=this.setProgram(v,ba,ga,material,C);C.render(function(B){e(B,F)})}}}if(A&&A.min_filter!==THREE.NearestFilter&&A.min_filter!==THREE.LinearFilter){d.bindTexture(d.TEXTURE_2D,A.__webGLTexture);d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}};this.initWebGLObjects=function(l){var v,A,u;if(!l.__webGLObjects){l.__webGLObjects=[];l.__webGLObjectsMap={};l.__webGLObjectsImmediate=[]}v=0;for(A=l.objects.length;v<A;v++){u=l.objects[v];t(l,u,true);x(l,u)}};this.removeObject=function(l,v){var A,
-u;for(A=l.__webGLObjects.length-1;A>=0;A--){u=l.__webGLObjects[A].object;v==u&&l.__webGLObjects.splice(A,1)}};this.setDepthTest=function(l){l?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST)};this.setFaceCulling=function(l,v){if(l){!v||v=="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW);if(l=="back")d.cullFace(d.BACK);else l=="front"?d.cullFace(d.FRONT):d.cullFace(d.FRONT_AND_BACK);d.enable(d.CULL_FACE)}else d.disable(d.CULL_FACE)};this.supportsVertexTextures=function(){return d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
+0)if(n.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLUV2Buffer);d.vertexAttribPointer(l.uv2,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.uv2)}else d.disableVertexAttribArray(l.uv2);if(N instanceof THREE.Mesh)if(o.wireframe){d.lineWidth(o.wireframe_linewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);d.drawElements(d.LINES,n.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,n.__webGLFaceCount,d.UNSIGNED_SHORT,
+0)}else if(N instanceof THREE.Line){N=N.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(o.linewidth);d.drawArrays(N,0,n.__webGLLineCount)}else N instanceof THREE.ParticleSystem&&d.drawArrays(d.POINTS,0,n.__webGLParticleCount)};this.render=function(l,y,B,o){var n,N,G,z,I,D,$,da=l.lights,C=l.fog;y.autoUpdateMatrix&&y.updateMatrix();y.matrix.flattenToArray(Y);y.projectionMatrix.flattenToArray(H);V.multiply(y.projectionMatrix,y.matrix);f(V);this.initWebGLObjects(l,y);v(B,o!==undefined?o:true);
+this.autoClear&&this.clear();z=l.__webGLObjects.length;for(o=0;o<z;o++){n=l.__webGLObjects[o];D=n.object;if(D.visible){if(n.root){D.autoUpdateMatrix&&D.updateMatrix();D.matrixWorld.copy(D.matrix);q(D)}if(!(D instanceof THREE.Mesh)||h(D)){D.matrixWorld.flattenToArray(D._objectMatrixArray);A(D,y);m(n);n.render=true;ea.copy(D.position);V.multiplyVector3(ea);n.z=ea.z}else n.render=false}else n.render=false}l.__webGLObjects.sort(w);I=l.__webGLObjectsImmediate.length;for(o=0;o<I;o++){n=l.__webGLObjectsImmediate[o];
+D=n.object;if(D.visible){if(D.autoUpdateMatrix){D.updateMatrix();D.matrixWorld.copy(D.matrix);D.matrixWorld.flattenToArray(D._objectMatrixArray)}A(D,y);j(n)}}E(THREE.NormalBlending);for(o=0;o<z;o++){n=l.__webGLObjects[o];if(n.render){D=n.object;$=n.buffer;G=n.opaque;g(D);for(n=0;n<G.count;n++){material=G.list[n];this.setDepthTest(material.depth_test);this.renderBuffer(y,da,C,material,$,D)}}}for(o=0;o<I;o++){n=l.__webGLObjectsImmediate[o];D=n.object;if(D.visible){G=n.opaque;g(D);for(n=0;n<G.count;n++){material=
+G.list[n];this.setDepthTest(material.depth_test);N=this.setProgram(y,da,C,material,D);D.render(function(L){e(L,N)})}}}for(o=0;o<z;o++){n=l.__webGLObjects[o];if(n.render){D=n.object;$=n.buffer;G=n.transparent;g(D);for(n=0;n<G.count;n++){material=G.list[n];E(material.blending);this.setDepthTest(material.depth_test);this.renderBuffer(y,da,C,material,$,D)}}}for(o=0;o<I;o++){n=l.__webGLObjectsImmediate[o];D=n.object;if(D.visible){G=n.transparent;g(D);for(n=0;n<G.count;n++){material=G.list[n];E(material.blending);
+this.setDepthTest(material.depth_test);N=this.setProgram(y,da,C,material,D);D.render(function(L){e(L,N)})}}}if(B&&B.min_filter!==THREE.NearestFilter&&B.min_filter!==THREE.LinearFilter){d.bindTexture(d.TEXTURE_2D,B.__webGLTexture);d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}};this.initWebGLObjects=function(l){var y,B,o;if(!l.__webGLObjects){l.__webGLObjects=[];l.__webGLObjectsMap={};l.__webGLObjectsImmediate=[]}y=0;for(B=l.objects.length;y<B;y++){o=l.objects[y];t(l,o,true);u(l,
+o)}};this.removeObject=function(l,y){var B,o;for(B=l.__webGLObjects.length-1;B>=0;B--){o=l.__webGLObjects[B].object;y==o&&l.__webGLObjects.splice(B,1)}};this.setDepthTest=function(l){l?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST)};this.setFaceCulling=function(l,y){if(l){!y||y=="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW);if(l=="back")d.cullFace(d.BACK);else l=="front"?d.cullFace(d.FRONT):d.cullFace(d.FRONT_AND_BACK);d.enable(d.CULL_FACE)}else d.disable(d.CULL_FACE)};this.supportsVertexTextures=function(){return d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
 0}};
 0}};
 THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
 THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
 envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
 envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
@@ -231,17 +231,17 @@ THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=ne
 THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
 THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
 THREE.Detector={canvas:!!document.createElement("canvas").getContext,webgl:window.Uint8Array!=undefined,workers:!!window.Worker,addGetWebGLMessage:function(a){var b=document.body,c="oldie";if(a){if(a.parent!==undefined)b=a.parent;if(a.id!==undefined)c=a.id}a=document.createElement("center");var e=document.createElement("div");e.innerHTML='Sorry, your browser doesn\'t support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a><br/>\n<br/>\nPlease try in\n<a href="http://www.google.com/chrome">Chrome 9+</a> /\n<a href="http://www.mozilla.com/en-US/firefox/all-beta.html">Firefox 4+</a> /\n<a href="http://nightly.webkit.org/">Safari OSX 10.6+</a>';e.id=
 THREE.Detector={canvas:!!document.createElement("canvas").getContext,webgl:window.Uint8Array!=undefined,workers:!!window.Worker,addGetWebGLMessage:function(a){var b=document.body,c="oldie";if(a){if(a.parent!==undefined)b=a.parent;if(a.id!==undefined)c=a.id}a=document.createElement("center");var e=document.createElement("div");e.innerHTML='Sorry, your browser doesn\'t support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a><br/>\n<br/>\nPlease try in\n<a href="http://www.google.com/chrome">Chrome 9+</a> /\n<a href="http://www.mozilla.com/en-US/firefox/all-beta.html">Firefox 4+</a> /\n<a href="http://nightly.webkit.org/">Safari OSX 10.6+</a>';e.id=
 c;c=e.style;c.fontFamily="monospace";c.fontSize="13px";c.textAlign="center";c.background="#eee";c.color="#000";c.padding="1em";c.width="475px";c.margin="5em auto 0";a.appendChild(e);b.appendChild(a);return e}};
 c;c=e.style;c.fontFamily="monospace";c.fontSize="13px";c.textAlign="center";c.background="#eee";c.color="#000";c.padding="1em";c.width="475px";c.margin="5em auto 0";a.appendChild(e);b.appendChild(a);return e}};
-var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,e=a.vertices.length,g=c?b.geometry:b,f=a.vertices,h=g.vertices,k=a.faces,j=g.faces,m=a.uvs;g=g.uvs;c&&b.autoUpdateMatrix&&b.updateMatrix();for(var p=0,x=h.length;p<x;p++){var t=new THREE.Vertex(h[p].position.clone());c&&b.matrix.multiplyVector3(t.position);f.push(t)}p=0;for(x=j.length;p<x;p++){h=j[p];var q,y=h.vertexNormals;if(h instanceof THREE.Face3)q=new THREE.Face3(h.a+e,h.b+e,h.c+e);else if(h instanceof THREE.Face4)q=new THREE.Face4(h.a+
-e,h.b+e,h.c+e,h.d+e);q.centroid.copy(h.centroid);q.normal.copy(h.normal);c=0;for(f=y.length;c<f;c++){t=y[c];q.vertexNormals.push(t.clone())}q.materials=h.materials.slice();k.push(q)}p=0;for(x=g.length;p<x;p++){e=g[p];k=[];c=0;for(f=e.length;c<f;c++)k.push(new THREE.UV(e[c].u,e[c].v));m.push(k)}}},ImageUtils={loadTexture:function(a,b,c){var e=new Image;e.onload=function(){this.loaded=true;c&&c(this)};e.src=a;return new THREE.Texture(e,b)},loadArray:function(a,b){var c,e,g=[];c=g.loadCount=0;for(e=
-a.length;c<e;++c){g[c]=new Image;g[c].loaded=0;g[c].onload=function(){g.loadCount+=1;this.loaded=true;b&&b(this)};g[c].src=a[c]}return g}},SceneUtils={loadScene:function(a,b,c,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(g){function f(){for(p in N.objects)if(!J.objects[p]){z=N.objects[p];if(o=J.geometries[z.geometry]){aa=[];for(i=0;i<z.materials.length;i++)aa[i]=J.materials[z.materials[i]];H=z.position;r=z.rotation;s=z.scale;object=new THREE.Mesh(o,aa);object.position.set(H[0],H[1],H[2]);
-object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=z.visible;J.scene.addObject(object);J.objects[p]=object}}}function h(X){return function(ha){J.geometries[X]=ha;f();U-=1;k()}}function k(){e({total_models:Y,total_textures:W,loaded_models:Y-U,loaded_textures:W-O},J);U==0&&O==0&&c(J)}var j,m,p,x,t,q,y,z,H,w,E,o,d,P,aa,N,M,U,O,Y,W,J;N=g.data;M=new THREE.Loader;O=U=0;J={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
-g=function(){O-=1;k()};for(t in N.cameras){w=N.cameras[t];if(w.type=="perspective")d=new THREE.Camera(w.fov,w.aspect,w.near,w.far);else if(w.type=="ortho"){d=new THREE.Camera;d.projectionMatrix=THREE.Matrix4.makeOrtho(w.left,w.right,w.top,w.bottom,w.near,w.far)}H=w.position;w=w.target;d.position.set(H[0],H[1],H[2]);d.target.position.set(w[0],w[1],w[2]);J.cameras[t]=d}for(x in N.lights){t=N.lights[x];if(t.type=="directional"){H=t.direction;light=new THREE.DirectionalLight;light.position.set(H[0],H[1],
-H[2]);light.position.normalize()}else if(t.type=="point"){H=t.position;light=new THREE.PointLight;light.position.set(H[0],H[1],H[2])}w=t.color;i=t.intensity||1;light.color.setRGB(w[0]*i,w[1]*i,w[2]*i);J.scene.addLight(light);J.lights[x]=light}for(q in N.fogs){x=N.fogs[q];if(x.type=="linear")P=new THREE.Fog(0,x.near,x.far);else if(x.type=="exp2")P=new THREE.FogExp2(0,x.density);w=x.color;P.color.setRGB(w[0],w[1],w[2]);J.fogs[q]=P}if(J.cameras&&N.defaults.camera)J.currentCamera=J.cameras[N.defaults.camera];
-if(J.fogs&&N.defaults.fog)J.scene.fog=J.fogs[N.defaults.fog];w=N.defaults.bgcolor;J.bgColor=new THREE.Color;J.bgColor.setRGB(w[0],w[1],w[2]);J.bgColorAlpha=N.defaults.bgalpha;for(j in N.geometries){q=N.geometries[j];if(q.type=="bin_mesh"||q.type=="ascii_mesh")U+=1}Y=U;for(j in N.geometries){q=N.geometries[j];if(q.type=="cube"){o=new Cube(q.width,q.height,q.depth,q.segments_width,q.segments_height,null,q.flipped,q.sides);J.geometries[j]=o}else if(q.type=="plane"){o=new Plane(q.width,q.height,q.segments_width,
-q.segments_height);J.geometries[j]=o}else if(q.type=="sphere"){o=new Sphere(q.radius,q.segments_width,q.segments_height);J.geometries[j]=o}else if(q.type=="cylinder"){o=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);J.geometries[j]=o}else if(q.type=="torus"){o=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);J.geometries[j]=o}else if(q.type=="icosahedron"){o=new Icosahedron(q.subdivisions);J.geometries[j]=o}else if(q.type=="bin_mesh")M.loadBinary({model:q.url,callback:h(j)});
-else q.type=="ascii_mesh"&&M.loadAscii({model:q.url,callback:h(j)})}for(y in N.textures){j=N.textures[y];O+=j.url instanceof Array?j.url.length:1}W=O;for(y in N.textures){j=N.textures[y];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array){q=ImageUtils.loadArray(j.url,g);q=new THREE.Texture(q,j.mapping)}else{q=ImageUtils.loadTexture(j.url,j.mapping,g);if(THREE[j.min_filter]!=undefined)q.min_filter=THREE[j.min_filter];if(THREE[j.mag_filter]!=
-undefined)q.mag_filter=THREE[j.mag_filter]}J.textures[y]=q}for(m in N.materials){y=N.materials[m];for(E in y.parameters)if(E=="env_map"||E=="map"||E=="light_map")y.parameters[E]=J.textures[y.parameters[E]];else if(E=="shading")y.parameters[E]=y.parameters[E]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(E=="blending")y.parameters[E]=THREE[y.parameters[E]]?THREE[y.parameters[E]]:THREE.NormalBlending;else if(E=="combine")y.parameters[E]=y.parameters[E]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
-y=new THREE[y.type](y.parameters);J.materials[m]=y}f();b(J)}},addMesh:function(a,b,c,e,g,f,h,k,j,m){b=new THREE.Mesh(b,m);b.scale.x=b.scale.y=b.scale.z=c;b.position.x=e;b.position.y=g;b.position.z=f;b.rotation.x=h;b.rotation.y=k;b.rotation.z=j;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,c){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=c;c=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,uniforms:e.uniforms});b=new THREE.Mesh(new Cube(b,
+var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,e=a.vertices.length,g=c?b.geometry:b,f=a.vertices,h=g.vertices,k=a.faces,j=g.faces,m=a.uvs;g=g.uvs;c&&b.autoUpdateMatrix&&b.updateMatrix();for(var q=0,w=h.length;q<w;q++){var u=new THREE.Vertex(h[q].position.clone());c&&b.matrix.multiplyVector3(u.position);f.push(u)}q=0;for(w=j.length;q<w;q++){h=j[q];var t,x=h.vertexNormals;if(h instanceof THREE.Face3)t=new THREE.Face3(h.a+e,h.b+e,h.c+e);else if(h instanceof THREE.Face4)t=new THREE.Face4(h.a+
+e,h.b+e,h.c+e,h.d+e);t.centroid.copy(h.centroid);t.normal.copy(h.normal);c=0;for(f=x.length;c<f;c++){u=x[c];t.vertexNormals.push(u.clone())}t.materials=h.materials.slice();k.push(t)}q=0;for(w=g.length;q<w;q++){e=g[q];k=[];c=0;for(f=e.length;c<f;c++)k.push(new THREE.UV(e[c].u,e[c].v));m.push(k)}}},ImageUtils={loadTexture:function(a,b,c){var e=new Image;e.onload=function(){this.loaded=true;c&&c(this)};e.src=a;return new THREE.Texture(e,b)},loadArray:function(a,b){var c,e,g=[];c=g.loadCount=0;for(e=
+a.length;c<e;++c){g[c]=new Image;g[c].loaded=0;g[c].onload=function(){g.loadCount+=1;this.loaded=true;b&&b(this)};g[c].src=a[c]}return g}},SceneUtils={loadScene:function(a,b,c,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(g){function f(){for(q in O.objects)if(!H.objects[q]){A=O.objects[q];if(p=H.geometries[A.geometry]){aa=[];for(i=0;i<A.materials.length;i++)aa[i]=H.materials[A.materials[i]];E=A.position;r=A.rotation;s=A.scale;object=new THREE.Mesh(p,aa);object.position.set(E[0],E[1],E[2]);
+object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=A.visible;H.scene.addObject(object);H.objects[q]=object}}}function h(Y){return function(ea){H.geometries[Y]=ea;f();X-=1;k()}}function k(){e({total_models:U,total_textures:V,loaded_models:U-X,loaded_textures:V-Q},H);X==0&&Q==0&&c(H)}var j,m,q,w,u,t,x,A,E,v,F,p,M,d,aa,O,K,X,Q,U,V,H;O=g.data;K=new THREE.Loader;Q=X=0;H={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
+g=function(){Q-=1;k()};for(u in O.cameras){v=O.cameras[u];if(v.type=="perspective")M=new THREE.Camera(v.fov,v.aspect,v.near,v.far);else if(v.type=="ortho"){M=new THREE.Camera;M.projectionMatrix=THREE.Matrix4.makeOrtho(v.left,v.right,v.top,v.bottom,v.near,v.far)}E=v.position;v=v.target;M.position.set(E[0],E[1],E[2]);M.target.position.set(v[0],v[1],v[2]);H.cameras[u]=M}for(w in O.lights){u=O.lights[w];if(u.type=="directional"){E=u.direction;light=new THREE.DirectionalLight;light.position.set(E[0],E[1],
+E[2]);light.position.normalize()}else if(u.type=="point"){E=u.position;light=new THREE.PointLight;light.position.set(E[0],E[1],E[2])}v=u.color;i=u.intensity||1;light.color.setRGB(v[0]*i,v[1]*i,v[2]*i);H.scene.addLight(light);H.lights[w]=light}for(t in O.fogs){w=O.fogs[t];if(w.type=="linear")d=new THREE.Fog(0,w.near,w.far);else if(w.type=="exp2")d=new THREE.FogExp2(0,w.density);v=w.color;d.color.setRGB(v[0],v[1],v[2]);H.fogs[t]=d}if(H.cameras&&O.defaults.camera)H.currentCamera=H.cameras[O.defaults.camera];
+if(H.fogs&&O.defaults.fog)H.scene.fog=H.fogs[O.defaults.fog];v=O.defaults.bgcolor;H.bgColor=new THREE.Color;H.bgColor.setRGB(v[0],v[1],v[2]);H.bgColorAlpha=O.defaults.bgalpha;for(j in O.geometries){t=O.geometries[j];if(t.type=="bin_mesh"||t.type=="ascii_mesh")X+=1}U=X;for(j in O.geometries){t=O.geometries[j];if(t.type=="cube"){p=new Cube(t.width,t.height,t.depth,t.segments_width,t.segments_height,null,t.flipped,t.sides);H.geometries[j]=p}else if(t.type=="plane"){p=new Plane(t.width,t.height,t.segments_width,
+t.segments_height);H.geometries[j]=p}else if(t.type=="sphere"){p=new Sphere(t.radius,t.segments_width,t.segments_height);H.geometries[j]=p}else if(t.type=="cylinder"){p=new Cylinder(t.numSegs,t.topRad,t.botRad,t.height,t.topOffset,t.botOffset);H.geometries[j]=p}else if(t.type=="torus"){p=new Torus(t.radius,t.tube,t.segmentsR,t.segmentsT);H.geometries[j]=p}else if(t.type=="icosahedron"){p=new Icosahedron(t.subdivisions);H.geometries[j]=p}else if(t.type=="bin_mesh")K.loadBinary({model:t.url,callback:h(j)});
+else t.type=="ascii_mesh"&&K.loadAscii({model:t.url,callback:h(j)})}for(x in O.textures){j=O.textures[x];Q+=j.url instanceof Array?j.url.length:1}V=Q;for(x in O.textures){j=O.textures[x];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array){t=ImageUtils.loadArray(j.url,g);t=new THREE.Texture(t,j.mapping)}else{t=ImageUtils.loadTexture(j.url,j.mapping,g);if(THREE[j.min_filter]!=undefined)t.min_filter=THREE[j.min_filter];if(THREE[j.mag_filter]!=
+undefined)t.mag_filter=THREE[j.mag_filter]}H.textures[x]=t}for(m in O.materials){x=O.materials[m];for(F in x.parameters)if(F=="env_map"||F=="map"||F=="light_map")x.parameters[F]=H.textures[x.parameters[F]];else if(F=="shading")x.parameters[F]=x.parameters[F]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(F=="blending")x.parameters[F]=THREE[x.parameters[F]]?THREE[x.parameters[F]]:THREE.NormalBlending;else if(F=="combine")x.parameters[F]=x.parameters[F]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
+x=new THREE[x.type](x.parameters);H.materials[m]=x}f();b(H)}},addMesh:function(a,b,c,e,g,f,h,k,j,m){b=new THREE.Mesh(b,m);b.scale.x=b.scale.y=b.scale.z=c;b.position.x=e;b.position.y=g;b.position.z=f;b.rotation.x=h;b.rotation.y=k;b.rotation.z=j;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,c){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=c;c=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,uniforms:e.uniforms});b=new THREE.Mesh(new Cube(b,
 b,b,1,1,null,true),c);a.addObject(b);return b},addPanoramaCube:function(a,b,c){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));b=new THREE.Mesh(new Cube(b,
 b,b,1,1,null,true),c);a.addObject(b);return b},addPanoramaCube:function(a,b,c){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));b=new THREE.Mesh(new Cube(b,
 b,b,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(b);return b},addPanoramaCubePlanes:function(a,b,c){var e=b/2;b=new Plane(b,b);var g=Math.PI/2,f=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));SceneUtils.addMesh(a,b,1,-e,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));SceneUtils.addMesh(a,b,1,e,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));SceneUtils.addMesh(a,b,1,0,e,0,g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));
 b,b,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(b);return b},addPanoramaCubePlanes:function(a,b,c){var e=b/2;b=new Plane(b,b);var g=Math.PI/2,f=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));SceneUtils.addMesh(a,b,1,-e,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));SceneUtils.addMesh(a,b,1,e,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));SceneUtils.addMesh(a,b,1,0,e,0,g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));
 SceneUtils.addMesh(a,b,1,0,-e,0,-g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[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}",
 SceneUtils.addMesh(a,b,1,0,-e,0,-g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[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}",
@@ -253,38 +253,38 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying ve
 value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertex_shader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
 value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertex_shader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
 film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},grayscale:{type:"i",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nconst float fNintensity = 0.35;\nconst float fSintensity = 0.35;\nconst float fScount = 4096.0;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time *  1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin(vUv.y * fScount), cos(vUv.y * fScount) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * fSintensity;\ncResult = cTextureScreen.rgb + clamp( fNintensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor =  vec4( cResult, cTextureScreen.a );\n}"},
 film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},grayscale:{type:"i",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nconst float fNintensity = 0.35;\nconst float fSintensity = 0.35;\nconst float fScount = 4096.0;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time *  1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin(vUv.y * fScount), cos(vUv.y * fScount) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * fSintensity;\ncResult = cTextureScreen.rgb + clamp( fNintensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor =  vec4( cResult, cTextureScreen.a );\n}"},
 screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
 screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
-fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var b,c,e,g,f=2*Math.ceil(a*3)+1;if(f>25)f=25;g=(f-1)*0.5;c=Array(f);for(b=e=0;b<f;++b){c[b]=Math.exp(-((b-g)*(b-g))/(2*a*a));e+=c[b]}for(b=0;b<f;++b)c[b]/=e;return c}},Cube=function(a,b,c,e,g,f,h,k){function j(z,H,w,E,o,d,P,aa){var N,M,U=e||1,O=g||1,Y=U+1,W=O+1,J=o/2,X=d/2;o=o/U;var ha=d/O,Z=m.vertices.length;if(z=="x"&&H=="y"||z=="y"&&H=="x")N="z";else if(z=="x"&&H=="z"||z=="z"&&H=="x")N="y";
-else if(z=="z"&&H=="y"||z=="y"&&H=="z")N="x";for(M=0;M<W;M++)for(d=0;d<Y;d++){var ea=new THREE.Vector3;ea[z]=(d*o-J)*w;ea[H]=(M*ha-X)*E;ea[N]=P;m.vertices.push(new THREE.Vertex(ea))}for(M=0;M<O;M++)for(d=0;d<U;d++){m.faces.push(new THREE.Face4(d+Y*M+Z,d+Y*(M+1)+Z,d+1+Y*(M+1)+Z,d+1+Y*M+Z,null,aa));m.uvs.push([new THREE.UV(d/U,M/O),new THREE.UV(d/U,(M+1)/O),new THREE.UV((d+1)/U,(M+1)/O),new THREE.UV((d+1)/U,M/O)])}}THREE.Geometry.call(this);var m=this,p=a/2,x=b/2,t=c/2;h=h?-1:1;if(f!==undefined)if(f instanceof
-Array)this.materials=f;else{this.materials=[];for(var q=0;q<6;q++)this.materials.push([f])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(k!=undefined)for(var y in k)if(this.sides[y]!=undefined)this.sides[y]=k[y];this.sides.px&&j("z","y",1*h,-1,c,b,-p,this.materials[0]);this.sides.nx&&j("z","y",-1*h,-1,c,b,p,this.materials[1]);this.sides.py&&j("x","z",1*h,1,a,c,x,this.materials[2]);this.sides.ny&&j("x","z",1*h,-1,a,c,-x,this.materials[3]);this.sides.pz&&j("x",
-"y",1*h,-1,a,b,t,this.materials[4]);this.sides.nz&&j("x","y",-1*h,-1,a,b,-t,this.materials[5]);(function(){for(var z=[],H=[],w=0,E=m.vertices.length;w<E;w++){for(var o=m.vertices[w],d=false,P=0,aa=z.length;P<aa;P++){var N=z[P];if(o.position.x==N.position.x&&o.position.y==N.position.y&&o.position.z==N.position.z){H[w]=P;d=true;break}}if(!d){H[w]=z.length;z.push(new THREE.Vertex(o.position.clone()))}}w=0;for(E=m.faces.length;w<E;w++){o=m.faces[w];o.a=H[o.a];o.b=H[o.b];o.c=H[o.c];o.d=H[o.d]}m.vertices=
-z})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
-var Cylinder=function(a,b,c,e,g){function f(m,p,x){h.vertices.push(new THREE.Vertex(new THREE.Vector3(m,p,x)))}THREE.Geometry.call(this);var h=this,k=Math.PI,j;for(j=0;j<a;j++)f(Math.sin(2*k*j/a)*b,Math.cos(2*k*j/a)*b,0);for(j=0;j<a;j++)f(Math.sin(2*k*j/a)*c,Math.cos(2*k*j/a)*c,e);for(j=0;j<a;j++)h.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(c!=0){f(0,0,-g);for(j=a;j<a+a/2;j++)h.faces.push(new THREE.Face4(2*a,(2*j-2*a)%a,(2*j-2*a+1)%a,(2*j-2*a+2)%a))}if(b!=0){f(0,0,e+g);for(j=a+a/2;j<
+fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var b,c,e,g,f=2*Math.ceil(a*3)+1;if(f>25)f=25;g=(f-1)*0.5;c=Array(f);for(b=e=0;b<f;++b){c[b]=Math.exp(-((b-g)*(b-g))/(2*a*a));e+=c[b]}for(b=0;b<f;++b)c[b]/=e;return c}},Cube=function(a,b,c,e,g,f,h,k){function j(A,E,v,F,p,M,d,aa){var O,K,X=e||1,Q=g||1,U=X+1,V=Q+1,H=p/2,Y=M/2;p=p/X;var ea=M/Q,Z=m.vertices.length;if(A=="x"&&E=="y"||A=="y"&&E=="x")O="z";else if(A=="x"&&E=="z"||A=="z"&&E=="x")O="y";
+else if(A=="z"&&E=="y"||A=="y"&&E=="z")O="x";for(K=0;K<V;K++)for(M=0;M<U;M++){var fa=new THREE.Vector3;fa[A]=(M*p-H)*v;fa[E]=(K*ea-Y)*F;fa[O]=d;m.vertices.push(new THREE.Vertex(fa))}for(K=0;K<Q;K++)for(M=0;M<X;M++){m.faces.push(new THREE.Face4(M+U*K+Z,M+U*(K+1)+Z,M+1+U*(K+1)+Z,M+1+U*K+Z,null,aa));m.uvs.push([new THREE.UV(M/X,K/Q),new THREE.UV(M/X,(K+1)/Q),new THREE.UV((M+1)/X,(K+1)/Q),new THREE.UV((M+1)/X,K/Q)])}}THREE.Geometry.call(this);var m=this,q=a/2,w=b/2,u=c/2;h=h?-1:1;if(f!==undefined)if(f instanceof
+Array)this.materials=f;else{this.materials=[];for(var t=0;t<6;t++)this.materials.push([f])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(k!=undefined)for(var x in k)if(this.sides[x]!=undefined)this.sides[x]=k[x];this.sides.px&&j("z","y",1*h,-1,c,b,-q,this.materials[0]);this.sides.nx&&j("z","y",-1*h,-1,c,b,q,this.materials[1]);this.sides.py&&j("x","z",1*h,1,a,c,w,this.materials[2]);this.sides.ny&&j("x","z",1*h,-1,a,c,-w,this.materials[3]);this.sides.pz&&j("x",
+"y",1*h,-1,a,b,u,this.materials[4]);this.sides.nz&&j("x","y",-1*h,-1,a,b,-u,this.materials[5]);(function(){for(var A=[],E=[],v=0,F=m.vertices.length;v<F;v++){for(var p=m.vertices[v],M=false,d=0,aa=A.length;d<aa;d++){var O=A[d];if(p.position.x==O.position.x&&p.position.y==O.position.y&&p.position.z==O.position.z){E[v]=d;M=true;break}}if(!M){E[v]=A.length;A.push(new THREE.Vertex(p.position.clone()))}}v=0;for(F=m.faces.length;v<F;v++){p=m.faces[v];p.a=E[p.a];p.b=E[p.b];p.c=E[p.c];p.d=E[p.d]}m.vertices=
+A})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
+var Cylinder=function(a,b,c,e,g){function f(m,q,w){h.vertices.push(new THREE.Vertex(new THREE.Vector3(m,q,w)))}THREE.Geometry.call(this);var h=this,k=Math.PI,j;for(j=0;j<a;j++)f(Math.sin(2*k*j/a)*b,Math.cos(2*k*j/a)*b,0);for(j=0;j<a;j++)f(Math.sin(2*k*j/a)*c,Math.cos(2*k*j/a)*c,e);for(j=0;j<a;j++)h.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(c!=0){f(0,0,-g);for(j=a;j<a+a/2;j++)h.faces.push(new THREE.Face4(2*a,(2*j-2*a)%a,(2*j-2*a+1)%a,(2*j-2*a+2)%a))}if(b!=0){f(0,0,e+g);for(j=a+a/2;j<
 2*a;j++)h.faces.push(new THREE.Face4((2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
 2*a;j++)h.faces.push(new THREE.Face4((2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
 var Plane=function(a,b,c,e){THREE.Geometry.call(this);var g,f=a/2,h=b/2;c=c||1;e=e||1;var k=c+1,j=e+1;a=a/c;var m=b/e;for(g=0;g<j;g++)for(b=0;b<k;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-f,-(g*m-h),0)));for(g=0;g<e;g++)for(b=0;b<c;b++){this.faces.push(new THREE.Face4(b+k*g,b+k*(g+1),b+1+k*(g+1),b+1+k*g));this.uvs.push([new THREE.UV(b/c,g/e),new THREE.UV(b/c,(g+1)/e),new THREE.UV((b+1)/c,(g+1)/e),new THREE.UV((b+1)/c,g/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
 var Plane=function(a,b,c,e){THREE.Geometry.call(this);var g,f=a/2,h=b/2;c=c||1;e=e||1;var k=c+1,j=e+1;a=a/c;var m=b/e;for(g=0;g<j;g++)for(b=0;b<k;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-f,-(g*m-h),0)));for(g=0;g<e;g++)for(b=0;b<c;b++){this.faces.push(new THREE.Face4(b+k*g,b+k*(g+1),b+1+k*(g+1),b+1+k*g));this.uvs.push([new THREE.UV(b/c,g/e),new THREE.UV(b/c,(g+1)/e),new THREE.UV((b+1)/c,(g+1)/e),new THREE.UV((b+1)/c,g/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
-var Sphere=function(a,b,c){THREE.Geometry.call(this);var e,g=Math.PI,f=Math.max(3,b||8),h=Math.max(2,c||6);b=[];for(c=0;c<h+1;c++){e=c/h;var k=a*Math.cos(e*g),j=a*Math.sin(e*g),m=[],p=0;for(e=0;e<f;e++){var x=2*e/f,t=j*Math.sin(x*g);x=j*Math.cos(x*g);(c==0||c==h)&&e>0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,t)))-1);m.push(p)}b.push(m)}var q,y,z;g=b.length;for(c=0;c<g;c++){f=b[c].length;if(c>0)for(e=0;e<f;e++){m=e==f-1;h=b[c][m?0:e+1];k=b[c][m?f-1:e];j=b[c-1][m?f-1:e];m=b[c-1][m?
-0:e+1];t=c/(g-1);q=(c-1)/(g-1);y=(e+1)/f;x=e/f;p=new THREE.UV(1-y,t);t=new THREE.UV(1-x,t);x=new THREE.UV(1-x,q);var H=new THREE.UV(1-y,q);if(c<b.length-1){q=this.vertices[h].position.clone();y=this.vertices[k].position.clone();z=this.vertices[j].position.clone();q.normalize();y.normalize();z.normalize();this.faces.push(new THREE.Face3(h,k,j,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(z.x,z.y,z.z)]));this.uvs.push([p,t,x])}if(c>1){q=this.vertices[h].position.clone();
-y=this.vertices[j].position.clone();z=this.vertices[m].position.clone();q.normalize();y.normalize();z.normalize();this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(z.x,z.y,z.z)]));this.uvs.push([p,x,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
+var Sphere=function(a,b,c){THREE.Geometry.call(this);var e,g=Math.PI,f=Math.max(3,b||8),h=Math.max(2,c||6);b=[];for(c=0;c<h+1;c++){e=c/h;var k=a*Math.cos(e*g),j=a*Math.sin(e*g),m=[],q=0;for(e=0;e<f;e++){var w=2*e/f,u=j*Math.sin(w*g);w=j*Math.cos(w*g);(c==0||c==h)&&e>0||(q=this.vertices.push(new THREE.Vertex(new THREE.Vector3(w,k,u)))-1);m.push(q)}b.push(m)}var t,x,A;g=b.length;for(c=0;c<g;c++){f=b[c].length;if(c>0)for(e=0;e<f;e++){m=e==f-1;h=b[c][m?0:e+1];k=b[c][m?f-1:e];j=b[c-1][m?f-1:e];m=b[c-1][m?
+0:e+1];u=c/(g-1);t=(c-1)/(g-1);x=(e+1)/f;w=e/f;q=new THREE.UV(1-x,u);u=new THREE.UV(1-w,u);w=new THREE.UV(1-w,t);var E=new THREE.UV(1-x,t);if(c<b.length-1){t=this.vertices[h].position.clone();x=this.vertices[k].position.clone();A=this.vertices[j].position.clone();t.normalize();x.normalize();A.normalize();this.faces.push(new THREE.Face3(h,k,j,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([q,u,w])}if(c>1){t=this.vertices[h].position.clone();
+x=this.vertices[j].position.clone();A=this.vertices[m].position.clone();t.normalize();x.normalize();A.normalize();this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([q,w,E])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
 var Torus=function(a,b,c,e){this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){e=c/this.segmentsT*2*Math.PI;var g=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(e),(this.radius+this.tube*Math.cos(g))*Math.sin(e),this.tube*Math.sin(g))));a.push([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c=
 var Torus=function(a,b,c,e){this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){e=c/this.segmentsT*2*Math.PI;var g=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(e),(this.radius+this.tube*Math.cos(g))*Math.sin(e),this.tube*Math.sin(g))));a.push([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c=
 1;c<=this.segmentsT;++c){e=(this.segmentsT+1)*b+c;g=(this.segmentsT+1)*b+c-1;var f=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(e,g,f,h));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
 1;c<=this.segmentsT;++c){e=(this.segmentsT+1)*b+c;g=(this.segmentsT+1)*b+c-1;var f=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(e,g,f,h));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
-var Icosahedron=function(a){function b(x,t,q){var y=Math.sqrt(x*x+t*t+q*q);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(x/y,t/y,q/y)))-1}function c(x,t,q,y){y.faces.push(new THREE.Face3(x,t,q))}function e(x,t){var q=g.vertices[x].position,y=g.vertices[t].position;return b((q.x+y.x)/2,(q.y+y.y)/2,(q.z+y.z)/2)}var g=this,f=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0,
-1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,f);c(0,5,1,f);c(0,1,7,f);c(0,7,10,f);c(0,10,11,f);c(1,5,9,f);c(5,11,4,f);c(11,10,2,f);c(10,7,6,f);c(7,1,8,f);c(3,9,4,f);c(3,4,2,f);c(3,2,6,f);c(3,6,8,f);c(3,8,9,f);c(4,9,5,f);c(2,4,11,f);c(6,2,10,f);c(8,6,7,f);c(9,8,1,f);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var k in f.faces){var j=e(f.faces[k].a,f.faces[k].b),m=e(f.faces[k].b,f.faces[k].c),p=e(f.faces[k].c,f.faces[k].a);c(f.faces[k].a,j,p,h);c(f.faces[k].b,m,j,h);c(f.faces[k].c,
-p,m,h);c(j,m,p,h)}f.faces=h.faces}g.faces=f.faces;delete f;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
+var Icosahedron=function(a){function b(w,u,t){var x=Math.sqrt(w*w+u*u+t*t);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(w/x,u/x,t/x)))-1}function c(w,u,t,x){x.faces.push(new THREE.Face3(w,u,t))}function e(w,u){var t=g.vertices[w].position,x=g.vertices[u].position;return b((t.x+x.x)/2,(t.y+x.y)/2,(t.z+x.z)/2)}var g=this,f=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0,
+1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,f);c(0,5,1,f);c(0,1,7,f);c(0,7,10,f);c(0,10,11,f);c(1,5,9,f);c(5,11,4,f);c(11,10,2,f);c(10,7,6,f);c(7,1,8,f);c(3,9,4,f);c(3,4,2,f);c(3,2,6,f);c(3,6,8,f);c(3,8,9,f);c(4,9,5,f);c(2,4,11,f);c(6,2,10,f);c(8,6,7,f);c(9,8,1,f);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var k in f.faces){var j=e(f.faces[k].a,f.faces[k].b),m=e(f.faces[k].b,f.faces[k].c),q=e(f.faces[k].c,f.faces[k].a);c(f.faces[k].a,j,q,h);c(f.faces[k].b,m,j,h);c(f.faces[k].c,
+q,m,h);c(j,m,q,h)}f.faces=h.faces}g.faces=f.faces;delete f;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
 function LathedObject(a,b,c){THREE.Geometry.call(this);b=b||12;c=c||2*Math.PI;b=c/b;for(var e=[],g=[],f=[],h=[],k=0;k<a.length;k++){this.vertices.push(new THREE.Vertex(a[k]));g[k]=this.vertices.length-1;e[k]=new THREE.Vector3(a[k].x,a[k].y,a[k].z)}for(var j=THREE.Matrix4.rotationZMatrix(b),m=0;m<=c+0.0010;m+=b){for(k=0;k<e.length;k++)if(m<c){e[k]=j.multiplyVector3(e[k].clone());this.vertices.push(new THREE.Vertex(e[k]));f[k]=this.vertices.length-1}else f=h;if(m==0)h=g;for(k=0;k<g.length-1;k++){this.faces.push(new THREE.Face4(f[k],
 function LathedObject(a,b,c){THREE.Geometry.call(this);b=b||12;c=c||2*Math.PI;b=c/b;for(var e=[],g=[],f=[],h=[],k=0;k<a.length;k++){this.vertices.push(new THREE.Vertex(a[k]));g[k]=this.vertices.length-1;e[k]=new THREE.Vector3(a[k].x,a[k].y,a[k].z)}for(var j=THREE.Matrix4.rotationZMatrix(b),m=0;m<=c+0.0010;m+=b){for(k=0;k<e.length;k++)if(m<c){e[k]=j.multiplyVector3(e[k].clone());this.vertices.push(new THREE.Vertex(e[k]));f[k]=this.vertices.length-1}else f=h;if(m==0)h=g;for(k=0;k<g.length-1;k++){this.faces.push(new THREE.Face4(f[k],
 f[k+1],g[k+1],g[k]));this.uvs.push([new THREE.UV(m/c,k/a.length),new THREE.UV(m/c,(k+1)/a.length),new THREE.UV((m-b)/c,(k+1)/a.length),new THREE.UV((m-b)/c,k/a.length)])}g=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
 f[k+1],g[k+1],g[k]));this.uvs.push([new THREE.UV(m/c,k/a.length),new THREE.UV(m/c,(k+1)/a.length),new THREE.UV((m-b)/c,(k+1)/a.length),new THREE.UV((m-b)/c,k/a.length)])}g=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
 THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b];this.init=function(c){this.isolation=80;this.size=c;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=true;this.maxCount=4096;this.count=
 THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b];this.init=function(c){this.isolation=80;this.size=c;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=true;this.maxCount=4096;this.count=
-0;this.hasNormal=this.hasPos=false;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(c,e,g){return c+(e-c)*g};this.VIntX=function(c,e,g,f,h,k,j,m,p,x){h=(h-p)/(x-p);p=this.normal_cache;e[f]=k+h*this.delta;e[f+1]=j;e[f+2]=m;g[f]=this.lerp(p[c],p[c+3],h);g[f+1]=this.lerp(p[c+1],p[c+4],h);g[f+2]=this.lerp(p[c+2],p[c+5],h)};this.VIntY=function(c,e,g,f,h,k,j,m,p,x){h=(h-p)/(x-p);p=this.normal_cache;e[f]=k;e[f+1]=j+h*this.delta;e[f+
-2]=m;e=c+this.yd*3;g[f]=this.lerp(p[c],p[e],h);g[f+1]=this.lerp(p[c+1],p[e+1],h);g[f+2]=this.lerp(p[c+2],p[e+2],h)};this.VIntZ=function(c,e,g,f,h,k,j,m,p,x){h=(h-p)/(x-p);p=this.normal_cache;e[f]=k;e[f+1]=j;e[f+2]=m+h*this.delta;e=c+this.zd*3;g[f]=this.lerp(p[c],p[e],h);g[f+1]=this.lerp(p[c+1],p[e+1],h);g[f+2]=this.lerp(p[c+2],p[e+2],h)};this.compNorm=function(c){var e=c*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[c-1]-this.field[c+1];this.normal_cache[e+1]=this.field[c-this.yd]-
-this.field[c+this.yd];this.normal_cache[e+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,e,g,f,h,k){var j=f+1,m=f+this.yd,p=f+this.zd,x=j+this.yd,t=j+this.zd,q=f+this.yd+this.zd,y=j+this.yd+this.zd,z=0,H=this.field[f],w=this.field[j],E=this.field[m],o=this.field[x],d=this.field[p],P=this.field[t],aa=this.field[q],N=this.field[y];if(H<h)z|=1;if(w<h)z|=2;if(E<h)z|=8;if(o<h)z|=4;if(d<h)z|=16;if(P<h)z|=32;if(aa<h)z|=128;if(N<h)z|=64;var M=THREE.edgeTable[z];if(M==0)return 0;
-var U=this.delta,O=c+U,Y=e+U;U=g+U;if(M&1){this.compNorm(f);this.compNorm(j);this.VIntX(f*3,this.vlist,this.nlist,0,h,c,e,g,H,w)}if(M&2){this.compNorm(j);this.compNorm(x);this.VIntY(j*3,this.vlist,this.nlist,3,h,O,e,g,w,o)}if(M&4){this.compNorm(m);this.compNorm(x);this.VIntX(m*3,this.vlist,this.nlist,6,h,c,Y,g,E,o)}if(M&8){this.compNorm(f);this.compNorm(m);this.VIntY(f*3,this.vlist,this.nlist,9,h,c,e,g,H,E)}if(M&16){this.compNorm(p);this.compNorm(t);this.VIntX(p*3,this.vlist,this.nlist,12,h,c,e,U,
-d,P)}if(M&32){this.compNorm(t);this.compNorm(y);this.VIntY(t*3,this.vlist,this.nlist,15,h,O,e,U,P,N)}if(M&64){this.compNorm(q);this.compNorm(y);this.VIntX(q*3,this.vlist,this.nlist,18,h,c,Y,U,aa,N)}if(M&128){this.compNorm(p);this.compNorm(q);this.VIntY(p*3,this.vlist,this.nlist,21,h,c,e,U,d,aa)}if(M&256){this.compNorm(f);this.compNorm(p);this.VIntZ(f*3,this.vlist,this.nlist,24,h,c,e,g,H,d)}if(M&512){this.compNorm(j);this.compNorm(t);this.VIntZ(j*3,this.vlist,this.nlist,27,h,O,e,g,w,P)}if(M&1024){this.compNorm(x);
-this.compNorm(y);this.VIntZ(x*3,this.vlist,this.nlist,30,h,O,Y,g,o,N)}if(M&2048){this.compNorm(m);this.compNorm(q);this.VIntZ(m*3,this.vlist,this.nlist,33,h,c,Y,g,E,aa)}z<<=4;for(h=f=0;THREE.triTable[z+h]!=-1;){c=z+h;e=c+1;g=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[e],3*THREE.triTable[g],k);h+=3;f++}return f};this.posnormtriv=function(c,e,g,f,h,k){var j=this.count*3;this.positionArray[j]=c[g];this.positionArray[j+1]=c[g+1];this.positionArray[j+2]=c[g+2];this.positionArray[j+
+0;this.hasNormal=this.hasPos=false;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(c,e,g){return c+(e-c)*g};this.VIntX=function(c,e,g,f,h,k,j,m,q,w){h=(h-q)/(w-q);q=this.normal_cache;e[f]=k+h*this.delta;e[f+1]=j;e[f+2]=m;g[f]=this.lerp(q[c],q[c+3],h);g[f+1]=this.lerp(q[c+1],q[c+4],h);g[f+2]=this.lerp(q[c+2],q[c+5],h)};this.VIntY=function(c,e,g,f,h,k,j,m,q,w){h=(h-q)/(w-q);q=this.normal_cache;e[f]=k;e[f+1]=j+h*this.delta;e[f+
+2]=m;e=c+this.yd*3;g[f]=this.lerp(q[c],q[e],h);g[f+1]=this.lerp(q[c+1],q[e+1],h);g[f+2]=this.lerp(q[c+2],q[e+2],h)};this.VIntZ=function(c,e,g,f,h,k,j,m,q,w){h=(h-q)/(w-q);q=this.normal_cache;e[f]=k;e[f+1]=j;e[f+2]=m+h*this.delta;e=c+this.zd*3;g[f]=this.lerp(q[c],q[e],h);g[f+1]=this.lerp(q[c+1],q[e+1],h);g[f+2]=this.lerp(q[c+2],q[e+2],h)};this.compNorm=function(c){var e=c*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[c-1]-this.field[c+1];this.normal_cache[e+1]=this.field[c-this.yd]-
+this.field[c+this.yd];this.normal_cache[e+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,e,g,f,h,k){var j=f+1,m=f+this.yd,q=f+this.zd,w=j+this.yd,u=j+this.zd,t=f+this.yd+this.zd,x=j+this.yd+this.zd,A=0,E=this.field[f],v=this.field[j],F=this.field[m],p=this.field[w],M=this.field[q],d=this.field[u],aa=this.field[t],O=this.field[x];if(E<h)A|=1;if(v<h)A|=2;if(F<h)A|=8;if(p<h)A|=4;if(M<h)A|=16;if(d<h)A|=32;if(aa<h)A|=128;if(O<h)A|=64;var K=THREE.edgeTable[A];if(K==0)return 0;
+var X=this.delta,Q=c+X,U=e+X;X=g+X;if(K&1){this.compNorm(f);this.compNorm(j);this.VIntX(f*3,this.vlist,this.nlist,0,h,c,e,g,E,v)}if(K&2){this.compNorm(j);this.compNorm(w);this.VIntY(j*3,this.vlist,this.nlist,3,h,Q,e,g,v,p)}if(K&4){this.compNorm(m);this.compNorm(w);this.VIntX(m*3,this.vlist,this.nlist,6,h,c,U,g,F,p)}if(K&8){this.compNorm(f);this.compNorm(m);this.VIntY(f*3,this.vlist,this.nlist,9,h,c,e,g,E,F)}if(K&16){this.compNorm(q);this.compNorm(u);this.VIntX(q*3,this.vlist,this.nlist,12,h,c,e,X,
+M,d)}if(K&32){this.compNorm(u);this.compNorm(x);this.VIntY(u*3,this.vlist,this.nlist,15,h,Q,e,X,d,O)}if(K&64){this.compNorm(t);this.compNorm(x);this.VIntX(t*3,this.vlist,this.nlist,18,h,c,U,X,aa,O)}if(K&128){this.compNorm(q);this.compNorm(t);this.VIntY(q*3,this.vlist,this.nlist,21,h,c,e,X,M,aa)}if(K&256){this.compNorm(f);this.compNorm(q);this.VIntZ(f*3,this.vlist,this.nlist,24,h,c,e,g,E,M)}if(K&512){this.compNorm(j);this.compNorm(u);this.VIntZ(j*3,this.vlist,this.nlist,27,h,Q,e,g,v,d)}if(K&1024){this.compNorm(w);
+this.compNorm(x);this.VIntZ(w*3,this.vlist,this.nlist,30,h,Q,U,g,p,O)}if(K&2048){this.compNorm(m);this.compNorm(t);this.VIntZ(m*3,this.vlist,this.nlist,33,h,c,U,g,F,aa)}A<<=4;for(h=f=0;THREE.triTable[A+h]!=-1;){c=A+h;e=c+1;g=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[e],3*THREE.triTable[g],k);h+=3;f++}return f};this.posnormtriv=function(c,e,g,f,h,k){var j=this.count*3;this.positionArray[j]=c[g];this.positionArray[j+1]=c[g+1];this.positionArray[j+2]=c[g+2];this.positionArray[j+
 3]=c[f];this.positionArray[j+4]=c[f+1];this.positionArray[j+5]=c[f+2];this.positionArray[j+6]=c[h];this.positionArray[j+7]=c[h+1];this.positionArray[j+8]=c[h+2];this.normalArray[j]=e[g];this.normalArray[j+1]=e[g+1];this.normalArray[j+2]=e[g+2];this.normalArray[j+3]=e[f];this.normalArray[j+4]=e[f+1];this.normalArray[j+5]=e[f+2];this.normalArray[j+6]=e[h];this.normalArray[j+7]=e[h+1];this.normalArray[j+8]=e[h+2];this.hasNormal=this.hasPos=true;this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=
 3]=c[f];this.positionArray[j+4]=c[f+1];this.positionArray[j+5]=c[f+2];this.positionArray[j+6]=c[h];this.positionArray[j+7]=c[h+1];this.positionArray[j+8]=c[h+2];this.normalArray[j]=e[g];this.normalArray[j+1]=e[g+1];this.normalArray[j+2]=e[g+2];this.normalArray[j+3]=e[f];this.normalArray[j+4]=e[f+1];this.normalArray[j+5]=e[f+2];this.normalArray[j+6]=e[h];this.normalArray[j+7]=e[h+1];this.normalArray[j+8]=e[h+2];this.hasNormal=this.hasPos=true;this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=
-function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(c){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;c(this)}};this.addBall=function(c,e,g,f,h){var k=this.size*Math.sqrt(f/h),j=g*this.size,m=e*this.size,p=c*this.size,x=Math.floor(j-k);if(x<1)x=1;j=Math.floor(j+k);if(j>this.size-1)j=this.size-1;var t=Math.floor(m-k);if(t<1)t=1;m=Math.floor(m+k);if(m>this.size-1)m=this.size-1;var q=Math.floor(p-k);if(q<1)q=1;k=Math.floor(p+k);
-if(k>this.size-1)k=this.size-1;var y,z,H,w,E,o;for(x=x;x<j;x++){p=this.size2*x;z=x/this.size-g;E=z*z;for(z=t;z<m;z++){H=p+this.size*z;y=z/this.size-e;o=y*y;for(y=q;y<k;y++){w=y/this.size-c;w=f/(1.0E-6+w*w+o+E)-h;if(w>0)this.field[H+y]+=w}}}};this.addPlaneX=function(c,e){var g,f,h,k,j,m=this.size,p=this.yd,x=this.zd,t=this.field,q=m*Math.sqrt(c/e);if(q>m)q=m;for(g=0;g<q;g++){f=g/m;f=f*f;k=c/(1.0E-4+f)-e;if(k>0)for(f=0;f<m;f++){j=g+f*p;for(h=0;h<m;h++)t[x*h+j]+=k}}};this.addPlaneY=function(c,e){var g,
-f,h,k,j,m,p=this.size,x=this.yd,t=this.zd,q=this.field,y=p*Math.sqrt(c/e);if(y>p)y=p;for(f=0;f<y;f++){g=f/p;g=g*g;k=c/(1.0E-4+g)-e;if(k>0){j=f*x;for(g=0;g<p;g++){m=j+g;for(h=0;h<p;h++)q[t*h+m]+=k}}}};this.addPlaneZ=function(c,e){var g,f,h,k,j,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/e);if(dist>size)dist=size;for(h=0;h<dist;h++){g=h/size;g=g*g;k=c/(1.0E-4+g)-e;if(k>0){j=zd*h;for(f=0;f<size;f++){m=j+f*yd;for(g=0;g<size;g++)field[m+g]+=k}}}};this.reset=function(){var c;
-for(c=0;c<this.size3;c++){this.normal_cache[c*3]=0;this.field[c]=0}};this.render=function(c){this.begin();var e,g,f,h,k,j,m,p,x,t=this.size-2;for(h=1;h<t;h++){x=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(f=1;f<t;f++){p=x+this.size*f;j=(f-this.halfsize)/this.halfsize;for(g=1;g<t;g++){k=(g-this.halfsize)/this.halfsize;e=p+g;this.polygonize(k,j,m,e,this.isolation,c)}}}this.end(c)};this.generateGeometry=function(){var c=0,e=new THREE.Geometry;this.render(function(g){var f,h,k,j,m,p,x,t;for(f=
-0;f<g.count;f++){m=f*3;x=m+1;t=m+2;h=g.positionArray[m];k=g.positionArray[x];j=g.positionArray[t];p=new THREE.Vector3(h,k,j);h=g.normalArray[m];k=g.normalArray[x];j=g.normalArray[t];m=new THREE.Vector3(h,k,j);m.normalize();m=new THREE.Vertex(p,m);e.vertices.push(m)}nfaces=g.count/3;for(f=0;f<nfaces;f++){m=(c+f)*3;x=m+1;t=m+2;p=e.vertices[m].normal;h=e.vertices[x].normal;k=e.vertices[t].normal;m=new THREE.Face3(m,x,t,[p,h,k]);e.faces.push(m)}c+=nfaces;g.count=0});e.sortFacesByMaterial();return e};
+function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(c){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;c(this)}};this.addBall=function(c,e,g,f,h){var k=this.size*Math.sqrt(f/h),j=g*this.size,m=e*this.size,q=c*this.size,w=Math.floor(j-k);if(w<1)w=1;j=Math.floor(j+k);if(j>this.size-1)j=this.size-1;var u=Math.floor(m-k);if(u<1)u=1;m=Math.floor(m+k);if(m>this.size-1)m=this.size-1;var t=Math.floor(q-k);if(t<1)t=1;k=Math.floor(q+k);
+if(k>this.size-1)k=this.size-1;var x,A,E,v,F,p;for(w=w;w<j;w++){q=this.size2*w;A=w/this.size-g;F=A*A;for(A=u;A<m;A++){E=q+this.size*A;x=A/this.size-e;p=x*x;for(x=t;x<k;x++){v=x/this.size-c;v=f/(1.0E-6+v*v+p+F)-h;if(v>0)this.field[E+x]+=v}}}};this.addPlaneX=function(c,e){var g,f,h,k,j,m=this.size,q=this.yd,w=this.zd,u=this.field,t=m*Math.sqrt(c/e);if(t>m)t=m;for(g=0;g<t;g++){f=g/m;f=f*f;k=c/(1.0E-4+f)-e;if(k>0)for(f=0;f<m;f++){j=g+f*q;for(h=0;h<m;h++)u[w*h+j]+=k}}};this.addPlaneY=function(c,e){var g,
+f,h,k,j,m,q=this.size,w=this.yd,u=this.zd,t=this.field,x=q*Math.sqrt(c/e);if(x>q)x=q;for(f=0;f<x;f++){g=f/q;g=g*g;k=c/(1.0E-4+g)-e;if(k>0){j=f*w;for(g=0;g<q;g++){m=j+g;for(h=0;h<q;h++)t[u*h+m]+=k}}}};this.addPlaneZ=function(c,e){var g,f,h,k,j,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/e);if(dist>size)dist=size;for(h=0;h<dist;h++){g=h/size;g=g*g;k=c/(1.0E-4+g)-e;if(k>0){j=zd*h;for(f=0;f<size;f++){m=j+f*yd;for(g=0;g<size;g++)field[m+g]+=k}}}};this.reset=function(){var c;
+for(c=0;c<this.size3;c++){this.normal_cache[c*3]=0;this.field[c]=0}};this.render=function(c){this.begin();var e,g,f,h,k,j,m,q,w,u=this.size-2;for(h=1;h<u;h++){w=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(f=1;f<u;f++){q=w+this.size*f;j=(f-this.halfsize)/this.halfsize;for(g=1;g<u;g++){k=(g-this.halfsize)/this.halfsize;e=q+g;this.polygonize(k,j,m,e,this.isolation,c)}}}this.end(c)};this.generateGeometry=function(){var c=0,e=new THREE.Geometry;this.render(function(g){var f,h,k,j,m,q,w,u;for(f=
+0;f<g.count;f++){m=f*3;w=m+1;u=m+2;h=g.positionArray[m];k=g.positionArray[w];j=g.positionArray[u];q=new THREE.Vector3(h,k,j);h=g.normalArray[m];k=g.normalArray[w];j=g.normalArray[u];m=new THREE.Vector3(h,k,j);m.normalize();m=new THREE.Vertex(q,m);e.vertices.push(m)}nfaces=g.count/3;for(f=0;f<nfaces;f++){m=(c+f)*3;w=m+1;u=m+2;q=e.vertices[m].normal;h=e.vertices[w].normal;k=e.vertices[u].normal;m=new THREE.Face3(m,w,u,[q,h,k]);e.faces.push(m)}c+=nfaces;g.count=0});e.sortFacesByMaterial();return e};
 this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
 this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
 THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
 THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
 1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
 1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
@@ -314,23 +314,23 @@ THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement
 b},loadAsciiOld:function(a,b){var c=document.createElement("script");c.type="text/javascript";c.onload=b;c.src=a;document.getElementsByTagName("head")[0].appendChild(c)},loadAscii:function(a){var b=a.model,c=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);b.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,c,e)};b.postMessage(a)},loadBinary:function(a){var b=a.model,c=a.callback,e=a.texture_path?a.texture_path:
 b},loadAsciiOld:function(a,b){var c=document.createElement("script");c.type="text/javascript";c.onload=b;c.src=a;document.getElementsByTagName("head")[0].appendChild(c)},loadAscii:function(a){var b=a.model,c=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);b.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,c,e)};b.postMessage(a)},loadBinary:function(a){var b=a.model,c=a.callback,e=a.texture_path?a.texture_path:
 THREE.Loader.prototype.extractUrlbase(b),g=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,c,g,e,f)};b.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,c,e,g,f){var h=new XMLHttpRequest,k=e+"/"+a,j=0;
 THREE.Loader.prototype.extractUrlbase(b),g=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,c,g,e,f)};b.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,c,e,g,f){var h=new XMLHttpRequest,k=e+"/"+a,j=0;
 h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,c,g,b):alert("Couldn't load ["+k+"] ["+h.status+"]");else if(h.readyState==3){if(f){if(j==0)j=h.getResponseHeader("Content-Length");f({total:j,loaded:h.responseText.length})}}else if(h.readyState==2)j=h.getResponseHeader("Content-Length")};h.open("GET",k,true);h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)},
 h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,c,g,b):alert("Couldn't load ["+k+"] ["+h.status+"]");else if(h.readyState==3){if(f){if(j==0)j=h.getResponseHeader("Content-Length");f({total:j,loaded:h.responseText.length})}}else if(h.readyState==2)j=h.getResponseHeader("Content-Length")};h.open("GET",k,true);h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)},
-createBinModel:function(a,b,c,e){var g=function(f){function h(B,K){var I=p(B,K),Q=p(B,K+1),da=p(B,K+2),V=p(B,K+3),ka=(V<<1&255|da>>7)-127;I=(da&127)<<16|Q<<8|I;if(I==0&&ka==-127)return 0;return(1-2*(V>>7))*(1+I*Math.pow(2,-23))*Math.pow(2,ka)}function k(B,K){var I=p(B,K),Q=p(B,K+1),da=p(B,K+2);return(p(B,K+3)<<24)+(da<<16)+(Q<<8)+I}function j(B,K){var I=p(B,K);return(p(B,K+1)<<8)+I}function m(B,K){var I=p(B,K);return I>127?I-256:I}function p(B,K){return B.charCodeAt(K)&255}function x(B){var K,I,Q;
-K=k(a,B);I=k(a,B+aa);Q=k(a,B+N);B=j(a,B+M);THREE.Loader.prototype.f3(w,K,I,Q,B)}function t(B){var K,I,Q,da,V,ka;K=k(a,B);I=k(a,B+aa);Q=k(a,B+N);da=j(a,B+M);V=k(a,B+U);ka=k(a,B+O);B=k(a,B+Y);THREE.Loader.prototype.f3n(w,d,K,I,Q,da,V,ka,B)}function q(B){var K,I,Q,da;K=k(a,B);I=k(a,B+W);Q=k(a,B+J);da=k(a,B+X);B=j(a,B+ha);THREE.Loader.prototype.f4(w,K,I,Q,da,B)}function y(B){var K,I,Q,da,V,ka,pa,ua;K=k(a,B);I=k(a,B+W);Q=k(a,B+J);da=k(a,B+X);V=j(a,B+ha);ka=k(a,B+Z);pa=k(a,B+ea);ua=k(a,B+l);B=k(a,B+v);
-THREE.Loader.prototype.f4n(w,d,K,I,Q,da,V,ka,pa,ua,B)}function z(B){var K,I;K=k(a,B);I=k(a,B+A);B=k(a,B+u);THREE.Loader.prototype.uv3(w.uvs,P[K*2],P[K*2+1],P[I*2],P[I*2+1],P[B*2],P[B*2+1])}function H(B){var K,I,Q;K=k(a,B);I=k(a,B+n);Q=k(a,B+F);B=k(a,B+L);THREE.Loader.prototype.uv4(w.uvs,P[K*2],P[K*2+1],P[I*2],P[I*2+1],P[Q*2],P[Q*2+1],P[B*2],P[B*2+1])}var w=this,E=0,o,d=[],P=[],aa,N,M,U,O,Y,W,J,X,ha,Z,ea,l,v,A,u,n,F,L,G,D,C,R,ba,ga;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,
-e,f);o={signature:a.substr(E,8),header_bytes:p(a,E+8),vertex_coordinate_bytes:p(a,E+9),normal_coordinate_bytes:p(a,E+10),uv_coordinate_bytes:p(a,E+11),vertex_index_bytes:p(a,E+12),normal_index_bytes:p(a,E+13),uv_index_bytes:p(a,E+14),material_index_bytes:p(a,E+15),nvertices:k(a,E+16),nnormals:k(a,E+16+4),nuvs:k(a,E+16+8),ntri_flat:k(a,E+16+12),ntri_smooth:k(a,E+16+16),ntri_flat_uv:k(a,E+16+20),ntri_smooth_uv:k(a,E+16+24),nquad_flat:k(a,E+16+28),nquad_smooth:k(a,E+16+32),nquad_flat_uv:k(a,E+16+36),
-nquad_smooth_uv:k(a,E+16+40)};E+=o.header_bytes;aa=o.vertex_index_bytes;N=o.vertex_index_bytes*2;M=o.vertex_index_bytes*3;U=o.vertex_index_bytes*3+o.material_index_bytes;O=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;Y=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;W=o.vertex_index_bytes;J=o.vertex_index_bytes*2;X=o.vertex_index_bytes*3;ha=o.vertex_index_bytes*4;Z=o.vertex_index_bytes*4+o.material_index_bytes;ea=o.vertex_index_bytes*4+o.material_index_bytes+
-o.normal_index_bytes;l=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*2;v=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*3;A=o.uv_index_bytes;u=o.uv_index_bytes*2;n=o.uv_index_bytes;F=o.uv_index_bytes*2;L=o.uv_index_bytes*3;f=o.vertex_index_bytes*3+o.material_index_bytes;ga=o.vertex_index_bytes*4+o.material_index_bytes;G=o.ntri_flat*f;D=o.ntri_smooth*(f+o.normal_index_bytes*3);C=o.ntri_flat_uv*(f+o.uv_index_bytes*3);R=o.ntri_smooth_uv*(f+o.normal_index_bytes*
-3+o.uv_index_bytes*3);ba=o.nquad_flat*ga;f=o.nquad_smooth*(ga+o.normal_index_bytes*4);ga=o.nquad_flat_uv*(ga+o.uv_index_bytes*4);E+=function(B){var K,I,Q,da=o.vertex_coordinate_bytes*3,V=B+o.nvertices*da;for(B=B;B<V;B+=da){K=h(a,B);I=h(a,B+o.vertex_coordinate_bytes);Q=h(a,B+o.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(w,K,I,Q)}return o.nvertices*da}(E);E+=function(B){var K,I,Q,da=o.normal_coordinate_bytes*3,V=B+o.nnormals*da;for(B=B;B<V;B+=da){K=m(a,B);I=m(a,B+o.normal_coordinate_bytes);
-Q=m(a,B+o.normal_coordinate_bytes*2);d.push(K/127,I/127,Q/127)}return o.nnormals*da}(E);E+=function(B){var K,I,Q=o.uv_coordinate_bytes*2,da=B+o.nuvs*Q;for(B=B;B<da;B+=Q){K=h(a,B);I=h(a,B+o.uv_coordinate_bytes);P.push(K,I)}return o.nuvs*Q}(E);E=E;G=E+G;D=G+D;C=D+C;R=C+R;ba=R+ba;f=ba+f;ga=f+ga;(function(B){var K,I=o.vertex_index_bytes*3+o.material_index_bytes,Q=I+o.uv_index_bytes*3,da=B+o.ntri_flat_uv*Q;for(K=B;K<da;K+=Q){x(K);z(K+I)}return da-B})(D);(function(B){var K,I=o.vertex_index_bytes*3+o.material_index_bytes+
-o.normal_index_bytes*3,Q=I+o.uv_index_bytes*3,da=B+o.ntri_smooth_uv*Q;for(K=B;K<da;K+=Q){t(K);z(K+I)}return da-B})(C);(function(B){var K,I=o.vertex_index_bytes*4+o.material_index_bytes,Q=I+o.uv_index_bytes*4,da=B+o.nquad_flat_uv*Q;for(K=B;K<da;K+=Q){q(K);H(K+I)}return da-B})(f);(function(B){var K,I=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,Q=I+o.uv_index_bytes*4,da=B+o.nquad_smooth_uv*Q;for(K=B;K<da;K+=Q){y(K);H(K+I)}return da-B})(ga);(function(B){var K,I=o.vertex_index_bytes*
-3+o.material_index_bytes,Q=B+o.ntri_flat*I;for(K=B;K<Q;K+=I)x(K);return Q-B})(E);(function(B){var K,I=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*3,Q=B+o.ntri_smooth*I;for(K=B;K<Q;K+=I)t(K);return Q-B})(G);(function(B){var K,I=o.vertex_index_bytes*4+o.material_index_bytes,Q=B+o.nquad_flat*I;for(K=B;K<Q;K+=I)q(K);return Q-B})(R);(function(B){var K,I=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,Q=B+o.nquad_smooth*I;for(K=B;K<Q;K+=I)y(K);return Q-B})(ba);
-this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g(c))},createModel:function(a,b,c){var e=function(g){var f=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,a.materials,g);(function(){var h,k,j,m,p;h=0;for(k=a.vertices.length;h<k;h+=3){j=a.vertices[h];m=a.vertices[h+1];p=a.vertices[h+2];THREE.Loader.prototype.v(f,j,m,p)}if(a.colors){h=0;for(k=a.colors.length;h<k;h+=3){j=a.colors[h];m=
-a.colors[h+1];p=a.colors[h+2];THREE.Loader.prototype.vc(f,j,m,p)}}})();(function(){function h(y,z){THREE.Loader.prototype.f3(f,y[z],y[z+1],y[z+2],y[z+3])}function k(y,z){THREE.Loader.prototype.f3n(f,a.normals,y[z],y[z+1],y[z+2],y[z+3],y[z+4],y[z+5],y[z+6])}function j(y,z){THREE.Loader.prototype.f4(f,y[z],y[z+1],y[z+2],y[z+3],y[z+4])}function m(y,z){THREE.Loader.prototype.f4n(f,a.normals,y[z],y[z+1],y[z+2],y[z+3],y[z+4],y[z+5],y[z+6],y[z+7],y[z+8])}function p(y,z){var H,w,E,o,d,P,aa,N,M;H=y[z];w=y[z+
-1];E=y[z+2];o=a.uvs[H*2];aa=a.uvs[H*2+1];d=a.uvs[w*2];N=a.uvs[w*2+1];P=a.uvs[E*2];M=a.uvs[E*2+1];THREE.Loader.prototype.uv3(f.uvs,o,aa,d,N,P,M);if(a.uvs2){o=a.uvs2[H*2];aa=a.uvs2[H*2+1];d=a.uvs2[w*2];N=a.uvs2[w*2+1];P=a.uvs2[E*2];M=a.uvs2[E*2+1];THREE.Loader.prototype.uv3(f.uvs2,o,1-aa,d,1-N,P,1-M)}}function x(y,z){var H,w,E,o,d,P,aa,N,M,U,O,Y;H=y[z];w=y[z+1];E=y[z+2];o=y[z+3];d=a.uvs[H*2];M=a.uvs[H*2+1];P=a.uvs[w*2];U=a.uvs[w*2+1];aa=a.uvs[E*2];O=a.uvs[E*2+1];N=a.uvs[o*2];Y=a.uvs[o*2+1];THREE.Loader.prototype.uv4(f.uvs,
-d,M,P,U,aa,O,N,Y);if(a.uvs2){d=a.uvs2[H*2];M=a.uvs2[H*2+1];P=a.uvs2[w*2];U=a.uvs2[w*2+1];aa=a.uvs2[E*2];O=a.uvs2[E*2+1];N=a.uvs2[o*2];Y=a.uvs2[o*2+1];THREE.Loader.prototype.uv4(f.uvs2,d,1-M,P,1-U,aa,1-O,N,1-Y)}}var t,q;t=0;for(q=a.triangles_uv.length;t<q;t+=7){h(a.triangles_uv,t);p(a.triangles_uv,t+4)}t=0;for(q=a.triangles_n_uv.length;t<q;t+=10){k(a.triangles_n_uv,t);p(a.triangles_n_uv,t+7)}t=0;for(q=a.quads_uv.length;t<q;t+=9){j(a.quads_uv,t);x(a.quads_uv,t+5)}t=0;for(q=a.quads_n_uv.length;t<q;t+=
-13){m(a.quads_n_uv,t);x(a.quads_n_uv,t+9)}t=0;for(q=a.triangles.length;t<q;t+=4)h(a.triangles,t);t=0;for(q=a.triangles_n.length;t<q;t+=7)k(a.triangles_n,t);t=0;for(q=a.quads.length;t<q;t+=5)j(a.quads,t);t=0;for(q=a.quads_n.length;t<q;t+=9)m(a.quads_n,t)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(c))},v:function(a,b,c,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))},vc:function(a,
-b,c,e){var g=new THREE.Color(16777215);g.setRGB(b,c,e);a.colors.push(g)},f3:function(a,b,c,e,g){a.faces.push(new THREE.Face3(b,c,e,null,a.materials[g]))},f4:function(a,b,c,e,g,f){a.faces.push(new THREE.Face4(b,c,e,g,null,a.materials[f]))},f3n:function(a,b,c,e,g,f,h,k,j){f=a.materials[f];var m=b[k*3],p=b[k*3+1];k=b[k*3+2];var x=b[j*3],t=b[j*3+1];j=b[j*3+2];a.faces.push(new THREE.Face3(c,e,g,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(m,p,k),new THREE.Vector3(x,t,j)],f))},f4n:function(a,
-b,c,e,g,f,h,k,j,m,p){h=a.materials[h];var x=b[j*3],t=b[j*3+1];j=b[j*3+2];var q=b[m*3],y=b[m*3+1];m=b[m*3+2];var z=b[p*3],H=b[p*3+1];p=b[p*3+2];a.faces.push(new THREE.Face4(c,e,g,f,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(x,t,j),new THREE.Vector3(q,y,m),new THREE.Vector3(z,H,p)],h))},uv3:function(a,b,c,e,g,f,h){var k=[];k.push(new THREE.UV(b,c));k.push(new THREE.UV(e,g));k.push(new THREE.UV(f,h));a.push(k)},uv4:function(a,b,c,e,g,f,h,k,j){var m=[];m.push(new THREE.UV(b,c));m.push(new THREE.UV(e,
-g));m.push(new THREE.UV(f,h));m.push(new THREE.UV(k,j));a.push(m)},init_materials:function(a,b,c){a.materials=[];for(var e=0;e<b.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(b[e],c)]},createMaterial:function(a,b){function c(k){k=Math.log(k)/Math.LN2;return Math.floor(k)==k}function e(k,j){var m=new Image;m.onload=function(){if(!c(this.width)||!c(this.height)){var p=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),x=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));k.image.width=
-p;k.image.height=x;k.image.getContext("2d").drawImage(this,0,0,p,x)}else k.image=this;k.image.loaded=1};m.src=j}var g,f,h;g="MeshLambertMaterial";f={color:15658734,opacity:1,map:null,light_map:null,vertex_colors:a.vertex_colors};if(a.shading)if(a.shading=="Phong")g="MeshPhongMaterial";if(a.map_diffuse&&b){h=document.createElement("canvas");f.map=new THREE.Texture(h);e(f.map,b+"/"+a.map_diffuse)}else if(a.col_diffuse){h=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;f.color=
-h;f.opacity=a.transparency}else if(a.a_dbg_color)f.color=a.a_dbg_color;if(a.map_lightmap&&b){h=document.createElement("canvas");f.light_map=new THREE.Texture(h);e(f.light_map,b+"/"+a.map_lightmap)}return new THREE[g](f)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
+createBinModel:function(a,b,c,e){var g=function(f){function h(C,L){var J=q(C,L),R=q(C,L+1),W=q(C,L+2),la=q(C,L+3),S=(la<<1&255|W>>7)-127;J=(W&127)<<16|R<<8|J;if(J==0&&S==-127)return 0;return(1-2*(la>>7))*(1+J*Math.pow(2,-23))*Math.pow(2,S)}function k(C,L){var J=q(C,L),R=q(C,L+1),W=q(C,L+2);return(q(C,L+3)<<24)+(W<<16)+(R<<8)+J}function j(C,L){var J=q(C,L);return(q(C,L+1)<<8)+J}function m(C,L){var J=q(C,L);return J>127?J-256:J}function q(C,L){return C.charCodeAt(L)&255}function w(C){var L,J,R;L=k(a,
+C);J=k(a,C+aa);R=k(a,C+O);C=j(a,C+K);THREE.Loader.prototype.f3(v,L,J,R,C)}function u(C){var L,J,R,W,la,S;L=k(a,C);J=k(a,C+aa);R=k(a,C+O);W=j(a,C+K);la=k(a,C+X);S=k(a,C+Q);C=k(a,C+U);THREE.Loader.prototype.f3n(v,M,L,J,R,W,la,S,C)}function t(C){var L,J,R,W;L=k(a,C);J=k(a,C+V);R=k(a,C+H);W=k(a,C+Y);C=j(a,C+ea);THREE.Loader.prototype.f4(v,L,J,R,W,C)}function x(C){var L,J,R,W,la,S,ta,sa;L=k(a,C);J=k(a,C+V);R=k(a,C+H);W=k(a,C+Y);la=j(a,C+ea);S=k(a,C+Z);ta=k(a,C+fa);sa=k(a,C+ia);C=k(a,C+l);THREE.Loader.prototype.f4n(v,
+M,L,J,R,W,la,S,ta,sa,C)}function A(C){var L,J;L=k(a,C);J=k(a,C+y);C=k(a,C+B);THREE.Loader.prototype.uv3(v.uvs,d[L*2],d[L*2+1],d[J*2],d[J*2+1],d[C*2],d[C*2+1])}function E(C){var L,J,R;L=k(a,C);J=k(a,C+o);R=k(a,C+n);C=k(a,C+N);THREE.Loader.prototype.uv4(v.uvs,d[L*2],d[L*2+1],d[J*2],d[J*2+1],d[R*2],d[R*2+1],d[C*2],d[C*2+1])}var v=this,F=0,p,M=[],d=[],aa,O,K,X,Q,U,V,H,Y,ea,Z,fa,ia,l,y,B,o,n,N,G,z,I,D,$,da;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,e,f);p={signature:a.substr(F,8),
+header_bytes:q(a,F+8),vertex_coordinate_bytes:q(a,F+9),normal_coordinate_bytes:q(a,F+10),uv_coordinate_bytes:q(a,F+11),vertex_index_bytes:q(a,F+12),normal_index_bytes:q(a,F+13),uv_index_bytes:q(a,F+14),material_index_bytes:q(a,F+15),nvertices:k(a,F+16),nnormals:k(a,F+16+4),nuvs:k(a,F+16+8),ntri_flat:k(a,F+16+12),ntri_smooth:k(a,F+16+16),ntri_flat_uv:k(a,F+16+20),ntri_smooth_uv:k(a,F+16+24),nquad_flat:k(a,F+16+28),nquad_smooth:k(a,F+16+32),nquad_flat_uv:k(a,F+16+36),nquad_smooth_uv:k(a,F+16+40)};F+=
+p.header_bytes;aa=p.vertex_index_bytes;O=p.vertex_index_bytes*2;K=p.vertex_index_bytes*3;X=p.vertex_index_bytes*3+p.material_index_bytes;Q=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes;U=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*2;V=p.vertex_index_bytes;H=p.vertex_index_bytes*2;Y=p.vertex_index_bytes*3;ea=p.vertex_index_bytes*4;Z=p.vertex_index_bytes*4+p.material_index_bytes;fa=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes;ia=p.vertex_index_bytes*
+4+p.material_index_bytes+p.normal_index_bytes*2;l=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*3;y=p.uv_index_bytes;B=p.uv_index_bytes*2;o=p.uv_index_bytes;n=p.uv_index_bytes*2;N=p.uv_index_bytes*3;f=p.vertex_index_bytes*3+p.material_index_bytes;da=p.vertex_index_bytes*4+p.material_index_bytes;G=p.ntri_flat*f;z=p.ntri_smooth*(f+p.normal_index_bytes*3);I=p.ntri_flat_uv*(f+p.uv_index_bytes*3);D=p.ntri_smooth_uv*(f+p.normal_index_bytes*3+p.uv_index_bytes*3);$=p.nquad_flat*da;f=
+p.nquad_smooth*(da+p.normal_index_bytes*4);da=p.nquad_flat_uv*(da+p.uv_index_bytes*4);F+=function(C){var L,J,R,W=p.vertex_coordinate_bytes*3,la=C+p.nvertices*W;for(C=C;C<la;C+=W){L=h(a,C);J=h(a,C+p.vertex_coordinate_bytes);R=h(a,C+p.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(v,L,J,R)}return p.nvertices*W}(F);F+=function(C){var L,J,R,W=p.normal_coordinate_bytes*3,la=C+p.nnormals*W;for(C=C;C<la;C+=W){L=m(a,C);J=m(a,C+p.normal_coordinate_bytes);R=m(a,C+p.normal_coordinate_bytes*2);M.push(L/
+127,J/127,R/127)}return p.nnormals*W}(F);F+=function(C){var L,J,R=p.uv_coordinate_bytes*2,W=C+p.nuvs*R;for(C=C;C<W;C+=R){L=h(a,C);J=h(a,C+p.uv_coordinate_bytes);d.push(L,J)}return p.nuvs*R}(F);F=F;G=F+G;z=G+z;I=z+I;D=I+D;$=D+$;f=$+f;da=f+da;(function(C){var L,J=p.vertex_index_bytes*3+p.material_index_bytes,R=J+p.uv_index_bytes*3,W=C+p.ntri_flat_uv*R;for(L=C;L<W;L+=R){w(L);A(L+J)}return W-C})(z);(function(C){var L,J=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*3,R=J+p.uv_index_bytes*
+3,W=C+p.ntri_smooth_uv*R;for(L=C;L<W;L+=R){u(L);A(L+J)}return W-C})(I);(function(C){var L,J=p.vertex_index_bytes*4+p.material_index_bytes,R=J+p.uv_index_bytes*4,W=C+p.nquad_flat_uv*R;for(L=C;L<W;L+=R){t(L);E(L+J)}return W-C})(f);(function(C){var L,J=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*4,R=J+p.uv_index_bytes*4,W=C+p.nquad_smooth_uv*R;for(L=C;L<W;L+=R){x(L);E(L+J)}return W-C})(da);(function(C){var L,J=p.vertex_index_bytes*3+p.material_index_bytes,R=C+p.ntri_flat*J;for(L=
+C;L<R;L+=J)w(L);return R-C})(F);(function(C){var L,J=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*3,R=C+p.ntri_smooth*J;for(L=C;L<R;L+=J)u(L);return R-C})(G);(function(C){var L,J=p.vertex_index_bytes*4+p.material_index_bytes,R=C+p.nquad_flat*J;for(L=C;L<R;L+=J)t(L);return R-C})(D);(function(C){var L,J=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*4,R=C+p.nquad_smooth*J;for(L=C;L<R;L+=J)x(L);return R-C})($);this.computeCentroids();this.computeFaceNormals();
+this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g(c))},createModel:function(a,b,c){var e=function(g){var f=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,a.materials,g);(function(){var h,k,j,m,q;h=0;for(k=a.vertices.length;h<k;h+=3){j=a.vertices[h];m=a.vertices[h+1];q=a.vertices[h+2];THREE.Loader.prototype.v(f,j,m,q)}if(a.colors){h=0;for(k=a.colors.length;h<k;h+=3){j=a.colors[h];m=a.colors[h+1];q=a.colors[h+2];THREE.Loader.prototype.vc(f,
+j,m,q)}}})();(function(){function h(x,A){THREE.Loader.prototype.f3(f,x[A],x[A+1],x[A+2],x[A+3])}function k(x,A){THREE.Loader.prototype.f3n(f,a.normals,x[A],x[A+1],x[A+2],x[A+3],x[A+4],x[A+5],x[A+6])}function j(x,A){THREE.Loader.prototype.f4(f,x[A],x[A+1],x[A+2],x[A+3],x[A+4])}function m(x,A){THREE.Loader.prototype.f4n(f,a.normals,x[A],x[A+1],x[A+2],x[A+3],x[A+4],x[A+5],x[A+6],x[A+7],x[A+8])}function q(x,A){var E,v,F,p,M,d,aa,O,K;E=x[A];v=x[A+1];F=x[A+2];p=a.uvs[E*2];aa=a.uvs[E*2+1];M=a.uvs[v*2];O=
+a.uvs[v*2+1];d=a.uvs[F*2];K=a.uvs[F*2+1];THREE.Loader.prototype.uv3(f.uvs,p,aa,M,O,d,K);if(a.uvs2){p=a.uvs2[E*2];aa=a.uvs2[E*2+1];M=a.uvs2[v*2];O=a.uvs2[v*2+1];d=a.uvs2[F*2];K=a.uvs2[F*2+1];THREE.Loader.prototype.uv3(f.uvs2,p,1-aa,M,1-O,d,1-K)}}function w(x,A){var E,v,F,p,M,d,aa,O,K,X,Q,U;E=x[A];v=x[A+1];F=x[A+2];p=x[A+3];M=a.uvs[E*2];K=a.uvs[E*2+1];d=a.uvs[v*2];X=a.uvs[v*2+1];aa=a.uvs[F*2];Q=a.uvs[F*2+1];O=a.uvs[p*2];U=a.uvs[p*2+1];THREE.Loader.prototype.uv4(f.uvs,M,K,d,X,aa,Q,O,U);if(a.uvs2){M=
+a.uvs2[E*2];K=a.uvs2[E*2+1];d=a.uvs2[v*2];X=a.uvs2[v*2+1];aa=a.uvs2[F*2];Q=a.uvs2[F*2+1];O=a.uvs2[p*2];U=a.uvs2[p*2+1];THREE.Loader.prototype.uv4(f.uvs2,M,1-K,d,1-X,aa,1-Q,O,1-U)}}var u,t;u=0;for(t=a.triangles_uv.length;u<t;u+=7){h(a.triangles_uv,u);q(a.triangles_uv,u+4)}u=0;for(t=a.triangles_n_uv.length;u<t;u+=10){k(a.triangles_n_uv,u);q(a.triangles_n_uv,u+7)}u=0;for(t=a.quads_uv.length;u<t;u+=9){j(a.quads_uv,u);w(a.quads_uv,u+5)}u=0;for(t=a.quads_n_uv.length;u<t;u+=13){m(a.quads_n_uv,u);w(a.quads_n_uv,
+u+9)}u=0;for(t=a.triangles.length;u<t;u+=4)h(a.triangles,u);u=0;for(t=a.triangles_n.length;u<t;u+=7)k(a.triangles_n,u);u=0;for(t=a.quads.length;u<t;u+=5)j(a.quads,u);u=0;for(t=a.quads_n.length;u<t;u+=9)m(a.quads_n,u)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(c))},v:function(a,b,c,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))},vc:function(a,b,c,e){var g=new THREE.Color(16777215);
+g.setRGB(b,c,e);a.colors.push(g)},f3:function(a,b,c,e,g){a.faces.push(new THREE.Face3(b,c,e,null,a.materials[g]))},f4:function(a,b,c,e,g,f){a.faces.push(new THREE.Face4(b,c,e,g,null,a.materials[f]))},f3n:function(a,b,c,e,g,f,h,k,j){f=a.materials[f];var m=b[k*3],q=b[k*3+1];k=b[k*3+2];var w=b[j*3],u=b[j*3+1];j=b[j*3+2];a.faces.push(new THREE.Face3(c,e,g,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(m,q,k),new THREE.Vector3(w,u,j)],f))},f4n:function(a,b,c,e,g,f,h,k,j,m,q){h=a.materials[h];
+var w=b[j*3],u=b[j*3+1];j=b[j*3+2];var t=b[m*3],x=b[m*3+1];m=b[m*3+2];var A=b[q*3],E=b[q*3+1];q=b[q*3+2];a.faces.push(new THREE.Face4(c,e,g,f,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(w,u,j),new THREE.Vector3(t,x,m),new THREE.Vector3(A,E,q)],h))},uv3:function(a,b,c,e,g,f,h){var k=[];k.push(new THREE.UV(b,c));k.push(new THREE.UV(e,g));k.push(new THREE.UV(f,h));a.push(k)},uv4:function(a,b,c,e,g,f,h,k,j){var m=[];m.push(new THREE.UV(b,c));m.push(new THREE.UV(e,g));m.push(new THREE.UV(f,
+h));m.push(new THREE.UV(k,j));a.push(m)},init_materials:function(a,b,c){a.materials=[];for(var e=0;e<b.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(b[e],c)]},createMaterial:function(a,b){function c(k){k=Math.log(k)/Math.LN2;return Math.floor(k)==k}function e(k,j){var m=new Image;m.onload=function(){if(!c(this.width)||!c(this.height)){var q=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),w=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));k.image.width=q;k.image.height=
+w;k.image.getContext("2d").drawImage(this,0,0,q,w)}else k.image=this;k.image.loaded=1};m.src=j}var g,f,h;g="MeshLambertMaterial";f={color:15658734,opacity:1,map:null,light_map:null,vertex_colors:a.vertex_colors};if(a.shading)if(a.shading=="Phong")g="MeshPhongMaterial";if(a.map_diffuse&&b){h=document.createElement("canvas");f.map=new THREE.Texture(h);e(f.map,b+"/"+a.map_diffuse)}else if(a.col_diffuse){h=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;f.color=h;f.opacity=a.transparency}else if(a.a_dbg_color)f.color=
+a.a_dbg_color;if(a.map_lightmap&&b){h=document.createElement("canvas");f.light_map=new THREE.Texture(h);e(f.light_map,b+"/"+a.map_lightmap)}return new THREE[g](f)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};

+ 289 - 0
src/animation/Animation.js

@@ -0,0 +1,289 @@
+/**
+ * @author mikael emtinger / http://gomo.se/
+ */
+
+THREE.Animation = function( root, data ) {
+	
+	this.root      = root;
+	this.data      = data;
+	this.hierarchy = [];
+
+	this.startTime = 0;
+	this.isPlaying = false;
+	this.loop      = true;
+
+
+	// need to initialize data?
+
+	if( !this.data.initialized )
+		THREE.AnimationHandler.initData( this.data );
+
+
+	// setup hierarchy
+
+	if( root instanceof THREE.SkinnedMesh ) {
+		
+		for( var b = 0; b < this.root.bones.length; b++ )
+			this.hierarchy.push( this.root.bones[ b ] );
+	}
+	else {
+		
+		// parse hierarchy and match against animation (somehow)
+	}
+
+}
+
+
+/*
+ * Play
+ */
+
+THREE.Animation.prototype.play = function( loop ) {
+
+	if( !this.isPlaying ) {
+		
+		this.isPlaying = true;
+		this.startTime = new Date().getTime() * 0.001;
+
+		
+		// reset key cache
+		
+		for( var h = 0; h < this.hierarchy.length; h++ ) {
+			
+			this.hierarchy[ h ].useQuaternion    = true;
+			this.hierarchy[ h ].autoUpdateMatrix = true;
+			
+			if( this.hierarchy[ h ].prevKey === undefined ) {
+				
+				this.hierarchy[ h ].prevKey = { pos: 0, rot: 0, scl: 0 };
+				this.hierarchy[ h ].nextKey = { pos: 0, rot: 0, scl: 0 };
+			}
+			
+			this.hierarchy[ h ].prevKey.pos = this.data.hierarchy[ h ].keys[ 0 ];
+			this.hierarchy[ h ].prevKey.rot = this.data.hierarchy[ h ].keys[ 0 ];
+			this.hierarchy[ h ].prevKey.scl = this.data.hierarchy[ h ].keys[ 0 ];
+			
+			this.hierarchy[ h ].nextKey.pos = this.getNextKeyWith( "pos", h, 1 );
+			this.hierarchy[ h ].nextKey.rot = this.getNextKeyWith( "rot", h, 1 );
+			this.hierarchy[ h ].nextKey.scl = this.getNextKeyWith( "scl", h, 1 );
+		}	
+		
+		this.update();
+		
+		THREE.AnimationHandler.add( this );
+
+	}
+
+};
+
+
+/*
+ * Pause
+ */
+
+THREE.Animation.prototype.pause = function() {
+	
+	THREE.AnimationHandler.remove( this );
+	
+	// todo
+}
+
+
+/*
+ * Stop
+ */
+
+THREE.Animation.prototype.stop = function() {
+	
+	this.isPlaying = false;
+	THREE.AnimationHandler.remove( this );
+}
+
+
+/*
+ * Update
+ */
+
+THREE.Animation.prototype.update = function( time ) {
+
+	// todo: add input time
+
+	// early out
+	
+	if( !this.isPlaying ) return;
+
+
+	// vars
+	
+	var types = [ "pos", "rot", "scl" ];
+	var scale;
+	var relative;
+	var vector;
+	var prevXYZ, nextXYZ;
+	var object;
+	var frame;
+	var JIThierarchy = this.data.JIT.hierarchy;
+	
+	
+	// update
+	
+	var currentTime         = new Date().getTime() * 0.001 - this.startTime;
+	var unloopedCurrentTime = currentTime;
+
+
+	// looped?
+	
+	if( currentTime > this.data.length ) {
+		
+		while( currentTime > this.data.length )
+			currentTime -= this.data.length;
+		
+		this.startTime = new Date().getTime() * 0.001 - currentTime;
+		currentTime    = new Date().getTime() * 0.001 - this.startTime;
+	}
+	
+	frame = Math.min( parseInt( currentTime * this.data.fps ), parseInt( this.data.length * this.data.fps ));
+	
+	
+	// update
+	
+	for( var h = 0, hl = this.hierarchy.length; h < hl; h++ )
+	{
+		object = this.hierarchy[ h ];
+	
+		if( JIThierarchy[ h ][ frame ] !== undefined ) {
+
+			object.skinMatrix           = JIThierarchy[ h ][ frame ];
+			object.autoUpdateMatrix     = false;
+			object.matrixNeedsToUpdate  = false;
+			this.root.boneMatrices[ h ] = object.skinMatrix.flatten32;
+		}
+		else {
+		
+			for( var t = 0; t < 3; t++ ) {
+				
+				// get keys
+				
+				var type    = types[ t ];
+				var prevKey = object.prevKey[ type ];
+				var nextKey = object.nextKey[ type ];
+				
+				// switch keys?
+							
+				if( nextKey.time < unloopedCurrentTime ) {
+		
+					// did we loop?
+		
+					if( currentTime < unloopedCurrentTime ) {
+						
+						if( this.loop ) {
+							
+							prevKey = this.data.hierarchy[ h ].keys[ 0 ];
+							nextKey = this.getNextKeyWith( type, h, 1 );
+						}
+						else {
+							
+							this.stop();
+							return;
+						}
+					}
+					else {
+						
+						do {
+							
+							prevKey = nextKey;
+							nextKey = this.getNextKeyWith( type, h, nextKey.index + 1 );
+						}
+						while( nextKey.time < currentTime )
+					}
+		
+					object.prevKey[ type ] = prevKey;
+					object.nextKey[ type ] = nextKey;
+				}
+				
+				
+				// interpolate rot (quaternion slerp)
+				
+				object.autoUpdateMatrix    = true;
+				object.matrixNeedsToUpdate = true;
+				
+				scale   = ( currentTime - prevKey.time ) / ( nextKey.time - prevKey.time );
+				prevXYZ = prevKey[ type ];
+				nextXYZ = nextKey[ type ];
+		
+				if( type === "rot" ) {
+		
+					if( scale < 0 || scale > 1 )
+						console.log( "Scale out of bounds:" + scale ); 
+		
+					THREE.Quaternion.slerp( prevXYZ, nextXYZ, object.quaternion, scale );
+				}
+				
+				// lerp pos/scl 
+							
+				else {
+					
+					vector   = type === "pos" ? object.position : object.scale; 
+					vector.x = prevXYZ[ 0 ] + ( nextXYZ[ 0 ] - prevXYZ[ 0 ] ) * scale;
+					vector.y = prevXYZ[ 1 ] + ( nextXYZ[ 1 ] - prevXYZ[ 1 ] ) * scale;
+					vector.z = prevXYZ[ 2 ] + ( nextXYZ[ 2 ] - prevXYZ[ 2 ] ) * scale;
+				}
+			}		
+		}
+	}
+	
+	
+	// update JIT?
+	
+	if( JIThierarchy[ 0 ][ frame ] === undefined ) {
+
+		console.log(this.hierarchy);
+		
+		this.hierarchy[ 0 ].update( undefined, true );
+	
+		for( var h = 0; h < this.hierarchy.length; h++ ) 
+			JIThierarchy[ h ][ frame ] = this.hierarchy[ h ].skinMatrix.clone();
+	}
+
+};
+
+
+
+/*
+ * Update Object
+ */	
+
+THREE.Animation.prototype.updateObject = function( h, currentTime, unloopedCurrentTime ) {
+	
+
+}
+		
+		
+
+
+THREE.Animation.prototype.getNextKeyWith = function( type, h, key ) {
+	
+	var keys = this.data.hierarchy[ h ].keys;
+	
+	for( ; key < keys.length; key++ ) {
+		
+		if( keys[ key ][ type ] !== undefined )
+			return keys[ key ];
+	}
+
+	return this.data.hierarchy[ h ].keys[ 0 ];
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 97 - 0
src/animation/AnimationHandler.js

@@ -0,0 +1,97 @@
+/**
+ * @author mikael emtinger / http://gomo.se/
+ */
+
+THREE.AnimationHandler = (function() {
+	
+	var playing = [];
+	var that    = {};
+	
+	
+	//--- update ---
+	
+	that.update = function( time ) {
+		
+		for( var i = 0; i < playing.length; i++ )
+			playing[ i ].update( time );
+
+	};
+	
+	
+	//--- add ---
+	
+	that.add = function( animation ) {
+		
+		if( playing.indexOf( animation ) === -1 )
+			playing.push( animation );
+
+	};
+	
+	
+	//--- remove ---
+	
+	that.remove = function( animation ) {
+		
+		var index = playing.indexOf( animation ); 
+		
+		if( index !== -1 )
+			playing.splice( childIndex, 1 );
+
+	};
+	
+	
+	//--- init data ---
+	
+	that.initData = function( data ) {
+		
+		if( data.initialized === true )
+			return;
+		
+		// loop through all keys		
+		
+		for( var h = 0; h < data.hierarchy.length; h++ ) {
+			
+			for( var k = 0; k < data.hierarchy[ h ].keys.length; k++ ) {
+			
+				// remove minus times
+				
+				if( data.hierarchy[ h ].keys[ k ].time < 0 )
+					data.hierarchy[ h ].keys[ k ].time = 0;
+			
+			
+				// set index
+				
+				data.hierarchy[ h ].keys[ k ].index = k;
+		
+			
+				// create quaternions
+			
+				if( data.hierarchy[ h ].keys[ k ].rot !== undefined &&
+				  !(data.hierarchy[ h ].keys[ k ].rot instanceof THREE.Quaternion )) {
+					
+					var quat = data.hierarchy[ h ].keys[ k ].rot;
+					data.hierarchy[ h ].keys[ k ].rot = new THREE.Quaternion( quat[0], quat[1], quat[2], quat[3] ); 
+				}	
+			}
+		}
+		
+		
+		// JIT
+
+		var lengthInFrames = parseInt( data.length * data.fps, 10 );
+		
+		data.JIT = {};
+		data.JIT.hierarchy = [];
+		
+		for( var h = 0; h < data.hierarchy.length; h++ )
+			data.JIT.hierarchy.push( new Array( lengthInFrames ));
+		
+		
+		// done
+		
+		data.initialized = true;
+
+	};
+	
+	return that;
+}());

+ 135 - 40
src/cameras/Camera.js

@@ -1,73 +1,168 @@
 /**
 /**
  * @author mr.doob / http://mrdoob.com/
  * @author mr.doob / http://mrdoob.com/
+ * @author mikael emtinger / http://gomo.se/
  */
  */
 
 
-THREE.Camera = function ( fov, aspect, near, far ) {
+THREE.Camera = function( FOV, aspect, zNear, zFar, renderer, target ) {
+	
+	// call super
+	
+	THREE.Object3D.call( this );
+	
+
+	// set arguments
+	
+	this.FOV              = FOV      || 50;
+	this.aspect           = aspect   || 1.0;
+	this.zNear            = zNear    || 0.1;
+	this.zFar             = zFar     || 2000;
+	this.screenCenterX    = 0;
+	this.screenCenterY    = 0;
+	this.target           = target   || new THREE.Object3D();
+	this.useTarget        = true;
+	this.up               = new THREE.Vector3( 0, 1, 0 );
+
+
+	// init
+	
+	this.inverseMatrix     = new THREE.Matrix4();
+	this.projectionMatrix = null;
 
 
-	this.fov = fov;
-	this.aspect = aspect;
-	this.near = near;
-	this.far = far;
+	this.updateProjectionMatrix();
+	
+}
 
 
-	this.position = new THREE.Vector3();
-	this.target = { position: new THREE.Vector3() };
+THREE.Camera.prototype             = new THREE.Object3D();
+THREE.Camera.prototype.constructor = THREE.Camera;
+THREE.Camera.prototype.supr        = THREE.Object3D.prototype;
 
 
-	this.autoUpdateMatrix = true;
+/*
+ * Update projection matrix
+ *
+ * TODO: make it work also for ortho camera
+*/
 
 
-	this.projectionMatrix = null;
-	this.matrix = new THREE.Matrix4();
+THREE.Camera.prototype.updateProjectionMatrix = function() {
+	
+	this.projectionMatrix = THREE.Matrix4.makePerspective( this.FOV, this.aspect, this.zNear, this.zFar );
 
 
-	this.up = new THREE.Vector3( 0, 1, 0 );
+} 
 
 
-	this.tmpVec = new THREE.Vector3();
 
 
-	this.translateX = function ( amount ) {
+/*
+ * Update
+ */
 
 
-		this.tmpVec.sub( this.target.position, this.position ).normalize().multiplyScalar( amount );
-		this.tmpVec.crossSelf( this.up );
+THREE.Camera.prototype.update = function( parentGlobalMatrix, forceUpdate, scene, camera ) {
+	
+	if( this.useTarget ) {
+		
+		// local
+		
+		this.localMatrix.lookAt( this.position, this.target.position, this.up );
+		
+		
+		// global
+		
+		if( parentGlobalMatrix )
+			this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix );
+		else
+			this.globalMatrix.copy( this.localMatrix );
+
+		THREE.Matrix4.makeInvert( this.globalMatrix, this.inverseMatrix );	
+			
+		forceUpdate = true;
+	
+	} else {
+		
+		if( this.autoUpdateMatrix )
+			forceUpdate |= this.updateMatrix();			
+			
+		if( forceUpdate || this.matrixNeedsToUpdate ) {
+			
+			if( parentGlobalMatrix )
+				this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix );
+			else
+				this.globalMatrix.copy( this.localMatrix );
+			
+			this.matrixNeedsToUpdate = false;
+			forceUpdate              = true;
+
+			THREE.Matrix4.makeInvert( this.globalMatrix, this.inverseMatrix );
+
+		}
 
 
-		this.position.addSelf( this.tmpVec );
-		this.target.position.addSelf( this.tmpVec );
+	}
+	
+	// update children
 
 
-	};
+	for( var i = 0; i < this.children.length; i++ )
+		this.children[ i ].update( this.globalMatrix, forceUpdate, camera, renderer );
 
 
-	/* TODO
-	this.translateY = function ( amount ) {
+}
 
 
-	};
-	*/
 
 
-	this.translateZ = function ( amount ) {
+/*
+ * FrustumContains
+ * Checks object against projected image (as opposed to ordinary frustum check)
+ *
+ * TODO: make it work also for ortho camera
+ */
 
 
-		this.tmpVec.sub( this.target.position, this.position ).normalize().multiplyScalar( amount );
+THREE.Camera.prototype.frustumContains = function( object3D ) {
 
 
-		this.position.subSelf( this.tmpVec );
-		this.target.position.subSelf( this.tmpVec );
+	// object pos
 
 
-	};
+	var vx0 = object3D.globalMatrix.n14, 
+	    vy0 = object3D.globalMatrix.n24,
+		vz0 = object3D.globalMatrix.n34;
+		
+		
+	// check z
 
 
-	this.updateMatrix = function () {
+	var inverse = this.inverseMatrix;
+	var radius  = object3D.boundRadius * object3D.boundRadiusScale;
+	var vz1     = ( inverse.n31 * vx0 + inverse.n32 * vy0 + inverse.n33 * vz0 + inverse.n34 );
 
 
-		this.matrix.lookAt( this.position, this.target.position, this.up );
+	if( vz1 - radius > -this.zNear )
+		return false;
+		
+	if( vz1 + radius < -this.zFar )
+		return false;
+	
 
 
-	};
+	// check x
 
 
-	this.updateProjectionMatrix = function () {
+	vz1 -= radius;
 
 
-		this.projectionMatrix = THREE.Matrix4.makePerspective( this.fov, this.aspect, this.near, this.far );
+	var perspective      = this.projectionMatrix;
+	var ooZ              = 1 / ( perspective.n43 * vz1 );
+	var ooZscreenCenterX = ooZ * this.screenCenterX;
+	var vx1              = ( inverse.n11 * vx0 + inverse.n12 * vy0 + inverse.n13 * vz0 + inverse.n14 ) * perspective.n11 * ooZscreenCenterX;
+	radius               = perspective.n11 * radius * ooZscreenCenterX;
 
 
-	};
+	if( vx1 + radius < -this.screenCenterX )
+		return false;
 
 
-	this.updateProjectionMatrix();
+	if( vx1 - radius > this.screenCenterX )
+		return false;
 
 
-};
 
 
-THREE.Camera.prototype = {
+	// check y
 
 
-	toString: function () {
+	var vy1 = ( inverse.n21 * vx0 + inverse.n22 * vy0 + inverse.n23 * vz0 + inverse.n24 ) * perspective.n22 * ooZ * this.screenCenterY;
+		
+	if( vy1 + radius < -this.screenCenterY )
+		return false;
+		
+	if( vy1 - radius > this.screenCenterY )
+		return false;		
 
 
-		return 'THREE.Camera ( ' + this.position + ', ' + this.target.position + ' )';
 
 
-	}
+	// inside
+
+	object3D.screenPosition.set( vx1, vy1, vz1, radius );
+	
+	return true;
 
 
-};
+}

+ 8 - 0
src/core/Geometry.js

@@ -2,15 +2,21 @@
  * @author mr.doob / http://mrdoob.com/
  * @author mr.doob / http://mrdoob.com/
  * @author kile / http://kile.stravaganza.org/
  * @author kile / http://kile.stravaganza.org/
  * @author alteredq / http://alteredqualia.com/
  * @author alteredq / http://alteredqualia.com/
+ * @author mikael emtinger / http://gomo.se/
  */
  */
 
 
 THREE.Geometry = function () {
 THREE.Geometry = function () {
 
 
+	this.id = "Geometry" + THREE.GeometryIdCounter++;
+	
 	this.vertices = [];
 	this.vertices = [];
 	this.faces = [];
 	this.faces = [];
 	this.uvs = [];
 	this.uvs = [];
 	this.uvs2 = [];
 	this.uvs2 = [];
 	this.colors = [];
 	this.colors = [];
+	
+	this.skinWeights = [];
+	this.skinIndices = [];
 
 
 	this.boundingBox = null;
 	this.boundingBox = null;
 	this.boundingSphere = null;
 	this.boundingSphere = null;
@@ -467,3 +473,5 @@ THREE.Geometry.prototype = {
 	}
 	}
 
 
 };
 };
+
+THREE.GeometryIdCounter = 0;

+ 97 - 0
src/core/Matrix4.js

@@ -4,6 +4,8 @@
  * @author philogb / http://blog.thejit.org/
  * @author philogb / http://blog.thejit.org/
  * @author jordi_ros / http://plattsoft.com
  * @author jordi_ros / http://plattsoft.com
  * @author D1plo1d / http://github.com/D1plo1d
  * @author D1plo1d / http://github.com/D1plo1d
+ * @author alteredq / http://alteredqualia.com/
+ * @author mikael emtinger / http://gomo.se/
  */
  */
 
 
 THREE.Matrix4 = function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
 THREE.Matrix4 = function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
@@ -83,6 +85,15 @@ THREE.Matrix4.prototype = {
 
 
 	},
 	},
 
 
+	multiplyVector3OnlyZ: function( v ) {
+		
+		var vx = v.x, vy = v.y, vz = v.z,
+		d = 1 / ( this.n41 * vx + this.n42 * vy + this.n43 * vz + this.n44 );
+
+		return ( this.n31 * vx + this.n32 * vy + this.n33 * vz + this.n34 ) * d;
+
+	},
+	
 	multiplyVector4: function ( v ) {
 	multiplyVector4: function ( v ) {
 
 
 		var vx = v.x, vy = v.y, vz = v.z, vw = v.w;
 		var vx = v.x, vy = v.y, vz = v.z, vw = v.w;
@@ -458,6 +469,92 @@ THREE.Matrix4.prototype = {
 
 
 	},
 	},
 
 
+	setPosition: function( vec3 ) {
+
+		this.n14 = vec3.x;
+		this.n24 = vec3.y;
+		this.n34 = vec3.z;
+		
+		return this;
+	
+	},
+	
+	setRotationFromEuler: function( vec3 ) {
+		
+		//var c = Math.PI / 180;
+		var x = vec3.x,// * c;
+			y = vec3.y,// * c;
+			z = vec3.z,// * c;
+		
+			ch = Math.cos( y  ),
+			sh = Math.sin( y  ),
+			ca = Math.cos( -z ),
+			sa = Math.sin( -z ),
+			cb = Math.cos( x  ),
+			sb = Math.sin( x  ),
+		
+			chsa = ch * sa,
+			shsa = sh * sa;
+	
+	    this.n11 = ch * ca;
+	    this.n12 = sh * sb - chsa * cb;
+	    this.n13 = chsa * sb + sh * cb;
+	    this.n21 = sa;
+	    this.n22 = ca * cb;
+	    this.n23 = - ca * sb;
+	    this.n31 = - sh * ca;
+	    this.n32 = shsa * cb + ch * sb;
+	    this.n33 = - shsa * sb + ch * cb;
+		
+	},
+
+	setRotationFromQuaternion: function( quat ) {
+
+		var x = quat.x, y = quat.y, z = quat.z, w = quat.w,
+	
+			x2 = x + x,
+			y2 = y + y,
+			z2 = z + z,
+	
+			xx = x * x2,
+			xy = x * y2,
+			xz = x * z2,
+	
+			yy = y * y2,
+			yz = y * z2,
+			zz = z * z2,
+	
+			wx = w * x2,
+			wy = w * y2,
+			wz = w * z2;
+	
+		this.n11 = 1 - ( yy + zz );
+		this.n12 = xy - wz;
+		this.n13 = xz + wy;
+	
+		this.n21 = xy + wz;
+		this.n22 = 1 - ( xx + zz );
+		this.n23 = yz - wx;
+	
+		this.n31 = xz - wy;
+		this.n32 = yz + wx;
+		this.n33 = 1 - ( xx + yy );
+		
+	},
+	
+	scale: function( vec3 ) {
+		
+		var x = vec3.x;
+		var y = vec3.y;
+		var z = vec3.z;
+		
+		this.n11 *= x; this.n12 *= x; this.n13 *= x;
+		this.n21 *= y; this.n22 *= y; this.n23 *= y;
+		this.n31 *= z; this.n32 *= z; this.n33 *= z;
+
+		return this;
+	},
+	
 	toString: function() {
 	toString: function() {
 
 
 		return  "| " + this.n11 + " " + this.n12 + " " + this.n13 + " " + this.n14 + " |\n" +
 		return  "| " + this.n11 + " " + this.n12 + " " + this.n13 + " " + this.n14 + " |\n" +

+ 315 - 0
src/core/Quaternion.js

@@ -0,0 +1,315 @@
+/*
+ * @author mikael emtinger / http://gomo.se/
+ */
+
+THREE.Quaternion = function( _x, _y, _z, _w ) {
+
+	this.x = _x || 0;
+	this.y = _y || 0;
+	this.z = _z || 0;
+	this.w = _w !== undefined ? _w : 1;
+
+	this.api = {
+	
+		isDirty:	false,
+		that: 		this,
+
+		get x() { return this.that.x; },
+		get y() { return this.that.y; },
+		get z() { return this.that.z; },
+		get w() { return this.that.w; },
+		
+		set x( value ) { this.that.x = value; this.isDirty = true; },
+		set y( value ) { this.that.y = value; this.isDirty = true; },
+		set z( value ) { this.that.z = value; this.isDirty = true; },
+		set w( value ) { this.that.w = value; this.isDirty = true; },
+	};
+
+	this.api.__proto__ = THREE.Quaternion.prototype;
+	
+	return this.api;
+	
+};
+
+
+THREE.Quaternion.prototype.set = function( x, y, z, w ) {
+	
+	var quat = this.that; 
+	quat.x = x;
+	quat.y = y;
+	quat.z = z;
+	quat.w = w;
+
+	this.isDirty = true;
+	return this;
+
+};
+
+
+THREE.Quaternion.prototype.setFromEuler = function( vec3 ) {
+	
+	var c = 0.5 * Math.PI / 360, // 0.5 is an optimization
+		x = vec3.x * c,
+		y = vec3.y * c,
+		z = vec3.z * c,
+	
+		c1 = Math.cos( y  ),
+		s1 = Math.sin( y  ),
+		c2 = Math.cos( -z ),
+		s2 = Math.sin( -z ),
+		c3 = Math.cos( x  ),
+		s3 = Math.sin( x  ),
+		c1c2 = c1 * c2,
+		s1s2 = s1 * s2,
+    
+		quat = this.that;
+	
+	quat.w = c1c2 * c3  - s1s2 * s3;
+  	quat.x = c1c2 * s3  + s1s2 * c3;
+	quat.y = s1 * c2 * c3 + c1 * s2 * s3;
+	quat.z = c1 * s2 * c3 - s1 * c2 * s3;
+
+	this.isDirty = true;
+	return this;
+
+};
+
+
+THREE.Quaternion.prototype.calculateW = function() {
+	
+	var quat = this.that,
+		x    = quat.x,
+		y    = quat.y,
+		z    = quat.z;
+
+	quat.w = -Math.sqrt( Math.abs( 1.0 - x*x - y*y - z*z ));
+
+	this.isDirty = true;
+	return this;
+
+};
+
+
+THREE.Quaternion.prototype.inverse = function() {
+	
+	var quat = this.that; 
+	quat.x *= -1;
+	quat.y *= -1;
+	quat.z *= -1;
+
+	this.isDirty = true;
+	return this;
+
+};
+
+
+THREE.Quaternion.prototype.length = function() {
+	
+	var quat = this.that; 
+
+	return Math.sqrt( quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w );
+
+};
+
+
+THREE.Quaternion.prototype.normalize = function() {
+	
+	var quat = this.that,
+		x = quat.x,
+		y = quat.y,
+		z = quat.z,
+		w = quat.w;
+	
+	var len = Math.sqrt( x*x + y*y + z*z + w*w );
+	
+	if ( len == 0 ) {
+		
+		quat.x = 0;
+		quat.y = 0;
+		quat.z = 0;
+		quat.w = 0;
+	
+		this.isDirty = true;
+		return this;
+	
+	}
+	
+	len = 1 / len;
+	
+	quat.x = x * len;
+	quat.y = y * len;
+	quat.z = z * len;
+	quat.w = w * len;
+	
+	this.isDirty = true;
+	return this;
+
+};
+
+
+THREE.Quaternion.prototype.multiplySelf = function( quat2 ) {
+	
+	var quat = this.that;
+
+		qax = quat.x,  qay = quat.y,  qaz = quat.z,  qaw = quat.w,
+		qbx = quat2.x, qby = quat2.y, qbz = quat2.z, qbw = quat2.w;
+	
+	quat.x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
+	quat.y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
+	quat.z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
+	quat.w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
+
+	this.isDirty = true;
+	return this;
+
+};
+
+
+THREE.Quaternion.prototype.multiplyVector3 = function( vec, dest ) {
+	
+	if( !dest ) { dest = vec; }
+	
+	var quat = this.that,
+		x    = vec.x,  y  = vec.y,  z  = vec.z,
+		qx   = quat.x, qy = quat.y, qz = quat.z, qw = quat.w;
+
+	// calculate quat * vec
+	
+	var ix =  qw * x + qy * z - qz * y,
+		iy =  qw * y + qz * x - qx * z,
+		iz =  qw * z + qx * y - qy * x,
+		iw = -qx * x - qy * y - qz * z;
+	
+	// calculate result * inverse quat
+	
+	dest.x = ix * qw + iw * -qx + iy * -qz - iz * -qy;
+	dest.y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
+	dest.z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
+	
+	return dest;
+
+};
+
+
+THREE.Quaternion.prototype.toMatrix3 = function( matrix3 ) {
+	
+/*	todo: create a proper Matrix3 first
+ 	
+ 	var x = quat[0], y = quat[1], z = quat[2], w = quat[3];
+
+	var x2 = x + x;
+	var y2 = y + y;
+	var z2 = z + z;
+
+	var xx = x*x2;
+	var xy = x*y2;
+	var xz = x*z2;
+
+	var yy = y*y2;
+	var yz = y*z2;
+	var zz = z*z2;
+
+	var wx = w*x2;
+	var wy = w*y2;
+	var wz = w*z2;
+
+	dest[0] = 1 - (yy + zz);
+	dest[1] = xy - wz;
+	dest[2] = xz + wy;
+
+	dest[3] = xy + wz;
+	dest[4] = 1 - (xx + zz);
+	dest[5] = yz - wx;
+
+	dest[6] = xz - wy;
+	dest[7] = yz + wx;
+	dest[8] = 1 - (xx + yy);
+	
+	return dest;*/
+};
+
+THREE.Quaternion.prototype.toMatrix4 = function( matrix4 ) {
+	
+/* todo: this is implemented in Matrix4.setFromQuaternion
+
+	var x = quat[0], y = quat[1], z = quat[2], w = quat[3];
+
+	var x2 = x + x;
+	var y2 = y + y;
+	var z2 = z + z;
+
+	var xx = x*x2;
+	var xy = x*y2;
+	var xz = x*z2;
+
+	var yy = y*y2;
+	var yz = y*z2;
+	var zz = z*z2;
+
+	var wx = w*x2;
+	var wy = w*y2;
+	var wz = w*z2;
+
+	dest[0] = 1 - (yy + zz);
+	dest[1] = xy - wz;
+	dest[2] = xz + wy;
+	dest[3] = 0;
+
+	dest[4] = xy + wz;
+	dest[5] = 1 - (xx + zz);
+	dest[6] = yz - wx;
+	dest[7] = 0;
+
+	dest[8] = xz - wy;
+	dest[9] = yz + wx;
+	dest[10] = 1 - (xx + yy);
+	dest[11] = 0;
+
+	dest[12] = 0;
+	dest[13] = 0;
+	dest[14] = 0;
+	dest[15] = 1;
+
+ */	
+};
+
+THREE.Quaternion.slerp = function( qa, qb, qm, t ) {
+	
+	
+	var cosHalfTheta = qa.w * qb.w + qa.x * qb.x + qa.y * qb.y + qa.z * qb.z;
+	
+	if( Math.abs( cosHalfTheta ) >= 1.0) {
+		
+		qm.w = qa.w; qm.x = qa.x; qm.y = qa.y; qm.z = qa.z;
+		return qm;
+
+	}
+	
+	var halfTheta    = Math.acos( cosHalfTheta ),
+		sinHalfTheta = Math.sqrt( 1.0 - cosHalfTheta * cosHalfTheta );
+
+	if( Math.abs( sinHalfTheta ) < 0.001 ) { 
+		
+		qm.w = 0.5 * ( qa.w + qb.w );
+		qm.x = 0.5 * ( qa.x + qb.x );
+		qm.y = 0.5 * ( qa.y + qb.y );
+		qm.z = 0.5 * ( qa.z + qb.z );
+		
+		return qm;
+
+	}
+	
+	var ratioA = Math.sin( (1 - t) * halfTheta ) / sinHalfTheta,
+		ratioB = Math.sin( t * halfTheta ) / sinHalfTheta; 
+
+	qm.w = ( qa.w * ratioA + qb.w * ratioB );
+	qm.x = ( qa.x * ratioA + qb.x * ratioB );
+	qm.y = ( qa.y * ratioA + qb.y * ratioB );
+	qm.z = ( qa.z * ratioA + qb.z * ratioB );
+
+	return qm;
+
+};
+	
+
+

+ 132 - 59
src/core/Vector3.js

@@ -2,208 +2,278 @@
  * @author mr.doob / http://mrdoob.com/
  * @author mr.doob / http://mrdoob.com/
  * @author kile / http://kile.stravaganza.org/
  * @author kile / http://kile.stravaganza.org/
  * @author philogb / http://blog.thejit.org/
  * @author philogb / http://blog.thejit.org/
+ * @author mikael emtinger / http://gomo.se/
  */
  */
 
 
-THREE.Vector3 = function ( x, y, z ) {
+THREE.Vector3 = function ( _x, _y, _z ) {
 
 
-	this.x = x || 0;
-	this.y = y || 0;
-	this.z = z || 0;
+	this.x = _x || 0;
+	this.y = _y || 0;
+	this.z = _z || 0;
+
+	this.api = {
+	
+		isDirty:	false,
+		that: 		this,
+
+		get x() { return this.that.x; },
+		get y() { return this.that.y; },
+		get z() { return this.that.z; },
+		
+		set x( value ) { this.that.x = value; this.isDirty = true; },
+		set y( value ) { this.that.y = value; this.isDirty = true; },
+		set z( value ) { this.that.z = value; this.isDirty = true; },
+	};
+
+	this.api.__proto__ = THREE.Vector3.prototype;
+	
+	return this.api;
 
 
 };
 };
 
 
+
 THREE.Vector3.prototype = {
 THREE.Vector3.prototype = {
 
 
 	set: function ( x, y, z ) {
 	set: function ( x, y, z ) {
 
 
-		this.x = x;
-		this.y = y;
-		this.z = z;
+		var vec = this.that; 
+		vec.x = x;
+		vec.y = y;
+		vec.z = z;
 
 
+		this.isDirty = true;
 		return this;
 		return this;
 
 
 	},
 	},
 
 
 	copy: function ( v ) {
 	copy: function ( v ) {
 
 
-		this.x = v.x;
-		this.y = v.y;
-		this.z = v.z;
+		var vec = this.that; 
+		vec.x = v.x;
+		vec.y = v.y;
+		vec.z = v.z;
 
 
+		this.isDirty = true;
 		return this;
 		return this;
 
 
 	},
 	},
 
 
+
 	add: function ( a, b ) {
 	add: function ( a, b ) {
 
 
-		this.x = a.x + b.x;
-		this.y = a.y + b.y;
-		this.z = a.z + b.z;
+		var vec = this.that; 
+		vec.x = a.x + b.x;
+		vec.y = a.y + b.y;
+		vec.z = a.z + b.z;
 
 
+		this.isDirty = true;
 		return this;
 		return this;
 
 
 	},
 	},
 
 
+
 	addSelf: function ( v ) {
 	addSelf: function ( v ) {
 
 
-		this.x += v.x;
-		this.y += v.y;
-		this.z += v.z;
+		var vec = this.that; 
+		vec.x += v.x;
+		vec.y += v.y;
+		vec.z += v.z;
 
 
+		this.isDirty = true;
 		return this;
 		return this;
 
 
 	},
 	},
 
 
+
 	addScalar: function ( s ) {
 	addScalar: function ( s ) {
 
 
-		this.x += s;
-		this.y += s;
-		this.z += s;
+		var vec = this.that; 
+		vec.x += s;
+		vec.y += s;
+		vec.z += s;
 
 
+		this.isDirty = true;
 		return this;
 		return this;
 
 
 	},
 	},
 
 
+
 	sub: function( a, b ) {
 	sub: function( a, b ) {
 
 
-		this.x = a.x - b.x;
-		this.y = a.y - b.y;
-		this.z = a.z - b.z;
+		var vec = this.that; 
+		vec.x = a.x - b.x;
+		vec.y = a.y - b.y;
+		vec.z = a.z - b.z;
 
 
+		this.isDirty = true;
 		return this;
 		return this;
 
 
 	},
 	},
+	
 
 
 	subSelf: function ( v ) {
 	subSelf: function ( v ) {
 
 
-		this.x -= v.x;
-		this.y -= v.y;
-		this.z -= v.z;
+		var vec = this.that; 
+		vec.x -= v.x;
+		vec.y -= v.y;
+		vec.z -= v.z;
 
 
+		this.isDirty = true;
 		return this;
 		return this;
 
 
 	},
 	},
 
 
+
 	cross: function ( a, 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;
+		var vec = this.that; 
+		vec.x = a.y * b.z - a.z * b.y;
+		vec.y = a.z * b.x - a.x * b.z;
+		vec.z = a.x * b.y - a.y * b.x;
 
 
+		this.isDirty = true;
 		return this;
 		return this;
 
 
 	},
 	},
 
 
 	crossSelf: function ( v ) {
 	crossSelf: function ( v ) {
 
 
-		var tx = this.x, ty = this.y, tz = this.z;
+		var vec = this.that; 
+		var tx  = vec.x, ty = vec.y, tz = vec.z;
 
 
-		this.x = ty * v.z - tz * v.y;
-		this.y = tz * v.x - tx * v.z;
-		this.z = tx * v.y - ty * v.x;
+		vec.x = ty * v.z - tz * v.y;
+		vec.y = tz * v.x - tx * v.z;
+		vec.z = tx * v.y - ty * v.x;
 
 
+		this.isDirty = true;
 		return this;
 		return this;
 
 
 	},
 	},
 
 
 	multiply: function ( a, b ) {
 	multiply: function ( a, b ) {
 
 
-		this.x = a.x * b.x;
-		this.y = a.y * b.y;
-		this.z = a.z * b.z;
+		var vec = this.that; 
+		vec.x = a.x * b.x;
+		vec.y = a.y * b.y;
+		vec.z = a.z * b.z;
 
 
+		this.isDirty = true;
 		return this;
 		return this;
 
 
 	},
 	},
 
 
 	multiplySelf: function ( v ) {
 	multiplySelf: function ( v ) {
 
 
-		this.x *= v.x;
-		this.y *= v.y;
-		this.z *= v.z;
+		var vec = this.that; 
+		vec.x *= v.x;
+		vec.y *= v.y;
+		vec.z *= v.z;
 
 
+		this.isDirty = true;
 		return this;
 		return this;
 
 
 	},
 	},
 
 
 	multiplyScalar: function ( s ) {
 	multiplyScalar: function ( s ) {
 
 
-		this.x *= s;
-		this.y *= s;
-		this.z *= s;
+		var vec = this.that; 
+		vec.x *= s;
+		vec.y *= s;
+		vec.z *= s;
 
 
+		this.isDirty = true;
 		return this;
 		return this;
 
 
 	},
 	},
 
 
 	divideSelf: function ( v ) {
 	divideSelf: function ( v ) {
 
 
-		this.x /= v.x;
-		this.y /= v.y;
-		this.z /= v.z;
+		var vec = this.that; 
+		vec.x /= v.x;
+		vec.y /= v.y;
+		vec.z /= v.z;
 
 
+		this.isDirty = true;
 		return this;
 		return this;
 
 
 	},
 	},
 
 
 	divideScalar: function ( s ) {
 	divideScalar: function ( s ) {
 
 
-		this.x /= s;
-		this.y /= s;
-		this.z /= s;
+		var vec = this.that; 
+		vec.x /= s;
+		vec.y /= s;
+		vec.z /= s;
 
 
+		this.isDirty = true;
 		return this;
 		return this;
-
 	},
 	},
 
 
 	dot: function ( v ) {
 	dot: function ( v ) {
 
 
-		return this.x * v.x + this.y * v.y + this.z * v.z;
+		var vec = this.that; 
+		return vec.x * v.x + vec.y * v.y + vec.z * v.z;
 
 
 	},
 	},
 
 
 	distanceTo: function ( v ) {
 	distanceTo: function ( v ) {
 
 
-		var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
+		var vec = this.that; 
+		var dx = vec.x - v.x, dy = vec.y - v.y, dz = vec.z - v.z;
 		return Math.sqrt( dx * dx + dy * dy + dz * dz );
 		return Math.sqrt( dx * dx + dy * dy + dz * dz );
 
 
 	},
 	},
 
 
 	distanceToSquared: function ( v ) {
 	distanceToSquared: function ( v ) {
 
 
-		var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
+		var vec = this.that; 
+		var dx = vec.x - v.x, dy = vec.y - v.y, dz = vec.z - v.z;
 		return dx * dx + dy * dy + dz * dz;
 		return dx * dx + dy * dy + dz * dz;
 
 
 	},
 	},
 
 
 	length: function () {
 	length: function () {
 
 
-		return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );
+		var vec = this.that; 
+		return Math.sqrt( vec.x * vec.x + vec.y * vec.y + vec.z * vec.z );
 
 
 	},
 	},
 
 
 	lengthSq: function () {
 	lengthSq: function () {
 
 
-		return this.x * this.x + this.y * this.y + this.z * this.z;
+		var vec = this.that; 
+		return vec.x * vec.x + vec.y * vec.y + vec.z * vec.z;
 
 
 	},
 	},
 
 
+	lengthManhattan: function () {
+
+		var vec = this.that; 
+		return vec.x + vec.y + vec.z;
+
+	},
+
+
 	negate: function () {
 	negate: function () {
 
 
-		this.x = - this.x;
-		this.y = - this.y;
-		this.z = - this.z;
+		var vec = this.that; 
+		vec.x = - this.x;
+		vec.y = - this.y;
+		vec.z = - this.z;
 
 
+		this.isDirty = true;
 		return this;
 		return this;
 
 
 	},
 	},
 
 
 	normalize: function () {
 	normalize: function () {
 
 
-		var length = Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );
+		var vec = this.that; 
+		var length = Math.sqrt( vec.x * vec.x + vec.y * vec.y + vec.z * vec.z );
 
 
 		length > 0 ? this.multiplyScalar( 1 / length ) : this.set( 0, 0, 0 );
 		length > 0 ? this.multiplyScalar( 1 / length ) : this.set( 0, 0, 0 );
 
 
+		this.isDirty = true;
 		return this;
 		return this;
 
 
 	},
 	},
@@ -217,13 +287,16 @@ THREE.Vector3.prototype = {
 	isZero: function () {
 	isZero: function () {
 
 
 		var almostZero = 0.0001;
 		var almostZero = 0.0001;
-		return ( Math.abs( this.x ) < almostZero ) && ( Math.abs( this.y ) < almostZero ) && ( Math.abs( this.z ) < almostZero );
+		var vec        = this.that; 
+		
+		return ( Math.abs( vec.x ) < almostZero ) && ( Math.abs( vec.y ) < almostZero ) && ( Math.abs( vec.z ) < almostZero );
 
 
 	},
 	},
 
 
 	clone: function () {
 	clone: function () {
 
 
-		return new THREE.Vector3( this.x, this.y, this.z );
+		var vec = this.that; 
+		return new THREE.Vector3( vec.x, vec.y, vec.z );
 
 
 	},
 	},
 
 

+ 3 - 1
src/core/Vector4.js

@@ -1,6 +1,7 @@
 /**
 /**
  * @author supereggbert / http://www.paulbrunt.co.uk/
  * @author supereggbert / http://www.paulbrunt.co.uk/
  * @author philogb / http://blog.thejit.org/
  * @author philogb / http://blog.thejit.org/
+ * @author mikael emtinger / http://gomo.se/
  */
  */
 
 
 THREE.Vector4 = function ( x, y, z, w ) {
 THREE.Vector4 = function ( x, y, z, w ) {
@@ -8,7 +9,7 @@ THREE.Vector4 = function ( x, y, z, w ) {
 	this.x = x || 0;
 	this.x = x || 0;
 	this.y = y || 0;
 	this.y = y || 0;
 	this.z = z || 0;
 	this.z = z || 0;
-	this.w = w || 1;
+	this.w = w !== undefined ? w : 1;
 
 
 };
 };
 
 
@@ -108,6 +109,7 @@ THREE.Vector4.prototype = {
 		this.y = this.y + (v.y - this.y) * alpha;
 		this.y = this.y + (v.y - this.y) * alpha;
 		this.z = this.z + (v.z - this.z) * alpha;
 		this.z = this.z + (v.z - this.z) * alpha;
 		this.w = this.w + (v.w - this.w) * alpha;
 		this.w = this.w + (v.w - this.w) * alpha;
+
 	},
 	},
 
 
 	clone: function () {
 	clone: function () {

+ 65 - 1
src/extras/io/Loader.js

@@ -759,11 +759,51 @@ THREE.Loader.prototype = {
 
 
 			init_vertices();
 			init_vertices();
 			init_faces();
 			init_faces();
+			init_skin();
 
 
 			this.computeCentroids();
 			this.computeCentroids();
 			this.computeFaceNormals();
 			this.computeFaceNormals();
 			this.sortFacesByMaterial();
 			this.sortFacesByMaterial();
 
 
+			function init_skin() {
+				
+				var i, l, x, y, z, w, a, b, c, d;
+
+				if ( data.skinWeights ) {
+					
+					for( i = 0, l = data.skinWeights.length; i < l; i += 2 ) {
+
+						x = data.skinWeights[ i     ];
+						y = data.skinWeights[ i + 1 ];
+						z = 0;
+						w = 0;
+
+						THREE.Loader.prototype.sw( scope, x, y, z, w );
+
+					}
+					
+				}
+				
+				if ( data.skinIndices ) {
+					
+					for( i = 0, l = data.skinIndices.length; i < l; i += 2 ) {
+
+						a = data.skinIndices[ i     ];
+						b = data.skinIndices[ i + 1 ];
+						c = 0;
+						d = 0;
+
+						THREE.Loader.prototype.si( scope, a, b, c, d );
+
+					}
+				
+				}
+				
+				THREE.Loader.prototype.bones( scope, data.bones );
+				THREE.Loader.prototype.animation( scope, data.animation );
+				
+			}
+			
 			function init_vertices() {
 			function init_vertices() {
 
 
 				var i, l, x, y, z, r, g, b;
 				var i, l, x, y, z, r, g, b;
@@ -882,7 +922,7 @@ THREE.Loader.prototype = {
 
 
 					THREE.Loader.prototype.uv3( scope.uvs, u1, v1, u2, v2, u3, v3 );
 					THREE.Loader.prototype.uv3( scope.uvs, u1, v1, u2, v2, u3, v3 );
 					
 					
-					if( data.uvs2 ) {
+					if( data.uvs2 && data.uvs2.length ) {
 						
 						
 						u1 = data.uvs2[ uva * 2 ];
 						u1 = data.uvs2[ uva * 2 ];
 						v1 = data.uvs2[ uva * 2 + 1 ];
 						v1 = data.uvs2[ uva * 2 + 1 ];
@@ -1012,6 +1052,30 @@ THREE.Loader.prototype = {
 
 
 	},
 	},
 
 
+	bones: function( scope, bones ) {
+
+		scope.bones = bones;
+
+	},
+	
+	animation: function( scope, animation ) {
+		
+		scope.animation = animation;
+
+	},
+	
+	si: function( scope, a, b, c, d ) {
+
+		scope.skinIndices.push( new THREE.Vector4( a, b, c, d ) );
+
+	},
+
+	sw: function( scope, x, y, z, w ) {
+
+		scope.skinWeights.push( new THREE.Vector4( x, y, z, w ) );
+
+	},
+	
 	v: function( scope, x, y, z ) {
 	v: function( scope, x, y, z ) {
 
 
 		scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
 		scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );

+ 12 - 0
src/lights/Light.js

@@ -1,5 +1,17 @@
+/**
+ * @author mr.doob / http://mrdoob.com/
+ * @author alteredq / http://alteredqualia.com/
+ */
+ 
 THREE.Light = function ( hex ) {
 THREE.Light = function ( hex ) {
 
 
+	THREE.Object3D.call( this );
+	
 	this.color = new THREE.Color( hex );
 	this.color = new THREE.Color( hex );
 
 
 };
 };
+
+THREE.Light.prototype             = new THREE.Object3D();
+THREE.Light.prototype.constructor = THREE.Light;
+THREE.Light.prototype.supr        = THREE.Object3D.prototype;
+

+ 91 - 0
src/objects/Bone.js

@@ -0,0 +1,91 @@
+/**
+ * @author mikael emtinger / http://gomo.se/
+ */
+
+THREE.Bone = function( belongsToSkin ) {
+	
+	THREE.Object3D.call( this );
+	
+	this.skin                = belongsToSkin;
+	this.skinMatrix          = new THREE.Matrix4();
+	this.hasNoneBoneChildren = false;	
+
+};
+
+THREE.Bone.prototype             = new THREE.Object3D();
+THREE.Bone.prototype.constructor = THREE.Bone;
+THREE.Bone.prototype.supr        = THREE.Object3D.prototype;
+
+
+/*
+ * Update
+ */
+
+THREE.Bone.prototype.update = function( parentSkinMatrix, forceUpdate, camera, renderer ) {
+	
+	// update local
+	
+	if( this.autoUpdateMatrix )
+		forceUpdate |= this.updateMatrix();			
+
+	
+	// update skin matrix
+
+	if( forceUpdate || this.matrixNeedsToUpdate ) {
+		
+		if( parentSkinMatrix )
+			this.skinMatrix.multiply( parentSkinMatrix, this.localMatrix );
+		else
+			this.skinMatrix.copy( this.localMatrix );
+		
+		this.matrixNeedsToUpdate = false;
+		forceUpdate              = true;
+
+	}
+
+
+	// update children
+	
+	if( this.hasNoneBoneChildren ) {
+		
+		this.globalMatrix.multiply( this.skin.globalMatrix, this.skinMatrix );
+
+		for( var i = 0; i < this.children.length; i++ )
+			if( !( this.children[ i ] instanceof THREE.Bone ))
+				this.children[ i ].update( this.globalMatrix, true, camera, renderer );
+			else
+				this.children[ i ].update( this.skinMatrix, forceUpdate, camera, renderer );
+		
+	} else {
+		
+		for( var i = 0; i < this.children.length; i++ )
+			this.children[ i ].update( this.skinMatrix, forceUpdate, camera, renderer );
+
+	}
+
+};
+
+
+/*
+ * Add child
+ */
+
+THREE.Bone.prototype.addChild = function( child ) {
+
+	if( this.children.indexOf( child ) === -1 ) {
+
+		if( child.parent !== undefined )
+			child.parent.removeChild( child );
+		
+		child.parent = this;		
+		this.children.push( child );
+
+		if( !( child instanceof THREE.Bone ))
+			this.hasNoneBoneChildren = true;	
+	}
+
+};
+
+/*
+ * Todo: Remove Children: see if any remaining are none-Bone
+ */

+ 97 - 0
src/objects/LOD.js

@@ -0,0 +1,97 @@
+/**
+ * @author mikael emtinger / http://gomo.se/
+ */
+
+THREE.LOD = function() {
+
+	THREE.Object3D.call( this );
+
+	this.LODs = [];
+
+};
+
+THREE.LOD.prototype             = new THREE.Object3D();
+THREE.LOD.prototype.constructor = THREE.LOD;
+THREE.LOD.prototype.supr        = THREE.Object3D.prototype;
+
+/*
+ * Add
+ */
+
+THREE.LOD.prototype.add = function( object3D, visibleAtDistance ) {
+	
+	if( visibleAtDistance === undefined ) visibleAtDistance = 0;
+	visibleAtDistance = Math.abs( visibleAtDistance );
+	
+	for( var l = 0; l < this.LODs.length; l++ ) {
+		
+		if( visibleAtDistance < this.LODs[ l ].visibleAtDistance )
+			break;
+	}
+	
+	this.LODs.splice( l, 0, { visibleAtDistance: visibleAtDistance, object3D: object3D } );
+	this.addChild( object3D );
+
+};
+
+
+/*
+ * Update
+ */
+
+THREE.LOD.prototype.update = function( parentGlobalMatrix, forceUpdate, camera, renderer ) {
+	
+	// update local
+	
+	if( this.autoUpdateMatrix )
+		forceUpdate |= this.updateMatrix();
+
+
+	// update global
+
+	if( forceUpdate || this.matrixNeedsToUpdate ) {
+		
+		if( parentGlobalMatrix )
+			this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix );
+		else
+			this.globalMatrix.copy( this.localMatrix );
+		
+		this.matrixNeedsToUpdate = false;
+		forceUpdate              = true;
+
+	}
+
+
+	// update lods
+		
+	if( this.LODs.length > 1 ) {
+		
+		var distance = -camera.inverseMatrix.mulitplyVector3OnlyZ( this.position );
+
+		this.LODs[ 0 ].object3D.visible = true;
+		
+		for( var l = 1; l < this.LODs.length; l++ ) {
+			
+			if( distance >= this.LODs[ l ].visibleAtDistance ) {
+				
+				this.LODs[ l - 1 ].object3D.visible = false;
+				this.LODs[ l     ].object3D.visible = true;
+			}
+			else 
+				break;
+
+		}
+		
+		for( ; l < this.LODs.length; l++ ) 
+			this.LODs[ l ].object3D.visible = false;
+
+	}
+
+
+	// update children
+
+	for( var c = 0; c < this.children.length; c++ )
+		this.children[ c ].update( this.globalMatrix, forceUpdate, camera, renderer );
+
+};
+

+ 83 - 8
src/objects/Mesh.js

@@ -1,23 +1,98 @@
 /**
 /**
  * @author mr.doob / http://mrdoob.com/
  * @author mr.doob / http://mrdoob.com/
  * @author alteredq / http://alteredqualia.com/
  * @author alteredq / http://alteredqualia.com/
+ * @author mikael emtinger / http://gomo.se/
  */
  */
 
 
-THREE.Mesh = function ( geometry, materials ) {
+THREE.Mesh = function( geometry, materials ) {
 
 
 	THREE.Object3D.call( this );
 	THREE.Object3D.call( this );
-
-	this.geometry = geometry;
-	this.materials = materials instanceof Array ? materials : [ materials ];
-
+	
+	this.geometry     = geometry;
+	this.materials    = materials && materials.length ? materials : [ materials ];
+	this.normalMatrix = THREE.Matrix4.makeInvert3x3( this.globalMatrix ).transpose();
+	
 	this.flipSided = false;
 	this.flipSided = false;
 	this.doubleSided = false;
 	this.doubleSided = false;
 
 
 	this.overdraw = false; // TODO: Move to material?
 	this.overdraw = false; // TODO: Move to material?
+	
+	// calc bound radius
+	
+	if( this.geometry ) {
+		
+		if( !this.geometry.boundingSphere )
+			 this.geometry.computeBoundingSphere();
+	
+		this.boundRadius = geometry.boundingSphere.radius;
 
 
-	this.geometry.boundingSphere || this.geometry.computeBoundingSphere();
+	}
 
 
-};
+}
 
 
-THREE.Mesh.prototype = new THREE.Object3D();
+THREE.Mesh.prototype             = new THREE.Object3D();
 THREE.Mesh.prototype.constructor = THREE.Mesh;
 THREE.Mesh.prototype.constructor = THREE.Mesh;
+THREE.Mesh.prototype.supr        = THREE.Object3D.prototype;
+
+/*
+ * Update
+ */
+
+THREE.Mesh.prototype.update = function( parentGlobalMatrix, forceUpdate, camera, renderer ) {
+	
+	// visible?
+	
+	if( this.visible ) {
+
+		// update local
+		
+		if( this.autoUpdateMatrix )
+			forceUpdate |= this.updateMatrix();
+
+
+		// update global
+
+		if( forceUpdate || this.matrixNeedsToUpdate ) {
+			
+			if( parentGlobalMatrix )
+				this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix );
+			else
+				this.globalMatrix.copy( this.localMatrix );
+			
+			this.matrixNeedsToUpdate = false;
+			forceUpdate               = true;
+			
+			
+			// update normal
+
+			this.normalMatrix = THREE.Matrix4.makeInvert3x3( this.globalMatrix ).transpose();
+
+		}
+
+
+		// update children
+	
+		for( var i = 0; i < this.children.length; i++ )
+			this.children[ i ].update( this.globalMatrix, forceUpdate, camera, renderer );
+
+
+		// check camera frustum and add to render list
+		
+		if( renderer && camera ) {
+			
+			if( camera.frustumContains( this ))
+				renderer.addToRenderList( this );
+			else
+				renderer.removeFromRenderList( this );
+		
+		}
+	
+	} else {
+		
+		renderer.removeFromRenderList( this );
+
+	}
+
+}
+
+

+ 165 - 35
src/objects/Object3D.js

@@ -1,74 +1,204 @@
 /**
 /**
  * @author mr.doob / http://mrdoob.com/
  * @author mr.doob / http://mrdoob.com/
+ * @author mikael emtinger / http://gomo.se/
+ * @author alteredq / http://alteredqualia.com/
  */
  */
 
 
-THREE.Object3D = function () {
+THREE.Object3D = function() {
+
+	this.id = THREE.Object3DCounter.value ++;
+	
+	this.visible             = true;
+	this.autoUpdateMatrix    = true;
+	this.matrixNeedsToUpdate = true;
+	
+	this.parent		  		 = undefined;
+	this.children     		 = [];
+
+	this.position            = new THREE.Vector3();
+	this.rotation            = new THREE.Vector3();
+	this.scale               = new THREE.Vector3( 1.0, 1.0, 1.0 );
+	this.localMatrix         = new THREE.Matrix4();
+	this.globalMatrix        = new THREE.Matrix4();
+	this.quaternion          = new THREE.Quaternion();
+	this.useQuaternion       = false;
+	this.screenPosition      = new THREE.Vector4(); // xyzr
+	
+	this.boundRadius         = 0.0;
+	this.boundRadiusScale    = 1.0;
 
 
-	this.id = THREE.Object3DCounter.value ++; // TODO: Probably not needed?
+};
+
+
+/*
+ * Update
+ */
+
+THREE.Object3D.prototype.update = function( parentGlobalMatrix, forceUpdate, camera, renderer ) {
 
 
-	this.position = new THREE.Vector3();
-	this.rotation = new THREE.Vector3();
-	this.scale = new THREE.Vector3( 1, 1, 1 );
+	// visible and auto update?
+	
+	if( this.visible ) {
 
 
-	this.matrix = new THREE.Matrix4();
-	this.matrixWorld = new THREE.Matrix4();
-	this.rotationMatrix = new THREE.Matrix4();
-	this.tmpMatrix = new THREE.Matrix4();
+		// update local
+		
+		if( this.autoUpdateMatrix )
+			forceUpdate |= this.updateMatrix();			
+
+	
+		// update global
+
+		if( forceUpdate || this.matrixNeedsToUpdate ) {
+			
+			if( parentGlobalMatrix )
+				this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix );
+			else
+				this.globalMatrix.copy( this.localMatrix );
+			
+			this.matrixNeedsToUpdate = false;
+			forceUpdate              = true;
+
+		}
 
 
-	this.screen = new THREE.Vector3();
 
 
-	this.autoUpdateMatrix = true;
-	this.visible = true;
+		// update children
+	
+		for( var i = 0; i < this.children.length; i++ ) {
+			
+			this.children[ i ].update( this.globalMatrix, forceUpdate, camera, renderer );
+			
+		}
 
 
-	this.children = [];
+	}
 
 
 };
 };
 
 
-THREE.Object3D.prototype = {
 
 
-	addChild: function ( object ) {
+/*
+ * Update Matrix
+ */
 
 
-		var i = this.children.indexOf( object );
+THREE.Object3D.prototype.updateMatrix = function() {
+	
+	// update position
+	
+	var isDirty = false;
+	
+	if( this.position.isDirty ) {
+		
+		this.localMatrix.setPosition( this.position );
+		this.position.isDirty = false;
+		isDirty = true;
 
 
-		if ( i === -1 ) {
+	}
 
 
-			this.children.push( object );
 
 
-		}
+	// update quaternion
+	
+	if( this.useQuaternion ) {
+		
+		if( this.quaternion.isDirty ) {
+			
+			this.localMatrix.setRotationFromQuaternion( this.quaternion );
+			this.quaternion.isDirty = false;
+			this.rotation  .isDirty = false;
+			
+			if( this.scale.isDirty || this.scale.x !== 1 || this.scale.y !== 1 || this.scale.z !== 1 ) {
+				
+				this.localMatrix.scale( this.scale );
+				this.scale.isDirty = false;
+	
+				this.boundRadiusScale = Math.max( this.scale.x, Math.max( this.scale.y, this.scale.z ) );
+
+			}
+			
+			isDirty = true;
 
 
-	},
+		}
 
 
-	removeChild: function ( object ) {
+	}
 
 
-		var i = this.children.indexOf( object );
+	// update rotation
 
 
-		if ( i !== -1 ) {
+	else if( this.rotation.isDirty ) {
+	
+		this.localMatrix.setRotationFromEuler( this.rotation );
+		this.rotation.isDirty = false;
 
 
-			this.children.splice( i, 1 );
+		if( this.scale.isDirty || this.scale.x !== 1 || this.scale.y !== 1 || this.scale.z !== 1 ) {
+			
+			this.localMatrix.scale( this.scale );
+			this.scale.isDirty = false;
+			
+			this.boundRadiusScale = Math.max( this.scale.x, Math.max( this.scale.y, this.scale.z ) );
 
 
 		}
 		}
 
 
-	},
+		isDirty = true;
+
+	}
+
+
+	// update scale
+	
+	if( this.scale.isDirty ) {
+		
+		if( this.useQuaternion ) 
+			this.localMatrix.setRotationFromQuaternion( this.quaternion );
+		else
+			this.localMatrix.setRotationFromEuler( this.rotation );
+
+		this.localMatrix.scale( this.scale );
+		this.scale.isDirty = false;
+
+		this.boundRadiusScale = Math.max( this.scale.x, Math.max( this.scale.y, this.scale.z ));
+
+		isDirty = true;
+
+	}
+
+	
+	return isDirty;
+
+};
 
 
-	updateMatrix: function () {
 
 
-		var p = this.position, r = this.rotation, s = this.scale,
-		matrix = this.matrix, rotationMatrix = this.rotationMatrix,
-		tmpMatrix = this.tmpMatrix;
+/*
+ * AddChild
+ */
 
 
-		matrix.setTranslation( p.x, p.y, p.z );
+THREE.Object3D.prototype.addChild = function( child ) {
+	
+	if( this.children.indexOf( child ) === -1 ) {
 
 
-		rotationMatrix.setRotX( r.x );
+		if( child.parent !== undefined )
+			child.parent.removeChild( child );
+		
+		child.parent = this;		
+		this.children.push( child );
 
 
-		if ( r.y != 0 ) rotationMatrix.multiplySelf( tmpMatrix.setRotY( r.y ) );
-		if ( r.z != 0 ) rotationMatrix.multiplySelf( tmpMatrix.setRotZ( r.z ) );
+	}
 
 
-		matrix.multiplySelf( rotationMatrix );
+};
 
 
-		if ( s.x != 0 || s.y != 0 || s.z != 0 ) matrix.multiplySelf( tmpMatrix.setScale( s.x, s.y, s.z ) );
+
+/*
+ * RemoveChild
+ */
+
+THREE.Object3D.prototype.removeChild = function() {
+	
+	var childIndex = this.children.indexOf( child ); 
+	
+	if( childIndex !== -1 )	{
+		
+		this.children.splice( childIndex, 1 );
+		child.parent = undefined;
 
 
 	}
 	}
 
 
 };
 };
 
 
 THREE.Object3DCounter = { value: 0 };
 THREE.Object3DCounter = { value: 0 };
+
+

+ 193 - 0
src/objects/SkinnedMesh.js

@@ -0,0 +1,193 @@
+/**
+ * @author mikael emtinger / http://gomo.se/
+ */
+
+THREE.SkinnedMesh = function( geometry, materials ) {
+	
+	THREE.Mesh.call( this, geometry, materials );
+	
+	
+	// init bones
+
+	this.identityMatrix = new THREE.Matrix4();
+
+	this.bones        = [];
+	this.boneMatrices = [];
+	
+	if( this.geometry.bones !== undefined ) {
+		
+		for( var b = 0; b < this.geometry.bones.length; b++ ) {
+			
+			var bone = this.addBone();
+			
+			bone.name         = this.geometry.bones[ b ].name;
+			bone.position.x   = this.geometry.bones[ b ].pos [ 0 ];
+			bone.position.y   = this.geometry.bones[ b ].pos [ 1 ];
+			bone.position.z   = this.geometry.bones[ b ].pos [ 2 ];
+			bone.quaternion.x = this.geometry.bones[ b ].rotq[ 0 ];
+			bone.quaternion.y = this.geometry.bones[ b ].rotq[ 1 ];
+			bone.quaternion.z = this.geometry.bones[ b ].rotq[ 2 ];
+			bone.quaternion.w = this.geometry.bones[ b ].rotq[ 3 ];
+			bone.scale.x      = this.geometry.bones[ b ].scl !== undefined ? this.geometry.bones[ b ].scl[ 0 ] : 1;
+			bone.scale.y      = this.geometry.bones[ b ].scl !== undefined ? this.geometry.bones[ b ].scl[ 1 ] : 1;
+			bone.scale.z      = this.geometry.bones[ b ].scl !== undefined ? this.geometry.bones[ b ].scl[ 2 ] : 1;
+
+		}
+		
+		for( var b = 0; b < this.bones.length; b++ ) {
+			
+			if( this.geometry.bones[ b ].parent === -1 ) 
+				this.addChild( this.bones[ b ] );
+			else
+				this.bones[ this.geometry.bones[ b ].parent ].addChild( this.bones[ b ] );
+		}
+		
+		this.pose();
+
+	}
+
+};
+
+THREE.SkinnedMesh.prototype             = new THREE.Mesh();
+THREE.SkinnedMesh.prototype.constructor = THREE.SkinnedMesh;
+
+
+/*
+ * Update
+ */
+
+THREE.SkinnedMesh.prototype.update = function( parentGlobalMatrix, forceUpdate, camera, renderer ) {
+	
+	// visible?
+	
+	if( this.visible ) {
+
+		// update local
+		
+		if( this.autoUpdateMatrix )
+			forceUpdate |= this.updateMatrix();
+
+
+		// update global
+
+		if( forceUpdate || this.matrixNeedsToUpdate ) {
+			
+			if( parentGlobalMatrix )
+				this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix );
+			else
+				this.globalMatrix.copy( this.localMatrix );
+			
+			this.matrixNeedsToUpdate = false;
+			forceUpdate              = true;
+			
+			
+			// update normal
+
+			this.normalMatrix = THREE.Matrix4.makeInvert3x3( this.globalMatrix ).transpose();
+
+		}
+
+
+		// update children
+	
+		for( var i = 0; i < this.children.length; i++ )
+			if( this.children[ i ] instanceof THREE.Bone )
+				this.children[ i ].update( this.identityMatrix, false, camera, renderer );
+			else
+				this.children[ i ].update( this.globalMatrix, forceUpdate, camera, renderer );
+			
+
+
+		// check camera frustum and add to render list
+		
+		if( renderer && camera ) {
+			
+			if( camera.frustumContains( this ) )
+				renderer.addToRenderList( this );
+			else
+				renderer.removeFromRenderList( this );
+
+		}
+
+	} else {
+		
+		renderer.removeFromRenderList( this );
+
+	}
+
+};
+
+
+/*
+ * Add 
+ */
+
+THREE.SkinnedMesh.prototype.addBone = function( bone ) {
+	
+	if( bone === undefined ) 
+		bone = new THREE.Bone( this );
+	
+	this.bones.push( bone );
+	
+	return bone;
+
+};
+
+/*
+ * Pose
+ */
+
+THREE.SkinnedMesh.prototype.pose = function() {
+
+	this.update( undefined, true );
+
+	var boneInverses = [];
+	
+	for( var b = 0; b < this.bones.length; b++ ) {
+		
+		boneInverses.push( THREE.Matrix4.makeInvert( this.bones[ b ].skinMatrix, new THREE.Matrix4()));
+		this.boneMatrices.push( this.bones[ b ].skinMatrix.flatten32 );
+
+	}
+	
+
+	// project vertices to local 
+
+	if( this.geometry.skinVerticesA === undefined ) {
+		
+		this.geometry.skinVerticesA = [];
+		this.geometry.skinVerticesB = [];
+		var orgVertex;
+		var vertex;
+	
+		for( var i = 0; i < this.geometry.skinIndices.length; i++ ) {
+			
+			orgVertex = this.geometry.vertices[ i ].position;
+	
+			var indexA = this.geometry.skinIndices[ i ].x;
+			var indexB = this.geometry.skinIndices[ i ].y;
+	
+			vertex = new THREE.Vector3( orgVertex.x, orgVertex.y, orgVertex.z );
+			this.geometry.skinVerticesA.push( boneInverses[ indexA ].multiplyVector3( vertex ));
+	
+			vertex = new THREE.Vector3( orgVertex.x, orgVertex.y, orgVertex.z );
+			this.geometry.skinVerticesB.push( boneInverses[ indexB ].multiplyVector3( vertex ));
+			
+			// todo: add more influences
+	
+			// normalize weights
+	
+			if( this.geometry.skinWeights[ i ].x + this.geometry.skinWeights[ i ].y !== 1 ) {
+				
+				var len = ( 1.0 - ( this.geometry.skinWeights[ i ].x + this.geometry.skinWeights[ i ].y )) * 0.5;
+				this.geometry.skinWeights[ i ].x += len;
+				this.geometry.skinWeights[ i ].y += len;
+
+			}
+
+		}
+
+	}
+
+};
+

+ 53 - 63
src/renderers/WebGLRenderer.js

@@ -64,6 +64,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	this.domElement = _canvas;
 	this.domElement = _canvas;
 	this.autoClear = true;
 	this.autoClear = true;
+	this.sortObjects = false;
 
 
 	initGL( antialias, clearColor, clearAlpha );
 	initGL( antialias, clearColor, clearAlpha );
 
 
@@ -809,7 +810,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		if ( object.sortParticles ) {
 		if ( object.sortParticles ) {
 		
 		
-			_projScreenMatrix.multiplySelf( object.matrixWorld );
+			_projScreenMatrix.multiplySelf( object.globalMatrix );
 			
 			
 			for ( v = 0; v < vl; v++ ) {
 			for ( v = 0; v < vl; v++ ) {
 
 
@@ -1355,7 +1356,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 	
 	
 	function isInFrustum( object ) {
 	function isInFrustum( object ) {
 
 
-		var distance, matrix = object.matrix,
+		var distance, matrix = object.globalMatrix,
 		radius = - object.geometry.boundingSphere.radius * Math.max( object.scale.x, Math.max( object.scale.y, object.scale.z ) );
 		radius = - object.geometry.boundingSphere.radius * Math.max( object.scale.x, Math.max( object.scale.y, object.scale.z ) );
 
 
 		for ( var i = 0; i < 6; i ++ ) {
 		for ( var i = 0; i < 6; i ++ ) {
@@ -1446,39 +1447,31 @@ THREE.WebGLRenderer = function ( parameters ) {
 		
 		
 	};
 	};
 	
 	
-	function updateChildren( object ) {
-		
-		var i, l, child, children = object.children;
-		
-		for ( i = 0, l = children.length; i < l; i ++ ) {
+	
+	function painterSort( a, b ) {
 
 
-			child = children[ i ];
+		return b.z - a.z;
 
 
-			child.autoUpdateMatrix && child.updateMatrix();
-			child.matrixWorld.multiply( object.matrixWorld, child.matrix );
-			
-			updateChildren( child );
-		
-		}
-	
 	};
 	};
 	
 	
 	this.render = function( scene, camera, renderTarget, clear ) {
 	this.render = function( scene, camera, renderTarget, clear ) {
-
+		
 		var i, program, opaque, transparent,
 		var i, program, opaque, transparent,
 			o, ol, oil, webGLObject, object, buffer,
 			o, ol, oil, webGLObject, object, buffer,
 			lights = scene.lights,
 			lights = scene.lights,
 			fog = scene.fog,
 			fog = scene.fog,
 			ol;
 			ol;
 		
 		
-		camera.autoUpdateMatrix && camera.updateMatrix();
+		camera.autoUpdateMatrix && camera.update();
 		
 		
-		camera.matrix.flattenToArray( _viewMatrixArray );
+		camera.globalMatrix.flattenToArray( _viewMatrixArray );
 		camera.projectionMatrix.flattenToArray( _projectionMatrixArray );
 		camera.projectionMatrix.flattenToArray( _projectionMatrixArray );
 
 
-		_projScreenMatrix.multiply( camera.projectionMatrix, camera.matrix );
+		_projScreenMatrix.multiply( camera.projectionMatrix, camera.globalMatrix );
 		computeFrustum( _projScreenMatrix );
 		computeFrustum( _projScreenMatrix );
 		
 		
+		scene.update( undefined, false, camera, this );
+		
 		this.initWebGLObjects( scene, camera );
 		this.initWebGLObjects( scene, camera );
 
 
 		setRenderTarget( renderTarget, clear !== undefined ? clear : true );
 		setRenderTarget( renderTarget, clear !== undefined ? clear : true );
@@ -1498,20 +1491,11 @@ THREE.WebGLRenderer = function ( parameters ) {
 			webGLObject = scene.__webGLObjects[ o ];
 			webGLObject = scene.__webGLObjects[ o ];
 			object = webGLObject.object;
 			object = webGLObject.object;
 
 
-			if ( object.visible ) {
-				
-				if ( webGLObject.root ) {
-			
-					object.autoUpdateMatrix && object.updateMatrix();
-					object.matrixWorld.copy( object.matrix );
-				
-					updateChildren( object );
-					
-				}
+			if ( object.visible ) {				
 
 
 				if ( ! ( object instanceof THREE.Mesh ) || isInFrustum( object ) ) {
 				if ( ! ( object instanceof THREE.Mesh ) || isInFrustum( object ) ) {
 					
 					
-					object.matrixWorld.flattenToArray( object._objectMatrixArray );
+					object.globalMatrix.flattenToArray( object._objectMatrixArray );
 					
 					
 					setupMatrices( object, camera );
 					setupMatrices( object, camera );
 					
 					
@@ -1519,6 +1503,14 @@ THREE.WebGLRenderer = function ( parameters ) {
 					
 					
 					webGLObject.render = true;
 					webGLObject.render = true;
 					
 					
+					if ( this.sortObjects ) {
+					
+						_vector3.copy( object.position );
+						_projScreenMatrix.multiplyVector3( _vector3 );
+
+						webGLObject.z = _vector3.z;
+					
+					}
 				
 				
 				} else {
 				} else {
 					
 					
@@ -1534,6 +1526,12 @@ THREE.WebGLRenderer = function ( parameters ) {
 		
 		
 		}
 		}
 		
 		
+		if ( this.sortObjects ) {
+			
+			scene.__webGLObjects.sort( painterSort );
+			
+		}
+		
 		oil = scene.__webGLObjectsImmediate.length;
 		oil = scene.__webGLObjectsImmediate.length;
 		
 		
 		for ( o = 0; o < oil; o++ ) {
 		for ( o = 0; o < oil; o++ ) {
@@ -1545,9 +1543,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			
 			
 				if( object.autoUpdateMatrix ) { 
 				if( object.autoUpdateMatrix ) { 
 				
 				
-					object.updateMatrix();
-					object.matrixWorld.copy( object.matrix );
-					object.matrixWorld.flattenToArray( object._objectMatrixArray );
+					object.globalMatrix.flattenToArray( object._objectMatrixArray );
 				
 				
 				}
 				}
 				
 				
@@ -1681,22 +1677,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	};
 	};
 
 
-	function addChildren( scene, object ) {
-	
-		var i, l, children = object.children;
-		
-		for ( i = 0, l = children.length; i < l; i ++ ) {
-
-			child = children[ i ];
-
-			addObject( scene, child, false );
-			addChildren( scene, child );
-		
-		}
-
-	};
-
-	function addObject( scene, object, root ) {
+	function addObject( scene, object ) {
 		
 		
 		var g, geometry, geometryChunk, objmap;
 		var g, geometry, geometryChunk, objmap;
 		
 		
@@ -1712,7 +1693,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			object._modelViewMatrixArray = new Float32Array( 16 );
 			object._modelViewMatrixArray = new Float32Array( 16 );
 			object._objectMatrixArray = new Float32Array( 16 );
 			object._objectMatrixArray = new Float32Array( 16 );
 			
 			
-			object.matrix.flattenToArray( object._objectMatrixArray );
+			object.globalMatrix.flattenToArray( object._objectMatrixArray );
 
 
 		}
 		}
 
 
@@ -1753,7 +1734,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 				// create separate wrapper per each use of VBO
 				// create separate wrapper per each use of VBO
 
 
-				add_buffer( objlist, objmap, g, geometryChunk, object, root );
+				add_buffer( objlist, objmap, g, geometryChunk, object );
 
 
 			}
 			}
 
 
@@ -1782,7 +1763,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			}
 			}
 
 
-			add_buffer( objlist, objmap, 0, geometry, object, root );
+			add_buffer( objlist, objmap, 0, geometry, object );
 
 
 			geometry.__dirtyVertices = false;
 			geometry.__dirtyVertices = false;
 			geometry.__dirtyColors = false;
 			geometry.__dirtyColors = false;
@@ -1805,14 +1786,14 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			}
 			}
 
 
-			add_buffer( objlist, objmap, 0, geometry, object, root );
+			add_buffer( objlist, objmap, 0, geometry, object );
 
 
 			geometry.__dirtyVertices = false;
 			geometry.__dirtyVertices = false;
 			geometry.__dirtyColors = false;
 			geometry.__dirtyColors = false;
 
 
 		} else if ( object instanceof THREE.MarchingCubes ) {
 		} else if ( object instanceof THREE.MarchingCubes ) {
 			
 			
-			add_buffer_immediate( scene.__webGLObjectsImmediate, objmap, 0, object, root );
+			add_buffer_immediate( scene.__webGLObjectsImmediate, objmap, 0, object );
 			
 			
 		}/*else if ( object instanceof THREE.Particle ) {
 		}/*else if ( object instanceof THREE.Particle ) {
 
 
@@ -1820,14 +1801,13 @@ THREE.WebGLRenderer = function ( parameters ) {
 		
 		
 	};
 	};
 
 
-	function add_buffer( objlist, objmap, id, buffer, object, root ) {
+	function add_buffer( objlist, objmap, id, buffer, object ) {
 
 
 		if ( objmap[ id ] == undefined ) {
 		if ( objmap[ id ] == undefined ) {
 
 
 			objlist.push( { buffer: buffer, object: object, 
 			objlist.push( { buffer: buffer, object: object, 
 							opaque: { list: [], count: 0 }, 
 							opaque: { list: [], count: 0 }, 
-							transparent: { list: [], count: 0 },
-							root: root
+							transparent: { list: [], count: 0 }
 						} );
 						} );
 			
 			
 			objmap[ id ] = 1;
 			objmap[ id ] = 1;
@@ -1836,14 +1816,13 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	};
 	};
 
 
-	function add_buffer_immediate( objlist, objmap, id, object, root ) {
+	function add_buffer_immediate( objlist, objmap, id, object ) {
 
 
 		if ( objmap[ id ] == undefined ) {
 		if ( objmap[ id ] == undefined ) {
 
 
 			objlist.push( { object: object, 
 			objlist.push( { object: object, 
 							opaque: { list: [], count: 0 }, 
 							opaque: { list: [], count: 0 }, 
-							transparent: { list: [], count: 0 },
-							root: root
+							transparent: { list: [], count: 0 }
 						} );
 						} );
 			
 			
 			objmap[ id ] = 1;
 			objmap[ id ] = 1;
@@ -1869,8 +1848,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			object = scene.objects[ o ];
 			object = scene.objects[ o ];
 
 
-			addObject( scene, object, true );
-			addChildren( scene, object );
+			addObject( scene, object );
 		
 		
 		}
 		}
 
 
@@ -1894,9 +1872,21 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	};
 	};
 
 
+	this.addToRenderList = function( object ) {
+		
+		// TODO: implement this
+		
+	};
+
+	this.removeFromRenderList = function( object ) {
+		
+		// TODO: implement this
+		
+	};
+	
 	function setupMatrices ( object, camera ) {
 	function setupMatrices ( object, camera ) {
 
 
-		object._modelViewMatrix.multiplyToArray( camera.matrix, object.matrixWorld, object._modelViewMatrixArray );
+		object._modelViewMatrix.multiplyToArray( camera.globalMatrix, object.globalMatrix, object._modelViewMatrixArray );
 		object._normalMatrix = THREE.Matrix4.makeInvert3x3( object._modelViewMatrix ).transposeIntoArray( object._normalMatrixArray );
 		object._normalMatrix = THREE.Matrix4.makeInvert3x3( object._modelViewMatrix ).transposeIntoArray( object._normalMatrixArray );
 
 
 	};
 	};

+ 71 - 36
src/scenes/Scene.js

@@ -1,65 +1,100 @@
 /**
 /**
  * @author mr.doob / http://mrdoob.com/
  * @author mr.doob / http://mrdoob.com/
+ * @author mikael emtinger / http://gomo.se/
  */
  */
 
 
-THREE.Scene = function () {
+THREE.Scene = function() {
+	
+	// call super
+	
+	THREE.Object3D.call( this );
 
 
-	this.objects = [];
-	this.lights = [];
-	this.fog = null;
-
-	this.addObject = function ( object ) {
-
-		var i = this.objects.indexOf( object );
-
-		if ( i === -1 ) {
+	// vars
 
 
-			this.objects.push( object );
-
-		}
-
-	};
+	this.objects = [];
+	this.lights  = [];
+	this.fog     = null;
 
 
-	this.removeObject = function ( object ) {
+};
 
 
-		var i = this.objects.indexOf( object );
+THREE.Scene.prototype             = new THREE.Object3D();
+THREE.Scene.prototype.constructor = THREE.Scene;
+THREE.Scene.prototype.supr        = THREE.Object3D.prototype;
 
 
-		if ( i !== -1 ) {
+/*
+ * Add Child
+ */
 
 
-			this.objects.splice( i, 1 );
+THREE.Scene.prototype.addChild = function( child ) {
 
 
-		}
+	this.supr.addChild.call( this, child );
+	this.addChildRecurse( child );
 
 
-	};
+}
 
 
-	this.addLight = function ( light ) {
+THREE.Scene.prototype.addChildRecurse = function( object ) {
+	
+	
+	if( object instanceof THREE.Light ) {
+			
+		if( this.lights.indexOf( object ) === -1 )
+			this.lights.push( object );	
 
 
-		var i = this.lights.indexOf( light );
+	} else if( !( object instanceof THREE.Camera ) ) {
+		
+		if( this.objects.indexOf( object ) === -1 )
+			this.objects.push( object );
 
 
-		if ( i === -1 ) {
+	}
+	
+	for( var c = 0; c < object.children.length; c++ )
+		this.addChildRecurse( object.children[ c ] );
 
 
-			this.lights.push( light );
+}
 
 
-		}
 
 
-	};
+/*
+ * Remove Child
+ */
 
 
-	this.removeLight = function ( light ) {
+THREE.Scene.prototype.removeChild = function( child ) {
 
 
-		var i = this.lights.indexOf( light );
+	this.supr.removeChild.call( this, child );
+	this.removeChildRecurse( child );
 
 
-		if ( i !== -1 ) {
+}
 
 
+THREE.Scene.prototype.removeChildRecurse = function( child ) {
+	
+	if( object instanceof THREE.Light ) {
+		
+		var i = this.lights.indexOf( object );
+		
+		if( i === -1 )
 			this.lights.splice( i, 1 );
 			this.lights.splice( i, 1 );
 
 
-		}
+	} else if( !( object instanceof THREE.Camera ) ) {
+		
+		var i = this.objects.indexOf( object );
+		
+		if( i === -1 )
+			this.objects.splice( i, 1 );
 
 
-	};
+	}
+	
+	for( var c = 0; c < object.children.length; c++ )
+		this.removeChildRecurse( object.children[ c ] );
 
 
-	this.toString = function () {
+}
 
 
-		return 'THREE.Scene ( ' + this.objects + ' )';
 
 
-	};
 
 
-};
+/*
+ * Backward Compatibility
+ */
+
+THREE.Scene.prototype.addObject    = THREE.Scene.prototype.addChild;
+THREE.Scene.prototype.removeObject = THREE.Scene.prototype.removeChild;
+THREE.Scene.prototype.addLight     = THREE.Scene.prototype.addChild;
+THREE.Scene.prototype.removeLight  = THREE.Scene.prototype.removeChild;
+