Browse Source

Removed `__styleString` and `updateStyleString` out of THREE.Color.
Using * ( 1 / scale ) instead of / scale in JSONLoader.

Mr.doob 14 years ago
parent
commit
e87caabbf8

File diff suppressed because it is too large
+ 90 - 89
build/Three.js


+ 75 - 76
build/custom/ThreeCanvas.js

@@ -1,8 +1,7 @@
 // ThreeCanvas.js r40 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}THREE.Color=function(a){this.setHex(a)};
-THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var d,e,h,f,k,g;if(c==0)d=e=h=0;else{f=Math.floor(a*6);k=a*6-f;a=c*(1-b);g=c*(1-b*k);b=c*(1-b*(1-k));switch(f){case 1:d=g;e=c;h=a;break;case 2:d=a;e=c;h=b;break;case 3:d=a;e=g;h=c;break;case 4:d=b;e=a;h=c;break;case 5:d=c;e=a;
-h=g;break;case 6:case 0:d=c;e=b;h=a}}this.r=d;this.g=e;this.b=h;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB: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)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)};
+THREE.Color.prototype={copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex},setHex:function(a){this.hex=~~a&16777215;this.updateRGB()},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;this.updateHex()},setHSV:function(a,b,c){var d,e,g,f,i,h;if(c==0)d=e=g=0;else{f=Math.floor(a*6);i=a*6-f;a=c*(1-b);h=c*(1-b*i);b=c*(1-b*(1-i));switch(f){case 1:d=h;e=c;g=a;break;case 2:d=a;e=c;g=b;break;case 3:d=a;e=h;g=c;break;case 4:d=b;e=a;g=c;break;case 5:d=c;e=a;g=h;break;case 6:case 0:d=c;e=b;g=a}}this.setRGB(d,
+e,g)},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)};
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
 this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)};
 THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
@@ -12,59 +11,59 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPosit
 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)};
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
 a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(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)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(h,f){return h.distance-f.distance});return e},intersectObject:function(a){function b(D,z,T,U){U=U.clone().subSelf(z);T=T.clone().subSelf(z);var X=D.clone().subSelf(z);D=U.dot(U);z=U.dot(T);U=U.dot(X);var s=T.dot(T);T=T.dot(X);X=1/(D*s-z*z);s=(s*U-z*T)*X;D=(D*T-z*U)*X;return s>0&&D>0&&s+D<1}var c,d,e,h,f,k,g,i,n,j,
-p,r=a.geometry,y=r.vertices,A=[];c=0;for(d=r.faces.length;c<d;c++){e=r.faces[c];j=this.origin.clone();p=this.direction.clone();g=a.matrixWorld;h=g.multiplyVector3(y[e.a].position.clone());f=g.multiplyVector3(y[e.b].position.clone());k=g.multiplyVector3(y[e.c].position.clone());g=e instanceof THREE.Face4?g.multiplyVector3(y[e.d].position.clone()):null;i=a.matrixRotationWorld.multiplyVector3(e.normal.clone());n=p.dot(i);if(a.doubleSided||(a.flipSided?n>0:n<0)){i=i.dot((new THREE.Vector3).sub(h,j))/
-n;j=j.addSelf(p.multiplyScalar(i));if(e instanceof THREE.Face3){if(b(j,h,f,k)){e={distance:this.origin.distanceTo(j),point:j,face:e,object:a};A.push(e)}}else if(e instanceof THREE.Face4&&(b(j,h,f,g)||b(j,f,k,g))){e={distance:this.origin.distanceTo(j),point:j,face:e,object:a};A.push(e)}}}return A}};
-THREE.Rectangle=function(){function a(){h=d-b;f=e-c}var b,c,d,e,h,f,k=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,i,n,j){k=!1;b=g;c=i;d=n;e=j;a()};this.addPoint=function(g,i){if(k){k=!1;b=g;c=i;d=g;e=i}else{b=b<g?b:g;c=c<i?c:i;d=d>g?d:g;e=e>i?e:i}a()};
-this.add3Points=function(g,i,n,j,p,r){if(k){k=!1;b=g<n?g<p?g:p:n<p?n:p;c=i<j?i<r?i:r:j<r?j:r;d=g>n?g>p?g:p:n>p?n:p;e=i>j?i>r?i:r:j>r?j:r}else{b=g<n?g<p?g<b?g:b:p<b?p:b:n<p?n<b?n:b:p<b?p:b;c=i<j?i<r?i<c?i:c:r<c?r:c:j<r?j<c?j:c:r<c?r:c;d=g>n?g>p?g>d?g:d:p>d?p:d:n>p?n>d?n:d:p>d?p:d;e=i>j?i>r?i>e?i:e:r>e?r:e:j>r?j>e?j:e:r>e?r:e}a()};this.addRectangle=function(g){if(k){k=!1;b=g.getLeft();c=g.getTop();d=g.getRight();e=g.getBottom()}else{b=b<g.getLeft()?b:g.getLeft();c=c<g.getTop()?c:g.getTop();d=d>g.getRight()?
-d:g.getRight();e=e>g.getBottom()?e:g.getBottom()}a()};this.inflate=function(g){b-=g;c-=g;d+=g;e+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d<g.getRight()?d:g.getRight();e=e<g.getBottom()?e:g.getBottom();a()};this.instersects=function(g){return Math.min(d,g.getRight())-Math.max(b,g.getLeft())>=0&&Math.min(e,g.getBottom())-Math.max(c,g.getTop())>=0};this.empty=function(){k=!0;e=d=c=b=0;a()};this.isEmpty=function(){return k}};
+THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(g,f){return g.distance-f.distance});return e},intersectObject:function(a){function b(D,x,W,X){X=X.clone().subSelf(x);W=W.clone().subSelf(x);var aa=D.clone().subSelf(x);D=X.dot(X);x=X.dot(W);X=X.dot(aa);var H=W.dot(W);W=W.dot(aa);aa=1/(D*H-x*x);H=(H*X-x*W)*aa;D=(D*W-x*X)*aa;return H>0&&D>0&&H+D<1}var c,d,e,g,f,i,h,
+j,p,n,o,k=a.geometry,t=k.vertices,w=[];c=0;for(d=k.faces.length;c<d;c++){e=k.faces[c];n=this.origin.clone();o=this.direction.clone();h=a.matrixWorld;g=h.multiplyVector3(t[e.a].position.clone());f=h.multiplyVector3(t[e.b].position.clone());i=h.multiplyVector3(t[e.c].position.clone());h=e instanceof THREE.Face4?h.multiplyVector3(t[e.d].position.clone()):null;j=a.matrixRotationWorld.multiplyVector3(e.normal.clone());p=o.dot(j);if(a.doubleSided||(a.flipSided?p>0:p<0)){j=j.dot((new THREE.Vector3).sub(g,
+n))/p;n=n.addSelf(o.multiplyScalar(j));if(e instanceof THREE.Face3){if(b(n,g,f,i)){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};w.push(e)}}else if(e instanceof THREE.Face4&&(b(n,g,f,h)||b(n,f,i,h))){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};w.push(e)}}}return w}};
+THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(h,j,p,n){i=!1;b=h;c=j;d=p;e=n;a()};this.addPoint=function(h,j){if(i){i=!1;b=h;c=j;d=h;e=j}else{b=b<h?b:h;c=c<j?c:j;d=d>h?d:h;e=e>j?e:j}a()};
+this.add3Points=function(h,j,p,n,o,k){if(i){i=!1;b=h<p?h<o?h:o:p<o?p:o;c=j<n?j<k?j:k:n<k?n:k;d=h>p?h>o?h:o:p>o?p:o;e=j>n?j>k?j:k:n>k?n:k}else{b=h<p?h<o?h<b?h:b:o<b?o:b:p<o?p<b?p:b:o<b?o:b;c=j<n?j<k?j<c?j:c:k<c?k:c:n<k?n<c?n:c:k<c?k:c;d=h>p?h>o?h>d?h:d:o>d?o:d:p>o?p>d?p:d:o>d?o:d;e=j>n?j>k?j>e?j:e:k>e?k:e:n>k?n>e?n:e:k>e?k:e}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();d=d>h.getRight()?
+d:h.getRight();e=e>h.getBottom()?e:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;d+=h;e+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();d=d<h.getRight()?d:h.getRight();e=e<h.getBottom()?e:h.getBottom();a()};this.instersects=function(h){return Math.min(d,h.getRight())-Math.max(b,h.getLeft())>=0&&Math.min(e,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){i=!0;e=d=c=b=0;a()};this.isEmpty=function(){return i}};
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
-THREE.Matrix4=function(a,b,c,d,e,h,f,k,g,i,n,j,p,r,y,A){this.set(a||1,b||0,c||0,d||0,e||0,h||1,f||0,k||0,g||0,i||0,n||1,j||0,p||0,r||0,y||0,A||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(a,b,c,d,e,h,f,k,g,i,n,j,p,r,y,A){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=h;this.n23=f;this.n24=k;this.n31=g;this.n32=i;this.n33=n;this.n34=j;this.n41=p;this.n42=r;this.n43=y;this.n44=A;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__v1,
-e=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,b).normalize();if(h.length()===0)h.z=1;d.cross(c,h).normalize();if(d.length()===0){h.x+=1.0E-4;d.cross(c,h).normalize()}e.cross(h,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=h.x;this.n21=d.y;this.n22=e.y;this.n23=h.y;this.n31=d.z;this.n32=e.z;this.n33=h.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*
+THREE.Matrix4=function(a,b,c,d,e,g,f,i,h,j,p,n,o,k,t,w){this.set(a||1,b||0,c||0,d||0,e||0,g||1,f||0,i||0,h||0,j||0,p||1,n||0,o||0,k||0,t||0,w||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,c,d,e,g,f,i,h,j,p,n,o,k,t,w){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=f;this.n24=i;this.n31=h;this.n32=j;this.n33=p;this.n34=n;this.n41=o;this.n42=k;this.n43=t;this.n44=w;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__v1,
+e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;d.cross(c,g).normalize();if(d.length()===0){g.x+=1.0E-4;d.cross(c,g).normalize()}e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*
 d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();
-return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,h=a.n14,f=a.n21,k=a.n22,g=a.n23,i=a.n24,n=a.n31,j=a.n32,p=a.n33,r=a.n34,y=a.n41,A=a.n42,D=a.n43,z=a.n44,T=b.n11,U=b.n12,X=b.n13,s=b.n14,o=b.n21,L=b.n22,
-R=b.n23,aa=b.n24,ba=b.n31,w=b.n32,u=b.n33,H=b.n34;this.n11=c*T+d*o+e*ba;this.n12=c*U+d*L+e*w;this.n13=c*X+d*R+e*u;this.n14=c*s+d*aa+e*H+h;this.n21=f*T+k*o+g*ba;this.n22=f*U+k*L+g*w;this.n23=f*X+k*R+g*u;this.n24=f*s+k*aa+g*H+i;this.n31=n*T+j*o+p*ba;this.n32=n*U+j*L+p*w;this.n33=n*X+j*R+p*u;this.n34=n*s+j*aa+p*H+r;this.n41=y*T+A*o+D*ba;this.n42=y*U+A*L+D*w;this.n43=y*X+A*R+D*u;this.n44=y*s+A*aa+D*H+z;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;
+return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,i=a.n22,h=a.n23,j=a.n24,p=a.n31,n=a.n32,o=a.n33,k=a.n34,t=a.n41,w=a.n42,D=a.n43,x=a.n44,W=b.n11,X=b.n12,aa=b.n13,H=b.n14,q=b.n21,B=b.n22,
+z=b.n23,L=b.n24,Y=b.n31,C=b.n32,A=b.n33,I=b.n34;this.n11=c*W+d*q+e*Y;this.n12=c*X+d*B+e*C;this.n13=c*aa+d*z+e*A;this.n14=c*H+d*L+e*I+g;this.n21=f*W+i*q+h*Y;this.n22=f*X+i*B+h*C;this.n23=f*aa+i*z+h*A;this.n24=f*H+i*L+h*I+j;this.n31=p*W+n*q+o*Y;this.n32=p*X+n*B+o*C;this.n33=p*aa+n*z+o*A;this.n34=p*H+n*L+o*I+k;this.n41=t*W+w*q+D*Y;this.n42=t*X+w*B+D*C;this.n43=t*aa+w*z+D*A;this.n44=t*H+w*L+D*I+x;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;
 c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=
-this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,h=this.n22,f=this.n23,k=this.n24,g=this.n31,i=this.n32,n=this.n33,j=this.n34,p=this.n41,r=this.n42,y=this.n43,A=this.n44;return d*f*i*p-c*k*i*p-d*h*n*p+b*k*n*p+c*h*j*p-b*f*j*p-d*f*g*r+c*k*g*r+d*e*n*r-a*k*n*r-c*e*j*r+a*f*j*r+d*h*g*y-b*k*g*y-d*e*i*y+a*k*i*y+b*e*j*y-a*h*j*y-c*h*g*A+b*f*g*A+c*e*i*A-a*f*i*A-b*e*n*A+a*h*n*A},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=
+this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,g=this.n22,f=this.n23,i=this.n24,h=this.n31,j=this.n32,p=this.n33,n=this.n34,o=this.n41,k=this.n42,t=this.n43,w=this.n44;return d*f*j*o-c*i*j*o-d*g*p*o+b*i*p*o+c*g*n*o-b*f*n*o-d*f*h*k+c*i*h*k+d*e*p*k-a*i*p*k-c*e*n*k+a*f*n*k+d*g*h*t-b*i*h*t-d*e*j*t+a*i*j*t+b*e*n*t-a*g*n*t-c*g*h*w+b*f*h*w+c*e*j*w-a*f*j*w-b*e*p*w+a*g*p*w},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=
 this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flat[0]=this.n11;this.flat[1]=this.n21;
 this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=
 this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,
-b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX: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},setRotationY: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},setRotationZ: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},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,h=a.x,f=a.y,k=a.z,g=e*h,i=e*f;this.set(g*
-h+c,g*f-d*k,g*k+d*f,0,g*f+d*k,i*f+c,i*k-d*h,0,g*k-d*f,i*k+d*h,e*k*k+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX=new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;
-this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var h=Math.cos(d);d=Math.sin(d);var f=a*c,k=b*c;this.n11=e*h;this.n12=-e*d;this.n13=c;this.n21=k*h+a*d;this.n22=-k*d+a*h;this.n23=-b*e;this.n31=-f*h+b*d;this.n32=f*d+b*h;this.n33=a*e;return this},
-setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,h=b+b,f=c+c,k=d+d;a=b*h;var g=b*f;b*=k;var i=c*f;c*=k;d*=k;h*=e;f*=e;e*=k;this.n11=1-(i+d);this.n12=g-e;this.n13=b+f;this.n21=g+e;this.n22=1-(a+d);this.n23=c-h;this.n31=b-f;this.n32=c+h;this.n33=1-(a+i);return this},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=
+b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX: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},setRotationY: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},setRotationZ: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},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,g=a.x,f=a.y,i=a.z,h=e*g,j=e*f;this.set(h*
+g+c,h*f-d*i,h*i+d*f,0,h*f+d*i,j*f+c,j*i-d*g,0,h*i-d*f,j*i+d*g,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX=new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;
+this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var f=a*c,i=b*c;this.n11=e*g;this.n12=-e*d;this.n13=c;this.n21=i*g+a*d;this.n22=-i*d+a*g;this.n23=-b*e;this.n31=-f*g+b*d;this.n32=f*d+b*g;this.n33=a*e;return this},
+setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,g=b+b,f=c+c,i=d+d;a=b*g;var h=b*f;b*=i;var j=c*f;c*=i;d*=i;g*=e;f*=e;e*=i;this.n11=1-(j+d);this.n12=h-e;this.n13=b+f;this.n21=h+e;this.n22=1-(a+d);this.n23=c-g;this.n31=b-f;this.n32=c+g;this.n33=1-(a+j);return this},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=
 a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/b.y,e=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,h=a.n14,f=a.n21,k=a.n22,g=a.n23,i=a.n24,n=a.n31,j=a.n32,p=a.n33,r=a.n34,y=a.n41,A=a.n42,D=a.n43,z=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=g*r*A-i*p*A+i*j*D-k*r*D-g*j*z+k*p*z;b.n12=h*p*A-e*r*A-h*j*D+d*r*D+e*j*z-d*p*z;b.n13=e*i*A-h*g*A+h*k*D-d*i*D-e*k*z+d*g*z;b.n14=h*g*j-e*i*j-h*k*p+d*i*p+e*k*r-d*g*r;b.n21=i*p*y-g*r*y-i*n*D+f*r*D+g*n*z-f*p*z;b.n22=e*r*y-h*p*y+h*n*D-c*r*D-e*n*z+c*p*z;b.n23=h*g*y-e*i*y-h*f*D+c*i*D+e*f*z-c*g*z;
-b.n24=e*i*n-h*g*n+h*f*p-c*i*p-e*f*r+c*g*r;b.n31=k*r*y-i*j*y+i*n*A-f*r*A-k*n*z+f*j*z;b.n32=h*j*y-d*r*y-h*n*A+c*r*A+d*n*z-c*j*z;b.n33=e*i*y-h*k*y+h*f*A-c*i*A-d*f*z+c*k*z;b.n34=h*k*n-d*i*n-h*f*j+c*i*j+d*f*r-c*k*r;b.n41=g*j*y-k*p*y-g*n*A+f*p*A+k*n*D-f*j*D;b.n42=d*p*y-e*j*y+e*n*A-c*p*A-d*n*D+c*j*D;b.n43=e*k*y-d*g*y-e*f*A+c*g*A+d*f*D-c*k*D;b.n44=d*g*n-e*k*n+e*f*j-c*g*j-d*f*p+c*k*p;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,e=-a.n33*a.n21+a.n31*a.n23,h=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,g=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,j=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*f+a.n31*i;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*h;c[3]=a*f;c[4]=a*k;c[5]=a*g;c[6]=a*i;c[7]=a*n;c[8]=a*j;return b};
-THREE.Matrix4.makeFrustum=function(a,b,c,d,e,h){var f;f=new THREE.Matrix4;f.n11=2*e/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*e/(d-c);f.n23=(d+c)/(d-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(h+e)/(h-e);f.n34=-2*h*e/(h-e);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
-THREE.Matrix4.makeOrtho=function(a,b,c,d,e,h){var f,k,g,i;f=new THREE.Matrix4;k=b-a;g=c-d;i=h-e;f.n11=2/k;f.n12=0;f.n13=0;f.n14=-((b+a)/k);f.n21=0;f.n22=2/g;f.n23=0;f.n24=-((c+d)/g);f.n31=0;f.n32=0;f.n33=-2/i;f.n34=-((h+e)/i);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,i=a.n22,h=a.n23,j=a.n24,p=a.n31,n=a.n32,o=a.n33,k=a.n34,t=a.n41,w=a.n42,D=a.n43,x=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*k*w-j*o*w+j*n*D-i*k*D-h*n*x+i*o*x;b.n12=g*o*w-e*k*w-g*n*D+d*k*D+e*n*x-d*o*x;b.n13=e*j*w-g*h*w+g*i*D-d*j*D-e*i*x+d*h*x;b.n14=g*h*n-e*j*n-g*i*o+d*j*o+e*i*k-d*h*k;b.n21=j*o*t-h*k*t-j*p*D+f*k*D+h*p*x-f*o*x;b.n22=e*k*t-g*o*t+g*p*D-c*k*D-e*p*x+c*o*x;b.n23=g*h*t-e*j*t-g*f*D+c*j*D+e*f*x-c*h*x;
+b.n24=e*j*p-g*h*p+g*f*o-c*j*o-e*f*k+c*h*k;b.n31=i*k*t-j*n*t+j*p*w-f*k*w-i*p*x+f*n*x;b.n32=g*n*t-d*k*t-g*p*w+c*k*w+d*p*x-c*n*x;b.n33=e*j*t-g*i*t+g*f*w-c*j*w-d*f*x+c*i*x;b.n34=g*i*p-d*j*p-g*f*n+c*j*n+d*f*k-c*i*k;b.n41=h*n*t-i*o*t-h*p*w+f*o*w+i*p*D-f*n*D;b.n42=d*o*t-e*n*t+e*p*w-c*o*w-d*p*D+c*n*D;b.n43=e*i*t-d*h*t-e*f*w+c*h*w+d*f*D-c*i*D;b.n44=d*h*p-e*i*p+e*f*n-c*h*n-d*f*o+c*i*o;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,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,j=a.n23*a.n12-a.n22*a.n13,p=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*f+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*f;c[4]=a*i;c[5]=a*h;c[6]=a*j;c[7]=a*p;c[8]=a*n;return b};
+THREE.Matrix4.makeFrustum=function(a,b,c,d,e,g){var f;f=new THREE.Matrix4;f.n11=2*e/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*e/(d-c);f.n23=(d+c)/(d-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(g+e)/(g-e);f.n34=-2*g*e/(g-e);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
+THREE.Matrix4.makeOrtho=function(a,b,c,d,e,g){var f,i,h,j;f=new THREE.Matrix4;i=b-a;h=c-d;j=g-e;f.n11=2/i;f.n12=0;f.n13=0;f.n14=-((b+a)/i);f.n21=0;f.n22=2/h;f.n23=0;f.n24=-((c+d)/h);f.n31=0;f.n32=0;f.n33=-2/j;f.n34=-((g+e)/j);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
 THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=
 !0;this._vector=new THREE.Vector3;this.name=""};
 THREE.Object3D.prototype={translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===
 -1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==undefined;)b=b.parent;b!==undefined&&b instanceof THREE.Scene&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},getChildByName:function(a,b){var c,d,e;c=0;for(d=this.children.length;c<d;c++){e=this.children[c];if(e.name===a)return e;if(b){e=e.getChildByName(a,b);if(e!==undefined)return e}}},updateMatrix:function(){this.matrix.setPosition(this.position);
 this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||b){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);
 this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;b=!0}a=0;for(var d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,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},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-e);e=Math.sin(-e);var h=Math.cos(c);c=Math.sin(c);var f=a*b,k=d*e;this.w=f*h-k*c;this.x=f*c+k*h;this.y=d*b*h+a*e*c;this.z=a*e*h-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=
+THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-e);e=Math.sin(-e);var g=Math.cos(c);c=Math.sin(c);var f=a*b,i=d*e;this.w=f*g-i*c;this.x=f*c+i*g;this.y=d*b*g+a*e*c;this.z=a*e*g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=
 a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},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},
-multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,h=a.x,f=a.y,k=a.z;a=a.w;this.x=b*a+e*h+c*k-d*f;this.y=c*a+e*f+d*h-b*k;this.z=d*a+e*k+b*f-c*h;this.w=e*a-b*h-c*f-d*k;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,h=this.x,f=this.y,k=this.z,g=this.w,i=g*c+f*e-k*d,n=
-g*d+k*c-h*e,j=g*e+h*d-f*c;c=-h*c-f*d-k*e;b.x=i*g+c*-h+n*-k-j*-f;b.y=n*g+c*-f+j*-h-i*-k;b.z=j*g+c*-k+i*-f-n*-h;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<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}e=Math.sin((1-d)*h)/f;d=Math.sin(d*h)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
-THREE.Face3=function(a,b,c,d,e,h){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};
-THREE.Face4=function(a,b,c,d,e,h,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
+multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,i=a.z;a=a.w;this.x=b*a+e*g+c*i-d*f;this.y=c*a+e*f+d*g-b*i;this.z=d*a+e*i+b*f-c*g;this.w=e*a-b*g-c*f-d*i;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,i=this.z,h=this.w,j=h*c+f*e-i*d,p=
+h*d+i*c-g*e,n=h*e+g*d-f*c;c=-g*c-f*d-i*e;b.x=j*h+c*-g+p*-i-n*-f;b.y=p*h+c*-f+n*-g-j*-i;b.z=n*h+c*-i+j*-f-p*-g;return b}};
+THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.001){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}e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
+THREE.Face4=function(a,b,c,d,e,g,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);
-c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,e,h,f,k=new THREE.Vector3,g=new THREE.Vector3;d=0;for(e=this.faces.length;d<e;d++){h=this.faces[d];if(a&&h.vertexNormals.length){k.set(0,0,0);b=0;for(c=h.vertexNormals.length;b<c;b++)k.addSelf(h.vertexNormals[b]);k.divideScalar(3)}else{b=this.vertices[h.a];c=this.vertices[h.b];f=this.vertices[h.c];k.sub(f.position,c.position);g.sub(b.position,c.position);k.crossSelf(g)}k.isZero()||
-k.normalize();h.normal.copy(k)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=
+c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,e,g,f,i=new THREE.Vector3,h=new THREE.Vector3;d=0;for(e=this.faces.length;d<e;d++){g=this.faces[d];if(a&&g.vertexNormals.length){i.set(0,0,0);b=0;for(c=g.vertexNormals.length;b<c;b++)i.addSelf(g.vertexNormals[b]);i.divideScalar(3)}else{b=this.vertices[g.a];c=this.vertices[g.b];f=this.vertices[g.c];i.sub(f.position,c.position);h.sub(b.position,c.position);i.crossSelf(h)}i.isZero()||
+i.normalize();g.normal.copy(i)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=
 this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal);d[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);
-c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(E,O,S,V,F,Y,B){k=E.vertices[O].position;g=E.vertices[S].position;i=E.vertices[V].position;n=f[F];j=f[Y];p=f[B];r=g.x-k.x;y=i.x-k.x;A=g.y-k.y;D=i.y-k.y;z=g.z-k.z;T=i.z-k.z;U=j.u-n.u;X=p.u-n.u;s=j.v-n.v;o=p.v-n.v;L=1/(U*o-X*s);w.set((o*
-r-s*y)*L,(o*A-s*D)*L,(o*z-s*T)*L);u.set((U*y-X*r)*L,(U*D-X*A)*L,(U*T-X*z)*L);aa[O].addSelf(w);aa[S].addSelf(w);aa[V].addSelf(w);ba[O].addSelf(u);ba[S].addSelf(u);ba[V].addSelf(u)}var b,c,d,e,h,f,k,g,i,n,j,p,r,y,A,D,z,T,U,X,s,o,L,R,aa=[],ba=[],w=new THREE.Vector3,u=new THREE.Vector3,H=new THREE.Vector3,M=new THREE.Vector3,P=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){aa[b]=new THREE.Vector3;ba[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){h=this.faces[b];f=this.faceVertexUvs[0][b];
-if(h instanceof THREE.Face3)a(this,h.a,h.b,h.c,0,1,2);else if(h instanceof THREE.Face4){a(this,h.a,h.b,h.c,0,1,2);a(this,h.a,h.b,h.d,0,1,3)}}var I=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){h=this.faces[b];for(d=0;d<h.vertexNormals.length;d++){P.copy(h.vertexNormals[d]);e=h[I[d]];R=aa[e];H.copy(R);H.subSelf(P.multiplyScalar(P.dot(R))).normalize();M.cross(h.vertexNormals[d],R);e=M.dot(ba[e]);e=e<0?-1:1;h.vertexTangents[d]=new THREE.Vector4(H.x,H.y,H.z,e)}}this.hasTangents=!0},computeBoundingBox:function(){var a;
+c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(y,F,Q,S,G,ba,Z){i=y.vertices[F].position;h=y.vertices[Q].position;j=y.vertices[S].position;p=f[G];n=f[ba];o=f[Z];k=h.x-i.x;t=j.x-i.x;w=h.y-i.y;D=j.y-i.y;x=h.z-i.z;W=j.z-i.z;X=n.u-p.u;aa=o.u-p.u;H=n.v-p.v;q=o.v-p.v;B=1/(X*q-aa*H);C.set((q*
+k-H*t)*B,(q*w-H*D)*B,(q*x-H*W)*B);A.set((X*t-aa*k)*B,(X*D-aa*w)*B,(X*W-aa*x)*B);L[F].addSelf(C);L[Q].addSelf(C);L[S].addSelf(C);Y[F].addSelf(A);Y[Q].addSelf(A);Y[S].addSelf(A)}var b,c,d,e,g,f,i,h,j,p,n,o,k,t,w,D,x,W,X,aa,H,q,B,z,L=[],Y=[],C=new THREE.Vector3,A=new THREE.Vector3,I=new THREE.Vector3,O=new THREE.Vector3,R=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){L[b]=new THREE.Vector3;Y[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){g=this.faces[b];f=this.faceVertexUvs[0][b];
+if(g instanceof THREE.Face3)a(this,g.a,g.b,g.c,0,1,2);else if(g instanceof THREE.Face4){a(this,g.a,g.b,g.c,0,1,2);a(this,g.a,g.b,g.d,0,1,3)}}var J=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){g=this.faces[b];for(d=0;d<g.vertexNormals.length;d++){R.copy(g.vertexNormals[d]);e=g[J[d]];z=L[e];I.copy(z);I.subSelf(R.multiplyScalar(R.dot(z))).normalize();O.cross(g.vertexNormals[d],z);e=O.dot(Y[e]);e=e<0?-1:1;g.vertexTangents[d]=new THREE.Vector4(I.x,I.y,I.z,e)}}this.hasTangents=!0},computeBoundingBox:function(){var a;
 if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;
-else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},computeEdgeFaces:function(){function a(g,i){return Math.min(g,
-i)+"_"+Math.max(g,i)}function b(g,i,n){if(g[i]===undefined){g[i]={set:{},array:[]};g[i].set[n]=1;g[i].array.push(n)}else if(g[i].set[n]===undefined){g[i].set[n]=1;g[i].array.push(n)}}var c,d,e,h,f,k={};c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];if(f instanceof THREE.Face3){e=a(f.a,f.b);b(k,e,c);e=a(f.b,f.c);b(k,e,c);e=a(f.a,f.c);b(k,e,c)}else if(f instanceof THREE.Face4){e=a(f.b,f.d);b(k,e,c);e=a(f.a,f.b);b(k,e,c);e=a(f.a,f.d);b(k,e,c);e=a(f.b,f.c);b(k,e,c);e=a(f.c,f.d);b(k,e,c)}}c=0;for(d=
-this.edges.length;c<d;c++){f=this.edges[c];e=f.vertexIndices[0];h=f.vertexIndices[1];f.faceIndices=k[a(e,h)].array;for(e=0;e<f.faceIndices.length;e++){h=f.faceIndices[e];f.faces.push(this.faces[h])}}}};THREE.GeometryIdCounter=0;THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};
+else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},computeEdgeFaces:function(){function a(h,j){return Math.min(h,
+j)+"_"+Math.max(h,j)}function b(h,j,p){if(h[j]===undefined){h[j]={set:{},array:[]};h[j].set[p]=1;h[j].array.push(p)}else if(h[j].set[p]===undefined){h[j].set[p]=1;h[j].array.push(p)}}var c,d,e,g,f,i={};c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];if(f instanceof THREE.Face3){e=a(f.a,f.b);b(i,e,c);e=a(f.b,f.c);b(i,e,c);e=a(f.a,f.c);b(i,e,c)}else if(f instanceof THREE.Face4){e=a(f.b,f.d);b(i,e,c);e=a(f.a,f.b);b(i,e,c);e=a(f.a,f.d);b(i,e,c);e=a(f.b,f.c);b(i,e,c);e=a(f.c,f.d);b(i,e,c)}}c=0;for(d=
+this.edges.length;c<d;c++){f=this.edges[c];e=f.vertexIndices[0];g=f.vertexIndices[1];f.faceIndices=i[a(e,g)].array;for(e=0;e<f.faceIndices.length;e++){g=f.faceIndices[e];f.faces.push(this.faces[g])}}}};THREE.GeometryIdCounter=0;THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};
 THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
 THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&this.updateMatrix();if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
 !1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};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;
@@ -85,7 +84,7 @@ THREE.MeshDepthMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.sha
 THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading?a.shading:THREE.FlatShading;this.wireframe=a.wireframe?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth?a.wireframeLinewidth:1};THREE.MeshNormalMaterial.prototype=new THREE.Material;THREE.MeshNormalMaterial.prototype.constructor=THREE.MeshNormalMaterial;THREE.MeshFaceMaterial=function(){};
 THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==undefined?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==undefined?a.map:null;this.size=a.size!==undefined?a.size:1;this.sizeAttenuation=a.sizeAttenuation!==undefined?a.sizeAttenuation:!0;this.vertexColors=a.vertexColors!==undefined?a.vertexColors:!1};THREE.ParticleBasicMaterial.prototype=new THREE.Material;THREE.ParticleBasicMaterial.prototype.constructor=THREE.ParticleBasicMaterial;
 THREE.ParticleCanvasMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==undefined?new THREE.Color(a.color):new THREE.Color(16777215);this.program=a.program!==undefined?a.program:function(){}};THREE.ParticleCanvasMaterial.prototype=new THREE.Material;THREE.ParticleCanvasMaterial.prototype.constructor=THREE.ParticleCanvasMaterial;
-THREE.Texture=function(a,b,c,d,e,h){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrapS=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrapT=d!==undefined?d:THREE.ClampToEdgeWrapping;this.magFilter=e!==undefined?e:THREE.LinearFilter;this.minFilter=h!==undefined?h:THREE.LinearMipMapLinearFilter;this.needsUpdate=!1};THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};
+THREE.Texture=function(a,b,c,d,e,g){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrapS=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrapT=d!==undefined?d:THREE.ClampToEdgeWrapping;this.magFilter=e!==undefined?e:THREE.LinearFilter;this.minFilter=g!==undefined?g:THREE.LinearMipMapLinearFilter;this.needsUpdate=!1};THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};
 THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;
 THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a]};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;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;
