Browse Source

More refactoring and optimizations.

- removed unnecessary normal matrix computation in hierarchies (this is already done in renderer)
- removed unnecessary enabling of attribute arrays in every frame (it's enough to do it when shader program is created)
- depth test is now only set if it changed
alteredq 14 years ago
parent
commit
313ce3ed94

+ 165 - 166
build/Three.js

@@ -1,6 +1,6 @@
 // Three.js r32 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=!0;this.setHex(a)};
-THREE.Color.prototype={setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var e,g,h,l,m,k;if(c==0)e=g=h=0;else{l=Math.floor(a*6);m=a*6-l;a=c*(1-b);k=c*(1-b*m);b=c*(1-b*(1-m));switch(l){case 1:e=k;g=c;h=a;break;case 2:e=a;g=c;h=b;break;case 3:e=a;g=k;h=c;break;case 4:e=b;g=a;h=c;break;case 5:e=c;g=a;h=k;break;case 6:case 0:e=c;g=b;h=a}}this.r=e;this.g=g;this.b=h;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
+THREE.Color.prototype={setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var e,g,i,l,n,k;if(c==0)e=g=i=0;else{l=Math.floor(a*6);n=a*6-l;a=c*(1-b);k=c*(1-b*n);b=c*(1-b*(1-n));switch(l){case 1:e=k;g=c;i=a;break;case 2:e=a;g=c;i=b;break;case 3:e=a;g=k;i=c;break;case 4:e=b;g=a;i=c;break;case 5:e=c;g=a;i=k;break;case 6:case 0:e=c;g=b;i=a}}this.r=e;this.g=g;this.b=i;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: "+
 this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
@@ -13,93 +13,92 @@ this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,b,c,e){this.x=a||
 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+")"}};
 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];c instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(c)))}g.sort(function(h,l){return h.distance-l.distance});return g},intersectObject:function(a){function b(J,r,d,I){I=I.clone().subSelf(r);d=d.clone().subSelf(r);var S=J.clone().subSelf(r);J=I.dot(I);r=I.dot(d);I=I.dot(S);var V=d.dot(d);d=d.dot(S);S=1/(J*V-r*r);V=(V*I-r*d)*S;J=(J*d-r*I)*S;return V>0&&J>0&&V+J<1}var c,e,g,h,l,m,k,o,u,x,
-v,A=a.geometry,K=A.vertices,N=[];c=0;for(e=A.faces.length;c<e;c++){g=A.faces[c];x=this.origin.clone();v=this.direction.clone();k=a.globalMatrix;k.extractRotationMatrix(a.rotationMatrix);h=k.multiplyVector3(K[g.a].position.clone());l=k.multiplyVector3(K[g.b].position.clone());m=k.multiplyVector3(K[g.c].position.clone());k=g instanceof THREE.Face4?k.multiplyVector3(K[g.d].position.clone()):null;o=a.rotationMatrix.multiplyVector3(g.normal.clone());u=v.dot(o);if(u<0){o=o.dot((new THREE.Vector3).sub(h,
-x))/u;x=x.addSelf(v.multiplyScalar(o));if(g instanceof THREE.Face3){if(b(x,h,l,m)){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};N.push(g)}}else if(g instanceof THREE.Face4&&(b(x,h,l,k)||b(x,l,m,k))){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};N.push(g)}}}return N}};
-THREE.Rectangle=function(){function a(){h=e-b;l=g-c}var b,c,e,g,h,l,m=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return l};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(k,o,u,x){m=!1;b=k;c=o;e=u;g=x;a()};this.addPoint=function(k,o){if(m){m=!1;b=k;c=o;e=k;g=o}else{b=b<k?b:k;c=c<o?c:o;e=e>k?e:k;g=g>o?g:o}a()};
-this.add3Points=function(k,o,u,x,v,A){if(m){m=!1;b=k<u?k<v?k:v:u<v?u:v;c=o<x?o<A?o:A:x<A?x:A;e=k>u?k>v?k:v:u>v?u:v;g=o>x?o>A?o:A:x>A?x:A}else{b=k<u?k<v?k<b?k:b:v<b?v:b:u<v?u<b?u:b:v<b?v:b;c=o<x?o<A?o<c?o:c:A<c?A:c:x<A?x<c?x:c:A<c?A:c;e=k>u?k>v?k>e?k:e:v>e?v:e:u>v?u>e?u:e:v>e?v:e;g=o>x?o>A?o>g?o:g:A>g?A:g:x>A?x>g?x:g:A>g?A:g}a()};this.addRectangle=function(k){if(m){m=!1;b=k.getLeft();c=k.getTop();e=k.getRight();g=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();c=c<k.getTop()?c:k.getTop();e=e>k.getRight()?
-e:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;c-=k;e+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();c=c>k.getTop()?c:k.getTop();e=e<k.getRight()?e:k.getRight();g=g<k.getBottom()?g:k.getBottom();a()};this.instersects=function(k){return Math.min(e,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(g,k.getBottom())-Math.max(c,k.getTop())>=0};this.empty=function(){m=!0;g=e=c=b=0;a()};this.isEmpty=function(){return m};this.toString=function(){return"THREE.Rectangle ( left: "+
-b+", right: "+e+", top: "+c+", bottom: "+g+", width: "+h+", height: "+l+" )"}};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,h,l,m,k,o,u,x,v,A,K,N){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=e||0;this.n21=g||0;this.n22=h||1;this.n23=l||0;this.n24=m||0;this.n31=k||0;this.n32=o||0;this.n33=u||1;this.n34=x||0;this.n41=v||0;this.n42=A||0;this.n43=K||0;this.n44=N||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,h,l,m,k,o,u,x,v,A,K,N){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=g;this.n22=h;this.n23=l;this.n24=m;this.n31=k;this.n32=o;this.n33=u;this.n34=x;this.n41=v;this.n42=A;this.n43=K;this.n44=N;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,h=THREE.Matrix4.__tmpVec3;h.sub(a,b).normalize();e.cross(c,h).normalize();g.cross(h,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=h.x;this.n32=h.y;this.n33=h.z;this.n34=-h.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},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*
+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];c instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(c)))}g.sort(function(i,l){return i.distance-l.distance});return g},intersectObject:function(a){function b(G,r,Z,D){D=D.clone().subSelf(r);Z=Z.clone().subSelf(r);var K=G.clone().subSelf(r);G=D.dot(D);r=D.dot(Z);D=D.dot(K);var d=Z.dot(Z);Z=Z.dot(K);K=1/(G*d-r*r);d=(d*D-r*Z)*K;G=(G*Z-r*D)*K;return d>0&&G>0&&d+G<1}var c,e,g,i,l,n,k,o,s,w,
+t,x=a.geometry,F=x.vertices,H=[];c=0;for(e=x.faces.length;c<e;c++){g=x.faces[c];w=this.origin.clone();t=this.direction.clone();k=a.globalMatrix;k.extractRotationMatrix(a.rotationMatrix);i=k.multiplyVector3(F[g.a].position.clone());l=k.multiplyVector3(F[g.b].position.clone());n=k.multiplyVector3(F[g.c].position.clone());k=g instanceof THREE.Face4?k.multiplyVector3(F[g.d].position.clone()):null;o=a.rotationMatrix.multiplyVector3(g.normal.clone());s=t.dot(o);if(s<0){o=o.dot((new THREE.Vector3).sub(i,
+w))/s;w=w.addSelf(t.multiplyScalar(o));if(g instanceof THREE.Face3){if(b(w,i,l,n)){g={distance:this.origin.distanceTo(w),point:w,face:g,object:a};H.push(g)}}else if(g instanceof THREE.Face4&&(b(w,i,l,k)||b(w,l,n,k))){g={distance:this.origin.distanceTo(w),point:w,face:g,object:a};H.push(g)}}}return H}};
+THREE.Rectangle=function(){function a(){i=e-b;l=g-c}var b,c,e,g,i,l,n=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return i};this.getHeight=function(){return l};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(k,o,s,w){n=!1;b=k;c=o;e=s;g=w;a()};this.addPoint=function(k,o){if(n){n=!1;b=k;c=o;e=k;g=o}else{b=b<k?b:k;c=c<o?c:o;e=e>k?e:k;g=g>o?g:o}a()};
+this.add3Points=function(k,o,s,w,t,x){if(n){n=!1;b=k<s?k<t?k:t:s<t?s:t;c=o<w?o<x?o:x:w<x?w:x;e=k>s?k>t?k:t:s>t?s:t;g=o>w?o>x?o:x:w>x?w:x}else{b=k<s?k<t?k<b?k:b:t<b?t:b:s<t?s<b?s:b:t<b?t:b;c=o<w?o<x?o<c?o:c:x<c?x:c:w<x?w<c?w:c:x<c?x:c;e=k>s?k>t?k>e?k:e:t>e?t:e:s>t?s>e?s:e:t>e?t:e;g=o>w?o>x?o>g?o:g:x>g?x:g:w>x?w>g?w:g:x>g?x:g}a()};this.addRectangle=function(k){if(n){n=!1;b=k.getLeft();c=k.getTop();e=k.getRight();g=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();c=c<k.getTop()?c:k.getTop();e=e>k.getRight()?
+e:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;c-=k;e+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();c=c>k.getTop()?c:k.getTop();e=e<k.getRight()?e:k.getRight();g=g<k.getBottom()?g:k.getBottom();a()};this.instersects=function(k){return Math.min(e,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(g,k.getBottom())-Math.max(c,k.getTop())>=0};this.empty=function(){n=!0;g=e=c=b=0;a()};this.isEmpty=function(){return n};this.toString=function(){return"THREE.Rectangle ( left: "+
+b+", right: "+e+", top: "+c+", bottom: "+g+", width: "+i+", height: "+l+" )"}};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,i,l,n,k,o,s,w,t,x,F,H){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=e||0;this.n21=g||0;this.n22=i||1;this.n23=l||0;this.n24=n||0;this.n31=k||0;this.n32=o||0;this.n33=s||1;this.n34=w||0;this.n41=t||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,b,c,e,g,i,l,n,k,o,s,w,t,x,F,H){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=g;this.n22=i;this.n23=l;this.n24=n;this.n31=k;this.n32=o;this.n33=s;this.n34=w;this.n41=t;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,b,c){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,i=THREE.Matrix4.__tmpVec3;i.sub(a,b).normalize();e.cross(c,i).normalize();g.cross(i,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=i.x;this.n32=i.y;this.n33=i.z;this.n34=-i.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;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},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*
 a+this.n44))},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,h=a.n14,l=a.n21,m=a.n22,k=a.n23,o=a.n24,u=a.n31,x=a.n32,v=a.n33,A=a.n34,K=a.n41,N=a.n42,J=a.n43,r=a.n44,d=b.n11,I=b.n12,S=b.n13,V=b.n14,ea=b.n21,T=b.n22,M=b.n23,aa=b.n24,R=b.n31,ca=b.n32,W=b.n33,E=b.n34,O=b.n41,ia=b.n42,Q=b.n43,f=b.n44;this.n11=c*d+e*ea+g*R+h*O;this.n12=c*I+e*T+g*ca+h*ia;this.n13=c*S+e*M+g*W+h*Q;this.n14=c*V+e*aa+g*E+h*f;this.n21=l*d+m*ea+k*R+o*O;this.n22=l*I+m*T+k*ca+o*ia;this.n23=
-l*S+m*M+k*W+o*Q;this.n24=l*V+m*aa+k*E+o*f;this.n31=u*d+x*ea+v*R+A*O;this.n32=u*I+x*T+v*ca+A*ia;this.n33=u*S+x*M+v*W+A*Q;this.n34=u*V+x*aa+v*E+A*f;this.n41=K*d+N*ea+J*R+r*O;this.n42=K*I+N*T+J*ca+r*ia;this.n43=K*S+N*M+J*W+r*Q;this.n44=K*V+N*aa+J*E+r*f;return this},multiplyToArray:function(a,b,c){var e=a.n11,g=a.n12,h=a.n13,l=a.n14,m=a.n21,k=a.n22,o=a.n23,u=a.n24,x=a.n31,v=a.n32,A=a.n33,K=a.n34,N=a.n41,J=a.n42,r=a.n43;a=a.n44;var d=b.n11,I=b.n12,S=b.n13,V=b.n14,ea=b.n21,T=b.n22,M=b.n23,aa=b.n24,R=b.n31,
-ca=b.n32,W=b.n33,E=b.n34,O=b.n41,ia=b.n42,Q=b.n43;b=b.n44;this.n11=e*d+g*ea+h*R+l*O;this.n12=e*I+g*T+h*ca+l*ia;this.n13=e*S+g*M+h*W+l*Q;this.n14=e*V+g*aa+h*E+l*b;this.n21=m*d+k*ea+o*R+u*O;this.n22=m*I+k*T+o*ca+u*ia;this.n23=m*S+k*M+o*W+u*Q;this.n24=m*V+k*aa+o*E+u*b;this.n31=x*d+v*ea+A*R+K*O;this.n32=x*I+v*T+A*ca+K*ia;this.n33=x*S+v*M+A*W+K*Q;this.n34=x*V+v*aa+A*E+K*b;this.n41=N*d+J*ea+r*R+a*O;this.n42=N*I+J*T+r*ca+a*ia;this.n43=N*S+J*M+r*W+a*Q;this.n44=N*V+J*aa+r*E+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,h=this.n21,l=this.n22,m=this.n23,k=this.n24,o=this.n31,u=this.n32,x=this.n33,v=this.n34,A=this.n41,K=this.n42,N=this.n43,J=this.n44,r=a.n11,d=a.n21,I=a.n31,S=a.n41,V=a.n12,ea=a.n22,T=a.n32,M=a.n42,aa=a.n13,R=a.n23,
-ca=a.n33,W=a.n43,E=a.n14,O=a.n24,ia=a.n34;a=a.n44;this.n11=b*r+c*d+e*I+g*S;this.n12=b*V+c*ea+e*T+g*M;this.n13=b*aa+c*R+e*ca+g*W;this.n14=b*E+c*O+e*ia+g*a;this.n21=h*r+l*d+m*I+k*S;this.n22=h*V+l*ea+m*T+k*M;this.n23=h*aa+l*R+m*ca+k*W;this.n24=h*E+l*O+m*ia+k*a;this.n31=o*r+u*d+x*I+v*S;this.n32=o*V+u*ea+x*T+v*M;this.n33=o*aa+u*R+x*ca+v*W;this.n34=o*E+u*O+x*ia+v*a;this.n41=A*r+K*d+N*I+J*S;this.n42=A*V+K*ea+N*T+J*M;this.n43=A*aa+K*R+N*ca+J*W;this.n44=A*E+K*O+N*ia+J*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,h=this.n22,l=this.n23,m=this.n24,k=this.n31,o=this.n32,u=this.n33,x=this.n34,v=this.n41,A=this.n42,K=this.n43,N=this.n44;return e*l*o*v-c*m*o*v-e*h*u*v+b*m*u*v+c*h*x*v-b*l*x*v-e*l*k*A+c*m*k*A+e*g*u*A-a*m*u*A-c*g*x*A+a*l*x*A+
-e*h*k*K-b*m*k*K-e*g*o*K+a*m*o*K+b*g*x*K-a*h*x*K-c*h*k*N+b*l*k*N+c*g*o*N-a*l*o*N-b*g*u*N+a*h*u*N},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.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,i=a.n14,l=a.n21,n=a.n22,k=a.n23,o=a.n24,s=a.n31,w=a.n32,t=a.n33,x=a.n34,F=a.n41,H=a.n42,G=a.n43,r=a.n44,Z=b.n11,D=b.n12,K=b.n13,d=b.n14,ga=b.n21,T=b.n22,N=b.n23,ba=b.n24,R=b.n31,aa=b.n32,V=b.n33,B=b.n34,I=b.n41,ka=b.n42,P=b.n43,ja=b.n44;this.n11=c*Z+e*ga+g*R+i*I;this.n12=c*D+e*T+g*aa+i*ka;this.n13=c*K+e*N+g*V+i*P;this.n14=c*d+e*ba+g*B+i*ja;this.n21=l*Z+n*ga+k*R+o*I;this.n22=l*D+n*T+k*aa+o*ka;
+this.n23=l*K+n*N+k*V+o*P;this.n24=l*d+n*ba+k*B+o*ja;this.n31=s*Z+w*ga+t*R+x*I;this.n32=s*D+w*T+t*aa+x*ka;this.n33=s*K+w*N+t*V+x*P;this.n34=s*d+w*ba+t*B+x*ja;this.n41=F*Z+H*ga+G*R+r*I;this.n42=F*D+H*T+G*aa+r*ka;this.n43=F*K+H*N+G*V+r*P;this.n44=F*d+H*ba+G*B+r*ja;return this},multiplyToArray:function(a,b,c){var e=a.n11,g=a.n12,i=a.n13,l=a.n14,n=a.n21,k=a.n22,o=a.n23,s=a.n24,w=a.n31,t=a.n32,x=a.n33,F=a.n34,H=a.n41,G=a.n42,r=a.n43;a=a.n44;var Z=b.n11,D=b.n12,K=b.n13,d=b.n14,ga=b.n21,T=b.n22,N=b.n23,ba=
+b.n24,R=b.n31,aa=b.n32,V=b.n33,B=b.n34,I=b.n41,ka=b.n42,P=b.n43;b=b.n44;this.n11=e*Z+g*ga+i*R+l*I;this.n12=e*D+g*T+i*aa+l*ka;this.n13=e*K+g*N+i*V+l*P;this.n14=e*d+g*ba+i*B+l*b;this.n21=n*Z+k*ga+o*R+s*I;this.n22=n*D+k*T+o*aa+s*ka;this.n23=n*K+k*N+o*V+s*P;this.n24=n*d+k*ba+o*B+s*b;this.n31=w*Z+t*ga+x*R+F*I;this.n32=w*D+t*T+x*aa+F*ka;this.n33=w*K+t*N+x*V+F*P;this.n34=w*d+t*ba+x*B+F*b;this.n41=H*Z+G*ga+r*R+a*I;this.n42=H*D+G*T+r*aa+a*ka;this.n43=H*K+G*N+r*V+a*P;this.n44=H*d+G*ba+r*B+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,i=this.n21,l=this.n22,n=this.n23,k=this.n24,o=this.n31,s=this.n32,w=this.n33,t=this.n34,x=this.n41,F=this.n42,H=this.n43,G=this.n44,r=a.n11,Z=a.n21,D=a.n31,K=a.n41,d=a.n12,ga=a.n22,T=a.n32,N=a.n42,ba=
+a.n13,R=a.n23,aa=a.n33,V=a.n43,B=a.n14,I=a.n24,ka=a.n34;a=a.n44;this.n11=b*r+c*Z+e*D+g*K;this.n12=b*d+c*ga+e*T+g*N;this.n13=b*ba+c*R+e*aa+g*V;this.n14=b*B+c*I+e*ka+g*a;this.n21=i*r+l*Z+n*D+k*K;this.n22=i*d+l*ga+n*T+k*N;this.n23=i*ba+l*R+n*aa+k*V;this.n24=i*B+l*I+n*ka+k*a;this.n31=o*r+s*Z+w*D+t*K;this.n32=o*d+s*ga+w*T+t*N;this.n33=o*ba+s*R+w*aa+t*V;this.n34=o*B+s*I+w*ka+t*a;this.n41=x*r+F*Z+H*D+G*K;this.n42=x*d+F*ga+H*T+G*N;this.n43=x*ba+F*R+H*aa+G*V;this.n44=x*B+F*I+H*ka+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,b=this.n12,c=this.n13,e=this.n14,g=this.n21,i=this.n22,l=this.n23,n=this.n24,k=this.n31,o=this.n32,s=this.n33,w=this.n34,t=this.n41,x=this.n42,F=this.n43,H=this.n44;return e*l*o*t-c*n*o*t-e*i*s*t+b*n*s*t+c*i*w*t-b*l*w*t-e*l*k*x+c*n*k*x+e*g*s*x-a*n*s*x-c*g*w*x+a*l*w*x+
+e*i*k*F-b*n*k*F-e*g*o*F+a*n*o*F+b*g*w*F-a*i*w*F-c*i*k*H+b*l*k*H+c*g*o*H-a*l*o*H-b*g*s*H+a*i*s*H},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;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},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+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),g=1-c,h=a.x,l=a.y,m=a.z,k=g*
-h,o=g*l;this.set(k*h+c,k*l-e*m,k*m+e*l,0,k*l+e*m,o*l+c,o*m-e*h,0,k*m-e*l,o*m+e*h,g*m*m+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,e=a.z;a=Math.cos(c);c=Math.sin(c);var g=Math.cos(-e);e=Math.sin(-e);var h=Math.cos(b);b=Math.sin(b);var l=a*e,m=c*e;this.n11=a*g;this.n12=c*b-l*h;this.n13=l*b+c*h;this.n21=e;this.n22=g*h;this.n23=-g*b;this.n31=-c*g;this.n32=m*h+a*b;this.n33=-m*b+a*h},setRotationFromQuaternion:function(a){var b=
-a.x,c=a.y,e=a.z,g=a.w,h=b+b,l=c+c,m=e+e;a=b*h;var k=b*l;b*=m;var o=c*l;c*=m;e*=m;h*=g;l*=g;g*=m;this.n11=1-(o+e);this.n12=k-g;this.n13=b+l;this.n21=k+g;this.n22=1-(a+e);this.n23=c-h;this.n31=b-l;this.n32=c+h;this.n33=1-(a+o)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=b;this.n13*=b;this.n21*=c;this.n22*=c;this.n23*=c;this.n31*=a;this.n32*=a;this.n33*=a;return this},extractRotationMatrix:function(a){a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=0;a.n21=this.n21;a.n22=this.n22;
+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,i=a.x,l=a.y,n=a.z,k=g*
+i,o=g*l;this.set(k*i+c,k*l-e*n,k*n+e*l,0,k*l+e*n,o*l+c,o*n-e*i,0,k*n-e*l,o*n+e*i,g*n*n+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,e=a.z;a=Math.cos(c);c=Math.sin(c);var g=Math.cos(-e);e=Math.sin(-e);var i=Math.cos(b);b=Math.sin(b);var l=a*e,n=c*e;this.n11=a*g;this.n12=c*b-l*i;this.n13=l*b+c*i;this.n21=e;this.n22=g*i;this.n23=-g*b;this.n31=-c*g;this.n32=n*i+a*b;this.n33=-n*b+a*i},setRotationFromQuaternion:function(a){var b=
+a.x,c=a.y,e=a.z,g=a.w,i=b+b,l=c+c,n=e+e;a=b*i;var k=b*l;b*=n;var o=c*l;c*=n;e*=n;i*=g;l*=g;g*=n;this.n11=1-(o+e);this.n12=k-g;this.n13=b+l;this.n21=k+g;this.n22=1-(a+e);this.n23=c-i;this.n31=b-l;this.n32=c+i;this.n33=1-(a+o)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=b;this.n13*=b;this.n21*=c;this.n22*=c;this.n23*=c;this.n31*=a;this.n32*=a;this.n33*=a;return this},extractRotationMatrix:function(a){a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=0;a.n21=this.n21;a.n22=this.n22;
 a.n23=this.n23;a.n24=0;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=0;a.n41=0;a.n42=0;a.n43=0;a.n44=1},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.makeInvert=function(a,b){var c=a.n11,e=a.n12,g=a.n13,h=a.n14,l=a.n21,m=a.n22,k=a.n23,o=a.n24,u=a.n31,x=a.n32,v=a.n33,A=a.n34,K=a.n41,N=a.n42,J=a.n43,r=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=k*A*N-o*v*N+o*x*J-m*A*J-k*x*r+m*v*r;b.n12=h*v*N-g*A*N-h*x*J+e*A*J+g*x*r-e*v*r;b.n13=g*o*N-h*k*N+h*m*J-e*o*J-g*m*r+e*k*r;b.n14=h*k*x-g*o*x-h*m*v+e*o*v+g*m*A-e*k*A;b.n21=o*v*K-k*A*K-o*u*J+l*A*J+k*u*r-l*v*r;b.n22=g*A*K-h*v*K+h*u*J-c*A*J-g*u*r+c*v*r;b.n23=h*k*K-g*o*K-h*l*J+c*o*J+g*l*r-c*k*r;
-b.n24=g*o*u-h*k*u+h*l*v-c*o*v-g*l*A+c*k*A;b.n31=m*A*K-o*x*K+o*u*N-l*A*N-m*u*r+l*x*r;b.n32=h*x*K-e*A*K-h*u*N+c*A*N+e*u*r-c*x*r;b.n33=g*o*K-h*m*K+h*l*N-c*o*N-e*l*r+c*m*r;b.n34=h*m*u-e*o*u-h*l*x+c*o*x+e*l*A-c*m*A;b.n41=k*x*K-m*v*K-k*u*N+l*v*N+m*u*J-l*x*J;b.n42=e*v*K-g*x*K+g*u*N-c*v*N-e*u*J+c*x*J;b.n43=g*m*K-e*k*K-g*l*N+c*k*N+e*l*J-c*m*J;b.n44=e*k*u-g*m*u+g*l*x-c*k*x-e*l*v+c*m*v;b.multiplyScalar(1/a.determinant());return b};
-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,h=a.n32*a.n21-a.n31*a.n22,l=-a.n33*a.n12+a.n32*a.n13,m=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,o=a.n23*a.n12-a.n22*a.n13,u=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*l+a.n31*o;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*g;c[2]=a*h;c[3]=a*l;c[4]=a*m;c[5]=a*k;c[6]=a*o;c[7]=a*u;c[8]=a*x;return b};
-THREE.Matrix4.makeFrustum=function(a,b,c,e,g,h){var l;l=new THREE.Matrix4;l.n11=2*g/(b-a);l.n12=0;l.n13=(b+a)/(b-a);l.n14=0;l.n21=0;l.n22=2*g/(e-c);l.n23=(e+c)/(e-c);l.n24=0;l.n31=0;l.n32=0;l.n33=-(h+g)/(h-g);l.n34=-2*h*g/(h-g);l.n41=0;l.n42=0;l.n43=-1;l.n44=0;return l};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,h){var l,m,k,o;l=new THREE.Matrix4;m=b-a;k=c-e;o=h-g;l.n11=2/m;l.n12=0;l.n13=0;l.n14=-((b+a)/m);l.n21=0;l.n22=2/k;l.n23=0;l.n24=-((c+e)/k);l.n31=0;l.n32=0;l.n33=-2/o;l.n34=-((h+g)/o);l.n41=0;l.n42=0;l.n43=0;l.n44=1;return l};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,e=a.n12,g=a.n13,i=a.n14,l=a.n21,n=a.n22,k=a.n23,o=a.n24,s=a.n31,w=a.n32,t=a.n33,x=a.n34,F=a.n41,H=a.n42,G=a.n43,r=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=k*x*H-o*t*H+o*w*G-n*x*G-k*w*r+n*t*r;b.n12=i*t*H-g*x*H-i*w*G+e*x*G+g*w*r-e*t*r;b.n13=g*o*H-i*k*H+i*n*G-e*o*G-g*n*r+e*k*r;b.n14=i*k*w-g*o*w-i*n*t+e*o*t+g*n*x-e*k*x;b.n21=o*t*F-k*x*F-o*s*G+l*x*G+k*s*r-l*t*r;b.n22=g*x*F-i*t*F+i*s*G-c*x*G-g*s*r+c*t*r;b.n23=i*k*F-g*o*F-i*l*G+c*o*G+g*l*r-c*k*r;
+b.n24=g*o*s-i*k*s+i*l*t-c*o*t-g*l*x+c*k*x;b.n31=n*x*F-o*w*F+o*s*H-l*x*H-n*s*r+l*w*r;b.n32=i*w*F-e*x*F-i*s*H+c*x*H+e*s*r-c*w*r;b.n33=g*o*F-i*n*F+i*l*H-c*o*H-e*l*r+c*n*r;b.n34=i*n*s-e*o*s-i*l*w+c*o*w+e*l*x-c*n*x;b.n41=k*w*F-n*t*F-k*s*H+l*t*H+n*s*G-l*w*G;b.n42=e*t*F-g*w*F+g*s*H-c*t*H-e*s*G+c*w*G;b.n43=g*n*F-e*k*F-g*l*H+c*k*H+e*l*G-c*n*G;b.n44=e*k*s-g*n*s+g*l*w-c*k*w-e*l*t+c*n*t;b.multiplyScalar(1/a.determinant());return b};
+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,i=a.n32*a.n21-a.n31*a.n22,l=-a.n33*a.n12+a.n32*a.n13,n=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,o=a.n23*a.n12-a.n22*a.n13,s=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*l+a.n31*o;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*g;c[2]=a*i;c[3]=a*l;c[4]=a*n;c[5]=a*k;c[6]=a*o;c[7]=a*s;c[8]=a*w;return b};
+THREE.Matrix4.makeFrustum=function(a,b,c,e,g,i){var l;l=new THREE.Matrix4;l.n11=2*g/(b-a);l.n12=0;l.n13=(b+a)/(b-a);l.n14=0;l.n21=0;l.n22=2*g/(e-c);l.n23=(e+c)/(e-c);l.n24=0;l.n31=0;l.n32=0;l.n33=-(i+g)/(i-g);l.n34=-2*i*g/(i-g);l.n41=0;l.n42=0;l.n43=-1;l.n44=0;return l};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,i){var l,n,k,o;l=new THREE.Matrix4;n=b-a;k=c-e;o=i-g;l.n11=2/n;l.n12=0;l.n13=0;l.n14=-((b+a)/n);l.n21=0;l.n22=2/k;l.n23=0;l.n24=-((c+e)/k);l.n31=0;l.n32=0;l.n33=-2/o;l.n34=-((i+g)/o);l.n41=0;l.n42=0;l.n43=0;l.n44=1;return l};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 THREE.Quaternion=function(a,b,c,e){this.x=a||0;this.y=b||0;this.z=c||0;this.w=e!==undefined?e:1;this.api={isDirty:!1,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(g){this.that.x=g;this.isDirty=!0},set y(g){this.that.y=g;this.isDirty=!0},set z(g){this.that.z=g;this.isDirty=!0},set w(g){this.that.w=g;this.isDirty=!0}};this.api.__proto__=THREE.Quaternion.prototype;return this.api};
-THREE.Quaternion.prototype.set=function(a,b,c,e){var g=this.that;g.x=a;g.y=b;g.z=c;g.w=e;this.isDirty=!0;return this};THREE.Quaternion.prototype.setFromEuler=function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,g=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-g);g=Math.sin(-g);var h=Math.cos(c);c=Math.sin(c);var l=a*b,m=e*g,k=this.that;k.w=l*h-m*c;k.x=l*c+m*h;k.y=e*b*h+a*g*c;k.z=a*g*h-e*b*c;this.isDirty=!0;return this};
+THREE.Quaternion.prototype.set=function(a,b,c,e){var g=this.that;g.x=a;g.y=b;g.z=c;g.w=e;this.isDirty=!0;return this};THREE.Quaternion.prototype.setFromEuler=function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,g=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-g);g=Math.sin(-g);var i=Math.cos(c);c=Math.sin(c);var l=a*b,n=e*g,k=this.that;k.w=l*i-n*c;k.x=l*c+n*i;k.y=e*b*i+a*g*c;k.z=a*g*i-e*b*c;this.isDirty=!0;return this};
 THREE.Quaternion.prototype.calculateW=function(){var a=this.that,b=a.x,c=a.y,e=a.z;a.w=-Math.sqrt(Math.abs(1-b*b-c*c-e*e));this.isDirty=!0;return this};THREE.Quaternion.prototype.inverse=function(){var a=this.that;a.x*=-1;a.y*=-1;a.z*=-1;this.isDirty=!0;return this};THREE.Quaternion.prototype.length=function(){var a=this.that;return Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z+a.w*a.w)};
-THREE.Quaternion.prototype.normalize=function(){var a=this.that,b=a.x,c=a.y,e=a.z,g=a.w,h=Math.sqrt(b*b+c*c+e*e+g*g);if(h==0){a.x=0;a.y=0;a.z=0;a.w=0;this.isDirty=!0;return this}h=1/h;a.x=b*h;a.y=c*h;a.z=e*h;a.w=g*h;this.isDirty=!0;return this};
+THREE.Quaternion.prototype.normalize=function(){var a=this.that,b=a.x,c=a.y,e=a.z,g=a.w,i=Math.sqrt(b*b+c*c+e*e+g*g);if(i==0){a.x=0;a.y=0;a.z=0;a.w=0;this.isDirty=!0;return this}i=1/i;a.x=b*i;a.y=c*i;a.z=e*i;a.w=g*i;this.isDirty=!0;return this};
 THREE.Quaternion.prototype.multiplySelf=function(a){var b=this.that;qax=b.x;qay=b.y;qaz=b.z;qaw=b.w;qbx=a.x;qby=a.y;qbz=a.z;qbw=a.w;b.x=qax*qbw+qaw*qbx+qay*qbz-qaz*qby;b.y=qay*qbw+qaw*qby+qaz*qbx-qax*qbz;b.z=qaz*qbw+qaw*qbz+qax*qby-qay*qbx;b.w=qaw*qbw-qax*qbx-qay*qby-qaz*qbz;this.isDirty=!0;return this};
-THREE.Quaternion.prototype.multiplyVector3=function(a,b){b||(b=a);var c=this.that,e=a.x,g=a.y,h=a.z,l=c.x,m=c.y,k=c.z;c=c.w;var o=c*e+m*h-k*g,u=c*g+k*e-l*h,x=c*h+l*g-m*e;e=-l*e-m*g-k*h;b.x=o*c+e*-l+u*-k-x*-m;b.y=u*c+e*-m+x*-l-o*-k;b.z=x*c+e*-k+o*-m-u*-l;return b};THREE.Quaternion.prototype.toMatrix3=function(){};THREE.Quaternion.prototype.toMatrix4=function(){};
-THREE.Quaternion.slerp=function(a,b,c,e){var g=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(g)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(g),l=Math.sqrt(1-g*g);if(Math.abs(l)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}g=Math.sin((1-e)*h)/l;e=Math.sin(e*h)/l;c.w=a.w*g+b.w*e;c.x=a.x*g+b.x*e;c.y=a.y*g+b.y*e;c.z=a.z*g+b.z*e;return c};
+THREE.Quaternion.prototype.multiplyVector3=function(a,b){b||(b=a);var c=this.that,e=a.x,g=a.y,i=a.z,l=c.x,n=c.y,k=c.z;c=c.w;var o=c*e+n*i-k*g,s=c*g+k*e-l*i,w=c*i+l*g-n*e;e=-l*e-n*g-k*i;b.x=o*c+e*-l+s*-k-w*-n;b.y=s*c+e*-n+w*-l-o*-k;b.z=w*c+e*-k+o*-n-s*-l;return b};THREE.Quaternion.prototype.toMatrix3=function(){};THREE.Quaternion.prototype.toMatrix4=function(){};
+THREE.Quaternion.slerp=function(a,b,c,e){var g=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(g)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var i=Math.acos(g),l=Math.sqrt(1-g*g);if(Math.abs(l)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}g=Math.sin((1-e)*i)/l;e=Math.sin(e*i)/l;c.w=a.w*g+b.w*e;c.x=a.x*g+b.x*e;c.y=a.y*g+b.y*e;c.z=a.z*g+b.z*e;return c};
 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=!0};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.Face4=function(a,b,c,e,g,h){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=h instanceof Array?h:[h]};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,i){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=i instanceof Array?i:[i]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.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=!1};
 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,h,l,m=new THREE.Vector3,k=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){h=this.vertices[e];h.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){h=this.faces[e];if(a&&h.vertexNormals.length){m.set(0,0,0);b=0;for(c=h.normal.length;b<c;b++)m.addSelf(h.vertexNormals[b]);m.divideScalar(3)}else{b=this.vertices[h.a];c=this.vertices[h.b];l=this.vertices[h.c];m.sub(l.position,
-c.position);k.sub(b.position,c.position);m.crossSelf(k)}m.isZero()||m.normalize();h.normal.copy(m)}},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.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,e,g,i,l,n=new THREE.Vector3,k=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){i=this.vertices[e];i.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){i=this.faces[e];if(a&&i.vertexNormals.length){n.set(0,0,0);b=0;for(c=i.normal.length;b<c;b++)n.addSelf(i.vertexNormals[b]);n.divideScalar(3)}else{b=this.vertices[i.a];c=this.vertices[i.b];l=this.vertices[i.c];n.sub(l.position,
+c.position);k.sub(b.position,c.position);n.crossSelf(k)}n.isZero()||n.normalize();i.normal.copy(n)}},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<
-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(E,O,ia,Q,f,p,n){h=E.vertices[O].position;l=E.vertices[ia].position;m=E.vertices[Q].position;k=g[f];o=g[p];u=g[n];x=l.x-h.x;v=m.x-h.x;A=l.y-h.y;K=m.y-h.y;
-N=l.z-h.z;J=m.z-h.z;r=o.u-k.u;d=u.u-k.u;I=o.v-k.v;S=u.v-k.v;V=1/(r*S-d*I);M.set((S*x-I*v)*V,(S*A-I*K)*V,(S*N-I*J)*V);aa.set((r*v-d*x)*V,(r*K-d*A)*V,(r*J-d*N)*V);ea[O].addSelf(M);ea[ia].addSelf(M);ea[Q].addSelf(M);T[O].addSelf(aa);T[ia].addSelf(aa);T[Q].addSelf(aa)}var b,c,e,g,h,l,m,k,o,u,x,v,A,K,N,J,r,d,I,S,V,ea=[],T=[],M=new THREE.Vector3,aa=new THREE.Vector3,R=new THREE.Vector3,ca=new THREE.Vector3,W=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){ea[b]=new THREE.Vector3;T[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(B,I,ka,P,ja,ca,Q){i=B.vertices[I].position;l=B.vertices[ka].position;n=B.vertices[P].position;k=g[ja];o=g[ca];s=g[Q];w=l.x-i.x;t=n.x-i.x;x=l.y-i.y;F=n.y-
+i.y;H=l.z-i.z;G=n.z-i.z;r=o.u-k.u;Z=s.u-k.u;D=o.v-k.v;K=s.v-k.v;d=1/(r*K-Z*D);N.set((K*w-D*t)*d,(K*x-D*F)*d,(K*H-D*G)*d);ba.set((r*t-Z*w)*d,(r*F-Z*x)*d,(r*G-Z*H)*d);ga[I].addSelf(N);ga[ka].addSelf(N);ga[P].addSelf(N);T[I].addSelf(ba);T[ka].addSelf(ba);T[P].addSelf(ba)}var b,c,e,g,i,l,n,k,o,s,w,t,x,F,H,G,r,Z,D,K,d,ga=[],T=[],N=new THREE.Vector3,ba=new THREE.Vector3,R=new THREE.Vector3,aa=new THREE.Vector3,V=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){ga[b]=new THREE.Vector3;T[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]);
-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=ea[b];R.copy(e);R.subSelf(W.multiplyScalar(W.dot(e))).normalize();ca.cross(this.vertices[b].normal,e);e=ca.dot(T[b]);e=e<0?-1:1;this.vertices[b].tangent.set(R.x,R.y,R.z,e)}this.hasTangents=!0},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=ga[b];R.copy(e);R.subSelf(V.multiplyScalar(V.dot(e))).normalize();aa.cross(this.vertices[b].normal,e);e=aa.dot(T[b]);e=e<0?-1:1;this.vertices[b].tangent.set(R.x,R.y,R.z,e)}this.hasTangents=!0},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>
-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(u){var x=[];b=0;for(c=u.length;b<c;b++)u[b]==undefined?x.push("undefined"):x.push(u[b].id);return x.join("_")}var b,c,e,g,h,l,m,k,o={};e=0;for(g=this.faces.length;e<g;e++){h=this.faces[e];
-l=h.materials;m=a(l);o[m]==undefined&&(o[m]={hash:m,counter:0});k=o[m].hash+"_"+o[m].counter;this.geometryChunks[k]==undefined&&(this.geometryChunks[k]={faces:[],materials:l,vertices:0});h=h instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+h>65535){o[m].counter+=1;k=o[m].hash+"_"+o[m].counter;this.geometryChunks[k]==undefined&&(this.geometryChunks[k]={faces:[],materials:l,vertices:0})}this.geometryChunks[k].faces.push(e);this.geometryChunks[k].vertices+=h}},toString:function(){return"THREE.Geometry ( vertices: "+
+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(s){var w=[];b=0;for(c=s.length;b<c;b++)s[b]==undefined?w.push("undefined"):w.push(s[b].id);return w.join("_")}var b,c,e,g,i,l,n,k,o={};e=0;for(g=this.faces.length;e<g;e++){i=this.faces[e];
+l=i.materials;n=a(l);o[n]==undefined&&(o[n]={hash:n,counter:0});k=o[n].hash+"_"+o[n].counter;this.geometryChunks[k]==undefined&&(this.geometryChunks[k]={faces:[],materials:l,vertices:0});i=i instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+i>65535){o[n].counter+=1;k=o[n].hash+"_"+o[n].counter;this.geometryChunks[k]==undefined&&(this.geometryChunks[k]={faces:[],materials:l,vertices:0})}this.geometryChunks[k].faces.push(e);this.geometryChunks[k].vertices+=i}},toString:function(){return"THREE.Geometry ( vertices: "+
 this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0;
 THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.visible=!0;this.autoUpdateMatrix=!0;this.matrixNeedsToUpdate=!0;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale=1;this.rotationMatrix=
 new THREE.Matrix4};THREE.Object3D.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}var e=this.children.length;for(a=0;a<e;a++)this.children[a].update(this.globalMatrix,b,c)}};
 THREE.Object3D.prototype.updateMatrix=function(){this.localMatrix.setPosition(this.position);if(this.useQuaternion){if(this.quaternion.isDirty){this.localMatrix.setRotationFromQuaternion(this.quaternion);this.quaternion.isDirty=!1}}else this.localMatrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.localMatrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}return!0};
 THREE.Object3D.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a)}};THREE.Object3D.prototype.removeChild=function(a){var b=this.children.indexOf(a);if(b!==-1){this.children.splice(b,1);a.parent=undefined}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=!1};THREE.Particle.prototype=new THREE.Object3D;
 THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=c!=undefined?c:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;
-THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b&&b.length?b:[b];this.normalMatrix=THREE.Matrix4.makeInvert3x3(this.globalMatrix).transpose();this.flipSided=!1;this.doubleSided=!1;this.overdraw=!1;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius}};THREE.Mesh.prototype=new THREE.Object3D;
-THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
-THREE.Mesh.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0;this.normalMatrix=THREE.Matrix4.makeInvert3x3(this.globalMatrix).transpose()}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,c)}};
-THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
+THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b&&b.length?b:[b];this.flipSided=!1;this.doubleSided=!1;this.overdraw=!1;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
+THREE.Mesh.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,c)}};THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;
+THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
 THREE.Bone.prototype.update=function(a,b,c){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.skinMatrix.multiply(a,this.localMatrix):this.skinMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}var e,g=this.children.length;if(this.hasNoneBoneChildren){this.globalMatrix.multiply(this.skin.globalMatrix,this.skinMatrix);for(e=0;e<g;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.globalMatrix,!0,c)}}else for(e=
 0;e<g;e++)this.children[e].update(this.skinMatrix,b,c)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);if(!(a instanceof THREE.Bone))this.hasNoneBoneChildren=!0}};if(!window.Float32Array)window.Float32Array=Array;
-THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var c,e,g,h,l,m;if(this.geometry.bones!==undefined){for(c=0;c<this.geometry.bones.length;c++){g=this.geometry.bones[c];h=g.pos;l=g.rotq;m=g.scl;e=this.addBone();e.name=g.name;e.position.set(h[0],h[1],h[2]);e.quaternion.set(l[0],l[1],l[2],l[3]);m!==undefined?e.scale.set(m[0],m[1],m[2]):e.scale.set(1,1,1)}for(c=0;c<this.bones.length;c++){g=this.geometry.bones[c];e=this.bones[c];
+THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var c,e,g,i,l,n;if(this.geometry.bones!==undefined){for(c=0;c<this.geometry.bones.length;c++){g=this.geometry.bones[c];i=g.pos;l=g.rotq;n=g.scl;e=this.addBone();e.name=g.name;e.position.set(i[0],i[1],i[2]);e.quaternion.set(l[0],l[1],l[2],l[3]);n!==undefined?e.scale.set(n[0],n[1],n[2]):e.scale.set(1,1,1)}for(c=0;c<this.bones.length;c++){g=this.geometry.bones[c];e=this.bones[c];
 g.parent===-1?this.addChild(e):this.bones[g.parent].addChild(e)}this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
-THREE.SkinnedMesh.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0;this.normalMatrix=THREE.Matrix4.makeInvert3x3(this.globalMatrix).transpose()}var e,g=this.children.length;for(e=0;e<g;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.identityMatrix,!1,c):a.update(this.globalMatrix,b,
-c)}}};THREE.SkinnedMesh.prototype.addBone=function(a){a===undefined&&(a=new THREE.Bone(this));this.bones.push(a);return a};
-THREE.SkinnedMesh.prototype.pose=function(){this.update(undefined,!0);for(var a,b=[],c=0;c<this.bones.length;c++){a=this.bones[c];b.push(THREE.Matrix4.makeInvert(a.skinMatrix));a.skinMatrix.flattenToArrayOffset(this.boneMatrices,c*16)}if(this.geometry.skinVerticesA===undefined){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var e;for(a=0;a<this.geometry.skinIndices.length;a++){c=this.geometry.vertices[a].position;var g=this.geometry.skinIndices[a].x,h=this.geometry.skinIndices[a].y;
-e=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesA.push(b[g].multiplyVector3(e));e=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesB.push(b[h].multiplyVector3(e));if(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1){c=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5;this.geometry.skinWeights[a].x+=c;this.geometry.skinWeights[a].y+=c}}}};
+THREE.SkinnedMesh.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}var e,g=this.children.length;for(e=0;e<g;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.identityMatrix,!1,c):a.update(this.globalMatrix,b,c)}}};
+THREE.SkinnedMesh.prototype.addBone=function(a){a===undefined&&(a=new THREE.Bone(this));this.bones.push(a);return a};
+THREE.SkinnedMesh.prototype.pose=function(){this.update(undefined,!0);for(var a,b=[],c=0;c<this.bones.length;c++){a=this.bones[c];b.push(THREE.Matrix4.makeInvert(a.skinMatrix));a.skinMatrix.flattenToArrayOffset(this.boneMatrices,c*16)}if(this.geometry.skinVerticesA===undefined){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var e;for(a=0;a<this.geometry.skinIndices.length;a++){c=this.geometry.vertices[a].position;var g=this.geometry.skinIndices[a].x,i=this.geometry.skinIndices[a].y;
+e=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesA.push(b[g].multiplyVector3(e));e=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesB.push(b[i].multiplyVector3(e));if(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1){c=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5;this.geometry.skinWeights[a].x+=c;this.geometry.skinWeights[a].y+=c}}}};
 THREE.AnimationHandler=function(){var a=[],b={};b.update=function(c){for(var e=0;e<a.length;e++)a[e].update(c)};b.add=function(c){a.indexOf(c)===-1&&a.push(c)};b.remove=function(c){a.indexOf(c)!==-1&&a.splice(childIndex,1)};b.initData=function(c){if(c.initialized!==!0){for(var e=0;e<c.hierarchy.length;e++)for(var g=0;g<c.hierarchy[e].keys.length;g++){if(c.hierarchy[e].keys[g].time<0)c.hierarchy[e].keys[g].time=0;c.hierarchy[e].keys[g].index=g;if(c.hierarchy[e].keys[g].rot!==undefined&&!(c.hierarchy[e].keys[g].rot instanceof
-THREE.Quaternion)){var h=c.hierarchy[e].keys[g].rot;c.hierarchy[e].keys[g].rot=new THREE.Quaternion(h[0],h[1],h[2],h[3])}}g=parseInt(c.length*c.fps,10);c.JIT={};c.JIT.hierarchy=[];for(e=0;e<c.hierarchy.length;e++)c.JIT.hierarchy.push(Array(g));c.initialized=!0}};return b}();
+THREE.Quaternion)){var i=c.hierarchy[e].keys[g].rot;c.hierarchy[e].keys[g].rot=new THREE.Quaternion(i[0],i[1],i[2],i[3])}}g=parseInt(c.length*c.fps,10);c.JIT={};c.JIT.hierarchy=[];for(e=0;e<c.hierarchy.length;e++)c.JIT.hierarchy.push(Array(g));c.initialized=!0}};return b}();
 THREE.Animation=function(a,b){this.root=a;this.data=b;this.hierarchy=[];this.startTime=0;this.isPlaying=!1;this.loop=!0;this.offset=0;this.data.initialized||THREE.AnimationHandler.initData(this.data);if(a instanceof THREE.SkinnedMesh)for(var c=0;c<this.root.bones.length;c++)this.hierarchy.push(this.root.bones[c])};
 THREE.Animation.prototype.play=function(){if(!this.isPlaying){this.isPlaying=!0;this.startTime=(new Date).getTime()*0.0010;for(var a=0;a<this.hierarchy.length;a++){this.hierarchy[a].useQuaternion=!0;this.hierarchy[a].autoUpdateMatrix=!0;if(this.hierarchy[a].prevKey===undefined){this.hierarchy[a].prevKey={pos:0,rot:0,scl:0};this.hierarchy[a].nextKey={pos:0,rot:0,scl:0}}this.hierarchy[a].prevKey.pos=this.data.hierarchy[a].keys[0];this.hierarchy[a].prevKey.rot=this.data.hierarchy[a].keys[0];this.hierarchy[a].prevKey.scl=
 this.data.hierarchy[a].keys[0];this.hierarchy[a].nextKey.pos=this.getNextKeyWith("pos",a,1);this.hierarchy[a].nextKey.rot=this.getNextKeyWith("rot",a,1);this.hierarchy[a].nextKey.scl=this.getNextKeyWith("scl",a,1)}this.update();THREE.AnimationHandler.add(this)}};THREE.Animation.prototype.pause=function(){THREE.AnimationHandler.remove(this)};THREE.Animation.prototype.stop=function(){this.isPlaying=!1;THREE.AnimationHandler.remove(this)};
-THREE.Animation.prototype.update=function(){if(this.isPlaying){var a=["pos","rot","scl"],b,c,e,g,h,l,m=this.data.JIT.hierarchy,k=(new Date).getTime()*0.0010-this.startTime+this.offset,o=k;if(k>this.data.length){for(;k>this.data.length;)k-=this.data.length;this.startTime=(new Date).getTime()*0.0010-k;k=(new Date).getTime()*0.0010-this.startTime}l=Math.min(parseInt(k*this.data.fps),parseInt(this.data.length*this.data.fps));for(var u=0,x=this.hierarchy.length;u<x;u++){h=this.hierarchy[u];if(m[u][l]!==
-undefined){h.skinMatrix=m[u][l];h.autoUpdateMatrix=!1;h.matrixNeedsToUpdate=!1;h.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,u*16)}else for(var v=0;v<3;v++){c=a[v];e=h.prevKey[c];g=h.nextKey[c];if(g.time<o){if(k<o)if(this.loop){e=this.data.hierarchy[u].keys[0];g=this.getNextKeyWith(c,u,1)}else{this.stop();return}else{do{e=g;g=this.getNextKeyWith(c,u,g.index+1)}while(g.time<k)}h.prevKey[c]=e;h.nextKey[c]=g}h.autoUpdateMatrix=!0;h.matrixNeedsToUpdate=!0;b=(k-e.time)/(g.time-e.time);e=e[c];
-g=g[c];if(c==="rot"){if(b<0||b>1){console.log("Scale out of bounds:"+b);b=b<0?0:1}THREE.Quaternion.slerp(e,g,h.quaternion,b)}else{c=c==="pos"?h.position:h.scale;c.x=e[0]+(g[0]-e[0])*b;c.y=e[1]+(g[1]-e[1])*b;c.z=e[2]+(g[2]-e[2])*b}}}if(m[0][l]===undefined){this.hierarchy[0].update(undefined,!0);for(u=0;u<this.hierarchy.length;u++)m[u][l]=this.hierarchy[u].skinMatrix.clone()}}};THREE.Animation.prototype.updateObject=function(){};
+THREE.Animation.prototype.update=function(){if(this.isPlaying){var a=["pos","rot","scl"],b,c,e,g,i,l,n=this.data.JIT.hierarchy,k=(new Date).getTime()*0.0010-this.startTime+this.offset,o=k;if(k>this.data.length){for(;k>this.data.length;)k-=this.data.length;this.startTime=(new Date).getTime()*0.0010-k;k=(new Date).getTime()*0.0010-this.startTime}l=Math.min(parseInt(k*this.data.fps),parseInt(this.data.length*this.data.fps));for(var s=0,w=this.hierarchy.length;s<w;s++){i=this.hierarchy[s];if(n[s][l]!==
+undefined){i.skinMatrix=n[s][l];i.autoUpdateMatrix=!1;i.matrixNeedsToUpdate=!1;i.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,s*16)}else for(var t=0;t<3;t++){c=a[t];e=i.prevKey[c];g=i.nextKey[c];if(g.time<o){if(k<o)if(this.loop){e=this.data.hierarchy[s].keys[0];g=this.getNextKeyWith(c,s,1)}else{this.stop();return}else{do{e=g;g=this.getNextKeyWith(c,s,g.index+1)}while(g.time<k)}i.prevKey[c]=e;i.nextKey[c]=g}i.autoUpdateMatrix=!0;i.matrixNeedsToUpdate=!0;b=(k-e.time)/(g.time-e.time);e=e[c];
+g=g[c];if(c==="rot"){if(b<0||b>1){console.log("Scale out of bounds:"+b);b=b<0?0:1}THREE.Quaternion.slerp(e,g,i.quaternion,b)}else{c=c==="pos"?i.position:i.scale;c.x=e[0]+(g[0]-e[0])*b;c.y=e[1]+(g[1]-e[1])*b;c.z=e[2]+(g[2]-e[2])*b}}}if(n[0][l]===undefined){this.hierarchy[0].update(undefined,!0);for(s=0;s<this.hierarchy.length;s++)n[s][l]=this.hierarchy[s].skinMatrix.clone()}}};THREE.Animation.prototype.updateObject=function(){};
 THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var e=this.data.hierarchy[b].keys;c<e.length;c++)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[0]};
-THREE.Camera=function(a,b,c,e,g,h){THREE.Object3D.call(this);this.FOV=a||50;this.aspect=b||1;this.zNear=c||0.1;this.zFar=e||2E3;this.screenCenterY=this.screenCenterX=0;this.target=h||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.inverseMatrix=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(l){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(l);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);
+THREE.Camera=function(a,b,c,e,g,i){THREE.Object3D.call(this);this.FOV=a||50;this.aspect=b||1;this.zNear=c||0.1;this.zFar=e||2E3;this.screenCenterY=this.screenCenterX=0;this.target=i||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.inverseMatrix=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(l){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(l);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);
 this.target.position.addSelf(this.tmpVec)};this.translateZ=function(l){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(l);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
 THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.FOV,this.aspect,this.zNear,this.zFar)};
 THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.localMatrix.lookAt(this.position,this.target.position,this.up);a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);THREE.Matrix4.makeInvert(this.globalMatrix,this.inverseMatrix);b=!0}else{this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.globalMatrix,
 this.inverseMatrix)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,c)};
-THREE.Camera.prototype.frustumContains=function(a){var b=a.globalMatrix.n14,c=a.globalMatrix.n24,e=a.globalMatrix.n34,g=this.inverseMatrix,h=a.boundRadius*a.boundRadiusScale,l=g.n31*b+g.n32*c+g.n33*e+g.n34;if(l-h>-this.zNear)return!1;if(l+h<-this.zFar)return!1;l-=h;var m=this.projectionMatrix,k=1/(m.n43*l),o=k*this.screenCenterX,u=(g.n11*b+g.n12*c+g.n13*e+g.n14)*m.n11*o;h=m.n11*h*o;if(u+h<-this.screenCenterX)return!1;if(u-h>this.screenCenterX)return!1;b=(g.n21*b+g.n22*c+g.n23*e+g.n24)*m.n22*k*this.screenCenterY;
-if(b+h<-this.screenCenterY)return!1;if(b-h>this.screenCenterY)return!1;a.screenPosition.set(u,b,l,h);return!0};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
+THREE.Camera.prototype.frustumContains=function(a){var b=a.globalMatrix.n14,c=a.globalMatrix.n24,e=a.globalMatrix.n34,g=this.inverseMatrix,i=a.boundRadius*a.boundRadiusScale,l=g.n31*b+g.n32*c+g.n33*e+g.n34;if(l-i>-this.zNear)return!1;if(l+i<-this.zFar)return!1;l-=i;var n=this.projectionMatrix,k=1/(n.n43*l),o=k*this.screenCenterX,s=(g.n11*b+g.n12*c+g.n13*e+g.n14)*n.n11*o;i=n.n11*i*o;if(s+i<-this.screenCenterX)return!1;if(s-i>this.screenCenterX)return!1;b=(g.n21*b+g.n22*c+g.n23*e+g.n24)*n.n22*k*this.screenCenterY;
+if(b+i<-this.screenCenterY)return!1;if(b-i>this.screenCenterY)return!1;a.screenPosition.set(s,b,l,i);return!0};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
 THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1;
 THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.MaterialCounter={value:0};
 THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=!1;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=
@@ -133,124 +132,124 @@ THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;th
 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.ParticleCircleMaterial=function(a){this.id=THREE.MaterialCounter.value++;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.id=THREE.MaterialCounter.value++;this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
-THREE.Texture=function(a,b,c,e,g,h){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=h!==undefined?h:THREE.LinearMipMapLinearFilter};
+THREE.Texture=function(a,b,c,e,g,i){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=i!==undefined?i: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.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,b,c){this.width=a;this.height=b;c=c||{};this.wrap_s=c.wrap_s!==undefined?c.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=c.wrap_t!==undefined?c.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=c.mag_filter!==undefined?c.mag_filter:THREE.LinearFilter;this.min_filter=c.min_filter!==undefined?c.min_filter:THREE.LinearMipMapLinearFilter;this.format=c.format!==undefined?c.format:THREE.RGBFormat;this.type=c.type!==undefined?c.type:THREE.UnsignedByteType};
 var Uniforms={clone:function(a){var b,c,e,g={};for(b in a){g[b]={};for(c in a[b]){e=a[b][c];g[b][c]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var b,c,e,g={};for(b=0;b<a.length;b++){e=this.clone(a[b]);for(c in e)g[c]=e[c]}return g}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};THREE.Scene=function(){THREE.Object3D.call(this);this.objects=[];this.lights=[];this.fog=null};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};
-THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else a instanceof THREE.Camera||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
+THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
 THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};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;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(T,M){return M.z-T.z}function b(T,M){var aa=0,R=1,ca=T.z+T.w,W=M.z+M.w,E=-T.z+T.w,O=-M.z+M.w;if(ca>=0&&W>=0&&E>=0&&O>=0)return!0;else if(ca<0&&W<0||E<0&&O<0)return!1;else{if(ca<0)aa=Math.max(aa,ca/(ca-W));else W<0&&(R=Math.min(R,ca/(ca-W)));if(E<0)aa=Math.max(aa,E/(E-O));else O<0&&(R=Math.min(R,E/(E-O)));if(R<aa)return!1;else{T.lerpSelf(M,aa);M.lerpSelf(T,1-R);return!0}}}var c,e,g=[],h,l,m,k=[],o,u,x=[],v,A,K=[],N=new THREE.Vector4,J=new THREE.Vector4,r=new THREE.Matrix4,
-d=new THREE.Matrix4,I=[],S=new THREE.Vector4,V=new THREE.Vector4,ea;this.projectObjects=function(T,M,aa){M=[];var R,ca,W;e=0;ca=T.objects;T=0;for(R=ca.length;T<R;T++){W=ca[T];var E;if(!(E=!W.visible))if(E=W instanceof THREE.Mesh){a:{E=void 0;for(var O=W.globalMatrix,ia=-W.geometry.boundingSphere.radius*Math.max(W.scale.x,Math.max(W.scale.y,W.scale.z)),Q=0;Q<6;Q++){E=I[Q].x*O.n14+I[Q].y*O.n24+I[Q].z*O.n34+I[Q].w;if(E<=ia){E=!1;break a}}E=!0}E=!E}if(!E){c=g[e]=g[e]||new THREE.RenderableObject;N.copy(W.position);
-r.multiplyVector3(N);c.object=W;c.z=N.z;M.push(c);e++}}aa&&M.sort(a);return M};this.projectScene=function(T,M,aa){var R=[],ca=M.near,W=M.far,E,O,ia,Q,f,p,n,j,i,q,s,w,F,t,y,B;m=u=A=0;M.autoUpdateMatrix&&M.update();r.multiply(M.projectionMatrix,M.globalMatrix);I[0]=new THREE.Vector4(r.n41-r.n11,r.n42-r.n12,r.n43-r.n13,r.n44-r.n14);I[1]=new THREE.Vector4(r.n41+r.n11,r.n42+r.n12,r.n43+r.n13,r.n44+r.n14);I[2]=new THREE.Vector4(r.n41+r.n21,r.n42+r.n22,r.n43+r.n23,r.n44+r.n24);I[3]=new THREE.Vector4(r.n41-
-r.n21,r.n42-r.n22,r.n43-r.n23,r.n44-r.n24);I[4]=new THREE.Vector4(r.n41-r.n31,r.n42-r.n32,r.n43-r.n33,r.n44-r.n34);I[5]=new THREE.Vector4(r.n41+r.n31,r.n42+r.n32,r.n43+r.n33,r.n44+r.n34);E=0;for(p=I.length;E<p;E++){n=I[E];n.divideScalar(Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z))}T.update(undefined,!1,M);p=this.projectObjects(T,M,!0);T=0;for(E=p.length;T<E;T++){n=p[T].object;n.autoUpdateMatrix&&n.updateMatrix();j=n.globalMatrix;j.extractRotationMatrix(n.rotationMatrix);s=n.rotationMatrix;i=n.materials;q=
-n.overdraw;if(n instanceof THREE.Mesh){w=n.geometry;F=w.vertices;O=0;for(ia=F.length;O<ia;O++){t=F[O];t.positionWorld.copy(t.position);j.multiplyVector3(t.positionWorld);Q=t.positionScreen;Q.copy(t.positionWorld);r.multiplyVector4(Q);Q.x/=Q.w;Q.y/=Q.w;t.__visible=Q.z>ca&&Q.z<W}w=w.faces;O=0;for(ia=w.length;O<ia;O++){t=w[O];if(t instanceof THREE.Face3){Q=F[t.a];f=F[t.b];y=F[t.c];if(Q.__visible&&f.__visible&&y.__visible&&(n.doubleSided||n.flipSided!=(y.positionScreen.x-Q.positionScreen.x)*(f.positionScreen.y-
-Q.positionScreen.y)-(y.positionScreen.y-Q.positionScreen.y)*(f.positionScreen.x-Q.positionScreen.x)<0)){h=k[m]=k[m]||new THREE.RenderableFace3;h.v1.positionWorld.copy(Q.positionWorld);h.v2.positionWorld.copy(f.positionWorld);h.v3.positionWorld.copy(y.positionWorld);h.v1.positionScreen.copy(Q.positionScreen);h.v2.positionScreen.copy(f.positionScreen);h.v3.positionScreen.copy(y.positionScreen);h.normalWorld.copy(t.normal);s.multiplyVector3(h.normalWorld);h.centroidWorld.copy(t.centroid);j.multiplyVector3(h.centroidWorld);
-h.centroidScreen.copy(h.centroidWorld);r.multiplyVector3(h.centroidScreen);y=t.vertexNormals;ea=h.vertexNormalsWorld;Q=0;for(f=y.length;Q<f;Q++){B=ea[Q]=ea[Q]||new THREE.Vector3;B.copy(y[Q]);s.multiplyVector3(B)}h.z=h.centroidScreen.z;h.meshMaterials=i;h.faceMaterials=t.materials;h.overdraw=q;if(n.geometry.uvs[O]){h.uvs[0]=n.geometry.uvs[O][0];h.uvs[1]=n.geometry.uvs[O][1];h.uvs[2]=n.geometry.uvs[O][2]}R.push(h);m++}}else if(t instanceof THREE.Face4){Q=F[t.a];f=F[t.b];y=F[t.c];B=F[t.d];if(Q.__visible&&
-f.__visible&&y.__visible&&B.__visible&&(n.doubleSided||n.flipSided!=((B.positionScreen.x-Q.positionScreen.x)*(f.positionScreen.y-Q.positionScreen.y)-(B.positionScreen.y-Q.positionScreen.y)*(f.positionScreen.x-Q.positionScreen.x)<0||(f.positionScreen.x-y.positionScreen.x)*(B.positionScreen.y-y.positionScreen.y)-(f.positionScreen.y-y.positionScreen.y)*(B.positionScreen.x-y.positionScreen.x)<0))){h=k[m]=k[m]||new THREE.RenderableFace3;h.v1.positionWorld.copy(Q.positionWorld);h.v2.positionWorld.copy(f.positionWorld);
-h.v3.positionWorld.copy(B.positionWorld);h.v1.positionScreen.copy(Q.positionScreen);h.v2.positionScreen.copy(f.positionScreen);h.v3.positionScreen.copy(B.positionScreen);h.normalWorld.copy(t.normal);s.multiplyVector3(h.normalWorld);h.centroidWorld.copy(t.centroid);j.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);r.multiplyVector3(h.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=i;h.faceMaterials=t.materials;h.overdraw=q;if(n.geometry.uvs[O]){h.uvs[0]=n.geometry.uvs[O][0];
-h.uvs[1]=n.geometry.uvs[O][1];h.uvs[2]=n.geometry.uvs[O][3]}R.push(h);m++;l=k[m]=k[m]||new THREE.RenderableFace3;l.v1.positionWorld.copy(f.positionWorld);l.v2.positionWorld.copy(y.positionWorld);l.v3.positionWorld.copy(B.positionWorld);l.v1.positionScreen.copy(f.positionScreen);l.v2.positionScreen.copy(y.positionScreen);l.v3.positionScreen.copy(B.positionScreen);l.normalWorld.copy(h.normalWorld);l.centroidWorld.copy(h.centroidWorld);l.centroidScreen.copy(h.centroidScreen);l.z=l.centroidScreen.z;l.meshMaterials=
-i;l.faceMaterials=t.materials;l.overdraw=q;if(n.geometry.uvs[O]){l.uvs[0]=n.geometry.uvs[O][1];l.uvs[1]=n.geometry.uvs[O][2];l.uvs[2]=n.geometry.uvs[O][3]}R.push(l);m++}}}}else if(n instanceof THREE.Line){d.multiply(r,j);F=n.geometry.vertices;t=F[0];t.positionScreen.copy(t.position);d.multiplyVector4(t.positionScreen);O=1;for(ia=F.length;O<ia;O++){Q=F[O];Q.positionScreen.copy(Q.position);d.multiplyVector4(Q.positionScreen);f=F[O-1];S.copy(Q.positionScreen);V.copy(f.positionScreen);if(b(S,V)){S.multiplyScalar(1/
-S.w);V.multiplyScalar(1/V.w);o=x[u]=x[u]||new THREE.RenderableLine;o.v1.positionScreen.copy(S);o.v2.positionScreen.copy(V);o.z=Math.max(S.z,V.z);o.materials=n.materials;R.push(o);u++}}}else if(n instanceof THREE.Particle){J.set(n.position.x,n.position.y,n.position.z,1);r.multiplyVector4(J);J.z/=J.w;if(J.z>0&&J.z<1){v=K[A]=K[A]||new THREE.RenderableParticle;v.x=J.x/J.w;v.y=J.y/J.w;v.z=J.z;v.rotation=n.rotation.z;v.scale.x=n.scale.x*Math.abs(v.x-(J.x+M.projectionMatrix.n11)/(J.w+M.projectionMatrix.n14));
-v.scale.y=n.scale.y*Math.abs(v.y-(J.y+M.projectionMatrix.n22)/(J.w+M.projectionMatrix.n24));v.materials=n.materials;R.push(v);A++}}}aa&&R.sort(a);return R};this.unprojectVector=function(T,M){var aa=THREE.Matrix4.makeInvert(M.globalMatrix);aa.multiplySelf(THREE.Matrix4.makeInvert(M.projectionMatrix));aa.multiplyVector3(T);return T}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,g,h;this.domElement=document.createElement("div");this.setSize=function(l,m){c=l;e=m;g=c/2;h=e/2};this.render=function(l,m){var k,o,u,x,v,A,K,N;a=b.projectScene(l,m);k=0;for(o=a.length;k<o;k++){v=a[k];if(v instanceof THREE.RenderableParticle){K=v.x*g+g;N=v.y*h+h;u=0;for(x=v.material.length;u<x;u++){A=v.material[u];if(A instanceof THREE.ParticleDOMMaterial){A=A.domElement;A.style.left=K+"px";A.style.top=N+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(G){if(v!=G)o.globalAlpha=v=G}function b(G){if(A!=G){switch(G){case THREE.NormalBlending:o.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:o.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:o.globalCompositeOperation="darker"}A=G}}var c=null,e=new THREE.Projector,g=document.createElement("canvas"),h,l,m,k,o=g.getContext("2d"),u=new THREE.Color(0),x=0,v=1,A=0,K=null,N=null,J=1,r,d,I,S,V,ea,T,M,aa,R=new THREE.Color,
-ca=new THREE.Color,W=new THREE.Color,E=new THREE.Color,O=new THREE.Color,ia,Q,f,p,n,j,i,q,s,w=new THREE.Rectangle,F=new THREE.Rectangle,t=new THREE.Rectangle,y=!1,B=new THREE.Color,Y=new THREE.Color,ga=new THREE.Color,na=new THREE.Color,ua=Math.PI*2,Z=new THREE.Vector3,fa,ha,Ia,C,Ca,wa,za=16;fa=document.createElement("canvas");fa.width=fa.height=2;ha=fa.getContext("2d");ha.fillStyle="rgba(0,0,0,1)";ha.fillRect(0,0,2,2);Ia=ha.getImageData(0,0,2,2);C=Ia.data;Ca=document.createElement("canvas");Ca.width=
-Ca.height=za;wa=Ca.getContext("2d");wa.translate(-za/2,-za/2);wa.scale(za,za);za--;this.domElement=g;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(G,L){h=G;l=L;m=h/2;k=l/2;g.width=h;g.height=l;w.set(-m,-k,m,k);v=1;A=0;N=K=null;J=1};this.setClearColor=function(G,L){u=G;x=L;F.set(-m,-k,m,k);o.setTransform(1,0,0,-1,m,k);this.clear()};this.setClearColorHex=function(G,L){u.setHex(G);x=L;F.set(-m,-k,m,k);o.setTransform(1,0,0,-1,m,k);this.clear()};this.clear=function(){o.setTransform(1,
-0,0,-1,m,k);if(!F.isEmpty()){F.inflate(1);F.minSelf(w);if(u.hex==0&&x==0)o.clearRect(F.getX(),F.getY(),F.getWidth(),F.getHeight());else{b(THREE.NormalBlending);a(1);o.fillStyle="rgba("+Math.floor(u.r*255)+","+Math.floor(u.g*255)+","+Math.floor(u.b*255)+","+x+")";o.fillRect(F.getX(),F.getY(),F.getWidth(),F.getHeight())}F.empty()}};this.render=function(G,L){function P(D){var ba,X,H,U=D.lights;Y.setRGB(0,0,0);ga.setRGB(0,0,0);na.setRGB(0,0,0);D=0;for(ba=U.length;D<ba;D++){X=U[D];H=X.color;if(X instanceof
-THREE.AmbientLight){Y.r+=H.r;Y.g+=H.g;Y.b+=H.b}else if(X instanceof THREE.DirectionalLight){ga.r+=H.r;ga.g+=H.g;ga.b+=H.b}else if(X instanceof THREE.PointLight){na.r+=H.r;na.g+=H.g;na.b+=H.b}}}function ja(D,ba,X,H){var U,da,sa,Aa,Da=D.lights;D=0;for(U=Da.length;D<U;D++){da=Da[D];sa=da.color;Aa=da.intensity;if(da instanceof THREE.DirectionalLight){da=X.dot(da.position)*Aa;if(da>0){H.r+=sa.r*da;H.g+=sa.g*da;H.b+=sa.b*da}}else if(da instanceof THREE.PointLight){Z.sub(da.position,ba);Z.normalize();da=
-X.dot(Z)*Aa;if(da>0){H.r+=sa.r*da;H.g+=sa.g*da;H.b+=sa.b*da}}}}function Ea(D,ba,X){if(X.opacity!=0){a(X.opacity);b(X.blending);var H,U,da,sa,Aa,Da;if(X instanceof THREE.ParticleBasicMaterial){if(X.map&&X.map.image.loaded){sa=X.map.image;Aa=sa.width>>1;Da=sa.height>>1;U=ba.scale.x*m;da=ba.scale.y*k;X=U*Aa;H=da*Da;t.set(D.x-X,D.y-H,D.x+X,D.y+H);if(w.instersects(t)){o.save();o.translate(D.x,D.y);o.rotate(-ba.rotation);o.scale(U,-da);o.translate(-Aa,-Da);o.drawImage(sa,0,0);o.restore()}}}else if(X instanceof
-THREE.ParticleCircleMaterial){if(y){B.r=Y.r+ga.r+na.r;B.g=Y.g+ga.g+na.g;B.b=Y.b+ga.b+na.b;R.r=X.color.r*B.r;R.g=X.color.g*B.g;R.b=X.color.b*B.b;R.updateStyleString()}else R.__styleString=X.color.__styleString;X=ba.scale.x*m;H=ba.scale.y*k;t.set(D.x-X,D.y-H,D.x+X,D.y+H);if(w.instersects(t)){U=R.__styleString;if(N!=U)o.fillStyle=N=U;o.save();o.translate(D.x,D.y);o.rotate(-ba.rotation);o.scale(X,H);o.beginPath();o.arc(0,0,1,0,ua,!0);o.closePath();o.fill();o.restore()}}}}function ra(D,ba,X,H){if(H.opacity!=
-0){a(H.opacity);b(H.blending);o.beginPath();o.moveTo(D.positionScreen.x,D.positionScreen.y);o.lineTo(ba.positionScreen.x,ba.positionScreen.y);o.closePath();if(H instanceof THREE.LineBasicMaterial){R.__styleString=H.color.__styleString;D=H.linewidth;if(J!=D)o.lineWidth=J=D;D=R.__styleString;if(K!=D)o.strokeStyle=K=D;o.stroke();t.inflate(H.linewidth*2)}}}function z(D,ba,X,H,U,da){if(U.opacity!=0){a(U.opacity);b(U.blending);S=D.positionScreen.x;V=D.positionScreen.y;ea=ba.positionScreen.x;T=ba.positionScreen.y;
-M=X.positionScreen.x;aa=X.positionScreen.y;o.beginPath();o.moveTo(S,V);o.lineTo(ea,T);o.lineTo(M,aa);o.lineTo(S,V);o.closePath();if(U instanceof THREE.MeshBasicMaterial)if(U.map)U.map.image.loaded&&U.map.mapping instanceof THREE.UVMapping&&Ka(S,V,ea,T,M,aa,U.map.image,H.uvs[0].u,H.uvs[0].v,H.uvs[1].u,H.uvs[1].v,H.uvs[2].u,H.uvs[2].v);else if(U.env_map){if(U.env_map.image.loaded&&U.env_map.mapping instanceof THREE.SphericalReflectionMapping){D=L.globalMatrix;Z.copy(H.vertexNormalsWorld[0]);p=(Z.x*
-D.n11+Z.y*D.n12+Z.z*D.n13)*0.5+0.5;n=-(Z.x*D.n21+Z.y*D.n22+Z.z*D.n23)*0.5+0.5;Z.copy(H.vertexNormalsWorld[1]);j=(Z.x*D.n11+Z.y*D.n12+Z.z*D.n13)*0.5+0.5;i=-(Z.x*D.n21+Z.y*D.n22+Z.z*D.n23)*0.5+0.5;Z.copy(H.vertexNormalsWorld[2]);q=(Z.x*D.n11+Z.y*D.n12+Z.z*D.n13)*0.5+0.5;s=-(Z.x*D.n21+Z.y*D.n22+Z.z*D.n23)*0.5+0.5;Ka(S,V,ea,T,M,aa,U.env_map.image,p,n,j,i,q,s)}}else U.wireframe?pa(U.color.__styleString,U.wireframe_linewidth):Ma(U.color.__styleString);else if(U instanceof THREE.MeshLambertMaterial){if(U.map&&
-!U.wireframe){U.map.mapping instanceof THREE.UVMapping&&Ka(S,V,ea,T,M,aa,U.map.image,H.uvs[0].u,H.uvs[0].v,H.uvs[1].u,H.uvs[1].v,H.uvs[2].u,H.uvs[2].v);b(THREE.SubtractiveBlending)}if(y)if(!U.wireframe&&U.shading==THREE.SmoothShading&&H.vertexNormalsWorld.length==3){ca.r=W.r=E.r=Y.r;ca.g=W.g=E.g=Y.g;ca.b=W.b=E.b=Y.b;ja(da,H.v1.positionWorld,H.vertexNormalsWorld[0],ca);ja(da,H.v2.positionWorld,H.vertexNormalsWorld[1],W);ja(da,H.v3.positionWorld,H.vertexNormalsWorld[2],E);O.r=(W.r+E.r)*0.5;O.g=(W.g+
-E.g)*0.5;O.b=(W.b+E.b)*0.5;f=Ha(ca,W,E,O);Ka(S,V,ea,T,M,aa,f,0,0,1,0,0,1)}else{B.r=Y.r;B.g=Y.g;B.b=Y.b;ja(da,H.centroidWorld,H.normalWorld,B);R.r=U.color.r*B.r;R.g=U.color.g*B.g;R.b=U.color.b*B.b;R.updateStyleString();U.wireframe?pa(R.__styleString,U.wireframe_linewidth):Ma(R.__styleString)}else U.wireframe?pa(U.color.__styleString,U.wireframe_linewidth):Ma(U.color.__styleString)}else if(U instanceof THREE.MeshDepthMaterial){ia=L.near;Q=L.far;ca.r=ca.g=ca.b=1-la(D.positionScreen.z,ia,Q);W.r=W.g=W.b=
-1-la(ba.positionScreen.z,ia,Q);E.r=E.g=E.b=1-la(X.positionScreen.z,ia,Q);O.r=(W.r+E.r)*0.5;O.g=(W.g+E.g)*0.5;O.b=(W.b+E.b)*0.5;f=Ha(ca,W,E,O);Ka(S,V,ea,T,M,aa,f,0,0,1,0,0,1)}else if(U instanceof THREE.MeshNormalMaterial){R.r=qa(H.normalWorld.x);R.g=qa(H.normalWorld.y);R.b=qa(H.normalWorld.z);R.updateStyleString();U.wireframe?pa(R.__styleString,U.wireframe_linewidth):Ma(R.__styleString)}}}function pa(D,ba){if(K!=D)o.strokeStyle=K=D;if(J!=ba)o.lineWidth=J=ba;o.stroke();t.inflate(ba*2)}function Ma(D){if(N!=
-D)o.fillStyle=N=D;o.fill()}function Ka(D,ba,X,H,U,da,sa,Aa,Da,La,ta,Ga,Ja){var Fa,Ba;Fa=sa.width-1;Ba=sa.height-1;Aa*=Fa;Da*=Ba;La*=Fa;ta*=Ba;Ga*=Fa;Ja*=Ba;X-=D;H-=ba;U-=D;da-=ba;La-=Aa;ta-=Da;Ga-=Aa;Ja-=Da;Fa=La*Ja-Ga*ta;if(Fa!=0){Ba=1/Fa;Fa=(Ja*X-ta*U)*Ba;ta=(Ja*H-ta*da)*Ba;X=(La*U-Ga*X)*Ba;H=(La*da-Ga*H)*Ba;D=D-Fa*Aa-X*Da;ba=ba-ta*Aa-H*Da;o.save();o.transform(Fa,ta,X,H,D,ba);o.clip();o.drawImage(sa,0,0);o.restore()}}function Ha(D,ba,X,H){var U=~~(D.r*255),da=~~(D.g*255);D=~~(D.b*255);var sa=~~(ba.r*
-255),Aa=~~(ba.g*255);ba=~~(ba.b*255);var Da=~~(X.r*255),La=~~(X.g*255);X=~~(X.b*255);var ta=~~(H.r*255),Ga=~~(H.g*255);H=~~(H.b*255);C[0]=U<0?0:U>255?255:U;C[1]=da<0?0:da>255?255:da;C[2]=D<0?0:D>255?255:D;C[4]=sa<0?0:sa>255?255:sa;C[5]=Aa<0?0:Aa>255?255:Aa;C[6]=ba<0?0:ba>255?255:ba;C[8]=Da<0?0:Da>255?255:Da;C[9]=La<0?0:La>255?255:La;C[10]=X<0?0:X>255?255:X;C[12]=ta<0?0:ta>255?255:ta;C[13]=Ga<0?0:Ga>255?255:Ga;C[14]=H<0?0:H>255?255:H;ha.putImageData(Ia,0,0);wa.drawImage(fa,0,0);return Ca}function la(D,
-ba,X){D=(D-ba)/(X-ba);return D*D*(3-2*D)}function qa(D){D=(D+1)*0.5;return D<0?0:D>1?1:D}function ma(D,ba){var X=ba.x-D.x,H=ba.y-D.y,U=1/Math.sqrt(X*X+H*H);X*=U;H*=U;ba.x+=X;ba.y+=H;D.x-=X;D.y-=H}var ka,oa,$,xa,va,Oa,ya,Na;this.autoClear?this.clear():o.setTransform(1,0,0,-1,m,k);c=e.projectScene(G,L,this.sortElements);(y=G.lights.length>0)&&P(G);ka=0;for(oa=c.length;ka<oa;ka++){$=c[ka];t.empty();if($ instanceof THREE.RenderableParticle){r=$;r.x*=m;r.y*=k;xa=0;for(va=$.materials.length;xa<va;xa++)Ea(r,
-$,$.materials[xa],G)}else if($ instanceof THREE.RenderableLine){r=$.v1;d=$.v2;r.positionScreen.x*=m;r.positionScreen.y*=k;d.positionScreen.x*=m;d.positionScreen.y*=k;t.addPoint(r.positionScreen.x,r.positionScreen.y);t.addPoint(d.positionScreen.x,d.positionScreen.y);if(w.instersects(t)){xa=0;for(va=$.materials.length;xa<va;)ra(r,d,$,$.materials[xa++],G)}}else if($ instanceof THREE.RenderableFace3){r=$.v1;d=$.v2;I=$.v3;r.positionScreen.x*=m;r.positionScreen.y*=k;d.positionScreen.x*=m;d.positionScreen.y*=
-k;I.positionScreen.x*=m;I.positionScreen.y*=k;if($.overdraw){ma(r.positionScreen,d.positionScreen);ma(d.positionScreen,I.positionScreen);ma(I.positionScreen,r.positionScreen)}t.add3Points(r.positionScreen.x,r.positionScreen.y,d.positionScreen.x,d.positionScreen.y,I.positionScreen.x,I.positionScreen.y);if(w.instersects(t)){xa=0;for(va=$.meshMaterials.length;xa<va;){Na=$.meshMaterials[xa++];if(Na instanceof THREE.MeshFaceMaterial){Oa=0;for(ya=$.faceMaterials.length;Oa<ya;)(Na=$.faceMaterials[Oa++])&&
-z(r,d,I,$,Na,G)}else z(r,d,I,$,Na,G)}}}F.addRectangle(t)}o.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(p,n,j){var i,q,s,w;i=0;for(q=p.lights.length;i<q;i++){s=p.lights[i];if(s instanceof THREE.DirectionalLight){w=n.normalWorld.dot(s.position)*s.intensity;if(w>0){j.r+=s.color.r*w;j.g+=s.color.g*w;j.b+=s.color.b*w}}else if(s instanceof THREE.PointLight){aa.sub(s.position,n.centroidWorld);aa.normalize();w=n.normalWorld.dot(aa)*s.intensity;if(w>0){j.r+=s.color.r*w;j.g+=s.color.g*w;j.b+=s.color.b*w}}}}function b(p,n,j,i,q,s){E=e(O++);E.setAttribute("d","M "+p.positionScreen.x+
-" "+p.positionScreen.y+" L "+n.positionScreen.x+" "+n.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+"z");if(q instanceof THREE.MeshBasicMaterial)I.__styleString=q.color.__styleString;else if(q instanceof THREE.MeshLambertMaterial)if(d){S.r=V.r;S.g=V.g;S.b=V.b;a(s,i,S);I.r=q.color.r*S.r;I.g=q.color.g*S.g;I.b=q.color.b*S.b;I.updateStyleString()}else I.__styleString=q.color.__styleString;else if(q instanceof THREE.MeshDepthMaterial){M=1-q.__2near/(q.__farPlusNear-i.z*q.__farMinusNear);
-I.setRGB(M,M,M)}else q instanceof THREE.MeshNormalMaterial&&I.setRGB(g(i.normalWorld.x),g(i.normalWorld.y),g(i.normalWorld.z));q.wireframe?E.setAttribute("style","fill: none; stroke: "+I.__styleString+"; stroke-width: "+q.wireframe_linewidth+"; stroke-opacity: "+q.opacity+"; stroke-linecap: "+q.wireframe_linecap+"; stroke-linejoin: "+q.wireframe_linejoin):E.setAttribute("style","fill: "+I.__styleString+"; fill-opacity: "+q.opacity);m.appendChild(E)}function c(p,n,j,i,q,s,w){E=e(O++);E.setAttribute("d",
-"M "+p.positionScreen.x+" "+p.positionScreen.y+" L "+n.positionScreen.x+" "+n.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+" L "+i.positionScreen.x+","+i.positionScreen.y+"z");if(s instanceof THREE.MeshBasicMaterial)I.__styleString=s.color.__styleString;else if(s instanceof THREE.MeshLambertMaterial)if(d){S.r=V.r;S.g=V.g;S.b=V.b;a(w,q,S);I.r=s.color.r*S.r;I.g=s.color.g*S.g;I.b=s.color.b*S.b;I.updateStyleString()}else I.__styleString=s.color.__styleString;else if(s instanceof THREE.MeshDepthMaterial){M=
-1-s.__2near/(s.__farPlusNear-q.z*s.__farMinusNear);I.setRGB(M,M,M)}else s instanceof THREE.MeshNormalMaterial&&I.setRGB(g(q.normalWorld.x),g(q.normalWorld.y),g(q.normalWorld.z));s.wireframe?E.setAttribute("style","fill: none; stroke: "+I.__styleString+"; stroke-width: "+s.wireframe_linewidth+"; stroke-opacity: "+s.opacity+"; stroke-linecap: "+s.wireframe_linecap+"; stroke-linejoin: "+s.wireframe_linejoin):E.setAttribute("style","fill: "+I.__styleString+"; fill-opacity: "+s.opacity);m.appendChild(E)}
-function e(p){if(R[p]==null){R[p]=document.createElementNS("http://www.w3.org/2000/svg","path");f==0&&R[p].setAttribute("shape-rendering","crispEdges")}return R[p]}function g(p){return p<0?Math.min((1+p)*0.5,0.5):0.5+Math.min(p*0.5,0.5)}var h=null,l=new THREE.Projector,m=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,o,u,x,v,A,K,N,J=new THREE.Rectangle,r=new THREE.Rectangle,d=!1,I=new THREE.Color(16777215),S=new THREE.Color(16777215),V=new THREE.Color(0),ea=new THREE.Color(0),T=new THREE.Color(0),
-M,aa=new THREE.Vector3,R=[],ca=[],W=[],E,O,ia,Q,f=1;this.domElement=m;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(p){switch(p){case "high":f=1;break;case "low":f=0}};this.setSize=function(p,n){k=p;o=n;u=k/2;x=o/2;m.setAttribute("viewBox",-u+" "+-x+" "+k+" "+o);m.setAttribute("width",k);m.setAttribute("height",o);J.set(-u,-x,u,x)};this.clear=function(){for(;m.childNodes.length>0;)m.removeChild(m.childNodes[0])};this.render=function(p,n){var j,i,q,s,w,F,t,y;this.autoClear&&
-this.clear();h=l.projectScene(p,n,this.sortElements);Q=ia=O=0;if(d=p.lights.length>0){t=p.lights;V.setRGB(0,0,0);ea.setRGB(0,0,0);T.setRGB(0,0,0);j=0;for(i=t.length;j<i;j++){q=t[j];s=q.color;if(q instanceof THREE.AmbientLight){V.r+=s.r;V.g+=s.g;V.b+=s.b}else if(q instanceof THREE.DirectionalLight){ea.r+=s.r;ea.g+=s.g;ea.b+=s.b}else if(q instanceof THREE.PointLight){T.r+=s.r;T.g+=s.g;T.b+=s.b}}}j=0;for(i=h.length;j<i;j++){t=h[j];r.empty();if(t instanceof THREE.RenderableParticle){v=t;v.x*=u;v.y*=-x;
-q=0;for(s=t.materials.length;q<s;q++)if(y=t.materials[q]){w=v;F=t;var B=ia++;if(ca[B]==null){ca[B]=document.createElementNS("http://www.w3.org/2000/svg","circle");f==0&&ca[B].setAttribute("shape-rendering","crispEdges")}E=ca[B];E.setAttribute("cx",w.x);E.setAttribute("cy",w.y);E.setAttribute("r",F.scale.x*u);if(y instanceof THREE.ParticleCircleMaterial){if(d){S.r=V.r+ea.r+T.r;S.g=V.g+ea.g+T.g;S.b=V.b+ea.b+T.b;I.r=y.color.r*S.r;I.g=y.color.g*S.g;I.b=y.color.b*S.b;I.updateStyleString()}else I=y.color;
-E.setAttribute("style","fill: "+I.__styleString)}m.appendChild(E)}}else if(t instanceof THREE.RenderableLine){v=t.v1;A=t.v2;v.positionScreen.x*=u;v.positionScreen.y*=-x;A.positionScreen.x*=u;A.positionScreen.y*=-x;r.addPoint(v.positionScreen.x,v.positionScreen.y);r.addPoint(A.positionScreen.x,A.positionScreen.y);if(J.instersects(r)){q=0;for(s=t.materials.length;q<s;)if(y=t.materials[q++]){w=v;F=A;B=Q++;if(W[B]==null){W[B]=document.createElementNS("http://www.w3.org/2000/svg","line");f==0&&W[B].setAttribute("shape-rendering",
-"crispEdges")}E=W[B];E.setAttribute("x1",w.positionScreen.x);E.setAttribute("y1",w.positionScreen.y);E.setAttribute("x2",F.positionScreen.x);E.setAttribute("y2",F.positionScreen.y);if(y instanceof THREE.LineBasicMaterial){I.__styleString=y.color.__styleString;E.setAttribute("style","fill: none; stroke: "+I.__styleString+"; stroke-width: "+y.linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.linecap+"; stroke-linejoin: "+y.linejoin);m.appendChild(E)}}}}else if(t instanceof THREE.RenderableFace3){v=
-t.v1;A=t.v2;K=t.v3;v.positionScreen.x*=u;v.positionScreen.y*=-x;A.positionScreen.x*=u;A.positionScreen.y*=-x;K.positionScreen.x*=u;K.positionScreen.y*=-x;r.addPoint(v.positionScreen.x,v.positionScreen.y);r.addPoint(A.positionScreen.x,A.positionScreen.y);r.addPoint(K.positionScreen.x,K.positionScreen.y);if(J.instersects(r)){q=0;for(s=t.meshMaterials.length;q<s;){y=t.meshMaterials[q++];if(y instanceof THREE.MeshFaceMaterial){w=0;for(F=t.faceMaterials.length;w<F;)(y=t.faceMaterials[w++])&&b(v,A,K,t,
-y,p)}else y&&b(v,A,K,t,y,p)}}}else if(t instanceof THREE.RenderableFace4){v=t.v1;A=t.v2;K=t.v3;N=t.v4;v.positionScreen.x*=u;v.positionScreen.y*=-x;A.positionScreen.x*=u;A.positionScreen.y*=-x;K.positionScreen.x*=u;K.positionScreen.y*=-x;N.positionScreen.x*=u;N.positionScreen.y*=-x;r.addPoint(v.positionScreen.x,v.positionScreen.y);r.addPoint(A.positionScreen.x,A.positionScreen.y);r.addPoint(K.positionScreen.x,K.positionScreen.y);r.addPoint(N.positionScreen.x,N.positionScreen.y);if(J.instersects(r)){q=
-0;for(s=t.meshMaterials.length;q<s;){y=t.meshMaterials[q++];if(y instanceof THREE.MeshFaceMaterial){w=0;for(F=t.faceMaterials.length;w<F;)(y=t.faceMaterials[w++])&&c(v,A,K,N,t,y,p)}else y&&c(v,A,K,N,t,y,p)}}}}}};
-THREE.WebGLRenderer=function(a){function b(f,p,n){var j,i,q,s=f.vertices,w=s.length,F=f.colors,t=F.length,y=f.__vertexArray,B=f.__colorArray,Y=f.__sortArray,ga=f.__dirtyVertices,na=f.__dirtyColors;if(n.sortParticles){aa.multiplySelf(n.globalMatrix);for(j=0;j<w;j++){i=s[j].position;E.copy(i);aa.multiplyVector3(E);Y[j]=[E.z,j]}Y.sort(function(ua,Z){return Z[0]-ua[0]});for(j=0;j<w;j++){i=s[Y[j][1]].position;q=j*3;y[q]=i.x;y[q+1]=i.y;y[q+2]=i.z}for(j=0;j<t;j++){q=j*3;color=F[Y[j][1]];B[q]=color.r;B[q+
-1]=color.g;B[q+2]=color.b}}else{if(ga)for(j=0;j<w;j++){i=s[j].position;q=j*3;y[q]=i.x;y[q+1]=i.y;y[q+2]=i.z}if(na)for(j=0;j<t;j++){color=F[j];q=j*3;B[q]=color.r;B[q+1]=color.g;B[q+2]=color.b}}if(ga||n.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,y,p)}if(na||n.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,B,p)}}function c(f,p){f.fragment_shader=p.fragment_shader;f.vertex_shader=p.vertex_shader;f.uniforms=
-Uniforms.clone(p.uniforms)}function e(f,p){if(!f.__webGLVertexBuffer)f.__webGLVertexBuffer=d.createBuffer();if(!f.__webGLNormalBuffer)f.__webGLNormalBuffer=d.createBuffer();if(f.hasPos){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,f.positionArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(p.attributes.position);d.vertexAttribPointer(p.attributes.position,3,d.FLOAT,!1,0,0)}if(f.hasNormal){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,
-f.normalArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(p.attributes.normal);d.vertexAttribPointer(p.attributes.normal,3,d.FLOAT,!1,0,0)}d.drawArrays(d.TRIANGLES,0,f.count);f.count=0}function g(f){if(V!=f.doubleSided){f.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE);V=f.doubleSided}if(ea!=f.flipSided){f.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW);ea=f.flipSided}}function h(f){M[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);M[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+
-f.n14);M[2].set(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);M[3].set(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);M[4].set(f.n41-f.n31,f.n42-f.n32,f.n43-f.n33,f.n44-f.n34);M[5].set(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);var p;for(f=0;f<5;f++){p=M[f];p.divideScalar(Math.sqrt(p.x*p.x+p.y*p.y+p.z*p.z))}}function l(f){for(var p=f.globalMatrix,n=-f.geometry.boundingSphere.radius*Math.max(f.scale.x,Math.max(f.scale.y,f.scale.z)),j=0;j<6;j++){f=M[j].x*p.n14+M[j].y*p.n24+M[j].z*p.n34+M[j].w;
-if(f<=n)return!1}return!0}function m(f,p){f.list[f.count]=p;f.count+=1}function k(f){var p,n,j=f.object,i=f.opaque,q=f.transparent;q.count=0;f=i.count=0;for(p=j.materials.length;f<p;f++){n=j.materials[f];n.opacity&&n.opacity<1||n.blending!=THREE.NormalBlending?m(q,n):m(i,n)}}function o(f){var p,n,j,i,q=f.object,s=f.buffer,w=f.opaque,F=f.transparent;F.count=0;f=w.count=0;for(j=q.materials.length;f<j;f++){p=q.materials[f];if(p instanceof THREE.MeshFaceMaterial){p=0;for(n=s.materials.length;p<n;p++)(i=
-s.materials[p])&&(i.opacity&&i.opacity<1||i.blending!=THREE.NormalBlending?m(F,i):m(w,i))}else{i=p;i.opacity&&i.opacity<1||i.blending!=THREE.NormalBlending?m(F,i):m(w,i)}}}function u(f,p){return p.z-f.z}function x(f,p,n,j,i){if(p[n]==undefined){f.push({buffer:j,object:i,opaque:{list:[],count:0},transparent:{list:[],count:0}});p[n]=1}}function v(f,p){f._modelViewMatrix.multiplyToArray(p.globalMatrix,f.globalMatrix,f._modelViewMatrixArray);f._normalMatrix=THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}
-function A(f){if(f!=T){switch(f){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)}T=f}}function K(f,p){if(f&&!f.__webGLFramebuffer){f.__webGLFramebuffer=d.createFramebuffer();f.__webGLRenderbuffer=d.createRenderbuffer();
-f.__webGLTexture=d.createTexture();d.bindRenderbuffer(d.RENDERBUFFER,f.__webGLRenderbuffer);d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,f.width,f.height);d.bindTexture(d.TEXTURE_2D,f.__webGLTexture);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,J(f.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,J(f.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,J(f.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,J(f.min_filter));d.texImage2D(d.TEXTURE_2D,0,J(f.format),
-f.width,f.height,0,J(f.format),J(f.type),null);d.bindFramebuffer(d.FRAMEBUFFER,f.__webGLFramebuffer);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,f.__webGLTexture,0);d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.RENDERBUFFER,f.__webGLRenderbuffer);d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,null)}var n,j,i;if(f){n=f.__webGLFramebuffer;j=f.width;i=f.height}else{n=null;j=r.width;i=r.height}if(n!=S){d.bindFramebuffer(d.FRAMEBUFFER,
-n);d.viewport(0,0,j,i);p&&d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT);S=n}}function N(f,p){var n;if(f=="fragment")n=d.createShader(d.FRAGMENT_SHADER);else f=="vertex"&&(n=d.createShader(d.VERTEX_SHADER));d.shaderSource(n,p);d.compileShader(n);if(!d.getShaderParameter(n,d.COMPILE_STATUS)){alert(d.getShaderInfoLog(n));return null}return n}function J(f){switch(f){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 r=document.createElement("canvas"),d,I=null,S=null,V=null,ea=null,T=null,M=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,
-new THREE.Vector4],aa=new THREE.Matrix4,R=new Float32Array(16),ca=new Float32Array(16),W=new Float32Array(16),E=new THREE.Vector4,O=!0,ia=new THREE.Color(0),Q=0;if(a){if(a.antialias!==undefined)O=a.antialias;a.clearColor!==undefined&&ia.setHex(a.clearColor);if(a.clearAlpha!==undefined)Q=a.clearAlpha}this.domElement=r;this.autoClear=!0;this.sortObjects=!1;(function(f,p,n){try{d=r.getContext("experimental-webgl",{antialias:f})}catch(j){console.log(j)}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(p.r,p.g,p.b,n);_cullEnabled=!0})(O,ia,Q);this.context=d;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,p){r.width=f;r.height=p;d.viewport(0,0,r.width,r.height)};this.setClearColorHex=function(f,
-p){var n=new THREE.Color(f);d.clearColor(n.r,n.g,n.b,p)};this.setClearColor=function(f,p){d.clearColor(f.r,f.g,f.b,p)};this.clear=function(){d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT)};this.setupLights=function(f,p){var n,j,i,q=0,s=0,w=0,F,t,y,B=this.lights,Y=B.directional.colors,ga=B.directional.positions,na=B.point.colors,ua=B.point.positions,Z=0,fa=0;n=i=i=0;for(j=p.length;n<j;n++){i=p[n];F=i.color;t=i.position;y=i.intensity;if(i instanceof THREE.AmbientLight){q+=F.r;s+=F.g;w+=F.b}else if(i instanceof
-THREE.DirectionalLight){i=Z*3;Y[i]=F.r*y;Y[i+1]=F.g*y;Y[i+2]=F.b*y;ga[i]=t.x;ga[i+1]=t.y;ga[i+2]=t.z;Z+=1}else if(i instanceof THREE.PointLight){i=fa*3;na[i]=F.r*y;na[i+1]=F.g*y;na[i+2]=F.b*y;ua[i]=t.x;ua[i+1]=t.y;ua[i+2]=t.z;fa+=1}}for(n=Z*3;n<Y.length;n++)Y[n]=0;for(n=fa*3;n<na.length;n++)na[n]=0;B.point.length=fa;B.directional.length=Z;B.ambient[0]=q;B.ambient[1]=s;B.ambient[2]=w};this.initMaterial=function(f,p,n){var j,i;if(f instanceof THREE.MeshDepthMaterial)c(f,THREE.ShaderLib.depth);else if(f instanceof
-THREE.MeshNormalMaterial)c(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)c(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)c(f,THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)c(f,THREE.ShaderLib.phong);else if(f instanceof THREE.LineBasicMaterial)c(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&c(f,THREE.ShaderLib.particle_basic);var q,s,w,F;i=w=F=0;for(q=p.length;i<q;i++){s=p[i];s instanceof THREE.DirectionalLight&&
-w++;s instanceof THREE.PointLight&&F++}if(F+w<=4)p=w;else{p=Math.ceil(4*w/(F+w));F=4-p}i={directional:p,point:F};F=f.fragment_shader;p=f.vertex_shader;q={fog:n,map:f.map,env_map:f.env_map,light_map:f.light_map,vertex_colors:f.vertex_colors,skinning:f.skinning,maxDirLights:i.directional,maxPointLights:i.point};n=d.createProgram();i=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+q.maxDirLights,"#define MAX_POINT_LIGHTS "+q.maxPointLights,q.fog?"#define USE_FOG":"",q.fog instanceof
-THREE.FogExp2?"#define FOG_EXP2":"",q.map?"#define USE_MAP":"",q.env_map?"#define USE_ENVMAP":"",q.light_map?"#define USE_LIGHTMAP":"",q.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");q=[d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+q.maxDirLights,"#define MAX_POINT_LIGHTS "+q.maxPointLights,q.map?"#define USE_MAP":"",q.env_map?"#define USE_ENVMAP":"",q.light_map?"#define USE_LIGHTMAP":
-"",q.vertex_colors?"#define USE_COLOR":"",q.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
-d.attachShader(n,N("fragment",i+F));d.attachShader(n,N("vertex",q+p));d.linkProgram(n);d.getProgramParameter(n,d.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+d.getProgramParameter(n,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");n.uniforms={};n.attributes={};f.program=n;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","uBoneGlobalMatrices"];for(j in f.uniforms)n.push(j);j=f.program;F=0;for(p=n.length;F<
-p;F++){i=n[F];j.uniforms[i]=d.getUniformLocation(j,i)}f=f.program;j=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];n=0;for(F=j.length;n<F;n++){p=j[n];f.attributes[p]=d.getAttribLocation(f,p)}};this.setProgram=function(f,p,n,j,i){j.program||this.initMaterial(j,p,n);var q=j.program,s=q.uniforms,w=j.uniforms;if(q!=I){d.useProgram(q);I=q;d.uniformMatrix4fv(s.projectionMatrix,!1,R)}if(n&&(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||
-j instanceof THREE.MeshPhongMaterial||j instanceof THREE.LineBasicMaterial||j instanceof THREE.ParticleBasicMaterial)){w.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){w.fogNear.value=n.near;w.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)w.fogDensity.value=n.density}if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){this.setupLights(q,p);p=this.lights;w.enableLighting.value=p.directional.length+p.point.length;w.ambientLightColor.value=p.ambient;
-w.directionalLightColor.value=p.directional.colors;w.directionalLightDirection.value=p.directional.positions;w.pointLightColor.value=p.point.colors;w.pointLightPosition.value=p.point.positions}if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial){w.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);w.opacity.value=j.opacity;w.map.texture=j.map;w.light_map.texture=j.light_map;w.env_map.texture=j.env_map;
-w.reflectivity.value=j.reflectivity;w.refraction_ratio.value=j.refraction_ratio;w.combine.value=j.combine;w.useRefract.value=j.env_map&&j.env_map.mapping instanceof THREE.CubeRefractionMapping}if(j instanceof THREE.LineBasicMaterial){w.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);w.opacity.value=j.opacity}else if(j instanceof THREE.ParticleBasicMaterial){w.psColor.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);w.opacity.value=j.opacity;
-w.size.value=j.size;w.map.texture=j.map}else if(j instanceof THREE.MeshPhongMaterial){w.ambient.value.setRGB(j.ambient.r,j.ambient.g,j.ambient.b);w.specular.value.setRGB(j.specular.r,j.specular.g,j.specular.b);w.shininess.value=j.shininess}else if(j instanceof THREE.MeshDepthMaterial){w.mNear.value=f.near;w.mFar.value=f.far;w.opacity.value=j.opacity}else if(j instanceof THREE.MeshNormalMaterial)w.opacity.value=j.opacity;var F,t,y;for(F in w)if(y=q.uniforms[F]){n=w[F];t=n.type;p=n.value;if(t=="i")d.uniform1i(y,
-p);else if(t=="f")d.uniform1f(y,p);else if(t=="fv1")d.uniform1fv(y,p);else if(t=="fv")d.uniform3fv(y,p);else if(t=="v2")d.uniform2f(y,p.x,p.y);else if(t=="v3")d.uniform3f(y,p.x,p.y,p.z);else if(t=="c")d.uniform3f(y,p.r,p.g,p.b);else if(t=="t"){d.uniform1i(y,p);if(n=n.texture)if(n.image instanceof Array&&n.image.length==6){if(n.image.length==6){if(!n.image.__webGLTextureCube&&!n.image.__cubeMapInitialized&&n.image.loadCount==6){n.image.__webGLTextureCube=d.createTexture();d.bindTexture(d.TEXTURE_CUBE_MAP,
-n.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(t=0;t<6;++t)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,n.image[t]);d.generateMipmap(d.TEXTURE_CUBE_MAP);d.bindTexture(d.TEXTURE_CUBE_MAP,null);n.image.__cubeMapInitialized=
-!0}d.activeTexture(d.TEXTURE0+p);d.bindTexture(d.TEXTURE_CUBE_MAP,n.image.__webGLTextureCube)}}else{if(!n.__webGLTexture&&n.image.loaded){n.__webGLTexture=d.createTexture();d.bindTexture(d.TEXTURE_2D,n.__webGLTexture);d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,n.image);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,J(n.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,J(n.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,J(n.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,
-J(n.min_filter));d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}d.activeTexture(d.TEXTURE0+p);d.bindTexture(d.TEXTURE_2D,n.__webGLTexture)}}}d.uniformMatrix4fv(s.modelViewMatrix,!1,i._modelViewMatrixArray);d.uniformMatrix3fv(s.normalMatrix,!1,i._normalMatrixArray);(j instanceof THREE.MeshShaderMaterial||j instanceof THREE.MeshPhongMaterial||j.env_map)&&d.uniform3f(s.cameraPosition,f.position.x,f.position.y,f.position.z);(j instanceof THREE.MeshShaderMaterial||j.env_map||j.skinning)&&
-d.uniformMatrix4fv(s.objectMatrix,!1,i._objectMatrixArray);(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshShaderMaterial||j.skinning)&&d.uniformMatrix4fv(s.viewMatrix,!1,W);if(j.skinning){d.uniformMatrix4fv(s.cameraInverseMatrix,!1,ca);d.uniformMatrix4fv(s.uBoneGlobalMatrices,!1,i.boneMatrices)}return q};this.renderBuffer=function(f,p,n,j,i,q){f=this.setProgram(f,p,n,j,q).attributes;d.bindBuffer(d.ARRAY_BUFFER,i.__webGLVertexBuffer);d.vertexAttribPointer(f.position,
-3,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.position);if(f.color>=0){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLColorBuffer);d.vertexAttribPointer(f.color,3,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.color)}if(f.normal>=0){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLNormalBuffer);d.vertexAttribPointer(f.normal,3,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.normal)}if(f.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLTangentBuffer);d.vertexAttribPointer(f.tangent,4,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.tangent)}if(f.uv>=
-0)if(i.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLUVBuffer);d.vertexAttribPointer(f.uv,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.uv)}else d.disableVertexAttribArray(f.uv);if(f.uv2>=0)if(i.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLUV2Buffer);d.vertexAttribPointer(f.uv2,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.uv2)}else d.disableVertexAttribArray(f.uv2);if(q instanceof THREE.SkinnedMesh){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinVertexABuffer);d.vertexAttribPointer(f.skinVertexA,
-4,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.skinVertexA);d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinVertexBBuffer);d.vertexAttribPointer(f.skinVertexB,4,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.skinVertexB);d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinIndicesBuffer);d.vertexAttribPointer(f.skinIndex,4,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.skinIndex);d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinWeightsBuffer);d.vertexAttribPointer(f.skinWeight,4,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.skinWeight)}if(q instanceof
-THREE.Mesh)if(j.wireframe){d.lineWidth(j.wireframe_linewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,i.__webGLLineBuffer);d.drawElements(d.LINES,i.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,i.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,i.__webGLFaceCount,d.UNSIGNED_SHORT,0)}else if(q instanceof THREE.Line){q=q.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(j.linewidth);d.drawArrays(q,0,i.__webGLLineCount)}else q instanceof THREE.ParticleSystem&&d.drawArrays(d.POINTS,
-0,i.__webGLParticleCount)};this.render=function(f,p,n,j){var i,q,s,w,F,t,y,B,Y=f.lights,ga=f.fog;p.autoUpdateMatrix&&p.update();p.globalMatrix.flattenToArray(W);p.projectionMatrix.flattenToArray(R);p.inverseMatrix.flattenToArray(ca);aa.multiply(p.projectionMatrix,p.globalMatrix);h(aa);THREE.AnimationHandler&&THREE.AnimationHandler.update();f.update(undefined,!1,p);this.initWebGLObjects(f,p);K(n,j!==undefined?j:!0);this.autoClear&&this.clear();F=f.__webGLObjects.length;for(j=0;j<F;j++){i=f.__webGLObjects[j];
-y=i.object;if(y.visible)if(!(y instanceof THREE.Mesh)||l(y)){y.globalMatrix.flattenToArray(y._objectMatrixArray);v(y,p);o(i);i.render=!0;if(this.sortObjects){E.copy(y.position);aa.multiplyVector3(E);i.z=E.z}}else i.render=!1;else i.render=!1}this.sortObjects&&f.__webGLObjects.sort(u);t=f.__webGLObjectsImmediate.length;for(j=0;j<t;j++){i=f.__webGLObjectsImmediate[j];y=i.object;if(y.visible){y.autoUpdateMatrix&&y.globalMatrix.flattenToArray(y._objectMatrixArray);v(y,p);k(i)}}A(THREE.NormalBlending);
-for(j=0;j<F;j++){i=f.__webGLObjects[j];if(i.render){y=i.object;B=i.buffer;s=i.opaque;g(y);for(i=0;i<s.count;i++){w=s.list[i];this.setDepthTest(w.depth_test);this.renderBuffer(p,Y,ga,w,B,y)}}}for(j=0;j<t;j++){i=f.__webGLObjectsImmediate[j];y=i.object;if(y.visible){s=i.opaque;g(y);for(i=0;i<s.count;i++){w=s.list[i];this.setDepthTest(w.depth_test);q=this.setProgram(p,Y,ga,w,y);y.render(function(na){e(na,q)})}}}for(j=0;j<F;j++){i=f.__webGLObjects[j];if(i.render){y=i.object;B=i.buffer;s=i.transparent;
-g(y);for(i=0;i<s.count;i++){w=s.list[i];A(w.blending);this.setDepthTest(w.depth_test);this.renderBuffer(p,Y,ga,w,B,y)}}}for(j=0;j<t;j++){i=f.__webGLObjectsImmediate[j];y=i.object;if(y.visible){s=i.transparent;g(y);for(i=0;i<s.count;i++){w=s.list[i];A(w.blending);this.setDepthTest(w.depth_test);q=this.setProgram(p,Y,ga,w,y);y.render(function(na){e(na,q)})}}}if(n&&n.min_filter!==THREE.NearestFilter&&n.min_filter!==THREE.LinearFilter){d.bindTexture(d.TEXTURE_2D,n.__webGLTexture);d.generateMipmap(d.TEXTURE_2D);
-d.bindTexture(d.TEXTURE_2D,null)}};this.initWebGLObjects=function(f){var p,n,j;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={};f.__webGLObjectsImmediate=[]}p=0;for(n=f.objects.length;p<n;p++){j=f.objects[p];var i=f,q=void 0,s=void 0,w=void 0,F=void 0;s=j.geometry;if(i.__webGLObjectsMap[j.id]==undefined){i.__webGLObjectsMap[j.id]={};j._modelViewMatrix=new THREE.Matrix4;j._normalMatrixArray=new Float32Array(9);j._modelViewMatrixArray=new Float32Array(16);j._objectMatrixArray=new Float32Array(16);
-j.globalMatrix.flattenToArray(j._objectMatrixArray)}F=i.__webGLObjectsMap[j.id];objlist=i.__webGLObjects;if(j instanceof THREE.Mesh){for(q in s.geometryChunks){w=s.geometryChunks[q];if(!w.__webGLVertexBuffer){i=w;i.__webGLVertexBuffer=d.createBuffer();i.__webGLNormalBuffer=d.createBuffer();i.__webGLTangentBuffer=d.createBuffer();i.__webGLColorBuffer=d.createBuffer();i.__webGLUVBuffer=d.createBuffer();i.__webGLUV2Buffer=d.createBuffer();i.__webGLSkinVertexABuffer=d.createBuffer();i.__webGLSkinVertexBBuffer=
-d.createBuffer();i.__webGLSkinIndicesBuffer=d.createBuffer();i.__webGLSkinWeightsBuffer=d.createBuffer();i.__webGLFaceBuffer=d.createBuffer();i.__webGLLineBuffer=d.createBuffer();i=w;var t=j,y=void 0,B=void 0,Y=0,ga=0,na=0,ua=t.geometry.faces,Z=i.faces;y=0;for(B=Z.length;y<B;y++){fi=Z[y];face=ua[fi];if(face instanceof THREE.Face3){Y+=3;ga+=1;na+=3}else if(face instanceof THREE.Face4){Y+=4;ga+=2;na+=4}}i.__vertexArray=new Float32Array(Y*3);i.__normalArray=new Float32Array(Y*3);i.__tangentArray=new Float32Array(Y*
-4);i.__colorArray=new Float32Array(Y*3);i.__uvArray=new Float32Array(Y*2);i.__uv2Array=new Float32Array(Y*2);i.__skinVertexAArray=new Float32Array(Y*4);i.__skinVertexBArray=new Float32Array(Y*4);i.__skinIndexArray=new Float32Array(Y*4);i.__skinWeightArray=new Float32Array(Y*4);i.__faceArray=new Uint16Array(ga*3);i.__lineArray=new Uint16Array(na*2);B=y=i;Y=void 0;ua=void 0;var fa=void 0,ha=void 0;fa=void 0;Z=!1;Y=0;for(ua=t.materials.length;Y<ua;Y++){fa=t.materials[Y];if(fa instanceof THREE.MeshFaceMaterial){fa=
-0;for(ha=B.materials.length;fa<ha;fa++)if(B.materials[fa]&&B.materials[fa].shading!=undefined&&B.materials[fa].shading==THREE.SmoothShading){Z=!0;break}}else if(fa&&fa.shading!=undefined&&fa.shading==THREE.SmoothShading){Z=!0;break}if(Z)break}y.__needsSmoothNormals=Z;i.__webGLFaceCount=ga*3;i.__webGLLineCount=na*2;s.__dirtyVertices=!0;s.__dirtyElements=!0;s.__dirtyUvs=!0;s.__dirtyNormals=!0;s.__dirtyTangents=!0;s.__dirtyColors=!0}if(s.__dirtyVertices||s.__dirtyElements||s.__dirtyUvs||s.__dirtyNormals||
-s.__dirtyColors||s.__dirtyTangents){i=w;ga=d.DYNAMIC_DRAW;na=void 0;y=void 0;var Ia=void 0,C=void 0,Ca=void 0,wa=void 0,za=void 0;Ia=void 0;var G=void 0,L=void 0,P=void 0,ja=void 0;G=void 0;L=void 0;P=void 0;C=void 0;G=void 0;L=void 0;P=void 0;ja=void 0;G=void 0;L=void 0;P=void 0;ja=void 0;G=void 0;L=void 0;P=void 0;ja=void 0;G=void 0;L=void 0;P=void 0;ja=void 0;G=void 0;L=void 0;P=void 0;ja=void 0;C=void 0;wa=void 0;Ca=void 0;za=void 0;var Ea=ha=fa=Z=ua=Y=t=B=0,ra=0,z=0,pa=i.__vertexArray,Ma=i.__uvArray,
-Ka=i.__uv2Array,Ha=i.__normalArray,la=i.__tangentArray,qa=i.__colorArray,ma=i.__skinVertexAArray,ka=i.__skinVertexBArray,oa=i.__skinIndexArray,$=i.__skinWeightArray,xa=i.__faceArray,va=i.__lineArray,Oa=i.__needsSmoothNormals,ya=j.geometry,Na=ya.__dirtyVertices,D=ya.__dirtyElements,ba=ya.__dirtyUvs,X=ya.__dirtyNormals,H=ya.__dirtyTangents,U=ya.__dirtyColors,da=ya.vertices,sa=i.faces,Aa=ya.faces,Da=ya.uvs,La=ya.uvs2,ta=ya.colors,Ga=ya.skinVerticesA,Ja=ya.skinVerticesB,Fa=ya.skinIndices,Ba=ya.skinWeights;
-na=0;for(y=sa.length;na<y;na++){Ia=sa[na];C=Aa[Ia];za=Da[Ia];Ia=La[Ia];Ca=C.vertexNormals;wa=C.normal;if(C instanceof THREE.Face3){if(Na){G=da[C.a].position;L=da[C.b].position;P=da[C.c].position;pa[t]=G.x;pa[t+1]=G.y;pa[t+2]=G.z;pa[t+3]=L.x;pa[t+4]=L.y;pa[t+5]=L.z;pa[t+6]=P.x;pa[t+7]=P.y;pa[t+8]=P.z;t+=9}if(Ba.length){G=Ba[C.a];L=Ba[C.b];P=Ba[C.c];$[z]=G.x;$[z+1]=G.y;$[z+2]=G.z;$[z+3]=G.w;$[z+4]=L.x;$[z+5]=L.y;$[z+6]=L.z;$[z+7]=L.w;$[z+8]=P.x;$[z+9]=P.y;$[z+10]=P.z;$[z+11]=P.w;G=Fa[C.a];L=Fa[C.b];
-P=Fa[C.c];oa[z]=G.x;oa[z+1]=G.y;oa[z+2]=G.z;oa[z+3]=G.w;oa[z+4]=L.x;oa[z+5]=L.y;oa[z+6]=L.z;oa[z+7]=L.w;oa[z+8]=P.x;oa[z+9]=P.y;oa[z+10]=P.z;oa[z+11]=P.w;G=Ga[C.a];L=Ga[C.b];P=Ga[C.c];ma[z]=G.x;ma[z+1]=G.y;ma[z+2]=G.z;ma[z+3]=1;ma[z+4]=L.x;ma[z+5]=L.y;ma[z+6]=L.z;ma[z+7]=1;ma[z+8]=P.x;ma[z+9]=P.y;ma[z+10]=P.z;ma[z+11]=1;G=Ja[C.a];L=Ja[C.b];P=Ja[C.c];ka[z]=G.x;ka[z+1]=G.y;ka[z+2]=G.z;ka[z+3]=1;ka[z+4]=L.x;ka[z+5]=L.y;ka[z+6]=L.z;ka[z+7]=1;ka[z+8]=P.x;ka[z+9]=P.y;ka[z+10]=P.z;ka[z+11]=1;z+=12}if(U&&
-ta.length){G=ta[C.a];L=ta[C.b];P=ta[C.c];qa[ra]=G.r;qa[ra+1]=G.g;qa[ra+2]=G.b;qa[ra+3]=L.r;qa[ra+4]=L.g;qa[ra+5]=L.b;qa[ra+6]=P.r;qa[ra+7]=P.g;qa[ra+8]=P.b;ra+=9}if(H&&ya.hasTangents){G=da[C.a].tangent;L=da[C.b].tangent;P=da[C.c].tangent;la[ha]=G.x;la[ha+1]=G.y;la[ha+2]=G.z;la[ha+3]=G.w;la[ha+4]=L.x;la[ha+5]=L.y;la[ha+6]=L.z;la[ha+7]=L.w;la[ha+8]=P.x;la[ha+9]=P.y;la[ha+10]=P.z;la[ha+11]=P.w;ha+=12}if(X)if(Ca.length==3&&Oa)for(C=0;C<3;C++){wa=Ca[C];Ha[fa]=wa.x;Ha[fa+1]=wa.y;Ha[fa+2]=wa.z;fa+=3}else for(C=
-0;C<3;C++){Ha[fa]=wa.x;Ha[fa+1]=wa.y;Ha[fa+2]=wa.z;fa+=3}if(ba&&za)for(C=0;C<3;C++){Ca=za[C];Ma[Y]=Ca.u;Ma[Y+1]=Ca.v;Y+=2}if(ba&&Ia)for(C=0;C<3;C++){za=Ia[C];Ka[ua]=za.u;Ka[ua+1]=za.v;ua+=2}if(D){xa[Z]=B;xa[Z+1]=B+1;xa[Z+2]=B+2;Z+=3;va[Ea]=B;va[Ea+1]=B+1;va[Ea+2]=B;va[Ea+3]=B+2;va[Ea+4]=B+1;va[Ea+5]=B+2;Ea+=6;B+=3}}else if(C instanceof THREE.Face4){if(Na){G=da[C.a].position;L=da[C.b].position;P=da[C.c].position;ja=da[C.d].position;pa[t]=G.x;pa[t+1]=G.y;pa[t+2]=G.z;pa[t+3]=L.x;pa[t+4]=L.y;pa[t+5]=
-L.z;pa[t+6]=P.x;pa[t+7]=P.y;pa[t+8]=P.z;pa[t+9]=ja.x;pa[t+10]=ja.y;pa[t+11]=ja.z;t+=12}if(Ba.length){G=Ba[C.a];L=Ba[C.b];P=Ba[C.c];ja=Ba[C.d];$[z]=G.x;$[z+1]=G.y;$[z+2]=G.z;$[z+3]=G.w;$[z+4]=L.x;$[z+5]=L.y;$[z+6]=L.z;$[z+7]=L.w;$[z+8]=P.x;$[z+9]=P.y;$[z+10]=P.z;$[z+11]=P.w;$[z+12]=ja.x;$[z+13]=ja.y;$[z+14]=ja.z;$[z+15]=ja.w;G=Fa[C.a];L=Fa[C.b];P=Fa[C.c];ja=Fa[C.d];oa[z]=G.x;oa[z+1]=G.y;oa[z+2]=G.z;oa[z+3]=G.w;oa[z+4]=L.x;oa[z+5]=L.y;oa[z+6]=L.z;oa[z+7]=L.w;oa[z+8]=P.x;oa[z+9]=P.y;oa[z+10]=P.z;oa[z+
-11]=P.w;oa[z+12]=ja.x;oa[z+13]=ja.y;oa[z+14]=ja.z;oa[z+15]=ja.w;G=Ga[C.a];L=Ga[C.b];P=Ga[C.c];ja=Ga[C.d];ma[z]=G.x;ma[z+1]=G.y;ma[z+2]=G.z;ma[z+3]=1;ma[z+4]=L.x;ma[z+5]=L.y;ma[z+6]=L.z;ma[z+7]=1;ma[z+8]=P.x;ma[z+9]=P.y;ma[z+10]=P.z;ma[z+11]=1;ma[z+12]=ja.x;ma[z+13]=ja.y;ma[z+14]=ja.z;ma[z+15]=1;G=Ja[C.a];L=Ja[C.b];P=Ja[C.c];ja=Ja[C.d];ka[z]=G.x;ka[z+1]=G.y;ka[z+2]=G.z;ka[z+3]=1;ka[z+4]=L.x;ka[z+5]=L.y;ka[z+6]=L.z;ka[z+7]=1;ka[z+8]=P.x;ka[z+9]=P.y;ka[z+10]=P.z;ka[z+11]=1;ka[z+12]=ja.x;ka[z+13]=ja.y;
-ka[z+14]=ja.z;ka[z+15]=1;z+=16}if(U&&ta.length){G=ta[C.a];L=ta[C.b];P=ta[C.c];ja=ta[C.d];qa[ra]=G.r;qa[ra+1]=G.g;qa[ra+2]=G.b;qa[ra+3]=L.r;qa[ra+4]=L.g;qa[ra+5]=L.b;qa[ra+6]=P.r;qa[ra+7]=P.g;qa[ra+8]=P.b;qa[ra+9]=ja.r;qa[ra+10]=ja.g;qa[ra+11]=ja.b;ra+=12}if(H&&ya.hasTangents){G=da[C.a].tangent;L=da[C.b].tangent;P=da[C.c].tangent;C=da[C.d].tangent;la[ha]=G.x;la[ha+1]=G.y;la[ha+2]=G.z;la[ha+3]=G.w;la[ha+4]=L.x;la[ha+5]=L.y;la[ha+6]=L.z;la[ha+7]=L.w;la[ha+8]=P.x;la[ha+9]=P.y;la[ha+10]=P.z;la[ha+11]=
-P.w;la[ha+12]=C.x;la[ha+13]=C.y;la[ha+14]=C.z;la[ha+15]=C.w;ha+=16}if(X)if(Ca.length==4&&Oa)for(C=0;C<4;C++){wa=Ca[C];Ha[fa]=wa.x;Ha[fa+1]=wa.y;Ha[fa+2]=wa.z;fa+=3}else for(C=0;C<4;C++){Ha[fa]=wa.x;Ha[fa+1]=wa.y;Ha[fa+2]=wa.z;fa+=3}if(ba&&za)for(C=0;C<4;C++){Ca=za[C];Ma[Y]=Ca.u;Ma[Y+1]=Ca.v;Y+=2}if(ba&&Ia)for(C=0;C<4;C++){za=Ia[C];Ka[ua]=za.u;Ka[ua+1]=za.v;ua+=2}if(D){xa[Z]=B;xa[Z+1]=B+1;xa[Z+2]=B+2;xa[Z+3]=B;xa[Z+4]=B+2;xa[Z+5]=B+3;Z+=6;va[Ea]=B;va[Ea+1]=B+1;va[Ea+2]=B;va[Ea+3]=B+3;va[Ea+4]=B+1;
-va[Ea+5]=B+2;va[Ea+6]=B+2;va[Ea+7]=B+3;Ea+=8;B+=4}}}if(Na){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,pa,ga)}if(U&&ta.length){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,qa,ga)}if(X){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,Ha,ga)}if(H&&ya.hasTangents){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLTangentBuffer);d.bufferData(d.ARRAY_BUFFER,la,ga)}if(ba&&Y>0){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLUVBuffer);
-d.bufferData(d.ARRAY_BUFFER,Ma,ga)}if(ba&&ua>0){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Ka,ga)}if(D){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,i.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,xa,ga);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,i.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,va,ga)}if(z>0){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinVertexABuffer);d.bufferData(d.ARRAY_BUFFER,ma,ga);d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinVertexBBuffer);d.bufferData(d.ARRAY_BUFFER,
-ka,ga);d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinIndicesBuffer);d.bufferData(d.ARRAY_BUFFER,oa,ga);d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinWeightsBuffer);d.bufferData(d.ARRAY_BUFFER,$,ga)}}x(objlist,F,q,w,j)}s.__dirtyVertices=!1;s.__dirtyElements=!1;s.__dirtyUvs=!1;s.__dirtyNormals=!1;s.__dirtyTangents=!1;s.__dirtyColors=!1}else if(j instanceof THREE.Line){if(!s.__webGLVertexBuffer){q=s;q.__webGLVertexBuffer=d.createBuffer();q.__webGLColorBuffer=d.createBuffer();q=s;w=q.vertices.length;q.__vertexArray=
-new Float32Array(w*3);q.__colorArray=new Float32Array(w*3);q.__webGLLineCount=w;s.__dirtyVertices=!0;s.__dirtyColors=!0}if(s.__dirtyVertices||s.__dirtyColors){q=s;w=d.DYNAMIC_DRAW;B=void 0;B=void 0;t=void 0;i=void 0;Y=q.vertices;ga=q.colors;ua=Y.length;na=ga.length;Z=q.__vertexArray;y=q.__colorArray;fa=q.__dirtyColors;if(q.__dirtyVertices){for(B=0;B<ua;B++){t=Y[B].position;i=B*3;Z[i]=t.x;Z[i+1]=t.y;Z[i+2]=t.z}d.bindBuffer(d.ARRAY_BUFFER,q.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,Z,w)}if(fa){for(B=
-0;B<na;B++){color=ga[B];i=B*3;y[i]=color.r;y[i+1]=color.g;y[i+2]=color.b}d.bindBuffer(d.ARRAY_BUFFER,q.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,y,w)}}x(objlist,F,0,s,j);s.__dirtyVertices=!1;s.__dirtyColors=!1}else if(j instanceof THREE.ParticleSystem){if(!s.__webGLVertexBuffer){q=s;q.__webGLVertexBuffer=d.createBuffer();q.__webGLColorBuffer=d.createBuffer();q=s;w=q.vertices.length;q.__vertexArray=new Float32Array(w*3);q.__colorArray=new Float32Array(w*3);q.__sortArray=[];q.__webGLParticleCount=
-w;s.__dirtyVertices=!0;s.__dirtyColors=!0}(s.__dirtyVertices||s.__dirtyColors||j.sortParticles)&&b(s,d.DYNAMIC_DRAW,j,camera);x(objlist,F,0,s,j);s.__dirtyVertices=!1;s.__dirtyColors=!1}else if(j instanceof THREE.MarchingCubes){s=F;if(s[0]==undefined){i.__webGLObjectsImmediate.push({object:j,opaque:{list:[],count:0},transparent:{list:[],count:0}});s[0]=1}}}};this.removeObject=function(f,p){var n,j;for(n=f.__webGLObjects.length-1;n>=0;n--){j=f.__webGLObjects[n].object;p==j&&f.__webGLObjects.splice(n,
-1)}};this.addToRenderList=function(){};this.removeFromRenderList=function(){};this.setDepthTest=function(f){f?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST)};this.setFaceCulling=function(f,p){if(f){!p||p=="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW);if(f=="back")d.cullFace(d.BACK);else f=="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}};
+THREE.Projector=function(){function a(T,N){return N.z-T.z}function b(T,N){var ba=0,R=1,aa=T.z+T.w,V=N.z+N.w,B=-T.z+T.w,I=-N.z+N.w;if(aa>=0&&V>=0&&B>=0&&I>=0)return!0;else if(aa<0&&V<0||B<0&&I<0)return!1;else{if(aa<0)ba=Math.max(ba,aa/(aa-V));else V<0&&(R=Math.min(R,aa/(aa-V)));if(B<0)ba=Math.max(ba,B/(B-I));else I<0&&(R=Math.min(R,B/(B-I)));if(R<ba)return!1;else{T.lerpSelf(N,ba);N.lerpSelf(T,1-R);return!0}}}var c,e,g=[],i,l,n,k=[],o,s,w=[],t,x,F=[],H=new THREE.Vector4,G=new THREE.Vector4,r=new THREE.Matrix4,
+Z=new THREE.Matrix4,D=[],K=new THREE.Vector4,d=new THREE.Vector4,ga;this.projectObjects=function(T,N,ba){N=[];var R,aa,V;e=0;aa=T.objects;T=0;for(R=aa.length;T<R;T++){V=aa[T];var B;if(!(B=!V.visible))if(B=V instanceof THREE.Mesh){a:{B=void 0;for(var I=V.globalMatrix,ka=-V.geometry.boundingSphere.radius*Math.max(V.scale.x,Math.max(V.scale.y,V.scale.z)),P=0;P<6;P++){B=D[P].x*I.n14+D[P].y*I.n24+D[P].z*I.n34+D[P].w;if(B<=ka){B=!1;break a}}B=!0}B=!B}if(!B){c=g[e]=g[e]||new THREE.RenderableObject;H.copy(V.position);
+r.multiplyVector3(H);c.object=V;c.z=H.z;N.push(c);e++}}ba&&N.sort(a);return N};this.projectScene=function(T,N,ba){var R=[],aa=N.near,V=N.far,B,I,ka,P,ja,ca,Q,ra,wa,f,m,p,j,h,q,v;n=s=x=0;N.autoUpdateMatrix&&N.update();r.multiply(N.projectionMatrix,N.globalMatrix);D[0]=new THREE.Vector4(r.n41-r.n11,r.n42-r.n12,r.n43-r.n13,r.n44-r.n14);D[1]=new THREE.Vector4(r.n41+r.n11,r.n42+r.n12,r.n43+r.n13,r.n44+r.n14);D[2]=new THREE.Vector4(r.n41+r.n21,r.n42+r.n22,r.n43+r.n23,r.n44+r.n24);D[3]=new THREE.Vector4(r.n41-
+r.n21,r.n42-r.n22,r.n43-r.n23,r.n44-r.n24);D[4]=new THREE.Vector4(r.n41-r.n31,r.n42-r.n32,r.n43-r.n33,r.n44-r.n34);D[5]=new THREE.Vector4(r.n41+r.n31,r.n42+r.n32,r.n43+r.n33,r.n44+r.n34);B=0;for(ca=D.length;B<ca;B++){Q=D[B];Q.divideScalar(Math.sqrt(Q.x*Q.x+Q.y*Q.y+Q.z*Q.z))}T.update(undefined,!1,N);ca=this.projectObjects(T,N,!0);T=0;for(B=ca.length;T<B;T++){Q=ca[T].object;if(Q.visible){Q.autoUpdateMatrix&&Q.updateMatrix();ra=Q.globalMatrix;ra.extractRotationMatrix(Q.rotationMatrix);m=Q.rotationMatrix;
+wa=Q.materials;f=Q.overdraw;if(Q instanceof THREE.Mesh){p=Q.geometry;j=p.vertices;I=0;for(ka=j.length;I<ka;I++){h=j[I];h.positionWorld.copy(h.position);ra.multiplyVector3(h.positionWorld);P=h.positionScreen;P.copy(h.positionWorld);r.multiplyVector4(P);P.x/=P.w;P.y/=P.w;h.__visible=P.z>aa&&P.z<V}p=p.faces;I=0;for(ka=p.length;I<ka;I++){h=p[I];if(h instanceof THREE.Face3){P=j[h.a];ja=j[h.b];q=j[h.c];if(P.__visible&&ja.__visible&&q.__visible&&(Q.doubleSided||Q.flipSided!=(q.positionScreen.x-P.positionScreen.x)*
+(ja.positionScreen.y-P.positionScreen.y)-(q.positionScreen.y-P.positionScreen.y)*(ja.positionScreen.x-P.positionScreen.x)<0)){i=k[n]=k[n]||new THREE.RenderableFace3;i.v1.positionWorld.copy(P.positionWorld);i.v2.positionWorld.copy(ja.positionWorld);i.v3.positionWorld.copy(q.positionWorld);i.v1.positionScreen.copy(P.positionScreen);i.v2.positionScreen.copy(ja.positionScreen);i.v3.positionScreen.copy(q.positionScreen);i.normalWorld.copy(h.normal);m.multiplyVector3(i.normalWorld);i.centroidWorld.copy(h.centroid);
+ra.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);r.multiplyVector3(i.centroidScreen);q=h.vertexNormals;ga=i.vertexNormalsWorld;P=0;for(ja=q.length;P<ja;P++){v=ga[P]=ga[P]||new THREE.Vector3;v.copy(q[P]);m.multiplyVector3(v)}i.z=i.centroidScreen.z;i.meshMaterials=wa;i.faceMaterials=h.materials;i.overdraw=f;if(Q.geometry.uvs[I]){i.uvs[0]=Q.geometry.uvs[I][0];i.uvs[1]=Q.geometry.uvs[I][1];i.uvs[2]=Q.geometry.uvs[I][2]}R.push(i);n++}}else if(h instanceof THREE.Face4){P=j[h.a];
+ja=j[h.b];q=j[h.c];v=j[h.d];if(P.__visible&&ja.__visible&&q.__visible&&v.__visible&&(Q.doubleSided||Q.flipSided!=((v.positionScreen.x-P.positionScreen.x)*(ja.positionScreen.y-P.positionScreen.y)-(v.positionScreen.y-P.positionScreen.y)*(ja.positionScreen.x-P.positionScreen.x)<0||(ja.positionScreen.x-q.positionScreen.x)*(v.positionScreen.y-q.positionScreen.y)-(ja.positionScreen.y-q.positionScreen.y)*(v.positionScreen.x-q.positionScreen.x)<0))){i=k[n]=k[n]||new THREE.RenderableFace3;i.v1.positionWorld.copy(P.positionWorld);
+i.v2.positionWorld.copy(ja.positionWorld);i.v3.positionWorld.copy(v.positionWorld);i.v1.positionScreen.copy(P.positionScreen);i.v2.positionScreen.copy(ja.positionScreen);i.v3.positionScreen.copy(v.positionScreen);i.normalWorld.copy(h.normal);m.multiplyVector3(i.normalWorld);i.centroidWorld.copy(h.centroid);ra.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);r.multiplyVector3(i.centroidScreen);i.z=i.centroidScreen.z;i.meshMaterials=wa;i.faceMaterials=h.materials;i.overdraw=f;
+if(Q.geometry.uvs[I]){i.uvs[0]=Q.geometry.uvs[I][0];i.uvs[1]=Q.geometry.uvs[I][1];i.uvs[2]=Q.geometry.uvs[I][3]}R.push(i);n++;l=k[n]=k[n]||new THREE.RenderableFace3;l.v1.positionWorld.copy(ja.positionWorld);l.v2.positionWorld.copy(q.positionWorld);l.v3.positionWorld.copy(v.positionWorld);l.v1.positionScreen.copy(ja.positionScreen);l.v2.positionScreen.copy(q.positionScreen);l.v3.positionScreen.copy(v.positionScreen);l.normalWorld.copy(i.normalWorld);l.centroidWorld.copy(i.centroidWorld);l.centroidScreen.copy(i.centroidScreen);
+l.z=l.centroidScreen.z;l.meshMaterials=wa;l.faceMaterials=h.materials;l.overdraw=f;if(Q.geometry.uvs[I]){l.uvs[0]=Q.geometry.uvs[I][1];l.uvs[1]=Q.geometry.uvs[I][2];l.uvs[2]=Q.geometry.uvs[I][3]}R.push(l);n++}}}}else if(Q instanceof THREE.Line){Z.multiply(r,ra);j=Q.geometry.vertices;h=j[0];h.positionScreen.copy(h.position);Z.multiplyVector4(h.positionScreen);I=1;for(ka=j.length;I<ka;I++){P=j[I];P.positionScreen.copy(P.position);Z.multiplyVector4(P.positionScreen);ja=j[I-1];K.copy(P.positionScreen);
+d.copy(ja.positionScreen);if(b(K,d)){K.multiplyScalar(1/K.w);d.multiplyScalar(1/d.w);o=w[s]=w[s]||new THREE.RenderableLine;o.v1.positionScreen.copy(K);o.v2.positionScreen.copy(d);o.z=Math.max(K.z,d.z);o.materials=Q.materials;R.push(o);s++}}}else if(Q instanceof THREE.Particle){G.set(Q.position.x,Q.position.y,Q.position.z,1);r.multiplyVector4(G);G.z/=G.w;if(G.z>0&&G.z<1){t=F[x]=F[x]||new THREE.RenderableParticle;t.x=G.x/G.w;t.y=G.y/G.w;t.z=G.z;t.rotation=Q.rotation.z;t.scale.x=Q.scale.x*Math.abs(t.x-
+(G.x+N.projectionMatrix.n11)/(G.w+N.projectionMatrix.n14));t.scale.y=Q.scale.y*Math.abs(t.y-(G.y+N.projectionMatrix.n22)/(G.w+N.projectionMatrix.n24));t.materials=Q.materials;R.push(t);x++}}}}ba&&R.sort(a);return R};this.unprojectVector=function(T,N){var ba=THREE.Matrix4.makeInvert(N.globalMatrix);ba.multiplySelf(THREE.Matrix4.makeInvert(N.projectionMatrix));ba.multiplyVector3(T);return T}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,g,i;this.domElement=document.createElement("div");this.setSize=function(l,n){c=l;e=n;g=c/2;i=e/2};this.render=function(l,n){var k,o,s,w,t,x,F,H;a=b.projectScene(l,n);k=0;for(o=a.length;k<o;k++){t=a[k];if(t instanceof THREE.RenderableParticle){F=t.x*g+g;H=t.y*i+i;s=0;for(w=t.material.length;s<w;s++){x=t.material[s];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=F+"px";x.style.top=H+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(na){if(t!=na)o.globalAlpha=t=na}function b(na){if(x!=na){switch(na){case THREE.NormalBlending:o.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:o.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:o.globalCompositeOperation="darker"}x=na}}var c=null,e=new THREE.Projector,g=document.createElement("canvas"),i,l,n,k,o=g.getContext("2d"),s=new THREE.Color(0),w=0,t=1,x=0,F=null,H=null,G=1,r,Z,D,K,d,ga,T,N,ba,R=new THREE.Color,
+aa=new THREE.Color,V=new THREE.Color,B=new THREE.Color,I=new THREE.Color,ka,P,ja,ca,Q,ra,wa,f,m,p=new THREE.Rectangle,j=new THREE.Rectangle,h=new THREE.Rectangle,q=!1,v=new THREE.Color,C=new THREE.Color,W=new THREE.Color,L=new THREE.Color,S=Math.PI*2,E=new THREE.Vector3,da,ea,va,la,ha,ia,fa=16;da=document.createElement("canvas");da.width=da.height=2;ea=da.getContext("2d");ea.fillStyle="rgba(0,0,0,1)";ea.fillRect(0,0,2,2);va=ea.getImageData(0,0,2,2);la=va.data;ha=document.createElement("canvas");ha.width=
+ha.height=fa;ia=ha.getContext("2d");ia.translate(-fa/2,-fa/2);ia.scale(fa,fa);fa--;this.domElement=g;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(na,y){i=na;l=y;n=i/2;k=l/2;g.width=i;g.height=l;p.set(-n,-k,n,k);t=1;x=0;H=F=null;G=1};this.setClearColor=function(na,y){s=na;w=y;j.set(-n,-k,n,k);o.setTransform(1,0,0,-1,n,k);this.clear()};this.setClearColorHex=function(na,y){s.setHex(na);w=y;j.set(-n,-k,n,k);o.setTransform(1,0,0,-1,n,k);this.clear()};this.clear=function(){o.setTransform(1,
+0,0,-1,n,k);if(!j.isEmpty()){j.inflate(1);j.minSelf(p);if(s.hex==0&&w==0)o.clearRect(j.getX(),j.getY(),j.getWidth(),j.getHeight());else{b(THREE.NormalBlending);a(1);o.fillStyle="rgba("+Math.floor(s.r*255)+","+Math.floor(s.g*255)+","+Math.floor(s.b*255)+","+w+")";o.fillRect(j.getX(),j.getY(),j.getWidth(),j.getHeight())}j.empty()}};this.render=function(na,y){function Fa(z){var X,Y,A,U=z.lights;C.setRGB(0,0,0);W.setRGB(0,0,0);L.setRGB(0,0,0);z=0;for(X=U.length;z<X;z++){Y=U[z];A=Y.color;if(Y instanceof
+THREE.AmbientLight){C.r+=A.r;C.g+=A.g;C.b+=A.b}else if(Y instanceof THREE.DirectionalLight){W.r+=A.r;W.g+=A.g;W.b+=A.b}else if(Y instanceof THREE.PointLight){L.r+=A.r;L.g+=A.g;L.b+=A.b}}}function za(z,X,Y,A){var U,ma,xa,Da,Ea=z.lights;z=0;for(U=Ea.length;z<U;z++){ma=Ea[z];xa=ma.color;Da=ma.intensity;if(ma instanceof THREE.DirectionalLight){ma=Y.dot(ma.position)*Da;if(ma>0){A.r+=xa.r*ma;A.g+=xa.g*ma;A.b+=xa.b*ma}}else if(ma instanceof THREE.PointLight){E.sub(ma.position,X);E.normalize();ma=Y.dot(E)*
+Da;if(ma>0){A.r+=xa.r*ma;A.g+=xa.g*ma;A.b+=xa.b*ma}}}}function Ga(z,X,Y){if(Y.opacity!=0){a(Y.opacity);b(Y.blending);var A,U,ma,xa,Da,Ea;if(Y instanceof THREE.ParticleBasicMaterial){if(Y.map&&Y.map.image.loaded){xa=Y.map.image;Da=xa.width>>1;Ea=xa.height>>1;U=X.scale.x*n;ma=X.scale.y*k;Y=U*Da;A=ma*Ea;h.set(z.x-Y,z.y-A,z.x+Y,z.y+A);if(p.instersects(h)){o.save();o.translate(z.x,z.y);o.rotate(-X.rotation);o.scale(U,-ma);o.translate(-Da,-Ea);o.drawImage(xa,0,0);o.restore()}}}else if(Y instanceof THREE.ParticleCircleMaterial){if(q){v.r=
+C.r+W.r+L.r;v.g=C.g+W.g+L.g;v.b=C.b+W.b+L.b;R.r=Y.color.r*v.r;R.g=Y.color.g*v.g;R.b=Y.color.b*v.b;R.updateStyleString()}else R.__styleString=Y.color.__styleString;Y=X.scale.x*n;A=X.scale.y*k;h.set(z.x-Y,z.y-A,z.x+Y,z.y+A);if(p.instersects(h)){U=R.__styleString;if(H!=U)o.fillStyle=H=U;o.save();o.translate(z.x,z.y);o.rotate(-X.rotation);o.scale(Y,A);o.beginPath();o.arc(0,0,1,0,S,!0);o.closePath();o.fill();o.restore()}}}}function O(z,X,Y,A){if(A.opacity!=0){a(A.opacity);b(A.blending);o.beginPath();o.moveTo(z.positionScreen.x,
+z.positionScreen.y);o.lineTo(X.positionScreen.x,X.positionScreen.y);o.closePath();if(A instanceof THREE.LineBasicMaterial){R.__styleString=A.color.__styleString;z=A.linewidth;if(G!=z)o.lineWidth=G=z;z=R.__styleString;if(F!=z)o.strokeStyle=F=z;o.stroke();h.inflate(A.linewidth*2)}}}function M(z,X,Y,A,U,ma){if(U.opacity!=0){a(U.opacity);b(U.blending);K=z.positionScreen.x;d=z.positionScreen.y;ga=X.positionScreen.x;T=X.positionScreen.y;N=Y.positionScreen.x;ba=Y.positionScreen.y;o.beginPath();o.moveTo(K,
+d);o.lineTo(ga,T);o.lineTo(N,ba);o.lineTo(K,d);o.closePath();if(U instanceof THREE.MeshBasicMaterial)if(U.map)U.map.image.loaded&&U.map.mapping instanceof THREE.UVMapping&&Ca(K,d,ga,T,N,ba,U.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);else if(U.env_map){if(U.env_map.image.loaded&&U.env_map.mapping instanceof THREE.SphericalReflectionMapping){z=y.globalMatrix;E.copy(A.vertexNormalsWorld[0]);ca=(E.x*z.n11+E.y*z.n12+E.z*z.n13)*0.5+0.5;Q=-(E.x*z.n21+E.y*z.n22+E.z*z.n23)*
+0.5+0.5;E.copy(A.vertexNormalsWorld[1]);ra=(E.x*z.n11+E.y*z.n12+E.z*z.n13)*0.5+0.5;wa=-(E.x*z.n21+E.y*z.n22+E.z*z.n23)*0.5+0.5;E.copy(A.vertexNormalsWorld[2]);f=(E.x*z.n11+E.y*z.n12+E.z*z.n13)*0.5+0.5;m=-(E.x*z.n21+E.y*z.n22+E.z*z.n23)*0.5+0.5;Ca(K,d,ga,T,N,ba,U.env_map.image,ca,Q,ra,wa,f,m)}}else U.wireframe?J(U.color.__styleString,U.wireframe_linewidth):oa(U.color.__styleString);else if(U instanceof THREE.MeshLambertMaterial){if(U.map&&!U.wireframe){U.map.mapping instanceof THREE.UVMapping&&Ca(K,
+d,ga,T,N,ba,U.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);b(THREE.SubtractiveBlending)}if(q)if(!U.wireframe&&U.shading==THREE.SmoothShading&&A.vertexNormalsWorld.length==3){aa.r=V.r=B.r=C.r;aa.g=V.g=B.g=C.g;aa.b=V.b=B.b=C.b;za(ma,A.v1.positionWorld,A.vertexNormalsWorld[0],aa);za(ma,A.v2.positionWorld,A.vertexNormalsWorld[1],V);za(ma,A.v3.positionWorld,A.vertexNormalsWorld[2],B);I.r=(V.r+B.r)*0.5;I.g=(V.g+B.g)*0.5;I.b=(V.b+B.b)*0.5;ja=Aa(aa,V,B,I);Ca(K,d,ga,T,N,ba,
+ja,0,0,1,0,0,1)}else{v.r=C.r;v.g=C.g;v.b=C.b;za(ma,A.centroidWorld,A.normalWorld,v);R.r=U.color.r*v.r;R.g=U.color.g*v.g;R.b=U.color.b*v.b;R.updateStyleString();U.wireframe?J(R.__styleString,U.wireframe_linewidth):oa(R.__styleString)}else U.wireframe?J(U.color.__styleString,U.wireframe_linewidth):oa(U.color.__styleString)}else if(U instanceof THREE.MeshDepthMaterial){ka=y.near;P=y.far;aa.r=aa.g=aa.b=1-u(z.positionScreen.z,ka,P);V.r=V.g=V.b=1-u(X.positionScreen.z,ka,P);B.r=B.g=B.b=1-u(Y.positionScreen.z,
+ka,P);I.r=(V.r+B.r)*0.5;I.g=(V.g+B.g)*0.5;I.b=(V.b+B.b)*0.5;ja=Aa(aa,V,B,I);Ca(K,d,ga,T,N,ba,ja,0,0,1,0,0,1)}else if(U instanceof THREE.MeshNormalMaterial){R.r=Ba(A.normalWorld.x);R.g=Ba(A.normalWorld.y);R.b=Ba(A.normalWorld.z);R.updateStyleString();U.wireframe?J(R.__styleString,U.wireframe_linewidth):oa(R.__styleString)}}}function J(z,X){if(F!=z)o.strokeStyle=F=z;if(G!=X)o.lineWidth=G=X;o.stroke();h.inflate(X*2)}function oa(z){if(H!=z)o.fillStyle=H=z;o.fill()}function Ca(z,X,Y,A,U,ma,xa,Da,Ea,Ia,
+ya,Ja,Qa){var Ka,La;Ka=xa.width-1;La=xa.height-1;Da*=Ka;Ea*=La;Ia*=Ka;ya*=La;Ja*=Ka;Qa*=La;Y-=z;A-=X;U-=z;ma-=X;Ia-=Da;ya-=Ea;Ja-=Da;Qa-=Ea;Ka=Ia*Qa-Ja*ya;if(Ka!=0){La=1/Ka;Ka=(Qa*Y-ya*U)*La;ya=(Qa*A-ya*ma)*La;Y=(Ia*U-Ja*Y)*La;A=(Ia*ma-Ja*A)*La;z=z-Ka*Da-Y*Ea;X=X-ya*Da-A*Ea;o.save();o.transform(Ka,ya,Y,A,z,X);o.clip();o.drawImage(xa,0,0);o.restore()}}function Aa(z,X,Y,A){var U=~~(z.r*255),ma=~~(z.g*255);z=~~(z.b*255);var xa=~~(X.r*255),Da=~~(X.g*255);X=~~(X.b*255);var Ea=~~(Y.r*255),Ia=~~(Y.g*255);
+Y=~~(Y.b*255);var ya=~~(A.r*255),Ja=~~(A.g*255);A=~~(A.b*255);la[0]=U<0?0:U>255?255:U;la[1]=ma<0?0:ma>255?255:ma;la[2]=z<0?0:z>255?255:z;la[4]=xa<0?0:xa>255?255:xa;la[5]=Da<0?0:Da>255?255:Da;la[6]=X<0?0:X>255?255:X;la[8]=Ea<0?0:Ea>255?255:Ea;la[9]=Ia<0?0:Ia>255?255:Ia;la[10]=Y<0?0:Y>255?255:Y;la[12]=ya<0?0:ya>255?255:ya;la[13]=Ja<0?0:Ja>255?255:Ja;la[14]=A<0?0:A>255?255:A;ea.putImageData(va,0,0);ia.drawImage(da,0,0);return ha}function u(z,X,Y){z=(z-X)/(Y-X);return z*z*(3-2*z)}function Ba(z){z=(z+
+1)*0.5;return z<0?0:z>1?1:z}function Oa(z,X){var Y=X.x-z.x,A=X.y-z.y,U=1/Math.sqrt(Y*Y+A*A);Y*=U;A*=U;X.x+=Y;X.y+=A;z.x-=Y;z.y-=A}var Ma,Ha,$,sa,pa,ta,ua,qa;this.autoClear?this.clear():o.setTransform(1,0,0,-1,n,k);c=e.projectScene(na,y,this.sortElements);(q=na.lights.length>0)&&Fa(na);Ma=0;for(Ha=c.length;Ma<Ha;Ma++){$=c[Ma];h.empty();if($ instanceof THREE.RenderableParticle){r=$;r.x*=n;r.y*=k;sa=0;for(pa=$.materials.length;sa<pa;sa++)Ga(r,$,$.materials[sa],na)}else if($ instanceof THREE.RenderableLine){r=
+$.v1;Z=$.v2;r.positionScreen.x*=n;r.positionScreen.y*=k;Z.positionScreen.x*=n;Z.positionScreen.y*=k;h.addPoint(r.positionScreen.x,r.positionScreen.y);h.addPoint(Z.positionScreen.x,Z.positionScreen.y);if(p.instersects(h)){sa=0;for(pa=$.materials.length;sa<pa;)O(r,Z,$,$.materials[sa++],na)}}else if($ instanceof THREE.RenderableFace3){r=$.v1;Z=$.v2;D=$.v3;r.positionScreen.x*=n;r.positionScreen.y*=k;Z.positionScreen.x*=n;Z.positionScreen.y*=k;D.positionScreen.x*=n;D.positionScreen.y*=k;if($.overdraw){Oa(r.positionScreen,
+Z.positionScreen);Oa(Z.positionScreen,D.positionScreen);Oa(D.positionScreen,r.positionScreen)}h.add3Points(r.positionScreen.x,r.positionScreen.y,Z.positionScreen.x,Z.positionScreen.y,D.positionScreen.x,D.positionScreen.y);if(p.instersects(h)){sa=0;for(pa=$.meshMaterials.length;sa<pa;){qa=$.meshMaterials[sa++];if(qa instanceof THREE.MeshFaceMaterial){ta=0;for(ua=$.faceMaterials.length;ta<ua;)(qa=$.faceMaterials[ta++])&&M(r,Z,D,$,qa,na)}else M(r,Z,D,$,qa,na)}}}j.addRectangle(h)}o.setTransform(1,0,0,
+1,0,0)}};
+THREE.SVGRenderer=function(){function a(ca,Q,ra){var wa,f,m,p;wa=0;for(f=ca.lights.length;wa<f;wa++){m=ca.lights[wa];if(m instanceof THREE.DirectionalLight){p=Q.normalWorld.dot(m.position)*m.intensity;if(p>0){ra.r+=m.color.r*p;ra.g+=m.color.g*p;ra.b+=m.color.b*p}}else if(m instanceof THREE.PointLight){ba.sub(m.position,Q.centroidWorld);ba.normalize();p=Q.normalWorld.dot(ba)*m.intensity;if(p>0){ra.r+=m.color.r*p;ra.g+=m.color.g*p;ra.b+=m.color.b*p}}}}function b(ca,Q,ra,wa,f,m){B=e(I++);B.setAttribute("d","M "+
+ca.positionScreen.x+" "+ca.positionScreen.y+" L "+Q.positionScreen.x+" "+Q.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+"z");if(f instanceof THREE.MeshBasicMaterial)D.__styleString=f.color.__styleString;else if(f instanceof THREE.MeshLambertMaterial)if(Z){K.r=d.r;K.g=d.g;K.b=d.b;a(m,wa,K);D.r=f.color.r*K.r;D.g=f.color.g*K.g;D.b=f.color.b*K.b;D.updateStyleString()}else D.__styleString=f.color.__styleString;else if(f instanceof THREE.MeshDepthMaterial){N=1-f.__2near/(f.__farPlusNear-
+wa.z*f.__farMinusNear);D.setRGB(N,N,N)}else f instanceof THREE.MeshNormalMaterial&&D.setRGB(g(wa.normalWorld.x),g(wa.normalWorld.y),g(wa.normalWorld.z));f.wireframe?B.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+f.wireframe_linewidth+"; stroke-opacity: "+f.opacity+"; stroke-linecap: "+f.wireframe_linecap+"; stroke-linejoin: "+f.wireframe_linejoin):B.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+f.opacity);n.appendChild(B)}function c(ca,Q,ra,wa,
+f,m,p){B=e(I++);B.setAttribute("d","M "+ca.positionScreen.x+" "+ca.positionScreen.y+" L "+Q.positionScreen.x+" "+Q.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+" L "+wa.positionScreen.x+","+wa.positionScreen.y+"z");if(m instanceof THREE.MeshBasicMaterial)D.__styleString=m.color.__styleString;else if(m instanceof THREE.MeshLambertMaterial)if(Z){K.r=d.r;K.g=d.g;K.b=d.b;a(p,f,K);D.r=m.color.r*K.r;D.g=m.color.g*K.g;D.b=m.color.b*K.b;D.updateStyleString()}else D.__styleString=m.color.__styleString;
+else if(m instanceof THREE.MeshDepthMaterial){N=1-m.__2near/(m.__farPlusNear-f.z*m.__farMinusNear);D.setRGB(N,N,N)}else m instanceof THREE.MeshNormalMaterial&&D.setRGB(g(f.normalWorld.x),g(f.normalWorld.y),g(f.normalWorld.z));m.wireframe?B.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+m.wireframe_linewidth+"; stroke-opacity: "+m.opacity+"; stroke-linecap: "+m.wireframe_linecap+"; stroke-linejoin: "+m.wireframe_linejoin):B.setAttribute("style","fill: "+D.__styleString+
+"; fill-opacity: "+m.opacity);n.appendChild(B)}function e(ca){if(R[ca]==null){R[ca]=document.createElementNS("http://www.w3.org/2000/svg","path");ja==0&&R[ca].setAttribute("shape-rendering","crispEdges")}return R[ca]}function g(ca){return ca<0?Math.min((1+ca)*0.5,0.5):0.5+Math.min(ca*0.5,0.5)}var i=null,l=new THREE.Projector,n=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,o,s,w,t,x,F,H,G=new THREE.Rectangle,r=new THREE.Rectangle,Z=!1,D=new THREE.Color(16777215),K=new THREE.Color(16777215),
+d=new THREE.Color(0),ga=new THREE.Color(0),T=new THREE.Color(0),N,ba=new THREE.Vector3,R=[],aa=[],V=[],B,I,ka,P,ja=1;this.domElement=n;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ca){switch(ca){case "high":ja=1;break;case "low":ja=0}};this.setSize=function(ca,Q){k=ca;o=Q;s=k/2;w=o/2;n.setAttribute("viewBox",-s+" "+-w+" "+k+" "+o);n.setAttribute("width",k);n.setAttribute("height",o);G.set(-s,-w,s,w)};this.clear=function(){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])};
+this.render=function(ca,Q){var ra,wa,f,m,p,j,h,q;this.autoClear&&this.clear();i=l.projectScene(ca,Q,this.sortElements);P=ka=I=0;if(Z=ca.lights.length>0){h=ca.lights;d.setRGB(0,0,0);ga.setRGB(0,0,0);T.setRGB(0,0,0);ra=0;for(wa=h.length;ra<wa;ra++){f=h[ra];m=f.color;if(f instanceof THREE.AmbientLight){d.r+=m.r;d.g+=m.g;d.b+=m.b}else if(f instanceof THREE.DirectionalLight){ga.r+=m.r;ga.g+=m.g;ga.b+=m.b}else if(f instanceof THREE.PointLight){T.r+=m.r;T.g+=m.g;T.b+=m.b}}}ra=0;for(wa=i.length;ra<wa;ra++){h=
+i[ra];r.empty();if(h instanceof THREE.RenderableParticle){t=h;t.x*=s;t.y*=-w;f=0;for(m=h.materials.length;f<m;f++)if(q=h.materials[f]){p=t;j=h;var v=ka++;if(aa[v]==null){aa[v]=document.createElementNS("http://www.w3.org/2000/svg","circle");ja==0&&aa[v].setAttribute("shape-rendering","crispEdges")}B=aa[v];B.setAttribute("cx",p.x);B.setAttribute("cy",p.y);B.setAttribute("r",j.scale.x*s);if(q instanceof THREE.ParticleCircleMaterial){if(Z){K.r=d.r+ga.r+T.r;K.g=d.g+ga.g+T.g;K.b=d.b+ga.b+T.b;D.r=q.color.r*
+K.r;D.g=q.color.g*K.g;D.b=q.color.b*K.b;D.updateStyleString()}else D=q.color;B.setAttribute("style","fill: "+D.__styleString)}n.appendChild(B)}}else if(h instanceof THREE.RenderableLine){t=h.v1;x=h.v2;t.positionScreen.x*=s;t.positionScreen.y*=-w;x.positionScreen.x*=s;x.positionScreen.y*=-w;r.addPoint(t.positionScreen.x,t.positionScreen.y);r.addPoint(x.positionScreen.x,x.positionScreen.y);if(G.instersects(r)){f=0;for(m=h.materials.length;f<m;)if(q=h.materials[f++]){p=t;j=x;v=P++;if(V[v]==null){V[v]=
+document.createElementNS("http://www.w3.org/2000/svg","line");ja==0&&V[v].setAttribute("shape-rendering","crispEdges")}B=V[v];B.setAttribute("x1",p.positionScreen.x);B.setAttribute("y1",p.positionScreen.y);B.setAttribute("x2",j.positionScreen.x);B.setAttribute("y2",j.positionScreen.y);if(q instanceof THREE.LineBasicMaterial){D.__styleString=q.color.__styleString;B.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+q.linewidth+"; stroke-opacity: "+q.opacity+"; stroke-linecap: "+
+q.linecap+"; stroke-linejoin: "+q.linejoin);n.appendChild(B)}}}}else if(h instanceof THREE.RenderableFace3){t=h.v1;x=h.v2;F=h.v3;t.positionScreen.x*=s;t.positionScreen.y*=-w;x.positionScreen.x*=s;x.positionScreen.y*=-w;F.positionScreen.x*=s;F.positionScreen.y*=-w;r.addPoint(t.positionScreen.x,t.positionScreen.y);r.addPoint(x.positionScreen.x,x.positionScreen.y);r.addPoint(F.positionScreen.x,F.positionScreen.y);if(G.instersects(r)){f=0;for(m=h.meshMaterials.length;f<m;){q=h.meshMaterials[f++];if(q instanceof
+THREE.MeshFaceMaterial){p=0;for(j=h.faceMaterials.length;p<j;)(q=h.faceMaterials[p++])&&b(t,x,F,h,q,ca)}else q&&b(t,x,F,h,q,ca)}}}else if(h instanceof THREE.RenderableFace4){t=h.v1;x=h.v2;F=h.v3;H=h.v4;t.positionScreen.x*=s;t.positionScreen.y*=-w;x.positionScreen.x*=s;x.positionScreen.y*=-w;F.positionScreen.x*=s;F.positionScreen.y*=-w;H.positionScreen.x*=s;H.positionScreen.y*=-w;r.addPoint(t.positionScreen.x,t.positionScreen.y);r.addPoint(x.positionScreen.x,x.positionScreen.y);r.addPoint(F.positionScreen.x,
+F.positionScreen.y);r.addPoint(H.positionScreen.x,H.positionScreen.y);if(G.instersects(r)){f=0;for(m=h.meshMaterials.length;f<m;){q=h.meshMaterials[f++];if(q instanceof THREE.MeshFaceMaterial){p=0;for(j=h.faceMaterials.length;p<j;)(q=h.faceMaterials[p++])&&c(t,x,F,H,h,q,ca)}else q&&c(t,x,F,H,h,q,ca)}}}}}};
+THREE.WebGLRenderer=function(a){function b(f,m,p){var j,h,q,v=f.vertices,C=v.length,W=f.colors,L=W.length,S=f.__vertexArray,E=f.__colorArray,da=f.__sortArray,ea=f.__dirtyVertices,va=f.__dirtyColors;if(p.sortParticles){I.multiplySelf(p.globalMatrix);for(j=0;j<C;j++){h=v[j].position;ca.copy(h);I.multiplyVector3(ca);da[j]=[ca.z,j]}da.sort(function(la,ha){return ha[0]-la[0]});for(j=0;j<C;j++){h=v[da[j][1]].position;q=j*3;S[q]=h.x;S[q+1]=h.y;S[q+2]=h.z}for(j=0;j<L;j++){q=j*3;color=W[da[j][1]];E[q]=color.r;
+E[q+1]=color.g;E[q+2]=color.b}}else{if(ea)for(j=0;j<C;j++){h=v[j].position;q=j*3;S[q]=h.x;S[q+1]=h.y;S[q+2]=h.z}if(va)for(j=0;j<L;j++){color=W[j];q=j*3;E[q]=color.r;E[q+1]=color.g;E[q+2]=color.b}}if(ea||p.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,S,m)}if(va||p.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,E,m)}}function c(f,m){f.fragment_shader=m.fragment_shader;f.vertex_shader=m.vertex_shader;f.uniforms=
+Uniforms.clone(m.uniforms)}function e(f,m,p,j,h){j.program||N.initMaterial(j,m,p);var q=j.program,v=q.uniforms,C=j.uniforms;if(q!=ga){d.useProgram(q);ga=q;d.uniformMatrix4fv(v.projectionMatrix,!1,ka)}if(p&&(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial||j instanceof THREE.LineBasicMaterial||j instanceof THREE.ParticleBasicMaterial)){C.fogColor.value.setHex(p.color.hex);if(p instanceof THREE.Fog){C.fogNear.value=p.near;C.fogFar.value=
+p.far}else if(p instanceof THREE.FogExp2)C.fogDensity.value=p.density}if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){var W,L,S=0,E=0,da=0,ea,va,la,ha=N.lights,ia=ha.directional.colors,fa=ha.directional.positions,na=ha.point.colors,y=ha.point.positions,Fa=0,za=0;p=L=L=0;for(W=m.length;p<W;p++){L=m[p];ea=L.color;va=L.position;la=L.intensity;if(L instanceof THREE.AmbientLight){S+=ea.r;E+=ea.g;da+=ea.b}else if(L instanceof THREE.DirectionalLight){L=Fa*3;ia[L]=ea.r*la;
+ia[L+1]=ea.g*la;ia[L+2]=ea.b*la;fa[L]=va.x;fa[L+1]=va.y;fa[L+2]=va.z;Fa+=1}else if(L instanceof THREE.PointLight){L=za*3;na[L]=ea.r*la;na[L+1]=ea.g*la;na[L+2]=ea.b*la;y[L]=va.x;y[L+1]=va.y;y[L+2]=va.z;za+=1}}for(p=Fa*3;p<ia.length;p++)ia[p]=0;for(p=za*3;p<na.length;p++)na[p]=0;ha.point.length=za;ha.directional.length=Fa;ha.ambient[0]=S;ha.ambient[1]=E;ha.ambient[2]=da;m=N.lights;C.enableLighting.value=m.directional.length+m.point.length;C.ambientLightColor.value=m.ambient;C.directionalLightColor.value=
+m.directional.colors;C.directionalLightDirection.value=m.directional.positions;C.pointLightColor.value=m.point.colors;C.pointLightPosition.value=m.point.positions}if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial){C.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);C.opacity.value=j.opacity;C.map.texture=j.map;C.light_map.texture=j.light_map;C.env_map.texture=j.env_map;C.reflectivity.value=j.reflectivity;
+C.refraction_ratio.value=j.refraction_ratio;C.combine.value=j.combine;C.useRefract.value=j.env_map&&j.env_map.mapping instanceof THREE.CubeRefractionMapping}if(j instanceof THREE.LineBasicMaterial){C.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);C.opacity.value=j.opacity}else if(j instanceof THREE.ParticleBasicMaterial){C.psColor.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);C.opacity.value=j.opacity;C.size.value=j.size;C.map.texture=
+j.map}else if(j instanceof THREE.MeshPhongMaterial){C.ambient.value.setRGB(j.ambient.r,j.ambient.g,j.ambient.b);C.specular.value.setRGB(j.specular.r,j.specular.g,j.specular.b);C.shininess.value=j.shininess}else if(j instanceof THREE.MeshDepthMaterial){C.mNear.value=f.near;C.mFar.value=f.far;C.opacity.value=j.opacity}else if(j instanceof THREE.MeshNormalMaterial)C.opacity.value=j.opacity;for(var Ga in C)if(S=q.uniforms[Ga]){p=C[Ga];W=p.type;m=p.value;if(W=="i")d.uniform1i(S,m);else if(W=="f")d.uniform1f(S,
+m);else if(W=="fv1")d.uniform1fv(S,m);else if(W=="fv")d.uniform3fv(S,m);else if(W=="v2")d.uniform2f(S,m.x,m.y);else if(W=="v3")d.uniform3f(S,m.x,m.y,m.z);else if(W=="c")d.uniform3f(S,m.r,m.g,m.b);else if(W=="t"){d.uniform1i(S,m);if(p=p.texture)if(p.image instanceof Array&&p.image.length==6){if(p.image.length==6){if(!p.image.__webGLTextureCube&&!p.image.__cubeMapInitialized&&p.image.loadCount==6){p.image.__webGLTextureCube=d.createTexture();d.bindTexture(d.TEXTURE_CUBE_MAP,p.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(W=0;W<6;++W)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,p.image[W]);d.generateMipmap(d.TEXTURE_CUBE_MAP);d.bindTexture(d.TEXTURE_CUBE_MAP,null);p.image.__cubeMapInitialized=!0}d.activeTexture(d.TEXTURE0+
+m);d.bindTexture(d.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube)}}else{if(!p.__webGLTexture&&p.image.loaded){p.__webGLTexture=d.createTexture();d.bindTexture(d.TEXTURE_2D,p.__webGLTexture);d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,p.image);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,D(p.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,D(p.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,D(p.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,D(p.min_filter));
+d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}d.activeTexture(d.TEXTURE0+m);d.bindTexture(d.TEXTURE_2D,p.__webGLTexture)}}}d.uniformMatrix4fv(v.modelViewMatrix,!1,h._modelViewMatrixArray);d.uniformMatrix3fv(v.normalMatrix,!1,h._normalMatrixArray);(j instanceof THREE.MeshShaderMaterial||j instanceof THREE.MeshPhongMaterial||j.env_map)&&d.uniform3f(v.cameraPosition,f.position.x,f.position.y,f.position.z);(j instanceof THREE.MeshShaderMaterial||j.env_map||j.skinning)&&d.uniformMatrix4fv(v.objectMatrix,
+!1,h._objectMatrixArray);(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshShaderMaterial||j.skinning)&&d.uniformMatrix4fv(v.viewMatrix,!1,ja);if(j.skinning){d.uniformMatrix4fv(v.cameraInverseMatrix,!1,P);d.uniformMatrix4fv(v.uBoneGlobalMatrices,!1,h.boneMatrices)}return q}function g(f,m,p,j,h,q){f=e(f,m,p,j,q).attributes;d.bindBuffer(d.ARRAY_BUFFER,h.__webGLVertexBuffer);d.vertexAttribPointer(f.position,3,d.FLOAT,!1,0,0);if(f.color>=0){d.bindBuffer(d.ARRAY_BUFFER,
+h.__webGLColorBuffer);d.vertexAttribPointer(f.color,3,d.FLOAT,!1,0,0)}if(f.normal>=0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLNormalBuffer);d.vertexAttribPointer(f.normal,3,d.FLOAT,!1,0,0)}if(f.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLTangentBuffer);d.vertexAttribPointer(f.tangent,4,d.FLOAT,!1,0,0)}if(f.uv>=0)if(h.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLUVBuffer);d.vertexAttribPointer(f.uv,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.uv)}else d.disableVertexAttribArray(f.uv);if(f.uv2>=
+0)if(h.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLUV2Buffer);d.vertexAttribPointer(f.uv2,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.uv2)}else d.disableVertexAttribArray(f.uv2);if(j.skinning&&f.skinVertexA>=0&&f.skinVertexB>=0&&f.skinIndex>=0&&f.skinWeight>=0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinVertexABuffer);d.vertexAttribPointer(f.skinVertexA,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinVertexBBuffer);d.vertexAttribPointer(f.skinVertexB,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,
+h.__webGLSkinIndicesBuffer);d.vertexAttribPointer(f.skinIndex,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinWeightsBuffer);d.vertexAttribPointer(f.skinWeight,4,d.FLOAT,!1,0,0)}if(q instanceof THREE.Mesh)if(j.wireframe){d.lineWidth(j.wireframe_linewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,h.__webGLLineBuffer);d.drawElements(d.LINES,h.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,h.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,h.__webGLFaceCount,d.UNSIGNED_SHORT,
+0)}else if(q instanceof THREE.Line){q=q.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(j.linewidth);d.drawArrays(q,0,h.__webGLLineCount)}else q instanceof THREE.ParticleSystem&&d.drawArrays(d.POINTS,0,h.__webGLParticleCount)}function i(f,m){if(!f.__webGLVertexBuffer)f.__webGLVertexBuffer=d.createBuffer();if(!f.__webGLNormalBuffer)f.__webGLNormalBuffer=d.createBuffer();if(f.hasPos){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,f.positionArray,d.DYNAMIC_DRAW);
+d.enableVertexAttribArray(m.attributes.position);d.vertexAttribPointer(m.attributes.position,3,d.FLOAT,!1,0,0)}if(f.hasNormal){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,f.normalArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(m.attributes.normal);d.vertexAttribPointer(m.attributes.normal,3,d.FLOAT,!1,0,0)}d.drawArrays(d.TRIANGLES,0,f.count);f.count=0}function l(f){if(ba!=f.doubleSided){f.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE);ba=f.doubleSided}if(R!=
+f.flipSided){f.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW);R=f.flipSided}}function n(f){if(V!=f){f?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST);V=f}}function k(f){B[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);B[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);B[2].set(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);B[3].set(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);B[4].set(f.n41-f.n31,f.n42-f.n32,f.n43-f.n33,f.n44-f.n34);B[5].set(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,
+f.n44+f.n34);var m;for(f=0;f<5;f++){m=B[f];m.divideScalar(Math.sqrt(m.x*m.x+m.y*m.y+m.z*m.z))}}function o(f){for(var m=f.globalMatrix,p=-f.geometry.boundingSphere.radius*Math.max(f.scale.x,Math.max(f.scale.y,f.scale.z)),j=0;j<6;j++){f=B[j].x*m.n14+B[j].y*m.n24+B[j].z*m.n34+B[j].w;if(f<=p)return!1}return!0}function s(f,m){f.list[f.count]=m;f.count+=1}function w(f){var m,p,j=f.object,h=f.opaque,q=f.transparent;q.count=0;f=h.count=0;for(m=j.materials.length;f<m;f++){p=j.materials[f];p.opacity&&p.opacity<
+1||p.blending!=THREE.NormalBlending?s(q,p):s(h,p)}}function t(f){var m,p,j,h,q=f.object,v=f.buffer,C=f.opaque,W=f.transparent;W.count=0;f=C.count=0;for(j=q.materials.length;f<j;f++){m=q.materials[f];if(m instanceof THREE.MeshFaceMaterial){m=0;for(p=v.materials.length;m<p;m++)(h=v.materials[m])&&(h.opacity&&h.opacity<1||h.blending!=THREE.NormalBlending?s(W,h):s(C,h))}else{h=m;h.opacity&&h.opacity<1||h.blending!=THREE.NormalBlending?s(W,h):s(C,h)}}}function x(f,m){return m.z-f.z}function F(f,m,p,j,
+h){if(m[p]==undefined){f.push({buffer:j,object:h,opaque:{list:[],count:0},transparent:{list:[],count:0}});m[p]=1}}function H(f,m){f._modelViewMatrix.multiplyToArray(m.globalMatrix,f.globalMatrix,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function G(f){if(f!=aa){switch(f){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)}aa=f}}function r(f,m){if(f&&!f.__webGLFramebuffer){f.__webGLFramebuffer=d.createFramebuffer();f.__webGLRenderbuffer=d.createRenderbuffer();f.__webGLTexture=d.createTexture();d.bindRenderbuffer(d.RENDERBUFFER,f.__webGLRenderbuffer);d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,f.width,f.height);d.bindTexture(d.TEXTURE_2D,f.__webGLTexture);d.texParameteri(d.TEXTURE_2D,
+d.TEXTURE_WRAP_S,D(f.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,D(f.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,D(f.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,D(f.min_filter));d.texImage2D(d.TEXTURE_2D,0,D(f.format),f.width,f.height,0,D(f.format),D(f.type),null);d.bindFramebuffer(d.FRAMEBUFFER,f.__webGLFramebuffer);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,f.__webGLTexture,0);d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,
+d.RENDERBUFFER,f.__webGLRenderbuffer);d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,null)}var p,j,h;if(f){p=f.__webGLFramebuffer;j=f.width;h=f.height}else{p=null;j=K.width;h=K.height}if(p!=T){d.bindFramebuffer(d.FRAMEBUFFER,p);d.viewport(0,0,j,h);m&&d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT);T=p}}function Z(f,m){var p;if(f=="fragment")p=d.createShader(d.FRAGMENT_SHADER);else f=="vertex"&&(p=d.createShader(d.VERTEX_SHADER));d.shaderSource(p,
+m);d.compileShader(p);if(!d.getShaderParameter(p,d.COMPILE_STATUS)){alert(d.getShaderInfoLog(p));return null}return p}function D(f){switch(f){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 K=document.createElement("canvas"),d,ga=null,T=null,N=this,ba=null,R=null,aa=null,V=null,B=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],I=new THREE.Matrix4,ka=new Float32Array(16),P=new Float32Array(16),ja=new Float32Array(16),ca=new THREE.Vector4,Q=!0,ra=new THREE.Color(0),wa=0;if(a){if(a.antialias!==undefined)Q=a.antialias;
+a.clearColor!==undefined&&ra.setHex(a.clearColor);if(a.clearAlpha!==undefined)wa=a.clearAlpha}this.domElement=K;this.autoClear=!0;this.sortObjects=!1;(function(f,m,p){try{d=K.getContext("experimental-webgl",{antialias:f})}catch(j){console.log(j)}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(m.r,m.g,m.b,p);_cullEnabled=!0})(Q,ra,wa);this.context=d;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,m){K.width=f;K.height=m;d.viewport(0,0,K.width,K.height)};this.setClearColorHex=function(f,m){var p=new THREE.Color(f);d.clearColor(p.r,p.g,p.b,m)};this.setClearColor=function(f,m){d.clearColor(f.r,f.g,f.b,m)};this.clear=function(){d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT)};this.initMaterial=
+function(f,m,p){var j,h;if(f instanceof THREE.MeshDepthMaterial)c(f,THREE.ShaderLib.depth);else if(f instanceof THREE.MeshNormalMaterial)c(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)c(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)c(f,THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)c(f,THREE.ShaderLib.phong);else if(f instanceof THREE.LineBasicMaterial)c(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&
+c(f,THREE.ShaderLib.particle_basic);var q,v,C,W;h=C=W=0;for(q=m.length;h<q;h++){v=m[h];v instanceof THREE.DirectionalLight&&C++;v instanceof THREE.PointLight&&W++}if(W+C<=4)m=C;else{m=Math.ceil(4*C/(W+C));W=4-m}h={directional:m,point:W};W=f.fragment_shader;m=f.vertex_shader;q={fog:p,map:f.map,env_map:f.env_map,light_map:f.light_map,vertex_colors:f.vertex_colors,skinning:f.skinning,maxDirLights:h.directional,maxPointLights:h.point};p=d.createProgram();h=["#ifdef GL_ES\nprecision highp float;\n#endif",
+"#define MAX_DIR_LIGHTS "+q.maxDirLights,"#define MAX_POINT_LIGHTS "+q.maxPointLights,q.fog?"#define USE_FOG":"",q.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",q.map?"#define USE_MAP":"",q.env_map?"#define USE_ENVMAP":"",q.light_map?"#define USE_LIGHTMAP":"",q.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");q=[d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+q.maxDirLights,"#define MAX_POINT_LIGHTS "+
+q.maxPointLights,q.map?"#define USE_MAP":"",q.env_map?"#define USE_ENVMAP":"",q.light_map?"#define USE_LIGHTMAP":"",q.vertex_colors?"#define USE_COLOR":"",q.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
+d.attachShader(p,Z("fragment",h+W));d.attachShader(p,Z("vertex",q+m));d.linkProgram(p);d.getProgramParameter(p,d.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+d.getProgramParameter(p,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");p.uniforms={};p.attributes={};f.program=p;p=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","uBoneGlobalMatrices"];for(j in f.uniforms)p.push(j);j=f.program;W=0;for(m=p.length;W<
+m;W++){h=p[W];j.uniforms[h]=d.getUniformLocation(j,h)}j=f.program;p=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];W=0;for(m=p.length;W<m;W++){h=p[W];j.attributes[h]=d.getAttribLocation(j,h)}j=f.program.attributes;d.enableVertexAttribArray(j.position);j.color>=0&&d.enableVertexAttribArray(j.color);j.normal>=0&&d.enableVertexAttribArray(j.normal);j.tangent>=0&&d.enableVertexAttribArray(j.tangent);if(f.skinning&&j.skinVertexA>=0&&j.skinVertexB>=
+0&&j.skinIndex>=0&&j.skinWeight>=0){d.enableVertexAttribArray(j.skinVertexA);d.enableVertexAttribArray(j.skinVertexB);d.enableVertexAttribArray(j.skinIndex);d.enableVertexAttribArray(j.skinWeight)}};this.render=function(f,m,p,j){var h,q,v,C,W,L,S,E,da=f.lights,ea=f.fog;m.autoUpdateMatrix&&m.update();m.globalMatrix.flattenToArray(ja);m.projectionMatrix.flattenToArray(ka);m.inverseMatrix.flattenToArray(P);I.multiply(m.projectionMatrix,m.globalMatrix);k(I);THREE.AnimationHandler&&THREE.AnimationHandler.update();
+f.update(undefined,!1,m);this.initWebGLObjects(f,m);r(p,j!==undefined?j:!0);this.autoClear&&this.clear();W=f.__webGLObjects.length;for(j=0;j<W;j++){h=f.__webGLObjects[j];S=h.object;if(S.visible)if(!(S instanceof THREE.Mesh)||o(S)){S.globalMatrix.flattenToArray(S._objectMatrixArray);H(S,m);t(h);h.render=!0;if(this.sortObjects){ca.copy(S.position);I.multiplyVector3(ca);h.z=ca.z}}else h.render=!1;else h.render=!1}this.sortObjects&&f.__webGLObjects.sort(x);L=f.__webGLObjectsImmediate.length;for(j=0;j<
+L;j++){h=f.__webGLObjectsImmediate[j];S=h.object;if(S.visible){S.autoUpdateMatrix&&S.globalMatrix.flattenToArray(S._objectMatrixArray);H(S,m);w(h)}}G(THREE.NormalBlending);for(j=0;j<W;j++){h=f.__webGLObjects[j];if(h.render){S=h.object;E=h.buffer;v=h.opaque;l(S);for(h=0;h<v.count;h++){C=v.list[h];n(C.depth_test);g(m,da,ea,C,E,S)}}}for(j=0;j<L;j++){h=f.__webGLObjectsImmediate[j];S=h.object;if(S.visible){v=h.opaque;l(S);for(h=0;h<v.count;h++){C=v.list[h];n(C.depth_test);q=e(m,da,ea,C,S);S.render(function(va){i(va,
+q)})}}}for(j=0;j<W;j++){h=f.__webGLObjects[j];if(h.render){S=h.object;E=h.buffer;v=h.transparent;l(S);for(h=0;h<v.count;h++){C=v.list[h];G(C.blending);n(C.depth_test);g(m,da,ea,C,E,S)}}}for(j=0;j<L;j++){h=f.__webGLObjectsImmediate[j];S=h.object;if(S.visible){v=h.transparent;l(S);for(h=0;h<v.count;h++){C=v.list[h];G(C.blending);n(C.depth_test);q=e(m,da,ea,C,S);S.render(function(va){i(va,q)})}}}if(p&&p.min_filter!==THREE.NearestFilter&&p.min_filter!==THREE.LinearFilter){d.bindTexture(d.TEXTURE_2D,p.__webGLTexture);
+d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}};this.initWebGLObjects=function(f){var m,p,j;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={};f.__webGLObjectsImmediate=[]}m=0;for(p=f.objects.length;m<p;m++){j=f.objects[m];var h=f,q=void 0,v=void 0,C=void 0,W=void 0;v=j.geometry;if(h.__webGLObjectsMap[j.id]==undefined){h.__webGLObjectsMap[j.id]={};j._modelViewMatrix=new THREE.Matrix4;j._normalMatrixArray=new Float32Array(9);j._modelViewMatrixArray=new Float32Array(16);
+j._objectMatrixArray=new Float32Array(16);j.globalMatrix.flattenToArray(j._objectMatrixArray)}W=h.__webGLObjectsMap[j.id];objlist=h.__webGLObjects;if(j instanceof THREE.Mesh){for(q in v.geometryChunks){C=v.geometryChunks[q];if(!C.__webGLVertexBuffer){h=C;h.__webGLVertexBuffer=d.createBuffer();h.__webGLNormalBuffer=d.createBuffer();h.__webGLTangentBuffer=d.createBuffer();h.__webGLColorBuffer=d.createBuffer();h.__webGLUVBuffer=d.createBuffer();h.__webGLUV2Buffer=d.createBuffer();h.__webGLSkinVertexABuffer=
+d.createBuffer();h.__webGLSkinVertexBBuffer=d.createBuffer();h.__webGLSkinIndicesBuffer=d.createBuffer();h.__webGLSkinWeightsBuffer=d.createBuffer();h.__webGLFaceBuffer=d.createBuffer();h.__webGLLineBuffer=d.createBuffer();h=C;var L=j,S=void 0,E=void 0,da=0,ea=0,va=0,la=L.geometry.faces,ha=h.faces;S=0;for(E=ha.length;S<E;S++){fi=ha[S];face=la[fi];if(face instanceof THREE.Face3){da+=3;ea+=1;va+=3}else if(face instanceof THREE.Face4){da+=4;ea+=2;va+=4}}h.__vertexArray=new Float32Array(da*3);h.__normalArray=
+new Float32Array(da*3);h.__tangentArray=new Float32Array(da*4);h.__colorArray=new Float32Array(da*3);h.__uvArray=new Float32Array(da*2);h.__uv2Array=new Float32Array(da*2);h.__skinVertexAArray=new Float32Array(da*4);h.__skinVertexBArray=new Float32Array(da*4);h.__skinIndexArray=new Float32Array(da*4);h.__skinWeightArray=new Float32Array(da*4);h.__faceArray=new Uint16Array(ea*3);h.__lineArray=new Uint16Array(va*2);E=S=h;da=void 0;la=void 0;var ia=void 0,fa=void 0;ia=void 0;ha=!1;da=0;for(la=L.materials.length;da<
+la;da++){ia=L.materials[da];if(ia instanceof THREE.MeshFaceMaterial){ia=0;for(fa=E.materials.length;ia<fa;ia++)if(E.materials[ia]&&E.materials[ia].shading!=undefined&&E.materials[ia].shading==THREE.SmoothShading){ha=!0;break}}else if(ia&&ia.shading!=undefined&&ia.shading==THREE.SmoothShading){ha=!0;break}if(ha)break}S.__needsSmoothNormals=ha;h.__webGLFaceCount=ea*3;h.__webGLLineCount=va*2;v.__dirtyVertices=!0;v.__dirtyElements=!0;v.__dirtyUvs=!0;v.__dirtyNormals=!0;v.__dirtyTangents=!0;v.__dirtyColors=
+!0}if(v.__dirtyVertices||v.__dirtyElements||v.__dirtyUvs||v.__dirtyNormals||v.__dirtyColors||v.__dirtyTangents){h=C;ea=d.DYNAMIC_DRAW;va=void 0;S=void 0;var na=void 0,y=void 0,Fa=void 0,za=void 0,Ga=void 0;na=void 0;var O=void 0,M=void 0,J=void 0,oa=void 0;O=void 0;M=void 0;J=void 0;y=void 0;O=void 0;M=void 0;J=void 0;oa=void 0;O=void 0;M=void 0;J=void 0;oa=void 0;O=void 0;M=void 0;J=void 0;oa=void 0;O=void 0;M=void 0;J=void 0;oa=void 0;O=void 0;M=void 0;J=void 0;oa=void 0;y=void 0;za=void 0;Fa=void 0;
+Ga=void 0;var Ca=fa=ia=ha=la=da=L=E=0,Aa=0,u=0,Ba=h.__vertexArray,Oa=h.__uvArray,Ma=h.__uv2Array,Ha=h.__normalArray,$=h.__tangentArray,sa=h.__colorArray,pa=h.__skinVertexAArray,ta=h.__skinVertexBArray,ua=h.__skinIndexArray,qa=h.__skinWeightArray,z=h.__faceArray,X=h.__lineArray,Y=h.__needsSmoothNormals,A=j.geometry,U=A.__dirtyVertices,ma=A.__dirtyElements,xa=A.__dirtyUvs,Da=A.__dirtyNormals,Ea=A.__dirtyTangents,Ia=A.__dirtyColors,ya=A.vertices,Ja=h.faces,Qa=A.faces,Ka=A.uvs,La=A.uvs2,Na=A.colors,Ra=
+A.skinVerticesA,Sa=A.skinVerticesB,Ta=A.skinIndices,Pa=A.skinWeights;va=0;for(S=Ja.length;va<S;va++){na=Ja[va];y=Qa[na];Ga=Ka[na];na=La[na];Fa=y.vertexNormals;za=y.normal;if(y instanceof THREE.Face3){if(U){O=ya[y.a].position;M=ya[y.b].position;J=ya[y.c].position;Ba[L]=O.x;Ba[L+1]=O.y;Ba[L+2]=O.z;Ba[L+3]=M.x;Ba[L+4]=M.y;Ba[L+5]=M.z;Ba[L+6]=J.x;Ba[L+7]=J.y;Ba[L+8]=J.z;L+=9}if(Pa.length){O=Pa[y.a];M=Pa[y.b];J=Pa[y.c];qa[u]=O.x;qa[u+1]=O.y;qa[u+2]=O.z;qa[u+3]=O.w;qa[u+4]=M.x;qa[u+5]=M.y;qa[u+6]=M.z;qa[u+
+7]=M.w;qa[u+8]=J.x;qa[u+9]=J.y;qa[u+10]=J.z;qa[u+11]=J.w;O=Ta[y.a];M=Ta[y.b];J=Ta[y.c];ua[u]=O.x;ua[u+1]=O.y;ua[u+2]=O.z;ua[u+3]=O.w;ua[u+4]=M.x;ua[u+5]=M.y;ua[u+6]=M.z;ua[u+7]=M.w;ua[u+8]=J.x;ua[u+9]=J.y;ua[u+10]=J.z;ua[u+11]=J.w;O=Ra[y.a];M=Ra[y.b];J=Ra[y.c];pa[u]=O.x;pa[u+1]=O.y;pa[u+2]=O.z;pa[u+3]=1;pa[u+4]=M.x;pa[u+5]=M.y;pa[u+6]=M.z;pa[u+7]=1;pa[u+8]=J.x;pa[u+9]=J.y;pa[u+10]=J.z;pa[u+11]=1;O=Sa[y.a];M=Sa[y.b];J=Sa[y.c];ta[u]=O.x;ta[u+1]=O.y;ta[u+2]=O.z;ta[u+3]=1;ta[u+4]=M.x;ta[u+5]=M.y;ta[u+
+6]=M.z;ta[u+7]=1;ta[u+8]=J.x;ta[u+9]=J.y;ta[u+10]=J.z;ta[u+11]=1;u+=12}if(Ia&&Na.length){O=Na[y.a];M=Na[y.b];J=Na[y.c];sa[Aa]=O.r;sa[Aa+1]=O.g;sa[Aa+2]=O.b;sa[Aa+3]=M.r;sa[Aa+4]=M.g;sa[Aa+5]=M.b;sa[Aa+6]=J.r;sa[Aa+7]=J.g;sa[Aa+8]=J.b;Aa+=9}if(Ea&&A.hasTangents){O=ya[y.a].tangent;M=ya[y.b].tangent;J=ya[y.c].tangent;$[fa]=O.x;$[fa+1]=O.y;$[fa+2]=O.z;$[fa+3]=O.w;$[fa+4]=M.x;$[fa+5]=M.y;$[fa+6]=M.z;$[fa+7]=M.w;$[fa+8]=J.x;$[fa+9]=J.y;$[fa+10]=J.z;$[fa+11]=J.w;fa+=12}if(Da)if(Fa.length==3&&Y)for(y=0;y<
+3;y++){za=Fa[y];Ha[ia]=za.x;Ha[ia+1]=za.y;Ha[ia+2]=za.z;ia+=3}else for(y=0;y<3;y++){Ha[ia]=za.x;Ha[ia+1]=za.y;Ha[ia+2]=za.z;ia+=3}if(xa&&Ga)for(y=0;y<3;y++){Fa=Ga[y];Oa[da]=Fa.u;Oa[da+1]=Fa.v;da+=2}if(xa&&na)for(y=0;y<3;y++){Ga=na[y];Ma[la]=Ga.u;Ma[la+1]=Ga.v;la+=2}if(ma){z[ha]=E;z[ha+1]=E+1;z[ha+2]=E+2;ha+=3;X[Ca]=E;X[Ca+1]=E+1;X[Ca+2]=E;X[Ca+3]=E+2;X[Ca+4]=E+1;X[Ca+5]=E+2;Ca+=6;E+=3}}else if(y instanceof THREE.Face4){if(U){O=ya[y.a].position;M=ya[y.b].position;J=ya[y.c].position;oa=ya[y.d].position;
+Ba[L]=O.x;Ba[L+1]=O.y;Ba[L+2]=O.z;Ba[L+3]=M.x;Ba[L+4]=M.y;Ba[L+5]=M.z;Ba[L+6]=J.x;Ba[L+7]=J.y;Ba[L+8]=J.z;Ba[L+9]=oa.x;Ba[L+10]=oa.y;Ba[L+11]=oa.z;L+=12}if(Pa.length){O=Pa[y.a];M=Pa[y.b];J=Pa[y.c];oa=Pa[y.d];qa[u]=O.x;qa[u+1]=O.y;qa[u+2]=O.z;qa[u+3]=O.w;qa[u+4]=M.x;qa[u+5]=M.y;qa[u+6]=M.z;qa[u+7]=M.w;qa[u+8]=J.x;qa[u+9]=J.y;qa[u+10]=J.z;qa[u+11]=J.w;qa[u+12]=oa.x;qa[u+13]=oa.y;qa[u+14]=oa.z;qa[u+15]=oa.w;O=Ta[y.a];M=Ta[y.b];J=Ta[y.c];oa=Ta[y.d];ua[u]=O.x;ua[u+1]=O.y;ua[u+2]=O.z;ua[u+3]=O.w;ua[u+4]=
+M.x;ua[u+5]=M.y;ua[u+6]=M.z;ua[u+7]=M.w;ua[u+8]=J.x;ua[u+9]=J.y;ua[u+10]=J.z;ua[u+11]=J.w;ua[u+12]=oa.x;ua[u+13]=oa.y;ua[u+14]=oa.z;ua[u+15]=oa.w;O=Ra[y.a];M=Ra[y.b];J=Ra[y.c];oa=Ra[y.d];pa[u]=O.x;pa[u+1]=O.y;pa[u+2]=O.z;pa[u+3]=1;pa[u+4]=M.x;pa[u+5]=M.y;pa[u+6]=M.z;pa[u+7]=1;pa[u+8]=J.x;pa[u+9]=J.y;pa[u+10]=J.z;pa[u+11]=1;pa[u+12]=oa.x;pa[u+13]=oa.y;pa[u+14]=oa.z;pa[u+15]=1;O=Sa[y.a];M=Sa[y.b];J=Sa[y.c];oa=Sa[y.d];ta[u]=O.x;ta[u+1]=O.y;ta[u+2]=O.z;ta[u+3]=1;ta[u+4]=M.x;ta[u+5]=M.y;ta[u+6]=M.z;ta[u+
+7]=1;ta[u+8]=J.x;ta[u+9]=J.y;ta[u+10]=J.z;ta[u+11]=1;ta[u+12]=oa.x;ta[u+13]=oa.y;ta[u+14]=oa.z;ta[u+15]=1;u+=16}if(Ia&&Na.length){O=Na[y.a];M=Na[y.b];J=Na[y.c];oa=Na[y.d];sa[Aa]=O.r;sa[Aa+1]=O.g;sa[Aa+2]=O.b;sa[Aa+3]=M.r;sa[Aa+4]=M.g;sa[Aa+5]=M.b;sa[Aa+6]=J.r;sa[Aa+7]=J.g;sa[Aa+8]=J.b;sa[Aa+9]=oa.r;sa[Aa+10]=oa.g;sa[Aa+11]=oa.b;Aa+=12}if(Ea&&A.hasTangents){O=ya[y.a].tangent;M=ya[y.b].tangent;J=ya[y.c].tangent;y=ya[y.d].tangent;$[fa]=O.x;$[fa+1]=O.y;$[fa+2]=O.z;$[fa+3]=O.w;$[fa+4]=M.x;$[fa+5]=M.y;
+$[fa+6]=M.z;$[fa+7]=M.w;$[fa+8]=J.x;$[fa+9]=J.y;$[fa+10]=J.z;$[fa+11]=J.w;$[fa+12]=y.x;$[fa+13]=y.y;$[fa+14]=y.z;$[fa+15]=y.w;fa+=16}if(Da)if(Fa.length==4&&Y)for(y=0;y<4;y++){za=Fa[y];Ha[ia]=za.x;Ha[ia+1]=za.y;Ha[ia+2]=za.z;ia+=3}else for(y=0;y<4;y++){Ha[ia]=za.x;Ha[ia+1]=za.y;Ha[ia+2]=za.z;ia+=3}if(xa&&Ga)for(y=0;y<4;y++){Fa=Ga[y];Oa[da]=Fa.u;Oa[da+1]=Fa.v;da+=2}if(xa&&na)for(y=0;y<4;y++){Ga=na[y];Ma[la]=Ga.u;Ma[la+1]=Ga.v;la+=2}if(ma){z[ha]=E;z[ha+1]=E+1;z[ha+2]=E+2;z[ha+3]=E;z[ha+4]=E+2;z[ha+5]=
+E+3;ha+=6;X[Ca]=E;X[Ca+1]=E+1;X[Ca+2]=E;X[Ca+3]=E+3;X[Ca+4]=E+1;X[Ca+5]=E+2;X[Ca+6]=E+2;X[Ca+7]=E+3;Ca+=8;E+=4}}}if(U){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,Ba,ea)}if(Ia&&Na.length){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,sa,ea)}if(Da){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,Ha,ea)}if(Ea&&A.hasTangents){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLTangentBuffer);d.bufferData(d.ARRAY_BUFFER,
+$,ea)}if(xa&&da>0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLUVBuffer);d.bufferData(d.ARRAY_BUFFER,Oa,ea)}if(xa&&la>0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Ma,ea)}if(ma){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,h.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,z,ea);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,h.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,X,ea)}if(u>0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinVertexABuffer);d.bufferData(d.ARRAY_BUFFER,pa,ea);
+d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinVertexBBuffer);d.bufferData(d.ARRAY_BUFFER,ta,ea);d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinIndicesBuffer);d.bufferData(d.ARRAY_BUFFER,ua,ea);d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinWeightsBuffer);d.bufferData(d.ARRAY_BUFFER,qa,ea)}}F(objlist,W,q,C,j)}v.__dirtyVertices=!1;v.__dirtyElements=!1;v.__dirtyUvs=!1;v.__dirtyNormals=!1;v.__dirtyTangents=!1;v.__dirtyColors=!1}else if(j instanceof THREE.Line){if(!v.__webGLVertexBuffer){q=v;q.__webGLVertexBuffer=d.createBuffer();
+q.__webGLColorBuffer=d.createBuffer();q=v;C=q.vertices.length;q.__vertexArray=new Float32Array(C*3);q.__colorArray=new Float32Array(C*3);q.__webGLLineCount=C;v.__dirtyVertices=!0;v.__dirtyColors=!0}if(v.__dirtyVertices||v.__dirtyColors){q=v;C=d.DYNAMIC_DRAW;E=void 0;E=void 0;L=void 0;h=void 0;da=q.vertices;ea=q.colors;la=da.length;va=ea.length;ha=q.__vertexArray;S=q.__colorArray;ia=q.__dirtyColors;if(q.__dirtyVertices){for(E=0;E<la;E++){L=da[E].position;h=E*3;ha[h]=L.x;ha[h+1]=L.y;ha[h+2]=L.z}d.bindBuffer(d.ARRAY_BUFFER,
+q.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,ha,C)}if(ia){for(E=0;E<va;E++){color=ea[E];h=E*3;S[h]=color.r;S[h+1]=color.g;S[h+2]=color.b}d.bindBuffer(d.ARRAY_BUFFER,q.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,S,C)}}F(objlist,W,0,v,j);v.__dirtyVertices=!1;v.__dirtyColors=!1}else if(j instanceof THREE.ParticleSystem){if(!v.__webGLVertexBuffer){q=v;q.__webGLVertexBuffer=d.createBuffer();q.__webGLColorBuffer=d.createBuffer();q=v;C=q.vertices.length;q.__vertexArray=new Float32Array(C*3);q.__colorArray=
+new Float32Array(C*3);q.__sortArray=[];q.__webGLParticleCount=C;v.__dirtyVertices=!0;v.__dirtyColors=!0}(v.__dirtyVertices||v.__dirtyColors||j.sortParticles)&&b(v,d.DYNAMIC_DRAW,j,camera);F(objlist,W,0,v,j);v.__dirtyVertices=!1;v.__dirtyColors=!1}else if(j instanceof THREE.MarchingCubes){v=W;if(v[0]==undefined){h.__webGLObjectsImmediate.push({object:j,opaque:{list:[],count:0},transparent:{list:[],count:0}});v[0]=1}}}};this.removeObject=function(f,m){var p,j;for(p=f.__webGLObjects.length-1;p>=0;p--){j=
+f.__webGLObjects[p].object;m==j&&f.__webGLObjects.splice(p,1)}};this.setFaceCulling=function(f,m){if(f){!m||m=="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW);if(f=="back")d.cullFace(d.BACK);else f=="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}};
 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",

+ 165 - 166
build/ThreeDebug.js

@@ -1,6 +1,6 @@
 // ThreeDebug.js r32 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=!0;this.setHex(a)};
-THREE.Color.prototype={setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var e,g,h,l,n,k;if(c==0)e=g=h=0;else{l=Math.floor(a*6);n=a*6-l;a=c*(1-b);k=c*(1-b*n);b=c*(1-b*(1-n));switch(l){case 1:e=k;g=c;h=a;break;case 2:e=a;g=c;h=b;break;case 3:e=a;g=k;h=c;break;case 4:e=b;g=a;h=c;break;case 5:e=c;g=a;h=k;break;case 6:case 0:e=c;g=b;h=a}}this.r=e;this.g=g;this.b=h;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
+THREE.Color.prototype={setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var e,g,i,l,o,k;if(c==0)e=g=i=0;else{l=Math.floor(a*6);o=a*6-l;a=c*(1-b);k=c*(1-b*o);b=c*(1-b*(1-o));switch(l){case 1:e=k;g=c;i=a;break;case 2:e=a;g=c;i=b;break;case 3:e=a;g=k;i=c;break;case 4:e=b;g=a;i=c;break;case 5:e=c;g=a;i=k;break;case 6:case 0:e=c;g=b;i=a}}this.r=e;this.g=g;this.b=i;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: "+
 this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
@@ -13,93 +13,92 @@ this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,b,c,e){this.x=a||
 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+")"}};
 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];c instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(c)))}g.sort(function(h,l){return h.distance-l.distance});return g},intersectObject:function(a){function b(J,r,d,I){I=I.clone().subSelf(r);d=d.clone().subSelf(r);var S=J.clone().subSelf(r);J=I.dot(I);r=I.dot(d);I=I.dot(S);var V=d.dot(d);d=d.dot(S);S=1/(J*V-r*r);V=(V*I-r*d)*S;J=(J*d-r*I)*S;return V>0&&J>0&&V+J<1}var c,e,g,h,l,n,k,m,u,x,
-w,A=a.geometry,K=A.vertices,N=[];c=0;for(e=A.faces.length;c<e;c++){g=A.faces[c];x=this.origin.clone();w=this.direction.clone();k=a.globalMatrix;k.extractRotationMatrix(a.rotationMatrix);h=k.multiplyVector3(K[g.a].position.clone());l=k.multiplyVector3(K[g.b].position.clone());n=k.multiplyVector3(K[g.c].position.clone());k=g instanceof THREE.Face4?k.multiplyVector3(K[g.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(g.normal.clone());u=w.dot(m);if(u<0){m=m.dot((new THREE.Vector3).sub(h,
-x))/u;x=x.addSelf(w.multiplyScalar(m));if(g instanceof THREE.Face3){if(b(x,h,l,n)){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};N.push(g)}}else if(g instanceof THREE.Face4&&(b(x,h,l,k)||b(x,l,n,k))){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};N.push(g)}}}return N}};
-THREE.Rectangle=function(){function a(){h=e-b;l=g-c}var b,c,e,g,h,l,n=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return l};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(k,m,u,x){n=!1;b=k;c=m;e=u;g=x;a()};this.addPoint=function(k,m){if(n){n=!1;b=k;c=m;e=k;g=m}else{b=b<k?b:k;c=c<m?c:m;e=e>k?e:k;g=g>m?g:m}a()};
-this.add3Points=function(k,m,u,x,w,A){if(n){n=!1;b=k<u?k<w?k:w:u<w?u:w;c=m<x?m<A?m:A:x<A?x:A;e=k>u?k>w?k:w:u>w?u:w;g=m>x?m>A?m:A:x>A?x:A}else{b=k<u?k<w?k<b?k:b:w<b?w:b:u<w?u<b?u:b:w<b?w:b;c=m<x?m<A?m<c?m:c:A<c?A:c:x<A?x<c?x:c:A<c?A:c;e=k>u?k>w?k>e?k:e:w>e?w:e:u>w?u>e?u:e:w>e?w:e;g=m>x?m>A?m>g?m:g:A>g?A:g:x>A?x>g?x:g:A>g?A:g}a()};this.addRectangle=function(k){if(n){n=!1;b=k.getLeft();c=k.getTop();e=k.getRight();g=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();c=c<k.getTop()?c:k.getTop();e=e>k.getRight()?
-e:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;c-=k;e+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();c=c>k.getTop()?c:k.getTop();e=e<k.getRight()?e:k.getRight();g=g<k.getBottom()?g:k.getBottom();a()};this.instersects=function(k){return Math.min(e,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(g,k.getBottom())-Math.max(c,k.getTop())>=0};this.empty=function(){n=!0;g=e=c=b=0;a()};this.isEmpty=function(){return n};this.toString=function(){return"THREE.Rectangle ( left: "+
-b+", right: "+e+", top: "+c+", bottom: "+g+", width: "+h+", height: "+l+" )"}};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,h,l,n,k,m,u,x,w,A,K,N){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=e||0;this.n21=g||0;this.n22=h||1;this.n23=l||0;this.n24=n||0;this.n31=k||0;this.n32=m||0;this.n33=u||1;this.n34=x||0;this.n41=w||0;this.n42=A||0;this.n43=K||0;this.n44=N||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,h,l,n,k,m,u,x,w,A,K,N){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=g;this.n22=h;this.n23=l;this.n24=n;this.n31=k;this.n32=m;this.n33=u;this.n34=x;this.n41=w;this.n42=A;this.n43=K;this.n44=N;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,h=THREE.Matrix4.__tmpVec3;h.sub(a,b).normalize();e.cross(c,h).normalize();g.cross(h,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=h.x;this.n32=h.y;this.n33=h.z;this.n34=-h.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},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*
+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];c instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(c)))}g.sort(function(i,l){return i.distance-l.distance});return g},intersectObject:function(a){function b(G,r,Z,D){D=D.clone().subSelf(r);Z=Z.clone().subSelf(r);var K=G.clone().subSelf(r);G=D.dot(D);r=D.dot(Z);D=D.dot(K);var d=Z.dot(Z);Z=Z.dot(K);K=1/(G*d-r*r);d=(d*D-r*Z)*K;G=(G*Z-r*D)*K;return d>0&&G>0&&d+G<1}var c,e,g,i,l,o,k,m,s,w,
+t,x=a.geometry,F=x.vertices,H=[];c=0;for(e=x.faces.length;c<e;c++){g=x.faces[c];w=this.origin.clone();t=this.direction.clone();k=a.globalMatrix;k.extractRotationMatrix(a.rotationMatrix);i=k.multiplyVector3(F[g.a].position.clone());l=k.multiplyVector3(F[g.b].position.clone());o=k.multiplyVector3(F[g.c].position.clone());k=g instanceof THREE.Face4?k.multiplyVector3(F[g.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(g.normal.clone());s=t.dot(m);if(s<0){m=m.dot((new THREE.Vector3).sub(i,
+w))/s;w=w.addSelf(t.multiplyScalar(m));if(g instanceof THREE.Face3){if(b(w,i,l,o)){g={distance:this.origin.distanceTo(w),point:w,face:g,object:a};H.push(g)}}else if(g instanceof THREE.Face4&&(b(w,i,l,k)||b(w,l,o,k))){g={distance:this.origin.distanceTo(w),point:w,face:g,object:a};H.push(g)}}}return H}};
+THREE.Rectangle=function(){function a(){i=e-b;l=g-c}var b,c,e,g,i,l,o=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return i};this.getHeight=function(){return l};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(k,m,s,w){o=!1;b=k;c=m;e=s;g=w;a()};this.addPoint=function(k,m){if(o){o=!1;b=k;c=m;e=k;g=m}else{b=b<k?b:k;c=c<m?c:m;e=e>k?e:k;g=g>m?g:m}a()};
+this.add3Points=function(k,m,s,w,t,x){if(o){o=!1;b=k<s?k<t?k:t:s<t?s:t;c=m<w?m<x?m:x:w<x?w:x;e=k>s?k>t?k:t:s>t?s:t;g=m>w?m>x?m:x:w>x?w:x}else{b=k<s?k<t?k<b?k:b:t<b?t:b:s<t?s<b?s:b:t<b?t:b;c=m<w?m<x?m<c?m:c:x<c?x:c:w<x?w<c?w:c:x<c?x:c;e=k>s?k>t?k>e?k:e:t>e?t:e:s>t?s>e?s:e:t>e?t:e;g=m>w?m>x?m>g?m:g:x>g?x:g:w>x?w>g?w:g:x>g?x:g}a()};this.addRectangle=function(k){if(o){o=!1;b=k.getLeft();c=k.getTop();e=k.getRight();g=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();c=c<k.getTop()?c:k.getTop();e=e>k.getRight()?
+e:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;c-=k;e+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();c=c>k.getTop()?c:k.getTop();e=e<k.getRight()?e:k.getRight();g=g<k.getBottom()?g:k.getBottom();a()};this.instersects=function(k){return Math.min(e,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(g,k.getBottom())-Math.max(c,k.getTop())>=0};this.empty=function(){o=!0;g=e=c=b=0;a()};this.isEmpty=function(){return o};this.toString=function(){return"THREE.Rectangle ( left: "+
+b+", right: "+e+", top: "+c+", bottom: "+g+", width: "+i+", height: "+l+" )"}};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,i,l,o,k,m,s,w,t,x,F,H){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=e||0;this.n21=g||0;this.n22=i||1;this.n23=l||0;this.n24=o||0;this.n31=k||0;this.n32=m||0;this.n33=s||1;this.n34=w||0;this.n41=t||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,b,c,e,g,i,l,o,k,m,s,w,t,x,F,H){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=g;this.n22=i;this.n23=l;this.n24=o;this.n31=k;this.n32=m;this.n33=s;this.n34=w;this.n41=t;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,b,c){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,i=THREE.Matrix4.__tmpVec3;i.sub(a,b).normalize();e.cross(c,i).normalize();g.cross(i,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=i.x;this.n32=i.y;this.n33=i.z;this.n34=-i.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;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},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*
 a+this.n44))},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,h=a.n14,l=a.n21,n=a.n22,k=a.n23,m=a.n24,u=a.n31,x=a.n32,w=a.n33,A=a.n34,K=a.n41,N=a.n42,J=a.n43,r=a.n44,d=b.n11,I=b.n12,S=b.n13,V=b.n14,ea=b.n21,T=b.n22,M=b.n23,aa=b.n24,R=b.n31,ca=b.n32,W=b.n33,F=b.n34,O=b.n41,ia=b.n42,Q=b.n43,f=b.n44;this.n11=c*d+e*ea+g*R+h*O;this.n12=c*I+e*T+g*ca+h*ia;this.n13=c*S+e*M+g*W+h*Q;this.n14=c*V+e*aa+g*F+h*f;this.n21=l*d+n*ea+k*R+m*O;this.n22=l*I+n*T+k*ca+m*ia;this.n23=
-l*S+n*M+k*W+m*Q;this.n24=l*V+n*aa+k*F+m*f;this.n31=u*d+x*ea+w*R+A*O;this.n32=u*I+x*T+w*ca+A*ia;this.n33=u*S+x*M+w*W+A*Q;this.n34=u*V+x*aa+w*F+A*f;this.n41=K*d+N*ea+J*R+r*O;this.n42=K*I+N*T+J*ca+r*ia;this.n43=K*S+N*M+J*W+r*Q;this.n44=K*V+N*aa+J*F+r*f;return this},multiplyToArray:function(a,b,c){var e=a.n11,g=a.n12,h=a.n13,l=a.n14,n=a.n21,k=a.n22,m=a.n23,u=a.n24,x=a.n31,w=a.n32,A=a.n33,K=a.n34,N=a.n41,J=a.n42,r=a.n43;a=a.n44;var d=b.n11,I=b.n12,S=b.n13,V=b.n14,ea=b.n21,T=b.n22,M=b.n23,aa=b.n24,R=b.n31,
-ca=b.n32,W=b.n33,F=b.n34,O=b.n41,ia=b.n42,Q=b.n43;b=b.n44;this.n11=e*d+g*ea+h*R+l*O;this.n12=e*I+g*T+h*ca+l*ia;this.n13=e*S+g*M+h*W+l*Q;this.n14=e*V+g*aa+h*F+l*b;this.n21=n*d+k*ea+m*R+u*O;this.n22=n*I+k*T+m*ca+u*ia;this.n23=n*S+k*M+m*W+u*Q;this.n24=n*V+k*aa+m*F+u*b;this.n31=x*d+w*ea+A*R+K*O;this.n32=x*I+w*T+A*ca+K*ia;this.n33=x*S+w*M+A*W+K*Q;this.n34=x*V+w*aa+A*F+K*b;this.n41=N*d+J*ea+r*R+a*O;this.n42=N*I+J*T+r*ca+a*ia;this.n43=N*S+J*M+r*W+a*Q;this.n44=N*V+J*aa+r*F+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,h=this.n21,l=this.n22,n=this.n23,k=this.n24,m=this.n31,u=this.n32,x=this.n33,w=this.n34,A=this.n41,K=this.n42,N=this.n43,J=this.n44,r=a.n11,d=a.n21,I=a.n31,S=a.n41,V=a.n12,ea=a.n22,T=a.n32,M=a.n42,aa=a.n13,R=a.n23,
-ca=a.n33,W=a.n43,F=a.n14,O=a.n24,ia=a.n34;a=a.n44;this.n11=b*r+c*d+e*I+g*S;this.n12=b*V+c*ea+e*T+g*M;this.n13=b*aa+c*R+e*ca+g*W;this.n14=b*F+c*O+e*ia+g*a;this.n21=h*r+l*d+n*I+k*S;this.n22=h*V+l*ea+n*T+k*M;this.n23=h*aa+l*R+n*ca+k*W;this.n24=h*F+l*O+n*ia+k*a;this.n31=m*r+u*d+x*I+w*S;this.n32=m*V+u*ea+x*T+w*M;this.n33=m*aa+u*R+x*ca+w*W;this.n34=m*F+u*O+x*ia+w*a;this.n41=A*r+K*d+N*I+J*S;this.n42=A*V+K*ea+N*T+J*M;this.n43=A*aa+K*R+N*ca+J*W;this.n44=A*F+K*O+N*ia+J*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,h=this.n22,l=this.n23,n=this.n24,k=this.n31,m=this.n32,u=this.n33,x=this.n34,w=this.n41,A=this.n42,K=this.n43,N=this.n44;return e*l*m*w-c*n*m*w-e*h*u*w+b*n*u*w+c*h*x*w-b*l*x*w-e*l*k*A+c*n*k*A+e*g*u*A-a*n*u*A-c*g*x*A+a*l*x*A+
-e*h*k*K-b*n*k*K-e*g*m*K+a*n*m*K+b*g*x*K-a*h*x*K-c*h*k*N+b*l*k*N+c*g*m*N-a*l*m*N-b*g*u*N+a*h*u*N},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.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,i=a.n14,l=a.n21,o=a.n22,k=a.n23,m=a.n24,s=a.n31,w=a.n32,t=a.n33,x=a.n34,F=a.n41,H=a.n42,G=a.n43,r=a.n44,Z=b.n11,D=b.n12,K=b.n13,d=b.n14,ga=b.n21,T=b.n22,N=b.n23,ba=b.n24,R=b.n31,aa=b.n32,V=b.n33,B=b.n34,I=b.n41,ka=b.n42,P=b.n43,ja=b.n44;this.n11=c*Z+e*ga+g*R+i*I;this.n12=c*D+e*T+g*aa+i*ka;this.n13=c*K+e*N+g*V+i*P;this.n14=c*d+e*ba+g*B+i*ja;this.n21=l*Z+o*ga+k*R+m*I;this.n22=l*D+o*T+k*aa+m*ka;
+this.n23=l*K+o*N+k*V+m*P;this.n24=l*d+o*ba+k*B+m*ja;this.n31=s*Z+w*ga+t*R+x*I;this.n32=s*D+w*T+t*aa+x*ka;this.n33=s*K+w*N+t*V+x*P;this.n34=s*d+w*ba+t*B+x*ja;this.n41=F*Z+H*ga+G*R+r*I;this.n42=F*D+H*T+G*aa+r*ka;this.n43=F*K+H*N+G*V+r*P;this.n44=F*d+H*ba+G*B+r*ja;return this},multiplyToArray:function(a,b,c){var e=a.n11,g=a.n12,i=a.n13,l=a.n14,o=a.n21,k=a.n22,m=a.n23,s=a.n24,w=a.n31,t=a.n32,x=a.n33,F=a.n34,H=a.n41,G=a.n42,r=a.n43;a=a.n44;var Z=b.n11,D=b.n12,K=b.n13,d=b.n14,ga=b.n21,T=b.n22,N=b.n23,ba=
+b.n24,R=b.n31,aa=b.n32,V=b.n33,B=b.n34,I=b.n41,ka=b.n42,P=b.n43;b=b.n44;this.n11=e*Z+g*ga+i*R+l*I;this.n12=e*D+g*T+i*aa+l*ka;this.n13=e*K+g*N+i*V+l*P;this.n14=e*d+g*ba+i*B+l*b;this.n21=o*Z+k*ga+m*R+s*I;this.n22=o*D+k*T+m*aa+s*ka;this.n23=o*K+k*N+m*V+s*P;this.n24=o*d+k*ba+m*B+s*b;this.n31=w*Z+t*ga+x*R+F*I;this.n32=w*D+t*T+x*aa+F*ka;this.n33=w*K+t*N+x*V+F*P;this.n34=w*d+t*ba+x*B+F*b;this.n41=H*Z+G*ga+r*R+a*I;this.n42=H*D+G*T+r*aa+a*ka;this.n43=H*K+G*N+r*V+a*P;this.n44=H*d+G*ba+r*B+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,i=this.n21,l=this.n22,o=this.n23,k=this.n24,m=this.n31,s=this.n32,w=this.n33,t=this.n34,x=this.n41,F=this.n42,H=this.n43,G=this.n44,r=a.n11,Z=a.n21,D=a.n31,K=a.n41,d=a.n12,ga=a.n22,T=a.n32,N=a.n42,ba=
+a.n13,R=a.n23,aa=a.n33,V=a.n43,B=a.n14,I=a.n24,ka=a.n34;a=a.n44;this.n11=b*r+c*Z+e*D+g*K;this.n12=b*d+c*ga+e*T+g*N;this.n13=b*ba+c*R+e*aa+g*V;this.n14=b*B+c*I+e*ka+g*a;this.n21=i*r+l*Z+o*D+k*K;this.n22=i*d+l*ga+o*T+k*N;this.n23=i*ba+l*R+o*aa+k*V;this.n24=i*B+l*I+o*ka+k*a;this.n31=m*r+s*Z+w*D+t*K;this.n32=m*d+s*ga+w*T+t*N;this.n33=m*ba+s*R+w*aa+t*V;this.n34=m*B+s*I+w*ka+t*a;this.n41=x*r+F*Z+H*D+G*K;this.n42=x*d+F*ga+H*T+G*N;this.n43=x*ba+F*R+H*aa+G*V;this.n44=x*B+F*I+H*ka+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,b=this.n12,c=this.n13,e=this.n14,g=this.n21,i=this.n22,l=this.n23,o=this.n24,k=this.n31,m=this.n32,s=this.n33,w=this.n34,t=this.n41,x=this.n42,F=this.n43,H=this.n44;return e*l*m*t-c*o*m*t-e*i*s*t+b*o*s*t+c*i*w*t-b*l*w*t-e*l*k*x+c*o*k*x+e*g*s*x-a*o*s*x-c*g*w*x+a*l*w*x+
+e*i*k*F-b*o*k*F-e*g*m*F+a*o*m*F+b*g*w*F-a*i*w*F-c*i*k*H+b*l*k*H+c*g*m*H-a*l*m*H-b*g*s*H+a*i*s*H},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;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},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+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),g=1-c,h=a.x,l=a.y,n=a.z,k=g*
-h,m=g*l;this.set(k*h+c,k*l-e*n,k*n+e*l,0,k*l+e*n,m*l+c,m*n-e*h,0,k*n-e*l,m*n+e*h,g*n*n+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,e=a.z;a=Math.cos(c);c=Math.sin(c);var g=Math.cos(-e);e=Math.sin(-e);var h=Math.cos(b);b=Math.sin(b);var l=a*e,n=c*e;this.n11=a*g;this.n12=c*b-l*h;this.n13=l*b+c*h;this.n21=e;this.n22=g*h;this.n23=-g*b;this.n31=-c*g;this.n32=n*h+a*b;this.n33=-n*b+a*h},setRotationFromQuaternion:function(a){var b=
-a.x,c=a.y,e=a.z,g=a.w,h=b+b,l=c+c,n=e+e;a=b*h;var k=b*l;b*=n;var m=c*l;c*=n;e*=n;h*=g;l*=g;g*=n;this.n11=1-(m+e);this.n12=k-g;this.n13=b+l;this.n21=k+g;this.n22=1-(a+e);this.n23=c-h;this.n31=b-l;this.n32=c+h;this.n33=1-(a+m)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=b;this.n13*=b;this.n21*=c;this.n22*=c;this.n23*=c;this.n31*=a;this.n32*=a;this.n33*=a;return this},extractRotationMatrix:function(a){a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=0;a.n21=this.n21;a.n22=this.n22;
+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,i=a.x,l=a.y,o=a.z,k=g*
+i,m=g*l;this.set(k*i+c,k*l-e*o,k*o+e*l,0,k*l+e*o,m*l+c,m*o-e*i,0,k*o-e*l,m*o+e*i,g*o*o+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,e=a.z;a=Math.cos(c);c=Math.sin(c);var g=Math.cos(-e);e=Math.sin(-e);var i=Math.cos(b);b=Math.sin(b);var l=a*e,o=c*e;this.n11=a*g;this.n12=c*b-l*i;this.n13=l*b+c*i;this.n21=e;this.n22=g*i;this.n23=-g*b;this.n31=-c*g;this.n32=o*i+a*b;this.n33=-o*b+a*i},setRotationFromQuaternion:function(a){var b=
+a.x,c=a.y,e=a.z,g=a.w,i=b+b,l=c+c,o=e+e;a=b*i;var k=b*l;b*=o;var m=c*l;c*=o;e*=o;i*=g;l*=g;g*=o;this.n11=1-(m+e);this.n12=k-g;this.n13=b+l;this.n21=k+g;this.n22=1-(a+e);this.n23=c-i;this.n31=b-l;this.n32=c+i;this.n33=1-(a+m)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=b;this.n13*=b;this.n21*=c;this.n22*=c;this.n23*=c;this.n31*=a;this.n32*=a;this.n33*=a;return this},extractRotationMatrix:function(a){a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=0;a.n21=this.n21;a.n22=this.n22;
 a.n23=this.n23;a.n24=0;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=0;a.n41=0;a.n42=0;a.n43=0;a.n44=1},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.makeInvert=function(a,b){var c=a.n11,e=a.n12,g=a.n13,h=a.n14,l=a.n21,n=a.n22,k=a.n23,m=a.n24,u=a.n31,x=a.n32,w=a.n33,A=a.n34,K=a.n41,N=a.n42,J=a.n43,r=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=k*A*N-m*w*N+m*x*J-n*A*J-k*x*r+n*w*r;b.n12=h*w*N-g*A*N-h*x*J+e*A*J+g*x*r-e*w*r;b.n13=g*m*N-h*k*N+h*n*J-e*m*J-g*n*r+e*k*r;b.n14=h*k*x-g*m*x-h*n*w+e*m*w+g*n*A-e*k*A;b.n21=m*w*K-k*A*K-m*u*J+l*A*J+k*u*r-l*w*r;b.n22=g*A*K-h*w*K+h*u*J-c*A*J-g*u*r+c*w*r;b.n23=h*k*K-g*m*K-h*l*J+c*m*J+g*l*r-c*k*r;
-b.n24=g*m*u-h*k*u+h*l*w-c*m*w-g*l*A+c*k*A;b.n31=n*A*K-m*x*K+m*u*N-l*A*N-n*u*r+l*x*r;b.n32=h*x*K-e*A*K-h*u*N+c*A*N+e*u*r-c*x*r;b.n33=g*m*K-h*n*K+h*l*N-c*m*N-e*l*r+c*n*r;b.n34=h*n*u-e*m*u-h*l*x+c*m*x+e*l*A-c*n*A;b.n41=k*x*K-n*w*K-k*u*N+l*w*N+n*u*J-l*x*J;b.n42=e*w*K-g*x*K+g*u*N-c*w*N-e*u*J+c*x*J;b.n43=g*n*K-e*k*K-g*l*N+c*k*N+e*l*J-c*n*J;b.n44=e*k*u-g*n*u+g*l*x-c*k*x-e*l*w+c*n*w;b.multiplyScalar(1/a.determinant());return b};
-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,h=a.n32*a.n21-a.n31*a.n22,l=-a.n33*a.n12+a.n32*a.n13,n=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,u=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*l+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*g;c[2]=a*h;c[3]=a*l;c[4]=a*n;c[5]=a*k;c[6]=a*m;c[7]=a*u;c[8]=a*x;return b};
-THREE.Matrix4.makeFrustum=function(a,b,c,e,g,h){var l;l=new THREE.Matrix4;l.n11=2*g/(b-a);l.n12=0;l.n13=(b+a)/(b-a);l.n14=0;l.n21=0;l.n22=2*g/(e-c);l.n23=(e+c)/(e-c);l.n24=0;l.n31=0;l.n32=0;l.n33=-(h+g)/(h-g);l.n34=-2*h*g/(h-g);l.n41=0;l.n42=0;l.n43=-1;l.n44=0;return l};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,h){var l,n,k,m;l=new THREE.Matrix4;n=b-a;k=c-e;m=h-g;l.n11=2/n;l.n12=0;l.n13=0;l.n14=-((b+a)/n);l.n21=0;l.n22=2/k;l.n23=0;l.n24=-((c+e)/k);l.n31=0;l.n32=0;l.n33=-2/m;l.n34=-((h+g)/m);l.n41=0;l.n42=0;l.n43=0;l.n44=1;return l};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,e=a.n12,g=a.n13,i=a.n14,l=a.n21,o=a.n22,k=a.n23,m=a.n24,s=a.n31,w=a.n32,t=a.n33,x=a.n34,F=a.n41,H=a.n42,G=a.n43,r=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=k*x*H-m*t*H+m*w*G-o*x*G-k*w*r+o*t*r;b.n12=i*t*H-g*x*H-i*w*G+e*x*G+g*w*r-e*t*r;b.n13=g*m*H-i*k*H+i*o*G-e*m*G-g*o*r+e*k*r;b.n14=i*k*w-g*m*w-i*o*t+e*m*t+g*o*x-e*k*x;b.n21=m*t*F-k*x*F-m*s*G+l*x*G+k*s*r-l*t*r;b.n22=g*x*F-i*t*F+i*s*G-c*x*G-g*s*r+c*t*r;b.n23=i*k*F-g*m*F-i*l*G+c*m*G+g*l*r-c*k*r;
+b.n24=g*m*s-i*k*s+i*l*t-c*m*t-g*l*x+c*k*x;b.n31=o*x*F-m*w*F+m*s*H-l*x*H-o*s*r+l*w*r;b.n32=i*w*F-e*x*F-i*s*H+c*x*H+e*s*r-c*w*r;b.n33=g*m*F-i*o*F+i*l*H-c*m*H-e*l*r+c*o*r;b.n34=i*o*s-e*m*s-i*l*w+c*m*w+e*l*x-c*o*x;b.n41=k*w*F-o*t*F-k*s*H+l*t*H+o*s*G-l*w*G;b.n42=e*t*F-g*w*F+g*s*H-c*t*H-e*s*G+c*w*G;b.n43=g*o*F-e*k*F-g*l*H+c*k*H+e*l*G-c*o*G;b.n44=e*k*s-g*o*s+g*l*w-c*k*w-e*l*t+c*o*t;b.multiplyScalar(1/a.determinant());return b};
+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,i=a.n32*a.n21-a.n31*a.n22,l=-a.n33*a.n12+a.n32*a.n13,o=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,s=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*l+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*g;c[2]=a*i;c[3]=a*l;c[4]=a*o;c[5]=a*k;c[6]=a*m;c[7]=a*s;c[8]=a*w;return b};
+THREE.Matrix4.makeFrustum=function(a,b,c,e,g,i){var l;l=new THREE.Matrix4;l.n11=2*g/(b-a);l.n12=0;l.n13=(b+a)/(b-a);l.n14=0;l.n21=0;l.n22=2*g/(e-c);l.n23=(e+c)/(e-c);l.n24=0;l.n31=0;l.n32=0;l.n33=-(i+g)/(i-g);l.n34=-2*i*g/(i-g);l.n41=0;l.n42=0;l.n43=-1;l.n44=0;return l};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,i){var l,o,k,m;l=new THREE.Matrix4;o=b-a;k=c-e;m=i-g;l.n11=2/o;l.n12=0;l.n13=0;l.n14=-((b+a)/o);l.n21=0;l.n22=2/k;l.n23=0;l.n24=-((c+e)/k);l.n31=0;l.n32=0;l.n33=-2/m;l.n34=-((i+g)/m);l.n41=0;l.n42=0;l.n43=0;l.n44=1;return l};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 THREE.Quaternion=function(a,b,c,e){this.x=a||0;this.y=b||0;this.z=c||0;this.w=e!==undefined?e:1;this.api={isDirty:!1,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(g){this.that.x=g;this.isDirty=!0},set y(g){this.that.y=g;this.isDirty=!0},set z(g){this.that.z=g;this.isDirty=!0},set w(g){this.that.w=g;this.isDirty=!0}};this.api.__proto__=THREE.Quaternion.prototype;return this.api};
-THREE.Quaternion.prototype.set=function(a,b,c,e){var g=this.that;g.x=a;g.y=b;g.z=c;g.w=e;this.isDirty=!0;return this};THREE.Quaternion.prototype.setFromEuler=function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,g=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-g);g=Math.sin(-g);var h=Math.cos(c);c=Math.sin(c);var l=a*b,n=e*g,k=this.that;k.w=l*h-n*c;k.x=l*c+n*h;k.y=e*b*h+a*g*c;k.z=a*g*h-e*b*c;this.isDirty=!0;return this};
+THREE.Quaternion.prototype.set=function(a,b,c,e){var g=this.that;g.x=a;g.y=b;g.z=c;g.w=e;this.isDirty=!0;return this};THREE.Quaternion.prototype.setFromEuler=function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,g=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-g);g=Math.sin(-g);var i=Math.cos(c);c=Math.sin(c);var l=a*b,o=e*g,k=this.that;k.w=l*i-o*c;k.x=l*c+o*i;k.y=e*b*i+a*g*c;k.z=a*g*i-e*b*c;this.isDirty=!0;return this};
 THREE.Quaternion.prototype.calculateW=function(){var a=this.that,b=a.x,c=a.y,e=a.z;a.w=-Math.sqrt(Math.abs(1-b*b-c*c-e*e));this.isDirty=!0;return this};THREE.Quaternion.prototype.inverse=function(){var a=this.that;a.x*=-1;a.y*=-1;a.z*=-1;this.isDirty=!0;return this};THREE.Quaternion.prototype.length=function(){var a=this.that;return Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z+a.w*a.w)};
-THREE.Quaternion.prototype.normalize=function(){var a=this.that,b=a.x,c=a.y,e=a.z,g=a.w,h=Math.sqrt(b*b+c*c+e*e+g*g);if(h==0){a.x=0;a.y=0;a.z=0;a.w=0;this.isDirty=!0;return this}h=1/h;a.x=b*h;a.y=c*h;a.z=e*h;a.w=g*h;this.isDirty=!0;return this};
+THREE.Quaternion.prototype.normalize=function(){var a=this.that,b=a.x,c=a.y,e=a.z,g=a.w,i=Math.sqrt(b*b+c*c+e*e+g*g);if(i==0){a.x=0;a.y=0;a.z=0;a.w=0;this.isDirty=!0;return this}i=1/i;a.x=b*i;a.y=c*i;a.z=e*i;a.w=g*i;this.isDirty=!0;return this};
 THREE.Quaternion.prototype.multiplySelf=function(a){var b=this.that;qax=b.x;qay=b.y;qaz=b.z;qaw=b.w;qbx=a.x;qby=a.y;qbz=a.z;qbw=a.w;b.x=qax*qbw+qaw*qbx+qay*qbz-qaz*qby;b.y=qay*qbw+qaw*qby+qaz*qbx-qax*qbz;b.z=qaz*qbw+qaw*qbz+qax*qby-qay*qbx;b.w=qaw*qbw-qax*qbx-qay*qby-qaz*qbz;this.isDirty=!0;return this};
-THREE.Quaternion.prototype.multiplyVector3=function(a,b){b||(b=a);var c=this.that,e=a.x,g=a.y,h=a.z,l=c.x,n=c.y,k=c.z;c=c.w;var m=c*e+n*h-k*g,u=c*g+k*e-l*h,x=c*h+l*g-n*e;e=-l*e-n*g-k*h;b.x=m*c+e*-l+u*-k-x*-n;b.y=u*c+e*-n+x*-l-m*-k;b.z=x*c+e*-k+m*-n-u*-l;return b};THREE.Quaternion.prototype.toMatrix3=function(){};THREE.Quaternion.prototype.toMatrix4=function(){};
-THREE.Quaternion.slerp=function(a,b,c,e){var g=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(g)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(g),l=Math.sqrt(1-g*g);if(Math.abs(l)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}g=Math.sin((1-e)*h)/l;e=Math.sin(e*h)/l;c.w=a.w*g+b.w*e;c.x=a.x*g+b.x*e;c.y=a.y*g+b.y*e;c.z=a.z*g+b.z*e;return c};
+THREE.Quaternion.prototype.multiplyVector3=function(a,b){b||(b=a);var c=this.that,e=a.x,g=a.y,i=a.z,l=c.x,o=c.y,k=c.z;c=c.w;var m=c*e+o*i-k*g,s=c*g+k*e-l*i,w=c*i+l*g-o*e;e=-l*e-o*g-k*i;b.x=m*c+e*-l+s*-k-w*-o;b.y=s*c+e*-o+w*-l-m*-k;b.z=w*c+e*-k+m*-o-s*-l;return b};THREE.Quaternion.prototype.toMatrix3=function(){};THREE.Quaternion.prototype.toMatrix4=function(){};
+THREE.Quaternion.slerp=function(a,b,c,e){var g=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(g)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var i=Math.acos(g),l=Math.sqrt(1-g*g);if(Math.abs(l)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}g=Math.sin((1-e)*i)/l;e=Math.sin(e*i)/l;c.w=a.w*g+b.w*e;c.x=a.x*g+b.x*e;c.y=a.y*g+b.y*e;c.z=a.z*g+b.z*e;return c};
 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=!0};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.Face4=function(a,b,c,e,g,h){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=h instanceof Array?h:[h]};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,i){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=i instanceof Array?i:[i]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.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=!1};
 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,h,l,n=new THREE.Vector3,k=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){h=this.vertices[e];h.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){h=this.faces[e];if(a&&h.vertexNormals.length){n.set(0,0,0);b=0;for(c=h.normal.length;b<c;b++)n.addSelf(h.vertexNormals[b]);n.divideScalar(3)}else{b=this.vertices[h.a];c=this.vertices[h.b];l=this.vertices[h.c];n.sub(l.position,
-c.position);k.sub(b.position,c.position);n.crossSelf(k)}n.isZero()||n.normalize();h.normal.copy(n)}},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.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,e,g,i,l,o=new THREE.Vector3,k=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){i=this.vertices[e];i.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){i=this.faces[e];if(a&&i.vertexNormals.length){o.set(0,0,0);b=0;for(c=i.normal.length;b<c;b++)o.addSelf(i.vertexNormals[b]);o.divideScalar(3)}else{b=this.vertices[i.a];c=this.vertices[i.b];l=this.vertices[i.c];o.sub(l.position,
+c.position);k.sub(b.position,c.position);o.crossSelf(k)}o.isZero()||o.normalize();i.normal.copy(o)}},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<
-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(F,O,ia,Q,f,p,o){h=F.vertices[O].position;l=F.vertices[ia].position;n=F.vertices[Q].position;k=g[f];m=g[p];u=g[o];x=l.x-h.x;w=n.x-h.x;A=l.y-h.y;K=n.y-h.y;
-N=l.z-h.z;J=n.z-h.z;r=m.u-k.u;d=u.u-k.u;I=m.v-k.v;S=u.v-k.v;V=1/(r*S-d*I);M.set((S*x-I*w)*V,(S*A-I*K)*V,(S*N-I*J)*V);aa.set((r*w-d*x)*V,(r*K-d*A)*V,(r*J-d*N)*V);ea[O].addSelf(M);ea[ia].addSelf(M);ea[Q].addSelf(M);T[O].addSelf(aa);T[ia].addSelf(aa);T[Q].addSelf(aa)}var b,c,e,g,h,l,n,k,m,u,x,w,A,K,N,J,r,d,I,S,V,ea=[],T=[],M=new THREE.Vector3,aa=new THREE.Vector3,R=new THREE.Vector3,ca=new THREE.Vector3,W=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){ea[b]=new THREE.Vector3;T[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(B,I,ka,P,ja,ca,Q){i=B.vertices[I].position;l=B.vertices[ka].position;o=B.vertices[P].position;k=g[ja];m=g[ca];s=g[Q];w=l.x-i.x;t=o.x-i.x;x=l.y-i.y;F=o.y-
+i.y;H=l.z-i.z;G=o.z-i.z;r=m.u-k.u;Z=s.u-k.u;D=m.v-k.v;K=s.v-k.v;d=1/(r*K-Z*D);N.set((K*w-D*t)*d,(K*x-D*F)*d,(K*H-D*G)*d);ba.set((r*t-Z*w)*d,(r*F-Z*x)*d,(r*G-Z*H)*d);ga[I].addSelf(N);ga[ka].addSelf(N);ga[P].addSelf(N);T[I].addSelf(ba);T[ka].addSelf(ba);T[P].addSelf(ba)}var b,c,e,g,i,l,o,k,m,s,w,t,x,F,H,G,r,Z,D,K,d,ga=[],T=[],N=new THREE.Vector3,ba=new THREE.Vector3,R=new THREE.Vector3,aa=new THREE.Vector3,V=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){ga[b]=new THREE.Vector3;T[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]);
-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=ea[b];R.copy(e);R.subSelf(W.multiplyScalar(W.dot(e))).normalize();ca.cross(this.vertices[b].normal,e);e=ca.dot(T[b]);e=e<0?-1:1;this.vertices[b].tangent.set(R.x,R.y,R.z,e)}this.hasTangents=!0},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=ga[b];R.copy(e);R.subSelf(V.multiplyScalar(V.dot(e))).normalize();aa.cross(this.vertices[b].normal,e);e=aa.dot(T[b]);e=e<0?-1:1;this.vertices[b].tangent.set(R.x,R.y,R.z,e)}this.hasTangents=!0},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>
-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(u){var x=[];b=0;for(c=u.length;b<c;b++)u[b]==undefined?x.push("undefined"):x.push(u[b].id);return x.join("_")}var b,c,e,g,h,l,n,k,m={};e=0;for(g=this.faces.length;e<g;e++){h=this.faces[e];
-l=h.materials;n=a(l);m[n]==undefined&&(m[n]={hash:n,counter:0});k=m[n].hash+"_"+m[n].counter;this.geometryChunks[k]==undefined&&(this.geometryChunks[k]={faces:[],materials:l,vertices:0});h=h instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+h>65535){m[n].counter+=1;k=m[n].hash+"_"+m[n].counter;this.geometryChunks[k]==undefined&&(this.geometryChunks[k]={faces:[],materials:l,vertices:0})}this.geometryChunks[k].faces.push(e);this.geometryChunks[k].vertices+=h}},toString:function(){return"THREE.Geometry ( vertices: "+
+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(s){var w=[];b=0;for(c=s.length;b<c;b++)s[b]==undefined?w.push("undefined"):w.push(s[b].id);return w.join("_")}var b,c,e,g,i,l,o,k,m={};e=0;for(g=this.faces.length;e<g;e++){i=this.faces[e];
+l=i.materials;o=a(l);m[o]==undefined&&(m[o]={hash:o,counter:0});k=m[o].hash+"_"+m[o].counter;this.geometryChunks[k]==undefined&&(this.geometryChunks[k]={faces:[],materials:l,vertices:0});i=i instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+i>65535){m[o].counter+=1;k=m[o].hash+"_"+m[o].counter;this.geometryChunks[k]==undefined&&(this.geometryChunks[k]={faces:[],materials:l,vertices:0})}this.geometryChunks[k].faces.push(e);this.geometryChunks[k].vertices+=i}},toString:function(){return"THREE.Geometry ( vertices: "+
 this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0;
 THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.visible=!0;this.autoUpdateMatrix=!0;this.matrixNeedsToUpdate=!0;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale=1;this.rotationMatrix=
 new THREE.Matrix4};THREE.Object3D.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}var e=this.children.length;for(a=0;a<e;a++)this.children[a].update(this.globalMatrix,b,c)}};
 THREE.Object3D.prototype.updateMatrix=function(){this.localMatrix.setPosition(this.position);if(this.useQuaternion){if(this.quaternion.isDirty){this.localMatrix.setRotationFromQuaternion(this.quaternion);this.quaternion.isDirty=!1}}else this.localMatrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.localMatrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}return!0};
 THREE.Object3D.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a)}};THREE.Object3D.prototype.removeChild=function(a){var b=this.children.indexOf(a);if(b!==-1){this.children.splice(b,1);a.parent=undefined}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=!1};THREE.Particle.prototype=new THREE.Object3D;
 THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=c!=undefined?c:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;
-THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b&&b.length?b:[b];this.normalMatrix=THREE.Matrix4.makeInvert3x3(this.globalMatrix).transpose();this.flipSided=!1;this.doubleSided=!1;this.overdraw=!1;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius}};THREE.Mesh.prototype=new THREE.Object3D;
-THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
-THREE.Mesh.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0;this.normalMatrix=THREE.Matrix4.makeInvert3x3(this.globalMatrix).transpose()}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,c)}};
-THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
+THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b&&b.length?b:[b];this.flipSided=!1;this.doubleSided=!1;this.overdraw=!1;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
+THREE.Mesh.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,c)}};THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;
+THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
 THREE.Bone.prototype.update=function(a,b,c){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.skinMatrix.multiply(a,this.localMatrix):this.skinMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}var e,g=this.children.length;if(this.hasNoneBoneChildren){this.globalMatrix.multiply(this.skin.globalMatrix,this.skinMatrix);for(e=0;e<g;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.globalMatrix,!0,c)}}else for(e=
 0;e<g;e++)this.children[e].update(this.skinMatrix,b,c)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);if(!(a instanceof THREE.Bone))this.hasNoneBoneChildren=!0}};if(!window.Float32Array)window.Float32Array=Array;
-THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var c,e,g,h,l,n;if(this.geometry.bones!==undefined){for(c=0;c<this.geometry.bones.length;c++){g=this.geometry.bones[c];h=g.pos;l=g.rotq;n=g.scl;e=this.addBone();e.name=g.name;e.position.set(h[0],h[1],h[2]);e.quaternion.set(l[0],l[1],l[2],l[3]);n!==undefined?e.scale.set(n[0],n[1],n[2]):e.scale.set(1,1,1)}for(c=0;c<this.bones.length;c++){g=this.geometry.bones[c];e=this.bones[c];
+THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var c,e,g,i,l,o;if(this.geometry.bones!==undefined){for(c=0;c<this.geometry.bones.length;c++){g=this.geometry.bones[c];i=g.pos;l=g.rotq;o=g.scl;e=this.addBone();e.name=g.name;e.position.set(i[0],i[1],i[2]);e.quaternion.set(l[0],l[1],l[2],l[3]);o!==undefined?e.scale.set(o[0],o[1],o[2]):e.scale.set(1,1,1)}for(c=0;c<this.bones.length;c++){g=this.geometry.bones[c];e=this.bones[c];
 g.parent===-1?this.addChild(e):this.bones[g.parent].addChild(e)}this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
-THREE.SkinnedMesh.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0;this.normalMatrix=THREE.Matrix4.makeInvert3x3(this.globalMatrix).transpose()}var e,g=this.children.length;for(e=0;e<g;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.identityMatrix,!1,c):a.update(this.globalMatrix,b,
-c)}}};THREE.SkinnedMesh.prototype.addBone=function(a){a===undefined&&(a=new THREE.Bone(this));this.bones.push(a);return a};
-THREE.SkinnedMesh.prototype.pose=function(){this.update(undefined,!0);for(var a,b=[],c=0;c<this.bones.length;c++){a=this.bones[c];b.push(THREE.Matrix4.makeInvert(a.skinMatrix));a.skinMatrix.flattenToArrayOffset(this.boneMatrices,c*16)}if(this.geometry.skinVerticesA===undefined){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var e;for(a=0;a<this.geometry.skinIndices.length;a++){c=this.geometry.vertices[a].position;var g=this.geometry.skinIndices[a].x,h=this.geometry.skinIndices[a].y;
-e=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesA.push(b[g].multiplyVector3(e));e=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesB.push(b[h].multiplyVector3(e));if(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1){c=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5;this.geometry.skinWeights[a].x+=c;this.geometry.skinWeights[a].y+=c}}}};
+THREE.SkinnedMesh.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}var e,g=this.children.length;for(e=0;e<g;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.identityMatrix,!1,c):a.update(this.globalMatrix,b,c)}}};
+THREE.SkinnedMesh.prototype.addBone=function(a){a===undefined&&(a=new THREE.Bone(this));this.bones.push(a);return a};
+THREE.SkinnedMesh.prototype.pose=function(){this.update(undefined,!0);for(var a,b=[],c=0;c<this.bones.length;c++){a=this.bones[c];b.push(THREE.Matrix4.makeInvert(a.skinMatrix));a.skinMatrix.flattenToArrayOffset(this.boneMatrices,c*16)}if(this.geometry.skinVerticesA===undefined){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var e;for(a=0;a<this.geometry.skinIndices.length;a++){c=this.geometry.vertices[a].position;var g=this.geometry.skinIndices[a].x,i=this.geometry.skinIndices[a].y;
+e=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesA.push(b[g].multiplyVector3(e));e=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesB.push(b[i].multiplyVector3(e));if(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1){c=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5;this.geometry.skinWeights[a].x+=c;this.geometry.skinWeights[a].y+=c}}}};
 THREE.AnimationHandler=function(){var a=[],b={};b.update=function(c){for(var e=0;e<a.length;e++)a[e].update(c)};b.add=function(c){a.indexOf(c)===-1&&a.push(c)};b.remove=function(c){a.indexOf(c)!==-1&&a.splice(childIndex,1)};b.initData=function(c){if(c.initialized!==!0){for(var e=0;e<c.hierarchy.length;e++)for(var g=0;g<c.hierarchy[e].keys.length;g++){if(c.hierarchy[e].keys[g].time<0)c.hierarchy[e].keys[g].time=0;c.hierarchy[e].keys[g].index=g;if(c.hierarchy[e].keys[g].rot!==undefined&&!(c.hierarchy[e].keys[g].rot instanceof
-THREE.Quaternion)){var h=c.hierarchy[e].keys[g].rot;c.hierarchy[e].keys[g].rot=new THREE.Quaternion(h[0],h[1],h[2],h[3])}}g=parseInt(c.length*c.fps,10);c.JIT={};c.JIT.hierarchy=[];for(e=0;e<c.hierarchy.length;e++)c.JIT.hierarchy.push(Array(g));c.initialized=!0}};return b}();
+THREE.Quaternion)){var i=c.hierarchy[e].keys[g].rot;c.hierarchy[e].keys[g].rot=new THREE.Quaternion(i[0],i[1],i[2],i[3])}}g=parseInt(c.length*c.fps,10);c.JIT={};c.JIT.hierarchy=[];for(e=0;e<c.hierarchy.length;e++)c.JIT.hierarchy.push(Array(g));c.initialized=!0}};return b}();
 THREE.Animation=function(a,b){this.root=a;this.data=b;this.hierarchy=[];this.startTime=0;this.isPlaying=!1;this.loop=!0;this.offset=0;this.data.initialized||THREE.AnimationHandler.initData(this.data);if(a instanceof THREE.SkinnedMesh)for(var c=0;c<this.root.bones.length;c++)this.hierarchy.push(this.root.bones[c])};
 THREE.Animation.prototype.play=function(){if(!this.isPlaying){this.isPlaying=!0;this.startTime=(new Date).getTime()*0.0010;for(var a=0;a<this.hierarchy.length;a++){this.hierarchy[a].useQuaternion=!0;this.hierarchy[a].autoUpdateMatrix=!0;if(this.hierarchy[a].prevKey===undefined){this.hierarchy[a].prevKey={pos:0,rot:0,scl:0};this.hierarchy[a].nextKey={pos:0,rot:0,scl:0}}this.hierarchy[a].prevKey.pos=this.data.hierarchy[a].keys[0];this.hierarchy[a].prevKey.rot=this.data.hierarchy[a].keys[0];this.hierarchy[a].prevKey.scl=
 this.data.hierarchy[a].keys[0];this.hierarchy[a].nextKey.pos=this.getNextKeyWith("pos",a,1);this.hierarchy[a].nextKey.rot=this.getNextKeyWith("rot",a,1);this.hierarchy[a].nextKey.scl=this.getNextKeyWith("scl",a,1)}this.update();THREE.AnimationHandler.add(this)}};THREE.Animation.prototype.pause=function(){THREE.AnimationHandler.remove(this)};THREE.Animation.prototype.stop=function(){this.isPlaying=!1;THREE.AnimationHandler.remove(this)};
-THREE.Animation.prototype.update=function(){if(this.isPlaying){var a=["pos","rot","scl"],b,c,e,g,h,l,n=this.data.JIT.hierarchy,k=(new Date).getTime()*0.0010-this.startTime+this.offset,m=k;if(k>this.data.length){for(;k>this.data.length;)k-=this.data.length;this.startTime=(new Date).getTime()*0.0010-k;k=(new Date).getTime()*0.0010-this.startTime}l=Math.min(parseInt(k*this.data.fps),parseInt(this.data.length*this.data.fps));for(var u=0,x=this.hierarchy.length;u<x;u++){h=this.hierarchy[u];if(n[u][l]!==
-undefined){h.skinMatrix=n[u][l];h.autoUpdateMatrix=!1;h.matrixNeedsToUpdate=!1;h.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,u*16)}else for(var w=0;w<3;w++){c=a[w];e=h.prevKey[c];g=h.nextKey[c];if(g.time<m){if(k<m)if(this.loop){e=this.data.hierarchy[u].keys[0];g=this.getNextKeyWith(c,u,1)}else{this.stop();return}else{do{e=g;g=this.getNextKeyWith(c,u,g.index+1)}while(g.time<k)}h.prevKey[c]=e;h.nextKey[c]=g}h.autoUpdateMatrix=!0;h.matrixNeedsToUpdate=!0;b=(k-e.time)/(g.time-e.time);e=e[c];
-g=g[c];if(c==="rot"){if(b<0||b>1){console.log("Scale out of bounds:"+b);b=b<0?0:1}THREE.Quaternion.slerp(e,g,h.quaternion,b)}else{c=c==="pos"?h.position:h.scale;c.x=e[0]+(g[0]-e[0])*b;c.y=e[1]+(g[1]-e[1])*b;c.z=e[2]+(g[2]-e[2])*b}}}if(n[0][l]===undefined){this.hierarchy[0].update(undefined,!0);for(u=0;u<this.hierarchy.length;u++)n[u][l]=this.hierarchy[u].skinMatrix.clone()}}};THREE.Animation.prototype.updateObject=function(){};
+THREE.Animation.prototype.update=function(){if(this.isPlaying){var a=["pos","rot","scl"],b,c,e,g,i,l,o=this.data.JIT.hierarchy,k=(new Date).getTime()*0.0010-this.startTime+this.offset,m=k;if(k>this.data.length){for(;k>this.data.length;)k-=this.data.length;this.startTime=(new Date).getTime()*0.0010-k;k=(new Date).getTime()*0.0010-this.startTime}l=Math.min(parseInt(k*this.data.fps),parseInt(this.data.length*this.data.fps));for(var s=0,w=this.hierarchy.length;s<w;s++){i=this.hierarchy[s];if(o[s][l]!==
+undefined){i.skinMatrix=o[s][l];i.autoUpdateMatrix=!1;i.matrixNeedsToUpdate=!1;i.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,s*16)}else for(var t=0;t<3;t++){c=a[t];e=i.prevKey[c];g=i.nextKey[c];if(g.time<m){if(k<m)if(this.loop){e=this.data.hierarchy[s].keys[0];g=this.getNextKeyWith(c,s,1)}else{this.stop();return}else{do{e=g;g=this.getNextKeyWith(c,s,g.index+1)}while(g.time<k)}i.prevKey[c]=e;i.nextKey[c]=g}i.autoUpdateMatrix=!0;i.matrixNeedsToUpdate=!0;b=(k-e.time)/(g.time-e.time);e=e[c];
+g=g[c];if(c==="rot"){if(b<0||b>1){console.log("Scale out of bounds:"+b);b=b<0?0:1}THREE.Quaternion.slerp(e,g,i.quaternion,b)}else{c=c==="pos"?i.position:i.scale;c.x=e[0]+(g[0]-e[0])*b;c.y=e[1]+(g[1]-e[1])*b;c.z=e[2]+(g[2]-e[2])*b}}}if(o[0][l]===undefined){this.hierarchy[0].update(undefined,!0);for(s=0;s<this.hierarchy.length;s++)o[s][l]=this.hierarchy[s].skinMatrix.clone()}}};THREE.Animation.prototype.updateObject=function(){};
 THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var e=this.data.hierarchy[b].keys;c<e.length;c++)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[0]};
-THREE.Camera=function(a,b,c,e,g,h){THREE.Object3D.call(this);this.FOV=a||50;this.aspect=b||1;this.zNear=c||0.1;this.zFar=e||2E3;this.screenCenterY=this.screenCenterX=0;this.target=h||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.inverseMatrix=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(l){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(l);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);
+THREE.Camera=function(a,b,c,e,g,i){THREE.Object3D.call(this);this.FOV=a||50;this.aspect=b||1;this.zNear=c||0.1;this.zFar=e||2E3;this.screenCenterY=this.screenCenterX=0;this.target=i||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.inverseMatrix=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(l){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(l);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);
 this.target.position.addSelf(this.tmpVec)};this.translateZ=function(l){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(l);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
 THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.FOV,this.aspect,this.zNear,this.zFar)};
 THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.localMatrix.lookAt(this.position,this.target.position,this.up);a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);THREE.Matrix4.makeInvert(this.globalMatrix,this.inverseMatrix);b=!0}else{this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.globalMatrix,
 this.inverseMatrix)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,c)};
-THREE.Camera.prototype.frustumContains=function(a){var b=a.globalMatrix.n14,c=a.globalMatrix.n24,e=a.globalMatrix.n34,g=this.inverseMatrix,h=a.boundRadius*a.boundRadiusScale,l=g.n31*b+g.n32*c+g.n33*e+g.n34;if(l-h>-this.zNear)return!1;if(l+h<-this.zFar)return!1;l-=h;var n=this.projectionMatrix,k=1/(n.n43*l),m=k*this.screenCenterX,u=(g.n11*b+g.n12*c+g.n13*e+g.n14)*n.n11*m;h=n.n11*h*m;if(u+h<-this.screenCenterX)return!1;if(u-h>this.screenCenterX)return!1;b=(g.n21*b+g.n22*c+g.n23*e+g.n24)*n.n22*k*this.screenCenterY;
-if(b+h<-this.screenCenterY)return!1;if(b-h>this.screenCenterY)return!1;a.screenPosition.set(u,b,l,h);return!0};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
+THREE.Camera.prototype.frustumContains=function(a){var b=a.globalMatrix.n14,c=a.globalMatrix.n24,e=a.globalMatrix.n34,g=this.inverseMatrix,i=a.boundRadius*a.boundRadiusScale,l=g.n31*b+g.n32*c+g.n33*e+g.n34;if(l-i>-this.zNear)return!1;if(l+i<-this.zFar)return!1;l-=i;var o=this.projectionMatrix,k=1/(o.n43*l),m=k*this.screenCenterX,s=(g.n11*b+g.n12*c+g.n13*e+g.n14)*o.n11*m;i=o.n11*i*m;if(s+i<-this.screenCenterX)return!1;if(s-i>this.screenCenterX)return!1;b=(g.n21*b+g.n22*c+g.n23*e+g.n24)*o.n22*k*this.screenCenterY;
+if(b+i<-this.screenCenterY)return!1;if(b-i>this.screenCenterY)return!1;a.screenPosition.set(s,b,l,i);return!0};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
 THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1;
 THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.MaterialCounter={value:0};
 THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=!1;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=
@@ -133,124 +132,124 @@ THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;th
 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.ParticleCircleMaterial=function(a){this.id=THREE.MaterialCounter.value++;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.id=THREE.MaterialCounter.value++;this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
-THREE.Texture=function(a,b,c,e,g,h){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=h!==undefined?h:THREE.LinearMipMapLinearFilter};
+THREE.Texture=function(a,b,c,e,g,i){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=i!==undefined?i: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.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,b,c){this.width=a;this.height=b;c=c||{};this.wrap_s=c.wrap_s!==undefined?c.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=c.wrap_t!==undefined?c.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=c.mag_filter!==undefined?c.mag_filter:THREE.LinearFilter;this.min_filter=c.min_filter!==undefined?c.min_filter:THREE.LinearMipMapLinearFilter;this.format=c.format!==undefined?c.format:THREE.RGBFormat;this.type=c.type!==undefined?c.type:THREE.UnsignedByteType};
 var Uniforms={clone:function(a){var b,c,e,g={};for(b in a){g[b]={};for(c in a[b]){e=a[b][c];g[b][c]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var b,c,e,g={};for(b=0;b<a.length;b++){e=this.clone(a[b]);for(c in e)g[c]=e[c]}return g}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};THREE.Scene=function(){THREE.Object3D.call(this);this.objects=[];this.lights=[];this.fog=null};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};
-THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else a instanceof THREE.Camera||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
+THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
 THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};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;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(T,M){return M.z-T.z}function b(T,M){var aa=0,R=1,ca=T.z+T.w,W=M.z+M.w,F=-T.z+T.w,O=-M.z+M.w;if(ca>=0&&W>=0&&F>=0&&O>=0)return!0;else if(ca<0&&W<0||F<0&&O<0)return!1;else{if(ca<0)aa=Math.max(aa,ca/(ca-W));else W<0&&(R=Math.min(R,ca/(ca-W)));if(F<0)aa=Math.max(aa,F/(F-O));else O<0&&(R=Math.min(R,F/(F-O)));if(R<aa)return!1;else{T.lerpSelf(M,aa);M.lerpSelf(T,1-R);return!0}}}var c,e,g=[],h,l,n,k=[],m,u,x=[],w,A,K=[],N=new THREE.Vector4,J=new THREE.Vector4,r=new THREE.Matrix4,
-d=new THREE.Matrix4,I=[],S=new THREE.Vector4,V=new THREE.Vector4,ea;this.projectObjects=function(T,M,aa){M=[];var R,ca,W;e=0;ca=T.objects;T=0;for(R=ca.length;T<R;T++){W=ca[T];var F;if(!(F=!W.visible))if(F=W instanceof THREE.Mesh){a:{F=void 0;for(var O=W.globalMatrix,ia=-W.geometry.boundingSphere.radius*Math.max(W.scale.x,Math.max(W.scale.y,W.scale.z)),Q=0;Q<6;Q++){F=I[Q].x*O.n14+I[Q].y*O.n24+I[Q].z*O.n34+I[Q].w;if(F<=ia){F=!1;break a}}F=!0}F=!F}if(!F){c=g[e]=g[e]||new THREE.RenderableObject;N.copy(W.position);
-r.multiplyVector3(N);c.object=W;c.z=N.z;M.push(c);e++}}aa&&M.sort(a);return M};this.projectScene=function(T,M,aa){var R=[],ca=M.near,W=M.far,F,O,ia,Q,f,p,o,j,i,q,s,v,E,t,y,B;n=u=A=0;M.autoUpdateMatrix&&M.update();r.multiply(M.projectionMatrix,M.globalMatrix);I[0]=new THREE.Vector4(r.n41-r.n11,r.n42-r.n12,r.n43-r.n13,r.n44-r.n14);I[1]=new THREE.Vector4(r.n41+r.n11,r.n42+r.n12,r.n43+r.n13,r.n44+r.n14);I[2]=new THREE.Vector4(r.n41+r.n21,r.n42+r.n22,r.n43+r.n23,r.n44+r.n24);I[3]=new THREE.Vector4(r.n41-
-r.n21,r.n42-r.n22,r.n43-r.n23,r.n44-r.n24);I[4]=new THREE.Vector4(r.n41-r.n31,r.n42-r.n32,r.n43-r.n33,r.n44-r.n34);I[5]=new THREE.Vector4(r.n41+r.n31,r.n42+r.n32,r.n43+r.n33,r.n44+r.n34);F=0;for(p=I.length;F<p;F++){o=I[F];o.divideScalar(Math.sqrt(o.x*o.x+o.y*o.y+o.z*o.z))}T.update(undefined,!1,M);p=this.projectObjects(T,M,!0);T=0;for(F=p.length;T<F;T++){o=p[T].object;o.autoUpdateMatrix&&o.updateMatrix();j=o.globalMatrix;j.extractRotationMatrix(o.rotationMatrix);s=o.rotationMatrix;i=o.materials;q=
-o.overdraw;if(o instanceof THREE.Mesh){v=o.geometry;E=v.vertices;O=0;for(ia=E.length;O<ia;O++){t=E[O];t.positionWorld.copy(t.position);j.multiplyVector3(t.positionWorld);Q=t.positionScreen;Q.copy(t.positionWorld);r.multiplyVector4(Q);Q.x/=Q.w;Q.y/=Q.w;t.__visible=Q.z>ca&&Q.z<W}v=v.faces;O=0;for(ia=v.length;O<ia;O++){t=v[O];if(t instanceof THREE.Face3){Q=E[t.a];f=E[t.b];y=E[t.c];if(Q.__visible&&f.__visible&&y.__visible&&(o.doubleSided||o.flipSided!=(y.positionScreen.x-Q.positionScreen.x)*(f.positionScreen.y-
-Q.positionScreen.y)-(y.positionScreen.y-Q.positionScreen.y)*(f.positionScreen.x-Q.positionScreen.x)<0)){h=k[n]=k[n]||new THREE.RenderableFace3;h.v1.positionWorld.copy(Q.positionWorld);h.v2.positionWorld.copy(f.positionWorld);h.v3.positionWorld.copy(y.positionWorld);h.v1.positionScreen.copy(Q.positionScreen);h.v2.positionScreen.copy(f.positionScreen);h.v3.positionScreen.copy(y.positionScreen);h.normalWorld.copy(t.normal);s.multiplyVector3(h.normalWorld);h.centroidWorld.copy(t.centroid);j.multiplyVector3(h.centroidWorld);
-h.centroidScreen.copy(h.centroidWorld);r.multiplyVector3(h.centroidScreen);y=t.vertexNormals;ea=h.vertexNormalsWorld;Q=0;for(f=y.length;Q<f;Q++){B=ea[Q]=ea[Q]||new THREE.Vector3;B.copy(y[Q]);s.multiplyVector3(B)}h.z=h.centroidScreen.z;h.meshMaterials=i;h.faceMaterials=t.materials;h.overdraw=q;if(o.geometry.uvs[O]){h.uvs[0]=o.geometry.uvs[O][0];h.uvs[1]=o.geometry.uvs[O][1];h.uvs[2]=o.geometry.uvs[O][2]}R.push(h);n++}}else if(t instanceof THREE.Face4){Q=E[t.a];f=E[t.b];y=E[t.c];B=E[t.d];if(Q.__visible&&
-f.__visible&&y.__visible&&B.__visible&&(o.doubleSided||o.flipSided!=((B.positionScreen.x-Q.positionScreen.x)*(f.positionScreen.y-Q.positionScreen.y)-(B.positionScreen.y-Q.positionScreen.y)*(f.positionScreen.x-Q.positionScreen.x)<0||(f.positionScreen.x-y.positionScreen.x)*(B.positionScreen.y-y.positionScreen.y)-(f.positionScreen.y-y.positionScreen.y)*(B.positionScreen.x-y.positionScreen.x)<0))){h=k[n]=k[n]||new THREE.RenderableFace3;h.v1.positionWorld.copy(Q.positionWorld);h.v2.positionWorld.copy(f.positionWorld);
-h.v3.positionWorld.copy(B.positionWorld);h.v1.positionScreen.copy(Q.positionScreen);h.v2.positionScreen.copy(f.positionScreen);h.v3.positionScreen.copy(B.positionScreen);h.normalWorld.copy(t.normal);s.multiplyVector3(h.normalWorld);h.centroidWorld.copy(t.centroid);j.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);r.multiplyVector3(h.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=i;h.faceMaterials=t.materials;h.overdraw=q;if(o.geometry.uvs[O]){h.uvs[0]=o.geometry.uvs[O][0];
-h.uvs[1]=o.geometry.uvs[O][1];h.uvs[2]=o.geometry.uvs[O][3]}R.push(h);n++;l=k[n]=k[n]||new THREE.RenderableFace3;l.v1.positionWorld.copy(f.positionWorld);l.v2.positionWorld.copy(y.positionWorld);l.v3.positionWorld.copy(B.positionWorld);l.v1.positionScreen.copy(f.positionScreen);l.v2.positionScreen.copy(y.positionScreen);l.v3.positionScreen.copy(B.positionScreen);l.normalWorld.copy(h.normalWorld);l.centroidWorld.copy(h.centroidWorld);l.centroidScreen.copy(h.centroidScreen);l.z=l.centroidScreen.z;l.meshMaterials=
-i;l.faceMaterials=t.materials;l.overdraw=q;if(o.geometry.uvs[O]){l.uvs[0]=o.geometry.uvs[O][1];l.uvs[1]=o.geometry.uvs[O][2];l.uvs[2]=o.geometry.uvs[O][3]}R.push(l);n++}}}}else if(o instanceof THREE.Line){d.multiply(r,j);E=o.geometry.vertices;t=E[0];t.positionScreen.copy(t.position);d.multiplyVector4(t.positionScreen);O=1;for(ia=E.length;O<ia;O++){Q=E[O];Q.positionScreen.copy(Q.position);d.multiplyVector4(Q.positionScreen);f=E[O-1];S.copy(Q.positionScreen);V.copy(f.positionScreen);if(b(S,V)){S.multiplyScalar(1/
-S.w);V.multiplyScalar(1/V.w);m=x[u]=x[u]||new THREE.RenderableLine;m.v1.positionScreen.copy(S);m.v2.positionScreen.copy(V);m.z=Math.max(S.z,V.z);m.materials=o.materials;R.push(m);u++}}}else if(o instanceof THREE.Particle){J.set(o.position.x,o.position.y,o.position.z,1);r.multiplyVector4(J);J.z/=J.w;if(J.z>0&&J.z<1){w=K[A]=K[A]||new THREE.RenderableParticle;w.x=J.x/J.w;w.y=J.y/J.w;w.z=J.z;w.rotation=o.rotation.z;w.scale.x=o.scale.x*Math.abs(w.x-(J.x+M.projectionMatrix.n11)/(J.w+M.projectionMatrix.n14));
-w.scale.y=o.scale.y*Math.abs(w.y-(J.y+M.projectionMatrix.n22)/(J.w+M.projectionMatrix.n24));w.materials=o.materials;R.push(w);A++}}}aa&&R.sort(a);return R};this.unprojectVector=function(T,M){var aa=THREE.Matrix4.makeInvert(M.globalMatrix);aa.multiplySelf(THREE.Matrix4.makeInvert(M.projectionMatrix));aa.multiplyVector3(T);return T}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,g,h;this.domElement=document.createElement("div");this.setSize=function(l,n){c=l;e=n;g=c/2;h=e/2};this.render=function(l,n){var k,m,u,x,w,A,K,N;a=b.projectScene(l,n);k=0;for(m=a.length;k<m;k++){w=a[k];if(w instanceof THREE.RenderableParticle){K=w.x*g+g;N=w.y*h+h;u=0;for(x=w.material.length;u<x;u++){A=w.material[u];if(A instanceof THREE.ParticleDOMMaterial){A=A.domElement;A.style.left=K+"px";A.style.top=N+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(G){if(w!=G)m.globalAlpha=w=G}function b(G){if(A!=G){switch(G){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}A=G}}var c=null,e=new THREE.Projector,g=document.createElement("canvas"),h,l,n,k,m=g.getContext("2d"),u=new THREE.Color(0),x=0,w=1,A=0,K=null,N=null,J=1,r,d,I,S,V,ea,T,M,aa,R=new THREE.Color,
-ca=new THREE.Color,W=new THREE.Color,F=new THREE.Color,O=new THREE.Color,ia,Q,f,p,o,j,i,q,s,v=new THREE.Rectangle,E=new THREE.Rectangle,t=new THREE.Rectangle,y=!1,B=new THREE.Color,Y=new THREE.Color,ga=new THREE.Color,na=new THREE.Color,ua=Math.PI*2,Z=new THREE.Vector3,fa,ha,Ia,C,Ca,wa,za=16;fa=document.createElement("canvas");fa.width=fa.height=2;ha=fa.getContext("2d");ha.fillStyle="rgba(0,0,0,1)";ha.fillRect(0,0,2,2);Ia=ha.getImageData(0,0,2,2);C=Ia.data;Ca=document.createElement("canvas");Ca.width=
-Ca.height=za;wa=Ca.getContext("2d");wa.translate(-za/2,-za/2);wa.scale(za,za);za--;this.domElement=g;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(G,L){h=G;l=L;n=h/2;k=l/2;g.width=h;g.height=l;v.set(-n,-k,n,k);w=1;A=0;N=K=null;J=1};this.setClearColor=function(G,L){u=G;x=L;E.set(-n,-k,n,k);m.setTransform(1,0,0,-1,n,k);this.clear()};this.setClearColorHex=function(G,L){u.setHex(G);x=L;E.set(-n,-k,n,k);m.setTransform(1,0,0,-1,n,k);this.clear()};this.clear=function(){m.setTransform(1,
-0,0,-1,n,k);if(!E.isEmpty()){E.inflate(1);E.minSelf(v);if(u.hex==0&&x==0)m.clearRect(E.getX(),E.getY(),E.getWidth(),E.getHeight());else{b(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(u.r*255)+","+Math.floor(u.g*255)+","+Math.floor(u.b*255)+","+x+")";m.fillRect(E.getX(),E.getY(),E.getWidth(),E.getHeight())}E.empty()}};this.render=function(G,L){function P(D){var ba,X,H,U=D.lights;Y.setRGB(0,0,0);ga.setRGB(0,0,0);na.setRGB(0,0,0);D=0;for(ba=U.length;D<ba;D++){X=U[D];H=X.color;if(X instanceof
-THREE.AmbientLight){Y.r+=H.r;Y.g+=H.g;Y.b+=H.b}else if(X instanceof THREE.DirectionalLight){ga.r+=H.r;ga.g+=H.g;ga.b+=H.b}else if(X instanceof THREE.PointLight){na.r+=H.r;na.g+=H.g;na.b+=H.b}}}function ja(D,ba,X,H){var U,da,sa,Aa,Da=D.lights;D=0;for(U=Da.length;D<U;D++){da=Da[D];sa=da.color;Aa=da.intensity;if(da instanceof THREE.DirectionalLight){da=X.dot(da.position)*Aa;if(da>0){H.r+=sa.r*da;H.g+=sa.g*da;H.b+=sa.b*da}}else if(da instanceof THREE.PointLight){Z.sub(da.position,ba);Z.normalize();da=
-X.dot(Z)*Aa;if(da>0){H.r+=sa.r*da;H.g+=sa.g*da;H.b+=sa.b*da}}}}function Ea(D,ba,X){if(X.opacity!=0){a(X.opacity);b(X.blending);var H,U,da,sa,Aa,Da;if(X instanceof THREE.ParticleBasicMaterial){if(X.map&&X.map.image.loaded){sa=X.map.image;Aa=sa.width>>1;Da=sa.height>>1;U=ba.scale.x*n;da=ba.scale.y*k;X=U*Aa;H=da*Da;t.set(D.x-X,D.y-H,D.x+X,D.y+H);if(!v.instersects(t))return;m.save();m.translate(D.x,D.y);m.rotate(-ba.rotation);m.scale(U,-da);m.translate(-Aa,-Da);m.drawImage(sa,0,0);m.restore()}m.beginPath();
-m.moveTo(D.x-10,D.y);m.lineTo(D.x+10,D.y);m.moveTo(D.x,D.y-10);m.lineTo(D.x,D.y+10);m.closePath();m.strokeStyle="rgb(255,255,0)";m.stroke()}else if(X instanceof THREE.ParticleCircleMaterial){if(y){B.r=Y.r+ga.r+na.r;B.g=Y.g+ga.g+na.g;B.b=Y.b+ga.b+na.b;R.r=X.color.r*B.r;R.g=X.color.g*B.g;R.b=X.color.b*B.b;R.updateStyleString()}else R.__styleString=X.color.__styleString;X=ba.scale.x*n;H=ba.scale.y*k;t.set(D.x-X,D.y-H,D.x+X,D.y+H);if(v.instersects(t)){U=R.__styleString;if(N!=U)m.fillStyle=N=U;m.save();
-m.translate(D.x,D.y);m.rotate(-ba.rotation);m.scale(X,H);m.beginPath();m.arc(0,0,1,0,ua,!0);m.closePath();m.fill();m.restore()}}}}function ra(D,ba,X,H){if(H.opacity!=0){a(H.opacity);b(H.blending);m.beginPath();m.moveTo(D.positionScreen.x,D.positionScreen.y);m.lineTo(ba.positionScreen.x,ba.positionScreen.y);m.closePath();if(H instanceof THREE.LineBasicMaterial){R.__styleString=H.color.__styleString;D=H.linewidth;if(J!=D)m.lineWidth=J=D;D=R.__styleString;if(K!=D)m.strokeStyle=K=D;m.stroke();t.inflate(H.linewidth*
-2)}}}function z(D,ba,X,H,U,da){if(U.opacity!=0){a(U.opacity);b(U.blending);S=D.positionScreen.x;V=D.positionScreen.y;ea=ba.positionScreen.x;T=ba.positionScreen.y;M=X.positionScreen.x;aa=X.positionScreen.y;m.beginPath();m.moveTo(S,V);m.lineTo(ea,T);m.lineTo(M,aa);m.lineTo(S,V);m.closePath();if(U instanceof THREE.MeshBasicMaterial)if(U.map)U.map.image.loaded&&U.map.mapping instanceof THREE.UVMapping&&Ka(S,V,ea,T,M,aa,U.map.image,H.uvs[0].u,H.uvs[0].v,H.uvs[1].u,H.uvs[1].v,H.uvs[2].u,H.uvs[2].v);else if(U.env_map){if(U.env_map.image.loaded&&
-U.env_map.mapping instanceof THREE.SphericalReflectionMapping){D=L.globalMatrix;Z.copy(H.vertexNormalsWorld[0]);p=(Z.x*D.n11+Z.y*D.n12+Z.z*D.n13)*0.5+0.5;o=-(Z.x*D.n21+Z.y*D.n22+Z.z*D.n23)*0.5+0.5;Z.copy(H.vertexNormalsWorld[1]);j=(Z.x*D.n11+Z.y*D.n12+Z.z*D.n13)*0.5+0.5;i=-(Z.x*D.n21+Z.y*D.n22+Z.z*D.n23)*0.5+0.5;Z.copy(H.vertexNormalsWorld[2]);q=(Z.x*D.n11+Z.y*D.n12+Z.z*D.n13)*0.5+0.5;s=-(Z.x*D.n21+Z.y*D.n22+Z.z*D.n23)*0.5+0.5;Ka(S,V,ea,T,M,aa,U.env_map.image,p,o,j,i,q,s)}}else U.wireframe?pa(U.color.__styleString,
-U.wireframe_linewidth):Ma(U.color.__styleString);else if(U instanceof THREE.MeshLambertMaterial){if(U.map&&!U.wireframe){U.map.mapping instanceof THREE.UVMapping&&Ka(S,V,ea,T,M,aa,U.map.image,H.uvs[0].u,H.uvs[0].v,H.uvs[1].u,H.uvs[1].v,H.uvs[2].u,H.uvs[2].v);b(THREE.SubtractiveBlending)}if(y)if(!U.wireframe&&U.shading==THREE.SmoothShading&&H.vertexNormalsWorld.length==3){ca.r=W.r=F.r=Y.r;ca.g=W.g=F.g=Y.g;ca.b=W.b=F.b=Y.b;ja(da,H.v1.positionWorld,H.vertexNormalsWorld[0],ca);ja(da,H.v2.positionWorld,
-H.vertexNormalsWorld[1],W);ja(da,H.v3.positionWorld,H.vertexNormalsWorld[2],F);O.r=(W.r+F.r)*0.5;O.g=(W.g+F.g)*0.5;O.b=(W.b+F.b)*0.5;f=Ha(ca,W,F,O);Ka(S,V,ea,T,M,aa,f,0,0,1,0,0,1)}else{B.r=Y.r;B.g=Y.g;B.b=Y.b;ja(da,H.centroidWorld,H.normalWorld,B);R.r=U.color.r*B.r;R.g=U.color.g*B.g;R.b=U.color.b*B.b;R.updateStyleString();U.wireframe?pa(R.__styleString,U.wireframe_linewidth):Ma(R.__styleString)}else U.wireframe?pa(U.color.__styleString,U.wireframe_linewidth):Ma(U.color.__styleString)}else if(U instanceof
-THREE.MeshDepthMaterial){ia=L.near;Q=L.far;ca.r=ca.g=ca.b=1-la(D.positionScreen.z,ia,Q);W.r=W.g=W.b=1-la(ba.positionScreen.z,ia,Q);F.r=F.g=F.b=1-la(X.positionScreen.z,ia,Q);O.r=(W.r+F.r)*0.5;O.g=(W.g+F.g)*0.5;O.b=(W.b+F.b)*0.5;f=Ha(ca,W,F,O);Ka(S,V,ea,T,M,aa,f,0,0,1,0,0,1)}else if(U instanceof THREE.MeshNormalMaterial){R.r=qa(H.normalWorld.x);R.g=qa(H.normalWorld.y);R.b=qa(H.normalWorld.z);R.updateStyleString();U.wireframe?pa(R.__styleString,U.wireframe_linewidth):Ma(R.__styleString)}}}function pa(D,
-ba){if(K!=D)m.strokeStyle=K=D;if(J!=ba)m.lineWidth=J=ba;m.stroke();t.inflate(ba*2)}function Ma(D){if(N!=D)m.fillStyle=N=D;m.fill()}function Ka(D,ba,X,H,U,da,sa,Aa,Da,La,ta,Ga,Ja){var Fa,Ba;Fa=sa.width-1;Ba=sa.height-1;Aa*=Fa;Da*=Ba;La*=Fa;ta*=Ba;Ga*=Fa;Ja*=Ba;X-=D;H-=ba;U-=D;da-=ba;La-=Aa;ta-=Da;Ga-=Aa;Ja-=Da;Fa=La*Ja-Ga*ta;if(Fa!=0){Ba=1/Fa;Fa=(Ja*X-ta*U)*Ba;ta=(Ja*H-ta*da)*Ba;X=(La*U-Ga*X)*Ba;H=(La*da-Ga*H)*Ba;D=D-Fa*Aa-X*Da;ba=ba-ta*Aa-H*Da;m.save();m.transform(Fa,ta,X,H,D,ba);m.clip();m.drawImage(sa,
-0,0);m.restore()}}function Ha(D,ba,X,H){var U=~~(D.r*255),da=~~(D.g*255);D=~~(D.b*255);var sa=~~(ba.r*255),Aa=~~(ba.g*255);ba=~~(ba.b*255);var Da=~~(X.r*255),La=~~(X.g*255);X=~~(X.b*255);var ta=~~(H.r*255),Ga=~~(H.g*255);H=~~(H.b*255);C[0]=U<0?0:U>255?255:U;C[1]=da<0?0:da>255?255:da;C[2]=D<0?0:D>255?255:D;C[4]=sa<0?0:sa>255?255:sa;C[5]=Aa<0?0:Aa>255?255:Aa;C[6]=ba<0?0:ba>255?255:ba;C[8]=Da<0?0:Da>255?255:Da;C[9]=La<0?0:La>255?255:La;C[10]=X<0?0:X>255?255:X;C[12]=ta<0?0:ta>255?255:ta;C[13]=Ga<0?0:
-Ga>255?255:Ga;C[14]=H<0?0:H>255?255:H;ha.putImageData(Ia,0,0);wa.drawImage(fa,0,0);return Ca}function la(D,ba,X){D=(D-ba)/(X-ba);return D*D*(3-2*D)}function qa(D){D=(D+1)*0.5;return D<0?0:D>1?1:D}function ma(D,ba){var X=ba.x-D.x,H=ba.y-D.y,U=1/Math.sqrt(X*X+H*H);X*=U;H*=U;ba.x+=X;ba.y+=H;D.x-=X;D.y-=H}var ka,oa,$,xa,va,Oa,ya,Na;this.autoClear?this.clear():m.setTransform(1,0,0,-1,n,k);c=e.projectScene(G,L,this.sortElements);m.fillStyle="rgba( 0, 255, 255, 0.5 )";m.fillRect(v.getX(),v.getY(),v.getWidth(),
-v.getHeight());(y=G.lights.length>0)&&P(G);ka=0;for(oa=c.length;ka<oa;ka++){$=c[ka];t.empty();if($ instanceof THREE.RenderableParticle){r=$;r.x*=n;r.y*=k;xa=0;for(va=$.materials.length;xa<va;xa++)Ea(r,$,$.materials[xa],G)}else if($ instanceof THREE.RenderableLine){r=$.v1;d=$.v2;r.positionScreen.x*=n;r.positionScreen.y*=k;d.positionScreen.x*=n;d.positionScreen.y*=k;t.addPoint(r.positionScreen.x,r.positionScreen.y);t.addPoint(d.positionScreen.x,d.positionScreen.y);if(v.instersects(t)){xa=0;for(va=$.materials.length;xa<
-va;)ra(r,d,$,$.materials[xa++],G)}}else if($ instanceof THREE.RenderableFace3){r=$.v1;d=$.v2;I=$.v3;r.positionScreen.x*=n;r.positionScreen.y*=k;d.positionScreen.x*=n;d.positionScreen.y*=k;I.positionScreen.x*=n;I.positionScreen.y*=k;if($.overdraw){ma(r.positionScreen,d.positionScreen);ma(d.positionScreen,I.positionScreen);ma(I.positionScreen,r.positionScreen)}t.add3Points(r.positionScreen.x,r.positionScreen.y,d.positionScreen.x,d.positionScreen.y,I.positionScreen.x,I.positionScreen.y);if(v.instersects(t)){xa=
-0;for(va=$.meshMaterials.length;xa<va;){Na=$.meshMaterials[xa++];if(Na instanceof THREE.MeshFaceMaterial){Oa=0;for(ya=$.faceMaterials.length;Oa<ya;)(Na=$.faceMaterials[Oa++])&&z(r,d,I,$,Na,G)}else z(r,d,I,$,Na,G)}}}E.addRectangle(t)}m.lineWidth=1;m.strokeStyle="rgba( 255, 0, 0, 0.5 )";m.strokeRect(E.getX(),E.getY(),E.getWidth(),E.getHeight());m.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(p,o,j){var i,q,s,v;i=0;for(q=p.lights.length;i<q;i++){s=p.lights[i];if(s instanceof THREE.DirectionalLight){v=o.normalWorld.dot(s.position)*s.intensity;if(v>0){j.r+=s.color.r*v;j.g+=s.color.g*v;j.b+=s.color.b*v}}else if(s instanceof THREE.PointLight){aa.sub(s.position,o.centroidWorld);aa.normalize();v=o.normalWorld.dot(aa)*s.intensity;if(v>0){j.r+=s.color.r*v;j.g+=s.color.g*v;j.b+=s.color.b*v}}}}function b(p,o,j,i,q,s){F=e(O++);F.setAttribute("d","M "+p.positionScreen.x+
-" "+p.positionScreen.y+" L "+o.positionScreen.x+" "+o.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+"z");if(q instanceof THREE.MeshBasicMaterial)I.__styleString=q.color.__styleString;else if(q instanceof THREE.MeshLambertMaterial)if(d){S.r=V.r;S.g=V.g;S.b=V.b;a(s,i,S);I.r=q.color.r*S.r;I.g=q.color.g*S.g;I.b=q.color.b*S.b;I.updateStyleString()}else I.__styleString=q.color.__styleString;else if(q instanceof THREE.MeshDepthMaterial){M=1-q.__2near/(q.__farPlusNear-i.z*q.__farMinusNear);
-I.setRGB(M,M,M)}else q instanceof THREE.MeshNormalMaterial&&I.setRGB(g(i.normalWorld.x),g(i.normalWorld.y),g(i.normalWorld.z));q.wireframe?F.setAttribute("style","fill: none; stroke: "+I.__styleString+"; stroke-width: "+q.wireframe_linewidth+"; stroke-opacity: "+q.opacity+"; stroke-linecap: "+q.wireframe_linecap+"; stroke-linejoin: "+q.wireframe_linejoin):F.setAttribute("style","fill: "+I.__styleString+"; fill-opacity: "+q.opacity);n.appendChild(F)}function c(p,o,j,i,q,s,v){F=e(O++);F.setAttribute("d",
-"M "+p.positionScreen.x+" "+p.positionScreen.y+" L "+o.positionScreen.x+" "+o.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+" L "+i.positionScreen.x+","+i.positionScreen.y+"z");if(s instanceof THREE.MeshBasicMaterial)I.__styleString=s.color.__styleString;else if(s instanceof THREE.MeshLambertMaterial)if(d){S.r=V.r;S.g=V.g;S.b=V.b;a(v,q,S);I.r=s.color.r*S.r;I.g=s.color.g*S.g;I.b=s.color.b*S.b;I.updateStyleString()}else I.__styleString=s.color.__styleString;else if(s instanceof THREE.MeshDepthMaterial){M=
-1-s.__2near/(s.__farPlusNear-q.z*s.__farMinusNear);I.setRGB(M,M,M)}else s instanceof THREE.MeshNormalMaterial&&I.setRGB(g(q.normalWorld.x),g(q.normalWorld.y),g(q.normalWorld.z));s.wireframe?F.setAttribute("style","fill: none; stroke: "+I.__styleString+"; stroke-width: "+s.wireframe_linewidth+"; stroke-opacity: "+s.opacity+"; stroke-linecap: "+s.wireframe_linecap+"; stroke-linejoin: "+s.wireframe_linejoin):F.setAttribute("style","fill: "+I.__styleString+"; fill-opacity: "+s.opacity);n.appendChild(F)}
-function e(p){if(R[p]==null){R[p]=document.createElementNS("http://www.w3.org/2000/svg","path");f==0&&R[p].setAttribute("shape-rendering","crispEdges")}return R[p]}function g(p){return p<0?Math.min((1+p)*0.5,0.5):0.5+Math.min(p*0.5,0.5)}var h=null,l=new THREE.Projector,n=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,m,u,x,w,A,K,N,J=new THREE.Rectangle,r=new THREE.Rectangle,d=!1,I=new THREE.Color(16777215),S=new THREE.Color(16777215),V=new THREE.Color(0),ea=new THREE.Color(0),T=new THREE.Color(0),
-M,aa=new THREE.Vector3,R=[],ca=[],W=[],F,O,ia,Q,f=1;this.domElement=n;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(p){switch(p){case "high":f=1;break;case "low":f=0}};this.setSize=function(p,o){k=p;m=o;u=k/2;x=m/2;n.setAttribute("viewBox",-u+" "+-x+" "+k+" "+m);n.setAttribute("width",k);n.setAttribute("height",m);J.set(-u,-x,u,x)};this.clear=function(){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])};this.render=function(p,o){var j,i,q,s,v,E,t,y;this.autoClear&&
-this.clear();h=l.projectScene(p,o,this.sortElements);Q=ia=O=0;if(d=p.lights.length>0){t=p.lights;V.setRGB(0,0,0);ea.setRGB(0,0,0);T.setRGB(0,0,0);j=0;for(i=t.length;j<i;j++){q=t[j];s=q.color;if(q instanceof THREE.AmbientLight){V.r+=s.r;V.g+=s.g;V.b+=s.b}else if(q instanceof THREE.DirectionalLight){ea.r+=s.r;ea.g+=s.g;ea.b+=s.b}else if(q instanceof THREE.PointLight){T.r+=s.r;T.g+=s.g;T.b+=s.b}}}j=0;for(i=h.length;j<i;j++){t=h[j];r.empty();if(t instanceof THREE.RenderableParticle){w=t;w.x*=u;w.y*=-x;
-q=0;for(s=t.materials.length;q<s;q++)if(y=t.materials[q]){v=w;E=t;var B=ia++;if(ca[B]==null){ca[B]=document.createElementNS("http://www.w3.org/2000/svg","circle");f==0&&ca[B].setAttribute("shape-rendering","crispEdges")}F=ca[B];F.setAttribute("cx",v.x);F.setAttribute("cy",v.y);F.setAttribute("r",E.scale.x*u);if(y instanceof THREE.ParticleCircleMaterial){if(d){S.r=V.r+ea.r+T.r;S.g=V.g+ea.g+T.g;S.b=V.b+ea.b+T.b;I.r=y.color.r*S.r;I.g=y.color.g*S.g;I.b=y.color.b*S.b;I.updateStyleString()}else I=y.color;
-F.setAttribute("style","fill: "+I.__styleString)}n.appendChild(F)}}else if(t instanceof THREE.RenderableLine){w=t.v1;A=t.v2;w.positionScreen.x*=u;w.positionScreen.y*=-x;A.positionScreen.x*=u;A.positionScreen.y*=-x;r.addPoint(w.positionScreen.x,w.positionScreen.y);r.addPoint(A.positionScreen.x,A.positionScreen.y);if(J.instersects(r)){q=0;for(s=t.materials.length;q<s;)if(y=t.materials[q++]){v=w;E=A;B=Q++;if(W[B]==null){W[B]=document.createElementNS("http://www.w3.org/2000/svg","line");f==0&&W[B].setAttribute("shape-rendering",
-"crispEdges")}F=W[B];F.setAttribute("x1",v.positionScreen.x);F.setAttribute("y1",v.positionScreen.y);F.setAttribute("x2",E.positionScreen.x);F.setAttribute("y2",E.positionScreen.y);if(y instanceof THREE.LineBasicMaterial){I.__styleString=y.color.__styleString;F.setAttribute("style","fill: none; stroke: "+I.__styleString+"; stroke-width: "+y.linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.linecap+"; stroke-linejoin: "+y.linejoin);n.appendChild(F)}}}}else if(t instanceof THREE.RenderableFace3){w=
-t.v1;A=t.v2;K=t.v3;w.positionScreen.x*=u;w.positionScreen.y*=-x;A.positionScreen.x*=u;A.positionScreen.y*=-x;K.positionScreen.x*=u;K.positionScreen.y*=-x;r.addPoint(w.positionScreen.x,w.positionScreen.y);r.addPoint(A.positionScreen.x,A.positionScreen.y);r.addPoint(K.positionScreen.x,K.positionScreen.y);if(J.instersects(r)){q=0;for(s=t.meshMaterials.length;q<s;){y=t.meshMaterials[q++];if(y instanceof THREE.MeshFaceMaterial){v=0;for(E=t.faceMaterials.length;v<E;)(y=t.faceMaterials[v++])&&b(w,A,K,t,
-y,p)}else y&&b(w,A,K,t,y,p)}}}else if(t instanceof THREE.RenderableFace4){w=t.v1;A=t.v2;K=t.v3;N=t.v4;w.positionScreen.x*=u;w.positionScreen.y*=-x;A.positionScreen.x*=u;A.positionScreen.y*=-x;K.positionScreen.x*=u;K.positionScreen.y*=-x;N.positionScreen.x*=u;N.positionScreen.y*=-x;r.addPoint(w.positionScreen.x,w.positionScreen.y);r.addPoint(A.positionScreen.x,A.positionScreen.y);r.addPoint(K.positionScreen.x,K.positionScreen.y);r.addPoint(N.positionScreen.x,N.positionScreen.y);if(J.instersects(r)){q=
-0;for(s=t.meshMaterials.length;q<s;){y=t.meshMaterials[q++];if(y instanceof THREE.MeshFaceMaterial){v=0;for(E=t.faceMaterials.length;v<E;)(y=t.faceMaterials[v++])&&c(w,A,K,N,t,y,p)}else y&&c(w,A,K,N,t,y,p)}}}}}};
-THREE.WebGLRenderer=function(a){function b(f,p,o){var j,i,q,s=f.vertices,v=s.length,E=f.colors,t=E.length,y=f.__vertexArray,B=f.__colorArray,Y=f.__sortArray,ga=f.__dirtyVertices,na=f.__dirtyColors;if(o.sortParticles){aa.multiplySelf(o.globalMatrix);for(j=0;j<v;j++){i=s[j].position;F.copy(i);aa.multiplyVector3(F);Y[j]=[F.z,j]}Y.sort(function(ua,Z){return Z[0]-ua[0]});for(j=0;j<v;j++){i=s[Y[j][1]].position;q=j*3;y[q]=i.x;y[q+1]=i.y;y[q+2]=i.z}for(j=0;j<t;j++){q=j*3;color=E[Y[j][1]];B[q]=color.r;B[q+
-1]=color.g;B[q+2]=color.b}}else{if(ga)for(j=0;j<v;j++){i=s[j].position;q=j*3;y[q]=i.x;y[q+1]=i.y;y[q+2]=i.z}if(na)for(j=0;j<t;j++){color=E[j];q=j*3;B[q]=color.r;B[q+1]=color.g;B[q+2]=color.b}}if(ga||o.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,y,p)}if(na||o.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,B,p)}}function c(f,p){f.fragment_shader=p.fragment_shader;f.vertex_shader=p.vertex_shader;f.uniforms=
-Uniforms.clone(p.uniforms)}function e(f,p){if(!f.__webGLVertexBuffer)f.__webGLVertexBuffer=d.createBuffer();if(!f.__webGLNormalBuffer)f.__webGLNormalBuffer=d.createBuffer();if(f.hasPos){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,f.positionArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(p.attributes.position);d.vertexAttribPointer(p.attributes.position,3,d.FLOAT,!1,0,0)}if(f.hasNormal){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,
-f.normalArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(p.attributes.normal);d.vertexAttribPointer(p.attributes.normal,3,d.FLOAT,!1,0,0)}d.drawArrays(d.TRIANGLES,0,f.count);f.count=0}function g(f){if(V!=f.doubleSided){f.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE);V=f.doubleSided}if(ea!=f.flipSided){f.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW);ea=f.flipSided}}function h(f){M[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);M[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+
-f.n14);M[2].set(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);M[3].set(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);M[4].set(f.n41-f.n31,f.n42-f.n32,f.n43-f.n33,f.n44-f.n34);M[5].set(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);var p;for(f=0;f<5;f++){p=M[f];p.divideScalar(Math.sqrt(p.x*p.x+p.y*p.y+p.z*p.z))}}function l(f){for(var p=f.globalMatrix,o=-f.geometry.boundingSphere.radius*Math.max(f.scale.x,Math.max(f.scale.y,f.scale.z)),j=0;j<6;j++){f=M[j].x*p.n14+M[j].y*p.n24+M[j].z*p.n34+M[j].w;
-if(f<=o)return!1}return!0}function n(f,p){f.list[f.count]=p;f.count+=1}function k(f){var p,o,j=f.object,i=f.opaque,q=f.transparent;q.count=0;f=i.count=0;for(p=j.materials.length;f<p;f++){o=j.materials[f];o.opacity&&o.opacity<1||o.blending!=THREE.NormalBlending?n(q,o):n(i,o)}}function m(f){var p,o,j,i,q=f.object,s=f.buffer,v=f.opaque,E=f.transparent;E.count=0;f=v.count=0;for(j=q.materials.length;f<j;f++){p=q.materials[f];if(p instanceof THREE.MeshFaceMaterial){p=0;for(o=s.materials.length;p<o;p++)(i=
-s.materials[p])&&(i.opacity&&i.opacity<1||i.blending!=THREE.NormalBlending?n(E,i):n(v,i))}else{i=p;i.opacity&&i.opacity<1||i.blending!=THREE.NormalBlending?n(E,i):n(v,i)}}}function u(f,p){return p.z-f.z}function x(f,p,o,j,i){if(p[o]==undefined){f.push({buffer:j,object:i,opaque:{list:[],count:0},transparent:{list:[],count:0}});p[o]=1}}function w(f,p){f._modelViewMatrix.multiplyToArray(p.globalMatrix,f.globalMatrix,f._modelViewMatrixArray);f._normalMatrix=THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}
-function A(f){if(f!=T){switch(f){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)}T=f}}function K(f,p){if(f&&!f.__webGLFramebuffer){f.__webGLFramebuffer=d.createFramebuffer();f.__webGLRenderbuffer=d.createRenderbuffer();
-f.__webGLTexture=d.createTexture();d.bindRenderbuffer(d.RENDERBUFFER,f.__webGLRenderbuffer);d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,f.width,f.height);d.bindTexture(d.TEXTURE_2D,f.__webGLTexture);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,J(f.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,J(f.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,J(f.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,J(f.min_filter));d.texImage2D(d.TEXTURE_2D,0,J(f.format),
-f.width,f.height,0,J(f.format),J(f.type),null);d.bindFramebuffer(d.FRAMEBUFFER,f.__webGLFramebuffer);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,f.__webGLTexture,0);d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.RENDERBUFFER,f.__webGLRenderbuffer);d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,null)}var o,j,i;if(f){o=f.__webGLFramebuffer;j=f.width;i=f.height}else{o=null;j=r.width;i=r.height}if(o!=S){d.bindFramebuffer(d.FRAMEBUFFER,
-o);d.viewport(0,0,j,i);p&&d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT);S=o}}function N(f,p){var o;if(f=="fragment")o=d.createShader(d.FRAGMENT_SHADER);else f=="vertex"&&(o=d.createShader(d.VERTEX_SHADER));d.shaderSource(o,p);d.compileShader(o);if(!d.getShaderParameter(o,d.COMPILE_STATUS)){alert(d.getShaderInfoLog(o));return null}return o}function J(f){switch(f){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 r=document.createElement("canvas"),d,I=null,S=null,V=null,ea=null,T=null,M=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,
-new THREE.Vector4],aa=new THREE.Matrix4,R=new Float32Array(16),ca=new Float32Array(16),W=new Float32Array(16),F=new THREE.Vector4,O=!0,ia=new THREE.Color(0),Q=0;if(a){if(a.antialias!==undefined)O=a.antialias;a.clearColor!==undefined&&ia.setHex(a.clearColor);if(a.clearAlpha!==undefined)Q=a.clearAlpha}this.domElement=r;this.autoClear=!0;this.sortObjects=!1;(function(f,p,o){try{d=r.getContext("experimental-webgl",{antialias:f})}catch(j){console.log(j)}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(p.r,p.g,p.b,o);_cullEnabled=!0})(O,ia,Q);this.context=d;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,p){r.width=f;r.height=p;d.viewport(0,0,r.width,r.height)};this.setClearColorHex=function(f,
-p){var o=new THREE.Color(f);d.clearColor(o.r,o.g,o.b,p)};this.setClearColor=function(f,p){d.clearColor(f.r,f.g,f.b,p)};this.clear=function(){d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT)};this.setupLights=function(f,p){var o,j,i,q=0,s=0,v=0,E,t,y,B=this.lights,Y=B.directional.colors,ga=B.directional.positions,na=B.point.colors,ua=B.point.positions,Z=0,fa=0;o=i=i=0;for(j=p.length;o<j;o++){i=p[o];E=i.color;t=i.position;y=i.intensity;if(i instanceof THREE.AmbientLight){q+=E.r;s+=E.g;v+=E.b}else if(i instanceof
-THREE.DirectionalLight){i=Z*3;Y[i]=E.r*y;Y[i+1]=E.g*y;Y[i+2]=E.b*y;ga[i]=t.x;ga[i+1]=t.y;ga[i+2]=t.z;Z+=1}else if(i instanceof THREE.PointLight){i=fa*3;na[i]=E.r*y;na[i+1]=E.g*y;na[i+2]=E.b*y;ua[i]=t.x;ua[i+1]=t.y;ua[i+2]=t.z;fa+=1}}for(o=Z*3;o<Y.length;o++)Y[o]=0;for(o=fa*3;o<na.length;o++)na[o]=0;B.point.length=fa;B.directional.length=Z;B.ambient[0]=q;B.ambient[1]=s;B.ambient[2]=v};this.initMaterial=function(f,p,o){var j,i;if(f instanceof THREE.MeshDepthMaterial)c(f,THREE.ShaderLib.depth);else if(f instanceof
-THREE.MeshNormalMaterial)c(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)c(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)c(f,THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)c(f,THREE.ShaderLib.phong);else if(f instanceof THREE.LineBasicMaterial)c(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&c(f,THREE.ShaderLib.particle_basic);var q,s,v,E;i=v=E=0;for(q=p.length;i<q;i++){s=p[i];s instanceof THREE.DirectionalLight&&
-v++;s instanceof THREE.PointLight&&E++}if(E+v<=4)p=v;else{p=Math.ceil(4*v/(E+v));E=4-p}i={directional:p,point:E};E=f.fragment_shader;p=f.vertex_shader;q={fog:o,map:f.map,env_map:f.env_map,light_map:f.light_map,vertex_colors:f.vertex_colors,skinning:f.skinning,maxDirLights:i.directional,maxPointLights:i.point};o=d.createProgram();i=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+q.maxDirLights,"#define MAX_POINT_LIGHTS "+q.maxPointLights,q.fog?"#define USE_FOG":"",q.fog instanceof
-THREE.FogExp2?"#define FOG_EXP2":"",q.map?"#define USE_MAP":"",q.env_map?"#define USE_ENVMAP":"",q.light_map?"#define USE_LIGHTMAP":"",q.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");q=[d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+q.maxDirLights,"#define MAX_POINT_LIGHTS "+q.maxPointLights,q.map?"#define USE_MAP":"",q.env_map?"#define USE_ENVMAP":"",q.light_map?"#define USE_LIGHTMAP":
-"",q.vertex_colors?"#define USE_COLOR":"",q.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
-d.attachShader(o,N("fragment",i+E));d.attachShader(o,N("vertex",q+p));d.linkProgram(o);d.getProgramParameter(o,d.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+d.getProgramParameter(o,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");o.uniforms={};o.attributes={};f.program=o;o=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","uBoneGlobalMatrices"];for(j in f.uniforms)o.push(j);j=f.program;E=0;for(p=o.length;E<
-p;E++){i=o[E];j.uniforms[i]=d.getUniformLocation(j,i)}f=f.program;j=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];o=0;for(E=j.length;o<E;o++){p=j[o];f.attributes[p]=d.getAttribLocation(f,p)}};this.setProgram=function(f,p,o,j,i){j.program||this.initMaterial(j,p,o);var q=j.program,s=q.uniforms,v=j.uniforms;if(q!=I){d.useProgram(q);I=q;d.uniformMatrix4fv(s.projectionMatrix,!1,R)}if(o&&(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||
-j instanceof THREE.MeshPhongMaterial||j instanceof THREE.LineBasicMaterial||j instanceof THREE.ParticleBasicMaterial)){v.fogColor.value.setHex(o.color.hex);if(o instanceof THREE.Fog){v.fogNear.value=o.near;v.fogFar.value=o.far}else if(o instanceof THREE.FogExp2)v.fogDensity.value=o.density}if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){this.setupLights(q,p);p=this.lights;v.enableLighting.value=p.directional.length+p.point.length;v.ambientLightColor.value=p.ambient;
-v.directionalLightColor.value=p.directional.colors;v.directionalLightDirection.value=p.directional.positions;v.pointLightColor.value=p.point.colors;v.pointLightPosition.value=p.point.positions}if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial){v.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);v.opacity.value=j.opacity;v.map.texture=j.map;v.light_map.texture=j.light_map;v.env_map.texture=j.env_map;
-v.reflectivity.value=j.reflectivity;v.refraction_ratio.value=j.refraction_ratio;v.combine.value=j.combine;v.useRefract.value=j.env_map&&j.env_map.mapping instanceof THREE.CubeRefractionMapping}if(j instanceof THREE.LineBasicMaterial){v.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);v.opacity.value=j.opacity}else if(j instanceof THREE.ParticleBasicMaterial){v.psColor.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);v.opacity.value=j.opacity;
-v.size.value=j.size;v.map.texture=j.map}else if(j instanceof THREE.MeshPhongMaterial){v.ambient.value.setRGB(j.ambient.r,j.ambient.g,j.ambient.b);v.specular.value.setRGB(j.specular.r,j.specular.g,j.specular.b);v.shininess.value=j.shininess}else if(j instanceof THREE.MeshDepthMaterial){v.mNear.value=f.near;v.mFar.value=f.far;v.opacity.value=j.opacity}else if(j instanceof THREE.MeshNormalMaterial)v.opacity.value=j.opacity;var E,t,y;for(E in v)if(y=q.uniforms[E]){o=v[E];t=o.type;p=o.value;if(t=="i")d.uniform1i(y,
-p);else if(t=="f")d.uniform1f(y,p);else if(t=="fv1")d.uniform1fv(y,p);else if(t=="fv")d.uniform3fv(y,p);else if(t=="v2")d.uniform2f(y,p.x,p.y);else if(t=="v3")d.uniform3f(y,p.x,p.y,p.z);else if(t=="c")d.uniform3f(y,p.r,p.g,p.b);else if(t=="t"){d.uniform1i(y,p);if(o=o.texture)if(o.image instanceof Array&&o.image.length==6){if(o.image.length==6){if(!o.image.__webGLTextureCube&&!o.image.__cubeMapInitialized&&o.image.loadCount==6){o.image.__webGLTextureCube=d.createTexture();d.bindTexture(d.TEXTURE_CUBE_MAP,
-o.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(t=0;t<6;++t)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,o.image[t]);d.generateMipmap(d.TEXTURE_CUBE_MAP);d.bindTexture(d.TEXTURE_CUBE_MAP,null);o.image.__cubeMapInitialized=
-!0}d.activeTexture(d.TEXTURE0+p);d.bindTexture(d.TEXTURE_CUBE_MAP,o.image.__webGLTextureCube)}}else{if(!o.__webGLTexture&&o.image.loaded){o.__webGLTexture=d.createTexture();d.bindTexture(d.TEXTURE_2D,o.__webGLTexture);d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,o.image);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,J(o.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,J(o.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,J(o.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,
-J(o.min_filter));d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}d.activeTexture(d.TEXTURE0+p);d.bindTexture(d.TEXTURE_2D,o.__webGLTexture)}}}d.uniformMatrix4fv(s.modelViewMatrix,!1,i._modelViewMatrixArray);d.uniformMatrix3fv(s.normalMatrix,!1,i._normalMatrixArray);(j instanceof THREE.MeshShaderMaterial||j instanceof THREE.MeshPhongMaterial||j.env_map)&&d.uniform3f(s.cameraPosition,f.position.x,f.position.y,f.position.z);(j instanceof THREE.MeshShaderMaterial||j.env_map||j.skinning)&&
-d.uniformMatrix4fv(s.objectMatrix,!1,i._objectMatrixArray);(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshShaderMaterial||j.skinning)&&d.uniformMatrix4fv(s.viewMatrix,!1,W);if(j.skinning){d.uniformMatrix4fv(s.cameraInverseMatrix,!1,ca);d.uniformMatrix4fv(s.uBoneGlobalMatrices,!1,i.boneMatrices)}return q};this.renderBuffer=function(f,p,o,j,i,q){f=this.setProgram(f,p,o,j,q).attributes;d.bindBuffer(d.ARRAY_BUFFER,i.__webGLVertexBuffer);d.vertexAttribPointer(f.position,
-3,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.position);if(f.color>=0){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLColorBuffer);d.vertexAttribPointer(f.color,3,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.color)}if(f.normal>=0){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLNormalBuffer);d.vertexAttribPointer(f.normal,3,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.normal)}if(f.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLTangentBuffer);d.vertexAttribPointer(f.tangent,4,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.tangent)}if(f.uv>=
-0)if(i.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLUVBuffer);d.vertexAttribPointer(f.uv,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.uv)}else d.disableVertexAttribArray(f.uv);if(f.uv2>=0)if(i.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLUV2Buffer);d.vertexAttribPointer(f.uv2,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.uv2)}else d.disableVertexAttribArray(f.uv2);if(q instanceof THREE.SkinnedMesh){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinVertexABuffer);d.vertexAttribPointer(f.skinVertexA,
-4,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.skinVertexA);d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinVertexBBuffer);d.vertexAttribPointer(f.skinVertexB,4,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.skinVertexB);d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinIndicesBuffer);d.vertexAttribPointer(f.skinIndex,4,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.skinIndex);d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinWeightsBuffer);d.vertexAttribPointer(f.skinWeight,4,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.skinWeight)}if(q instanceof
-THREE.Mesh)if(j.wireframe){d.lineWidth(j.wireframe_linewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,i.__webGLLineBuffer);d.drawElements(d.LINES,i.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,i.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,i.__webGLFaceCount,d.UNSIGNED_SHORT,0)}else if(q instanceof THREE.Line){q=q.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(j.linewidth);d.drawArrays(q,0,i.__webGLLineCount)}else q instanceof THREE.ParticleSystem&&d.drawArrays(d.POINTS,
-0,i.__webGLParticleCount)};this.render=function(f,p,o,j){var i,q,s,v,E,t,y,B,Y=f.lights,ga=f.fog;p.autoUpdateMatrix&&p.update();p.globalMatrix.flattenToArray(W);p.projectionMatrix.flattenToArray(R);p.inverseMatrix.flattenToArray(ca);aa.multiply(p.projectionMatrix,p.globalMatrix);h(aa);THREE.AnimationHandler&&THREE.AnimationHandler.update();f.update(undefined,!1,p);this.initWebGLObjects(f,p);K(o,j!==undefined?j:!0);this.autoClear&&this.clear();E=f.__webGLObjects.length;for(j=0;j<E;j++){i=f.__webGLObjects[j];
-y=i.object;if(y.visible)if(!(y instanceof THREE.Mesh)||l(y)){y.globalMatrix.flattenToArray(y._objectMatrixArray);w(y,p);m(i);i.render=!0;if(this.sortObjects){F.copy(y.position);aa.multiplyVector3(F);i.z=F.z}}else i.render=!1;else i.render=!1}this.sortObjects&&f.__webGLObjects.sort(u);t=f.__webGLObjectsImmediate.length;for(j=0;j<t;j++){i=f.__webGLObjectsImmediate[j];y=i.object;if(y.visible){y.autoUpdateMatrix&&y.globalMatrix.flattenToArray(y._objectMatrixArray);w(y,p);k(i)}}A(THREE.NormalBlending);
-for(j=0;j<E;j++){i=f.__webGLObjects[j];if(i.render){y=i.object;B=i.buffer;s=i.opaque;g(y);for(i=0;i<s.count;i++){v=s.list[i];this.setDepthTest(v.depth_test);this.renderBuffer(p,Y,ga,v,B,y)}}}for(j=0;j<t;j++){i=f.__webGLObjectsImmediate[j];y=i.object;if(y.visible){s=i.opaque;g(y);for(i=0;i<s.count;i++){v=s.list[i];this.setDepthTest(v.depth_test);q=this.setProgram(p,Y,ga,v,y);y.render(function(na){e(na,q)})}}}for(j=0;j<E;j++){i=f.__webGLObjects[j];if(i.render){y=i.object;B=i.buffer;s=i.transparent;
-g(y);for(i=0;i<s.count;i++){v=s.list[i];A(v.blending);this.setDepthTest(v.depth_test);this.renderBuffer(p,Y,ga,v,B,y)}}}for(j=0;j<t;j++){i=f.__webGLObjectsImmediate[j];y=i.object;if(y.visible){s=i.transparent;g(y);for(i=0;i<s.count;i++){v=s.list[i];A(v.blending);this.setDepthTest(v.depth_test);q=this.setProgram(p,Y,ga,v,y);y.render(function(na){e(na,q)})}}}if(o&&o.min_filter!==THREE.NearestFilter&&o.min_filter!==THREE.LinearFilter){d.bindTexture(d.TEXTURE_2D,o.__webGLTexture);d.generateMipmap(d.TEXTURE_2D);
-d.bindTexture(d.TEXTURE_2D,null)}};this.initWebGLObjects=function(f){var p,o,j;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={};f.__webGLObjectsImmediate=[]}p=0;for(o=f.objects.length;p<o;p++){j=f.objects[p];var i=f,q=void 0,s=void 0,v=void 0,E=void 0;s=j.geometry;if(i.__webGLObjectsMap[j.id]==undefined){i.__webGLObjectsMap[j.id]={};j._modelViewMatrix=new THREE.Matrix4;j._normalMatrixArray=new Float32Array(9);j._modelViewMatrixArray=new Float32Array(16);j._objectMatrixArray=new Float32Array(16);
-j.globalMatrix.flattenToArray(j._objectMatrixArray)}E=i.__webGLObjectsMap[j.id];objlist=i.__webGLObjects;if(j instanceof THREE.Mesh){for(q in s.geometryChunks){v=s.geometryChunks[q];if(!v.__webGLVertexBuffer){i=v;i.__webGLVertexBuffer=d.createBuffer();i.__webGLNormalBuffer=d.createBuffer();i.__webGLTangentBuffer=d.createBuffer();i.__webGLColorBuffer=d.createBuffer();i.__webGLUVBuffer=d.createBuffer();i.__webGLUV2Buffer=d.createBuffer();i.__webGLSkinVertexABuffer=d.createBuffer();i.__webGLSkinVertexBBuffer=
-d.createBuffer();i.__webGLSkinIndicesBuffer=d.createBuffer();i.__webGLSkinWeightsBuffer=d.createBuffer();i.__webGLFaceBuffer=d.createBuffer();i.__webGLLineBuffer=d.createBuffer();i=v;var t=j,y=void 0,B=void 0,Y=0,ga=0,na=0,ua=t.geometry.faces,Z=i.faces;y=0;for(B=Z.length;y<B;y++){fi=Z[y];face=ua[fi];if(face instanceof THREE.Face3){Y+=3;ga+=1;na+=3}else if(face instanceof THREE.Face4){Y+=4;ga+=2;na+=4}}i.__vertexArray=new Float32Array(Y*3);i.__normalArray=new Float32Array(Y*3);i.__tangentArray=new Float32Array(Y*
-4);i.__colorArray=new Float32Array(Y*3);i.__uvArray=new Float32Array(Y*2);i.__uv2Array=new Float32Array(Y*2);i.__skinVertexAArray=new Float32Array(Y*4);i.__skinVertexBArray=new Float32Array(Y*4);i.__skinIndexArray=new Float32Array(Y*4);i.__skinWeightArray=new Float32Array(Y*4);i.__faceArray=new Uint16Array(ga*3);i.__lineArray=new Uint16Array(na*2);B=y=i;Y=void 0;ua=void 0;var fa=void 0,ha=void 0;fa=void 0;Z=!1;Y=0;for(ua=t.materials.length;Y<ua;Y++){fa=t.materials[Y];if(fa instanceof THREE.MeshFaceMaterial){fa=
-0;for(ha=B.materials.length;fa<ha;fa++)if(B.materials[fa]&&B.materials[fa].shading!=undefined&&B.materials[fa].shading==THREE.SmoothShading){Z=!0;break}}else if(fa&&fa.shading!=undefined&&fa.shading==THREE.SmoothShading){Z=!0;break}if(Z)break}y.__needsSmoothNormals=Z;i.__webGLFaceCount=ga*3;i.__webGLLineCount=na*2;s.__dirtyVertices=!0;s.__dirtyElements=!0;s.__dirtyUvs=!0;s.__dirtyNormals=!0;s.__dirtyTangents=!0;s.__dirtyColors=!0}if(s.__dirtyVertices||s.__dirtyElements||s.__dirtyUvs||s.__dirtyNormals||
-s.__dirtyColors||s.__dirtyTangents){i=v;ga=d.DYNAMIC_DRAW;na=void 0;y=void 0;var Ia=void 0,C=void 0,Ca=void 0,wa=void 0,za=void 0;Ia=void 0;var G=void 0,L=void 0,P=void 0,ja=void 0;G=void 0;L=void 0;P=void 0;C=void 0;G=void 0;L=void 0;P=void 0;ja=void 0;G=void 0;L=void 0;P=void 0;ja=void 0;G=void 0;L=void 0;P=void 0;ja=void 0;G=void 0;L=void 0;P=void 0;ja=void 0;G=void 0;L=void 0;P=void 0;ja=void 0;C=void 0;wa=void 0;Ca=void 0;za=void 0;var Ea=ha=fa=Z=ua=Y=t=B=0,ra=0,z=0,pa=i.__vertexArray,Ma=i.__uvArray,
-Ka=i.__uv2Array,Ha=i.__normalArray,la=i.__tangentArray,qa=i.__colorArray,ma=i.__skinVertexAArray,ka=i.__skinVertexBArray,oa=i.__skinIndexArray,$=i.__skinWeightArray,xa=i.__faceArray,va=i.__lineArray,Oa=i.__needsSmoothNormals,ya=j.geometry,Na=ya.__dirtyVertices,D=ya.__dirtyElements,ba=ya.__dirtyUvs,X=ya.__dirtyNormals,H=ya.__dirtyTangents,U=ya.__dirtyColors,da=ya.vertices,sa=i.faces,Aa=ya.faces,Da=ya.uvs,La=ya.uvs2,ta=ya.colors,Ga=ya.skinVerticesA,Ja=ya.skinVerticesB,Fa=ya.skinIndices,Ba=ya.skinWeights;
-na=0;for(y=sa.length;na<y;na++){Ia=sa[na];C=Aa[Ia];za=Da[Ia];Ia=La[Ia];Ca=C.vertexNormals;wa=C.normal;if(C instanceof THREE.Face3){if(Na){G=da[C.a].position;L=da[C.b].position;P=da[C.c].position;pa[t]=G.x;pa[t+1]=G.y;pa[t+2]=G.z;pa[t+3]=L.x;pa[t+4]=L.y;pa[t+5]=L.z;pa[t+6]=P.x;pa[t+7]=P.y;pa[t+8]=P.z;t+=9}if(Ba.length){G=Ba[C.a];L=Ba[C.b];P=Ba[C.c];$[z]=G.x;$[z+1]=G.y;$[z+2]=G.z;$[z+3]=G.w;$[z+4]=L.x;$[z+5]=L.y;$[z+6]=L.z;$[z+7]=L.w;$[z+8]=P.x;$[z+9]=P.y;$[z+10]=P.z;$[z+11]=P.w;G=Fa[C.a];L=Fa[C.b];
-P=Fa[C.c];oa[z]=G.x;oa[z+1]=G.y;oa[z+2]=G.z;oa[z+3]=G.w;oa[z+4]=L.x;oa[z+5]=L.y;oa[z+6]=L.z;oa[z+7]=L.w;oa[z+8]=P.x;oa[z+9]=P.y;oa[z+10]=P.z;oa[z+11]=P.w;G=Ga[C.a];L=Ga[C.b];P=Ga[C.c];ma[z]=G.x;ma[z+1]=G.y;ma[z+2]=G.z;ma[z+3]=1;ma[z+4]=L.x;ma[z+5]=L.y;ma[z+6]=L.z;ma[z+7]=1;ma[z+8]=P.x;ma[z+9]=P.y;ma[z+10]=P.z;ma[z+11]=1;G=Ja[C.a];L=Ja[C.b];P=Ja[C.c];ka[z]=G.x;ka[z+1]=G.y;ka[z+2]=G.z;ka[z+3]=1;ka[z+4]=L.x;ka[z+5]=L.y;ka[z+6]=L.z;ka[z+7]=1;ka[z+8]=P.x;ka[z+9]=P.y;ka[z+10]=P.z;ka[z+11]=1;z+=12}if(U&&
-ta.length){G=ta[C.a];L=ta[C.b];P=ta[C.c];qa[ra]=G.r;qa[ra+1]=G.g;qa[ra+2]=G.b;qa[ra+3]=L.r;qa[ra+4]=L.g;qa[ra+5]=L.b;qa[ra+6]=P.r;qa[ra+7]=P.g;qa[ra+8]=P.b;ra+=9}if(H&&ya.hasTangents){G=da[C.a].tangent;L=da[C.b].tangent;P=da[C.c].tangent;la[ha]=G.x;la[ha+1]=G.y;la[ha+2]=G.z;la[ha+3]=G.w;la[ha+4]=L.x;la[ha+5]=L.y;la[ha+6]=L.z;la[ha+7]=L.w;la[ha+8]=P.x;la[ha+9]=P.y;la[ha+10]=P.z;la[ha+11]=P.w;ha+=12}if(X)if(Ca.length==3&&Oa)for(C=0;C<3;C++){wa=Ca[C];Ha[fa]=wa.x;Ha[fa+1]=wa.y;Ha[fa+2]=wa.z;fa+=3}else for(C=
-0;C<3;C++){Ha[fa]=wa.x;Ha[fa+1]=wa.y;Ha[fa+2]=wa.z;fa+=3}if(ba&&za)for(C=0;C<3;C++){Ca=za[C];Ma[Y]=Ca.u;Ma[Y+1]=Ca.v;Y+=2}if(ba&&Ia)for(C=0;C<3;C++){za=Ia[C];Ka[ua]=za.u;Ka[ua+1]=za.v;ua+=2}if(D){xa[Z]=B;xa[Z+1]=B+1;xa[Z+2]=B+2;Z+=3;va[Ea]=B;va[Ea+1]=B+1;va[Ea+2]=B;va[Ea+3]=B+2;va[Ea+4]=B+1;va[Ea+5]=B+2;Ea+=6;B+=3}}else if(C instanceof THREE.Face4){if(Na){G=da[C.a].position;L=da[C.b].position;P=da[C.c].position;ja=da[C.d].position;pa[t]=G.x;pa[t+1]=G.y;pa[t+2]=G.z;pa[t+3]=L.x;pa[t+4]=L.y;pa[t+5]=
-L.z;pa[t+6]=P.x;pa[t+7]=P.y;pa[t+8]=P.z;pa[t+9]=ja.x;pa[t+10]=ja.y;pa[t+11]=ja.z;t+=12}if(Ba.length){G=Ba[C.a];L=Ba[C.b];P=Ba[C.c];ja=Ba[C.d];$[z]=G.x;$[z+1]=G.y;$[z+2]=G.z;$[z+3]=G.w;$[z+4]=L.x;$[z+5]=L.y;$[z+6]=L.z;$[z+7]=L.w;$[z+8]=P.x;$[z+9]=P.y;$[z+10]=P.z;$[z+11]=P.w;$[z+12]=ja.x;$[z+13]=ja.y;$[z+14]=ja.z;$[z+15]=ja.w;G=Fa[C.a];L=Fa[C.b];P=Fa[C.c];ja=Fa[C.d];oa[z]=G.x;oa[z+1]=G.y;oa[z+2]=G.z;oa[z+3]=G.w;oa[z+4]=L.x;oa[z+5]=L.y;oa[z+6]=L.z;oa[z+7]=L.w;oa[z+8]=P.x;oa[z+9]=P.y;oa[z+10]=P.z;oa[z+
-11]=P.w;oa[z+12]=ja.x;oa[z+13]=ja.y;oa[z+14]=ja.z;oa[z+15]=ja.w;G=Ga[C.a];L=Ga[C.b];P=Ga[C.c];ja=Ga[C.d];ma[z]=G.x;ma[z+1]=G.y;ma[z+2]=G.z;ma[z+3]=1;ma[z+4]=L.x;ma[z+5]=L.y;ma[z+6]=L.z;ma[z+7]=1;ma[z+8]=P.x;ma[z+9]=P.y;ma[z+10]=P.z;ma[z+11]=1;ma[z+12]=ja.x;ma[z+13]=ja.y;ma[z+14]=ja.z;ma[z+15]=1;G=Ja[C.a];L=Ja[C.b];P=Ja[C.c];ja=Ja[C.d];ka[z]=G.x;ka[z+1]=G.y;ka[z+2]=G.z;ka[z+3]=1;ka[z+4]=L.x;ka[z+5]=L.y;ka[z+6]=L.z;ka[z+7]=1;ka[z+8]=P.x;ka[z+9]=P.y;ka[z+10]=P.z;ka[z+11]=1;ka[z+12]=ja.x;ka[z+13]=ja.y;
-ka[z+14]=ja.z;ka[z+15]=1;z+=16}if(U&&ta.length){G=ta[C.a];L=ta[C.b];P=ta[C.c];ja=ta[C.d];qa[ra]=G.r;qa[ra+1]=G.g;qa[ra+2]=G.b;qa[ra+3]=L.r;qa[ra+4]=L.g;qa[ra+5]=L.b;qa[ra+6]=P.r;qa[ra+7]=P.g;qa[ra+8]=P.b;qa[ra+9]=ja.r;qa[ra+10]=ja.g;qa[ra+11]=ja.b;ra+=12}if(H&&ya.hasTangents){G=da[C.a].tangent;L=da[C.b].tangent;P=da[C.c].tangent;C=da[C.d].tangent;la[ha]=G.x;la[ha+1]=G.y;la[ha+2]=G.z;la[ha+3]=G.w;la[ha+4]=L.x;la[ha+5]=L.y;la[ha+6]=L.z;la[ha+7]=L.w;la[ha+8]=P.x;la[ha+9]=P.y;la[ha+10]=P.z;la[ha+11]=
-P.w;la[ha+12]=C.x;la[ha+13]=C.y;la[ha+14]=C.z;la[ha+15]=C.w;ha+=16}if(X)if(Ca.length==4&&Oa)for(C=0;C<4;C++){wa=Ca[C];Ha[fa]=wa.x;Ha[fa+1]=wa.y;Ha[fa+2]=wa.z;fa+=3}else for(C=0;C<4;C++){Ha[fa]=wa.x;Ha[fa+1]=wa.y;Ha[fa+2]=wa.z;fa+=3}if(ba&&za)for(C=0;C<4;C++){Ca=za[C];Ma[Y]=Ca.u;Ma[Y+1]=Ca.v;Y+=2}if(ba&&Ia)for(C=0;C<4;C++){za=Ia[C];Ka[ua]=za.u;Ka[ua+1]=za.v;ua+=2}if(D){xa[Z]=B;xa[Z+1]=B+1;xa[Z+2]=B+2;xa[Z+3]=B;xa[Z+4]=B+2;xa[Z+5]=B+3;Z+=6;va[Ea]=B;va[Ea+1]=B+1;va[Ea+2]=B;va[Ea+3]=B+3;va[Ea+4]=B+1;
-va[Ea+5]=B+2;va[Ea+6]=B+2;va[Ea+7]=B+3;Ea+=8;B+=4}}}if(Na){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,pa,ga)}if(U&&ta.length){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,qa,ga)}if(X){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,Ha,ga)}if(H&&ya.hasTangents){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLTangentBuffer);d.bufferData(d.ARRAY_BUFFER,la,ga)}if(ba&&Y>0){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLUVBuffer);
-d.bufferData(d.ARRAY_BUFFER,Ma,ga)}if(ba&&ua>0){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Ka,ga)}if(D){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,i.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,xa,ga);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,i.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,va,ga)}if(z>0){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinVertexABuffer);d.bufferData(d.ARRAY_BUFFER,ma,ga);d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinVertexBBuffer);d.bufferData(d.ARRAY_BUFFER,
-ka,ga);d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinIndicesBuffer);d.bufferData(d.ARRAY_BUFFER,oa,ga);d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinWeightsBuffer);d.bufferData(d.ARRAY_BUFFER,$,ga)}}x(objlist,E,q,v,j)}s.__dirtyVertices=!1;s.__dirtyElements=!1;s.__dirtyUvs=!1;s.__dirtyNormals=!1;s.__dirtyTangents=!1;s.__dirtyColors=!1}else if(j instanceof THREE.Line){if(!s.__webGLVertexBuffer){q=s;q.__webGLVertexBuffer=d.createBuffer();q.__webGLColorBuffer=d.createBuffer();q=s;v=q.vertices.length;q.__vertexArray=
-new Float32Array(v*3);q.__colorArray=new Float32Array(v*3);q.__webGLLineCount=v;s.__dirtyVertices=!0;s.__dirtyColors=!0}if(s.__dirtyVertices||s.__dirtyColors){q=s;v=d.DYNAMIC_DRAW;B=void 0;B=void 0;t=void 0;i=void 0;Y=q.vertices;ga=q.colors;ua=Y.length;na=ga.length;Z=q.__vertexArray;y=q.__colorArray;fa=q.__dirtyColors;if(q.__dirtyVertices){for(B=0;B<ua;B++){t=Y[B].position;i=B*3;Z[i]=t.x;Z[i+1]=t.y;Z[i+2]=t.z}d.bindBuffer(d.ARRAY_BUFFER,q.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,Z,v)}if(fa){for(B=
-0;B<na;B++){color=ga[B];i=B*3;y[i]=color.r;y[i+1]=color.g;y[i+2]=color.b}d.bindBuffer(d.ARRAY_BUFFER,q.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,y,v)}}x(objlist,E,0,s,j);s.__dirtyVertices=!1;s.__dirtyColors=!1}else if(j instanceof THREE.ParticleSystem){if(!s.__webGLVertexBuffer){q=s;q.__webGLVertexBuffer=d.createBuffer();q.__webGLColorBuffer=d.createBuffer();q=s;v=q.vertices.length;q.__vertexArray=new Float32Array(v*3);q.__colorArray=new Float32Array(v*3);q.__sortArray=[];q.__webGLParticleCount=
-v;s.__dirtyVertices=!0;s.__dirtyColors=!0}(s.__dirtyVertices||s.__dirtyColors||j.sortParticles)&&b(s,d.DYNAMIC_DRAW,j,camera);x(objlist,E,0,s,j);s.__dirtyVertices=!1;s.__dirtyColors=!1}else if(j instanceof THREE.MarchingCubes){s=E;if(s[0]==undefined){i.__webGLObjectsImmediate.push({object:j,opaque:{list:[],count:0},transparent:{list:[],count:0}});s[0]=1}}}};this.removeObject=function(f,p){var o,j;for(o=f.__webGLObjects.length-1;o>=0;o--){j=f.__webGLObjects[o].object;p==j&&f.__webGLObjects.splice(o,
-1)}};this.addToRenderList=function(){};this.removeFromRenderList=function(){};this.setDepthTest=function(f){f?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST)};this.setFaceCulling=function(f,p){if(f){!p||p=="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW);if(f=="back")d.cullFace(d.BACK);else f=="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}};
+THREE.Projector=function(){function a(T,N){return N.z-T.z}function b(T,N){var ba=0,R=1,aa=T.z+T.w,V=N.z+N.w,B=-T.z+T.w,I=-N.z+N.w;if(aa>=0&&V>=0&&B>=0&&I>=0)return!0;else if(aa<0&&V<0||B<0&&I<0)return!1;else{if(aa<0)ba=Math.max(ba,aa/(aa-V));else V<0&&(R=Math.min(R,aa/(aa-V)));if(B<0)ba=Math.max(ba,B/(B-I));else I<0&&(R=Math.min(R,B/(B-I)));if(R<ba)return!1;else{T.lerpSelf(N,ba);N.lerpSelf(T,1-R);return!0}}}var c,e,g=[],i,l,o,k=[],m,s,w=[],t,x,F=[],H=new THREE.Vector4,G=new THREE.Vector4,r=new THREE.Matrix4,
+Z=new THREE.Matrix4,D=[],K=new THREE.Vector4,d=new THREE.Vector4,ga;this.projectObjects=function(T,N,ba){N=[];var R,aa,V;e=0;aa=T.objects;T=0;for(R=aa.length;T<R;T++){V=aa[T];var B;if(!(B=!V.visible))if(B=V instanceof THREE.Mesh){a:{B=void 0;for(var I=V.globalMatrix,ka=-V.geometry.boundingSphere.radius*Math.max(V.scale.x,Math.max(V.scale.y,V.scale.z)),P=0;P<6;P++){B=D[P].x*I.n14+D[P].y*I.n24+D[P].z*I.n34+D[P].w;if(B<=ka){B=!1;break a}}B=!0}B=!B}if(!B){c=g[e]=g[e]||new THREE.RenderableObject;H.copy(V.position);
+r.multiplyVector3(H);c.object=V;c.z=H.z;N.push(c);e++}}ba&&N.sort(a);return N};this.projectScene=function(T,N,ba){var R=[],aa=N.near,V=N.far,B,I,ka,P,ja,ca,Q,ra,wa,f,n,p,j,h,q,v;o=s=x=0;N.autoUpdateMatrix&&N.update();r.multiply(N.projectionMatrix,N.globalMatrix);D[0]=new THREE.Vector4(r.n41-r.n11,r.n42-r.n12,r.n43-r.n13,r.n44-r.n14);D[1]=new THREE.Vector4(r.n41+r.n11,r.n42+r.n12,r.n43+r.n13,r.n44+r.n14);D[2]=new THREE.Vector4(r.n41+r.n21,r.n42+r.n22,r.n43+r.n23,r.n44+r.n24);D[3]=new THREE.Vector4(r.n41-
+r.n21,r.n42-r.n22,r.n43-r.n23,r.n44-r.n24);D[4]=new THREE.Vector4(r.n41-r.n31,r.n42-r.n32,r.n43-r.n33,r.n44-r.n34);D[5]=new THREE.Vector4(r.n41+r.n31,r.n42+r.n32,r.n43+r.n33,r.n44+r.n34);B=0;for(ca=D.length;B<ca;B++){Q=D[B];Q.divideScalar(Math.sqrt(Q.x*Q.x+Q.y*Q.y+Q.z*Q.z))}T.update(undefined,!1,N);ca=this.projectObjects(T,N,!0);T=0;for(B=ca.length;T<B;T++){Q=ca[T].object;if(Q.visible){Q.autoUpdateMatrix&&Q.updateMatrix();ra=Q.globalMatrix;ra.extractRotationMatrix(Q.rotationMatrix);n=Q.rotationMatrix;
+wa=Q.materials;f=Q.overdraw;if(Q instanceof THREE.Mesh){p=Q.geometry;j=p.vertices;I=0;for(ka=j.length;I<ka;I++){h=j[I];h.positionWorld.copy(h.position);ra.multiplyVector3(h.positionWorld);P=h.positionScreen;P.copy(h.positionWorld);r.multiplyVector4(P);P.x/=P.w;P.y/=P.w;h.__visible=P.z>aa&&P.z<V}p=p.faces;I=0;for(ka=p.length;I<ka;I++){h=p[I];if(h instanceof THREE.Face3){P=j[h.a];ja=j[h.b];q=j[h.c];if(P.__visible&&ja.__visible&&q.__visible&&(Q.doubleSided||Q.flipSided!=(q.positionScreen.x-P.positionScreen.x)*
+(ja.positionScreen.y-P.positionScreen.y)-(q.positionScreen.y-P.positionScreen.y)*(ja.positionScreen.x-P.positionScreen.x)<0)){i=k[o]=k[o]||new THREE.RenderableFace3;i.v1.positionWorld.copy(P.positionWorld);i.v2.positionWorld.copy(ja.positionWorld);i.v3.positionWorld.copy(q.positionWorld);i.v1.positionScreen.copy(P.positionScreen);i.v2.positionScreen.copy(ja.positionScreen);i.v3.positionScreen.copy(q.positionScreen);i.normalWorld.copy(h.normal);n.multiplyVector3(i.normalWorld);i.centroidWorld.copy(h.centroid);
+ra.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);r.multiplyVector3(i.centroidScreen);q=h.vertexNormals;ga=i.vertexNormalsWorld;P=0;for(ja=q.length;P<ja;P++){v=ga[P]=ga[P]||new THREE.Vector3;v.copy(q[P]);n.multiplyVector3(v)}i.z=i.centroidScreen.z;i.meshMaterials=wa;i.faceMaterials=h.materials;i.overdraw=f;if(Q.geometry.uvs[I]){i.uvs[0]=Q.geometry.uvs[I][0];i.uvs[1]=Q.geometry.uvs[I][1];i.uvs[2]=Q.geometry.uvs[I][2]}R.push(i);o++}}else if(h instanceof THREE.Face4){P=j[h.a];
+ja=j[h.b];q=j[h.c];v=j[h.d];if(P.__visible&&ja.__visible&&q.__visible&&v.__visible&&(Q.doubleSided||Q.flipSided!=((v.positionScreen.x-P.positionScreen.x)*(ja.positionScreen.y-P.positionScreen.y)-(v.positionScreen.y-P.positionScreen.y)*(ja.positionScreen.x-P.positionScreen.x)<0||(ja.positionScreen.x-q.positionScreen.x)*(v.positionScreen.y-q.positionScreen.y)-(ja.positionScreen.y-q.positionScreen.y)*(v.positionScreen.x-q.positionScreen.x)<0))){i=k[o]=k[o]||new THREE.RenderableFace3;i.v1.positionWorld.copy(P.positionWorld);
+i.v2.positionWorld.copy(ja.positionWorld);i.v3.positionWorld.copy(v.positionWorld);i.v1.positionScreen.copy(P.positionScreen);i.v2.positionScreen.copy(ja.positionScreen);i.v3.positionScreen.copy(v.positionScreen);i.normalWorld.copy(h.normal);n.multiplyVector3(i.normalWorld);i.centroidWorld.copy(h.centroid);ra.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);r.multiplyVector3(i.centroidScreen);i.z=i.centroidScreen.z;i.meshMaterials=wa;i.faceMaterials=h.materials;i.overdraw=f;
+if(Q.geometry.uvs[I]){i.uvs[0]=Q.geometry.uvs[I][0];i.uvs[1]=Q.geometry.uvs[I][1];i.uvs[2]=Q.geometry.uvs[I][3]}R.push(i);o++;l=k[o]=k[o]||new THREE.RenderableFace3;l.v1.positionWorld.copy(ja.positionWorld);l.v2.positionWorld.copy(q.positionWorld);l.v3.positionWorld.copy(v.positionWorld);l.v1.positionScreen.copy(ja.positionScreen);l.v2.positionScreen.copy(q.positionScreen);l.v3.positionScreen.copy(v.positionScreen);l.normalWorld.copy(i.normalWorld);l.centroidWorld.copy(i.centroidWorld);l.centroidScreen.copy(i.centroidScreen);
+l.z=l.centroidScreen.z;l.meshMaterials=wa;l.faceMaterials=h.materials;l.overdraw=f;if(Q.geometry.uvs[I]){l.uvs[0]=Q.geometry.uvs[I][1];l.uvs[1]=Q.geometry.uvs[I][2];l.uvs[2]=Q.geometry.uvs[I][3]}R.push(l);o++}}}}else if(Q instanceof THREE.Line){Z.multiply(r,ra);j=Q.geometry.vertices;h=j[0];h.positionScreen.copy(h.position);Z.multiplyVector4(h.positionScreen);I=1;for(ka=j.length;I<ka;I++){P=j[I];P.positionScreen.copy(P.position);Z.multiplyVector4(P.positionScreen);ja=j[I-1];K.copy(P.positionScreen);
+d.copy(ja.positionScreen);if(b(K,d)){K.multiplyScalar(1/K.w);d.multiplyScalar(1/d.w);m=w[s]=w[s]||new THREE.RenderableLine;m.v1.positionScreen.copy(K);m.v2.positionScreen.copy(d);m.z=Math.max(K.z,d.z);m.materials=Q.materials;R.push(m);s++}}}else if(Q instanceof THREE.Particle){G.set(Q.position.x,Q.position.y,Q.position.z,1);r.multiplyVector4(G);G.z/=G.w;if(G.z>0&&G.z<1){t=F[x]=F[x]||new THREE.RenderableParticle;t.x=G.x/G.w;t.y=G.y/G.w;t.z=G.z;t.rotation=Q.rotation.z;t.scale.x=Q.scale.x*Math.abs(t.x-
+(G.x+N.projectionMatrix.n11)/(G.w+N.projectionMatrix.n14));t.scale.y=Q.scale.y*Math.abs(t.y-(G.y+N.projectionMatrix.n22)/(G.w+N.projectionMatrix.n24));t.materials=Q.materials;R.push(t);x++}}}}ba&&R.sort(a);return R};this.unprojectVector=function(T,N){var ba=THREE.Matrix4.makeInvert(N.globalMatrix);ba.multiplySelf(THREE.Matrix4.makeInvert(N.projectionMatrix));ba.multiplyVector3(T);return T}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,g,i;this.domElement=document.createElement("div");this.setSize=function(l,o){c=l;e=o;g=c/2;i=e/2};this.render=function(l,o){var k,m,s,w,t,x,F,H;a=b.projectScene(l,o);k=0;for(m=a.length;k<m;k++){t=a[k];if(t instanceof THREE.RenderableParticle){F=t.x*g+g;H=t.y*i+i;s=0;for(w=t.material.length;s<w;s++){x=t.material[s];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=F+"px";x.style.top=H+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(na){if(t!=na)m.globalAlpha=t=na}function b(na){if(x!=na){switch(na){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}x=na}}var c=null,e=new THREE.Projector,g=document.createElement("canvas"),i,l,o,k,m=g.getContext("2d"),s=new THREE.Color(0),w=0,t=1,x=0,F=null,H=null,G=1,r,Z,D,K,d,ga,T,N,ba,R=new THREE.Color,
+aa=new THREE.Color,V=new THREE.Color,B=new THREE.Color,I=new THREE.Color,ka,P,ja,ca,Q,ra,wa,f,n,p=new THREE.Rectangle,j=new THREE.Rectangle,h=new THREE.Rectangle,q=!1,v=new THREE.Color,C=new THREE.Color,W=new THREE.Color,L=new THREE.Color,S=Math.PI*2,E=new THREE.Vector3,da,ea,va,la,ha,ia,fa=16;da=document.createElement("canvas");da.width=da.height=2;ea=da.getContext("2d");ea.fillStyle="rgba(0,0,0,1)";ea.fillRect(0,0,2,2);va=ea.getImageData(0,0,2,2);la=va.data;ha=document.createElement("canvas");ha.width=
+ha.height=fa;ia=ha.getContext("2d");ia.translate(-fa/2,-fa/2);ia.scale(fa,fa);fa--;this.domElement=g;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(na,z){i=na;l=z;o=i/2;k=l/2;g.width=i;g.height=l;p.set(-o,-k,o,k);t=1;x=0;H=F=null;G=1};this.setClearColor=function(na,z){s=na;w=z;j.set(-o,-k,o,k);m.setTransform(1,0,0,-1,o,k);this.clear()};this.setClearColorHex=function(na,z){s.setHex(na);w=z;j.set(-o,-k,o,k);m.setTransform(1,0,0,-1,o,k);this.clear()};this.clear=function(){m.setTransform(1,
+0,0,-1,o,k);if(!j.isEmpty()){j.inflate(1);j.minSelf(p);if(s.hex==0&&w==0)m.clearRect(j.getX(),j.getY(),j.getWidth(),j.getHeight());else{b(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(s.r*255)+","+Math.floor(s.g*255)+","+Math.floor(s.b*255)+","+w+")";m.fillRect(j.getX(),j.getY(),j.getWidth(),j.getHeight())}j.empty()}};this.render=function(na,z){function Fa(y){var X,Y,A,U=y.lights;C.setRGB(0,0,0);W.setRGB(0,0,0);L.setRGB(0,0,0);y=0;for(X=U.length;y<X;y++){Y=U[y];A=Y.color;if(Y instanceof
+THREE.AmbientLight){C.r+=A.r;C.g+=A.g;C.b+=A.b}else if(Y instanceof THREE.DirectionalLight){W.r+=A.r;W.g+=A.g;W.b+=A.b}else if(Y instanceof THREE.PointLight){L.r+=A.r;L.g+=A.g;L.b+=A.b}}}function za(y,X,Y,A){var U,ma,xa,Da,Ea=y.lights;y=0;for(U=Ea.length;y<U;y++){ma=Ea[y];xa=ma.color;Da=ma.intensity;if(ma instanceof THREE.DirectionalLight){ma=Y.dot(ma.position)*Da;if(ma>0){A.r+=xa.r*ma;A.g+=xa.g*ma;A.b+=xa.b*ma}}else if(ma instanceof THREE.PointLight){E.sub(ma.position,X);E.normalize();ma=Y.dot(E)*
+Da;if(ma>0){A.r+=xa.r*ma;A.g+=xa.g*ma;A.b+=xa.b*ma}}}}function Ga(y,X,Y){if(Y.opacity!=0){a(Y.opacity);b(Y.blending);var A,U,ma,xa,Da,Ea;if(Y instanceof THREE.ParticleBasicMaterial){if(Y.map&&Y.map.image.loaded){xa=Y.map.image;Da=xa.width>>1;Ea=xa.height>>1;U=X.scale.x*o;ma=X.scale.y*k;Y=U*Da;A=ma*Ea;h.set(y.x-Y,y.y-A,y.x+Y,y.y+A);if(!p.instersects(h))return;m.save();m.translate(y.x,y.y);m.rotate(-X.rotation);m.scale(U,-ma);m.translate(-Da,-Ea);m.drawImage(xa,0,0);m.restore()}m.beginPath();m.moveTo(y.x-
+10,y.y);m.lineTo(y.x+10,y.y);m.moveTo(y.x,y.y-10);m.lineTo(y.x,y.y+10);m.closePath();m.strokeStyle="rgb(255,255,0)";m.stroke()}else if(Y instanceof THREE.ParticleCircleMaterial){if(q){v.r=C.r+W.r+L.r;v.g=C.g+W.g+L.g;v.b=C.b+W.b+L.b;R.r=Y.color.r*v.r;R.g=Y.color.g*v.g;R.b=Y.color.b*v.b;R.updateStyleString()}else R.__styleString=Y.color.__styleString;Y=X.scale.x*o;A=X.scale.y*k;h.set(y.x-Y,y.y-A,y.x+Y,y.y+A);if(p.instersects(h)){U=R.__styleString;if(H!=U)m.fillStyle=H=U;m.save();m.translate(y.x,y.y);
+m.rotate(-X.rotation);m.scale(Y,A);m.beginPath();m.arc(0,0,1,0,S,!0);m.closePath();m.fill();m.restore()}}}}function O(y,X,Y,A){if(A.opacity!=0){a(A.opacity);b(A.blending);m.beginPath();m.moveTo(y.positionScreen.x,y.positionScreen.y);m.lineTo(X.positionScreen.x,X.positionScreen.y);m.closePath();if(A instanceof THREE.LineBasicMaterial){R.__styleString=A.color.__styleString;y=A.linewidth;if(G!=y)m.lineWidth=G=y;y=R.__styleString;if(F!=y)m.strokeStyle=F=y;m.stroke();h.inflate(A.linewidth*2)}}}function M(y,
+X,Y,A,U,ma){if(U.opacity!=0){a(U.opacity);b(U.blending);K=y.positionScreen.x;d=y.positionScreen.y;ga=X.positionScreen.x;T=X.positionScreen.y;N=Y.positionScreen.x;ba=Y.positionScreen.y;m.beginPath();m.moveTo(K,d);m.lineTo(ga,T);m.lineTo(N,ba);m.lineTo(K,d);m.closePath();if(U instanceof THREE.MeshBasicMaterial)if(U.map)U.map.image.loaded&&U.map.mapping instanceof THREE.UVMapping&&Ca(K,d,ga,T,N,ba,U.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);else if(U.env_map){if(U.env_map.image.loaded&&
+U.env_map.mapping instanceof THREE.SphericalReflectionMapping){y=z.globalMatrix;E.copy(A.vertexNormalsWorld[0]);ca=(E.x*y.n11+E.y*y.n12+E.z*y.n13)*0.5+0.5;Q=-(E.x*y.n21+E.y*y.n22+E.z*y.n23)*0.5+0.5;E.copy(A.vertexNormalsWorld[1]);ra=(E.x*y.n11+E.y*y.n12+E.z*y.n13)*0.5+0.5;wa=-(E.x*y.n21+E.y*y.n22+E.z*y.n23)*0.5+0.5;E.copy(A.vertexNormalsWorld[2]);f=(E.x*y.n11+E.y*y.n12+E.z*y.n13)*0.5+0.5;n=-(E.x*y.n21+E.y*y.n22+E.z*y.n23)*0.5+0.5;Ca(K,d,ga,T,N,ba,U.env_map.image,ca,Q,ra,wa,f,n)}}else U.wireframe?
+J(U.color.__styleString,U.wireframe_linewidth):oa(U.color.__styleString);else if(U instanceof THREE.MeshLambertMaterial){if(U.map&&!U.wireframe){U.map.mapping instanceof THREE.UVMapping&&Ca(K,d,ga,T,N,ba,U.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);b(THREE.SubtractiveBlending)}if(q)if(!U.wireframe&&U.shading==THREE.SmoothShading&&A.vertexNormalsWorld.length==3){aa.r=V.r=B.r=C.r;aa.g=V.g=B.g=C.g;aa.b=V.b=B.b=C.b;za(ma,A.v1.positionWorld,A.vertexNormalsWorld[0],aa);
+za(ma,A.v2.positionWorld,A.vertexNormalsWorld[1],V);za(ma,A.v3.positionWorld,A.vertexNormalsWorld[2],B);I.r=(V.r+B.r)*0.5;I.g=(V.g+B.g)*0.5;I.b=(V.b+B.b)*0.5;ja=Aa(aa,V,B,I);Ca(K,d,ga,T,N,ba,ja,0,0,1,0,0,1)}else{v.r=C.r;v.g=C.g;v.b=C.b;za(ma,A.centroidWorld,A.normalWorld,v);R.r=U.color.r*v.r;R.g=U.color.g*v.g;R.b=U.color.b*v.b;R.updateStyleString();U.wireframe?J(R.__styleString,U.wireframe_linewidth):oa(R.__styleString)}else U.wireframe?J(U.color.__styleString,U.wireframe_linewidth):oa(U.color.__styleString)}else if(U instanceof
+THREE.MeshDepthMaterial){ka=z.near;P=z.far;aa.r=aa.g=aa.b=1-u(y.positionScreen.z,ka,P);V.r=V.g=V.b=1-u(X.positionScreen.z,ka,P);B.r=B.g=B.b=1-u(Y.positionScreen.z,ka,P);I.r=(V.r+B.r)*0.5;I.g=(V.g+B.g)*0.5;I.b=(V.b+B.b)*0.5;ja=Aa(aa,V,B,I);Ca(K,d,ga,T,N,ba,ja,0,0,1,0,0,1)}else if(U instanceof THREE.MeshNormalMaterial){R.r=Ba(A.normalWorld.x);R.g=Ba(A.normalWorld.y);R.b=Ba(A.normalWorld.z);R.updateStyleString();U.wireframe?J(R.__styleString,U.wireframe_linewidth):oa(R.__styleString)}}}function J(y,
+X){if(F!=y)m.strokeStyle=F=y;if(G!=X)m.lineWidth=G=X;m.stroke();h.inflate(X*2)}function oa(y){if(H!=y)m.fillStyle=H=y;m.fill()}function Ca(y,X,Y,A,U,ma,xa,Da,Ea,Ia,ya,Ja,Qa){var Ka,La;Ka=xa.width-1;La=xa.height-1;Da*=Ka;Ea*=La;Ia*=Ka;ya*=La;Ja*=Ka;Qa*=La;Y-=y;A-=X;U-=y;ma-=X;Ia-=Da;ya-=Ea;Ja-=Da;Qa-=Ea;Ka=Ia*Qa-Ja*ya;if(Ka!=0){La=1/Ka;Ka=(Qa*Y-ya*U)*La;ya=(Qa*A-ya*ma)*La;Y=(Ia*U-Ja*Y)*La;A=(Ia*ma-Ja*A)*La;y=y-Ka*Da-Y*Ea;X=X-ya*Da-A*Ea;m.save();m.transform(Ka,ya,Y,A,y,X);m.clip();m.drawImage(xa,0,
+0);m.restore()}}function Aa(y,X,Y,A){var U=~~(y.r*255),ma=~~(y.g*255);y=~~(y.b*255);var xa=~~(X.r*255),Da=~~(X.g*255);X=~~(X.b*255);var Ea=~~(Y.r*255),Ia=~~(Y.g*255);Y=~~(Y.b*255);var ya=~~(A.r*255),Ja=~~(A.g*255);A=~~(A.b*255);la[0]=U<0?0:U>255?255:U;la[1]=ma<0?0:ma>255?255:ma;la[2]=y<0?0:y>255?255:y;la[4]=xa<0?0:xa>255?255:xa;la[5]=Da<0?0:Da>255?255:Da;la[6]=X<0?0:X>255?255:X;la[8]=Ea<0?0:Ea>255?255:Ea;la[9]=Ia<0?0:Ia>255?255:Ia;la[10]=Y<0?0:Y>255?255:Y;la[12]=ya<0?0:ya>255?255:ya;la[13]=Ja<0?0:
+Ja>255?255:Ja;la[14]=A<0?0:A>255?255:A;ea.putImageData(va,0,0);ia.drawImage(da,0,0);return ha}function u(y,X,Y){y=(y-X)/(Y-X);return y*y*(3-2*y)}function Ba(y){y=(y+1)*0.5;return y<0?0:y>1?1:y}function Oa(y,X){var Y=X.x-y.x,A=X.y-y.y,U=1/Math.sqrt(Y*Y+A*A);Y*=U;A*=U;X.x+=Y;X.y+=A;y.x-=Y;y.y-=A}var Ma,Ha,$,sa,pa,ta,ua,qa;this.autoClear?this.clear():m.setTransform(1,0,0,-1,o,k);c=e.projectScene(na,z,this.sortElements);m.fillStyle="rgba( 0, 255, 255, 0.5 )";m.fillRect(p.getX(),p.getY(),p.getWidth(),
+p.getHeight());(q=na.lights.length>0)&&Fa(na);Ma=0;for(Ha=c.length;Ma<Ha;Ma++){$=c[Ma];h.empty();if($ instanceof THREE.RenderableParticle){r=$;r.x*=o;r.y*=k;sa=0;for(pa=$.materials.length;sa<pa;sa++)Ga(r,$,$.materials[sa],na)}else if($ instanceof THREE.RenderableLine){r=$.v1;Z=$.v2;r.positionScreen.x*=o;r.positionScreen.y*=k;Z.positionScreen.x*=o;Z.positionScreen.y*=k;h.addPoint(r.positionScreen.x,r.positionScreen.y);h.addPoint(Z.positionScreen.x,Z.positionScreen.y);if(p.instersects(h)){sa=0;for(pa=
+$.materials.length;sa<pa;)O(r,Z,$,$.materials[sa++],na)}}else if($ instanceof THREE.RenderableFace3){r=$.v1;Z=$.v2;D=$.v3;r.positionScreen.x*=o;r.positionScreen.y*=k;Z.positionScreen.x*=o;Z.positionScreen.y*=k;D.positionScreen.x*=o;D.positionScreen.y*=k;if($.overdraw){Oa(r.positionScreen,Z.positionScreen);Oa(Z.positionScreen,D.positionScreen);Oa(D.positionScreen,r.positionScreen)}h.add3Points(r.positionScreen.x,r.positionScreen.y,Z.positionScreen.x,Z.positionScreen.y,D.positionScreen.x,D.positionScreen.y);
+if(p.instersects(h)){sa=0;for(pa=$.meshMaterials.length;sa<pa;){qa=$.meshMaterials[sa++];if(qa instanceof THREE.MeshFaceMaterial){ta=0;for(ua=$.faceMaterials.length;ta<ua;)(qa=$.faceMaterials[ta++])&&M(r,Z,D,$,qa,na)}else M(r,Z,D,$,qa,na)}}}j.addRectangle(h)}m.lineWidth=1;m.strokeStyle="rgba( 255, 0, 0, 0.5 )";m.strokeRect(j.getX(),j.getY(),j.getWidth(),j.getHeight());m.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(ca,Q,ra){var wa,f,n,p;wa=0;for(f=ca.lights.length;wa<f;wa++){n=ca.lights[wa];if(n instanceof THREE.DirectionalLight){p=Q.normalWorld.dot(n.position)*n.intensity;if(p>0){ra.r+=n.color.r*p;ra.g+=n.color.g*p;ra.b+=n.color.b*p}}else if(n instanceof THREE.PointLight){ba.sub(n.position,Q.centroidWorld);ba.normalize();p=Q.normalWorld.dot(ba)*n.intensity;if(p>0){ra.r+=n.color.r*p;ra.g+=n.color.g*p;ra.b+=n.color.b*p}}}}function b(ca,Q,ra,wa,f,n){B=e(I++);B.setAttribute("d",
+"M "+ca.positionScreen.x+" "+ca.positionScreen.y+" L "+Q.positionScreen.x+" "+Q.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+"z");if(f instanceof THREE.MeshBasicMaterial)D.__styleString=f.color.__styleString;else if(f instanceof THREE.MeshLambertMaterial)if(Z){K.r=d.r;K.g=d.g;K.b=d.b;a(n,wa,K);D.r=f.color.r*K.r;D.g=f.color.g*K.g;D.b=f.color.b*K.b;D.updateStyleString()}else D.__styleString=f.color.__styleString;else if(f instanceof THREE.MeshDepthMaterial){N=1-f.__2near/(f.__farPlusNear-
+wa.z*f.__farMinusNear);D.setRGB(N,N,N)}else f instanceof THREE.MeshNormalMaterial&&D.setRGB(g(wa.normalWorld.x),g(wa.normalWorld.y),g(wa.normalWorld.z));f.wireframe?B.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+f.wireframe_linewidth+"; stroke-opacity: "+f.opacity+"; stroke-linecap: "+f.wireframe_linecap+"; stroke-linejoin: "+f.wireframe_linejoin):B.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+f.opacity);o.appendChild(B)}function c(ca,Q,ra,wa,
+f,n,p){B=e(I++);B.setAttribute("d","M "+ca.positionScreen.x+" "+ca.positionScreen.y+" L "+Q.positionScreen.x+" "+Q.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+" L "+wa.positionScreen.x+","+wa.positionScreen.y+"z");if(n instanceof THREE.MeshBasicMaterial)D.__styleString=n.color.__styleString;else if(n instanceof THREE.MeshLambertMaterial)if(Z){K.r=d.r;K.g=d.g;K.b=d.b;a(p,f,K);D.r=n.color.r*K.r;D.g=n.color.g*K.g;D.b=n.color.b*K.b;D.updateStyleString()}else D.__styleString=n.color.__styleString;
+else if(n instanceof THREE.MeshDepthMaterial){N=1-n.__2near/(n.__farPlusNear-f.z*n.__farMinusNear);D.setRGB(N,N,N)}else n instanceof THREE.MeshNormalMaterial&&D.setRGB(g(f.normalWorld.x),g(f.normalWorld.y),g(f.normalWorld.z));n.wireframe?B.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+n.wireframe_linewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframe_linecap+"; stroke-linejoin: "+n.wireframe_linejoin):B.setAttribute("style","fill: "+D.__styleString+
+"; fill-opacity: "+n.opacity);o.appendChild(B)}function e(ca){if(R[ca]==null){R[ca]=document.createElementNS("http://www.w3.org/2000/svg","path");ja==0&&R[ca].setAttribute("shape-rendering","crispEdges")}return R[ca]}function g(ca){return ca<0?Math.min((1+ca)*0.5,0.5):0.5+Math.min(ca*0.5,0.5)}var i=null,l=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,m,s,w,t,x,F,H,G=new THREE.Rectangle,r=new THREE.Rectangle,Z=!1,D=new THREE.Color(16777215),K=new THREE.Color(16777215),
+d=new THREE.Color(0),ga=new THREE.Color(0),T=new THREE.Color(0),N,ba=new THREE.Vector3,R=[],aa=[],V=[],B,I,ka,P,ja=1;this.domElement=o;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ca){switch(ca){case "high":ja=1;break;case "low":ja=0}};this.setSize=function(ca,Q){k=ca;m=Q;s=k/2;w=m/2;o.setAttribute("viewBox",-s+" "+-w+" "+k+" "+m);o.setAttribute("width",k);o.setAttribute("height",m);G.set(-s,-w,s,w)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};
+this.render=function(ca,Q){var ra,wa,f,n,p,j,h,q;this.autoClear&&this.clear();i=l.projectScene(ca,Q,this.sortElements);P=ka=I=0;if(Z=ca.lights.length>0){h=ca.lights;d.setRGB(0,0,0);ga.setRGB(0,0,0);T.setRGB(0,0,0);ra=0;for(wa=h.length;ra<wa;ra++){f=h[ra];n=f.color;if(f instanceof THREE.AmbientLight){d.r+=n.r;d.g+=n.g;d.b+=n.b}else if(f instanceof THREE.DirectionalLight){ga.r+=n.r;ga.g+=n.g;ga.b+=n.b}else if(f instanceof THREE.PointLight){T.r+=n.r;T.g+=n.g;T.b+=n.b}}}ra=0;for(wa=i.length;ra<wa;ra++){h=
+i[ra];r.empty();if(h instanceof THREE.RenderableParticle){t=h;t.x*=s;t.y*=-w;f=0;for(n=h.materials.length;f<n;f++)if(q=h.materials[f]){p=t;j=h;var v=ka++;if(aa[v]==null){aa[v]=document.createElementNS("http://www.w3.org/2000/svg","circle");ja==0&&aa[v].setAttribute("shape-rendering","crispEdges")}B=aa[v];B.setAttribute("cx",p.x);B.setAttribute("cy",p.y);B.setAttribute("r",j.scale.x*s);if(q instanceof THREE.ParticleCircleMaterial){if(Z){K.r=d.r+ga.r+T.r;K.g=d.g+ga.g+T.g;K.b=d.b+ga.b+T.b;D.r=q.color.r*
+K.r;D.g=q.color.g*K.g;D.b=q.color.b*K.b;D.updateStyleString()}else D=q.color;B.setAttribute("style","fill: "+D.__styleString)}o.appendChild(B)}}else if(h instanceof THREE.RenderableLine){t=h.v1;x=h.v2;t.positionScreen.x*=s;t.positionScreen.y*=-w;x.positionScreen.x*=s;x.positionScreen.y*=-w;r.addPoint(t.positionScreen.x,t.positionScreen.y);r.addPoint(x.positionScreen.x,x.positionScreen.y);if(G.instersects(r)){f=0;for(n=h.materials.length;f<n;)if(q=h.materials[f++]){p=t;j=x;v=P++;if(V[v]==null){V[v]=
+document.createElementNS("http://www.w3.org/2000/svg","line");ja==0&&V[v].setAttribute("shape-rendering","crispEdges")}B=V[v];B.setAttribute("x1",p.positionScreen.x);B.setAttribute("y1",p.positionScreen.y);B.setAttribute("x2",j.positionScreen.x);B.setAttribute("y2",j.positionScreen.y);if(q instanceof THREE.LineBasicMaterial){D.__styleString=q.color.__styleString;B.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+q.linewidth+"; stroke-opacity: "+q.opacity+"; stroke-linecap: "+
+q.linecap+"; stroke-linejoin: "+q.linejoin);o.appendChild(B)}}}}else if(h instanceof THREE.RenderableFace3){t=h.v1;x=h.v2;F=h.v3;t.positionScreen.x*=s;t.positionScreen.y*=-w;x.positionScreen.x*=s;x.positionScreen.y*=-w;F.positionScreen.x*=s;F.positionScreen.y*=-w;r.addPoint(t.positionScreen.x,t.positionScreen.y);r.addPoint(x.positionScreen.x,x.positionScreen.y);r.addPoint(F.positionScreen.x,F.positionScreen.y);if(G.instersects(r)){f=0;for(n=h.meshMaterials.length;f<n;){q=h.meshMaterials[f++];if(q instanceof
+THREE.MeshFaceMaterial){p=0;for(j=h.faceMaterials.length;p<j;)(q=h.faceMaterials[p++])&&b(t,x,F,h,q,ca)}else q&&b(t,x,F,h,q,ca)}}}else if(h instanceof THREE.RenderableFace4){t=h.v1;x=h.v2;F=h.v3;H=h.v4;t.positionScreen.x*=s;t.positionScreen.y*=-w;x.positionScreen.x*=s;x.positionScreen.y*=-w;F.positionScreen.x*=s;F.positionScreen.y*=-w;H.positionScreen.x*=s;H.positionScreen.y*=-w;r.addPoint(t.positionScreen.x,t.positionScreen.y);r.addPoint(x.positionScreen.x,x.positionScreen.y);r.addPoint(F.positionScreen.x,
+F.positionScreen.y);r.addPoint(H.positionScreen.x,H.positionScreen.y);if(G.instersects(r)){f=0;for(n=h.meshMaterials.length;f<n;){q=h.meshMaterials[f++];if(q instanceof THREE.MeshFaceMaterial){p=0;for(j=h.faceMaterials.length;p<j;)(q=h.faceMaterials[p++])&&c(t,x,F,H,h,q,ca)}else q&&c(t,x,F,H,h,q,ca)}}}}}};
+THREE.WebGLRenderer=function(a){function b(f,n,p){var j,h,q,v=f.vertices,C=v.length,W=f.colors,L=W.length,S=f.__vertexArray,E=f.__colorArray,da=f.__sortArray,ea=f.__dirtyVertices,va=f.__dirtyColors;if(p.sortParticles){I.multiplySelf(p.globalMatrix);for(j=0;j<C;j++){h=v[j].position;ca.copy(h);I.multiplyVector3(ca);da[j]=[ca.z,j]}da.sort(function(la,ha){return ha[0]-la[0]});for(j=0;j<C;j++){h=v[da[j][1]].position;q=j*3;S[q]=h.x;S[q+1]=h.y;S[q+2]=h.z}for(j=0;j<L;j++){q=j*3;color=W[da[j][1]];E[q]=color.r;
+E[q+1]=color.g;E[q+2]=color.b}}else{if(ea)for(j=0;j<C;j++){h=v[j].position;q=j*3;S[q]=h.x;S[q+1]=h.y;S[q+2]=h.z}if(va)for(j=0;j<L;j++){color=W[j];q=j*3;E[q]=color.r;E[q+1]=color.g;E[q+2]=color.b}}if(ea||p.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,S,n)}if(va||p.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,E,n)}}function c(f,n){f.fragment_shader=n.fragment_shader;f.vertex_shader=n.vertex_shader;f.uniforms=
+Uniforms.clone(n.uniforms)}function e(f,n,p,j,h){j.program||N.initMaterial(j,n,p);var q=j.program,v=q.uniforms,C=j.uniforms;if(q!=ga){d.useProgram(q);ga=q;d.uniformMatrix4fv(v.projectionMatrix,!1,ka)}if(p&&(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial||j instanceof THREE.LineBasicMaterial||j instanceof THREE.ParticleBasicMaterial)){C.fogColor.value.setHex(p.color.hex);if(p instanceof THREE.Fog){C.fogNear.value=p.near;C.fogFar.value=
+p.far}else if(p instanceof THREE.FogExp2)C.fogDensity.value=p.density}if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){var W,L,S=0,E=0,da=0,ea,va,la,ha=N.lights,ia=ha.directional.colors,fa=ha.directional.positions,na=ha.point.colors,z=ha.point.positions,Fa=0,za=0;p=L=L=0;for(W=n.length;p<W;p++){L=n[p];ea=L.color;va=L.position;la=L.intensity;if(L instanceof THREE.AmbientLight){S+=ea.r;E+=ea.g;da+=ea.b}else if(L instanceof THREE.DirectionalLight){L=Fa*3;ia[L]=ea.r*la;
+ia[L+1]=ea.g*la;ia[L+2]=ea.b*la;fa[L]=va.x;fa[L+1]=va.y;fa[L+2]=va.z;Fa+=1}else if(L instanceof THREE.PointLight){L=za*3;na[L]=ea.r*la;na[L+1]=ea.g*la;na[L+2]=ea.b*la;z[L]=va.x;z[L+1]=va.y;z[L+2]=va.z;za+=1}}for(p=Fa*3;p<ia.length;p++)ia[p]=0;for(p=za*3;p<na.length;p++)na[p]=0;ha.point.length=za;ha.directional.length=Fa;ha.ambient[0]=S;ha.ambient[1]=E;ha.ambient[2]=da;n=N.lights;C.enableLighting.value=n.directional.length+n.point.length;C.ambientLightColor.value=n.ambient;C.directionalLightColor.value=
+n.directional.colors;C.directionalLightDirection.value=n.directional.positions;C.pointLightColor.value=n.point.colors;C.pointLightPosition.value=n.point.positions}if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial){C.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);C.opacity.value=j.opacity;C.map.texture=j.map;C.light_map.texture=j.light_map;C.env_map.texture=j.env_map;C.reflectivity.value=j.reflectivity;
+C.refraction_ratio.value=j.refraction_ratio;C.combine.value=j.combine;C.useRefract.value=j.env_map&&j.env_map.mapping instanceof THREE.CubeRefractionMapping}if(j instanceof THREE.LineBasicMaterial){C.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);C.opacity.value=j.opacity}else if(j instanceof THREE.ParticleBasicMaterial){C.psColor.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);C.opacity.value=j.opacity;C.size.value=j.size;C.map.texture=
+j.map}else if(j instanceof THREE.MeshPhongMaterial){C.ambient.value.setRGB(j.ambient.r,j.ambient.g,j.ambient.b);C.specular.value.setRGB(j.specular.r,j.specular.g,j.specular.b);C.shininess.value=j.shininess}else if(j instanceof THREE.MeshDepthMaterial){C.mNear.value=f.near;C.mFar.value=f.far;C.opacity.value=j.opacity}else if(j instanceof THREE.MeshNormalMaterial)C.opacity.value=j.opacity;for(var Ga in C)if(S=q.uniforms[Ga]){p=C[Ga];W=p.type;n=p.value;if(W=="i")d.uniform1i(S,n);else if(W=="f")d.uniform1f(S,
+n);else if(W=="fv1")d.uniform1fv(S,n);else if(W=="fv")d.uniform3fv(S,n);else if(W=="v2")d.uniform2f(S,n.x,n.y);else if(W=="v3")d.uniform3f(S,n.x,n.y,n.z);else if(W=="c")d.uniform3f(S,n.r,n.g,n.b);else if(W=="t"){d.uniform1i(S,n);if(p=p.texture)if(p.image instanceof Array&&p.image.length==6){if(p.image.length==6){if(!p.image.__webGLTextureCube&&!p.image.__cubeMapInitialized&&p.image.loadCount==6){p.image.__webGLTextureCube=d.createTexture();d.bindTexture(d.TEXTURE_CUBE_MAP,p.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(W=0;W<6;++W)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,p.image[W]);d.generateMipmap(d.TEXTURE_CUBE_MAP);d.bindTexture(d.TEXTURE_CUBE_MAP,null);p.image.__cubeMapInitialized=!0}d.activeTexture(d.TEXTURE0+
+n);d.bindTexture(d.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube)}}else{if(!p.__webGLTexture&&p.image.loaded){p.__webGLTexture=d.createTexture();d.bindTexture(d.TEXTURE_2D,p.__webGLTexture);d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,p.image);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,D(p.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,D(p.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,D(p.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,D(p.min_filter));
+d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}d.activeTexture(d.TEXTURE0+n);d.bindTexture(d.TEXTURE_2D,p.__webGLTexture)}}}d.uniformMatrix4fv(v.modelViewMatrix,!1,h._modelViewMatrixArray);d.uniformMatrix3fv(v.normalMatrix,!1,h._normalMatrixArray);(j instanceof THREE.MeshShaderMaterial||j instanceof THREE.MeshPhongMaterial||j.env_map)&&d.uniform3f(v.cameraPosition,f.position.x,f.position.y,f.position.z);(j instanceof THREE.MeshShaderMaterial||j.env_map||j.skinning)&&d.uniformMatrix4fv(v.objectMatrix,
+!1,h._objectMatrixArray);(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshShaderMaterial||j.skinning)&&d.uniformMatrix4fv(v.viewMatrix,!1,ja);if(j.skinning){d.uniformMatrix4fv(v.cameraInverseMatrix,!1,P);d.uniformMatrix4fv(v.uBoneGlobalMatrices,!1,h.boneMatrices)}return q}function g(f,n,p,j,h,q){f=e(f,n,p,j,q).attributes;d.bindBuffer(d.ARRAY_BUFFER,h.__webGLVertexBuffer);d.vertexAttribPointer(f.position,3,d.FLOAT,!1,0,0);if(f.color>=0){d.bindBuffer(d.ARRAY_BUFFER,
+h.__webGLColorBuffer);d.vertexAttribPointer(f.color,3,d.FLOAT,!1,0,0)}if(f.normal>=0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLNormalBuffer);d.vertexAttribPointer(f.normal,3,d.FLOAT,!1,0,0)}if(f.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLTangentBuffer);d.vertexAttribPointer(f.tangent,4,d.FLOAT,!1,0,0)}if(f.uv>=0)if(h.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLUVBuffer);d.vertexAttribPointer(f.uv,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.uv)}else d.disableVertexAttribArray(f.uv);if(f.uv2>=
+0)if(h.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLUV2Buffer);d.vertexAttribPointer(f.uv2,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.uv2)}else d.disableVertexAttribArray(f.uv2);if(j.skinning&&f.skinVertexA>=0&&f.skinVertexB>=0&&f.skinIndex>=0&&f.skinWeight>=0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinVertexABuffer);d.vertexAttribPointer(f.skinVertexA,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinVertexBBuffer);d.vertexAttribPointer(f.skinVertexB,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,
+h.__webGLSkinIndicesBuffer);d.vertexAttribPointer(f.skinIndex,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinWeightsBuffer);d.vertexAttribPointer(f.skinWeight,4,d.FLOAT,!1,0,0)}if(q instanceof THREE.Mesh)if(j.wireframe){d.lineWidth(j.wireframe_linewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,h.__webGLLineBuffer);d.drawElements(d.LINES,h.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,h.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,h.__webGLFaceCount,d.UNSIGNED_SHORT,
+0)}else if(q instanceof THREE.Line){q=q.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(j.linewidth);d.drawArrays(q,0,h.__webGLLineCount)}else q instanceof THREE.ParticleSystem&&d.drawArrays(d.POINTS,0,h.__webGLParticleCount)}function i(f,n){if(!f.__webGLVertexBuffer)f.__webGLVertexBuffer=d.createBuffer();if(!f.__webGLNormalBuffer)f.__webGLNormalBuffer=d.createBuffer();if(f.hasPos){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,f.positionArray,d.DYNAMIC_DRAW);
+d.enableVertexAttribArray(n.attributes.position);d.vertexAttribPointer(n.attributes.position,3,d.FLOAT,!1,0,0)}if(f.hasNormal){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,f.normalArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(n.attributes.normal);d.vertexAttribPointer(n.attributes.normal,3,d.FLOAT,!1,0,0)}d.drawArrays(d.TRIANGLES,0,f.count);f.count=0}function l(f){if(ba!=f.doubleSided){f.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE);ba=f.doubleSided}if(R!=
+f.flipSided){f.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW);R=f.flipSided}}function o(f){if(V!=f){f?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST);V=f}}function k(f){B[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);B[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);B[2].set(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);B[3].set(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);B[4].set(f.n41-f.n31,f.n42-f.n32,f.n43-f.n33,f.n44-f.n34);B[5].set(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,
+f.n44+f.n34);var n;for(f=0;f<5;f++){n=B[f];n.divideScalar(Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z))}}function m(f){for(var n=f.globalMatrix,p=-f.geometry.boundingSphere.radius*Math.max(f.scale.x,Math.max(f.scale.y,f.scale.z)),j=0;j<6;j++){f=B[j].x*n.n14+B[j].y*n.n24+B[j].z*n.n34+B[j].w;if(f<=p)return!1}return!0}function s(f,n){f.list[f.count]=n;f.count+=1}function w(f){var n,p,j=f.object,h=f.opaque,q=f.transparent;q.count=0;f=h.count=0;for(n=j.materials.length;f<n;f++){p=j.materials[f];p.opacity&&p.opacity<
+1||p.blending!=THREE.NormalBlending?s(q,p):s(h,p)}}function t(f){var n,p,j,h,q=f.object,v=f.buffer,C=f.opaque,W=f.transparent;W.count=0;f=C.count=0;for(j=q.materials.length;f<j;f++){n=q.materials[f];if(n instanceof THREE.MeshFaceMaterial){n=0;for(p=v.materials.length;n<p;n++)(h=v.materials[n])&&(h.opacity&&h.opacity<1||h.blending!=THREE.NormalBlending?s(W,h):s(C,h))}else{h=n;h.opacity&&h.opacity<1||h.blending!=THREE.NormalBlending?s(W,h):s(C,h)}}}function x(f,n){return n.z-f.z}function F(f,n,p,j,
+h){if(n[p]==undefined){f.push({buffer:j,object:h,opaque:{list:[],count:0},transparent:{list:[],count:0}});n[p]=1}}function H(f,n){f._modelViewMatrix.multiplyToArray(n.globalMatrix,f.globalMatrix,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function G(f){if(f!=aa){switch(f){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)}aa=f}}function r(f,n){if(f&&!f.__webGLFramebuffer){f.__webGLFramebuffer=d.createFramebuffer();f.__webGLRenderbuffer=d.createRenderbuffer();f.__webGLTexture=d.createTexture();d.bindRenderbuffer(d.RENDERBUFFER,f.__webGLRenderbuffer);d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,f.width,f.height);d.bindTexture(d.TEXTURE_2D,f.__webGLTexture);d.texParameteri(d.TEXTURE_2D,
+d.TEXTURE_WRAP_S,D(f.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,D(f.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,D(f.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,D(f.min_filter));d.texImage2D(d.TEXTURE_2D,0,D(f.format),f.width,f.height,0,D(f.format),D(f.type),null);d.bindFramebuffer(d.FRAMEBUFFER,f.__webGLFramebuffer);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,f.__webGLTexture,0);d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,
+d.RENDERBUFFER,f.__webGLRenderbuffer);d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,null)}var p,j,h;if(f){p=f.__webGLFramebuffer;j=f.width;h=f.height}else{p=null;j=K.width;h=K.height}if(p!=T){d.bindFramebuffer(d.FRAMEBUFFER,p);d.viewport(0,0,j,h);n&&d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT);T=p}}function Z(f,n){var p;if(f=="fragment")p=d.createShader(d.FRAGMENT_SHADER);else f=="vertex"&&(p=d.createShader(d.VERTEX_SHADER));d.shaderSource(p,
+n);d.compileShader(p);if(!d.getShaderParameter(p,d.COMPILE_STATUS)){alert(d.getShaderInfoLog(p));return null}return p}function D(f){switch(f){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 K=document.createElement("canvas"),d,ga=null,T=null,N=this,ba=null,R=null,aa=null,V=null,B=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],I=new THREE.Matrix4,ka=new Float32Array(16),P=new Float32Array(16),ja=new Float32Array(16),ca=new THREE.Vector4,Q=!0,ra=new THREE.Color(0),wa=0;if(a){if(a.antialias!==undefined)Q=a.antialias;
+a.clearColor!==undefined&&ra.setHex(a.clearColor);if(a.clearAlpha!==undefined)wa=a.clearAlpha}this.domElement=K;this.autoClear=!0;this.sortObjects=!1;(function(f,n,p){try{d=K.getContext("experimental-webgl",{antialias:f})}catch(j){console.log(j)}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(n.r,n.g,n.b,p);_cullEnabled=!0})(Q,ra,wa);this.context=d;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,n){K.width=f;K.height=n;d.viewport(0,0,K.width,K.height)};this.setClearColorHex=function(f,n){var p=new THREE.Color(f);d.clearColor(p.r,p.g,p.b,n)};this.setClearColor=function(f,n){d.clearColor(f.r,f.g,f.b,n)};this.clear=function(){d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT)};this.initMaterial=
+function(f,n,p){var j,h;if(f instanceof THREE.MeshDepthMaterial)c(f,THREE.ShaderLib.depth);else if(f instanceof THREE.MeshNormalMaterial)c(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)c(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)c(f,THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)c(f,THREE.ShaderLib.phong);else if(f instanceof THREE.LineBasicMaterial)c(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&
+c(f,THREE.ShaderLib.particle_basic);var q,v,C,W;h=C=W=0;for(q=n.length;h<q;h++){v=n[h];v instanceof THREE.DirectionalLight&&C++;v instanceof THREE.PointLight&&W++}if(W+C<=4)n=C;else{n=Math.ceil(4*C/(W+C));W=4-n}h={directional:n,point:W};W=f.fragment_shader;n=f.vertex_shader;q={fog:p,map:f.map,env_map:f.env_map,light_map:f.light_map,vertex_colors:f.vertex_colors,skinning:f.skinning,maxDirLights:h.directional,maxPointLights:h.point};p=d.createProgram();h=["#ifdef GL_ES\nprecision highp float;\n#endif",
+"#define MAX_DIR_LIGHTS "+q.maxDirLights,"#define MAX_POINT_LIGHTS "+q.maxPointLights,q.fog?"#define USE_FOG":"",q.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",q.map?"#define USE_MAP":"",q.env_map?"#define USE_ENVMAP":"",q.light_map?"#define USE_LIGHTMAP":"",q.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");q=[d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+q.maxDirLights,"#define MAX_POINT_LIGHTS "+
+q.maxPointLights,q.map?"#define USE_MAP":"",q.env_map?"#define USE_ENVMAP":"",q.light_map?"#define USE_LIGHTMAP":"",q.vertex_colors?"#define USE_COLOR":"",q.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
+d.attachShader(p,Z("fragment",h+W));d.attachShader(p,Z("vertex",q+n));d.linkProgram(p);d.getProgramParameter(p,d.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+d.getProgramParameter(p,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");p.uniforms={};p.attributes={};f.program=p;p=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","uBoneGlobalMatrices"];for(j in f.uniforms)p.push(j);j=f.program;W=0;for(n=p.length;W<
+n;W++){h=p[W];j.uniforms[h]=d.getUniformLocation(j,h)}j=f.program;p=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];W=0;for(n=p.length;W<n;W++){h=p[W];j.attributes[h]=d.getAttribLocation(j,h)}j=f.program.attributes;d.enableVertexAttribArray(j.position);j.color>=0&&d.enableVertexAttribArray(j.color);j.normal>=0&&d.enableVertexAttribArray(j.normal);j.tangent>=0&&d.enableVertexAttribArray(j.tangent);if(f.skinning&&j.skinVertexA>=0&&j.skinVertexB>=
+0&&j.skinIndex>=0&&j.skinWeight>=0){d.enableVertexAttribArray(j.skinVertexA);d.enableVertexAttribArray(j.skinVertexB);d.enableVertexAttribArray(j.skinIndex);d.enableVertexAttribArray(j.skinWeight)}};this.render=function(f,n,p,j){var h,q,v,C,W,L,S,E,da=f.lights,ea=f.fog;n.autoUpdateMatrix&&n.update();n.globalMatrix.flattenToArray(ja);n.projectionMatrix.flattenToArray(ka);n.inverseMatrix.flattenToArray(P);I.multiply(n.projectionMatrix,n.globalMatrix);k(I);THREE.AnimationHandler&&THREE.AnimationHandler.update();
+f.update(undefined,!1,n);this.initWebGLObjects(f,n);r(p,j!==undefined?j:!0);this.autoClear&&this.clear();W=f.__webGLObjects.length;for(j=0;j<W;j++){h=f.__webGLObjects[j];S=h.object;if(S.visible)if(!(S instanceof THREE.Mesh)||m(S)){S.globalMatrix.flattenToArray(S._objectMatrixArray);H(S,n);t(h);h.render=!0;if(this.sortObjects){ca.copy(S.position);I.multiplyVector3(ca);h.z=ca.z}}else h.render=!1;else h.render=!1}this.sortObjects&&f.__webGLObjects.sort(x);L=f.__webGLObjectsImmediate.length;for(j=0;j<
+L;j++){h=f.__webGLObjectsImmediate[j];S=h.object;if(S.visible){S.autoUpdateMatrix&&S.globalMatrix.flattenToArray(S._objectMatrixArray);H(S,n);w(h)}}G(THREE.NormalBlending);for(j=0;j<W;j++){h=f.__webGLObjects[j];if(h.render){S=h.object;E=h.buffer;v=h.opaque;l(S);for(h=0;h<v.count;h++){C=v.list[h];o(C.depth_test);g(n,da,ea,C,E,S)}}}for(j=0;j<L;j++){h=f.__webGLObjectsImmediate[j];S=h.object;if(S.visible){v=h.opaque;l(S);for(h=0;h<v.count;h++){C=v.list[h];o(C.depth_test);q=e(n,da,ea,C,S);S.render(function(va){i(va,
+q)})}}}for(j=0;j<W;j++){h=f.__webGLObjects[j];if(h.render){S=h.object;E=h.buffer;v=h.transparent;l(S);for(h=0;h<v.count;h++){C=v.list[h];G(C.blending);o(C.depth_test);g(n,da,ea,C,E,S)}}}for(j=0;j<L;j++){h=f.__webGLObjectsImmediate[j];S=h.object;if(S.visible){v=h.transparent;l(S);for(h=0;h<v.count;h++){C=v.list[h];G(C.blending);o(C.depth_test);q=e(n,da,ea,C,S);S.render(function(va){i(va,q)})}}}if(p&&p.min_filter!==THREE.NearestFilter&&p.min_filter!==THREE.LinearFilter){d.bindTexture(d.TEXTURE_2D,p.__webGLTexture);
+d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}};this.initWebGLObjects=function(f){var n,p,j;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={};f.__webGLObjectsImmediate=[]}n=0;for(p=f.objects.length;n<p;n++){j=f.objects[n];var h=f,q=void 0,v=void 0,C=void 0,W=void 0;v=j.geometry;if(h.__webGLObjectsMap[j.id]==undefined){h.__webGLObjectsMap[j.id]={};j._modelViewMatrix=new THREE.Matrix4;j._normalMatrixArray=new Float32Array(9);j._modelViewMatrixArray=new Float32Array(16);
+j._objectMatrixArray=new Float32Array(16);j.globalMatrix.flattenToArray(j._objectMatrixArray)}W=h.__webGLObjectsMap[j.id];objlist=h.__webGLObjects;if(j instanceof THREE.Mesh){for(q in v.geometryChunks){C=v.geometryChunks[q];if(!C.__webGLVertexBuffer){h=C;h.__webGLVertexBuffer=d.createBuffer();h.__webGLNormalBuffer=d.createBuffer();h.__webGLTangentBuffer=d.createBuffer();h.__webGLColorBuffer=d.createBuffer();h.__webGLUVBuffer=d.createBuffer();h.__webGLUV2Buffer=d.createBuffer();h.__webGLSkinVertexABuffer=
+d.createBuffer();h.__webGLSkinVertexBBuffer=d.createBuffer();h.__webGLSkinIndicesBuffer=d.createBuffer();h.__webGLSkinWeightsBuffer=d.createBuffer();h.__webGLFaceBuffer=d.createBuffer();h.__webGLLineBuffer=d.createBuffer();h=C;var L=j,S=void 0,E=void 0,da=0,ea=0,va=0,la=L.geometry.faces,ha=h.faces;S=0;for(E=ha.length;S<E;S++){fi=ha[S];face=la[fi];if(face instanceof THREE.Face3){da+=3;ea+=1;va+=3}else if(face instanceof THREE.Face4){da+=4;ea+=2;va+=4}}h.__vertexArray=new Float32Array(da*3);h.__normalArray=
+new Float32Array(da*3);h.__tangentArray=new Float32Array(da*4);h.__colorArray=new Float32Array(da*3);h.__uvArray=new Float32Array(da*2);h.__uv2Array=new Float32Array(da*2);h.__skinVertexAArray=new Float32Array(da*4);h.__skinVertexBArray=new Float32Array(da*4);h.__skinIndexArray=new Float32Array(da*4);h.__skinWeightArray=new Float32Array(da*4);h.__faceArray=new Uint16Array(ea*3);h.__lineArray=new Uint16Array(va*2);E=S=h;da=void 0;la=void 0;var ia=void 0,fa=void 0;ia=void 0;ha=!1;da=0;for(la=L.materials.length;da<
+la;da++){ia=L.materials[da];if(ia instanceof THREE.MeshFaceMaterial){ia=0;for(fa=E.materials.length;ia<fa;ia++)if(E.materials[ia]&&E.materials[ia].shading!=undefined&&E.materials[ia].shading==THREE.SmoothShading){ha=!0;break}}else if(ia&&ia.shading!=undefined&&ia.shading==THREE.SmoothShading){ha=!0;break}if(ha)break}S.__needsSmoothNormals=ha;h.__webGLFaceCount=ea*3;h.__webGLLineCount=va*2;v.__dirtyVertices=!0;v.__dirtyElements=!0;v.__dirtyUvs=!0;v.__dirtyNormals=!0;v.__dirtyTangents=!0;v.__dirtyColors=
+!0}if(v.__dirtyVertices||v.__dirtyElements||v.__dirtyUvs||v.__dirtyNormals||v.__dirtyColors||v.__dirtyTangents){h=C;ea=d.DYNAMIC_DRAW;va=void 0;S=void 0;var na=void 0,z=void 0,Fa=void 0,za=void 0,Ga=void 0;na=void 0;var O=void 0,M=void 0,J=void 0,oa=void 0;O=void 0;M=void 0;J=void 0;z=void 0;O=void 0;M=void 0;J=void 0;oa=void 0;O=void 0;M=void 0;J=void 0;oa=void 0;O=void 0;M=void 0;J=void 0;oa=void 0;O=void 0;M=void 0;J=void 0;oa=void 0;O=void 0;M=void 0;J=void 0;oa=void 0;z=void 0;za=void 0;Fa=void 0;
+Ga=void 0;var Ca=fa=ia=ha=la=da=L=E=0,Aa=0,u=0,Ba=h.__vertexArray,Oa=h.__uvArray,Ma=h.__uv2Array,Ha=h.__normalArray,$=h.__tangentArray,sa=h.__colorArray,pa=h.__skinVertexAArray,ta=h.__skinVertexBArray,ua=h.__skinIndexArray,qa=h.__skinWeightArray,y=h.__faceArray,X=h.__lineArray,Y=h.__needsSmoothNormals,A=j.geometry,U=A.__dirtyVertices,ma=A.__dirtyElements,xa=A.__dirtyUvs,Da=A.__dirtyNormals,Ea=A.__dirtyTangents,Ia=A.__dirtyColors,ya=A.vertices,Ja=h.faces,Qa=A.faces,Ka=A.uvs,La=A.uvs2,Na=A.colors,Ra=
+A.skinVerticesA,Sa=A.skinVerticesB,Ta=A.skinIndices,Pa=A.skinWeights;va=0;for(S=Ja.length;va<S;va++){na=Ja[va];z=Qa[na];Ga=Ka[na];na=La[na];Fa=z.vertexNormals;za=z.normal;if(z instanceof THREE.Face3){if(U){O=ya[z.a].position;M=ya[z.b].position;J=ya[z.c].position;Ba[L]=O.x;Ba[L+1]=O.y;Ba[L+2]=O.z;Ba[L+3]=M.x;Ba[L+4]=M.y;Ba[L+5]=M.z;Ba[L+6]=J.x;Ba[L+7]=J.y;Ba[L+8]=J.z;L+=9}if(Pa.length){O=Pa[z.a];M=Pa[z.b];J=Pa[z.c];qa[u]=O.x;qa[u+1]=O.y;qa[u+2]=O.z;qa[u+3]=O.w;qa[u+4]=M.x;qa[u+5]=M.y;qa[u+6]=M.z;qa[u+
+7]=M.w;qa[u+8]=J.x;qa[u+9]=J.y;qa[u+10]=J.z;qa[u+11]=J.w;O=Ta[z.a];M=Ta[z.b];J=Ta[z.c];ua[u]=O.x;ua[u+1]=O.y;ua[u+2]=O.z;ua[u+3]=O.w;ua[u+4]=M.x;ua[u+5]=M.y;ua[u+6]=M.z;ua[u+7]=M.w;ua[u+8]=J.x;ua[u+9]=J.y;ua[u+10]=J.z;ua[u+11]=J.w;O=Ra[z.a];M=Ra[z.b];J=Ra[z.c];pa[u]=O.x;pa[u+1]=O.y;pa[u+2]=O.z;pa[u+3]=1;pa[u+4]=M.x;pa[u+5]=M.y;pa[u+6]=M.z;pa[u+7]=1;pa[u+8]=J.x;pa[u+9]=J.y;pa[u+10]=J.z;pa[u+11]=1;O=Sa[z.a];M=Sa[z.b];J=Sa[z.c];ta[u]=O.x;ta[u+1]=O.y;ta[u+2]=O.z;ta[u+3]=1;ta[u+4]=M.x;ta[u+5]=M.y;ta[u+
+6]=M.z;ta[u+7]=1;ta[u+8]=J.x;ta[u+9]=J.y;ta[u+10]=J.z;ta[u+11]=1;u+=12}if(Ia&&Na.length){O=Na[z.a];M=Na[z.b];J=Na[z.c];sa[Aa]=O.r;sa[Aa+1]=O.g;sa[Aa+2]=O.b;sa[Aa+3]=M.r;sa[Aa+4]=M.g;sa[Aa+5]=M.b;sa[Aa+6]=J.r;sa[Aa+7]=J.g;sa[Aa+8]=J.b;Aa+=9}if(Ea&&A.hasTangents){O=ya[z.a].tangent;M=ya[z.b].tangent;J=ya[z.c].tangent;$[fa]=O.x;$[fa+1]=O.y;$[fa+2]=O.z;$[fa+3]=O.w;$[fa+4]=M.x;$[fa+5]=M.y;$[fa+6]=M.z;$[fa+7]=M.w;$[fa+8]=J.x;$[fa+9]=J.y;$[fa+10]=J.z;$[fa+11]=J.w;fa+=12}if(Da)if(Fa.length==3&&Y)for(z=0;z<
+3;z++){za=Fa[z];Ha[ia]=za.x;Ha[ia+1]=za.y;Ha[ia+2]=za.z;ia+=3}else for(z=0;z<3;z++){Ha[ia]=za.x;Ha[ia+1]=za.y;Ha[ia+2]=za.z;ia+=3}if(xa&&Ga)for(z=0;z<3;z++){Fa=Ga[z];Oa[da]=Fa.u;Oa[da+1]=Fa.v;da+=2}if(xa&&na)for(z=0;z<3;z++){Ga=na[z];Ma[la]=Ga.u;Ma[la+1]=Ga.v;la+=2}if(ma){y[ha]=E;y[ha+1]=E+1;y[ha+2]=E+2;ha+=3;X[Ca]=E;X[Ca+1]=E+1;X[Ca+2]=E;X[Ca+3]=E+2;X[Ca+4]=E+1;X[Ca+5]=E+2;Ca+=6;E+=3}}else if(z instanceof THREE.Face4){if(U){O=ya[z.a].position;M=ya[z.b].position;J=ya[z.c].position;oa=ya[z.d].position;
+Ba[L]=O.x;Ba[L+1]=O.y;Ba[L+2]=O.z;Ba[L+3]=M.x;Ba[L+4]=M.y;Ba[L+5]=M.z;Ba[L+6]=J.x;Ba[L+7]=J.y;Ba[L+8]=J.z;Ba[L+9]=oa.x;Ba[L+10]=oa.y;Ba[L+11]=oa.z;L+=12}if(Pa.length){O=Pa[z.a];M=Pa[z.b];J=Pa[z.c];oa=Pa[z.d];qa[u]=O.x;qa[u+1]=O.y;qa[u+2]=O.z;qa[u+3]=O.w;qa[u+4]=M.x;qa[u+5]=M.y;qa[u+6]=M.z;qa[u+7]=M.w;qa[u+8]=J.x;qa[u+9]=J.y;qa[u+10]=J.z;qa[u+11]=J.w;qa[u+12]=oa.x;qa[u+13]=oa.y;qa[u+14]=oa.z;qa[u+15]=oa.w;O=Ta[z.a];M=Ta[z.b];J=Ta[z.c];oa=Ta[z.d];ua[u]=O.x;ua[u+1]=O.y;ua[u+2]=O.z;ua[u+3]=O.w;ua[u+4]=
+M.x;ua[u+5]=M.y;ua[u+6]=M.z;ua[u+7]=M.w;ua[u+8]=J.x;ua[u+9]=J.y;ua[u+10]=J.z;ua[u+11]=J.w;ua[u+12]=oa.x;ua[u+13]=oa.y;ua[u+14]=oa.z;ua[u+15]=oa.w;O=Ra[z.a];M=Ra[z.b];J=Ra[z.c];oa=Ra[z.d];pa[u]=O.x;pa[u+1]=O.y;pa[u+2]=O.z;pa[u+3]=1;pa[u+4]=M.x;pa[u+5]=M.y;pa[u+6]=M.z;pa[u+7]=1;pa[u+8]=J.x;pa[u+9]=J.y;pa[u+10]=J.z;pa[u+11]=1;pa[u+12]=oa.x;pa[u+13]=oa.y;pa[u+14]=oa.z;pa[u+15]=1;O=Sa[z.a];M=Sa[z.b];J=Sa[z.c];oa=Sa[z.d];ta[u]=O.x;ta[u+1]=O.y;ta[u+2]=O.z;ta[u+3]=1;ta[u+4]=M.x;ta[u+5]=M.y;ta[u+6]=M.z;ta[u+
+7]=1;ta[u+8]=J.x;ta[u+9]=J.y;ta[u+10]=J.z;ta[u+11]=1;ta[u+12]=oa.x;ta[u+13]=oa.y;ta[u+14]=oa.z;ta[u+15]=1;u+=16}if(Ia&&Na.length){O=Na[z.a];M=Na[z.b];J=Na[z.c];oa=Na[z.d];sa[Aa]=O.r;sa[Aa+1]=O.g;sa[Aa+2]=O.b;sa[Aa+3]=M.r;sa[Aa+4]=M.g;sa[Aa+5]=M.b;sa[Aa+6]=J.r;sa[Aa+7]=J.g;sa[Aa+8]=J.b;sa[Aa+9]=oa.r;sa[Aa+10]=oa.g;sa[Aa+11]=oa.b;Aa+=12}if(Ea&&A.hasTangents){O=ya[z.a].tangent;M=ya[z.b].tangent;J=ya[z.c].tangent;z=ya[z.d].tangent;$[fa]=O.x;$[fa+1]=O.y;$[fa+2]=O.z;$[fa+3]=O.w;$[fa+4]=M.x;$[fa+5]=M.y;
+$[fa+6]=M.z;$[fa+7]=M.w;$[fa+8]=J.x;$[fa+9]=J.y;$[fa+10]=J.z;$[fa+11]=J.w;$[fa+12]=z.x;$[fa+13]=z.y;$[fa+14]=z.z;$[fa+15]=z.w;fa+=16}if(Da)if(Fa.length==4&&Y)for(z=0;z<4;z++){za=Fa[z];Ha[ia]=za.x;Ha[ia+1]=za.y;Ha[ia+2]=za.z;ia+=3}else for(z=0;z<4;z++){Ha[ia]=za.x;Ha[ia+1]=za.y;Ha[ia+2]=za.z;ia+=3}if(xa&&Ga)for(z=0;z<4;z++){Fa=Ga[z];Oa[da]=Fa.u;Oa[da+1]=Fa.v;da+=2}if(xa&&na)for(z=0;z<4;z++){Ga=na[z];Ma[la]=Ga.u;Ma[la+1]=Ga.v;la+=2}if(ma){y[ha]=E;y[ha+1]=E+1;y[ha+2]=E+2;y[ha+3]=E;y[ha+4]=E+2;y[ha+5]=
+E+3;ha+=6;X[Ca]=E;X[Ca+1]=E+1;X[Ca+2]=E;X[Ca+3]=E+3;X[Ca+4]=E+1;X[Ca+5]=E+2;X[Ca+6]=E+2;X[Ca+7]=E+3;Ca+=8;E+=4}}}if(U){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,Ba,ea)}if(Ia&&Na.length){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,sa,ea)}if(Da){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,Ha,ea)}if(Ea&&A.hasTangents){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLTangentBuffer);d.bufferData(d.ARRAY_BUFFER,
+$,ea)}if(xa&&da>0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLUVBuffer);d.bufferData(d.ARRAY_BUFFER,Oa,ea)}if(xa&&la>0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Ma,ea)}if(ma){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,h.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,y,ea);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,h.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,X,ea)}if(u>0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinVertexABuffer);d.bufferData(d.ARRAY_BUFFER,pa,ea);
+d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinVertexBBuffer);d.bufferData(d.ARRAY_BUFFER,ta,ea);d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinIndicesBuffer);d.bufferData(d.ARRAY_BUFFER,ua,ea);d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinWeightsBuffer);d.bufferData(d.ARRAY_BUFFER,qa,ea)}}F(objlist,W,q,C,j)}v.__dirtyVertices=!1;v.__dirtyElements=!1;v.__dirtyUvs=!1;v.__dirtyNormals=!1;v.__dirtyTangents=!1;v.__dirtyColors=!1}else if(j instanceof THREE.Line){if(!v.__webGLVertexBuffer){q=v;q.__webGLVertexBuffer=d.createBuffer();
+q.__webGLColorBuffer=d.createBuffer();q=v;C=q.vertices.length;q.__vertexArray=new Float32Array(C*3);q.__colorArray=new Float32Array(C*3);q.__webGLLineCount=C;v.__dirtyVertices=!0;v.__dirtyColors=!0}if(v.__dirtyVertices||v.__dirtyColors){q=v;C=d.DYNAMIC_DRAW;E=void 0;E=void 0;L=void 0;h=void 0;da=q.vertices;ea=q.colors;la=da.length;va=ea.length;ha=q.__vertexArray;S=q.__colorArray;ia=q.__dirtyColors;if(q.__dirtyVertices){for(E=0;E<la;E++){L=da[E].position;h=E*3;ha[h]=L.x;ha[h+1]=L.y;ha[h+2]=L.z}d.bindBuffer(d.ARRAY_BUFFER,
+q.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,ha,C)}if(ia){for(E=0;E<va;E++){color=ea[E];h=E*3;S[h]=color.r;S[h+1]=color.g;S[h+2]=color.b}d.bindBuffer(d.ARRAY_BUFFER,q.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,S,C)}}F(objlist,W,0,v,j);v.__dirtyVertices=!1;v.__dirtyColors=!1}else if(j instanceof THREE.ParticleSystem){if(!v.__webGLVertexBuffer){q=v;q.__webGLVertexBuffer=d.createBuffer();q.__webGLColorBuffer=d.createBuffer();q=v;C=q.vertices.length;q.__vertexArray=new Float32Array(C*3);q.__colorArray=
+new Float32Array(C*3);q.__sortArray=[];q.__webGLParticleCount=C;v.__dirtyVertices=!0;v.__dirtyColors=!0}(v.__dirtyVertices||v.__dirtyColors||j.sortParticles)&&b(v,d.DYNAMIC_DRAW,j,camera);F(objlist,W,0,v,j);v.__dirtyVertices=!1;v.__dirtyColors=!1}else if(j instanceof THREE.MarchingCubes){v=W;if(v[0]==undefined){h.__webGLObjectsImmediate.push({object:j,opaque:{list:[],count:0},transparent:{list:[],count:0}});v[0]=1}}}};this.removeObject=function(f,n){var p,j;for(p=f.__webGLObjects.length-1;p>=0;p--){j=
+f.__webGLObjects[p].object;n==j&&f.__webGLObjects.splice(p,1)}};this.setFaceCulling=function(f,n){if(f){!n||n=="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW);if(f=="back")d.cullFace(d.BACK);else f=="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}};
 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",

+ 201 - 202
build/ThreeExtras.js

@@ -13,35 +13,35 @@ this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,b,c,d){this.x=a||
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,f=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(f=f.concat(this.intersectObject(c)))}f.sort(function(g,h){return g.distance-h.distance});return f},intersectObject:function(a){function b(F,u,e,q){q=q.clone().subSelf(u);e=e.clone().subSelf(u);var O=F.clone().subSelf(u);F=q.dot(q);u=q.dot(e);q=q.dot(O);var R=e.dot(e);e=e.dot(O);O=1/(F*R-u*u);R=(R*q-u*e)*O;F=(F*e-u*q)*O;return R>0&&F>0&&R+F<1}var c,d,f,g,h,k,j,m,n,w,
-t,p=a.geometry,x=p.vertices,z=[];c=0;for(d=p.faces.length;c<d;c++){f=p.faces[c];w=this.origin.clone();t=this.direction.clone();j=a.globalMatrix;j.extractRotationMatrix(a.rotationMatrix);g=j.multiplyVector3(x[f.a].position.clone());h=j.multiplyVector3(x[f.b].position.clone());k=j.multiplyVector3(x[f.c].position.clone());j=f instanceof THREE.Face4?j.multiplyVector3(x[f.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(f.normal.clone());n=t.dot(m);if(n<0){m=m.dot((new THREE.Vector3).sub(g,
-w))/n;w=w.addSelf(t.multiplyScalar(m));if(f instanceof THREE.Face3){if(b(w,g,h,k)){f={distance:this.origin.distanceTo(w),point:w,face:f,object:a};z.push(f)}}else if(f instanceof THREE.Face4&&(b(w,g,h,j)||b(w,h,k,j))){f={distance:this.origin.distanceTo(w),point:w,face:f,object:a};z.push(f)}}}return z}};
-THREE.Rectangle=function(){function a(){g=d-b;h=f-c}var b,c,d,f,g,h,k=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(j,m,n,w){k=!1;b=j;c=m;d=n;f=w;a()};this.addPoint=function(j,m){if(k){k=!1;b=j;c=m;d=j;f=m}else{b=b<j?b:j;c=c<m?c:m;d=d>j?d:j;f=f>m?f:m}a()};
-this.add3Points=function(j,m,n,w,t,p){if(k){k=!1;b=j<n?j<t?j:t:n<t?n:t;c=m<w?m<p?m:p:w<p?w:p;d=j>n?j>t?j:t:n>t?n:t;f=m>w?m>p?m:p:w>p?w:p}else{b=j<n?j<t?j<b?j:b:t<b?t:b:n<t?n<b?n:b:t<b?t:b;c=m<w?m<p?m<c?m:c:p<c?p:c:w<p?w<c?w:c:p<c?p:c;d=j>n?j>t?j>d?j:d:t>d?t:d:n>t?n>d?n:d:t>d?t:d;f=m>w?m>p?m>f?m:f:p>f?p:f:w>p?w>f?w:f:p>f?p:f}a()};this.addRectangle=function(j){if(k){k=!1;b=j.getLeft();c=j.getTop();d=j.getRight();f=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();c=c<j.getTop()?c:j.getTop();d=d>j.getRight()?
+THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,f=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(f=f.concat(this.intersectObject(c)))}f.sort(function(g,h){return g.distance-h.distance});return f},intersectObject:function(a){function b(F,v,H,q){q=q.clone().subSelf(v);H=H.clone().subSelf(v);var J=F.clone().subSelf(v);F=q.dot(q);v=q.dot(H);q=q.dot(J);var e=H.dot(H);H=H.dot(J);J=1/(F*e-v*v);e=(e*q-v*H)*J;F=(F*H-v*q)*J;return e>0&&F>0&&e+F<1}var c,d,f,g,h,k,j,m,o,w,
+u,t=a.geometry,x=t.vertices,A=[];c=0;for(d=t.faces.length;c<d;c++){f=t.faces[c];w=this.origin.clone();u=this.direction.clone();j=a.globalMatrix;j.extractRotationMatrix(a.rotationMatrix);g=j.multiplyVector3(x[f.a].position.clone());h=j.multiplyVector3(x[f.b].position.clone());k=j.multiplyVector3(x[f.c].position.clone());j=f instanceof THREE.Face4?j.multiplyVector3(x[f.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(f.normal.clone());o=u.dot(m);if(o<0){m=m.dot((new THREE.Vector3).sub(g,
+w))/o;w=w.addSelf(u.multiplyScalar(m));if(f instanceof THREE.Face3){if(b(w,g,h,k)){f={distance:this.origin.distanceTo(w),point:w,face:f,object:a};A.push(f)}}else if(f instanceof THREE.Face4&&(b(w,g,h,j)||b(w,h,k,j))){f={distance:this.origin.distanceTo(w),point:w,face:f,object:a};A.push(f)}}}return A}};
+THREE.Rectangle=function(){function a(){g=d-b;h=f-c}var b,c,d,f,g,h,k=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(j,m,o,w){k=!1;b=j;c=m;d=o;f=w;a()};this.addPoint=function(j,m){if(k){k=!1;b=j;c=m;d=j;f=m}else{b=b<j?b:j;c=c<m?c:m;d=d>j?d:j;f=f>m?f:m}a()};
+this.add3Points=function(j,m,o,w,u,t){if(k){k=!1;b=j<o?j<u?j:u:o<u?o:u;c=m<w?m<t?m:t:w<t?w:t;d=j>o?j>u?j:u:o>u?o:u;f=m>w?m>t?m:t:w>t?w:t}else{b=j<o?j<u?j<b?j:b:u<b?u:b:o<u?o<b?o: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;d=j>o?j>u?j>d?j:d:u>d?u:d:o>u?o>d?o:d:u>d?u:d;f=m>w?m>t?m>f?m:f:t>f?t:f:w>t?w>f?w:f:t>f?t:f}a()};this.addRectangle=function(j){if(k){k=!1;b=j.getLeft();c=j.getTop();d=j.getRight();f=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();c=c<j.getTop()?c:j.getTop();d=d>j.getRight()?
 d:j.getRight();f=f>j.getBottom()?f:j.getBottom()}a()};this.inflate=function(j){b-=j;c-=j;d+=j;f+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();c=c>j.getTop()?c:j.getTop();d=d<j.getRight()?d:j.getRight();f=f<j.getBottom()?f:j.getBottom();a()};this.instersects=function(j){return Math.min(d,j.getRight())-Math.max(b,j.getLeft())>=0&&Math.min(f,j.getBottom())-Math.max(c,j.getTop())>=0};this.empty=function(){k=!0;f=d=c=b=0;a()};this.isEmpty=function(){return k};this.toString=function(){return"THREE.Rectangle ( left: "+
 b+", right: "+d+", top: "+c+", bottom: "+f+", width: "+g+", 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,d,f,g,h,k,j,m,n,w,t,p,x,z){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=d||0;this.n21=f||0;this.n22=g||1;this.n23=h||0;this.n24=k||0;this.n31=j||0;this.n32=m||0;this.n33=n||1;this.n34=w||0;this.n41=t||0;this.n42=p||0;this.n43=x||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,d,f,g,h,k,j,m,n,w,t,p,x,z){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=f;this.n22=g;this.n23=h;this.n24=k;this.n31=j;this.n32=m;this.n33=n;this.n34=w;this.n41=t;this.n42=p;this.n43=x;this.n44=z;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
+THREE.Matrix4=function(a,b,c,d,f,g,h,k,j,m,o,w,u,t,x,A){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=d||0;this.n21=f||0;this.n22=g||1;this.n23=h||0;this.n24=k||0;this.n31=j||0;this.n32=m||0;this.n33=o||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,d,f,g,h,k,j,m,o,w,u,t,x,A){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=f;this.n22=g;this.n23=h;this.n24=k;this.n31=j;this.n32=m;this.n33=o;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 d=THREE.Matrix4.__tmpVec1,f=THREE.Matrix4.__tmpVec2,g=THREE.Matrix4.__tmpVec3;g.sub(a,b).normalize();d.cross(c,g).normalize();f.cross(g,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);
 this.n31=g.x;this.n32=g.y;this.n33=g.z;this.n34=-g.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,f=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*f;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*f;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*f;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*
 a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,f=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*f;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*f;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*f;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*f;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*
-a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,n=a.n31,w=a.n32,t=a.n33,p=a.n34,x=a.n41,z=a.n42,F=a.n43,u=a.n44,e=b.n11,q=b.n12,O=b.n13,R=b.n14,ea=b.n21,L=b.n22,I=b.n23,Y=b.n24,V=b.n31,ca=b.n32,da=b.n33,G=b.n34,$=b.n41,na=b.n42,aa=b.n43,l=b.n44;this.n11=c*e+d*ea+f*V+g*$;this.n12=c*q+d*L+f*ca+g*na;this.n13=c*O+d*I+f*da+g*aa;this.n14=c*R+d*Y+f*G+g*l;this.n21=h*e+k*ea+j*V+m*$;this.n22=h*q+k*L+j*ca+m*na;
-this.n23=h*O+k*I+j*da+m*aa;this.n24=h*R+k*Y+j*G+m*l;this.n31=n*e+w*ea+t*V+p*$;this.n32=n*q+w*L+t*ca+p*na;this.n33=n*O+w*I+t*da+p*aa;this.n34=n*R+w*Y+t*G+p*l;this.n41=x*e+z*ea+F*V+u*$;this.n42=x*q+z*L+F*ca+u*na;this.n43=x*O+z*I+F*da+u*aa;this.n44=x*R+z*Y+F*G+u*l;return this},multiplyToArray:function(a,b,c){var d=a.n11,f=a.n12,g=a.n13,h=a.n14,k=a.n21,j=a.n22,m=a.n23,n=a.n24,w=a.n31,t=a.n32,p=a.n33,x=a.n34,z=a.n41,F=a.n42,u=a.n43;a=a.n44;var e=b.n11,q=b.n12,O=b.n13,R=b.n14,ea=b.n21,L=b.n22,I=b.n23,Y=
-b.n24,V=b.n31,ca=b.n32,da=b.n33,G=b.n34,$=b.n41,na=b.n42,aa=b.n43;b=b.n44;this.n11=d*e+f*ea+g*V+h*$;this.n12=d*q+f*L+g*ca+h*na;this.n13=d*O+f*I+g*da+h*aa;this.n14=d*R+f*Y+g*G+h*b;this.n21=k*e+j*ea+m*V+n*$;this.n22=k*q+j*L+m*ca+n*na;this.n23=k*O+j*I+m*da+n*aa;this.n24=k*R+j*Y+m*G+n*b;this.n31=w*e+t*ea+p*V+x*$;this.n32=w*q+t*L+p*ca+x*na;this.n33=w*O+t*I+p*da+x*aa;this.n34=w*R+t*Y+p*G+x*b;this.n41=z*e+F*ea+u*V+a*$;this.n42=z*q+F*L+u*ca+a*na;this.n43=z*O+F*I+u*da+a*aa;this.n44=z*R+F*Y+u*G+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,d=this.n13,f=this.n14,g=this.n21,h=this.n22,k=this.n23,j=this.n24,m=this.n31,n=this.n32,w=this.n33,t=this.n34,p=this.n41,x=this.n42,z=this.n43,F=this.n44,u=a.n11,e=a.n21,q=a.n31,O=a.n41,R=a.n12,ea=a.n22,L=a.n32,I=a.n42,Y=
-a.n13,V=a.n23,ca=a.n33,da=a.n43,G=a.n14,$=a.n24,na=a.n34;a=a.n44;this.n11=b*u+c*e+d*q+f*O;this.n12=b*R+c*ea+d*L+f*I;this.n13=b*Y+c*V+d*ca+f*da;this.n14=b*G+c*$+d*na+f*a;this.n21=g*u+h*e+k*q+j*O;this.n22=g*R+h*ea+k*L+j*I;this.n23=g*Y+h*V+k*ca+j*da;this.n24=g*G+h*$+k*na+j*a;this.n31=m*u+n*e+w*q+t*O;this.n32=m*R+n*ea+w*L+t*I;this.n33=m*Y+n*V+w*ca+t*da;this.n34=m*G+n*$+w*na+t*a;this.n41=p*u+x*e+z*q+F*O;this.n42=p*R+x*ea+z*L+F*I;this.n43=p*Y+x*V+z*ca+F*da;this.n44=p*G+x*$+z*na+F*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,d=this.n14,f=this.n21,g=this.n22,h=this.n23,k=this.n24,j=this.n31,m=this.n32,n=this.n33,w=this.n34,t=this.n41,p=this.n42,x=this.n43,z=this.n44;return d*h*m*t-c*k*m*t-d*g*n*t+b*k*n*t+c*g*w*t-b*h*w*t-d*h*j*p+c*k*j*p+d*f*n*p-a*k*n*p-c*f*w*p+a*h*w*p+
-d*g*j*x-b*k*j*x-d*f*m*x+a*k*m*x+b*f*w*x-a*g*w*x-c*g*j*z+b*h*j*z+c*f*m*z-a*h*m*z-b*f*n*z+a*g*n*z},transpose:function(){function a(b,c,d){var f=b[c];b[c]=b[d];b[d]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;
-a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){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},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+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),d=Math.sin(b),f=1-c,g=a.x,h=a.y,k=a.z,j=f*
-g,m=f*h;this.set(j*g+c,j*h-d*k,j*k+d*h,0,j*h+d*k,m*h+c,m*k-d*g,0,j*k-d*h,m*k+d*g,f*k*k+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(c);c=Math.sin(c);var f=Math.cos(-d);d=Math.sin(-d);var g=Math.cos(b);b=Math.sin(b);var h=a*d,k=c*d;this.n11=a*f;this.n12=c*b-h*g;this.n13=h*b+c*g;this.n21=d;this.n22=f*g;this.n23=-f*b;this.n31=-c*f;this.n32=k*g+a*b;this.n33=-k*b+a*g},setRotationFromQuaternion:function(a){var b=
-a.x,c=a.y,d=a.z,f=a.w,g=b+b,h=c+c,k=d+d;a=b*g;var j=b*h;b*=k;var m=c*h;c*=k;d*=k;g*=f;h*=f;f*=k;this.n11=1-(m+d);this.n12=j-f;this.n13=b+h;this.n21=j+f;this.n22=1-(a+d);this.n23=c-g;this.n31=b-h;this.n32=c+g;this.n33=1-(a+m)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=b;this.n13*=b;this.n21*=c;this.n22*=c;this.n23*=c;this.n31*=a;this.n32*=a;this.n33*=a;return this},extractRotationMatrix:function(a){a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=0;a.n21=this.n21;a.n22=this.n22;
-a.n23=this.n23;a.n24=0;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=0;a.n41=0;a.n42=0;a.n43=0;a.n44=1},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 d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};
+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,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,o=a.n31,w=a.n32,u=a.n33,t=a.n34,x=a.n41,A=a.n42,F=a.n43,v=a.n44,H=b.n11,q=b.n12,J=b.n13,e=b.n14,ba=b.n21,L=b.n22,M=b.n23,V=b.n24,S=b.n31,Y=b.n32,Z=b.n33,G=b.n34,T=b.n41,la=b.n42,W=b.n43,ja=b.n44;this.n11=c*H+d*ba+f*S+g*T;this.n12=c*q+d*L+f*Y+g*la;this.n13=c*J+d*M+f*Z+g*W;this.n14=c*e+d*V+f*G+g*ja;this.n21=h*H+k*ba+j*S+m*T;this.n22=h*q+k*L+j*Y+m*la;this.n23=
+h*J+k*M+j*Z+m*W;this.n24=h*e+k*V+j*G+m*ja;this.n31=o*H+w*ba+u*S+t*T;this.n32=o*q+w*L+u*Y+t*la;this.n33=o*J+w*M+u*Z+t*W;this.n34=o*e+w*V+u*G+t*ja;this.n41=x*H+A*ba+F*S+v*T;this.n42=x*q+A*L+F*Y+v*la;this.n43=x*J+A*M+F*Z+v*W;this.n44=x*e+A*V+F*G+v*ja;return this},multiplyToArray:function(a,b,c){var d=a.n11,f=a.n12,g=a.n13,h=a.n14,k=a.n21,j=a.n22,m=a.n23,o=a.n24,w=a.n31,u=a.n32,t=a.n33,x=a.n34,A=a.n41,F=a.n42,v=a.n43;a=a.n44;var H=b.n11,q=b.n12,J=b.n13,e=b.n14,ba=b.n21,L=b.n22,M=b.n23,V=b.n24,S=b.n31,
+Y=b.n32,Z=b.n33,G=b.n34,T=b.n41,la=b.n42,W=b.n43;b=b.n44;this.n11=d*H+f*ba+g*S+h*T;this.n12=d*q+f*L+g*Y+h*la;this.n13=d*J+f*M+g*Z+h*W;this.n14=d*e+f*V+g*G+h*b;this.n21=k*H+j*ba+m*S+o*T;this.n22=k*q+j*L+m*Y+o*la;this.n23=k*J+j*M+m*Z+o*W;this.n24=k*e+j*V+m*G+o*b;this.n31=w*H+u*ba+t*S+x*T;this.n32=w*q+u*L+t*Y+x*la;this.n33=w*J+u*M+t*Z+x*W;this.n34=w*e+u*V+t*G+x*b;this.n41=A*H+F*ba+v*S+a*T;this.n42=A*q+F*L+v*Y+a*la;this.n43=A*J+F*M+v*Z+a*W;this.n44=A*e+F*V+v*G+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,d=this.n13,f=this.n14,g=this.n21,h=this.n22,k=this.n23,j=this.n24,m=this.n31,o=this.n32,w=this.n33,u=this.n34,t=this.n41,x=this.n42,A=this.n43,F=this.n44,v=a.n11,H=a.n21,q=a.n31,J=a.n41,e=a.n12,ba=a.n22,L=a.n32,M=a.n42,V=a.n13,S=a.n23,Y=a.n33,Z=a.n43,
+G=a.n14,T=a.n24,la=a.n34;a=a.n44;this.n11=b*v+c*H+d*q+f*J;this.n12=b*e+c*ba+d*L+f*M;this.n13=b*V+c*S+d*Y+f*Z;this.n14=b*G+c*T+d*la+f*a;this.n21=g*v+h*H+k*q+j*J;this.n22=g*e+h*ba+k*L+j*M;this.n23=g*V+h*S+k*Y+j*Z;this.n24=g*G+h*T+k*la+j*a;this.n31=m*v+o*H+w*q+u*J;this.n32=m*e+o*ba+w*L+u*M;this.n33=m*V+o*S+w*Y+u*Z;this.n34=m*G+o*T+w*la+u*a;this.n41=t*v+x*H+A*q+F*J;this.n42=t*e+x*ba+A*L+F*M;this.n43=t*V+x*S+A*Y+F*Z;this.n44=t*G+x*T+A*la+F*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,d=this.n14,f=this.n21,g=this.n22,h=this.n23,k=this.n24,j=this.n31,m=this.n32,o=this.n33,w=this.n34,u=this.n41,t=this.n42,x=this.n43,A=this.n44;return d*h*m*u-c*k*m*u-d*g*o*u+b*k*o*u+c*g*w*u-b*h*w*u-d*h*j*t+c*k*j*t+d*f*o*t-a*k*o*t-c*f*w*t+a*h*w*t+d*g*j*x-b*k*
+j*x-d*f*m*x+a*k*m*x+b*f*w*x-a*g*w*x-c*g*j*A+b*h*j*A+c*f*m*A-a*h*m*A-b*f*o*A+a*g*o*A},transpose:function(){function a(b,c,d){var f=b[c];b[c]=b[d];b[d]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;
+a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){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},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+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),d=Math.sin(b),f=1-c,g=a.x,h=a.y,k=a.z,j=f*g,m=f*h;this.set(j*g+c,j*h-d*k,j*
+k+d*h,0,j*h+d*k,m*h+c,m*k-d*g,0,j*k-d*h,m*k+d*g,f*k*k+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(c);c=Math.sin(c);var f=Math.cos(-d);d=Math.sin(-d);var g=Math.cos(b);b=Math.sin(b);var h=a*d,k=c*d;this.n11=a*f;this.n12=c*b-h*g;this.n13=h*b+c*g;this.n21=d;this.n22=f*g;this.n23=-f*b;this.n31=-c*f;this.n32=k*g+a*b;this.n33=-k*b+a*g},setRotationFromQuaternion:function(a){var b=a.x,
+c=a.y,d=a.z,f=a.w,g=b+b,h=c+c,k=d+d;a=b*g;var j=b*h;b*=k;var m=c*h;c*=k;d*=k;g*=f;h*=f;f*=k;this.n11=1-(m+d);this.n12=j-f;this.n13=b+h;this.n21=j+f;this.n22=1-(a+d);this.n23=c-g;this.n31=b-h;this.n32=c+g;this.n33=1-(a+m)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=b;this.n13*=b;this.n21*=c;this.n22*=c;this.n23*=c;this.n31*=a;this.n32*=a;this.n33*=a;return this},extractRotationMatrix:function(a){a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=0;a.n21=this.n21;a.n22=this.n22;a.n23=
+this.n23;a.n24=0;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=0;a.n41=0;a.n42=0;a.n43=0;a.n44=1},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 d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};
 THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d};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,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,n=a.n31,w=a.n32,t=a.n33,p=a.n34,x=a.n41,z=a.n42,F=a.n43,u=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=j*p*z-m*t*z+m*w*F-k*p*F-j*w*u+k*t*u;b.n12=g*t*z-f*p*z-g*w*F+d*p*F+f*w*u-d*t*u;b.n13=f*m*z-g*j*z+g*k*F-d*m*F-f*k*u+d*j*u;b.n14=g*j*w-f*m*w-g*k*t+d*m*t+f*k*p-d*j*p;b.n21=m*t*x-j*p*x-m*n*F+h*p*F+j*n*u-h*t*u;b.n22=f*p*x-g*t*x+g*n*F-c*p*F-f*n*u+c*t*u;b.n23=g*j*x-f*m*x-g*h*F+c*m*F+f*h*u-c*j*u;
-b.n24=f*m*n-g*j*n+g*h*t-c*m*t-f*h*p+c*j*p;b.n31=k*p*x-m*w*x+m*n*z-h*p*z-k*n*u+h*w*u;b.n32=g*w*x-d*p*x-g*n*z+c*p*z+d*n*u-c*w*u;b.n33=f*m*x-g*k*x+g*h*z-c*m*z-d*h*u+c*k*u;b.n34=g*k*n-d*m*n-g*h*w+c*m*w+d*h*p-c*k*p;b.n41=j*w*x-k*t*x-j*n*z+h*t*z+k*n*F-h*w*F;b.n42=d*t*x-f*w*x+f*n*z-c*t*z-d*n*F+c*w*F;b.n43=f*k*x-d*j*x-f*h*z+c*j*z+d*h*F-c*k*F;b.n44=d*j*n-f*k*n+f*h*w-c*j*w-d*h*t+c*k*t;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=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,n=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*g;c[3]=a*h;c[4]=a*k;c[5]=a*j;c[6]=a*m;c[7]=a*n;c[8]=a*w;return b};
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,o=a.n31,w=a.n32,u=a.n33,t=a.n34,x=a.n41,A=a.n42,F=a.n43,v=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=j*t*A-m*u*A+m*w*F-k*t*F-j*w*v+k*u*v;b.n12=g*u*A-f*t*A-g*w*F+d*t*F+f*w*v-d*u*v;b.n13=f*m*A-g*j*A+g*k*F-d*m*F-f*k*v+d*j*v;b.n14=g*j*w-f*m*w-g*k*u+d*m*u+f*k*t-d*j*t;b.n21=m*u*x-j*t*x-m*o*F+h*t*F+j*o*v-h*u*v;b.n22=f*t*x-g*u*x+g*o*F-c*t*F-f*o*v+c*u*v;b.n23=g*j*x-f*m*x-g*h*F+c*m*F+f*h*v-c*j*v;
+b.n24=f*m*o-g*j*o+g*h*u-c*m*u-f*h*t+c*j*t;b.n31=k*t*x-m*w*x+m*o*A-h*t*A-k*o*v+h*w*v;b.n32=g*w*x-d*t*x-g*o*A+c*t*A+d*o*v-c*w*v;b.n33=f*m*x-g*k*x+g*h*A-c*m*A-d*h*v+c*k*v;b.n34=g*k*o-d*m*o-g*h*w+c*m*w+d*h*t-c*k*t;b.n41=j*w*x-k*u*x-j*o*A+h*u*A+k*o*F-h*w*F;b.n42=d*u*x-f*w*x+f*o*A-c*u*A-d*o*F+c*w*F;b.n43=f*k*x-d*j*x-f*h*A+c*j*A+d*h*F-c*k*F;b.n44=d*j*o-f*k*o+f*h*w-c*j*w-d*h*u+c*k*u;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=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,o=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*g;c[3]=a*h;c[4]=a*k;c[5]=a*j;c[6]=a*m;c[7]=a*o;c[8]=a*w;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,f,g){var h;h=new THREE.Matrix4;h.n11=2*f/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*f/(d-c);h.n23=(d+c)/(d-c);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+f)/(g-f);h.n34=-2*g*f/(g-f);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,d){var f;a=c*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,c,d)};
 THREE.Matrix4.makeOrtho=function(a,b,c,d,f,g){var h,k,j,m;h=new THREE.Matrix4;k=b-a;j=c-d;m=g-f;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-((b+a)/k);h.n21=0;h.n22=2/j;h.n23=0;h.n24=-((c+d)/j);h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-((g+f)/m);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.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d!==undefined?d:1;this.api={isDirty:!1,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(f){this.that.x=f;this.isDirty=!0},set y(f){this.that.y=f;this.isDirty=!0},set z(f){this.that.z=f;this.isDirty=!0},set w(f){this.that.w=f;this.isDirty=!0}};this.api.__proto__=THREE.Quaternion.prototype;return this.api};
@@ -49,7 +49,7 @@ THREE.Quaternion.prototype.set=function(a,b,c,d){var f=this.that;f.x=a;f.y=b;f.z
 THREE.Quaternion.prototype.calculateW=function(){var a=this.that,b=a.x,c=a.y,d=a.z;a.w=-Math.sqrt(Math.abs(1-b*b-c*c-d*d));this.isDirty=!0;return this};THREE.Quaternion.prototype.inverse=function(){var a=this.that;a.x*=-1;a.y*=-1;a.z*=-1;this.isDirty=!0;return this};THREE.Quaternion.prototype.length=function(){var a=this.that;return Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z+a.w*a.w)};
 THREE.Quaternion.prototype.normalize=function(){var a=this.that,b=a.x,c=a.y,d=a.z,f=a.w,g=Math.sqrt(b*b+c*c+d*d+f*f);if(g==0){a.x=0;a.y=0;a.z=0;a.w=0;this.isDirty=!0;return this}g=1/g;a.x=b*g;a.y=c*g;a.z=d*g;a.w=f*g;this.isDirty=!0;return this};
 THREE.Quaternion.prototype.multiplySelf=function(a){var b=this.that;qax=b.x;qay=b.y;qaz=b.z;qaw=b.w;qbx=a.x;qby=a.y;qbz=a.z;qbw=a.w;b.x=qax*qbw+qaw*qbx+qay*qbz-qaz*qby;b.y=qay*qbw+qaw*qby+qaz*qbx-qax*qbz;b.z=qaz*qbw+qaw*qbz+qax*qby-qay*qbx;b.w=qaw*qbw-qax*qbx-qay*qby-qaz*qbz;this.isDirty=!0;return this};
-THREE.Quaternion.prototype.multiplyVector3=function(a,b){b||(b=a);var c=this.that,d=a.x,f=a.y,g=a.z,h=c.x,k=c.y,j=c.z;c=c.w;var m=c*d+k*g-j*f,n=c*f+j*d-h*g,w=c*g+h*f-k*d;d=-h*d-k*f-j*g;b.x=m*c+d*-h+n*-j-w*-k;b.y=n*c+d*-k+w*-h-m*-j;b.z=w*c+d*-j+m*-k-n*-h;return b};THREE.Quaternion.prototype.toMatrix3=function(){};THREE.Quaternion.prototype.toMatrix4=function(){};
+THREE.Quaternion.prototype.multiplyVector3=function(a,b){b||(b=a);var c=this.that,d=a.x,f=a.y,g=a.z,h=c.x,k=c.y,j=c.z;c=c.w;var m=c*d+k*g-j*f,o=c*f+j*d-h*g,w=c*g+h*f-k*d;d=-h*d-k*f-j*g;b.x=m*c+d*-h+o*-j-w*-k;b.y=o*c+d*-k+w*-h-m*-j;b.z=w*c+d*-j+m*-k-o*-h;return b};THREE.Quaternion.prototype.toMatrix3=function(){};THREE.Quaternion.prototype.toMatrix4=function(){};
 THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(f)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(f),h=Math.sqrt(1-f*f);if(Math.abs(h)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}f=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;c.w=a.w*f+b.w*d;c.x=a.x*f+b.x*d;c.y=a.y*f+b.y*d;c.z=a.z*f+b.z*d;return c};
 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=!0};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
 THREE.Face3=function(a,b,c,d,f){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
@@ -59,12 +59,12 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.f
 c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,f,g,h,k=new THREE.Vector3,j=new THREE.Vector3;d=0;for(f=this.vertices.length;d<f;d++){g=this.vertices[d];g.normal.set(0,0,0)}d=0;for(f=this.faces.length;d<f;d++){g=this.faces[d];if(a&&g.vertexNormals.length){k.set(0,0,0);b=0;for(c=g.normal.length;b<c;b++)k.addSelf(g.vertexNormals[b]);k.divideScalar(3)}else{b=this.vertices[g.a];c=this.vertices[g.b];h=this.vertices[g.c];k.sub(h.position,
 c.position);j.sub(b.position,c.position);k.crossSelf(j)}k.isZero()||k.normalize();g.normal.copy(k)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[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{d=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal);d[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)d[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(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(G,$,na,aa,l,A,y){g=G.vertices[$].position;h=G.vertices[na].position;k=G.vertices[aa].position;j=f[l];m=f[A];n=f[y];w=h.x-g.x;t=k.x-g.x;p=h.y-g.y;x=k.y-
-g.y;z=h.z-g.z;F=k.z-g.z;u=m.u-j.u;e=n.u-j.u;q=m.v-j.v;O=n.v-j.v;R=1/(u*O-e*q);I.set((O*w-q*t)*R,(O*p-q*x)*R,(O*z-q*F)*R);Y.set((u*t-e*w)*R,(u*x-e*p)*R,(u*F-e*z)*R);ea[$].addSelf(I);ea[na].addSelf(I);ea[aa].addSelf(I);L[$].addSelf(Y);L[na].addSelf(Y);L[aa].addSelf(Y)}var b,c,d,f,g,h,k,j,m,n,w,t,p,x,z,F,u,e,q,O,R,ea=[],L=[],I=new THREE.Vector3,Y=new THREE.Vector3,V=new THREE.Vector3,ca=new THREE.Vector3,da=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){ea[b]=new THREE.Vector3;L[b]=new THREE.Vector3}b=
+b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(G,T,la,W,ja,ia,$){g=G.vertices[T].position;h=G.vertices[la].position;k=G.vertices[W].position;j=f[ja];m=f[ia];o=f[$];w=h.x-g.x;u=k.x-g.x;t=h.y-g.y;x=k.y-
+g.y;A=h.z-g.z;F=k.z-g.z;v=m.u-j.u;H=o.u-j.u;q=m.v-j.v;J=o.v-j.v;e=1/(v*J-H*q);M.set((J*w-q*u)*e,(J*t-q*x)*e,(J*A-q*F)*e);V.set((v*u-H*w)*e,(v*x-H*t)*e,(v*F-H*A)*e);ba[T].addSelf(M);ba[la].addSelf(M);ba[W].addSelf(M);L[T].addSelf(V);L[la].addSelf(V);L[W].addSelf(V)}var b,c,d,f,g,h,k,j,m,o,w,u,t,x,A,F,v,H,q,J,e,ba=[],L=[],M=new THREE.Vector3,V=new THREE.Vector3,S=new THREE.Vector3,Y=new THREE.Vector3,Z=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){ba[b]=new THREE.Vector3;L[b]=new THREE.Vector3}b=
 0;for(c=this.faces.length;b<c;b++){d=this.faces[b];f=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c,0,1,2);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c,0,1,2);a(this,d.a,d.b,d.d,0,1,3);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2]);
-this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){da.copy(this.vertices[b].normal);d=ea[b];V.copy(d);V.subSelf(da.multiplyScalar(da.dot(d))).normalize();ca.cross(this.vertices[b].normal,d);d=ca.dot(L[b]);d=d<0?-1:1;this.vertices[b].tangent.set(V.x,V.y,V.z,d)}this.hasTangents=!0},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[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){Z.copy(this.vertices[b].normal);d=ba[b];S.copy(d);S.subSelf(Z.multiplyScalar(Z.dot(d))).normalize();Y.cross(this.vertices[b].normal,d);d=Y.dot(L[b]);d=d<0?-1:1;this.vertices[b].tangent.set(S.x,S.y,S.z,d)}this.hasTangents=!0},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>
-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(n){var w=[];b=0;for(c=n.length;b<c;b++)n[b]==undefined?w.push("undefined"):w.push(n[b].id);return w.join("_")}var b,c,d,f,g,h,k,j,m={};d=0;for(f=this.faces.length;d<f;d++){g=this.faces[d];
+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(o){var w=[];b=0;for(c=o.length;b<c;b++)o[b]==undefined?w.push("undefined"):w.push(o[b].id);return w.join("_")}var b,c,d,f,g,h,k,j,m={};d=0;for(f=this.faces.length;d<f;d++){g=this.faces[d];
 h=g.materials;k=a(h);m[k]==undefined&&(m[k]={hash:k,counter:0});j=m[k].hash+"_"+m[k].counter;this.geometryChunks[j]==undefined&&(this.geometryChunks[j]={faces:[],materials:h,vertices:0});g=g instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+g>65535){m[k].counter+=1;j=m[k].hash+"_"+m[k].counter;this.geometryChunks[j]==undefined&&(this.geometryChunks[j]={faces:[],materials:h,vertices:0})}this.geometryChunks[j].faces.push(d);this.geometryChunks[j].vertices+=g}},toString:function(){return"THREE.Geometry ( vertices: "+
 this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0;
 THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.visible=!0;this.autoUpdateMatrix=!0;this.matrixNeedsToUpdate=!0;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale=1;this.rotationMatrix=
@@ -72,16 +72,15 @@ new THREE.Matrix4};THREE.Object3D.prototype.update=function(a,b,c){if(this.visib
 THREE.Object3D.prototype.updateMatrix=function(){this.localMatrix.setPosition(this.position);if(this.useQuaternion){if(this.quaternion.isDirty){this.localMatrix.setRotationFromQuaternion(this.quaternion);this.quaternion.isDirty=!1}}else this.localMatrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.localMatrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}return!0};
 THREE.Object3D.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a)}};THREE.Object3D.prototype.removeChild=function(a){var b=this.children.indexOf(a);if(b!==-1){this.children.splice(b,1);a.parent=undefined}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=!1};THREE.Particle.prototype=new THREE.Object3D;
 THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=c!=undefined?c:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;
-THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b&&b.length?b:[b];this.normalMatrix=THREE.Matrix4.makeInvert3x3(this.globalMatrix).transpose();this.flipSided=!1;this.doubleSided=!1;this.overdraw=!1;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius}};THREE.Mesh.prototype=new THREE.Object3D;
-THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
-THREE.Mesh.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0;this.normalMatrix=THREE.Matrix4.makeInvert3x3(this.globalMatrix).transpose()}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,c)}};
-THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
+THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b&&b.length?b:[b];this.flipSided=!1;this.doubleSided=!1;this.overdraw=!1;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
+THREE.Mesh.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,c)}};THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;
+THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
 THREE.Bone.prototype.update=function(a,b,c){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.skinMatrix.multiply(a,this.localMatrix):this.skinMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}var d,f=this.children.length;if(this.hasNoneBoneChildren){this.globalMatrix.multiply(this.skin.globalMatrix,this.skinMatrix);for(d=0;d<f;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.globalMatrix,!0,c)}}else for(d=
 0;d<f;d++)this.children[d].update(this.skinMatrix,b,c)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);if(!(a instanceof THREE.Bone))this.hasNoneBoneChildren=!0}};if(!window.Float32Array)window.Float32Array=Array;
 THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var c,d,f,g,h,k;if(this.geometry.bones!==undefined){for(c=0;c<this.geometry.bones.length;c++){f=this.geometry.bones[c];g=f.pos;h=f.rotq;k=f.scl;d=this.addBone();d.name=f.name;d.position.set(g[0],g[1],g[2]);d.quaternion.set(h[0],h[1],h[2],h[3]);k!==undefined?d.scale.set(k[0],k[1],k[2]):d.scale.set(1,1,1)}for(c=0;c<this.bones.length;c++){f=this.geometry.bones[c];d=this.bones[c];
 f.parent===-1?this.addChild(d):this.bones[f.parent].addChild(d)}this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
-THREE.SkinnedMesh.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0;this.normalMatrix=THREE.Matrix4.makeInvert3x3(this.globalMatrix).transpose()}var d,f=this.children.length;for(d=0;d<f;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.identityMatrix,!1,c):a.update(this.globalMatrix,b,
-c)}}};THREE.SkinnedMesh.prototype.addBone=function(a){a===undefined&&(a=new THREE.Bone(this));this.bones.push(a);return a};
+THREE.SkinnedMesh.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}var d,f=this.children.length;for(d=0;d<f;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.identityMatrix,!1,c):a.update(this.globalMatrix,b,c)}}};
+THREE.SkinnedMesh.prototype.addBone=function(a){a===undefined&&(a=new THREE.Bone(this));this.bones.push(a);return a};
 THREE.SkinnedMesh.prototype.pose=function(){this.update(undefined,!0);for(var a,b=[],c=0;c<this.bones.length;c++){a=this.bones[c];b.push(THREE.Matrix4.makeInvert(a.skinMatrix));a.skinMatrix.flattenToArrayOffset(this.boneMatrices,c*16)}if(this.geometry.skinVerticesA===undefined){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var d;for(a=0;a<this.geometry.skinIndices.length;a++){c=this.geometry.vertices[a].position;var f=this.geometry.skinIndices[a].x,g=this.geometry.skinIndices[a].y;
 d=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesA.push(b[f].multiplyVector3(d));d=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesB.push(b[g].multiplyVector3(d));if(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1){c=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5;this.geometry.skinWeights[a].x+=c;this.geometry.skinWeights[a].y+=c}}}};
 THREE.AnimationHandler=function(){var a=[],b={};b.update=function(c){for(var d=0;d<a.length;d++)a[d].update(c)};b.add=function(c){a.indexOf(c)===-1&&a.push(c)};b.remove=function(c){a.indexOf(c)!==-1&&a.splice(childIndex,1)};b.initData=function(c){if(c.initialized!==!0){for(var d=0;d<c.hierarchy.length;d++)for(var f=0;f<c.hierarchy[d].keys.length;f++){if(c.hierarchy[d].keys[f].time<0)c.hierarchy[d].keys[f].time=0;c.hierarchy[d].keys[f].index=f;if(c.hierarchy[d].keys[f].rot!==undefined&&!(c.hierarchy[d].keys[f].rot instanceof
@@ -89,17 +88,17 @@ THREE.Quaternion)){var g=c.hierarchy[d].keys[f].rot;c.hierarchy[d].keys[f].rot=n
 THREE.Animation=function(a,b){this.root=a;this.data=b;this.hierarchy=[];this.startTime=0;this.isPlaying=!1;this.loop=!0;this.offset=0;this.data.initialized||THREE.AnimationHandler.initData(this.data);if(a instanceof THREE.SkinnedMesh)for(var c=0;c<this.root.bones.length;c++)this.hierarchy.push(this.root.bones[c])};
 THREE.Animation.prototype.play=function(){if(!this.isPlaying){this.isPlaying=!0;this.startTime=(new Date).getTime()*0.0010;for(var a=0;a<this.hierarchy.length;a++){this.hierarchy[a].useQuaternion=!0;this.hierarchy[a].autoUpdateMatrix=!0;if(this.hierarchy[a].prevKey===undefined){this.hierarchy[a].prevKey={pos:0,rot:0,scl:0};this.hierarchy[a].nextKey={pos:0,rot:0,scl:0}}this.hierarchy[a].prevKey.pos=this.data.hierarchy[a].keys[0];this.hierarchy[a].prevKey.rot=this.data.hierarchy[a].keys[0];this.hierarchy[a].prevKey.scl=
 this.data.hierarchy[a].keys[0];this.hierarchy[a].nextKey.pos=this.getNextKeyWith("pos",a,1);this.hierarchy[a].nextKey.rot=this.getNextKeyWith("rot",a,1);this.hierarchy[a].nextKey.scl=this.getNextKeyWith("scl",a,1)}this.update();THREE.AnimationHandler.add(this)}};THREE.Animation.prototype.pause=function(){THREE.AnimationHandler.remove(this)};THREE.Animation.prototype.stop=function(){this.isPlaying=!1;THREE.AnimationHandler.remove(this)};
-THREE.Animation.prototype.update=function(){if(this.isPlaying){var a=["pos","rot","scl"],b,c,d,f,g,h,k=this.data.JIT.hierarchy,j=(new Date).getTime()*0.0010-this.startTime+this.offset,m=j;if(j>this.data.length){for(;j>this.data.length;)j-=this.data.length;this.startTime=(new Date).getTime()*0.0010-j;j=(new Date).getTime()*0.0010-this.startTime}h=Math.min(parseInt(j*this.data.fps),parseInt(this.data.length*this.data.fps));for(var n=0,w=this.hierarchy.length;n<w;n++){g=this.hierarchy[n];if(k[n][h]!==
-undefined){g.skinMatrix=k[n][h];g.autoUpdateMatrix=!1;g.matrixNeedsToUpdate=!1;g.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,n*16)}else for(var t=0;t<3;t++){c=a[t];d=g.prevKey[c];f=g.nextKey[c];if(f.time<m){if(j<m)if(this.loop){d=this.data.hierarchy[n].keys[0];f=this.getNextKeyWith(c,n,1)}else{this.stop();return}else{do{d=f;f=this.getNextKeyWith(c,n,f.index+1)}while(f.time<j)}g.prevKey[c]=d;g.nextKey[c]=f}g.autoUpdateMatrix=!0;g.matrixNeedsToUpdate=!0;b=(j-d.time)/(f.time-d.time);d=d[c];
-f=f[c];if(c==="rot"){if(b<0||b>1){console.log("Scale out of bounds:"+b);b=b<0?0:1}THREE.Quaternion.slerp(d,f,g.quaternion,b)}else{c=c==="pos"?g.position:g.scale;c.x=d[0]+(f[0]-d[0])*b;c.y=d[1]+(f[1]-d[1])*b;c.z=d[2]+(f[2]-d[2])*b}}}if(k[0][h]===undefined){this.hierarchy[0].update(undefined,!0);for(n=0;n<this.hierarchy.length;n++)k[n][h]=this.hierarchy[n].skinMatrix.clone()}}};THREE.Animation.prototype.updateObject=function(){};
+THREE.Animation.prototype.update=function(){if(this.isPlaying){var a=["pos","rot","scl"],b,c,d,f,g,h,k=this.data.JIT.hierarchy,j=(new Date).getTime()*0.0010-this.startTime+this.offset,m=j;if(j>this.data.length){for(;j>this.data.length;)j-=this.data.length;this.startTime=(new Date).getTime()*0.0010-j;j=(new Date).getTime()*0.0010-this.startTime}h=Math.min(parseInt(j*this.data.fps),parseInt(this.data.length*this.data.fps));for(var o=0,w=this.hierarchy.length;o<w;o++){g=this.hierarchy[o];if(k[o][h]!==
+undefined){g.skinMatrix=k[o][h];g.autoUpdateMatrix=!1;g.matrixNeedsToUpdate=!1;g.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,o*16)}else for(var u=0;u<3;u++){c=a[u];d=g.prevKey[c];f=g.nextKey[c];if(f.time<m){if(j<m)if(this.loop){d=this.data.hierarchy[o].keys[0];f=this.getNextKeyWith(c,o,1)}else{this.stop();return}else{do{d=f;f=this.getNextKeyWith(c,o,f.index+1)}while(f.time<j)}g.prevKey[c]=d;g.nextKey[c]=f}g.autoUpdateMatrix=!0;g.matrixNeedsToUpdate=!0;b=(j-d.time)/(f.time-d.time);d=d[c];
+f=f[c];if(c==="rot"){if(b<0||b>1){console.log("Scale out of bounds:"+b);b=b<0?0:1}THREE.Quaternion.slerp(d,f,g.quaternion,b)}else{c=c==="pos"?g.position:g.scale;c.x=d[0]+(f[0]-d[0])*b;c.y=d[1]+(f[1]-d[1])*b;c.z=d[2]+(f[2]-d[2])*b}}}if(k[0][h]===undefined){this.hierarchy[0].update(undefined,!0);for(o=0;o<this.hierarchy.length;o++)k[o][h]=this.hierarchy[o].skinMatrix.clone()}}};THREE.Animation.prototype.updateObject=function(){};
 THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys;c<d.length;c++)if(d[c][a]!==undefined)return d[c];return this.data.hierarchy[b].keys[0]};
 THREE.Camera=function(a,b,c,d,f,g){THREE.Object3D.call(this);this.FOV=a||50;this.aspect=b||1;this.zNear=c||0.1;this.zFar=d||2E3;this.screenCenterY=this.screenCenterX=0;this.target=g||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.inverseMatrix=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);
 this.target.position.addSelf(this.tmpVec)};this.translateZ=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
 THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.FOV,this.aspect,this.zNear,this.zFar)};
 THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.localMatrix.lookAt(this.position,this.target.position,this.up);a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);THREE.Matrix4.makeInvert(this.globalMatrix,this.inverseMatrix);b=!0}else{this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.globalMatrix,
 this.inverseMatrix)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,c)};
-THREE.Camera.prototype.frustumContains=function(a){var b=a.globalMatrix.n14,c=a.globalMatrix.n24,d=a.globalMatrix.n34,f=this.inverseMatrix,g=a.boundRadius*a.boundRadiusScale,h=f.n31*b+f.n32*c+f.n33*d+f.n34;if(h-g>-this.zNear)return!1;if(h+g<-this.zFar)return!1;h-=g;var k=this.projectionMatrix,j=1/(k.n43*h),m=j*this.screenCenterX,n=(f.n11*b+f.n12*c+f.n13*d+f.n14)*k.n11*m;g=k.n11*g*m;if(n+g<-this.screenCenterX)return!1;if(n-g>this.screenCenterX)return!1;b=(f.n21*b+f.n22*c+f.n23*d+f.n24)*k.n22*j*this.screenCenterY;
-if(b+g<-this.screenCenterY)return!1;if(b-g>this.screenCenterY)return!1;a.screenPosition.set(n,b,h,g);return!0};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
+THREE.Camera.prototype.frustumContains=function(a){var b=a.globalMatrix.n14,c=a.globalMatrix.n24,d=a.globalMatrix.n34,f=this.inverseMatrix,g=a.boundRadius*a.boundRadiusScale,h=f.n31*b+f.n32*c+f.n33*d+f.n34;if(h-g>-this.zNear)return!1;if(h+g<-this.zFar)return!1;h-=g;var k=this.projectionMatrix,j=1/(k.n43*h),m=j*this.screenCenterX,o=(f.n11*b+f.n12*c+f.n13*d+f.n14)*k.n11*m;g=k.n11*g*m;if(o+g<-this.screenCenterX)return!1;if(o-g>this.screenCenterX)return!1;b=(f.n21*b+f.n22*c+f.n23*d+f.n24)*k.n22*j*this.screenCenterY;
+if(b+g<-this.screenCenterY)return!1;if(b-g>this.screenCenterY)return!1;a.screenPosition.set(o,b,h,g);return!0};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
 THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1;
 THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.MaterialCounter={value:0};
 THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=!1;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=
@@ -139,118 +138,118 @@ THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLine
 THREE.RenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrap_s=c.wrap_s!==undefined?c.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=c.wrap_t!==undefined?c.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=c.mag_filter!==undefined?c.mag_filter:THREE.LinearFilter;this.min_filter=c.min_filter!==undefined?c.min_filter:THREE.LinearMipMapLinearFilter;this.format=c.format!==undefined?c.format:THREE.RGBFormat;this.type=c.type!==undefined?c.type:THREE.UnsignedByteType};
 var Uniforms={clone:function(a){var b,c,d,f={};for(b in a){f[b]={};for(c in a[b]){d=a[b][c];f[b][c]=d instanceof THREE.Color||d instanceof THREE.Vector3||d instanceof THREE.Texture?d.clone():d}}return f},merge:function(a){var b,c,d,f={};for(b=0;b<a.length;b++){d=this.clone(a[b]);for(c in d)f[c]=d[c]}return f}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};THREE.Scene=function(){THREE.Object3D.call(this);this.objects=[];this.lights=[];this.fog=null};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};
-THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else a instanceof THREE.Camera||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
+THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
 THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};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;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(L,I){return I.z-L.z}function b(L,I){var Y=0,V=1,ca=L.z+L.w,da=I.z+I.w,G=-L.z+L.w,$=-I.z+I.w;if(ca>=0&&da>=0&&G>=0&&$>=0)return!0;else if(ca<0&&da<0||G<0&&$<0)return!1;else{if(ca<0)Y=Math.max(Y,ca/(ca-da));else da<0&&(V=Math.min(V,ca/(ca-da)));if(G<0)Y=Math.max(Y,G/(G-$));else $<0&&(V=Math.min(V,G/(G-$)));if(V<Y)return!1;else{L.lerpSelf(I,Y);I.lerpSelf(L,1-V);return!0}}}var c,d,f=[],g,h,k,j=[],m,n,w=[],t,p,x=[],z=new THREE.Vector4,F=new THREE.Vector4,u=new THREE.Matrix4,
-e=new THREE.Matrix4,q=[],O=new THREE.Vector4,R=new THREE.Vector4,ea;this.projectObjects=function(L,I,Y){I=[];var V,ca,da;d=0;ca=L.objects;L=0;for(V=ca.length;L<V;L++){da=ca[L];var G;if(!(G=!da.visible))if(G=da instanceof THREE.Mesh){a:{G=void 0;for(var $=da.globalMatrix,na=-da.geometry.boundingSphere.radius*Math.max(da.scale.x,Math.max(da.scale.y,da.scale.z)),aa=0;aa<6;aa++){G=q[aa].x*$.n14+q[aa].y*$.n24+q[aa].z*$.n34+q[aa].w;if(G<=na){G=!1;break a}}G=!0}G=!G}if(!G){c=f[d]=f[d]||new THREE.RenderableObject;
-z.copy(da.position);u.multiplyVector3(z);c.object=da;c.z=z.z;I.push(c);d++}}Y&&I.sort(a);return I};this.projectScene=function(L,I,Y){var V=[],ca=I.near,da=I.far,G,$,na,aa,l,A,y,v,o,B,E,H,T,D,J,P;k=n=p=0;I.autoUpdateMatrix&&I.update();u.multiply(I.projectionMatrix,I.globalMatrix);q[0]=new THREE.Vector4(u.n41-u.n11,u.n42-u.n12,u.n43-u.n13,u.n44-u.n14);q[1]=new THREE.Vector4(u.n41+u.n11,u.n42+u.n12,u.n43+u.n13,u.n44+u.n14);q[2]=new THREE.Vector4(u.n41+u.n21,u.n42+u.n22,u.n43+u.n23,u.n44+u.n24);q[3]=
-new THREE.Vector4(u.n41-u.n21,u.n42-u.n22,u.n43-u.n23,u.n44-u.n24);q[4]=new THREE.Vector4(u.n41-u.n31,u.n42-u.n32,u.n43-u.n33,u.n44-u.n34);q[5]=new THREE.Vector4(u.n41+u.n31,u.n42+u.n32,u.n43+u.n33,u.n44+u.n34);G=0;for(A=q.length;G<A;G++){y=q[G];y.divideScalar(Math.sqrt(y.x*y.x+y.y*y.y+y.z*y.z))}L.update(undefined,!1,I);A=this.projectObjects(L,I,!0);L=0;for(G=A.length;L<G;L++){y=A[L].object;y.autoUpdateMatrix&&y.updateMatrix();v=y.globalMatrix;v.extractRotationMatrix(y.rotationMatrix);E=y.rotationMatrix;
-o=y.materials;B=y.overdraw;if(y instanceof THREE.Mesh){H=y.geometry;T=H.vertices;$=0;for(na=T.length;$<na;$++){D=T[$];D.positionWorld.copy(D.position);v.multiplyVector3(D.positionWorld);aa=D.positionScreen;aa.copy(D.positionWorld);u.multiplyVector4(aa);aa.x/=aa.w;aa.y/=aa.w;D.__visible=aa.z>ca&&aa.z<da}H=H.faces;$=0;for(na=H.length;$<na;$++){D=H[$];if(D instanceof THREE.Face3){aa=T[D.a];l=T[D.b];J=T[D.c];if(aa.__visible&&l.__visible&&J.__visible&&(y.doubleSided||y.flipSided!=(J.positionScreen.x-aa.positionScreen.x)*
-(l.positionScreen.y-aa.positionScreen.y)-(J.positionScreen.y-aa.positionScreen.y)*(l.positionScreen.x-aa.positionScreen.x)<0)){g=j[k]=j[k]||new THREE.RenderableFace3;g.v1.positionWorld.copy(aa.positionWorld);g.v2.positionWorld.copy(l.positionWorld);g.v3.positionWorld.copy(J.positionWorld);g.v1.positionScreen.copy(aa.positionScreen);g.v2.positionScreen.copy(l.positionScreen);g.v3.positionScreen.copy(J.positionScreen);g.normalWorld.copy(D.normal);E.multiplyVector3(g.normalWorld);g.centroidWorld.copy(D.centroid);
-v.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);u.multiplyVector3(g.centroidScreen);J=D.vertexNormals;ea=g.vertexNormalsWorld;aa=0;for(l=J.length;aa<l;aa++){P=ea[aa]=ea[aa]||new THREE.Vector3;P.copy(J[aa]);E.multiplyVector3(P)}g.z=g.centroidScreen.z;g.meshMaterials=o;g.faceMaterials=D.materials;g.overdraw=B;if(y.geometry.uvs[$]){g.uvs[0]=y.geometry.uvs[$][0];g.uvs[1]=y.geometry.uvs[$][1];g.uvs[2]=y.geometry.uvs[$][2]}V.push(g);k++}}else if(D instanceof THREE.Face4){aa=T[D.a];
-l=T[D.b];J=T[D.c];P=T[D.d];if(aa.__visible&&l.__visible&&J.__visible&&P.__visible&&(y.doubleSided||y.flipSided!=((P.positionScreen.x-aa.positionScreen.x)*(l.positionScreen.y-aa.positionScreen.y)-(P.positionScreen.y-aa.positionScreen.y)*(l.positionScreen.x-aa.positionScreen.x)<0||(l.positionScreen.x-J.positionScreen.x)*(P.positionScreen.y-J.positionScreen.y)-(l.positionScreen.y-J.positionScreen.y)*(P.positionScreen.x-J.positionScreen.x)<0))){g=j[k]=j[k]||new THREE.RenderableFace3;g.v1.positionWorld.copy(aa.positionWorld);
-g.v2.positionWorld.copy(l.positionWorld);g.v3.positionWorld.copy(P.positionWorld);g.v1.positionScreen.copy(aa.positionScreen);g.v2.positionScreen.copy(l.positionScreen);g.v3.positionScreen.copy(P.positionScreen);g.normalWorld.copy(D.normal);E.multiplyVector3(g.normalWorld);g.centroidWorld.copy(D.centroid);v.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);u.multiplyVector3(g.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=o;g.faceMaterials=D.materials;g.overdraw=B;if(y.geometry.uvs[$]){g.uvs[0]=
-y.geometry.uvs[$][0];g.uvs[1]=y.geometry.uvs[$][1];g.uvs[2]=y.geometry.uvs[$][3]}V.push(g);k++;h=j[k]=j[k]||new THREE.RenderableFace3;h.v1.positionWorld.copy(l.positionWorld);h.v2.positionWorld.copy(J.positionWorld);h.v3.positionWorld.copy(P.positionWorld);h.v1.positionScreen.copy(l.positionScreen);h.v2.positionScreen.copy(J.positionScreen);h.v3.positionScreen.copy(P.positionScreen);h.normalWorld.copy(g.normalWorld);h.centroidWorld.copy(g.centroidWorld);h.centroidScreen.copy(g.centroidScreen);h.z=
-h.centroidScreen.z;h.meshMaterials=o;h.faceMaterials=D.materials;h.overdraw=B;if(y.geometry.uvs[$]){h.uvs[0]=y.geometry.uvs[$][1];h.uvs[1]=y.geometry.uvs[$][2];h.uvs[2]=y.geometry.uvs[$][3]}V.push(h);k++}}}}else if(y instanceof THREE.Line){e.multiply(u,v);T=y.geometry.vertices;D=T[0];D.positionScreen.copy(D.position);e.multiplyVector4(D.positionScreen);$=1;for(na=T.length;$<na;$++){aa=T[$];aa.positionScreen.copy(aa.position);e.multiplyVector4(aa.positionScreen);l=T[$-1];O.copy(aa.positionScreen);
-R.copy(l.positionScreen);if(b(O,R)){O.multiplyScalar(1/O.w);R.multiplyScalar(1/R.w);m=w[n]=w[n]||new THREE.RenderableLine;m.v1.positionScreen.copy(O);m.v2.positionScreen.copy(R);m.z=Math.max(O.z,R.z);m.materials=y.materials;V.push(m);n++}}}else if(y instanceof THREE.Particle){F.set(y.position.x,y.position.y,y.position.z,1);u.multiplyVector4(F);F.z/=F.w;if(F.z>0&&F.z<1){t=x[p]=x[p]||new THREE.RenderableParticle;t.x=F.x/F.w;t.y=F.y/F.w;t.z=F.z;t.rotation=y.rotation.z;t.scale.x=y.scale.x*Math.abs(t.x-
-(F.x+I.projectionMatrix.n11)/(F.w+I.projectionMatrix.n14));t.scale.y=y.scale.y*Math.abs(t.y-(F.y+I.projectionMatrix.n22)/(F.w+I.projectionMatrix.n24));t.materials=y.materials;V.push(t);p++}}}Y&&V.sort(a);return V};this.unprojectVector=function(L,I){var Y=THREE.Matrix4.makeInvert(I.globalMatrix);Y.multiplySelf(THREE.Matrix4.makeInvert(I.projectionMatrix));Y.multiplyVector3(L);return L}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,f,g;this.domElement=document.createElement("div");this.setSize=function(h,k){c=h;d=k;f=c/2;g=d/2};this.render=function(h,k){var j,m,n,w,t,p,x,z;a=b.projectScene(h,k);j=0;for(m=a.length;j<m;j++){t=a[j];if(t instanceof THREE.RenderableParticle){x=t.x*f+f;z=t.y*g+g;n=0;for(w=t.material.length;n<w;n++){p=t.material[n];if(p instanceof THREE.ParticleDOMMaterial){p=p.domElement;p.style.left=x+"px";p.style.top=z+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(W){if(t!=W)m.globalAlpha=t=W}function b(W){if(p!=W){switch(W){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}p=W}}var c=null,d=new THREE.Projector,f=document.createElement("canvas"),g,h,k,j,m=f.getContext("2d"),n=new THREE.Color(0),w=0,t=1,p=0,x=null,z=null,F=1,u,e,q,O,R,ea,L,I,Y,V=new THREE.Color,
-ca=new THREE.Color,da=new THREE.Color,G=new THREE.Color,$=new THREE.Color,na,aa,l,A,y,v,o,B,E,H=new THREE.Rectangle,T=new THREE.Rectangle,D=new THREE.Rectangle,J=!1,P=new THREE.Color,ga=new THREE.Color,la=new THREE.Color,C=new THREE.Color,Q=Math.PI*2,K=new THREE.Vector3,U,ba,ta,N,Ba,xa,Ea=16;U=document.createElement("canvas");U.width=U.height=2;ba=U.getContext("2d");ba.fillStyle="rgba(0,0,0,1)";ba.fillRect(0,0,2,2);ta=ba.getImageData(0,0,2,2);N=ta.data;Ba=document.createElement("canvas");Ba.width=
-Ba.height=Ea;xa=Ba.getContext("2d");xa.translate(-Ea/2,-Ea/2);xa.scale(Ea,Ea);Ea--;this.domElement=f;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(W,Z){g=W;h=Z;k=g/2;j=h/2;f.width=g;f.height=h;H.set(-k,-j,k,j);t=1;p=0;z=x=null;F=1};this.setClearColor=function(W,Z){n=W;w=Z;T.set(-k,-j,k,j);m.setTransform(1,0,0,-1,k,j);this.clear()};this.setClearColorHex=function(W,Z){n.setHex(W);w=Z;T.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(!T.isEmpty()){T.inflate(1);T.minSelf(H);if(n.hex==0&&w==0)m.clearRect(T.getX(),T.getY(),T.getWidth(),T.getHeight());else{b(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+w+")";m.fillRect(T.getX(),T.getY(),T.getWidth(),T.getHeight())}T.empty()}};this.render=function(W,Z){function fa(S){var ka,ia,X,ha=S.lights;ga.setRGB(0,0,0);la.setRGB(0,0,0);C.setRGB(0,0,0);S=0;for(ka=ha.length;S<ka;S++){ia=ha[S];X=ia.color;if(ia instanceof
-THREE.AmbientLight){ga.r+=X.r;ga.g+=X.g;ga.b+=X.b}else if(ia instanceof THREE.DirectionalLight){la.r+=X.r;la.g+=X.g;la.b+=X.b}else if(ia instanceof THREE.PointLight){C.r+=X.r;C.g+=X.g;C.b+=X.b}}}function oa(S,ka,ia,X){var ha,ma,ya,Fa,Ha=S.lights;S=0;for(ha=Ha.length;S<ha;S++){ma=Ha[S];ya=ma.color;Fa=ma.intensity;if(ma instanceof THREE.DirectionalLight){ma=ia.dot(ma.position)*Fa;if(ma>0){X.r+=ya.r*ma;X.g+=ya.g*ma;X.b+=ya.b*ma}}else if(ma instanceof THREE.PointLight){K.sub(ma.position,ka);K.normalize();
-ma=ia.dot(K)*Fa;if(ma>0){X.r+=ya.r*ma;X.g+=ya.g*ma;X.b+=ya.b*ma}}}}function Ia(S,ka,ia){if(ia.opacity!=0){a(ia.opacity);b(ia.blending);var X,ha,ma,ya,Fa,Ha;if(ia instanceof THREE.ParticleBasicMaterial){if(ia.map&&ia.map.image.loaded){ya=ia.map.image;Fa=ya.width>>1;Ha=ya.height>>1;ha=ka.scale.x*k;ma=ka.scale.y*j;ia=ha*Fa;X=ma*Ha;D.set(S.x-ia,S.y-X,S.x+ia,S.y+X);if(H.instersects(D)){m.save();m.translate(S.x,S.y);m.rotate(-ka.rotation);m.scale(ha,-ma);m.translate(-Fa,-Ha);m.drawImage(ya,0,0);m.restore()}}}else if(ia instanceof
-THREE.ParticleCircleMaterial){if(J){P.r=ga.r+la.r+C.r;P.g=ga.g+la.g+C.g;P.b=ga.b+la.b+C.b;V.r=ia.color.r*P.r;V.g=ia.color.g*P.g;V.b=ia.color.b*P.b;V.updateStyleString()}else V.__styleString=ia.color.__styleString;ia=ka.scale.x*k;X=ka.scale.y*j;D.set(S.x-ia,S.y-X,S.x+ia,S.y+X);if(H.instersects(D)){ha=V.__styleString;if(z!=ha)m.fillStyle=z=ha;m.save();m.translate(S.x,S.y);m.rotate(-ka.rotation);m.scale(ia,X);m.beginPath();m.arc(0,0,1,0,Q,!0);m.closePath();m.fill();m.restore()}}}}function wa(S,ka,ia,
-X){if(X.opacity!=0){a(X.opacity);b(X.blending);m.beginPath();m.moveTo(S.positionScreen.x,S.positionScreen.y);m.lineTo(ka.positionScreen.x,ka.positionScreen.y);m.closePath();if(X instanceof THREE.LineBasicMaterial){V.__styleString=X.color.__styleString;S=X.linewidth;if(F!=S)m.lineWidth=F=S;S=V.__styleString;if(x!=S)m.strokeStyle=x=S;m.stroke();D.inflate(X.linewidth*2)}}}function M(S,ka,ia,X,ha,ma){if(ha.opacity!=0){a(ha.opacity);b(ha.blending);O=S.positionScreen.x;R=S.positionScreen.y;ea=ka.positionScreen.x;
-L=ka.positionScreen.y;I=ia.positionScreen.x;Y=ia.positionScreen.y;m.beginPath();m.moveTo(O,R);m.lineTo(ea,L);m.lineTo(I,Y);m.lineTo(O,R);m.closePath();if(ha instanceof THREE.MeshBasicMaterial)if(ha.map)ha.map.image.loaded&&ha.map.mapping instanceof THREE.UVMapping&&Na(O,R,ea,L,I,Y,ha.map.image,X.uvs[0].u,X.uvs[0].v,X.uvs[1].u,X.uvs[1].v,X.uvs[2].u,X.uvs[2].v);else if(ha.env_map){if(ha.env_map.image.loaded&&ha.env_map.mapping instanceof THREE.SphericalReflectionMapping){S=Z.globalMatrix;K.copy(X.vertexNormalsWorld[0]);
-A=(K.x*S.n11+K.y*S.n12+K.z*S.n13)*0.5+0.5;y=-(K.x*S.n21+K.y*S.n22+K.z*S.n23)*0.5+0.5;K.copy(X.vertexNormalsWorld[1]);v=(K.x*S.n11+K.y*S.n12+K.z*S.n13)*0.5+0.5;o=-(K.x*S.n21+K.y*S.n22+K.z*S.n23)*0.5+0.5;K.copy(X.vertexNormalsWorld[2]);B=(K.x*S.n11+K.y*S.n12+K.z*S.n13)*0.5+0.5;E=-(K.x*S.n21+K.y*S.n22+K.z*S.n23)*0.5+0.5;Na(O,R,ea,L,I,Y,ha.env_map.image,A,y,v,o,B,E)}}else ha.wireframe?ua(ha.color.__styleString,ha.wireframe_linewidth):Pa(ha.color.__styleString);else if(ha instanceof THREE.MeshLambertMaterial){if(ha.map&&
-!ha.wireframe){ha.map.mapping instanceof THREE.UVMapping&&Na(O,R,ea,L,I,Y,ha.map.image,X.uvs[0].u,X.uvs[0].v,X.uvs[1].u,X.uvs[1].v,X.uvs[2].u,X.uvs[2].v);b(THREE.SubtractiveBlending)}if(J)if(!ha.wireframe&&ha.shading==THREE.SmoothShading&&X.vertexNormalsWorld.length==3){ca.r=da.r=G.r=ga.r;ca.g=da.g=G.g=ga.g;ca.b=da.b=G.b=ga.b;oa(ma,X.v1.positionWorld,X.vertexNormalsWorld[0],ca);oa(ma,X.v2.positionWorld,X.vertexNormalsWorld[1],da);oa(ma,X.v3.positionWorld,X.vertexNormalsWorld[2],G);$.r=(da.r+G.r)*
-0.5;$.g=(da.g+G.g)*0.5;$.b=(da.b+G.b)*0.5;l=La(ca,da,G,$);Na(O,R,ea,L,I,Y,l,0,0,1,0,0,1)}else{P.r=ga.r;P.g=ga.g;P.b=ga.b;oa(ma,X.centroidWorld,X.normalWorld,P);V.r=ha.color.r*P.r;V.g=ha.color.g*P.g;V.b=ha.color.b*P.b;V.updateStyleString();ha.wireframe?ua(V.__styleString,ha.wireframe_linewidth):Pa(V.__styleString)}else ha.wireframe?ua(ha.color.__styleString,ha.wireframe_linewidth):Pa(ha.color.__styleString)}else if(ha instanceof THREE.MeshDepthMaterial){na=Z.near;aa=Z.far;ca.r=ca.g=ca.b=1-qa(S.positionScreen.z,
-na,aa);da.r=da.g=da.b=1-qa(ka.positionScreen.z,na,aa);G.r=G.g=G.b=1-qa(ia.positionScreen.z,na,aa);$.r=(da.r+G.r)*0.5;$.g=(da.g+G.g)*0.5;$.b=(da.b+G.b)*0.5;l=La(ca,da,G,$);Na(O,R,ea,L,I,Y,l,0,0,1,0,0,1)}else if(ha instanceof THREE.MeshNormalMaterial){V.r=va(X.normalWorld.x);V.g=va(X.normalWorld.y);V.b=va(X.normalWorld.z);V.updateStyleString();ha.wireframe?ua(V.__styleString,ha.wireframe_linewidth):Pa(V.__styleString)}}}function ua(S,ka){if(x!=S)m.strokeStyle=x=S;if(F!=ka)m.lineWidth=F=ka;m.stroke();
-D.inflate(ka*2)}function Pa(S){if(z!=S)m.fillStyle=z=S;m.fill()}function Na(S,ka,ia,X,ha,ma,ya,Fa,Ha,Oa,za,Ka,Ma){var Ja,Ga;Ja=ya.width-1;Ga=ya.height-1;Fa*=Ja;Ha*=Ga;Oa*=Ja;za*=Ga;Ka*=Ja;Ma*=Ga;ia-=S;X-=ka;ha-=S;ma-=ka;Oa-=Fa;za-=Ha;Ka-=Fa;Ma-=Ha;Ja=Oa*Ma-Ka*za;if(Ja!=0){Ga=1/Ja;Ja=(Ma*ia-za*ha)*Ga;za=(Ma*X-za*ma)*Ga;ia=(Oa*ha-Ka*ia)*Ga;X=(Oa*ma-Ka*X)*Ga;S=S-Ja*Fa-ia*Ha;ka=ka-za*Fa-X*Ha;m.save();m.transform(Ja,za,ia,X,S,ka);m.clip();m.drawImage(ya,0,0);m.restore()}}function La(S,ka,ia,X){var ha=
-~~(S.r*255),ma=~~(S.g*255);S=~~(S.b*255);var ya=~~(ka.r*255),Fa=~~(ka.g*255);ka=~~(ka.b*255);var Ha=~~(ia.r*255),Oa=~~(ia.g*255);ia=~~(ia.b*255);var za=~~(X.r*255),Ka=~~(X.g*255);X=~~(X.b*255);N[0]=ha<0?0:ha>255?255:ha;N[1]=ma<0?0:ma>255?255:ma;N[2]=S<0?0:S>255?255:S;N[4]=ya<0?0:ya>255?255:ya;N[5]=Fa<0?0:Fa>255?255:Fa;N[6]=ka<0?0:ka>255?255:ka;N[8]=Ha<0?0:Ha>255?255:Ha;N[9]=Oa<0?0:Oa>255?255:Oa;N[10]=ia<0?0:ia>255?255:ia;N[12]=za<0?0:za>255?255:za;N[13]=Ka<0?0:Ka>255?255:Ka;N[14]=X<0?0:X>255?255:
-X;ba.putImageData(ta,0,0);xa.drawImage(U,0,0);return Ba}function qa(S,ka,ia){S=(S-ka)/(ia-ka);return S*S*(3-2*S)}function va(S){S=(S+1)*0.5;return S<0?0:S>1?1:S}function ra(S,ka){var ia=ka.x-S.x,X=ka.y-S.y,ha=1/Math.sqrt(ia*ia+X*X);ia*=ha;X*=ha;ka.x+=ia;ka.y+=X;S.x-=ia;S.y-=X}var pa,sa,ja,Ca,Aa,Ra,Da,Qa;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,j);c=d.projectScene(W,Z,this.sortElements);(J=W.lights.length>0)&&fa(W);pa=0;for(sa=c.length;pa<sa;pa++){ja=c[pa];D.empty();if(ja instanceof THREE.RenderableParticle){u=
-ja;u.x*=k;u.y*=j;Ca=0;for(Aa=ja.materials.length;Ca<Aa;Ca++)Ia(u,ja,ja.materials[Ca],W)}else if(ja instanceof THREE.RenderableLine){u=ja.v1;e=ja.v2;u.positionScreen.x*=k;u.positionScreen.y*=j;e.positionScreen.x*=k;e.positionScreen.y*=j;D.addPoint(u.positionScreen.x,u.positionScreen.y);D.addPoint(e.positionScreen.x,e.positionScreen.y);if(H.instersects(D)){Ca=0;for(Aa=ja.materials.length;Ca<Aa;)wa(u,e,ja,ja.materials[Ca++],W)}}else if(ja instanceof THREE.RenderableFace3){u=ja.v1;e=ja.v2;q=ja.v3;u.positionScreen.x*=
-k;u.positionScreen.y*=j;e.positionScreen.x*=k;e.positionScreen.y*=j;q.positionScreen.x*=k;q.positionScreen.y*=j;if(ja.overdraw){ra(u.positionScreen,e.positionScreen);ra(e.positionScreen,q.positionScreen);ra(q.positionScreen,u.positionScreen)}D.add3Points(u.positionScreen.x,u.positionScreen.y,e.positionScreen.x,e.positionScreen.y,q.positionScreen.x,q.positionScreen.y);if(H.instersects(D)){Ca=0;for(Aa=ja.meshMaterials.length;Ca<Aa;){Qa=ja.meshMaterials[Ca++];if(Qa instanceof THREE.MeshFaceMaterial){Ra=
-0;for(Da=ja.faceMaterials.length;Ra<Da;)(Qa=ja.faceMaterials[Ra++])&&M(u,e,q,ja,Qa,W)}else M(u,e,q,ja,Qa,W)}}}T.addRectangle(D)}m.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(A,y,v){var o,B,E,H;o=0;for(B=A.lights.length;o<B;o++){E=A.lights[o];if(E instanceof THREE.DirectionalLight){H=y.normalWorld.dot(E.position)*E.intensity;if(H>0){v.r+=E.color.r*H;v.g+=E.color.g*H;v.b+=E.color.b*H}}else if(E instanceof THREE.PointLight){Y.sub(E.position,y.centroidWorld);Y.normalize();H=y.normalWorld.dot(Y)*E.intensity;if(H>0){v.r+=E.color.r*H;v.g+=E.color.g*H;v.b+=E.color.b*H}}}}function b(A,y,v,o,B,E){G=d($++);G.setAttribute("d","M "+A.positionScreen.x+
-" "+A.positionScreen.y+" L "+y.positionScreen.x+" "+y.positionScreen.y+" L "+v.positionScreen.x+","+v.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)q.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(e){O.r=R.r;O.g=R.g;O.b=R.b;a(E,o,O);q.r=B.color.r*O.r;q.g=B.color.g*O.g;q.b=B.color.b*O.b;q.updateStyleString()}else q.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){I=1-B.__2near/(B.__farPlusNear-o.z*B.__farMinusNear);
-q.setRGB(I,I,I)}else B instanceof THREE.MeshNormalMaterial&&q.setRGB(f(o.normalWorld.x),f(o.normalWorld.y),f(o.normalWorld.z));B.wireframe?G.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):G.setAttribute("style","fill: "+q.__styleString+"; fill-opacity: "+B.opacity);k.appendChild(G)}function c(A,y,v,o,B,E,H){G=d($++);G.setAttribute("d",
-"M "+A.positionScreen.x+" "+A.positionScreen.y+" L "+y.positionScreen.x+" "+y.positionScreen.y+" L "+v.positionScreen.x+","+v.positionScreen.y+" L "+o.positionScreen.x+","+o.positionScreen.y+"z");if(E instanceof THREE.MeshBasicMaterial)q.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshLambertMaterial)if(e){O.r=R.r;O.g=R.g;O.b=R.b;a(H,B,O);q.r=E.color.r*O.r;q.g=E.color.g*O.g;q.b=E.color.b*O.b;q.updateStyleString()}else q.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshDepthMaterial){I=
-1-E.__2near/(E.__farPlusNear-B.z*E.__farMinusNear);q.setRGB(I,I,I)}else E instanceof THREE.MeshNormalMaterial&&q.setRGB(f(B.normalWorld.x),f(B.normalWorld.y),f(B.normalWorld.z));E.wireframe?G.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframe_linecap+"; stroke-linejoin: "+E.wireframe_linejoin):G.setAttribute("style","fill: "+q.__styleString+"; fill-opacity: "+E.opacity);k.appendChild(G)}
-function d(A){if(V[A]==null){V[A]=document.createElementNS("http://www.w3.org/2000/svg","path");l==0&&V[A].setAttribute("shape-rendering","crispEdges")}return V[A]}function f(A){return A<0?Math.min((1+A)*0.5,0.5):0.5+Math.min(A*0.5,0.5)}var g=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,n,w,t,p,x,z,F=new THREE.Rectangle,u=new THREE.Rectangle,e=!1,q=new THREE.Color(16777215),O=new THREE.Color(16777215),R=new THREE.Color(0),ea=new THREE.Color(0),L=new THREE.Color(0),
-I,Y=new THREE.Vector3,V=[],ca=[],da=[],G,$,na,aa,l=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(A){switch(A){case "high":l=1;break;case "low":l=0}};this.setSize=function(A,y){j=A;m=y;n=j/2;w=m/2;k.setAttribute("viewBox",-n+" "+-w+" "+j+" "+m);k.setAttribute("width",j);k.setAttribute("height",m);F.set(-n,-w,n,w)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(A,y){var v,o,B,E,H,T,D,J;
-this.autoClear&&this.clear();g=h.projectScene(A,y,this.sortElements);aa=na=$=0;if(e=A.lights.length>0){D=A.lights;R.setRGB(0,0,0);ea.setRGB(0,0,0);L.setRGB(0,0,0);v=0;for(o=D.length;v<o;v++){B=D[v];E=B.color;if(B instanceof THREE.AmbientLight){R.r+=E.r;R.g+=E.g;R.b+=E.b}else if(B instanceof THREE.DirectionalLight){ea.r+=E.r;ea.g+=E.g;ea.b+=E.b}else if(B instanceof THREE.PointLight){L.r+=E.r;L.g+=E.g;L.b+=E.b}}}v=0;for(o=g.length;v<o;v++){D=g[v];u.empty();if(D instanceof THREE.RenderableParticle){t=
-D;t.x*=n;t.y*=-w;B=0;for(E=D.materials.length;B<E;B++)if(J=D.materials[B]){H=t;T=D;var P=na++;if(ca[P]==null){ca[P]=document.createElementNS("http://www.w3.org/2000/svg","circle");l==0&&ca[P].setAttribute("shape-rendering","crispEdges")}G=ca[P];G.setAttribute("cx",H.x);G.setAttribute("cy",H.y);G.setAttribute("r",T.scale.x*n);if(J instanceof THREE.ParticleCircleMaterial){if(e){O.r=R.r+ea.r+L.r;O.g=R.g+ea.g+L.g;O.b=R.b+ea.b+L.b;q.r=J.color.r*O.r;q.g=J.color.g*O.g;q.b=J.color.b*O.b;q.updateStyleString()}else q=
-J.color;G.setAttribute("style","fill: "+q.__styleString)}k.appendChild(G)}}else if(D instanceof THREE.RenderableLine){t=D.v1;p=D.v2;t.positionScreen.x*=n;t.positionScreen.y*=-w;p.positionScreen.x*=n;p.positionScreen.y*=-w;u.addPoint(t.positionScreen.x,t.positionScreen.y);u.addPoint(p.positionScreen.x,p.positionScreen.y);if(F.instersects(u)){B=0;for(E=D.materials.length;B<E;)if(J=D.materials[B++]){H=t;T=p;P=aa++;if(da[P]==null){da[P]=document.createElementNS("http://www.w3.org/2000/svg","line");l==
-0&&da[P].setAttribute("shape-rendering","crispEdges")}G=da[P];G.setAttribute("x1",H.positionScreen.x);G.setAttribute("y1",H.positionScreen.y);G.setAttribute("x2",T.positionScreen.x);G.setAttribute("y2",T.positionScreen.y);if(J instanceof THREE.LineBasicMaterial){q.__styleString=J.color.__styleString;G.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+J.linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.linecap+"; stroke-linejoin: "+J.linejoin);k.appendChild(G)}}}}else if(D instanceof
-THREE.RenderableFace3){t=D.v1;p=D.v2;x=D.v3;t.positionScreen.x*=n;t.positionScreen.y*=-w;p.positionScreen.x*=n;p.positionScreen.y*=-w;x.positionScreen.x*=n;x.positionScreen.y*=-w;u.addPoint(t.positionScreen.x,t.positionScreen.y);u.addPoint(p.positionScreen.x,p.positionScreen.y);u.addPoint(x.positionScreen.x,x.positionScreen.y);if(F.instersects(u)){B=0;for(E=D.meshMaterials.length;B<E;){J=D.meshMaterials[B++];if(J instanceof THREE.MeshFaceMaterial){H=0;for(T=D.faceMaterials.length;H<T;)(J=D.faceMaterials[H++])&&
-b(t,p,x,D,J,A)}else J&&b(t,p,x,D,J,A)}}}else if(D instanceof THREE.RenderableFace4){t=D.v1;p=D.v2;x=D.v3;z=D.v4;t.positionScreen.x*=n;t.positionScreen.y*=-w;p.positionScreen.x*=n;p.positionScreen.y*=-w;x.positionScreen.x*=n;x.positionScreen.y*=-w;z.positionScreen.x*=n;z.positionScreen.y*=-w;u.addPoint(t.positionScreen.x,t.positionScreen.y);u.addPoint(p.positionScreen.x,p.positionScreen.y);u.addPoint(x.positionScreen.x,x.positionScreen.y);u.addPoint(z.positionScreen.x,z.positionScreen.y);if(F.instersects(u)){B=
-0;for(E=D.meshMaterials.length;B<E;){J=D.meshMaterials[B++];if(J instanceof THREE.MeshFaceMaterial){H=0;for(T=D.faceMaterials.length;H<T;)(J=D.faceMaterials[H++])&&c(t,p,x,z,D,J,A)}else J&&c(t,p,x,z,D,J,A)}}}}}};
-THREE.WebGLRenderer=function(a){function b(l,A,y){var v,o,B,E=l.vertices,H=E.length,T=l.colors,D=T.length,J=l.__vertexArray,P=l.__colorArray,ga=l.__sortArray,la=l.__dirtyVertices,C=l.__dirtyColors;if(y.sortParticles){Y.multiplySelf(y.globalMatrix);for(v=0;v<H;v++){o=E[v].position;G.copy(o);Y.multiplyVector3(G);ga[v]=[G.z,v]}ga.sort(function(Q,K){return K[0]-Q[0]});for(v=0;v<H;v++){o=E[ga[v][1]].position;B=v*3;J[B]=o.x;J[B+1]=o.y;J[B+2]=o.z}for(v=0;v<D;v++){B=v*3;color=T[ga[v][1]];P[B]=color.r;P[B+
-1]=color.g;P[B+2]=color.b}}else{if(la)for(v=0;v<H;v++){o=E[v].position;B=v*3;J[B]=o.x;J[B+1]=o.y;J[B+2]=o.z}if(C)for(v=0;v<D;v++){color=T[v];B=v*3;P[B]=color.r;P[B+1]=color.g;P[B+2]=color.b}}if(la||y.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,J,A)}if(C||y.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,P,A)}}function c(l,A){l.fragment_shader=A.fragment_shader;l.vertex_shader=A.vertex_shader;l.uniforms=
-Uniforms.clone(A.uniforms)}function d(l,A){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=e.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=e.createBuffer();if(l.hasPos){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,l.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(A.attributes.position);e.vertexAttribPointer(A.attributes.position,3,e.FLOAT,!1,0,0)}if(l.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,
-l.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(A.attributes.normal);e.vertexAttribPointer(A.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,l.count);l.count=0}function f(l){if(R!=l.doubleSided){l.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);R=l.doubleSided}if(ea!=l.flipSided){l.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);ea=l.flipSided}}function g(l){I[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,l.n44-l.n14);I[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+
-l.n14);I[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);I[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);I[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);I[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var A;for(l=0;l<5;l++){A=I[l];A.divideScalar(Math.sqrt(A.x*A.x+A.y*A.y+A.z*A.z))}}function h(l){for(var A=l.globalMatrix,y=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),v=0;v<6;v++){l=I[v].x*A.n14+I[v].y*A.n24+I[v].z*A.n34+I[v].w;
-if(l<=y)return!1}return!0}function k(l,A){l.list[l.count]=A;l.count+=1}function j(l){var A,y,v=l.object,o=l.opaque,B=l.transparent;B.count=0;l=o.count=0;for(A=v.materials.length;l<A;l++){y=v.materials[l];y.opacity&&y.opacity<1||y.blending!=THREE.NormalBlending?k(B,y):k(o,y)}}function m(l){var A,y,v,o,B=l.object,E=l.buffer,H=l.opaque,T=l.transparent;T.count=0;l=H.count=0;for(v=B.materials.length;l<v;l++){A=B.materials[l];if(A instanceof THREE.MeshFaceMaterial){A=0;for(y=E.materials.length;A<y;A++)(o=
-E.materials[A])&&(o.opacity&&o.opacity<1||o.blending!=THREE.NormalBlending?k(T,o):k(H,o))}else{o=A;o.opacity&&o.opacity<1||o.blending!=THREE.NormalBlending?k(T,o):k(H,o)}}}function n(l,A){return A.z-l.z}function w(l,A,y,v,o){if(A[y]==undefined){l.push({buffer:v,object:o,opaque:{list:[],count:0},transparent:{list:[],count:0}});A[y]=1}}function t(l,A){l._modelViewMatrix.multiplyToArray(A.globalMatrix,l.globalMatrix,l._modelViewMatrixArray);l._normalMatrix=THREE.Matrix4.makeInvert3x3(l._modelViewMatrix).transposeIntoArray(l._normalMatrixArray)}
-function p(l){if(l!=L){switch(l){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE);break;case THREE.SubtractiveBlending:e.blendFunc(e.DST_COLOR,e.ZERO);break;case THREE.BillboardBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);break;default:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}L=l}}function x(l,A){if(l&&!l.__webGLFramebuffer){l.__webGLFramebuffer=e.createFramebuffer();l.__webGLRenderbuffer=e.createRenderbuffer();
-l.__webGLTexture=e.createTexture();e.bindRenderbuffer(e.RENDERBUFFER,l.__webGLRenderbuffer);e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,l.width,l.height);e.bindTexture(e.TEXTURE_2D,l.__webGLTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,F(l.wrap_s));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,F(l.wrap_t));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,F(l.mag_filter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,F(l.min_filter));e.texImage2D(e.TEXTURE_2D,0,F(l.format),
-l.width,l.height,0,F(l.format),F(l.type),null);e.bindFramebuffer(e.FRAMEBUFFER,l.__webGLFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,l.__webGLTexture,0);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,l.__webGLRenderbuffer);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var y,v,o;if(l){y=l.__webGLFramebuffer;v=l.width;o=l.height}else{y=null;v=u.width;o=u.height}if(y!=O){e.bindFramebuffer(e.FRAMEBUFFER,
-y);e.viewport(0,0,v,o);A&&e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT);O=y}}function z(l,A){var y;if(l=="fragment")y=e.createShader(e.FRAGMENT_SHADER);else l=="vertex"&&(y=e.createShader(e.VERTEX_SHADER));e.shaderSource(y,A);e.compileShader(y);if(!e.getShaderParameter(y,e.COMPILE_STATUS)){alert(e.getShaderInfoLog(y));return null}return y}function F(l){switch(l){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;
-case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;
-case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var u=document.createElement("canvas"),e,q=null,O=null,R=null,ea=null,L=null,I=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,
-new THREE.Vector4],Y=new THREE.Matrix4,V=new Float32Array(16),ca=new Float32Array(16),da=new Float32Array(16),G=new THREE.Vector4,$=!0,na=new THREE.Color(0),aa=0;if(a){if(a.antialias!==undefined)$=a.antialias;a.clearColor!==undefined&&na.setHex(a.clearColor);if(a.clearAlpha!==undefined)aa=a.clearAlpha}this.domElement=u;this.autoClear=!0;this.sortObjects=!1;(function(l,A,y){try{e=u.getContext("experimental-webgl",{antialias:l})}catch(v){console.log(v)}if(!e){alert("WebGL not supported");throw"cannot create webgl context";
-}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);e.clearColor(A.r,A.g,A.b,y);_cullEnabled=!0})($,na,aa);this.context=e;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,A){u.width=l;u.height=A;e.viewport(0,0,u.width,u.height)};this.setClearColorHex=function(l,
-A){var y=new THREE.Color(l);e.clearColor(y.r,y.g,y.b,A)};this.setClearColor=function(l,A){e.clearColor(l.r,l.g,l.b,A)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)};this.setupLights=function(l,A){var y,v,o,B=0,E=0,H=0,T,D,J,P=this.lights,ga=P.directional.colors,la=P.directional.positions,C=P.point.colors,Q=P.point.positions,K=0,U=0;y=o=o=0;for(v=A.length;y<v;y++){o=A[y];T=o.color;D=o.position;J=o.intensity;if(o instanceof THREE.AmbientLight){B+=T.r;E+=T.g;H+=T.b}else if(o instanceof
-THREE.DirectionalLight){o=K*3;ga[o]=T.r*J;ga[o+1]=T.g*J;ga[o+2]=T.b*J;la[o]=D.x;la[o+1]=D.y;la[o+2]=D.z;K+=1}else if(o instanceof THREE.PointLight){o=U*3;C[o]=T.r*J;C[o+1]=T.g*J;C[o+2]=T.b*J;Q[o]=D.x;Q[o+1]=D.y;Q[o+2]=D.z;U+=1}}for(y=K*3;y<ga.length;y++)ga[y]=0;for(y=U*3;y<C.length;y++)C[y]=0;P.point.length=U;P.directional.length=K;P.ambient[0]=B;P.ambient[1]=E;P.ambient[2]=H};this.initMaterial=function(l,A,y){var v,o;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 B,E,H,T;o=H=T=0;for(B=A.length;o<B;o++){E=A[o];E instanceof THREE.DirectionalLight&&
-H++;E instanceof THREE.PointLight&&T++}if(T+H<=4)A=H;else{A=Math.ceil(4*H/(T+H));T=4-A}o={directional:A,point:T};T=l.fragment_shader;A=l.vertex_shader;B={fog:y,map:l.map,env_map:l.env_map,light_map:l.light_map,vertex_colors:l.vertex_colors,skinning:l.skinning,maxDirLights:o.directional,maxPointLights:o.point};y=e.createProgram();o=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+B.maxDirLights,"#define MAX_POINT_LIGHTS "+B.maxPointLights,B.fog?"#define USE_FOG":"",B.fog instanceof
-THREE.FogExp2?"#define FOG_EXP2":"",B.map?"#define USE_MAP":"",B.env_map?"#define USE_ENVMAP":"",B.light_map?"#define USE_LIGHTMAP":"",B.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");B=[e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+B.maxDirLights,"#define MAX_POINT_LIGHTS "+B.maxPointLights,B.map?"#define USE_MAP":"",B.env_map?"#define USE_ENVMAP":"",B.light_map?"#define USE_LIGHTMAP":
-"",B.vertex_colors?"#define USE_COLOR":"",B.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
-e.attachShader(y,z("fragment",o+T));e.attachShader(y,z("vertex",B+A));e.linkProgram(y);e.getProgramParameter(y,e.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+e.getProgramParameter(y,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");y.uniforms={};y.attributes={};l.program=y;y=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","uBoneGlobalMatrices"];for(v in l.uniforms)y.push(v);v=l.program;T=0;for(A=y.length;T<
-A;T++){o=y[T];v.uniforms[o]=e.getUniformLocation(v,o)}l=l.program;v=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];y=0;for(T=v.length;y<T;y++){A=v[y];l.attributes[A]=e.getAttribLocation(l,A)}};this.setProgram=function(l,A,y,v,o){v.program||this.initMaterial(v,A,y);var B=v.program,E=B.uniforms,H=v.uniforms;if(B!=q){e.useProgram(B);q=B;e.uniformMatrix4fv(E.projectionMatrix,!1,V)}if(y&&(v instanceof THREE.MeshBasicMaterial||v instanceof THREE.MeshLambertMaterial||
-v instanceof THREE.MeshPhongMaterial||v instanceof THREE.LineBasicMaterial||v instanceof THREE.ParticleBasicMaterial)){H.fogColor.value.setHex(y.color.hex);if(y instanceof THREE.Fog){H.fogNear.value=y.near;H.fogFar.value=y.far}else if(y instanceof THREE.FogExp2)H.fogDensity.value=y.density}if(v instanceof THREE.MeshPhongMaterial||v instanceof THREE.MeshLambertMaterial){this.setupLights(B,A);A=this.lights;H.enableLighting.value=A.directional.length+A.point.length;H.ambientLightColor.value=A.ambient;
-H.directionalLightColor.value=A.directional.colors;H.directionalLightDirection.value=A.directional.positions;H.pointLightColor.value=A.point.colors;H.pointLightPosition.value=A.point.positions}if(v instanceof THREE.MeshBasicMaterial||v instanceof THREE.MeshLambertMaterial||v instanceof THREE.MeshPhongMaterial){H.diffuse.value.setRGB(v.color.r*v.opacity,v.color.g*v.opacity,v.color.b*v.opacity);H.opacity.value=v.opacity;H.map.texture=v.map;H.light_map.texture=v.light_map;H.env_map.texture=v.env_map;
-H.reflectivity.value=v.reflectivity;H.refraction_ratio.value=v.refraction_ratio;H.combine.value=v.combine;H.useRefract.value=v.env_map&&v.env_map.mapping instanceof THREE.CubeRefractionMapping}if(v instanceof THREE.LineBasicMaterial){H.diffuse.value.setRGB(v.color.r*v.opacity,v.color.g*v.opacity,v.color.b*v.opacity);H.opacity.value=v.opacity}else if(v instanceof THREE.ParticleBasicMaterial){H.psColor.value.setRGB(v.color.r*v.opacity,v.color.g*v.opacity,v.color.b*v.opacity);H.opacity.value=v.opacity;
-H.size.value=v.size;H.map.texture=v.map}else if(v instanceof THREE.MeshPhongMaterial){H.ambient.value.setRGB(v.ambient.r,v.ambient.g,v.ambient.b);H.specular.value.setRGB(v.specular.r,v.specular.g,v.specular.b);H.shininess.value=v.shininess}else if(v instanceof THREE.MeshDepthMaterial){H.mNear.value=l.near;H.mFar.value=l.far;H.opacity.value=v.opacity}else if(v instanceof THREE.MeshNormalMaterial)H.opacity.value=v.opacity;var T,D,J;for(T in H)if(J=B.uniforms[T]){y=H[T];D=y.type;A=y.value;if(D=="i")e.uniform1i(J,
-A);else if(D=="f")e.uniform1f(J,A);else if(D=="fv1")e.uniform1fv(J,A);else if(D=="fv")e.uniform3fv(J,A);else if(D=="v2")e.uniform2f(J,A.x,A.y);else if(D=="v3")e.uniform3f(J,A.x,A.y,A.z);else if(D=="c")e.uniform3f(J,A.r,A.g,A.b);else if(D=="t"){e.uniform1i(J,A);if(y=y.texture)if(y.image instanceof Array&&y.image.length==6){if(y.image.length==6){if(!y.image.__webGLTextureCube&&!y.image.__cubeMapInitialized&&y.image.loadCount==6){y.image.__webGLTextureCube=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,
-y.image.__webGLTextureCube);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAG_FILTER,e.LINEAR);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR);for(D=0;D<6;++D)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,y.image[D]);e.generateMipmap(e.TEXTURE_CUBE_MAP);e.bindTexture(e.TEXTURE_CUBE_MAP,null);y.image.__cubeMapInitialized=
-!0}e.activeTexture(e.TEXTURE0+A);e.bindTexture(e.TEXTURE_CUBE_MAP,y.image.__webGLTextureCube)}}else{if(!y.__webGLTexture&&y.image.loaded){y.__webGLTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,y.__webGLTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,y.image);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,F(y.wrap_s));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,F(y.wrap_t));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,F(y.mag_filter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,
-F(y.min_filter));e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)}e.activeTexture(e.TEXTURE0+A);e.bindTexture(e.TEXTURE_2D,y.__webGLTexture)}}}e.uniformMatrix4fv(E.modelViewMatrix,!1,o._modelViewMatrixArray);e.uniformMatrix3fv(E.normalMatrix,!1,o._normalMatrixArray);(v instanceof THREE.MeshShaderMaterial||v instanceof THREE.MeshPhongMaterial||v.env_map)&&e.uniform3f(E.cameraPosition,l.position.x,l.position.y,l.position.z);(v instanceof THREE.MeshShaderMaterial||v.env_map||v.skinning)&&
-e.uniformMatrix4fv(E.objectMatrix,!1,o._objectMatrixArray);(v instanceof THREE.MeshPhongMaterial||v instanceof THREE.MeshLambertMaterial||v instanceof THREE.MeshShaderMaterial||v.skinning)&&e.uniformMatrix4fv(E.viewMatrix,!1,da);if(v.skinning){e.uniformMatrix4fv(E.cameraInverseMatrix,!1,ca);e.uniformMatrix4fv(E.uBoneGlobalMatrices,!1,o.boneMatrices)}return B};this.renderBuffer=function(l,A,y,v,o,B){l=this.setProgram(l,A,y,v,B).attributes;e.bindBuffer(e.ARRAY_BUFFER,o.__webGLVertexBuffer);e.vertexAttribPointer(l.position,
-3,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.position);if(l.color>=0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLColorBuffer);e.vertexAttribPointer(l.color,3,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.color)}if(l.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLNormalBuffer);e.vertexAttribPointer(l.normal,3,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.normal)}if(l.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLTangentBuffer);e.vertexAttribPointer(l.tangent,4,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.tangent)}if(l.uv>=
-0)if(o.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLUVBuffer);e.vertexAttribPointer(l.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.uv)}else e.disableVertexAttribArray(l.uv);if(l.uv2>=0)if(o.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLUV2Buffer);e.vertexAttribPointer(l.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.uv2)}else e.disableVertexAttribArray(l.uv2);if(B instanceof THREE.SkinnedMesh){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexABuffer);e.vertexAttribPointer(l.skinVertexA,
-4,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.skinVertexA);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);e.vertexAttribPointer(l.skinVertexB,4,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.skinVertexB);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer);e.vertexAttribPointer(l.skinIndex,4,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.skinIndex);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);e.vertexAttribPointer(l.skinWeight,4,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.skinWeight)}if(B instanceof
-THREE.Mesh)if(v.wireframe){e.lineWidth(v.wireframe_linewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);e.drawElements(e.LINES,o.__webGLLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);e.drawElements(e.TRIANGLES,o.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else if(B instanceof THREE.Line){B=B.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(v.linewidth);e.drawArrays(B,0,o.__webGLLineCount)}else B instanceof THREE.ParticleSystem&&e.drawArrays(e.POINTS,
-0,o.__webGLParticleCount)};this.render=function(l,A,y,v){var o,B,E,H,T,D,J,P,ga=l.lights,la=l.fog;A.autoUpdateMatrix&&A.update();A.globalMatrix.flattenToArray(da);A.projectionMatrix.flattenToArray(V);A.inverseMatrix.flattenToArray(ca);Y.multiply(A.projectionMatrix,A.globalMatrix);g(Y);THREE.AnimationHandler&&THREE.AnimationHandler.update();l.update(undefined,!1,A);this.initWebGLObjects(l,A);x(y,v!==undefined?v:!0);this.autoClear&&this.clear();T=l.__webGLObjects.length;for(v=0;v<T;v++){o=l.__webGLObjects[v];
-J=o.object;if(J.visible)if(!(J instanceof THREE.Mesh)||h(J)){J.globalMatrix.flattenToArray(J._objectMatrixArray);t(J,A);m(o);o.render=!0;if(this.sortObjects){G.copy(J.position);Y.multiplyVector3(G);o.z=G.z}}else o.render=!1;else o.render=!1}this.sortObjects&&l.__webGLObjects.sort(n);D=l.__webGLObjectsImmediate.length;for(v=0;v<D;v++){o=l.__webGLObjectsImmediate[v];J=o.object;if(J.visible){J.autoUpdateMatrix&&J.globalMatrix.flattenToArray(J._objectMatrixArray);t(J,A);j(o)}}p(THREE.NormalBlending);
-for(v=0;v<T;v++){o=l.__webGLObjects[v];if(o.render){J=o.object;P=o.buffer;E=o.opaque;f(J);for(o=0;o<E.count;o++){H=E.list[o];this.setDepthTest(H.depth_test);this.renderBuffer(A,ga,la,H,P,J)}}}for(v=0;v<D;v++){o=l.__webGLObjectsImmediate[v];J=o.object;if(J.visible){E=o.opaque;f(J);for(o=0;o<E.count;o++){H=E.list[o];this.setDepthTest(H.depth_test);B=this.setProgram(A,ga,la,H,J);J.render(function(C){d(C,B)})}}}for(v=0;v<T;v++){o=l.__webGLObjects[v];if(o.render){J=o.object;P=o.buffer;E=o.transparent;
-f(J);for(o=0;o<E.count;o++){H=E.list[o];p(H.blending);this.setDepthTest(H.depth_test);this.renderBuffer(A,ga,la,H,P,J)}}}for(v=0;v<D;v++){o=l.__webGLObjectsImmediate[v];J=o.object;if(J.visible){E=o.transparent;f(J);for(o=0;o<E.count;o++){H=E.list[o];p(H.blending);this.setDepthTest(H.depth_test);B=this.setProgram(A,ga,la,H,J);J.render(function(C){d(C,B)})}}}if(y&&y.min_filter!==THREE.NearestFilter&&y.min_filter!==THREE.LinearFilter){e.bindTexture(e.TEXTURE_2D,y.__webGLTexture);e.generateMipmap(e.TEXTURE_2D);
-e.bindTexture(e.TEXTURE_2D,null)}};this.initWebGLObjects=function(l){var A,y,v;if(!l.__webGLObjects){l.__webGLObjects=[];l.__webGLObjectsMap={};l.__webGLObjectsImmediate=[]}A=0;for(y=l.objects.length;A<y;A++){v=l.objects[A];var o=l,B=void 0,E=void 0,H=void 0,T=void 0;E=v.geometry;if(o.__webGLObjectsMap[v.id]==undefined){o.__webGLObjectsMap[v.id]={};v._modelViewMatrix=new THREE.Matrix4;v._normalMatrixArray=new Float32Array(9);v._modelViewMatrixArray=new Float32Array(16);v._objectMatrixArray=new Float32Array(16);
-v.globalMatrix.flattenToArray(v._objectMatrixArray)}T=o.__webGLObjectsMap[v.id];objlist=o.__webGLObjects;if(v instanceof THREE.Mesh){for(B in E.geometryChunks){H=E.geometryChunks[B];if(!H.__webGLVertexBuffer){o=H;o.__webGLVertexBuffer=e.createBuffer();o.__webGLNormalBuffer=e.createBuffer();o.__webGLTangentBuffer=e.createBuffer();o.__webGLColorBuffer=e.createBuffer();o.__webGLUVBuffer=e.createBuffer();o.__webGLUV2Buffer=e.createBuffer();o.__webGLSkinVertexABuffer=e.createBuffer();o.__webGLSkinVertexBBuffer=
-e.createBuffer();o.__webGLSkinIndicesBuffer=e.createBuffer();o.__webGLSkinWeightsBuffer=e.createBuffer();o.__webGLFaceBuffer=e.createBuffer();o.__webGLLineBuffer=e.createBuffer();o=H;var D=v,J=void 0,P=void 0,ga=0,la=0,C=0,Q=D.geometry.faces,K=o.faces;J=0;for(P=K.length;J<P;J++){fi=K[J];face=Q[fi];if(face instanceof THREE.Face3){ga+=3;la+=1;C+=3}else if(face instanceof THREE.Face4){ga+=4;la+=2;C+=4}}o.__vertexArray=new Float32Array(ga*3);o.__normalArray=new Float32Array(ga*3);o.__tangentArray=new Float32Array(ga*
-4);o.__colorArray=new Float32Array(ga*3);o.__uvArray=new Float32Array(ga*2);o.__uv2Array=new Float32Array(ga*2);o.__skinVertexAArray=new Float32Array(ga*4);o.__skinVertexBArray=new Float32Array(ga*4);o.__skinIndexArray=new Float32Array(ga*4);o.__skinWeightArray=new Float32Array(ga*4);o.__faceArray=new Uint16Array(la*3);o.__lineArray=new Uint16Array(C*2);P=J=o;ga=void 0;Q=void 0;var U=void 0,ba=void 0;U=void 0;K=!1;ga=0;for(Q=D.materials.length;ga<Q;ga++){U=D.materials[ga];if(U instanceof THREE.MeshFaceMaterial){U=
-0;for(ba=P.materials.length;U<ba;U++)if(P.materials[U]&&P.materials[U].shading!=undefined&&P.materials[U].shading==THREE.SmoothShading){K=!0;break}}else if(U&&U.shading!=undefined&&U.shading==THREE.SmoothShading){K=!0;break}if(K)break}J.__needsSmoothNormals=K;o.__webGLFaceCount=la*3;o.__webGLLineCount=C*2;E.__dirtyVertices=!0;E.__dirtyElements=!0;E.__dirtyUvs=!0;E.__dirtyNormals=!0;E.__dirtyTangents=!0;E.__dirtyColors=!0}if(E.__dirtyVertices||E.__dirtyElements||E.__dirtyUvs||E.__dirtyNormals||E.__dirtyColors||
-E.__dirtyTangents){o=H;la=e.DYNAMIC_DRAW;C=void 0;J=void 0;var ta=void 0,N=void 0,Ba=void 0,xa=void 0,Ea=void 0;ta=void 0;var W=void 0,Z=void 0,fa=void 0,oa=void 0;W=void 0;Z=void 0;fa=void 0;N=void 0;W=void 0;Z=void 0;fa=void 0;oa=void 0;W=void 0;Z=void 0;fa=void 0;oa=void 0;W=void 0;Z=void 0;fa=void 0;oa=void 0;W=void 0;Z=void 0;fa=void 0;oa=void 0;W=void 0;Z=void 0;fa=void 0;oa=void 0;N=void 0;xa=void 0;Ba=void 0;Ea=void 0;var Ia=ba=U=K=Q=ga=D=P=0,wa=0,M=0,ua=o.__vertexArray,Pa=o.__uvArray,Na=
-o.__uv2Array,La=o.__normalArray,qa=o.__tangentArray,va=o.__colorArray,ra=o.__skinVertexAArray,pa=o.__skinVertexBArray,sa=o.__skinIndexArray,ja=o.__skinWeightArray,Ca=o.__faceArray,Aa=o.__lineArray,Ra=o.__needsSmoothNormals,Da=v.geometry,Qa=Da.__dirtyVertices,S=Da.__dirtyElements,ka=Da.__dirtyUvs,ia=Da.__dirtyNormals,X=Da.__dirtyTangents,ha=Da.__dirtyColors,ma=Da.vertices,ya=o.faces,Fa=Da.faces,Ha=Da.uvs,Oa=Da.uvs2,za=Da.colors,Ka=Da.skinVerticesA,Ma=Da.skinVerticesB,Ja=Da.skinIndices,Ga=Da.skinWeights;
-C=0;for(J=ya.length;C<J;C++){ta=ya[C];N=Fa[ta];Ea=Ha[ta];ta=Oa[ta];Ba=N.vertexNormals;xa=N.normal;if(N instanceof THREE.Face3){if(Qa){W=ma[N.a].position;Z=ma[N.b].position;fa=ma[N.c].position;ua[D]=W.x;ua[D+1]=W.y;ua[D+2]=W.z;ua[D+3]=Z.x;ua[D+4]=Z.y;ua[D+5]=Z.z;ua[D+6]=fa.x;ua[D+7]=fa.y;ua[D+8]=fa.z;D+=9}if(Ga.length){W=Ga[N.a];Z=Ga[N.b];fa=Ga[N.c];ja[M]=W.x;ja[M+1]=W.y;ja[M+2]=W.z;ja[M+3]=W.w;ja[M+4]=Z.x;ja[M+5]=Z.y;ja[M+6]=Z.z;ja[M+7]=Z.w;ja[M+8]=fa.x;ja[M+9]=fa.y;ja[M+10]=fa.z;ja[M+11]=fa.w;W=
-Ja[N.a];Z=Ja[N.b];fa=Ja[N.c];sa[M]=W.x;sa[M+1]=W.y;sa[M+2]=W.z;sa[M+3]=W.w;sa[M+4]=Z.x;sa[M+5]=Z.y;sa[M+6]=Z.z;sa[M+7]=Z.w;sa[M+8]=fa.x;sa[M+9]=fa.y;sa[M+10]=fa.z;sa[M+11]=fa.w;W=Ka[N.a];Z=Ka[N.b];fa=Ka[N.c];ra[M]=W.x;ra[M+1]=W.y;ra[M+2]=W.z;ra[M+3]=1;ra[M+4]=Z.x;ra[M+5]=Z.y;ra[M+6]=Z.z;ra[M+7]=1;ra[M+8]=fa.x;ra[M+9]=fa.y;ra[M+10]=fa.z;ra[M+11]=1;W=Ma[N.a];Z=Ma[N.b];fa=Ma[N.c];pa[M]=W.x;pa[M+1]=W.y;pa[M+2]=W.z;pa[M+3]=1;pa[M+4]=Z.x;pa[M+5]=Z.y;pa[M+6]=Z.z;pa[M+7]=1;pa[M+8]=fa.x;pa[M+9]=fa.y;pa[M+
-10]=fa.z;pa[M+11]=1;M+=12}if(ha&&za.length){W=za[N.a];Z=za[N.b];fa=za[N.c];va[wa]=W.r;va[wa+1]=W.g;va[wa+2]=W.b;va[wa+3]=Z.r;va[wa+4]=Z.g;va[wa+5]=Z.b;va[wa+6]=fa.r;va[wa+7]=fa.g;va[wa+8]=fa.b;wa+=9}if(X&&Da.hasTangents){W=ma[N.a].tangent;Z=ma[N.b].tangent;fa=ma[N.c].tangent;qa[ba]=W.x;qa[ba+1]=W.y;qa[ba+2]=W.z;qa[ba+3]=W.w;qa[ba+4]=Z.x;qa[ba+5]=Z.y;qa[ba+6]=Z.z;qa[ba+7]=Z.w;qa[ba+8]=fa.x;qa[ba+9]=fa.y;qa[ba+10]=fa.z;qa[ba+11]=fa.w;ba+=12}if(ia)if(Ba.length==3&&Ra)for(N=0;N<3;N++){xa=Ba[N];La[U]=
-xa.x;La[U+1]=xa.y;La[U+2]=xa.z;U+=3}else for(N=0;N<3;N++){La[U]=xa.x;La[U+1]=xa.y;La[U+2]=xa.z;U+=3}if(ka&&Ea)for(N=0;N<3;N++){Ba=Ea[N];Pa[ga]=Ba.u;Pa[ga+1]=Ba.v;ga+=2}if(ka&&ta)for(N=0;N<3;N++){Ea=ta[N];Na[Q]=Ea.u;Na[Q+1]=Ea.v;Q+=2}if(S){Ca[K]=P;Ca[K+1]=P+1;Ca[K+2]=P+2;K+=3;Aa[Ia]=P;Aa[Ia+1]=P+1;Aa[Ia+2]=P;Aa[Ia+3]=P+2;Aa[Ia+4]=P+1;Aa[Ia+5]=P+2;Ia+=6;P+=3}}else if(N instanceof THREE.Face4){if(Qa){W=ma[N.a].position;Z=ma[N.b].position;fa=ma[N.c].position;oa=ma[N.d].position;ua[D]=W.x;ua[D+1]=W.y;
-ua[D+2]=W.z;ua[D+3]=Z.x;ua[D+4]=Z.y;ua[D+5]=Z.z;ua[D+6]=fa.x;ua[D+7]=fa.y;ua[D+8]=fa.z;ua[D+9]=oa.x;ua[D+10]=oa.y;ua[D+11]=oa.z;D+=12}if(Ga.length){W=Ga[N.a];Z=Ga[N.b];fa=Ga[N.c];oa=Ga[N.d];ja[M]=W.x;ja[M+1]=W.y;ja[M+2]=W.z;ja[M+3]=W.w;ja[M+4]=Z.x;ja[M+5]=Z.y;ja[M+6]=Z.z;ja[M+7]=Z.w;ja[M+8]=fa.x;ja[M+9]=fa.y;ja[M+10]=fa.z;ja[M+11]=fa.w;ja[M+12]=oa.x;ja[M+13]=oa.y;ja[M+14]=oa.z;ja[M+15]=oa.w;W=Ja[N.a];Z=Ja[N.b];fa=Ja[N.c];oa=Ja[N.d];sa[M]=W.x;sa[M+1]=W.y;sa[M+2]=W.z;sa[M+3]=W.w;sa[M+4]=Z.x;sa[M+5]=
-Z.y;sa[M+6]=Z.z;sa[M+7]=Z.w;sa[M+8]=fa.x;sa[M+9]=fa.y;sa[M+10]=fa.z;sa[M+11]=fa.w;sa[M+12]=oa.x;sa[M+13]=oa.y;sa[M+14]=oa.z;sa[M+15]=oa.w;W=Ka[N.a];Z=Ka[N.b];fa=Ka[N.c];oa=Ka[N.d];ra[M]=W.x;ra[M+1]=W.y;ra[M+2]=W.z;ra[M+3]=1;ra[M+4]=Z.x;ra[M+5]=Z.y;ra[M+6]=Z.z;ra[M+7]=1;ra[M+8]=fa.x;ra[M+9]=fa.y;ra[M+10]=fa.z;ra[M+11]=1;ra[M+12]=oa.x;ra[M+13]=oa.y;ra[M+14]=oa.z;ra[M+15]=1;W=Ma[N.a];Z=Ma[N.b];fa=Ma[N.c];oa=Ma[N.d];pa[M]=W.x;pa[M+1]=W.y;pa[M+2]=W.z;pa[M+3]=1;pa[M+4]=Z.x;pa[M+5]=Z.y;pa[M+6]=Z.z;pa[M+
-7]=1;pa[M+8]=fa.x;pa[M+9]=fa.y;pa[M+10]=fa.z;pa[M+11]=1;pa[M+12]=oa.x;pa[M+13]=oa.y;pa[M+14]=oa.z;pa[M+15]=1;M+=16}if(ha&&za.length){W=za[N.a];Z=za[N.b];fa=za[N.c];oa=za[N.d];va[wa]=W.r;va[wa+1]=W.g;va[wa+2]=W.b;va[wa+3]=Z.r;va[wa+4]=Z.g;va[wa+5]=Z.b;va[wa+6]=fa.r;va[wa+7]=fa.g;va[wa+8]=fa.b;va[wa+9]=oa.r;va[wa+10]=oa.g;va[wa+11]=oa.b;wa+=12}if(X&&Da.hasTangents){W=ma[N.a].tangent;Z=ma[N.b].tangent;fa=ma[N.c].tangent;N=ma[N.d].tangent;qa[ba]=W.x;qa[ba+1]=W.y;qa[ba+2]=W.z;qa[ba+3]=W.w;qa[ba+4]=Z.x;
-qa[ba+5]=Z.y;qa[ba+6]=Z.z;qa[ba+7]=Z.w;qa[ba+8]=fa.x;qa[ba+9]=fa.y;qa[ba+10]=fa.z;qa[ba+11]=fa.w;qa[ba+12]=N.x;qa[ba+13]=N.y;qa[ba+14]=N.z;qa[ba+15]=N.w;ba+=16}if(ia)if(Ba.length==4&&Ra)for(N=0;N<4;N++){xa=Ba[N];La[U]=xa.x;La[U+1]=xa.y;La[U+2]=xa.z;U+=3}else for(N=0;N<4;N++){La[U]=xa.x;La[U+1]=xa.y;La[U+2]=xa.z;U+=3}if(ka&&Ea)for(N=0;N<4;N++){Ba=Ea[N];Pa[ga]=Ba.u;Pa[ga+1]=Ba.v;ga+=2}if(ka&&ta)for(N=0;N<4;N++){Ea=ta[N];Na[Q]=Ea.u;Na[Q+1]=Ea.v;Q+=2}if(S){Ca[K]=P;Ca[K+1]=P+1;Ca[K+2]=P+2;Ca[K+3]=P;Ca[K+
-4]=P+2;Ca[K+5]=P+3;K+=6;Aa[Ia]=P;Aa[Ia+1]=P+1;Aa[Ia+2]=P;Aa[Ia+3]=P+3;Aa[Ia+4]=P+1;Aa[Ia+5]=P+2;Aa[Ia+6]=P+2;Aa[Ia+7]=P+3;Ia+=8;P+=4}}}if(Qa){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,ua,la)}if(ha&&za.length){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,va,la)}if(ia){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,La,la)}if(X&&Da.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLTangentBuffer);e.bufferData(e.ARRAY_BUFFER,
-qa,la)}if(ka&&ga>0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,Pa,la)}if(ka&&Q>0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Na,la)}if(S){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ca,la);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Aa,la)}if(M>0){e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,ra,la);
-e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,pa,la);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,sa,la);e.bindBuffer(e.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,ja,la)}}w(objlist,T,B,H,v)}E.__dirtyVertices=!1;E.__dirtyElements=!1;E.__dirtyUvs=!1;E.__dirtyNormals=!1;E.__dirtyTangents=!1;E.__dirtyColors=!1}else if(v instanceof THREE.Line){if(!E.__webGLVertexBuffer){B=E;B.__webGLVertexBuffer=e.createBuffer();
-B.__webGLColorBuffer=e.createBuffer();B=E;H=B.vertices.length;B.__vertexArray=new Float32Array(H*3);B.__colorArray=new Float32Array(H*3);B.__webGLLineCount=H;E.__dirtyVertices=!0;E.__dirtyColors=!0}if(E.__dirtyVertices||E.__dirtyColors){B=E;H=e.DYNAMIC_DRAW;P=void 0;P=void 0;D=void 0;o=void 0;ga=B.vertices;la=B.colors;Q=ga.length;C=la.length;K=B.__vertexArray;J=B.__colorArray;U=B.__dirtyColors;if(B.__dirtyVertices){for(P=0;P<Q;P++){D=ga[P].position;o=P*3;K[o]=D.x;K[o+1]=D.y;K[o+2]=D.z}e.bindBuffer(e.ARRAY_BUFFER,
-B.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,K,H)}if(U){for(P=0;P<C;P++){color=la[P];o=P*3;J[o]=color.r;J[o+1]=color.g;J[o+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,B.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,J,H)}}w(objlist,T,0,E,v);E.__dirtyVertices=!1;E.__dirtyColors=!1}else if(v instanceof THREE.ParticleSystem){if(!E.__webGLVertexBuffer){B=E;B.__webGLVertexBuffer=e.createBuffer();B.__webGLColorBuffer=e.createBuffer();B=E;H=B.vertices.length;B.__vertexArray=new Float32Array(H*3);B.__colorArray=
-new Float32Array(H*3);B.__sortArray=[];B.__webGLParticleCount=H;E.__dirtyVertices=!0;E.__dirtyColors=!0}(E.__dirtyVertices||E.__dirtyColors||v.sortParticles)&&b(E,e.DYNAMIC_DRAW,v,camera);w(objlist,T,0,E,v);E.__dirtyVertices=!1;E.__dirtyColors=!1}else if(v instanceof THREE.MarchingCubes){E=T;if(E[0]==undefined){o.__webGLObjectsImmediate.push({object:v,opaque:{list:[],count:0},transparent:{list:[],count:0}});E[0]=1}}}};this.removeObject=function(l,A){var y,v;for(y=l.__webGLObjects.length-1;y>=0;y--){v=
-l.__webGLObjects[y].object;A==v&&l.__webGLObjects.splice(y,1)}};this.addToRenderList=function(){};this.removeFromRenderList=function(){};this.setDepthTest=function(l){l?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST)};this.setFaceCulling=function(l,A){if(l){!A||A=="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW);if(l=="back")e.cullFace(e.BACK);else l=="front"?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK);e.enable(e.CULL_FACE)}else e.disable(e.CULL_FACE)};this.supportsVertexTextures=function(){return e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
+THREE.Projector=function(){function a(L,M){return M.z-L.z}function b(L,M){var V=0,S=1,Y=L.z+L.w,Z=M.z+M.w,G=-L.z+L.w,T=-M.z+M.w;if(Y>=0&&Z>=0&&G>=0&&T>=0)return!0;else if(Y<0&&Z<0||G<0&&T<0)return!1;else{if(Y<0)V=Math.max(V,Y/(Y-Z));else Z<0&&(S=Math.min(S,Y/(Y-Z)));if(G<0)V=Math.max(V,G/(G-T));else T<0&&(S=Math.min(S,G/(G-T)));if(S<V)return!1;else{L.lerpSelf(M,V);M.lerpSelf(L,1-S);return!0}}}var c,d,f=[],g,h,k,j=[],m,o,w=[],u,t,x=[],A=new THREE.Vector4,F=new THREE.Vector4,v=new THREE.Matrix4,H=new THREE.Matrix4,
+q=[],J=new THREE.Vector4,e=new THREE.Vector4,ba;this.projectObjects=function(L,M,V){M=[];var S,Y,Z;d=0;Y=L.objects;L=0;for(S=Y.length;L<S;L++){Z=Y[L];var G;if(!(G=!Z.visible))if(G=Z instanceof THREE.Mesh){a:{G=void 0;for(var T=Z.globalMatrix,la=-Z.geometry.boundingSphere.radius*Math.max(Z.scale.x,Math.max(Z.scale.y,Z.scale.z)),W=0;W<6;W++){G=q[W].x*T.n14+q[W].y*T.n24+q[W].z*T.n34+q[W].w;if(G<=la){G=!1;break a}}G=!0}G=!G}if(!G){c=f[d]=f[d]||new THREE.RenderableObject;A.copy(Z.position);v.multiplyVector3(A);
+c.object=Z;c.z=A.z;M.push(c);d++}}V&&M.sort(a);return M};this.projectScene=function(L,M,V){var S=[],Y=M.near,Z=M.far,G,T,la,W,ja,ia,$,ra,ya,l,z,B,p,n,E,I;k=o=t=0;M.autoUpdateMatrix&&M.update();v.multiply(M.projectionMatrix,M.globalMatrix);q[0]=new THREE.Vector4(v.n41-v.n11,v.n42-v.n12,v.n43-v.n13,v.n44-v.n14);q[1]=new THREE.Vector4(v.n41+v.n11,v.n42+v.n12,v.n43+v.n13,v.n44+v.n14);q[2]=new THREE.Vector4(v.n41+v.n21,v.n42+v.n22,v.n43+v.n23,v.n44+v.n24);q[3]=new THREE.Vector4(v.n41-v.n21,v.n42-v.n22,
+v.n43-v.n23,v.n44-v.n24);q[4]=new THREE.Vector4(v.n41-v.n31,v.n42-v.n32,v.n43-v.n33,v.n44-v.n34);q[5]=new THREE.Vector4(v.n41+v.n31,v.n42+v.n32,v.n43+v.n33,v.n44+v.n34);G=0;for(ia=q.length;G<ia;G++){$=q[G];$.divideScalar(Math.sqrt($.x*$.x+$.y*$.y+$.z*$.z))}L.update(undefined,!1,M);ia=this.projectObjects(L,M,!0);L=0;for(G=ia.length;L<G;L++){$=ia[L].object;if($.visible){$.autoUpdateMatrix&&$.updateMatrix();ra=$.globalMatrix;ra.extractRotationMatrix($.rotationMatrix);z=$.rotationMatrix;ya=$.materials;
+l=$.overdraw;if($ instanceof THREE.Mesh){B=$.geometry;p=B.vertices;T=0;for(la=p.length;T<la;T++){n=p[T];n.positionWorld.copy(n.position);ra.multiplyVector3(n.positionWorld);W=n.positionScreen;W.copy(n.positionWorld);v.multiplyVector4(W);W.x/=W.w;W.y/=W.w;n.__visible=W.z>Y&&W.z<Z}B=B.faces;T=0;for(la=B.length;T<la;T++){n=B[T];if(n instanceof THREE.Face3){W=p[n.a];ja=p[n.b];E=p[n.c];if(W.__visible&&ja.__visible&&E.__visible&&($.doubleSided||$.flipSided!=(E.positionScreen.x-W.positionScreen.x)*(ja.positionScreen.y-
+W.positionScreen.y)-(E.positionScreen.y-W.positionScreen.y)*(ja.positionScreen.x-W.positionScreen.x)<0)){g=j[k]=j[k]||new THREE.RenderableFace3;g.v1.positionWorld.copy(W.positionWorld);g.v2.positionWorld.copy(ja.positionWorld);g.v3.positionWorld.copy(E.positionWorld);g.v1.positionScreen.copy(W.positionScreen);g.v2.positionScreen.copy(ja.positionScreen);g.v3.positionScreen.copy(E.positionScreen);g.normalWorld.copy(n.normal);z.multiplyVector3(g.normalWorld);g.centroidWorld.copy(n.centroid);ra.multiplyVector3(g.centroidWorld);
+g.centroidScreen.copy(g.centroidWorld);v.multiplyVector3(g.centroidScreen);E=n.vertexNormals;ba=g.vertexNormalsWorld;W=0;for(ja=E.length;W<ja;W++){I=ba[W]=ba[W]||new THREE.Vector3;I.copy(E[W]);z.multiplyVector3(I)}g.z=g.centroidScreen.z;g.meshMaterials=ya;g.faceMaterials=n.materials;g.overdraw=l;if($.geometry.uvs[T]){g.uvs[0]=$.geometry.uvs[T][0];g.uvs[1]=$.geometry.uvs[T][1];g.uvs[2]=$.geometry.uvs[T][2]}S.push(g);k++}}else if(n instanceof THREE.Face4){W=p[n.a];ja=p[n.b];E=p[n.c];I=p[n.d];if(W.__visible&&
+ja.__visible&&E.__visible&&I.__visible&&($.doubleSided||$.flipSided!=((I.positionScreen.x-W.positionScreen.x)*(ja.positionScreen.y-W.positionScreen.y)-(I.positionScreen.y-W.positionScreen.y)*(ja.positionScreen.x-W.positionScreen.x)<0||(ja.positionScreen.x-E.positionScreen.x)*(I.positionScreen.y-E.positionScreen.y)-(ja.positionScreen.y-E.positionScreen.y)*(I.positionScreen.x-E.positionScreen.x)<0))){g=j[k]=j[k]||new THREE.RenderableFace3;g.v1.positionWorld.copy(W.positionWorld);g.v2.positionWorld.copy(ja.positionWorld);
+g.v3.positionWorld.copy(I.positionWorld);g.v1.positionScreen.copy(W.positionScreen);g.v2.positionScreen.copy(ja.positionScreen);g.v3.positionScreen.copy(I.positionScreen);g.normalWorld.copy(n.normal);z.multiplyVector3(g.normalWorld);g.centroidWorld.copy(n.centroid);ra.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);v.multiplyVector3(g.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=ya;g.faceMaterials=n.materials;g.overdraw=l;if($.geometry.uvs[T]){g.uvs[0]=$.geometry.uvs[T][0];
+g.uvs[1]=$.geometry.uvs[T][1];g.uvs[2]=$.geometry.uvs[T][3]}S.push(g);k++;h=j[k]=j[k]||new THREE.RenderableFace3;h.v1.positionWorld.copy(ja.positionWorld);h.v2.positionWorld.copy(E.positionWorld);h.v3.positionWorld.copy(I.positionWorld);h.v1.positionScreen.copy(ja.positionScreen);h.v2.positionScreen.copy(E.positionScreen);h.v3.positionScreen.copy(I.positionScreen);h.normalWorld.copy(g.normalWorld);h.centroidWorld.copy(g.centroidWorld);h.centroidScreen.copy(g.centroidScreen);h.z=h.centroidScreen.z;
+h.meshMaterials=ya;h.faceMaterials=n.materials;h.overdraw=l;if($.geometry.uvs[T]){h.uvs[0]=$.geometry.uvs[T][1];h.uvs[1]=$.geometry.uvs[T][2];h.uvs[2]=$.geometry.uvs[T][3]}S.push(h);k++}}}}else if($ instanceof THREE.Line){H.multiply(v,ra);p=$.geometry.vertices;n=p[0];n.positionScreen.copy(n.position);H.multiplyVector4(n.positionScreen);T=1;for(la=p.length;T<la;T++){W=p[T];W.positionScreen.copy(W.position);H.multiplyVector4(W.positionScreen);ja=p[T-1];J.copy(W.positionScreen);e.copy(ja.positionScreen);
+if(b(J,e)){J.multiplyScalar(1/J.w);e.multiplyScalar(1/e.w);m=w[o]=w[o]||new THREE.RenderableLine;m.v1.positionScreen.copy(J);m.v2.positionScreen.copy(e);m.z=Math.max(J.z,e.z);m.materials=$.materials;S.push(m);o++}}}else if($ instanceof THREE.Particle){F.set($.position.x,$.position.y,$.position.z,1);v.multiplyVector4(F);F.z/=F.w;if(F.z>0&&F.z<1){u=x[t]=x[t]||new THREE.RenderableParticle;u.x=F.x/F.w;u.y=F.y/F.w;u.z=F.z;u.rotation=$.rotation.z;u.scale.x=$.scale.x*Math.abs(u.x-(F.x+M.projectionMatrix.n11)/
+(F.w+M.projectionMatrix.n14));u.scale.y=$.scale.y*Math.abs(u.y-(F.y+M.projectionMatrix.n22)/(F.w+M.projectionMatrix.n24));u.materials=$.materials;S.push(u);t++}}}}V&&S.sort(a);return S};this.unprojectVector=function(L,M){var V=THREE.Matrix4.makeInvert(M.globalMatrix);V.multiplySelf(THREE.Matrix4.makeInvert(M.projectionMatrix));V.multiplyVector3(L);return L}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,f,g;this.domElement=document.createElement("div");this.setSize=function(h,k){c=h;d=k;f=c/2;g=d/2};this.render=function(h,k){var j,m,o,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*f+f;A=u.y*g+g;o=0;for(w=u.material.length;o<w;o++){t=u.material[o];if(t instanceof THREE.ParticleDOMMaterial){t=t.domElement;t.style.left=x+"px";t.style.top=A+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(sa){if(u!=sa)m.globalAlpha=u=sa}function b(sa){if(t!=sa){switch(sa){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}t=sa}}var c=null,d=new THREE.Projector,f=document.createElement("canvas"),g,h,k,j,m=f.getContext("2d"),o=new THREE.Color(0),w=0,u=1,t=0,x=null,A=null,F=1,v,H,q,J,e,ba,L,M,V,S=new THREE.Color,
+Y=new THREE.Color,Z=new THREE.Color,G=new THREE.Color,T=new THREE.Color,la,W,ja,ia,$,ra,ya,l,z,B=new THREE.Rectangle,p=new THREE.Rectangle,n=new THREE.Rectangle,E=!1,I=new THREE.Color,P=new THREE.Color,da=new THREE.Color,y=new THREE.Color,C=Math.PI*2,D=new THREE.Vector3,Q,U,pa,ka,ma,na,oa=16;Q=document.createElement("canvas");Q.width=Q.height=2;U=Q.getContext("2d");U.fillStyle="rgba(0,0,0,1)";U.fillRect(0,0,2,2);pa=U.getImageData(0,0,2,2);ka=pa.data;ma=document.createElement("canvas");ma.width=ma.height=
+oa;na=ma.getContext("2d");na.translate(-oa/2,-oa/2);na.scale(oa,oa);oa--;this.domElement=f;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(sa,N){g=sa;h=N;k=g/2;j=h/2;f.width=g;f.height=h;B.set(-k,-j,k,j);u=1;t=0;A=x=null;F=1};this.setClearColor=function(sa,N){o=sa;w=N;p.set(-k,-j,k,j);m.setTransform(1,0,0,-1,k,j);this.clear()};this.setClearColorHex=function(sa,N){o.setHex(sa);w=N;p.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(!p.isEmpty()){p.inflate(1);p.minSelf(B);if(o.hex==0&&w==0)m.clearRect(p.getX(),p.getY(),p.getWidth(),p.getHeight());else{b(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(o.r*255)+","+Math.floor(o.g*255)+","+Math.floor(o.b*255)+","+w+")";m.fillRect(p.getX(),p.getY(),p.getWidth(),p.getHeight())}p.empty()}};this.render=function(sa,N){function Ia(O){var fa,ga,R,ea=O.lights;P.setRGB(0,0,0);da.setRGB(0,0,0);y.setRGB(0,0,0);O=0;for(fa=ea.length;O<fa;O++){ga=ea[O];R=ga.color;if(ga instanceof
+THREE.AmbientLight){P.r+=R.r;P.g+=R.g;P.b+=R.b}else if(ga instanceof THREE.DirectionalLight){da.r+=R.r;da.g+=R.g;da.b+=R.b}else if(ga instanceof THREE.PointLight){y.r+=R.r;y.g+=R.g;y.b+=R.b}}}function Ca(O,fa,ga,R){var ea,qa,Aa,Ga,Ha=O.lights;O=0;for(ea=Ha.length;O<ea;O++){qa=Ha[O];Aa=qa.color;Ga=qa.intensity;if(qa instanceof THREE.DirectionalLight){qa=ga.dot(qa.position)*Ga;if(qa>0){R.r+=Aa.r*qa;R.g+=Aa.g*qa;R.b+=Aa.b*qa}}else if(qa instanceof THREE.PointLight){D.sub(qa.position,fa);D.normalize();
+qa=ga.dot(D)*Ga;if(qa>0){R.r+=Aa.r*qa;R.g+=Aa.g*qa;R.b+=Aa.b*qa}}}}function Ja(O,fa,ga){if(ga.opacity!=0){a(ga.opacity);b(ga.blending);var R,ea,qa,Aa,Ga,Ha;if(ga instanceof THREE.ParticleBasicMaterial){if(ga.map&&ga.map.image.loaded){Aa=ga.map.image;Ga=Aa.width>>1;Ha=Aa.height>>1;ea=fa.scale.x*k;qa=fa.scale.y*j;ga=ea*Ga;R=qa*Ha;n.set(O.x-ga,O.y-R,O.x+ga,O.y+R);if(B.instersects(n)){m.save();m.translate(O.x,O.y);m.rotate(-fa.rotation);m.scale(ea,-qa);m.translate(-Ga,-Ha);m.drawImage(Aa,0,0);m.restore()}}}else if(ga instanceof
+THREE.ParticleCircleMaterial){if(E){I.r=P.r+da.r+y.r;I.g=P.g+da.g+y.g;I.b=P.b+da.b+y.b;S.r=ga.color.r*I.r;S.g=ga.color.g*I.g;S.b=ga.color.b*I.b;S.updateStyleString()}else S.__styleString=ga.color.__styleString;ga=fa.scale.x*k;R=fa.scale.y*j;n.set(O.x-ga,O.y-R,O.x+ga,O.y+R);if(B.instersects(n)){ea=S.__styleString;if(A!=ea)m.fillStyle=A=ea;m.save();m.translate(O.x,O.y);m.rotate(-fa.rotation);m.scale(ga,R);m.beginPath();m.arc(0,0,1,0,C,!0);m.closePath();m.fill();m.restore()}}}}function ca(O,fa,ga,R){if(R.opacity!=
+0){a(R.opacity);b(R.blending);m.beginPath();m.moveTo(O.positionScreen.x,O.positionScreen.y);m.lineTo(fa.positionScreen.x,fa.positionScreen.y);m.closePath();if(R instanceof THREE.LineBasicMaterial){S.__styleString=R.color.__styleString;O=R.linewidth;if(F!=O)m.lineWidth=F=O;O=S.__styleString;if(x!=O)m.strokeStyle=x=O;m.stroke();n.inflate(R.linewidth*2)}}}function aa(O,fa,ga,R,ea,qa){if(ea.opacity!=0){a(ea.opacity);b(ea.blending);J=O.positionScreen.x;e=O.positionScreen.y;ba=fa.positionScreen.x;L=fa.positionScreen.y;
+M=ga.positionScreen.x;V=ga.positionScreen.y;m.beginPath();m.moveTo(J,e);m.lineTo(ba,L);m.lineTo(M,V);m.lineTo(J,e);m.closePath();if(ea instanceof THREE.MeshBasicMaterial)if(ea.map)ea.map.image.loaded&&ea.map.mapping instanceof THREE.UVMapping&&Fa(J,e,ba,L,M,V,ea.map.image,R.uvs[0].u,R.uvs[0].v,R.uvs[1].u,R.uvs[1].v,R.uvs[2].u,R.uvs[2].v);else if(ea.env_map){if(ea.env_map.image.loaded&&ea.env_map.mapping instanceof THREE.SphericalReflectionMapping){O=N.globalMatrix;D.copy(R.vertexNormalsWorld[0]);
+ia=(D.x*O.n11+D.y*O.n12+D.z*O.n13)*0.5+0.5;$=-(D.x*O.n21+D.y*O.n22+D.z*O.n23)*0.5+0.5;D.copy(R.vertexNormalsWorld[1]);ra=(D.x*O.n11+D.y*O.n12+D.z*O.n13)*0.5+0.5;ya=-(D.x*O.n21+D.y*O.n22+D.z*O.n23)*0.5+0.5;D.copy(R.vertexNormalsWorld[2]);l=(D.x*O.n11+D.y*O.n12+D.z*O.n13)*0.5+0.5;z=-(D.x*O.n21+D.y*O.n22+D.z*O.n23)*0.5+0.5;Fa(J,e,ba,L,M,V,ea.env_map.image,ia,$,ra,ya,l,z)}}else ea.wireframe?X(ea.color.__styleString,ea.wireframe_linewidth):ta(ea.color.__styleString);else if(ea instanceof THREE.MeshLambertMaterial){if(ea.map&&
+!ea.wireframe){ea.map.mapping instanceof THREE.UVMapping&&Fa(J,e,ba,L,M,V,ea.map.image,R.uvs[0].u,R.uvs[0].v,R.uvs[1].u,R.uvs[1].v,R.uvs[2].u,R.uvs[2].v);b(THREE.SubtractiveBlending)}if(E)if(!ea.wireframe&&ea.shading==THREE.SmoothShading&&R.vertexNormalsWorld.length==3){Y.r=Z.r=G.r=P.r;Y.g=Z.g=G.g=P.g;Y.b=Z.b=G.b=P.b;Ca(qa,R.v1.positionWorld,R.vertexNormalsWorld[0],Y);Ca(qa,R.v2.positionWorld,R.vertexNormalsWorld[1],Z);Ca(qa,R.v3.positionWorld,R.vertexNormalsWorld[2],G);T.r=(Z.r+G.r)*0.5;T.g=(Z.g+
+G.g)*0.5;T.b=(Z.b+G.b)*0.5;ja=Da(Y,Z,G,T);Fa(J,e,ba,L,M,V,ja,0,0,1,0,0,1)}else{I.r=P.r;I.g=P.g;I.b=P.b;Ca(qa,R.centroidWorld,R.normalWorld,I);S.r=ea.color.r*I.r;S.g=ea.color.g*I.g;S.b=ea.color.b*I.b;S.updateStyleString();ea.wireframe?X(S.__styleString,ea.wireframe_linewidth):ta(S.__styleString)}else ea.wireframe?X(ea.color.__styleString,ea.wireframe_linewidth):ta(ea.color.__styleString)}else if(ea instanceof THREE.MeshDepthMaterial){la=N.near;W=N.far;Y.r=Y.g=Y.b=1-K(O.positionScreen.z,la,W);Z.r=Z.g=
+Z.b=1-K(fa.positionScreen.z,la,W);G.r=G.g=G.b=1-K(ga.positionScreen.z,la,W);T.r=(Z.r+G.r)*0.5;T.g=(Z.g+G.g)*0.5;T.b=(Z.b+G.b)*0.5;ja=Da(Y,Z,G,T);Fa(J,e,ba,L,M,V,ja,0,0,1,0,0,1)}else if(ea instanceof THREE.MeshNormalMaterial){S.r=Ea(R.normalWorld.x);S.g=Ea(R.normalWorld.y);S.b=Ea(R.normalWorld.z);S.updateStyleString();ea.wireframe?X(S.__styleString,ea.wireframe_linewidth):ta(S.__styleString)}}}function X(O,fa){if(x!=O)m.strokeStyle=x=O;if(F!=fa)m.lineWidth=F=fa;m.stroke();n.inflate(fa*2)}function ta(O){if(A!=
+O)m.fillStyle=A=O;m.fill()}function Fa(O,fa,ga,R,ea,qa,Aa,Ga,Ha,La,Ba,Ma,Ta){var Na,Oa;Na=Aa.width-1;Oa=Aa.height-1;Ga*=Na;Ha*=Oa;La*=Na;Ba*=Oa;Ma*=Na;Ta*=Oa;ga-=O;R-=fa;ea-=O;qa-=fa;La-=Ga;Ba-=Ha;Ma-=Ga;Ta-=Ha;Na=La*Ta-Ma*Ba;if(Na!=0){Oa=1/Na;Na=(Ta*ga-Ba*ea)*Oa;Ba=(Ta*R-Ba*qa)*Oa;ga=(La*ea-Ma*ga)*Oa;R=(La*qa-Ma*R)*Oa;O=O-Na*Ga-ga*Ha;fa=fa-Ba*Ga-R*Ha;m.save();m.transform(Na,Ba,ga,R,O,fa);m.clip();m.drawImage(Aa,0,0);m.restore()}}function Da(O,fa,ga,R){var ea=~~(O.r*255),qa=~~(O.g*255);O=~~(O.b*255);
+var Aa=~~(fa.r*255),Ga=~~(fa.g*255);fa=~~(fa.b*255);var Ha=~~(ga.r*255),La=~~(ga.g*255);ga=~~(ga.b*255);var Ba=~~(R.r*255),Ma=~~(R.g*255);R=~~(R.b*255);ka[0]=ea<0?0:ea>255?255:ea;ka[1]=qa<0?0:qa>255?255:qa;ka[2]=O<0?0:O>255?255:O;ka[4]=Aa<0?0:Aa>255?255:Aa;ka[5]=Ga<0?0:Ga>255?255:Ga;ka[6]=fa<0?0:fa>255?255:fa;ka[8]=Ha<0?0:Ha>255?255:Ha;ka[9]=La<0?0:La>255?255:La;ka[10]=ga<0?0:ga>255?255:ga;ka[12]=Ba<0?0:Ba>255?255:Ba;ka[13]=Ma<0?0:Ma>255?255:Ma;ka[14]=R<0?0:R>255?255:R;U.putImageData(pa,0,0);na.drawImage(Q,
+0,0);return ma}function K(O,fa,ga){O=(O-fa)/(ga-fa);return O*O*(3-2*O)}function Ea(O){O=(O+1)*0.5;return O<0?0:O>1?1:O}function Ra(O,fa){var ga=fa.x-O.x,R=fa.y-O.y,ea=1/Math.sqrt(ga*ga+R*R);ga*=ea;R*=ea;fa.x+=ga;fa.y+=R;O.x-=ga;O.y-=R}var Pa,Ka,ha,wa,ua,xa,za,va;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,j);c=d.projectScene(sa,N,this.sortElements);(E=sa.lights.length>0)&&Ia(sa);Pa=0;for(Ka=c.length;Pa<Ka;Pa++){ha=c[Pa];n.empty();if(ha instanceof THREE.RenderableParticle){v=ha;v.x*=k;v.y*=
+j;wa=0;for(ua=ha.materials.length;wa<ua;wa++)Ja(v,ha,ha.materials[wa],sa)}else if(ha instanceof THREE.RenderableLine){v=ha.v1;H=ha.v2;v.positionScreen.x*=k;v.positionScreen.y*=j;H.positionScreen.x*=k;H.positionScreen.y*=j;n.addPoint(v.positionScreen.x,v.positionScreen.y);n.addPoint(H.positionScreen.x,H.positionScreen.y);if(B.instersects(n)){wa=0;for(ua=ha.materials.length;wa<ua;)ca(v,H,ha,ha.materials[wa++],sa)}}else if(ha instanceof THREE.RenderableFace3){v=ha.v1;H=ha.v2;q=ha.v3;v.positionScreen.x*=
+k;v.positionScreen.y*=j;H.positionScreen.x*=k;H.positionScreen.y*=j;q.positionScreen.x*=k;q.positionScreen.y*=j;if(ha.overdraw){Ra(v.positionScreen,H.positionScreen);Ra(H.positionScreen,q.positionScreen);Ra(q.positionScreen,v.positionScreen)}n.add3Points(v.positionScreen.x,v.positionScreen.y,H.positionScreen.x,H.positionScreen.y,q.positionScreen.x,q.positionScreen.y);if(B.instersects(n)){wa=0;for(ua=ha.meshMaterials.length;wa<ua;){va=ha.meshMaterials[wa++];if(va instanceof THREE.MeshFaceMaterial){xa=
+0;for(za=ha.faceMaterials.length;xa<za;)(va=ha.faceMaterials[xa++])&&aa(v,H,q,ha,va,sa)}else aa(v,H,q,ha,va,sa)}}}p.addRectangle(n)}m.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(ia,$,ra){var ya,l,z,B;ya=0;for(l=ia.lights.length;ya<l;ya++){z=ia.lights[ya];if(z instanceof THREE.DirectionalLight){B=$.normalWorld.dot(z.position)*z.intensity;if(B>0){ra.r+=z.color.r*B;ra.g+=z.color.g*B;ra.b+=z.color.b*B}}else if(z instanceof THREE.PointLight){V.sub(z.position,$.centroidWorld);V.normalize();B=$.normalWorld.dot(V)*z.intensity;if(B>0){ra.r+=z.color.r*B;ra.g+=z.color.g*B;ra.b+=z.color.b*B}}}}function b(ia,$,ra,ya,l,z){G=d(T++);G.setAttribute("d",
+"M "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+"z");if(l instanceof THREE.MeshBasicMaterial)q.__styleString=l.color.__styleString;else if(l instanceof THREE.MeshLambertMaterial)if(H){J.r=e.r;J.g=e.g;J.b=e.b;a(z,ya,J);q.r=l.color.r*J.r;q.g=l.color.g*J.g;q.b=l.color.b*J.b;q.updateStyleString()}else q.__styleString=l.color.__styleString;else if(l instanceof THREE.MeshDepthMaterial){M=1-l.__2near/(l.__farPlusNear-
+ya.z*l.__farMinusNear);q.setRGB(M,M,M)}else l instanceof THREE.MeshNormalMaterial&&q.setRGB(f(ya.normalWorld.x),f(ya.normalWorld.y),f(ya.normalWorld.z));l.wireframe?G.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+l.wireframe_linewidth+"; stroke-opacity: "+l.opacity+"; stroke-linecap: "+l.wireframe_linecap+"; stroke-linejoin: "+l.wireframe_linejoin):G.setAttribute("style","fill: "+q.__styleString+"; fill-opacity: "+l.opacity);k.appendChild(G)}function c(ia,$,ra,ya,
+l,z,B){G=d(T++);G.setAttribute("d","M "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+" L "+ya.positionScreen.x+","+ya.positionScreen.y+"z");if(z instanceof THREE.MeshBasicMaterial)q.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshLambertMaterial)if(H){J.r=e.r;J.g=e.g;J.b=e.b;a(B,l,J);q.r=z.color.r*J.r;q.g=z.color.g*J.g;q.b=z.color.b*J.b;q.updateStyleString()}else q.__styleString=z.color.__styleString;
+else if(z instanceof THREE.MeshDepthMaterial){M=1-z.__2near/(z.__farPlusNear-l.z*z.__farMinusNear);q.setRGB(M,M,M)}else z instanceof THREE.MeshNormalMaterial&&q.setRGB(f(l.normalWorld.x),f(l.normalWorld.y),f(l.normalWorld.z));z.wireframe?G.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+z.wireframe_linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.wireframe_linecap+"; stroke-linejoin: "+z.wireframe_linejoin):G.setAttribute("style","fill: "+q.__styleString+
+"; fill-opacity: "+z.opacity);k.appendChild(G)}function d(ia){if(S[ia]==null){S[ia]=document.createElementNS("http://www.w3.org/2000/svg","path");ja==0&&S[ia].setAttribute("shape-rendering","crispEdges")}return S[ia]}function f(ia){return ia<0?Math.min((1+ia)*0.5,0.5):0.5+Math.min(ia*0.5,0.5)}var g=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,o,w,u,t,x,A,F=new THREE.Rectangle,v=new THREE.Rectangle,H=!1,q=new THREE.Color(16777215),J=new THREE.Color(16777215),
+e=new THREE.Color(0),ba=new THREE.Color(0),L=new THREE.Color(0),M,V=new THREE.Vector3,S=[],Y=[],Z=[],G,T,la,W,ja=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ia){switch(ia){case "high":ja=1;break;case "low":ja=0}};this.setSize=function(ia,$){j=ia;m=$;o=j/2;w=m/2;k.setAttribute("viewBox",-o+" "+-w+" "+j+" "+m);k.setAttribute("width",j);k.setAttribute("height",m);F.set(-o,-w,o,w)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};
+this.render=function(ia,$){var ra,ya,l,z,B,p,n,E;this.autoClear&&this.clear();g=h.projectScene(ia,$,this.sortElements);W=la=T=0;if(H=ia.lights.length>0){n=ia.lights;e.setRGB(0,0,0);ba.setRGB(0,0,0);L.setRGB(0,0,0);ra=0;for(ya=n.length;ra<ya;ra++){l=n[ra];z=l.color;if(l instanceof THREE.AmbientLight){e.r+=z.r;e.g+=z.g;e.b+=z.b}else if(l instanceof THREE.DirectionalLight){ba.r+=z.r;ba.g+=z.g;ba.b+=z.b}else if(l instanceof THREE.PointLight){L.r+=z.r;L.g+=z.g;L.b+=z.b}}}ra=0;for(ya=g.length;ra<ya;ra++){n=
+g[ra];v.empty();if(n instanceof THREE.RenderableParticle){u=n;u.x*=o;u.y*=-w;l=0;for(z=n.materials.length;l<z;l++)if(E=n.materials[l]){B=u;p=n;var I=la++;if(Y[I]==null){Y[I]=document.createElementNS("http://www.w3.org/2000/svg","circle");ja==0&&Y[I].setAttribute("shape-rendering","crispEdges")}G=Y[I];G.setAttribute("cx",B.x);G.setAttribute("cy",B.y);G.setAttribute("r",p.scale.x*o);if(E instanceof THREE.ParticleCircleMaterial){if(H){J.r=e.r+ba.r+L.r;J.g=e.g+ba.g+L.g;J.b=e.b+ba.b+L.b;q.r=E.color.r*
+J.r;q.g=E.color.g*J.g;q.b=E.color.b*J.b;q.updateStyleString()}else q=E.color;G.setAttribute("style","fill: "+q.__styleString)}k.appendChild(G)}}else if(n instanceof THREE.RenderableLine){u=n.v1;t=n.v2;u.positionScreen.x*=o;u.positionScreen.y*=-w;t.positionScreen.x*=o;t.positionScreen.y*=-w;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(t.positionScreen.x,t.positionScreen.y);if(F.instersects(v)){l=0;for(z=n.materials.length;l<z;)if(E=n.materials[l++]){B=u;p=t;I=W++;if(Z[I]==null){Z[I]=
+document.createElementNS("http://www.w3.org/2000/svg","line");ja==0&&Z[I].setAttribute("shape-rendering","crispEdges")}G=Z[I];G.setAttribute("x1",B.positionScreen.x);G.setAttribute("y1",B.positionScreen.y);G.setAttribute("x2",p.positionScreen.x);G.setAttribute("y2",p.positionScreen.y);if(E instanceof THREE.LineBasicMaterial){q.__styleString=E.color.__styleString;G.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+E.linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+
+E.linecap+"; stroke-linejoin: "+E.linejoin);k.appendChild(G)}}}}else if(n instanceof THREE.RenderableFace3){u=n.v1;t=n.v2;x=n.v3;u.positionScreen.x*=o;u.positionScreen.y*=-w;t.positionScreen.x*=o;t.positionScreen.y*=-w;x.positionScreen.x*=o;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(F.instersects(v)){l=0;for(z=n.meshMaterials.length;l<z;){E=n.meshMaterials[l++];if(E instanceof
+THREE.MeshFaceMaterial){B=0;for(p=n.faceMaterials.length;B<p;)(E=n.faceMaterials[B++])&&b(u,t,x,n,E,ia)}else E&&b(u,t,x,n,E,ia)}}}else if(n instanceof THREE.RenderableFace4){u=n.v1;t=n.v2;x=n.v3;A=n.v4;u.positionScreen.x*=o;u.positionScreen.y*=-w;t.positionScreen.x*=o;t.positionScreen.y*=-w;x.positionScreen.x*=o;x.positionScreen.y*=-w;A.positionScreen.x*=o;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(F.instersects(v)){l=0;for(z=n.meshMaterials.length;l<z;){E=n.meshMaterials[l++];if(E instanceof THREE.MeshFaceMaterial){B=0;for(p=n.faceMaterials.length;B<p;)(E=n.faceMaterials[B++])&&c(u,t,x,A,n,E,ia)}else E&&c(u,t,x,A,n,E,ia)}}}}}};
+THREE.WebGLRenderer=function(a){function b(l,z,B){var p,n,E,I=l.vertices,P=I.length,da=l.colors,y=da.length,C=l.__vertexArray,D=l.__colorArray,Q=l.__sortArray,U=l.__dirtyVertices,pa=l.__dirtyColors;if(B.sortParticles){T.multiplySelf(B.globalMatrix);for(p=0;p<P;p++){n=I[p].position;ia.copy(n);T.multiplyVector3(ia);Q[p]=[ia.z,p]}Q.sort(function(ka,ma){return ma[0]-ka[0]});for(p=0;p<P;p++){n=I[Q[p][1]].position;E=p*3;C[E]=n.x;C[E+1]=n.y;C[E+2]=n.z}for(p=0;p<y;p++){E=p*3;color=da[Q[p][1]];D[E]=color.r;
+D[E+1]=color.g;D[E+2]=color.b}}else{if(U)for(p=0;p<P;p++){n=I[p].position;E=p*3;C[E]=n.x;C[E+1]=n.y;C[E+2]=n.z}if(pa)for(p=0;p<y;p++){color=da[p];E=p*3;D[E]=color.r;D[E+1]=color.g;D[E+2]=color.b}}if(U||B.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,C,z)}if(pa||B.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,D,z)}}function c(l,z){l.fragment_shader=z.fragment_shader;l.vertex_shader=z.vertex_shader;l.uniforms=
+Uniforms.clone(z.uniforms)}function d(l,z,B,p,n){p.program||M.initMaterial(p,z,B);var E=p.program,I=E.uniforms,P=p.uniforms;if(E!=ba){e.useProgram(E);ba=E;e.uniformMatrix4fv(I.projectionMatrix,!1,la)}if(B&&(p instanceof THREE.MeshBasicMaterial||p instanceof THREE.MeshLambertMaterial||p instanceof THREE.MeshPhongMaterial||p instanceof THREE.LineBasicMaterial||p instanceof THREE.ParticleBasicMaterial)){P.fogColor.value.setHex(B.color.hex);if(B instanceof THREE.Fog){P.fogNear.value=B.near;P.fogFar.value=
+B.far}else if(B instanceof THREE.FogExp2)P.fogDensity.value=B.density}if(p instanceof THREE.MeshPhongMaterial||p instanceof THREE.MeshLambertMaterial){var da,y,C=0,D=0,Q=0,U,pa,ka,ma=M.lights,na=ma.directional.colors,oa=ma.directional.positions,sa=ma.point.colors,N=ma.point.positions,Ia=0,Ca=0;B=y=y=0;for(da=z.length;B<da;B++){y=z[B];U=y.color;pa=y.position;ka=y.intensity;if(y instanceof THREE.AmbientLight){C+=U.r;D+=U.g;Q+=U.b}else if(y instanceof THREE.DirectionalLight){y=Ia*3;na[y]=U.r*ka;na[y+
+1]=U.g*ka;na[y+2]=U.b*ka;oa[y]=pa.x;oa[y+1]=pa.y;oa[y+2]=pa.z;Ia+=1}else if(y instanceof THREE.PointLight){y=Ca*3;sa[y]=U.r*ka;sa[y+1]=U.g*ka;sa[y+2]=U.b*ka;N[y]=pa.x;N[y+1]=pa.y;N[y+2]=pa.z;Ca+=1}}for(B=Ia*3;B<na.length;B++)na[B]=0;for(B=Ca*3;B<sa.length;B++)sa[B]=0;ma.point.length=Ca;ma.directional.length=Ia;ma.ambient[0]=C;ma.ambient[1]=D;ma.ambient[2]=Q;z=M.lights;P.enableLighting.value=z.directional.length+z.point.length;P.ambientLightColor.value=z.ambient;P.directionalLightColor.value=z.directional.colors;
+P.directionalLightDirection.value=z.directional.positions;P.pointLightColor.value=z.point.colors;P.pointLightPosition.value=z.point.positions}if(p instanceof THREE.MeshBasicMaterial||p instanceof THREE.MeshLambertMaterial||p instanceof THREE.MeshPhongMaterial){P.diffuse.value.setRGB(p.color.r*p.opacity,p.color.g*p.opacity,p.color.b*p.opacity);P.opacity.value=p.opacity;P.map.texture=p.map;P.light_map.texture=p.light_map;P.env_map.texture=p.env_map;P.reflectivity.value=p.reflectivity;P.refraction_ratio.value=
+p.refraction_ratio;P.combine.value=p.combine;P.useRefract.value=p.env_map&&p.env_map.mapping instanceof THREE.CubeRefractionMapping}if(p instanceof THREE.LineBasicMaterial){P.diffuse.value.setRGB(p.color.r*p.opacity,p.color.g*p.opacity,p.color.b*p.opacity);P.opacity.value=p.opacity}else if(p instanceof THREE.ParticleBasicMaterial){P.psColor.value.setRGB(p.color.r*p.opacity,p.color.g*p.opacity,p.color.b*p.opacity);P.opacity.value=p.opacity;P.size.value=p.size;P.map.texture=p.map}else if(p instanceof
+THREE.MeshPhongMaterial){P.ambient.value.setRGB(p.ambient.r,p.ambient.g,p.ambient.b);P.specular.value.setRGB(p.specular.r,p.specular.g,p.specular.b);P.shininess.value=p.shininess}else if(p instanceof THREE.MeshDepthMaterial){P.mNear.value=l.near;P.mFar.value=l.far;P.opacity.value=p.opacity}else if(p instanceof THREE.MeshNormalMaterial)P.opacity.value=p.opacity;for(var Ja in P)if(C=E.uniforms[Ja]){B=P[Ja];da=B.type;z=B.value;if(da=="i")e.uniform1i(C,z);else if(da=="f")e.uniform1f(C,z);else if(da==
+"fv1")e.uniform1fv(C,z);else if(da=="fv")e.uniform3fv(C,z);else if(da=="v2")e.uniform2f(C,z.x,z.y);else if(da=="v3")e.uniform3f(C,z.x,z.y,z.z);else if(da=="c")e.uniform3f(C,z.r,z.g,z.b);else if(da=="t"){e.uniform1i(C,z);if(B=B.texture)if(B.image instanceof Array&&B.image.length==6){if(B.image.length==6){if(!B.image.__webGLTextureCube&&!B.image.__cubeMapInitialized&&B.image.loadCount==6){B.image.__webGLTextureCube=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,B.image.__webGLTextureCube);e.texParameteri(e.TEXTURE_CUBE_MAP,
+e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAG_FILTER,e.LINEAR);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR);for(da=0;da<6;++da)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+da,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,B.image[da]);e.generateMipmap(e.TEXTURE_CUBE_MAP);e.bindTexture(e.TEXTURE_CUBE_MAP,null);B.image.__cubeMapInitialized=!0}e.activeTexture(e.TEXTURE0+z);e.bindTexture(e.TEXTURE_CUBE_MAP,
+B.image.__webGLTextureCube)}}else{if(!B.__webGLTexture&&B.image.loaded){B.__webGLTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,B.__webGLTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,B.image);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,q(B.wrap_s));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,q(B.wrap_t));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,q(B.mag_filter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,q(B.min_filter));e.generateMipmap(e.TEXTURE_2D);
+e.bindTexture(e.TEXTURE_2D,null)}e.activeTexture(e.TEXTURE0+z);e.bindTexture(e.TEXTURE_2D,B.__webGLTexture)}}}e.uniformMatrix4fv(I.modelViewMatrix,!1,n._modelViewMatrixArray);e.uniformMatrix3fv(I.normalMatrix,!1,n._normalMatrixArray);(p instanceof THREE.MeshShaderMaterial||p instanceof THREE.MeshPhongMaterial||p.env_map)&&e.uniform3f(I.cameraPosition,l.position.x,l.position.y,l.position.z);(p instanceof THREE.MeshShaderMaterial||p.env_map||p.skinning)&&e.uniformMatrix4fv(I.objectMatrix,!1,n._objectMatrixArray);
+(p instanceof THREE.MeshPhongMaterial||p instanceof THREE.MeshLambertMaterial||p instanceof THREE.MeshShaderMaterial||p.skinning)&&e.uniformMatrix4fv(I.viewMatrix,!1,ja);if(p.skinning){e.uniformMatrix4fv(I.cameraInverseMatrix,!1,W);e.uniformMatrix4fv(I.uBoneGlobalMatrices,!1,n.boneMatrices)}return E}function f(l,z,B,p,n,E){l=d(l,z,B,p,E).attributes;e.bindBuffer(e.ARRAY_BUFFER,n.__webGLVertexBuffer);e.vertexAttribPointer(l.position,3,e.FLOAT,!1,0,0);if(l.color>=0){e.bindBuffer(e.ARRAY_BUFFER,n.__webGLColorBuffer);
+e.vertexAttribPointer(l.color,3,e.FLOAT,!1,0,0)}if(l.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,n.__webGLNormalBuffer);e.vertexAttribPointer(l.normal,3,e.FLOAT,!1,0,0)}if(l.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,n.__webGLTangentBuffer);e.vertexAttribPointer(l.tangent,4,e.FLOAT,!1,0,0)}if(l.uv>=0)if(n.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,n.__webGLUVBuffer);e.vertexAttribPointer(l.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.uv)}else e.disableVertexAttribArray(l.uv);if(l.uv2>=0)if(n.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,
+n.__webGLUV2Buffer);e.vertexAttribPointer(l.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.uv2)}else e.disableVertexAttribArray(l.uv2);if(p.skinning&&l.skinVertexA>=0&&l.skinVertexB>=0&&l.skinIndex>=0&&l.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,n.__webGLSkinVertexABuffer);e.vertexAttribPointer(l.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,n.__webGLSkinVertexBBuffer);e.vertexAttribPointer(l.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,n.__webGLSkinIndicesBuffer);e.vertexAttribPointer(l.skinIndex,
+4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,n.__webGLSkinWeightsBuffer);e.vertexAttribPointer(l.skinWeight,4,e.FLOAT,!1,0,0)}if(E instanceof THREE.Mesh)if(p.wireframe){e.lineWidth(p.wireframe_linewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);e.drawElements(e.LINES,n.__webGLLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);e.drawElements(e.TRIANGLES,n.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else if(E instanceof THREE.Line){E=E.type==THREE.LineStrip?
+e.LINE_STRIP:e.LINES;e.lineWidth(p.linewidth);e.drawArrays(E,0,n.__webGLLineCount)}else E instanceof THREE.ParticleSystem&&e.drawArrays(e.POINTS,0,n.__webGLParticleCount)}function g(l,z){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=e.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=e.createBuffer();if(l.hasPos){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,l.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(z.attributes.position);e.vertexAttribPointer(z.attributes.position,
+3,e.FLOAT,!1,0,0)}if(l.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,l.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(z.attributes.normal);e.vertexAttribPointer(z.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,l.count);l.count=0}function h(l){if(V!=l.doubleSided){l.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);V=l.doubleSided}if(S!=l.flipSided){l.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);S=l.flipSided}}function k(l){if(Z!=
+l){l?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);Z=l}}function j(l){G[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,l.n44-l.n14);G[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+l.n14);G[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);G[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);G[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);G[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var z;for(l=0;l<5;l++){z=G[l];z.divideScalar(Math.sqrt(z.x*z.x+z.y*z.y+z.z*z.z))}}
+function m(l){for(var z=l.globalMatrix,B=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),p=0;p<6;p++){l=G[p].x*z.n14+G[p].y*z.n24+G[p].z*z.n34+G[p].w;if(l<=B)return!1}return!0}function o(l,z){l.list[l.count]=z;l.count+=1}function w(l){var z,B,p=l.object,n=l.opaque,E=l.transparent;E.count=0;l=n.count=0;for(z=p.materials.length;l<z;l++){B=p.materials[l];B.opacity&&B.opacity<1||B.blending!=THREE.NormalBlending?o(E,B):o(n,B)}}function u(l){var z,B,p,n,E=l.object,I=
+l.buffer,P=l.opaque,da=l.transparent;da.count=0;l=P.count=0;for(p=E.materials.length;l<p;l++){z=E.materials[l];if(z instanceof THREE.MeshFaceMaterial){z=0;for(B=I.materials.length;z<B;z++)(n=I.materials[z])&&(n.opacity&&n.opacity<1||n.blending!=THREE.NormalBlending?o(da,n):o(P,n))}else{n=z;n.opacity&&n.opacity<1||n.blending!=THREE.NormalBlending?o(da,n):o(P,n)}}}function t(l,z){return z.z-l.z}function x(l,z,B,p,n){if(z[B]==undefined){l.push({buffer:p,object:n,opaque:{list:[],count:0},transparent:{list:[],
+count:0}});z[B]=1}}function A(l,z){l._modelViewMatrix.multiplyToArray(z.globalMatrix,l.globalMatrix,l._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(l._modelViewMatrix).transposeIntoArray(l._normalMatrixArray)}function F(l){if(l!=Y){switch(l){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE);break;case THREE.SubtractiveBlending:e.blendFunc(e.DST_COLOR,e.ZERO);break;case THREE.BillboardBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);
+break;default:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}Y=l}}function v(l,z){if(l&&!l.__webGLFramebuffer){l.__webGLFramebuffer=e.createFramebuffer();l.__webGLRenderbuffer=e.createRenderbuffer();l.__webGLTexture=e.createTexture();e.bindRenderbuffer(e.RENDERBUFFER,l.__webGLRenderbuffer);e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,l.width,l.height);e.bindTexture(e.TEXTURE_2D,l.__webGLTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,q(l.wrap_s));e.texParameteri(e.TEXTURE_2D,
+e.TEXTURE_WRAP_T,q(l.wrap_t));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,q(l.mag_filter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,q(l.min_filter));e.texImage2D(e.TEXTURE_2D,0,q(l.format),l.width,l.height,0,q(l.format),q(l.type),null);e.bindFramebuffer(e.FRAMEBUFFER,l.__webGLFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,l.__webGLTexture,0);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,l.__webGLRenderbuffer);e.bindTexture(e.TEXTURE_2D,
+null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var B,p,n;if(l){B=l.__webGLFramebuffer;p=l.width;n=l.height}else{B=null;p=J.width;n=J.height}if(B!=L){e.bindFramebuffer(e.FRAMEBUFFER,B);e.viewport(0,0,p,n);z&&e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT);L=B}}function H(l,z){var B;if(l=="fragment")B=e.createShader(e.FRAGMENT_SHADER);else l=="vertex"&&(B=e.createShader(e.VERTEX_SHADER));e.shaderSource(B,z);e.compileShader(B);if(!e.getShaderParameter(B,e.COMPILE_STATUS)){alert(e.getShaderInfoLog(B));
+return null}return B}function q(l){switch(l){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;
+case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}
+var J=document.createElement("canvas"),e,ba=null,L=null,M=this,V=null,S=null,Y=null,Z=null,G=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],T=new THREE.Matrix4,la=new Float32Array(16),W=new Float32Array(16),ja=new Float32Array(16),ia=new THREE.Vector4,$=!0,ra=new THREE.Color(0),ya=0;if(a){if(a.antialias!==undefined)$=a.antialias;a.clearColor!==undefined&&ra.setHex(a.clearColor);if(a.clearAlpha!==undefined)ya=a.clearAlpha}this.domElement=
+J;this.autoClear=!0;this.sortObjects=!1;(function(l,z,B){try{e=J.getContext("experimental-webgl",{antialias:l})}catch(p){console.log(p)}if(!e){alert("WebGL not supported");throw"cannot create webgl context";}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);e.clearColor(z.r,z.g,z.b,B);_cullEnabled=!0})($,ra,ya);this.context=e;this.lights={ambient:[0,
+0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,z){J.width=l;J.height=z;e.viewport(0,0,J.width,J.height)};this.setClearColorHex=function(l,z){var B=new THREE.Color(l);e.clearColor(B.r,B.g,B.b,z)};this.setClearColor=function(l,z){e.clearColor(l.r,l.g,l.b,z)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)};this.initMaterial=function(l,z,B){var p,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 E,I,P,da;n=P=da=0;for(E=z.length;n<E;n++){I=z[n];
+I instanceof THREE.DirectionalLight&&P++;I instanceof THREE.PointLight&&da++}if(da+P<=4)z=P;else{z=Math.ceil(4*P/(da+P));da=4-z}n={directional:z,point:da};da=l.fragment_shader;z=l.vertex_shader;E={fog:B,map:l.map,env_map:l.env_map,light_map:l.light_map,vertex_colors:l.vertex_colors,skinning:l.skinning,maxDirLights:n.directional,maxPointLights:n.point};B=e.createProgram();n=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+E.maxDirLights,"#define MAX_POINT_LIGHTS "+E.maxPointLights,
+E.fog?"#define USE_FOG":"",E.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",E.map?"#define USE_MAP":"",E.env_map?"#define USE_ENVMAP":"",E.light_map?"#define USE_LIGHTMAP":"",E.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");E=[e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+E.maxDirLights,"#define MAX_POINT_LIGHTS "+E.maxPointLights,E.map?"#define USE_MAP":"",E.env_map?"#define USE_ENVMAP":
+"",E.light_map?"#define USE_LIGHTMAP":"",E.vertex_colors?"#define USE_COLOR":"",E.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
+e.attachShader(B,H("fragment",n+da));e.attachShader(B,H("vertex",E+z));e.linkProgram(B);e.getProgramParameter(B,e.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+e.getProgramParameter(B,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");B.uniforms={};B.attributes={};l.program=B;B=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","uBoneGlobalMatrices"];for(p in l.uniforms)B.push(p);p=l.program;da=0;for(z=B.length;da<
+z;da++){n=B[da];p.uniforms[n]=e.getUniformLocation(p,n)}p=l.program;B=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];da=0;for(z=B.length;da<z;da++){n=B[da];p.attributes[n]=e.getAttribLocation(p,n)}p=l.program.attributes;e.enableVertexAttribArray(p.position);p.color>=0&&e.enableVertexAttribArray(p.color);p.normal>=0&&e.enableVertexAttribArray(p.normal);p.tangent>=0&&e.enableVertexAttribArray(p.tangent);if(l.skinning&&p.skinVertexA>=0&&p.skinVertexB>=
+0&&p.skinIndex>=0&&p.skinWeight>=0){e.enableVertexAttribArray(p.skinVertexA);e.enableVertexAttribArray(p.skinVertexB);e.enableVertexAttribArray(p.skinIndex);e.enableVertexAttribArray(p.skinWeight)}};this.render=function(l,z,B,p){var n,E,I,P,da,y,C,D,Q=l.lights,U=l.fog;z.autoUpdateMatrix&&z.update();z.globalMatrix.flattenToArray(ja);z.projectionMatrix.flattenToArray(la);z.inverseMatrix.flattenToArray(W);T.multiply(z.projectionMatrix,z.globalMatrix);j(T);THREE.AnimationHandler&&THREE.AnimationHandler.update();
+l.update(undefined,!1,z);this.initWebGLObjects(l,z);v(B,p!==undefined?p:!0);this.autoClear&&this.clear();da=l.__webGLObjects.length;for(p=0;p<da;p++){n=l.__webGLObjects[p];C=n.object;if(C.visible)if(!(C instanceof THREE.Mesh)||m(C)){C.globalMatrix.flattenToArray(C._objectMatrixArray);A(C,z);u(n);n.render=!0;if(this.sortObjects){ia.copy(C.position);T.multiplyVector3(ia);n.z=ia.z}}else n.render=!1;else n.render=!1}this.sortObjects&&l.__webGLObjects.sort(t);y=l.__webGLObjectsImmediate.length;for(p=0;p<
+y;p++){n=l.__webGLObjectsImmediate[p];C=n.object;if(C.visible){C.autoUpdateMatrix&&C.globalMatrix.flattenToArray(C._objectMatrixArray);A(C,z);w(n)}}F(THREE.NormalBlending);for(p=0;p<da;p++){n=l.__webGLObjects[p];if(n.render){C=n.object;D=n.buffer;I=n.opaque;h(C);for(n=0;n<I.count;n++){P=I.list[n];k(P.depth_test);f(z,Q,U,P,D,C)}}}for(p=0;p<y;p++){n=l.__webGLObjectsImmediate[p];C=n.object;if(C.visible){I=n.opaque;h(C);for(n=0;n<I.count;n++){P=I.list[n];k(P.depth_test);E=d(z,Q,U,P,C);C.render(function(pa){g(pa,
+E)})}}}for(p=0;p<da;p++){n=l.__webGLObjects[p];if(n.render){C=n.object;D=n.buffer;I=n.transparent;h(C);for(n=0;n<I.count;n++){P=I.list[n];F(P.blending);k(P.depth_test);f(z,Q,U,P,D,C)}}}for(p=0;p<y;p++){n=l.__webGLObjectsImmediate[p];C=n.object;if(C.visible){I=n.transparent;h(C);for(n=0;n<I.count;n++){P=I.list[n];F(P.blending);k(P.depth_test);E=d(z,Q,U,P,C);C.render(function(pa){g(pa,E)})}}}if(B&&B.min_filter!==THREE.NearestFilter&&B.min_filter!==THREE.LinearFilter){e.bindTexture(e.TEXTURE_2D,B.__webGLTexture);
+e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)}};this.initWebGLObjects=function(l){var z,B,p;if(!l.__webGLObjects){l.__webGLObjects=[];l.__webGLObjectsMap={};l.__webGLObjectsImmediate=[]}z=0;for(B=l.objects.length;z<B;z++){p=l.objects[z];var n=l,E=void 0,I=void 0,P=void 0,da=void 0;I=p.geometry;if(n.__webGLObjectsMap[p.id]==undefined){n.__webGLObjectsMap[p.id]={};p._modelViewMatrix=new THREE.Matrix4;p._normalMatrixArray=new Float32Array(9);p._modelViewMatrixArray=new Float32Array(16);
+p._objectMatrixArray=new Float32Array(16);p.globalMatrix.flattenToArray(p._objectMatrixArray)}da=n.__webGLObjectsMap[p.id];objlist=n.__webGLObjects;if(p instanceof THREE.Mesh){for(E in I.geometryChunks){P=I.geometryChunks[E];if(!P.__webGLVertexBuffer){n=P;n.__webGLVertexBuffer=e.createBuffer();n.__webGLNormalBuffer=e.createBuffer();n.__webGLTangentBuffer=e.createBuffer();n.__webGLColorBuffer=e.createBuffer();n.__webGLUVBuffer=e.createBuffer();n.__webGLUV2Buffer=e.createBuffer();n.__webGLSkinVertexABuffer=
+e.createBuffer();n.__webGLSkinVertexBBuffer=e.createBuffer();n.__webGLSkinIndicesBuffer=e.createBuffer();n.__webGLSkinWeightsBuffer=e.createBuffer();n.__webGLFaceBuffer=e.createBuffer();n.__webGLLineBuffer=e.createBuffer();n=P;var y=p,C=void 0,D=void 0,Q=0,U=0,pa=0,ka=y.geometry.faces,ma=n.faces;C=0;for(D=ma.length;C<D;C++){fi=ma[C];face=ka[fi];if(face instanceof THREE.Face3){Q+=3;U+=1;pa+=3}else if(face instanceof THREE.Face4){Q+=4;U+=2;pa+=4}}n.__vertexArray=new Float32Array(Q*3);n.__normalArray=
+new Float32Array(Q*3);n.__tangentArray=new Float32Array(Q*4);n.__colorArray=new Float32Array(Q*3);n.__uvArray=new Float32Array(Q*2);n.__uv2Array=new Float32Array(Q*2);n.__skinVertexAArray=new Float32Array(Q*4);n.__skinVertexBArray=new Float32Array(Q*4);n.__skinIndexArray=new Float32Array(Q*4);n.__skinWeightArray=new Float32Array(Q*4);n.__faceArray=new Uint16Array(U*3);n.__lineArray=new Uint16Array(pa*2);D=C=n;Q=void 0;ka=void 0;var na=void 0,oa=void 0;na=void 0;ma=!1;Q=0;for(ka=y.materials.length;Q<
+ka;Q++){na=y.materials[Q];if(na instanceof THREE.MeshFaceMaterial){na=0;for(oa=D.materials.length;na<oa;na++)if(D.materials[na]&&D.materials[na].shading!=undefined&&D.materials[na].shading==THREE.SmoothShading){ma=!0;break}}else if(na&&na.shading!=undefined&&na.shading==THREE.SmoothShading){ma=!0;break}if(ma)break}C.__needsSmoothNormals=ma;n.__webGLFaceCount=U*3;n.__webGLLineCount=pa*2;I.__dirtyVertices=!0;I.__dirtyElements=!0;I.__dirtyUvs=!0;I.__dirtyNormals=!0;I.__dirtyTangents=!0;I.__dirtyColors=
+!0}if(I.__dirtyVertices||I.__dirtyElements||I.__dirtyUvs||I.__dirtyNormals||I.__dirtyColors||I.__dirtyTangents){n=P;U=e.DYNAMIC_DRAW;pa=void 0;C=void 0;var sa=void 0,N=void 0,Ia=void 0,Ca=void 0,Ja=void 0;sa=void 0;var ca=void 0,aa=void 0,X=void 0,ta=void 0;ca=void 0;aa=void 0;X=void 0;N=void 0;ca=void 0;aa=void 0;X=void 0;ta=void 0;ca=void 0;aa=void 0;X=void 0;ta=void 0;ca=void 0;aa=void 0;X=void 0;ta=void 0;ca=void 0;aa=void 0;X=void 0;ta=void 0;ca=void 0;aa=void 0;X=void 0;ta=void 0;N=void 0;Ca=
+void 0;Ia=void 0;Ja=void 0;var Fa=oa=na=ma=ka=Q=y=D=0,Da=0,K=0,Ea=n.__vertexArray,Ra=n.__uvArray,Pa=n.__uv2Array,Ka=n.__normalArray,ha=n.__tangentArray,wa=n.__colorArray,ua=n.__skinVertexAArray,xa=n.__skinVertexBArray,za=n.__skinIndexArray,va=n.__skinWeightArray,O=n.__faceArray,fa=n.__lineArray,ga=n.__needsSmoothNormals,R=p.geometry,ea=R.__dirtyVertices,qa=R.__dirtyElements,Aa=R.__dirtyUvs,Ga=R.__dirtyNormals,Ha=R.__dirtyTangents,La=R.__dirtyColors,Ba=R.vertices,Ma=n.faces,Ta=R.faces,Na=R.uvs,Oa=
+R.uvs2,Qa=R.colors,Ua=R.skinVerticesA,Va=R.skinVerticesB,Wa=R.skinIndices,Sa=R.skinWeights;pa=0;for(C=Ma.length;pa<C;pa++){sa=Ma[pa];N=Ta[sa];Ja=Na[sa];sa=Oa[sa];Ia=N.vertexNormals;Ca=N.normal;if(N instanceof THREE.Face3){if(ea){ca=Ba[N.a].position;aa=Ba[N.b].position;X=Ba[N.c].position;Ea[y]=ca.x;Ea[y+1]=ca.y;Ea[y+2]=ca.z;Ea[y+3]=aa.x;Ea[y+4]=aa.y;Ea[y+5]=aa.z;Ea[y+6]=X.x;Ea[y+7]=X.y;Ea[y+8]=X.z;y+=9}if(Sa.length){ca=Sa[N.a];aa=Sa[N.b];X=Sa[N.c];va[K]=ca.x;va[K+1]=ca.y;va[K+2]=ca.z;va[K+3]=ca.w;
+va[K+4]=aa.x;va[K+5]=aa.y;va[K+6]=aa.z;va[K+7]=aa.w;va[K+8]=X.x;va[K+9]=X.y;va[K+10]=X.z;va[K+11]=X.w;ca=Wa[N.a];aa=Wa[N.b];X=Wa[N.c];za[K]=ca.x;za[K+1]=ca.y;za[K+2]=ca.z;za[K+3]=ca.w;za[K+4]=aa.x;za[K+5]=aa.y;za[K+6]=aa.z;za[K+7]=aa.w;za[K+8]=X.x;za[K+9]=X.y;za[K+10]=X.z;za[K+11]=X.w;ca=Ua[N.a];aa=Ua[N.b];X=Ua[N.c];ua[K]=ca.x;ua[K+1]=ca.y;ua[K+2]=ca.z;ua[K+3]=1;ua[K+4]=aa.x;ua[K+5]=aa.y;ua[K+6]=aa.z;ua[K+7]=1;ua[K+8]=X.x;ua[K+9]=X.y;ua[K+10]=X.z;ua[K+11]=1;ca=Va[N.a];aa=Va[N.b];X=Va[N.c];xa[K]=ca.x;
+xa[K+1]=ca.y;xa[K+2]=ca.z;xa[K+3]=1;xa[K+4]=aa.x;xa[K+5]=aa.y;xa[K+6]=aa.z;xa[K+7]=1;xa[K+8]=X.x;xa[K+9]=X.y;xa[K+10]=X.z;xa[K+11]=1;K+=12}if(La&&Qa.length){ca=Qa[N.a];aa=Qa[N.b];X=Qa[N.c];wa[Da]=ca.r;wa[Da+1]=ca.g;wa[Da+2]=ca.b;wa[Da+3]=aa.r;wa[Da+4]=aa.g;wa[Da+5]=aa.b;wa[Da+6]=X.r;wa[Da+7]=X.g;wa[Da+8]=X.b;Da+=9}if(Ha&&R.hasTangents){ca=Ba[N.a].tangent;aa=Ba[N.b].tangent;X=Ba[N.c].tangent;ha[oa]=ca.x;ha[oa+1]=ca.y;ha[oa+2]=ca.z;ha[oa+3]=ca.w;ha[oa+4]=aa.x;ha[oa+5]=aa.y;ha[oa+6]=aa.z;ha[oa+7]=aa.w;
+ha[oa+8]=X.x;ha[oa+9]=X.y;ha[oa+10]=X.z;ha[oa+11]=X.w;oa+=12}if(Ga)if(Ia.length==3&&ga)for(N=0;N<3;N++){Ca=Ia[N];Ka[na]=Ca.x;Ka[na+1]=Ca.y;Ka[na+2]=Ca.z;na+=3}else for(N=0;N<3;N++){Ka[na]=Ca.x;Ka[na+1]=Ca.y;Ka[na+2]=Ca.z;na+=3}if(Aa&&Ja)for(N=0;N<3;N++){Ia=Ja[N];Ra[Q]=Ia.u;Ra[Q+1]=Ia.v;Q+=2}if(Aa&&sa)for(N=0;N<3;N++){Ja=sa[N];Pa[ka]=Ja.u;Pa[ka+1]=Ja.v;ka+=2}if(qa){O[ma]=D;O[ma+1]=D+1;O[ma+2]=D+2;ma+=3;fa[Fa]=D;fa[Fa+1]=D+1;fa[Fa+2]=D;fa[Fa+3]=D+2;fa[Fa+4]=D+1;fa[Fa+5]=D+2;Fa+=6;D+=3}}else if(N instanceof
+THREE.Face4){if(ea){ca=Ba[N.a].position;aa=Ba[N.b].position;X=Ba[N.c].position;ta=Ba[N.d].position;Ea[y]=ca.x;Ea[y+1]=ca.y;Ea[y+2]=ca.z;Ea[y+3]=aa.x;Ea[y+4]=aa.y;Ea[y+5]=aa.z;Ea[y+6]=X.x;Ea[y+7]=X.y;Ea[y+8]=X.z;Ea[y+9]=ta.x;Ea[y+10]=ta.y;Ea[y+11]=ta.z;y+=12}if(Sa.length){ca=Sa[N.a];aa=Sa[N.b];X=Sa[N.c];ta=Sa[N.d];va[K]=ca.x;va[K+1]=ca.y;va[K+2]=ca.z;va[K+3]=ca.w;va[K+4]=aa.x;va[K+5]=aa.y;va[K+6]=aa.z;va[K+7]=aa.w;va[K+8]=X.x;va[K+9]=X.y;va[K+10]=X.z;va[K+11]=X.w;va[K+12]=ta.x;va[K+13]=ta.y;va[K+14]=
+ta.z;va[K+15]=ta.w;ca=Wa[N.a];aa=Wa[N.b];X=Wa[N.c];ta=Wa[N.d];za[K]=ca.x;za[K+1]=ca.y;za[K+2]=ca.z;za[K+3]=ca.w;za[K+4]=aa.x;za[K+5]=aa.y;za[K+6]=aa.z;za[K+7]=aa.w;za[K+8]=X.x;za[K+9]=X.y;za[K+10]=X.z;za[K+11]=X.w;za[K+12]=ta.x;za[K+13]=ta.y;za[K+14]=ta.z;za[K+15]=ta.w;ca=Ua[N.a];aa=Ua[N.b];X=Ua[N.c];ta=Ua[N.d];ua[K]=ca.x;ua[K+1]=ca.y;ua[K+2]=ca.z;ua[K+3]=1;ua[K+4]=aa.x;ua[K+5]=aa.y;ua[K+6]=aa.z;ua[K+7]=1;ua[K+8]=X.x;ua[K+9]=X.y;ua[K+10]=X.z;ua[K+11]=1;ua[K+12]=ta.x;ua[K+13]=ta.y;ua[K+14]=ta.z;ua[K+
+15]=1;ca=Va[N.a];aa=Va[N.b];X=Va[N.c];ta=Va[N.d];xa[K]=ca.x;xa[K+1]=ca.y;xa[K+2]=ca.z;xa[K+3]=1;xa[K+4]=aa.x;xa[K+5]=aa.y;xa[K+6]=aa.z;xa[K+7]=1;xa[K+8]=X.x;xa[K+9]=X.y;xa[K+10]=X.z;xa[K+11]=1;xa[K+12]=ta.x;xa[K+13]=ta.y;xa[K+14]=ta.z;xa[K+15]=1;K+=16}if(La&&Qa.length){ca=Qa[N.a];aa=Qa[N.b];X=Qa[N.c];ta=Qa[N.d];wa[Da]=ca.r;wa[Da+1]=ca.g;wa[Da+2]=ca.b;wa[Da+3]=aa.r;wa[Da+4]=aa.g;wa[Da+5]=aa.b;wa[Da+6]=X.r;wa[Da+7]=X.g;wa[Da+8]=X.b;wa[Da+9]=ta.r;wa[Da+10]=ta.g;wa[Da+11]=ta.b;Da+=12}if(Ha&&R.hasTangents){ca=
+Ba[N.a].tangent;aa=Ba[N.b].tangent;X=Ba[N.c].tangent;N=Ba[N.d].tangent;ha[oa]=ca.x;ha[oa+1]=ca.y;ha[oa+2]=ca.z;ha[oa+3]=ca.w;ha[oa+4]=aa.x;ha[oa+5]=aa.y;ha[oa+6]=aa.z;ha[oa+7]=aa.w;ha[oa+8]=X.x;ha[oa+9]=X.y;ha[oa+10]=X.z;ha[oa+11]=X.w;ha[oa+12]=N.x;ha[oa+13]=N.y;ha[oa+14]=N.z;ha[oa+15]=N.w;oa+=16}if(Ga)if(Ia.length==4&&ga)for(N=0;N<4;N++){Ca=Ia[N];Ka[na]=Ca.x;Ka[na+1]=Ca.y;Ka[na+2]=Ca.z;na+=3}else for(N=0;N<4;N++){Ka[na]=Ca.x;Ka[na+1]=Ca.y;Ka[na+2]=Ca.z;na+=3}if(Aa&&Ja)for(N=0;N<4;N++){Ia=Ja[N];Ra[Q]=
+Ia.u;Ra[Q+1]=Ia.v;Q+=2}if(Aa&&sa)for(N=0;N<4;N++){Ja=sa[N];Pa[ka]=Ja.u;Pa[ka+1]=Ja.v;ka+=2}if(qa){O[ma]=D;O[ma+1]=D+1;O[ma+2]=D+2;O[ma+3]=D;O[ma+4]=D+2;O[ma+5]=D+3;ma+=6;fa[Fa]=D;fa[Fa+1]=D+1;fa[Fa+2]=D;fa[Fa+3]=D+3;fa[Fa+4]=D+1;fa[Fa+5]=D+2;fa[Fa+6]=D+2;fa[Fa+7]=D+3;Fa+=8;D+=4}}}if(ea){e.bindBuffer(e.ARRAY_BUFFER,n.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Ea,U)}if(La&&Qa.length){e.bindBuffer(e.ARRAY_BUFFER,n.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,wa,U)}if(Ga){e.bindBuffer(e.ARRAY_BUFFER,
+n.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,Ka,U)}if(Ha&&R.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,n.__webGLTangentBuffer);e.bufferData(e.ARRAY_BUFFER,ha,U)}if(Aa&&Q>0){e.bindBuffer(e.ARRAY_BUFFER,n.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,Ra,U)}if(Aa&&ka>0){e.bindBuffer(e.ARRAY_BUFFER,n.__webGLUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Pa,U)}if(qa){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,O,U);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);
+e.bufferData(e.ELEMENT_ARRAY_BUFFER,fa,U)}if(K>0){e.bindBuffer(e.ARRAY_BUFFER,n.__webGLSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,ua,U);e.bindBuffer(e.ARRAY_BUFFER,n.__webGLSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,xa,U);e.bindBuffer(e.ARRAY_BUFFER,n.__webGLSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,za,U);e.bindBuffer(e.ARRAY_BUFFER,n.__webGLSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,va,U)}}x(objlist,da,E,P,p)}I.__dirtyVertices=!1;I.__dirtyElements=!1;I.__dirtyUvs=!1;I.__dirtyNormals=
+!1;I.__dirtyTangents=!1;I.__dirtyColors=!1}else if(p instanceof THREE.Line){if(!I.__webGLVertexBuffer){E=I;E.__webGLVertexBuffer=e.createBuffer();E.__webGLColorBuffer=e.createBuffer();E=I;P=E.vertices.length;E.__vertexArray=new Float32Array(P*3);E.__colorArray=new Float32Array(P*3);E.__webGLLineCount=P;I.__dirtyVertices=!0;I.__dirtyColors=!0}if(I.__dirtyVertices||I.__dirtyColors){E=I;P=e.DYNAMIC_DRAW;D=void 0;D=void 0;y=void 0;n=void 0;Q=E.vertices;U=E.colors;ka=Q.length;pa=U.length;ma=E.__vertexArray;
+C=E.__colorArray;na=E.__dirtyColors;if(E.__dirtyVertices){for(D=0;D<ka;D++){y=Q[D].position;n=D*3;ma[n]=y.x;ma[n+1]=y.y;ma[n+2]=y.z}e.bindBuffer(e.ARRAY_BUFFER,E.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,ma,P)}if(na){for(D=0;D<pa;D++){color=U[D];n=D*3;C[n]=color.r;C[n+1]=color.g;C[n+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,E.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,C,P)}}x(objlist,da,0,I,p);I.__dirtyVertices=!1;I.__dirtyColors=!1}else if(p instanceof THREE.ParticleSystem){if(!I.__webGLVertexBuffer){E=
+I;E.__webGLVertexBuffer=e.createBuffer();E.__webGLColorBuffer=e.createBuffer();E=I;P=E.vertices.length;E.__vertexArray=new Float32Array(P*3);E.__colorArray=new Float32Array(P*3);E.__sortArray=[];E.__webGLParticleCount=P;I.__dirtyVertices=!0;I.__dirtyColors=!0}(I.__dirtyVertices||I.__dirtyColors||p.sortParticles)&&b(I,e.DYNAMIC_DRAW,p,camera);x(objlist,da,0,I,p);I.__dirtyVertices=!1;I.__dirtyColors=!1}else if(p instanceof THREE.MarchingCubes){I=da;if(I[0]==undefined){n.__webGLObjectsImmediate.push({object:p,
+opaque:{list:[],count:0},transparent:{list:[],count:0}});I[0]=1}}}};this.removeObject=function(l,z){var B,p;for(B=l.__webGLObjects.length-1;B>=0;B--){p=l.__webGLObjects[B].object;z==p&&l.__webGLObjects.splice(B,1)}};this.setFaceCulling=function(l,z){if(l){!z||z=="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW);if(l=="back")e.cullFace(e.BACK);else l=="front"?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK);e.enable(e.CULL_FACE)}else e.disable(e.CULL_FACE)};this.supportsVertexTextures=function(){return e.getParameter(e.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",
@@ -276,16 +275,16 @@ 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.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 d=document.createElement("div");d.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>';d.id=
 c;c=d.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(d);b.appendChild(a);return d}};
-var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,d=a.vertices.length,f=c?b.geometry:b,g=a.vertices,h=f.vertices,k=a.faces,j=f.faces,m=a.uvs;f=f.uvs;c&&b.autoUpdateMatrix&&b.updateMatrix();for(var n=0,w=h.length;n<w;n++){var t=new THREE.Vertex(h[n].position.clone());c&&b.localMatrix.multiplyVector3(t.position);g.push(t)}n=0;for(w=j.length;n<w;n++){h=j[n];var p,x=h.vertexNormals;if(h instanceof THREE.Face3)p=new THREE.Face3(h.a+d,h.b+d,h.c+d);else h instanceof THREE.Face4&&(p=new THREE.Face4(h.a+
-d,h.b+d,h.c+d,h.d+d));p.centroid.copy(h.centroid);p.normal.copy(h.normal);c=0;for(g=x.length;c<g;c++){t=x[c];p.vertexNormals.push(t.clone())}p.materials=h.materials.slice();k.push(p)}n=0;for(w=f.length;n<w;n++){d=f[n];k=[];c=0;for(g=d.length;c<g;c++)k.push(new THREE.UV(d[c].u,d[c].v));m.push(k)}}},ImageUtils={loadTexture:function(a,b,c){var d=new Image;d.onload=function(){this.loaded=!0;c&&c(this)};d.src=a;return new THREE.Texture(d,b)},loadArray:function(a,b){var c,d,f=[];c=f.loadCount=0;for(d=a.length;c<
-d;++c){f[c]=new Image;f[c].loaded=0;f[c].onload=function(){f.loadCount+=1;this.loaded=!0;b&&b(this)};f[c].src=a[c]}return f}},SceneUtils={loadScene:function(a,b,c,d){a=new Worker(a);a.postMessage(0);a.onmessage=function(f){function g(){for(n in L.objects)if(!G.objects[n]){z=L.objects[n];if(q=G.geometries[z.geometry]){ea=[];for(i=0;i<z.materials.length;i++)ea[i]=G.materials[z.materials[i]];F=z.position;r=z.rotation;s=z.scale;object=new THREE.Mesh(q,ea);object.position.set(F[0],F[1],F[2]);object.rotation.set(r[0],
-r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=z.visible;G.scene.addObject(object);G.objects[n]=object}}}function h($){return function(na){G.geometries[$]=na;g();Y-=1;k()}}function k(){d({total_models:ca,total_textures:da,loaded_models:ca-Y,loaded_textures:da-V},G);Y==0&&V==0&&c(G)}var j,m,n,w,t,p,x,z,F,u,e,q,O,R,ea,L,I,Y,V,ca,da,G;L=f.data;I=new THREE.Loader;V=Y=0;G={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};f=function(){V-=
-1;k()};for(t in L.cameras){u=L.cameras[t];if(u.type=="perspective")O=new THREE.Camera(u.fov,u.aspect,u.near,u.far);else if(u.type=="ortho"){O=new THREE.Camera;O.projectionMatrix=THREE.Matrix4.makeOrtho(u.left,u.right,u.top,u.bottom,u.near,u.far)}F=u.position;u=u.target;O.position.set(F[0],F[1],F[2]);O.target.position.set(u[0],u[1],u[2]);G.cameras[t]=O}for(w in L.lights){t=L.lights[w];if(t.type=="directional"){F=t.direction;light=new THREE.DirectionalLight;light.position.set(F[0],F[1],F[2]);light.position.normalize()}else if(t.type==
-"point"){F=t.position;light=new THREE.PointLight;light.position.set(F[0],F[1],F[2])}u=t.color;i=t.intensity||1;light.color.setRGB(u[0]*i,u[1]*i,u[2]*i);G.scene.addLight(light);G.lights[w]=light}for(p in L.fogs){w=L.fogs[p];if(w.type=="linear")R=new THREE.Fog(0,w.near,w.far);else w.type=="exp2"&&(R=new THREE.FogExp2(0,w.density));u=w.color;R.color.setRGB(u[0],u[1],u[2]);G.fogs[p]=R}if(G.cameras&&L.defaults.camera)G.currentCamera=G.cameras[L.defaults.camera];if(G.fogs&&L.defaults.fog)G.scene.fog=G.fogs[L.defaults.fog];
-u=L.defaults.bgcolor;G.bgColor=new THREE.Color;G.bgColor.setRGB(u[0],u[1],u[2]);G.bgColorAlpha=L.defaults.bgalpha;for(j in L.geometries){p=L.geometries[j];if(p.type=="bin_mesh"||p.type=="ascii_mesh")Y+=1}ca=Y;for(j in L.geometries){p=L.geometries[j];if(p.type=="cube"){q=new Cube(p.width,p.height,p.depth,p.segments_width,p.segments_height,null,p.flipped,p.sides);G.geometries[j]=q}else if(p.type=="plane"){q=new Plane(p.width,p.height,p.segments_width,p.segments_height);G.geometries[j]=q}else if(p.type==
-"sphere"){q=new Sphere(p.radius,p.segments_width,p.segments_height);G.geometries[j]=q}else if(p.type=="cylinder"){q=new Cylinder(p.numSegs,p.topRad,p.botRad,p.height,p.topOffset,p.botOffset);G.geometries[j]=q}else if(p.type=="torus"){q=new Torus(p.radius,p.tube,p.segmentsR,p.segmentsT);G.geometries[j]=q}else if(p.type=="icosahedron"){q=new Icosahedron(p.subdivisions);G.geometries[j]=q}else if(p.type=="bin_mesh")I.loadBinary({model:p.url,callback:h(j)});else p.type=="ascii_mesh"&&I.loadAscii({model:p.url,
-callback:h(j)})}for(x in L.textures){j=L.textures[x];V+=j.url instanceof Array?j.url.length:1}da=V;for(x in L.textures){j=L.textures[x];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array){p=ImageUtils.loadArray(j.url,f);p=new THREE.Texture(p,j.mapping)}else{p=ImageUtils.loadTexture(j.url,j.mapping,f);if(THREE[j.min_filter]!=undefined)p.min_filter=THREE[j.min_filter];if(THREE[j.mag_filter]!=undefined)p.mag_filter=THREE[j.mag_filter]}G.textures[x]=
-p}for(m in L.materials){x=L.materials[m];for(e in x.parameters)if(e=="env_map"||e=="map"||e=="light_map")x.parameters[e]=G.textures[x.parameters[e]];else if(e=="shading")x.parameters[e]=x.parameters[e]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(e=="blending")x.parameters[e]=THREE[x.parameters[e]]?THREE[x.parameters[e]]:THREE.NormalBlending;else e=="combine"&&(x.parameters[e]=x.parameters[e]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);x=new THREE[x.type](x.parameters);G.materials[m]=
+var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,d=a.vertices.length,f=c?b.geometry:b,g=a.vertices,h=f.vertices,k=a.faces,j=f.faces,m=a.uvs;f=f.uvs;c&&b.autoUpdateMatrix&&b.updateMatrix();for(var o=0,w=h.length;o<w;o++){var u=new THREE.Vertex(h[o].position.clone());c&&b.localMatrix.multiplyVector3(u.position);g.push(u)}o=0;for(w=j.length;o<w;o++){h=j[o];var t,x=h.vertexNormals;if(h instanceof THREE.Face3)t=new THREE.Face3(h.a+d,h.b+d,h.c+d);else h instanceof THREE.Face4&&(t=new THREE.Face4(h.a+
+d,h.b+d,h.c+d,h.d+d));t.centroid.copy(h.centroid);t.normal.copy(h.normal);c=0;for(g=x.length;c<g;c++){u=x[c];t.vertexNormals.push(u.clone())}t.materials=h.materials.slice();k.push(t)}o=0;for(w=f.length;o<w;o++){d=f[o];k=[];c=0;for(g=d.length;c<g;c++)k.push(new THREE.UV(d[c].u,d[c].v));m.push(k)}}},ImageUtils={loadTexture:function(a,b,c){var d=new Image;d.onload=function(){this.loaded=!0;c&&c(this)};d.src=a;return new THREE.Texture(d,b)},loadArray:function(a,b){var c,d,f=[];c=f.loadCount=0;for(d=a.length;c<
+d;++c){f[c]=new Image;f[c].loaded=0;f[c].onload=function(){f.loadCount+=1;this.loaded=!0;b&&b(this)};f[c].src=a[c]}return f}},SceneUtils={loadScene:function(a,b,c,d){a=new Worker(a);a.postMessage(0);a.onmessage=function(f){function g(){for(o in L.objects)if(!G.objects[o]){A=L.objects[o];if(q=G.geometries[A.geometry]){ba=[];for(i=0;i<A.materials.length;i++)ba[i]=G.materials[A.materials[i]];F=A.position;r=A.rotation;s=A.scale;object=new THREE.Mesh(q,ba);object.position.set(F[0],F[1],F[2]);object.rotation.set(r[0],
+r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=A.visible;G.scene.addObject(object);G.objects[o]=object}}}function h(T){return function(la){G.geometries[T]=la;g();V-=1;k()}}function k(){d({total_models:Y,total_textures:Z,loaded_models:Y-V,loaded_textures:Z-S},G);V==0&&S==0&&c(G)}var j,m,o,w,u,t,x,A,F,v,H,q,J,e,ba,L,M,V,S,Y,Z,G;L=f.data;M=new THREE.Loader;S=V=0;G={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};f=function(){S-=1;k()};
+for(u in L.cameras){v=L.cameras[u];if(v.type=="perspective")J=new THREE.Camera(v.fov,v.aspect,v.near,v.far);else if(v.type=="ortho"){J=new THREE.Camera;J.projectionMatrix=THREE.Matrix4.makeOrtho(v.left,v.right,v.top,v.bottom,v.near,v.far)}F=v.position;v=v.target;J.position.set(F[0],F[1],F[2]);J.target.position.set(v[0],v[1],v[2]);G.cameras[u]=J}for(w in L.lights){u=L.lights[w];if(u.type=="directional"){F=u.direction;light=new THREE.DirectionalLight;light.position.set(F[0],F[1],F[2]);light.position.normalize()}else if(u.type==
+"point"){F=u.position;light=new THREE.PointLight;light.position.set(F[0],F[1],F[2])}v=u.color;i=u.intensity||1;light.color.setRGB(v[0]*i,v[1]*i,v[2]*i);G.scene.addLight(light);G.lights[w]=light}for(t in L.fogs){w=L.fogs[t];if(w.type=="linear")e=new THREE.Fog(0,w.near,w.far);else w.type=="exp2"&&(e=new THREE.FogExp2(0,w.density));v=w.color;e.color.setRGB(v[0],v[1],v[2]);G.fogs[t]=e}if(G.cameras&&L.defaults.camera)G.currentCamera=G.cameras[L.defaults.camera];if(G.fogs&&L.defaults.fog)G.scene.fog=G.fogs[L.defaults.fog];
+v=L.defaults.bgcolor;G.bgColor=new THREE.Color;G.bgColor.setRGB(v[0],v[1],v[2]);G.bgColorAlpha=L.defaults.bgalpha;for(j in L.geometries){t=L.geometries[j];if(t.type=="bin_mesh"||t.type=="ascii_mesh")V+=1}Y=V;for(j in L.geometries){t=L.geometries[j];if(t.type=="cube"){q=new Cube(t.width,t.height,t.depth,t.segments_width,t.segments_height,null,t.flipped,t.sides);G.geometries[j]=q}else if(t.type=="plane"){q=new Plane(t.width,t.height,t.segments_width,t.segments_height);G.geometries[j]=q}else if(t.type==
+"sphere"){q=new Sphere(t.radius,t.segments_width,t.segments_height);G.geometries[j]=q}else if(t.type=="cylinder"){q=new Cylinder(t.numSegs,t.topRad,t.botRad,t.height,t.topOffset,t.botOffset);G.geometries[j]=q}else if(t.type=="torus"){q=new Torus(t.radius,t.tube,t.segmentsR,t.segmentsT);G.geometries[j]=q}else if(t.type=="icosahedron"){q=new Icosahedron(t.subdivisions);G.geometries[j]=q}else if(t.type=="bin_mesh")M.loadBinary({model:t.url,callback:h(j)});else t.type=="ascii_mesh"&&M.loadAscii({model:t.url,
+callback:h(j)})}for(x in L.textures){j=L.textures[x];S+=j.url instanceof Array?j.url.length:1}Z=S;for(x in L.textures){j=L.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,f);t=new THREE.Texture(t,j.mapping)}else{t=ImageUtils.loadTexture(j.url,j.mapping,f);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]}G.textures[x]=
+t}for(m in L.materials){x=L.materials[m];for(H in x.parameters)if(H=="env_map"||H=="map"||H=="light_map")x.parameters[H]=G.textures[x.parameters[H]];else if(H=="shading")x.parameters[H]=x.parameters[H]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(H=="blending")x.parameters[H]=THREE[x.parameters[H]]?THREE[x.parameters[H]]:THREE.NormalBlending;else H=="combine"&&(x.parameters[H]=x.parameters[H]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);x=new THREE[x.type](x.parameters);G.materials[m]=
 x}g();b(G)}},addMesh:function(a,b,c,d,f,g,h,k,j,m){b=new THREE.Mesh(b,m);b.scale.x=b.scale.y=b.scale.z=c;b.position.x=d;b.position.y=f;b.position.z=g;b.rotation.x=h;b.rotation.y=k;b.rotation.z=j;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,c){var d=ShaderUtils.lib.cube;d.uniforms.tCube.texture=c;c=new THREE.MeshShaderMaterial({fragment_shader:d.fragment_shader,vertex_shader:d.vertex_shader,uniforms:d.uniforms});b=new THREE.Mesh(new Cube(b,b,b,1,1,null,!0),c);a.addObject(b);return b},
 addPanoramaCube:function(a,b,c){var d=[];d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[4])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));b=new THREE.Mesh(new Cube(b,b,b,1,1,d,!0),new THREE.MeshFaceMaterial);
 a.addObject(b);return b},addPanoramaCubePlanes:function(a,b,c){var d=b/2;b=new Plane(b,b);var f=Math.PI/2,g=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-d,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));SceneUtils.addMesh(a,b,1,-d,0,0,0,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));SceneUtils.addMesh(a,b,1,d,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));SceneUtils.addMesh(a,b,1,0,d,0,f,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));
@@ -298,38 +297,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}"},
 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.5;\nconst float fSintensity = 0.05;\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}",
-fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var b,c,d,f,g=2*Math.ceil(a*3)+1;g>25&&(g=25);f=(g-1)*0.5;c=Array(g);for(b=d=0;b<g;++b){c[b]=Math.exp(-((b-f)*(b-f))/(2*a*a));d+=c[b]}for(b=0;b<g;++b)c[b]/=d;return c}},Cube=function(a,b,c,d,f,g,h,k){function j(z,F,u,e,q,O,R,ea){var L,I,Y=d||1,V=f||1,ca=Y+1,da=V+1,G=q/2,$=O/2;q/=Y;var na=O/V,aa=m.vertices.length;if(z=="x"&&F=="y"||z=="y"&&F=="x")L="z";else if(z=="x"&&F=="z"||z=="z"&&F=="x")L="y";
-else if(z=="z"&&F=="y"||z=="y"&&F=="z")L="x";for(I=0;I<da;I++)for(O=0;O<ca;O++){var l=new THREE.Vector3;l[z]=(O*q-G)*u;l[F]=(I*na-$)*e;l[L]=R;m.vertices.push(new THREE.Vertex(l))}for(I=0;I<V;I++)for(O=0;O<Y;O++){m.faces.push(new THREE.Face4(O+ca*I+aa,O+ca*(I+1)+aa,O+1+ca*(I+1)+aa,O+1+ca*I+aa,null,ea));m.uvs.push([new THREE.UV(O/Y,I/V),new THREE.UV(O/Y,(I+1)/V),new THREE.UV((O+1)/Y,(I+1)/V),new THREE.UV((O+1)/Y,I/V)])}}THREE.Geometry.call(this);var m=this,n=a/2,w=b/2,t=c/2;h=h?-1:1;if(g!==undefined)if(g instanceof
-Array)this.materials=g;else{this.materials=[];for(var p=0;p<6;p++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(k!=undefined)for(var x in k)this.sides[x]!=undefined&&(this.sides[x]=k[x]);this.sides.px&&j("z","y",1*h,-1,c,b,-n,this.materials[0]);this.sides.nx&&j("z","y",-1*h,-1,c,b,n,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,t,this.materials[4]);this.sides.nz&&j("x","y",-1*h,-1,a,b,-t,this.materials[5]);(function(){for(var z=[],F=[],u=0,e=m.vertices.length;u<e;u++){for(var q=m.vertices[u],O=!1,R=0,ea=z.length;R<ea;R++){var L=z[R];if(q.position.x==L.position.x&&q.position.y==L.position.y&&q.position.z==L.position.z){F[u]=R;O=!0;break}}if(!O){F[u]=z.length;z.push(new THREE.Vertex(q.position.clone()))}}u=0;for(e=m.faces.length;u<e;u++){q=m.faces[u];q.a=F[q.a];q.b=F[q.b];q.c=F[q.c];q.d=F[q.d]}m.vertices=z})();this.computeCentroids();
+fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var b,c,d,f,g=2*Math.ceil(a*3)+1;g>25&&(g=25);f=(g-1)*0.5;c=Array(g);for(b=d=0;b<g;++b){c[b]=Math.exp(-((b-f)*(b-f))/(2*a*a));d+=c[b]}for(b=0;b<g;++b)c[b]/=d;return c}},Cube=function(a,b,c,d,f,g,h,k){function j(A,F,v,H,q,J,e,ba){var L,M,V=d||1,S=f||1,Y=V+1,Z=S+1,G=q/2,T=J/2;q/=V;var la=J/S,W=m.vertices.length;if(A=="x"&&F=="y"||A=="y"&&F=="x")L="z";else if(A=="x"&&F=="z"||A=="z"&&F=="x")L="y";
+else if(A=="z"&&F=="y"||A=="y"&&F=="z")L="x";for(M=0;M<Z;M++)for(J=0;J<Y;J++){var ja=new THREE.Vector3;ja[A]=(J*q-G)*v;ja[F]=(M*la-T)*H;ja[L]=e;m.vertices.push(new THREE.Vertex(ja))}for(M=0;M<S;M++)for(J=0;J<V;J++){m.faces.push(new THREE.Face4(J+Y*M+W,J+Y*(M+1)+W,J+1+Y*(M+1)+W,J+1+Y*M+W,null,ba));m.uvs.push([new THREE.UV(J/V,M/S),new THREE.UV(J/V,(M+1)/S),new THREE.UV((J+1)/V,(M+1)/S),new THREE.UV((J+1)/V,M/S)])}}THREE.Geometry.call(this);var m=this,o=a/2,w=b/2,u=c/2;h=h?-1:1;if(g!==undefined)if(g instanceof
+Array)this.materials=g;else{this.materials=[];for(var t=0;t<6;t++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(k!=undefined)for(var x in k)this.sides[x]!=undefined&&(this.sides[x]=k[x]);this.sides.px&&j("z","y",1*h,-1,c,b,-o,this.materials[0]);this.sides.nx&&j("z","y",-1*h,-1,c,b,o,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=[],F=[],v=0,H=m.vertices.length;v<H;v++){for(var q=m.vertices[v],J=!1,e=0,ba=A.length;e<ba;e++){var L=A[e];if(q.position.x==L.position.x&&q.position.y==L.position.y&&q.position.z==L.position.z){F[v]=e;J=!0;break}}if(!J){F[v]=A.length;A.push(new THREE.Vertex(q.position.clone()))}}v=0;for(H=m.faces.length;v<H;v++){q=m.faces[v];q.a=F[q.a];q.b=F[q.b];q.c=F[q.c];q.d=F[q.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,d,f){function g(m,n,w){h.vertices.push(new THREE.Vertex(new THREE.Vector3(m,n,w)))}THREE.Geometry.call(this);var h=this,k=Math.PI,j;for(j=0;j<a;j++)g(Math.sin(2*k*j/a)*b,Math.cos(2*k*j/a)*b,0);for(j=0;j<a;j++)g(Math.sin(2*k*j/a)*c,Math.cos(2*k*j/a)*c,d);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){g(0,0,-f);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){g(0,0,d+f);for(j=a+a/2;j<
+var Cylinder=function(a,b,c,d,f){function g(m,o,w){h.vertices.push(new THREE.Vertex(new THREE.Vector3(m,o,w)))}THREE.Geometry.call(this);var h=this,k=Math.PI,j;for(j=0;j<a;j++)g(Math.sin(2*k*j/a)*b,Math.cos(2*k*j/a)*b,0);for(j=0;j<a;j++)g(Math.sin(2*k*j/a)*c,Math.cos(2*k*j/a)*c,d);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){g(0,0,-f);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){g(0,0,d+f);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;
 var Plane=function(a,b,c,d){THREE.Geometry.call(this);var f,g=a/2,h=b/2;c=c||1;d=d||1;var k=c+1,j=d+1;a/=c;var m=b/d;for(f=0;f<j;f++)for(b=0;b<k;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-g,-(f*m-h),0)));for(f=0;f<d;f++)for(b=0;b<c;b++){this.faces.push(new THREE.Face4(b+k*f,b+k*(f+1),b+1+k*(f+1),b+1+k*f));this.uvs.push([new THREE.UV(b/c,f/d),new THREE.UV(b/c,(f+1)/d),new THREE.UV((b+1)/c,(f+1)/d),new THREE.UV((b+1)/c,f/d)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
-var Sphere=function(a,b,c){THREE.Geometry.call(this);var d,f=Math.PI,g=Math.max(3,b||8),h=Math.max(2,c||6);b=[];for(c=0;c<h+1;c++){d=c/h;var k=a*Math.cos(d*f),j=a*Math.sin(d*f),m=[],n=0;for(d=0;d<g;d++){var w=2*d/g,t=j*Math.sin(w*f);w=j*Math.cos(w*f);(c==0||c==h)&&d>0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(w,k,t)))-1);m.push(n)}b.push(m)}var p,x,z;f=b.length;for(c=0;c<f;c++){g=b[c].length;if(c>0)for(d=0;d<g;d++){m=d==g-1;h=b[c][m?0:d+1];k=b[c][m?g-1:d];j=b[c-1][m?g-1:d];m=b[c-1][m?
-0:d+1];t=c/(f-1);p=(c-1)/(f-1);x=(d+1)/g;w=d/g;n=new THREE.UV(1-x,t);t=new THREE.UV(1-w,t);w=new THREE.UV(1-w,p);var F=new THREE.UV(1-x,p);if(c<b.length-1){p=this.vertices[h].position.clone();x=this.vertices[k].position.clone();z=this.vertices[j].position.clone();p.normalize();x.normalize();z.normalize();this.faces.push(new THREE.Face3(h,k,j,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(z.x,z.y,z.z)]));this.uvs.push([n,t,w])}if(c>1){p=this.vertices[h].position.clone();
-x=this.vertices[j].position.clone();z=this.vertices[m].position.clone();p.normalize();x.normalize();z.normalize();this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(z.x,z.y,z.z)]));this.uvs.push([n,w,F])}}}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 d,f=Math.PI,g=Math.max(3,b||8),h=Math.max(2,c||6);b=[];for(c=0;c<h+1;c++){d=c/h;var k=a*Math.cos(d*f),j=a*Math.sin(d*f),m=[],o=0;for(d=0;d<g;d++){var w=2*d/g,u=j*Math.sin(w*f);w=j*Math.cos(w*f);(c==0||c==h)&&d>0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(w,k,u)))-1);m.push(o)}b.push(m)}var t,x,A;f=b.length;for(c=0;c<f;c++){g=b[c].length;if(c>0)for(d=0;d<g;d++){m=d==g-1;h=b[c][m?0:d+1];k=b[c][m?g-1:d];j=b[c-1][m?g-1:d];m=b[c-1][m?
+0:d+1];u=c/(f-1);t=(c-1)/(f-1);x=(d+1)/g;w=d/g;o=new THREE.UV(1-x,u);u=new THREE.UV(1-w,u);w=new THREE.UV(1-w,t);var F=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([o,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([o,w,F])}}}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,d){this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){d=c/this.segmentsT*2*Math.PI;var f=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(d),(this.radius+this.tube*Math.cos(f))*Math.sin(d),this.tube*Math.sin(f))));a.push([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c=
 1;c<=this.segmentsT;++c){d=(this.segmentsT+1)*b+c;f=(this.segmentsT+1)*b+c-1;var g=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(d,f,g,h));this.uvs.push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][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(w,t,p){var x=Math.sqrt(w*w+t*t+p*p);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(w/x,t/x,p/x)))-1}function c(w,t,p,x){x.faces.push(new THREE.Face3(w,t,p))}function d(w,t){var p=f.vertices[w].position,x=f.vertices[t].position;return b((p.x+x.x)/2,(p.y+x.y)/2,(p.z+x.z)/2)}var f=this,g=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,g);c(0,5,1,g);c(0,1,7,g);c(0,7,10,g);c(0,10,11,g);c(1,5,9,g);c(5,11,4,g);c(11,10,2,g);c(10,7,6,g);c(7,1,8,g);c(3,9,4,g);c(3,4,2,g);c(3,2,6,g);c(3,6,8,g);c(3,8,9,g);c(4,9,5,g);c(2,4,11,g);c(6,2,10,g);c(8,6,7,g);c(9,8,1,g);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var k in g.faces){var j=d(g.faces[k].a,g.faces[k].b),m=d(g.faces[k].b,g.faces[k].c),n=d(g.faces[k].c,g.faces[k].a);c(g.faces[k].a,j,n,h);c(g.faces[k].b,m,j,h);c(g.faces[k].c,
-n,m,h);c(j,m,n,h)}g.faces=h.faces}f.faces=g.faces;delete g;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 f.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 d(w,u){var t=f.vertices[w].position,x=f.vertices[u].position;return b((t.x+x.x)/2,(t.y+x.y)/2,(t.z+x.z)/2)}var f=this,g=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,g);c(0,5,1,g);c(0,1,7,g);c(0,7,10,g);c(0,10,11,g);c(1,5,9,g);c(5,11,4,g);c(11,10,2,g);c(10,7,6,g);c(7,1,8,g);c(3,9,4,g);c(3,4,2,g);c(3,2,6,g);c(3,6,8,g);c(3,8,9,g);c(4,9,5,g);c(2,4,11,g);c(6,2,10,g);c(8,6,7,g);c(9,8,1,g);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var k in g.faces){var j=d(g.faces[k].a,g.faces[k].b),m=d(g.faces[k].b,g.faces[k].c),o=d(g.faces[k].c,g.faces[k].a);c(g.faces[k].a,j,o,h);c(g.faces[k].b,m,j,h);c(g.faces[k].c,
+o,m,h);c(j,m,o,h)}g.faces=h.faces}f.faces=g.faces;delete g;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);c=c||2*Math.PI;b=c/(b||12);for(var d=[],f=[],g=[],h=[],k=0;k<a.length;k++){this.vertices.push(new THREE.Vertex(a[k]));f[k]=this.vertices.length-1;d[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<d.length;k++)if(m<c){d[k]=j.multiplyVector3(d[k].clone());this.vertices.push(new THREE.Vertex(d[k]));g[k]=this.vertices.length-1}else g=h;m==0&&(h=f);for(k=0;k<f.length-1;k++){this.faces.push(new THREE.Face4(g[k],
 g[k+1],f[k+1],f[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)])}f=g;g=[]}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=!0;this.maxCount=4096;this.count=
-0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(c,d,f){return c+(d-c)*f};this.VIntX=function(c,d,f,g,h,k,j,m,n,w){h=(h-n)/(w-n);n=this.normal_cache;d[g]=k+h*this.delta;d[g+1]=j;d[g+2]=m;f[g]=this.lerp(n[c],n[c+3],h);f[g+1]=this.lerp(n[c+1],n[c+4],h);f[g+2]=this.lerp(n[c+2],n[c+5],h)};this.VIntY=function(c,d,f,g,h,k,j,m,n,w){h=(h-n)/(w-n);n=this.normal_cache;d[g]=k;d[g+1]=j+h*this.delta;d[g+
-2]=m;d=c+this.yd*3;f[g]=this.lerp(n[c],n[d],h);f[g+1]=this.lerp(n[c+1],n[d+1],h);f[g+2]=this.lerp(n[c+2],n[d+2],h)};this.VIntZ=function(c,d,f,g,h,k,j,m,n,w){h=(h-n)/(w-n);n=this.normal_cache;d[g]=k;d[g+1]=j;d[g+2]=m+h*this.delta;d=c+this.zd*3;f[g]=this.lerp(n[c],n[d],h);f[g+1]=this.lerp(n[c+1],n[d+1],h);f[g+2]=this.lerp(n[c+2],n[d+2],h)};this.compNorm=function(c){var d=c*3;if(this.normal_cache[d]==0){this.normal_cache[d]=this.field[c-1]-this.field[c+1];this.normal_cache[d+1]=this.field[c-this.yd]-
-this.field[c+this.yd];this.normal_cache[d+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,d,f,g,h,k){var j=g+1,m=g+this.yd,n=g+this.zd,w=j+this.yd,t=j+this.zd,p=g+this.yd+this.zd,x=j+this.yd+this.zd,z=0,F=this.field[g],u=this.field[j],e=this.field[m],q=this.field[w],O=this.field[n],R=this.field[t],ea=this.field[p],L=this.field[x];F<h&&(z|=1);u<h&&(z|=2);e<h&&(z|=8);q<h&&(z|=4);O<h&&(z|=16);R<h&&(z|=32);ea<h&&(z|=128);L<h&&(z|=64);var I=THREE.edgeTable[z];if(I==0)return 0;
-var Y=this.delta,V=c+Y,ca=d+Y;Y=f+Y;if(I&1){this.compNorm(g);this.compNorm(j);this.VIntX(g*3,this.vlist,this.nlist,0,h,c,d,f,F,u)}if(I&2){this.compNorm(j);this.compNorm(w);this.VIntY(j*3,this.vlist,this.nlist,3,h,V,d,f,u,q)}if(I&4){this.compNorm(m);this.compNorm(w);this.VIntX(m*3,this.vlist,this.nlist,6,h,c,ca,f,e,q)}if(I&8){this.compNorm(g);this.compNorm(m);this.VIntY(g*3,this.vlist,this.nlist,9,h,c,d,f,F,e)}if(I&16){this.compNorm(n);this.compNorm(t);this.VIntX(n*3,this.vlist,this.nlist,12,h,c,d,
-Y,O,R)}if(I&32){this.compNorm(t);this.compNorm(x);this.VIntY(t*3,this.vlist,this.nlist,15,h,V,d,Y,R,L)}if(I&64){this.compNorm(p);this.compNorm(x);this.VIntX(p*3,this.vlist,this.nlist,18,h,c,ca,Y,ea,L)}if(I&128){this.compNorm(n);this.compNorm(p);this.VIntY(n*3,this.vlist,this.nlist,21,h,c,d,Y,O,ea)}if(I&256){this.compNorm(g);this.compNorm(n);this.VIntZ(g*3,this.vlist,this.nlist,24,h,c,d,f,F,O)}if(I&512){this.compNorm(j);this.compNorm(t);this.VIntZ(j*3,this.vlist,this.nlist,27,h,V,d,f,u,R)}if(I&1024){this.compNorm(w);
-this.compNorm(x);this.VIntZ(w*3,this.vlist,this.nlist,30,h,V,ca,f,q,L)}if(I&2048){this.compNorm(m);this.compNorm(p);this.VIntZ(m*3,this.vlist,this.nlist,33,h,c,ca,f,e,ea)}z<<=4;for(h=g=0;THREE.triTable[z+h]!=-1;){c=z+h;d=c+1;f=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[d],3*THREE.triTable[f],k);h+=3;g++}return g};this.posnormtriv=function(c,d,f,g,h,k){var j=this.count*3;this.positionArray[j]=c[f];this.positionArray[j+1]=c[f+1];this.positionArray[j+2]=c[f+2];this.positionArray[j+
+0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(c,d,f){return c+(d-c)*f};this.VIntX=function(c,d,f,g,h,k,j,m,o,w){h=(h-o)/(w-o);o=this.normal_cache;d[g]=k+h*this.delta;d[g+1]=j;d[g+2]=m;f[g]=this.lerp(o[c],o[c+3],h);f[g+1]=this.lerp(o[c+1],o[c+4],h);f[g+2]=this.lerp(o[c+2],o[c+5],h)};this.VIntY=function(c,d,f,g,h,k,j,m,o,w){h=(h-o)/(w-o);o=this.normal_cache;d[g]=k;d[g+1]=j+h*this.delta;d[g+
+2]=m;d=c+this.yd*3;f[g]=this.lerp(o[c],o[d],h);f[g+1]=this.lerp(o[c+1],o[d+1],h);f[g+2]=this.lerp(o[c+2],o[d+2],h)};this.VIntZ=function(c,d,f,g,h,k,j,m,o,w){h=(h-o)/(w-o);o=this.normal_cache;d[g]=k;d[g+1]=j;d[g+2]=m+h*this.delta;d=c+this.zd*3;f[g]=this.lerp(o[c],o[d],h);f[g+1]=this.lerp(o[c+1],o[d+1],h);f[g+2]=this.lerp(o[c+2],o[d+2],h)};this.compNorm=function(c){var d=c*3;if(this.normal_cache[d]==0){this.normal_cache[d]=this.field[c-1]-this.field[c+1];this.normal_cache[d+1]=this.field[c-this.yd]-
+this.field[c+this.yd];this.normal_cache[d+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,d,f,g,h,k){var j=g+1,m=g+this.yd,o=g+this.zd,w=j+this.yd,u=j+this.zd,t=g+this.yd+this.zd,x=j+this.yd+this.zd,A=0,F=this.field[g],v=this.field[j],H=this.field[m],q=this.field[w],J=this.field[o],e=this.field[u],ba=this.field[t],L=this.field[x];F<h&&(A|=1);v<h&&(A|=2);H<h&&(A|=8);q<h&&(A|=4);J<h&&(A|=16);e<h&&(A|=32);ba<h&&(A|=128);L<h&&(A|=64);var M=THREE.edgeTable[A];if(M==0)return 0;
+var V=this.delta,S=c+V,Y=d+V;V=f+V;if(M&1){this.compNorm(g);this.compNorm(j);this.VIntX(g*3,this.vlist,this.nlist,0,h,c,d,f,F,v)}if(M&2){this.compNorm(j);this.compNorm(w);this.VIntY(j*3,this.vlist,this.nlist,3,h,S,d,f,v,q)}if(M&4){this.compNorm(m);this.compNorm(w);this.VIntX(m*3,this.vlist,this.nlist,6,h,c,Y,f,H,q)}if(M&8){this.compNorm(g);this.compNorm(m);this.VIntY(g*3,this.vlist,this.nlist,9,h,c,d,f,F,H)}if(M&16){this.compNorm(o);this.compNorm(u);this.VIntX(o*3,this.vlist,this.nlist,12,h,c,d,V,
+J,e)}if(M&32){this.compNorm(u);this.compNorm(x);this.VIntY(u*3,this.vlist,this.nlist,15,h,S,d,V,e,L)}if(M&64){this.compNorm(t);this.compNorm(x);this.VIntX(t*3,this.vlist,this.nlist,18,h,c,Y,V,ba,L)}if(M&128){this.compNorm(o);this.compNorm(t);this.VIntY(o*3,this.vlist,this.nlist,21,h,c,d,V,J,ba)}if(M&256){this.compNorm(g);this.compNorm(o);this.VIntZ(g*3,this.vlist,this.nlist,24,h,c,d,f,F,J)}if(M&512){this.compNorm(j);this.compNorm(u);this.VIntZ(j*3,this.vlist,this.nlist,27,h,S,d,f,v,e)}if(M&1024){this.compNorm(w);
+this.compNorm(x);this.VIntZ(w*3,this.vlist,this.nlist,30,h,S,Y,f,q,L)}if(M&2048){this.compNorm(m);this.compNorm(t);this.VIntZ(m*3,this.vlist,this.nlist,33,h,c,Y,f,H,ba)}A<<=4;for(h=g=0;THREE.triTable[A+h]!=-1;){c=A+h;d=c+1;f=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[d],3*THREE.triTable[f],k);h+=3;g++}return g};this.posnormtriv=function(c,d,f,g,h,k){var j=this.count*3;this.positionArray[j]=c[f];this.positionArray[j+1]=c[f+1];this.positionArray[j+2]=c[f+2];this.positionArray[j+
 3]=c[g];this.positionArray[j+4]=c[g+1];this.positionArray[j+5]=c[g+2];this.positionArray[j+6]=c[h];this.positionArray[j+7]=c[h+1];this.positionArray[j+8]=c[h+2];this.normalArray[j]=d[f];this.normalArray[j+1]=d[f+1];this.normalArray[j+2]=d[f+2];this.normalArray[j+3]=d[g];this.normalArray[j+4]=d[g+1];this.normalArray[j+5]=d[g+2];this.normalArray[j+6]=d[h];this.normalArray[j+7]=d[h+1];this.normalArray[j+8]=d[h+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=
-function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var d=this.count*3;d<this.positionArray.length;d++)this.positionArray[d]=0;c(this)}};this.addBall=function(c,d,f,g,h){var k=this.size*Math.sqrt(g/h),j=f*this.size,m=d*this.size,n=c*this.size,w=Math.floor(j-k);w<1&&(w=1);j=Math.floor(j+k);j>this.size-1&&(j=this.size-1);var t=Math.floor(m-k);t<1&&(t=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var p=Math.floor(n-k);p<1&&(p=1);k=Math.floor(n+k);
-k>this.size-1&&(k=this.size-1);for(var x,z,F,u,e,q;w<j;w++){n=this.size2*w;z=w/this.size-f;e=z*z;for(z=t;z<m;z++){F=n+this.size*z;x=z/this.size-d;q=x*x;for(x=p;x<k;x++){u=x/this.size-c;u=g/(1.0E-6+u*u+q+e)-h;u>0&&(this.field[F+x]+=u)}}}};this.addPlaneX=function(c,d){var f,g,h,k,j,m=this.size,n=this.yd,w=this.zd,t=this.field,p=m*Math.sqrt(c/d);p>m&&(p=m);for(f=0;f<p;f++){g=f/m;g*=g;k=c/(1.0E-4+g)-d;if(k>0)for(g=0;g<m;g++){j=f+g*n;for(h=0;h<m;h++)t[w*h+j]+=k}}};this.addPlaneY=function(c,d){var f,g,
-h,k,j,m,n=this.size,w=this.yd,t=this.zd,p=this.field,x=n*Math.sqrt(c/d);x>n&&(x=n);for(g=0;g<x;g++){f=g/n;f*=f;k=c/(1.0E-4+f)-d;if(k>0){j=g*w;for(f=0;f<n;f++){m=j+f;for(h=0;h<n;h++)p[t*h+m]+=k}}}};this.addPlaneZ=function(c,d){var f,g,h,k,j,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/d);dist>size&&(dist=size);for(h=0;h<dist;h++){f=h/size;f*=f;k=c/(1.0E-4+f)-d;if(k>0){j=zd*h;for(g=0;g<size;g++){m=j+g*yd;for(f=0;f<size;f++)field[m+f]+=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 d,f,g,h,k,j,m,n,w,t=this.size-2;for(h=1;h<t;h++){w=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(g=1;g<t;g++){n=w+this.size*g;j=(g-this.halfsize)/this.halfsize;for(f=1;f<t;f++){k=(f-this.halfsize)/this.halfsize;d=n+f;this.polygonize(k,j,m,d,this.isolation,c)}}}this.end(c)};this.generateGeometry=function(){var c=0,d=new THREE.Geometry;this.render(function(f){var g,h,k,j,m,n,w,t;for(g=
-0;g<f.count;g++){m=g*3;w=m+1;t=m+2;h=f.positionArray[m];k=f.positionArray[w];j=f.positionArray[t];n=new THREE.Vector3(h,k,j);h=f.normalArray[m];k=f.normalArray[w];j=f.normalArray[t];m=new THREE.Vector3(h,k,j);m.normalize();m=new THREE.Vertex(n,m);d.vertices.push(m)}nfaces=f.count/3;for(g=0;g<nfaces;g++){m=(c+g)*3;w=m+1;t=m+2;n=d.vertices[m].normal;h=d.vertices[w].normal;k=d.vertices[t].normal;m=new THREE.Face3(m,w,t,[n,h,k]);d.faces.push(m)}c+=nfaces;f.count=0});d.sortFacesByMaterial();return d};
+function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var d=this.count*3;d<this.positionArray.length;d++)this.positionArray[d]=0;c(this)}};this.addBall=function(c,d,f,g,h){var k=this.size*Math.sqrt(g/h),j=f*this.size,m=d*this.size,o=c*this.size,w=Math.floor(j-k);w<1&&(w=1);j=Math.floor(j+k);j>this.size-1&&(j=this.size-1);var u=Math.floor(m-k);u<1&&(u=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var t=Math.floor(o-k);t<1&&(t=1);k=Math.floor(o+k);
+k>this.size-1&&(k=this.size-1);for(var x,A,F,v,H,q;w<j;w++){o=this.size2*w;A=w/this.size-f;H=A*A;for(A=u;A<m;A++){F=o+this.size*A;x=A/this.size-d;q=x*x;for(x=t;x<k;x++){v=x/this.size-c;v=g/(1.0E-6+v*v+q+H)-h;v>0&&(this.field[F+x]+=v)}}}};this.addPlaneX=function(c,d){var f,g,h,k,j,m=this.size,o=this.yd,w=this.zd,u=this.field,t=m*Math.sqrt(c/d);t>m&&(t=m);for(f=0;f<t;f++){g=f/m;g*=g;k=c/(1.0E-4+g)-d;if(k>0)for(g=0;g<m;g++){j=f+g*o;for(h=0;h<m;h++)u[w*h+j]+=k}}};this.addPlaneY=function(c,d){var f,g,
+h,k,j,m,o=this.size,w=this.yd,u=this.zd,t=this.field,x=o*Math.sqrt(c/d);x>o&&(x=o);for(g=0;g<x;g++){f=g/o;f*=f;k=c/(1.0E-4+f)-d;if(k>0){j=g*w;for(f=0;f<o;f++){m=j+f;for(h=0;h<o;h++)t[u*h+m]+=k}}}};this.addPlaneZ=function(c,d){var f,g,h,k,j,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/d);dist>size&&(dist=size);for(h=0;h<dist;h++){f=h/size;f*=f;k=c/(1.0E-4+f)-d;if(k>0){j=zd*h;for(g=0;g<size;g++){m=j+g*yd;for(f=0;f<size;f++)field[m+f]+=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 d,f,g,h,k,j,m,o,w,u=this.size-2;for(h=1;h<u;h++){w=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(g=1;g<u;g++){o=w+this.size*g;j=(g-this.halfsize)/this.halfsize;for(f=1;f<u;f++){k=(f-this.halfsize)/this.halfsize;d=o+f;this.polygonize(k,j,m,d,this.isolation,c)}}}this.end(c)};this.generateGeometry=function(){var c=0,d=new THREE.Geometry;this.render(function(f){var g,h,k,j,m,o,w,u;for(g=
+0;g<f.count;g++){m=g*3;w=m+1;u=m+2;h=f.positionArray[m];k=f.positionArray[w];j=f.positionArray[u];o=new THREE.Vector3(h,k,j);h=f.normalArray[m];k=f.normalArray[w];j=f.normalArray[u];m=new THREE.Vector3(h,k,j);m.normalize();m=new THREE.Vertex(o,m);d.vertices.push(m)}nfaces=f.count/3;for(g=0;g<nfaces;g++){m=(c+g)*3;w=m+1;u=m+2;o=d.vertices[m].normal;h=d.vertices[w].normal;k=d.vertices[u].normal;m=new THREE.Face3(m,w,u,[o,h,k]);d.faces.push(m)}c+=nfaces;f.count=0});d.sortFacesByMaterial();return d};
 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,
 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,
@@ -359,24 +358,24 @@ 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,d=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);b.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,c,d)};b.postMessage(a)},loadBinary:function(a){var b=a.model,c=a.callback,d=a.texture_path?a.texture_path:
 THREE.Loader.prototype.extractUrlbase(b),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,c,f,d,g)};b.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,c,d,f,g){var h=new XMLHttpRequest,k=d+"/"+a,j=0;
 h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,c,f,b):alert("Couldn't load ["+k+"] ["+h.status+"]");else if(h.readyState==3){if(g){j==0&&(j=h.getResponseHeader("Content-Length"));g({total:j,loaded:h.responseText.length})}}else h.readyState==2&&(j=h.getResponseHeader("Content-Length"))};h.open("GET",k,!0);h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)},
-createBinModel:function(a,b,c,d){var f=function(g){function h(C,Q){var K=n(C,Q),U=n(C,Q+1),ba=n(C,Q+2),ta=n(C,Q+3),N=(ta<<1&255|ba>>7)-127;K|=(ba&127)<<16|U<<8;if(K==0&&N==-127)return 0;return(1-2*(ta>>7))*(1+K*Math.pow(2,-23))*Math.pow(2,N)}function k(C,Q){var K=n(C,Q),U=n(C,Q+1),ba=n(C,Q+2);return(n(C,Q+3)<<24)+(ba<<16)+(U<<8)+K}function j(C,Q){var K=n(C,Q);return(n(C,Q+1)<<8)+K}function m(C,Q){var K=n(C,Q);return K>127?K-256:K}function n(C,Q){return C.charCodeAt(Q)&255}function w(C){var Q,K,U;
-Q=k(a,C);K=k(a,C+ea);U=k(a,C+L);C=j(a,C+I);THREE.Loader.prototype.f3(u,Q,K,U,C)}function t(C){var Q,K,U,ba,ta,N;Q=k(a,C);K=k(a,C+ea);U=k(a,C+L);ba=j(a,C+I);ta=k(a,C+Y);N=k(a,C+V);C=k(a,C+ca);THREE.Loader.prototype.f3n(u,O,Q,K,U,ba,ta,N,C)}function p(C){var Q,K,U,ba;Q=k(a,C);K=k(a,C+da);U=k(a,C+G);ba=k(a,C+$);C=j(a,C+na);THREE.Loader.prototype.f4(u,Q,K,U,ba,C)}function x(C){var Q,K,U,ba,ta,N,Ba,xa;Q=k(a,C);K=k(a,C+da);U=k(a,C+G);ba=k(a,C+$);ta=j(a,C+na);N=k(a,C+aa);Ba=k(a,C+l);xa=k(a,C+A);C=k(a,C+
-y);THREE.Loader.prototype.f4n(u,O,Q,K,U,ba,ta,N,Ba,xa,C)}function z(C){var Q,K;Q=k(a,C);K=k(a,C+v);C=k(a,C+o);THREE.Loader.prototype.uv3(u.uvs,R[Q*2],R[Q*2+1],R[K*2],R[K*2+1],R[C*2],R[C*2+1])}function F(C){var Q,K,U;Q=k(a,C);K=k(a,C+B);U=k(a,C+E);C=k(a,C+H);THREE.Loader.prototype.uv4(u.uvs,R[Q*2],R[Q*2+1],R[K*2],R[K*2+1],R[U*2],R[U*2+1],R[C*2],R[C*2+1])}var u=this,e=0,q,O=[],R=[],ea,L,I,Y,V,ca,da,G,$,na,aa,l,A,y,v,o,B,E,H,T,D,J,P,ga,la;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(u,
-d,g);q={signature:a.substr(e,8),header_bytes:n(a,e+8),vertex_coordinate_bytes:n(a,e+9),normal_coordinate_bytes:n(a,e+10),uv_coordinate_bytes:n(a,e+11),vertex_index_bytes:n(a,e+12),normal_index_bytes:n(a,e+13),uv_index_bytes:n(a,e+14),material_index_bytes:n(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+=q.header_bytes;ea=q.vertex_index_bytes;L=q.vertex_index_bytes*2;I=q.vertex_index_bytes*3;Y=q.vertex_index_bytes*3+q.material_index_bytes;V=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes;ca=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes*2;da=q.vertex_index_bytes;G=q.vertex_index_bytes*2;$=q.vertex_index_bytes*3;na=q.vertex_index_bytes*4;aa=q.vertex_index_bytes*4+q.material_index_bytes;l=q.vertex_index_bytes*4+q.material_index_bytes+
-q.normal_index_bytes;A=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*2;y=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*3;v=q.uv_index_bytes;o=q.uv_index_bytes*2;B=q.uv_index_bytes;E=q.uv_index_bytes*2;H=q.uv_index_bytes*3;g=q.vertex_index_bytes*3+q.material_index_bytes;la=q.vertex_index_bytes*4+q.material_index_bytes;T=q.ntri_flat*g;D=q.ntri_smooth*(g+q.normal_index_bytes*3);J=q.ntri_flat_uv*(g+q.uv_index_bytes*3);P=q.ntri_smooth_uv*(g+q.normal_index_bytes*
-3+q.uv_index_bytes*3);ga=q.nquad_flat*la;g=q.nquad_smooth*(la+q.normal_index_bytes*4);la=q.nquad_flat_uv*(la+q.uv_index_bytes*4);e+=function(C){for(var Q,K,U,ba=q.vertex_coordinate_bytes*3,ta=C+q.nvertices*ba;C<ta;C+=ba){Q=h(a,C);K=h(a,C+q.vertex_coordinate_bytes);U=h(a,C+q.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(u,Q,K,U)}return q.nvertices*ba}(e);e+=function(C){for(var Q,K,U,ba=q.normal_coordinate_bytes*3,ta=C+q.nnormals*ba;C<ta;C+=ba){Q=m(a,C);K=m(a,C+q.normal_coordinate_bytes);U=m(a,
-C+q.normal_coordinate_bytes*2);O.push(Q/127,K/127,U/127)}return q.nnormals*ba}(e);e+=function(C){for(var Q,K,U=q.uv_coordinate_bytes*2,ba=C+q.nuvs*U;C<ba;C+=U){Q=h(a,C);K=h(a,C+q.uv_coordinate_bytes);R.push(Q,K)}return q.nuvs*U}(e);T=e+T;D=T+D;J=D+J;P=J+P;ga=P+ga;g=ga+g;la=g+la;(function(C){var Q,K=q.vertex_index_bytes*3+q.material_index_bytes,U=K+q.uv_index_bytes*3,ba=C+q.ntri_flat_uv*U;for(Q=C;Q<ba;Q+=U){w(Q);z(Q+K)}return ba-C})(D);(function(C){var Q,K=q.vertex_index_bytes*3+q.material_index_bytes+
-q.normal_index_bytes*3,U=K+q.uv_index_bytes*3,ba=C+q.ntri_smooth_uv*U;for(Q=C;Q<ba;Q+=U){t(Q);z(Q+K)}return ba-C})(J);(function(C){var Q,K=q.vertex_index_bytes*4+q.material_index_bytes,U=K+q.uv_index_bytes*4,ba=C+q.nquad_flat_uv*U;for(Q=C;Q<ba;Q+=U){p(Q);F(Q+K)}return ba-C})(g);(function(C){var Q,K=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*4,U=K+q.uv_index_bytes*4,ba=C+q.nquad_smooth_uv*U;for(Q=C;Q<ba;Q+=U){x(Q);F(Q+K)}return ba-C})(la);(function(C){var Q,K=q.vertex_index_bytes*
-3+q.material_index_bytes,U=C+q.ntri_flat*K;for(Q=C;Q<U;Q+=K)w(Q);return U-C})(e);(function(C){var Q,K=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes*3,U=C+q.ntri_smooth*K;for(Q=C;Q<U;Q+=K)t(Q);return U-C})(T);(function(C){var Q,K=q.vertex_index_bytes*4+q.material_index_bytes,U=C+q.nquad_flat*K;for(Q=C;Q<U;Q+=K)p(Q);return U-C})(P);(function(C){var Q,K=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*4,U=C+q.nquad_smooth*K;for(Q=C;Q<U;Q+=K)x(Q);return U-C})(ga);
-this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(c))},createModel:function(a,b,c){var d=function(f){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,a.materials,f);(function(){var h,k,j,m,n;h=0;for(k=a.vertices.length;h<k;h+=3){j=a.vertices[h];m=a.vertices[h+1];n=a.vertices[h+2];THREE.Loader.prototype.v(g,j,m,n)}if(a.colors){h=0;for(k=a.colors.length;h<k;h+=3){j=a.colors[h];m=
-a.colors[h+1];n=a.colors[h+2];THREE.Loader.prototype.vc(g,j,m,n)}}})();(function(){function h(x,z){THREE.Loader.prototype.f3(g,x[z],x[z+1],x[z+2],x[z+3])}function k(x,z){THREE.Loader.prototype.f3n(g,a.normals,x[z],x[z+1],x[z+2],x[z+3],x[z+4],x[z+5],x[z+6])}function j(x,z){THREE.Loader.prototype.f4(g,x[z],x[z+1],x[z+2],x[z+3],x[z+4])}function m(x,z){THREE.Loader.prototype.f4n(g,a.normals,x[z],x[z+1],x[z+2],x[z+3],x[z+4],x[z+5],x[z+6],x[z+7],x[z+8])}function n(x,z){var F,u,e,q,O,R,ea,L,I;F=x[z];u=x[z+
-1];e=x[z+2];q=a.uvs[F*2];ea=a.uvs[F*2+1];O=a.uvs[u*2];L=a.uvs[u*2+1];R=a.uvs[e*2];I=a.uvs[e*2+1];THREE.Loader.prototype.uv3(g.uvs,q,ea,O,L,R,I);if(a.uvs2&&a.uvs2.length){q=a.uvs2[F*2];ea=a.uvs2[F*2+1];O=a.uvs2[u*2];L=a.uvs2[u*2+1];R=a.uvs2[e*2];I=a.uvs2[e*2+1];THREE.Loader.prototype.uv3(g.uvs2,q,1-ea,O,1-L,R,1-I)}}function w(x,z){var F,u,e,q,O,R,ea,L,I,Y,V,ca;F=x[z];u=x[z+1];e=x[z+2];q=x[z+3];O=a.uvs[F*2];I=a.uvs[F*2+1];R=a.uvs[u*2];Y=a.uvs[u*2+1];ea=a.uvs[e*2];V=a.uvs[e*2+1];L=a.uvs[q*2];ca=a.uvs[q*
-2+1];THREE.Loader.prototype.uv4(g.uvs,O,I,R,Y,ea,V,L,ca);if(a.uvs2){O=a.uvs2[F*2];I=a.uvs2[F*2+1];R=a.uvs2[u*2];Y=a.uvs2[u*2+1];ea=a.uvs2[e*2];V=a.uvs2[e*2+1];L=a.uvs2[q*2];ca=a.uvs2[q*2+1];THREE.Loader.prototype.uv4(g.uvs2,O,1-I,R,1-Y,ea,1-V,L,1-ca)}}var t,p;t=0;for(p=a.triangles_uv.length;t<p;t+=7){h(a.triangles_uv,t);n(a.triangles_uv,t+4)}t=0;for(p=a.triangles_n_uv.length;t<p;t+=10){k(a.triangles_n_uv,t);n(a.triangles_n_uv,t+7)}t=0;for(p=a.quads_uv.length;t<p;t+=9){j(a.quads_uv,t);w(a.quads_uv,
-t+5)}t=0;for(p=a.quads_n_uv.length;t<p;t+=13){m(a.quads_n_uv,t);w(a.quads_n_uv,t+9)}t=0;for(p=a.triangles.length;t<p;t+=4)h(a.triangles,t);t=0;for(p=a.triangles_n.length;t<p;t+=7)k(a.triangles_n,t);t=0;for(p=a.quads.length;t<p;t+=5)j(a.quads,t);t=0;for(p=a.quads_n.length;t<p;t+=9)m(a.quads_n,t)})();(function(){var h,k,j,m;if(a.skinWeights){h=0;for(k=a.skinWeights.length;h<k;h+=2){j=a.skinWeights[h];m=a.skinWeights[h+1];THREE.Loader.prototype.sw(g,j,m,0,0)}}if(a.skinIndices){h=0;for(k=a.skinIndices.length;h<
-k;h+=2){j=a.skinIndices[h];m=a.skinIndices[h+1];THREE.Loader.prototype.si(g,j,m,0,0)}}THREE.Loader.prototype.bones(g,a.bones);THREE.Loader.prototype.animation(g,a.animation)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};d.prototype=new THREE.Geometry;d.prototype.constructor=d;b(new d(c))},bones:function(a,b){a.bones=b},animation:function(a,b){a.animation=b},si:function(a,b,c,d,f){a.skinIndices.push(new THREE.Vector4(b,c,d,f))},sw:function(a,b,c,d,f){a.skinWeights.push(new THREE.Vector4(b,
-c,d,f))},v:function(a,b,c,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,d)))},vc:function(a,b,c,d){var f=new THREE.Color(16777215);f.setRGB(b,c,d);a.colors.push(f)},f3:function(a,b,c,d,f){a.faces.push(new THREE.Face3(b,c,d,null,a.materials[f]))},f4:function(a,b,c,d,f,g){a.faces.push(new THREE.Face4(b,c,d,f,null,a.materials[g]))},f3n:function(a,b,c,d,f,g,h,k,j){g=a.materials[g];var m=b[k*3],n=b[k*3+1];k=b[k*3+2];var w=b[j*3],t=b[j*3+1];j=b[j*3+2];a.faces.push(new THREE.Face3(c,d,f,[new THREE.Vector3(b[h*
-3],b[h*3+1],b[h*3+2]),new THREE.Vector3(m,n,k),new THREE.Vector3(w,t,j)],g))},f4n:function(a,b,c,d,f,g,h,k,j,m,n){h=a.materials[h];var w=b[j*3],t=b[j*3+1];j=b[j*3+2];var p=b[m*3],x=b[m*3+1];m=b[m*3+2];var z=b[n*3],F=b[n*3+1];n=b[n*3+2];a.faces.push(new THREE.Face4(c,d,f,g,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(w,t,j),new THREE.Vector3(p,x,m),new THREE.Vector3(z,F,n)],h))},uv3:function(a,b,c,d,f,g,h){var k=[];k.push(new THREE.UV(b,c));k.push(new THREE.UV(d,f));k.push(new THREE.UV(g,
-h));a.push(k)},uv4:function(a,b,c,d,f,g,h,k,j){var m=[];m.push(new THREE.UV(b,c));m.push(new THREE.UV(d,f));m.push(new THREE.UV(g,h));m.push(new THREE.UV(k,j));a.push(m)},init_materials:function(a,b,c){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=[THREE.Loader.prototype.createMaterial(b[d],c)]},createMaterial:function(a,b){function c(k){k=Math.log(k)/Math.LN2;return Math.floor(k)==k}function d(k,j){var m=new Image;m.onload=function(){if(!c(this.width)||!c(this.height)){var n=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=n;k.image.height=w;k.image.getContext("2d").drawImage(this,0,0,n,w)}else k.image=this;k.image.loaded=1};m.src=j}var f,g,h;f="MeshLambertMaterial";g={color:15658734,opacity:1,map:null,light_map:null,vertex_colors:a.vertex_colors};a.shading&&a.shading=="Phong"&&(f="MeshPhongMaterial");if(a.map_diffuse&&b){h=document.createElement("canvas");g.map=new THREE.Texture(h);d(g.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;g.color=h;g.opacity=a.transparency}else if(a.a_dbg_color)g.color=a.a_dbg_color;if(a.map_lightmap&&b){h=document.createElement("canvas");g.light_map=new THREE.Texture(h);d(g.light_map,b+"/"+a.map_lightmap)}return new THREE[f](g)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
+createBinModel:function(a,b,c,d){var f=function(g){function h(y,C){var D=o(y,C),Q=o(y,C+1),U=o(y,C+2),pa=o(y,C+3),ka=(pa<<1&255|U>>7)-127;D|=(U&127)<<16|Q<<8;if(D==0&&ka==-127)return 0;return(1-2*(pa>>7))*(1+D*Math.pow(2,-23))*Math.pow(2,ka)}function k(y,C){var D=o(y,C),Q=o(y,C+1),U=o(y,C+2);return(o(y,C+3)<<24)+(U<<16)+(Q<<8)+D}function j(y,C){var D=o(y,C);return(o(y,C+1)<<8)+D}function m(y,C){var D=o(y,C);return D>127?D-256:D}function o(y,C){return y.charCodeAt(C)&255}function w(y){var C,D,Q;C=
+k(a,y);D=k(a,y+ba);Q=k(a,y+L);y=j(a,y+M);THREE.Loader.prototype.f3(v,C,D,Q,y)}function u(y){var C,D,Q,U,pa,ka;C=k(a,y);D=k(a,y+ba);Q=k(a,y+L);U=j(a,y+M);pa=k(a,y+V);ka=k(a,y+S);y=k(a,y+Y);THREE.Loader.prototype.f3n(v,J,C,D,Q,U,pa,ka,y)}function t(y){var C,D,Q,U;C=k(a,y);D=k(a,y+Z);Q=k(a,y+G);U=k(a,y+T);y=j(a,y+la);THREE.Loader.prototype.f4(v,C,D,Q,U,y)}function x(y){var C,D,Q,U,pa,ka,ma,na;C=k(a,y);D=k(a,y+Z);Q=k(a,y+G);U=k(a,y+T);pa=j(a,y+la);ka=k(a,y+W);ma=k(a,y+ja);na=k(a,y+ia);y=k(a,y+$);THREE.Loader.prototype.f4n(v,
+J,C,D,Q,U,pa,ka,ma,na,y)}function A(y){var C,D;C=k(a,y);D=k(a,y+ra);y=k(a,y+ya);THREE.Loader.prototype.uv3(v.uvs,e[C*2],e[C*2+1],e[D*2],e[D*2+1],e[y*2],e[y*2+1])}function F(y){var C,D,Q;C=k(a,y);D=k(a,y+l);Q=k(a,y+z);y=k(a,y+B);THREE.Loader.prototype.uv4(v.uvs,e[C*2],e[C*2+1],e[D*2],e[D*2+1],e[Q*2],e[Q*2+1],e[y*2],e[y*2+1])}var v=this,H=0,q,J=[],e=[],ba,L,M,V,S,Y,Z,G,T,la,W,ja,ia,$,ra,ya,l,z,B,p,n,E,I,P,da;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,d,g);q={signature:a.substr(H,
+8),header_bytes:o(a,H+8),vertex_coordinate_bytes:o(a,H+9),normal_coordinate_bytes:o(a,H+10),uv_coordinate_bytes:o(a,H+11),vertex_index_bytes:o(a,H+12),normal_index_bytes:o(a,H+13),uv_index_bytes:o(a,H+14),material_index_bytes:o(a,H+15),nvertices:k(a,H+16),nnormals:k(a,H+16+4),nuvs:k(a,H+16+8),ntri_flat:k(a,H+16+12),ntri_smooth:k(a,H+16+16),ntri_flat_uv:k(a,H+16+20),ntri_smooth_uv:k(a,H+16+24),nquad_flat:k(a,H+16+28),nquad_smooth:k(a,H+16+32),nquad_flat_uv:k(a,H+16+36),nquad_smooth_uv:k(a,H+16+40)};
+H+=q.header_bytes;ba=q.vertex_index_bytes;L=q.vertex_index_bytes*2;M=q.vertex_index_bytes*3;V=q.vertex_index_bytes*3+q.material_index_bytes;S=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes;Y=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes*2;Z=q.vertex_index_bytes;G=q.vertex_index_bytes*2;T=q.vertex_index_bytes*3;la=q.vertex_index_bytes*4;W=q.vertex_index_bytes*4+q.material_index_bytes;ja=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes;ia=q.vertex_index_bytes*
+4+q.material_index_bytes+q.normal_index_bytes*2;$=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*3;ra=q.uv_index_bytes;ya=q.uv_index_bytes*2;l=q.uv_index_bytes;z=q.uv_index_bytes*2;B=q.uv_index_bytes*3;g=q.vertex_index_bytes*3+q.material_index_bytes;da=q.vertex_index_bytes*4+q.material_index_bytes;p=q.ntri_flat*g;n=q.ntri_smooth*(g+q.normal_index_bytes*3);E=q.ntri_flat_uv*(g+q.uv_index_bytes*3);I=q.ntri_smooth_uv*(g+q.normal_index_bytes*3+q.uv_index_bytes*3);P=q.nquad_flat*da;
+g=q.nquad_smooth*(da+q.normal_index_bytes*4);da=q.nquad_flat_uv*(da+q.uv_index_bytes*4);H+=function(y){for(var C,D,Q,U=q.vertex_coordinate_bytes*3,pa=y+q.nvertices*U;y<pa;y+=U){C=h(a,y);D=h(a,y+q.vertex_coordinate_bytes);Q=h(a,y+q.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(v,C,D,Q)}return q.nvertices*U}(H);H+=function(y){for(var C,D,Q,U=q.normal_coordinate_bytes*3,pa=y+q.nnormals*U;y<pa;y+=U){C=m(a,y);D=m(a,y+q.normal_coordinate_bytes);Q=m(a,y+q.normal_coordinate_bytes*2);J.push(C/127,D/
+127,Q/127)}return q.nnormals*U}(H);H+=function(y){for(var C,D,Q=q.uv_coordinate_bytes*2,U=y+q.nuvs*Q;y<U;y+=Q){C=h(a,y);D=h(a,y+q.uv_coordinate_bytes);e.push(C,D)}return q.nuvs*Q}(H);p=H+p;n=p+n;E=n+E;I=E+I;P=I+P;g=P+g;da=g+da;(function(y){var C,D=q.vertex_index_bytes*3+q.material_index_bytes,Q=D+q.uv_index_bytes*3,U=y+q.ntri_flat_uv*Q;for(C=y;C<U;C+=Q){w(C);A(C+D)}return U-y})(n);(function(y){var C,D=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes*3,Q=D+q.uv_index_bytes*3,U=y+
+q.ntri_smooth_uv*Q;for(C=y;C<U;C+=Q){u(C);A(C+D)}return U-y})(E);(function(y){var C,D=q.vertex_index_bytes*4+q.material_index_bytes,Q=D+q.uv_index_bytes*4,U=y+q.nquad_flat_uv*Q;for(C=y;C<U;C+=Q){t(C);F(C+D)}return U-y})(g);(function(y){var C,D=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*4,Q=D+q.uv_index_bytes*4,U=y+q.nquad_smooth_uv*Q;for(C=y;C<U;C+=Q){x(C);F(C+D)}return U-y})(da);(function(y){var C,D=q.vertex_index_bytes*3+q.material_index_bytes,Q=y+q.ntri_flat*D;for(C=y;C<
+Q;C+=D)w(C);return Q-y})(H);(function(y){var C,D=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes*3,Q=y+q.ntri_smooth*D;for(C=y;C<Q;C+=D)u(C);return Q-y})(p);(function(y){var C,D=q.vertex_index_bytes*4+q.material_index_bytes,Q=y+q.nquad_flat*D;for(C=y;C<Q;C+=D)t(C);return Q-y})(I);(function(y){var C,D=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*4,Q=y+q.nquad_smooth*D;for(C=y;C<Q;C+=D)x(C);return Q-y})(P);this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
+f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(c))},createModel:function(a,b,c){var d=function(f){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,a.materials,f);(function(){var h,k,j,m,o;h=0;for(k=a.vertices.length;h<k;h+=3){j=a.vertices[h];m=a.vertices[h+1];o=a.vertices[h+2];THREE.Loader.prototype.v(g,j,m,o)}if(a.colors){h=0;for(k=a.colors.length;h<k;h+=3){j=a.colors[h];m=a.colors[h+1];o=a.colors[h+2];THREE.Loader.prototype.vc(g,j,m,o)}}})();(function(){function h(x,
+A){THREE.Loader.prototype.f3(g,x[A],x[A+1],x[A+2],x[A+3])}function k(x,A){THREE.Loader.prototype.f3n(g,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(g,x[A],x[A+1],x[A+2],x[A+3],x[A+4])}function m(x,A){THREE.Loader.prototype.f4n(g,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 o(x,A){var F,v,H,q,J,e,ba,L,M;F=x[A];v=x[A+1];H=x[A+2];q=a.uvs[F*2];ba=a.uvs[F*2+1];J=a.uvs[v*2];L=a.uvs[v*2+1];e=a.uvs[H*2];M=a.uvs[H*2+
+1];THREE.Loader.prototype.uv3(g.uvs,q,ba,J,L,e,M);if(a.uvs2&&a.uvs2.length){q=a.uvs2[F*2];ba=a.uvs2[F*2+1];J=a.uvs2[v*2];L=a.uvs2[v*2+1];e=a.uvs2[H*2];M=a.uvs2[H*2+1];THREE.Loader.prototype.uv3(g.uvs2,q,1-ba,J,1-L,e,1-M)}}function w(x,A){var F,v,H,q,J,e,ba,L,M,V,S,Y;F=x[A];v=x[A+1];H=x[A+2];q=x[A+3];J=a.uvs[F*2];M=a.uvs[F*2+1];e=a.uvs[v*2];V=a.uvs[v*2+1];ba=a.uvs[H*2];S=a.uvs[H*2+1];L=a.uvs[q*2];Y=a.uvs[q*2+1];THREE.Loader.prototype.uv4(g.uvs,J,M,e,V,ba,S,L,Y);if(a.uvs2){J=a.uvs2[F*2];M=a.uvs2[F*
+2+1];e=a.uvs2[v*2];V=a.uvs2[v*2+1];ba=a.uvs2[H*2];S=a.uvs2[H*2+1];L=a.uvs2[q*2];Y=a.uvs2[q*2+1];THREE.Loader.prototype.uv4(g.uvs2,J,1-M,e,1-V,ba,1-S,L,1-Y)}}var u,t;u=0;for(t=a.triangles_uv.length;u<t;u+=7){h(a.triangles_uv,u);o(a.triangles_uv,u+4)}u=0;for(t=a.triangles_n_uv.length;u<t;u+=10){k(a.triangles_n_uv,u);o(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)})();(function(){var h,k,j,m;if(a.skinWeights){h=0;for(k=a.skinWeights.length;h<k;h+=2){j=a.skinWeights[h];m=a.skinWeights[h+1];THREE.Loader.prototype.sw(g,j,m,0,0)}}if(a.skinIndices){h=0;for(k=a.skinIndices.length;h<k;h+=2){j=a.skinIndices[h];m=a.skinIndices[h+1];THREE.Loader.prototype.si(g,j,m,0,0)}}THREE.Loader.prototype.bones(g,
+a.bones);THREE.Loader.prototype.animation(g,a.animation)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};d.prototype=new THREE.Geometry;d.prototype.constructor=d;b(new d(c))},bones:function(a,b){a.bones=b},animation:function(a,b){a.animation=b},si:function(a,b,c,d,f){a.skinIndices.push(new THREE.Vector4(b,c,d,f))},sw:function(a,b,c,d,f){a.skinWeights.push(new THREE.Vector4(b,c,d,f))},v:function(a,b,c,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,d)))},
+vc:function(a,b,c,d){var f=new THREE.Color(16777215);f.setRGB(b,c,d);a.colors.push(f)},f3:function(a,b,c,d,f){a.faces.push(new THREE.Face3(b,c,d,null,a.materials[f]))},f4:function(a,b,c,d,f,g){a.faces.push(new THREE.Face4(b,c,d,f,null,a.materials[g]))},f3n:function(a,b,c,d,f,g,h,k,j){g=a.materials[g];var m=b[k*3],o=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,d,f,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(m,o,k),new THREE.Vector3(w,u,j)],
+g))},f4n:function(a,b,c,d,f,g,h,k,j,m,o){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[o*3],F=b[o*3+1];o=b[o*3+2];a.faces.push(new THREE.Face4(c,d,f,g,[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,F,o)],h))},uv3:function(a,b,c,d,f,g,h){var k=[];k.push(new THREE.UV(b,c));k.push(new THREE.UV(d,f));k.push(new THREE.UV(g,h));a.push(k)},uv4:function(a,b,c,d,f,g,h,k,j){var m=[];m.push(new THREE.UV(b,
+c));m.push(new THREE.UV(d,f));m.push(new THREE.UV(g,h));m.push(new THREE.UV(k,j));a.push(m)},init_materials:function(a,b,c){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=[THREE.Loader.prototype.createMaterial(b[d],c)]},createMaterial:function(a,b){function c(k){k=Math.log(k)/Math.LN2;return Math.floor(k)==k}function d(k,j){var m=new Image;m.onload=function(){if(!c(this.width)||!c(this.height)){var o=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=o;k.image.height=w;k.image.getContext("2d").drawImage(this,0,0,o,w)}else k.image=this;k.image.loaded=1};m.src=j}var f,g,h;f="MeshLambertMaterial";g={color:15658734,opacity:1,map:null,light_map:null,vertex_colors:a.vertex_colors};a.shading&&a.shading=="Phong"&&(f="MeshPhongMaterial");if(a.map_diffuse&&b){h=document.createElement("canvas");g.map=new THREE.Texture(h);d(g.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;g.color=h;g.opacity=a.transparency}else if(a.a_dbg_color)g.color=a.a_dbg_color;if(a.map_lightmap&&b){h=document.createElement("canvas");g.light_map=new THREE.Texture(h);d(g.light_map,b+"/"+a.map_lightmap)}return new THREE[f](g)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};

+ 2 - 0
examples/materials_shaders_fresnel.html

@@ -114,6 +114,8 @@
 					
 				}
 
+				scene.autoUpdateMatrix = false;
+				
 				SceneUtils.addPanoramaCubeWebGL( sceneCube, 100000, textureCube );
 
 				webglRenderer = new THREE.WebGLRenderer();

+ 5 - 1
examples/scene_test.html

@@ -346,7 +346,7 @@
 				
 				result.camera.position.z = 100;
 				
-				var object, geometry, material, light, count = 100, range = 150;
+				var object, geometry, material, light, count = 500, range = 200;
 				
 				material = new THREE.MeshLambertMaterial( { color:0xffffff } );
 				geometry = new Cube( 5, 5, 5 );
@@ -360,10 +360,14 @@
 					object.rotation.x = Math.random() * 6;
 					object.rotation.y = Math.random() * 6;
 					object.rotation.z = Math.random() * 6;
+					object.autoUpdateMatrix = false;
+					object.updateMatrix();
 					result.scene.addObject( object );
 					
 				}
 				
+				result.scene.autoUpdateMatrix = false;
+				
 				light = new THREE.PointLight( 0xffffff );
 				result.scene.addLight( light );
 

+ 6 - 3
src/core/Matrix4.js

@@ -525,9 +525,11 @@ THREE.Matrix4.prototype = {
 	    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;
@@ -570,15 +572,16 @@ THREE.Matrix4.prototype = {
 	
 	scale: function( vec3 ) {
 		
-		var x = vec3.x;
-		var y = vec3.y;
-		var z = vec3.z;
+		var x = vec3.x,
+			y = vec3.y,
+			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;
+
 	},
 	
 	extractRotationMatrix: function( m ) {

+ 1 - 7
src/objects/Mesh.js

@@ -10,7 +10,6 @@ THREE.Mesh = function( geometry, materials ) {
 	
 	this.geometry     = geometry;
 	this.materials    = materials && materials.length ? materials : [ materials ];
-	this.normalMatrix = THREE.Matrix4.makeInvert3x3( this.globalMatrix ).transpose();
 	
 	this.flipSided = false;
 	this.doubleSided = false;
@@ -60,12 +59,7 @@ THREE.Mesh.prototype.update = function( parentGlobalMatrix, forceUpdate, camera
 				this.globalMatrix.copy( this.localMatrix );
 			
 			this.matrixNeedsToUpdate = false;
-			forceUpdate               = true;
-			
-			
-			// update normal
-
-			this.normalMatrix = THREE.Matrix4.makeInvert3x3( this.globalMatrix ).transpose();
+			forceUpdate               = true;			
 
 		}
 

+ 0 - 5
src/objects/SkinnedMesh.js

@@ -98,11 +98,6 @@ THREE.SkinnedMesh.prototype.update = function( parentGlobalMatrix, forceUpdate,
 			
 			this.matrixNeedsToUpdate = false;
 			forceUpdate              = true;
-			
-			
-			// update normal
-
-			this.normalMatrix = THREE.Matrix4.makeInvert3x3( this.globalMatrix ).transpose();
 
 		}
 

+ 68 - 56
src/renderers/WebGLRenderer.js

@@ -24,11 +24,14 @@ THREE.WebGLRenderer = function ( parameters ) {
 	_oldProgram = null,
 	_oldFramebuffer = null,	
 
+	_this = this,
+	
 	// gl state cache
 	
 	_oldDoubleSided = null,
 	_oldFlipSided = null,
 	_oldBlending = null,
+	_oldDepth = null,
 	
 	// camera matrices caches
 	
@@ -109,12 +112,12 @@ THREE.WebGLRenderer = function ( parameters ) {
 	};
 
 
-	this.setupLights = function ( program, lights ) {
+	function setupLights ( program, lights ) {
 
 		var l, ll, light, r = 0, g = 0, b = 0,
 			color, position, intensity,
 
-			zlights = this.lights,
+			zlights = _this.lights,
 
 			dcolors    = zlights.directional.colors,
 			dpositions = zlights.directional.positions,
@@ -1289,12 +1292,31 @@ THREE.WebGLRenderer = function ( parameters ) {
 		cacheUniformLocations( material.program, identifiers );
 		cacheAttributeLocations( material.program, [ "position", "normal", "uv", "uv2", "tangent", "color", 
 													 "skinVertexA", "skinVertexB", "skinIndex", "skinWeight" ] );
+		
+		var attributes = material.program.attributes;
+		
+		_gl.enableVertexAttribArray( attributes.position );
+		
+		if ( attributes.color >= 0 ) 	_gl.enableVertexAttribArray( attributes.color );
+		if ( attributes.normal >= 0 ) 	_gl.enableVertexAttribArray( attributes.normal );	
+		if ( attributes.tangent >= 0 ) 	_gl.enableVertexAttribArray( attributes.tangent );
+		
+		if ( material.skinning && 
+			 attributes.skinVertexA >=0 && attributes.skinVertexB >= 0 && 
+			 attributes.skinIndex >= 0 && attributes.skinWeight >= 0 ) {
+			
+			_gl.enableVertexAttribArray( attributes.skinVertexA );
+			_gl.enableVertexAttribArray( attributes.skinVertexB );
+			_gl.enableVertexAttribArray( attributes.skinIndex );
+			_gl.enableVertexAttribArray( attributes.skinWeight );
+			
+		}
 
 	};
 	
-	this.setProgram = function( camera, lights, fog, material, object ) {
+	function setProgram ( camera, lights, fog, material, object ) {
 		
-		if ( !material.program ) this.initMaterial( material, lights, fog );
+		if ( !material.program ) _this.initMaterial( material, lights, fog );
 
 		var program = material.program, 
 			p_uniforms = program.uniforms,
@@ -1326,8 +1348,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 		if ( material instanceof THREE.MeshPhongMaterial ||
 			 material instanceof THREE.MeshLambertMaterial ) {
 
-			this.setupLights( program, lights );
-			refreshUniformsLights( m_uniforms, this.lights );
+			setupLights( program, lights );
+			refreshUniformsLights( m_uniforms, _this.lights );
 
 		}
 
@@ -1408,11 +1430,11 @@ THREE.WebGLRenderer = function ( parameters ) {
 		
 	};
 		
-	this.renderBuffer = function ( camera, lights, fog, material, geometryChunk, object ) {
+	function renderBuffer( camera, lights, fog, material, geometryChunk, object ) {
 
 		var program, attributes, linewidth, primitives;
 
-		program = this.setProgram( camera, lights, fog, material, object );
+		program = setProgram( camera, lights, fog, material, object );
 		
 		attributes = program.attributes;
 
@@ -1420,15 +1442,13 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLVertexBuffer );
 		_gl.vertexAttribPointer( attributes.position, 3, _gl.FLOAT, false, 0, 0 );
-		_gl.enableVertexAttribArray( attributes.position );
 
 		// colors
 
 		if ( attributes.color >= 0 ) {
 
 			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLColorBuffer );
-			_gl.vertexAttribPointer( attributes.color, 3, _gl.FLOAT, false, 0, 0 );
-			_gl.enableVertexAttribArray( attributes.color );
+			_gl.vertexAttribPointer( attributes.color, 3, _gl.FLOAT, false, 0, 0 );			
 
 		}
 
@@ -1437,8 +1457,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		if ( attributes.normal >= 0 ) {
 
 			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLNormalBuffer );
-			_gl.vertexAttribPointer( attributes.normal, 3, _gl.FLOAT, false, 0, 0 );
-			_gl.enableVertexAttribArray( attributes.normal );
+			_gl.vertexAttribPointer( attributes.normal, 3, _gl.FLOAT, false, 0, 0 );			
 
 		}
 
@@ -1448,7 +1467,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLTangentBuffer );
 			_gl.vertexAttribPointer( attributes.tangent, 4, _gl.FLOAT, false, 0, 0 );
-			_gl.enableVertexAttribArray( attributes.tangent );
 
 		}
 
@@ -1488,23 +1506,21 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		}
 
-		if ( object instanceof THREE.SkinnedMesh ) {
+		if ( material.skinning && 
+			 attributes.skinVertexA >=0 && attributes.skinVertexB >= 0 && 
+			 attributes.skinIndex >= 0 && attributes.skinWeight >= 0 ) {
 			
 			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLSkinVertexABuffer );
 			_gl.vertexAttribPointer( attributes.skinVertexA, 4, _gl.FLOAT, false, 0, 0 );
-			_gl.enableVertexAttribArray( attributes.skinVertexA );
 
 			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLSkinVertexBBuffer );
 			_gl.vertexAttribPointer( attributes.skinVertexB, 4, _gl.FLOAT, false, 0, 0 );
-			_gl.enableVertexAttribArray( attributes.skinVertexB );
 
 			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLSkinIndicesBuffer );
 			_gl.vertexAttribPointer( attributes.skinIndex, 4, _gl.FLOAT, false, 0, 0 );
-			_gl.enableVertexAttribArray( attributes.skinIndex );
 
 			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLSkinWeightsBuffer );
 			_gl.vertexAttribPointer( attributes.skinWeight, 4, _gl.FLOAT, false, 0, 0 );
-			_gl.enableVertexAttribArray( attributes.skinWeight );
 			
 		}
 		
@@ -1613,6 +1629,26 @@ THREE.WebGLRenderer = function ( parameters ) {
 		
 	};
 	
+	function setDepthTest( test ) {
+		
+		if ( _oldDepth != test ) {
+
+			if( test ) {
+				
+				_gl.enable( _gl.DEPTH_TEST );
+				
+			} else {
+				
+				_gl.disable( _gl.DEPTH_TEST );
+				
+			}
+			
+			_oldDepth = test;
+
+		}
+		
+	};
+	
 	function computeFrustum( m ) {
 
 		_frustum[ 0 ].set( m.n41 - m.n11, m.n42 - m.n12, m.n43 - m.n13, m.n44 - m.n14 );
@@ -1750,8 +1786,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		_projScreenMatrix.multiply( camera.projectionMatrix, camera.globalMatrix );
 		computeFrustum( _projScreenMatrix );
 		
-		if( THREE.AnimationHandler )
-			THREE.AnimationHandler.update();
+		if( THREE.AnimationHandler ) THREE.AnimationHandler.update();
 		
 		scene.update( undefined, false, camera );
 		
@@ -1858,8 +1893,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 					
 					material = opaque.list[ i ];
 					
-					this.setDepthTest( material.depth_test );
-					this.renderBuffer( camera, lights, fog, material, buffer, object );
+					setDepthTest( material.depth_test );
+					renderBuffer( camera, lights, fog, material, buffer, object );
 				
 				}
 
@@ -1884,8 +1919,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 				
 					material = opaque.list[ i ];
 				
-					this.setDepthTest( material.depth_test );
-					program = this.setProgram( camera, lights, fog, material, object );
+					setDepthTest( material.depth_test );
+					
+					program = setProgram( camera, lights, fog, material, object );
 					object.render( function( object ) { renderBufferImmediate( object, program ); } );
 				
 				}
@@ -1913,8 +1949,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 					material = transparent.list[ i ];
 					
 					setBlending( material.blending );
-					this.setDepthTest( material.depth_test );
-					this.renderBuffer( camera, lights, fog, material, buffer, object );
+					setDepthTest( material.depth_test );
+					
+					renderBuffer( camera, lights, fog, material, buffer, object );
 				
 				}
 
@@ -1940,8 +1977,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 					material = transparent.list[ i ];
 				
 					setBlending( material.blending );
-					this.setDepthTest( material.depth_test );
-					program = this.setProgram( camera, lights, fog, material, object );
+					setDepthTest( material.depth_test );
+					
+					program = setProgram( camera, lights, fog, material, object );
 					object.render( function( object ) { renderBufferImmediate( object, program ); } );
 				
 				}
@@ -2154,40 +2192,14 @@ THREE.WebGLRenderer = function ( parameters ) {
 		}
 
 	};
-
-	this.addToRenderList = function( object ) {
-		
-		// TODO: implement this
-		
-	};
-
-	this.removeFromRenderList = function( object ) {
-		
-		// TODO: implement this
-		
-	};
 	
 	function setupMatrices ( object, camera ) {
 
 		object._modelViewMatrix.multiplyToArray( camera.globalMatrix, object.globalMatrix, object._modelViewMatrixArray );
-		object._normalMatrix = THREE.Matrix4.makeInvert3x3( object._modelViewMatrix ).transposeIntoArray( object._normalMatrixArray );
+		THREE.Matrix4.makeInvert3x3( object._modelViewMatrix ).transposeIntoArray( object._normalMatrixArray );
 
 	};
 
-	this.setDepthTest = function( test ) {
-		
-		if( test ) {
-			
-			_gl.enable( _gl.DEPTH_TEST );
-			
-		} else {
-			
-			_gl.disable( _gl.DEPTH_TEST );
-			
-		}
-		
-	};
-
 	this.setFaceCulling = function ( cullFace, frontFace ) {
 
 		if ( cullFace ) {

+ 1 - 1
src/scenes/Scene.js

@@ -40,7 +40,7 @@ THREE.Scene.prototype.addChildRecurse = function( child ) {
 		if( this.lights.indexOf( child ) === -1 )
 			this.lights.push( child );	
 
-	} else if( !( child instanceof THREE.Camera ) ) {
+	} else if( !( child instanceof THREE.Camera || child instanceof THREE.Bone ) ) {
 		
 		if( this.objects.indexOf( child ) === -1 )
 			this.objects.push( child );