Browse Source

Removed dirty flag from Quaternion.

There don't seem to be any effects on performance (though I'm not sure this was actually used in any example/test code path - so far quaternions are used just for animation interpolation and even there they were always dirty, and also just updated during JIT baking).

Also some more code cleanup - no need for Mesh to have own "update" as now it was exactly the same as its parent Object3D.
alteredq 14 years ago
parent
commit
b36cf734bd

+ 105 - 108
build/Three.js

@@ -1,6 +1,6 @@
 // Three.js r32 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
-THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,d){var e,g,i,l,n,k;if(d==0)e=g=i=0;else{l=Math.floor(a*6);n=a*6-l;a=d*(1-b);k=d*(1-b*n);b=d*(1-b*(1-n));switch(l){case 1:e=k;g=d;i=a;break;case 2:e=a;g=d;i=b;break;case 3:e=a;g=k;i=d;break;case 4:e=b;g=a;i=d;break;case 5:e=d;g=a;i=k;break;case 6:case 0:e=d;g=b;i=a}}this.r=e;this.g=g;this.b=i;if(this.autoUpdate){this.updateHex();
+THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,d){var e,g,i,l,m,k;if(d==0)e=g=i=0;else{l=Math.floor(a*6);m=a*6-l;a=d*(1-b);k=d*(1-b*m);b=d*(1-b*(1-m));switch(l){case 1:e=k;g=d;i=a;break;case 2:e=a;g=d;i=b;break;case 3:e=a;g=k;i=d;break;case 4:e=b;g=a;i=d;break;case 5:e=d;g=a;i=k;break;case 6:case 0:e=d;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,71 +13,68 @@ this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,b,d,e){this.x=a||
 THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){d=e[a];d instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(d)))}g.sort(function(i,l){return i.distance-l.distance});return g},intersectObject:function(a){function b(H,r,Z,E){E=E.clone().subSelf(r);Z=Z.clone().subSelf(r);var L=H.clone().subSelf(r);H=E.dot(E);r=E.dot(Z);E=E.dot(L);var c=Z.dot(Z);Z=Z.dot(L);L=1/(H*c-r*r);c=(c*E-r*Z)*L;H=(H*Z-r*E)*L;return c>0&&H>0&&c+H<1}var d,e,g,i,l,n,k,o,s,w,
-u,x=a.geometry,F=x.vertices,I=[];d=0;for(e=x.faces.length;d<e;d++){g=x.faces[d];w=this.origin.clone();u=this.direction.clone();k=a.globalMatrix;k.extractRotationMatrix(a.matrixRotation);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.matrixRotation.multiplyVector3(g.normal.clone());s=u.dot(o);if(s<0){o=o.dot((new THREE.Vector3).sub(i,
-w))/s;w=w.addSelf(u.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};I.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};I.push(g)}}}return I}};
-THREE.Rectangle=function(){function a(){i=e-b;l=g-d}var b,d,e,g,i,l,n=!0;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return i};this.getHeight=function(){return l};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(k,o,s,w){n=!1;b=k;d=o;e=s;g=w;a()};this.addPoint=function(k,o){if(n){n=!1;b=k;d=o;e=k;g=o}else{b=b<k?b:k;d=d<o?d:o;e=e>k?e:k;g=g>o?g:o}a()};
-this.add3Points=function(k,o,s,w,u,x){if(n){n=!1;b=k<s?k<u?k:u:s<u?s:u;d=o<w?o<x?o:x:w<x?w:x;e=k>s?k>u?k:u:s>u?s:u;g=o>w?o>x?o:x:w>x?w:x}else{b=k<s?k<u?k<b?k:b:u<b?u:b:s<u?s<b?s:b:u<b?u:b;d=o<w?o<x?o<d?o:d:x<d?x:d:w<x?w<d?w:d:x<d?x:d;e=k>s?k>u?k>e?k:e:u>e?u:e:s>u?s>e?s:e:u>e?u: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();d=k.getTop();e=k.getRight();g=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();d=d<k.getTop()?d:k.getTop();e=e>k.getRight()?
-e:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;d-=k;e+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();d=d>k.getTop()?d: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(d,k.getTop())>=0};this.empty=function(){n=!0;g=e=d=b=0;a()};this.isEmpty=function(){return n};this.toString=function(){return"THREE.Rectangle ( left: "+
+THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){d=e[a];d instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(d)))}g.sort(function(i,l){return i.distance-l.distance});return g},intersectObject:function(a){function b(H,r,Z,E){E=E.clone().subSelf(r);Z=Z.clone().subSelf(r);var L=H.clone().subSelf(r);H=E.dot(E);r=E.dot(Z);E=E.dot(L);var c=Z.dot(Z);Z=Z.dot(L);L=1/(H*c-r*r);c=(c*E-r*Z)*L;H=(H*Z-r*E)*L;return c>0&&H>0&&c+H<1}var d,e,g,i,l,m,k,o,s,w,
+u,x=a.geometry,F=x.vertices,I=[];d=0;for(e=x.faces.length;d<e;d++){g=x.faces[d];w=this.origin.clone();u=this.direction.clone();k=a.globalMatrix;k.extractRotationMatrix(a.matrixRotation);i=k.multiplyVector3(F[g.a].position.clone());l=k.multiplyVector3(F[g.b].position.clone());m=k.multiplyVector3(F[g.c].position.clone());k=g instanceof THREE.Face4?k.multiplyVector3(F[g.d].position.clone()):null;o=a.matrixRotation.multiplyVector3(g.normal.clone());s=u.dot(o);if(s<0){o=o.dot((new THREE.Vector3).sub(i,
+w))/s;w=w.addSelf(u.multiplyScalar(o));if(g instanceof THREE.Face3){if(b(w,i,l,m)){g={distance:this.origin.distanceTo(w),point:w,face:g,object:a};I.push(g)}}else if(g instanceof THREE.Face4&&(b(w,i,l,k)||b(w,l,m,k))){g={distance:this.origin.distanceTo(w),point:w,face:g,object:a};I.push(g)}}}return I}};
+THREE.Rectangle=function(){function a(){i=e-b;l=g-d}var b,d,e,g,i,l,m=!0;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return i};this.getHeight=function(){return l};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(k,o,s,w){m=!1;b=k;d=o;e=s;g=w;a()};this.addPoint=function(k,o){if(m){m=!1;b=k;d=o;e=k;g=o}else{b=b<k?b:k;d=d<o?d:o;e=e>k?e:k;g=g>o?g:o}a()};
+this.add3Points=function(k,o,s,w,u,x){if(m){m=!1;b=k<s?k<u?k:u:s<u?s:u;d=o<w?o<x?o:x:w<x?w:x;e=k>s?k>u?k:u:s>u?s:u;g=o>w?o>x?o:x:w>x?w:x}else{b=k<s?k<u?k<b?k:b:u<b?u:b:s<u?s<b?s:b:u<b?u:b;d=o<w?o<x?o<d?o:d:x<d?x:d:w<x?w<d?w:d:x<d?x:d;e=k>s?k>u?k>e?k:e:u>e?u:e:s>u?s>e?s:e:u>e?u: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(m){m=!1;b=k.getLeft();d=k.getTop();e=k.getRight();g=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();d=d<k.getTop()?d:k.getTop();e=e>k.getRight()?
+e:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;d-=k;e+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();d=d>k.getTop()?d: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(d,k.getTop())>=0};this.empty=function(){m=!0;g=e=d=b=0;a()};this.isEmpty=function(){return m};this.toString=function(){return"THREE.Rectangle ( left: "+
 b+", right: "+e+", top: "+d+", 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,d,e,g,i,l,n,k,o,s,w,u,x,F,I){this.n11=a||1;this.n12=b||0;this.n13=d||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=u||0;this.n42=x||0;this.n43=F||0;this.n44=I||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,d,e,g,i,l,n,k,o,s,w,u,x,F,I){this.n11=a;this.n12=b;this.n13=d;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=u;this.n42=x;this.n43=F;this.n44=I;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
+THREE.Matrix4=function(a,b,d,e,g,i,l,m,k,o,s,w,u,x,F,I){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=g||0;this.n22=i||1;this.n23=l||0;this.n24=m||0;this.n31=k||0;this.n32=o||0;this.n33=s||1;this.n34=w||0;this.n41=u||0;this.n42=x||0;this.n43=F||0;this.n44=I||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,d,e,g,i,l,m,k,o,s,w,u,x,F,I){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=g;this.n22=i;this.n23=l;this.n24=m;this.n31=k;this.n32=o;this.n33=s;this.n34=w;this.n41=u;this.n42=x;this.n43=F;this.n44=I;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,d){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,i=THREE.Matrix4.__tmpVec3;i.sub(a,b).normalize();e.cross(d,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,d=a.y,e=a.z,g=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*g;return a},multiplyVector3OnlyZ:function(a){var b=a.x,d=a.y;a=a.z;return(this.n31*b+this.n32*d+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*d+this.n43*
 a+this.n44))},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*g;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*d+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 d=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,u=a.n33,x=a.n34,F=a.n41,I=a.n42,H=a.n43,r=a.n44,Z=b.n11,E=b.n12,L=b.n13,c=b.n14,ia=b.n21,T=b.n22,O=b.n23,ca=b.n24,S=b.n31,ba=b.n32,V=b.n33,D=b.n34,J=b.n41,la=b.n42,Q=b.n43,ja=b.n44;this.n11=d*Z+e*ia+g*S+i*J;this.n12=d*E+e*T+g*ba+i*la;this.n13=d*L+e*O+g*V+i*Q;this.n14=d*c+e*ca+g*D+i*ja;this.n21=l*Z+n*ia+k*S+o*J;this.n22=l*E+n*T+k*ba+o*la;
-this.n23=l*L+n*O+k*V+o*Q;this.n24=l*c+n*ca+k*D+o*ja;this.n31=s*Z+w*ia+u*S+x*J;this.n32=s*E+w*T+u*ba+x*la;this.n33=s*L+w*O+u*V+x*Q;this.n34=s*c+w*ca+u*D+x*ja;this.n41=F*Z+I*ia+H*S+r*J;this.n42=F*E+I*T+H*ba+r*la;this.n43=F*L+I*O+H*V+r*Q;this.n44=F*c+I*ca+H*D+r*ja;return this},multiplyToArray:function(a,b,d){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,u=a.n32,x=a.n33,F=a.n34,I=a.n41,H=a.n42,r=a.n43;a=a.n44;var Z=b.n11,E=b.n12,L=b.n13,c=b.n14,ia=b.n21,T=b.n22,O=b.n23,ca=
-b.n24,S=b.n31,ba=b.n32,V=b.n33,D=b.n34,J=b.n41,la=b.n42,Q=b.n43;b=b.n44;this.n11=e*Z+g*ia+i*S+l*J;this.n12=e*E+g*T+i*ba+l*la;this.n13=e*L+g*O+i*V+l*Q;this.n14=e*c+g*ca+i*D+l*b;this.n21=n*Z+k*ia+o*S+s*J;this.n22=n*E+k*T+o*ba+s*la;this.n23=n*L+k*O+o*V+s*Q;this.n24=n*c+k*ca+o*D+s*b;this.n31=w*Z+u*ia+x*S+F*J;this.n32=w*E+u*T+x*ba+F*la;this.n33=w*L+u*O+x*V+F*Q;this.n34=w*c+u*ca+x*D+F*b;this.n41=I*Z+H*ia+r*S+a*J;this.n42=I*E+H*T+r*ba+a*la;this.n43=I*L+H*O+r*V+a*Q;this.n44=I*c+H*ca+r*D+a*b;d[0]=this.n11;
-d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,d=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,u=this.n34,x=this.n41,F=this.n42,I=this.n43,H=this.n44,r=a.n11,Z=a.n21,E=a.n31,L=a.n41,c=a.n12,ia=a.n22,T=a.n32,O=a.n42,ca=
-a.n13,S=a.n23,ba=a.n33,V=a.n43,D=a.n14,J=a.n24,la=a.n34;a=a.n44;this.n11=b*r+d*Z+e*E+g*L;this.n12=b*c+d*ia+e*T+g*O;this.n13=b*ca+d*S+e*ba+g*V;this.n14=b*D+d*J+e*la+g*a;this.n21=i*r+l*Z+n*E+k*L;this.n22=i*c+l*ia+n*T+k*O;this.n23=i*ca+l*S+n*ba+k*V;this.n24=i*D+l*J+n*la+k*a;this.n31=o*r+s*Z+w*E+u*L;this.n32=o*c+s*ia+w*T+u*O;this.n33=o*ca+s*S+w*ba+u*V;this.n34=o*D+s*J+w*la+u*a;this.n41=x*r+F*Z+I*E+H*L;this.n42=x*c+F*ia+I*T+H*O;this.n43=x*ca+F*S+I*ba+H*V;this.n44=x*D+F*J+I*la+H*a;return this},multiplyScalar:function(a){this.n11*=
-a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,d=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,u=this.n41,x=this.n42,F=this.n43,I=this.n44;return e*l*o*u-d*n*o*u-e*i*s*u+b*n*s*u+d*i*w*u-b*l*w*u-e*l*k*x+d*n*k*x+e*g*s*x-a*n*s*x-d*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-d*i*k*I+b*l*k*I+d*g*o*I-a*l*o*I-b*g*s*I+a*i*s*I},transpose:function(){function a(b,d,e){var g=b[d];b[d]=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 d=a.n11,e=a.n12,g=a.n13,i=a.n14,l=a.n21,m=a.n22,k=a.n23,o=a.n24,s=a.n31,w=a.n32,u=a.n33,x=a.n34,F=a.n41,I=a.n42,H=a.n43,r=a.n44,Z=b.n11,E=b.n12,L=b.n13,c=b.n14,ia=b.n21,T=b.n22,O=b.n23,ca=b.n24,S=b.n31,ba=b.n32,V=b.n33,D=b.n34,J=b.n41,la=b.n42,Q=b.n43,ja=b.n44;this.n11=d*Z+e*ia+g*S+i*J;this.n12=d*E+e*T+g*ba+i*la;this.n13=d*L+e*O+g*V+i*Q;this.n14=d*c+e*ca+g*D+i*ja;this.n21=l*Z+m*ia+k*S+o*J;this.n22=l*E+m*T+k*ba+o*la;
+this.n23=l*L+m*O+k*V+o*Q;this.n24=l*c+m*ca+k*D+o*ja;this.n31=s*Z+w*ia+u*S+x*J;this.n32=s*E+w*T+u*ba+x*la;this.n33=s*L+w*O+u*V+x*Q;this.n34=s*c+w*ca+u*D+x*ja;this.n41=F*Z+I*ia+H*S+r*J;this.n42=F*E+I*T+H*ba+r*la;this.n43=F*L+I*O+H*V+r*Q;this.n44=F*c+I*ca+H*D+r*ja;return this},multiplyToArray:function(a,b,d){var e=a.n11,g=a.n12,i=a.n13,l=a.n14,m=a.n21,k=a.n22,o=a.n23,s=a.n24,w=a.n31,u=a.n32,x=a.n33,F=a.n34,I=a.n41,H=a.n42,r=a.n43;a=a.n44;var Z=b.n11,E=b.n12,L=b.n13,c=b.n14,ia=b.n21,T=b.n22,O=b.n23,ca=
+b.n24,S=b.n31,ba=b.n32,V=b.n33,D=b.n34,J=b.n41,la=b.n42,Q=b.n43;b=b.n44;this.n11=e*Z+g*ia+i*S+l*J;this.n12=e*E+g*T+i*ba+l*la;this.n13=e*L+g*O+i*V+l*Q;this.n14=e*c+g*ca+i*D+l*b;this.n21=m*Z+k*ia+o*S+s*J;this.n22=m*E+k*T+o*ba+s*la;this.n23=m*L+k*O+o*V+s*Q;this.n24=m*c+k*ca+o*D+s*b;this.n31=w*Z+u*ia+x*S+F*J;this.n32=w*E+u*T+x*ba+F*la;this.n33=w*L+u*O+x*V+F*Q;this.n34=w*c+u*ca+x*D+F*b;this.n41=I*Z+H*ia+r*S+a*J;this.n42=I*E+H*T+r*ba+a*la;this.n43=I*L+H*O+r*V+a*Q;this.n44=I*c+H*ca+r*D+a*b;d[0]=this.n11;
+d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,g=this.n14,i=this.n21,l=this.n22,m=this.n23,k=this.n24,o=this.n31,s=this.n32,w=this.n33,u=this.n34,x=this.n41,F=this.n42,I=this.n43,H=this.n44,r=a.n11,Z=a.n21,E=a.n31,L=a.n41,c=a.n12,ia=a.n22,T=a.n32,O=a.n42,ca=
+a.n13,S=a.n23,ba=a.n33,V=a.n43,D=a.n14,J=a.n24,la=a.n34;a=a.n44;this.n11=b*r+d*Z+e*E+g*L;this.n12=b*c+d*ia+e*T+g*O;this.n13=b*ca+d*S+e*ba+g*V;this.n14=b*D+d*J+e*la+g*a;this.n21=i*r+l*Z+m*E+k*L;this.n22=i*c+l*ia+m*T+k*O;this.n23=i*ca+l*S+m*ba+k*V;this.n24=i*D+l*J+m*la+k*a;this.n31=o*r+s*Z+w*E+u*L;this.n32=o*c+s*ia+w*T+u*O;this.n33=o*ca+s*S+w*ba+u*V;this.n34=o*D+s*J+w*la+u*a;this.n41=x*r+F*Z+I*E+H*L;this.n42=x*c+F*ia+I*T+H*O;this.n43=x*ca+F*S+I*ba+H*V;this.n44=x*D+F*J+I*la+H*a;return this},multiplyScalar:function(a){this.n11*=
+a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,d=this.n13,e=this.n14,g=this.n21,i=this.n22,l=this.n23,m=this.n24,k=this.n31,o=this.n32,s=this.n33,w=this.n34,u=this.n41,x=this.n42,F=this.n43,I=this.n44;return e*l*o*u-d*m*o*u-e*i*s*u+b*m*s*u+d*i*w*u-b*l*w*u-e*l*k*x+d*m*k*x+e*g*s*x-a*m*s*x-d*g*w*x+a*l*w*x+
+e*i*k*F-b*m*k*F-e*g*o*F+a*m*o*F+b*g*w*F-a*i*w*F-d*i*k*I+b*l*k*I+d*g*o*I-a*l*o*I-b*g*s*I+a*i*s*I},transpose:function(){function a(b,d,e){var g=b[d];b[d]=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,d){this.set(1,0,0,a,0,1,0,b,0,0,1,d,0,0,0,1);
-return this},setScale:function(a,b,d){this.set(a,0,0,0,0,b,0,0,0,0,d,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 d=Math.cos(b),e=Math.sin(b),g=1-d,i=a.x,l=a.y,n=a.z,k=g*
-i,o=g*l;this.set(k*i+d,k*l-e*n,k*n+e*l,0,k*l+e*n,o*l+d,o*n-e*i,0,k*n-e*l,o*n+e*i,g*n*n+d,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,d=a.y,e=a.z;a=Math.cos(d);d=Math.sin(d);var g=Math.cos(-e);e=Math.sin(-e);var i=Math.cos(b);b=Math.sin(b);var l=a*e,n=d*e;this.n11=a*g;this.n12=d*b-l*i;this.n13=l*b+d*i;this.n21=e;this.n22=g*i;this.n23=-g*b;this.n31=-d*g;this.n32=n*i+a*b;this.n33=-n*b+a*i},setRotationFromQuaternion:function(a){var b=
-a.x,d=a.y,e=a.z,g=a.w,i=b+b,l=d+d,n=e+e;a=b*i;var k=b*l;b*=n;var o=d*l;d*=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=d-i;this.n31=b-l;this.n32=d+i;this.n33=1-(a+o)},scale:function(a){var b=a.x,d=a.y;a=a.z;this.n11*=b;this.n12*=b;this.n13*=b;this.n21*=d;this.n22*=d;this.n23*=d;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,d){this.set(a,0,0,0,0,b,0,0,0,0,d,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 d=Math.cos(b),e=Math.sin(b),g=1-d,i=a.x,l=a.y,m=a.z,k=g*
+i,o=g*l;this.set(k*i+d,k*l-e*m,k*m+e*l,0,k*l+e*m,o*l+d,o*m-e*i,0,k*m-e*l,o*m+e*i,g*m*m+d,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,d=a.y,e=a.z;a=Math.cos(d);d=Math.sin(d);var g=Math.cos(-e);e=Math.sin(-e);var i=Math.cos(b);b=Math.sin(b);var l=a*e,m=d*e;this.n11=a*g;this.n12=d*b-l*i;this.n13=l*b+d*i;this.n21=e;this.n22=g*i;this.n23=-g*b;this.n31=-d*g;this.n32=m*i+a*b;this.n33=-m*b+a*i},setRotationFromQuaternion:function(a){var b=
+a.x,d=a.y,e=a.z,g=a.w,i=b+b,l=d+d,m=e+e;a=b*i;var k=b*l;b*=m;var o=d*l;d*=m;e*=m;i*=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=d-i;this.n31=b-l;this.n32=d+i;this.n33=1-(a+o)},scale:function(a){var b=a.x,d=a.y;a=a.z;this.n11*=b;this.n12*=b;this.n13*=b;this.n21*=d;this.n22*=d;this.n23*=d;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,d){var e=new THREE.Matrix4;e.setTranslation(a,b,d);return e};
 THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.setScale(a,b,d);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 d=new THREE.Matrix4;d.setRotAxis(a,b);return d};
-THREE.Matrix4.makeInvert=function(a,b){var d=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,u=a.n33,x=a.n34,F=a.n41,I=a.n42,H=a.n43,r=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=k*x*I-o*u*I+o*w*H-n*x*H-k*w*r+n*u*r;b.n12=i*u*I-g*x*I-i*w*H+e*x*H+g*w*r-e*u*r;b.n13=g*o*I-i*k*I+i*n*H-e*o*H-g*n*r+e*k*r;b.n14=i*k*w-g*o*w-i*n*u+e*o*u+g*n*x-e*k*x;b.n21=o*u*F-k*x*F-o*s*H+l*x*H+k*s*r-l*u*r;b.n22=g*x*F-i*u*F+i*s*H-d*x*H-g*s*r+d*u*r;b.n23=i*k*F-g*o*F-i*l*H+d*o*H+g*l*r-d*k*r;
-b.n24=g*o*s-i*k*s+i*l*u-d*o*u-g*l*x+d*k*x;b.n31=n*x*F-o*w*F+o*s*I-l*x*I-n*s*r+l*w*r;b.n32=i*w*F-e*x*F-i*s*I+d*x*I+e*s*r-d*w*r;b.n33=g*o*F-i*n*F+i*l*I-d*o*I-e*l*r+d*n*r;b.n34=i*n*s-e*o*s-i*l*w+d*o*w+e*l*x-d*n*x;b.n41=k*w*F-n*u*F-k*s*I+l*u*I+n*s*H-l*w*H;b.n42=e*u*F-g*w*F+g*s*I-d*u*I-e*s*H+d*w*H;b.n43=g*n*F-e*k*F-g*l*I+d*k*I+e*l*H-d*n*H;b.n44=e*k*s-g*n*s+g*l*w-d*k*w-e*l*u+d*n*u;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,d=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;d[0]=a*e;d[1]=a*g;d[2]=a*i;d[3]=a*l;d[4]=a*n;d[5]=a*k;d[6]=a*o;d[7]=a*s;d[8]=a*w;return b};
+THREE.Matrix4.makeInvert=function(a,b){var d=a.n11,e=a.n12,g=a.n13,i=a.n14,l=a.n21,m=a.n22,k=a.n23,o=a.n24,s=a.n31,w=a.n32,u=a.n33,x=a.n34,F=a.n41,I=a.n42,H=a.n43,r=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=k*x*I-o*u*I+o*w*H-m*x*H-k*w*r+m*u*r;b.n12=i*u*I-g*x*I-i*w*H+e*x*H+g*w*r-e*u*r;b.n13=g*o*I-i*k*I+i*m*H-e*o*H-g*m*r+e*k*r;b.n14=i*k*w-g*o*w-i*m*u+e*o*u+g*m*x-e*k*x;b.n21=o*u*F-k*x*F-o*s*H+l*x*H+k*s*r-l*u*r;b.n22=g*x*F-i*u*F+i*s*H-d*x*H-g*s*r+d*u*r;b.n23=i*k*F-g*o*F-i*l*H+d*o*H+g*l*r-d*k*r;
+b.n24=g*o*s-i*k*s+i*l*u-d*o*u-g*l*x+d*k*x;b.n31=m*x*F-o*w*F+o*s*I-l*x*I-m*s*r+l*w*r;b.n32=i*w*F-e*x*F-i*s*I+d*x*I+e*s*r-d*w*r;b.n33=g*o*F-i*m*F+i*l*I-d*o*I-e*l*r+d*m*r;b.n34=i*m*s-e*o*s-i*l*w+d*o*w+e*l*x-d*m*x;b.n41=k*w*F-m*u*F-k*s*I+l*u*I+m*s*H-l*w*H;b.n42=e*u*F-g*w*F+g*s*I-d*u*I-e*s*H+d*w*H;b.n43=g*m*F-e*k*F-g*l*I+d*k*I+e*l*H-d*m*H;b.n44=e*k*s-g*m*s+g*l*w-d*k*w-e*l*u+d*m*u;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,d=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,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,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;d[0]=a*e;d[1]=a*g;d[2]=a*i;d[3]=a*l;d[4]=a*m;d[5]=a*k;d[6]=a*o;d[7]=a*s;d[8]=a*w;return b};
 THREE.Matrix4.makeFrustum=function(a,b,d,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-d);l.n23=(e+d)/(e-d);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,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,d,e)};
-THREE.Matrix4.makeOrtho=function(a,b,d,e,g,i){var l,n,k,o;l=new THREE.Matrix4;n=b-a;k=d-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=-((d+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,d,e){this.x=a||0;this.y=b||0;this.z=d||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,d,e){var g=this.that;g.x=a;g.y=b;g.z=d;g.w=e;this.isDirty=!0;return this};THREE.Quaternion.prototype.setFromEuler=function(a){var b=0.5*Math.PI/360,d=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(d);d=Math.sin(d);var l=a*b,n=e*g,k=this.that;k.w=l*i-n*d;k.x=l*d+n*i;k.y=e*b*i+a*g*d;k.z=a*g*i-e*b*d;this.isDirty=!0;return this};
-THREE.Quaternion.prototype.calculateW=function(){var a=this.that,b=a.x,d=a.y,e=a.z;a.w=-Math.sqrt(Math.abs(1-b*b-d*d-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,d=a.y,e=a.z,g=a.w,i=Math.sqrt(b*b+d*d+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=d*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 d=this.that,e=a.x,g=a.y,i=a.z,l=d.x,n=d.y,k=d.z;d=d.w;var o=d*e+n*i-k*g,s=d*g+k*e-l*i,w=d*i+l*g-n*e;e=-l*e-n*g-k*i;b.x=o*d+e*-l+s*-k-w*-n;b.y=s*d+e*-n+w*-l-o*-k;b.z=w*d+e*-k+o*-n-s*-l;return b};THREE.Quaternion.prototype.toMatrix3=function(){};THREE.Quaternion.prototype.toMatrix4=function(){};
+THREE.Matrix4.makeOrtho=function(a,b,d,e,g,i){var l,m,k,o;l=new THREE.Matrix4;m=b-a;k=d-e;o=i-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=-((d+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,d,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e!==undefined?e:1};
+THREE.Quaternion.prototype.set=function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this};THREE.Quaternion.prototype.setFromEuler=function(a){var b=0.5*Math.PI/360,d=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(d);d=Math.sin(d);var l=a*b,m=e*g;this.w=l*i-m*d;this.x=l*d+m*i;this.y=e*b*i+a*g*d;this.z=a*g*i-e*b*d;return this};
+THREE.Quaternion.prototype.calculateW=function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this};THREE.Quaternion.prototype.inverse=function(){this.x*=-1;this.y*=-1;this.z*=-1;return this};THREE.Quaternion.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)};
+THREE.Quaternion.prototype.normalize=function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this};THREE.Quaternion.prototype.multiplySelf=function(a){var b=this.x,d=this.y,e=this.z,g=this.w,i=a.x,l=a.y,m=a.z;a=a.w;this.x=b*a+g*i+d*m-e*l;this.y=d*a+g*l+e*i-b*m;this.z=e*a+g*m+b*l-d*i;this.w=g*a-b*i-d*l-e*m;return this};
+THREE.Quaternion.prototype.multiplyVector3=function(a,b){b||(b=a);var d=a.x,e=a.y,g=a.z,i=this.x,l=this.y,m=this.z,k=this.w,o=k*d+l*g-m*e,s=k*e+m*d-i*g,w=k*g+i*e-l*d;d=-i*d-l*e-m*g;b.x=o*k+d*-i+s*-m-w*-l;b.y=s*k+d*-l+w*-i-o*-m;b.z=w*k+d*-m+o*-l-s*-i;return b};THREE.Quaternion.prototype.toMatrix3=function(){};THREE.Quaternion.prototype.toMatrix4=function(){};
 THREE.Quaternion.slerp=function(a,b,d,e){var g=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(g)>=1){d.w=a.w;d.x=a.x;d.y=a.y;d.z=a.z;return d}var i=Math.acos(g),l=Math.sqrt(1-g*g);if(Math.abs(l)<0.0010){d.w=0.5*(a.w+b.w);d.x=0.5*(a.x+b.x);d.y=0.5*(a.y+b.y);d.z=0.5*(a.z+b.z);return d}g=Math.sin((1-e)*i)/l;e=Math.sin(e*i)/l;d.w=a.w*g+b.w*e;d.x=a.x*g+b.x*e;d.y=a.y*g+b.y*e;d.z=a.z*g+b.z*e;return d};
 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,d,e,g){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.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,d,e,g,i){this.a=a;this.b=b;this.c=d;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,d;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
-d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,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(d=i.normal.length;b<d;b++)n.addSelf(i.vertexNormals[b]);n.divideScalar(3)}else{b=this.vertices[i.a];d=this.vertices[i.b];l=this.vertices[i.c];n.sub(l.position,
-d.position);k.sub(b.position,d.position);n.crossSelf(k)}n.isZero()||n.normalize();i.normal.copy(n)}},computeVertexNormals:function(){var a,b,d,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++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
+d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,g,i,l,m=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){m.set(0,0,0);b=0;for(d=i.normal.length;b<d;b++)m.addSelf(i.vertexNormals[b]);m.divideScalar(3)}else{b=this.vertices[i.a];d=this.vertices[i.b];l=this.vertices[i.c];m.sub(l.position,
+d.position);k.sub(b.position,d.position);m.crossSelf(k)}m.isZero()||m.normalize();i.normal.copy(m)}},computeVertexNormals:function(){var a,b,d,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++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
 new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{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++){d=this.faces[a];if(d instanceof THREE.Face3){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal);e[d.d].addSelf(d.normal)}}a=0;for(b=this.vertices.length;a<b;a++)e[a].normalize();a=0;for(b=this.faces.length;a<
-b;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(D,J,la,Q,ja,ea,R){i=D.vertices[J].position;l=D.vertices[la].position;n=D.vertices[Q].position;k=g[ja];o=g[ea];s=g[R];w=l.x-i.x;u=n.x-i.x;x=l.y-i.y;F=n.y-
-i.y;I=l.z-i.z;H=n.z-i.z;r=o.u-k.u;Z=s.u-k.u;E=o.v-k.v;L=s.v-k.v;c=1/(r*L-Z*E);O.set((L*w-E*u)*c,(L*x-E*F)*c,(L*I-E*H)*c);ca.set((r*u-Z*w)*c,(r*F-Z*x)*c,(r*H-Z*I)*c);ia[J].addSelf(O);ia[la].addSelf(O);ia[Q].addSelf(O);T[J].addSelf(ca);T[la].addSelf(ca);T[Q].addSelf(ca)}var b,d,e,g,i,l,n,k,o,s,w,u,x,F,I,H,r,Z,E,L,c,ia=[],T=[],O=new THREE.Vector3,ca=new THREE.Vector3,S=new THREE.Vector3,ba=new THREE.Vector3,V=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++){ia[b]=new THREE.Vector3;T[b]=new THREE.Vector3}b=
+b;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(D,J,la,Q,ja,ea,R){i=D.vertices[J].position;l=D.vertices[la].position;m=D.vertices[Q].position;k=g[ja];o=g[ea];s=g[R];w=l.x-i.x;u=m.x-i.x;x=l.y-i.y;F=m.y-
+i.y;I=l.z-i.z;H=m.z-i.z;r=o.u-k.u;Z=s.u-k.u;E=o.v-k.v;L=s.v-k.v;c=1/(r*L-Z*E);O.set((L*w-E*u)*c,(L*x-E*F)*c,(L*I-E*H)*c);ca.set((r*u-Z*w)*c,(r*F-Z*x)*c,(r*H-Z*I)*c);ia[J].addSelf(O);ia[la].addSelf(O);ia[Q].addSelf(O);T[J].addSelf(ca);T[la].addSelf(ca);T[Q].addSelf(ca)}var b,d,e,g,i,l,m,k,o,s,w,u,x,F,I,H,r,Z,E,L,c,ia=[],T=[],O=new THREE.Vector3,ca=new THREE.Vector3,S=new THREE.Vector3,ba=new THREE.Vector3,V=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++){ia[b]=new THREE.Vector3;T[b]=new THREE.Vector3}b=
 0;for(d=this.faces.length;b<d;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(d=this.vertices.length;b<d;b++){V.copy(this.vertices[b].normal);e=ia[b];S.copy(e);S.subSelf(V.multiplyScalar(V.dot(e))).normalize();ba.cross(this.vertices[b].normal,e);e=ba.dot(T[b]);e=e<0?-1:1;this.vertices[b].tangent.set(S.x,S.y,S.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,d=this.vertices.length;b<d;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,d=this.vertices.length;b<d;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(s){var w=[];b=0;for(d=s.length;b<d;b++)s[b]==undefined?w.push("undefined"):w.push(s[b].id);return w.join("_")}var b,d,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.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,d=this.vertices.length;b<d;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(s){var w=[];b=0;for(d=s.length;b<d;b++)s[b]==undefined?w.push("undefined"):w.push(s[b].id);return w.join("_")}var b,d,e,g,i,l,m,k,o={};e=0;for(g=this.faces.length;e<g;e++){i=this.faces[e];
+l=i.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});i=i instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+i>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+=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.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrixRotation=new THREE.Matrix4;this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale=
 1;this.visible=!0};THREE.Object3D.prototype.update=function(a,b,d){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;b=!0}var e=this.children.length;for(a=0;a<e;a++)this.children[a].update(this.globalMatrix,b,d)}};