@@ -103,43 +102,43 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.c
 THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1){this.objects.push(a);this.__objectsAdded.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.Sound){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);if(b!==-1){this.objects.splice(b,1);this.__objectsRemoved.push(a)}}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.Projector=function(){function a(){var w=g[k]=g[k]||new THREE.RenderableVertex;k++;return w}function b(w,u){return u.z-w.z}function c(w,u){var H=0,M=1,P=w.z+w.w,I=u.z+u.w,E=-w.z+w.w,O=-u.z+u.w;if(P>=0&&I>=0&&E>=0&&O>=0)return!0;else if(P<0&&I<0||E<0&&O<0)return!1;else{if(P<0)H=Math.max(H,P/(P-I));else I<0&&(M=Math.min(M,P/(P-I)));if(E<0)H=Math.max(H,E/(E-O));else O<0&&(M=Math.min(M,E/(E-O)));if(M<H)return!1;else{w.lerpSelf(u,H);u.lerpSelf(w,1-M);return!0}}}var d,e,h=[],f,k,g=[],i,n,j=[],p,r=
-[],y,A,D=[],z,T,U=[],X=new THREE.Vector4,s=new THREE.Vector4,o=new THREE.Matrix4,L=new THREE.Matrix4,R=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],aa=new THREE.Vector4,ba=new THREE.Vector4;this.projectVector=function(w,u){o.multiply(u.projectionMatrix,u.matrixWorldInverse);o.multiplyVector3(w);return w};this.unprojectVector=function(w,u){o.multiply(u.matrixWorld,THREE.Matrix4.makeInvert(u.projectionMatrix));o.multiplyVector3(w);return w};
-this.projectObjects=function(w,u,H){u=[];var M,P,I;e=0;P=w.objects;w=0;for(M=P.length;w<M;w++){I=P[w];var E;if(!(E=!I.visible))if(E=I instanceof THREE.Mesh){a:{E=void 0;for(var O=I.matrixWorld,S=-I.geometry.boundingSphere.radius*Math.max(I.scale.x,Math.max(I.scale.y,I.scale.z)),V=0;V<6;V++){E=R[V].x*O.n14+R[V].y*O.n24+R[V].z*O.n34+R[V].w;if(E<=S){E=!1;break a}}E=!0}E=!E}if(!E){E=h[e]=h[e]||new THREE.RenderableObject;e++;d=E;X.copy(I.position);o.multiplyVector3(X);d.object=I;d.z=X.z;u.push(d)}}H&&
-u.sort(b);return u};this.projectScene=function(w,u,H){var M=[],P=u.near,I=u.far,E,O,S,V,F,Y,B,Q,K,C,Z,ia,ma,ja,ca,Da,wa;T=A=p=n=0;u.matrixAutoUpdate&&u.update(undefined,!0);w.update(undefined,!1,u);o.multiply(u.projectionMatrix,u.matrixWorldInverse);R[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);R[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);R[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);R[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);R[4].set(o.n41-o.n31,
-o.n42-o.n32,o.n43-o.n33,o.n44-o.n34);R[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(E=0;E<6;E++){K=R[E];K.divideScalar(Math.sqrt(K.x*K.x+K.y*K.y+K.z*K.z))}K=this.projectObjects(w,u,!0);w=0;for(E=K.length;w<E;w++){C=K[w].object;if(C.visible){Z=C.matrixWorld;ia=C.matrixRotationWorld;ma=C.materials;ja=C.overdraw;k=0;if(C instanceof THREE.Mesh){ca=C.geometry;V=ca.vertices;Da=ca.faces;ca=ca.faceVertexUvs;O=0;for(S=V.length;O<S;O++){f=a();f.positionWorld.copy(V[O].position);Z.multiplyVector3(f.positionWorld);
-f.positionScreen.copy(f.positionWorld);o.multiplyVector4(f.positionScreen);f.positionScreen.x/=f.positionScreen.w;f.positionScreen.y/=f.positionScreen.w;f.visible=f.positionScreen.z>P&&f.positionScreen.z<I}V=0;for(O=Da.length;V<O;V++){S=Da[V];if(S instanceof THREE.Face3){F=g[S.a];Y=g[S.b];B=g[S.c];if(F.visible&&Y.visible&&B.visible&&(C.doubleSided||C.flipSided!=(B.positionScreen.x-F.positionScreen.x)*(Y.positionScreen.y-F.positionScreen.y)-(B.positionScreen.y-F.positionScreen.y)*(Y.positionScreen.x-
-F.positionScreen.x)<0)){Q=j[n]=j[n]||new THREE.RenderableFace3;n++;i=Q;i.v1.copy(F);i.v2.copy(Y);i.v3.copy(B)}else continue}else if(S instanceof THREE.Face4){F=g[S.a];Y=g[S.b];B=g[S.c];Q=g[S.d];if(F.visible&&Y.visible&&B.visible&&Q.visible&&(C.doubleSided||C.flipSided!=((Q.positionScreen.x-F.positionScreen.x)*(Y.positionScreen.y-F.positionScreen.y)-(Q.positionScreen.y-F.positionScreen.y)*(Y.positionScreen.x-F.positionScreen.x)<0||(Y.positionScreen.x-B.positionScreen.x)*(Q.positionScreen.y-B.positionScreen.y)-
-(Y.positionScreen.y-B.positionScreen.y)*(Q.positionScreen.x-B.positionScreen.x)<0))){wa=r[p]=r[p]||new THREE.RenderableFace4;p++;i=wa;i.v1.copy(F);i.v2.copy(Y);i.v3.copy(B);i.v4.copy(Q)}else continue}i.normalWorld.copy(S.normal);ia.multiplyVector3(i.normalWorld);i.centroidWorld.copy(S.centroid);Z.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);o.multiplyVector3(i.centroidScreen);B=S.vertexNormals;F=0;for(Y=B.length;F<Y;F++){Q=i.vertexNormalsWorld[F];Q.copy(B[F]);ia.multiplyVector3(Q)}F=
-0;for(Y=ca.length;F<Y;F++)if(wa=ca[F][V]){B=0;for(Q=wa.length;B<Q;B++)i.uvs[F][B]=wa[B]}i.meshMaterials=ma;i.faceMaterials=S.materials;i.overdraw=ja;i.z=i.centroidScreen.z;M.push(i)}}else if(C instanceof THREE.Line){L.multiply(o,Z);V=C.geometry.vertices;F=a();F.positionScreen.copy(V[0].position);L.multiplyVector4(F.positionScreen);O=1;for(S=V.length;O<S;O++){F=a();F.positionScreen.copy(V[O].position);L.multiplyVector4(F.positionScreen);Y=g[k-2];aa.copy(F.positionScreen);ba.copy(Y.positionScreen);
-if(c(aa,ba)){aa.multiplyScalar(1/aa.w);ba.multiplyScalar(1/ba.w);Z=D[A]=D[A]||new THREE.RenderableLine;A++;y=Z;y.v1.positionScreen.copy(aa);y.v2.positionScreen.copy(ba);y.z=Math.max(aa.z,ba.z);y.materials=C.materials;M.push(y)}}}else if(C instanceof THREE.Particle){s.set(C.matrixWorld.n14,C.matrixWorld.n24,C.matrixWorld.n34,1);o.multiplyVector4(s);s.z/=s.w;if(s.z>0&&s.z<1){Z=U[T]=U[T]||new THREE.RenderableParticle;T++;z=Z;z.x=s.x/s.w;z.y=s.y/s.w;z.z=s.z;z.rotation=C.rotation.z;z.scale.x=C.scale.x*
-Math.abs(z.x-(s.x+u.projectionMatrix.n11)/(s.w+u.projectionMatrix.n14));z.scale.y=C.scale.y*Math.abs(z.y-(s.y+u.projectionMatrix.n22)/(s.w+u.projectionMatrix.n24));z.materials=C.materials;M.push(z)}}}}H&&M.sort(b);return M}};
-THREE.CanvasRenderer=function(){function a($){if(y!=$)j.globalAlpha=y=$}function b($){if(A!=$){switch($){case THREE.NormalBlending:j.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:j.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:j.globalCompositeOperation="darker"}A=$}}function c($){if(D!=$)j.strokeStyle=D=$}var d=this,e=null,h=new THREE.Projector,f=document.createElement("canvas"),k,g,i,n,j=f.getContext("2d"),p=new THREE.Color(0),r=0,y=1,A=0,D=null,
-z=null,T=null,U=null,X=null,s,o,L,R,aa=new THREE.RenderableVertex,ba=new THREE.RenderableVertex,w,u,H,M,P,I,E,O,S,V,F,Y,B=new THREE.Color,Q=new THREE.Color,K=new THREE.Color,C=new THREE.Color,Z=new THREE.Color,ia,ma,ja,ca,Da,wa,Wa,Xa,Ya,Za,Ba=new THREE.Rectangle,ka=new THREE.Rectangle,fa=new THREE.Rectangle,Ua=!1,ha=new THREE.Color,ga=new THREE.Color,Ma=new THREE.Color,Na=new THREE.Color,da=new THREE.Vector3,Ha,Ia,Va,la,Ja,Oa,Ea=16;Ha=document.createElement("canvas");Ha.width=Ha.height=2;Ia=Ha.getContext("2d");
-Ia.fillStyle="rgba(0,0,0,1)";Ia.fillRect(0,0,2,2);Va=Ia.getImageData(0,0,2,2);la=Va.data;Ja=document.createElement("canvas");Ja.width=Ja.height=Ea;Oa=Ja.getContext("2d");Oa.translate(-Ea/2,-Ea/2);Oa.scale(Ea,Ea);Ea--;this.domElement=f;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data={vertices:0,faces:0};this.setSize=function($,na){k=$;g=na;i=k/2;n=g/2;f.width=k;f.height=g;Ba.set(-i,-n,i,n);y=1;A=0;X=U=T=z=D=null};this.setClearColor=function($,na){p=$;r=na};this.setClearColorHex=
-function($,na){p.setHex($);r=na};this.clear=function(){j.setTransform(1,0,0,-1,i,n);if(!ka.isEmpty()){ka.inflate(1);ka.minSelf(Ba);if(p.hex==0&&r==0)j.clearRect(ka.getX(),ka.getY(),ka.getWidth(),ka.getHeight());else{b(THREE.NormalBlending);a(1);j.fillStyle="rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*255)+","+r+")";j.fillRect(ka.getX(),ka.getY(),ka.getWidth(),ka.getHeight())}ka.empty()}};this.render=function($,na){function bb(m){var x,t,q,J=m.lights;ga.setRGB(0,0,0);Ma.setRGB(0,
-0,0);Na.setRGB(0,0,0);m=0;for(x=J.length;m<x;m++){t=J[m];q=t.color;if(t instanceof THREE.AmbientLight){ga.r+=q.r;ga.g+=q.g;ga.b+=q.b}else if(t instanceof THREE.DirectionalLight){Ma.r+=q.r;Ma.g+=q.g;Ma.b+=q.b}else if(t instanceof THREE.PointLight){Na.r+=q.r;Na.g+=q.g;Na.b+=q.b}}}function ra(m,x,t,q){var J,G,v,l,W=m.lights;m=0;for(J=W.length;m<J;m++){G=W[m];v=G.color;if(G instanceof THREE.DirectionalLight){l=t.dot(G.position);if(!(l<=0)){l*=G.intensity;q.r+=v.r*l;q.g+=v.g*l;q.b+=v.b*l}}else if(G instanceof
-THREE.PointLight){l=t.dot(da.sub(G.position,x).normalize());if(!(l<=0)){l*=G.distance==0?1:1-Math.min(x.distanceTo(G.position)/G.distance,1);if(l!=0){l*=G.intensity;q.r+=v.r*l;q.g+=v.g*l;q.b+=v.b*l}}}}}function cb(m,x,t){a(t.opacity);b(t.blending);var q,J,G,v,l,W;if(t instanceof THREE.ParticleBasicMaterial){if(t.map){v=t.map.image;l=v.width>>1;W=v.height>>1;t=x.scale.x*i;G=x.scale.y*n;q=t*l;J=G*W;fa.set(m.x-q,m.y-J,m.x+q,m.y+J);if(Ba.instersects(fa)){j.save();j.translate(m.x,m.y);j.rotate(-x.rotation);
-j.scale(t,-G);j.translate(-l,-W);j.drawImage(v,0,0);j.restore()}}}else if(t instanceof THREE.ParticleCanvasMaterial){q=x.scale.x*i;J=x.scale.y*n;fa.set(m.x-q,m.y-J,m.x+q,m.y+J);if(Ba.instersects(fa)){c(t.color.__styleString);G=t.color.__styleString;if(z!=G)j.fillStyle=z=G;j.save();j.translate(m.x,m.y);j.rotate(-x.rotation);j.scale(q,J);t.program(j);j.restore()}}}function db(m,x,t,q){a(q.opacity);b(q.blending);j.beginPath();j.moveTo(m.positionScreen.x,m.positionScreen.y);j.lineTo(x.positionScreen.x,
-x.positionScreen.y);j.closePath();if(q instanceof THREE.LineBasicMaterial){B.__styleString=q.color.__styleString;m=q.linewidth;if(T!=m)j.lineWidth=T=m;m=q.linecap;if(U!=m)j.lineCap=U=m;m=q.linejoin;if(X!=m)j.lineJoin=X=m;c(B.__styleString);j.stroke();fa.inflate(q.linewidth*2)}}function Pa(m,x,t,q,J,G,v,l,W){d.data.vertices+=3;d.data.faces++;a(l.opacity);b(l.blending);w=m.positionScreen.x;u=m.positionScreen.y;H=x.positionScreen.x;M=x.positionScreen.y;P=t.positionScreen.x;I=t.positionScreen.y;Ka(w,
-u,H,M,P,I);if(l instanceof THREE.MeshBasicMaterial)if(l.map){if(l.map.mapping instanceof THREE.UVMapping){ca=v.uvs[0];sa(w,u,H,M,P,I,l.map.image,ca[q].u,ca[q].v,ca[J].u,ca[J].v,ca[G].u,ca[G].v)}}else if(l.envMap){if(l.envMap.mapping instanceof THREE.SphericalReflectionMapping){m=na.matrixWorldInverse;da.copy(v.vertexNormalsWorld[0]);Da=(da.x*m.n11+da.y*m.n12+da.z*m.n13)*0.5+0.5;wa=-(da.x*m.n21+da.y*m.n22+da.z*m.n23)*0.5+0.5;da.copy(v.vertexNormalsWorld[1]);Wa=(da.x*m.n11+da.y*m.n12+da.z*m.n13)*0.5+
-0.5;Xa=-(da.x*m.n21+da.y*m.n22+da.z*m.n23)*0.5+0.5;da.copy(v.vertexNormalsWorld[2]);Ya=(da.x*m.n11+da.y*m.n12+da.z*m.n13)*0.5+0.5;Za=-(da.x*m.n21+da.y*m.n22+da.z*m.n23)*0.5+0.5;sa(w,u,H,M,P,I,l.envMap.image,Da,wa,Wa,Xa,Ya,Za)}}else l.wireframe?xa(l.color.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(l.color.__styleString);else if(l instanceof THREE.MeshLambertMaterial){if(l.map&&!l.wireframe){if(l.map.mapping instanceof THREE.UVMapping){ca=v.uvs[0];sa(w,u,H,M,P,I,l.map.image,
-ca[q].u,ca[q].v,ca[J].u,ca[J].v,ca[G].u,ca[G].v)}b(THREE.SubtractiveBlending)}if(Ua)if(!l.wireframe&&l.shading==THREE.SmoothShading&&v.vertexNormalsWorld.length==3){Q.r=K.r=C.r=ga.r;Q.g=K.g=C.g=ga.g;Q.b=K.b=C.b=ga.b;ra(W,v.v1.positionWorld,v.vertexNormalsWorld[0],Q);ra(W,v.v2.positionWorld,v.vertexNormalsWorld[1],K);ra(W,v.v3.positionWorld,v.vertexNormalsWorld[2],C);Z.r=(K.r+C.r)*0.5;Z.g=(K.g+C.g)*0.5;Z.b=(K.b+C.b)*0.5;ja=Qa(Q,K,C,Z);sa(w,u,H,M,P,I,ja,0,0,1,0,0,1)}else{ha.r=ga.r;ha.g=ga.g;ha.b=ga.b;
-ra(W,v.centroidWorld,v.normalWorld,ha);B.r=l.color.r*ha.r;B.g=l.color.g*ha.g;B.b=l.color.b*ha.b;B.updateStyleString();l.wireframe?xa(B.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(B.__styleString)}else l.wireframe?xa(l.color.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(l.color.__styleString)}else if(l instanceof THREE.MeshDepthMaterial){ia=na.near;ma=na.far;Q.r=Q.g=Q.b=1-Ca(m.positionScreen.z,ia,ma);K.r=K.g=K.b=1-Ca(x.positionScreen.z,
-ia,ma);C.r=C.g=C.b=1-Ca(t.positionScreen.z,ia,ma);Z.r=(K.r+C.r)*0.5;Z.g=(K.g+C.g)*0.5;Z.b=(K.b+C.b)*0.5;ja=Qa(Q,K,C,Z);sa(w,u,H,M,P,I,ja,0,0,1,0,0,1)}else if(l instanceof THREE.MeshNormalMaterial){B.r=Fa(v.normalWorld.x);B.g=Fa(v.normalWorld.y);B.b=Fa(v.normalWorld.z);B.updateStyleString();l.wireframe?xa(B.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(B.__styleString)}}function $a(m,x,t,q,J,G,v,l,W){d.data.vertices+=4;d.data.faces++;a(l.opacity);b(l.blending);if(l.map||
-l.envMap){Pa(m,x,q,0,1,3,v,l,W);Pa(J,t,G,1,2,3,v,l,W)}else{w=m.positionScreen.x;u=m.positionScreen.y;H=x.positionScreen.x;M=x.positionScreen.y;P=t.positionScreen.x;I=t.positionScreen.y;E=q.positionScreen.x;O=q.positionScreen.y;S=J.positionScreen.x;V=J.positionScreen.y;F=G.positionScreen.x;Y=G.positionScreen.y;if(l instanceof THREE.MeshBasicMaterial){Ra(w,u,H,M,P,I,E,O);l.wireframe?xa(l.color.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(l.color.__styleString)}else if(l instanceof
-THREE.MeshLambertMaterial)if(Ua)if(!l.wireframe&&l.shading==THREE.SmoothShading&&v.vertexNormalsWorld.length==4){Q.r=K.r=C.r=Z.r=ga.r;Q.g=K.g=C.g=Z.g=ga.g;Q.b=K.b=C.b=Z.b=ga.b;ra(W,v.v1.positionWorld,v.vertexNormalsWorld[0],Q);ra(W,v.v2.positionWorld,v.vertexNormalsWorld[1],K);ra(W,v.v4.positionWorld,v.vertexNormalsWorld[3],C);ra(W,v.v3.positionWorld,v.vertexNormalsWorld[2],Z);ja=Qa(Q,K,C,Z);Ka(w,u,H,M,E,O);sa(w,u,H,M,E,O,ja,0,0,1,0,0,1);Ka(S,V,P,I,F,Y);sa(S,V,P,I,F,Y,ja,1,0,1,1,0,1)}else{ha.r=ga.r;
-ha.g=ga.g;ha.b=ga.b;ra(W,v.centroidWorld,v.normalWorld,ha);B.r=l.color.r*ha.r;B.g=l.color.g*ha.g;B.b=l.color.b*ha.b;B.updateStyleString();Ra(w,u,H,M,P,I,E,O);l.wireframe?xa(B.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(B.__styleString)}else{Ra(w,u,H,M,P,I,E,O);l.wireframe?xa(l.color.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(l.color.__styleString)}else if(l instanceof THREE.MeshNormalMaterial){B.r=Fa(v.normalWorld.x);B.g=Fa(v.normalWorld.y);
-B.b=Fa(v.normalWorld.z);B.updateStyleString();Ra(w,u,H,M,P,I,E,O);l.wireframe?xa(B.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(B.__styleString)}else if(l instanceof THREE.MeshDepthMaterial){ia=na.near;ma=na.far;Q.r=Q.g=Q.b=1-Ca(m.positionScreen.z,ia,ma);K.r=K.g=K.b=1-Ca(x.positionScreen.z,ia,ma);C.r=C.g=C.b=1-Ca(q.positionScreen.z,ia,ma);Z.r=Z.g=Z.b=1-Ca(t.positionScreen.z,ia,ma);ja=Qa(Q,K,C,Z);Ka(w,u,H,M,E,O);sa(w,u,H,M,E,O,ja,0,0,1,0,0,1);Ka(S,V,P,I,F,Y);sa(S,V,
-P,I,F,Y,ja,1,0,1,1,0,1)}}}function Ka(m,x,t,q,J,G){j.beginPath();j.moveTo(m,x);j.lineTo(t,q);j.lineTo(J,G);j.lineTo(m,x);j.closePath()}function Ra(m,x,t,q,J,G,v,l){j.beginPath();j.moveTo(m,x);j.lineTo(t,q);j.lineTo(J,G);j.lineTo(v,l);j.lineTo(m,x);j.closePath()}function xa(m,x,t,q){if(T!=x)j.lineWidth=T=x;if(U!=t)j.lineCap=U=t;if(X!=q)j.lineJoin=X=q;c(m);j.stroke();fa.inflate(x*2)}function ya(m){if(z!=m)j.fillStyle=z=m;j.fill()}function sa(m,x,t,q,J,G,v,l,W,ta,oa,ua,La){var qa,va;qa=v.width-1;va=
-v.height-1;l*=qa;W*=va;ta*=qa;oa*=va;ua*=qa;La*=va;t-=m;q-=x;J-=m;G-=x;ta-=l;oa-=W;ua-=l;La-=W;qa=ta*La-ua*oa;if(qa!=0){va=1/qa;qa=(La*t-oa*J)*va;oa=(La*q-oa*G)*va;t=(ta*J-ua*t)*va;q=(ta*G-ua*q)*va;m=m-qa*l-t*W;x=x-oa*l-q*W;j.save();j.transform(qa,oa,t,q,m,x);j.clip();j.drawImage(v,0,0);j.restore()}}function Qa(m,x,t,q){var J=~~(m.r*255),G=~~(m.g*255);m=~~(m.b*255);var v=~~(x.r*255),l=~~(x.g*255);x=~~(x.b*255);var W=~~(t.r*255),ta=~~(t.g*255);t=~~(t.b*255);var oa=~~(q.r*255),ua=~~(q.g*255);q=~~(q.b*
-255);la[0]=J<0?0:J>255?255:J;la[1]=G<0?0:G>255?255:G;la[2]=m<0?0:m>255?255:m;la[4]=v<0?0:v>255?255:v;la[5]=l<0?0:l>255?255:l;la[6]=x<0?0:x>255?255:x;la[8]=W<0?0:W>255?255:W;la[9]=ta<0?0:ta>255?255:ta;la[10]=t<0?0:t>255?255:t;la[12]=oa<0?0:oa>255?255:oa;la[13]=ua<0?0:ua>255?255:ua;la[14]=q<0?0:q>255?255:q;Ia.putImageData(Va,0,0);Oa.drawImage(Ha,0,0);return Ja}function Ca(m,x,t){m=(m-x)/(t-x);return m*m*(3-2*m)}function Fa(m){m=(m+1)*0.5;return m<0?0:m>1?1:m}function za(m,x){var t=x.x-m.x,q=x.y-m.y,
-J=1/Math.sqrt(t*t+q*q);t*=J;q*=J;x.x+=t;x.y+=q;m.x-=t;m.y-=q}var Sa,ab,N,pa,Aa,Ga,Ta,ea;this.autoClear?this.clear():j.setTransform(1,0,0,-1,i,n);d.data.vertices=0;d.data.faces=0;e=h.projectScene($,na,this.sortElements);(Ua=$.lights.length>0)&&bb($);Sa=0;for(ab=e.length;Sa<ab;Sa++){N=e[Sa];fa.empty();if(N instanceof THREE.RenderableParticle){s=N;s.x*=i;s.y*=n;pa=0;for(Aa=N.materials.length;pa<Aa;){ea=N.materials[pa++];ea.opacity!=0&&cb(s,N,ea,$)}}else if(N instanceof THREE.RenderableLine){s=N.v1;o=
-N.v2;s.positionScreen.x*=i;s.positionScreen.y*=n;o.positionScreen.x*=i;o.positionScreen.y*=n;fa.addPoint(s.positionScreen.x,s.positionScreen.y);fa.addPoint(o.positionScreen.x,o.positionScreen.y);if(Ba.instersects(fa)){pa=0;for(Aa=N.materials.length;pa<Aa;){ea=N.materials[pa++];ea.opacity!=0&&db(s,o,N,ea,$)}}}else if(N instanceof THREE.RenderableFace3){s=N.v1;o=N.v2;L=N.v3;s.positionScreen.x*=i;s.positionScreen.y*=n;o.positionScreen.x*=i;o.positionScreen.y*=n;L.positionScreen.x*=i;L.positionScreen.y*=
-n;if(N.overdraw){za(s.positionScreen,o.positionScreen);za(o.positionScreen,L.positionScreen);za(L.positionScreen,s.positionScreen)}fa.add3Points(s.positionScreen.x,s.positionScreen.y,o.positionScreen.x,o.positionScreen.y,L.positionScreen.x,L.positionScreen.y);if(Ba.instersects(fa)){pa=0;for(Aa=N.meshMaterials.length;pa<Aa;){ea=N.meshMaterials[pa++];if(ea instanceof THREE.MeshFaceMaterial){Ga=0;for(Ta=N.faceMaterials.length;Ga<Ta;)(ea=N.faceMaterials[Ga++])&&ea.opacity!=0&&Pa(s,o,L,0,1,2,N,ea,$)}else ea.opacity!=
-0&&Pa(s,o,L,0,1,2,N,ea,$)}}}else if(N instanceof THREE.RenderableFace4){s=N.v1;o=N.v2;L=N.v3;R=N.v4;s.positionScreen.x*=i;s.positionScreen.y*=n;o.positionScreen.x*=i;o.positionScreen.y*=n;L.positionScreen.x*=i;L.positionScreen.y*=n;R.positionScreen.x*=i;R.positionScreen.y*=n;aa.positionScreen.copy(o.positionScreen);ba.positionScreen.copy(R.positionScreen);if(N.overdraw){za(s.positionScreen,o.positionScreen);za(o.positionScreen,R.positionScreen);za(R.positionScreen,s.positionScreen);za(L.positionScreen,
-aa.positionScreen);za(L.positionScreen,ba.positionScreen)}fa.addPoint(s.positionScreen.x,s.positionScreen.y);fa.addPoint(o.positionScreen.x,o.positionScreen.y);fa.addPoint(L.positionScreen.x,L.positionScreen.y);fa.addPoint(R.positionScreen.x,R.positionScreen.y);if(Ba.instersects(fa)){pa=0;for(Aa=N.meshMaterials.length;pa<Aa;){ea=N.meshMaterials[pa++];if(ea instanceof THREE.MeshFaceMaterial){Ga=0;for(Ta=N.faceMaterials.length;Ga<Ta;)(ea=N.faceMaterials[Ga++])&&ea.opacity!=0&&$a(s,o,L,R,aa,ba,N,ea,
-$)}else ea.opacity!=0&&$a(s,o,L,R,aa,ba,N,ea,$)}}}ka.addRectangle(fa)}j.setTransform(1,0,0,1,0,0)}};
+THREE.Projector=function(){function a(){var C=h[i]=h[i]||new THREE.RenderableVertex;i++;return C}function b(C,A){return A.z-C.z}function c(C,A){var I=0,O=1,R=C.z+C.w,J=A.z+A.w,y=-C.z+C.w,F=-A.z+A.w;if(R>=0&&J>=0&&y>=0&&F>=0)return!0;else if(R<0&&J<0||y<0&&F<0)return!1;else{if(R<0)I=Math.max(I,R/(R-J));else J<0&&(O=Math.min(O,R/(R-J)));if(y<0)I=Math.max(I,y/(y-F));else F<0&&(O=Math.min(O,y/(y-F)));if(O<I)return!1;else{C.lerpSelf(A,I);A.lerpSelf(C,1-O);return!0}}}var d,e,g=[],f,i,h=[],j,p,n=[],o,k=
+[],t,w,D=[],x,W,X=[],aa=new THREE.Vector4,H=new THREE.Vector4,q=new THREE.Matrix4,B=new THREE.Matrix4,z=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],L=new THREE.Vector4,Y=new THREE.Vector4;this.projectVector=function(C,A){q.multiply(A.projectionMatrix,A.matrixWorldInverse);q.multiplyVector3(C);return C};this.unprojectVector=function(C,A){q.multiply(A.matrixWorld,THREE.Matrix4.makeInvert(A.projectionMatrix));q.multiplyVector3(C);return C};
+this.projectObjects=function(C,A,I){A=[];var O,R,J;e=0;R=C.objects;C=0;for(O=R.length;C<O;C++){J=R[C];var y;if(!(y=!J.visible))if(y=J instanceof THREE.Mesh){a:{y=void 0;for(var F=J.matrixWorld,Q=-J.geometry.boundingSphere.radius*Math.max(J.scale.x,Math.max(J.scale.y,J.scale.z)),S=0;S<6;S++){y=z[S].x*F.n14+z[S].y*F.n24+z[S].z*F.n34+z[S].w;if(y<=Q){y=!1;break a}}y=!0}y=!y}if(!y){y=g[e]=g[e]||new THREE.RenderableObject;e++;d=y;aa.copy(J.position);q.multiplyVector3(aa);d.object=J;d.z=aa.z;A.push(d)}}I&&
+A.sort(b);return A};this.projectScene=function(C,A,I){var O=[],R=A.near,J=A.far,y,F,Q,S,G,ba,Z,da,M,E,T,$,ea,oa,ia,ka,fa;W=w=o=p=0;A.matrixAutoUpdate&&A.update(undefined,!0);C.update(undefined,!1,A);q.multiply(A.projectionMatrix,A.matrixWorldInverse);z[0].set(q.n41-q.n11,q.n42-q.n12,q.n43-q.n13,q.n44-q.n14);z[1].set(q.n41+q.n11,q.n42+q.n12,q.n43+q.n13,q.n44+q.n14);z[2].set(q.n41+q.n21,q.n42+q.n22,q.n43+q.n23,q.n44+q.n24);z[3].set(q.n41-q.n21,q.n42-q.n22,q.n43-q.n23,q.n44-q.n24);z[4].set(q.n41-q.n31,
+q.n42-q.n32,q.n43-q.n33,q.n44-q.n34);z[5].set(q.n41+q.n31,q.n42+q.n32,q.n43+q.n33,q.n44+q.n34);for(y=0;y<6;y++){M=z[y];M.divideScalar(Math.sqrt(M.x*M.x+M.y*M.y+M.z*M.z))}M=this.projectObjects(C,A,!0);C=0;for(y=M.length;C<y;C++){E=M[C].object;if(E.visible){T=E.matrixWorld;$=E.matrixRotationWorld;ea=E.materials;oa=E.overdraw;i=0;if(E instanceof THREE.Mesh){ia=E.geometry;S=ia.vertices;ka=ia.faces;ia=ia.faceVertexUvs;F=0;for(Q=S.length;F<Q;F++){f=a();f.positionWorld.copy(S[F].position);T.multiplyVector3(f.positionWorld);
+f.positionScreen.copy(f.positionWorld);q.multiplyVector4(f.positionScreen);f.positionScreen.x/=f.positionScreen.w;f.positionScreen.y/=f.positionScreen.w;f.visible=f.positionScreen.z>R&&f.positionScreen.z<J}S=0;for(F=ka.length;S<F;S++){Q=ka[S];if(Q instanceof THREE.Face3){G=h[Q.a];ba=h[Q.b];Z=h[Q.c];if(G.visible&&ba.visible&&Z.visible&&(E.doubleSided||E.flipSided!=(Z.positionScreen.x-G.positionScreen.x)*(ba.positionScreen.y-G.positionScreen.y)-(Z.positionScreen.y-G.positionScreen.y)*(ba.positionScreen.x-
+G.positionScreen.x)<0)){da=n[p]=n[p]||new THREE.RenderableFace3;p++;j=da;j.v1.copy(G);j.v2.copy(ba);j.v3.copy(Z)}else continue}else if(Q instanceof THREE.Face4){G=h[Q.a];ba=h[Q.b];Z=h[Q.c];da=h[Q.d];if(G.visible&&ba.visible&&Z.visible&&da.visible&&(E.doubleSided||E.flipSided!=((da.positionScreen.x-G.positionScreen.x)*(ba.positionScreen.y-G.positionScreen.y)-(da.positionScreen.y-G.positionScreen.y)*(ba.positionScreen.x-G.positionScreen.x)<0||(ba.positionScreen.x-Z.positionScreen.x)*(da.positionScreen.y-
+Z.positionScreen.y)-(ba.positionScreen.y-Z.positionScreen.y)*(da.positionScreen.x-Z.positionScreen.x)<0))){fa=k[o]=k[o]||new THREE.RenderableFace4;o++;j=fa;j.v1.copy(G);j.v2.copy(ba);j.v3.copy(Z);j.v4.copy(da)}else continue}j.normalWorld.copy(Q.normal);$.multiplyVector3(j.normalWorld);j.centroidWorld.copy(Q.centroid);T.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);q.multiplyVector3(j.centroidScreen);Z=Q.vertexNormals;G=0;for(ba=Z.length;G<ba;G++){da=j.vertexNormalsWorld[G];
+da.copy(Z[G]);$.multiplyVector3(da)}G=0;for(ba=ia.length;G<ba;G++)if(fa=ia[G][S]){Z=0;for(da=fa.length;Z<da;Z++)j.uvs[G][Z]=fa[Z]}j.meshMaterials=ea;j.faceMaterials=Q.materials;j.overdraw=oa;j.z=j.centroidScreen.z;O.push(j)}}else if(E instanceof THREE.Line){B.multiply(q,T);S=E.geometry.vertices;G=a();G.positionScreen.copy(S[0].position);B.multiplyVector4(G.positionScreen);F=1;for(Q=S.length;F<Q;F++){G=a();G.positionScreen.copy(S[F].position);B.multiplyVector4(G.positionScreen);ba=h[i-2];L.copy(G.positionScreen);
+Y.copy(ba.positionScreen);if(c(L,Y)){L.multiplyScalar(1/L.w);Y.multiplyScalar(1/Y.w);T=D[w]=D[w]||new THREE.RenderableLine;w++;t=T;t.v1.positionScreen.copy(L);t.v2.positionScreen.copy(Y);t.z=Math.max(L.z,Y.z);t.materials=E.materials;O.push(t)}}}else if(E instanceof THREE.Particle){H.set(E.matrixWorld.n14,E.matrixWorld.n24,E.matrixWorld.n34,1);q.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){T=X[W]=X[W]||new THREE.RenderableParticle;W++;x=T;x.x=H.x/H.w;x.y=H.y/H.w;x.z=H.z;x.rotation=E.rotation.z;x.scale.x=
+E.scale.x*Math.abs(x.x-(H.x+A.projectionMatrix.n11)/(H.w+A.projectionMatrix.n14));x.scale.y=E.scale.y*Math.abs(x.y-(H.y+A.projectionMatrix.n22)/(H.w+A.projectionMatrix.n24));x.materials=E.materials;O.push(x)}}}}I&&O.sort(b);return O}};
+THREE.CanvasRenderer=function(){function a(U){if(D!=U)k.globalAlpha=D=U}function b(U){if(x!=U){switch(U){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}x=U}}function c(U){if(W!=U.hex){W=U.hex;k.strokeStyle="#"+e(W.toString(16))}}function d(U){if(X!=U.hex){X=U.hex;k.fillStyle="#"+e(X.toString(16))}}function e(U){for(;U.length<6;)U="0"+U;
+return U}var g=this,f=null,i=new THREE.Projector,h=document.createElement("canvas"),j,p,n,o,k=h.getContext("2d"),t=new THREE.Color(0),w=0,D=1,x=0,W=null,X=null,aa=null,H=null,q=null,B,z,L,Y,C=new THREE.RenderableVertex,A=new THREE.RenderableVertex,I,O,R,J,y,F,Q,S,G,ba,Z,da,M=new THREE.Color(0),E=new THREE.Color(0),T=new THREE.Color(0),$=new THREE.Color(0),ea=new THREE.Color(0),oa,ia,ka,fa,Wa,Xa,Ya,Za,$a,ab,Ca=new THREE.Rectangle,ma=new THREE.Rectangle,ha=new THREE.Rectangle,Ua=!1,la=new THREE.Color,
+ja=new THREE.Color,Ma=new THREE.Color,Na=new THREE.Color,ca=new THREE.Vector3,Ha,Ia,Va,na,Ja,Oa,Ea=16;Ha=document.createElement("canvas");Ha.width=Ha.height=2;Ia=Ha.getContext("2d");Ia.fillStyle="rgba(0,0,0,1)";Ia.fillRect(0,0,2,2);Va=Ia.getImageData(0,0,2,2);na=Va.data;Ja=document.createElement("canvas");Ja.width=Ja.height=Ea;Oa=Ja.getContext("2d");Oa.translate(-Ea/2,-Ea/2);Oa.scale(Ea,Ea);Ea--;this.domElement=h;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data={vertices:0,faces:0};
+this.setSize=function(U,pa){j=U;p=pa;n=j/2;o=p/2;h.width=j;h.height=p;Ca.set(-n,-o,n,o);D=1;x=0;q=H=aa=X=W=null};this.setClearColor=function(U,pa){t=U;w=pa};this.setClearColorHex=function(U,pa){t.setHex(U);w=pa};this.clear=function(){k.setTransform(1,0,0,-1,n,o);if(!ma.isEmpty()){ma.inflate(1);ma.minSelf(Ca);if(t.hex==0&&w==0)k.clearRect(ma.getX(),ma.getY(),ma.getWidth(),ma.getHeight());else{b(THREE.NormalBlending);a(1);k.fillStyle="rgba("+Math.floor(t.r*255)+","+Math.floor(t.g*255)+","+Math.floor(t.b*
+255)+","+w+")";k.fillRect(ma.getX(),ma.getY(),ma.getWidth(),ma.getHeight())}ma.empty()}};this.render=function(U,pa){function db(m){var v,s,r,K=m.lights;ja.setRGB(0,0,0);Ma.setRGB(0,0,0);Na.setRGB(0,0,0);m=0;for(v=K.length;m<v;m++){s=K[m];r=s.color;if(s instanceof THREE.AmbientLight){ja.r+=r.r;ja.g+=r.g;ja.b+=r.b}else if(s instanceof THREE.DirectionalLight){Ma.r+=r.r;Ma.g+=r.g;Ma.b+=r.b}else if(s instanceof THREE.PointLight){Na.r+=r.r;Na.g+=r.g;Na.b+=r.b}}}function ta(m,v,s,r){var K,N,u,l,V=m.lights;
+m=0;for(K=V.length;m<K;m++){N=V[m];u=N.color;if(N instanceof THREE.DirectionalLight){l=s.dot(N.position);if(!(l<=0)){l*=N.intensity;r.r+=u.r*l;r.g+=u.g*l;r.b+=u.b*l}}else if(N instanceof THREE.PointLight){l=s.dot(ca.sub(N.position,v).normalize());if(!(l<=0)){l*=N.distance==0?1:1-Math.min(v.distanceTo(N.position)/N.distance,1);if(l!=0){l*=N.intensity;r.r+=u.r*l;r.g+=u.g*l;r.b+=u.b*l}}}}}function eb(m,v,s){a(s.opacity);b(s.blending);var r,K,N,u,l,V;if(s instanceof THREE.ParticleBasicMaterial){if(s.map){u=
+s.map.image;l=u.width>>1;V=u.height>>1;s=v.scale.x*n;N=v.scale.y*o;r=s*l;K=N*V;ha.set(m.x-r,m.y-K,m.x+r,m.y+K);if(Ca.instersects(ha)){k.save();k.translate(m.x,m.y);k.rotate(-v.rotation);k.scale(s,-N);k.translate(-l,-V);k.drawImage(u,0,0);k.restore()}}}else if(s instanceof THREE.ParticleCanvasMaterial){r=v.scale.x*n;K=v.scale.y*o;ha.set(m.x-r,m.y-K,m.x+r,m.y+K);if(Ca.instersects(ha)){c(s.color);d(s.color);k.save();k.translate(m.x,m.y);k.rotate(-v.rotation);k.scale(r,K);s.program(k);k.restore()}}}function fb(m,
+v,s,r){a(r.opacity);b(r.blending);k.beginPath();k.moveTo(m.positionScreen.x,m.positionScreen.y);k.lineTo(v.positionScreen.x,v.positionScreen.y);k.closePath();if(r instanceof THREE.LineBasicMaterial){m=r.linewidth;if(aa!=m)k.lineWidth=aa=m;m=r.linecap;if(H!=m)k.lineCap=H=m;m=r.linejoin;if(q!=m)k.lineJoin=q=m;c(r.color);k.stroke();ha.inflate(r.linewidth*2)}}function Pa(m,v,s,r,K,N,u,l,V){g.data.vertices+=3;g.data.faces++;a(l.opacity);b(l.blending);I=m.positionScreen.x;O=m.positionScreen.y;R=v.positionScreen.x;
+J=v.positionScreen.y;y=s.positionScreen.x;F=s.positionScreen.y;Ka(I,O,R,J,y,F);if(l instanceof THREE.MeshBasicMaterial)if(l.map){if(l.map.mapping instanceof THREE.UVMapping){fa=u.uvs[0];ua(I,O,R,J,y,F,l.map.image,fa[r].u,fa[r].v,fa[K].u,fa[K].v,fa[N].u,fa[N].v)}}else if(l.envMap){if(l.envMap.mapping instanceof THREE.SphericalReflectionMapping){m=pa.matrixWorldInverse;ca.copy(u.vertexNormalsWorld[0]);Wa=(ca.x*m.n11+ca.y*m.n12+ca.z*m.n13)*0.5+0.5;Xa=-(ca.x*m.n21+ca.y*m.n22+ca.z*m.n23)*0.5+0.5;ca.copy(u.vertexNormalsWorld[1]);
+Ya=(ca.x*m.n11+ca.y*m.n12+ca.z*m.n13)*0.5+0.5;Za=-(ca.x*m.n21+ca.y*m.n22+ca.z*m.n23)*0.5+0.5;ca.copy(u.vertexNormalsWorld[2]);$a=(ca.x*m.n11+ca.y*m.n12+ca.z*m.n13)*0.5+0.5;ab=-(ca.x*m.n21+ca.y*m.n22+ca.z*m.n23)*0.5+0.5;ua(I,O,R,J,y,F,l.envMap.image,Wa,Xa,Ya,Za,$a,ab)}}else l.wireframe?ya(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(l.color);else if(l instanceof THREE.MeshLambertMaterial){if(l.map&&!l.wireframe){if(l.map.mapping instanceof THREE.UVMapping){fa=u.uvs[0];ua(I,
+O,R,J,y,F,l.map.image,fa[r].u,fa[r].v,fa[K].u,fa[K].v,fa[N].u,fa[N].v)}b(THREE.SubtractiveBlending)}if(Ua)if(!l.wireframe&&l.shading==THREE.SmoothShading&&u.vertexNormalsWorld.length==3){E.r=T.r=$.r=ja.r;E.g=T.g=$.g=ja.g;E.b=T.b=$.b=ja.b;ta(V,u.v1.positionWorld,u.vertexNormalsWorld[0],E);ta(V,u.v2.positionWorld,u.vertexNormalsWorld[1],T);ta(V,u.v3.positionWorld,u.vertexNormalsWorld[2],$);ea.r=(T.r+$.r)*0.5;ea.g=(T.g+$.g)*0.5;ea.b=(T.b+$.b)*0.5;ka=Qa(E,T,$,ea);ua(I,O,R,J,y,F,ka,0,0,1,0,0,1)}else{la.r=
+ja.r;la.g=ja.g;la.b=ja.b;ta(V,u.centroidWorld,u.normalWorld,la);M.r=Math.max(0,Math.min(l.color.r*la.r,1));M.g=Math.max(0,Math.min(l.color.g*la.g,1));M.b=Math.max(0,Math.min(l.color.b*la.b,1));M.updateHex();l.wireframe?ya(M,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(M)}else l.wireframe?ya(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(l.color)}else if(l instanceof THREE.MeshDepthMaterial){oa=pa.near;ia=pa.far;E.r=E.g=E.b=1-Da(m.positionScreen.z,oa,ia);
+T.r=T.g=T.b=1-Da(v.positionScreen.z,oa,ia);$.r=$.g=$.b=1-Da(s.positionScreen.z,oa,ia);ea.r=(T.r+$.r)*0.5;ea.g=(T.g+$.g)*0.5;ea.b=(T.b+$.b)*0.5;ka=Qa(E,T,$,ea);ua(I,O,R,J,y,F,ka,0,0,1,0,0,1)}else if(l instanceof THREE.MeshNormalMaterial){M.r=Fa(u.normalWorld.x);M.g=Fa(u.normalWorld.y);M.b=Fa(u.normalWorld.z);M.updateHex();l.wireframe?ya(M,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(M)}}function bb(m,v,s,r,K,N,u,l,V){g.data.vertices+=4;g.data.faces++;a(l.opacity);b(l.blending);if(l.map||
+l.envMap){Pa(m,v,r,0,1,3,u,l,V);Pa(K,s,N,1,2,3,u,l,V)}else{I=m.positionScreen.x;O=m.positionScreen.y;R=v.positionScreen.x;J=v.positionScreen.y;y=s.positionScreen.x;F=s.positionScreen.y;Q=r.positionScreen.x;S=r.positionScreen.y;G=K.positionScreen.x;ba=K.positionScreen.y;Z=N.positionScreen.x;da=N.positionScreen.y;if(l instanceof THREE.MeshBasicMaterial){Ra(I,O,R,J,y,F,Q,S);l.wireframe?ya(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(l.color)}else if(l instanceof THREE.MeshLambertMaterial)if(Ua)if(!l.wireframe&&
+l.shading==THREE.SmoothShading&&u.vertexNormalsWorld.length==4){E.r=T.r=$.r=ea.r=ja.r;E.g=T.g=$.g=ea.g=ja.g;E.b=T.b=$.b=ea.b=ja.b;ta(V,u.v1.positionWorld,u.vertexNormalsWorld[0],E);ta(V,u.v2.positionWorld,u.vertexNormalsWorld[1],T);ta(V,u.v4.positionWorld,u.vertexNormalsWorld[3],$);ta(V,u.v3.positionWorld,u.vertexNormalsWorld[2],ea);ka=Qa(E,T,$,ea);Ka(I,O,R,J,Q,S);ua(I,O,R,J,Q,S,ka,0,0,1,0,0,1);Ka(G,ba,y,F,Z,da);ua(G,ba,y,F,Z,da,ka,1,0,1,1,0,1)}else{la.r=ja.r;la.g=ja.g;la.b=ja.b;ta(V,u.centroidWorld,
+u.normalWorld,la);M.r=Math.max(0,Math.min(l.color.r*la.r,1));M.g=Math.max(0,Math.min(l.color.g*la.g,1));M.b=Math.max(0,Math.min(l.color.b*la.b,1));M.updateHex();Ra(I,O,R,J,y,F,Q,S);l.wireframe?ya(M,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(M)}else{Ra(I,O,R,J,y,F,Q,S);l.wireframe?ya(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(l.color)}else if(l instanceof THREE.MeshNormalMaterial){M.r=Fa(u.normalWorld.x);M.g=Fa(u.normalWorld.y);M.b=Fa(u.normalWorld.z);
+M.updateHex();Ra(I,O,R,J,y,F,Q,S);l.wireframe?ya(M,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(M)}else if(l instanceof THREE.MeshDepthMaterial){oa=pa.near;ia=pa.far;E.r=E.g=E.b=1-Da(m.positionScreen.z,oa,ia);T.r=T.g=T.b=1-Da(v.positionScreen.z,oa,ia);$.r=$.g=$.b=1-Da(r.positionScreen.z,oa,ia);ea.r=ea.g=ea.b=1-Da(s.positionScreen.z,oa,ia);ka=Qa(E,T,$,ea);Ka(I,O,R,J,Q,S);ua(I,O,R,J,Q,S,ka,0,0,1,0,0,1);Ka(G,ba,y,F,Z,da);ua(G,ba,y,F,Z,da,ka,1,0,1,1,0,1)}}}function Ka(m,v,s,r,K,N){k.beginPath();
+k.moveTo(m,v);k.lineTo(s,r);k.lineTo(K,N);k.lineTo(m,v);k.closePath()}function Ra(m,v,s,r,K,N,u,l){k.beginPath();k.moveTo(m,v);k.lineTo(s,r);k.lineTo(K,N);k.lineTo(u,l);k.lineTo(m,v);k.closePath()}function ya(m,v,s,r){if(aa!=v)k.lineWidth=aa=v;if(H!=s)k.lineCap=H=s;if(q!=r)k.lineJoin=q=r;c(m);k.stroke();ha.inflate(v*2)}function za(m){d(m);k.fill()}function ua(m,v,s,r,K,N,u,l,V,va,qa,wa,La){var sa,xa;sa=u.width-1;xa=u.height-1;l*=sa;V*=xa;va*=sa;qa*=xa;wa*=sa;La*=xa;s-=m;r-=v;K-=m;N-=v;va-=l;qa-=V;
+wa-=l;La-=V;sa=va*La-wa*qa;if(sa!=0){xa=1/sa;sa=(La*s-qa*K)*xa;qa=(La*r-qa*N)*xa;s=(va*K-wa*s)*xa;r=(va*N-wa*r)*xa;m=m-sa*l-s*V;v=v-qa*l-r*V;k.save();k.transform(sa,qa,s,r,m,v);k.clip();k.drawImage(u,0,0);k.restore()}}function Qa(m,v,s,r){var K=~~(m.r*255),N=~~(m.g*255);m=~~(m.b*255);var u=~~(v.r*255),l=~~(v.g*255);v=~~(v.b*255);var V=~~(s.r*255),va=~~(s.g*255);s=~~(s.b*255);var qa=~~(r.r*255),wa=~~(r.g*255);r=~~(r.b*255);na[0]=K<0?0:K>255?255:K;na[1]=N<0?0:N>255?255:N;na[2]=m<0?0:m>255?255:m;na[4]=
+u<0?0:u>255?255:u;na[5]=l<0?0:l>255?255:l;na[6]=v<0?0:v>255?255:v;na[8]=V<0?0:V>255?255:V;na[9]=va<0?0:va>255?255:va;na[10]=s<0?0:s>255?255:s;na[12]=qa<0?0:qa>255?255:qa;na[13]=wa<0?0:wa>255?255:wa;na[14]=r<0?0:r>255?255:r;Ia.putImageData(Va,0,0);Oa.drawImage(Ha,0,0);return Ja}function Da(m,v,s){m=(m-v)/(s-v);return m*m*(3-2*m)}function Fa(m){m=(m+1)*0.5;return m<0?0:m>1?1:m}function Aa(m,v){var s=v.x-m.x,r=v.y-m.y,K=1/Math.sqrt(s*s+r*r);s*=K;r*=K;v.x+=s;v.y+=r;m.x-=s;m.y-=r}var Sa,cb,P,ra,Ba,Ga,
+Ta,ga;this.autoClear?this.clear():k.setTransform(1,0,0,-1,n,o);g.data.vertices=0;g.data.faces=0;f=i.projectScene(U,pa,this.sortElements);(Ua=U.lights.length>0)&&db(U);Sa=0;for(cb=f.length;Sa<cb;Sa++){P=f[Sa];ha.empty();if(P instanceof THREE.RenderableParticle){B=P;B.x*=n;B.y*=o;ra=0;for(Ba=P.materials.length;ra<Ba;){ga=P.materials[ra++];ga.opacity!=0&&eb(B,P,ga,U)}}else if(P instanceof THREE.RenderableLine){B=P.v1;z=P.v2;B.positionScreen.x*=n;B.positionScreen.y*=o;z.positionScreen.x*=n;z.positionScreen.y*=
+o;ha.addPoint(B.positionScreen.x,B.positionScreen.y);ha.addPoint(z.positionScreen.x,z.positionScreen.y);if(Ca.instersects(ha)){ra=0;for(Ba=P.materials.length;ra<Ba;){ga=P.materials[ra++];ga.opacity!=0&&fb(B,z,P,ga,U)}}}else if(P instanceof THREE.RenderableFace3){B=P.v1;z=P.v2;L=P.v3;B.positionScreen.x*=n;B.positionScreen.y*=o;z.positionScreen.x*=n;z.positionScreen.y*=o;L.positionScreen.x*=n;L.positionScreen.y*=o;if(P.overdraw){Aa(B.positionScreen,z.positionScreen);Aa(z.positionScreen,L.positionScreen);
+Aa(L.positionScreen,B.positionScreen)}ha.add3Points(B.positionScreen.x,B.positionScreen.y,z.positionScreen.x,z.positionScreen.y,L.positionScreen.x,L.positionScreen.y);if(Ca.instersects(ha)){ra=0;for(Ba=P.meshMaterials.length;ra<Ba;){ga=P.meshMaterials[ra++];if(ga instanceof THREE.MeshFaceMaterial){Ga=0;for(Ta=P.faceMaterials.length;Ga<Ta;)(ga=P.faceMaterials[Ga++])&&ga.opacity!=0&&Pa(B,z,L,0,1,2,P,ga,U)}else ga.opacity!=0&&Pa(B,z,L,0,1,2,P,ga,U)}}}else if(P instanceof THREE.RenderableFace4){B=P.v1;
+z=P.v2;L=P.v3;Y=P.v4;B.positionScreen.x*=n;B.positionScreen.y*=o;z.positionScreen.x*=n;z.positionScreen.y*=o;L.positionScreen.x*=n;L.positionScreen.y*=o;Y.positionScreen.x*=n;Y.positionScreen.y*=o;C.positionScreen.copy(z.positionScreen);A.positionScreen.copy(Y.positionScreen);if(P.overdraw){Aa(B.positionScreen,z.positionScreen);Aa(z.positionScreen,Y.positionScreen);Aa(Y.positionScreen,B.positionScreen);Aa(L.positionScreen,C.positionScreen);Aa(L.positionScreen,A.positionScreen)}ha.addPoint(B.positionScreen.x,
+B.positionScreen.y);ha.addPoint(z.positionScreen.x,z.positionScreen.y);ha.addPoint(L.positionScreen.x,L.positionScreen.y);ha.addPoint(Y.positionScreen.x,Y.positionScreen.y);if(Ca.instersects(ha)){ra=0;for(Ba=P.meshMaterials.length;ra<Ba;){ga=P.meshMaterials[ra++];if(ga instanceof THREE.MeshFaceMaterial){Ga=0;for(Ta=P.faceMaterials.length;Ga<Ta;)(ga=P.faceMaterials[Ga++])&&ga.opacity!=0&&bb(B,z,L,Y,C,A,P,ga,U)}else ga.opacity!=0&&bb(B,z,L,Y,C,A,P,ga,U)}}}ma.addRectangle(ha)}k.setTransform(1,0,0,1,
+0,0)}};
 THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,c){c&&a.update(undefined,!1,b);c=a.sounds;var d,e=c.length;for(d=0;d<e;d++){a=c[d];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
 THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
 THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};

+ 3 - 4
build/custom/ThreeDOM.js

@@ -1,8 +1,7 @@
 // ThreeDOM.js r40 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}THREE.Color=function(a){this.setHex(a)};
-THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var d,e,h,f,j,g;if(c==0)d=e=h=0;else{f=Math.floor(a*6);j=a*6-f;a=c*(1-b);g=c*(1-b*j);b=c*(1-b*(1-j));switch(f){case 1:d=g;e=c;h=a;break;case 2:d=a;e=c;h=b;break;case 3:d=a;e=g;h=c;break;case 4:d=b;e=a;h=c;break;case 5:d=c;e=a;
-h=g;break;case 6:case 0:d=c;e=b;h=a}}this.r=d;this.g=e;this.b=h;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB: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)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)};
+THREE.Color.prototype={copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex},setHex:function(a){this.hex=~~a&16777215;this.updateRGB()},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;this.updateHex()},setHSV:function(a,b,c){var d,e,h,f,j,g;if(c==0)d=e=h=0;else{f=Math.floor(a*6);j=a*6-f;a=c*(1-b);g=c*(1-b*j);b=c*(1-b*(1-j));switch(f){case 1:d=g;e=c;h=a;break;case 2:d=a;e=c;h=b;break;case 3:d=a;e=g;h=c;break;case 4:d=b;e=a;h=c;break;case 5:d=c;e=a;h=g;break;case 6:case 0:d=c;e=b;h=a}}this.setRGB(d,
+e,h)},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)};
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
 this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)};
 THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
@@ -50,7 +49,7 @@ THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;thi
 a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},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},
 multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,h=a.x,f=a.y,j=a.z;a=a.w;this.x=b*a+e*h+c*j-d*f;this.y=c*a+e*f+d*h-b*j;this.z=d*a+e*j+b*f-c*h;this.w=e*a-b*h-c*f-d*j;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,h=this.x,f=this.y,j=this.z,g=this.w,i=g*c+f*e-j*d,l=
 g*d+j*c-h*e,k=g*e+h*d-f*c;c=-h*c-f*d-j*e;b.x=i*g+c*-h+l*-j-k*-f;b.y=l*g+c*-f+k*-h-i*-j;b.z=k*g+c*-j+i*-f-l*-h;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<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}e=Math.sin((1-d)*h)/f;d=Math.sin(d*h)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.001){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}e=Math.sin((1-d)*h)/f;d=Math.sin(d*h)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,e,h){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,h,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;

+ 8 - 8
build/custom/ThreeExtras.js

@@ -35,7 +35,7 @@ value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.00195
 film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time *  1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor =  vec4( cResult, cTextureScreen.a );\n}"},
 screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
 fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,b,e,f,d=2*Math.ceil(a*3)+1;d>25&&(d=25);f=(d-1)*0.5;b=Array(d);for(c=e=0;c<d;++c){b[c]=Math.exp(-((c-f)*(c-f))/(2*a*a));e+=b[c]}for(c=0;c<d;++c)b[c]/=e;return b}};
-THREE.QuakeCamera=function(a){function c(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=
+THREE.QuakeCamera=function(a){function c(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=
 a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=a.noFly;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.activeLook!==undefined)this.activeLook=a.activeLook;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=
 a.heightMax;if(a.constrainVertical!==undefined)this.constrainVertical=a.constrainVertical;if(a.verticalMin!==undefined)this.verticalMin=a.verticalMin;if(a.verticalMax!==undefined)this.verticalMax=a.verticalMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.freeze=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=
 window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.onKeyDown=
@@ -47,14 +47,14 @@ this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.o
 THREE.QuakeCamera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))};
 THREE.PathCamera=function(a){function c(l,k,m,p){var n={name:m,fps:0.6,length:p,hierarchy:[]},v,A=k.getControlPointsArray(),w=k.getLength(),u=A.length,y=0;v=u-1;k={parent:-1,keys:[]};k.keys[0]={time:0,pos:A[0],rot:[0,0,0,1],scl:[1,1,1]};k.keys[v]={time:p,pos:A[v],rot:[0,0,0,1],scl:[1,1,1]};for(v=1;v<u-1;v++){y=p*w.chunks[v]/w.total;k.keys[v]={time:y,pos:A[v]}}n.hierarchy[0]=k;THREE.AnimationHandler.add(n);return new THREE.Animation(l,m,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(l,k){var m,
 p,n=new THREE.Geometry;for(m=0;m<l.points.length*k;m++){p=m/(l.points.length*k);p=l.getPoint(p);n.vertices[m]=new THREE.Vertex(new THREE.Vector3(p.x,p.y,p.z))}return n}function e(l,k){var m=b(k,10),p=b(k,10),n=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(m,n);particleObj=new THREE.ParticleSystem(p,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);l.addChild(lineObj);particleObj.scale.set(1,1,1);l.addChild(particleObj);p=new THREE.Sphere(1,
-16,8);n=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<k.points.length;i++){m=new THREE.Mesh(p,n);m.position.copy(k.points[i]);m.updateMatrix();l.addChild(m)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookVertical=
+16,8);n=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<k.points.length;i++){m=new THREE.Mesh(p,n);m.position.copy(k.points[i]);m.updateMatrix();l.addChild(m)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookVertical=
 !0;this.lookHorizontal=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(a){if(a.duration!==undefined)this.duration=a.duration*1E3;if(a.waypoints!==undefined)this.waypoints=a.waypoints;if(a.useConstantSpeed!==undefined)this.useConstantSpeed=a.useConstantSpeed;if(a.resamplingCoef!==undefined)this.resamplingCoef=a.resamplingCoef;if(a.createDebugPath!==undefined)this.createDebugPath=a.createDebugPath;
 if(a.createDebugDummy!==undefined)this.createDebugDummy=a.createDebugDummy;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.lookHorizontal!==undefined)this.lookHorizontal=a.lookHorizontal;if(a.verticalAngleMap!==undefined)this.verticalAngleMap=a.verticalAngleMap;if(a.horizontalAngleMap!==undefined)this.horizontalAngleMap=a.horizontalAngleMap;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=
 this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var f=Math.PI*2,d=Math.PI/180;this.update=function(l,k,m){var p,n;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*d;this.theta=this.lon*d;p=this.phi%f;this.phi=p>=0?p:p+f;p=this.verticalAngleMap.srcRange;n=this.verticalAngleMap.dstRange;
 this.phi=(this.phi-p[0])*(n[1]-n[0])/(p[1]-p[0])+n[0];p=this.horizontalAngleMap.srcRange;n=this.horizontalAngleMap.dstRange;this.theta=(this.theta-p[0])*(n[1]-n[0])/(p[1]-p[0])+n[0];p=this.target.position;p.x=100*Math.sin(this.phi)*Math.cos(this.theta);p.y=100*Math.cos(this.phi);p.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,l,k,m)};this.onMouseMove=function(l){this.mouseX=l.clientX-this.windowHalfX;this.mouseY=l.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);
 this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var g=new THREE.MeshLambertMaterial({color:65280}),h=new THREE.Cube(10,10,20),j=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(h,a);a=new THREE.Mesh(j,g);a.position.set(0,10,0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation=
 c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&e(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(l,k){return function(){k.apply(l,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
-THREE.FlyCamera=function(a){function c(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.dragToLook=!1;this.autoForward=!1;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==undefined)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.autoForward!==undefined)this.autoForward=
+THREE.FlyCamera=function(a){function c(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.005;this.dragToLook=!1;this.autoForward=!1;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==undefined)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.autoForward!==undefined)this.autoForward=
 a.autoForward;if(a.domElement!==undefined)this.domElement=a.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=-1;this.tdiff=0;this.handleEvent=function(b){if(typeof this[b.type]=="function")this[b.type](b)};this.keydown=function(b){if(!b.altKey){switch(b.keyCode){case 16:this.movementSpeedMultiplier=
 0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};
 this.keyup=function(b){switch(b.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;
@@ -82,7 +82,7 @@ e));b instanceof THREE.Face4&&c.push(new THREE.UV(0.5+Math.atan2(m.position.x,m.
 THREE.Icosahedron=function(a){function c(m,p,n){var v=Math.sqrt(m*m+p*p+n*n);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(m/v,p/v,n/v)))-1}function b(m,p,n,v){v.faces.push(new THREE.Face3(m,p,n))}function e(m,p){var n=f.vertices[m].position,v=f.vertices[p].position;return c((n.x+v.x)/2,(n.y+v.y)/2,(n.z+v.z)/2)}var f=this,d=new THREE.Geometry,g;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
 1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,d);b(0,5,1,d);b(0,1,7,d);b(0,7,10,d);b(0,10,11,d);b(1,5,9,d);b(5,11,4,d);b(11,10,2,d);b(10,7,6,d);b(7,1,8,d);b(3,9,4,d);b(3,4,2,d);b(3,2,6,d);b(3,6,8,d);b(3,8,9,d);b(4,9,5,d);b(2,4,11,d);b(6,2,10,d);b(8,6,7,d);b(9,8,1,d);for(a=0;a<this.subdivisions;a++){g=new THREE.Geometry;for(var h in d.faces){var j=e(d.faces[h].a,d.faces[h].b),l=e(d.faces[h].b,d.faces[h].c),k=e(d.faces[h].c,d.faces[h].a);b(d.faces[h].a,j,k,g);b(d.faces[h].b,l,j,g);b(d.faces[h].c,
 k,l,g);b(j,l,k,g)}d.faces=g.faces}f.faces=d.faces;delete d;delete g;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Icosahedron.prototype=new THREE.Geometry;THREE.Icosahedron.prototype.constructor=THREE.Icosahedron;
-THREE.Lathe=function(a,c,b){THREE.Geometry.call(this);this.steps=c||12;this.angle=b||2*Math.PI;c=this.angle/this.steps;b=[];for(var e=[],f=[],d=[],g=(new THREE.Matrix4).setRotationZ(c),h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));b[h]=a[h].clone();e[h]=this.vertices.length-1}for(var j=0;j<=this.angle+0.0010;j+=c){for(h=0;h<b.length;h++)if(j<this.angle){b[h]=g.multiplyVector3(b[h].clone());this.vertices.push(new THREE.Vertex(b[h]));f[h]=this.vertices.length-1}else f=d;j==0&&(d=e);
+THREE.Lathe=function(a,c,b){THREE.Geometry.call(this);this.steps=c||12;this.angle=b||2*Math.PI;c=this.angle/this.steps;b=[];for(var e=[],f=[],d=[],g=(new THREE.Matrix4).setRotationZ(c),h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));b[h]=a[h].clone();e[h]=this.vertices.length-1}for(var j=0;j<=this.angle+0.001;j+=c){for(h=0;h<b.length;h++)if(j<this.angle){b[h]=g.multiplyVector3(b[h].clone());this.vertices.push(new THREE.Vertex(b[h]));f[h]=this.vertices.length-1}else f=d;j==0&&(d=e);
 for(h=0;h<e.length-1;h++){this.faces.push(new THREE.Face4(f[h],f[h+1],e[h+1],e[h]));this.faceVertexUvs[0].push([new THREE.UV(1-j/this.angle,h/a.length),new THREE.UV(1-j/this.angle,(h+1)/a.length),new THREE.UV(1-(j-c)/this.angle,(h+1)/a.length),new THREE.UV(1-(j-c)/this.angle,h/a.length)])}e=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Lathe.prototype=new THREE.Geometry;THREE.Lathe.prototype.constructor=THREE.Lathe;
 THREE.Plane=function(a,c,b,e){THREE.Geometry.call(this);var f,d=a/2,g=c/2;b=b||1;e=e||1;var h=b+1,j=e+1;a/=b;var l=c/e;for(f=0;f<j;f++)for(c=0;c<h;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-d,-(f*l-g),0)));for(f=0;f<e;f++)for(c=0;c<b;c++){this.faces.push(new THREE.Face4(c+h*f,c+h*(f+1),c+1+h*(f+1),c+1+h*f));this.faceVertexUvs[0].push([new THREE.UV(c/b,f/e),new THREE.UV(c/b,(f+1)/e),new THREE.UV((c+1)/b,(f+1)/e),new THREE.UV((c+1)/b,f/e)])}this.computeCentroids();this.computeFaceNormals()};
 THREE.Plane.prototype=new THREE.Geometry;THREE.Plane.prototype.constructor=THREE.Plane;
@@ -101,11 +101,11 @@ Math.LN2));h.image.width=k;h.image.height=m;h.image.getContext("2d").drawImage(t
 "Multiply")d.blending=THREE.MultiplyBlending;if(a.transparent!==undefined||a.opacity<1)d.transparent=a.transparent;if(a.depthTest!==undefined)d.depthTest=a.depthTest;if(a.vertexColors!==undefined)if(a.vertexColors=="face")d.vertexColors=THREE.FaceColors;else if(a.vertexColors)d.vertexColors=THREE.VertexColors;if(a.mapDiffuse&&c){g=document.createElement("canvas");d.map=new THREE.Texture(g);d.map.sourceFile=a.mapDiffuse;e(d.map,c+"/"+a.mapDiffuse)}else if(a.colorDiffuse){g=(a.colorDiffuse[0]*255<<
 16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;d.color=g;d.opacity=a.transparency}else if(a.DbgColor)d.color=a.DbgColor;if(a.mapLightmap&&c){g=document.createElement("canvas");d.lightMap=new THREE.Texture(g);d.lightMap.sourceFile=a.mapLightmap;e(d.lightMap,c+"/"+a.mapLightmap)}return new THREE[f](d)}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
 THREE.JSONLoader.prototype.load=function(a){var c=this,b=a.model,e=a.callback,f=a.texture_path?a.texture_path:this.extractUrlbase(b);a=new Worker(b);a.onmessage=function(d){c.createModel(d.data,e,f);c.onLoadComplete()};this.onLoadStart();a.postMessage((new Date).getTime())};
-THREE.JSONLoader.prototype.createModel=function(a,c,b){var e=new THREE.Geometry,f=a.scale!==undefined?a.scale:1;this.init_materials(e,a.materials,b);(function(d){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");else{var g,h,j,l,k,m,p,n,v,A,w,u,y,o,z=a.faces;m=a.vertices;var B=a.normals,I=a.colors,K=0;for(g=0;g<a.uvs.length;g++)a.uvs[g].length&&K++;for(g=0;g<K;g++){e.faceUvs[g]=[];e.faceVertexUvs[g]=[]}l=0;for(k=m.length;l<k;){p=new THREE.Vertex;p.position.x=m[l++]/d;
-p.position.y=m[l++]/d;p.position.z=m[l++]/d;e.vertices.push(p)}l=0;for(k=z.length;l<k;){d=z[l++];m=d&1;j=d&2;g=d&4;h=d&8;n=d&16;p=d&32;A=d&64;d&=128;if(m){w=new THREE.Face4;w.a=z[l++];w.b=z[l++];w.c=z[l++];w.d=z[l++];m=4}else{w=new THREE.Face3;w.a=z[l++];w.b=z[l++];w.c=z[l++];m=3}if(j){j=z[l++];w.materials=e.materials[j]}j=e.faces.length;if(g)for(g=0;g<K;g++){u=a.uvs[g];v=z[l++];o=u[v*2];v=u[v*2+1];e.faceUvs[g][j]=new THREE.UV(o,v)}if(h)for(g=0;g<K;g++){u=a.uvs[g];y=[];for(h=0;h<m;h++){v=z[l++];o=
-u[v*2];v=u[v*2+1];y[h]=new THREE.UV(o,v)}e.faceVertexUvs[g][j]=y}if(n){n=z[l++]*3;h=new THREE.Vector3;h.x=B[n++];h.y=B[n++];h.z=B[n];w.normal=h}if(p)for(g=0;g<m;g++){n=z[l++]*3;h=new THREE.Vector3;h.x=B[n++];h.y=B[n++];h.z=B[n];w.vertexNormals.push(h)}if(A){p=z[l++];p=new THREE.Color(I[p]);w.color=p}if(d)for(g=0;g<m;g++){p=z[l++];p=new THREE.Color(I[p]);w.vertexColors.push(p)}e.faces.push(w)}}})(f);(function(){var d,g,h,j;if(a.skinWeights){d=0;for(g=a.skinWeights.length;d<g;d+=2){h=a.skinWeights[d];
+THREE.JSONLoader.prototype.createModel=function(a,c,b){var e=new THREE.Geometry,f=a.scale!==undefined?1/a.scale:1;this.init_materials(e,a.materials,b);(function(d){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");else{var g,h,j,l,k,m,p,n,v,A,w,u,y,o,z=a.faces;m=a.vertices;var B=a.normals,I=a.colors,K=0;for(g=0;g<a.uvs.length;g++)a.uvs[g].length&&K++;for(g=0;g<K;g++){e.faceUvs[g]=[];e.faceVertexUvs[g]=[]}l=0;for(k=m.length;l<k;){p=new THREE.Vertex;p.position.x=m[l++]*
+d;p.position.y=m[l++]*d;p.position.z=m[l++]*d;e.vertices.push(p)}l=0;for(k=z.length;l<k;){d=z[l++];m=d&1;j=d&2;g=d&4;h=d&8;n=d&16;p=d&32;A=d&64;d&=128;if(m){w=new THREE.Face4;w.a=z[l++];w.b=z[l++];w.c=z[l++];w.d=z[l++];m=4}else{w=new THREE.Face3;w.a=z[l++];w.b=z[l++];w.c=z[l++];m=3}if(j){j=z[l++];w.materials=e.materials[j]}j=e.faces.length;if(g)for(g=0;g<K;g++){u=a.uvs[g];v=z[l++];o=u[v*2];v=u[v*2+1];e.faceUvs[g][j]=new THREE.UV(o,v)}if(h)for(g=0;g<K;g++){u=a.uvs[g];y=[];for(h=0;h<m;h++){v=z[l++];
+o=u[v*2];v=u[v*2+1];y[h]=new THREE.UV(o,v)}e.faceVertexUvs[g][j]=y}if(n){n=z[l++]*3;h=new THREE.Vector3;h.x=B[n++];h.y=B[n++];h.z=B[n];w.normal=h}if(p)for(g=0;g<m;g++){n=z[l++]*3;h=new THREE.Vector3;h.x=B[n++];h.y=B[n++];h.z=B[n];w.vertexNormals.push(h)}if(A){p=z[l++];p=new THREE.Color(I[p]);w.color=p}if(d)for(g=0;g<m;g++){p=z[l++];p=new THREE.Color(I[p]);w.vertexColors.push(p)}e.faces.push(w)}}})(f);(function(){var d,g,h,j;if(a.skinWeights){d=0;for(g=a.skinWeights.length;d<g;d+=2){h=a.skinWeights[d];
 j=a.skinWeights[d+1];e.skinWeights.push(new THREE.Vector4(h,j,0,0))}}if(a.skinIndices){d=0;for(g=a.skinIndices.length;d<g;d+=2){h=a.skinIndices[d];j=a.skinIndices[d+1];e.skinIndices.push(new THREE.Vector4(h,j,0,0))}}e.bones=a.bones;e.animation=a.animation})();(function(d){if(a.morphTargets!==undefined){var g,h,j,l,k,m,p,n,v;g=0;for(h=a.morphTargets.length;g<h;g++){e.morphTargets[g]={};e.morphTargets[g].name=a.morphTargets[g].name;e.morphTargets[g].vertices=[];n=e.morphTargets[g].vertices;v=a.morphTargets[g].vertices;
-j=0;for(l=v.length;j<l;j+=3){k=v[j]/d;m=v[j+1]/d;p=v[j+2]/d;n.push(new THREE.Vertex(new THREE.Vector3(k,m,p)))}}}if(a.morphColors!==undefined){g=0;for(h=a.morphColors.length;g<h;g++){e.morphColors[g]={};e.morphColors[g].name=a.morphColors[g].name;e.morphColors[g].colors=[];l=e.morphColors[g].colors;k=a.morphColors[g].colors;d=0;for(j=k.length;d<j;d+=3){m=new THREE.Color(16755200);m.setRGB(k[d],k[d+1],k[d+2]);l.push(m)}}}})(f);(function(){if(a.edges!==undefined){var d,g,h;for(d=0;d<a.edges.length;d+=
+j=0;for(l=v.length;j<l;j+=3){k=v[j]*d;m=v[j+1]*d;p=v[j+2]*d;n.push(new THREE.Vertex(new THREE.Vector3(k,m,p)))}}}if(a.morphColors!==undefined){g=0;for(h=a.morphColors.length;g<h;g++){e.morphColors[g]={};e.morphColors[g].name=a.morphColors[g].name;e.morphColors[g].colors=[];l=e.morphColors[g].colors;k=a.morphColors[g].colors;d=0;for(j=k.length;d<j;d+=3){m=new THREE.Color(16755200);m.setRGB(k[d],k[d+1],k[d+2]);l.push(m)}}}})(f);(function(){if(a.edges!==undefined){var d,g,h;for(d=0;d<a.edges.length;d+=
 2){g=a.edges[d];h=a.edges[d+1];e.edges.push(new THREE.Edge(e.vertices[g],e.vertices[h],g,h))}}})();e.computeFaceNormals();c(e)};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
 THREE.BinaryLoader.prototype={load:function(a){var c=a.model,b=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var d=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(g){THREE.BinaryLoader.prototype.loadAjaxBuffers(g.data.buffers,g.data.materials,b,f,e,d)};c.onerror=function(g){alert("worker.onerror: "+g.message+"\n"+g.data);g.preventDefault()};
 c.postMessage(a)},loadAjaxBuffers:function(a,c,b,e,f,d){var g=new XMLHttpRequest,h=e+"/"+a,j=0;g.onreadystatechange=function(){if(g.readyState==4)g.status==200||g.status==0?THREE.BinaryLoader.prototype.createBinModel(g.responseText,b,f,c):alert("Couldn't load ["+h+"] ["+g.status+"]");else if(g.readyState==3){if(d){j==0&&(j=g.getResponseHeader("Content-Length"));d({total:j,loaded:g.responseText.length})}}else g.readyState==2&&(j=g.getResponseHeader("Content-Length"))};g.open("GET",h,!0);g.overrideMimeType("text/plain; charset=x-user-defined");

+ 61 - 62
build/custom/ThreeSVG.js

@@ -1,8 +1,7 @@
 // ThreeSVG.js r40 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}THREE.Color=function(a){this.setHex(a)};
-THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var d,e,h,f,i,g;if(c==0)d=e=h=0;else{f=Math.floor(a*6);i=a*6-f;a=c*(1-b);g=c*(1-b*i);b=c*(1-b*(1-i));switch(f){case 1:d=g;e=c;h=a;break;case 2:d=a;e=c;h=b;break;case 3:d=a;e=g;h=c;break;case 4:d=b;e=a;h=c;break;case 5:d=c;e=a;
-h=g;break;case 6:case 0:d=c;e=b;h=a}}this.r=d;this.g=e;this.b=h;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB: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)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)};
+THREE.Color.prototype={copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex},setHex:function(a){this.hex=~~a&16777215;this.updateRGB()},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;this.updateHex()},setHSV:function(a,b,c){var d,e,g,f,j,h;if(c==0)d=e=g=0;else{f=Math.floor(a*6);j=a*6-f;a=c*(1-b);h=c*(1-b*j);b=c*(1-b*(1-j));switch(f){case 1:d=h;e=c;g=a;break;case 2:d=a;e=c;g=b;break;case 3:d=a;e=h;g=c;break;case 4:d=b;e=a;g=c;break;case 5:d=c;e=a;g=h;break;case 6:case 0:d=c;e=b;g=a}}this.setRGB(d,
+e,g)},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)};
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
 this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)};
 THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
@@ -12,59 +11,59 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPosit
 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)};
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
 a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(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)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(h,f){return h.distance-f.distance});return e},intersectObject:function(a){function b(y,u,H,I){I=I.clone().subSelf(u);H=H.clone().subSelf(u);var D=y.clone().subSelf(u);y=I.dot(I);u=I.dot(H);I=I.dot(D);var w=H.dot(H);H=H.dot(D);D=1/(y*w-u*u);w=(w*I-u*H)*D;y=(y*H-u*I)*D;return w>0&&y>0&&w+y<1}var c,d,e,h,f,i,g,j,m,k,
-n,l=a.geometry,r=l.vertices,s=[];c=0;for(d=l.faces.length;c<d;c++){e=l.faces[c];k=this.origin.clone();n=this.direction.clone();g=a.matrixWorld;h=g.multiplyVector3(r[e.a].position.clone());f=g.multiplyVector3(r[e.b].position.clone());i=g.multiplyVector3(r[e.c].position.clone());g=e instanceof THREE.Face4?g.multiplyVector3(r[e.d].position.clone()):null;j=a.matrixRotationWorld.multiplyVector3(e.normal.clone());m=n.dot(j);if(a.doubleSided||(a.flipSided?m>0:m<0)){j=j.dot((new THREE.Vector3).sub(h,k))/
-m;k=k.addSelf(n.multiplyScalar(j));if(e instanceof THREE.Face3){if(b(k,h,f,i)){e={distance:this.origin.distanceTo(k),point:k,face:e,object:a};s.push(e)}}else if(e instanceof THREE.Face4&&(b(k,h,f,g)||b(k,f,i,g))){e={distance:this.origin.distanceTo(k),point:k,face:e,object:a};s.push(e)}}}return s}};
-THREE.Rectangle=function(){function a(){h=d-b;f=e-c}var b,c,d,e,h,f,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,j,m,k){i=!1;b=g;c=j;d=m;e=k;a()};this.addPoint=function(g,j){if(i){i=!1;b=g;c=j;d=g;e=j}else{b=b<g?b:g;c=c<j?c:j;d=d>g?d:g;e=e>j?e:j}a()};
-this.add3Points=function(g,j,m,k,n,l){if(i){i=!1;b=g<m?g<n?g:n:m<n?m:n;c=j<k?j<l?j:l:k<l?k:l;d=g>m?g>n?g:n:m>n?m:n;e=j>k?j>l?j:l:k>l?k:l}else{b=g<m?g<n?g<b?g:b:n<b?n:b:m<n?m<b?m:b:n<b?n:b;c=j<k?j<l?j<c?j:c:l<c?l:c:k<l?k<c?k:c:l<c?l:c;d=g>m?g>n?g>d?g:d:n>d?n:d:m>n?m>d?m:d:n>d?n:d;e=j>k?j>l?j>e?j:e:l>e?l:e:k>l?k>e?k:e:l>e?l:e}a()};this.addRectangle=function(g){if(i){i=!1;b=g.getLeft();c=g.getTop();d=g.getRight();e=g.getBottom()}else{b=b<g.getLeft()?b:g.getLeft();c=c<g.getTop()?c:g.getTop();d=d>g.getRight()?
-d:g.getRight();e=e>g.getBottom()?e:g.getBottom()}a()};this.inflate=function(g){b-=g;c-=g;d+=g;e+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d<g.getRight()?d:g.getRight();e=e<g.getBottom()?e:g.getBottom();a()};this.instersects=function(g){return Math.min(d,g.getRight())-Math.max(b,g.getLeft())>=0&&Math.min(e,g.getBottom())-Math.max(c,g.getTop())>=0};this.empty=function(){i=!0;e=d=c=b=0;a()};this.isEmpty=function(){return i}};
+THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(g,f){return g.distance-f.distance});return e},intersectObject:function(a){function b(v,w,I,D){D=D.clone().subSelf(w);I=I.clone().subSelf(w);var N=v.clone().subSelf(w);v=D.dot(D);w=D.dot(I);D=D.dot(N);var x=I.dot(I);I=I.dot(N);N=1/(v*x-w*w);x=(x*D-w*I)*N;v=(v*I-w*D)*N;return x>0&&v>0&&x+v<1}var c,d,e,g,f,j,h,i,k,n,
+m,o=a.geometry,q=o.vertices,r=[];c=0;for(d=o.faces.length;c<d;c++){e=o.faces[c];n=this.origin.clone();m=this.direction.clone();h=a.matrixWorld;g=h.multiplyVector3(q[e.a].position.clone());f=h.multiplyVector3(q[e.b].position.clone());j=h.multiplyVector3(q[e.c].position.clone());h=e instanceof THREE.Face4?h.multiplyVector3(q[e.d].position.clone()):null;i=a.matrixRotationWorld.multiplyVector3(e.normal.clone());k=m.dot(i);if(a.doubleSided||(a.flipSided?k>0:k<0)){i=i.dot((new THREE.Vector3).sub(g,n))/
+k;n=n.addSelf(m.multiplyScalar(i));if(e instanceof THREE.Face3){if(b(n,g,f,j)){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};r.push(e)}}else if(e instanceof THREE.Face4&&(b(n,g,f,h)||b(n,f,j,h))){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};r.push(e)}}}return r}};
+THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,j=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(h,i,k,n){j=!1;b=h;c=i;d=k;e=n;a()};this.addPoint=function(h,i){if(j){j=!1;b=h;c=i;d=h;e=i}else{b=b<h?b:h;c=c<i?c:i;d=d>h?d:h;e=e>i?e:i}a()};
+this.add3Points=function(h,i,k,n,m,o){if(j){j=!1;b=h<k?h<m?h:m:k<m?k:m;c=i<n?i<o?i:o:n<o?n:o;d=h>k?h>m?h:m:k>m?k:m;e=i>n?i>o?i:o:n>o?n:o}else{b=h<k?h<m?h<b?h:b:m<b?m:b:k<m?k<b?k:b:m<b?m:b;c=i<n?i<o?i<c?i:c:o<c?o:c:n<o?n<c?n:c:o<c?o:c;d=h>k?h>m?h>d?h:d:m>d?m:d:k>m?k>d?k:d:m>d?m:d;e=i>n?i>o?i>e?i:e:o>e?o:e:n>o?n>e?n:e:o>e?o:e}a()};this.addRectangle=function(h){if(j){j=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();d=d>h.getRight()?
+d:h.getRight();e=e>h.getBottom()?e:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;d+=h;e+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();d=d<h.getRight()?d:h.getRight();e=e<h.getBottom()?e:h.getBottom();a()};this.instersects=function(h){return Math.min(d,h.getRight())-Math.max(b,h.getLeft())>=0&&Math.min(e,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){j=!0;e=d=c=b=0;a()};this.isEmpty=function(){return j}};
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
-THREE.Matrix4=function(a,b,c,d,e,h,f,i,g,j,m,k,n,l,r,s){this.set(a||1,b||0,c||0,d||0,e||0,h||1,f||0,i||0,g||0,j||0,m||1,k||0,n||0,l||0,r||0,s||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(a,b,c,d,e,h,f,i,g,j,m,k,n,l,r,s){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=h;this.n23=f;this.n24=i;this.n31=g;this.n32=j;this.n33=m;this.n34=k;this.n41=n;this.n42=l;this.n43=r;this.n44=s;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__v1,
-e=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,b).normalize();if(h.length()===0)h.z=1;d.cross(c,h).normalize();if(d.length()===0){h.x+=1.0E-4;d.cross(c,h).normalize()}e.cross(h,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=h.x;this.n21=d.y;this.n22=e.y;this.n23=h.y;this.n31=d.z;this.n32=e.z;this.n33=h.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*
+THREE.Matrix4=function(a,b,c,d,e,g,f,j,h,i,k,n,m,o,q,r){this.set(a||1,b||0,c||0,d||0,e||0,g||1,f||0,j||0,h||0,i||0,k||1,n||0,m||0,o||0,q||0,r||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,c,d,e,g,f,j,h,i,k,n,m,o,q,r){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=f;this.n24=j;this.n31=h;this.n32=i;this.n33=k;this.n34=n;this.n41=m;this.n42=o;this.n43=q;this.n44=r;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__v1,
+e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;d.cross(c,g).normalize();if(d.length()===0){g.x+=1.0E-4;d.cross(c,g).normalize()}e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*
 d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();
-return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,h=a.n14,f=a.n21,i=a.n22,g=a.n23,j=a.n24,m=a.n31,k=a.n32,n=a.n33,l=a.n34,r=a.n41,s=a.n42,y=a.n43,u=a.n44,H=b.n11,I=b.n12,D=b.n13,w=b.n14,o=b.n21,O=b.n22,
-J=b.n23,K=b.n24,P=b.n31,C=b.n32,x=b.n33,F=b.n34;this.n11=c*H+d*o+e*P;this.n12=c*I+d*O+e*C;this.n13=c*D+d*J+e*x;this.n14=c*w+d*K+e*F+h;this.n21=f*H+i*o+g*P;this.n22=f*I+i*O+g*C;this.n23=f*D+i*J+g*x;this.n24=f*w+i*K+g*F+j;this.n31=m*H+k*o+n*P;this.n32=m*I+k*O+n*C;this.n33=m*D+k*J+n*x;this.n34=m*w+k*K+n*F+l;this.n41=r*H+s*o+y*P;this.n42=r*I+s*O+y*C;this.n43=r*D+s*J+y*x;this.n44=r*w+s*K+y*F+u;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=
+return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,j=a.n22,h=a.n23,i=a.n24,k=a.n31,n=a.n32,m=a.n33,o=a.n34,q=a.n41,r=a.n42,v=a.n43,w=a.n44,I=b.n11,D=b.n12,N=b.n13,x=b.n14,l=b.n21,J=b.n22,
+K=b.n23,P=b.n24,L=b.n31,B=b.n32,z=b.n33,M=b.n34;this.n11=c*I+d*l+e*L;this.n12=c*D+d*J+e*B;this.n13=c*N+d*K+e*z;this.n14=c*x+d*P+e*M+g;this.n21=f*I+j*l+h*L;this.n22=f*D+j*J+h*B;this.n23=f*N+j*K+h*z;this.n24=f*x+j*P+h*M+i;this.n31=k*I+n*l+m*L;this.n32=k*D+n*J+m*B;this.n33=k*N+n*K+m*z;this.n34=k*x+n*P+m*M+o;this.n41=q*I+r*l+v*L;this.n42=q*D+r*J+v*B;this.n43=q*N+r*K+v*z;this.n44=q*x+r*P+v*M+w;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=
 this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=
-this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,h=this.n22,f=this.n23,i=this.n24,g=this.n31,j=this.n32,m=this.n33,k=this.n34,n=this.n41,l=this.n42,r=this.n43,s=this.n44;return d*f*j*n-c*i*j*n-d*h*m*n+b*i*m*n+c*h*k*n-b*f*k*n-d*f*g*l+c*i*g*l+d*e*m*l-a*i*m*l-c*e*k*l+a*f*k*l+d*h*g*r-b*i*g*r-d*e*j*r+a*i*j*r+b*e*k*r-a*h*k*r-c*h*g*s+b*f*g*s+c*e*j*s-a*f*j*s-b*e*m*s+a*h*m*s},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=
+this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,g=this.n22,f=this.n23,j=this.n24,h=this.n31,i=this.n32,k=this.n33,n=this.n34,m=this.n41,o=this.n42,q=this.n43,r=this.n44;return d*f*i*m-c*j*i*m-d*g*k*m+b*j*k*m+c*g*n*m-b*f*n*m-d*f*h*o+c*j*h*o+d*e*k*o-a*j*k*o-c*e*n*o+a*f*n*o+d*g*h*q-b*j*h*q-d*e*i*q+a*j*i*q+b*e*n*q-a*g*n*q-c*g*h*r+b*f*h*r+c*e*i*r-a*f*i*r-b*e*k*r+a*g*k*r},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=
 this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flat[0]=this.n11;this.flat[1]=this.n21;
 this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=
 this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,
-b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX: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},setRotationY: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},setRotationZ: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},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,h=a.x,f=a.y,i=a.z,g=e*h,j=e*f;this.set(g*
-h+c,g*f-d*i,g*i+d*f,0,g*f+d*i,j*f+c,j*i-d*h,0,g*i-d*f,j*i+d*h,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX=new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;
-this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var h=Math.cos(d);d=Math.sin(d);var f=a*c,i=b*c;this.n11=e*h;this.n12=-e*d;this.n13=c;this.n21=i*h+a*d;this.n22=-i*d+a*h;this.n23=-b*e;this.n31=-f*h+b*d;this.n32=f*d+b*h;this.n33=a*e;return this},
-setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,h=b+b,f=c+c,i=d+d;a=b*h;var g=b*f;b*=i;var j=c*f;c*=i;d*=i;h*=e;f*=e;e*=i;this.n11=1-(j+d);this.n12=g-e;this.n13=b+f;this.n21=g+e;this.n22=1-(a+d);this.n23=c-h;this.n31=b-f;this.n32=c+h;this.n33=1-(a+j);return this},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=
+b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX: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},setRotationY: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},setRotationZ: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},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,g=a.x,f=a.y,j=a.z,h=e*g,i=e*f;this.set(h*
+g+c,h*f-d*j,h*j+d*f,0,h*f+d*j,i*f+c,i*j-d*g,0,h*j-d*f,i*j+d*g,e*j*j+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX=new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;
+this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var f=a*c,j=b*c;this.n11=e*g;this.n12=-e*d;this.n13=c;this.n21=j*g+a*d;this.n22=-j*d+a*g;this.n23=-b*e;this.n31=-f*g+b*d;this.n32=f*d+b*g;this.n33=a*e;return this},
+setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,g=b+b,f=c+c,j=d+d;a=b*g;var h=b*f;b*=j;var i=c*f;c*=j;d*=j;g*=e;f*=e;e*=j;this.n11=1-(i+d);this.n12=h-e;this.n13=b+f;this.n21=h+e;this.n22=1-(a+d);this.n23=c-g;this.n31=b-f;this.n32=c+g;this.n33=1-(a+i);return this},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=
 a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/b.y,e=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,h=a.n14,f=a.n21,i=a.n22,g=a.n23,j=a.n24,m=a.n31,k=a.n32,n=a.n33,l=a.n34,r=a.n41,s=a.n42,y=a.n43,u=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=g*l*s-j*n*s+j*k*y-i*l*y-g*k*u+i*n*u;b.n12=h*n*s-e*l*s-h*k*y+d*l*y+e*k*u-d*n*u;b.n13=e*j*s-h*g*s+h*i*y-d*j*y-e*i*u+d*g*u;b.n14=h*g*k-e*j*k-h*i*n+d*j*n+e*i*l-d*g*l;b.n21=j*n*r-g*l*r-j*m*y+f*l*y+g*m*u-f*n*u;b.n22=e*l*r-h*n*r+h*m*y-c*l*y-e*m*u+c*n*u;b.n23=h*g*r-e*j*r-h*f*y+c*j*y+e*f*u-c*g*u;