-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.updateMatrix=function(){this.localMatrix.setPosition(this.position);this.useQuaternion?this.localMatrix.setRotationFromQuaternion(this.quaternion):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.matrixAutoUpdate=!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,d){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;
 THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,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,d){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;b=!0}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,d)}};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=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,d){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.skinMatrix.multiply(a,this.localMatrix):this.skinMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!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,d):a.update(this.globalMatrix,!0,d)}}else for(e=0;e<
 g;e++)this.children[e].update(this.skinMatrix,b,d)};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 d,e,g,i,l,n;if(this.geometry.bones!==undefined){for(d=0;d<this.geometry.bones.length;d++){g=this.geometry.bones[d];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(d=0;d<this.bones.length;d++){g=this.geometry.bones[d];e=this.bones[d];
+THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var d,e,g,i,l,m;if(this.geometry.bones!==undefined){for(d=0;d<this.geometry.bones.length;d++){g=this.geometry.bones[d];i=g.pos;l=g.rotq;m=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]);m!==undefined?e.scale.set(m[0],m[1],m[2]):e.scale.set(1,1,1)}for(d=0;d<this.bones.length;d++){g=this.geometry.bones[d];e=this.bones[d];
 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,d){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!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,d):a.update(this.globalMatrix,b,d)}}};
 THREE.SkinnedMesh.prototype.addBone=function(a){a===undefined&&(a=new THREE.Bone(this));this.bones.push(a);return a};