-b.n24=e*j*m-h*g*m+h*f*n-c*j*n-e*f*l+c*g*l;b.n31=i*l*r-j*k*r+j*m*s-f*l*s-i*m*u+f*k*u;b.n32=h*k*r-d*l*r-h*m*s+c*l*s+d*m*u-c*k*u;b.n33=e*j*r-h*i*r+h*f*s-c*j*s-d*f*u+c*i*u;b.n34=h*i*m-d*j*m-h*f*k+c*j*k+d*f*l-c*i*l;b.n41=g*k*r-i*n*r-g*m*s+f*n*s+i*m*y-f*k*y;b.n42=d*n*r-e*k*r+e*m*s-c*n*s-d*m*y+c*k*y;b.n43=e*i*r-d*g*r-e*f*s+c*g*s+d*f*y-c*i*y;b.n44=d*g*m-e*i*m+e*f*k-c*g*k-d*f*n+c*i*n;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,e=-a.n33*a.n21+a.n31*a.n23,h=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,g=-a.n32*a.n11+a.n31*a.n12,j=a.n23*a.n12-a.n22*a.n13,m=-a.n23*a.n11+a.n21*a.n13,k=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*f+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*h;c[3]=a*f;c[4]=a*i;c[5]=a*g;c[6]=a*j;c[7]=a*m;c[8]=a*k;return b};
-THREE.Matrix4.makeFrustum=function(a,b,c,d,e,h){var f;f=new THREE.Matrix4;f.n11=2*e/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*e/(d-c);f.n23=(d+c)/(d-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(h+e)/(h-e);f.n34=-2*h*e/(h-e);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
-THREE.Matrix4.makeOrtho=function(a,b,c,d,e,h){var f,i,g,j;f=new THREE.Matrix4;i=b-a;g=c-d;j=h-e;f.n11=2/i;f.n12=0;f.n13=0;f.n14=-((b+a)/i);f.n21=0;f.n22=2/g;f.n23=0;f.n24=-((c+d)/g);f.n31=0;f.n32=0;f.n33=-2/j;f.n34=-((h+e)/j);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,j=a.n22,h=a.n23,i=a.n24,k=a.n31,n=a.n32,m=a.n33,o=a.n34,q=a.n41,r=a.n42,v=a.n43,w=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*r-i*m*r+i*n*v-j*o*v-h*n*w+j*m*w;b.n12=g*m*r-e*o*r-g*n*v+d*o*v+e*n*w-d*m*w;b.n13=e*i*r-g*h*r+g*j*v-d*i*v-e*j*w+d*h*w;b.n14=g*h*n-e*i*n-g*j*m+d*i*m+e*j*o-d*h*o;b.n21=i*m*q-h*o*q-i*k*v+f*o*v+h*k*w-f*m*w;b.n22=e*o*q-g*m*q+g*k*v-c*o*v-e*k*w+c*m*w;b.n23=g*h*q-e*i*q-g*f*v+c*i*v+e*f*w-c*h*w;
+b.n24=e*i*k-g*h*k+g*f*m-c*i*m-e*f*o+c*h*o;b.n31=j*o*q-i*n*q+i*k*r-f*o*r-j*k*w+f*n*w;b.n32=g*n*q-d*o*q-g*k*r+c*o*r+d*k*w-c*n*w;b.n33=e*i*q-g*j*q+g*f*r-c*i*r-d*f*w+c*j*w;b.n34=g*j*k-d*i*k-g*f*n+c*i*n+d*f*o-c*j*o;b.n41=h*n*q-j*m*q-h*k*r+f*m*r+j*k*v-f*n*v;b.n42=d*m*q-e*n*q+e*k*r-c*m*r-d*k*v+c*n*v;b.n43=e*j*q-d*h*q-e*f*r+c*h*r+d*f*v-c*j*v;b.n44=d*h*k-e*j*k+e*f*n-c*h*n-d*f*m+c*j*m;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,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,k=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*f+a.n31*i;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*f;c[4]=a*j;c[5]=a*h;c[6]=a*i;c[7]=a*k;c[8]=a*n;return b};
+THREE.Matrix4.makeFrustum=function(a,b,c,d,e,g){var f;f=new THREE.Matrix4;f.n11=2*e/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*e/(d-c);f.n23=(d+c)/(d-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(g+e)/(g-e);f.n34=-2*g*e/(g-e);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
+THREE.Matrix4.makeOrtho=function(a,b,c,d,e,g){var f,j,h,i;f=new THREE.Matrix4;j=b-a;h=c-d;i=g-e;f.n11=2/j;f.n12=0;f.n13=0;f.n14=-((b+a)/j);f.n21=0;f.n22=2/h;f.n23=0;f.n24=-((c+d)/h);f.n31=0;f.n32=0;f.n33=-2/i;f.n34=-((g+e)/i);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
 THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=
 !0;this._vector=new THREE.Vector3;this.name=""};
 THREE.Object3D.prototype={translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===
 -1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==undefined;)b=b.parent;b!==undefined&&b instanceof THREE.Scene&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},getChildByName:function(a,b){var c,d,e;c=0;for(d=this.children.length;c<d;c++){e=this.children[c];if(e.name===a)return e;if(b){e=e.getChildByName(a,b);if(e!==undefined)return e}}},updateMatrix:function(){this.matrix.setPosition(this.position);
 this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||b){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);
 this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;b=!0}a=0;for(var d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,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},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-e);e=Math.sin(-e);var h=Math.cos(c);c=Math.sin(c);var f=a*b,i=d*e;this.w=f*h-i*c;this.x=f*c+i*h;this.y=d*b*h+a*e*c;this.z=a*e*h-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=
+THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-e);e=Math.sin(-e);var g=Math.cos(c);c=Math.sin(c);var f=a*b,j=d*e;this.w=f*g-j*c;this.x=f*c+j*g;this.y=d*b*g+a*e*c;this.z=a*e*g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=
 a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},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},
-multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,h=a.x,f=a.y,i=a.z;a=a.w;this.x=b*a+e*h+c*i-d*f;this.y=c*a+e*f+d*h-b*i;this.z=d*a+e*i+b*f-c*h;this.w=e*a-b*h-c*f-d*i;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,h=this.x,f=this.y,i=this.z,g=this.w,j=g*c+f*e-i*d,m=
-g*d+i*c-h*e,k=g*e+h*d-f*c;c=-h*c-f*d-i*e;b.x=j*g+c*-h+m*-i-k*-f;b.y=m*g+c*-f+k*-h-j*-i;b.z=k*g+c*-i+j*-f-m*-h;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<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}e=Math.sin((1-d)*h)/f;d=Math.sin(d*h)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
-THREE.Face3=function(a,b,c,d,e,h){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};
-THREE.Face4=function(a,b,c,d,e,h,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
+multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,j=a.z;a=a.w;this.x=b*a+e*g+c*j-d*f;this.y=c*a+e*f+d*g-b*j;this.z=d*a+e*j+b*f-c*g;this.w=e*a-b*g-c*f-d*j;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,j=this.z,h=this.w,i=h*c+f*e-j*d,k=
+h*d+j*c-g*e,n=h*e+g*d-f*c;c=-g*c-f*d-j*e;b.x=i*h+c*-g+k*-j-n*-f;b.y=k*h+c*-f+n*-g-i*-j;b.z=n*h+c*-j+i*-f-k*-g;return b}};
+THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.001){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}e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
+THREE.Face4=function(a,b,c,d,e,g,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);
-c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,e,h,f,i=new THREE.Vector3,g=new THREE.Vector3;d=0;for(e=this.faces.length;d<e;d++){h=this.faces[d];if(a&&h.vertexNormals.length){i.set(0,0,0);b=0;for(c=h.vertexNormals.length;b<c;b++)i.addSelf(h.vertexNormals[b]);i.divideScalar(3)}else{b=this.vertices[h.a];c=this.vertices[h.b];f=this.vertices[h.c];i.sub(f.position,c.position);g.sub(b.position,c.position);i.crossSelf(g)}i.isZero()||
-i.normalize();h.normal.copy(i)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=
+c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,e,g,f,j=new THREE.Vector3,h=new THREE.Vector3;d=0;for(e=this.faces.length;d<e;d++){g=this.faces[d];if(a&&g.vertexNormals.length){j.set(0,0,0);b=0;for(c=g.vertexNormals.length;b<c;b++)j.addSelf(g.vertexNormals[b]);j.divideScalar(3)}else{b=this.vertices[g.a];c=this.vertices[g.b];f=this.vertices[g.c];j.sub(f.position,c.position);h.sub(b.position,c.position);j.crossSelf(h)}j.isZero()||
+j.normalize();g.normal.copy(j)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=
 this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal);d[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);
-c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(t,G,z,E,p,q,A){i=t.vertices[G].position;g=t.vertices[z].position;j=t.vertices[E].position;m=f[p];k=f[q];n=f[A];l=g.x-i.x;r=j.x-i.x;s=g.y-i.y;y=j.y-i.y;u=g.z-i.z;H=j.z-i.z;I=k.u-m.u;D=n.u-m.u;w=k.v-m.v;o=n.v-m.v;O=1/(I*o-D*w);C.set((o*
-l-w*r)*O,(o*s-w*y)*O,(o*u-w*H)*O);x.set((I*r-D*l)*O,(I*y-D*s)*O,(I*H-D*u)*O);K[G].addSelf(C);K[z].addSelf(C);K[E].addSelf(C);P[G].addSelf(x);P[z].addSelf(x);P[E].addSelf(x)}var b,c,d,e,h,f,i,g,j,m,k,n,l,r,s,y,u,H,I,D,w,o,O,J,K=[],P=[],C=new THREE.Vector3,x=new THREE.Vector3,F=new THREE.Vector3,M=new THREE.Vector3,Q=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){K[b]=new THREE.Vector3;P[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){h=this.faces[b];f=this.faceVertexUvs[0][b];
-if(h instanceof THREE.Face3)a(this,h.a,h.b,h.c,0,1,2);else if(h instanceof THREE.Face4){a(this,h.a,h.b,h.c,0,1,2);a(this,h.a,h.b,h.d,0,1,3)}}var L=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){h=this.faces[b];for(d=0;d<h.vertexNormals.length;d++){Q.copy(h.vertexNormals[d]);e=h[L[d]];J=K[e];F.copy(J);F.subSelf(Q.multiplyScalar(Q.dot(J))).normalize();M.cross(h.vertexNormals[d],J);e=M.dot(P[e]);e=e<0?-1:1;h.vertexTangents[d]=new THREE.Vector4(F.x,F.y,F.z,e)}}this.hasTangents=!0},computeBoundingBox:function(){var a;
+c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(F,t,C,A,y,s,p){j=F.vertices[t].position;h=F.vertices[C].position;i=F.vertices[A].position;k=f[y];n=f[s];m=f[p];o=h.x-j.x;q=i.x-j.x;r=h.y-j.y;v=i.y-j.y;w=h.z-j.z;I=i.z-j.z;D=n.u-k.u;N=m.u-k.u;x=n.v-k.v;l=m.v-k.v;J=1/(D*l-N*x);B.set((l*
+o-x*q)*J,(l*r-x*v)*J,(l*w-x*I)*J);z.set((D*q-N*o)*J,(D*v-N*r)*J,(D*I-N*w)*J);P[t].addSelf(B);P[C].addSelf(B);P[A].addSelf(B);L[t].addSelf(z);L[C].addSelf(z);L[A].addSelf(z)}var b,c,d,e,g,f,j,h,i,k,n,m,o,q,r,v,w,I,D,N,x,l,J,K,P=[],L=[],B=new THREE.Vector3,z=new THREE.Vector3,M=new THREE.Vector3,G=new THREE.Vector3,Q=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){P[b]=new THREE.Vector3;L[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){g=this.faces[b];f=this.faceVertexUvs[0][b];
+if(g instanceof THREE.Face3)a(this,g.a,g.b,g.c,0,1,2);else if(g instanceof THREE.Face4){a(this,g.a,g.b,g.c,0,1,2);a(this,g.a,g.b,g.d,0,1,3)}}var O=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){g=this.faces[b];for(d=0;d<g.vertexNormals.length;d++){Q.copy(g.vertexNormals[d]);e=g[O[d]];K=P[e];M.copy(K);M.subSelf(Q.multiplyScalar(Q.dot(K))).normalize();G.cross(g.vertexNormals[d],K);e=G.dot(L[e]);e=e<0?-1:1;g.vertexTangents[d]=new THREE.Vector4(M.x,M.y,M.z,e)}}this.hasTangents=!0},computeBoundingBox:function(){var a;
 if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;
-else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},computeEdgeFaces:function(){function a(g,j){return Math.min(g,
-j)+"_"+Math.max(g,j)}function b(g,j,m){if(g[j]===undefined){g[j]={set:{},array:[]};g[j].set[m]=1;g[j].array.push(m)}else if(g[j].set[m]===undefined){g[j].set[m]=1;g[j].array.push(m)}}var c,d,e,h,f,i={};c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];if(f instanceof THREE.Face3){e=a(f.a,f.b);b(i,e,c);e=a(f.b,f.c);b(i,e,c);e=a(f.a,f.c);b(i,e,c)}else if(f instanceof THREE.Face4){e=a(f.b,f.d);b(i,e,c);e=a(f.a,f.b);b(i,e,c);e=a(f.a,f.d);b(i,e,c);e=a(f.b,f.c);b(i,e,c);e=a(f.c,f.d);b(i,e,c)}}c=0;for(d=
-this.edges.length;c<d;c++){f=this.edges[c];e=f.vertexIndices[0];h=f.vertexIndices[1];f.faceIndices=i[a(e,h)].array;for(e=0;e<f.faceIndices.length;e++){h=f.faceIndices[e];f.faces.push(this.faces[h])}}}};THREE.GeometryIdCounter=0;THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};
+else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},computeEdgeFaces:function(){function a(h,i){return Math.min(h,
+i)+"_"+Math.max(h,i)}function b(h,i,k){if(h[i]===undefined){h[i]={set:{},array:[]};h[i].set[k]=1;h[i].array.push(k)}else if(h[i].set[k]===undefined){h[i].set[k]=1;h[i].array.push(k)}}var c,d,e,g,f,j={};c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];if(f instanceof THREE.Face3){e=a(f.a,f.b);b(j,e,c);e=a(f.b,f.c);b(j,e,c);e=a(f.a,f.c);b(j,e,c)}else if(f instanceof THREE.Face4){e=a(f.b,f.d);b(j,e,c);e=a(f.a,f.b);b(j,e,c);e=a(f.a,f.d);b(j,e,c);e=a(f.b,f.c);b(j,e,c);e=a(f.c,f.d);b(j,e,c)}}c=0;for(d=
+this.edges.length;c<d;c++){f=this.edges[c];e=f.vertexIndices[0];g=f.vertexIndices[1];f.faceIndices=j[a(e,g)].array;for(e=0;e<f.faceIndices.length;e++){g=f.faceIndices[e];f.faces.push(this.faces[g])}}}};THREE.GeometryIdCounter=0;THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};
 THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
 THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&this.updateMatrix();if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
 !1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};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;
@@ -99,30 +98,30 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.c
 THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1){this.objects.push(a);this.__objectsAdded.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.Sound){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);if(b!==-1){this.objects.splice(b,1);this.__objectsRemoved.push(a)}}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.Projector=function(){function a(){var C=g[i]=g[i]||new THREE.RenderableVertex;i++;return C}function b(C,x){return x.z-C.z}function c(C,x){var F=0,M=1,Q=C.z+C.w,L=x.z+x.w,t=-C.z+C.w,G=-x.z+x.w;if(Q>=0&&L>=0&&t>=0&&G>=0)return!0;else if(Q<0&&L<0||t<0&&G<0)return!1;else{if(Q<0)F=Math.max(F,Q/(Q-L));else L<0&&(M=Math.min(M,Q/(Q-L)));if(t<0)F=Math.max(F,t/(t-G));else G<0&&(M=Math.min(M,t/(t-G)));if(M<F)return!1;else{C.lerpSelf(x,F);x.lerpSelf(C,1-M);return!0}}}var d,e,h=[],f,i,g=[],j,m,k=[],n,l=
-[],r,s,y=[],u,H,I=[],D=new THREE.Vector4,w=new THREE.Vector4,o=new THREE.Matrix4,O=new THREE.Matrix4,J=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],K=new THREE.Vector4,P=new THREE.Vector4;this.projectVector=function(C,x){o.multiply(x.projectionMatrix,x.matrixWorldInverse);o.multiplyVector3(C);return C};this.unprojectVector=function(C,x){o.multiply(x.matrixWorld,THREE.Matrix4.makeInvert(x.projectionMatrix));o.multiplyVector3(C);return C};
-this.projectObjects=function(C,x,F){x=[];var M,Q,L;e=0;Q=C.objects;C=0;for(M=Q.length;C<M;C++){L=Q[C];var t;if(!(t=!L.visible))if(t=L instanceof THREE.Mesh){a:{t=void 0;for(var G=L.matrixWorld,z=-L.geometry.boundingSphere.radius*Math.max(L.scale.x,Math.max(L.scale.y,L.scale.z)),E=0;E<6;E++){t=J[E].x*G.n14+J[E].y*G.n24+J[E].z*G.n34+J[E].w;if(t<=z){t=!1;break a}}t=!0}t=!t}if(!t){t=h[e]=h[e]||new THREE.RenderableObject;e++;d=t;D.copy(L.position);o.multiplyVector3(D);d.object=L;d.z=D.z;x.push(d)}}F&&
-x.sort(b);return x};this.projectScene=function(C,x,F){var M=[],Q=x.near,L=x.far,t,G,z,E,p,q,A,N,B,v,R,U,W,X,S,V,T;H=s=n=m=0;x.matrixAutoUpdate&&x.update(undefined,!0);C.update(undefined,!1,x);o.multiply(x.projectionMatrix,x.matrixWorldInverse);J[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);J[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);J[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);J[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);J[4].set(o.n41-o.n31,o.n42-
-o.n32,o.n43-o.n33,o.n44-o.n34);J[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(t=0;t<6;t++){B=J[t];B.divideScalar(Math.sqrt(B.x*B.x+B.y*B.y+B.z*B.z))}B=this.projectObjects(C,x,!0);C=0;for(t=B.length;C<t;C++){v=B[C].object;if(v.visible){R=v.matrixWorld;U=v.matrixRotationWorld;W=v.materials;X=v.overdraw;i=0;if(v instanceof THREE.Mesh){S=v.geometry;E=S.vertices;V=S.faces;S=S.faceVertexUvs;G=0;for(z=E.length;G<z;G++){f=a();f.positionWorld.copy(E[G].position);R.multiplyVector3(f.positionWorld);
-f.positionScreen.copy(f.positionWorld);o.multiplyVector4(f.positionScreen);f.positionScreen.x/=f.positionScreen.w;f.positionScreen.y/=f.positionScreen.w;f.visible=f.positionScreen.z>Q&&f.positionScreen.z<L}E=0;for(G=V.length;E<G;E++){z=V[E];if(z instanceof THREE.Face3){p=g[z.a];q=g[z.b];A=g[z.c];if(p.visible&&q.visible&&A.visible&&(v.doubleSided||v.flipSided!=(A.positionScreen.x-p.positionScreen.x)*(q.positionScreen.y-p.positionScreen.y)-(A.positionScreen.y-p.positionScreen.y)*(q.positionScreen.x-
-p.positionScreen.x)<0)){N=k[m]=k[m]||new THREE.RenderableFace3;m++;j=N;j.v1.copy(p);j.v2.copy(q);j.v3.copy(A)}else continue}else if(z instanceof THREE.Face4){p=g[z.a];q=g[z.b];A=g[z.c];N=g[z.d];if(p.visible&&q.visible&&A.visible&&N.visible&&(v.doubleSided||v.flipSided!=((N.positionScreen.x-p.positionScreen.x)*(q.positionScreen.y-p.positionScreen.y)-(N.positionScreen.y-p.positionScreen.y)*(q.positionScreen.x-p.positionScreen.x)<0||(q.positionScreen.x-A.positionScreen.x)*(N.positionScreen.y-A.positionScreen.y)-
-(q.positionScreen.y-A.positionScreen.y)*(N.positionScreen.x-A.positionScreen.x)<0))){T=l[n]=l[n]||new THREE.RenderableFace4;n++;j=T;j.v1.copy(p);j.v2.copy(q);j.v3.copy(A);j.v4.copy(N)}else continue}j.normalWorld.copy(z.normal);U.multiplyVector3(j.normalWorld);j.centroidWorld.copy(z.centroid);R.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);o.multiplyVector3(j.centroidScreen);A=z.vertexNormals;p=0;for(q=A.length;p<q;p++){N=j.vertexNormalsWorld[p];N.copy(A[p]);U.multiplyVector3(N)}p=
-0;for(q=S.length;p<q;p++)if(T=S[p][E]){A=0;for(N=T.length;A<N;A++)j.uvs[p][A]=T[A]}j.meshMaterials=W;j.faceMaterials=z.materials;j.overdraw=X;j.z=j.centroidScreen.z;M.push(j)}}else if(v instanceof THREE.Line){O.multiply(o,R);E=v.geometry.vertices;p=a();p.positionScreen.copy(E[0].position);O.multiplyVector4(p.positionScreen);G=1;for(z=E.length;G<z;G++){p=a();p.positionScreen.copy(E[G].position);O.multiplyVector4(p.positionScreen);q=g[i-2];K.copy(p.positionScreen);P.copy(q.positionScreen);if(c(K,P)){K.multiplyScalar(1/
-K.w);P.multiplyScalar(1/P.w);R=y[s]=y[s]||new THREE.RenderableLine;s++;r=R;r.v1.positionScreen.copy(K);r.v2.positionScreen.copy(P);r.z=Math.max(K.z,P.z);r.materials=v.materials;M.push(r)}}}else if(v instanceof THREE.Particle){w.set(v.matrixWorld.n14,v.matrixWorld.n24,v.matrixWorld.n34,1);o.multiplyVector4(w);w.z/=w.w;if(w.z>0&&w.z<1){R=I[H]=I[H]||new THREE.RenderableParticle;H++;u=R;u.x=w.x/w.w;u.y=w.y/w.w;u.z=w.z;u.rotation=v.rotation.z;u.scale.x=v.scale.x*Math.abs(u.x-(w.x+x.projectionMatrix.n11)/
-(w.w+x.projectionMatrix.n14));u.scale.y=v.scale.y*Math.abs(u.y-(w.y+x.projectionMatrix.n22)/(w.w+x.projectionMatrix.n24));u.materials=v.materials;M.push(u)}}}}F&&M.sort(b);return M}};
-THREE.SVGRenderer=function(){function a(t,G,z){var E,p,q,A;E=0;for(p=t.lights.length;E<p;E++){q=t.lights[E];if(q instanceof THREE.DirectionalLight){A=G.normalWorld.dot(q.position)*q.intensity;if(A>0){z.r+=q.color.r*A;z.g+=q.color.g*A;z.b+=q.color.b*A}}else if(q instanceof THREE.PointLight){P.sub(q.position,G.centroidWorld);P.normalize();A=G.normalWorld.dot(P)*q.intensity;if(A>0){z.r+=q.color.r*A;z.g+=q.color.g*A;z.b+=q.color.b*A}}}}function b(t,G,z,E,p,q){h.data.vertices+=3;h.data.faces++;F=d(M++);
-F.setAttribute("d","M "+t.positionScreen.x+" "+t.positionScreen.y+" L "+G.positionScreen.x+" "+G.positionScreen.y+" L "+z.positionScreen.x+","+z.positionScreen.y+"z");if(p instanceof THREE.MeshBasicMaterial)D.__styleString=p.color.__styleString;else if(p instanceof THREE.MeshLambertMaterial)if(I){w.r=o.r;w.g=o.g;w.b=o.b;a(q,E,w);D.r=p.color.r*w.r;D.g=p.color.g*w.g;D.b=p.color.b*w.b;D.updateStyleString()}else D.__styleString=p.color.__styleString;else if(p instanceof THREE.MeshDepthMaterial){K=1-p.__2near/
-(p.__farPlusNear-E.z*p.__farMinusNear);D.setRGB(K,K,K)}else p instanceof THREE.MeshNormalMaterial&&D.setRGB(e(E.normalWorld.x),e(E.normalWorld.y),e(E.normalWorld.z));p.wireframe?F.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+p.wireframeLinewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.wireframeLinecap+"; stroke-linejoin: "+p.wireframeLinejoin):F.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+p.opacity);g.appendChild(F)}function c(t,
-G,z,E,p,q,A){h.data.vertices+=4;h.data.faces++;F=d(M++);F.setAttribute("d","M "+t.positionScreen.x+" "+t.positionScreen.y+" L "+G.positionScreen.x+" "+G.positionScreen.y+" L "+z.positionScreen.x+","+z.positionScreen.y+" L "+E.positionScreen.x+","+E.positionScreen.y+"z");if(q instanceof THREE.MeshBasicMaterial)D.__styleString=q.color.__styleString;else if(q instanceof THREE.MeshLambertMaterial)if(I){w.r=o.r;w.g=o.g;w.b=o.b;a(A,p,w);D.r=q.color.r*w.r;D.g=q.color.g*w.g;D.b=q.color.b*w.b;D.updateStyleString()}else D.__styleString=
-q.color.__styleString;else if(q instanceof THREE.MeshDepthMaterial){K=1-q.__2near/(q.__farPlusNear-p.z*q.__farMinusNear);D.setRGB(K,K,K)}else q instanceof THREE.MeshNormalMaterial&&D.setRGB(e(p.normalWorld.x),e(p.normalWorld.y),e(p.normalWorld.z));q.wireframe?F.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+q.wireframeLinewidth+"; stroke-opacity: "+q.opacity+"; stroke-linecap: "+q.wireframeLinecap+"; stroke-linejoin: "+q.wireframeLinejoin):F.setAttribute("style","fill: "+
-D.__styleString+"; fill-opacity: "+q.opacity);g.appendChild(F)}function d(t){if(C[t]==null){C[t]=document.createElementNS("http://www.w3.org/2000/svg","path");L==0&&C[t].setAttribute("shape-rendering","crispEdges")}return C[t]}function e(t){return t<0?Math.min((1+t)*0.5,0.5):0.5+Math.min(t*0.5,0.5)}var h=this,f=null,i=new THREE.Projector,g=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,k,n,l,r,s,y,u=new THREE.Rectangle,H=new THREE.Rectangle,I=!1,D=new THREE.Color(16777215),w=new THREE.Color(16777215),
-o=new THREE.Color(0),O=new THREE.Color(0),J=new THREE.Color(0),K,P=new THREE.Vector3,C=[],x=[],F,M,Q,L=1;this.domElement=g;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data={vertices:0,faces:0};this.setQuality=function(t){switch(t){case "high":L=1;break;case "low":L=0}};this.setSize=function(t,G){j=t;m=G;k=j/2;n=m/2;g.setAttribute("viewBox",-k+" "+-n+" "+j+" "+m);g.setAttribute("width",j);g.setAttribute("height",m);u.set(-k,-n,k,n)};this.clear=function(){for(;g.childNodes.length>
-0;)g.removeChild(g.childNodes[0])};this.render=function(t,G){var z,E,p,q,A,N,B,v;this.autoClear&&this.clear();h.data.vertices=0;h.data.faces=0;f=i.projectScene(t,G,this.sortElements);Q=M=0;if(I=t.lights.length>0){B=t.lights;o.setRGB(0,0,0);O.setRGB(0,0,0);J.setRGB(0,0,0);z=0;for(E=B.length;z<E;z++){p=B[z];q=p.color;if(p instanceof THREE.AmbientLight){o.r+=q.r;o.g+=q.g;o.b+=q.b}else if(p instanceof THREE.DirectionalLight){O.r+=q.r;O.g+=q.g;O.b+=q.b}else if(p instanceof THREE.PointLight){J.r+=q.r;J.g+=
-q.g;J.b+=q.b}}}z=0;for(E=f.length;z<E;z++){B=f[z];H.empty();if(B instanceof THREE.RenderableParticle){l=B;l.x*=k;l.y*=-n;p=0;for(q=B.materials.length;p<q;)p++}else if(B instanceof THREE.RenderableLine){l=B.v1;r=B.v2;l.positionScreen.x*=k;l.positionScreen.y*=-n;r.positionScreen.x*=k;r.positionScreen.y*=-n;H.addPoint(l.positionScreen.x,l.positionScreen.y);H.addPoint(r.positionScreen.x,r.positionScreen.y);if(u.instersects(H)){p=0;for(q=B.materials.length;p<q;)if((v=B.materials[p++])&&v.opacity!=0){A=
-l;N=r;var R=Q++;if(x[R]==null){x[R]=document.createElementNS("http://www.w3.org/2000/svg","line");L==0&&x[R].setAttribute("shape-rendering","crispEdges")}F=x[R];F.setAttribute("x1",A.positionScreen.x);F.setAttribute("y1",A.positionScreen.y);F.setAttribute("x2",N.positionScreen.x);F.setAttribute("y2",N.positionScreen.y);if(v instanceof THREE.LineBasicMaterial){D.__styleString=v.color.__styleString;F.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+v.linewidth+"; stroke-opacity: "+
-v.opacity+"; stroke-linecap: "+v.linecap+"; stroke-linejoin: "+v.linejoin);g.appendChild(F)}}}}else if(B instanceof THREE.RenderableFace3){l=B.v1;r=B.v2;s=B.v3;l.positionScreen.x*=k;l.positionScreen.y*=-n;r.positionScreen.x*=k;r.positionScreen.y*=-n;s.positionScreen.x*=k;s.positionScreen.y*=-n;H.addPoint(l.positionScreen.x,l.positionScreen.y);H.addPoint(r.positionScreen.x,r.positionScreen.y);H.addPoint(s.positionScreen.x,s.positionScreen.y);if(u.instersects(H)){p=0;for(q=B.meshMaterials.length;p<
-q;){v=B.meshMaterials[p++];if(v instanceof THREE.MeshFaceMaterial){A=0;for(N=B.faceMaterials.length;A<N;)(v=B.faceMaterials[A++])&&v.opacity!=0&&b(l,r,s,B,v,t)}else v&&v.opacity!=0&&b(l,r,s,B,v,t)}}}else if(B instanceof THREE.RenderableFace4){l=B.v1;r=B.v2;s=B.v3;y=B.v4;l.positionScreen.x*=k;l.positionScreen.y*=-n;r.positionScreen.x*=k;r.positionScreen.y*=-n;s.positionScreen.x*=k;s.positionScreen.y*=-n;y.positionScreen.x*=k;y.positionScreen.y*=-n;H.addPoint(l.positionScreen.x,l.positionScreen.y);
-H.addPoint(r.positionScreen.x,r.positionScreen.y);H.addPoint(s.positionScreen.x,s.positionScreen.y);H.addPoint(y.positionScreen.x,y.positionScreen.y);if(u.instersects(H)){p=0;for(q=B.meshMaterials.length;p<q;){v=B.meshMaterials[p++];if(v instanceof THREE.MeshFaceMaterial){A=0;for(N=B.faceMaterials.length;A<N;)(v=B.faceMaterials[A++])&&v.opacity!=0&&c(l,r,s,y,B,v,t)}else v&&v.opacity!=0&&c(l,r,s,y,B,v,t)}}}}}};
+THREE.Projector=function(){function a(){var B=h[j]=h[j]||new THREE.RenderableVertex;j++;return B}function b(B,z){return z.z-B.z}function c(B,z){var M=0,G=1,Q=B.z+B.w,O=z.z+z.w,F=-B.z+B.w,t=-z.z+z.w;if(Q>=0&&O>=0&&F>=0&&t>=0)return!0;else if(Q<0&&O<0||F<0&&t<0)return!1;else{if(Q<0)M=Math.max(M,Q/(Q-O));else O<0&&(G=Math.min(G,Q/(Q-O)));if(F<0)M=Math.max(M,F/(F-t));else t<0&&(G=Math.min(G,F/(F-t)));if(G<M)return!1;else{B.lerpSelf(z,M);z.lerpSelf(B,1-G);return!0}}}var d,e,g=[],f,j,h=[],i,k,n=[],m,o=
+[],q,r,v=[],w,I,D=[],N=new THREE.Vector4,x=new THREE.Vector4,l=new THREE.Matrix4,J=new THREE.Matrix4,K=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],P=new THREE.Vector4,L=new THREE.Vector4;this.projectVector=function(B,z){l.multiply(z.projectionMatrix,z.matrixWorldInverse);l.multiplyVector3(B);return B};this.unprojectVector=function(B,z){l.multiply(z.matrixWorld,THREE.Matrix4.makeInvert(z.projectionMatrix));l.multiplyVector3(B);return B};
+this.projectObjects=function(B,z,M){z=[];var G,Q,O;e=0;Q=B.objects;B=0;for(G=Q.length;B<G;B++){O=Q[B];var F;if(!(F=!O.visible))if(F=O instanceof THREE.Mesh){a:{F=void 0;for(var t=O.matrixWorld,C=-O.geometry.boundingSphere.radius*Math.max(O.scale.x,Math.max(O.scale.y,O.scale.z)),A=0;A<6;A++){F=K[A].x*t.n14+K[A].y*t.n24+K[A].z*t.n34+K[A].w;if(F<=C){F=!1;break a}}F=!0}F=!F}if(!F){F=g[e]=g[e]||new THREE.RenderableObject;e++;d=F;N.copy(O.position);l.multiplyVector3(N);d.object=O;d.z=N.z;z.push(d)}}M&&
+z.sort(b);return z};this.projectScene=function(B,z,M){var G=[],Q=z.near,O=z.far,F,t,C,A,y,s,p,E,R,u,H,S,W,X,T,V,U;I=r=m=k=0;z.matrixAutoUpdate&&z.update(undefined,!0);B.update(undefined,!1,z);l.multiply(z.projectionMatrix,z.matrixWorldInverse);K[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,l.n44-l.n14);K[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+l.n14);K[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);K[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);K[4].set(l.n41-l.n31,l.n42-
+l.n32,l.n43-l.n33,l.n44-l.n34);K[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);for(F=0;F<6;F++){R=K[F];R.divideScalar(Math.sqrt(R.x*R.x+R.y*R.y+R.z*R.z))}R=this.projectObjects(B,z,!0);B=0;for(F=R.length;B<F;B++){u=R[B].object;if(u.visible){H=u.matrixWorld;S=u.matrixRotationWorld;W=u.materials;X=u.overdraw;j=0;if(u instanceof THREE.Mesh){T=u.geometry;A=T.vertices;V=T.faces;T=T.faceVertexUvs;t=0;for(C=A.length;t<C;t++){f=a();f.positionWorld.copy(A[t].position);H.multiplyVector3(f.positionWorld);
+f.positionScreen.copy(f.positionWorld);l.multiplyVector4(f.positionScreen);f.positionScreen.x/=f.positionScreen.w;f.positionScreen.y/=f.positionScreen.w;f.visible=f.positionScreen.z>Q&&f.positionScreen.z<O}A=0;for(t=V.length;A<t;A++){C=V[A];if(C instanceof THREE.Face3){y=h[C.a];s=h[C.b];p=h[C.c];if(y.visible&&s.visible&&p.visible&&(u.doubleSided||u.flipSided!=(p.positionScreen.x-y.positionScreen.x)*(s.positionScreen.y-y.positionScreen.y)-(p.positionScreen.y-y.positionScreen.y)*(s.positionScreen.x-
+y.positionScreen.x)<0)){E=n[k]=n[k]||new THREE.RenderableFace3;k++;i=E;i.v1.copy(y);i.v2.copy(s);i.v3.copy(p)}else continue}else if(C instanceof THREE.Face4){y=h[C.a];s=h[C.b];p=h[C.c];E=h[C.d];if(y.visible&&s.visible&&p.visible&&E.visible&&(u.doubleSided||u.flipSided!=((E.positionScreen.x-y.positionScreen.x)*(s.positionScreen.y-y.positionScreen.y)-(E.positionScreen.y-y.positionScreen.y)*(s.positionScreen.x-y.positionScreen.x)<0||(s.positionScreen.x-p.positionScreen.x)*(E.positionScreen.y-p.positionScreen.y)-
+(s.positionScreen.y-p.positionScreen.y)*(E.positionScreen.x-p.positionScreen.x)<0))){U=o[m]=o[m]||new THREE.RenderableFace4;m++;i=U;i.v1.copy(y);i.v2.copy(s);i.v3.copy(p);i.v4.copy(E)}else continue}i.normalWorld.copy(C.normal);S.multiplyVector3(i.normalWorld);i.centroidWorld.copy(C.centroid);H.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);l.multiplyVector3(i.centroidScreen);p=C.vertexNormals;y=0;for(s=p.length;y<s;y++){E=i.vertexNormalsWorld[y];E.copy(p[y]);S.multiplyVector3(E)}y=
+0;for(s=T.length;y<s;y++)if(U=T[y][A]){p=0;for(E=U.length;p<E;p++)i.uvs[y][p]=U[p]}i.meshMaterials=W;i.faceMaterials=C.materials;i.overdraw=X;i.z=i.centroidScreen.z;G.push(i)}}else if(u instanceof THREE.Line){J.multiply(l,H);A=u.geometry.vertices;y=a();y.positionScreen.copy(A[0].position);J.multiplyVector4(y.positionScreen);t=1;for(C=A.length;t<C;t++){y=a();y.positionScreen.copy(A[t].position);J.multiplyVector4(y.positionScreen);s=h[j-2];P.copy(y.positionScreen);L.copy(s.positionScreen);if(c(P,L)){P.multiplyScalar(1/
+P.w);L.multiplyScalar(1/L.w);H=v[r]=v[r]||new THREE.RenderableLine;r++;q=H;q.v1.positionScreen.copy(P);q.v2.positionScreen.copy(L);q.z=Math.max(P.z,L.z);q.materials=u.materials;G.push(q)}}}else if(u instanceof THREE.Particle){x.set(u.matrixWorld.n14,u.matrixWorld.n24,u.matrixWorld.n34,1);l.multiplyVector4(x);x.z/=x.w;if(x.z>0&&x.z<1){H=D[I]=D[I]||new THREE.RenderableParticle;I++;w=H;w.x=x.x/x.w;w.y=x.y/x.w;w.z=x.z;w.rotation=u.rotation.z;w.scale.x=u.scale.x*Math.abs(w.x-(x.x+z.projectionMatrix.n11)/
+(x.w+z.projectionMatrix.n14));w.scale.y=u.scale.y*Math.abs(w.y-(x.y+z.projectionMatrix.n22)/(x.w+z.projectionMatrix.n24));w.materials=u.materials;G.push(w)}}}}M&&G.sort(b);return G}};
+THREE.SVGRenderer=function(){function a(t,C,A){var y,s,p,E;y=0;for(s=t.lights.length;y<s;y++){p=t.lights[y];if(p instanceof THREE.DirectionalLight){E=C.normalWorld.dot(p.position)*p.intensity;if(E>0){A.r+=p.color.r*E;A.g+=p.color.g*E;A.b+=p.color.b*E}}else if(p instanceof THREE.PointLight){B.sub(p.position,C.centroidWorld);B.normalize();E=C.normalWorld.dot(B)*p.intensity;if(E>0){A.r+=p.color.r*E;A.g+=p.color.g*E;A.b+=p.color.b*E}}}}function b(t,C,A,y,s,p){f.data.vertices+=3;f.data.faces++;G=d(Q++);
+G.setAttribute("d","M "+t.positionScreen.x+" "+t.positionScreen.y+" L "+C.positionScreen.x+" "+C.positionScreen.y+" L "+A.positionScreen.x+","+A.positionScreen.y+"z");if(s instanceof THREE.MeshBasicMaterial)x.hex=s.color.hex;else if(s instanceof THREE.MeshLambertMaterial)if(N){l.r=J.r;l.g=J.g;l.b=J.b;a(p,y,l);x.r=Math.max(0,Math.min(s.color.r*l.r,1));x.g=Math.max(0,Math.min(s.color.g*l.g,1));x.b=Math.max(0,Math.min(s.color.b*l.b,1));x.updateHex()}else x.hex=s.color.hex;else if(s instanceof THREE.MeshDepthMaterial){L=
+1-s.__2near/(s.__farPlusNear-y.z*s.__farMinusNear);x.setRGB(L,L,L)}else s instanceof THREE.MeshNormalMaterial&&x.setRGB(e(y.normalWorld.x),e(y.normalWorld.y),e(y.normalWorld.z));s.wireframe?G.setAttribute("style","fill: none; stroke: #"+g(x.hex.toString(16))+"; stroke-width: "+s.wireframeLinewidth+"; stroke-opacity: "+s.opacity+"; stroke-linecap: "+s.wireframeLinecap+"; stroke-linejoin: "+s.wireframeLinejoin):G.setAttribute("style","fill: #"+g(x.hex.toString(16))+"; fill-opacity: "+s.opacity);i.appendChild(G)}
+function c(t,C,A,y,s,p,E){f.data.vertices+=4;f.data.faces++;G=d(Q++);G.setAttribute("d","M "+t.positionScreen.x+" "+t.positionScreen.y+" L "+C.positionScreen.x+" "+C.positionScreen.y+" L "+A.positionScreen.x+","+A.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+"z");if(p instanceof THREE.MeshBasicMaterial)x.hex=p.color.hex;else if(p instanceof THREE.MeshLambertMaterial)if(N){l.r=J.r;l.g=J.g;l.b=J.b;a(E,s,l);x.r=Math.max(0,Math.min(p.color.r*l.r,1));x.g=Math.max(0,Math.min(p.color.g*
+l.g,1));x.b=Math.max(0,Math.min(p.color.b*l.b,1));x.updateHex()}else x.hex=p.color.hex;else if(p instanceof THREE.MeshDepthMaterial){L=1-p.__2near/(p.__farPlusNear-s.z*p.__farMinusNear);x.setRGB(L,L,L)}else p instanceof THREE.MeshNormalMaterial&&x.setRGB(e(s.normalWorld.x),e(s.normalWorld.y),e(s.normalWorld.z));p.wireframe?G.setAttribute("style","fill: none; stroke: #"+g(x.hex.toString(16))+"; stroke-width: "+p.wireframeLinewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.wireframeLinecap+
+"; stroke-linejoin: "+p.wireframeLinejoin):G.setAttribute("style","fill: #"+g(x.hex.toString(16))+"; fill-opacity: "+p.opacity);i.appendChild(G)}function d(t){if(z[t]==null){z[t]=document.createElementNS("http://www.w3.org/2000/svg","path");F==0&&z[t].setAttribute("shape-rendering","crispEdges")}return z[t]}function e(t){t=(t+1)*0.5;return t<0?0:t>1?1:t}function g(t){for(;t.length<6;)t="0"+t;return t}var f=this,j=null,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),
+k,n,m,o,q,r,v,w,I=new THREE.Rectangle,D=new THREE.Rectangle,N=!1,x=new THREE.Color(16777215),l=new THREE.Color(16777215),J=new THREE.Color(0),K=new THREE.Color(0),P=new THREE.Color(0),L,B=new THREE.Vector3,z=[],M=[],G,Q,O,F=1;this.domElement=i;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data={vertices:0,faces:0};this.setQuality=function(t){switch(t){case "high":F=1;break;case "low":F=0}};this.setSize=function(t,C){k=t;n=C;m=k/2;o=n/2;i.setAttribute("viewBox",-m+" "+-o+" "+k+" "+
+n);i.setAttribute("width",k);i.setAttribute("height",n);I.set(-m,-o,m,o)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(t,C){var A,y,s,p,E,R,u,H;this.autoClear&&this.clear();f.data.vertices=0;f.data.faces=0;j=h.projectScene(t,C,this.sortElements);O=Q=0;if(N=t.lights.length>0){u=t.lights;J.setRGB(0,0,0);K.setRGB(0,0,0);P.setRGB(0,0,0);A=0;for(y=u.length;A<y;A++){s=u[A];p=s.color;if(s instanceof THREE.AmbientLight){J.r+=p.r;J.g+=p.g;J.b+=p.b}else if(s instanceof
+THREE.DirectionalLight){K.r+=p.r;K.g+=p.g;K.b+=p.b}else if(s instanceof THREE.PointLight){P.r+=p.r;P.g+=p.g;P.b+=p.b}}}A=0;for(y=j.length;A<y;A++){u=j[A];D.empty();if(u instanceof THREE.RenderableParticle){q=u;q.x*=m;q.y*=-o;s=0;for(p=u.materials.length;s<p;)s++}else if(u instanceof THREE.RenderableLine){q=u.v1;r=u.v2;q.positionScreen.x*=m;q.positionScreen.y*=-o;r.positionScreen.x*=m;r.positionScreen.y*=-o;D.addPoint(q.positionScreen.x,q.positionScreen.y);D.addPoint(r.positionScreen.x,r.positionScreen.y);
+if(I.instersects(D)){s=0;for(p=u.materials.length;s<p;)if((H=u.materials[s++])&&H.opacity!=0){E=q;R=r;var S=O++;if(M[S]==null){M[S]=document.createElementNS("http://www.w3.org/2000/svg","line");F==0&&M[S].setAttribute("shape-rendering","crispEdges")}G=M[S];G.setAttribute("x1",E.positionScreen.x);G.setAttribute("y1",E.positionScreen.y);G.setAttribute("x2",R.positionScreen.x);G.setAttribute("y2",R.positionScreen.y);if(H instanceof THREE.LineBasicMaterial){G.setAttribute("style","fill: none; stroke: ##"+
+g(H.color.hex.toString(16))+"; stroke-width: "+H.linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: "+H.linecap+"; stroke-linejoin: "+H.linejoin);i.appendChild(G)}}}}else if(u instanceof THREE.RenderableFace3){q=u.v1;r=u.v2;v=u.v3;q.positionScreen.x*=m;q.positionScreen.y*=-o;r.positionScreen.x*=m;r.positionScreen.y*=-o;v.positionScreen.x*=m;v.positionScreen.y*=-o;D.addPoint(q.positionScreen.x,q.positionScreen.y);D.addPoint(r.positionScreen.x,r.positionScreen.y);D.addPoint(v.positionScreen.x,
+v.positionScreen.y);if(I.instersects(D)){s=0;for(p=u.meshMaterials.length;s<p;){H=u.meshMaterials[s++];if(H instanceof THREE.MeshFaceMaterial){E=0;for(R=u.faceMaterials.length;E<R;)(H=u.faceMaterials[E++])&&H.opacity!=0&&b(q,r,v,u,H,t)}else H&&H.opacity!=0&&b(q,r,v,u,H,t)}}}else if(u instanceof THREE.RenderableFace4){q=u.v1;r=u.v2;v=u.v3;w=u.v4;q.positionScreen.x*=m;q.positionScreen.y*=-o;r.positionScreen.x*=m;r.positionScreen.y*=-o;v.positionScreen.x*=m;v.positionScreen.y*=-o;w.positionScreen.x*=
+m;w.positionScreen.y*=-o;D.addPoint(q.positionScreen.x,q.positionScreen.y);D.addPoint(r.positionScreen.x,r.positionScreen.y);D.addPoint(v.positionScreen.x,v.positionScreen.y);D.addPoint(w.positionScreen.x,w.positionScreen.y);if(I.instersects(D)){s=0;for(p=u.meshMaterials.length;s<p;){H=u.meshMaterials[s++];if(H instanceof THREE.MeshFaceMaterial){E=0;for(R=u.faceMaterials.length;E<R;)(H=u.faceMaterials[E++])&&H.opacity!=0&&c(q,r,v,w,u,H,t)}else H&&H.opacity!=0&&c(q,r,v,w,u,H,t)}}}}}};
 THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,c){c&&a.update(undefined,!1,b);c=a.sounds;var d,e=c.length;for(d=0;d<e;d++){a=c[d];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
 THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
 THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};

+ 4 - 5
build/custom/ThreeWebGL.js

@@ -1,8 +1,7 @@
 // ThreeWebGL.js r40 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}THREE.Color=function(b){this.setHex(b)};
-THREE.Color.prototype={autoUpdate:!0,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex;this.__styleString=b.__styleString},setRGB:function(b,d,e){this.r=b;this.g=d;this.b=e;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(b,d,e){var g,h,o,n,q,r;if(e==0)g=h=o=0;else{n=Math.floor(b*6);q=b*6-n;b=e*(1-d);r=e*(1-d*q);d=e*(1-d*(1-q));switch(n){case 1:g=r;h=e;o=b;break;case 2:g=b;h=e;o=d;break;case 3:g=b;h=r;o=e;break;case 4:g=d;h=b;o=e;break;case 5:g=e;h=b;
-o=r;break;case 6:case 0:g=e;h=d;o=b}}this.r=g;this.g=h;this.b=o;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(b){this.hex=~~b&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB: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)}};THREE.Vector2=function(b,d){this.set(b||0,d||0)};
+THREE.Color.prototype={copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex},setHex:function(b){this.hex=~~b&16777215;this.updateRGB()},setRGB:function(b,d,e){this.r=b;this.g=d;this.b=e;this.updateHex()},setHSV:function(b,d,e){var g,h,o,n,q,r;if(e==0)g=h=o=0;else{n=Math.floor(b*6);q=b*6-n;b=e*(1-d);r=e*(1-d*q);d=e*(1-d*(1-q));switch(n){case 1:g=r;h=e;o=b;break;case 2:g=b;h=e;o=d;break;case 3:g=b;h=r;o=e;break;case 4:g=d;h=b;o=e;break;case 5:g=e;h=b;o=r;break;case 6:case 0:g=e;h=d;o=b}}this.setRGB(g,
+h,o)},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(b,d){this.set(b||0,d||0)};
 THREE.Vector2.prototype={set:function(b,d){this.x=b;this.y=d;return this},copy:function(b){this.set(b.x,b.y);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y);return this},multiplyScalar:function(b){this.set(this.x*b,this.y*b);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
 this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(b,d,e){this.set(b||0,d||0,e||0)};
 THREE.Vector3.prototype={set:function(b,d,e){this.x=b;this.y=d;this.z=e;return this},copy:function(b){this.set(b.x,b.y,b.z);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y,b.z+d.z);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z);return this},addScalar:function(b){this.set(this.x+b,this.y+b,this.z+b);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y,b.z-d.z);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z);return this},cross:function(b,
@@ -50,7 +49,7 @@ THREE.Quaternion.prototype={set:function(b,d,e,g){this.x=b;this.y=d;this.z=e;thi
 b.y*g;this.z=b.z*g;this.w=Math.cos(e);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(b==0)this.w=this.z=this.y=this.x=0;else{b=1/b;this.x*=b;this.y*=b;this.z*=b;this.w*=b}return this},
 multiplySelf:function(b){var d=this.x,e=this.y,g=this.z,h=this.w,o=b.x,n=b.y,q=b.z;b=b.w;this.x=d*b+h*o+e*q-g*n;this.y=e*b+h*n+g*o-d*q;this.z=g*b+h*q+d*n-e*o;this.w=h*b-d*o-e*n-g*q;return this},multiply:function(b,d){this.x=b.x*d.w+b.y*d.z-b.z*d.y+b.w*d.x;this.y=-b.x*d.z+b.y*d.w+b.z*d.x+b.w*d.y;this.z=b.x*d.y-b.y*d.x+b.z*d.w+b.w*d.z;this.w=-b.x*d.x-b.y*d.y-b.z*d.z+b.w*d.w;return this},multiplyVector3:function(b,d){d||(d=b);var e=b.x,g=b.y,h=b.z,o=this.x,n=this.y,q=this.z,r=this.w,v=r*e+n*h-q*g,E=
 r*g+q*e-o*h,F=r*h+o*g-n*e;e=-o*e-n*g-q*h;d.x=v*r+e*-o+E*-q-F*-n;d.y=E*r+e*-n+F*-o-v*-q;d.z=F*r+e*-q+v*-n-E*-o;return d}};
-THREE.Quaternion.slerp=function(b,d,e,g){var h=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(h)>=1){e.w=b.w;e.x=b.x;e.y=b.y;e.z=b.z;return e}var o=Math.acos(h),n=Math.sqrt(1-h*h);if(Math.abs(n)<0.0010){e.w=0.5*(b.w+d.w);e.x=0.5*(b.x+d.x);e.y=0.5*(b.y+d.y);e.z=0.5*(b.z+d.z);return e}h=Math.sin((1-g)*o)/n;g=Math.sin(g*o)/n;e.w=b.w*h+d.w*g;e.x=b.x*h+d.x*g;e.y=b.y*h+d.y*g;e.z=b.z*h+d.z*g;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
+THREE.Quaternion.slerp=function(b,d,e,g){var h=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(h)>=1){e.w=b.w;e.x=b.x;e.y=b.y;e.z=b.z;return e}var o=Math.acos(h),n=Math.sqrt(1-h*h);if(Math.abs(n)<0.001){e.w=0.5*(b.w+d.w);e.x=0.5*(b.x+d.x);e.y=0.5*(b.y+d.y);e.z=0.5*(b.z+d.z);return e}h=Math.sin((1-g)*o)/n;g=Math.sin(g*o)/n;e.w=b.w*h+d.w*g;e.x=b.x*h+d.x*g;e.y=b.y*h+d.y*g;e.z=b.z*h+d.z*g;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
 THREE.Face3=function(b,d,e,g,h,o){this.a=b;this.b=d;this.c=e;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=o instanceof Array?o:[o];this.centroid=new THREE.Vector3};
 THREE.Face4=function(b,d,e,g,h,o,n){this.a=b;this.b=d;this.c=e;this.d=g;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=o instanceof THREE.Color?o:new THREE.Color;this.vertexColors=o instanceof Array?o:[];this.vertexTangents=[];this.materials=n instanceof Array?n:[n];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)};
 THREE.UV.prototype={set:function(b,d){this.u=b;this.v=d;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
@@ -205,7 +204,7 @@ m.rotation);c.uniform2fv(x.scale,A);if(m.mergeWith3D&&!z){c.enable(c.DEPTH_TEST)
 c.enableVertexAttribArray(J.attributes.uv);qb=!0}c.uniform1i(P.occlusionMap,0);c.uniform1i(P.map,1);c.bindBuffer(c.ARRAY_BUFFER,J.vertexBuffer);c.vertexAttribPointer(j.vertex,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(j.uv,2,c.FLOAT,!1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,J.elementBuffer);c.disable(c.CULL_FACE);c.depthMask(!1);c.activeTexture(c.TEXTURE0);c.bindTexture(c.TEXTURE_2D,J.occlusionTexture);c.activeTexture(c.TEXTURE1);for(k=0;k<m;k++){j=f.__webglLensFlares[k].object;A.set(j.matrixWorld.n14,
 j.matrixWorld.n24,j.matrixWorld.n34);p.matrixWorldInverse.multiplyVector3(A);p.projectionMatrix.multiplyVector3(A);O[0]=A.x;O[1]=A.y;O[2]=A.z;W[0]=O[0]*w+w;W[1]=O[1]*z+z;if(J.hasVertexTexture||W[0]>0&&W[0]<za&&W[1]>0&&W[1]<Aa){c.bindTexture(c.TEXTURE_2D,J.tempTexture);c.copyTexImage2D(c.TEXTURE_2D,0,c.RGB,W[0]-8,W[1]-8,16,16,0);c.uniform1i(P.renderType,0);c.uniform2fv(P.scale,B);c.uniform3fv(P.screenPosition,O);c.disable(c.BLEND);c.enable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,
 0);c.bindTexture(c.TEXTURE_2D,J.occlusionTexture);c.copyTexImage2D(c.TEXTURE_2D,0,c.RGBA,W[0]-8,W[1]-8,16,16,0);c.uniform1i(P.renderType,1);c.disable(c.DEPTH_TEST);c.bindTexture(c.TEXTURE_2D,J.tempTexture);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);j.positionScreen.x=O[0];j.positionScreen.y=O[1];j.positionScreen.z=O[2];j.customUpdateCallback?j.customUpdateCallback(j):j.updateLensFlares();c.uniform1i(P.renderType,2);c.enable(c.BLEND);x=0;for(y=j.lensFlares.length;x<y;x++){u=j.lensFlares[x];if(u.opacity>
-0.0010&&u.scale>0.0010){O[0]=u.x;O[1]=u.y;O[2]=u.z;D=u.size*u.scale/Aa;B[0]=D*t;B[1]=D;c.uniform3fv(P.screenPosition,O);c.uniform2fv(P.scale,B);c.uniform1f(P.rotation,u.rotation);c.uniform1f(P.opacity,u.opacity);pa(u.blending);K(u.texture,1);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}}}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(Y)}function V(f,p){f._modelViewMatrix.multiplyToArray(p.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}
+0.001&&u.scale>0.001){O[0]=u.x;O[1]=u.y;O[2]=u.z;D=u.size*u.scale/Aa;B[0]=D*t;B[1]=D;c.uniform3fv(P.screenPosition,O);c.uniform2fv(P.scale,B);c.uniform1f(P.rotation,u.rotation);c.uniform1f(P.opacity,u.opacity);pa(u.blending);K(u.texture,1);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}}}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(Y)}function V(f,p){f._modelViewMatrix.multiplyToArray(p.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}
 function L(f){var p,j,k,m,x;if(f instanceof THREE.Mesh){j=f.geometry;for(p in j.geometryGroups){k=j.geometryGroups[p];x=!1;for(m in k.__webglCustomAttributes)if(k.__webglCustomAttributes[m].needsUpdate){x=!0;break}if(j.__dirtyVertices||j.__dirtyMorphTargets||j.__dirtyElements||j.__dirtyUvs||j.__dirtyNormals||j.__dirtyColors||j.__dirtyTangents||x){x=c.DYNAMIC_DRAW;var y=void 0,u=void 0,A=void 0,t=void 0;A=void 0;var w=void 0,z=void 0,D=void 0,B=void 0,O=void 0,W=void 0,P=void 0,X=void 0,Ga=void 0,
 T=void 0,R=void 0,U=void 0,ta=void 0;z=void 0;D=void 0;t=void 0;B=void 0;t=void 0;var s=void 0,G=void 0;z=void 0;s=void 0;G=void 0;var i=void 0,Ka=void 0;s=void 0;G=void 0;i=void 0;Ka=void 0;s=void 0;G=void 0;i=void 0;Ka=void 0;s=void 0;G=void 0;i=void 0;t=void 0;B=void 0;w=void 0;A=void 0;A=void 0;s=void 0;G=void 0;i=void 0;var Va=void 0,ua=0,Ba=0,Za=0,$a=0,Ja=0,La=0,ea=0,Ma=0,wa=0,C=0,Ca=0;G=s=0;var Da=k.__vertexArray,gb=k.__uvArray,hb=k.__uv2Array,Qa=k.__normalArray,ia=k.__tangentArray,Ea=k.__colorArray,
 ja=k.__skinVertexAArray,ka=k.__skinVertexBArray,la=k.__skinIndexArray,ma=k.__skinWeightArray,ib=k.__morphTargetsArrays,Ra=k.__webglCustomAttributes;i=void 0;var Na=k.__faceArray,Oa=k.__lineArray,rb=k.__needsSmoothNormals;W=k.__vertexColorType;O=k.__uvType;P=k.__normalType;var Ha=f.geometry,jb=Ha.__dirtyVertices,kb=Ha.__dirtyElements,fb=Ha.__dirtyUvs,lb=Ha.__dirtyNormals,mb=Ha.__dirtyTangents,nb=Ha.__dirtyColors,ob=Ha.__dirtyMorphTargets,ab=Ha.vertices,sb=k.faces,vb=Ha.faces,tb=Ha.faceVertexUvs[0],

+ 1 - 1
examples/canvas_geometry_birds.html

@@ -420,7 +420,7 @@
 
 					color = bird.materials[ 0 ].color;
 					color.r = color.g = color.b = ( 500 - bird.position.z ) / 1000;
-					color.updateStyleString();
+					color.updateHex();
 
 					bird.rotation.y = Math.atan2( - boid.velocity.z, boid.velocity.x );
 					bird.rotation.z = Math.asin( boid.velocity.y / boid.velocity.length() );

+ 17 - 46
src/core/Color.js

@@ -10,15 +10,19 @@ THREE.Color = function ( hex ) {
 
 THREE.Color.prototype = {
 
-	autoUpdate : true,
-
 	copy : function ( color ) {
 
 		this.r = color.r;
 		this.g = color.g;
 		this.b = color.b;
 		this.hex = color.hex;
-		this.__styleString = color.__styleString;
+
+	},
+
+	setHex : function ( hex ) {
+
+		this.hex = ( ~~ hex ) & 0xffffff;
+		this.updateRGB();
 
 	},
 
@@ -28,12 +32,7 @@ THREE.Color.prototype = {
 		this.g = g;
 		this.b = b;
 
-		if ( this.autoUpdate ) {
-
-			this.updateHex();
-			this.updateStyleString();
-
-		}
+		this.updateHex();
 
 	},
 
@@ -42,11 +41,11 @@ THREE.Color.prototype = {
 		// based on MochiKit implementation by Bob Ippolito
 		// h,s,v ranges are < 0.0 - 1.0 >
 
-		var red, green, blue, i, f, p, q, t;
+		var r, g, b, i, f, p, q, t;
 
 		if ( v == 0.0 ) {
 
-			red = green = blue = 0;
+			r = g = b = 0;
 
 		} else {
 
@@ -58,41 +57,19 @@ THREE.Color.prototype = {
 
 			switch ( i ) {
 
-				case 1: red = q; green = v; blue = p; break;
-				case 2: red = p; green = v; blue = t; break;
-				case 3: red = p; green = q; blue = v; break;
-				case 4: red = t; green = p; blue = v; break;
-				case 5: red = v; green = p; blue = q; break;
+				case 1: r = q; g = v; b = p; break;
+				case 2: r = p; g = v; b = t; break;
+				case 3: r = p; g = q; b = v; break;
+				case 4: r = t; g = p; b = v; break;
+				case 5: r = v; g = p; b = q; break;
 				case 6: // fall through
-				case 0: red = v; green = t; blue = p; break;
+				case 0: r = v; g = t; b = p; break;
 
 			}
 
 		}
 
-		this.r = red;
-		this.g = green;
-		this.b = blue;
-
-		if ( this.autoUpdate ) {
-
-			this.updateHex();
-			this.updateStyleString();
-
-		}
-
-	},
-
-	setHex : function ( hex ) {
-
-		this.hex = ( ~~ hex ) & 0xffffff;
-
-		if ( this.autoUpdate ) {
-
-			this.updateRGB();
-			this.updateStyleString();
-
-		}
+		this.setRGB( r, g, b );
 
 	},
 
@@ -110,12 +87,6 @@ THREE.Color.prototype = {
 
 	},
 
-	updateStyleString : function () {
-
-		this.__styleString = 'rgb(' + ~~ ( this.r * 255 ) + ',' + ~~ ( this.g * 255 ) + ',' + ~~ ( this.b * 255 ) + ')';
-
-	},
-
 	clone : function () {
 
 		return new THREE.Color( this.hex );

+ 7 - 7
src/extras/io/JSONLoader.js

@@ -46,7 +46,7 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 
 	var scope = this,
 	geometry = new THREE.Geometry(),
-	scale = ( json.scale !== undefined ) ? json.scale : 1.0;
+	scale = ( json.scale !== undefined ) ? 1.0 / json.scale : 1.0;
 
 	this.init_materials( geometry, json.materials, texture_path );
 
@@ -121,9 +121,9 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 
 			vertex = new THREE.Vertex();
 
-			vertex.position.x = vertices[ offset ++ ] / scale;
-			vertex.position.y = vertices[ offset ++ ] / scale;
-			vertex.position.z = vertices[ offset ++ ] / scale;
+			vertex.position.x = vertices[ offset ++ ] * scale;
+			vertex.position.y = vertices[ offset ++ ] * scale;
+			vertex.position.z = vertices[ offset ++ ] * scale;
 
 			geometry.vertices.push( vertex );
 
@@ -342,9 +342,9 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 
 				for( v = 0, vl = srcVertices.length; v < vl; v += 3 ) {
 
-					x = srcVertices[ v ] / scale;
-					y = srcVertices[ v + 1 ] / scale;
-					z = srcVertices[ v + 2 ] / scale;
+					x = srcVertices[ v ] * scale;
+					y = srcVertices[ v + 1 ] * scale;
+					z = srcVertices[ v + 2 ] * scale;
 
 					dstVertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
 

+ 42 - 37
src/renderers/CanvasRenderer.js

@@ -30,11 +30,11 @@ THREE.CanvasRenderer = function () {
 	_v1x, _v1y, _v2x, _v2y, _v3x, _v3y,
 	_v4x, _v4y, _v5x, _v5y, _v6x, _v6y,
 
-	_color = new THREE.Color(),
-	_color1 = new THREE.Color(),
-	_color2 = new THREE.Color(),
-	_color3 = new THREE.Color(),
-	_color4 = new THREE.Color(),
+	_color = new THREE.Color( 0x000000 ),
+	_color1 = new THREE.Color( 0x000000 ),
+	_color2 = new THREE.Color( 0x000000 ),
+	_color3 = new THREE.Color( 0x000000 ),
+	_color4 = new THREE.Color( 0x000000 ),
 
 	_near, _far,
 
@@ -505,8 +505,8 @@ THREE.CanvasRenderer = function () {
 
 				}
 
-				setStrokeStyle( material.color.__styleString );
-				setFillStyle( material.color.__styleString );
+				setStrokeStyle( material.color );
+				setFillStyle( material.color );
 
 				_context.save();
 				_context.translate( v1.x, v1.y );
@@ -533,12 +533,10 @@ THREE.CanvasRenderer = function () {
 
 			if ( material instanceof THREE.LineBasicMaterial ) {
 
-				_color.__styleString = material.color.__styleString;
-
 				setLineWidth( material.linewidth );
 				setLineCap( material.linecap );
 				setLineJoin( material.linejoin );
-				setStrokeStyle( _color.__styleString );
+				setStrokeStyle( material.color );
 
 				_context.stroke();
 				_bboxRect.inflate( material.linewidth * 2 );
@@ -602,7 +600,7 @@ THREE.CanvasRenderer = function () {
 
 				} else {
 
-					material.wireframe ? strokePath( material.color.__styleString, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color.__styleString );
+					material.wireframe ? strokePath( material.color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color );
 
 				}
 
@@ -633,7 +631,7 @@ THREE.CanvasRenderer = function () {
 						calculateLight( scene, element.v2.positionWorld, element.vertexNormalsWorld[ 1 ], _color2 );
 						calculateLight( scene, element.v3.positionWorld, element.vertexNormalsWorld[ 2 ], _color3 );
 
-						_color4.r = ( _color2.r + _color3.r ) * 0.5;
+						_color4.r =  ( _color2.r + _color3.r ) * 0.5;
 						_color4.g = ( _color2.g + _color3.g ) * 0.5;
 						_color4.b = ( _color2.b + _color3.b ) * 0.5;
 
@@ -649,19 +647,18 @@ THREE.CanvasRenderer = function () {
 
 						calculateLight( scene, element.centroidWorld, element.normalWorld, _light );
 
-						_color.r = material.color.r * _light.r;
-						_color.g = material.color.g * _light.g;
-						_color.b = material.color.b * _light.b;
-
-						_color.updateStyleString();
+						_color.r = Math.max( 0, Math.min( material.color.r * _light.r, 1 ) );
+						_color.g = Math.max( 0, Math.min( material.color.g * _light.g, 1 ) );
+						_color.b = Math.max( 0, Math.min( material.color.b * _light.b, 1 ) );
+						_color.updateHex();
 
-						material.wireframe ? strokePath( _color.__styleString, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color.__styleString );
+						material.wireframe ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color );
 
 					}
 
 				} else {
 
-					material.wireframe ? strokePath( material.color.__styleString, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color.__styleString );
+					material.wireframe ? strokePath( material.color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color );
 
 				}
 
@@ -687,9 +684,9 @@ THREE.CanvasRenderer = function () {
 				_color.r = normalToComponent( element.normalWorld.x );
 				_color.g = normalToComponent( element.normalWorld.y );
 				_color.b = normalToComponent( element.normalWorld.z );
-				_color.updateStyleString();
+				_color.updateHex();
 
-				material.wireframe ? strokePath( _color.__styleString, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color.__styleString );
+				material.wireframe ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color );
 
 			}
 
@@ -725,7 +722,7 @@ THREE.CanvasRenderer = function () {
 
 				drawQuad( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y );
 
-				material.wireframe ? strokePath( material.color.__styleString, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color.__styleString );
+				material.wireframe ? strokePath( material.color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color );
 
 			} else if ( material instanceof THREE.MeshLambertMaterial ) {
 
@@ -760,15 +757,14 @@ THREE.CanvasRenderer = function () {
 
 						calculateLight( scene, element.centroidWorld, element.normalWorld, _light );
 
-						_color.r = material.color.r * _light.r;
-						_color.g = material.color.g * _light.g;
-						_color.b = material.color.b * _light.b;
-
-						_color.updateStyleString();
+						_color.r = Math.max( 0, Math.min( material.color.r * _light.r, 1 ) );
+						_color.g = Math.max( 0, Math.min( material.color.g * _light.g, 1 ) );
+						_color.b = Math.max( 0, Math.min( material.color.b * _light.b, 1 ) );
+						_color.updateHex();
 
 						drawQuad( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y );
 
-						material.wireframe ? strokePath( _color.__styleString, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color.__styleString );
+						material.wireframe ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color );
 
 					}
 
@@ -776,7 +772,7 @@ THREE.CanvasRenderer = function () {
 
 					drawQuad( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y );
 
-					material.wireframe ? strokePath( material.color.__styleString, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color.__styleString );
+					material.wireframe ? strokePath( material.color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( material.color );
 
 				}
 
@@ -785,11 +781,11 @@ THREE.CanvasRenderer = function () {
 				_color.r = normalToComponent( element.normalWorld.x );
 				_color.g = normalToComponent( element.normalWorld.y );
 				_color.b = normalToComponent( element.normalWorld.z );
-				_color.updateStyleString();
+				_color.updateHex();
 
 				drawQuad( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _v4x, _v4y );
 
-				material.wireframe ? strokePath( _color.__styleString, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color.__styleString );
+				material.wireframe ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) : fillPath( _color );
 
 			} else if ( material instanceof THREE.MeshDepthMaterial ) {
 
@@ -1076,24 +1072,33 @@ THREE.CanvasRenderer = function () {
 
 	}
 
-	function setStrokeStyle( value ) {
+	function setStrokeStyle( color ) {
 
-		if ( _contextStrokeStyle != value ) {
+		if ( _contextStrokeStyle != color.hex ) {
 
-			_context.strokeStyle = _contextStrokeStyle  = value;
+			_contextStrokeStyle = color.hex;
+			_context.strokeStyle = '#' + pad( _contextStrokeStyle.toString( 16 ) );
 
 		}
 
 	}
 
-	function setFillStyle( value ) {
+	function setFillStyle( color ) {
 
-		if ( _contextFillStyle != value ) {
+		if ( _contextFillStyle != color.hex ) {
 
-			_context.fillStyle = _contextFillStyle = value;
+			_contextFillStyle = color.hex;
+			_context.fillStyle = '#' + pad( _contextFillStyle.toString( 16 ) );
 
 		}
 
 	}
 
+	function pad( str ) {
+
+		while ( str.length < 6 ) str = '0' + str;
+		return str;
+
+	}
+
 };

+ 25 - 21
src/renderers/SVGRenderer.js

@@ -363,9 +363,7 @@ THREE.SVGRenderer = function () {
 
 		if ( material instanceof THREE.LineBasicMaterial ) {
 
-			_color.__styleString = material.color.__styleString;
-
-			_svgNode.setAttribute( 'style', 'fill: none; stroke: ' + _color.__styleString + '; stroke-width: ' + material.linewidth + '; stroke-opacity: ' + material.opacity + '; stroke-linecap: ' + material.linecap + '; stroke-linejoin: ' + material.linejoin );
+			_svgNode.setAttribute( 'style', 'fill: none; stroke: #' + '#' + pad( material.color.hex.toString( 16 ) ) + '; stroke-width: ' + material.linewidth + '; stroke-opacity: ' + material.opacity + '; stroke-linecap: ' + material.linecap + '; stroke-linejoin: ' + material.linejoin );
 
 			_svg.appendChild( _svgNode );
 
@@ -383,7 +381,7 @@ THREE.SVGRenderer = function () {
 
 		if ( material instanceof THREE.MeshBasicMaterial ) {
 
-			_color.__styleString = material.color.__styleString;
+			_color.hex = material.color.hex;
 
 		} else if ( material instanceof THREE.MeshLambertMaterial ) {
 
@@ -395,15 +393,15 @@ THREE.SVGRenderer = function () {
 
 				calculateFaceLight( scene, element, _light );
 
-				_color.r = material.color.r * _light.r;
-				_color.g = material.color.g * _light.g;
-				_color.b = material.color.b * _light.b;
+				_color.r = Math.max( 0, Math.min( material.color.r * _light.r, 1 ) );
+				_color.g = Math.max( 0, Math.min( material.color.g * _light.g, 1 ) );
+				_color.b = Math.max( 0, Math.min( material.color.b * _light.b, 1 ) );
 
-				_color.updateStyleString();
+				_color.updateHex();
 
 			} else {
 
-				_color.__styleString = material.color.__styleString;
+				_color.hex = material.color.hex;
 
 			}
 
@@ -420,11 +418,11 @@ THREE.SVGRenderer = function () {
 
 		if ( material.wireframe ) {
 
-			_svgNode.setAttribute( 'style', 'fill: none; stroke: ' + _color.__styleString + '; stroke-width: ' + material.wireframeLinewidth + '; stroke-opacity: ' + material.opacity + '; stroke-linecap: ' + material.wireframeLinecap + '; stroke-linejoin: ' + material.wireframeLinejoin );
+			_svgNode.setAttribute( 'style', 'fill: none; stroke: #' + pad( _color.hex.toString( 16 ) ) + '; stroke-width: ' + material.wireframeLinewidth + '; stroke-opacity: ' + material.opacity + '; stroke-linecap: ' + material.wireframeLinecap + '; stroke-linejoin: ' + material.wireframeLinejoin );
 
 		} else {
 
-			_svgNode.setAttribute( 'style', 'fill: ' + _color.__styleString + '; fill-opacity: ' + material.opacity );
+			_svgNode.setAttribute( 'style', 'fill: #' + pad( _color.hex.toString( 16 ) ) + '; fill-opacity: ' + material.opacity );
 
 		}
 
@@ -442,7 +440,7 @@ THREE.SVGRenderer = function () {
 
 		if ( material instanceof THREE.MeshBasicMaterial ) {
 
-			_color.__styleString = material.color.__styleString;
+			_color.hex = material.color.hex;
 
 		} else if ( material instanceof THREE.MeshLambertMaterial ) {
 
@@ -454,15 +452,15 @@ THREE.SVGRenderer = function () {
 
 				calculateFaceLight( scene, element, _light );
 
-				_color.r = material.color.r * _light.r;
-				_color.g = material.color.g * _light.g;
-				_color.b = material.color.b * _light.b;
+				_color.r = Math.max( 0, Math.min( material.color.r * _light.r, 1 ) );
+				_color.g = Math.max( 0, Math.min( material.color.g * _light.g, 1 ) );
+				_color.b = Math.max( 0, Math.min( material.color.b * _light.b, 1 ) );
 
-				_color.updateStyleString();
+				_color.updateHex();
 
 			} else {
 
-				_color.__styleString = material.color.__styleString;
+				_color.hex = material.color.hex;
 
 			}
 
@@ -479,11 +477,11 @@ THREE.SVGRenderer = function () {
 
 		if ( material.wireframe ) {
 
-			_svgNode.setAttribute( 'style', 'fill: none; stroke: ' + _color.__styleString + '; stroke-width: ' + material.wireframeLinewidth + '; stroke-opacity: ' + material.opacity + '; stroke-linecap: ' + material.wireframeLinecap + '; stroke-linejoin: ' + material.wireframeLinejoin );
+			_svgNode.setAttribute( 'style', 'fill: none; stroke: #' + pad( _color.hex.toString( 16 ) ) + '; stroke-width: ' + material.wireframeLinewidth + '; stroke-opacity: ' + material.opacity + '; stroke-linecap: ' + material.wireframeLinecap + '; stroke-linejoin: ' + material.wireframeLinejoin );
 
 		} else {
 
-			_svgNode.setAttribute( 'style', 'fill: ' + _color.__styleString + '; fill-opacity: ' + material.opacity );
+			_svgNode.setAttribute( 'style', 'fill: #' + pad( _color.hex.toString( 16 ) ) + '; fill-opacity: ' + material.opacity );
 
 		}
 
@@ -553,9 +551,15 @@ THREE.SVGRenderer = function () {
 
 	function normalToComponent( normal ) {
 
-		// https://gist.github.com/665829
+		var component = ( normal + 1 ) * 0.5;
+		return component < 0 ? 0 : ( component > 1 ? 1 : component );
+
+	}
+
+	function pad( str ) {
 
-		return normal < 0 ? Math.min( ( 1 + normal ) * 0.5, 0.5 ) : 0.5 + Math.min( normal * 0.5, 0.5 );
+		while ( str.length < 6 ) str = '0' + str;
+		return str;
 
 	}
 

Some files were not shown because too many files changed in this diff