@@ -89,16 +86,16 @@ THREE.Quaternion)){var i=d.hierarchy[e].keys[g].rot;d.hierarchy[e].keys[g].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 d=0;d<this.root.bones.length;d++)this.hierarchy.push(this.root.bones[d])};
 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].matrixAutoUpdate=!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,d,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.matrixAutoUpdate=!1;i.matrixNeedsUpdate=!1;i.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,s*16)}else for(var u=0;u<3;u++){d=a[u];e=i.prevKey[d];g=i.nextKey[d];if(g.time<o){if(k<o)if(this.loop){e=this.data.hierarchy[s].keys[0];g=this.getNextKeyWith(d,s,1)}else{this.stop();return}else{do{e=g;g=this.getNextKeyWith(d,s,g.index+1)}while(g.time<k)}i.prevKey[d]=e;i.nextKey[d]=g}i.matrixAutoUpdate=!0;i.matrixNeedsUpdate=!0;b=(k-e.time)/(g.time-e.time);e=e[d];g=
-g[d];if(d==="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{d=d==="pos"?i.position:i.scale;d.x=e[0]+(g[0]-e[0])*b;d.y=e[1]+(g[1]-e[1])*b;d.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.update=function(){if(this.isPlaying){var a=["pos","rot","scl"],b,d,e,g,i,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 s=0,w=this.hierarchy.length;s<w;s++){i=this.hierarchy[s];if(m[s][l]!==
+undefined){i.skinMatrix=m[s][l];i.matrixAutoUpdate=!1;i.matrixNeedsUpdate=!1;i.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,s*16)}else for(var u=0;u<3;u++){d=a[u];e=i.prevKey[d];g=i.nextKey[d];if(g.time<o){if(k<o)if(this.loop){e=this.data.hierarchy[s].keys[0];g=this.getNextKeyWith(d,s,1)}else{this.stop();return}else{do{e=g;g=this.getNextKeyWith(d,s,g.index+1)}while(g.time<k)}i.prevKey[d]=e;i.nextKey[d]=g}i.matrixAutoUpdate=!0;i.matrixNeedsUpdate=!0;b=(k-e.time)/(g.time-e.time);e=e[d];g=
+g[d];if(d==="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{d=d==="pos"?i.position:i.scale;d.x=e[0]+(g[0]-e[0])*b;d.y=e[1]+(g[1]-e[1])*b;d.z=e[2]+(g[2]-e[2])*b}}}if(m[0][l]===undefined){this.hierarchy[0].update(undefined,!0);for(s=0;s<this.hierarchy.length;s++)m[s][l]=this.hierarchy[s].skinMatrix.clone()}}};THREE.Animation.prototype.updateObject=function(){};
 THREE.Animation.prototype.getNextKeyWith=function(a,b,d){for(var e=this.data.hierarchy[b].keys;d<e.length;d++)if(e[d][a]!==undefined)return e[d];return this.data.hierarchy[b].keys[0]};
 THREE.Camera=function(a,b,d,e,g,i){THREE.Object3D.call(this);this.FOV=a||50;this.aspect=b||1;this.zNear=d||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,d){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.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!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,d)};
-THREE.Camera.prototype.frustumContains=function(a){var b=a.globalMatrix.n14,d=a.globalMatrix.n24,e=a.globalMatrix.n34,g=this.inverseMatrix,i=a.boundRadius*a.boundRadiusScale,l=g.n31*b+g.n32*d+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*d+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*d+g.n23*e+g.n24)*n.n22*k*this.screenCenterY;
+THREE.Camera.prototype.frustumContains=function(a){var b=a.globalMatrix.n14,d=a.globalMatrix.n24,e=a.globalMatrix.n34,g=this.inverseMatrix,i=a.boundRadius*a.boundRadiusScale,l=g.n31*b+g.n32*d+g.n33*e+g.n34;if(l-i>-this.zNear)return!1;if(l+i<-this.zFar)return!1;l-=i;var m=this.projectionMatrix,k=1/(m.n43*l),o=k*this.screenCenterX,s=(g.n11*b+g.n12*d+g.n13*e+g.n14)*m.n11*o;i=m.n11*i*o;if(s+i<-this.screenCenterX)return!1;if(s-i>this.screenCenterX)return!1;b=(g.n21*b+g.n22*d+g.n23*e+g.n24)*m.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.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};
@@ -142,94 +139,94 @@ THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=f
 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,d){this.color=new THREE.Color(a);this.near=b||1;this.far=d||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
-THREE.Projector=function(){function a(T,O){return O.z-T.z}function b(T,O){var ca=0,S=1,ba=T.z+T.w,V=O.z+O.w,D=-T.z+T.w,J=-O.z+O.w;if(ba>=0&&V>=0&&D>=0&&J>=0)return!0;else if(ba<0&&V<0||D<0&&J<0)return!1;else{if(ba<0)ca=Math.max(ca,ba/(ba-V));else V<0&&(S=Math.min(S,ba/(ba-V)));if(D<0)ca=Math.max(ca,D/(D-J));else J<0&&(S=Math.min(S,D/(D-J)));if(S<ca)return!1;else{T.lerpSelf(O,ca);O.lerpSelf(T,1-S);return!0}}}var d,e,g=[],i,l,n,k=[],o,s,w=[],u,x,F=[],I=new THREE.Vector4,H=new THREE.Vector4,r=new THREE.Matrix4,
+THREE.Projector=function(){function a(T,O){return O.z-T.z}function b(T,O){var ca=0,S=1,ba=T.z+T.w,V=O.z+O.w,D=-T.z+T.w,J=-O.z+O.w;if(ba>=0&&V>=0&&D>=0&&J>=0)return!0;else if(ba<0&&V<0||D<0&&J<0)return!1;else{if(ba<0)ca=Math.max(ca,ba/(ba-V));else V<0&&(S=Math.min(S,ba/(ba-V)));if(D<0)ca=Math.max(ca,D/(D-J));else J<0&&(S=Math.min(S,D/(D-J)));if(S<ca)return!1;else{T.lerpSelf(O,ca);O.lerpSelf(T,1-S);return!0}}}var d,e,g=[],i,l,m,k=[],o,s,w=[],u,x,F=[],I=new THREE.Vector4,H=new THREE.Vector4,r=new THREE.Matrix4,
 Z=new THREE.Matrix4,E=[],L=new THREE.Vector4,c=new THREE.Vector4,ia;this.projectObjects=function(T,O,ca){O=[];var S,ba,V;e=0;ba=T.objects;T=0;for(S=ba.length;T<S;T++){V=ba[T];var D;if(!(D=!V.visible))if(D=V instanceof THREE.Mesh){a:{D=void 0;for(var J=V.globalMatrix,la=-V.geometry.boundingSphere.radius*Math.max(V.scale.x,Math.max(V.scale.y,V.scale.z)),Q=0;Q<6;Q++){D=E[Q].x*J.n14+E[Q].y*J.n24+E[Q].z*J.n34+E[Q].w;if(D<=la){D=!1;break a}}D=!0}D=!D}if(!D){d=g[e]=g[e]||new THREE.RenderableObject;I.copy(V.position);
-r.multiplyVector3(I);d.object=V;d.z=I.z;O.push(d);e++}}ca&&O.sort(a);return O};this.projectScene=function(T,O,ca){var S=[],ba=O.zNear,V=O.zFar,D,J,la,Q,ja,ea,R,ra,wa,f,m,p,j,h,q,t;n=s=x=0;O.matrixAutoUpdate&&O.update();r.multiply(O.projectionMatrix,O.globalMatrix);E[0]=new THREE.Vector4(r.n41-r.n11,r.n42-r.n12,r.n43-r.n13,r.n44-r.n14);E[1]=new THREE.Vector4(r.n41+r.n11,r.n42+r.n12,r.n43+r.n13,r.n44+r.n14);E[2]=new THREE.Vector4(r.n41+r.n21,r.n42+r.n22,r.n43+r.n23,r.n44+r.n24);E[3]=new THREE.Vector4(r.n41-
-r.n21,r.n42-r.n22,r.n43-r.n23,r.n44-r.n24);E[4]=new THREE.Vector4(r.n41-r.n31,r.n42-r.n32,r.n43-r.n33,r.n44-r.n34);E[5]=new THREE.Vector4(r.n41+r.n31,r.n42+r.n32,r.n43+r.n33,r.n44+r.n34);D=0;for(ea=E.length;D<ea;D++){R=E[D];R.divideScalar(Math.sqrt(R.x*R.x+R.y*R.y+R.z*R.z))}T.update(undefined,!1,O);ea=this.projectObjects(T,O,!0);T=0;for(D=ea.length;T<D;T++){R=ea[T].object;if(R.visible){R.matrixAutoUpdate&&R.updateMatrix();ra=R.globalMatrix;ra.extractRotationMatrix(R.matrixRotation);m=R.matrixRotation;
+r.multiplyVector3(I);d.object=V;d.z=I.z;O.push(d);e++}}ca&&O.sort(a);return O};this.projectScene=function(T,O,ca){var S=[],ba=O.zNear,V=O.zFar,D,J,la,Q,ja,ea,R,ra,wa,f,n,p,j,h,q,t;m=s=x=0;O.matrixAutoUpdate&&O.update();r.multiply(O.projectionMatrix,O.globalMatrix);E[0]=new THREE.Vector4(r.n41-r.n11,r.n42-r.n12,r.n43-r.n13,r.n44-r.n14);E[1]=new THREE.Vector4(r.n41+r.n11,r.n42+r.n12,r.n43+r.n13,r.n44+r.n14);E[2]=new THREE.Vector4(r.n41+r.n21,r.n42+r.n22,r.n43+r.n23,r.n44+r.n24);E[3]=new THREE.Vector4(r.n41-
+r.n21,r.n42-r.n22,r.n43-r.n23,r.n44-r.n24);E[4]=new THREE.Vector4(r.n41-r.n31,r.n42-r.n32,r.n43-r.n33,r.n44-r.n34);E[5]=new THREE.Vector4(r.n41+r.n31,r.n42+r.n32,r.n43+r.n33,r.n44+r.n34);D=0;for(ea=E.length;D<ea;D++){R=E[D];R.divideScalar(Math.sqrt(R.x*R.x+R.y*R.y+R.z*R.z))}T.update(undefined,!1,O);ea=this.projectObjects(T,O,!0);T=0;for(D=ea.length;T<D;T++){R=ea[T].object;if(R.visible){R.matrixAutoUpdate&&R.updateMatrix();ra=R.globalMatrix;ra.extractRotationMatrix(R.matrixRotation);n=R.matrixRotation;
 wa=R.materials;f=R.overdraw;if(R instanceof THREE.Mesh){p=R.geometry;j=p.vertices;J=0;for(la=j.length;J<la;J++){h=j[J];h.positionWorld.copy(h.position);ra.multiplyVector3(h.positionWorld);Q=h.positionScreen;Q.copy(h.positionWorld);r.multiplyVector4(Q);Q.x/=Q.w;Q.y/=Q.w;h.__visible=Q.z>ba&&Q.z<V}p=p.faces;J=0;for(la=p.length;J<la;J++){h=p[J];if(h instanceof THREE.Face3){Q=j[h.a];ja=j[h.b];q=j[h.c];if(Q.__visible&&ja.__visible&&q.__visible&&(R.doubleSided||R.flipSided!=(q.positionScreen.x-Q.positionScreen.x)*
-(ja.positionScreen.y-Q.positionScreen.y)-(q.positionScreen.y-Q.positionScreen.y)*(ja.positionScreen.x-Q.positionScreen.x)<0)){i=k[n]=k[n]||new THREE.RenderableFace3;i.v1.positionWorld.copy(Q.positionWorld);i.v2.positionWorld.copy(ja.positionWorld);i.v3.positionWorld.copy(q.positionWorld);i.v1.positionScreen.copy(Q.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;ia=i.vertexNormalsWorld;Q=0;for(ja=q.length;Q<ja;Q++){t=ia[Q]=ia[Q]||new THREE.Vector3;t.copy(q[Q]);m.multiplyVector3(t)}i.z=i.centroidScreen.z;i.meshMaterials=wa;i.faceMaterials=h.materials;i.overdraw=f;if(R.geometry.uvs[J]){i.uvs[0]=R.geometry.uvs[J][0];i.uvs[1]=R.geometry.uvs[J][1];i.uvs[2]=R.geometry.uvs[J][2]}S.push(i);n++}}else if(h instanceof THREE.Face4){Q=j[h.a];
-ja=j[h.b];q=j[h.c];t=j[h.d];if(Q.__visible&&ja.__visible&&q.__visible&&t.__visible&&(R.doubleSided||R.flipSided!=((t.positionScreen.x-Q.positionScreen.x)*(ja.positionScreen.y-Q.positionScreen.y)-(t.positionScreen.y-Q.positionScreen.y)*(ja.positionScreen.x-Q.positionScreen.x)<0||(ja.positionScreen.x-q.positionScreen.x)*(t.positionScreen.y-q.positionScreen.y)-(ja.positionScreen.y-q.positionScreen.y)*(t.positionScreen.x-q.positionScreen.x)<0))){i=k[n]=k[n]||new THREE.RenderableFace3;i.v1.positionWorld.copy(Q.positionWorld);
-i.v2.positionWorld.copy(ja.positionWorld);i.v3.positionWorld.copy(t.positionWorld);i.v1.positionScreen.copy(Q.positionScreen);i.v2.positionScreen.copy(ja.positionScreen);i.v3.positionScreen.copy(t.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(R.geometry.uvs[J]){i.uvs[0]=R.geometry.uvs[J][0];i.uvs[1]=R.geometry.uvs[J][1];i.uvs[2]=R.geometry.uvs[J][3]}S.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(t.positionWorld);l.v1.positionScreen.copy(ja.positionScreen);l.v2.positionScreen.copy(q.positionScreen);l.v3.positionScreen.copy(t.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(R.geometry.uvs[J]){l.uvs[0]=R.geometry.uvs[J][1];l.uvs[1]=R.geometry.uvs[J][2];l.uvs[2]=R.geometry.uvs[J][3]}S.push(l);n++}}}}else if(R instanceof THREE.Line){Z.multiply(r,ra);j=R.geometry.vertices;h=j[0];h.positionScreen.copy(h.position);Z.multiplyVector4(h.positionScreen);J=1;for(la=j.length;J<la;J++){Q=j[J];Q.positionScreen.copy(Q.position);Z.multiplyVector4(Q.positionScreen);ja=j[J-1];L.copy(Q.positionScreen);
+(ja.positionScreen.y-Q.positionScreen.y)-(q.positionScreen.y-Q.positionScreen.y)*(ja.positionScreen.x-Q.positionScreen.x)<0)){i=k[m]=k[m]||new THREE.RenderableFace3;i.v1.positionWorld.copy(Q.positionWorld);i.v2.positionWorld.copy(ja.positionWorld);i.v3.positionWorld.copy(q.positionWorld);i.v1.positionScreen.copy(Q.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;ia=i.vertexNormalsWorld;Q=0;for(ja=q.length;Q<ja;Q++){t=ia[Q]=ia[Q]||new THREE.Vector3;t.copy(q[Q]);n.multiplyVector3(t)}i.z=i.centroidScreen.z;i.meshMaterials=wa;i.faceMaterials=h.materials;i.overdraw=f;if(R.geometry.uvs[J]){i.uvs[0]=R.geometry.uvs[J][0];i.uvs[1]=R.geometry.uvs[J][1];i.uvs[2]=R.geometry.uvs[J][2]}S.push(i);m++}}else if(h instanceof THREE.Face4){Q=j[h.a];
+ja=j[h.b];q=j[h.c];t=j[h.d];if(Q.__visible&&ja.__visible&&q.__visible&&t.__visible&&(R.doubleSided||R.flipSided!=((t.positionScreen.x-Q.positionScreen.x)*(ja.positionScreen.y-Q.positionScreen.y)-(t.positionScreen.y-Q.positionScreen.y)*(ja.positionScreen.x-Q.positionScreen.x)<0||(ja.positionScreen.x-q.positionScreen.x)*(t.positionScreen.y-q.positionScreen.y)-(ja.positionScreen.y-q.positionScreen.y)*(t.positionScreen.x-q.positionScreen.x)<0))){i=k[m]=k[m]||new THREE.RenderableFace3;i.v1.positionWorld.copy(Q.positionWorld);
+i.v2.positionWorld.copy(ja.positionWorld);i.v3.positionWorld.copy(t.positionWorld);i.v1.positionScreen.copy(Q.positionScreen);i.v2.positionScreen.copy(ja.positionScreen);i.v3.positionScreen.copy(t.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(R.geometry.uvs[J]){i.uvs[0]=R.geometry.uvs[J][0];i.uvs[1]=R.geometry.uvs[J][1];i.uvs[2]=R.geometry.uvs[J][3]}S.push(i);m++;l=k[m]=k[m]||new THREE.RenderableFace3;l.v1.positionWorld.copy(ja.positionWorld);l.v2.positionWorld.copy(q.positionWorld);l.v3.positionWorld.copy(t.positionWorld);l.v1.positionScreen.copy(ja.positionScreen);l.v2.positionScreen.copy(q.positionScreen);l.v3.positionScreen.copy(t.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(R.geometry.uvs[J]){l.uvs[0]=R.geometry.uvs[J][1];l.uvs[1]=R.geometry.uvs[J][2];l.uvs[2]=R.geometry.uvs[J][3]}S.push(l);m++}}}}else if(R instanceof THREE.Line){Z.multiply(r,ra);j=R.geometry.vertices;h=j[0];h.positionScreen.copy(h.position);Z.multiplyVector4(h.positionScreen);J=1;for(la=j.length;J<la;J++){Q=j[J];Q.positionScreen.copy(Q.position);Z.multiplyVector4(Q.positionScreen);ja=j[J-1];L.copy(Q.positionScreen);
 c.copy(ja.positionScreen);if(b(L,c)){L.multiplyScalar(1/L.w);c.multiplyScalar(1/c.w);o=w[s]=w[s]||new THREE.RenderableLine;o.v1.positionScreen.copy(L);o.v2.positionScreen.copy(c);o.z=Math.max(L.z,c.z);o.materials=R.materials;S.push(o);s++}}}else if(R instanceof THREE.Particle){H.set(R.position.x,R.position.y,R.position.z,1);r.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){u=F[x]=F[x]||new THREE.RenderableParticle;u.x=H.x/H.w;u.y=H.y/H.w;u.z=H.z;u.rotation=R.rotation.z;u.scale.x=R.scale.x*Math.abs(u.x-
 (H.x+O.projectionMatrix.n11)/(H.w+O.projectionMatrix.n14));u.scale.y=R.scale.y*Math.abs(u.y-(H.y+O.projectionMatrix.n22)/(H.w+O.projectionMatrix.n24));u.materials=R.materials;S.push(u);x++}}}}ca&&S.sort(a);return S};this.unprojectVector=function(T,O){var ca=THREE.Matrix4.makeInvert(O.globalMatrix);ca.multiplySelf(THREE.Matrix4.makeInvert(O.projectionMatrix));ca.multiplyVector3(T);return T}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,g,i;this.domElement=document.createElement("div");this.setSize=function(l,n){d=l;e=n;g=d/2;i=e/2};this.render=function(l,n){var k,o,s,w,u,x,F,I;a=b.projectScene(l,n);k=0;for(o=a.length;k<o;k++){u=a[k];if(u instanceof THREE.RenderableParticle){F=u.x*g+g;I=u.y*i+i;s=0;for(w=u.material.length;s<w;s++){x=u.material[s];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=F+"px";x.style.top=I+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(na){if(u!=na)o.globalAlpha=u=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 d=null,e=new THREE.Projector,g=document.createElement("canvas"),i,l,n,k,o=g.getContext("2d"),s=new THREE.Color(0),w=0,u=1,x=0,F=null,I=null,H=1,r,Z,E,L,c,ia,T,O,ca,S=new THREE.Color,
-ba=new THREE.Color,V=new THREE.Color,D=new THREE.Color,J=new THREE.Color,la,Q,ja,ea,R,ra,wa,f,m,p=new THREE.Rectangle,j=new THREE.Rectangle,h=new THREE.Rectangle,q=!1,t=new THREE.Color,A=new THREE.Color,W=new THREE.Color,G=new THREE.Color,M=Math.PI*2,C=new THREE.Vector3,aa,da,ua,ka,fa,ga,ha=16;aa=document.createElement("canvas");aa.width=aa.height=2;da=aa.getContext("2d");da.fillStyle="rgba(0,0,0,1)";da.fillRect(0,0,2,2);ua=da.getImageData(0,0,2,2);ka=ua.data;fa=document.createElement("canvas");fa.width=
-fa.height=ha;ga=fa.getContext("2d");ga.translate(-ha/2,-ha/2);ga.scale(ha,ha);ha--;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);u=1;x=0;I=F=null;H=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,B,U=z.lights;A.setRGB(0,0,0);W.setRGB(0,0,0);G.setRGB(0,0,0);z=0;for(X=U.length;z<X;z++){Y=U[z];B=Y.color;if(Y instanceof
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,g,i;this.domElement=document.createElement("div");this.setSize=function(l,m){d=l;e=m;g=d/2;i=e/2};this.render=function(l,m){var k,o,s,w,u,x,F,I;a=b.projectScene(l,m);k=0;for(o=a.length;k<o;k++){u=a[k];if(u instanceof THREE.RenderableParticle){F=u.x*g+g;I=u.y*i+i;s=0;for(w=u.material.length;s<w;s++){x=u.material[s];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=F+"px";x.style.top=I+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(na){if(u!=na)o.globalAlpha=u=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 d=null,e=new THREE.Projector,g=document.createElement("canvas"),i,l,m,k,o=g.getContext("2d"),s=new THREE.Color(0),w=0,u=1,x=0,F=null,I=null,H=1,r,Z,E,L,c,ia,T,O,ca,S=new THREE.Color,
+ba=new THREE.Color,V=new THREE.Color,D=new THREE.Color,J=new THREE.Color,la,Q,ja,ea,R,ra,wa,f,n,p=new THREE.Rectangle,j=new THREE.Rectangle,h=new THREE.Rectangle,q=!1,t=new THREE.Color,A=new THREE.Color,W=new THREE.Color,G=new THREE.Color,M=Math.PI*2,C=new THREE.Vector3,aa,da,ua,ka,fa,ga,ha=16;aa=document.createElement("canvas");aa.width=aa.height=2;da=aa.getContext("2d");da.fillStyle="rgba(0,0,0,1)";da.fillRect(0,0,2,2);ua=da.getImageData(0,0,2,2);ka=ua.data;fa=document.createElement("canvas");fa.width=
+fa.height=ha;ga=fa.getContext("2d");ga.translate(-ha/2,-ha/2);ga.scale(ha,ha);ha--;this.domElement=g;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(na,y){i=na;l=y;m=i/2;k=l/2;g.width=i;g.height=l;p.set(-m,-k,m,k);u=1;x=0;I=F=null;H=1};this.setClearColor=function(na,y){s=na;w=y;j.set(-m,-k,m,k);o.setTransform(1,0,0,-1,m,k);this.clear()};this.setClearColorHex=function(na,y){s.setHex(na);w=y;j.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(!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,B,U=z.lights;A.setRGB(0,0,0);W.setRGB(0,0,0);G.setRGB(0,0,0);z=0;for(X=U.length;z<X;z++){Y=U[z];B=Y.color;if(Y instanceof
 THREE.AmbientLight){A.r+=B.r;A.g+=B.g;A.b+=B.b}else if(Y instanceof THREE.DirectionalLight){W.r+=B.r;W.g+=B.g;W.b+=B.b}else if(Y instanceof THREE.PointLight){G.r+=B.r;G.g+=B.g;G.b+=B.b}}}function za(z,X,Y,B){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){B.r+=xa.r*ma;B.g+=xa.g*ma;B.b+=xa.b*ma}}else if(ma instanceof THREE.PointLight){C.sub(ma.position,X);C.normalize();ma=Y.dot(C)*
-Da;if(ma>0){B.r+=xa.r*ma;B.g+=xa.g*ma;B.b+=xa.b*ma}}}}function Ga(z,X,Y){if(Y.opacity!=0){a(Y.opacity);b(Y.blending);var B,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;B=ma*Ea;h.set(z.x-Y,z.y-B,z.x+Y,z.y+B);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){t.r=
-A.r+W.r+G.r;t.g=A.g+W.g+G.g;t.b=A.b+W.b+G.b;S.r=Y.color.r*t.r;S.g=Y.color.g*t.g;S.b=Y.color.b*t.b;S.updateStyleString()}else S.__styleString=Y.color.__styleString;Y=X.scale.x*n;B=X.scale.y*k;h.set(z.x-Y,z.y-B,z.x+Y,z.y+B);if(p.instersects(h)){U=S.__styleString;if(I!=U)o.fillStyle=I=U;o.save();o.translate(z.x,z.y);o.rotate(-X.rotation);o.scale(Y,B);o.beginPath();o.arc(0,0,1,0,M,!0);o.closePath();o.fill();o.restore()}}}}function P(z,X,Y,B){if(B.opacity!=0){a(B.opacity);b(B.blending);o.beginPath();o.moveTo(z.positionScreen.x,
+Da;if(ma>0){B.r+=xa.r*ma;B.g+=xa.g*ma;B.b+=xa.b*ma}}}}function Ga(z,X,Y){if(Y.opacity!=0){a(Y.opacity);b(Y.blending);var B,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*m;ma=X.scale.y*k;Y=U*Da;B=ma*Ea;h.set(z.x-Y,z.y-B,z.x+Y,z.y+B);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){t.r=
+A.r+W.r+G.r;t.g=A.g+W.g+G.g;t.b=A.b+W.b+G.b;S.r=Y.color.r*t.r;S.g=Y.color.g*t.g;S.b=Y.color.b*t.b;S.updateStyleString()}else S.__styleString=Y.color.__styleString;Y=X.scale.x*m;B=X.scale.y*k;h.set(z.x-Y,z.y-B,z.x+Y,z.y+B);if(p.instersects(h)){U=S.__styleString;if(I!=U)o.fillStyle=I=U;o.save();o.translate(z.x,z.y);o.rotate(-X.rotation);o.scale(Y,B);o.beginPath();o.arc(0,0,1,0,M,!0);o.closePath();o.fill();o.restore()}}}}function P(z,X,Y,B){if(B.opacity!=0){a(B.opacity);b(B.blending);o.beginPath();o.moveTo(z.positionScreen.x,
 z.positionScreen.y);o.lineTo(X.positionScreen.x,X.positionScreen.y);o.closePath();if(B instanceof THREE.LineBasicMaterial){S.__styleString=B.color.__styleString;z=B.linewidth;if(H!=z)o.lineWidth=H=z;z=S.__styleString;if(F!=z)o.strokeStyle=F=z;o.stroke();h.inflate(B.linewidth*2)}}}function N(z,X,Y,B,U,ma){if(U.opacity!=0){a(U.opacity);b(U.blending);L=z.positionScreen.x;c=z.positionScreen.y;ia=X.positionScreen.x;T=X.positionScreen.y;O=Y.positionScreen.x;ca=Y.positionScreen.y;o.beginPath();o.moveTo(L,
 c);o.lineTo(ia,T);o.lineTo(O,ca);o.lineTo(L,c);o.closePath();if(U instanceof THREE.MeshBasicMaterial)if(U.map)U.map.image.loaded&&U.map.mapping instanceof THREE.UVMapping&&Ca(L,c,ia,T,O,ca,U.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);else if(U.env_map){if(U.env_map.image.loaded&&U.env_map.mapping instanceof THREE.SphericalReflectionMapping){z=y.globalMatrix;C.copy(B.vertexNormalsWorld[0]);ea=(C.x*z.n11+C.y*z.n12+C.z*z.n13)*0.5+0.5;R=-(C.x*z.n21+C.y*z.n22+C.z*z.n23)*
-0.5+0.5;C.copy(B.vertexNormalsWorld[1]);ra=(C.x*z.n11+C.y*z.n12+C.z*z.n13)*0.5+0.5;wa=-(C.x*z.n21+C.y*z.n22+C.z*z.n23)*0.5+0.5;C.copy(B.vertexNormalsWorld[2]);f=(C.x*z.n11+C.y*z.n12+C.z*z.n13)*0.5+0.5;m=-(C.x*z.n21+C.y*z.n22+C.z*z.n23)*0.5+0.5;Ca(L,c,ia,T,O,ca,U.env_map.image,ea,R,ra,wa,f,m)}}else U.wireframe?K(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(L,
+0.5+0.5;C.copy(B.vertexNormalsWorld[1]);ra=(C.x*z.n11+C.y*z.n12+C.z*z.n13)*0.5+0.5;wa=-(C.x*z.n21+C.y*z.n22+C.z*z.n23)*0.5+0.5;C.copy(B.vertexNormalsWorld[2]);f=(C.x*z.n11+C.y*z.n12+C.z*z.n13)*0.5+0.5;n=-(C.x*z.n21+C.y*z.n22+C.z*z.n23)*0.5+0.5;Ca(L,c,ia,T,O,ca,U.env_map.image,ea,R,ra,wa,f,n)}}else U.wireframe?K(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(L,
 c,ia,T,O,ca,U.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);b(THREE.SubtractiveBlending)}if(q)if(!U.wireframe&&U.shading==THREE.SmoothShading&&B.vertexNormalsWorld.length==3){ba.r=V.r=D.r=A.r;ba.g=V.g=D.g=A.g;ba.b=V.b=D.b=A.b;za(ma,B.v1.positionWorld,B.vertexNormalsWorld[0],ba);za(ma,B.v2.positionWorld,B.vertexNormalsWorld[1],V);za(ma,B.v3.positionWorld,B.vertexNormalsWorld[2],D);J.r=(V.r+D.r)*0.5;J.g=(V.g+D.g)*0.5;J.b=(V.b+D.b)*0.5;ja=Aa(ba,V,D,J);Ca(L,c,ia,T,O,ca,
 ja,0,0,1,0,0,1)}else{t.r=A.r;t.g=A.g;t.b=A.b;za(ma,B.centroidWorld,B.normalWorld,t);S.r=U.color.r*t.r;S.g=U.color.g*t.g;S.b=U.color.b*t.b;S.updateStyleString();U.wireframe?K(S.__styleString,U.wireframe_linewidth):oa(S.__styleString)}else U.wireframe?K(U.color.__styleString,U.wireframe_linewidth):oa(U.color.__styleString)}else if(U instanceof THREE.MeshDepthMaterial){la=y.near;Q=y.far;ba.r=ba.g=ba.b=1-v(z.positionScreen.z,la,Q);V.r=V.g=V.b=1-v(X.positionScreen.z,la,Q);D.r=D.g=D.b=1-v(Y.positionScreen.z,
 la,Q);J.r=(V.r+D.r)*0.5;J.g=(V.g+D.g)*0.5;J.b=(V.b+D.b)*0.5;ja=Aa(ba,V,D,J);Ca(L,c,ia,T,O,ca,ja,0,0,1,0,0,1)}else if(U instanceof THREE.MeshNormalMaterial){S.r=Ba(B.normalWorld.x);S.g=Ba(B.normalWorld.y);S.b=Ba(B.normalWorld.z);S.updateStyleString();U.wireframe?K(S.__styleString,U.wireframe_linewidth):oa(S.__styleString)}}}function K(z,X){if(F!=z)o.strokeStyle=F=z;if(H!=X)o.lineWidth=H=X;o.stroke();h.inflate(X*2)}function oa(z){if(I!=z)o.fillStyle=I=z;o.fill()}function Ca(z,X,Y,B,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;B-=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*B-ya*ma)*La;Y=(Ia*U-Ja*Y)*La;B=(Ia*ma-Ja*B)*La;z=z-Ka*Da-Y*Ea;X=X-ya*Da-B*Ea;o.save();o.transform(Ka,ya,Y,B,z,X);o.clip();o.drawImage(xa,0,0);o.restore()}}function Aa(z,X,Y,B){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=~~(B.r*255),Ja=~~(B.g*255);B=~~(B.b*255);ka[0]=U<0?0:U>255?255:U;ka[1]=ma<0?0:ma>255?255:ma;ka[2]=z<0?0:z>255?255:z;ka[4]=xa<0?0:xa>255?255:xa;ka[5]=Da<0?0:Da>255?255:Da;ka[6]=X<0?0:X>255?255:X;ka[8]=Ea<0?0:Ea>255?255:Ea;ka[9]=Ia<0?0:Ia>255?255:Ia;ka[10]=Y<0?0:Y>255?255:Y;ka[12]=ya<0?0:ya>255?255:ya;ka[13]=Ja<0?0:Ja>255?255:Ja;ka[14]=B<0?0:B>255?255:B;da.putImageData(ua,0,0);ga.drawImage(aa,0,0);return fa}function v(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,B=X.y-z.y,U=1/Math.sqrt(Y*Y+B*B);Y*=U;B*=U;X.x+=Y;X.y+=B;z.x-=Y;z.y-=B}var Ma,Ha,$,sa,pa,ta,va,qa;this.autoClear?this.clear():o.setTransform(1,0,0,-1,n,k);d=e.projectScene(na,y,this.sortElements);(q=na.lights.length>0)&&Fa(na);Ma=0;for(Ha=d.length;Ma<Ha;Ma++){$=d[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;)P(r,Z,$,$.materials[sa++],na)}}else if($ instanceof THREE.RenderableFace3){r=$.v1;Z=$.v2;E=$.v3;r.positionScreen.x*=n;r.positionScreen.y*=k;Z.positionScreen.x*=n;Z.positionScreen.y*=k;E.positionScreen.x*=n;E.positionScreen.y*=k;if($.overdraw){Oa(r.positionScreen,
+1)*0.5;return z<0?0:z>1?1:z}function Oa(z,X){var Y=X.x-z.x,B=X.y-z.y,U=1/Math.sqrt(Y*Y+B*B);Y*=U;B*=U;X.x+=Y;X.y+=B;z.x-=Y;z.y-=B}var Ma,Ha,$,sa,pa,ta,va,qa;this.autoClear?this.clear():o.setTransform(1,0,0,-1,m,k);d=e.projectScene(na,y,this.sortElements);(q=na.lights.length>0)&&Fa(na);Ma=0;for(Ha=d.length;Ma<Ha;Ma++){$=d[Ma];h.empty();if($ instanceof THREE.RenderableParticle){r=$;r.x*=m;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*=m;r.positionScreen.y*=k;Z.positionScreen.x*=m;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;)P(r,Z,$,$.materials[sa++],na)}}else if($ instanceof THREE.RenderableFace3){r=$.v1;Z=$.v2;E=$.v3;r.positionScreen.x*=m;r.positionScreen.y*=k;Z.positionScreen.x*=m;Z.positionScreen.y*=k;E.positionScreen.x*=m;E.positionScreen.y*=k;if($.overdraw){Oa(r.positionScreen,
 Z.positionScreen);Oa(Z.positionScreen,E.positionScreen);Oa(E.positionScreen,r.positionScreen)}h.add3Points(r.positionScreen.x,r.positionScreen.y,Z.positionScreen.x,Z.positionScreen.y,E.positionScreen.x,E.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(va=$.faceMaterials.length;ta<va;)(qa=$.faceMaterials[ta++])&&N(r,Z,E,$,qa,na)}else N(r,Z,E,$,qa,na)}}}j.addRectangle(h)}o.setTransform(1,0,0,
 1,0,0)}};
-THREE.SVGRenderer=function(){function a(ea,R,ra){var wa,f,m,p;wa=0;for(f=ea.lights.length;wa<f;wa++){m=ea.lights[wa];if(m instanceof THREE.DirectionalLight){p=R.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){ca.sub(m.position,R.centroidWorld);ca.normalize();p=R.normalWorld.dot(ca)*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(ea,R,ra,wa,f,m){D=e(J++);D.setAttribute("d","M "+
-ea.positionScreen.x+" "+ea.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+"z");if(f instanceof THREE.MeshBasicMaterial)E.__styleString=f.color.__styleString;else if(f instanceof THREE.MeshLambertMaterial)if(Z){L.r=c.r;L.g=c.g;L.b=c.b;a(m,wa,L);E.r=f.color.r*L.r;E.g=f.color.g*L.g;E.b=f.color.b*L.b;E.updateStyleString()}else E.__styleString=f.color.__styleString;else if(f instanceof THREE.MeshDepthMaterial){O=1-f.__2near/(f.__farPlusNear-
-wa.z*f.__farMinusNear);E.setRGB(O,O,O)}else f instanceof THREE.MeshNormalMaterial&&E.setRGB(g(wa.normalWorld.x),g(wa.normalWorld.y),g(wa.normalWorld.z));f.wireframe?D.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+f.wireframe_linewidth+"; stroke-opacity: "+f.opacity+"; stroke-linecap: "+f.wireframe_linecap+"; stroke-linejoin: "+f.wireframe_linejoin):D.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+f.opacity);n.appendChild(D)}function d(ea,R,ra,wa,
-f,m,p){D=e(J++);D.setAttribute("d","M "+ea.positionScreen.x+" "+ea.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+" L "+wa.positionScreen.x+","+wa.positionScreen.y+"z");if(m instanceof THREE.MeshBasicMaterial)E.__styleString=m.color.__styleString;else if(m instanceof THREE.MeshLambertMaterial)if(Z){L.r=c.r;L.g=c.g;L.b=c.b;a(p,f,L);E.r=m.color.r*L.r;E.g=m.color.g*L.g;E.b=m.color.b*L.b;E.updateStyleString()}else E.__styleString=m.color.__styleString;
-else if(m instanceof THREE.MeshDepthMaterial){O=1-m.__2near/(m.__farPlusNear-f.z*m.__farMinusNear);E.setRGB(O,O,O)}else m instanceof THREE.MeshNormalMaterial&&E.setRGB(g(f.normalWorld.x),g(f.normalWorld.y),g(f.normalWorld.z));m.wireframe?D.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+m.wireframe_linewidth+"; stroke-opacity: "+m.opacity+"; stroke-linecap: "+m.wireframe_linecap+"; stroke-linejoin: "+m.wireframe_linejoin):D.setAttribute("style","fill: "+E.__styleString+
-"; fill-opacity: "+m.opacity);n.appendChild(D)}function e(ea){if(S[ea]==null){S[ea]=document.createElementNS("http://www.w3.org/2000/svg","path");ja==0&&S[ea].setAttribute("shape-rendering","crispEdges")}return S[ea]}function g(ea){return ea<0?Math.min((1+ea)*0.5,0.5):0.5+Math.min(ea*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,u,x,F,I,H=new THREE.Rectangle,r=new THREE.Rectangle,Z=!1,E=new THREE.Color(16777215),L=new THREE.Color(16777215),
-c=new THREE.Color(0),ia=new THREE.Color(0),T=new THREE.Color(0),O,ca=new THREE.Vector3,S=[],ba=[],V=[],D,J,la,Q,ja=1;this.domElement=n;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ea){switch(ea){case "high":ja=1;break;case "low":ja=0}};this.setSize=function(ea,R){k=ea;o=R;s=k/2;w=o/2;n.setAttribute("viewBox",-s+" "+-w+" "+k+" "+o);n.setAttribute("width",k);n.setAttribute("height",o);H.set(-s,-w,s,w)};this.clear=function(){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])};
-this.render=function(ea,R){var ra,wa,f,m,p,j,h,q;this.autoClear&&this.clear();i=l.projectScene(ea,R,this.sortElements);Q=la=J=0;if(Z=ea.lights.length>0){h=ea.lights;c.setRGB(0,0,0);ia.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){c.r+=m.r;c.g+=m.g;c.b+=m.b}else if(f instanceof THREE.DirectionalLight){ia.r+=m.r;ia.g+=m.g;ia.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){u=h;u.x*=s;u.y*=-w;f=0;for(m=h.materials.length;f<m;f++)if(q=h.materials[f]){p=u;j=h;var t=la++;if(ba[t]==null){ba[t]=document.createElementNS("http://www.w3.org/2000/svg","circle");ja==0&&ba[t].setAttribute("shape-rendering","crispEdges")}D=ba[t];D.setAttribute("cx",p.x);D.setAttribute("cy",p.y);D.setAttribute("r",j.scale.x*s);if(q instanceof THREE.ParticleCircleMaterial){if(Z){L.r=c.r+ia.r+T.r;L.g=c.g+ia.g+T.g;L.b=c.b+ia.b+T.b;E.r=q.color.r*
-L.r;E.g=q.color.g*L.g;E.b=q.color.b*L.b;E.updateStyleString()}else E=q.color;D.setAttribute("style","fill: "+E.__styleString)}n.appendChild(D)}}else if(h instanceof THREE.RenderableLine){u=h.v1;x=h.v2;u.positionScreen.x*=s;u.positionScreen.y*=-w;x.positionScreen.x*=s;x.positionScreen.y*=-w;r.addPoint(u.positionScreen.x,u.positionScreen.y);r.addPoint(x.positionScreen.x,x.positionScreen.y);if(H.instersects(r)){f=0;for(m=h.materials.length;f<m;)if(q=h.materials[f++]){p=u;j=x;t=Q++;if(V[t]==null){V[t]=
+THREE.SVGRenderer=function(){function a(ea,R,ra){var wa,f,n,p;wa=0;for(f=ea.lights.length;wa<f;wa++){n=ea.lights[wa];if(n instanceof THREE.DirectionalLight){p=R.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){ca.sub(n.position,R.centroidWorld);ca.normalize();p=R.normalWorld.dot(ca)*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(ea,R,ra,wa,f,n){D=e(J++);D.setAttribute("d","M "+
+ea.positionScreen.x+" "+ea.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+"z");if(f instanceof THREE.MeshBasicMaterial)E.__styleString=f.color.__styleString;else if(f instanceof THREE.MeshLambertMaterial)if(Z){L.r=c.r;L.g=c.g;L.b=c.b;a(n,wa,L);E.r=f.color.r*L.r;E.g=f.color.g*L.g;E.b=f.color.b*L.b;E.updateStyleString()}else E.__styleString=f.color.__styleString;else if(f instanceof THREE.MeshDepthMaterial){O=1-f.__2near/(f.__farPlusNear-
+wa.z*f.__farMinusNear);E.setRGB(O,O,O)}else f instanceof THREE.MeshNormalMaterial&&E.setRGB(g(wa.normalWorld.x),g(wa.normalWorld.y),g(wa.normalWorld.z));f.wireframe?D.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+f.wireframe_linewidth+"; stroke-opacity: "+f.opacity+"; stroke-linecap: "+f.wireframe_linecap+"; stroke-linejoin: "+f.wireframe_linejoin):D.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+f.opacity);m.appendChild(D)}function d(ea,R,ra,wa,
+f,n,p){D=e(J++);D.setAttribute("d","M "+ea.positionScreen.x+" "+ea.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+" L "+wa.positionScreen.x+","+wa.positionScreen.y+"z");if(n instanceof THREE.MeshBasicMaterial)E.__styleString=n.color.__styleString;else if(n instanceof THREE.MeshLambertMaterial)if(Z){L.r=c.r;L.g=c.g;L.b=c.b;a(p,f,L);E.r=n.color.r*L.r;E.g=n.color.g*L.g;E.b=n.color.b*L.b;E.updateStyleString()}else E.__styleString=n.color.__styleString;
+else if(n instanceof THREE.MeshDepthMaterial){O=1-n.__2near/(n.__farPlusNear-f.z*n.__farMinusNear);E.setRGB(O,O,O)}else n instanceof THREE.MeshNormalMaterial&&E.setRGB(g(f.normalWorld.x),g(f.normalWorld.y),g(f.normalWorld.z));n.wireframe?D.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+n.wireframe_linewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframe_linecap+"; stroke-linejoin: "+n.wireframe_linejoin):D.setAttribute("style","fill: "+E.__styleString+
+"; fill-opacity: "+n.opacity);m.appendChild(D)}function e(ea){if(S[ea]==null){S[ea]=document.createElementNS("http://www.w3.org/2000/svg","path");ja==0&&S[ea].setAttribute("shape-rendering","crispEdges")}return S[ea]}function g(ea){return ea<0?Math.min((1+ea)*0.5,0.5):0.5+Math.min(ea*0.5,0.5)}var i=null,l=new THREE.Projector,m=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,o,s,w,u,x,F,I,H=new THREE.Rectangle,r=new THREE.Rectangle,Z=!1,E=new THREE.Color(16777215),L=new THREE.Color(16777215),
+c=new THREE.Color(0),ia=new THREE.Color(0),T=new THREE.Color(0),O,ca=new THREE.Vector3,S=[],ba=[],V=[],D,J,la,Q,ja=1;this.domElement=m;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ea){switch(ea){case "high":ja=1;break;case "low":ja=0}};this.setSize=function(ea,R){k=ea;o=R;s=k/2;w=o/2;m.setAttribute("viewBox",-s+" "+-w+" "+k+" "+o);m.setAttribute("width",k);m.setAttribute("height",o);H.set(-s,-w,s,w)};this.clear=function(){for(;m.childNodes.length>0;)m.removeChild(m.childNodes[0])};
+this.render=function(ea,R){var ra,wa,f,n,p,j,h,q;this.autoClear&&this.clear();i=l.projectScene(ea,R,this.sortElements);Q=la=J=0;if(Z=ea.lights.length>0){h=ea.lights;c.setRGB(0,0,0);ia.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){c.r+=n.r;c.g+=n.g;c.b+=n.b}else if(f instanceof THREE.DirectionalLight){ia.r+=n.r;ia.g+=n.g;ia.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){u=h;u.x*=s;u.y*=-w;f=0;for(n=h.materials.length;f<n;f++)if(q=h.materials[f]){p=u;j=h;var t=la++;if(ba[t]==null){ba[t]=document.createElementNS("http://www.w3.org/2000/svg","circle");ja==0&&ba[t].setAttribute("shape-rendering","crispEdges")}D=ba[t];D.setAttribute("cx",p.x);D.setAttribute("cy",p.y);D.setAttribute("r",j.scale.x*s);if(q instanceof THREE.ParticleCircleMaterial){if(Z){L.r=c.r+ia.r+T.r;L.g=c.g+ia.g+T.g;L.b=c.b+ia.b+T.b;E.r=q.color.r*
+L.r;E.g=q.color.g*L.g;E.b=q.color.b*L.b;E.updateStyleString()}else E=q.color;D.setAttribute("style","fill: "+E.__styleString)}m.appendChild(D)}}else if(h instanceof THREE.RenderableLine){u=h.v1;x=h.v2;u.positionScreen.x*=s;u.positionScreen.y*=-w;x.positionScreen.x*=s;x.positionScreen.y*=-w;r.addPoint(u.positionScreen.x,u.positionScreen.y);r.addPoint(x.positionScreen.x,x.positionScreen.y);if(H.instersects(r)){f=0;for(n=h.materials.length;f<n;)if(q=h.materials[f++]){p=u;j=x;t=Q++;if(V[t]==null){V[t]=
 document.createElementNS("http://www.w3.org/2000/svg","line");ja==0&&V[t].setAttribute("shape-rendering","crispEdges")}D=V[t];D.setAttribute("x1",p.positionScreen.x);D.setAttribute("y1",p.positionScreen.y);D.setAttribute("x2",j.positionScreen.x);D.setAttribute("y2",j.positionScreen.y);if(q instanceof THREE.LineBasicMaterial){E.__styleString=q.color.__styleString;D.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+q.linewidth+"; stroke-opacity: "+q.opacity+"; stroke-linecap: "+
-q.linecap+"; stroke-linejoin: "+q.linejoin);n.appendChild(D)}}}}else if(h instanceof THREE.RenderableFace3){u=h.v1;x=h.v2;F=h.v3;u.positionScreen.x*=s;u.positionScreen.y*=-w;x.positionScreen.x*=s;x.positionScreen.y*=-w;F.positionScreen.x*=s;F.positionScreen.y*=-w;r.addPoint(u.positionScreen.x,u.positionScreen.y);r.addPoint(x.positionScreen.x,x.positionScreen.y);r.addPoint(F.positionScreen.x,F.positionScreen.y);if(H.instersects(r)){f=0;for(m=h.meshMaterials.length;f<m;){q=h.meshMaterials[f++];if(q instanceof
+q.linecap+"; stroke-linejoin: "+q.linejoin);m.appendChild(D)}}}}else if(h instanceof THREE.RenderableFace3){u=h.v1;x=h.v2;F=h.v3;u.positionScreen.x*=s;u.positionScreen.y*=-w;x.positionScreen.x*=s;x.positionScreen.y*=-w;F.positionScreen.x*=s;F.positionScreen.y*=-w;r.addPoint(u.positionScreen.x,u.positionScreen.y);r.addPoint(x.positionScreen.x,x.positionScreen.y);r.addPoint(F.positionScreen.x,F.positionScreen.y);if(H.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(u,x,F,h,q,ea)}else q&&b(u,x,F,h,q,ea)}}}else if(h instanceof THREE.RenderableFace4){u=h.v1;x=h.v2;F=h.v3;I=h.v4;u.positionScreen.x*=s;u.positionScreen.y*=-w;x.positionScreen.x*=s;x.positionScreen.y*=-w;F.positionScreen.x*=s;F.positionScreen.y*=-w;I.positionScreen.x*=s;I.positionScreen.y*=-w;r.addPoint(u.positionScreen.x,u.positionScreen.y);r.addPoint(x.positionScreen.x,x.positionScreen.y);r.addPoint(F.positionScreen.x,
-F.positionScreen.y);r.addPoint(I.positionScreen.x,I.positionScreen.y);if(H.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++])&&d(u,x,F,I,h,q,ea)}else q&&d(u,x,F,I,h,q,ea)}}}}}};
-THREE.WebGLRenderer=function(a){function b(f,m,p){var j,h,q,t=f.vertices,A=t.length,W=f.colors,G=W.length,M=f.__vertexArray,C=f.__colorArray,aa=f.__sortArray,da=f.__dirtyVertices,ua=f.__dirtyColors;if(p.sortParticles){J.multiplySelf(p.globalMatrix);for(j=0;j<A;j++){h=t[j].position;ea.copy(h);J.multiplyVector3(ea);aa[j]=[ea.z,j]}aa.sort(function(ka,fa){return fa[0]-ka[0]});for(j=0;j<A;j++){h=t[aa[j][1]].position;q=j*3;M[q]=h.x;M[q+1]=h.y;M[q+2]=h.z}for(j=0;j<G;j++){q=j*3;color=W[aa[j][1]];C[q]=color.r;
-C[q+1]=color.g;C[q+2]=color.b}}else{if(da)for(j=0;j<A;j++){h=t[j].position;q=j*3;M[q]=h.x;M[q+1]=h.y;M[q+2]=h.z}if(ua)for(j=0;j<G;j++){color=W[j];q=j*3;C[q]=color.r;C[q+1]=color.g;C[q+2]=color.b}}if(da||p.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,M,m)}if(ua||p.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,C,m)}}function d(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||O.initMaterial(j,m,p);var q=j.program,t=q.uniforms,A=j.uniforms;if(q!=ia){c.useProgram(q);ia=q;c.uniformMatrix4fv(t.projectionMatrix,!1,la)}if(p&&(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial||j instanceof THREE.LineBasicMaterial||j instanceof THREE.ParticleBasicMaterial)){A.fogColor.value.setHex(p.color.hex);if(p instanceof THREE.Fog){A.fogNear.value=p.near;A.fogFar.value=
-p.far}else if(p instanceof THREE.FogExp2)A.fogDensity.value=p.density}if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){var W,G,M=0,C=0,aa=0,da,ua,ka,fa=O.lights,ga=fa.directional.colors,ha=fa.directional.positions,na=fa.point.colors,y=fa.point.positions,Fa=0,za=0;p=G=G=0;for(W=m.length;p<W;p++){G=m[p];da=G.color;ua=G.position;ka=G.intensity;if(G instanceof THREE.AmbientLight){M+=da.r;C+=da.g;aa+=da.b}else if(G instanceof THREE.DirectionalLight){G=Fa*3;ga[G]=da.r*ka;
-ga[G+1]=da.g*ka;ga[G+2]=da.b*ka;ha[G]=ua.x;ha[G+1]=ua.y;ha[G+2]=ua.z;Fa+=1}else if(G instanceof THREE.PointLight){G=za*3;na[G]=da.r*ka;na[G+1]=da.g*ka;na[G+2]=da.b*ka;y[G]=ua.x;y[G+1]=ua.y;y[G+2]=ua.z;za+=1}}for(p=Fa*3;p<ga.length;p++)ga[p]=0;for(p=za*3;p<na.length;p++)na[p]=0;fa.point.length=za;fa.directional.length=Fa;fa.ambient[0]=M;fa.ambient[1]=C;fa.ambient[2]=aa;m=O.lights;A.enableLighting.value=m.directional.length+m.point.length;A.ambientLightColor.value=m.ambient;A.directionalLightColor.value=
-m.directional.colors;A.directionalLightDirection.value=m.directional.positions;A.pointLightColor.value=m.point.colors;A.pointLightPosition.value=m.point.positions}if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial){A.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);A.opacity.value=j.opacity;A.map.texture=j.map;A.light_map.texture=j.light_map;A.env_map.texture=j.env_map;A.reflectivity.value=j.reflectivity;
+F.positionScreen.y);r.addPoint(I.positionScreen.x,I.positionScreen.y);if(H.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++])&&d(u,x,F,I,h,q,ea)}else q&&d(u,x,F,I,h,q,ea)}}}}}};
+THREE.WebGLRenderer=function(a){function b(f,n,p){var j,h,q,t=f.vertices,A=t.length,W=f.colors,G=W.length,M=f.__vertexArray,C=f.__colorArray,aa=f.__sortArray,da=f.__dirtyVertices,ua=f.__dirtyColors;if(p.sortParticles){J.multiplySelf(p.globalMatrix);for(j=0;j<A;j++){h=t[j].position;ea.copy(h);J.multiplyVector3(ea);aa[j]=[ea.z,j]}aa.sort(function(ka,fa){return fa[0]-ka[0]});for(j=0;j<A;j++){h=t[aa[j][1]].position;q=j*3;M[q]=h.x;M[q+1]=h.y;M[q+2]=h.z}for(j=0;j<G;j++){q=j*3;color=W[aa[j][1]];C[q]=color.r;
+C[q+1]=color.g;C[q+2]=color.b}}else{if(da)for(j=0;j<A;j++){h=t[j].position;q=j*3;M[q]=h.x;M[q+1]=h.y;M[q+2]=h.z}if(ua)for(j=0;j<G;j++){color=W[j];q=j*3;C[q]=color.r;C[q+1]=color.g;C[q+2]=color.b}}if(da||p.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,M,n)}if(ua||p.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,C,n)}}function d(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||O.initMaterial(j,n,p);var q=j.program,t=q.uniforms,A=j.uniforms;if(q!=ia){c.useProgram(q);ia=q;c.uniformMatrix4fv(t.projectionMatrix,!1,la)}if(p&&(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial||j instanceof THREE.LineBasicMaterial||j instanceof THREE.ParticleBasicMaterial)){A.fogColor.value.setHex(p.color.hex);if(p instanceof THREE.Fog){A.fogNear.value=p.near;A.fogFar.value=
+p.far}else if(p instanceof THREE.FogExp2)A.fogDensity.value=p.density}if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){var W,G,M=0,C=0,aa=0,da,ua,ka,fa=O.lights,ga=fa.directional.colors,ha=fa.directional.positions,na=fa.point.colors,y=fa.point.positions,Fa=0,za=0;p=G=G=0;for(W=n.length;p<W;p++){G=n[p];da=G.color;ua=G.position;ka=G.intensity;if(G instanceof THREE.AmbientLight){M+=da.r;C+=da.g;aa+=da.b}else if(G instanceof THREE.DirectionalLight){G=Fa*3;ga[G]=da.r*ka;
+ga[G+1]=da.g*ka;ga[G+2]=da.b*ka;ha[G]=ua.x;ha[G+1]=ua.y;ha[G+2]=ua.z;Fa+=1}else if(G instanceof THREE.PointLight){G=za*3;na[G]=da.r*ka;na[G+1]=da.g*ka;na[G+2]=da.b*ka;y[G]=ua.x;y[G+1]=ua.y;y[G+2]=ua.z;za+=1}}for(p=Fa*3;p<ga.length;p++)ga[p]=0;for(p=za*3;p<na.length;p++)na[p]=0;fa.point.length=za;fa.directional.length=Fa;fa.ambient[0]=M;fa.ambient[1]=C;fa.ambient[2]=aa;n=O.lights;A.enableLighting.value=n.directional.length+n.point.length;A.ambientLightColor.value=n.ambient;A.directionalLightColor.value=
+n.directional.colors;A.directionalLightDirection.value=n.directional.positions;A.pointLightColor.value=n.point.colors;A.pointLightPosition.value=n.point.positions}if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial){A.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);A.opacity.value=j.opacity;A.map.texture=j.map;A.light_map.texture=j.light_map;A.env_map.texture=j.env_map;A.reflectivity.value=j.reflectivity;
 A.refraction_ratio.value=j.refraction_ratio;A.combine.value=j.combine;A.useRefract.value=j.env_map&&j.env_map.mapping instanceof THREE.CubeRefractionMapping}if(j instanceof THREE.LineBasicMaterial){A.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);A.opacity.value=j.opacity}else if(j instanceof THREE.ParticleBasicMaterial){A.psColor.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);A.opacity.value=j.opacity;A.size.value=j.size;A.map.texture=
-j.map}else if(j instanceof THREE.MeshPhongMaterial){A.ambient.value.setRGB(j.ambient.r,j.ambient.g,j.ambient.b);A.specular.value.setRGB(j.specular.r,j.specular.g,j.specular.b);A.shininess.value=j.shininess}else if(j instanceof THREE.MeshDepthMaterial){A.mNear.value=f.zNear;A.mFar.value=f.zFar;A.opacity.value=j.opacity}else if(j instanceof THREE.MeshNormalMaterial)A.opacity.value=j.opacity;for(var Ga in A)if(M=q.uniforms[Ga]){p=A[Ga];W=p.type;m=p.value;if(W=="i")c.uniform1i(M,m);else if(W=="f")c.uniform1f(M,
-m);else if(W=="fv1")c.uniform1fv(M,m);else if(W=="fv")c.uniform3fv(M,m);else if(W=="v2")c.uniform2f(M,m.x,m.y);else if(W=="v3")c.uniform3f(M,m.x,m.y,m.z);else if(W=="c")c.uniform3f(M,m.r,m.g,m.b);else if(W=="t"){c.uniform1i(M,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=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube);
+j.map}else if(j instanceof THREE.MeshPhongMaterial){A.ambient.value.setRGB(j.ambient.r,j.ambient.g,j.ambient.b);A.specular.value.setRGB(j.specular.r,j.specular.g,j.specular.b);A.shininess.value=j.shininess}else if(j instanceof THREE.MeshDepthMaterial){A.mNear.value=f.zNear;A.mFar.value=f.zFar;A.opacity.value=j.opacity}else if(j instanceof THREE.MeshNormalMaterial)A.opacity.value=j.opacity;for(var Ga in A)if(M=q.uniforms[Ga]){p=A[Ga];W=p.type;n=p.value;if(W=="i")c.uniform1i(M,n);else if(W=="f")c.uniform1f(M,
+n);else if(W=="fv1")c.uniform1fv(M,n);else if(W=="fv")c.uniform3fv(M,n);else if(W=="v2")c.uniform2f(M,n.x,n.y);else if(W=="v3")c.uniform3f(M,n.x,n.y,n.z);else if(W=="c")c.uniform3f(M,n.r,n.g,n.b);else if(W=="t"){c.uniform1i(M,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=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube);
 c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(W=0;W<6;++W)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,p.image[W]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);p.image.__cubeMapInitialized=!0}c.activeTexture(c.TEXTURE0+
-m);c.bindTexture(c.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube)}}else{if(!p.__webGLTexture&&p.image.loaded){p.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,p.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,p.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,E(p.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,E(p.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,E(p.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,E(p.min_filter));
-c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_2D,p.__webGLTexture)}}}c.uniformMatrix4fv(t.modelViewMatrix,!1,h._modelViewMatrixArray);c.uniformMatrix3fv(t.normalMatrix,!1,h._normalMatrixArray);(j instanceof THREE.MeshShaderMaterial||j instanceof THREE.MeshPhongMaterial||j.env_map)&&c.uniform3f(t.cameraPosition,f.position.x,f.position.y,f.position.z);(j instanceof THREE.MeshShaderMaterial||j.env_map||j.skinning)&&c.uniformMatrix4fv(t.objectMatrix,
-!1,h._objectMatrixArray);(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshShaderMaterial||j.skinning)&&c.uniformMatrix4fv(t.viewMatrix,!1,ja);if(j.skinning){c.uniformMatrix4fv(t.cameraInverseMatrix,!1,Q);c.uniformMatrix4fv(t.uBoneGlobalMatrices,!1,h.boneMatrices)}return q}function g(f,m,p,j,h,q){f=e(f,m,p,j,q).attributes;c.bindBuffer(c.ARRAY_BUFFER,h.__webGLVertexBuffer);c.vertexAttribPointer(f.position,3,c.FLOAT,!1,0,0);if(f.color>=0){c.bindBuffer(c.ARRAY_BUFFER,
+n);c.bindTexture(c.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube)}}else{if(!p.__webGLTexture&&p.image.loaded){p.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,p.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,p.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,E(p.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,E(p.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,E(p.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,E(p.min_filter));
+c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+n);c.bindTexture(c.TEXTURE_2D,p.__webGLTexture)}}}c.uniformMatrix4fv(t.modelViewMatrix,!1,h._modelViewMatrixArray);c.uniformMatrix3fv(t.normalMatrix,!1,h._normalMatrixArray);(j instanceof THREE.MeshShaderMaterial||j instanceof THREE.MeshPhongMaterial||j.env_map)&&c.uniform3f(t.cameraPosition,f.position.x,f.position.y,f.position.z);(j instanceof THREE.MeshShaderMaterial||j.env_map||j.skinning)&&c.uniformMatrix4fv(t.objectMatrix,
+!1,h._objectMatrixArray);(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshShaderMaterial||j.skinning)&&c.uniformMatrix4fv(t.viewMatrix,!1,ja);if(j.skinning){c.uniformMatrix4fv(t.cameraInverseMatrix,!1,Q);c.uniformMatrix4fv(t.boneGlobalMatrices,!1,h.boneMatrices)}return q}function g(f,n,p,j,h,q){f=e(f,n,p,j,q).attributes;c.bindBuffer(c.ARRAY_BUFFER,h.__webGLVertexBuffer);c.vertexAttribPointer(f.position,3,c.FLOAT,!1,0,0);if(f.color>=0){c.bindBuffer(c.ARRAY_BUFFER,
 h.__webGLColorBuffer);c.vertexAttribPointer(f.color,3,c.FLOAT,!1,0,0)}if(f.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,h.__webGLNormalBuffer);c.vertexAttribPointer(f.normal,3,c.FLOAT,!1,0,0)}if(f.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,h.__webGLTangentBuffer);c.vertexAttribPointer(f.tangent,4,c.FLOAT,!1,0,0)}if(f.uv>=0)if(h.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,h.__webGLUVBuffer);c.vertexAttribPointer(f.uv,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv)}else c.disableVertexAttribArray(f.uv);if(f.uv2>=
 0)if(h.__webGLUV2Buffer){c.bindBuffer(c.ARRAY_BUFFER,h.__webGLUV2Buffer);c.vertexAttribPointer(f.uv2,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv2)}else c.disableVertexAttribArray(f.uv2);if(j.skinning&&f.skinVertexA>=0&&f.skinVertexB>=0&&f.skinIndex>=0&&f.skinWeight>=0){c.bindBuffer(c.ARRAY_BUFFER,h.__webGLSkinVertexABuffer);c.vertexAttribPointer(f.skinVertexA,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,h.__webGLSkinVertexBBuffer);c.vertexAttribPointer(f.skinVertexB,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,
 h.__webGLSkinIndicesBuffer);c.vertexAttribPointer(f.skinIndex,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,h.__webGLSkinWeightsBuffer);c.vertexAttribPointer(f.skinWeight,4,c.FLOAT,!1,0,0)}if(q instanceof THREE.Mesh)if(j.wireframe){c.lineWidth(j.wireframe_linewidth);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webGLLineBuffer);c.drawElements(c.LINES,h.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,h.__webGLFaceCount,c.UNSIGNED_SHORT,
-0)}else if(q instanceof THREE.Line){q=q.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(j.linewidth);c.drawArrays(q,0,h.__webGLLineCount)}else if(q instanceof THREE.ParticleSystem)c.drawArrays(c.POINTS,0,h.__webGLParticleCount);else q instanceof THREE.Ribbon&&c.drawArrays(c.TRIANGLE_STRIP,0,h.__webGLVertexCount)}function i(f,m){if(!f.__webGLVertexBuffer)f.__webGLVertexBuffer=c.createBuffer();if(!f.__webGLNormalBuffer)f.__webGLNormalBuffer=c.createBuffer();if(f.hasPos){c.bindBuffer(c.ARRAY_BUFFER,
-f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,f.positionArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(m.attributes.position);c.vertexAttribPointer(m.attributes.position,3,c.FLOAT,!1,0,0)}if(f.hasNormal){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,f.normalArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(m.attributes.normal);c.vertexAttribPointer(m.attributes.normal,3,c.FLOAT,!1,0,0)}c.drawArrays(c.TRIANGLES,0,f.count);f.count=0}function l(f){if(ca!=f.doubleSided){f.doubleSided?
-c.disable(c.CULL_FACE):c.enable(c.CULL_FACE);ca=f.doubleSided}if(S!=f.flipSided){f.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW);S=f.flipSided}}function n(f){if(V!=f){f?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST);V=f}}function k(f){D[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);D[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);D[2].set(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);D[3].set(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);D[4].set(f.n41-f.n31,f.n42-f.n32,
-f.n43-f.n33,f.n44-f.n34);D[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=D[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=D[j].x*m.n14+D[j].y*m.n24+D[j].z*m.n34+D[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 u(f){var m,p,j,h,q=f.object,t=f.buffer,A=f.opaque,W=f.transparent;W.count=0;f=A.count=0;for(j=q.materials.length;f<j;f++){m=q.materials[f];if(m instanceof THREE.MeshFaceMaterial){m=0;for(p=t.materials.length;m<p;m++)(h=t.materials[m])&&(h.opacity&&h.opacity<1||h.blending!=THREE.NormalBlending?s(W,h):s(A,h))}else{h=m;h.opacity&&h.opacity<1||h.blending!=THREE.NormalBlending?
-s(W,h):s(A,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 I(f,m){f._modelViewMatrix.multiplyToArray(m.globalMatrix,f.globalMatrix,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function H(f){if(f!=ba){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,
-c.ZERO);break;case THREE.BillboardBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:c.blendEquation(c.FUNC_REVERSE_SUBTRACT);c.blendFunc(c.ONE,c.ONE);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}ba=f}}function r(f,m){if(f&&!f.__webGLFramebuffer){f.__webGLFramebuffer=c.createFramebuffer();f.__webGLRenderbuffer=c.createRenderbuffer();f.__webGLTexture=c.createTexture();c.bindRenderbuffer(c.RENDERBUFFER,
+0)}else if(q instanceof THREE.Line){q=q.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(j.linewidth);c.drawArrays(q,0,h.__webGLLineCount)}else if(q instanceof THREE.ParticleSystem)c.drawArrays(c.POINTS,0,h.__webGLParticleCount);else q instanceof THREE.Ribbon&&c.drawArrays(c.TRIANGLE_STRIP,0,h.__webGLVertexCount)}function i(f,n){if(!f.__webGLVertexBuffer)f.__webGLVertexBuffer=c.createBuffer();if(!f.__webGLNormalBuffer)f.__webGLNormalBuffer=c.createBuffer();if(f.hasPos){c.bindBuffer(c.ARRAY_BUFFER,
+f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,f.positionArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(n.attributes.position);c.vertexAttribPointer(n.attributes.position,3,c.FLOAT,!1,0,0)}if(f.hasNormal){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,f.normalArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(n.attributes.normal);c.vertexAttribPointer(n.attributes.normal,3,c.FLOAT,!1,0,0)}c.drawArrays(c.TRIANGLES,0,f.count);f.count=0}function l(f){if(ca!=f.doubleSided){f.doubleSided?
+c.disable(c.CULL_FACE):c.enable(c.CULL_FACE);ca=f.doubleSided}if(S!=f.flipSided){f.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW);S=f.flipSided}}function m(f){if(V!=f){f?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST);V=f}}function k(f){D[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);D[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);D[2].set(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);D[3].set(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);D[4].set(f.n41-f.n31,f.n42-f.n32,
+f.n43-f.n33,f.n44-f.n34);D[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=D[f];n.divideScalar(Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z))}}function o(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=D[j].x*n.n14+D[j].y*n.n24+D[j].z*n.n34+D[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 u(f){var n,p,j,h,q=f.object,t=f.buffer,A=f.opaque,W=f.transparent;W.count=0;f=A.count=0;for(j=q.materials.length;f<j;f++){n=q.materials[f];if(n instanceof THREE.MeshFaceMaterial){n=0;for(p=t.materials.length;n<p;n++)(h=t.materials[n])&&(h.opacity&&h.opacity<1||h.blending!=THREE.NormalBlending?s(W,h):s(A,h))}else{h=n;h.opacity&&h.opacity<1||h.blending!=THREE.NormalBlending?
+s(W,h):s(A,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 I(f,n){f._modelViewMatrix.multiplyToArray(n.globalMatrix,f.globalMatrix,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function H(f){if(f!=ba){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,
+c.ZERO);break;case THREE.BillboardBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:c.blendEquation(c.FUNC_REVERSE_SUBTRACT);c.blendFunc(c.ONE,c.ONE);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}ba=f}}function r(f,n){if(f&&!f.__webGLFramebuffer){f.__webGLFramebuffer=c.createFramebuffer();f.__webGLRenderbuffer=c.createRenderbuffer();f.__webGLTexture=c.createTexture();c.bindRenderbuffer(c.RENDERBUFFER,
 f.__webGLRenderbuffer);c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,f.width,f.height);c.bindTexture(c.TEXTURE_2D,f.__webGLTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,E(f.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,E(f.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,E(f.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,E(f.min_filter));c.texImage2D(c.TEXTURE_2D,0,E(f.format),f.width,f.height,0,E(f.format),E(f.type),null);c.bindFramebuffer(c.FRAMEBUFFER,
-f.__webGLFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,f.__webGLTexture,0);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,f.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var p,j,h;if(f){p=f.__webGLFramebuffer;j=f.width;h=f.height}else{p=null;j=L.width;h=L.height}if(p!=T){c.bindFramebuffer(c.FRAMEBUFFER,p);c.viewport(0,0,j,h);m&&c.clear(c.COLOR_BUFFER_BIT|
-c.DEPTH_BUFFER_BIT);T=p}}function Z(f,m){var p;if(f=="fragment")p=c.createShader(c.FRAGMENT_SHADER);else f=="vertex"&&(p=c.createShader(c.VERTEX_SHADER));c.shaderSource(p,m);c.compileShader(p);if(!c.getShaderParameter(p,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(p));return null}return p}function E(f){switch(f){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;
+f.__webGLFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,f.__webGLTexture,0);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,f.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var p,j,h;if(f){p=f.__webGLFramebuffer;j=f.width;h=f.height}else{p=null;j=L.width;h=L.height}if(p!=T){c.bindFramebuffer(c.FRAMEBUFFER,p);c.viewport(0,0,j,h);n&&c.clear(c.COLOR_BUFFER_BIT|
+c.DEPTH_BUFFER_BIT);T=p}}function Z(f,n){var p;if(f=="fragment")p=c.createShader(c.FRAGMENT_SHADER);else f=="vertex"&&(p=c.createShader(c.VERTEX_SHADER));c.shaderSource(p,n);c.compileShader(p);if(!c.getShaderParameter(p,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(p));return null}return p}function E(f){switch(f){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;
 case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE;case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;case THREE.IntType:return c.INT;
 case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var L=document.createElement("canvas"),c,ia=null,T=null,O=this,ca=null,S=null,ba=null,V=null,D=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],
-J=new THREE.Matrix4,la=new Float32Array(16),Q=new Float32Array(16),ja=new Float32Array(16),ea=new THREE.Vector4,R=!0,ra=new THREE.Color(0),wa=0;if(a){if(a.antialias!==undefined)R=a.antialias;a.clearColor!==undefined&&ra.setHex(a.clearColor);if(a.clearAlpha!==undefined)wa=a.clearAlpha}this.domElement=L;this.autoClear=!0;this.sortObjects=!1;(function(f,m,p){try{c=L.getContext("experimental-webgl",{antialias:f})}catch(j){console.log(j)}if(!c){alert("WebGL not supported");throw"cannot create webgl context";
-}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(m.r,m.g,m.b,p);_cullEnabled=!0})(R,ra,wa);this.context=c;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,m){L.width=f;L.height=m;c.viewport(0,0,L.width,L.height)};this.setClearColorHex=function(f,
-m){var p=new THREE.Color(f);c.clearColor(p.r,p.g,p.b,m)};this.setClearColor=function(f,m){c.clearColor(f.r,f.g,f.b,m)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.initMaterial=function(f,m,p){var j,h;if(f instanceof THREE.MeshDepthMaterial)d(f,THREE.ShaderLib.depth);else if(f instanceof THREE.MeshNormalMaterial)d(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)d(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)d(f,THREE.ShaderLib.lambert);
-else if(f instanceof THREE.MeshPhongMaterial)d(f,THREE.ShaderLib.phong);else if(f instanceof THREE.LineBasicMaterial)d(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&d(f,THREE.ShaderLib.particle_basic);var q,t,A,W;h=A=W=0;for(q=m.length;h<q;h++){t=m[h];t instanceof THREE.DirectionalLight&&A++;t instanceof THREE.PointLight&&W++}if(W+A<=4)m=A;else{m=Math.ceil(4*A/(W+A));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,
+J=new THREE.Matrix4,la=new Float32Array(16),Q=new Float32Array(16),ja=new Float32Array(16),ea=new THREE.Vector4,R=!0,ra=new THREE.Color(0),wa=0;if(a){if(a.antialias!==undefined)R=a.antialias;a.clearColor!==undefined&&ra.setHex(a.clearColor);if(a.clearAlpha!==undefined)wa=a.clearAlpha}this.domElement=L;this.autoClear=!0;this.sortObjects=!1;(function(f,n,p){try{c=L.getContext("experimental-webgl",{antialias:f})}catch(j){console.log(j)}if(!c){alert("WebGL not supported");throw"cannot create webgl context";
+}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(n.r,n.g,n.b,p);_cullEnabled=!0})(R,ra,wa);this.context=c;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,n){L.width=f;L.height=n;c.viewport(0,0,L.width,L.height)};this.setClearColorHex=function(f,
+n){var p=new THREE.Color(f);c.clearColor(p.r,p.g,p.b,n)};this.setClearColor=function(f,n){c.clearColor(f.r,f.g,f.b,n)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.initMaterial=function(f,n,p){var j,h;if(f instanceof THREE.MeshDepthMaterial)d(f,THREE.ShaderLib.depth);else if(f instanceof THREE.MeshNormalMaterial)d(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)d(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)d(f,THREE.ShaderLib.lambert);
+else if(f instanceof THREE.MeshPhongMaterial)d(f,THREE.ShaderLib.phong);else if(f instanceof THREE.LineBasicMaterial)d(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&d(f,THREE.ShaderLib.particle_basic);var q,t,A,W;h=A=W=0;for(q=n.length;h<q;h++){t=n[h];t instanceof THREE.DirectionalLight&&A++;t instanceof THREE.PointLight&&W++}if(W+A<=4)n=A;else{n=Math.ceil(4*A/(W+A));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=c.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=[c.getParameter(c.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");
-c.attachShader(p,Z("fragment",h+W));c.attachShader(p,Z("vertex",q+m));c.linkProgram(p);c.getProgramParameter(p,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(p,c.VALIDATE_STATUS)+", gl error ["+c.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]=c.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]=c.getAttribLocation(j,h)}j=f.program.attributes;c.enableVertexAttribArray(j.position);j.color>=0&&c.enableVertexAttribArray(j.color);j.normal>=0&&c.enableVertexAttribArray(j.normal);j.tangent>=0&&c.enableVertexAttribArray(j.tangent);if(f.skinning&&j.skinVertexA>=0&&j.skinVertexB>=
-0&&j.skinIndex>=0&&j.skinWeight>=0){c.enableVertexAttribArray(j.skinVertexA);c.enableVertexAttribArray(j.skinVertexB);c.enableVertexAttribArray(j.skinIndex);c.enableVertexAttribArray(j.skinWeight)}};this.render=function(f,m,p,j){var h,q,t,A,W,G,M,C,aa=f.lights,da=f.fog;m.matrixAutoUpdate&&m.update();m.globalMatrix.flattenToArray(ja);m.projectionMatrix.flattenToArray(la);m.inverseMatrix.flattenToArray(Q);J.multiply(m.projectionMatrix,m.globalMatrix);k(J);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];M=h.object;if(M.visible)if(!(M instanceof THREE.Mesh)||o(M)){M.globalMatrix.flattenToArray(M._objectMatrixArray);I(M,m);u(h);h.render=!0;if(this.sortObjects){ea.copy(M.position);J.multiplyVector3(ea);h.z=ea.z}}else h.render=!1;else h.render=!1}this.sortObjects&&f.__webGLObjects.sort(x);G=f.__webGLObjectsImmediate.length;for(j=0;j<
-G;j++){h=f.__webGLObjectsImmediate[j];M=h.object;if(M.visible){M.matrixAutoUpdate&&M.globalMatrix.flattenToArray(M._objectMatrixArray);I(M,m);w(h)}}H(THREE.NormalBlending);for(j=0;j<W;j++){h=f.__webGLObjects[j];if(h.render){M=h.object;C=h.buffer;t=h.opaque;l(M);for(h=0;h<t.count;h++){A=t.list[h];n(A.depth_test);g(m,aa,da,A,C,M)}}}for(j=0;j<G;j++){h=f.__webGLObjectsImmediate[j];M=h.object;if(M.visible){t=h.opaque;l(M);for(h=0;h<t.count;h++){A=t.list[h];n(A.depth_test);q=e(m,aa,da,A,M);M.render(function(ua){i(ua,
-q)})}}}for(j=0;j<W;j++){h=f.__webGLObjects[j];if(h.render){M=h.object;C=h.buffer;t=h.transparent;l(M);for(h=0;h<t.count;h++){A=t.list[h];H(A.blending);n(A.depth_test);g(m,aa,da,A,C,M)}}}for(j=0;j<G;j++){h=f.__webGLObjectsImmediate[j];M=h.object;if(M.visible){t=h.transparent;l(M);for(h=0;h<t.count;h++){A=t.list[h];H(A.blending);n(A.depth_test);q=e(m,aa,da,A,M);M.render(function(ua){i(ua,q)})}}}if(p&&p.min_filter!==THREE.NearestFilter&&p.min_filter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,p.__webGLTexture);
-c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.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,t=void 0,A=void 0,W=void 0;t=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);
+c.attachShader(p,Z("fragment",h+W));c.attachShader(p,Z("vertex",q+n));c.linkProgram(p);c.getProgramParameter(p,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(p,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");p.uniforms={};p.attributes={};f.program=p;p=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];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]=c.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]=c.getAttribLocation(j,h)}j=f.program.attributes;c.enableVertexAttribArray(j.position);j.color>=0&&c.enableVertexAttribArray(j.color);j.normal>=0&&c.enableVertexAttribArray(j.normal);j.tangent>=0&&c.enableVertexAttribArray(j.tangent);if(f.skinning&&j.skinVertexA>=0&&j.skinVertexB>=
+0&&j.skinIndex>=0&&j.skinWeight>=0){c.enableVertexAttribArray(j.skinVertexA);c.enableVertexAttribArray(j.skinVertexB);c.enableVertexAttribArray(j.skinIndex);c.enableVertexAttribArray(j.skinWeight)}};this.render=function(f,n,p,j){var h,q,t,A,W,G,M,C,aa=f.lights,da=f.fog;n.matrixAutoUpdate&&n.update();n.globalMatrix.flattenToArray(ja);n.projectionMatrix.flattenToArray(la);n.inverseMatrix.flattenToArray(Q);J.multiply(n.projectionMatrix,n.globalMatrix);k(J);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];M=h.object;if(M.visible)if(!(M instanceof THREE.Mesh)||o(M)){M.globalMatrix.flattenToArray(M._objectMatrixArray);I(M,n);u(h);h.render=!0;if(this.sortObjects){ea.copy(M.position);J.multiplyVector3(ea);h.z=ea.z}}else h.render=!1;else h.render=!1}this.sortObjects&&f.__webGLObjects.sort(x);G=f.__webGLObjectsImmediate.length;for(j=0;j<
+G;j++){h=f.__webGLObjectsImmediate[j];M=h.object;if(M.visible){M.matrixAutoUpdate&&M.globalMatrix.flattenToArray(M._objectMatrixArray);I(M,n);w(h)}}H(THREE.NormalBlending);for(j=0;j<W;j++){h=f.__webGLObjects[j];if(h.render){M=h.object;C=h.buffer;t=h.opaque;l(M);for(h=0;h<t.count;h++){A=t.list[h];m(A.depth_test);g(n,aa,da,A,C,M)}}}for(j=0;j<G;j++){h=f.__webGLObjectsImmediate[j];M=h.object;if(M.visible){t=h.opaque;l(M);for(h=0;h<t.count;h++){A=t.list[h];m(A.depth_test);q=e(n,aa,da,A,M);M.render(function(ua){i(ua,
+q)})}}}for(j=0;j<W;j++){h=f.__webGLObjects[j];if(h.render){M=h.object;C=h.buffer;t=h.transparent;l(M);for(h=0;h<t.count;h++){A=t.list[h];H(A.blending);m(A.depth_test);g(n,aa,da,A,C,M)}}}for(j=0;j<G;j++){h=f.__webGLObjectsImmediate[j];M=h.object;if(M.visible){t=h.transparent;l(M);for(h=0;h<t.count;h++){A=t.list[h];H(A.blending);m(A.depth_test);q=e(n,aa,da,A,M);M.render(function(ua){i(ua,q)})}}}if(p&&p.min_filter!==THREE.NearestFilter&&p.min_filter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,p.__webGLTexture);
+c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.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,t=void 0,A=void 0,W=void 0;t=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 t.geometryChunks){A=t.geometryChunks[q];if(!A.__webGLVertexBuffer){h=A;h.__webGLVertexBuffer=c.createBuffer();h.__webGLNormalBuffer=c.createBuffer();h.__webGLTangentBuffer=c.createBuffer();h.__webGLColorBuffer=c.createBuffer();h.__webGLUVBuffer=c.createBuffer();h.__webGLUV2Buffer=c.createBuffer();h.__webGLSkinVertexABuffer=
 c.createBuffer();h.__webGLSkinVertexBBuffer=c.createBuffer();h.__webGLSkinIndicesBuffer=c.createBuffer();h.__webGLSkinWeightsBuffer=c.createBuffer();h.__webGLFaceBuffer=c.createBuffer();h.__webGLLineBuffer=c.createBuffer();h=A;var G=j,M=void 0,C=void 0,aa=0,da=0,ua=0,ka=G.geometry.faces,fa=h.faces;M=0;for(C=fa.length;M<C;M++){fi=fa[M];face=ka[fi];if(face instanceof THREE.Face3){aa+=3;da+=1;ua+=3}else if(face instanceof THREE.Face4){aa+=4;da+=2;ua+=4}}h.__vertexArray=new Float32Array(aa*3);h.__normalArray=
 new Float32Array(aa*3);h.__tangentArray=new Float32Array(aa*4);h.__colorArray=new Float32Array(aa*3);h.__uvArray=new Float32Array(aa*2);h.__uv2Array=new Float32Array(aa*2);h.__skinVertexAArray=new Float32Array(aa*4);h.__skinVertexBArray=new Float32Array(aa*4);h.__skinIndexArray=new Float32Array(aa*4);h.__skinWeightArray=new Float32Array(aa*4);h.__faceArray=new Uint16Array(da*3);h.__lineArray=new Uint16Array(ua*2);C=M=h;aa=void 0;ka=void 0;var ga=void 0,ha=void 0;ga=void 0;fa=!1;aa=0;for(ka=G.materials.length;aa<
@@ -251,8 +248,8 @@ q.__webGLColorBuffer=c.createBuffer();q=t;A=q.vertices.length;q.__vertexArray=ne
 q.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,fa,A)}if(ga){for(C=0;C<ua;C++){color=da[C];h=C*3;M[h]=color.r;M[h+1]=color.g;M[h+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,q.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,M,A)}}F(objlist,W,0,t,j);t.__dirtyVertices=!1;t.__dirtyColors=!1}else if(j instanceof THREE.Line){if(!t.__webGLVertexBuffer){q=t;q.__webGLVertexBuffer=c.createBuffer();q.__webGLColorBuffer=c.createBuffer();q=t;A=q.vertices.length;q.__vertexArray=new Float32Array(A*3);q.__colorArray=
 new Float32Array(A*3);q.__webGLLineCount=A;t.__dirtyVertices=!0;t.__dirtyColors=!0}if(t.__dirtyVertices||t.__dirtyColors){q=t;A=c.DYNAMIC_DRAW;C=void 0;C=void 0;G=void 0;h=void 0;aa=q.vertices;da=q.colors;ka=aa.length;ua=da.length;fa=q.__vertexArray;M=q.__colorArray;ga=q.__dirtyColors;if(q.__dirtyVertices){for(C=0;C<ka;C++){G=aa[C].position;h=C*3;fa[h]=G.x;fa[h+1]=G.y;fa[h+2]=G.z}c.bindBuffer(c.ARRAY_BUFFER,q.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,fa,A)}if(ga){for(C=0;C<ua;C++){color=da[C];
 h=C*3;M[h]=color.r;M[h+1]=color.g;M[h+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,q.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,M,A)}}F(objlist,W,0,t,j);t.__dirtyVertices=!1;t.__dirtyColors=!1}else if(j instanceof THREE.ParticleSystem){if(!t.__webGLVertexBuffer){q=t;q.__webGLVertexBuffer=c.createBuffer();q.__webGLColorBuffer=c.createBuffer();q=t;A=q.vertices.length;q.__vertexArray=new Float32Array(A*3);q.__colorArray=new Float32Array(A*3);q.__sortArray=[];q.__webGLParticleCount=A;t.__dirtyVertices=
-!0;t.__dirtyColors=!0}(t.__dirtyVertices||t.__dirtyColors||j.sortParticles)&&b(t,c.DYNAMIC_DRAW,j,camera);F(objlist,W,0,t,j);t.__dirtyVertices=!1;t.__dirtyColors=!1}else if(j instanceof THREE.MarchingCubes){t=W;if(t[0]==undefined){h.__webGLObjectsImmediate.push({object:j,opaque:{list:[],count:0},transparent:{list:[],count:0}});t[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"?c.frontFace(c.CCW):c.frontFace(c.CW);if(f=="back")c.cullFace(c.BACK);else f=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
+!0;t.__dirtyColors=!0}(t.__dirtyVertices||t.__dirtyColors||j.sortParticles)&&b(t,c.DYNAMIC_DRAW,j,camera);F(objlist,W,0,t,j);t.__dirtyVertices=!1;t.__dirtyColors=!1}else if(j instanceof THREE.MarchingCubes){t=W;if(t[0]==undefined){h.__webGLObjectsImmediate.push({object:j,opaque:{list:[],count:0},transparent:{list:[],count:0}});t[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"?c.frontFace(c.CCW):c.frontFace(c.CW);if(f=="back")c.cullFace(c.BACK);else f=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.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",
@@ -260,7 +257,7 @@ map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D(
 lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
 lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
 lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse  = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse  += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse  = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse  += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
-color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 uBoneGlobalMatrices[20];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position  = ( uBoneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( uBoneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position  = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif"};
+color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[20];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position  = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position  = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif"};
 THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},light_map:{type:"t",value:2,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",
 value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
 THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}",vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f",

+ 10 - 13
build/ThreeExtras.js

@@ -43,13 +43,11 @@ THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n
 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};
-THREE.Quaternion.prototype.set=function(a,b,c,d){var f=this.that;f.x=a;f.y=b;f.z=c;f.w=d;this.isDirty=!0;return this};THREE.Quaternion.prototype.setFromEuler=function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,f=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-f);f=Math.sin(-f);var g=Math.cos(c);c=Math.sin(c);var h=a*b,k=d*f,j=this.that;j.w=h*g-k*c;j.x=h*c+k*g;j.y=d*b*g+a*f*c;j.z=a*f*g-d*b*c;this.isDirty=!0;return this};
-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,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.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};
+THREE.Quaternion.prototype.set=function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this};THREE.Quaternion.prototype.setFromEuler=function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,f=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-f);f=Math.sin(-f);var g=Math.cos(c);c=Math.sin(c);var h=a*b,k=d*f;this.w=h*g-k*c;this.x=h*c+k*g;this.y=d*b*g+a*f*c;this.z=a*f*g-d*b*c;return this};
+THREE.Quaternion.prototype.calculateW=function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this};THREE.Quaternion.prototype.inverse=function(){this.x*=-1;this.y*=-1;this.z*=-1;return this};THREE.Quaternion.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)};
+THREE.Quaternion.prototype.normalize=function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this};THREE.Quaternion.prototype.multiplySelf=function(a){var b=this.x,c=this.y,d=this.z,f=this.w,g=a.x,h=a.y,k=a.z;a=a.w;this.x=b*a+f*g+c*k-d*h;this.y=c*a+f*h+d*g-b*k;this.z=d*a+f*k+b*h-c*g;this.w=f*a-b*g-c*h-d*k;return this};
+THREE.Quaternion.prototype.multiplyVector3=function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,g=this.x,h=this.y,k=this.z,j=this.w,m=j*c+h*f-k*d,o=j*d+k*c-g*f,w=j*f+g*d-h*c;c=-g*c-h*d-k*f;b.x=m*j+c*-g+o*-k-w*-h;b.y=o*j+c*-h+w*-g-m*-k;b.z=w*j+c*-k+m*-h-o*-g;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+" )"}};
@@ -69,12 +67,11 @@ h=g.materials;k=a(h);m[k]==undefined&&(m[k]={hash:k,counter:0});j=m[k].hash+"_"+
 this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0;
 THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrixRotation=new THREE.Matrix4;this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale=
 1;this.visible=!0};THREE.Object3D.prototype.update=function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;b=!0}var d=this.children.length;for(a=0;a<d;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.updateMatrix=function(){this.localMatrix.setPosition(this.position);this.useQuaternion?this.localMatrix.setRotationFromQuaternion(this.quaternion):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.matrixAutoUpdate=!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.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.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!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=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.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.skinMatrix.multiply(a,this.localMatrix):this.skinMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!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];
@@ -201,7 +198,7 @@ THREE.MeshPhongMaterial){N.ambient.value.setRGB(p.ambient.r,p.ambient.g,p.ambien
 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(ca=0;ca<6;++ca)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ca,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,C.image[ca]);e.generateMipmap(e.TEXTURE_CUBE_MAP);e.bindTexture(e.TEXTURE_CUBE_MAP,null);C.image.__cubeMapInitialized=!0}e.activeTexture(e.TEXTURE0+z);e.bindTexture(e.TEXTURE_CUBE_MAP,
 C.image.__webGLTextureCube)}}else{if(!C.__webGLTexture&&C.image.loaded){C.__webGLTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,C.__webGLTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,C.image);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,q(C.wrap_s));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,q(C.wrap_t));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,q(C.mag_filter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,q(C.min_filter));e.generateMipmap(e.TEXTURE_2D);
 e.bindTexture(e.TEXTURE_2D,null)}e.activeTexture(e.TEXTURE0+z);e.bindTexture(e.TEXTURE_2D,C.__webGLTexture)}}}e.uniformMatrix4fv(H.modelViewMatrix,!1,n._modelViewMatrixArray);e.uniformMatrix3fv(H.normalMatrix,!1,n._normalMatrixArray);(p instanceof THREE.MeshShaderMaterial||p instanceof THREE.MeshPhongMaterial||p.env_map)&&e.uniform3f(H.cameraPosition,l.position.x,l.position.y,l.position.z);(p instanceof THREE.MeshShaderMaterial||p.env_map||p.skinning)&&e.uniformMatrix4fv(H.objectMatrix,!1,n._objectMatrixArray);
-(p instanceof THREE.MeshPhongMaterial||p instanceof THREE.MeshLambertMaterial||p instanceof THREE.MeshShaderMaterial||p.skinning)&&e.uniformMatrix4fv(H.viewMatrix,!1,ka);if(p.skinning){e.uniformMatrix4fv(H.cameraInverseMatrix,!1,W);e.uniformMatrix4fv(H.uBoneGlobalMatrices,!1,n.boneMatrices)}return B}function f(l,z,C,p,n,B){l=d(l,z,C,p,B).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);
+(p instanceof THREE.MeshPhongMaterial||p instanceof THREE.MeshLambertMaterial||p instanceof THREE.MeshShaderMaterial||p.skinning)&&e.uniformMatrix4fv(H.viewMatrix,!1,ka);if(p.skinning){e.uniformMatrix4fv(H.cameraInverseMatrix,!1,W);e.uniformMatrix4fv(H.boneGlobalMatrices,!1,n.boneMatrices)}return B}function f(l,z,C,p,n,B){l=d(l,z,C,p,B).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(B 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(B instanceof THREE.Line){B=B.type==THREE.LineStrip?
@@ -223,7 +220,7 @@ z){var C=new THREE.Color(l);e.clearColor(C.r,C.g,C.b,z)};this.setClearColor=func
 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,H,N,ca;n=N=ca=0;for(B=z.length;n<B;n++){H=z[n];H instanceof THREE.DirectionalLight&&N++;H instanceof THREE.PointLight&&ca++}if(ca+N<=4)z=N;else{z=Math.ceil(4*N/(ca+N));ca=4-z}n={directional:z,point:ca};ca=l.fragment_shader;z=l.vertex_shader;B={fog:C,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};C=e.createProgram();n=["#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(C,I("fragment",n+ca));e.attachShader(C,I("vertex",B+z));e.linkProgram(C);e.getProgramParameter(C,e.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+e.getProgramParameter(C,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");C.uniforms={};C.attributes={};l.program=C;C=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","uBoneGlobalMatrices"];for(p in l.uniforms)C.push(p);p=l.program;ca=0;for(z=C.length;ca<
+e.attachShader(C,I("fragment",n+ca));e.attachShader(C,I("vertex",B+z));e.linkProgram(C);e.getProgramParameter(C,e.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+e.getProgramParameter(C,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");C.uniforms={};C.attributes={};l.program=C;C=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(p in l.uniforms)C.push(p);p=l.program;ca=0;for(z=C.length;ca<
 z;ca++){n=C[ca];p.uniforms[n]=e.getUniformLocation(p,n)}p=l.program;C=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];ca=0;for(z=C.length;ca<z;ca++){n=C[ca];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,C,p){var n,B,H,N,ca,y,E,D,P=l.lights,T=l.fog;z.matrixAutoUpdate&&z.update();z.globalMatrix.flattenToArray(ka);z.projectionMatrix.flattenToArray(na);z.inverseMatrix.flattenToArray(W);U.multiply(z.projectionMatrix,z.globalMatrix);j(U);THREE.AnimationHandler&&THREE.AnimationHandler.update();
 l.update(undefined,!1,z);this.initWebGLObjects(l,z);v(C,p!==undefined?p:!0);this.autoClear&&this.clear();ca=l.__webGLObjects.length;for(p=0;p<ca;p++){n=l.__webGLObjects[p];E=n.object;if(E.visible)if(!(E instanceof THREE.Mesh)||m(E)){E.globalMatrix.flattenToArray(E._objectMatrixArray);A(E,z);u(n);n.render=!0;if(this.sortObjects){ia.copy(E.position);U.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<
@@ -260,7 +257,7 @@ map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D(
 lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
 lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
 lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse  = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse  += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse  = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse  += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
-color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 uBoneGlobalMatrices[20];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position  = ( uBoneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( uBoneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position  = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif"};
+color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[20];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position  = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position  = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif"};
 THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},light_map:{type:"t",value:2,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",
 value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
 THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}",vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f",

+ 15 - 13
src/animation/Animation.js

@@ -28,10 +28,10 @@ THREE.Animation = function( root, data ) {
 		for( var b = 0; b < this.root.bones.length; b++ )
 			this.hierarchy.push( this.root.bones[ b ] );
 
-	}
-	else {
+	} else {
 		
 		// parse hierarchy and match against animation (somehow)
+
 	}
 
 }
@@ -147,22 +147,21 @@ THREE.Animation.prototype.update = function( time ) {
 
 	}
 	
-	frame = Math.min( parseInt( currentTime * this.data.fps ), parseInt( this.data.length * this.data.fps ));
+	frame = Math.min( parseInt( currentTime * this.data.fps ), parseInt( this.data.length * this.data.fps ) );
 	
 	
 	// update
 	
-	for( var h = 0, hl = this.hierarchy.length; h < hl; h++ )
-	{
+	for( var h = 0, hl = this.hierarchy.length; h < hl; h++ ) {
+
 		object = this.hierarchy[ h ];
 	
 		if( JIThierarchy[ h ][ frame ] !== undefined ) {
 
-			object.skinMatrix           = JIThierarchy[ h ][ frame ];
-			object.matrixAutoUpdate     = false;
+			object.skinMatrix         = JIThierarchy[ h ][ frame ];
+			object.matrixAutoUpdate   = false;
 			object.matrixNeedsUpdate  = false;
-			
-			//object.skinMatrix.flattenToArray( this.root.boneMatrices[ h ] );
+
 			object.skinMatrix.flattenToArrayOffset( this.root.boneMatrices, h * 16 );
 			
 		}
@@ -177,7 +176,7 @@ THREE.Animation.prototype.update = function( time ) {
 				var nextKey = object.nextKey[ type ];
 				
 				// switch keys?
-							
+
 				if( nextKey.time < unloopedCurrentTime ) {
 		
 					// did we loop?
@@ -202,6 +201,7 @@ THREE.Animation.prototype.update = function( time ) {
 							
 							prevKey = nextKey;
 							nextKey = this.getNextKeyWith( type, h, nextKey.index + 1 );
+
 						}
 						while( nextKey.time < currentTime )
 					}
@@ -244,8 +244,11 @@ THREE.Animation.prototype.update = function( time ) {
 					vector.z = prevXYZ[ 2 ] + ( nextXYZ[ 2 ] - prevXYZ[ 2 ] ) * scale;
 
 				}
-			}	
+
+			}
+
 		}
+
 	}
 	
 	
@@ -272,8 +275,7 @@ THREE.Animation.prototype.updateObject = function( h, currentTime, unloopedCurre
 	
 
 }
-		
-		
+
 
 
 THREE.Animation.prototype.getNextKeyWith = function( type, h, key ) {

+ 2 - 1
src/animation/AnimationHandler.js

@@ -67,10 +67,11 @@ THREE.AnimationHandler = (function() {
 				// create quaternions
 			
 				if( data.hierarchy[ h ].keys[ k ].rot !== undefined &&
-				  !(data.hierarchy[ h ].keys[ k ].rot instanceof THREE.Quaternion )) {
+				  !( data.hierarchy[ h ].keys[ k ].rot instanceof THREE.Quaternion ) ) {
 					
 					var quat = data.hierarchy[ h ].keys[ k ].rot;
 					data.hierarchy[ h ].keys[ k ].rot = new THREE.Quaternion( quat[0], quat[1], quat[2], quat[3] ); 
+
 				}	
 			}
 		}

+ 41 - 89
src/core/Quaternion.js

@@ -2,46 +2,23 @@
  * @author mikael emtinger / http://gomo.se/
  */
 
-THREE.Quaternion = function( _x, _y, _z, _w ) {
+THREE.Quaternion = function( x, y, z, w ) {
 
-	this.x = _x || 0;
-	this.y = _y || 0;
-	this.z = _z || 0;
-	this.w = _w !== undefined ? _w : 1;
-
-	this.api = {
-	
-		isDirty:	false,
-		that: 		this,
-
-		get x() { return this.that.x; },
-		get y() { return this.that.y; },
-		get z() { return this.that.z; },
-		get w() { return this.that.w; },
-		
-		set x( value ) { this.that.x = value; this.isDirty = true; },
-		set y( value ) { this.that.y = value; this.isDirty = true; },
-		set z( value ) { this.that.z = value; this.isDirty = true; },
-		set w( value ) { this.that.w = value; this.isDirty = true; }
-
-	};
-
-	this.api.__proto__ = THREE.Quaternion.prototype;
-	
-	return this.api;
+	this.x = x || 0;
+	this.y = y || 0;
+	this.z = z || 0;
+	this.w = w !== undefined ? w : 1;
 	
 };
 
 
 THREE.Quaternion.prototype.set = function( x, y, z, w ) {
 	
-	var quat = this.that; 
-	quat.x = x;
-	quat.y = y;
-	quat.z = z;
-	quat.w = w;
+	this.x = x;
+	this.y = y;
+	this.z = z;
+	this.w = w;
 
-	this.isDirty = true;
 	return this;
 
 };
@@ -61,88 +38,67 @@ THREE.Quaternion.prototype.setFromEuler = function( vec3 ) {
 		c3 = Math.cos( x  ),
 		s3 = Math.sin( x  ),
 		c1c2 = c1 * c2,
-		s1s2 = s1 * s2,
-    
-		quat = this.that;
+		s1s2 = s1 * s2;
 	
-	quat.w = c1c2 * c3  - s1s2 * s3;
-  	quat.x = c1c2 * s3  + s1s2 * c3;
-	quat.y = s1 * c2 * c3 + c1 * s2 * s3;
-	quat.z = c1 * s2 * c3 - s1 * c2 * s3;
+	this.w = c1c2 * c3  - s1s2 * s3;
+  	this.x = c1c2 * s3  + s1s2 * c3;
+	this.y = s1 * c2 * c3 + c1 * s2 * s3;
+	this.z = c1 * s2 * c3 - s1 * c2 * s3;
 
-	this.isDirty = true;
 	return this;
 
 };
 
 
-THREE.Quaternion.prototype.calculateW = function() {
-	
-	var quat = this.that,
-		x    = quat.x,
-		y    = quat.y,
-		z    = quat.z;
+THREE.Quaternion.prototype.calculateW = function() {	
 
-	quat.w = -Math.sqrt( Math.abs( 1.0 - x*x - y*y - z*z ));
+	this.w = -Math.sqrt( Math.abs( 1.0 - this.x * this.x - this.y * this.y - this.z * this.z ) );
 
-	this.isDirty = true;
 	return this;
 
 };
 
 
 THREE.Quaternion.prototype.inverse = function() {
-	
-	var quat = this.that; 
-	quat.x *= -1;
-	quat.y *= -1;
-	quat.z *= -1;
 
-	this.isDirty = true;
+	this.x *= -1;
+	this.y *= -1;
+	this.z *= -1;
+
 	return this;
 
 };
 
 
 THREE.Quaternion.prototype.length = function() {
-	
-	var quat = this.that; 
 
-	return Math.sqrt( quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w );
+	return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );
 
 };
 
 
 THREE.Quaternion.prototype.normalize = function() {
 	
-	var quat = this.that,
-		x = quat.x,
-		y = quat.y,
-		z = quat.z,
-		w = quat.w;
-	
-	var len = Math.sqrt( x*x + y*y + z*z + w*w );
+	var len = Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );
 	
 	if ( len == 0 ) {
 		
-		quat.x = 0;
-		quat.y = 0;
-		quat.z = 0;
-		quat.w = 0;
+		this.x = 0;
+		this.y = 0;
+		this.z = 0;
+		this.w = 0;
 	
-		this.isDirty = true;
-		return this;
+	} else {
 	
+		len = 1 / len;
+		
+		this.x = this.x * len;
+		this.y = this.y * len;
+		this.z = this.z * len;
+		this.w = this.w * len;
+		
 	}
 	
-	len = 1 / len;
-	
-	quat.x = x * len;
-	quat.y = y * len;
-	quat.z = z * len;
-	quat.w = w * len;
-	
-	this.isDirty = true;
 	return this;
 
 };
@@ -150,17 +106,14 @@ THREE.Quaternion.prototype.normalize = function() {
 
 THREE.Quaternion.prototype.multiplySelf = function( quat2 ) {
 	
-	var quat = this.that;
-
-		qax = quat.x,  qay = quat.y,  qaz = quat.z,  qaw = quat.w,
+	var qax = this.x,  qay = this.y,  qaz = this.z,  qaw = this.w,
 		qbx = quat2.x, qby = quat2.y, qbz = quat2.z, qbw = quat2.w;
 	
-	quat.x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
-	quat.y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
-	quat.z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
-	quat.w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
+	this.x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
+	this.y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
+	this.z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
+	this.w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
 
-	this.isDirty = true;
 	return this;
 
 };
@@ -170,9 +123,8 @@ THREE.Quaternion.prototype.multiplyVector3 = function( vec, dest ) {
 	
 	if( !dest ) { dest = vec; }
 	
-	var quat = this.that,
-		x    = vec.x,  y  = vec.y,  z  = vec.z,
-		qx   = quat.x, qy = quat.y, qz = quat.z, qw = quat.w;
+	var x    = vec.x,  y  = vec.y,  z  = vec.z,
+		qx   = this.x, qy = this.y, qz = this.z, qw = this.w;
 
 	// calculate quat * vec
 	

+ 0 - 39
src/objects/Mesh.js

@@ -33,44 +33,5 @@ THREE.Mesh.prototype             = new THREE.Object3D();
 THREE.Mesh.prototype.constructor = THREE.Mesh;
 THREE.Mesh.prototype.supr        = THREE.Object3D.prototype;
 
-/*
- * Update
- */
-
-THREE.Mesh.prototype.update = function( parentGlobalMatrix, forceUpdate, camera ) {
-	
-	// visible?
-	
-	if( this.visible ) {
-
-		// update local
-		
-		if( this.matrixAutoUpdate )
-			forceUpdate |= this.updateMatrix();
-
-
-		// update global
-
-		if( forceUpdate || this.matrixNeedsUpdate ) {
-			
-			if( parentGlobalMatrix )
-				this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix );
-			else
-				this.globalMatrix.copy( this.localMatrix );
-			
-			this.matrixNeedsUpdate = false;
-			forceUpdate               = true;			
-
-		}
-
-
-		// update children
-	
-		for( var i = 0; i < this.children.length; i++ )
-			this.children[ i ].update( this.globalMatrix, forceUpdate, camera );
-
-	}
-
-}
 
 

+ 8 - 8
src/objects/Object3D.js

@@ -54,11 +54,16 @@ THREE.Object3D.prototype.update = function( parentGlobalMatrix, forceUpdate, cam
 
 		if( forceUpdate || this.matrixNeedsUpdate ) {
 
-			if( parentGlobalMatrix )
+			if( parentGlobalMatrix ) {
+				
 				this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix );
-			else
+
+			} else {
+
 				this.globalMatrix.copy( this.localMatrix );
 
+			}
+
 			this.matrixNeedsUpdate = false;
 			forceUpdate              = true;
 
@@ -94,12 +99,7 @@ THREE.Object3D.prototype.updateMatrix = function() {
 
 	if( this.useQuaternion )  {
 
-		if( this.quaternion.isDirty ) {
-
-			this.localMatrix.setRotationFromQuaternion( this.quaternion );
-			this.quaternion.isDirty = false;
-
-		}
+		this.localMatrix.setRotationFromQuaternion( this.quaternion );
 
 	// update rotation
 

+ 6 - 16
src/renderers/WebGLRenderer.js

@@ -1353,8 +1353,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 		material.program = buildProgram( material.fragment_shader, material.vertex_shader, parameters );
 
 		identifiers = [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition',
-						'cameraInverseMatrix', 'uBoneGlobalMatrices'
+						'cameraInverseMatrix', 'boneGlobalMatrices'
 						];
+
 		for( u in material.uniforms ) {
 
 			identifiers.push(u);
@@ -2471,18 +2472,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 	function loadUniformsSkinning( uniforms, object ) {
 
 		_gl.uniformMatrix4fv( uniforms.cameraInverseMatrix, false, _cameraInverseMatrixArray );
-
-		/*
-		var i, l = object.boneMatrices.length;
-
-		for( i = 0; i < l; i++ ) {
-
-			//_gl.uniformMatrix4fv( uniforms[ "uBoneGlobalMatrices[" + i + "]" ], false, object.boneMatrices[ i ]() );
-			_gl.uniformMatrix4fv( uniforms[ "uBoneGlobalMatrices[" + i + "]" ], false, object.boneMatrices[ i ] );
-
-		}
-		*/
-		_gl.uniformMatrix4fv( uniforms[ "uBoneGlobalMatrices" ], false, object.boneMatrices );
+		_gl.uniformMatrix4fv( uniforms.boneGlobalMatrices, false, object.boneMatrices );
 
 	};
 
@@ -3372,7 +3362,7 @@ THREE.Snippets = {
 
 	"#ifdef USE_SKINNING",
 
-		"uniform mat4 uBoneGlobalMatrices[20];",
+		"uniform mat4 boneGlobalMatrices[20];",
 
 	"#endif"
 
@@ -3382,8 +3372,8 @@ THREE.Snippets = {
 
 	"#ifdef USE_SKINNING",
 
-		"gl_Position  = ( uBoneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;",
-		"gl_Position += ( uBoneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;",
+		"gl_Position  = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;",
+		"gl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;",
 
 		// this doesn't work, no idea why
 		//"gl_Position  = projectionMatrix * cameraInverseMatrix * objectMatrix * gl_Position;",